From be2fb01f90f5f299dd07402a41fed7c7c7567f00 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Fri, 29 Mar 2019 14:33:40 -0400 Subject: [PATCH] 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 61eb0b2811..228a4c21f0 100644 --- a/CRM/Activity/Form/ActivityFilter.php +++ b/CRM/Activity/Form/ActivityFilter.php @@ -44,7 +44,7 @@ class CRM_Activity_Form_ActivityFilter extends CRM_Core_Form { $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 @@ class CRM_Activity_Form_ActivityFilter extends CRM_Core_Form { */ 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 13028e4736..1bbdd423f3 100644 --- a/CRM/Activity/Form/ActivityLinks.php +++ b/CRM/Activity/Form/ActivityLinks.php @@ -49,13 +49,13 @@ class CRM_Activity_Form_ActivityLinks extends CRM_Core_Form { } $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 @@ class CRM_Activity_Form_ActivityLinks extends CRM_Core_Form { } // 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 @@ class CRM_Activity_Form_ActivityLinks extends CRM_Core_Form { $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 ddf67d7630..4a2ef88b30 100644 --- a/CRM/Activity/Form/ActivityView.php +++ b/CRM/Activity/Form/ActivityView.php @@ -53,11 +53,11 @@ class CRM_Activity_Form_ActivityView extends CRM_Core_Form { } $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 @@ class CRM_Activity_Form_ActivityView extends CRM_Core_Form { } $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 @@ class CRM_Activity_Form_ActivityView extends CRM_Core_Form { * 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 d598dab992..a44b314c6c 100644 --- a/CRM/Activity/Form/Search.php +++ b/CRM/Activity/Form/Search.php @@ -198,16 +198,16 @@ class CRM_Activity_Form_Search extends CRM_Core_Form_Search { 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 7cc1176a6b..d64c173297 100644 --- a/CRM/Activity/Form/Task.php +++ b/CRM/Activity/Form/Task.php @@ -57,7 +57,7 @@ class CRM_Activity_Form_Task extends CRM_Core_Form_Task { * @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 @@ class CRM_Activity_Form_Task extends CRM_Core_Form_Task { $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 @@ class CRM_Activity_Form_Task extends CRM_Core_Form_Task { $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 @@ WHERE activity_id IN ( $IDs ) AND * @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 ef9e9f080a..f712d44924 100644 --- a/CRM/Activity/Form/Task/AddToTag.php +++ b/CRM/Activity/Form/Task/AddToTag.php @@ -71,7 +71,7 @@ class CRM_Activity_Form_Task_AddToTag extends CRM_Activity_Form_Task { } public function addRules() { - $this->addFormRule(array('CRM_Activity_Form_Task_AddToTag', 'formRule')); + $this->addFormRule(['CRM_Activity_Form_Task_AddToTag', 'formRule']); } /** @@ -81,7 +81,7 @@ class CRM_Activity_Form_Task_AddToTag extends CRM_Activity_Form_Task { * @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 @@ class CRM_Activity_Form_Task_AddToTag extends CRM_Activity_Form_Task { 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 @@ class CRM_Activity_Form_Task_AddToTag extends CRM_Activity_Form_Task { // 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 = ''; - 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 69c72417d4..b8cd458e10 100644 --- a/CRM/Activity/Form/Task/Batch.php +++ b/CRM/Activity/Form/Task/Batch.php @@ -62,7 +62,7 @@ class CRM_Activity_Form_Task_Batch extends CRM_Activity_Form_Task { 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 @@ class CRM_Activity_Form_Task_Batch extends CRM_Activity_Form_Task { 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 @@ class CRM_Activity_Form_Task_Batch extends CRM_Activity_Form_Task { $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 @@ class CRM_Activity_Form_Task_Batch extends CRM_Activity_Form_Task { // 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 @@ class CRM_Activity_Form_Task_Batch extends CRM_Activity_Form_Task { 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 6a46fba6dc..7fa2bef6ca 100644 --- a/CRM/Activity/Form/Task/Delete.php +++ b/CRM/Activity/Form/Task/Delete.php @@ -76,12 +76,12 @@ class CRM_Activity_Form_Task_Delete extends CRM_Activity_Form_Task { } 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 72ee30ed2b..90225b18a6 100644 --- a/CRM/Activity/Form/Task/FileOnCase.php +++ b/CRM/Activity/Form/Task/FileOnCase.php @@ -68,7 +68,7 @@ class CRM_Activity_Form_Task_FileOnCase extends CRM_Activity_Form_Task { * 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 @@ class CRM_Activity_Form_Task_FileOnCase extends CRM_Activity_Form_Task { $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 @@ class CRM_Activity_Form_Task_FileOnCase extends CRM_Activity_Form_Task { $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 @@ class CRM_Activity_Form_Task_FileOnCase extends CRM_Activity_Form_Task { } } 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 9eb2c5dcb0..df4e59f5a4 100644 --- a/CRM/Activity/Form/Task/PickOption.php +++ b/CRM/Activity/Form/Task/PickOption.php @@ -73,10 +73,10 @@ class CRM_Activity_Form_Task_PickOption extends CRM_Activity_Form_Task { $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 @@ class CRM_Activity_Form_Task_PickOption extends CRM_Activity_Form_Task { $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 @@ class CRM_Activity_Form_Task_PickOption extends CRM_Activity_Form_Task { * 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 @@ class CRM_Activity_Form_Task_PickOption extends CRM_Activity_Form_Task { !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 @@ class CRM_Activity_Form_Task_PickOption extends CRM_Activity_Form_Task { // 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 d6a0f40fb6..10f258837c 100644 --- a/CRM/Activity/Form/Task/PickProfile.php +++ b/CRM/Activity/Form/Task/PickProfile.php @@ -68,10 +68,10 @@ class CRM_Activity_Form_Task_PickProfile extends CRM_Activity_Form_Task { $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 @@ class CRM_Activity_Form_Task_PickProfile extends CRM_Activity_Form_Task { * 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 @@ class CRM_Activity_Form_Task_PickProfile extends CRM_Activity_Form_Task { $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 @@ class CRM_Activity_Form_Task_PickProfile extends CRM_Activity_Form_Task { } 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 @@ class CRM_Activity_Form_Task_PickProfile extends CRM_Activity_Form_Task { } $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 @@ class CRM_Activity_Form_Task_PickProfile extends CRM_Activity_Form_Task { * 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 90893d6cb5..69f822bd74 100644 --- a/CRM/Activity/Form/Task/Print.php +++ b/CRM/Activity/Form/Task/Print.php @@ -71,18 +71,18 @@ class CRM_Activity_Form_Task_Print extends CRM_Activity_Form_Task { 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 8d6c4d7456..2590ba073d 100644 --- a/CRM/Activity/Form/Task/RemoveFromTag.php +++ b/CRM/Activity/Form/Task/RemoveFromTag.php @@ -67,7 +67,7 @@ class CRM_Activity_Form_Task_RemoveFromTag extends CRM_Activity_Form_Task { } public function addRules() { - $this->addFormRule(array('CRM_Activity_Form_Task_RemoveFromTag', 'formRule')); + $this->addFormRule(['CRM_Activity_Form_Task_RemoveFromTag', 'formRule']); } /** @@ -77,7 +77,7 @@ class CRM_Activity_Form_Task_RemoveFromTag extends CRM_Activity_Form_Task { * @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 @@ class CRM_Activity_Form_Task_RemoveFromTag extends CRM_Activity_Form_Task { //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 @@ class CRM_Activity_Form_Task_RemoveFromTag extends CRM_Activity_Form_Task { // 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 = ''; - 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 7c72776a95..488842609a 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 @@ INNER JOIN civicrm_contact ct ON ( ac.contact_id = ct.id ) $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 @@ INNER JOIN civicrm_contact ct ON ( ac.contact_id = ct.id ) * 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 6d69fc759c..9edc8e66b4 100644 --- a/CRM/Activity/Import/Controller.php +++ b/CRM/Activity/Import/Controller.php @@ -54,7 +54,7 @@ class CRM_Activity_Import_Controller extends CRM_Core_Controller { // 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 f4c89e2eeb..1055aa3b13 100644 --- a/CRM/Activity/Import/Form/DataSource.php +++ b/CRM/Activity/Import/Form/DataSource.php @@ -47,7 +47,7 @@ class CRM_Activity_Import_Form_DataSource extends CRM_Import_Form_DataSource { 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 @@ class CRM_Activity_Import_Form_DataSource extends CRM_Import_Form_DataSource { * 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 8cb5204d59..6a2352d062 100644 --- a/CRM/Activity/Import/Form/Preview.php +++ b/CRM/Activity/Import/Form/Preview.php @@ -82,7 +82,7 @@ class CRM_Activity_Import_Form_Preview extends CRM_Import_Form_Preview { $this->set('downloadMismatchRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams)); } - $properties = array( + $properties = [ 'mapper', 'dataValues', 'columnCount', @@ -93,7 +93,7 @@ class CRM_Activity_Import_Form_Preview extends CRM_Import_Form_Preview { 'downloadErrorRecordsUrl', 'downloadConflictRecordsUrl', 'downloadMismatchRecordsUrl', - ); + ]; $this->setStatusUrl(); foreach ($properties as $property) { @@ -115,9 +115,9 @@ class CRM_Activity_Import_Form_Preview extends CRM_Import_Form_Preview { $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 @@ class CRM_Activity_Import_Form_Preview extends CRM_Import_Form_Preview { $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 @@ class CRM_Activity_Import_Form_Preview extends CRM_Import_Form_Preview { $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 b2e74ab00f..5e263c5edb 100644 --- a/CRM/Activity/Import/Form/Summary.php +++ b/CRM/Activity/Import/Form/Summary.php @@ -89,7 +89,7 @@ class CRM_Activity_Import_Form_Summary extends CRM_Import_Form_Summary { } $this->assign('dupeActionString', $dupeActionString); - $properties = array( + $properties = [ 'totalRowCount', 'validRowCount', 'invalidRowCount', @@ -101,7 +101,7 @@ class CRM_Activity_Import_Form_Summary extends CRM_Import_Form_Summary { '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 1ac6dd30b1..664e4a0deb 100644 --- a/CRM/Activity/Import/Parser.php +++ b/CRM/Activity/Import/Parser.php @@ -97,14 +97,14 @@ abstract class CRM_Activity_Import_Parser extends CRM_Import_Parser { $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 @@ abstract class CRM_Activity_Import_Parser extends CRM_Import_Parser { } 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 @@ abstract class CRM_Activity_Import_Parser extends CRM_Import_Parser { * (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 @@ abstract class CRM_Activity_Import_Parser extends CRM_Import_Parser { * @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 83e358c77e..fbb3c61497 100644 --- a/CRM/Activity/Import/Parser/Activity.php +++ b/CRM/Activity/Import/Parser/Activity.php @@ -78,16 +78,16 @@ class CRM_Activity_Import_Parser_Activity extends CRM_Activity_Import_Parser { $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 @@ class CRM_Activity_Import_Parser_Activity extends CRM_Activity_Import_Parser { $this->addField($name, $field['title'], $field['type'], $field['headerPattern'], $field['dataPattern']); } - $this->_newActivity = array(); + $this->_newActivity = []; $this->setActiveFields($this->_mapperKeys); @@ -258,7 +258,7 @@ class CRM_Activity_Import_Parser_Activity extends CRM_Activity_Import_Parser { $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 @@ class CRM_Activity_Import_Parser_Activity extends CRM_Activity_Import_Parser { } 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 a840524af6..f96c4c0938 100644 --- a/CRM/Activity/Page/AJAX.php +++ b/CRM/Activity/Page/AJAX.php @@ -43,7 +43,7 @@ class CRM_Activity_Page_AJAX { $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 @@ class CRM_Activity_Page_AJAX { // "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 @@ class CRM_Activity_Page_AJAX { $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 @@ class CRM_Activity_Page_AJAX { array_push($relationships, $relationship); } - $globalRelationshipsDT = array(); + $globalRelationshipsDT = []; $globalRelationshipsDT['data'] = $relationships; $globalRelationshipsDT['recordsTotal'] = count($relationships); $globalRelationshipsDT['recordsFiltered'] = count($relationships); @@ -108,7 +108,7 @@ class CRM_Activity_Page_AJAX { // 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 @@ class CRM_Activity_Page_AJAX { $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 @@ class CRM_Activity_Page_AJAX { array_push($relationships, $relationship); } - $clientRelationshipsDT = array(); + $clientRelationshipsDT = []; $clientRelationshipsDT['data'] = $relationships; $clientRelationshipsDT['recordsTotal'] = count($relationships); $clientRelationshipsDT['recordsFiltered'] = count($relationships); @@ -173,7 +173,7 @@ class CRM_Activity_Page_AJAX { // 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 @@ class CRM_Activity_Page_AJAX { } else { foreach ($value as $clientRole) { - $relClient = array(); + $relClient = []; $relClient['relation'] = 'Client'; $relClient['name'] = $clientRole['sort_name']; $relClient['phone'] = $clientRole['phone']; @@ -203,7 +203,7 @@ class CRM_Activity_Page_AJAX { $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 @@ class CRM_Activity_Page_AJAX { $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 @@ class CRM_Activity_Page_AJAX { } $params['total'] = count($relationships); - $caseRelationshipsDT = array(); + $caseRelationshipsDT = []; $caseRelationshipsDT['data'] = $relationships; $caseRelationshipsDT['recordsTotal'] = $params['total']; $caseRelationshipsDT['recordsFiltered'] = $params['total']; @@ -262,8 +262,8 @@ class CRM_Activity_Page_AJAX { } 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 @@ class CRM_Activity_Page_AJAX { */ 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 @@ class CRM_Activity_Page_AJAX { // 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 @@ class CRM_Activity_Page_AJAX { $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 @@ class CRM_Activity_Page_AJAX { $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 @@ class CRM_Activity_Page_AJAX { $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 @@ class CRM_Activity_Page_AJAX { 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 @@ class CRM_Activity_Page_AJAX { * @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 @@ class CRM_Activity_Page_AJAX { '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 @@ class CRM_Activity_Page_AJAX { // 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 @@ class CRM_Activity_Page_AJAX { } 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 @@ class CRM_Activity_Page_AJAX { 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 9e66e632dd..4415618a7e 100644 --- a/CRM/Activity/Page/Tab.php +++ b/CRM/Activity/Page/Tab.php @@ -86,12 +86,12 @@ class CRM_Activity_Page_Tab extends CRM_Core_Page { 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 @@ class CRM_Activity_Page_Tab extends CRM_Core_Page { // 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 @@ class CRM_Activity_Page_Tab extends CRM_Core_Page { '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 e6c9018ccd..d16a23d32e 100644 --- a/CRM/Activity/Page/UserDashboard.php +++ b/CRM/Activity/Page/UserDashboard.php @@ -54,7 +54,7 @@ class CRM_Activity_Page_UserDashboard extends CRM_Contact_Page_View_UserDashBoar $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 405fd50d02..befd1effda 100644 --- a/CRM/Activity/Selector/Activity.php +++ b/CRM/Activity/Selector/Activity.php @@ -214,18 +214,18 @@ class CRM_Activity_Selector_Activity extends CRM_Core_Selector_Base implements C $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 @@ class CRM_Activity_Selector_Activity extends CRM_Core_Selector_Base implements C $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 @@ class CRM_Activity_Selector_Activity extends CRM_Core_Selector_Base implements C $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 @@ class CRM_Activity_Selector_Activity extends CRM_Core_Selector_Base implements C */ 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 @@ class CRM_Activity_Selector_Activity extends CRM_Core_Selector_Base implements C * 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 @@ class CRM_Activity_Selector_Activity extends CRM_Core_Selector_Base implements C 'offset' => 0, 'rowCount' => 0, 'sort' => NULL, - ); + ]; return CRM_Activity_BAO_Activity::getActivitiesCount($params); } @@ -381,7 +381,7 @@ class CRM_Activity_Selector_Activity extends CRM_Core_Selector_Base implements C * 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 @@ class CRM_Activity_Selector_Activity extends CRM_Core_Selector_Base implements C 'offset' => $offset, 'rowCount' => $rowCount, 'sort' => $sort, - ); + ]; $config = CRM_Core_Config::singleton(); $rows = CRM_Activity_BAO_Activity::getActivities($params); @@ -403,7 +403,7 @@ class CRM_Activity_Selector_Activity extends CRM_Core_Selector_Base implements C $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 @@ class CRM_Activity_Selector_Activity extends CRM_Core_Selector_Base implements C 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 @@ class CRM_Activity_Selector_Activity extends CRM_Core_Selector_Base implements C */ 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 f6de0e43dd..f690f1bc53 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 @@ class CRM_Activity_Selector_Search extends CRM_Core_Selector_Base implements CRM // 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 @@ class CRM_Activity_Selector_Search extends CRM_Core_Selector_Base implements CRM FALSE, $this->_activityClause ); - $rows = array(); + $rows = []; $mailingIDs = CRM_Mailing_BAO_Mailing::mailingACLIDs(); $accessCiviMail = CRM_Core_Permission::check('access CiviMail'); @@ -276,7 +276,7 @@ class CRM_Activity_Selector_Search extends CRM_Core_Selector_Base implements CRM $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 @@ class CRM_Activity_Selector_Search extends CRM_Core_Selector_Base implements CRM $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 @@ class CRM_Activity_Selector_Search extends CRM_Core_Selector_Base implements CRM $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 @@ class CRM_Activity_Selector_Search extends CRM_Core_Selector_Base implements CRM */ 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 226744b997..237e9704fd 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 7fd32d2078..bcd4cc804e 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 @@ class CRM_Activity_Task extends CRM_Core_Task { * @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 @@ class CRM_Activity_Task extends CRM_Core_Task { $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 cf85181609..eae8333691 100644 --- a/CRM/Admin/Form.php +++ b/CRM/Admin/Form.php @@ -73,9 +73,9 @@ class CRM_Admin_Form extends CRM_Core_Form { $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 @@ class CRM_Admin_Form extends CRM_Core_Form { 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 @@ class CRM_Admin_Form extends CRM_Core_Form { */ 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 7c5563a831..37ce38eb8d 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 @@ class CRM_Admin_Form_CMSUser extends CRM_Core_Form { $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 e2032703fd..3e6f2a7536 100644 --- a/CRM/Admin/Form/ContactType.php +++ b/CRM/Admin/Form/ContactType.php @@ -73,7 +73,7 @@ class CRM_Admin_Form_ContactType extends CRM_Admin_Form { ); $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 @@ class CRM_Admin_Form_ContactType extends CRM_Admin_Form { */ 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 @@ class CRM_Admin_Form_ContactType extends CRM_Admin_Form { } $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 bd8dda913d..35927326e9 100644 --- a/CRM/Admin/Form/Extensions.php +++ b/CRM/Admin/Form/Extensions.php @@ -90,7 +90,7 @@ class CRM_Admin_Form_Extensions extends CRM_Admin_Form { * Set default values for the form. */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; return $defaults; } @@ -101,52 +101,52 @@ class CRM_Admin_Form_Extensions extends CRM_Admin_Form { 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 @@ class CRM_Admin_Form_Extensions extends CRM_Admin_Form { * 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 @@ class CRM_Admin_Form_Extensions extends CRM_Admin_Form { 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 @@ class CRM_Admin_Form_Extensions extends CRM_Admin_Form { } 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 d18e4baacc..9919469cba 100644 --- a/CRM/Admin/Form/Generic.php +++ b/CRM/Admin/Form/Generic.php @@ -78,22 +78,22 @@ class CRM_Admin_Form_Generic extends CRM_Core_Form { // @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 73f9aad7b2..624e03a70e 100644 --- a/CRM/Admin/Form/Job.php +++ b/CRM/Admin/Form/Job.php @@ -77,10 +77,10 @@ class CRM_Admin_Form_Job extends CRM_Admin_Form { $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 @@ class CRM_Admin_Form_Job extends CRM_Admin_Form { $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 @@ class CRM_Admin_Form_Job extends CRM_Admin_Form { // 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 @@ class CRM_Admin_Form_Job extends CRM_Admin_Form { */ 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 @@ class CRM_Admin_Form_Job extends CRM_Admin_Form { * @return array */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; if (!$this->_id) { $defaults['is_active'] = $defaults['is_default'] = 1; @@ -217,13 +217,13 @@ class CRM_Admin_Form_Job extends CRM_Admin_Form { 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 @@ class CRM_Admin_Form_Job extends CRM_Admin_Form { 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 70e767395d..0a829c6889 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 @@ class CRM_Admin_Form_LabelFormats extends CRM_Admin_Form { 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 @@ class CRM_Admin_Form_LabelFormats extends CRM_Admin_Form { $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 @@ class CRM_Admin_Form_LabelFormats extends CRM_Admin_Form { */ $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 @@ class CRM_Admin_Form_LabelFormats extends CRM_Admin_Form { $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 @@ class CRM_Admin_Form_LabelFormats extends CRM_Admin_Form { 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 @@ class CRM_Admin_Form_LabelFormats extends CRM_Admin_Form { $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 @@ class CRM_Admin_Form_LabelFormats extends CRM_Admin_Form { $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 ae691e8561..65e43aff0b 100644 --- a/CRM/Admin/Form/LocationType.php +++ b/CRM/Admin/Form/LocationType.php @@ -57,7 +57,7 @@ class CRM_Admin_Form_LocationType extends CRM_Admin_Form { $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 @@ class CRM_Admin_Form_LocationType extends CRM_Admin_Form { 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 @@ class CRM_Admin_Form_LocationType extends CRM_Admin_Form { $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 3644d9d907..b87ccd9610 100644 --- a/CRM/Admin/Form/MailSettings.php +++ b/CRM/Admin/Form/MailSettings.php @@ -66,33 +66,33 @@ class CRM_Admin_Form_MailSettings extends CRM_Admin_Form { $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 @@ class CRM_Admin_Form_MailSettings extends CRM_Admin_Form { * 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 @@ class CRM_Admin_Form_MailSettings extends CRM_Admin_Form { $formValues = $this->controller->exportValues($this->_name); //form fields. - $fields = array( + $fields = [ 'name', 'domain', 'localpart', @@ -162,14 +162,14 @@ class CRM_Admin_Form_MailSettings extends CRM_Admin_Form { '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 e600b53f78..8dc369ae95 100644 --- a/CRM/Admin/Form/Mapping.php +++ b/CRM/Admin/Form/Mapping.php @@ -60,10 +60,10 @@ class CRM_Admin_Form_Mapping extends CRM_Admin_Form { $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 2b286e5f8b..370d0cdff7 100644 --- a/CRM/Admin/Form/Navigation.php +++ b/CRM/Admin/Form/Navigation.php @@ -54,7 +54,7 @@ class CRM_Admin_Form_Navigation extends CRM_Admin_Form { } 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 @@ class CRM_Admin_Form_Navigation extends CRM_Admin_Form { $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 @@ class CRM_Admin_Form_Navigation extends CRM_Admin_Form { $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 @@ class CRM_Admin_Form_Navigation extends CRM_Admin_Form { 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 1a11de9674..8076680a6f 100644 --- a/CRM/Admin/Form/OptionGroup.php +++ b/CRM/Admin/Form/OptionGroup.php @@ -63,7 +63,7 @@ class CRM_Admin_Form_OptionGroup extends CRM_Admin_Form { $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 @@ class CRM_Admin_Form_OptionGroup extends CRM_Admin_Form { 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 @@ class CRM_Admin_Form_OptionGroup extends CRM_Admin_Form { $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 @@ class CRM_Admin_Form_OptionGroup extends CRM_Admin_Form { } $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 0dfda0f113..b380feacf5 100644 --- a/CRM/Admin/Form/Options.php +++ b/CRM/Admin/Form/Options.php @@ -85,20 +85,20 @@ class CRM_Admin_Form_Options extends CRM_Admin_Form { $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 @@ class CRM_Admin_Form_Options extends CRM_Admin_Form { $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 @@ class CRM_Admin_Form_Options extends CRM_Admin_Form { */ 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 @@ class CRM_Admin_Form_Options extends CRM_Admin_Form { $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 @@ class CRM_Admin_Form_Options extends CRM_Admin_Form { $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 @@ class CRM_Admin_Form_Options extends CRM_Admin_Form { $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 @@ class CRM_Admin_Form_Options extends CRM_Admin_Form { // 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 @@ class CRM_Admin_Form_Options extends CRM_Admin_Form { (($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 @@ class CRM_Admin_Form_Options extends CRM_Admin_Form { } // fix for CRM-3552, CRM-4575 - $showIsDefaultGroups = array( + $showIsDefaultGroups = [ 'email_greeting', 'postal_greeting', 'addressee', @@ -315,7 +315,7 @@ class CRM_Admin_Form_Options extends CRM_Admin_Form { 'communication_style', 'soft_credit_type', 'website_type', - ); + ]; if (in_array($this->_gName, $showIsDefaultGroups)) { $this->assign('showDefault', TRUE); @@ -323,19 +323,19 @@ class CRM_Admin_Form_Options extends CRM_Admin_Form { } // 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 @@ class CRM_Admin_Form_Options extends CRM_Admin_Form { $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 @@ class CRM_Admin_Form_Options extends CRM_Admin_Form { * @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 @@ class CRM_Admin_Form_Options extends CRM_Admin_Form { */ 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 @@ class CRM_Admin_Form_Options extends CRM_Admin_Form { CRM_Core_BAO_Phone::setOptionToNull(CRM_Utils_Array::value('value', $this->_defaultValues)); } - CRM_Core_Session::setStatus(ts('Selected %1 type has been deleted.', array(1 => $this->_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 @@ class CRM_Admin_Form_Options extends CRM_Admin_Form { $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 @@ class CRM_Admin_Form_Options extends CRM_Admin_Form { $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 5fc9c7e5ba..fcaac917b1 100644 --- a/CRM/Admin/Form/ParticipantStatusType.php +++ b/CRM/Admin/Form/ParticipantStatusType.php @@ -59,14 +59,14 @@ class CRM_Admin_Form_ParticipantStatusType extends CRM_Admin_Form { $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 @@ class CRM_Admin_Form_ParticipantStatusType extends CRM_Admin_Form { } $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 @@ class CRM_Admin_Form_ParticipantStatusType extends CRM_Admin_Form { $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 @@ class CRM_Admin_Form_ParticipantStatusType extends CRM_Admin_Form { '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 ecac6332ab..84fdf07e7d 100644 --- a/CRM/Admin/Form/PaymentProcessor.php +++ b/CRM/Admin/Form/PaymentProcessor.php @@ -111,56 +111,56 @@ class CRM_Admin_Form_PaymentProcessor extends CRM_Admin_Form { $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 @@ class CRM_Admin_Form_PaymentProcessor extends CRM_Admin_Form { $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 @@ class CRM_Admin_Form_PaymentProcessor extends CRM_Admin_Form { 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 @@ class CRM_Admin_Form_PaymentProcessor extends CRM_Admin_Form { $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 @@ class CRM_Admin_Form_PaymentProcessor extends CRM_Admin_Form { 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 @@ class CRM_Admin_Form_PaymentProcessor extends CRM_Admin_Form { } } - $this->addFormRule(array('CRM_Admin_Form_PaymentProcessor', 'formRule')); + $this->addFormRule(['CRM_Admin_Form_PaymentProcessor', 'formRule']); } /** @@ -258,7 +258,7 @@ class CRM_Admin_Form_PaymentProcessor extends CRM_Admin_Form { // 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 @@ class CRM_Admin_Form_PaymentProcessor extends CRM_Admin_Form { * @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 @@ class CRM_Admin_Form_PaymentProcessor extends CRM_Admin_Form { * @return array */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; if (!$this->_id) { $defaults['is_active'] = $defaults['is_default'] = 1; @@ -354,7 +354,7 @@ class CRM_Admin_Form_PaymentProcessor extends CRM_Admin_Form { $this->_id, 'accepted_credit_cards' ), TRUE); - $acceptedCards = array(); + $acceptedCards = []; if (!empty($cards)) { foreach ($cards as $card => $val) { $acceptedCards[$card] = 1; @@ -409,7 +409,7 @@ class CRM_Admin_Form_PaymentProcessor extends CRM_Admin_Form { $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 @@ class CRM_Admin_Form_PaymentProcessor extends CRM_Admin_Form { 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 @@ class CRM_Admin_Form_PaymentProcessor extends CRM_Admin_Form { */ 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 @@ class CRM_Admin_Form_PaymentProcessor extends CRM_Admin_Form { 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 @@ class CRM_Admin_Form_PaymentProcessor extends CRM_Admin_Form { '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 8627c89be7..29c2e5fde6 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 @@ class CRM_Admin_Form_PaymentProcessorType extends CRM_Admin_Form { * @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 f871064330..c075b044bb 100644 --- a/CRM/Admin/Form/PdfFormats.php +++ b/CRM/Admin/Form/PdfFormats.php @@ -56,33 +56,33 @@ class CRM_Admin_Form_PdfFormats extends CRM_Admin_Form { $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 @@ class CRM_Admin_Form_PdfFormats extends CRM_Admin_Form { $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 b7b9ca334d..3c44d84737 100644 --- a/CRM/Admin/Form/Persistent.php +++ b/CRM/Admin/Form/Persistent.php @@ -56,10 +56,10 @@ class CRM_Admin_Form_Persistent extends CRM_Core_Form { * @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 @@ class CRM_Admin_Form_Persistent extends CRM_Core_Form { 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 4585b4e926..6a6e8e2e7a 100644 --- a/CRM/Admin/Form/Preferences.php +++ b/CRM/Admin/Form/Preferences.php @@ -104,7 +104,7 @@ class CRM_Admin_Form_Preferences extends CRM_Core_Form { * @return array */ public function setDefaultValues() { - $this->_defaults = array(); + $this->_defaults = []; $this->setDefaultsForMetadataDefinedFields(); foreach ($this->_varNames as $groupName => $settings) { @@ -135,7 +135,7 @@ class CRM_Admin_Form_Preferences extends CRM_Core_Form { 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 @@ class CRM_Admin_Form_Preferences extends CRM_Core_Form { 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 @@ class CRM_Admin_Form_Preferences extends CRM_Core_Form { $this->addElement('text', $fieldName, $fieldValue['title'], - array( + [ 'maxlength' => 64, 'size' => 32, - ) + ] ); break; @@ -187,12 +187,12 @@ class CRM_Admin_Form_Preferences extends CRM_Core_Form { 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 @@ class CRM_Admin_Form_Preferences extends CRM_Core_Form { $fieldValue['title'], $newOptions, NULL, NULL, NULL, NULL, - array('  ', '  ', '
') + ['  ', '  ', '
'] ); break; @@ -218,7 +218,7 @@ class CRM_Admin_Form_Preferences extends CRM_Core_Form { 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 @@ class CRM_Admin_Form_Preferences extends CRM_Core_Form { } } - $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 @@ class CRM_Admin_Form_Preferences extends CRM_Core_Form { $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 0eb2b22faf..059b5bc6ff 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 @@ class CRM_Admin_Form_Preferences_Address extends CRM_Admin_Form_Preferences { 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 f7ce870fd4..7421754c72 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 ea13835328..7cf91d240b 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 @@ class CRM_Admin_Form_Preferences_Display extends CRM_Admin_Form_Preferences { $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 746f05dd10..95940ff6f8 100644 --- a/CRM/Admin/Form/PreferencesDate.php +++ b/CRM/Admin/Form/PreferencesDate.php @@ -69,17 +69,17 @@ class CRM_Admin_Form_PreferencesDate extends CRM_Admin_Form { } 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 @@ class CRM_Admin_Form_PreferencesDate extends CRM_Admin_Form { * 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 @@ class CRM_Admin_Form_PreferencesDate extends CRM_Admin_Form { 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 968aa79dc4..8383ed28de 100644 --- a/CRM/Admin/Form/RelationshipType.php +++ b/CRM/Admin/Form/RelationshipType.php @@ -119,18 +119,18 @@ class CRM_Admin_Form_RelationshipType extends CRM_Admin_Form { } $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 @@ class CRM_Admin_Form_RelationshipType extends CRM_Admin_Form { 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 77ee1ad450..c7c89716fd 100644 --- a/CRM/Admin/Form/ScheduleReminders.php +++ b/CRM/Admin/Form/ScheduleReminders.php @@ -89,9 +89,9 @@ class CRM_Admin_Form_ScheduleReminders extends CRM_Admin_Form { } 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 @@ class CRM_Admin_Form_ScheduleReminders extends CRM_Admin_Form { '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 @@ class CRM_Admin_Form_ScheduleReminders extends CRM_Admin_Form { // 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 @@ class CRM_Admin_Form_ScheduleReminders extends CRM_Admin_Form { $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 @@ class CRM_Admin_Form_ScheduleReminders extends CRM_Admin_Form { $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 @@ class CRM_Admin_Form_ScheduleReminders extends CRM_Admin_Form { } 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 @@ class CRM_Admin_Form_ScheduleReminders extends CRM_Admin_Form { $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 @@ class CRM_Admin_Form_ScheduleReminders extends CRM_Admin_Form { $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 @@ class CRM_Admin_Form_ScheduleReminders extends CRM_Admin_Form { } $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 @@ class CRM_Admin_Form_ScheduleReminders extends CRM_Admin_Form { $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 @@ class CRM_Admin_Form_ScheduleReminders extends CRM_Admin_Form { $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 @@ class CRM_Admin_Form_ScheduleReminders extends CRM_Admin_Form { * 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 @@ class CRM_Admin_Form_ScheduleReminders extends CRM_Admin_Form { 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 @@ class CRM_Admin_Form_ScheduleReminders extends CRM_Admin_Form { $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 @@ class CRM_Admin_Form_ScheduleReminders extends CRM_Admin_Form { * @return CRM_Core_DAO_ActionSchedule */ public function parseActionSchedule($values) { - $params = array(); + $params = []; - $keys = array( + $keys = [ 'title', 'subject', 'absolute_date', @@ -503,14 +503,14 @@ class CRM_Admin_Form_ScheduleReminders extends CRM_Admin_Form { '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 @@ class CRM_Admin_Form_ScheduleReminders extends CRM_Admin_Form { 'end_frequency_interval', 'end_action', 'end_date', - ); + ]; if (!CRM_Utils_Array::value('absolute_date', $params)) { $params['absolute_date'] = 'null'; @@ -569,8 +569,8 @@ class CRM_Admin_Form_ScheduleReminders extends CRM_Admin_Form { $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 @@ class CRM_Admin_Form_ScheduleReminders extends CRM_Admin_Form { } // 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 @@ class CRM_Admin_Form_ScheduleReminders extends CRM_Admin_Form { $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 @@ class CRM_Admin_Form_ScheduleReminders extends CRM_Admin_Form { //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 @@ class CRM_Admin_Form_ScheduleReminders extends CRM_Admin_Form { } 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 @@ class CRM_Admin_Form_ScheduleReminders extends CRM_Admin_Form { } 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 e03c04db50..6f60a4c933 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 @@ class CRM_Admin_Form_Setting extends CRM_Core_Form { */ 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 @@ class CRM_Admin_Form_Setting extends CRM_Core_Form { // 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 f04d79625d..242c93adcd 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 a497908487..f64cf081e7 100644 --- a/CRM/Admin/Form/Setting/Component.php +++ b/CRM/Admin/Form/Setting/Component.php @@ -45,17 +45,17 @@ class CRM_Admin_Form_Setting_Component extends CRM_Admin_Form_Setting { $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 @@ class CRM_Admin_Form_Setting_Component extends CRM_Admin_Form_Setting { * 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 @@ class CRM_Admin_Form_Setting_Component extends CRM_Admin_Form_Setting { * @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 9e5f740056..cd8d5976e6 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 3129ba63db..133ed57a9d 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 7ac52ec02f..44829d5504 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 @@ class CRM_Admin_Form_Setting_Localization extends CRM_Admin_Form_Setting { 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 @@ class CRM_Admin_Form_Setting_Localization extends CRM_Admin_Form_Setting { !\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 @@ class CRM_Admin_Form_Setting_Localization extends CRM_Admin_Form_Setting { $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 @@ class CRM_Admin_Form_Setting_Localization extends CRM_Admin_Form_Setting { * @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 @@ class CRM_Admin_Form_Setting_Localization extends CRM_Admin_Form_Setting { // 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 @@ class CRM_Admin_Form_Setting_Localization extends CRM_Admin_Form_Setting { 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 @@ class CRM_Admin_Form_Setting_Localization extends CRM_Admin_Form_Setting { */ 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 @@ class CRM_Admin_Form_Setting_Localization extends CRM_Admin_Form_Setting { $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 @@ class CRM_Admin_Form_Setting_Localization extends CRM_Admin_Form_Setting { * 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 @@ class CRM_Admin_Form_Setting_Localization extends CRM_Admin_Form_Setting { $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 @@ class CRM_Admin_Form_Setting_Localization extends CRM_Admin_Form_Setting { * @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 1186b4c909..bd75e95a83 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 @@ class CRM_Admin_Form_Setting_Mail extends CRM_Admin_Form_Setting { * @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 cf4c0c5041..2d71f739df 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 @@ class CRM_Admin_Form_Setting_Mapping extends CRM_Admin_Form_Setting { * 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 @@ class CRM_Admin_Form_Setting_Mapping extends CRM_Admin_Form_Setting { * 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 1da6fc363e..8b92a4b411 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 @@ class CRM_Admin_Form_Setting_Miscellaneous extends CRM_Admin_Form_Setting { 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 @@ class CRM_Admin_Form_Setting_Miscellaneous extends CRM_Admin_Form_Setting { 'recentItemsProviders', 'dedupe_default_limit', 'prevNextBackend', - )); + ]); } /** @@ -90,7 +90,7 @@ class CRM_Admin_Form_Setting_Miscellaneous extends CRM_Admin_Form_Setting { $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 @@ class CRM_Admin_Form_Setting_Miscellaneous extends CRM_Admin_Form_Setting { * 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 @@ class CRM_Admin_Form_Setting_Miscellaneous extends CRM_Admin_Form_Setting { // 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 546bfcfc9e..b83c527067 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 @@ class CRM_Admin_Form_Setting_Path extends CRM_Admin_Form_Setting { 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 8c632e2a69..95cab96824 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 @@ class CRM_Admin_Form_Setting_Search extends CRM_Admin_Form_Setting { * @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 bf1566239d..e70260e63f 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 @@ class CRM_Admin_Form_Setting_Smtp extends CRM_Admin_Form_Setting { $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 @@ class CRM_Admin_Form_Setting_Smtp extends CRM_Admin_Form_Setting { 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 @@ class CRM_Admin_Form_Setting_Smtp extends CRM_Admin_Form_Setting { $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 @@ class CRM_Admin_Form_Setting_Smtp extends CRM_Admin_Form_Setting { $mailerName = 'mail'; } - $headers = array( + $headers = [ 'From' => $from, 'To' => $to, 'Subject' => $subject, - ); + ]; $mailer = Mail::factory($mailerName, $params); @@ -173,14 +173,14 @@ class CRM_Admin_Form_Setting_Smtp extends CRM_Admin_Form_Setting { $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 @@ class CRM_Admin_Form_Setting_Smtp extends CRM_Admin_Form_Setting { */ 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 792136a8f3..7fa620428d 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 @@ class CRM_Admin_Form_Setting_UF extends CRM_Admin_Form_Setting { } 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 b16f242a1e..d1a258738c 100644 --- a/CRM/Admin/Form/Setting/UpdateConfigBackend.php +++ b/CRM/Admin/Form/Setting/UpdateConfigBackend.php @@ -44,12 +44,12 @@ class CRM_Admin_Form_Setting_UpdateConfigBackend extends CRM_Admin_Form_Setting $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 7a3e0a710b..9d6a622455 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 @@ class CRM_Admin_Form_Setting_Url extends CRM_Admin_Form_Setting { ) ); 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 81fb55fa08..b1b1cd31a4 100644 --- a/CRM/Admin/Form/SettingTrait.php +++ b/CRM/Admin/Form/SettingTrait.php @@ -235,7 +235,7 @@ trait CRM_Admin_Form_SettingTrait { $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 5f7489142a..df67f04a24 100644 --- a/CRM/Admin/Form/WordReplacements.php +++ b/CRM/Admin/Form/WordReplacements.php @@ -61,19 +61,19 @@ class CRM_Admin_Form_WordReplacements extends CRM_Core_Form { 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 @@ class CRM_Admin_Form_WordReplacements extends CRM_Core_Form { } $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 @@ class CRM_Admin_Form_WordReplacements extends CRM_Core_Form { $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 @@ class CRM_Admin_Form_WordReplacements extends CRM_Core_Form { * 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 @@ class CRM_Admin_Form_WordReplacements extends CRM_Core_Form { $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 dc1f065896..02a9485e3b 100644 --- a/CRM/Admin/Page/AJAX.php +++ b/CRM/Admin/Page/AJAX.php @@ -123,16 +123,16 @@ class CRM_Admin_Page_AJAX { 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 @@ class CRM_Admin_Page_AJAX { 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 @@ class CRM_Admin_Page_AJAX { $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 @@ class CRM_Admin_Page_AJAX { 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 @@ class CRM_Admin_Page_AJAX { } } 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 @@ class CRM_Admin_Page_AJAX { */ 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 @@ class CRM_Admin_Page_AJAX { * 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 @@ class CRM_Admin_Page_AJAX { 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 aebc45bde3..8414ec8ab3 100644 --- a/CRM/Admin/Page/APIExplorer.php +++ b/CRM/Admin/Page/APIExplorer.php @@ -70,13 +70,13 @@ class CRM_Admin_Page_APIExplorer extends CRM_Core_Page { ->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 @@ class CRM_Admin_Page_APIExplorer extends CRM_Core_Page { */ 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 @@ class CRM_Admin_Page_APIExplorer extends CRM_Core_Page { 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 @@ class CRM_Admin_Page_APIExplorer extends CRM_Core_Page { 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 @@ class CRM_Admin_Page_APIExplorer extends CRM_Core_Page { // 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 @@ class CRM_Admin_Page_APIExplorer extends CRM_Core_Page { 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 @@ class CRM_Admin_Page_APIExplorer extends CRM_Core_Page { $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 17d78e08ef..eab28f37aa 100644
--- a/CRM/Admin/Page/Admin.php
+++ b/CRM/Admin/Page/Admin.php
@@ -45,13 +45,13 @@ class CRM_Admin_Page_Admin extends CRM_Core_Page {
 
     $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 @@ class CRM_Admin_Page_Admin extends CRM_Core_Page {
         $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 d8ebfea519..ac157b423e 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 @@ class CRM_Admin_Page_CKEditorConfig extends CRM_Core_Page {
       ->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 @@ class CRM_Admin_Page_CKEditorConfig extends CRM_Core_Page {
     $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 @@ class CRM_Admin_Page_CKEditorConfig extends CRM_Core_Page {
    * @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 @@ class CRM_Admin_Page_CKEditorConfig extends CRM_Core_Page {
       $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 @@ class CRM_Admin_Page_CKEditorConfig extends CRM_Core_Page {
    * @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 @@ class CRM_Admin_Page_CKEditorConfig extends CRM_Core_Page {
    * @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 @@ class CRM_Admin_Page_CKEditorConfig extends CRM_Core_Page {
    * @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 b8355ec702..1cfc16a5ad 100644
--- a/CRM/Admin/Page/ContactType.php
+++ b/CRM/Admin/Page/ContactType.php
@@ -63,30 +63,30 @@ class CRM_Admin_Page_ContactType extends CRM_Core_Page_Basic {
    */
   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 @@ class CRM_Admin_Page_ContactType extends CRM_Core_Page_Basic {
         }
       }
       $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 600702cba0..6c6ca7804f 100644
--- a/CRM/Admin/Page/EventTemplate.php
+++ b/CRM/Admin/Page/EventTemplate.php
@@ -62,20 +62,20 @@ class CRM_Admin_Page_EventTemplate extends CRM_Core_Page_Basic {
   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 @@ class CRM_Admin_Page_EventTemplate extends CRM_Core_Page_Basic {
    */
   public function browse() {
     //get all event templates.
-    $allEventTemplates = array();
+    $allEventTemplates = [];
 
     $eventTemplate = new CRM_Event_DAO_Event();
 
@@ -120,7 +120,7 @@ class CRM_Admin_Page_EventTemplate extends CRM_Core_Page_Basic {
 
       //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 97da3d1755..9250536e5d 100644
--- a/CRM/Admin/Page/Extensions.php
+++ b/CRM/Admin/Page/Extensions.php
@@ -76,39 +76,39 @@ class CRM_Admin_Page_Extensions extends CRM_Core_Page_Basic {
    */
   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 @@ class CRM_Admin_Page_Extensions extends CRM_Core_Page_Basic {
     $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 @@ class CRM_Admin_Page_Extensions extends CRM_Core_Page_Basic {
         $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 @@ class CRM_Admin_Page_Extensions extends CRM_Core_Page_Basic {
       // 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 @@ class CRM_Admin_Page_Extensions extends CRM_Core_Page_Basic {
       $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 @@ class CRM_Admin_Page_Extensions extends CRM_Core_Page_Basic {
       $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 b0a2a8e7ec..fceb66ebb3 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 059a6b3735..c90b5eba3d 100644
--- a/CRM/Admin/Page/LabelFormats.php
+++ b/CRM/Admin/Page/LabelFormats.php
@@ -65,26 +65,26 @@ class CRM_Admin_Page_LabelFormats extends CRM_Core_Page_Basic {
   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 @@ class CRM_Admin_Page_LabelFormats extends CRM_Core_Page_Basic {
 
       $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 6ae5a62f49..16b2b25df6 100644
--- a/CRM/Admin/Page/LocationType.php
+++ b/CRM/Admin/Page/LocationType.php
@@ -63,30 +63,30 @@ class CRM_Admin_Page_LocationType extends CRM_Core_Page_Basic {
    */
   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 400288ef80..94b984a5e9 100644
--- a/CRM/Admin/Page/MailSettings.php
+++ b/CRM/Admin/Page/MailSettings.php
@@ -64,20 +64,20 @@ class CRM_Admin_Page_MailSettings extends CRM_Core_Page_Basic {
   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 @@ class CRM_Admin_Page_MailSettings extends CRM_Core_Page_Basic {
    */
   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 @@ class CRM_Admin_Page_MailSettings extends CRM_Core_Page_Basic {
 
       //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 d5b171749b..33744306f0 100644
--- a/CRM/Admin/Page/Mapping.php
+++ b/CRM/Admin/Page/Mapping.php
@@ -65,20 +65,20 @@ class CRM_Admin_Page_Mapping extends CRM_Core_Page_Basic {
     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 43a7ba6145..ab21c4da17 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 @@ class CRM_Admin_Page_MessageTemplates extends CRM_Core_Page_Basic {
    */
   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 @@ class CRM_Admin_Page_MessageTemplates extends CRM_Core_Page_Basic {
       }
 
       // 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 @@ class CRM_Admin_Page_MessageTemplates extends CRM_Core_Page_Basic {
     $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 @@ class CRM_Admin_Page_MessageTemplates extends CRM_Core_Page_Basic {
       }
     }
 
-    $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 64422224a4..7f0202c3a4 100644
--- a/CRM/Admin/Page/ParticipantStatusType.php
+++ b/CRM/Admin/Page/ParticipantStatusType.php
@@ -49,36 +49,36 @@ class CRM_Admin_Page_ParticipantStatusType extends CRM_Core_Page_Basic {
   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 @@ class CRM_Admin_Page_ParticipantStatusType extends CRM_Core_Page_Basic {
     $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 @@ class CRM_Admin_Page_ParticipantStatusType extends CRM_Core_Page_Basic {
       $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 d750e1bb54..212c60e42d 100644
--- a/CRM/Admin/Page/PaymentProcessorType.php
+++ b/CRM/Admin/Page/PaymentProcessorType.php
@@ -61,30 +61,30 @@ class CRM_Admin_Page_PaymentProcessorType extends CRM_Core_Page_Basic {
    */
   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 c99cf4ad5c..ba7b0a2e48 100644
--- a/CRM/Admin/Page/PdfFormats.php
+++ b/CRM/Admin/Page/PdfFormats.php
@@ -65,20 +65,20 @@ class CRM_Admin_Page_PdfFormats extends CRM_Core_Page_Basic {
   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 @@ class CRM_Admin_Page_PdfFormats extends CRM_Core_Page_Basic {
       $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 ed4c07561e..4524da5444 100644
--- a/CRM/Admin/Page/Persistent.php
+++ b/CRM/Admin/Page/Persistent.php
@@ -54,14 +54,14 @@ class CRM_Admin_Page_Persistent extends CRM_Core_Page {
     // 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 @@ class CRM_Admin_Page_Persistent extends CRM_Core_Page {
     // 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 @@ class CRM_Admin_Page_Persistent extends CRM_Core_Page {
 
     $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 @@ class CRM_Admin_Page_Persistent extends CRM_Core_Page {
       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 @@ class CRM_Admin_Page_Persistent extends CRM_Core_Page {
         $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 c1e93463a7..f1a65a7698 100644
--- a/CRM/Admin/Page/PreferencesDate.php
+++ b/CRM/Admin/Page/PreferencesDate.php
@@ -63,14 +63,14 @@ class CRM_Admin_Page_PreferencesDate extends CRM_Core_Page_Basic {
    */
   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 a389b71006..a93f8a70da 100644
--- a/CRM/Admin/Page/RelationshipType.php
+++ b/CRM/Admin/Page/RelationshipType.php
@@ -63,36 +63,36 @@ class CRM_Admin_Page_RelationshipType extends CRM_Core_Page_Basic {
    */
   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 eea6c62e3a..a4edd63958 100644
--- a/CRM/Admin/Page/ScheduleReminders.php
+++ b/CRM/Admin/Page/ScheduleReminders.php
@@ -64,30 +64,30 @@ class CRM_Admin_Page_ScheduleReminders extends CRM_Core_Page_Basic {
   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 @@ class CRM_Admin_Page_ScheduleReminders extends CRM_Core_Page_Basic {
         $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 e3691a34f8..7775cd4ae5 100644
--- a/CRM/Badge/BAO/Badge.php
+++ b/CRM/Badge/BAO/Badge.php
@@ -88,7 +88,7 @@ class CRM_Badge_BAO_Badge {
    *   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 @@ class CRM_Badge_BAO_Badge {
           }
         }
 
-        $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 @@ class CRM_Badge_BAO_Badge {
     }
 
     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 @@ class CRM_Badge_BAO_Badge {
       }
     }
 
-    $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 @@ class CRM_Badge_BAO_Badge {
             break;
         }
 
-        $style = array(
+        $style = [
           'position' => '',
           'align' => '',
           'stretch' => FALSE,
@@ -313,13 +313,13 @@ class CRM_Badge_BAO_Badge {
           '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 @@ class CRM_Badge_BAO_Badge {
             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 @@ class CRM_Badge_BAO_Badge {
     $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 @@ class CRM_Badge_BAO_Badge {
     $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 @@ class CRM_Badge_BAO_Badge {
     }
 
     // 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 @@ class CRM_Badge_BAO_Badge {
     $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 c73b6be587..fc60633e23 100644
--- a/CRM/Badge/BAO/Layout.php
+++ b/CRM/Badge/BAO/Layout.php
@@ -141,7 +141,7 @@ class CRM_Badge_BAO_Layout extends CRM_Core_DAO_PrintLabel {
     $printLabel = new CRM_Core_DAO_PrintLabel();
     $printLabel->find();
 
-    $labels = array();
+    $labels = [];
     while ($printLabel->fetch()) {
       $labels[$printLabel->id] = $printLabel->title;
     }
@@ -158,7 +158,7 @@ class CRM_Badge_BAO_Layout extends CRM_Core_DAO_PrintLabel {
    *   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 ec950bc0fa..a34b5ebcc4 100644
--- a/CRM/Badge/Form/Layout.php
+++ b/CRM/Badge/Form/Layout.php
@@ -49,9 +49,9 @@ class CRM_Badge_Form_Layout extends CRM_Admin_Form {
     $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 @@ class CRM_Badge_Form_Layout extends CRM_Admin_Form {
     $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 @@ class CRM_Badge_Form_Layout extends CRM_Admin_Form {
 
     $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 @@ class CRM_Badge_Form_Layout extends CRM_Admin_Form {
     $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 @@ class CRM_Badge_Form_Layout extends CRM_Admin_Form {
     $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 @@ class CRM_Badge_Form_Layout extends CRM_Admin_Form {
     }
     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 @@ class CRM_Badge_Form_Layout extends CRM_Admin_Form {
     }
 
     $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 22fb6474d0..2918f14deb 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 eb9a8e666c..da2e4ca1fa 100644
--- a/CRM/Badge/Page/Layout.php
+++ b/CRM/Badge/Page/Layout.php
@@ -61,30 +61,30 @@ class CRM_Badge_Page_Layout extends CRM_Core_Page_Basic {
    */
   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 21d61188a1..fb8dd25c32 100644
--- a/CRM/Batch/BAO/Batch.php
+++ b/CRM/Batch/BAO/Batch.php
@@ -130,7 +130,7 @@ class CRM_Batch_BAO_Batch extends CRM_Batch_DAO_Batch {
   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 @@ class CRM_Batch_BAO_Batch extends CRM_Batch_DAO_Batch {
     $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 @@ class CRM_Batch_BAO_Batch extends CRM_Batch_DAO_Batch {
     $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 @@ class CRM_Batch_BAO_Batch extends CRM_Batch_DAO_Batch {
     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 @@ class CRM_Batch_BAO_Batch extends CRM_Batch_DAO_Batch {
       "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 @@ class CRM_Batch_BAO_Batch extends CRM_Batch_DAO_Batch {
 
     $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 @@ class CRM_Batch_BAO_Batch extends CRM_Batch_DAO_Batch {
           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 @@ class CRM_Batch_BAO_Batch extends CRM_Batch_DAO_Batch {
    * @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 @@ class CRM_Batch_BAO_Batch extends CRM_Batch_DAO_Batch {
       "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 @@ class CRM_Batch_BAO_Batch extends CRM_Batch_DAO_Batch {
         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 @@ class CRM_Batch_BAO_Batch extends CRM_Batch_DAO_Batch {
    */
   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 @@ class CRM_Batch_BAO_Batch extends CRM_Batch_DAO_Batch {
       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 @@ class CRM_Batch_BAO_Batch extends CRM_Batch_DAO_Batch {
    * @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 @@ class CRM_Batch_BAO_Batch extends CRM_Batch_DAO_Batch {
     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 @@ class CRM_Batch_BAO_Batch extends CRM_Batch_DAO_Batch {
    * @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 @@ LEFT JOIN civicrm_contact contact_a ON contact_a.id = civicrm_contribution.conta
 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 @@ LEFT JOIN civicrm_contribution_soft ON civicrm_contribution_soft.contribution_id
       '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 @@ WHERE  {$where}
       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 @@ WHERE  {$where}
       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 fba50810ef..426ce28262 100644
--- a/CRM/Batch/BAO/EntityBatch.php
+++ b/CRM/Batch/BAO/EntityBatch.php
@@ -59,7 +59,7 @@ class CRM_Batch_BAO_EntityBatch extends CRM_Batch_DAO_EntityBatch {
    */
   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 c1295fe1e6..4fb2753c19 100644
--- a/CRM/Batch/Form/Batch.php
+++ b/CRM/Batch/Form/Batch.php
@@ -71,7 +71,7 @@ class CRM_Batch_Form_Batch extends CRM_Admin_Form {
    * 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 08b916d7dc..ab4475da81 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 @@ class CRM_Batch_Form_Entry extends CRM_Core_Form {
     $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 @@ class CRM_Batch_Form_Entry extends CRM_Core_Form {
     }
     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 @@ class CRM_Batch_Form_Entry extends CRM_Core_Form {
 
     $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 @@ class CRM_Batch_Form_Entry extends CRM_Core_Form {
     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 @@ class CRM_Batch_Form_Entry extends CRM_Core_Form {
       }
     }
 
-    $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 @@ class CRM_Batch_Form_Entry extends CRM_Core_Form {
       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 @@ class CRM_Batch_Form_Entry extends CRM_Core_Form {
             $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 @@ class CRM_Batch_Form_Entry extends CRM_Core_Form {
 
     $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 @@ class CRM_Batch_Form_Entry extends CRM_Core_Form {
    *   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 @@ class CRM_Batch_Form_Entry extends CRM_Core_Form {
       $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 @@ class CRM_Batch_Form_Entry extends CRM_Core_Form {
     $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 @@ class CRM_Batch_Form_Entry extends CRM_Core_Form {
     }
 
     // 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 @@ class CRM_Batch_Form_Entry extends CRM_Core_Form {
           $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 @@ class CRM_Batch_Form_Entry extends CRM_Core_Form {
         $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 @@ class CRM_Batch_Form_Entry extends CRM_Core_Form {
         $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 @@ class CRM_Batch_Form_Entry extends CRM_Core_Form {
             }
             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 @@ class CRM_Batch_Form_Entry extends CRM_Core_Form {
               $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 @@ class CRM_Batch_Form_Entry extends CRM_Core_Form {
 
     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 @@ class CRM_Batch_Form_Entry extends CRM_Core_Form {
 
         // 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 @@ class CRM_Batch_Form_Entry extends CRM_Core_Form {
           $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 @@ class CRM_Batch_Form_Entry extends CRM_Core_Form {
           $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 @@ class CRM_Batch_Form_Entry extends CRM_Core_Form {
             }
           }
 
-          $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 @@ class CRM_Batch_Form_Entry extends CRM_Core_Form {
           );
 
           // 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 @@ class CRM_Batch_Form_Entry extends CRM_Core_Form {
 
           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 @@ class CRM_Batch_Form_Entry extends CRM_Core_Form {
               $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 66ca38686b..daab61e9f8 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 @@ class CRM_Batch_Form_Search extends CRM_Core_Form {
     );
 
     $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 9dc0ad60a9..3d840a48cc 100644
--- a/CRM/Batch/Page/AJAX.php
+++ b/CRM/Batch/Page/AJAX.php
@@ -44,7 +44,7 @@ class CRM_Batch_Page_AJAX {
     $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 @@ class CRM_Batch_Page_AJAX {
   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 @@ class CRM_Batch_Page_AJAX {
     $iFilteredTotal = $iTotal = $params['total'];
 
     if ($context == 'financialBatch') {
-      $selectorElements = array(
+      $selectorElements = [
         'check',
         'batch_name',
         'payment_instrument',
@@ -111,10 +111,10 @@ class CRM_Batch_Page_AJAX {
         'status',
         'created_by',
         'links',
-      );
+      ];
     }
     else {
-      $selectorElements = array(
+      $selectorElements = [
         'batch_name',
         'type',
         'item_count',
@@ -122,7 +122,7 @@ class CRM_Batch_Page_AJAX {
         '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 e4dc66f43a..7d27c85807 100644
--- a/CRM/Bridge/OG/Drupal.php
+++ b/CRM/Bridge/OG/Drupal.php
@@ -47,7 +47,7 @@ class CRM_Bridge_OG_Drupal {
     // 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 @@ class CRM_Bridge_OG_Drupal {
       $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 @@ class CRM_Bridge_OG_Drupal {
     $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 @@ SELECT v.id
  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 @@ SELECT v.id
       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 @@ SELECT v.id
         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 931bd7e8e9..154bf83308 100644
--- a/CRM/Bridge/OG/Utils.php
+++ b/CRM/Bridge/OG/Utils.php
@@ -131,11 +131,11 @@ class CRM_Bridge_OG_Utils {
 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 77440fa746..23c75b5c79 100644
--- a/CRM/Campaign/BAO/Campaign.php
+++ b/CRM/Campaign/BAO/Campaign.php
@@ -181,14 +181,14 @@ class CRM_Campaign_BAO_Campaign extends CRM_Campaign_DAO_Campaign {
   ) {
     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 @@ class CRM_Campaign_BAO_Campaign extends CRM_Campaign_DAO_Campaign {
     }
 
     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 @@ class CRM_Campaign_BAO_Campaign extends CRM_Campaign_DAO_Campaign {
 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 @@ Order By  camp.title";
     $doCheckForPermissions = TRUE
   ) {
     $cacheKey = 0;
-    $cachekeyParams = array(
+    $cachekeyParams = [
       'includeId',
       'excludeId',
       'onlyActive',
@@ -286,7 +286,7 @@ Order By  camp.title";
       'doCheckForComponent',
       'doCheckForPermissions',
       'forceAll',
-    );
+    ];
     foreach ($cachekeyParams as $param) {
       $cacheKeyParam = $$param;
       if (!$cacheKeyParam) {
@@ -298,11 +298,11 @@ Order By  camp.title";
     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 @@ Order By  camp.title";
    *
    * @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 @@ INNER JOIN civicrm_option_group grp ON ( campaign_type.option_group_id = grp.id
     }
 
     //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 @@ INNER JOIN civicrm_option_group grp ON ( campaign_type.option_group_id = grp.id
       $whereClause = ' WHERE ' . implode(" \nAND ", $where);
     }
 
-    $properties = array(
+    $properties = [
       'id',
       'name',
       'title',
@@ -466,7 +466,7 @@ INNER JOIN civicrm_option_group grp ON ( campaign_type.option_group_id = grp.id
       'is_active',
       'description',
       'campaign_type_id',
-    );
+    ];
 
     $selectClause = '
 SELECT  campaign.id               as id,
@@ -519,11 +519,11 @@ SELECT  campaign.id               as id,
   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 @@ INNER JOIN  civicrm_group grp ON ( grp.id = campgrp.entity_id )
        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 @@ INNER JOIN  civicrm_group grp ON ( grp.id = campgrp.entity_id )
     }
 
     $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 @@ INNER JOIN  civicrm_group grp ON ( grp.id = campgrp.entity_id )
     }
 
     //carry this info to templates.
-    $infoFields = array(
+    $infoFields = [
       'showAddCampaign',
       'hasAccessCampaign',
       'isCampaignEnabled',
-    );
+    ];
     foreach ($infoFields as $fld) {
       $campaignInfo[$fld] = $$fld;
     }
@@ -629,9 +629,9 @@ INNER JOIN  civicrm_group grp ON ( grp.id = campgrp.entity_id )
    * @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 @@ INNER JOIN  civicrm_group grp ON ( grp.id = campgrp.entity_id )
       //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 19844003bd..82573024e6 100644
--- a/CRM/Campaign/BAO/Petition.php
+++ b/CRM/Campaign/BAO/Petition.php
@@ -48,16 +48,16 @@ class CRM_Campaign_BAO_Petition extends CRM_Campaign_BAO_Survey {
    *
    * @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 @@ INNER JOIN civicrm_option_group grp ON ( activity_type.option_group_id = grp.id
     }
 
     //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 @@ SELECT  petition.id                         as id,
       return (int) CRM_Core_DAO::singleValueQuery($query, $queryParams);
     }
 
-    $petitions = array();
-    $properties = array(
+    $petitions = [];
+    $properties = [
       'id',
       'title',
       'campaign_id',
@@ -141,7 +141,7 @@ SELECT  petition.id                         as id,
       'is_default',
       'result_id',
       'activity_type_id',
-    );
+    ];
 
     $petition = CRM_Core_DAO::executeQuery($query, $queryParams);
     while ($petition->fetch()) {
@@ -159,11 +159,11 @@ SELECT  petition.id                         as id,
    */
   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 @@ SELECT  petition.id                         as id,
       // 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 @@ SELECT  petition.id                         as id,
         '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 @@ SELECT  petition.id                         as 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 @@ DELETE FROM civicrm_entity_tag
 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 @@ AND         tag_id = ( SELECT id FROM civicrm_tag WHERE name = %2 )";
    * @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 @@ AND         tag_id = ( SELECT id FROM civicrm_tag WHERE name = %2 )";
 
     $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 @@ AND         tag_id = ( SELECT id FROM civicrm_tag WHERE name = %2 )";
             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 @@ AND         tag_id = ( SELECT id FROM civicrm_tag WHERE name = %2 )";
    * @return array
    */
   public static function getSurveyInfo($surveyId = NULL) {
-    $surveyInfo = array();
+    $surveyInfo = [];
 
     $sql = "
             SELECT  activity_type_id,
@@ -399,7 +399,7 @@ AND         tag_id = ( SELECT id FROM civicrm_tag WHERE name = %2 )";
 
     // sql injection protection
     $surveyId = (int) $surveyId;
-    $signature = array();
+    $signature = [];
 
     $sql = "
             SELECT  a.id,
@@ -424,19 +424,19 @@ AND         tag_id = ( SELECT id FROM civicrm_tag WHERE name = %2 )";
             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 @@ AND         tag_id = ( SELECT id FROM civicrm_tag WHERE name = %2 )";
       '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 @@ AND         tag_id = ( SELECT id FROM civicrm_tag WHERE name = %2 )";
    *   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 @@ AND         tag_id = ( SELECT id FROM civicrm_tag WHERE name = %2 )";
   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 @@ AND         tag_id = ( SELECT id FROM civicrm_tag WHERE name = %2 )";
             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 @@ AND         tag_id = ( SELECT id FROM civicrm_tag WHERE name = %2 )";
 
     // 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 @@ AND         tag_id = ( SELECT id FROM civicrm_tag WHERE name = %2 )";
 
         // 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 @@ AND         tag_id = ( SELECT id FROM civicrm_tag WHERE name = %2 )";
               'replyTo' => $replyTo,
               'petitionId' => $params['sid'],
               'petitionTitle' => $petitionInfo['title'],
-            )
+            ]
           );
         }
         break;
@@ -635,12 +635,12 @@ AND         tag_id = ( SELECT id FROM civicrm_tag WHERE name = %2 )";
         $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 @@ AND         tag_id = ( SELECT id FROM civicrm_tag WHERE name = %2 )";
 
         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 @@ AND         tag_id = ( SELECT id FROM civicrm_tag WHERE name = %2 )";
               'petitionId' => $params['sid'],
               'petitionTitle' => $petitionInfo['title'],
               'confirmUrl' => $confirmUrl,
-            )
+            ]
           );
         }
         break;
diff --git a/CRM/Campaign/BAO/Query.php b/CRM/Campaign/BAO/Query.php
index 5138915ae5..4f2f0e09a7 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 @@ class CRM_Campaign_BAO_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 @@ class CRM_Campaign_BAO_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 @@ class CRM_Campaign_BAO_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 @@ civicrm_activity_assignment.record_type_id = $assigneeID ) ";
   ) {
     $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 @@ civicrm_activity_assignment.record_type_id = $assigneeID ) ";
         'campaign_id' => 1,
         'survey_interviewer_id' => 1,
         'survey_activity_target_contact_id' => 1,
-      );
+      ];
     }
 
     return $properties;
@@ -355,11 +355,11 @@ civicrm_activity_assignment.record_type_id = $assigneeID ) ";
     $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 @@ civicrm_activity_assignment.record_type_id = $assigneeID ) ";
       $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 @@ civicrm_activity_assignment.record_type_id = $assigneeID ) ";
         $userId = $session->get('userID');
       }
       if ($userId) {
-        $defaults = array();
+        $defaults = [];
         $defaults['survey_interviewer_id'] = $userId;
         $form->setDefaults($defaults);
       }
@@ -395,13 +395,13 @@ civicrm_activity_assignment.record_type_id = $assigneeID ) ";
       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 @@ INNER JOIN  civicrm_custom_group grp on fld.custom_group_id = grp.id
       ($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 @@ INNER JOIN  civicrm_custom_group grp on fld.custom_group_id = grp.id
     //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 @@ INNER JOIN  civicrm_custom_group grp on fld.custom_group_id = grp.id
    * @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 @@ INNER JOIN  civicrm_custom_group grp on fld.custom_group_id = grp.id
 
     //get the survey activities.
     $activityStatus = CRM_Core_PseudoConstant::activityStatus('name');
-    $status = array('Scheduled');
+    $status = ['Scheduled'];
     if ($searchVoterFor == 'reserve') {
       $status[] = 'Completed';
     }
@@ -494,7 +494,7 @@ INNER JOIN  civicrm_custom_group grp on fld.custom_group_id = grp.id
           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 @@ INNER JOIN  civicrm_custom_group grp on fld.custom_group_id = grp.id
         }
       }
     }
-    $voterClause = array(
+    $voterClause = [
       'fromClause' => $fromClause,
       'whereClause' => $whereClause,
-    );
+    ];
 
     return $voterClause;
   }
diff --git a/CRM/Campaign/BAO/Survey.php b/CRM/Campaign/BAO/Survey.php
index 58c45b25e2..7ec3ca0e4a 100644
--- a/CRM/Campaign/BAO/Survey.php
+++ b/CRM/Campaign/BAO/Survey.php
@@ -121,16 +121,16 @@ class CRM_Campaign_BAO_Survey extends CRM_Campaign_DAO_Survey {
    *
    * @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 @@ INNER JOIN civicrm_option_group grp ON ( activity_type.option_group_id = grp.id
     }
 
     //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 @@ SELECT  survey.id                         as id,
       return (int) CRM_Core_DAO::singleValueQuery($query, $queryParams);
     }
 
-    $surveys = array();
-    $properties = array(
+    $surveys = [];
+    $properties = [
       'id',
       'title',
       'campaign_id',
@@ -228,7 +228,7 @@ SELECT  survey.id                         as id,
       'release_frequency',
       'max_number_of_contacts',
       'default_number_of_contacts',
-    );
+    ];
 
     $survey = CRM_Core_DAO::executeQuery($query, $queryParams);
     while ($survey->fetch()) {
@@ -263,7 +263,7 @@ SELECT  survey.id                         as id,
    */
   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 @@ SELECT  survey.id                         as id,
         //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 @@ SELECT  survey.id    as id,
         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 @@ SELECT  survey.id    as id,
     $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 @@ SELECT  survey.id    as id,
    *
    * @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 @@ SELECT  survey.id    as 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 @@ SELECT  survey.id    as id,
       $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 @@ SELECT  survey.id    as id,
    * @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 @@ SELECT  survey.id    as id,
     $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 @@ INNER JOIN  civicrm_activity_contact activityAssignment
      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 @@ INNER JOIN  civicrm_activity_contact activityAssignment
     $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 @@ INNER JOIN  civicrm_contact contact_a ON ( activityTarget.contact_id = contact_a
        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 @@ INNER JOIN  civicrm_contact contact_a ON ( activityTarget.contact_id = contact_a
     $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 @@ INNER JOIN  civicrm_contact contact_a ON ( activityTarget.contact_id = contact_a
         'interviewer_id' => $activity->interviewer_id,
         'result' => $activity->result,
         'activity_date_time' => $activity->activity_date_time,
-      );
+      ];
     }
 
     return $activities;
@@ -690,8 +690,8 @@ INNER JOIN  civicrm_contact contact_a ON ( activityTarget.contact_id = contact_a
    * @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 @@ INNER JOIN  civicrm_contact contact_a ON ( activityTarget.contact_id = contact_a
       $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 @@ INNER JOIN  civicrm_contact contact_a ON ( activityTarget.contact_id = contact_a
    *   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 @@ INNER JOIN  civicrm_contact contact_a ON ( activityTarget.contact_id = contact_a
    *   an array of option values
    */
   public static function getResponsesOptions($surveyId) {
-    $responseOptions = array();
+    $responseOptions = [];
     if (!$surveyId) {
       return $responseOptions;
     }
@@ -796,12 +796,12 @@ INNER JOIN  civicrm_contact contact_a ON ( activityTarget.contact_id = contact_a
    *   $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 @@ INNER JOIN  civicrm_contact contact_a ON ( activityTarget.contact_id = contact_a
       }
 
       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 @@ INNER JOIN  civicrm_contact contact_a ON ( activityTarget.contact_id = contact_a
       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 @@ INNER JOIN  civicrm_contact contact_a ON ( activityTarget.contact_id = contact_a
    * @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 @@ INNER JOIN  civicrm_contact contact_a ON ( activityTarget.contact_id = contact_a
     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 @@ INNER JOIN  civicrm_contact contact_a ON ( activityTarget.contact_id = contact_a
    */
   public static function getSurveyResponseFields($surveyId, $surveyTypeId = NULL) {
     if (empty($surveyId)) {
-      return array();
+      return [];
     }
 
     static $responseFields;
@@ -984,7 +984,7 @@ INNER JOIN  civicrm_contact contact_a ON ( activityTarget.contact_id = contact_a
       return $responseFields[$cacheKey];
     }
 
-    $responseFields[$cacheKey] = array();
+    $responseFields[$cacheKey] = [];
 
     $profileId = self::getSurveyProfileId($surveyId);
 
@@ -1001,7 +1001,7 @@ INNER JOIN  civicrm_contact contact_a ON ( activityTarget.contact_id = contact_a
     );
 
     //don't load these fields in grid.
-    $removeFields = array('File', 'RichTextEditor');
+    $removeFields = ['File', 'RichTextEditor'];
 
     $supportableFieldTypes = self::surveyProfileTypes();
 
@@ -1053,7 +1053,7 @@ INNER JOIN  civicrm_contact contact_a ON ( activityTarget.contact_id = contact_a
       $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 @@ INNER JOIN  civicrm_survey survey ON ( survey.id = activity.source_record_id )
      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 @@ UPDATE  civicrm_activity
       }
     }
 
-    $rtnMsg = array(
+    $rtnMsg = [
       'is_error' => 0,
       'messages' => "Number of respondents released = {$releasedCount}",
-    );
+    ];
 
     return $rtnMsg;
   }
@@ -1146,14 +1146,14 @@ UPDATE  civicrm_activity
    *
    * @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 865ad02b0f..91536ec81d 100644
--- a/CRM/Campaign/Form/Campaign.php
+++ b/CRM/Campaign/Form/Campaign.php
@@ -101,11 +101,11 @@ class CRM_Campaign_Form_Campaign extends CRM_Core_Form {
     //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 @@ class CRM_Campaign_Form_Campaign extends CRM_Core_Form {
 
     $dao = new CRM_Campaign_DAO_CampaignGroup();
 
-    $campaignGroups = array();
+    $campaignGroups = [];
     $dao->campaign_id = $this->_campaignId;
     $dao->find();
 
@@ -167,17 +167,17 @@ class CRM_Campaign_Form_Campaign extends CRM_Core_Form {
   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 @@ class CRM_Campaign_Form_Campaign extends CRM_Core_Form {
     $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 @@ class CRM_Campaign_Form_Campaign extends CRM_Core_Form {
     $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 @@ class CRM_Campaign_Form_Campaign extends CRM_Core_Form {
       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 @@ class CRM_Campaign_Form_Campaign extends CRM_Core_Form {
    * @see valid_date
    */
   public static function formRule($fields, $files, $errors) {
-    $errors = array();
+    $errors = [];
 
     return empty($errors) ? TRUE : $errors;
   }
@@ -292,7 +292,7 @@ class CRM_Campaign_Form_Campaign extends CRM_Core_Form {
     $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 @@ class CRM_Campaign_Form_Campaign extends CRM_Core_Form {
     $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 7f017da8f3..d260b93262 100644
--- a/CRM/Campaign/Form/Gotv.php
+++ b/CRM/Campaign/Form/Gotv.php
@@ -84,7 +84,7 @@ class CRM_Campaign_Form_Gotv extends CRM_Core_Form {
     //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 @@ class CRM_Campaign_Form_Gotv extends CRM_Core_Form {
     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 @@ class CRM_Campaign_Form_Gotv extends CRM_Core_Form {
     $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 @@ class CRM_Campaign_Form_Gotv extends CRM_Core_Form {
   }
 
   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 @@ class CRM_Campaign_Form_Gotv extends CRM_Core_Form {
 
     $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 e1e005eda0..30e9349ff4 100644
--- a/CRM/Campaign/Form/Petition.php
+++ b/CRM/Campaign/Form/Petition.php
@@ -90,9 +90,9 @@ class CRM_Campaign_Form_Petition extends CRM_Core_Form {
     $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 @@ class CRM_Campaign_Form_Petition extends CRM_Core_Form {
     $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 @@ class CRM_Campaign_Form_Petition extends CRM_Core_Form {
   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 @@ class CRM_Campaign_Form_Petition extends CRM_Core_Form {
 
     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 @@ class CRM_Campaign_Form_Petition extends CRM_Core_Form {
       '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 @@ class CRM_Campaign_Form_Petition extends CRM_Core_Form {
 
     // 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 @@ class CRM_Campaign_Form_Petition extends CRM_Core_Form {
    * @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 @@ class CRM_Campaign_Form_Petition extends CRM_Core_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 @@ WHERE  $whereClause
     $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 74fa32114f..c973bfdc55 100644
--- a/CRM/Campaign/Form/Petition/Signature.php
+++ b/CRM/Campaign/Form/Petition/Signature.php
@@ -181,7 +181,7 @@ class CRM_Campaign_Form_Petition_Signature extends CRM_Core_Form {
     }
     //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 @@ class CRM_Campaign_Form_Petition_Signature extends CRM_Core_Form {
 
     // 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 @@ class CRM_Campaign_Form_Petition_Signature extends CRM_Core_Form {
    * 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 @@ class CRM_Campaign_Form_Petition_Signature extends CRM_Core_Form {
       $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 @@ class CRM_Campaign_Form_Petition_Signature extends CRM_Core_Form {
    * @return array|bool
    */
   public static function formRule($fields, $files, $errors) {
-    $errors = array();
+    $errors = [];
 
     return empty($errors) ? TRUE : $errors;
   }
@@ -371,11 +371,11 @@ class CRM_Campaign_Form_Petition_Signature extends CRM_Core_Form {
       $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 f28c272a9a..331cadd605 100644
--- a/CRM/Campaign/Form/Search/Campaign.php
+++ b/CRM/Campaign/Form/Search/Campaign.php
@@ -79,17 +79,17 @@ class CRM_Campaign_Form_Search_Campaign extends CRM_Core_Form {
     $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 @@ class CRM_Campaign_Form_Search_Campaign extends CRM_Core_Form {
     //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 a43174ab15..d23e9e8829 100644
--- a/CRM/Campaign/Form/Search/Petition.php
+++ b/CRM/Campaign/Form/Search/Petition.php
@@ -76,12 +76,12 @@ class CRM_Campaign_Form_Search_Petition extends CRM_Core_Form {
 
     //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 ee5682caa4..3cf35bf2ee 100644
--- a/CRM/Campaign/Form/Search/Survey.php
+++ b/CRM/Campaign/Form/Search/Survey.php
@@ -78,21 +78,21 @@ class CRM_Campaign_Form_Search_Survey extends CRM_Core_Form {
     //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 981514751a..05eec10cee 100644
--- a/CRM/Campaign/Form/Survey.php
+++ b/CRM/Campaign/Form/Survey.php
@@ -84,11 +84,11 @@ class CRM_Campaign_Form_Survey extends CRM_Core_Form {
     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 @@ class CRM_Campaign_Form_Survey extends CRM_Core_Form {
     // 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 @@ class CRM_Campaign_Form_Survey extends CRM_Core_Form {
   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 @@ class CRM_Campaign_Form_Survey extends CRM_Core_Form {
         $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 e7df3edb41..8d32335eb8 100644
--- a/CRM/Campaign/Form/Survey/Delete.php
+++ b/CRM/Campaign/Form/Survey/Delete.php
@@ -60,7 +60,7 @@ class CRM_Campaign_Form_Survey_Delete extends CRM_Core_Form {
     }
 
     $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 @@ class CRM_Campaign_Form_Survey_Delete extends CRM_Core_Form {
    * 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 @@ class CRM_Campaign_Form_Survey_Delete extends CRM_Core_Form {
   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 901981ab07..24aae308b4 100644
--- a/CRM/Campaign/Form/Survey/Main.php
+++ b/CRM/Campaign/Form/Survey/Main.php
@@ -68,14 +68,14 @@ class CRM_Campaign_Form_Survey_Main extends CRM_Campaign_Form_Survey {
 
     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 @@ class CRM_Campaign_Form_Survey_Main extends CRM_Campaign_Form_Survey {
     $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 @@ class CRM_Campaign_Form_Survey_Main extends CRM_Campaign_Form_Survey {
     ]);
 
     // 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 @@ class CRM_Campaign_Form_Survey_Main extends CRM_Campaign_Form_Survey {
     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 1b83d14897..b0cfd2ddba 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 @@ class CRM_Campaign_Form_Survey_Questions extends CRM_Campaign_Form_Survey {
       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 @@ class CRM_Campaign_Form_Survey_Questions extends CRM_Campaign_Form_Survey {
     $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 4dd86299f7..5c2946ac8e 100644
--- a/CRM/Campaign/Form/Survey/Results.php
+++ b/CRM/Campaign/Form/Survey/Results.php
@@ -53,16 +53,16 @@ class CRM_Campaign_Form_Survey_Results extends CRM_Campaign_Form_Survey {
 
     $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 @@ class CRM_Campaign_Form_Survey_Results extends CRM_Campaign_Form_Survey {
     $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 @@ class CRM_Campaign_Form_Survey_Results extends CRM_Campaign_Form_Survey { $this->freeze('report_title'); } - $this->addFormRule(array( + $this->addFormRule([ 'CRM_Campaign_Form_Survey_Results', 'formRule', - ), $this); + ], $this); parent::buildQuickForm(); } @@ -208,7 +208,7 @@ class CRM_Campaign_Form_Survey_Results extends CRM_Campaign_Form_Survey { * @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 @@ class CRM_Campaign_Form_Survey_Results extends CRM_Campaign_Form_Survey { $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 @@ class CRM_Campaign_Form_Survey_Results extends CRM_Campaign_Form_Survey { 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 @@ class CRM_Campaign_Form_Survey_Results extends CRM_Campaign_Form_Survey { '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 @@ class CRM_Campaign_Form_Survey_Results extends CRM_Campaign_Form_Survey { 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 c55ccbd916..3aecece43a 100644 --- a/CRM/Campaign/Form/Survey/TabHeader.php +++ b/CRM/Campaign/Form/Survey/TabHeader.php @@ -52,11 +52,11 @@ class CRM_Campaign_Form_Survey_TabHeader { $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 @@ class CRM_Campaign_Form_Survey_TabHeader { 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 4e5b91fe16..f7a38ad6c0 100644 --- a/CRM/Campaign/Form/SurveyType.php +++ b/CRM/Campaign/Form/SurveyType.php @@ -98,7 +98,7 @@ class CRM_Campaign_Form_SurveyType extends CRM_Admin_Form { $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 @@ class CRM_Campaign_Form_SurveyType extends CRM_Admin_Form { 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 @@ class CRM_Campaign_Form_SurveyType extends CRM_Admin_Form { 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 @@ class CRM_Campaign_Form_SurveyType extends CRM_Admin_Form { } } 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 @@ class CRM_Campaign_Form_SurveyType extends CRM_Admin_Form { $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 fb721b5e09..86b7a269b9 100644 --- a/CRM/Campaign/Form/Task.php +++ b/CRM/Campaign/Form/Task.php @@ -54,7 +54,7 @@ class CRM_Campaign_Form_Task extends CRM_Core_Form_Task { $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 @@ class CRM_Campaign_Form_Task extends CRM_Core_Form_Task { * @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 82fdf3b6d3..30bc84499d 100644 --- a/CRM/Campaign/Form/Task/Interview.php +++ b/CRM/Campaign/Form/Task/Interview.php @@ -74,11 +74,11 @@ class CRM_Campaign_Form_Task_Interview extends CRM_Campaign_Form_Task { $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 @@ class CRM_Campaign_Form_Task_Interview extends CRM_Campaign_Form_Task { } if ($this->_surveyId) { - $params = array('id' => $this->_surveyId); + $params = ['id' => $this->_surveyId]; CRM_Campaign_BAO_Survey::retrieve($params, $this->_surveyDetails); } @@ -106,27 +106,27 @@ class CRM_Campaign_Form_Task_Interview extends CRM_Campaign_Form_Task { } 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 @@ LEFT JOIN civicrm_address ON contact_a.id = civicrm_address.contact_id 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 @@ WHERE {$clause} } //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 @@ WHERE {$clause} ); $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 @@ WHERE {$clause} //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 @@ WHERE {$clause} //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 @@ WHERE {$clause} //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 @@ WHERE {$clause} $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 @@ WHERE {$clause} //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 @@ WHERE {$clause} 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 @@ WHERE {$clause} 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 @@ WHERE {$clause} $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 @@ WHERE {$clause} */ 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 @@ WHERE {$clause} $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 @@ WHERE {$clause} } 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 @@ WHERE {$clause} 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 @@ WHERE {$clause} $subject .= ts('Respondent Interview'); $activity->subject = $subject; - $activityParams = array( + $activityParams = [ 'details' => 'details', 'result' => 'result', 'engagement_level' => 'activity_engagement_level', @@ -548,7 +548,7 @@ WHERE {$clause} '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 @@ WHERE {$clause} $this->_interviewerId, $statusIds ); - $this->_contactIds = array(); + $this->_contactIds = []; foreach ($surveyActivities as $val) { $this->_contactIds[$val['voter_id']] = $val['voter_id']; } @@ -635,7 +635,7 @@ WHERE {$clause} 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 6ac3b52f01..e6fea042b5 100644 --- a/CRM/Campaign/Form/Task/Print.php +++ b/CRM/Campaign/Form/Task/Print.php @@ -81,18 +81,18 @@ class CRM_Campaign_Form_Task_Print extends CRM_Campaign_Form_Task { // // 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 d8b34a1a55..c45a8d5369 100644 --- a/CRM/Campaign/Form/Task/Release.php +++ b/CRM/Campaign/Form/Task/Release.php @@ -66,11 +66,11 @@ class CRM_Campaign_Form_Task_Release extends CRM_Campaign_Form_Task { $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 @@ class CRM_Campaign_Form_Task_Release extends CRM_Campaign_Form_Task { 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 @@ class CRM_Campaign_Form_Task_Release extends CRM_Campaign_Form_Task { //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 @@ class CRM_Campaign_Form_Task_Release extends CRM_Campaign_Form_Task { } 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 @@ class CRM_Campaign_Form_Task_Release extends CRM_Campaign_Form_Task { 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 0d95e2b21a..639156c164 100644 --- a/CRM/Campaign/Form/Task/Reserve.php +++ b/CRM/Campaign/Form/Task/Reserve.php @@ -82,13 +82,13 @@ class CRM_Campaign_Form_Task_Reserve extends CRM_Campaign_Form_Task { 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 @@ class CRM_Campaign_Form_Task_Reserve extends CRM_Campaign_Form_Task { //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 @@ class CRM_Campaign_Form_Task_Reserve extends CRM_Campaign_Form_Task { } 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 @@ class CRM_Campaign_Form_Task_Reserve extends CRM_Campaign_Form_Task { $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 @@ class CRM_Campaign_Form_Task_Reserve extends CRM_Campaign_Form_Task { 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 @@ class CRM_Campaign_Form_Task_Reserve extends CRM_Campaign_Form_Task { * 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 @@ class CRM_Campaign_Form_Task_Reserve extends CRM_Campaign_Form_Task { $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 @@ class CRM_Campaign_Form_Task_Reserve extends CRM_Campaign_Form_Task { '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 @@ class CRM_Campaign_Form_Task_Reserve extends CRM_Campaign_Form_Task { // 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 @@ class CRM_Campaign_Form_Task_Reserve extends CRM_Campaign_Form_Task { // 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 @@ class CRM_Campaign_Form_Task_Reserve extends CRM_Campaign_Form_Task { * @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 65543a1aec..88185e5859 100644 --- a/CRM/Campaign/Form/Task/Result.php +++ b/CRM/Campaign/Form/Task/Result.php @@ -46,13 +46,13 @@ class CRM_Campaign_Form_Task_Result extends CRM_Campaign_Form_Task { * 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 6cd4a7953e..07b5373ff3 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 @@ class CRM_Campaign_Info extends CRM_Core_Component_Info { * @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 @@ class CRM_Campaign_Info extends CRM_Core_Component_Info { 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 ccb04eeed6..a784ef99af 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 @@ class CRM_Campaign_Page_AJAX { '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 @@ class CRM_Campaign_Page_AJAX { } } - $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 @@ class CRM_Campaign_Page_AJAX { $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 @@ class CRM_Campaign_Page_AJAX { $status = 'success'; } - $result = array( + $result = [ 'status' => $status, 'result' => $opValues, - ); + ]; CRM_Utils_JSON::output($result); } @@ -149,7 +149,7 @@ class CRM_Campaign_Page_AJAX { $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 @@ class CRM_Campaign_Page_AJAX { } //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 @@ class CRM_Campaign_Page_AJAX { } } - $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 @@ class CRM_Campaign_Page_AJAX { } } - $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 @@ class CRM_Campaign_Page_AJAX { $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 @@ class CRM_Campaign_Page_AJAX { $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 @@ class CRM_Campaign_Page_AJAX { } } - $selectorElements = array_merge($selectorCols, array($extraVoterColName)); + $selectorElements = array_merge($selectorCols, [$extraVoterColName]); $iFilteredTotal = $iTotal; @@ -400,13 +400,13 @@ class CRM_Campaign_Page_AJAX { } } 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 @@ class CRM_Campaign_Page_AJAX { $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 @@ class CRM_Campaign_Page_AJAX { } 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 @@ class CRM_Campaign_Page_AJAX { } } - 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 @@ class CRM_Campaign_Page_AJAX { 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 @@ class CRM_Campaign_Page_AJAX { $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 @@ class CRM_Campaign_Page_AJAX { } //this is sequence columns on datatable. - $selectorCols = array( + $selectorCols = [ 'id', 'name', 'title', @@ -562,36 +562,36 @@ class CRM_Campaign_Page_AJAX { '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 @@ class CRM_Campaign_Page_AJAX { } } } - foreach (array( + foreach ([ 'sort', 'offset', 'rowCount', 'sortOrder', - ) as $sortParam) { + ] as $sortParam) { $params[$sortParam] = $$sortParam; } @@ -643,7 +643,7 @@ class CRM_Campaign_Page_AJAX { $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 @@ class CRM_Campaign_Page_AJAX { } //this is sequence columns on datatable. - $selectorCols = array( + $selectorCols = [ 'id', 'title', 'campaign_id', @@ -667,36 +667,36 @@ class CRM_Campaign_Page_AJAX { '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 @@ class CRM_Campaign_Page_AJAX { } } } - foreach (array( + foreach ([ 'sort', 'offset', 'rowCount', 'sortOrder', - ) as $sortParam) { + ] as $sortParam) { $params[$sortParam] = $$sortParam; } @@ -748,7 +748,7 @@ class CRM_Campaign_Page_AJAX { $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 @@ class CRM_Campaign_Page_AJAX { } //this is sequence columns on datatable. - $selectorCols = array( + $selectorCols = [ 'id', 'title', 'campaign_id', @@ -767,36 +767,36 @@ class CRM_Campaign_Page_AJAX { '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 @@ class CRM_Campaign_Page_AJAX { } } } - 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 bccf6cfcb5..08ac5a08e2 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 @@ class CRM_Campaign_Page_DashBoard extends CRM_Core_Page { 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 @@ class CRM_Campaign_Page_DashBoard extends CRM_Core_Page { 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 @@ class CRM_Campaign_Page_DashBoard extends CRM_Core_Page { * * @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 @@ class CRM_Campaign_Page_DashBoard extends CRM_Core_Page { $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 @@ class CRM_Campaign_Page_DashBoard extends CRM_Core_Page { '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 @@ class CRM_Campaign_Page_DashBoard extends CRM_Core_Page { } $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 @@ class CRM_Campaign_Page_DashBoard extends CRM_Core_Page { * * @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 @@ class CRM_Campaign_Page_DashBoard extends CRM_Core_Page { $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 @@ class CRM_Campaign_Page_DashBoard extends CRM_Core_Page { } $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 @@ class CRM_Campaign_Page_DashBoard extends CRM_Core_Page { * * @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 @@ class CRM_Campaign_Page_DashBoard extends CRM_Core_Page { $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 @@ class CRM_Campaign_Page_DashBoard extends CRM_Core_Page { } 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 @@ class CRM_Campaign_Page_DashBoard extends CRM_Core_Page { } 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 @@ class CRM_Campaign_Page_DashBoard extends CRM_Core_Page { } 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 74c76e66ed..4d6548f6ab 100644 --- a/CRM/Campaign/Page/Petition/Confirm.php +++ b/CRM/Campaign/Page/Petition/Confirm.php @@ -71,7 +71,7 @@ class CRM_Campaign_Page_Petition_Confirm extends CRM_Core_Page { $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 @@ class CRM_Campaign_Page_Petition_Confirm extends CRM_Core_Page { $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 d0b8d1a67a..88eae02f3f 100644 --- a/CRM/Campaign/Page/Petition/ThankYou.php +++ b/CRM/Campaign/Page/Petition/ThankYou.php @@ -40,7 +40,7 @@ class CRM_Campaign_Page_Petition_ThankYou extends CRM_Core_Page { $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 bf495f2cb4..7303571c3f 100644 --- a/CRM/Campaign/Page/SurveyType.php +++ b/CRM/Campaign/Page/SurveyType.php @@ -79,9 +79,9 @@ class CRM_Campaign_Page_SurveyType extends CRM_Core_Page_Basic { $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 @@ class CRM_Campaign_Page_SurveyType extends CRM_Core_Page_Basic { */ 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 @@ class CRM_Campaign_Page_SurveyType extends CRM_Core_Page_Basic { */ 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 6d86c4ee58..4bb67d1cc4 100644 --- a/CRM/Campaign/Page/Vote.php +++ b/CRM/Campaign/Page/Vote.php @@ -70,10 +70,10 @@ class CRM_Campaign_Page_Vote extends CRM_Core_Page { } 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 @@ class CRM_Campaign_Page_Vote extends CRM_Core_Page { 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 @@ class CRM_Campaign_Page_Vote extends CRM_Core_Page { } 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 @@ class CRM_Campaign_Page_Vote extends CRM_Core_Page { 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 a5fb362a1e..c9838d310b 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 f3315a0b00..5840333917 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 @@ class CRM_Campaign_Selector_Search extends CRM_Core_Selector_Base implements CRM * @return array */ static public function &links() { - return self::$_links = array(); + return self::$_links = []; } /** @@ -241,11 +241,11 @@ class CRM_Campaign_Selector_Search extends CRM_Core_Selector_Base implements CRM ); // 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 @@ FROM {$sql['from']} * 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 37006e0dd1..6d38b3aa5f 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 0cacffdc1b..13682c1a44 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 @@ class CRM_Campaign_Task extends CRM_Core_Task { * @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 @@ class CRM_Campaign_Task extends CRM_Core_Task { $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 1928fa4e43..f58660fef3 100644 --- a/CRM/Case/Audit/Audit.php +++ b/CRM/Case/Audit/Audit.php @@ -22,7 +22,7 @@ class CRM_Case_Audit_Audit { * @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 @@ class CRM_Case_Audit_Audit { $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 @@ class CRM_Case_Audit_Audit { } 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 @@ class CRM_Case_Audit_Audit { //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 @@ class CRM_Case_Audit_Audit { } 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 5065cca44b..be1ee8a08d 100644 --- a/CRM/Case/Audit/AuditConfig.php +++ b/CRM/Case/Audit/AuditConfig.php @@ -22,8 +22,8 @@ class CRM_Case_Audit_AuditConfig { // 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 @@ class CRM_Case_Audit_AuditConfig { } 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 @@ class CRM_Case_Audit_AuditConfig { $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 @@ class CRM_Case_Audit_AuditConfig { $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 cec9de15fe..a8cfcdbb02 100644 --- a/CRM/Case/BAO/CaseContact.php +++ b/CRM/Case/BAO/CaseContact.php @@ -57,7 +57,7 @@ class CRM_Case_BAO_CaseContact extends CRM_Case_DAO_CaseContact { $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 @@ class CRM_Case_BAO_CaseContact extends CRM_Case_DAO_CaseContact { * @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 aa65688f87..b89f35abf3 100644 --- a/CRM/Case/BAO/CaseType.php +++ b/CRM/Case/BAO/CaseType.php @@ -233,7 +233,7 @@ class CRM_Case_BAO_CaseType extends CRM_Case_DAO_CaseType { */ 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 @@ class CRM_Case_BAO_CaseType extends CRM_Case_DAO_CaseType { // 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 @@ class CRM_Case_BAO_CaseType extends CRM_Case_DAO_CaseType { // 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 @@ class CRM_Case_BAO_CaseType extends CRM_Case_DAO_CaseType { } 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 @@ class CRM_Case_BAO_CaseType extends CRM_Case_DAO_CaseType { // 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 @@ class CRM_Case_BAO_CaseType extends CRM_Case_DAO_CaseType { $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 4fafe47ed7..e5bf54125e 100644 --- a/CRM/Case/BAO/Query.php +++ b/CRM/Case/BAO/Query.php @@ -261,7 +261,7 @@ class CRM_Case_BAO_Query extends CRM_Core_BAO_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 @@ class CRM_Case_BAO_Query extends CRM_Core_BAO_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 @@ class CRM_Case_BAO_Query extends CRM_Core_BAO_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 @@ class CRM_Case_BAO_Query extends CRM_Core_BAO_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 @@ class CRM_Case_BAO_Query extends CRM_Core_BAO_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 @@ class CRM_Case_BAO_Query extends CRM_Core_BAO_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 @@ class CRM_Case_BAO_Query extends CRM_Core_BAO_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 @@ class CRM_Case_BAO_Query extends CRM_Core_BAO_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 @@ class CRM_Case_BAO_Query extends CRM_Core_BAO_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 @@ class CRM_Case_BAO_Query extends CRM_Core_BAO_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 @@ class CRM_Case_BAO_Query extends CRM_Core_BAO_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 @@ class CRM_Case_BAO_Query extends CRM_Core_BAO_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 @@ class CRM_Case_BAO_Query extends CRM_Core_BAO_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 @@ class CRM_Case_BAO_Query extends CRM_Core_BAO_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 @@ class CRM_Case_BAO_Query extends CRM_Core_BAO_Query { case 'case_taglist': $taglist = $value; - $value = array(); + $value = []; foreach ($taglist as $val) { if ($val) { $val = explode(',', $val); @@ -479,7 +479,7 @@ class CRM_Case_BAO_Query extends CRM_Core_BAO_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 @@ class CRM_Case_BAO_Query extends CRM_Core_BAO_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 @@ case_relation_type.id = case_relationship.relationship_type_id )"; $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 @@ case_relation_type.id = case_relationship.relationship_type_id )"; '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 @@ case_relation_type.id = case_relationship.relationship_type_id )"; $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 @@ case_relation_type.id = case_relationship.relationship_type_id )"; 'case_activity_medium_id' => 1, 'case_activity_details' => 1, 'case_activity_is_auto' => 1, - ); + ]; } return $properties; } @@ -663,11 +663,11 @@ case_relation_type.id = case_relationship.relationship_type_id )"; */ 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 @@ case_relation_type.id = case_relationship.relationship_type_id )"; $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 @@ case_relation_type.id = case_relationship.relationship_type_id )"; $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 @@ case_relation_type.id = case_relationship.relationship_type_id )"; $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 @@ case_relation_type.id = case_relationship.relationship_type_id )"; $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 @@ case_relation_type.id = case_relationship.relationship_type_id )"; * @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 9e2dda642d..4b9cdbe1dd 100644 --- a/CRM/Case/Form/Activity.php +++ b/CRM/Case/Form/Activity.php @@ -108,7 +108,7 @@ class CRM_Case_Form_Activity extends CRM_Activity_Form_Activity { 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 @@ class CRM_Case_Form_Activity extends CRM_Activity_Form_Activity { $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 @@ class CRM_Case_Form_Activity extends CRM_Activity_Form_Activity { ); } 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 @@ class CRM_Case_Form_Activity extends CRM_Activity_Form_Activity { */ 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 @@ class CRM_Case_Form_Activity extends CRM_Activity_Form_Activity { 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 @@ class CRM_Case_Form_Activity extends CRM_Activity_Form_Activity { $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 @@ class CRM_Case_Form_Activity extends CRM_Activity_Form_Activity { } 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 @@ class CRM_Case_Form_Activity extends CRM_Activity_Form_Activity { $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 @@ class CRM_Case_Form_Activity extends CRM_Activity_Form_Activity { $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 @@ class CRM_Case_Form_Activity extends CRM_Activity_Form_Activity { 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 @@ class CRM_Case_Form_Activity extends CRM_Activity_Form_Activity { $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 @@ class CRM_Case_Form_Activity extends CRM_Activity_Form_Activity { $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 @@ class CRM_Case_Form_Activity extends CRM_Activity_Form_Activity { $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 @@ class CRM_Case_Form_Activity extends CRM_Activity_Form_Activity { 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 @@ class CRM_Case_Form_Activity extends CRM_Activity_Form_Activity { 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 @@ class CRM_Case_Form_Activity extends CRM_Activity_Form_Activity { 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 @@ class CRM_Case_Form_Activity extends CRM_Activity_Form_Activity { ); 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 @@ class CRM_Case_Form_Activity extends CRM_Activity_Form_Activity { $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 @@ class CRM_Case_Form_Activity extends CRM_Activity_Form_Activity { } } - $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 @@ class CRM_Case_Form_Activity extends CRM_Activity_Form_Activity { $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 7066aa10b5..aecb3caef7 100644 --- a/CRM/Case/Form/Activity/ChangeCaseStartDate.php +++ b/CRM/Case/Form/Activity/ChangeCaseStartDate.php @@ -60,11 +60,11 @@ class CRM_Case_Form_Activity_ChangeCaseStartDate { * @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 @@ class CRM_Case_Form_Activity_ChangeCaseStartDate { $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 @@ class CRM_Case_Form_Activity_ChangeCaseStartDate { 'activityTypeName' => 'Change Case Start Date', 'activitySetName' => 'standard_timeline', 'resetTimeline' => 1, - ); + ]; $xmlProcessor->run($caseType, $xmlProcessorParams); @@ -183,21 +183,21 @@ class CRM_Case_Form_Activity_ChangeCaseStartDate { 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 @@ class CRM_Case_Form_Activity_ChangeCaseStartDate { } 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 62d1e3c087..a5503aac1e 100644 --- a/CRM/Case/Form/Activity/ChangeCaseStatus.php +++ b/CRM/Case/Form/Activity/ChangeCaseStatus.php @@ -46,7 +46,7 @@ class CRM_Case_Form_Activity_ChangeCaseStatus { 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 @@ class CRM_Case_Form_Activity_ChangeCaseStatus { * @return array */ public static function setDefaultValues(&$form) { - $defaults = array(); + $defaults = []; // Retrieve current case status $defaults['case_status_id'] = $form->_defaultCaseStatus; @@ -78,17 +78,17 @@ class CRM_Case_Form_Activity_ChangeCaseStatus { $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 @@ class CRM_Case_Form_Activity_ChangeCaseStatus { // 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 @@ class CRM_Case_Form_Activity_ChangeCaseStatus { // 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 @@ class CRM_Case_Form_Activity_ChangeCaseStatus { 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 53fa4a051b..2a8ac64e85 100644 --- a/CRM/Case/Form/Activity/ChangeCaseType.php +++ b/CRM/Case/Form/Activity/ChangeCaseType.php @@ -57,7 +57,7 @@ class CRM_Case_Form_Activity_ChangeCaseType { * @return array */ public static function setDefaultValues(&$form) { - $defaults = array(); + $defaults = []; $defaults['is_reset_timeline'] = 1; @@ -84,7 +84,7 @@ class CRM_Case_Form_Activity_ChangeCaseType { $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 @@ class CRM_Case_Form_Activity_ChangeCaseType { 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 @@ class CRM_Case_Form_Activity_ChangeCaseType { // 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 @@ class CRM_Case_Form_Activity_ChangeCaseType { '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 f416d0d8f2..516647c3f4 100644 --- a/CRM/Case/Form/Activity/LinkCases.php +++ b/CRM/Case/Form/Activity/LinkCases.php @@ -70,7 +70,7 @@ class CRM_Case_Form_Activity_LinkCases { * @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 @@ class CRM_Case_Form_Activity_LinkCases { 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 @@ class CRM_Case_Form_Activity_LinkCases { * 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 @@ class CRM_Case_Form_Activity_LinkCases { //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 b2f2c5eaaa..1903cc87d4 100644 --- a/CRM/Case/Form/Activity/OpenCase.php +++ b/CRM/Case/Form/Activity/OpenCase.php @@ -93,7 +93,7 @@ class CRM_Case_Form_Activity_OpenCase { * @return array $defaults */ public static function setDefaultValues(&$form) { - $defaults = array(); + $defaults = []; if ($form->_context == 'caseActivity') { return $defaults; } @@ -152,25 +152,25 @@ class CRM_Case_Form_Activity_OpenCase { 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 @@ class CRM_Case_Form_Activity_OpenCase { $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 @@ class CRM_Case_Form_Activity_OpenCase { return TRUE; } - $errors = array(); + $errors = []; return $errors; } @@ -294,25 +294,25 @@ class CRM_Case_Form_Activity_OpenCase { 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 @@ class CRM_Case_Form_Activity_OpenCase { '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 4d69175ffe..d165d4c079 100644 --- a/CRM/Case/Form/ActivityToCase.php +++ b/CRM/Case/Form/ActivityToCase.php @@ -58,8 +58,8 @@ class CRM_Case_Form_ActivityToCase extends CRM_Core_Form { * @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 @@ class CRM_Case_Form_ActivityToCase extends CRM_Core_Form { // 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 @@ class CRM_Case_Form_ActivityToCase extends CRM_Core_Form { * 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 e690d59b9d..b18be74fdc 100644 --- a/CRM/Case/Form/ActivityView.php +++ b/CRM/Case/Form/ActivityView.php @@ -66,31 +66,31 @@ class CRM_Case_Form_ActivityView extends CRM_Core_Form { $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 @@ class CRM_Case_Form_ActivityView extends CRM_Core_Form { $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 af02512fdd..20be94a95a 100644 --- a/CRM/Case/Form/AddToCaseAsRole.php +++ b/CRM/Case/Form/AddToCaseAsRole.php @@ -15,29 +15,29 @@ class CRM_Case_Form_AddToCaseAsRole extends CRM_Contact_Form_Task { '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 @@ class CRM_Case_Form_AddToCaseAsRole extends CRM_Contact_Form_Task { */ 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 @@ class CRM_Case_Form_AddToCaseAsRole extends CRM_Contact_Form_Task { $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 de0ba89cb4..87885469db 100644 --- a/CRM/Case/Form/Case.php +++ b/CRM/Case/Form/Case.php @@ -143,15 +143,15 @@ class CRM_Case_Form_Case extends CRM_Core_Form { } 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 @@ class CRM_Case_Form_Case extends CRM_Core_Form { $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 @@ class CRM_Case_Form_Case extends CRM_Core_Form { 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 @@ class CRM_Case_Form_Case extends CRM_Core_Form { $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 @@ class CRM_Case_Form_Case extends CRM_Core_Form { $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 @@ class CRM_Case_Form_Case extends CRM_Core_Form { 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 @@ class CRM_Case_Form_Case extends CRM_Core_Form { 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 cd386d276b..dd479144b4 100644 --- a/CRM/Case/Form/CaseView.php +++ b/CRM/Case/Form/CaseView.php @@ -86,21 +86,21 @@ class CRM_Case_Form_CaseView extends CRM_Core_Form { $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 @@ class CRM_Case_Form_CaseView extends CRM_Core_Form { 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 @@ class CRM_Case_Form_CaseView extends CRM_Core_Form { } $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 @@ class CRM_Case_Form_CaseView extends CRM_Core_Form { * @return array; */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; return $defaults; } @@ -225,11 +225,11 @@ class CRM_Case_Form_CaseView extends CRM_Core_Form { // 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 @@ class CRM_Case_Form_CaseView extends CRM_Core_Form { 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 @@ class CRM_Case_Form_CaseView extends CRM_Core_Form { $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 @@ class CRM_Case_Form_CaseView extends CRM_Core_Form { // 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 @@ class CRM_Case_Form_CaseView extends CRM_Core_Form { $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 @@ class CRM_Case_Form_CaseView extends CRM_Core_Form { $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 @@ class CRM_Case_Form_CaseView extends CRM_Core_Form { 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 @@ class CRM_Case_Form_CaseView extends CRM_Core_Form { } } - $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 @@ class CRM_Case_Form_CaseView extends CRM_Core_Form { // 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 @@ class CRM_Case_Form_CaseView extends CRM_Core_Form { $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 @@ class CRM_Case_Form_CaseView extends CRM_Core_Form { * @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 @@ class CRM_Case_Form_CaseView extends CRM_Core_Form { * 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 @@ class CRM_Case_Form_CaseView extends CRM_Core_Form { 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 d5e2285b8f..0ff5a3dde9 100644 --- a/CRM/Case/Form/CustomData.php +++ b/CRM/Case/Form/CustomData.php @@ -76,10 +76,10 @@ class CRM_Case_Form_CustomData extends CRM_Core_Form { // 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 @@ class CRM_Case_Form_CustomData extends CRM_Core_Form { 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 @@ class CRM_Case_Form_CustomData extends CRM_Core_Form { $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 @@ class CRM_Case_Form_CustomData extends CRM_Core_Form { '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 e48aec08fd..30c354a668 100644 --- a/CRM/Case/Form/EditClient.php +++ b/CRM/Case/Form/EditClient.php @@ -61,10 +61,10 @@ class CRM_Case_Form_EditClient extends CRM_Core_Form { 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 @@ class CRM_Case_Form_EditClient extends CRM_Core_Form { * 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 @@ class CRM_Case_Form_EditClient extends CRM_Core_Form { public function addRules() { - $this->addFormRule(array(get_class($this), 'formRule'), $this); + $this->addFormRule([get_class($this), 'formRule'], $this); } /** @@ -104,7 +104,7 @@ class CRM_Case_Form_EditClient extends CRM_Core_Form { * @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 384f98a4f6..5cb501fe19 100644 --- a/CRM/Case/Form/Report.php +++ b/CRM/Case/Form/Report.php @@ -79,10 +79,10 @@ class CRM_Case_Form_Report extends CRM_Core_Form { return; } - $includeActivites = array( + $includeActivites = [ 1 => ts('All Activities'), 2 => ts('Exclude Completed Activities'), - ); + ]; $includeActivitesGroup = $this->addRadio('include_activities', NULL, $includeActivites, @@ -97,17 +97,17 @@ class CRM_Case_Form_Report extends CRM_Core_Form { 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 14ca731cc0..313b74aa8e 100644 --- a/CRM/Case/Form/Search.php +++ b/CRM/Case/Form/Search.php @@ -290,7 +290,7 @@ class CRM_Case_Form_Search extends CRM_Core_Form_Search { * @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 @@ class CRM_Case_Form_Search extends CRM_Core_Form_Search { * @return array|bool */ public static function formRule($fields) { - $errors = array(); + $errors = []; if (!empty($errors)) { return $errors; @@ -319,7 +319,7 @@ class CRM_Case_Form_Search extends CRM_Core_Form_Search { * 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 3c65b3103c..5d28b97617 100644 --- a/CRM/Case/Form/Task/Batch.php +++ b/CRM/Case/Form/Task/Batch.php @@ -53,13 +53,13 @@ class CRM_Case_Form_Task_Batch extends CRM_Core_Form_Task_Batch { 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 cb878db818..d32a9300ea 100644 --- a/CRM/Case/Form/Task/Delete.php +++ b/CRM/Case/Form/Task/Delete.php @@ -84,16 +84,16 @@ class CRM_Case_Form_Task_Delete extends CRM_Case_Form_Task { 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 9138810a63..09e0085768 100644 --- a/CRM/Case/Form/Task/Print.php +++ b/CRM/Case/Form/Task/Print.php @@ -73,18 +73,18 @@ class CRM_Case_Form_Task_Print extends CRM_Case_Form_Task { // // 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 5bfdde5111..db78e81b73 100644 --- a/CRM/Case/Form/Task/Restore.php +++ b/CRM/Case/Form/Task/Restore.php @@ -73,15 +73,15 @@ class CRM_Case_Form_Task_Restore extends CRM_Case_Form_Task { } 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 196dc97231..49de632eba 100644 --- a/CRM/Case/Form/Task/Result.php +++ b/CRM/Case/Form/Task/Result.php @@ -46,13 +46,13 @@ class CRM_Case_Form_Task_Result extends CRM_Case_Form_Task { * 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 f12ea6960d..f9f9744234 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 @@ WHERE cs.id IN ( {$caseIDs} )"; $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 @@ WHERE cs.id IN ( {$caseIDs} )"; * 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 ab8130c66c..cb5e7b8cbb 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 @@ class CRM_Case_Info extends CRM_Core_Component_Info { public function getAngularModules() { global $civicrm_root; - $result = array(); + $result = []; $result['crmCaseType'] = include "$civicrm_root/ang/crmCaseType.ang.php"; return $result; } @@ -89,28 +89,28 @@ class CRM_Case_Info extends CRM_Core_Component_Info { * @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 @@ class CRM_Case_Info extends CRM_Core_Component_Info { * @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 @@ class CRM_Case_Info extends CRM_Core_Component_Info { $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 @@ class CRM_Case_Info extends CRM_Core_Component_Info { $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 @@ class CRM_Case_Info extends CRM_Core_Component_Info { * @return array */ public function getUserDashboardElement() { - return array(); + return []; } /** @@ -169,11 +169,11 @@ class CRM_Case_Info extends CRM_Core_Component_Info { * @return array */ public function registerTab() { - return array( + return [ 'title' => ts('Cases'), 'url' => 'case', 'weight' => 50, - ); + ]; } /** @@ -189,10 +189,10 @@ class CRM_Case_Info extends CRM_Core_Component_Info { * @return array */ public function registerAdvancedSearchPane() { - return array( + return [ 'title' => ts('Cases'), 'weight' => 50, - ); + ]; } /** @@ -213,14 +213,14 @@ class CRM_Case_Info extends CRM_Core_Component_Info { ) { $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 @@ class CRM_Case_Info extends CRM_Core_Component_Info { * 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 @@ class CRM_Case_Info extends CRM_Core_Component_Info { * 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 @@ class CRM_Case_Info extends CRM_Core_Component_Info { * 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 382f9a05a7..461b51f5da 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 @@ class CRM_Case_ManagedEntities { } 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 @@ class CRM_Case_ManagedEntities { '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 @@ class CRM_Case_ManagedEntities { * @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 @@ class CRM_Case_ManagedEntities { * @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 @@ class CRM_Case_ManagedEntities { $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 @@ class CRM_Case_ManagedEntities { '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 78e93a3d39..764f1f7d13 100644 --- a/CRM/Case/Page/AJAX.php +++ b/CRM/Case/Page/AJAX.php @@ -50,15 +50,15 @@ class CRM_Case_Page_AJAX { 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 @@ class CRM_Case_Page_AJAX { $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 @@ class CRM_Case_Page_AJAX { $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 @@ class CRM_Case_Page_AJAX { 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 @@ class CRM_Case_Page_AJAX { CRM_Utils_System::permissionDenied(); } - $params = array( + $params = [ 'case_id' => $caseId, 'contact_id' => $contactId, - ); + ]; CRM_Case_BAO_CaseContact::create($params); @@ -148,7 +148,7 @@ class CRM_Case_Page_AJAX { $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 @@ class CRM_Case_Page_AJAX { $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 @@ class CRM_Case_Page_AJAX { } 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 @@ class CRM_Case_Page_AJAX { $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 f2dccd4af4..fd0002c3cf 100644 --- a/CRM/Case/Page/DashBoard.php +++ b/CRM/Case/Page/DashBoard.php @@ -84,8 +84,8 @@ class CRM_Case_Page_DashBoard extends CRM_Core_Page { $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 8e1c9a91de..36116498f4 100644 --- a/CRM/Case/Page/Tab.php +++ b/CRM/Case/Page/Tab.php @@ -67,7 +67,7 @@ class CRM_Case_Page_Tab extends CRM_Core_Page { 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 @@ class CRM_Case_Page_Tab extends CRM_Core_Page { 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 bff8dc9160..3ee2236862 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 @@ class CRM_Case_PseudoConstant extends CRM_Core_PseudoConstant { $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 @@ class CRM_Case_PseudoConstant extends CRM_Core_PseudoConstant { $dao = CRM_Core_DAO::executeQuery($query); - $activityTypes = array(); + $activityTypes = []; while ($dao->fetch()) { if ($indexName) { $index = $dao->name; @@ -187,7 +187,7 @@ class CRM_Case_PseudoConstant extends CRM_Core_PseudoConstant { 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 d068a128af..5869a50fd2 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 @@ class CRM_Case_Selector_Search extends CRM_Core_Selector_Base { $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 @@ class CRM_Case_Selector_Search extends CRM_Core_Selector_Base { $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 @@ class CRM_Case_Selector_Search extends CRM_Core_Selector_Base { $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 @@ class CRM_Case_Selector_Search extends CRM_Core_Selector_Base { $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 @@ class CRM_Case_Selector_Search extends CRM_Core_Selector_Base { */ 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 5bbea3e532..8f29c530ad 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 06502469f4..6196aa6cf4 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 @@ class CRM_Case_Task extends CRM_Core_Task { * @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 @@ class CRM_Case_Task extends CRM_Core_Task { $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 @@ class CRM_Case_Task extends CRM_Core_Task { $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 801279f44f..d30b3cd06a 100644 --- a/CRM/Case/XMLProcessor.php +++ b/CRM/Case/XMLProcessor.php @@ -113,7 +113,7 @@ class CRM_Case_XMLProcessor { 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 255c7cc029..338ae20fad 100644 --- a/CRM/Case/XMLProcessor/Process.php +++ b/CRM/Case/XMLProcessor/Process.php @@ -48,7 +48,7 @@ class CRM_Case_XMLProcessor_Process extends CRM_Case_XMLProcessor { 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 @@ class CRM_Case_XMLProcessor_Process extends CRM_Case_XMLProcessor { 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 @@ class CRM_Case_XMLProcessor_Process extends CRM_Case_XMLProcessor { 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 @@ class CRM_Case_XMLProcessor_Process extends CRM_Case_XMLProcessor { 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 @@ class CRM_Case_XMLProcessor_Process extends CRM_Case_XMLProcessor { '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 @@ class CRM_Case_XMLProcessor_Process extends CRM_Case_XMLProcessor { */ 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 @@ class CRM_Case_XMLProcessor_Process extends CRM_Case_XMLProcessor { * @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 @@ class CRM_Case_XMLProcessor_Process extends CRM_Case_XMLProcessor { * @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 @@ AND a.is_auto = 1 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 @@ AND ca.case_id = %2 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 @@ AND a.is_deleted = 0 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 @@ AND a.is_deleted = 0 } if ($activityTypeName == 'Open Case') { - $activityParams = array( + $activityParams = [ 'activity_type_id' => $activityTypeID, 'source_contact_id' => $params['creatorID'], 'is_auto' => FALSE, @@ -463,10 +463,10 @@ AND a.is_deleted = 0 '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 @@ AND a.is_deleted = 0 '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 @@ AND a.is_deleted = 0 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 @@ AND a.is_deleted = 0 } // 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 @@ AND a.is_deleted = 0 * @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 @@ AND a.is_deleted = 0 */ 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 cef502b5af..dbe1dedb43 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 7973e439a6..252babe18a 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 @@ class CRM_Case_XMLRepository { } 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 @@ class CRM_Case_XMLRepository { * @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 @@ class CRM_Case_XMLRepository { 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 @@ class CRM_Case_XMLRepository { 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 @@ class CRM_Case_XMLRepository { */ 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 @@ class CRM_Case_XMLRepository { * @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 @@ class CRM_Case_XMLRepository { * @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 4dee05a6ed..90cae0a3a8 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 @@ class CRM_Contact_ActionMapping extends \Civi\ActionSchedule\Mapping { '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 @@ class CRM_Contact_ActionMapping extends \Civi\ActionSchedule\Mapping { * 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 @@ class CRM_Contact_ActionMapping extends \Civi\ActionSchedule\Mapping { 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 a6c54fbfce..8e7a12f373 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 @@ class CRM_Contact_BAO_Contact_Location { 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 @@ class CRM_Contact_BAO_Contact_Location { 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 @@ LEFT JOIN civicrm_phone ON ( civicrm_phone.contact_id = civicrm_contact.id ) $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 @@ WHERE civicrm_address.geo_code_1 IS NOT NULL 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 @@ AND civicrm_contact.id IN $idString "; $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 4469a37c39..3ab63c8290 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 @@ class CRM_Contact_BAO_Contact_Permission { // 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 @@ WHERE contact_id IN ({$contact_id_list}) } // 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 @@ WHERE contact_a.id = %1 AND $permission 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 @@ WHERE contact_a.id = %1 AND $permission $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 @@ AND $operationClause } } - $tables = array(); - $whereTables = array(); + $tables = []; + $whereTables = []; $permission = CRM_ACL_API::whereClause($type, $tables, $whereTables, $userID, FALSE, FALSE, TRUE); @@ -273,16 +273,16 @@ AND ac.user_id IS NULL 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 @@ AND ac.user_id IS NULL 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 @@ AND ac.user_id IS NULL $whereClase = " aclContactCache.user_id = $contactID AND $contactAlias.is_deleted = 0"; } - return array($fromClause, $whereClase); + return [$fromClause, $whereClase]; } /** @@ -315,7 +315,7 @@ AND ac.user_id IS NULL * @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 @@ AND ac.user_id IS NULL * 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 @@ SELECT second_degree_relationship.contact_id_{$second_direction['to']} AS contac // 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 a4aff68fa8..2b3f087913 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 @@ WHERE id IN ( $idString ) * 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 @@ UNION 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 @@ UNION } 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 @@ UNION } // 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 @@ UNION } // 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 @@ UNION * @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 @@ WHERE id={$contactId}; "; 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 @@ WHERE id={$contactId}; "; 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 @@ WHERE id={$contactId}; "; $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 @@ UPDATE civicrm_contact * 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 @@ UPDATE civicrm_contact } // 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 @@ LEFT JOIN civicrm_email ce ON ( ce.contact_id=c.id AND ce.is_primary = 1 ) * @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 @@ LEFT JOIN civicrm_email ce ON ( ce.contact_id=c.id AND ce.is_primary = 1 ) $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 @@ LEFT JOIN civicrm_email ce ON ( ce.contact_id=c.id AND ce.is_primary = 1 ) $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 @@ INNER JOIN civicrm_contact contact_target ON ( contact_target.id = act.contact_i $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 @@ INNER JOIN civicrm_contact contact_target ON ( contact_target.id = act.contact_i // 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 @@ INNER JOIN civicrm_contact contact_target ON ( contact_target.id = act.contact_i * 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 @@ INNER JOIN civicrm_contact contact_target ON ( contact_target.id = act.contact_i 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 @@ INNER JOIN civicrm_contact contact_target ON ( contact_target.id = act.contact_i $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 @@ INNER JOIN civicrm_contact contact_target ON ( contact_target.id = act.contact_i } //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 @@ INNER JOIN civicrm_contact contact_target ON ( contact_target.id = act.contact_i } 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 @@ INNER JOIN civicrm_contact contact_target ON ( contact_target.id = act.contact_i 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 @@ INNER JOIN civicrm_contact contact_target ON ( contact_target.id = act.contact_i } // 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 @@ WHERE id IN (" . implode(',', $contactIds) . ")"; * @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 @@ WHERE id IN (" . implode(',', $contactIds) . ")"; * 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 87b1def2ad..2b264dd8be 100644 --- a/CRM/Contact/BAO/ContactType.php +++ b/CRM/Contact/BAO/ContactType.php @@ -78,7 +78,7 @@ class CRM_Contact_BAO_ContactType extends CRM_Contact_DAO_ContactType { static $_cache = NULL; if ($_cache === NULL) { - $_cache = array(); + $_cache = []; } $argString = $all ? 'CRM_CT_BTI_1' : 'CRM_CT_BTI_0'; @@ -95,14 +95,14 @@ WHERE parent_id IS NULL $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 @@ WHERE parent_id IS NULL 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 @@ WHERE parent_id IS NULL } 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 @@ WHERE parent_id IS NULL $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 @@ WHERE subtype.name IS NOT NULL AND subtype.parent_id IS NOT NULL {$ctWHERE} 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 @@ WHERE subtype.name IS NOT NULL AND subtype.parent_id IS NOT NULL {$ctWHERE} 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 @@ WHERE subtype.name IS NOT NULL AND subtype.parent_id IS NOT NULL {$ctWHERE} } if ($_cache === NULL) { - $_cache = array(); + $_cache = []; } $argString = $all ? 'CRM_CT_CTI_1' : 'CRM_CT_CTI_0'; @@ -293,7 +293,7 @@ WHERE subtype.name IS NOT NULL AND subtype.parent_id IS NOT NULL {$ctWHERE} $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 @@ WHERE type.name IS NOT NULL } $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 @@ WHERE type.name IS NOT NULL $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 @@ WHERE type.name IS NOT NULL static $_cache = NULL; if ($_cache === NULL) { - $_cache = array(); + $_cache = []; } $argString = $all ? 'CRM_CT_GSE_1' : 'CRM_CT_GSE_0'; @@ -393,7 +393,7 @@ WHERE type.name IS NOT NULL $_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 @@ AND ( p.is_active = 1 OR p.id IS NULL ) } $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 @@ AND ( p.is_active = 1 OR p.id IS NULL ) } 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 @@ AND ( p.is_active = 1 OR p.id IS NULL ) 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 @@ WHERE subtype.name IN ('" . implode("','", $subType) . "' )"; * 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 @@ WHERE subtype.name IN ('" . implode("','", $subType) . "' )"; 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 @@ WHERE subtype.name IN ('" . implode("','", $subType) . "' )"; 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 @@ WHERE contact_sub_type = '$name'"; 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 @@ WHERE name = %1"; } 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 @@ WHERE name = %1"; 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 @@ WHERE name = %1"; * 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 @@ LIMIT 1"; * * @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 @@ LIMIT 1"; $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 @@ WHERE extends = %1 AND " . implode(" OR ", $subTypeClause); 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 @@ WHERE extends = %1 AND " . implode(" OR ", $subTypeClause); * * @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 @@ WHERE extends = %1 AND " . implode(" OR ", $subTypeClause); } $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 @@ WHERE ($subtypeClause)"; 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 2b94fe37a4..3ac9d27470 100644 --- a/CRM/Contact/BAO/Group.php +++ b/CRM/Contact/BAO/Group.php @@ -89,7 +89,7 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group { $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 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group { 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 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group { * @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 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group { */ 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 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group { * 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 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group { $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 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group { ) { // 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 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group { 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 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group { * 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 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group { */ 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 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group { //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 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group { } 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 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group { // 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 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group { } // 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 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group { 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 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group { } } $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 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group { 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 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group { //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 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group { $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 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group { $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 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group { 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 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group { $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 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group { $titleOnly = FALSE ) { if (empty($groupIDs)) { - return array(); + return []; } $groupIdString = '(' . implode(',', array_keys($groupIDs)) . ')'; @@ -1067,8 +1067,8 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group { // 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 @@ WHERE id IN $groupIdString // 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 @@ WHERE id IN $groupIdString // $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 @@ WHERE id IN $groupIdString $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 @@ WHERE {$whereClause}"; * @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 @@ WHERE {$whereClause}"; 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 @@ WHERE {$whereClause}"; 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 @@ WHERE {$whereClause}"; $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 @@ WHERE {$whereClause}"; $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 @@ WHERE {$whereClause}"; * @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 @@ WHERE {$whereClause}"; */ 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 9bb1dc439a..688fb63f02 100644 --- a/CRM/Contact/BAO/GroupContact.php +++ b/CRM/Contact/BAO/GroupContact.php @@ -140,7 +140,7 @@ class CRM_Contact_BAO_GroupContact extends CRM_Contact_DAO_GroupContact { $tracking = NULL ) { if (empty($contactIds) || empty($groupId)) { - return array(); + return []; } CRM_Utils_Hook::pre('create', 'GroupContact', $groupId, $contactIds); @@ -152,7 +152,7 @@ class CRM_Contact_BAO_GroupContact extends CRM_Contact_DAO_GroupContact { CRM_Utils_Hook::post('create', 'GroupContact', $groupId, $contactIds); - return array(count($contactIds), $numContactsAdded, $numContactsNotAdded); + return [count($contactIds), $numContactsAdded, $numContactsNotAdded]; } /** @@ -178,7 +178,7 @@ class CRM_Contact_BAO_GroupContact extends CRM_Contact_DAO_GroupContact { $tracking = NULL ) { if (!is_array($contactIds)) { - return array(0, 0, 0); + return [0, 0, 0]; } if ($status == 'Removed' || $status == 'Deleted') { @@ -202,14 +202,14 @@ class CRM_Contact_BAO_GroupContact extends CRM_Contact_DAO_GroupContact { 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 @@ class CRM_Contact_BAO_GroupContact extends CRM_Contact_DAO_GroupContact { } //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 @@ class CRM_Contact_BAO_GroupContact extends CRM_Contact_DAO_GroupContact { CRM_Utils_Hook::post($op, 'GroupContact', $groupId, $contactIds); - return array(count($contactIds), $numContactsRemoved, $numContactsNotRemoved); + return [count($contactIds), $numContactsRemoved, $numContactsNotRemoved]; } /** @@ -285,7 +285,7 @@ class CRM_Contact_BAO_GroupContact extends CRM_Contact_DAO_GroupContact { $group->query($sql); - $values = array(); + $values = []; while ($group->fetch()) { $values[$group->id] = $group->title; } @@ -354,21 +354,21 @@ class CRM_Contact_BAO_GroupContact extends CRM_Contact_DAO_GroupContact { 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 @@ class CRM_Contact_BAO_GroupContact extends CRM_Contact_DAO_GroupContact { } 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 @@ SELECT * $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 @@ SELECT * * @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 @@ SELECT * // 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 @@ SELECT * 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 @@ SELECT * * 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 @@ AND cMain.contact_id IS NULL "; $dao = CRM_Core_DAO::executeQuery($sql, $params); - $otherGroupIDs = array(); + $otherGroupIDs = []; while ($dao->fetch()) { $otherGroupIDs[] = $dao->group_id; } @@ -645,7 +645,7 @@ AND cOther.contact_id = %2 "; $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 @@ WHERE group_id = %1 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 @@ AND contact_id IN ( $contactStr ) } } - return array($numContactsAdded, $numContactsNotAdded); + return [$numContactsAdded, $numContactsNotAdded]; } /** @@ -786,7 +786,7 @@ AND contact_id IN ( $contactStr ) * * @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 5bad91bed0..e05bd90938 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 @@ AND ( */ 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 @@ AND ( // 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 @@ AND ( "; $dao = CRM_Core_DAO::executeQuery($query); - $processGroupIDs = array(); + $processGroupIDs = []; $refreshGroupIDs = $groupIDs; while ($dao->fetch()) { $processGroupIDs[] = $dao->id; @@ -221,9 +221,9 @@ AND g.refresh_date IS NULL 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 @@ WHERE id IN ( $groupIDs ) */ 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 @@ WHERE id IN ( $groupIDs ) 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 @@ WHERE id IN ( $groupIDs ) // 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 @@ WHERE id IN ( $groupIDs ) */ 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 @@ WHERE id IN ( $groupIDs ) * 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 @@ WHERE id IN ( $groupIDs ) 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 @@ WHERE civicrm_group_contact.status = 'Added' $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 @@ WHERE civicrm_group_contact.status = 'Added' CRM_Core_DAO::executeQuery(" DROP TEMPORARY TABLE $tempTable"); } - self::updateCacheTime(array($groupID), $processed); + self::updateCacheTime([$groupID], $processed); if ($group->children) { @@ -610,7 +610,7 @@ FROM civicrm_group_contact 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 @@ AND civicrm_group_contact.group_id = $groupID "; 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 @@ AND civicrm_group_contact.group_id = $groupID "; $contactIDs = $contactID; } else { - $contactIDs = array($contactID); + $contactIDs = [$contactID]; } self::loadAll(); @@ -700,7 +700,7 @@ ORDER BY gc.contact_id, g.children "; $dao = CRM_Core_DAO::executeQuery($sql); - $contactGroup = array(); + $contactGroup = []; $prevContactID = NULL; while ($dao->fetch()) { if ( @@ -712,16 +712,16 @@ ORDER BY gc.contact_id, g.children $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 615b9a0e97..dae7b4a3fd 100644 --- a/CRM/Contact/BAO/GroupNesting.php +++ b/CRM/Contact/BAO/GroupNesting.php @@ -146,12 +146,12 @@ class CRM_Contact_BAO_GroupNesting extends CRM_Contact_DAO_GroupNesting { */ 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 @@ class CRM_Contact_BAO_GroupNesting extends CRM_Contact_DAO_GroupNesting { */ 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 @@ class CRM_Contact_BAO_GroupNesting extends CRM_Contact_DAO_GroupNesting { */ 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 af7ee5d590..74d7d6f1fe 100644 --- a/CRM/Contact/BAO/GroupNestingCache.php +++ b/CRM/Contact/BAO/GroupNestingCache.php @@ -52,20 +52,20 @@ WHERE n.child_group_id = gc.id $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 @@ SET parents = null, "; 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 @@ WHERE id = $id * @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 @@ WHERE id = $id 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 9b383d6b4c..523849e723 100644 --- a/CRM/Contact/BAO/Household.php +++ b/CRM/Contact/BAO/Household.php @@ -54,17 +54,17 @@ class CRM_Contact_BAO_Household extends CRM_Contact_DAO_Contact { $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 28cfcbb221..e0ada62e16 100644 --- a/CRM/Contact/BAO/Individual.php +++ b/CRM/Contact/BAO/Individual.php @@ -59,7 +59,7 @@ class CRM_Contact_BAO_Individual extends CRM_Contact_DAO_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 @@ class CRM_Contact_BAO_Individual extends CRM_Contact_DAO_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 @@ class CRM_Contact_BAO_Individual extends CRM_Contact_DAO_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 @@ class CRM_Contact_BAO_Individual extends CRM_Contact_DAO_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 @@ class CRM_Contact_BAO_Individual extends CRM_Contact_DAO_Contact { } } - foreach (array('prefix', 'suffix') as $name) { + foreach (['prefix', 'suffix'] as $name) { $dbName = "{$name}_id"; $value = $individual->$dbName; @@ -179,14 +179,14 @@ class CRM_Contact_BAO_Individual extends CRM_Contact_DAO_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 @@ class CRM_Contact_BAO_Individual extends CRM_Contact_DAO_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 @@ class CRM_Contact_BAO_Individual extends CRM_Contact_DAO_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 @@ class CRM_Contact_BAO_Individual extends CRM_Contact_DAO_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 @@ class CRM_Contact_BAO_Individual extends CRM_Contact_DAO_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 @@ class CRM_Contact_BAO_Individual extends CRM_Contact_DAO_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 7ee0be7ad9..2815979a17 100644 --- a/CRM/Contact/BAO/ProximityQuery.php +++ b/CRM/Contact/BAO/ProximityQuery.php @@ -114,7 +114,7 @@ class CRM_Contact_BAO_ProximityQuery { $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 @@ class CRM_Contact_BAO_ProximityQuery { $maxLong = $maxLong - pi() * 2; } - return array( + return [ rad2deg($minLong), rad2deg($maxLong), - ); + ]; } /** @@ -198,10 +198,10 @@ class CRM_Contact_BAO_ProximityQuery { $maxLat = $rightangle; } - return array( + return [ rad2deg($minLat), rad2deg($maxLat), - ); + ]; } /** @@ -215,15 +215,15 @@ class CRM_Contact_BAO_ProximityQuery { 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 @@ ACOS( 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 @@ ACOS( '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 @@ ACOS( } $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 @@ ACOS( 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 0e66244547..bc0450975b 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 @@ class CRM_Contact_BAO_Query { $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 @@ class CRM_Contact_BAO_Query { * 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 @@ class CRM_Contact_BAO_Query { */ 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 @@ class CRM_Contact_BAO_Query { //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 @@ class CRM_Contact_BAO_Query { $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 @@ class CRM_Contact_BAO_Query { } 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 @@ class CRM_Contact_BAO_Query { * 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 @@ class CRM_Contact_BAO_Query { $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 @@ class CRM_Contact_BAO_Query { // 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 @@ class CRM_Contact_BAO_Query { 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 @@ class CRM_Contact_BAO_Query { } 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 @@ class CRM_Contact_BAO_Query { } } 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 @@ class CRM_Contact_BAO_Query { 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 @@ class CRM_Contact_BAO_Query { 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 @@ class CRM_Contact_BAO_Query { $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 @@ class CRM_Contact_BAO_Query { // 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 @@ class CRM_Contact_BAO_Query { } } 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 @@ class CRM_Contact_BAO_Query { } } if (!$fnd) { - $p[2] = array('to' => $p[2]); + $p[2] = ['to' => $p[2]]; $this->_cfIDs[$cfID][] = $p; } } @@ -1006,11 +1006,11 @@ class CRM_Contact_BAO_Query { } $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 @@ class CRM_Contact_BAO_Query { $this->_element["{$tName}"] = 1; $locationTypeName = $tName; - $locationTypeJoin = array(); + $locationTypeJoin = []; $addWhereCount = 0; foreach ($elements as $elementFullName => $dontCare) { @@ -1055,7 +1055,7 @@ class CRM_Contact_BAO_Query { // 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 @@ class CRM_Contact_BAO_Query { } 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 @@ class CRM_Contact_BAO_Query { } 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 @@ class CRM_Contact_BAO_Query { 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 @@ class CRM_Contact_BAO_Query { $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 @@ class CRM_Contact_BAO_Query { $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 @@ class CRM_Contact_BAO_Query { } } - 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 @@ class CRM_Contact_BAO_Query { // 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 @@ class CRM_Contact_BAO_Query { $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 @@ class CRM_Contact_BAO_Query { // 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 @@ class CRM_Contact_BAO_Query { $this->filterRelatedContacts($from, $where, $having); } - return array($select, $from, $where, $having); + return [$select, $from, $where, $having]; } /** @@ -1541,8 +1541,8 @@ class CRM_Contact_BAO_Query { * @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 @@ class CRM_Contact_BAO_Query { // 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 @@ class CRM_Contact_BAO_Query { $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 @@ class CRM_Contact_BAO_Query { $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 @@ class CRM_Contact_BAO_Query { } 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 @@ class CRM_Contact_BAO_Query { * */ 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 @@ class CRM_Contact_BAO_Query { } if (!$skipWhere) { - $skipWhere = array( + $skipWhere = [ 'task', 'radio_ts', 'uf_group_id', @@ -1725,7 +1725,7 @@ class CRM_Contact_BAO_Query { 'qfKey', 'operator', 'display_relationship_type', - ); + ]; } if (in_array($id, $skipWhere) || @@ -1744,7 +1744,7 @@ class CRM_Contact_BAO_Query { } 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 @@ class CRM_Contact_BAO_Query { } 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 @@ class CRM_Contact_BAO_Query { * @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 @@ class CRM_Contact_BAO_Query { $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 @@ class CRM_Contact_BAO_Query { $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 @@ class CRM_Contact_BAO_Query { $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 @@ class CRM_Contact_BAO_Query { $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 @@ class CRM_Contact_BAO_Query { } 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 @@ class CRM_Contact_BAO_Query { } 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 @@ class CRM_Contact_BAO_Query { } 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 @@ class CRM_Contact_BAO_Query { } 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 @@ class CRM_Contact_BAO_Query { //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 @@ class CRM_Contact_BAO_Query { //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 @@ class CRM_Contact_BAO_Query { } } elseif (in_array($locType[0], - array( + [ 'address_name', 'street_address', 'street_name', @@ -2410,18 +2410,18 @@ class CRM_Contact_BAO_Query { '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 @@ class CRM_Contact_BAO_Query { $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 @@ class CRM_Contact_BAO_Query { * 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 @@ class CRM_Contact_BAO_Query { $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 @@ class CRM_Contact_BAO_Query { } 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 @@ class CRM_Contact_BAO_Query { $tempTable[$k . ".$key"] = $key; } ksort($tempTable); - $newTables = array(); + $newTables = []; foreach ($tempTable as $key) { $newTables[$key] = $tables[$key]; } @@ -2850,8 +2850,8 @@ class CRM_Contact_BAO_Query { 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 @@ class CRM_Contact_BAO_Query { $value = $value[$op]; } - $clause = array(); + $clause = []; $alias = "contact_a.contact_sub_type"; $qillOperators = CRM_Core_SelectValues::getSearchBuilderOperators(); @@ -2952,7 +2952,7 @@ class CRM_Contact_BAO_Query { 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 @@ class CRM_Contact_BAO_Query { 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 @@ class CRM_Contact_BAO_Query { $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 @@ class CRM_Contact_BAO_Query { $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 @@ class CRM_Contact_BAO_Query { 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 @@ class CRM_Contact_BAO_Query { ); } $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 @@ class CRM_Contact_BAO_Query { 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 @@ class CRM_Contact_BAO_Query { } 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 @@ class CRM_Contact_BAO_Query { * @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 @@ class CRM_Contact_BAO_Query { 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 @@ WHERE $smartGroupClause 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 @@ WHERE $smartGroupClause 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 @@ WHERE $smartGroupClause 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 @@ WHERE $smartGroupClause 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 @@ WHERE $smartGroupClause = " 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 @@ WHERE $smartGroupClause $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 @@ WHERE $smartGroupClause } $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 @@ WHERE $smartGroupClause } $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 @@ WHERE $smartGroupClause $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 @@ WHERE $smartGroupClause } $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 @@ WHERE $smartGroupClause $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 @@ WHERE $smartGroupClause $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 @@ WHERE $smartGroupClause 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 @@ WHERE $smartGroupClause } 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 @@ WHERE $smartGroupClause $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 @@ WHERE $smartGroupClause } $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 @@ WHERE $smartGroupClause if ($fromStateProvince) { if (!empty($countryClause)) { - return array( + return [ $countryClause, " ...AND... " . $countryQill, - ); + ]; } else { - return array(NULL, NULL); + return [NULL, NULL]; } } } @@ -3829,7 +3829,7 @@ WHERE $smartGroupClause 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 @@ WHERE $smartGroupClause break; } } - $names = array(); + $names = []; if ($op == '=') { $op = 'IN'; } @@ -3852,7 +3852,7 @@ WHERE $smartGroupClause $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 @@ WHERE $smartGroupClause } } else { - $inputClause = array(); + $inputClause = []; $county = CRM_Core_PseudoConstant::county(); foreach ($value as $name) { $name = trim($name); @@ -3912,7 +3912,7 @@ WHERE $smartGroupClause $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 @@ WHERE $smartGroupClause $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 @@ WHERE $smartGroupClause 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 @@ WHERE $smartGroupClause } $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 @@ WHERE $smartGroupClause } } - $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 @@ WHERE $smartGroupClause // 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 @@ WHERE $smartGroupClause //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 @@ civicrm_relationship.start_date > {$today} } $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 @@ civicrm_relationship.start_date > {$today} 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 @@ civicrm_relationship.start_date > {$today} * 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 @@ civicrm_relationship.start_date > {$today} * 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 @@ civicrm_relationship.start_date > {$today} */ public static function &defaultReturnProperties($mode = 1) { if (!isset(self::$_defaultReturnProperties)) { - self::$_defaultReturnProperties = array(); + self::$_defaultReturnProperties = []; } if (!isset(self::$_defaultReturnProperties[$mode])) { @@ -4418,7 +4418,7 @@ civicrm_relationship.start_date > {$today} } 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 @@ civicrm_relationship.start_date > {$today} 'contact_is_deleted' => 1, 'preferred_communication_method' => 1, 'preferred_language' => 1, - ); + ]; } } return self::$_defaultReturnProperties[$mode]; @@ -4608,11 +4608,11 @@ civicrm_relationship.start_date > {$today} // @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 @@ civicrm_relationship.start_date > {$today} } $values[$dao->$entityIDField] = $val; } - return array($values, $options); + return [$values, $options]; } /** @@ -4693,22 +4693,22 @@ civicrm_relationship.start_date > {$today} 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 @@ civicrm_relationship.start_date > {$today} 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 @@ civicrm_relationship.start_date > {$today} 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 @@ civicrm_relationship.start_date > {$today} CRM_Core_DAO::reenableFullGroupByMode(); if ($groupContacts) { - $ids = array(); + $ids = []; while ($dao->fetch()) { $ids[] = $dao->id; } @@ -4969,7 +4969,7 @@ civicrm_relationship.start_date > {$today} 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 @@ civicrm_relationship.start_date > {$today} */ 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 @@ civicrm_relationship.start_date > {$today} '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 @@ civicrm_relationship.start_date > {$today} 'email-1' => 1, 'email-2' => 1, 'email-3' => 1, - ), - '2' => array( + ], + '2' => [ 'location_type' => 1, 'street_address' => 1, 'city' => 1, @@ -5195,9 +5195,9 @@ civicrm_relationship.start_date > {$today} 'email-1' => 1, 'email-2' => 1, 'email-3' => 1, - ), - ), - ); + ], + ], + ]; } return self::$_defaultHierReturnProperties; } @@ -5301,7 +5301,7 @@ civicrm_relationship.start_date > {$today} $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 @@ civicrm_relationship.start_date > {$today} 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 @@ civicrm_relationship.start_date > {$today} } 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 @@ civicrm_relationship.start_date > {$today} } // pane name to table mapper - $panesMapper = array( + $panesMapper = [ ts('Contributions') => 'civicrm_contribution', ts('Memberships') => 'civicrm_membership', ts('Events') => 'civicrm_participant', @@ -5622,7 +5622,7 @@ civicrm_relationship.start_date > {$today} 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 @@ civicrm_relationship.start_date > {$today} * @param $operator */ public function setOperator($operator) { - $validOperators = array('AND', 'OR'); + $validOperators = ['AND', 'OR']; if (!in_array($operator, $validOperators)) { $operator = 'AND'; } @@ -5659,7 +5659,7 @@ civicrm_relationship.start_date > {$today} */ 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 @@ SELECT contact_a.id "; 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 @@ SELECT contact_a.id } 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 @@ AND displayRelType.is_active = 1 */ 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 @@ AND displayRelType.is_active = 1 $useIDsOnly = FALSE ) { - $pseudoFields = array( + $pseudoFields = [ 'email_greeting', 'postal_greeting', 'addressee', @@ -5828,7 +5828,7 @@ AND displayRelType.is_active = 1 'prefix_id', 'suffix_id', 'communication_style_id', - ); + ]; if ($useIDsOnly) { list($tableName, $fieldName) = explode('.', $field['where'], 2); @@ -5852,7 +5852,7 @@ AND displayRelType.is_active = 1 $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 @@ AND displayRelType.is_active = 1 } 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 @@ AND displayRelType.is_active = 1 return FALSE; } - $returnValues = array(); + $returnValues = []; foreach ($values as $v) { if ($dataType == 'Integer' && !is_numeric($v)) { return FALSE; @@ -5923,7 +5923,7 @@ AND displayRelType.is_active = 1 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 @@ AND displayRelType.is_active = 1 $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 @@ AND displayRelType.is_active = 1 $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 @@ AND displayRelType.is_active = 1 } } 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 @@ AND displayRelType.is_active = 1 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 @@ AND displayRelType.is_active = 1 $this->_fromClause = $this->_fromClause . $presentClause; $this->_simpleFromClause = $this->_simpleFromClause . $presentSimpleFromClause; - return array($presentClause, $presentSimpleFromClause); + return [$presentClause, $presentSimpleFromClause]; } /** @@ -6109,7 +6109,7 @@ AND displayRelType.is_active = 1 $fieldName, $fieldValue, $op, - $pseudoExtraParam = array(), + $pseudoExtraParam = [], $type = CRM_Utils_Type::T_STRING ) { $qillOperators = CRM_Core_SelectValues::getSearchBuilderOperators(); @@ -6123,7 +6123,7 @@ AND displayRelType.is_active = 1 // 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 @@ AND displayRelType.is_active = 1 } 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 @@ AND displayRelType.is_active = 1 $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 @@ AND displayRelType.is_active = 1 * @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 @@ AND displayRelType.is_active = 1 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 @@ AND displayRelType.is_active = 1 $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 @@ AND displayRelType.is_active = 1 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 30b30451ac..4b020772be 100644 --- a/CRM/Contact/BAO/Query/Hook.php +++ b/CRM/Contact/BAO/Query/Hook.php @@ -62,7 +62,7 @@ class CRM_Contact_BAO_Query_Hook { */ 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 @@ class CRM_Contact_BAO_Query_Hook { * @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 f30a44fcfc..e229a03ea5 100644 --- a/CRM/Contact/BAO/RelationshipType.php +++ b/CRM/Contact/BAO/RelationshipType.php @@ -142,10 +142,10 @@ class CRM_Contact_BAO_RelationshipType extends CRM_Contact_DAO_RelationshipType $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 67e95d095f..049dcaf517 100644 --- a/CRM/Contact/BAO/SavedSearch.php +++ b/CRM/Contact/BAO/SavedSearch.php @@ -92,7 +92,7 @@ class CRM_Contact_BAO_SavedSearch extends CRM_Contact_DAO_SavedSearch { * 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 @@ class CRM_Contact_BAO_SavedSearch extends CRM_Contact_DAO_SavedSearch { '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 @@ class CRM_Contact_BAO_SavedSearch extends CRM_Contact_DAO_SavedSearch { $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 @@ class CRM_Contact_BAO_SavedSearch extends CRM_Contact_DAO_SavedSearch { 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 @@ class CRM_Contact_BAO_SavedSearch extends CRM_Contact_DAO_SavedSearch { 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 @@ class CRM_Contact_BAO_SavedSearch extends CRM_Contact_DAO_SavedSearch { 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 @@ WHERE $where"; 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 @@ LEFT JOIN civicrm_email ON (contact_a.id = civicrm_email.contact_id AND civicrm_ $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 @@ LEFT JOIN civicrm_email ON (contact_a.id = civicrm_email.contact_id AND civicrm_ } 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 @@ LEFT JOIN civicrm_email ON (contact_a.id = civicrm_email.contact_id AND civicrm_ 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 @@ LEFT JOIN civicrm_email ON (contact_a.id = civicrm_email.contact_id AND civicrm_ * @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 @@ LEFT JOIN civicrm_email ON (contact_a.id = civicrm_email.contact_id AND civicrm_ */ 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 625b6b82df..cadd086e4c 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 @@ class CRM_Contact_BAO_SearchCustom { } $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 @@ class CRM_Contact_BAO_SearchCustom { // 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 @@ class CRM_Contact_BAO_SearchCustom { 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 @@ class CRM_Contact_BAO_SearchCustom { $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 @@ class CRM_Contact_BAO_SearchCustom { $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 5c29e67b1b..5f3ce8babc 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 @@ class CRM_Contact_Form_Contact extends CRM_Core_Form { $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 @@ class CRM_Contact_Form_Contact extends CRM_Core_Form { $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 @@ class CRM_Contact_Form_Contact extends CRM_Core_Form { ); $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 @@ class CRM_Contact_Form_Contact extends CRM_Core_Form { } 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 @@ class CRM_Contact_Form_Contact extends CRM_Core_Form { 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 @@ class CRM_Contact_Form_Contact extends CRM_Core_Form { $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 @@ class CRM_Contact_Form_Contact extends CRM_Core_Form { } // 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 @@ class CRM_Contact_Form_Contact extends CRM_Core_Form { 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 @@ class CRM_Contact_Form_Contact extends CRM_Core_Form { $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 @@ class CRM_Contact_Form_Contact extends CRM_Core_Form { 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 @@ class CRM_Contact_Form_Contact extends CRM_Core_Form { $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 @@ class CRM_Contact_Form_Contact extends CRM_Core_Form { 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 @@ class CRM_Contact_Form_Contact extends CRM_Core_Form { 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 @@ class CRM_Contact_Form_Contact extends CRM_Core_Form { 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 @@ class CRM_Contact_Form_Contact extends CRM_Core_Form { 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 @@ class CRM_Contact_Form_Contact extends CRM_Core_Form { $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 @@ class CRM_Contact_Form_Contact extends CRM_Core_Form { } // 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 @@ class CRM_Contact_Form_Contact extends CRM_Core_Form { 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 @@ class CRM_Contact_Form_Contact extends CRM_Core_Form { 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 @@ class CRM_Contact_Form_Contact extends CRM_Core_Form { $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 @@ class CRM_Contact_Form_Contact extends CRM_Core_Form { 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 @@ class CRM_Contact_Form_Contact extends CRM_Core_Form { $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 @@ class CRM_Contact_Form_Contact extends CRM_Core_Form { // 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 @@ class CRM_Contact_Form_Contact extends CRM_Core_Form { $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 @@ class CRM_Contact_Form_Contact extends CRM_Core_Form { return FALSE; } - static $skipFields = array( + static $skipFields = [ 'location_type_id', 'is_primary', 'phone_type_id', @@ -1109,7 +1109,7 @@ class CRM_Contact_Form_Contact extends CRM_Core_Form { 'country_id', 'website_type_id', 'master_id', - ); + ]; foreach ($fields as $name => $value) { $skipField = FALSE; foreach ($skipFields as $skip) { @@ -1154,27 +1154,27 @@ class CRM_Contact_Form_Contact extends CRM_Core_Form { // 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 @@ class CRM_Contact_Form_Contact extends CRM_Core_Form { * 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 @@ class CRM_Contact_Form_Contact extends CRM_Core_Form { 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 @@ class CRM_Contact_Form_Contact extends CRM_Core_Form { $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 @@ class CRM_Contact_Form_Contact extends CRM_Core_Form { return $statusMsg; } - $parseFails = array(); + $parseFails = []; foreach ($parseResult as $instance => $success) { if (!$success) { $parseFails[] = self::ordinalNumber($instance); @@ -1362,7 +1362,7 @@ class CRM_Contact_Form_Contact extends CRM_Core_Form { 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 @@ class CRM_Contact_Form_Contact extends CRM_Core_Form { ); // 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 @@ class CRM_Contact_Form_Contact extends CRM_Core_Form { '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 @@ class CRM_Contact_Form_Contact extends CRM_Core_Form { 'is_auto' => 0, 'is_current_revision' => 1, 'is_deleted' => 0, - ); + ]; $activityResult = civicrm_api('activity', 'create', $activityParam); $memCount++; @@ -1495,7 +1495,7 @@ class CRM_Contact_Form_Contact extends CRM_Core_Form { // 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 1b60d5f5b9..dadbeb75e7 100644 --- a/CRM/Contact/Form/CustomData.php +++ b/CRM/Contact/Form/CustomData.php @@ -135,7 +135,7 @@ class CRM_Contact_Form_CustomData extends CRM_Core_Form { $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 @@ class CRM_Contact_Form_CustomData extends CRM_Core_Form { 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 @@ class CRM_Contact_Form_CustomData extends CRM_Core_Form { // 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 @@ class CRM_Contact_Form_CustomData extends CRM_Core_Form { NULL, $this->_entityId, $this->_groupID, - array(), + [], NULL, TRUE, NULL, @@ -242,7 +242,7 @@ class CRM_Contact_Form_CustomData extends CRM_Core_Form { 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 @@ class CRM_Contact_Form_CustomData extends CRM_Core_Form { $this->assign('customValueCount', $customValueCount); - $defaults = array(); + $defaults = []; return $defaults; } diff --git a/CRM/Contact/Form/DedupeFind.php b/CRM/Contact/Form/DedupeFind.php index 999390ec5e..69e62a70c6 100644 --- a/CRM/Contact/Form/DedupeFind.php +++ b/CRM/Contact/Form/DedupeFind.php @@ -53,26 +53,26 @@ class CRM_Contact_Form_DedupeFind extends CRM_Admin_Form { */ 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 ee6483257e..4a8294f44e 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 @@ class CRM_Contact_Form_DedupeRules extends CRM_Admin_Form { $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 @@ class CRM_Contact_Form_DedupeRules extends CRM_Admin_Form { * 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 @@ class CRM_Contact_Form_DedupeRules extends CRM_Admin_Form { * 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 @@ UPDATE civicrm_dedupe_rule_group 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 @@ UPDATE civicrm_dedupe_rule_group // 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 @@ UPDATE civicrm_dedupe_rule_group $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 @@ UPDATE civicrm_dedupe_rule_group $ruleDao->free(); if (!array_key_exists($table, $tables)) { - $tables[$table] = array(); + $tables[$table] = []; } $tables[$table][] = $field; } @@ -277,7 +277,7 @@ UPDATE civicrm_dedupe_rule_group // 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 @@ UPDATE civicrm_dedupe_rule_group 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 @@ UPDATE civicrm_dedupe_rule_group 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 472bb00b09..dcd9eb9146 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 @@ class CRM_Contact_Form_Domain extends CRM_Core_Form { * */ public function setDefaultValues() { - $defaults = array(); - $params = array(); + $defaults = []; + $params = []; if (isset($this->_id)) { $params['id'] = $this->_id; @@ -120,7 +120,7 @@ class CRM_Contact_Form_Domain extends CRM_Core_Form { $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 @@ class CRM_Contact_Form_Domain extends CRM_Core_Form { * 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 @@ class CRM_Contact_Form_Domain extends CRM_Core_Form { * 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 @@ class CRM_Contact_Form_Domain extends CRM_Core_Form { // $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 @@ class CRM_Contact_Form_Domain extends CRM_Core_Form { $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 @@ class CRM_Contact_Form_Domain extends CRM_Core_Form { 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 2e91480071..2420f8bdda 100644 --- a/CRM/Contact/Form/Edit/Address.php +++ b/CRM/Contact/Form/Edit/Address.php @@ -58,40 +58,40 @@ class CRM_Contact_Form_Edit_Address { $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 @@ class CRM_Contact_Form_Edit_Address { 'street_number', 'street_name', 'street_unit', - ); + ]; foreach ($elements as $name) { //Remove id from name, to allow comparison against enabled addressOptions. @@ -117,11 +117,11 @@ class CRM_Contact_Form_Edit_Address { 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 @@ class CRM_Contact_Form_Edit_Address { $name = 'name'; } - $params = array('entity' => 'address'); + $params = ['entity' => 'address']; if ($name == 'postal_code_suffix') { $params['label'] = ts('Suffix'); @@ -183,10 +183,10 @@ class CRM_Contact_Form_Edit_Address { * @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 @@ class CRM_Contact_Form_Edit_Address { * 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 @@ class CRM_Contact_Form_Edit_Address { 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 @@ class CRM_Contact_Form_Edit_Address { // 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 @@ class CRM_Contact_Form_Edit_Address { $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 @@ class CRM_Contact_Form_Edit_Address { $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 @@ class CRM_Contact_Form_Edit_Address { * @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 @@ class CRM_Contact_Form_Edit_Address { } } - $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 @@ class CRM_Contact_Form_Edit_Address { $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 531a749d84..dddb5d58d3 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 @@ class CRM_Contact_Form_Edit_CommunicationPreferences { // 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 @@ class CRM_Contact_Form_Edit_CommunicationPreferences { $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 @@ class CRM_Contact_Form_Edit_CommunicationPreferences { //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 @@ class CRM_Contact_Form_Edit_CommunicationPreferences { $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 @@ class CRM_Contact_Form_Edit_CommunicationPreferences { */ 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 758233de48..0a2105a94a 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 6a4d1bdc7d..91ddeffea0 100644 --- a/CRM/Contact/Form/Edit/Email.php +++ b/CRM/Contact/Form/Edit/Email.php @@ -58,38 +58,38 @@ class CRM_Contact_Form_Edit_Email { $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 @@ class CRM_Contact_Form_Edit_Email { 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 c09c3d1a60..1d9fc60fdf 100644 --- a/CRM/Contact/Form/Edit/Household.php +++ b/CRM/Contact/Form/Edit/Household.php @@ -58,15 +58,15 @@ class CRM_Contact_Form_Edit_Household { 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 @@ class CRM_Contact_Form_Edit_Household { * $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 242426e4f9..78781d8c22 100644 --- a/CRM/Contact/Form/Edit/IM.php +++ b/CRM/Contact/Form/Edit/IM.php @@ -56,14 +56,14 @@ class CRM_Contact_Form_Edit_IM { $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 3534dca7c8..d39c7d95e8 100644 --- a/CRM/Contact/Form/Edit/Individual.php +++ b/CRM/Contact/Form/Edit/Individual.php @@ -69,10 +69,10 @@ class CRM_Contact_Form_Edit_Individual { } 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 @@ class CRM_Contact_Form_Edit_Individual { // 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 @@ class CRM_Contact_Form_Edit_Individual { * 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 c2746fe956..c844b8cea5 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 @@ class CRM_Contact_Form_Edit_Lock { * 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 a23078fb12..d926847685 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 1f3f70d457..2d4ab2ca0c 100644 --- a/CRM/Contact/Form/Edit/OpenID.php +++ b/CRM/Contact/Form/Edit/OpenID.php @@ -64,7 +64,7 @@ class CRM_Contact_Form_Edit_OpenID { $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 b2fbc22b2c..05ae544a4f 100644 --- a/CRM/Contact/Form/Edit/Organization.php +++ b/CRM/Contact/Form/Edit/Organization.php @@ -68,11 +68,11 @@ class CRM_Contact_Form_Edit_Organization { } 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 @@ class CRM_Contact_Form_Edit_Organization { * @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 d7e2b72d93..0a881f3f95 100644 --- a/CRM/Contact/Form/Edit/Phone.php +++ b/CRM/Contact/Form/Edit/Phone.php @@ -58,25 +58,25 @@ class CRM_Contact_Form_Edit_Phone { $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 2622b78958..b89c3a023e 100644 --- a/CRM/Contact/Form/Edit/TagsAndGroups.php +++ b/CRM/Contact/Form/Edit/TagsAndGroups.php @@ -73,7 +73,7 @@ class CRM_Contact_Form_Edit_TagsAndGroups { $groupElementType = 'checkbox' ) { if (!isset($form->_tagGroup)) { - $form->_tagGroup = array(); + $form->_tagGroup = []; } // NYSS 5670 @@ -91,7 +91,7 @@ class CRM_Contact_Form_Edit_TagsAndGroups { $groupID = isset($form->_grid) ? $form->_grid : NULL; if ($groupID && $visibility) { - $ids = array($groupID => $groupID); + $ids = [$groupID => $groupID]; } else { if ($visibility) { @@ -107,8 +107,8 @@ class CRM_Contact_Form_Edit_TagsAndGroups { $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 @@ class CRM_Contact_Form_Edit_TagsAndGroups { 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 @@ class CRM_Contact_Form_Edit_TagsAndGroups { $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 @@ class CRM_Contact_Form_Edit_TagsAndGroups { $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 fb798a044a..8930e9956c 100644 --- a/CRM/Contact/Form/Edit/Website.php +++ b/CRM/Contact/Form/Edit/Website.php @@ -55,10 +55,10 @@ class CRM_Contact_Form_Edit_Website { $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 0a628244af..5221210918 100644 --- a/CRM/Contact/Form/GroupContact.php +++ b/CRM/Contact/Form/GroupContact.php @@ -83,7 +83,7 @@ class CRM_Contact_Form_GroupContact extends CRM_Core_Form { $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 @@ class CRM_Contact_Form_GroupContact extends CRM_Core_Form { $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 @@ class CRM_Contact_Form_GroupContact extends CRM_Core_Form { $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 @@ class CRM_Contact_Form_GroupContact extends CRM_Core_Form { * 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 @@ class CRM_Contact_Form_GroupContact extends CRM_Core_Form { 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 dbf6413cfd..541cf814c6 100644 --- a/CRM/Contact/Form/Inline.php +++ b/CRM/Contact/Form/Inline.php @@ -96,17 +96,17 @@ abstract class CRM_Contact_Form_Inline extends CRM_Core_Form { 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 @@ abstract class CRM_Contact_Form_Inline extends CRM_Core_Form { * Override default cancel action. */ public function cancelAction() { - $response = array('status' => 'cancel'); + $response = ['status' => 'cancel']; CRM_Utils_JSON::output($response); } @@ -124,7 +124,7 @@ abstract class CRM_Contact_Form_Inline extends CRM_Core_Form { * @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 @@ abstract class CRM_Contact_Form_Inline extends CRM_Core_Form { '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 ed07ea6983..3bbd2d28a9 100644 --- a/CRM/Contact/Form/Inline/Address.php +++ b/CRM/Contact/Form/Inline/Address.php @@ -87,12 +87,12 @@ class CRM_Contact_Form_Inline_Address extends CRM_Contact_Form_Inline { $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 @@ class CRM_Contact_Form_Inline_Address extends CRM_Contact_Form_Inline { 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 8f4b3358b6..adbc82f079 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 d33eae9863..55f1a1ddc8 100644 --- a/CRM/Contact/Form/Inline/ContactInfo.php +++ b/CRM/Contact/Form/Inline/ContactInfo.php @@ -73,9 +73,9 @@ class CRM_Contact_Form_Inline_ContactInfo extends CRM_Contact_Form_Inline { 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 3a9a6db30e..2458683ff2 100644 --- a/CRM/Contact/Form/Inline/ContactName.php +++ b/CRM/Contact/Form/Inline/ContactName.php @@ -45,7 +45,7 @@ class CRM_Contact_Form_Inline_ContactName extends CRM_Contact_Form_Inline { // 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 @@ class CRM_Contact_Form_Inline_ContactName extends CRM_Contact_Form_Inline { 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 2440f8bb3c..f7595e051c 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 @@ class CRM_Contact_Form_Inline_Email extends CRM_Contact_Form_Inline { 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 @@ class CRM_Contact_Form_Inline_Email extends CRM_Contact_Form_Inline { * @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 @@ class CRM_Contact_Form_Inline_Email extends CRM_Contact_Form_Inline { * @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 @@ class CRM_Contact_Form_Inline_Email extends CRM_Contact_Form_Inline { 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 991443c593..a44fbb3c45 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 @@ class CRM_Contact_Form_Inline_IM extends CRM_Contact_Form_Inline { 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 @@ class CRM_Contact_Form_Inline_IM extends CRM_Contact_Form_Inline { * @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 @@ class CRM_Contact_Form_Inline_IM extends CRM_Contact_Form_Inline { * @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 3fa0a5ab47..62c94420f5 100644 --- a/CRM/Contact/Form/Inline/Lock.php +++ b/CRM/Contact/Form/Inline/Lock.php @@ -53,8 +53,8 @@ class CRM_Contact_Form_Inline_Lock { // - 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 @@ class CRM_Contact_Form_Inline_Lock { * 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 @@ class CRM_Contact_Form_Inline_Lock { */ 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 a225e3a81e..55b9f1b227 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 @@ class CRM_Contact_Form_Inline_OpenID extends CRM_Contact_Form_Inline { 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 @@ class CRM_Contact_Form_Inline_OpenID extends CRM_Contact_Form_Inline { * @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 @@ class CRM_Contact_Form_Inline_OpenID extends CRM_Contact_Form_Inline { * @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 9d46c70eee..1ee20388ab 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 @@ class CRM_Contact_Form_Inline_Phone extends CRM_Contact_Form_Inline { 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 @@ class CRM_Contact_Form_Inline_Phone extends CRM_Contact_Form_Inline { * @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 @@ class CRM_Contact_Form_Inline_Phone extends CRM_Contact_Form_Inline { * @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 afab6f5679..0491e745ce 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 @@ class CRM_Contact_Form_Inline_Website extends CRM_Contact_Form_Inline { 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 @@ class CRM_Contact_Form_Inline_Website extends CRM_Contact_Form_Inline { 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 @@ class CRM_Contact_Form_Inline_Website extends CRM_Contact_Form_Inline { * @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 @@ class CRM_Contact_Form_Inline_Website extends CRM_Contact_Form_Inline { * @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 8218001d63..0f3bd5c63b 100644 --- a/CRM/Contact/Form/Location.php +++ b/CRM/Contact/Form/Location.php @@ -51,11 +51,11 @@ class CRM_Contact_Form_Location { 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 @@ class CRM_Contact_Form_Location { */ 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 cbb1c3a8e8..6dc3475ef0 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 @@ class CRM_Contact_Form_Merge extends CRM_Core_Form { 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 @@ class CRM_Contact_Form_Merge extends CRM_Core_Form { $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 @@ class CRM_Contact_Form_Merge extends CRM_Core_Form { $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 @@ class CRM_Contact_Form_Merge extends CRM_Core_Form { // 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 @@ class CRM_Contact_Form_Merge extends CRM_Core_Form { 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 @@ class CRM_Contact_Form_Merge extends CRM_Core_Form { * @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 @@ class CRM_Contact_Form_Merge extends CRM_Core_Form { $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 @@ class CRM_Contact_Form_Merge extends CRM_Core_Form { } 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 @@ class CRM_Contact_Form_Merge extends CRM_Core_Form { // 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 086852d9f3..ad21672bee 100644 --- a/CRM/Contact/Form/RelatedContact.php +++ b/CRM/Contact/Form/RelatedContact.php @@ -80,7 +80,7 @@ class CRM_Contact_Form_RelatedContact extends CRM_Core_Form { $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 @@ class CRM_Contact_Form_RelatedContact extends CRM_Core_Form { * 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 @@ class CRM_Contact_Form_RelatedContact extends CRM_Core_Form { 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 @@ class CRM_Contact_Form_RelatedContact extends CRM_Core_Form { $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 @@ class CRM_Contact_Form_RelatedContact extends CRM_Core_Form { // 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 ee3a24d0f5..686a371c2b 100644 --- a/CRM/Contact/Form/Relationship.php +++ b/CRM/Contact/Form/Relationship.php @@ -132,14 +132,14 @@ class CRM_Contact_Form_Relationship extends CRM_Core_Form { $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 @@ class CRM_Contact_Form_Relationship extends CRM_Core_Form { // 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 @@ class CRM_Contact_Form_Relationship extends CRM_Core_Form { } //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 @@ class CRM_Contact_Form_Relationship extends CRM_Core_Form { * 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 @@ class CRM_Contact_Form_Relationship extends CRM_Core_Form { $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 @@ class CRM_Contact_Form_Relationship extends CRM_Core_Form { */ 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 @@ class CRM_Contact_Form_Relationship extends CRM_Core_Form { */ 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 @@ class CRM_Contact_Form_Relationship extends CRM_Core_Form { $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 @@ class CRM_Contact_Form_Relationship extends CRM_Core_Form { $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 @@ class CRM_Contact_Form_Relationship extends CRM_Core_Form { 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 @@ class CRM_Contact_Form_Relationship extends CRM_Core_Form { $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 @@ class CRM_Contact_Form_Relationship extends CRM_Core_Form { * 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 @@ class CRM_Contact_Form_Relationship extends CRM_Core_Form { */ 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 @@ class CRM_Contact_Form_Relationship extends CRM_Core_Form { 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 @@ class CRM_Contact_Form_Relationship extends CRM_Core_Form { 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 @@ class CRM_Contact_Form_Relationship extends CRM_Core_Form { 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 @@ class CRM_Contact_Form_Relationship extends CRM_Core_Form { $this->setMessage($outcome); - return array($params, $relationshipIds); + return [$params, $relationshipIds]; } @@ -595,7 +595,7 @@ class CRM_Contact_Form_Relationship extends CRM_Core_Form { $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 @@ class CRM_Contact_Form_Relationship extends CRM_Core_Form { */ 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 @@ class CRM_Contact_Form_Relationship extends CRM_Core_Form { * @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 fc389c6087..4671db0ec8 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 @@ class CRM_Contact_Form_Search extends CRM_Core_Form_Search { */ 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 @@ class CRM_Contact_Form_Search extends CRM_Core_Form_Search { 'builder' => 'Search Builder', 'advanced' => 'Advanced Search', 'custom' => 'Custom Search', - ); + ]; } return self::$_validContext; } @@ -199,8 +199,8 @@ class CRM_Contact_Form_Search extends CRM_Core_Form_Search { } 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 @@ class CRM_Contact_Form_Search extends CRM_Core_Form_Search { '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 @@ class CRM_Contact_Form_Search extends CRM_Core_Form_Search { '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 @@ class CRM_Contact_Form_Search extends CRM_Core_Form_Search { '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 @@ class CRM_Contact_Form_Search extends CRM_Core_Form_Search { '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 @@ class CRM_Contact_Form_Search extends CRM_Core_Form_Search { '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 @@ class CRM_Contact_Form_Search extends CRM_Core_Form_Search { '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 @@ class CRM_Contact_Form_Search extends CRM_Core_Form_Search { '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 @@ class CRM_Contact_Form_Search extends CRM_Core_Form_Search { 'resultContext' => 'Search', 'taskClassName' => 'CRM_Mailing_Task', 'component' => 'CiviMail', - ), - ); + ], + ]; } /** @@ -330,7 +330,7 @@ class CRM_Contact_Form_Search extends CRM_Core_Form_Search { 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 @@ class CRM_Contact_Form_Search extends CRM_Core_Form_Search { $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 @@ class CRM_Contact_Form_Search extends CRM_Core_Form_Search { } // 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 @@ class CRM_Contact_Form_Search extends CRM_Core_Form_Search { } // 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 @@ class CRM_Contact_Form_Search extends CRM_Core_Form_Search { } // 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 @@ class CRM_Contact_Form_Search extends CRM_Core_Form_Search { // 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 @@ class CRM_Contact_Form_Search extends CRM_Core_Form_Search { '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 @@ class CRM_Contact_Form_Search extends CRM_Core_Form_Search { // 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 c68343686f..cdfc0c71ba 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 @@ class CRM_Contact_Form_Search_Basic extends CRM_Contact_Form_Search { ); 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 @@ class CRM_Contact_Form_Search_Basic extends CRM_Contact_Form_Search { // 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 @@ class CRM_Contact_Form_Search_Basic extends CRM_Contact_Form_Search { * 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 @@ class CRM_Contact_Form_Search_Basic extends CRM_Contact_Form_Search { * 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 @@ class CRM_Contact_Form_Search_Basic extends CRM_Contact_Form_Search { // 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 @@ class CRM_Contact_Form_Search_Basic extends CRM_Contact_Form_Search { 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 10f06b104f..a1322ee1b8 100644 --- a/CRM/Contact/Form/Search/Builder.php +++ b/CRM/Contact/Form/Search/Builder.php @@ -91,7 +91,7 @@ class CRM_Contact_Form_Search_Builder extends CRM_Contact_Form_Search { */ 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 @@ class CRM_Contact_Form_Search_Builder extends CRM_Contact_Form_Search { // 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 @@ class CRM_Contact_Form_Search_Builder extends CRM_Contact_Form_Search { * 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 @@ class CRM_Contact_Form_Search_Builder extends CRM_Contact_Form_Search { $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 @@ class CRM_Contact_Form_Search_Builder extends CRM_Contact_Form_Search { // 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 @@ class CRM_Contact_Form_Search_Builder extends CRM_Contact_Form_Search { $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 @@ class CRM_Contact_Form_Search_Builder extends CRM_Contact_Form_Search { } // 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 @@ class CRM_Contact_Form_Search_Builder extends CRM_Contact_Form_Search { // 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 @@ class CRM_Contact_Form_Search_Builder extends CRM_Contact_Form_Search { 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 @@ class CRM_Contact_Form_Search_Builder extends CRM_Contact_Form_Search { 'member_is_test' => 'yesno', 'member_is_pay_later' => 'yesno', 'is_override' => 'yesno', - ); - $entities = array( + ]; + $entities = [ 'contact', 'address', 'activity', @@ -461,7 +461,7 @@ class CRM_Contact_Form_Search_Builder extends CRM_Contact_Form_Search { '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 @@ class CRM_Contact_Form_Search_Builder extends CRM_Contact_Form_Search { } } 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 7862472f7f..10e61cb3a8 100644 --- a/CRM/Contact/Form/Search/Criteria.php +++ b/CRM/Contact/Form/Search/Criteria.php @@ -43,7 +43,7 @@ class CRM_Contact_Form_Search_Criteria { 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 @@ class CRM_Contact_Form_Search_Criteria { $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 @@ class CRM_Contact_Form_Search_Criteria { 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 @@ class CRM_Contact_Form_Search_Criteria { 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 @@ class CRM_Contact_Form_Search_Criteria { } $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 @@ class CRM_Contact_Form_Search_Criteria { $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 @@ class CRM_Contact_Form_Search_Criteria { // 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 @@ class CRM_Contact_Form_Search_Criteria { $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 @@ class CRM_Contact_Form_Search_Criteria { 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 @@ class CRM_Contact_Form_Search_Criteria { '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 @@ class CRM_Contact_Form_Search_Criteria { 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 @@ class CRM_Contact_Form_Search_Criteria { $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 @@ class CRM_Contact_Form_Search_Criteria { 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 @@ class CRM_Contact_Form_Search_Criteria { $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 @@ class CRM_Contact_Form_Search_Criteria { } 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 @@ class CRM_Contact_Form_Search_Criteria { // 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 @@ class CRM_Contact_Form_Search_Criteria { 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 @@ class CRM_Contact_Form_Search_Criteria { 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 @@ class CRM_Contact_Form_Search_Criteria { 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 @@ class CRM_Contact_Form_Search_Criteria { 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 @@ class CRM_Contact_Form_Search_Criteria { */ 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 1c7e4d4f8c..afda78618c 100644 --- a/CRM/Contact/Form/Search/Custom/ActivitySearch.php +++ b/CRM/Contact/Form/Search/Custom/ActivitySearch.php @@ -47,7 +47,7 @@ class CRM_Contact_Form_Search_Custom_ActivitySearch extends CRM_Contact_Form_Sea /** * 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 @@ class CRM_Contact_Form_Search_Custom_ActivitySearch extends CRM_Contact_Form_Sea 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 @@ class CRM_Contact_Form_Search_Custom_ActivitySearch extends CRM_Contact_Form_Sea ); // 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 @@ class CRM_Contact_Form_Search_Custom_ActivitySearch extends CRM_Contact_Form_Sea ); // 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 @@ class CRM_Contact_Form_Search_Custom_ActivitySearch extends CRM_Contact_Form_Sea ); // 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 @@ class CRM_Contact_Form_Search_Custom_ActivitySearch extends CRM_Contact_Form_Sea * 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 @@ class CRM_Contact_Form_Search_Custom_ActivitySearch extends CRM_Contact_Form_Sea 'start_date', 'end_date', 'sort_name', - )); + ]); } /** @@ -296,7 +296,7 @@ ORDER BY contact_a.sort_name'; * @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 @@ ORDER BY contact_a.sort_name'; } 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 @@ ORDER BY contact_a.sort_name'; * @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 5ecf0738ab..b4edd5986d 100644 --- a/CRM/Contact/Form/Search/Custom/Base.php +++ b/CRM/Contact/Form/Search/Custom/Base.php @@ -153,7 +153,7 @@ class CRM_Contact_Form_Search_Custom_Base { * @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 @@ class CRM_Contact_Form_Search_Custom_Base { * @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 @@ class CRM_Contact_Form_Search_Custom_Base { 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 e497591e37..9968ce95c8 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 @@ class CRM_Contact_Form_Search_Custom_Basic extends CRM_Contact_Form_Search_Custo 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 @@ class CRM_Contact_Form_Search_Custom_Basic extends CRM_Contact_Form_Search_Custo ); 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 @@ class CRM_Contact_Form_Search_Custom_Basic extends CRM_Contact_Form_Search_Custo * @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 db0809ab07..3263889090 100644 --- a/CRM/Contact/Form/Search/Custom/ContribSYBNT.php +++ b/CRM/Contact/Form/Search/Custom/ContribSYBNT.php @@ -46,32 +46,32 @@ class CRM_Contact_Form_Search_Custom_ContribSYBNT extends CRM_Contact_Form_Searc $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 @@ class CRM_Contact_Form_Search_Custom_ContribSYBNT extends CRM_Contact_Form_Searc } 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 @@ count(contrib_1.id) AS donation_count * @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 @@ count(contrib_1.id) AS donation_count $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 @@ count(contrib_1.id) AS donation_count $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 @@ AND c.receive_date < {$this->start_date_1} * @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 @@ AND c.receive_date < {$this->start_date_1} * @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 65b1c859dc..f776f8448e 100644 --- a/CRM/Contact/Form/Search/Custom/ContributionAggregate.php +++ b/CRM/Contact/Form/Search/Custom/ContributionAggregate.php @@ -46,12 +46,12 @@ class CRM_Contact_Form_Search_Custom_ContributionAggregate extends CRM_Contact_F $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 @@ class CRM_Contact_Form_Search_Custom_ContributionAggregate extends CRM_Contact_F 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 @@ civicrm_contact AS contact_a {$this->_aclFrom} * @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 @@ civicrm_contact AS contact_a {$this->_aclFrom} } 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 @@ civicrm_contact AS contact_a {$this->_aclFrom} * @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 fb6f378bf3..14916ac877 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 @@ class CRM_Contact_Form_Search_Custom_DateAdded extends CRM_Contact_Form_Search_C * 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 @@ class CRM_Contact_Form_Search_Custom_DateAdded extends CRM_Contact_Form_Search_C $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 @@ class CRM_Contact_Form_Search_Custom_DateAdded extends CRM_Contact_Form_Search_C // 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 @@ class CRM_Contact_Form_Search_Custom_DateAdded extends CRM_Contact_Form_Search_C * @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 9b3973145e..004e080c28 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 @@ class CRM_Contact_Form_Search_Custom_EventAggregate extends CRM_Contact_Form_Sea ts('Fee') => 'fee', ts('Net Payment') => 'net_payment', ts('Participant') => 'participant', - ); + ]; } /** @@ -83,7 +83,7 @@ class CRM_Contact_Form_Search_Custom_EventAggregate extends CRM_Contact_Form_Sea $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 @@ class CRM_Contact_Form_Search_Custom_EventAggregate extends CRM_Contact_Form_Sea * 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 @@ class CRM_Contact_Form_Search_Custom_EventAggregate extends CRM_Contact_Form_Sea * @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 @@ class CRM_Contact_Form_Search_Custom_EventAggregate extends CRM_Contact_Form_Sea } 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 @@ class CRM_Contact_Form_Search_Custom_EventAggregate extends CRM_Contact_Form_Sea $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 @@ class CRM_Contact_Form_Search_Custom_EventAggregate extends CRM_Contact_Form_Sea * @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 44c0f399be..43dad2e26e 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 @@ class CRM_Contact_Form_Search_Custom_FullText extends CRM_Contact_Form_Search_Cu $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 @@ class CRM_Contact_Form_Search_Custom_FullText extends CRM_Contact_Form_Search_Cu $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 @@ class CRM_Contact_Form_Search_Custom_FullText extends CRM_Contact_Form_Search_Cu $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 @@ class CRM_Contact_Form_Search_Custom_FullText extends CRM_Contact_Form_Search_Cu // 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 @@ class CRM_Contact_Form_Search_Custom_FullText extends CRM_Contact_Form_Search_Cu CRM_Contact_BAO_Contact_Permission::cache($contactID); - $params = array(1 => array($contactID, 'Integer')); + $params = [1 => [$contactID, 'Integer']]; $sql = " DELETE t.* @@ -301,7 +301,7 @@ WHERE t.table_name = 'Activity' AND ); // 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 @@ WHERE t.table_name = 'Activity' AND // set form defaults if (!empty($form->_formValues)) { - $defaults = array(); + $defaults = []; if (isset($form->_formValues['text'])) { $defaults['text'] = $form->_formValues['text']; @@ -345,10 +345,10 @@ WHERE t.table_name = 'Activity' AND * @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 @@ WHERE t.table_name = 'Activity' AND 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 @@ WHERE t.table_name = 'Activity' AND $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 @@ WHERE t.table_name = 'Activity' AND } 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 @@ WHERE t.table_name = 'Activity' AND $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 @@ FROM {$this->_tableName} contact_a * @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 9cd6252184..2e3c9ade0c 100644 --- a/CRM/Contact/Form/Search/Custom/FullText/AbstractPartialQuery.php +++ b/CRM/Contact/Form/Search/Custom/FullText/AbstractPartialQuery.php @@ -121,10 +121,10 @@ AND cf.html_type IN ( 'Text', 'TextArea', 'RichTextEditor' ) $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 @@ $sqlStatement 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 @@ $sqlStatement } } 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 @@ GROUP BY {$tableValues['id']} } } - return array( + return [ 'count' => CRM_Core_DAO::singleValueQuery("SELECT count(*) FROM {$entityIDTableName}"), 'files' => $files, - ); + ]; } /** @@ -277,16 +277,16 @@ GROUP BY {$tableValues['id']} 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 @@ GROUP BY {$tableValues['id']} 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 @@ GROUP BY {$tableValues['id']} 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 350edb67a5..9af565f7bb 100644 --- a/CRM/Contact/Form/Search/Custom/FullText/Activity.php +++ b/CRM/Contact/Form/Search/Custom/FullText/Activity.php @@ -71,7 +71,7 @@ class CRM_Contact_Form_Search_Custom_FullText_Activity extends CRM_Contact_Form_ 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 @@ LEFT JOIN civicrm_email e ON cat.contact_id = e.contact_id 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 @@ GROUP BY et.entity_id $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 b774974079..bf3f7eede7 100644 --- a/CRM/Contact/Form/Search/Custom/FullText/Case.php +++ b/CRM/Contact/Form/Search/Custom/FullText/Case.php @@ -74,14 +74,14 @@ class CRM_Contact_Form_Search_Custom_FullText_Case extends CRM_Contact_Form_Sear 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 @@ AND ({$this->matchText('civicrm_tag t', 'name', $queryText)}) 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 375509e12d..4930e99cd1 100644 --- a/CRM/Contact/Form/Search/Custom/FullText/Contact.php +++ b/CRM/Contact/Form/Search/Custom/FullText/Contact.php @@ -70,7 +70,7 @@ class CRM_Contact_Form_Search_Custom_FullText_Contact extends CRM_Contact_Form_S 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 @@ GROUP BY et.entity_id // 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 b6e0345ba1..758dcedfc3 100644 --- a/CRM/Contact/Form/Search/Custom/FullText/Contribution.php +++ b/CRM/Contact/Form/Search/Custom/FullText/Contribution.php @@ -74,38 +74,38 @@ class CRM_Contact_Form_Search_Custom_FullText_Contribution extends CRM_Contact_F 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 926b5bb873..f81694b6cf 100644 --- a/CRM/Contact/Form/Search/Custom/FullText/Membership.php +++ b/CRM/Contact/Form/Search/Custom/FullText/Membership.php @@ -75,23 +75,23 @@ class CRM_Contact_Form_Search_Custom_FullText_Membership extends CRM_Contact_For 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 ad1da5af19..20bbbd3e4d 100644 --- a/CRM/Contact/Form/Search/Custom/FullText/Participant.php +++ b/CRM/Contact/Form/Search/Custom/FullText/Participant.php @@ -75,35 +75,35 @@ class CRM_Contact_Form_Search_Custom_FullText_Participant extends CRM_Contact_Fo 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 b4fb09717a..76c7efbc36 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 @@ class CRM_Contact_Form_Search_Custom_Group extends CRM_Contact_Form_Search_Custo $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 @@ class CRM_Contact_Form_Search_Custom_Group extends CRM_Contact_Form_Search_Custo $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 @@ class CRM_Contact_Form_Search_Custom_Group extends CRM_Contact_Form_Search_Custo * 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 @@ class CRM_Contact_Form_Search_Custom_Group extends CRM_Contact_Form_Search_Custo $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 @@ WHERE gcc.group_id = {$ssGroup->id} /* * 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 @@ WHERE gcc.group_id = {$ssGroup->id} } } $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 @@ WHERE gcc.group_id = {$ssGroup->id} */ 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 e6ace98635..2737366bdb 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 @@ class CRM_Contact_Form_Search_Custom_MultipleValues extends CRM_Contact_Form_Sea $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 @@ class CRM_Contact_Form_Search_Custom_MultipleValues extends CRM_Contact_Form_Sea * 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 @@ class CRM_Contact_Form_Search_Custom_MultipleValues extends CRM_Contact_Form_Sea 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 @@ class CRM_Contact_Form_Search_Custom_MultipleValues extends CRM_Contact_Form_Sea $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 @@ contact_a.sort_name as sort_name, "; } - $customClauses = array(); + $customClauses = []; foreach ($this->_tables as $tableName => $fields) { foreach ($fields as $fieldID => $fieldName) { $customClauses[] = "{$tableName}.{$fieldName} as custom_{$fieldID}"; @@ -198,7 +198,7 @@ contact_a.sort_name as sort_name, 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 @@ contact_a.sort_name as sort_name, */ 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 @@ contact_a.sort_name as sort_name, 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 17c9a8c2f1..865740f7de 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 @@ class CRM_Contact_Form_Search_Custom_PostalMailing extends CRM_Contact_Form_Sear // 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 @@ LEFT JOIN civicrm_state_province state_province ON state_province.id = address. * @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 f62b8e010d..3253fffb81 100644 --- a/CRM/Contact/Form/Search/Custom/PriceSet.php +++ b/CRM/Contact/Form/Search/Custom/PriceSet.php @@ -81,11 +81,11 @@ CREATE TEMPORARY TABLE {$this->_tableName} ( "; 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 @@ ORDER BY c.id, l.price_field_value_id; $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 @@ WHERE p.entity_table = 'civicrm_event' 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 @@ AND p.entity_id = e.id public function buildForm(&$form) { $dao = $this->priceSetDAO(); - $event = array(); + $event = []; while ($dao->fetch()) { $event[$dao->id] = $dao->title; } @@ -221,15 +221,15 @@ AND p.entity_id = e.id * 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 @@ contact_a.id as contact_id , 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 f1742af37b..4d382d46fa 100644 --- a/CRM/Contact/Form/Search/Custom/Proximity.php +++ b/CRM/Contact/Form/Search/Custom/Proximity.php @@ -74,14 +74,14 @@ class CRM_Contact_Form_Search_Custom_Proximity extends CRM_Contact_Form_Search_C $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 @@ class CRM_Contact_Form_Search_Custom_Proximity extends CRM_Contact_Form_Search_C $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 @@ class CRM_Contact_Form_Search_Custom_Proximity extends CRM_Contact_Form_Search_C 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 @@ class CRM_Contact_Form_Search_Custom_Proximity extends CRM_Contact_Form_Search_C * 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 @@ class CRM_Contact_Form_Search_Custom_Proximity extends CRM_Contact_Form_Search_C 'state_province_id', 'group', 'tag', - )); + ]); } /** @@ -275,7 +275,7 @@ class CRM_Contact_Form_Search_Custom_Proximity extends CRM_Contact_Form_Search_C $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 391ed0ec50..57e45eb016 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 @@ class CRM_Contact_Form_Search_Custom_RandomSegment extends CRM_Contact_Form_Sear $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 @@ class CRM_Contact_Form_Search_Custom_RandomSegment extends CRM_Contact_Form_Sear * 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 @@ class CRM_Contact_Form_Search_Custom_RandomSegment extends CRM_Contact_Form_Sear $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 5e12d8a8cf..197985fd94 100644 --- a/CRM/Contact/Form/Search/Custom/Sample.php +++ b/CRM/Contact/Form/Search/Custom/Sample.php @@ -48,12 +48,12 @@ class CRM_Contact_Form_Search_Custom_Sample extends CRM_Contact_Form_Search_Cust } } - $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 @@ class CRM_Contact_Form_Search_Custom_Sample extends CRM_Contact_Form_Search_Cust 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 @@ class CRM_Contact_Form_Search_Custom_Sample extends CRM_Contact_Form_Search_Cust * 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 @@ LEFT JOIN civicrm_state_province state_province ON state_province.id = address.s * @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 @@ LEFT JOIN civicrm_state_province state_province ON state_province.id = address.s 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 @@ LEFT JOIN civicrm_state_province state_province ON state_province.id = address.s } if ($state) { - $params[$count] = array($state, 'Integer'); + $params[$count] = [$state, 'Integer']; $clause[] = "state_province.id = %{$count}"; } @@ -211,7 +211,7 @@ LEFT JOIN civicrm_state_province state_province ON state_province.id = address.s * @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 579032c716..123de6f387 100644 --- a/CRM/Contact/Form/Search/Custom/TagContributions.php +++ b/CRM/Contact/Form/Search/Custom/TagContributions.php @@ -49,14 +49,14 @@ class CRM_Contact_Form_Search_Custom_TagContributions extends CRM_Contact_Form_S /** * 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 @@ class CRM_Contact_Form_Search_Custom_TagContributions extends CRM_Contact_Form_S * 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 @@ WHERE $where * @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 @@ WHERE $where } 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 @@ WHERE $where * @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 386080b480..0ffa0ee4f0 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 @@ class CRM_Contact_Form_Search_Custom_ZipCodeRange extends CRM_Contact_Form_Searc ts('Name') => 'sort_name', ts('Email') => 'email', ts('Zip') => 'postal_code', - ); + ]; } /** @@ -81,14 +81,14 @@ class CRM_Contact_Form_Search_Custom_ZipCodeRange extends CRM_Contact_Form_Searc * 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 @@ LEFT JOIN civicrm_email email ON ( email.contact_id = contact_a.id AND * @return string */ public function where($includeContactIDs = FALSE) { - $params = array(); + $params = []; $low = CRM_Utils_Array::value('postal_code_low', $this->_formValues @@ -179,10 +179,10 @@ LEFT JOIN civicrm_email email ON ( email.contact_id = contact_a.id AND } $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 857d1b22b0..76a875ee38 100644 --- a/CRM/Contact/Form/Task.php +++ b/CRM/Contact/Form/Task.php @@ -98,8 +98,8 @@ class CRM_Contact_Form_Task extends CRM_Core_Form_Task { * @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 @@ class CRM_Contact_Form_Task extends CRM_Core_Form_Task { $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 @@ class CRM_Contact_Form_Task extends CRM_Core_Form_Task { $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 @@ class CRM_Contact_Form_Task extends CRM_Core_Form_Task { 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 @@ class CRM_Contact_Form_Task extends CRM_Core_Form_Task { // 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 @@ class CRM_Contact_Form_Task extends CRM_Core_Form_Task { $queryOperator ); - $contactIds = array(); + $contactIds = []; while ($dao->fetch()) { $contactIds[$dao->contact_id] = $dao->contact_id; } @@ -341,7 +341,7 @@ class CRM_Contact_Form_Task extends CRM_Core_Form_Task { * @return array */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; return $defaults; } @@ -377,18 +377,18 @@ class CRM_Contact_Form_Task extends CRM_Core_Form_Task { * @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 @@ class CRM_Contact_Form_Task extends CRM_Core_Form_Task { // 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 @@ class CRM_Contact_Form_Task extends CRM_Core_Form_Task { // 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 @@ class CRM_Contact_Form_Task extends CRM_Core_Form_Task { $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 @@ class CRM_Contact_Form_Task extends CRM_Core_Form_Task { $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 @@ class CRM_Contact_Form_Task extends CRM_Core_Form_Task { 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 f8f665105d..c14badd652 100644 --- a/CRM/Contact/Form/Task/AddToGroup.php +++ b/CRM/Contact/Form/Task/AddToGroup.php @@ -77,16 +77,16 @@ class CRM_Contact_Form_Task_AddToGroup extends CRM_Contact_Form_Task { 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 @@ class CRM_Contact_Form_Task_AddToGroup extends CRM_Contact_Form_Task { } // 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 @@ class CRM_Contact_Form_Task_AddToGroup extends CRM_Contact_Form_Task { $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 @@ class CRM_Contact_Form_Task_AddToGroup extends CRM_Contact_Form_Task { * the default array reference */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; if ($this->_context === 'amtg') { $defaults['group_id'] = $this->_id; @@ -162,7 +162,7 @@ class CRM_Contact_Form_Task_AddToGroup extends CRM_Contact_Form_Task { * 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 @@ class CRM_Contact_Form_Task_AddToGroup extends CRM_Contact_Form_Task { * 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 @@ class CRM_Contact_Form_Task_AddToGroup extends CRM_Contact_Form_Task { $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 @@ class CRM_Contact_Form_Task_AddToGroup extends CRM_Contact_Form_Task { 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 bfa6c63309..729b86838f 100644 --- a/CRM/Contact/Form/Task/AddToParentClass.php +++ b/CRM/Contact/Form/Task/AddToParentClass.php @@ -46,22 +46,22 @@ class CRM_Contact_Form_Task_AddToParentClass extends CRM_Contact_Form_Task { 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 @@ class CRM_Contact_Form_Task_AddToParentClass extends CRM_Contact_Form_Task { $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 @@ class CRM_Contact_Form_Task_AddToParentClass extends CRM_Contact_Form_Task { 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 @@ class CRM_Contact_Form_Task_AddToParentClass extends CRM_Contact_Form_Task { $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 @@ class CRM_Contact_Form_Task_AddToParentClass extends CRM_Contact_Form_Task { */ 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 @@ class CRM_Contact_Form_Task_AddToParentClass extends CRM_Contact_Form_Task { $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 @@ class CRM_Contact_Form_Task_AddToParentClass extends CRM_Contact_Form_Task { $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 b7e2e4c068..c296641ac6 100644 --- a/CRM/Contact/Form/Task/AddToTag.php +++ b/CRM/Contact/Form/Task/AddToTag.php @@ -72,7 +72,7 @@ class CRM_Contact_Form_Task_AddToTag extends CRM_Contact_Form_Task { } public function addRules() { - $this->addFormRule(array('CRM_Contact_Form_Task_AddToTag', 'formRule')); + $this->addFormRule(['CRM_Contact_Form_Task_AddToTag', 'formRule']); } /** @@ -82,7 +82,7 @@ class CRM_Contact_Form_Task_AddToTag extends CRM_Contact_Form_Task { * @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 @@ class CRM_Contact_Form_Task_AddToTag extends CRM_Contact_Form_Task { 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 @@ class CRM_Contact_Form_Task_AddToTag extends CRM_Contact_Form_Task { // 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 aed844fa76..cd596f0c98 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 @@ class CRM_Contact_Form_Task_AlterPreferences extends CRM_Contact_Form_Task { } public function addRules() { - $this->addFormRule(array('CRM_Contact_Form_Task_AlterPreferences', 'formRule')); + $this->addFormRule(['CRM_Contact_Form_Task_AlterPreferences', 'formRule']); } /** @@ -68,7 +68,7 @@ class CRM_Contact_Form_Task_AlterPreferences extends CRM_Contact_Form_Task { * the default array reference */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; $defaults['actionTypeOption'] = 0; return $defaults; @@ -81,7 +81,7 @@ class CRM_Contact_Form_Task_AlterPreferences extends CRM_Contact_Form_Task { * @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 @@ class CRM_Contact_Form_Task_AlterPreferences extends CRM_Contact_Form_Task { } // 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 3e2b50ccbe..cea1787a06 100644 --- a/CRM/Contact/Form/Task/Batch.php +++ b/CRM/Contact/Form/Task/Batch.php @@ -88,7 +88,7 @@ class CRM_Contact_Form_Task_Batch extends CRM_Contact_Form_Task { // 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 @@ class CRM_Contact_Form_Task_Batch extends CRM_Contact_Form_Task { //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 @@ class CRM_Contact_Form_Task_Batch extends CRM_Contact_Form_Task { // 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 @@ class CRM_Contact_Form_Task_Batch extends CRM_Contact_Form_Task { 'prefix_id', 'suffix_id', 'household_name', - ); + ]; foreach ($this->_contactIds as $contactId) { $profileFields = $this->_fields; @@ -151,7 +151,7 @@ class CRM_Contact_Form_Task_Batch extends CRM_Contact_Form_Task { } $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 @@ class CRM_Contact_Form_Task_Batch extends CRM_Contact_Form_Task { 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 @@ class CRM_Contact_Form_Task_Batch extends CRM_Contact_Form_Task { * 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 @@ class CRM_Contact_Form_Task_Batch extends CRM_Contact_Form_Task { 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 @@ class CRM_Contact_Form_Task_Batch extends CRM_Contact_Form_Task { 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 b9401dc367..1c0b5c71e5 100644 --- a/CRM/Contact/Form/Task/Delete.php +++ b/CRM/Contact/Form/Task/Delete.php @@ -89,7 +89,7 @@ class CRM_Contact_Form_Task_Delete extends CRM_Contact_Form_Task { 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 @@ class CRM_Contact_Form_Task_Delete extends CRM_Contact_Form_Task { $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 @@ class CRM_Contact_Form_Task_Delete extends CRM_Contact_Form_Task { } } - $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 @@ class CRM_Contact_Form_Task_Delete extends CRM_Contact_Form_Task { $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 @@ class CRM_Contact_Form_Task_Delete extends CRM_Contact_Form_Task { */ 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 @@ class CRM_Contact_Form_Task_Delete extends CRM_Contact_Form_Task { // 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 @@ class CRM_Contact_Form_Task_Delete extends CRM_Contact_Form_Task { $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 @@ class CRM_Contact_Form_Task_Delete extends CRM_Contact_Form_Task { } $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 034f294c7e..d8dd851e33 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 @@ class CRM_Contact_Form_Task_Email extends CRM_Contact_Form_Task { // 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 @@ class CRM_Contact_Form_Task_Email extends CRM_Contact_Form_Task { 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 2ed6b570e4..a93a92a7ed 100644 --- a/CRM/Contact/Form/Task/HookSample.php +++ b/CRM/Contact/Form/Task/HookSample.php @@ -54,15 +54,15 @@ WHERE e.contact_id = c.id 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 bbd4cc7c44..674d1d1ad3 100644 --- a/CRM/Contact/Form/Task/Label.php +++ b/CRM/Contact/Form/Task/Label.php @@ -62,13 +62,13 @@ class CRM_Contact_Form_Task_Label extends CRM_Contact_Form_Task { //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 @@ class CRM_Contact_Form_Task_Label extends CRM_Contact_Form_Task { $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 @@ class CRM_Contact_Form_Task_Label extends CRM_Contact_Form_Task { * 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 @@ class CRM_Contact_Form_Task_Label extends CRM_Contact_Form_Task { } //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 @@ class CRM_Contact_Form_Task_Label extends CRM_Contact_Form_Task { 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 @@ class CRM_Contact_Form_Task_Label extends CRM_Contact_Form_Task { } //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 @@ class CRM_Contact_Form_Task_Label extends CRM_Contact_Form_Task { '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 @@ class CRM_Contact_Form_Task_Label extends CRM_Contact_Form_Task { $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 @@ class CRM_Contact_Form_Task_Label extends CRM_Contact_Form_Task { 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 @@ class CRM_Contact_Form_Task_Label extends CRM_Contact_Form_Task { 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 @@ class CRM_Contact_Form_Task_Label extends CRM_Contact_Form_Task { } $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 62a0013f24..d9cb705283 100644 --- a/CRM/Contact/Form/Task/LabelCommon.php +++ b/CRM/Contact/Form/Task/LabelCommon.php @@ -80,21 +80,21 @@ class CRM_Contact_Form_Task_LabelCommon { */ 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 @@ class CRM_Contact_Form_Task_LabelCommon { } //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 @@ class CRM_Contact_Form_Task_LabelCommon { $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 @@ class CRM_Contact_Form_Task_LabelCommon { $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 @@ class CRM_Contact_Form_Task_LabelCommon { } } // sigh couldn't extract out tokenfields yet - return array($rows, $tokenFields); + return [$rows, $tokenFields]; } /** @@ -269,7 +269,7 @@ class CRM_Contact_Form_Task_LabelCommon { */ 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 @@ class CRM_Contact_Form_Task_LabelCommon { */ 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 5d8d2947f3..f22d59d122 100644 --- a/CRM/Contact/Form/Task/Map.php +++ b/CRM/Contact/Form/Task/Map.php @@ -67,7 +67,7 @@ class CRM_Contact_Form_Task_Map extends CRM_Contact_Form_Task { $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 @@ class CRM_Contact_Form_Task_Map extends CRM_Contact_Form_Task { * Build the form object. */ public function buildQuickForm() { - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'done', 'name' => ts('Done'), 'isDefault' => TRUE, - ), - ) + ], + ] ); } @@ -221,14 +221,14 @@ class CRM_Contact_Form_Task_Map extends CRM_Contact_Form_Task { } } - $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 2b914eee5e..80359da7af 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 @@ class CRM_Contact_Form_Task_Merge extends CRM_Contact_Form_Task { } // 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 b84f420604..67f42d2c30 100644 --- a/CRM/Contact/Form/Task/PDF.php +++ b/CRM/Contact/Form/Task/PDF.php @@ -88,9 +88,9 @@ class CRM_Contact_Form_Task_PDF extends CRM_Contact_Form_Task { * 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 04ca1101a9..b52b24d767 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 @@ class CRM_Contact_Form_Task_PDFLetterCommon extends CRM_Core_Form_Task_PDFLetter */ 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 @@ class CRM_Contact_Form_Task_PDFLetterCommon extends CRM_Core_Form_Task_PDFLetter $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 @@ class CRM_Contact_Form_Task_PDFLetterCommon extends CRM_Core_Form_Task_PDFLetter $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 @@ class CRM_Contact_Form_Task_PDFLetterCommon extends CRM_Core_Form_Task_PDFLetter $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 @@ class CRM_Contact_Form_Task_PDFLetterCommon extends CRM_Core_Form_Task_PDFLetter 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 @@ class CRM_Contact_Form_Task_PDFLetterCommon extends CRM_Core_Form_Task_PDFLetter 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 @@ class CRM_Contact_Form_Task_PDFLetterCommon extends CRM_Core_Form_Task_PDFLetter * * @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 @@ class CRM_Contact_Form_Task_PDFLetterCommon extends CRM_Core_Form_Task_PDFLetter 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 @@ class CRM_Contact_Form_Task_PDFLetterCommon extends CRM_Core_Form_Task_PDFLetter * @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 @@ class CRM_Contact_Form_Task_PDFLetterCommon extends CRM_Core_Form_Task_PDFLetter */ 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 2fdc1bdca2..875d3ae1d4 100644 --- a/CRM/Contact/Form/Task/PickProfile.php +++ b/CRM/Contact/Form/Task/PickProfile.php @@ -71,10 +71,10 @@ class CRM_Contact_Form_Task_PickProfile extends CRM_Contact_Form_Task { $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 @@ class CRM_Contact_Form_Task_PickProfile extends CRM_Contact_Form_Task { 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 @@ class CRM_Contact_Form_Task_PickProfile extends CRM_Contact_Form_Task { * 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 aeff179f3b..8040df3e5d 100644 --- a/CRM/Contact/Form/Task/Print.php +++ b/CRM/Contact/Form/Task/Print.php @@ -53,13 +53,13 @@ class CRM_Contact_Form_Task_Print extends CRM_Contact_Form_Task { //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 @@ class CRM_Contact_Form_Task_Print extends CRM_Contact_Form_Task { // // 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 79e21da02d..19d2bd37f0 100644 --- a/CRM/Contact/Form/Task/ProximityCommon.php +++ b/CRM/Contact/Form/Task/ProximityCommon.php @@ -74,18 +74,18 @@ class CRM_Contact_Form_Task_ProximityCommon { $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 @@ class CRM_Contact_Form_Task_ProximityCommon { * 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 @@ class CRM_Contact_Form_Task_ProximityCommon { * 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 ba8cc9f111..5df58cc48f 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 @@ class CRM_Contact_Form_Task_RemoveFromGroup extends CRM_Contact_Form_Task { * 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 @@ class CRM_Contact_Form_Task_RemoveFromGroup extends CRM_Contact_Form_Task { 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 3d5025ccdb..d88a15b59f 100644 --- a/CRM/Contact/Form/Task/RemoveFromTag.php +++ b/CRM/Contact/Form/Task/RemoveFromTag.php @@ -67,7 +67,7 @@ class CRM_Contact_Form_Task_RemoveFromTag extends CRM_Contact_Form_Task { } public function addRules() { - $this->addFormRule(array('CRM_Contact_Form_Task_RemoveFromTag', 'formRule')); + $this->addFormRule(['CRM_Contact_Form_Task_RemoveFromTag', 'formRule']); } /** @@ -77,7 +77,7 @@ class CRM_Contact_Form_Task_RemoveFromTag extends CRM_Contact_Form_Task { * @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 @@ class CRM_Contact_Form_Task_RemoveFromTag extends CRM_Contact_Form_Task { //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 @@ class CRM_Contact_Form_Task_RemoveFromTag extends CRM_Contact_Form_Task { // 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 41a66dd5f0..3222cf410a 100644 --- a/CRM/Contact/Form/Task/Result.php +++ b/CRM/Contact/Form/Task/Result.php @@ -46,10 +46,10 @@ class CRM_Contact_Form_Task_Result extends CRM_Contact_Form_Task { $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 @@ class CRM_Contact_Form_Task_Result extends CRM_Contact_Form_Task { * 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 f4d304affd..d6802158a1 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 @@ class CRM_Contact_Form_Task_SMSCommon { } 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 @@ class CRM_Contact_Form_Task_SMSCommon { */ 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 @@ class CRM_Contact_Form_Task_SMSCommon { $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 @@ class CRM_Contact_Form_Task_SMSCommon { } // 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 @@ class CRM_Contact_Form_Task_SMSCommon { 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 @@ class CRM_Contact_Form_Task_SMSCommon { 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 @@ class CRM_Contact_Form_Task_SMSCommon { } if ($phone) { - $toArray[] = array( + $toArray[] = [ 'text' => '"' . $value['sort_name'] . '" (' . $phone . ')', 'id' => "$contactId::{$phone}", - ); + ]; } } @@ -294,7 +294,7 @@ class CRM_Contact_Form_Task_SMSCommon { $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 @@ class CRM_Contact_Form_Task_SMSCommon { * 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 @@ class CRM_Contact_Form_Task_SMSCommon { $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 @@ class CRM_Contact_Form_Task_SMSCommon { // 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 @@ class CRM_Contact_Form_Task_SMSCommon { } // 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 @@ class CRM_Contact_Form_Task_SMSCommon { ); 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 @@ class CRM_Contact_Form_Task_SMSCommon { $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 @@ class CRM_Contact_Form_Task_SMSCommon { } $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 87133586c6..f871162a34 100644 --- a/CRM/Contact/Form/Task/SaveSearch.php +++ b/CRM/Contact/Form/Task/SaveSearch.php @@ -138,7 +138,7 @@ class CRM_Contact_Form_Task_SaveSearch extends CRM_Contact_Form_Task { $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 @@ class CRM_Contact_Form_Task_SaveSearch extends CRM_Contact_Form_Task { 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 @@ class CRM_Contact_Form_Task_SaveSearch extends CRM_Contact_Form_Task { $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 @@ class CRM_Contact_Form_Task_SaveSearch extends CRM_Contact_Form_Task { // 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 @@ class CRM_Contact_Form_Task_SaveSearch extends CRM_Contact_Form_Task { * 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 703af1422b..4d6e7446a7 100644 --- a/CRM/Contact/Form/Task/SaveSearch/Update.php +++ b/CRM/Contact/Form/Task/SaveSearch/Update.php @@ -57,10 +57,10 @@ class CRM_Contact_Form_Task_SaveSearch_Update extends CRM_Contact_Form_Task_Save */ 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 3da999ed31..0f51395bc2 100644 --- a/CRM/Contact/Form/Task/Unhold.php +++ b/CRM/Contact/Form/Task/Unhold.php @@ -27,15 +27,15 @@ WHERE on_hold = 1 AND hold_date is not null AND contact_id in (" . implode(",", $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 4fe0b7af12..303fee2ad5 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 @@ class CRM_Contact_Form_Task_Useradd extends CRM_Core_Form { * 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 @@ class CRM_Contact_Form_Task_Useradd extends CRM_Core_Form { */ 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 b73a8a43d1..b483639ce7 100644 --- a/CRM/Contact/Import/Controller.php +++ b/CRM/Contact/Import/Controller.php @@ -54,7 +54,7 @@ class CRM_Contact_Import_Controller extends CRM_Core_Controller { // 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 ddecff176e..0c8f1061bc 100644 --- a/CRM/Contact/Import/Form/DataSource.php +++ b/CRM/Contact/Import/Form/DataSource.php @@ -61,10 +61,10 @@ class CRM_Contact_Import_Form_DataSource extends CRM_Core_Form { 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 @@ class CRM_Contact_Import_Form_DataSource extends CRM_Core_Form { } 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 @@ class CRM_Contact_Import_Form_DataSource extends CRM_Core_Form { $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 @@ class CRM_Contact_Import_Form_DataSource extends CRM_Core_Form { $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 @@ class CRM_Contact_Import_Form_DataSource extends CRM_Core_Form { } $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 @@ class CRM_Contact_Import_Form_DataSource extends CRM_Core_Form { */ 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 @@ class CRM_Contact_Import_Form_DataSource extends CRM_Core_Form { // 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 @@ class CRM_Contact_Import_Form_DataSource extends CRM_Core_Form { 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 @@ class CRM_Contact_Import_Form_DataSource extends CRM_Core_Form { // 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 @@ class CRM_Contact_Import_Form_DataSource extends CRM_Core_Form { // 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 @@ class CRM_Contact_Import_Form_DataSource extends CRM_Core_Form { 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 2baf9b11f3..811b3f62e2 100644 --- a/CRM/Contact/Import/Form/Summary.php +++ b/CRM/Contact/Import/Form/Summary.php @@ -96,7 +96,7 @@ class CRM_Contact_Import_Form_Summary extends CRM_Import_Form_Summary { $this->assign('dupeActionString', $dupeActionString); - $properties = array( + $properties = [ 'totalRowCount', 'validRowCount', 'invalidRowCount', @@ -110,7 +110,7 @@ class CRM_Contact_Import_Form_Summary extends CRM_Import_Form_Summary { '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 6c9e880343..94a9e0afd3 100644 --- a/CRM/Contact/Import/Page/AJAX.php +++ b/CRM/Contact/Import/Page/AJAX.php @@ -53,7 +53,7 @@ class CRM_Contact_Import_Page_AJAX { } 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 fd1f644da7..114986d8e7 100644 --- a/CRM/Contact/Import/Parser.php +++ b/CRM/Contact/Import/Parser.php @@ -140,17 +140,17 @@ abstract class CRM_Contact_Import_Parser extends CRM_Import_Parser { $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 @@ abstract class CRM_Contact_Import_Parser extends CRM_Import_Parser { 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 @@ abstract class CRM_Contact_Import_Parser extends CRM_Import_Parser { 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 @@ abstract class CRM_Contact_Import_Parser extends CRM_Import_Parser { 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 @@ abstract class CRM_Contact_Import_Parser extends CRM_Import_Parser { * (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 @@ abstract class CRM_Contact_Import_Parser extends CRM_Import_Parser { 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 @@ abstract class CRM_Contact_Import_Parser extends CRM_Import_Parser { $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 @@ abstract class CRM_Contact_Import_Parser extends CRM_Import_Parser { //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 @@ abstract class CRM_Contact_Import_Parser extends CRM_Import_Parser { 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 @@ abstract class CRM_Contact_Import_Parser extends CRM_Import_Parser { $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 @@ abstract class CRM_Contact_Import_Parser extends CRM_Import_Parser { * @return array */ public function getColumnPatterns() { - $values = array(); + $values = []; foreach ($this->_fields as $name => $field) { $values[$name] = $field->_columnPattern; } @@ -682,8 +682,8 @@ abstract class CRM_Contact_Import_Parser extends CRM_Import_Parser { 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 @@ abstract class CRM_Contact_Import_Parser extends CRM_Import_Parser { } $data = $errorValues; - $output = array(); + $output = []; $fd = fopen($fileName, 'w'); foreach ($header as $key => $value) { @@ -733,11 +733,11 @@ abstract class CRM_Contact_Import_Parser extends CRM_Import_Parser { 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 @@ abstract class CRM_Contact_Import_Parser extends CRM_Import_Parser { * 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 @@ abstract class CRM_Contact_Import_Parser extends CRM_Import_Parser { $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 @@ abstract class CRM_Contact_Import_Parser extends CRM_Import_Parser { } } - $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 @@ abstract class CRM_Contact_Import_Parser extends CRM_Import_Parser { 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 @@ abstract class CRM_Contact_Import_Parser extends CRM_Import_Parser { // 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 @@ abstract class CRM_Contact_Import_Parser extends CRM_Import_Parser { // 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 @@ abstract class CRM_Contact_Import_Parser extends CRM_Import_Parser { 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 @@ abstract class CRM_Contact_Import_Parser extends CRM_Import_Parser { 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 @@ abstract class CRM_Contact_Import_Parser extends CRM_Import_Parser { } 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 @@ abstract class CRM_Contact_Import_Parser extends CRM_Import_Parser { if (!array_key_exists('website', $params) || !is_array($params['website']) ) { - $params['website'] = array(); + $params['website'] = []; } $websiteCount = count($params['website']); @@ -1135,13 +1135,13 @@ abstract class CRM_Contact_Import_Parser extends CRM_Import_Parser { // 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 @@ abstract class CRM_Contact_Import_Parser extends CRM_Import_Parser { // 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 @@ abstract class CRM_Contact_Import_Parser extends CRM_Import_Parser { 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 @@ abstract class CRM_Contact_Import_Parser extends CRM_Import_Parser { // 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 @@ abstract class CRM_Contact_Import_Parser extends CRM_Import_Parser { // 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 @@ abstract class CRM_Contact_Import_Parser extends CRM_Import_Parser { 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 @@ abstract class CRM_Contact_Import_Parser extends CRM_Import_Parser { _civicrm_api3_store_values($fields['Address'], $values, $params['address'][$values['location_type_id']]); - $addressFields = array( + $addressFields = [ 'county', 'country', 'state_province', @@ -1251,12 +1251,12 @@ abstract class CRM_Contact_Import_Parser extends CRM_Import_Parser { '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 @@ abstract class CRM_Contact_Import_Parser extends CRM_Import_Parser { 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 @@ abstract class CRM_Contact_Import_Parser extends CRM_Import_Parser { 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 1c5fd1069c..08bc64789f 100644 --- a/CRM/Contact/Import/Parser/Contact.php +++ b/CRM/Contact/Import/Parser/Contact.php @@ -182,18 +182,18 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { } 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 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { 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 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { 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 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { $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 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { $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 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { 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 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { $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 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { /* 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 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { 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 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { //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 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { */ 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 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { $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 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { } //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 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { // 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 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { $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 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { 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 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { 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 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { // 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 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { $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 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { $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 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { 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 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { //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 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { $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 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { 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 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { $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 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { $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 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { //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 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { //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 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { $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 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { // 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 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { $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 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { } // 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 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { // 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 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { //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 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { // 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 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { } // 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 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { } } // 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 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { $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 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { 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 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { //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 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { $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 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { 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 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { 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 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { $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 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { 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 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { } 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 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { */ 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 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { $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 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { $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 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { } 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 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { * @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 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { 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 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { } } } - $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 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { } 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 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser { * @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 16b493e3a0..db7dca4ab7 100644 --- a/CRM/Contact/Page/AJAX.php +++ b/CRM/Contact/Page/AJAX.php @@ -56,20 +56,20 @@ class CRM_Contact_Page_AJAX { $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 @@ class CRM_Contact_Page_AJAX { '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 @@ class CRM_Contact_Page_AJAX { 's', 'q', 'action', - ); + ]; foreach ($_GET as $param => $val) { if (empty($val) || in_array($param, $excludeGet) || @@ -139,15 +139,15 @@ class CRM_Contact_Page_AJAX { 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 @@ class CRM_Contact_Page_AJAX { "; $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 @@ class CRM_Contact_Page_AJAX { CRM_Utils_System::permissionDenied(); } - $ret = array('is_error' => 0); + $ret = ['is_error' => 0]; list($relTypeId, $b, $a) = explode('_', $relType); @@ -285,9 +285,9 @@ class CRM_Contact_Page_AJAX { */ 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 @@ class CRM_Contact_Page_AJAX { * 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 @@ class CRM_Contact_Page_AJAX { || $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 @@ class CRM_Contact_Page_AJAX { } if ($queryString) { - $result = array(); + $result = []; $offset = CRM_Utils_Array::value('offset', $_GET, 0); $rowCount = Civi::settings()->get('search_autocomplete_count'); @@ -430,10 +430,10 @@ LIMIT {$offset}, {$rowCount} $dao = CRM_Core_DAO::executeQuery($query); while ($dao->fetch()) { - $result[] = array( + $result[] = [ 'id' => $dao->id, 'text' => $dao->name, - ); + ]; } } else { @@ -457,10 +457,10 @@ LIMIT {$offset}, {$rowCount} 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 @@ LIMIT {$offset}, {$rowCount} } 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 @@ LIMIT {$offset}, {$rowCount} $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 @@ LIMIT {$offset}, {$rowCount} $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 @@ LIMIT {$offset}, {$rowCount} $status = $exception->delete(); } - CRM_Utils_JSON::output(array('status' => ($status) ? $oper : $status)); + CRM_Utils_JSON::output(['status' => ($status) ? $oper : $status]); } /** @@ -662,18 +662,18 @@ LIMIT {$offset}, {$rowCount} $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 @@ LIMIT {$offset}, {$rowCount} '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 @@ LIMIT {$offset}, {$rowCount} } $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 @@ LIMIT {$offset}, {$rowCount} '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 @@ LIMIT {$offset}, {$rowCount} $count++; } - $dupePairs = array( + $dupePairs = [ 'data' => $searchRows, 'recordsTotal' => $iTotal, 'recordsFiltered' => $iFilteredTotal, - ); + ]; if (!empty($_REQUEST['is_unit_test'])) { return $dupePairs; } @@ -857,10 +857,10 @@ LIMIT {$offset}, {$rowCount} * @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 @@ LIMIT {$offset}, {$rowCount} 'conflicts', 'weight', 'actions', - ); + ]; $columns = $_REQUEST['columns']; foreach ($columns as $column) { @@ -984,7 +984,7 @@ LIMIT {$offset}, {$rowCount} $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 @@ LIMIT {$offset}, {$rowCount} $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 @@ LIMIT {$offset}, {$rowCount} $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 @@ LIMIT {$offset}, {$rowCount} 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 b4ccd6948a..e1f4749c25 100644 --- a/CRM/Contact/Page/CustomSearch.php +++ b/CRM/Contact/Page/CustomSearch.php @@ -60,7 +60,7 @@ ORDER By v.weight 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 bd4ad15347..3444e1ae99 100644 --- a/CRM/Contact/Page/Dashlet.php +++ b/CRM/Contact/Page/Dashlet.php @@ -49,23 +49,23 @@ class CRM_Contact_Page_Dashlet extends CRM_Core_Page { // 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 8b47b516e4..ea612da891 100644 --- a/CRM/Contact/Page/DedupeException.php +++ b/CRM/Contact/Page/DedupeException.php @@ -53,26 +53,26 @@ class CRM_Contact_Page_DedupeException extends CRM_Core_Page { * @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 @@ class CRM_Contact_Page_DedupeException extends CRM_Core_Page { $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 a8e70a37dc..56eba2c984 100644 --- a/CRM/Contact/Page/DedupeFind.php +++ b/CRM/Contact/Page/DedupeFind.php @@ -101,13 +101,13 @@ class CRM_Contact_Page_DedupeFind extends CRM_Core_Page_Basic { } $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 @@ class CRM_Contact_Page_DedupeFind extends CRM_Core_Page_Basic { 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 @@ class CRM_Contact_Page_DedupeFind extends CRM_Core_Page_Basic { 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 @@ class CRM_Contact_Page_DedupeFind extends CRM_Core_Page_Basic { 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 01b5d3a60e..45064446bb 100644 --- a/CRM/Contact/Page/DedupeMerge.php +++ b/CRM/Contact/Page/DedupeMerge.php @@ -60,14 +60,14 @@ class CRM_Contact_Page_DedupeMerge extends CRM_Core_Page { $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 @@ class CRM_Contact_Page_DedupeMerge extends CRM_Core_Page { 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 @@ class CRM_Contact_Page_DedupeMerge extends CRM_Core_Page { 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 @@ class CRM_Contact_Page_DedupeMerge extends CRM_Core_Page { 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 8570988d34..73573cd384 100644 --- a/CRM/Contact/Page/DedupeRules.php +++ b/CRM/Contact/Page/DedupeRules.php @@ -60,30 +60,30 @@ class CRM_Contact_Page_DedupeRules extends CRM_Core_Page_Basic { $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 @@ class CRM_Contact_Page_DedupeRules extends CRM_Core_Page_Basic { */ 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 @@ class CRM_Contact_Page_DedupeRules extends CRM_Core_Page_Basic { $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 @@ class CRM_Contact_Page_DedupeRules extends CRM_Core_Page_Basic { $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 50e740edf4..9ea30c409b 100644 --- a/CRM/Contact/Page/ImageFile.php +++ b/CRM/Contact/Page/ImageFile.php @@ -50,9 +50,9 @@ class CRM_Contact_Page_ImageFile extends CRM_Core_Page { // 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 9b65080967..10257bd464 100644 --- a/CRM/Contact/Page/Inline/Address.php +++ b/CRM/Contact/Page/Inline/Address.php @@ -47,11 +47,11 @@ class CRM_Contact_Page_Inline_Address extends CRM_Core_Page { $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 @@ class CRM_Contact_Page_Inline_Address extends CRM_Core_Page { 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 @@ class CRM_Contact_Page_Inline_Address extends CRM_Core_Page { $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 3f3757470b..c6d480a902 100644 --- a/CRM/Contact/Page/Inline/CommunicationPreferences.php +++ b/CRM/Contact/Page/Inline/CommunicationPreferences.php @@ -45,9 +45,9 @@ class CRM_Contact_Page_Inline_CommunicationPreferences extends CRM_Core_Page { // 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 fb8b2969ea..3435e19356 100644 --- a/CRM/Contact/Page/Inline/ContactInfo.php +++ b/CRM/Contact/Page/Inline/ContactInfo.php @@ -45,9 +45,9 @@ class CRM_Contact_Page_Inline_ContactInfo extends CRM_Core_Page { // 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 7d9afb7a02..39b4d424f2 100644 --- a/CRM/Contact/Page/Inline/Demographics.php +++ b/CRM/Contact/Page/Inline/Demographics.php @@ -45,9 +45,9 @@ class CRM_Contact_Page_Inline_Demographics extends CRM_Core_Page { // 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 f70792e34e..9a257e1a3b 100644 --- a/CRM/Contact/Page/Inline/Email.php +++ b/CRM/Contact/Page/Inline/Email.php @@ -45,9 +45,9 @@ class CRM_Contact_Page_Inline_Email extends CRM_Core_Page { // 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 @@ class CRM_Contact_Page_Inline_Email extends CRM_Core_Page { $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 045922fe6d..8b0fd8d52c 100644 --- a/CRM/Contact/Page/Inline/IM.php +++ b/CRM/Contact/Page/Inline/IM.php @@ -45,10 +45,10 @@ class CRM_Contact_Page_Inline_IM extends CRM_Core_Page { // 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 22dbec1a42..b20baf6e5d 100644 --- a/CRM/Contact/Page/Inline/OpenID.php +++ b/CRM/Contact/Page/Inline/OpenID.php @@ -45,9 +45,9 @@ class CRM_Contact_Page_Inline_OpenID extends CRM_Core_Page { // 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 dc22002ccf..4e78071fe3 100644 --- a/CRM/Contact/Page/Inline/Phone.php +++ b/CRM/Contact/Page/Inline/Phone.php @@ -45,10 +45,10 @@ class CRM_Contact_Page_Inline_Phone extends CRM_Core_Page { // 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 @@ class CRM_Contact_Page_Inline_Phone extends CRM_Core_Page { $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 5cf4a59c74..929ec1e509 100644 --- a/CRM/Contact/Page/Inline/Website.php +++ b/CRM/Contact/Page/Inline/Website.php @@ -47,7 +47,7 @@ class CRM_Contact_Page_Inline_Website extends CRM_Core_Page { $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 72d890c746..128b22239e 100644 --- a/CRM/Contact/Page/SavedSearch.php +++ b/CRM/Contact/Page/SavedSearch.php @@ -70,14 +70,14 @@ class CRM_Contact_Page_SavedSearch extends CRM_Core_Page { * 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 @@ class CRM_Contact_Page_SavedSearch extends CRM_Core_Page { 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 @@ class CRM_Contact_Page_SavedSearch extends CRM_Core_Page { $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 @@ class CRM_Contact_Page_SavedSearch extends CRM_Core_Page { $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 b51c292b2c..ca01608a90 100644 --- a/CRM/Contact/Page/View.php +++ b/CRM/Contact/Page/View.php @@ -101,7 +101,7 @@ class CRM_Contact_Page_View extends CRM_Core_Page { // 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 @@ class CRM_Contact_Page_View extends CRM_Core_Page { $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 @@ class CRM_Contact_Page_View extends CRM_Core_Page { } 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 @@ class CRM_Contact_Page_View extends CRM_Core_Page { // 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 @@ class CRM_Contact_Page_View extends CRM_Core_Page { $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 @@ class CRM_Contact_Page_View extends CRM_Core_Page { } // 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 3ccfcbe6c1..d018f62402 100644 --- a/CRM/Contact/Page/View/ContactSmartGroup.php +++ b/CRM/Contact/Page/View/ContactSmartGroup.php @@ -46,7 +46,7 @@ class CRM_Contact_Page_View_ContactSmartGroup extends CRM_Core_Page { // 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 @@ class CRM_Contact_Page_View_ContactSmartGroup extends CRM_Core_Page { $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 6cd9220f8c..37983dab96 100644 --- a/CRM/Contact/Page/View/CustomData.php +++ b/CRM/Contact/Page/View/CustomData.php @@ -139,7 +139,7 @@ class CRM_Contact_Page_View_CustomData extends CRM_Core_Page { $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 78ee608f6c..88178d4b47 100644 --- a/CRM/Contact/Page/View/GroupContact.php +++ b/CRM/Contact/Page/View/GroupContact.php @@ -45,7 +45,7 @@ class CRM_Contact_Page_View_GroupContact extends CRM_Core_Page { // 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 @@ class CRM_Contact_Page_View_GroupContact extends CRM_Core_Page { 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 d59f20acae..493148f4db 100644 --- a/CRM/Contact/Page/View/Log.php +++ b/CRM/Contact/Page/View/Log.php @@ -55,15 +55,15 @@ class CRM_Contact_Page_View_Log extends CRM_Core_Page { $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 39fe00be8c..e118762fd8 100644 --- a/CRM/Contact/Page/View/Note.php +++ b/CRM/Contact/Page/View/Note.php @@ -57,7 +57,7 @@ class CRM_Contact_Page_View_Note extends CRM_Core_Page { $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 @@ class CRM_Contact_Page_View_Note extends CRM_Core_Page { $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 @@ class CRM_Contact_Page_View_Note extends CRM_Core_Page { $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 @@ class CRM_Contact_Page_View_Note extends CRM_Core_Page { $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 @@ class CRM_Contact_Page_View_Note extends CRM_Core_Page { $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 @@ class CRM_Contact_Page_View_Note extends CRM_Core_Page { 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 @@ class CRM_Contact_Page_View_Note extends CRM_Core_Page { */ 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 d6fd3193d0..7ebbd40427 100644 --- a/CRM/Contact/Page/View/Print.php +++ b/CRM/Contact/Page/View/Print.php @@ -55,9 +55,9 @@ class CRM_Contact_Page_View_Print extends CRM_Contact_Page_View_Summary { * 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 b9863de198..af3e6e0d6b 100644 --- a/CRM/Contact/Page/View/UserDashBoard.php +++ b/CRM/Contact/Page/View/UserDashBoard.php @@ -101,7 +101,7 @@ class CRM_Contact_Page_View_UserDashBoard extends CRM_Core_Page { $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 @@ class CRM_Contact_Page_View_UserDashBoard extends CRM_Core_Page { ) { $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 @@ class CRM_Contact_Page_View_UserDashBoard extends CRM_Core_Page { 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 @@ class CRM_Contact_Page_View_UserDashBoard extends CRM_Core_Page { 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 9e288fdec4..bbf06ec5cc 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 1736f0b20b..385958764e 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 @@ class CRM_Contact_Selector extends CRM_Core_Selector_Base implements CRM_Core_Se $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 @@ class CRM_Contact_Selector extends CRM_Core_Selector_Base implements CRM_Core_Se $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 @@ class CRM_Contact_Selector extends CRM_Core_Selector_Base implements CRM_Core_Se */ 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 @@ class CRM_Contact_Selector extends CRM_Core_Selector_Base implements CRM_Core_Se // 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 @@ class CRM_Contact_Selector extends CRM_Core_Selector_Base implements CRM_Core_Se $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 @@ class CRM_Contact_Selector extends CRM_Core_Selector_Base implements CRM_Core_Se 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 @@ class CRM_Contact_Selector extends CRM_Core_Selector_Base implements CRM_Core_Se $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 @@ class CRM_Contact_Selector extends CRM_Core_Selector_Base implements CRM_Core_Se $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 @@ class CRM_Contact_Selector extends CRM_Core_Selector_Base implements CRM_Core_Se // 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 @@ class CRM_Contact_Selector extends CRM_Core_Selector_Base implements CRM_Core_Se $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 @@ class CRM_Contact_Selector extends CRM_Core_Selector_Base implements CRM_Core_Se } // 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 @@ class CRM_Contact_Selector extends CRM_Core_Selector_Base implements CRM_Core_Se 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 @@ class CRM_Contact_Selector extends CRM_Core_Selector_Base implements CRM_Core_Se } $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 @@ class CRM_Contact_Selector extends CRM_Core_Selector_Base implements CRM_Core_Se //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 @@ class CRM_Contact_Selector extends CRM_Core_Selector_Base implements CRM_Core_Se $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 @@ class CRM_Contact_Selector extends CRM_Core_Selector_Base implements CRM_Core_Se ) { $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 @@ class CRM_Contact_Selector extends CRM_Core_Selector_Base implements CRM_Core_Se 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 @@ class CRM_Contact_Selector extends CRM_Core_Selector_Base implements CRM_Core_Se $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 @@ class CRM_Contact_Selector extends CRM_Core_Selector_Base implements CRM_Core_Se $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 @@ class CRM_Contact_Selector extends CRM_Core_Selector_Base implements CRM_Core_Se */ 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 @@ class CRM_Contact_Selector extends CRM_Core_Selector_Base implements CRM_Core_Se 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 @@ class CRM_Contact_Selector extends CRM_Core_Selector_Base implements CRM_Core_Se 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 @@ class CRM_Contact_Selector extends CRM_Core_Selector_Base implements CRM_Core_Se $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 @@ class CRM_Contact_Selector extends CRM_Core_Selector_Base implements CRM_Core_Se $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 @@ class CRM_Contact_Selector extends CRM_Core_Selector_Base implements CRM_Core_Se '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 @@ class CRM_Contact_Selector extends CRM_Core_Selector_Base implements CRM_Core_Se } } - 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 @@ class CRM_Contact_Selector extends CRM_Core_Selector_Base implements CRM_Core_Se * @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 c7498fd335..fa9d7ac463 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 @@ class CRM_Contact_Selector_Custom extends CRM_Contact_Selector { $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 @@ class CRM_Contact_Selector_Custom extends CRM_Contact_Selector { */ 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 @@ class CRM_Contact_Selector_Custom extends CRM_Contact_Selector { 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 @@ class CRM_Contact_Selector_Custom extends CRM_Contact_Selector { $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 @@ class CRM_Contact_Selector_Custom extends CRM_Contact_Selector { $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 @@ class CRM_Contact_Selector_Custom extends CRM_Contact_Selector { $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 @@ class CRM_Contact_Selector_Custom extends CRM_Contact_Selector { // 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 @@ class CRM_Contact_Selector_Custom extends CRM_Contact_Selector { 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 @@ class CRM_Contact_Selector_Custom extends CRM_Contact_Selector { 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 76d01e0826..97d8b375cd 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 b42e52b9c7..285e7987a7 100644 --- a/CRM/Contribute/ActionMapping/ByPage.php +++ b/CRM/Contribute/ActionMapping/ByPage.php @@ -102,7 +102,7 @@ class CRM_Contribute_ActionMapping_ByPage implements \Civi\ActionSchedule\Mappin * @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 @@ class CRM_Contribute_ActionMapping_ByPage implements \Civi\ActionSchedule\Mappin * @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 @@ class CRM_Contribute_ActionMapping_ByPage implements \Civi\ActionSchedule\Mappin * 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 @@ class CRM_Contribute_ActionMapping_ByPage implements \Civi\ActionSchedule\Mappin * Ex: array('assignee' => 'Activity Assignee'). */ public function getRecipientTypes() { - return array(); + return []; } /** @@ -163,7 +163,7 @@ class CRM_Contribute_ActionMapping_ByPage implements \Civi\ActionSchedule\Mappin * @see getRecipientTypes */ public function getRecipientListing($recipientType) { - return array(); + return []; } /** @@ -176,7 +176,7 @@ class CRM_Contribute_ActionMapping_ByPage implements \Civi\ActionSchedule\Mappin * 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 288148af50..8708ef3965 100644 --- a/CRM/Contribute/ActionMapping/ByType.php +++ b/CRM/Contribute/ActionMapping/ByType.php @@ -102,7 +102,7 @@ class CRM_Contribute_ActionMapping_ByType implements \Civi\ActionSchedule\Mappin * @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 @@ class CRM_Contribute_ActionMapping_ByType implements \Civi\ActionSchedule\Mappin * @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 @@ class CRM_Contribute_ActionMapping_ByType implements \Civi\ActionSchedule\Mappin * 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 @@ class CRM_Contribute_ActionMapping_ByType implements \Civi\ActionSchedule\Mappin * Ex: array('assignee' => 'Activity Assignee'). */ public function getRecipientTypes() { - return array( + return [ 'soft_credit_type' => ts('Soft Credit Role'), - ); + ]; } /** @@ -170,7 +170,7 @@ class CRM_Contribute_ActionMapping_ByType implements \Civi\ActionSchedule\Mappin return \CRM_Core_OptionGroup::values('soft_credit_type', FALSE, FALSE, FALSE, NULL, 'label', TRUE, FALSE, 'name'); default: - return array(); + return []; } } @@ -184,7 +184,7 @@ class CRM_Contribute_ActionMapping_ByType implements \Civi\ActionSchedule\Mappin * 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 03da0e1ba7..ebd162952e 100644 --- a/CRM/Contribute/BAO/Contribution/Utils.php +++ b/CRM/Contribute/BAO/Contribution/Utils.php @@ -100,12 +100,12 @@ class CRM_Contribute_BAO_Contribution_Utils { } 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 @@ class CRM_Contribute_BAO_Contribution_Utils { 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 @@ class CRM_Contribute_BAO_Contribution_Utils { 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 @@ class CRM_Contribute_BAO_Contribution_Utils { // 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 @@ class CRM_Contribute_BAO_Contribution_Utils { */ 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 @@ INNER JOIN civicrm_contact contact ON ( contact.id = contrib.contact_id ) $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 @@ INNER JOIN civicrm_contact contact ON ( contact.id = contrib.contact_id ) } $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 @@ INNER JOIN civicrm_contact contact ON ( contact.id = contrib.contact_id ) static $_cache; if (!$_cache) { - $_cache = array(); + $_cache = []; } if (!isset($_cache[$contactID])) { @@ -452,28 +452,28 @@ WHERE contact_id = %1 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 @@ LIMIT 1 * */ 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 @@ LIMIT 1 $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 @@ LIMIT 1 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 741c2e03f3..10e47c8a90 100644 --- a/CRM/Contribute/BAO/ContributionPage.php +++ b/CRM/Contribute/BAO/ContributionPage.php @@ -88,17 +88,17 @@ class CRM_Contribute_BAO_ContributionPage extends CRM_Contribute_DAO_Contributio * @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 @@ class CRM_Contribute_BAO_ContributionPage extends CRM_Contribute_DAO_Contributio * @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 @@ class CRM_Contribute_BAO_ContributionPage extends CRM_Contribute_DAO_Contributio 'amount', 'receipt_date', 'is_pay_later', - ); + ]; foreach ($valuesRequiredForTemplate as $valueRequiredForTemplate) { if (!isset($values[$valueRequiredForTemplate])) { @@ -179,26 +179,26 @@ class CRM_Contribute_BAO_ContributionPage extends CRM_Contribute_DAO_Contributio 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 @@ class CRM_Contribute_BAO_ContributionPage extends CRM_Contribute_DAO_Contributio 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 @@ class CRM_Contribute_BAO_ContributionPage extends CRM_Contribute_DAO_Contributio 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 @@ class CRM_Contribute_BAO_ContributionPage extends CRM_Contribute_DAO_Contributio } 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 @@ class CRM_Contribute_BAO_ContributionPage extends CRM_Contribute_DAO_Contributio // 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 @@ class CRM_Contribute_BAO_ContributionPage extends CRM_Contribute_DAO_Contributio '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 @@ class CRM_Contribute_BAO_ContributionPage extends CRM_Contribute_DAO_Contributio } // 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 @@ class CRM_Contribute_BAO_ContributionPage extends CRM_Contribute_DAO_Contributio * * @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 @@ class CRM_Contribute_BAO_ContributionPage extends CRM_Contribute_DAO_Contributio CRM_Core_BAO_UFGroup::getValues($cid, $fields, $values, FALSE, $params); } } - return array($groupTitle, $values); + return [$groupTitle, $values]; } /** @@ -545,17 +545,17 @@ class CRM_Contribute_BAO_ContributionPage extends CRM_Contribute_DAO_Contributio * @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 @@ class CRM_Contribute_BAO_ContributionPage extends CRM_Contribute_DAO_Contributio } 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 @@ class CRM_Contribute_BAO_ContributionPage extends CRM_Contribute_DAO_Contributio '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 @@ class CRM_Contribute_BAO_ContributionPage extends CRM_Contribute_DAO_Contributio * @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 @@ WHERE entity_table = 'civicrm_contribution_page' $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 @@ WHERE entity_table = 'civicrm_contribution_page' * @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 @@ WHERE entity_table = 'civicrm_contribution_page' 'pcp', 'widget', 'premium', - ); + ]; $query = " SELECT civicrm_contribution_page.id as id, civicrm_contribution_page.financial_type_id as settings, @@ -834,8 +834,8 @@ LEFT JOIN civicrm_premiums ON ( civicrm_premiums.entity_id = civicrm * * @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 @@ LEFT JOIN civicrm_premiums ON ( civicrm_premiums.entity_id = civicrm $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 @@ LEFT JOIN civicrm_premiums ON ( civicrm_premiums.entity_id = civicrm //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 @@ LEFT JOIN civicrm_premiums ON ( civicrm_premiums.entity_id = civicrm 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 @@ LEFT JOIN civicrm_premiums ON ( civicrm_premiums.entity_id = civicrm * @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 @@ LEFT JOIN civicrm_premiums ON ( civicrm_premiums.entity_id = civicrm * 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 25e79ce86e..27f41cfcb2 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 @@ class CRM_Contribute_BAO_ContributionRecur extends CRM_Contribute_DAO_Contributi // 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 @@ class CRM_Contribute_BAO_ContributionRecur extends CRM_Contribute_DAO_Contributi $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 @@ class CRM_Contribute_BAO_ContributionRecur extends CRM_Contribute_DAO_Contributi $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 @@ class CRM_Contribute_BAO_ContributionRecur extends CRM_Contribute_DAO_Contributi */ 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 @@ class CRM_Contribute_BAO_ContributionRecur extends CRM_Contribute_DAO_Contributi * * @return bool */ - public static function cancelRecurContribution($recurId, $activityParams = array()) { + public static function cancelRecurContribution($recurId, $activityParams = []) { if (!$recurId) { return FALSE; } @@ -294,17 +294,17 @@ class CRM_Contribute_BAO_ContributionRecur extends CRM_Contribute_DAO_Contributi $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 @@ class CRM_Contribute_BAO_ContributionRecur extends CRM_Contribute_DAO_Contributi '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 @@ class CRM_Contribute_BAO_ContributionRecur extends CRM_Contribute_DAO_Contributi */ 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 @@ INNER JOIN civicrm_contribution con ON ( con.id = mp.contribution_id ) 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 @@ INNER JOIN civicrm_contribution con ON ( con.id = mp.contribution_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 @@ INNER JOIN civicrm_contribution con ON ( con.id = mp.contribution_id ) } // 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 @@ INNER JOIN civicrm_contribution con ON ( con.id = mp.contribution_id ) 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 @@ INNER JOIN civicrm_contribution con ON ( con.id = mp.contribution_id ) * @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 @@ INNER JOIN civicrm_contribution con ON ( con.id = mp.contribution_id ) } // 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 @@ INNER JOIN civicrm_contribution con ON ( con.id = mp.contribution_id ) } // 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 @@ INNER JOIN civicrm_contribution con ON ( con.id = mp.contribution_id ) // 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 @@ INNER JOIN civicrm_contribution con ON ( con.id = mp.contribution_id ) $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 @@ INNER JOIN civicrm_contribution con ON ( con.id = mp.contribution_id ) * @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 @@ INNER JOIN civicrm_contribution con ON ( con.id = mp.contribution_id ) '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 @@ INNER JOIN civicrm_contribution con ON ( con.id = mp.contribution_id ) 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 @@ INNER JOIN civicrm_contribution con ON ( con.id = mp.contribution_id ) '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 @@ INNER JOIN civicrm_contribution con ON ( con.id = mp.contribution_id ) * @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 @@ INNER JOIN civicrm_contribution con ON ( con.id = mp.contribution_id ) * * @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 1629382763..f3fca06da7 100644 --- a/CRM/Contribute/BAO/Premium.php +++ b/CRM/Contribute/BAO/Premium.php @@ -102,7 +102,7 @@ class CRM_Contribute_BAO_Premium extends CRM_Contribute_DAO_Premium { * @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 @@ class CRM_Contribute_BAO_Premium extends CRM_Contribute_DAO_Premium { 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 @@ class CRM_Contribute_BAO_Premium extends CRM_Contribute_DAO_Premium { $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 @@ class CRM_Contribute_BAO_Premium extends CRM_Contribute_DAO_Premium { 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 @@ class CRM_Contribute_BAO_Premium extends CRM_Contribute_DAO_Premium { } $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 @@ class CRM_Contribute_BAO_Premium extends CRM_Contribute_DAO_Premium { //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 @@ class CRM_Contribute_BAO_Premium extends CRM_Contribute_DAO_Premium { */ 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 @@ class CRM_Contribute_BAO_Premium extends CRM_Contribute_DAO_Premium { } } - 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 4be21cd7b7..d0af3c53fa 100644 --- a/CRM/Contribute/BAO/Query.php +++ b/CRM/Contribute/BAO/Query.php @@ -157,21 +157,21 @@ class CRM_Contribute_BAO_Query extends CRM_Core_BAO_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 @@ class CRM_Contribute_BAO_Query extends CRM_Core_BAO_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 @@ class CRM_Contribute_BAO_Query extends CRM_Core_BAO_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 @@ class CRM_Contribute_BAO_Query extends CRM_Core_BAO_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 @@ class CRM_Contribute_BAO_Query extends CRM_Core_BAO_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 @@ class CRM_Contribute_BAO_Query extends CRM_Core_BAO_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 @@ class CRM_Contribute_BAO_Query extends CRM_Core_BAO_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 @@ class CRM_Contribute_BAO_Query extends CRM_Core_BAO_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 @@ class CRM_Contribute_BAO_Query extends CRM_Core_BAO_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 @@ class CRM_Contribute_BAO_Query extends CRM_Core_BAO_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 @@ class CRM_Contribute_BAO_Query extends CRM_Core_BAO_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 @@ class CRM_Contribute_BAO_Query extends CRM_Core_BAO_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 @@ class CRM_Contribute_BAO_Query extends CRM_Core_BAO_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 @@ class CRM_Contribute_BAO_Query extends CRM_Core_BAO_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 @@ class CRM_Contribute_BAO_Query extends CRM_Core_BAO_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 @@ class CRM_Contribute_BAO_Query extends CRM_Core_BAO_Query { 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 @@ class CRM_Contribute_BAO_Query extends CRM_Core_BAO_Query { 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 @@ class CRM_Contribute_BAO_Query extends CRM_Core_BAO_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 @@ class CRM_Contribute_BAO_Query extends CRM_Core_BAO_Query { } } 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 @@ class CRM_Contribute_BAO_Query extends CRM_Core_BAO_Query { * @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 @@ class CRM_Contribute_BAO_Query extends CRM_Core_BAO_Query { * @return array */ public static function selectorReturnProperties($queryParams) { - $properties = array( + $properties = [ 'contact_type' => 1, 'contact_sub_type' => 1, 'sort_name' => 1, @@ -772,7 +772,7 @@ class CRM_Contribute_BAO_Query extends CRM_Core_BAO_Query { '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 @@ class CRM_Contribute_BAO_Query extends CRM_Core_BAO_Query { 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 @@ class CRM_Contribute_BAO_Query extends CRM_Core_BAO_Query { 'contribution_campaign_id' => 1, // calling //function - ); + ]; if (self::isSiteHasProducts()) { $properties['fulfilled_date'] = 1; $properties['product_name'] = 1; @@ -927,56 +927,56 @@ class CRM_Contribute_BAO_Query extends CRM_Core_BAO_Query { // 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 @@ class CRM_Contribute_BAO_Query extends CRM_Core_BAO_Query { $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 @@ class CRM_Contribute_BAO_Query extends CRM_Core_BAO_Query { ); } - self::addCustomFormFields($form, array('Contribution')); + self::addCustomFormFields($form, ['Contribution']); CRM_Campaign_BAO_Campaign::addCampaignInComponentSearch($form, 'contribution_campaign_id'); @@ -1045,17 +1045,17 @@ class CRM_Contribute_BAO_Query extends CRM_Core_BAO_Query { 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 @@ class CRM_Contribute_BAO_Query extends CRM_Core_BAO_Query { 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 @@ class CRM_Contribute_BAO_Query extends CRM_Core_BAO_Query { * @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 71d8361528..78535f2493 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 @@ class CRM_Contribute_BAO_Widget extends CRM_Contribute_DAO_Widget { 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 @@ class CRM_Contribute_BAO_Widget extends CRM_Contribute_DAO_Widget { 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 @@ class CRM_Contribute_BAO_Widget extends CRM_Contribute_DAO_Widget { $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 @@ class CRM_Contribute_BAO_Widget extends CRM_Contribute_DAO_Widget { ) { $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 @@ class CRM_Contribute_BAO_Widget extends CRM_Contribute_DAO_Widget { $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 @@ class CRM_Contribute_BAO_Widget extends CRM_Contribute_DAO_Widget { // 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 7beab54f86..745b0d7c66 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 3ee23fd7d9..70b4860aed 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 @@ class CRM_Contribute_Form_AbstractEditPayment extends CRM_Contact_Form_Task { $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 @@ class CRM_Contribute_Form_AbstractEditPayment extends CRM_Contact_Form_Task { * @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 @@ WHERE contribution_id = {$id} * @throws Exception */ public function getValidProcessors() { - $capabilities = array('BackOffice'); + $capabilities = ['BackOffice']; if ($this->_mode) { $capabilities[] = (ucfirst($this->_mode) . 'Mode'); } @@ -363,7 +363,7 @@ WHERE contribution_id = {$id} 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 @@ WHERE contribution_id = {$id} 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 @@ WHERE contribution_id = {$id} * * @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 @@ WHERE contribution_id = {$id} 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 @@ WHERE contribution_id = {$id} //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 @@ WHERE contribution_id = {$id} $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 @@ WHERE contribution_id = {$id} "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 @@ WHERE contribution_id = {$id} */ public function unsetCreditCardFields($submittedValues) { //Offline Contribution. - $unsetParams = array( + $unsetParams = [ 'payment_processor_id', "email-{$this->_bltID}", 'hidden_buildCreditCard', @@ -532,7 +532,7 @@ WHERE contribution_id = {$id} 'cvv2', 'credit_card_exp_date', 'credit_card_type', - ); + ]; foreach ($unsetParams as $key) { if (isset($submittedValues[$key])) { unset($submittedValues[$key]); @@ -621,7 +621,7 @@ WHERE contribution_id = {$id} * 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 @@ WHERE contribution_id = {$id} 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 8eedeaa8d9..eb68ed514c 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 @@ class CRM_Contribute_Form_AdditionalInfo { } } - $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 @@ class CRM_Contribute_Form_AdditionalInfo { $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 @@ class CRM_Contribute_Form_AdditionalInfo { $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 @@ class CRM_Contribute_Form_AdditionalInfo { $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 @@ class CRM_Contribute_Form_AdditionalInfo { 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 @@ class CRM_Contribute_Form_AdditionalInfo { * @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 @@ class CRM_Contribute_Form_AdditionalInfo { $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 @@ class CRM_Contribute_Form_AdditionalInfo { $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 @@ class CRM_Contribute_Form_AdditionalInfo { 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 @@ class CRM_Contribute_Form_AdditionalInfo { * @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 @@ class CRM_Contribute_Form_AdditionalInfo { 'creditnote_id', 'campaign_id', 'contribution_page_id', - ); + ]; foreach ($fields as $f) { $formatted[$f] = CRM_Utils_Array::value($f, $params); } @@ -339,12 +339,12 @@ class CRM_Contribute_Form_AdditionalInfo { // 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 @@ class CRM_Contribute_Form_AdditionalInfo { //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 @@ class CRM_Contribute_Form_AdditionalInfo { } 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 @@ class CRM_Contribute_Form_AdditionalInfo { '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 93cb1e0ee9..84c7d7ba77 100644 --- a/CRM/Contribute/Form/AdditionalPayment.php +++ b/CRM/Contribute/Form/AdditionalPayment.php @@ -160,7 +160,7 @@ class CRM_Contribute_Form_AdditionalPayment extends CRM_Contribute_Form_Abstract 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 @@ class CRM_Contribute_Form_AdditionalPayment extends CRM_Contribute_Form_Abstract */ 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 @@ class CRM_Contribute_Form_AdditionalPayment extends CRM_Contribute_Form_Abstract $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 @@ class CRM_Contribute_Form_AdditionalPayment extends CRM_Contribute_Form_Abstract $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 @@ class CRM_Contribute_Form_AdditionalPayment extends CRM_Contribute_Form_Abstract } $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 @@ class CRM_Contribute_Form_AdditionalPayment extends CRM_Contribute_Form_Abstract * @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 @@ class CRM_Contribute_Form_AdditionalPayment extends CRM_Contribute_Form_Abstract } $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 @@ class CRM_Contribute_Form_AdditionalPayment extends CRM_Contribute_Form_Abstract $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 @@ class CRM_Contribute_Form_AdditionalPayment extends CRM_Contribute_Form_Abstract $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 @@ class CRM_Contribute_Form_AdditionalPayment extends CRM_Contribute_Form_Abstract $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 @@ class CRM_Contribute_Form_AdditionalPayment extends CRM_Contribute_Form_Abstract $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 1ac38e03e3..ce98fbb513 100644 --- a/CRM/Contribute/Form/CancelSubscription.php +++ b/CRM/Contribute/Form/CancelSubscription.php @@ -123,7 +123,7 @@ class CRM_Contribute_Form_CancelSubscription extends CRM_Contribute_Form_Contrib // 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 @@ class CRM_Contribute_Form_CancelSubscription extends CRM_Contribute_Form_Contrib $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 @@ class CRM_Contribute_Form_CancelSubscription extends CRM_Contribute_Form_Contrib $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 @@ class CRM_Contribute_Form_CancelSubscription extends CRM_Contribute_Form_Contrib * array of default values */ public function setDefaultValues() { - return array( + return [ 'is_notify' => 1, 'send_cancel_request' => 1, - ); + ]; } /** @@ -199,7 +199,7 @@ class CRM_Contribute_Form_CancelSubscription extends CRM_Contribute_Form_Contrib } 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 @@ class CRM_Contribute_Form_CancelSubscription extends CRM_Contribute_Form_Contrib } 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 @@ class CRM_Contribute_Form_CancelSubscription extends CRM_Contribute_Form_Contrib $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 @@ class CRM_Contribute_Form_CancelSubscription extends CRM_Contribute_Form_Contrib '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 @@ class CRM_Contribute_Form_CancelSubscription extends CRM_Contribute_Form_Contrib // 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 @@ class CRM_Contribute_Form_CancelSubscription extends CRM_Contribute_Form_Contrib '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 8326d73c03..f088ade2aa 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 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP if ($this->_id) { $this->showRecordLinkMesssage($this->_id); } - $this->_values = array(); + $this->_values = []; // Current contribution id. if ($this->_id) { @@ -287,7 +287,7 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP $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 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP 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 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP } } - $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 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP } $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 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP 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 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP */ 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 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP 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 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP $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 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP $defaults['hidden_AdditionalDetail'] = 1; } - $paneNames = array(); + $paneNames = []; if (empty($this->_payNow)) { $paneNames[ts('Additional Details')] = 'AdditionalDetail'; } @@ -582,7 +582,7 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP } 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 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP $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 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP $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 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP } $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 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP $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 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP $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 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP } // 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 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP // 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 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP $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 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP $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 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP * 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 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP // $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 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP $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 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP $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 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP $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 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP '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 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP */ 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 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP '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 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP $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 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP * @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 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP 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 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP } // 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 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP $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 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP $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 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP // 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 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP 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 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP 'check_number', 'card_type_id', 'pan_truncation', - ); + ]; foreach ($fields as $f) { $params[$f] = CRM_Utils_Array::value($f, $formValues); } @@ -1695,7 +1695,7 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP 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 24f3edc2e4..d597b15ece 100644 --- a/CRM/Contribute/Form/Contribution/Confirm.php +++ b/CRM/Contribute/Form/Contribution/Confirm.php @@ -66,7 +66,7 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr //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 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr $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 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr } 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 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr 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 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr '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 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr $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 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr '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 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr $locationValue = $locType; } $locTypeId = ''; - $phoneExtField = array(); + $phoneExtField = []; if ($field == 'url') { $blockName = 'website'; @@ -407,7 +407,7 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr //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 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr $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 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr 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 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr $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 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr !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 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr ) ); - $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 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr // 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 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr $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 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr $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 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr 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 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr $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 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr } // 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 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr 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 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr */ 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 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr 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 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr // 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 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr * 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 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr 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 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr '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 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr 'from' => "$domainValues[0] <$domainValues[1]>", 'tplParams' => $tplParams, 'PDFFilename' => 'receipt.pdf', - ); + ]; CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams); } } @@ -1332,12 +1332,12 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr 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 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr $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 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr $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 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr $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 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr 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 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr } //@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 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr } $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 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr 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 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr // 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 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr // 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 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr $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 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr //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 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr $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 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr $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 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr $form->assign('membership_trx_id', $result['trxn_id']); } - return array($membershipContribution, $result); + return [$membershipContribution, $result]; } /** @@ -1951,7 +1951,7 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr $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 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr } $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 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr $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 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr 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 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr // 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 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr $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 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr 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 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr $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 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr !empty($this->_params['is_for_organization']) ) ) { - $ufFields = array(); + $ufFields = []; foreach ($this->_fields['onbehalf'] as $name => $value) { $ufFields[$name] = 1; } @@ -2361,7 +2361,7 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr $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 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr ); } } - $fieldTypes = array('Contact', 'Organization', 'Membership'); + $fieldTypes = ['Contact', 'Organization', 'Membership']; } $priceFieldIds = $this->get('memberPriceFieldIDS'); @@ -2386,8 +2386,8 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr 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 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr // 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 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr 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 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr '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 0115fab9a9..4fd859f9bf 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 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu $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 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu //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 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu $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 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu $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 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu 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 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu } 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 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu $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 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu } 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 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu } $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 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu } 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 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu $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 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu } 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 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu * 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 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu $membershipOrgDetails = CRM_Member_BAO_MembershipType::getMembershipTypeOrganization(); - $unallowedOrgs = array(); + $unallowedOrgs = []; foreach (array_keys($lifeMember) as $memTypeId) { $unallowedOrgs[] = $membershipOrgDetails[$memTypeId]; } @@ -665,7 +665,7 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu $priceField->orderBy('weight'); $priceField->find(); - $check = array(); + $check = []; $membershipIsActive = TRUE; $previousId = $otherAmount = FALSE; while ($priceField->fetch()) { @@ -688,12 +688,12 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu $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 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu // 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 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu 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 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu 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 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu } 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 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu $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 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu $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 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu $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 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu $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 @@ class CRM_Contribute_Form_Contribution_Main extends CRM_Contribute_Form_Contribu $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 f393a4c0a9..a82579729a 100644 --- a/CRM/Contribute/Form/Contribution/ThankYou.php +++ b/CRM/Contribute/Form/Contribution/ThankYou.php @@ -147,7 +147,7 @@ class CRM_Contribute_Form_Contribution_ThankYou extends CRM_Contribute_Form_Cont $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 @@ class CRM_Contribute_Form_Contribution_ThankYou extends CRM_Contribute_Form_Cont 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 @@ class CRM_Contribute_Form_Contribution_ThankYou extends CRM_Contribute_Form_Cont !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 @@ class CRM_Contribute_Form_Contribution_ThankYou extends CRM_Contribute_Form_Cont 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 @@ class CRM_Contribute_Form_Contribution_ThankYou extends CRM_Contribute_Form_Cont $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 @@ class CRM_Contribute_Form_Contribution_ThankYou extends CRM_Contribute_Form_Cont $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 3e40cafd8f..4b22fae1a4 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 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form { 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 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form { 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 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form { ); $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 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form { $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 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form { ) { $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 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form { // 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 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form { '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 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form { // 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 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form { } //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 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form { 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 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_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 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_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 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_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 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_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 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_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 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_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 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_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 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form { $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 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form { //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 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form { $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 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form { 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 @@ class CRM_Contribute_Form_ContributionBase extends CRM_Core_Form { } 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 24283e37df..f8c10cd1cc 100644 --- a/CRM/Contribute/Form/ContributionCharts.php +++ b/CRM/Contribute/Form/ContributionCharts.php @@ -65,17 +65,17 @@ class CRM_Contribute_Form_ContributionCharts extends CRM_Core_Form { 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 @@ class CRM_Contribute_Form_ContributionCharts extends CRM_Core_Form { } $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 @@ class CRM_Contribute_Form_ContributionCharts extends CRM_Core_Form { //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 @@ class CRM_Contribute_Form_ContributionCharts extends CRM_Core_Form { $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 @@ class CRM_Contribute_Form_ContributionCharts extends CRM_Core_Form { $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 @@ class CRM_Contribute_Form_ContributionCharts extends CRM_Core_Form { $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 0ce526e056..b426a3b927 100644 --- a/CRM/Contribute/Form/ContributionPage.php +++ b/CRM/Contribute/Form/ContributionPage.php @@ -120,21 +120,21 @@ class CRM_Contribute_Form_ContributionPage extends CRM_Core_Form { 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 @@ class CRM_Contribute_Form_ContributionPage extends CRM_Core_Form { } // 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 @@ class CRM_Contribute_Form_ContributionPage extends CRM_Core_Form { } 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 @@ class CRM_Contribute_Form_ContributionPage extends CRM_Core_Form { // 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 @@ class CRM_Contribute_Form_ContributionPage extends CRM_Core_Form { } } // 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 @@ class CRM_Contribute_Form_ContributionPage extends CRM_Core_Form { //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 @@ class CRM_Contribute_Form_ContributionPage extends CRM_Core_Form { 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 @@ class CRM_Contribute_Form_ContributionPage extends CRM_Core_Form { '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 @@ class CRM_Contribute_Form_ContributionPage extends CRM_Core_Form { } 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 @@ class CRM_Contribute_Form_ContributionPage extends CRM_Core_Form { } 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 cb55e4da75..70adad65a1 100644 --- a/CRM/Contribute/Form/ContributionPage/AddProduct.php +++ b/CRM/Contribute/Form/ContributionPage/AddProduct.php @@ -68,7 +68,7 @@ class CRM_Contribute_Form_ContributionPage_AddProduct extends CRM_Contribute_For * 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 @@ class CRM_Contribute_Form_ContributionPage_AddProduct extends CRM_Contribute_For $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 @@ class CRM_Contribute_Form_ContributionPage_AddProduct extends CRM_Contribute_For 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 @@ class CRM_Contribute_Form_ContributionPage_AddProduct extends CRM_Contribute_For $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 @@ class CRM_Contribute_Form_ContributionPage_AddProduct extends CRM_Contribute_For 'account_relationship = 8' ); - $costFinancialType = array(); + $costFinancialType = []; CRM_Core_PseudoConstant::populate( $costFinancialType, 'CRM_Financial_DAO_EntityFinancialAccount', @@ -195,24 +195,24 @@ class CRM_Contribute_Form_ContributionPage_AddProduct extends CRM_Contribute_For '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 @@ class CRM_Contribute_Form_ContributionPage_AddProduct extends CRM_Contribute_For } // 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 3b24f835f6..6de2f49ffa 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 @@ class CRM_Contribute_Form_ContributionPage_Amount extends CRM_Contribute_Form_Co $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 @@ class CRM_Contribute_Form_ContributionPage_Amount extends CRM_Contribute_Form_Co $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 @@ class CRM_Contribute_Form_ContributionPage_Amount extends CRM_Contribute_Form_Co $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 @@ class CRM_Contribute_Form_ContributionPage_Amount extends CRM_Contribute_Form_Co //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 @@ class CRM_Contribute_Form_ContributionPage_Amount extends CRM_Contribute_Form_Co 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 @@ class CRM_Contribute_Form_ContributionPage_Amount extends CRM_Contribute_Form_Co * 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 @@ class CRM_Contribute_Form_ContributionPage_Amount extends CRM_Contribute_Form_Co $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 @@ class CRM_Contribute_Form_ContributionPage_Amount extends CRM_Contribute_Form_Co '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 @@ class CRM_Contribute_Form_ContributionPage_Amount extends CRM_Contribute_Form_Co $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 @@ class CRM_Contribute_Form_ContributionPage_Amount extends CRM_Contribute_Form_Co 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 @@ class CRM_Contribute_Form_ContributionPage_Amount extends CRM_Contribute_Form_Co $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 @@ class CRM_Contribute_Form_ContributionPage_Amount extends CRM_Contribute_Form_Co } 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 @@ class CRM_Contribute_Form_ContributionPage_Amount extends CRM_Contribute_Form_Co $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 @@ class CRM_Contribute_Form_ContributionPage_Amount extends CRM_Contribute_Form_Co '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 @@ class CRM_Contribute_Form_ContributionPage_Amount extends CRM_Contribute_Form_Co 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 @@ class CRM_Contribute_Form_ContributionPage_Amount extends CRM_Contribute_Form_Co 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 @@ class CRM_Contribute_Form_ContributionPage_Amount extends CRM_Contribute_Form_Co 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 @@ class CRM_Contribute_Form_ContributionPage_Amount extends CRM_Contribute_Form_Co '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 8831bc0fe4..94f02e99c1 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 @@ class CRM_Contribute_Form_ContributionPage_Custom extends CRM_Contribute_Form_Co $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 @@ class CRM_Contribute_Form_ContributionPage_Custom extends CRM_Contribute_Form_Co $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 @@ class CRM_Contribute_Form_ContributionPage_Custom extends CRM_Contribute_Form_Co * 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 ce80ff7e61..b89a1448be 100644 --- a/CRM/Contribute/Form/ContributionPage/Delete.php +++ b/CRM/Contribute/Form/ContributionPage/Delete.php @@ -79,19 +79,19 @@ class CRM_Contribute_Form_ContributionPage_Delete extends CRM_Contribute_Form_Co //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 @@ class CRM_Contribute_Form_ContributionPage_Delete extends CRM_Contribute_Form_Co // 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 @@ class CRM_Contribute_Form_ContributionPage_Delete extends CRM_Contribute_Form_Co $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 e041747ed9..109dbc39ed 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 @@ class CRM_Contribute_Form_ContributionPage_Premium extends CRM_Contribute_Form_C // 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 @@ class CRM_Contribute_Form_ContributionPage_Premium extends CRM_Contribute_Form_C $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 @@ class CRM_Contribute_Form_ContributionPage_Premium extends CRM_Contribute_Form_C * 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 13a3e49115..c2f7aa06a7 100644 --- a/CRM/Contribute/Form/ContributionPage/Settings.php +++ b/CRM/Contribute/Form/ContributionPage/Settings.php @@ -58,7 +58,7 @@ class CRM_Contribute_Form_ContributionPage_Settings extends CRM_Contribute_Form_ ); 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 @@ class CRM_Contribute_Form_ContributionPage_Settings extends CRM_Contribute_Form_ 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 @@ class CRM_Contribute_Form_ContributionPage_Settings extends CRM_Contribute_Form_ 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 @@ class CRM_Contribute_Form_ContributionPage_Settings extends CRM_Contribute_Form_ // 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 @@ class CRM_Contribute_Form_ContributionPage_Settings extends CRM_Contribute_Form_ $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 @@ class CRM_Contribute_Form_ContributionPage_Settings extends CRM_Contribute_Form_ $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 @@ class CRM_Contribute_Form_ContributionPage_Settings extends CRM_Contribute_Form_ $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 @@ class CRM_Contribute_Form_ContributionPage_Settings extends CRM_Contribute_Form_ * 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 @@ class CRM_Contribute_Form_ContributionPage_Settings extends CRM_Contribute_Form_ $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 @@ class CRM_Contribute_Form_ContributionPage_Settings extends CRM_Contribute_Form_ //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 @@ class CRM_Contribute_Form_ContributionPage_Settings extends CRM_Contribute_Form_ } } 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 @@ class CRM_Contribute_Form_ContributionPage_Settings extends CRM_Contribute_Form_ $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 @@ class CRM_Contribute_Form_ContributionPage_Settings extends CRM_Contribute_Form_ $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 7deb3722f9..0becb7fb8a 100644 --- a/CRM/Contribute/Form/ContributionPage/TabHeader.php +++ b/CRM/Contribute/Form/ContributionPage/TabHeader.php @@ -49,11 +49,11 @@ class CRM_Contribute_Form_ContributionPage_TabHeader { $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 @@ class CRM_Contribute_Form_ContributionPage_TabHeader { 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 @@ class CRM_Contribute_Form_ContributionPage_TabHeader { $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 67e6e45e61..d8a53f151a 100644 --- a/CRM/Contribute/Form/ContributionPage/ThankYou.php +++ b/CRM/Contribute/Form/ContributionPage/ThankYou.php @@ -54,11 +54,11 @@ class CRM_Contribute_Form_ContributionPage_ThankYou extends CRM_Contribute_Form_ // 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 @@ class CRM_Contribute_Form_ContributionPage_ThankYou extends CRM_Contribute_Form_ $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 @@ class CRM_Contribute_Form_ContributionPage_ThankYou extends CRM_Contribute_Form_ * 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 78f0434954..2a88bc06b5 100644 --- a/CRM/Contribute/Form/ContributionPage/Widget.php +++ b/CRM/Contribute/Form/ContributionPage/Widget.php @@ -61,90 +61,90 @@ class CRM_Contribute_Form_ContributionPage_Widget extends CRM_Contribute_Form_Co '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 @@ class CRM_Contribute_Form_ContributionPage_Widget extends CRM_Contribute_Form_Co '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 @@ class CRM_Contribute_Form_ContributionPage_Widget extends CRM_Contribute_Form_Co 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 @@ class CRM_Contribute_Form_ContributionPage_Widget extends CRM_Contribute_Form_Co * 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 @@ class CRM_Contribute_Form_ContributionPage_Widget extends CRM_Contribute_Form_Co 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 aee9f0ec37..99b02342bd 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 @@ class CRM_Contribute_Form_ContributionView extends CRM_Core_Form { 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 @@ class CRM_Contribute_Form_ContributionView extends CRM_Core_Form { // 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 @@ class CRM_Contribute_Form_ContributionView extends CRM_Core_Form { $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 @@ class CRM_Contribute_Form_ContributionView extends CRM_Core_Form { } 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 @@ class CRM_Contribute_Form_ContributionView extends CRM_Core_Form { $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 @@ class CRM_Contribute_Form_ContributionView extends CRM_Core_Form { $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 @@ class CRM_Contribute_Form_ContributionView extends CRM_Core_Form { * 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 1176098f2c..6cfbe11798 100644 --- a/CRM/Contribute/Form/ManagePremiums.php +++ b/CRM/Contribute/Form/ManagePremiums.php @@ -49,7 +49,7 @@ class CRM_Contribute_Form_ManagePremiums extends CRM_Contribute_Form { 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 @@ class CRM_Contribute_Form_ManagePremiums extends CRM_Contribute_Form { $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 @@ class CRM_Contribute_Form_ManagePremiums extends CRM_Contribute_Form { $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 @@ class CRM_Contribute_Form_ManagePremiums extends CRM_Contribute_Form { 'account_relationship = 8' ); - $costFinancialType = array(); + $costFinancialType = []; CRM_Core_PseudoConstant::populate( $costFinancialType, 'CRM_Financial_DAO_EntityFinancialAccount', @@ -173,24 +173,24 @@ class CRM_Contribute_Form_ManagePremiums extends CRM_Contribute_Form { '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 @@ class CRM_Contribute_Form_ManagePremiums extends CRM_Contribute_Form { 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 @@ class CRM_Contribute_Form_ManagePremiums extends CRM_Contribute_Form { $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 @@ class CRM_Contribute_Form_ManagePremiums extends CRM_Contribute_Form { $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 @@ class CRM_Contribute_Form_ManagePremiums extends CRM_Contribute_Form { * @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 f00ec96621..3aa1d912bf 100644 --- a/CRM/Contribute/Form/Search.php +++ b/CRM/Contribute/Form/Search.php @@ -269,10 +269,10 @@ class CRM_Contribute_Form_Search extends CRM_Core_Form_Search { $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 @@ class CRM_Contribute_Form_Search extends CRM_Core_Form_Search { $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 @@ class CRM_Contribute_Form_Search extends CRM_Core_Form_Search { '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 @@ class CRM_Contribute_Form_Search extends CRM_Core_Form_Search { $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 051613405e..1b31304695 100644 --- a/CRM/Contribute/Form/SearchContribution.php +++ b/CRM/Contribute/Form/SearchContribution.php @@ -48,13 +48,13 @@ class CRM_Contribute_Form_SearchContribution extends CRM_Core_Form { 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 @@ class CRM_Contribute_Form_SearchContribution extends CRM_Core_Form { $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 5a42f2f4f1..b45472fda6 100644 --- a/CRM/Contribute/Form/SoftCredit.php +++ b/CRM/Contribute/Form/SoftCredit.php @@ -51,7 +51,7 @@ class CRM_Contribute_Form_SoftCredit { 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 @@ class CRM_Contribute_Form_SoftCredit { } 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 @@ class CRM_Contribute_Form_SoftCredit { $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 @@ class CRM_Contribute_Form_SoftCredit { 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 @@ class CRM_Contribute_Form_SoftCredit { * 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 3ce717f915..0414b694d7 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 @@ class CRM_Contribute_Form_Task extends CRM_Core_Form_Task { * @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 @@ class CRM_Contribute_Form_Task extends CRM_Core_Form_Task { $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 @@ class CRM_Contribute_Form_Task extends CRM_Core_Form_Task { } } 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 @@ class CRM_Contribute_Form_Task extends CRM_Core_Form_Task { // @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 @@ class CRM_Contribute_Form_Task extends CRM_Core_Form_Task { * @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 7ef312fff5..2e52dccdef 100644 --- a/CRM/Contribute/Form/Task/Batch.php +++ b/CRM/Contribute/Form/Task/Batch.php @@ -61,7 +61,7 @@ class CRM_Contribute_Form_Task_Batch extends CRM_Contribute_Form_Task { 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 @@ class CRM_Contribute_Form_Task_Batch extends CRM_Contribute_Form_Task { 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 @@ class CRM_Contribute_Form_Task_Batch extends CRM_Contribute_Form_Task { $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 @@ class CRM_Contribute_Form_Task_Batch extends CRM_Contribute_Form_Task { //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 @@ class CRM_Contribute_Form_Task_Batch extends CRM_Contribute_Form_Task { // 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 @@ class CRM_Contribute_Form_Task_Batch extends CRM_Contribute_Form_Task { 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 @@ class CRM_Contribute_Form_Task_Batch extends CRM_Contribute_Form_Task { $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 26394d8411..82c69c935a 100644 --- a/CRM/Contribute/Form/Task/Delete.php +++ b/CRM/Contribute/Form/Task/Delete.php @@ -82,17 +82,17 @@ class CRM_Contribute_Form_Task_Delete extends CRM_Contribute_Form_Task { } } 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 @@ class CRM_Contribute_Form_Task_Delete extends CRM_Contribute_Form_Task { } 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 865f91b5a1..dffc33c9f4 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 @@ class CRM_Contribute_Form_Task_Invoice extends CRM_Contribute_Form_Task { // 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 @@ class CRM_Contribute_Form_Task_Invoice extends CRM_Contribute_Form_Task { } $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 @@ class CRM_Contribute_Form_Task_Invoice extends CRM_Contribute_Form_Task { $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 @@ class CRM_Contribute_Form_Task_Invoice extends CRM_Contribute_Form_Task { * 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 @@ class CRM_Contribute_Form_Task_Invoice extends CRM_Contribute_Form_Task { */ 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 @@ class CRM_Contribute_Form_Task_Invoice extends CRM_Contribute_Form_Task { $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 @@ class CRM_Contribute_Form_Task_Invoice extends CRM_Contribute_Form_Task { $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 @@ class CRM_Contribute_Form_Task_Invoice extends CRM_Contribute_Form_Task { $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 @@ class CRM_Contribute_Form_Task_Invoice extends CRM_Contribute_Form_Task { $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 @@ class CRM_Contribute_Form_Task_Invoice extends CRM_Contribute_Form_Task { } // 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 @@ class CRM_Contribute_Form_Task_Invoice extends CRM_Contribute_Form_Task { 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 @@ class CRM_Contribute_Form_Task_Invoice extends CRM_Contribute_Form_Task { // 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 @@ class CRM_Contribute_Form_Task_Invoice extends CRM_Contribute_Form_Task { } // parameters to be assign for template - $tplParams = array( + $tplParams = [ 'title' => $title, 'component' => $input['component'], 'id' => $contribution->id, @@ -443,20 +443,20 @@ class CRM_Contribute_Form_Task_Invoice extends CRM_Contribute_Form_Task { '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 @@ class CRM_Contribute_Form_Task_Invoice extends CRM_Contribute_Form_Task { return $html; } else { - $mail = array( + $mail = [ 'subject' => $subject, 'body' => $message, 'html' => $html, - ); + ]; if ($mail['html']) { $messageInvoice[] = $mail['html']; } @@ -484,7 +484,7 @@ class CRM_Contribute_Form_Task_Invoice extends CRM_Contribute_Form_Task { 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 @@ class CRM_Contribute_Form_Task_Invoice extends CRM_Contribute_Form_Task { 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 @@ class CRM_Contribute_Form_Task_Invoice extends CRM_Contribute_Form_Task { 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 @@ class CRM_Contribute_Form_Task_Invoice extends CRM_Contribute_Form_Task { } 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 @@ class CRM_Contribute_Form_Task_Invoice extends CRM_Contribute_Form_Task { ); } - $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 @@ class CRM_Contribute_Form_Task_Invoice extends CRM_Contribute_Form_Task { */ 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 f29751970c..aff1abaf0d 100644 --- a/CRM/Contribute/Form/Task/PDF.php +++ b/CRM/Contribute/Form/Task/PDF.php @@ -56,7 +56,7 @@ class CRM_Contribute_Form_Task_PDF extends CRM_Contribute_Form_Task { ); 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 @@ AND {$this->_componentClause}"; } $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 @@ AND {$this->_componentClause}"; 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 @@ AND {$this->_componentClause}"; */ 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 @@ AND {$this->_componentClause}"; */ 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 @@ AND {$this->_componentClause}"; 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 @@ AND {$this->_componentClause}"; } 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 @@ AND {$this->_componentClause}"; * */ static public function getElements($contribIds, $params, $contactIds) { - $pdfElements = array(); + $pdfElements = []; $pdfElements['contribIDs'] = implode(',', $contribIds); @@ -280,14 +280,14 @@ AND {$this->_componentClause}"; $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 397907b509..b481060195 100644 --- a/CRM/Contribute/Form/Task/PDFLetter.php +++ b/CRM/Contribute/Form/Task/PDFLetter.php @@ -88,9 +88,9 @@ class CRM_Contribute_Form_Task_PDFLetter extends CRM_Contribute_Form_Task { * @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 @@ class CRM_Contribute_Form_Task_PDFLetter extends CRM_Contribute_Form_Task { $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 044d7df56f..c6af7bcd7c 100644 --- a/CRM/Contribute/Form/Task/PDFLetterCommon.php +++ b/CRM/Contribute/Form/Task/PDFLetterCommon.php @@ -32,13 +32,13 @@ class CRM_Contribute_Form_Task_PDFLetterCommon extends CRM_Contact_Form_Task_PDF } 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 @@ class CRM_Contribute_Form_Task_PDFLetterCommon extends CRM_Contact_Form_Task_PDF $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 @@ class CRM_Contribute_Form_Task_PDFLetterCommon extends CRM_Contact_Form_Task_PDF $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 @@ class CRM_Contribute_Form_Task_PDFLetterCommon extends CRM_Contact_Form_Task_PDF $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 @@ class CRM_Contribute_Form_Task_PDFLetterCommon extends CRM_Contact_Form_Task_PDF $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 @@ class CRM_Contribute_Form_Task_PDFLetterCommon extends CRM_Contact_Form_Task_PDF * @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 @@ class CRM_Contribute_Form_Task_PDFLetterCommon extends CRM_Contact_Form_Task_PDF * @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 @@ class CRM_Contribute_Form_Task_PDFLetterCommon extends CRM_Contact_Form_Task_PDF $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 @@ class CRM_Contribute_Form_Task_PDFLetterCommon extends CRM_Contact_Form_Task_PDF // 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 @@ class CRM_Contribute_Form_Task_PDFLetterCommon extends CRM_Contact_Form_Task_PDF ); $contacts[$contactID] = array_merge($tokenResolvedContacts[0][$contactID], $contact); } - return array($contributions, $contacts); + return [$contributions, $contacts]; } /** @@ -363,24 +363,24 @@ class CRM_Contribute_Form_Task_PDFLetterCommon extends CRM_Contact_Form_Task_PDF * * @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 @@ class CRM_Contribute_Form_Task_PDFLetterCommon extends CRM_Contact_Form_Task_PDF } 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 c937de4ac4..c4908eb068 100644 --- a/CRM/Contribute/Form/Task/PickProfile.php +++ b/CRM/Contribute/Form/Task/PickProfile.php @@ -67,10 +67,10 @@ class CRM_Contribute_Form_Task_PickProfile extends CRM_Contribute_Form_Task { $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 @@ class CRM_Contribute_Form_Task_PickProfile extends CRM_Contribute_Form_Task { */ 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 @@ class CRM_Contribute_Form_Task_PickProfile extends CRM_Contribute_Form_Task { * 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 8b11f90881..132e2cefe8 100644 --- a/CRM/Contribute/Form/Task/Print.php +++ b/CRM/Contribute/Form/Task/Print.php @@ -72,18 +72,18 @@ class CRM_Contribute_Form_Task_Print extends CRM_Contribute_Form_Task { // // 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 27f98f1647..6e9c0999ef 100644 --- a/CRM/Contribute/Form/Task/Result.php +++ b/CRM/Contribute/Form/Task/Result.php @@ -46,13 +46,13 @@ class CRM_Contribute_Form_Task_Result extends CRM_Contribute_Form_Task { * 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 f7e46c5cad..ce9e319b84 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 @@ INNER JOIN civicrm_contact ct ON ( co.contact_id = ct.id ) ); 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 @@ INNER JOIN civicrm_contact ct ON ( co.contact_id = ct.id ) * 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 c3f4e9d9e6..08262c92b3 100644 --- a/CRM/Contribute/Form/Task/Status.php +++ b/CRM/Contribute/Form/Task/Status.php @@ -55,7 +55,7 @@ class CRM_Contribute_Form_Task_Status extends CRM_Contribute_Form_Task { ); 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 @@ AND co.id IN ( $contribIDs )"; ); // 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 @@ AND co.id IN ( $contribIDs )"; $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 @@ AND co.id IN ( $contribIDs )"; $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 @@ AND co.id IN ( $contribIDs )"; * 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 @@ AND co.id IN ( $contribIDs )"; // 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 @@ LEFT JOIN civicrm_participant_payment pp ON pp.contribution_id = c.id 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 @@ WHERE c.id IN ( $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 c1a092e53c..cbe2ee8333 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 @@ class CRM_Contribute_Form_UpdateSubscription extends CRM_Contribute_Form_Contrib 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 @@ class CRM_Contribute_Form_UpdateSubscription extends CRM_Contribute_Form_Contrib 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 @@ class CRM_Contribute_Form_UpdateSubscription extends CRM_Contribute_Form_Contrib * 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 @@ class CRM_Contribute_Form_UpdateSubscription extends CRM_Contribute_Form_Contrib */ 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 @@ class CRM_Contribute_Form_UpdateSubscription extends CRM_Contribute_Form_Contrib } 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 @@ class CRM_Contribute_Form_UpdateSubscription extends CRM_Contribute_Form_Contrib } // 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 @@ class CRM_Contribute_Form_UpdateSubscription extends CRM_Contribute_Form_Contrib // 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 @@ class CRM_Contribute_Form_UpdateSubscription extends CRM_Contribute_Form_Contrib 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 @@ class CRM_Contribute_Form_UpdateSubscription extends CRM_Contribute_Form_Contrib } 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 @@ class CRM_Contribute_Form_UpdateSubscription extends CRM_Contribute_Form_Contrib // 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 @@ class CRM_Contribute_Form_UpdateSubscription extends CRM_Contribute_Form_Contrib 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 @@ class CRM_Contribute_Form_UpdateSubscription extends CRM_Contribute_Form_Contrib '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 3368e3685e..7860644926 100644 --- a/CRM/Contribute/Import/Controller.php +++ b/CRM/Contribute/Import/Controller.php @@ -54,7 +54,7 @@ class CRM_Contribute_Import_Controller extends CRM_Core_Controller { // 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 db74800df6..fdd1ce6177 100644 --- a/CRM/Contribute/Import/Field.php +++ b/CRM/Contribute/Import/Field.php @@ -152,7 +152,7 @@ class CRM_Contribute_Import_Field { 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 b4058d0a2a..ff0ee51e54 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 @@ class CRM_Contribute_Import_Form_DataSource extends CRM_Import_Form_DataSource { 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 @@ class CRM_Contribute_Import_Form_DataSource extends CRM_Import_Form_DataSource { * 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 0d60984e71..074c06b6d5 100644 --- a/CRM/Contribute/Import/Form/Preview.php +++ b/CRM/Contribute/Import/Form/Preview.php @@ -84,7 +84,7 @@ class CRM_Contribute_Import_Form_Preview extends CRM_Import_Form_Preview { $this->set('downloadMismatchRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams)); } - $properties = array( + $properties = [ 'mapper', 'softCreditFields', 'mapperSoftCreditType', @@ -97,7 +97,7 @@ class CRM_Contribute_Import_Form_Preview extends CRM_Import_Form_Preview { 'downloadErrorRecordsUrl', 'downloadConflictRecordsUrl', 'downloadMismatchRecordsUrl', - ); + ]; $this->setStatusUrl(); foreach ($properties as $property) { @@ -118,9 +118,9 @@ class CRM_Contribute_Import_Form_Preview extends CRM_Import_Form_Preview { $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 @@ class CRM_Contribute_Import_Form_Preview extends CRM_Import_Form_Preview { $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 @@ class CRM_Contribute_Import_Form_Preview extends CRM_Import_Form_Preview { $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 706d375e4b..ddd0222305 100644 --- a/CRM/Contribute/Import/Form/Summary.php +++ b/CRM/Contribute/Import/Form/Summary.php @@ -101,7 +101,7 @@ class CRM_Contribute_Import_Form_Summary extends CRM_Import_Form_Summary { } $this->assign('dupeActionString', $dupeActionString); - $properties = array( + $properties = [ 'totalRowCount', 'validRowCount', 'invalidRowCount', @@ -119,7 +119,7 @@ class CRM_Contribute_Import_Form_Summary extends CRM_Import_Form_Summary { '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 d8669559b2..57a0156537 100644 --- a/CRM/Contribute/Import/Parser.php +++ b/CRM/Contribute/Import/Parser.php @@ -162,11 +162,11 @@ abstract class CRM_Contribute_Import_Parser extends CRM_Import_Parser { $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 @@ abstract class CRM_Contribute_Import_Parser extends CRM_Import_Parser { $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 @@ abstract class CRM_Contribute_Import_Parser extends CRM_Import_Parser { } 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 @@ abstract class CRM_Contribute_Import_Parser extends CRM_Import_Parser { 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 @@ abstract class CRM_Contribute_Import_Parser extends CRM_Import_Parser { 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 @@ abstract class CRM_Contribute_Import_Parser extends CRM_Import_Parser { } 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 @@ abstract class CRM_Contribute_Import_Parser extends CRM_Import_Parser { * (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 @@ abstract class CRM_Contribute_Import_Parser extends CRM_Import_Parser { * @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 8d0ac22971..3d6dbd7691 100644 --- a/CRM/Contribute/Import/Parser/Contribution.php +++ b/CRM/Contribute/Import/Parser/Contribution.php @@ -74,27 +74,27 @@ class CRM_Contribute_Import_Parser_Contribution extends CRM_Contribute_Import_Pa $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 @@ class CRM_Contribute_Import_Parser_Contribution extends CRM_Contribute_Import_Pa $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 @@ class CRM_Contribute_Import_Parser_Contribution extends CRM_Contribute_Import_Pa $indieFields = $tempIndieFields; } - $paramValues = array(); + $paramValues = []; foreach ($params as $key => $field) { if ($field == NULL || $field === '') { continue; @@ -282,11 +282,11 @@ class CRM_Contribute_Import_Parser_Contribution extends CRM_Contribute_Import_Pa //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 @@ class CRM_Contribute_Import_Parser_Contribution extends CRM_Contribute_Import_Pa ); //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 @@ class CRM_Contribute_Import_Parser_Contribution extends CRM_Contribute_Import_Pa $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 @@ class CRM_Contribute_Import_Parser_Contribution extends CRM_Contribute_Import_Pa 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 @@ class CRM_Contribute_Import_Parser_Contribution extends CRM_Contribute_Import_Pa } 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 @@ class CRM_Contribute_Import_Parser_Contribution extends CRM_Contribute_Import_Pa ); 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 b72317b5fe..b6934b6167 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 @@ class CRM_Contribute_Info extends CRM_Core_Component_Info { * 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 @@ class CRM_Contribute_Info extends CRM_Core_Component_Info { * @return array */ public function getAnonymousPermissionWarnings() { - return array( + return [ 'access CiviContribute', - ); + ]; } /** @@ -136,12 +136,12 @@ class CRM_Contribute_Info extends CRM_Core_Component_Info { * @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 @@ class CRM_Contribute_Info extends CRM_Core_Component_Info { * @return array|null */ public function registerTab() { - return array( + return [ 'title' => ts('Contributions'), 'url' => 'contribution', 'weight' => 20, - ); + ]; } /** @@ -185,10 +185,10 @@ class CRM_Contribute_Info extends CRM_Core_Component_Info { * @return array|null */ public function registerAdvancedSearchPane() { - return array( + return [ 'title' => ts('Contributions'), 'weight' => 20, - ); + ]; } /** @@ -217,20 +217,20 @@ class CRM_Contribute_Info extends CRM_Core_Component_Info { 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 efe9bd4b4b..1f3c70c5fb 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 4365e1faa1..6a5029d076 100644 --- a/CRM/Contribute/Page/ContributionRecur.php +++ b/CRM/Contribute/Page/ContributionRecur.php @@ -51,9 +51,9 @@ class CRM_Contribute_Page_ContributionRecur extends CRM_Core_Page { } 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 @@ class CRM_Contribute_Page_ContributionRecur extends CRM_Core_Page { $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 @@ class CRM_Contribute_Page_ContributionRecur extends CRM_Core_Page { } // 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 70f62f8ca9..91419ff364 100644 --- a/CRM/Contribute/Page/ContributionRecurPayments.php +++ b/CRM/Contribute/Page/ContributionRecurPayments.php @@ -38,15 +38,15 @@ class CRM_Contribute_Page_ContributionRecurPayments extends CRM_Core_Page { * 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 @@ class CRM_Contribute_Page_ContributionRecurPayments extends CRM_Core_Page { $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 @@ class CRM_Contribute_Page_ContributionRecurPayments extends CRM_Core_Page { $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 @@ class CRM_Contribute_Page_ContributionRecurPayments extends CRM_Core_Page { 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 @@ class CRM_Contribute_Page_ContributionRecurPayments extends CRM_Core_Page { * @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 79835022dc..29893f8812 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 65fb595258..c4f0939a61 100644 --- a/CRM/Contribute/Page/ManagePremiums.php +++ b/CRM/Contribute/Page/ManagePremiums.php @@ -63,36 +63,36 @@ class CRM_Contribute_Page_ManagePremiums extends CRM_Core_Page_Basic { */ 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 @@ class CRM_Contribute_Page_ManagePremiums extends CRM_Core_Page_Basic { */ 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 @@ class CRM_Contribute_Page_ManagePremiums extends CRM_Core_Page_Basic { $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 a24eb3960c..eb0c035fa5 100644 --- a/CRM/Contribute/Page/Premium.php +++ b/CRM/Contribute/Page/Premium.php @@ -64,27 +64,27 @@ class CRM_Contribute_Page_Premium extends CRM_Core_Page_Basic { // 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 @@ class CRM_Contribute_Page_Premium extends CRM_Core_Page_Basic { */ 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 @@ class CRM_Contribute_Page_Premium extends CRM_Core_Page_Basic { $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 e055d79e79..f87dff5bbc 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 @@ class CRM_Contribute_Page_Tab extends CRM_Core_Page { } 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 @@ class CRM_Contribute_Page_Tab extends CRM_Core_Page { */ public function browse() { // add annual contribution - $annual = array(); + $annual = []; list($annual['count'], $annual['amount'], $annual['avg'] @@ -151,7 +151,7 @@ class CRM_Contribute_Page_Tab extends CRM_Core_Page { $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 @@ class CRM_Contribute_Page_Tab extends CRM_Core_Page { */ 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 @@ class CRM_Contribute_Page_Tab extends CRM_Core_Page { */ 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 @@ class CRM_Contribute_Page_Tab extends CRM_Core_Page { } $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 @@ class CRM_Contribute_Page_Tab extends CRM_Core_Page { 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 1efad9f386..e02872e984 100644 --- a/CRM/Contribute/Page/UserDashboard.php +++ b/CRM/Contribute/Page/UserDashboard.php @@ -86,8 +86,8 @@ class CRM_Contribute_Page_UserDashboard extends CRM_Contact_Page_View_UserDashBo $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 @@ class CRM_Contribute_Page_UserDashboard extends CRM_Contact_Page_View_UserDashBo } $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 4c29ef368e..37433be2e3 100644 --- a/CRM/Contribute/PseudoConstant.php +++ b/CRM/Contribute/PseudoConstant.php @@ -260,7 +260,7 @@ class CRM_Contribute_PseudoConstant extends CRM_Core_PseudoConstant { * 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 @@ class CRM_Contribute_PseudoConstant extends CRM_Core_PseudoConstant { $dao->find(TRUE); $premiumID = $dao->id; - $productID = array(); + $productID = []; $dao = new CRM_Contribute_DAO_PremiumsProduct(); $dao->premiums_id = $premiumID; @@ -285,7 +285,7 @@ class CRM_Contribute_PseudoConstant extends CRM_Core_PseudoConstant { $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 @@ class CRM_Contribute_PseudoConstant extends CRM_Core_PseudoConstant { */ 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 @@ class CRM_Contribute_PseudoConstant extends CRM_Core_PseudoConstant { * @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 e17f043cb7..c8fa53a775 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 @@ class CRM_Contribute_Selector_Search extends CRM_Core_Selector_Base implements C } 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 @@ class CRM_Contribute_Selector_Search extends CRM_Core_Selector_Base implements C $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 @@ class CRM_Contribute_Selector_Search extends CRM_Core_Selector_Base implements C $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 @@ class CRM_Contribute_Selector_Search extends CRM_Core_Selector_Base implements C 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 @@ class CRM_Contribute_Selector_Search extends CRM_Core_Selector_Base implements C $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 @@ class CRM_Contribute_Selector_Search extends CRM_Core_Selector_Base implements C * 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 @@ class CRM_Contribute_Selector_Search extends CRM_Core_Selector_Base implements C ]; } 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 8d3a8eae64..f7c598805c 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 ce08f0f6e3..47ccc247b8 100644 --- a/CRM/Contribute/StateMachine/ContributionPage.php +++ b/CRM/Contribute/StateMachine/ContributionPage.php @@ -52,7 +52,7 @@ class CRM_Contribute_StateMachine_ContributionPage extends CRM_Core_StateMachine $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 @@ class CRM_Contribute_StateMachine_ContributionPage extends CRM_Core_StateMachine '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 43c344cb5e..43ac47fa19 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 8b562c7c8d..2c6065350a 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 @@ class CRM_Contribute_Task extends CRM_Core_Task { * @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 @@ class CRM_Contribute_Task extends CRM_Core_Task { $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 d6aba8ff9e..5906f5e969 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 @@ class CRM_Contribute_Tokens extends \Civi\Token\AbstractTokenSubscriber { 'receipt_date', 'thankyou_date', 'tax_amount', - ); + ]; } /** @@ -63,13 +63,13 @@ class CRM_Contribute_Tokens extends \Civi\Token\AbstractTokenSubscriber { * @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 @@ class CRM_Contribute_Tokens extends \Civi\Token\AbstractTokenSubscriber { $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 bd6ac2c2f7..4e5e811ea5 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 @@ class CRM_Core_Action { // 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 @@ class CRM_Core_Action { 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 fe30d41619..af9acb87a3 100644 --- a/CRM/Core/BAO/ActionSchedule.php +++ b/CRM/Core/BAO/ActionSchedule.php @@ -58,9 +58,9 @@ class CRM_Core_BAO_ActionSchedule extends CRM_Core_DAO_ActionSchedule { 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 @@ class CRM_Core_BAO_ActionSchedule extends CRM_Core_DAO_ActionSchedule { * @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 @@ class CRM_Core_BAO_ActionSchedule extends CRM_Core_DAO_ActionSchedule { */ 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 @@ SELECT 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 @@ FROM civicrm_action_schedule cas * * @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 @@ FROM civicrm_action_schedule cas * @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 @@ FROM civicrm_action_schedule cas 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 @@ FROM civicrm_action_schedule cas 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 @@ FROM civicrm_action_schedule cas } // 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 @@ FROM civicrm_action_schedule cas * * @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 @@ FROM civicrm_action_schedule cas 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 @@ FROM civicrm_action_schedule cas * * @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 @@ FROM civicrm_action_schedule cas 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 @@ FROM civicrm_action_schedule cas 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 @@ FROM civicrm_action_schedule cas */ 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 @@ FROM civicrm_action_schedule cas = 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 @@ FROM civicrm_action_schedule cas '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 @@ FROM civicrm_action_schedule cas ->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 @@ FROM civicrm_action_schedule cas 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 @@ FROM civicrm_action_schedule cas $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 @@ FROM civicrm_action_schedule cas $userID ); - return array(); + return []; } /** @@ -603,7 +603,7 @@ FROM civicrm_action_schedule cas 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 @@ FROM civicrm_action_schedule cas } // 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 @@ FROM civicrm_action_schedule cas '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 @@ FROM civicrm_action_schedule cas } $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 @@ FROM civicrm_action_schedule cas * @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 @@ FROM civicrm_action_schedule cas * @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 @@ FROM civicrm_action_schedule cas * 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 c7a9d68b9e..8b57485017 100644 --- a/CRM/Core/BAO/Address.php +++ b/CRM/Core/BAO/Address.php @@ -55,7 +55,7 @@ class CRM_Core_BAO_Address extends CRM_Core_DAO_Address { 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 @@ class CRM_Core_BAO_Address extends CRM_Core_DAO_Address { } 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 @@ class CRM_Core_BAO_Address extends CRM_Core_DAO_Address { // $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 @@ class CRM_Core_BAO_Address extends CRM_Core_DAO_Address { 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 @@ class CRM_Core_BAO_Address extends CRM_Core_DAO_Address { '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 @@ class CRM_Core_BAO_Address extends CRM_Core_DAO_Address { ); 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 @@ class CRM_Core_BAO_Address extends CRM_Core_DAO_Address { $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 @@ class CRM_Core_BAO_Address extends CRM_Core_DAO_Address { 'is_billing', 'display', 'master_id', - ))) { + ])) { continue; } elseif (!CRM_Utils_System::isNull($value)) { @@ -462,14 +462,14 @@ class CRM_Core_BAO_Address extends CRM_Core_DAO_Address { 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 @@ class CRM_Core_BAO_Address extends CRM_Core_DAO_Address { 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 @@ class CRM_Core_BAO_Address extends CRM_Core_DAO_Address { * 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 @@ class CRM_Core_BAO_Address extends CRM_Core_DAO_Address { '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 @@ SELECT civicrm_address.id as address_id, civicrm_address.location_type_id as loc 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 @@ ORDER BY civicrm_address.is_primary DESC, address_id ASC"; * the array of adrress data */ public static function allEntityAddress(&$entityElements) { - $addresses = array(); + $addresses = []; if (empty($entityElements)) { return $addresses; } @@ -651,7 +651,7 @@ WHERE ev.id = %1 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 @@ ORDER BY civicrm_address.is_primary DESC, civicrm_address.location_type_id DESC, $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 @@ ORDER BY civicrm_address.is_primary DESC, civicrm_address.location_type_id DESC, $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 @@ ORDER BY civicrm_address.is_primary DESC, civicrm_address.location_type_id DESC, $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 @@ ORDER BY civicrm_address.is_primary DESC, civicrm_address.location_type_id DESC, } // 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 @@ ORDER BY civicrm_address.is_primary DESC, civicrm_address.location_type_id DESC, $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 @@ ORDER BY civicrm_address.is_primary DESC, civicrm_address.location_type_id DESC, } // 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 @@ ORDER BY civicrm_address.is_primary DESC, civicrm_address.location_type_id DESC, // now get the street unit. // supportable street unit formats. - $streetUnitFormats = array( + $streetUnitFormats = [ 'APT', 'APARTMENT', 'BSMT', @@ -829,19 +829,19 @@ ORDER BY civicrm_address.is_primary DESC, civicrm_address.location_type_id DESC, '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 @@ ORDER BY civicrm_address.is_primary DESC, civicrm_address.location_type_id DESC, $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 @@ ORDER BY civicrm_address.is_primary DESC, civicrm_address.location_type_id DESC, */ 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 @@ ORDER BY civicrm_address.is_primary DESC, civicrm_address.location_type_id DESC, return; } - $sharedLocations = array(); + $sharedLocations = []; $query = " SELECT is_primary, @@ -965,7 +965,7 @@ SELECT is_primary, 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 @@ SELECT is_primary, return; } - $addressFields = array( + $addressFields = [ 'city', 'county', 'country', @@ -992,7 +992,7 @@ SELECT is_primary, 'supplemental_address_1', 'supplemental_address_2', 'supplemental_address_3', - ); + ]; foreach ($fields as $name => & $values) { if (!is_array($values) || empty($values)) { @@ -1045,13 +1045,13 @@ SELECT is_primary, */ 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 @@ SELECT is_primary, * 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 @@ SELECT is_primary, } // 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 @@ SELECT is_primary, 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 @@ SELECT is_primary, 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 @@ SELECT is_primary, 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 @@ SELECT is_primary, CRM_Core_Session::setStatus($statusMessage, '', 'info'); } else { - return array( + return [ 'contactList' => $sharedContactList, 'count' => $addressCount, - ); + ]; } } @@ -1311,8 +1311,8 @@ SELECT is_primary, * * @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 f462b7ffca..780d00acda 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 @@ class CRM_Core_BAO_Block { $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 @@ class CRM_Core_BAO_Block { $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 @@ class CRM_Core_BAO_Block { * */ public static function getBlockIds($blockName, $contactId = NULL, $entityElements = NULL, $updateBlankLocInfo = FALSE) { - $allBlocks = array(); + $allBlocks = []; $name = ucfirst($blockName); if ($blockName == 'im') { @@ -226,15 +226,15 @@ class CRM_Core_BAO_Block { $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 @@ class CRM_Core_BAO_Block { // $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 @@ class CRM_Core_BAO_Block { // 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 3144e9ad98..368bcd97de 100644 --- a/CRM/Core/BAO/CMSUser.php +++ b/CRM/Core/BAO/CMSUser.php @@ -113,9 +113,9 @@ class CRM_Core_BAO_CMSUser { 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 @@ class CRM_Core_BAO_CMSUser { $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 @@ class CRM_Core_BAO_CMSUser { $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 @@ class CRM_Core_BAO_CMSUser { // 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 793ee064c4..ffdcfa7b31 100644 --- a/CRM/Core/BAO/Cache.php +++ b/CRM/Core/BAO/Cache.php @@ -73,7 +73,7 @@ class CRM_Core_BAO_Cache extends CRM_Core_DAO_Cache { } if (self::$_cache === NULL) { - self::$_cache = array(); + self::$_cache = []; } $argString = "CRM_CT_{$group}_{$path}_{$componentID}"; @@ -115,7 +115,7 @@ class CRM_Core_BAO_Cache extends CRM_Core_DAO_Cache { } if (self::$_cache === NULL) { - self::$_cache = array(); + self::$_cache = []; } $argString = "CRM_CT_CI_{$group}_{$componentID}"; @@ -128,7 +128,7 @@ class CRM_Core_BAO_Cache extends CRM_Core_DAO_Cache { $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 @@ class CRM_Core_BAO_Cache extends CRM_Core_DAO_Cache { } 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 @@ class CRM_Core_BAO_Cache extends CRM_Core_DAO_Cache { // "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 @@ class CRM_Core_BAO_Cache extends CRM_Core_DAO_Cache { 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 @@ class CRM_Core_BAO_Cache extends CRM_Core_DAO_Cache { * @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 48ae52994d..986a4bcbf4 100644 --- a/CRM/Core/BAO/Cache/Psr16.php +++ b/CRM/Core/BAO/Cache/Psr16.php @@ -62,7 +62,7 @@ class CRM_Core_BAO_Cache_Psr16 { $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 0338e56f0e..946890452e 100644 --- a/CRM/Core/BAO/ConfigSetting.php +++ b/CRM/Core/BAO/ConfigSetting.php @@ -108,7 +108,7 @@ class CRM_Core_BAO_ConfigSetting { if ($domain->config_backend) { $defaults = unserialize($domain->config_backend); if ($defaults === FALSE || !is_array($defaults)) { - $defaults = array(); + $defaults = []; return FALSE; } @@ -231,7 +231,7 @@ class CRM_Core_BAO_ConfigSetting { * @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 @@ class CRM_Core_BAO_ConfigSetting { 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 @@ class CRM_Core_BAO_ConfigSetting { // 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 @@ class CRM_Core_BAO_ConfigSetting { * @return array */ public static function skipVars() { - return array( + return [ 'dsn', 'templateCompileDir', 'userFrameworkDSN', @@ -386,7 +386,7 @@ class CRM_Core_BAO_ConfigSetting { 'autocompleteContactReference', 'checksumTimeout', 'checksum_timeout', - ); + ]; } /** @@ -410,26 +410,26 @@ class CRM_Core_BAO_ConfigSetting { * @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 1a64a575c8..df195660c0 100644 --- a/CRM/Core/BAO/Country.php +++ b/CRM/Core/BAO/Country.php @@ -47,7 +47,7 @@ class CRM_Core_BAO_Country extends CRM_Core_DAO_Country { 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 @@ class CRM_Core_BAO_Country extends CRM_Core_DAO_Country { 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 @@ class CRM_Core_BAO_Country extends CRM_Core_DAO_Country { 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 df5d09adaf..8fa78cbf7a 100644 --- a/CRM/Core/BAO/CustomGroup.php +++ b/CRM/Core/BAO/CustomGroup.php @@ -64,11 +64,11 @@ class CRM_Core_BAO_CustomGroup extends CRM_Core_DAO_CustomGroup { $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 @@ class CRM_Core_BAO_CustomGroup extends CRM_Core_DAO_CustomGroup { 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 @@ class CRM_Core_BAO_CustomGroup extends CRM_Core_DAO_CustomGroup { $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 @@ class CRM_Core_BAO_CustomGroup extends CRM_Core_DAO_CustomGroup { '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 @@ class CRM_Core_BAO_CustomGroup extends CRM_Core_DAO_CustomGroup { 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 @@ class CRM_Core_BAO_CustomGroup extends CRM_Core_DAO_CustomGroup { 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 @@ class CRM_Core_BAO_CustomGroup extends CRM_Core_DAO_CustomGroup { */ 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 @@ class CRM_Core_BAO_CustomGroup extends CRM_Core_DAO_CustomGroup { } if (!is_array($subTypes)) { if (empty($subTypes)) { - $subTypes = array(); + $subTypes = []; } else { if (stristr($subTypes, ',')) { @@ -391,8 +391,8 @@ class CRM_Core_BAO_CustomGroup extends CRM_Core_DAO_CustomGroup { // 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 @@ class CRM_Core_BAO_CustomGroup extends CRM_Core_DAO_CustomGroup { 'time_format', 'option_group_id', 'in_selector', - ), - 'custom_group' => array( + ], + 'custom_group' => [ 'id', 'name', 'table_name', @@ -427,8 +427,8 @@ class CRM_Core_BAO_CustomGroup extends CRM_Core_DAO_CustomGroup { '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 @@ class CRM_Core_BAO_CustomGroup extends CRM_Core_DAO_CustomGroup { // 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 @@ LEFT JOIN civicrm_custom_field ON (civicrm_custom_field.custom_group_id = civicr $in = "'$entityType'"; } - $params = array(); + $params = []; $sqlParamKey = 1; if (!empty($subTypes)) { foreach ($subTypes as $key => $subType) { @@ -497,7 +497,7 @@ WHERE civicrm_custom_group.is_active = 1 "; 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 @@ WHERE civicrm_custom_group.is_active = 1 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 @@ ORDER BY civicrm_custom_group.weight, } 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 @@ ORDER BY civicrm_custom_group.weight, } // 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 @@ ORDER BY civicrm_custom_group.weight, } $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 @@ ORDER BY civicrm_custom_group.weight, } if (!empty($customValueTables)) { - $groupTree['info'] = array('tables' => $customValueTables); + $groupTree['info'] = ['tables' => $customValueTables]; } $cache->set($cacheKey, $groupTree); @@ -628,8 +628,8 @@ ORDER BY civicrm_custom_group.weight, } // 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 @@ ORDER BY civicrm_custom_group.weight, 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 @@ ORDER BY civicrm_custom_group.weight, } $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 @@ ORDER BY civicrm_custom_group.weight, $offset = $singleRecord - 1; $query .= " LIMIT {$offset}, 1"; } - self::buildTreeEntityDataFromQuery($groupTree, $query, array($table), $singleRecord); + self::buildTreeEntityDataFromQuery($groupTree, $query, [$table], $singleRecord); } } @@ -882,23 +882,23 @@ ORDER BY civicrm_custom_group.weight, $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 @@ ORDER BY civicrm_custom_group.weight, } } 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 @@ ORDER BY civicrm_custom_group.weight, */ 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 @@ ORDER BY civicrm_custom_group.weight, 'is_view', 'option_group_id', 'in_selector', - ), - 'civicrm_custom_group' => array( + ], + 'civicrm_custom_group' => [ 'id', 'name', 'title', @@ -1031,25 +1031,25 @@ ORDER BY civicrm_custom_group.weight, '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 @@ ORDER BY civicrm_custom_group.weight, } if ($extends) { - $clause = array(); + $clause = []; foreach ($extends as $e) { $clause[] = "civicrm_custom_group.extends = '$e'"; } @@ -1072,7 +1072,7 @@ ORDER BY civicrm_custom_group.weight, 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 @@ ORDER BY civicrm_custom_group.weight, // 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 @@ ORDER BY civicrm_custom_group.weight, $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 @@ ORDER BY civicrm_custom_group.weight, // 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 @@ ORDER BY civicrm_custom_group.weight, // 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 @@ ORDER BY civicrm_custom_group.weight, $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 @@ ORDER BY civicrm_custom_group.weight, 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 @@ ORDER BY civicrm_custom_group.weight, 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 @@ ORDER BY civicrm_custom_group.weight, // 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 @@ ORDER BY civicrm_custom_group.weight, $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 @@ ORDER BY civicrm_custom_group.weight, */ 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 @@ ORDER BY civicrm_custom_group.weight, $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 @@ ORDER BY civicrm_custom_group.weight, 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 @@ SELECT IF( EXISTS(SELECT name FROM civicrm_contact_type WHERE name like %1), 1, * @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 @@ SELECT IF( EXISTS(SELECT name FROM civicrm_contact_type WHERE name like %1), 1, * @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 @@ SELECT IF( EXISTS(SELECT name FROM civicrm_contact_type WHERE name like %1), 1, * @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 @@ SELECT IF( EXISTS(SELECT name FROM civicrm_contact_type WHERE name like %1), 1, $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 @@ SELECT IF( EXISTS(SELECT name FROM civicrm_contact_type WHERE name like %1), 1, $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 @@ SELECT IF( EXISTS(SELECT name FROM civicrm_contact_type WHERE name like %1), 1, return count($details[$gID]); } else { - $countValue = array(); + $countValue = []; foreach ($details as $key => $value) { $countValue[$key] = count($details[$key]); } @@ -2058,7 +2058,7 @@ SELECT IF( EXISTS(SELECT name FROM civicrm_contact_type WHERE name like %1), 1, return NULL; } - $groupLabels = array(); + $groupLabels = []; $fIds = "(" . implode(',', $fieldIds) . ")"; $query = " @@ -2070,12 +2070,12 @@ SELECT civicrm_custom_group.id as groupID, civicrm_custom_group.title as groupT $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 @@ SELECT civicrm_custom_group.id as groupID, civicrm_custom_group.title as groupT * 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 @@ SELECT civicrm_custom_group.id as groupID, civicrm_custom_group.title as groupT list($callback, $args) = explode(';', trim($ovValues['description'])); if (empty($args)) { - $args = array(); + $args = []; } if (!is_array($args)) { @@ -2184,7 +2184,7 @@ SELECT civicrm_custom_group.id as groupID, civicrm_custom_group.title as groupT $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 @@ SELECT civicrm_custom_group.id as groupID, civicrm_custom_group.title as groupT * @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 99133b4a93..f667ba4d1f 100644 --- a/CRM/Core/BAO/CustomOption.php +++ b/CRM/Core/BAO/CustomOption.php @@ -74,18 +74,18 @@ class CRM_Core_BAO_CustomOption { $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 @@ class CRM_Core_BAO_CustomOption { * -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 @@ class CRM_Core_BAO_CustomOption { 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 @@ class CRM_Core_BAO_CustomOption { $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 @@ class CRM_Core_BAO_CustomOption { $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 @@ FROM civicrm_option_value v, 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 @@ AND g.id = v.option_group_id"; 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 @@ FROM civicrm_custom_group g, 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 @@ WHERE id = %2"; 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 @@ WHERE id = %2"; $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 @@ SET {$dao->columnName} = REPLACE( {$dao->columnName}, %1, %2 )"; $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 29335eaec8..f3efb735d3 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 @@ SELECT f.id, f.label, f.data_type, // 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 @@ SELECT f.id, f.label, f.data_type, '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 @@ SELECT f.id, f.label, f.data_type, 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 @@ SELECT f.id, f.label, f.data_type, // 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 @@ SELECT f.id, f.label, f.data_type, 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 @@ SELECT f.id, f.label, f.data_type, 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 @@ SELECT f.id, f.label, f.data_type, $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 @@ SELECT f.id, f.label, f.data_type, 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 @@ SELECT f.id, f.label, f.data_type, $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 @@ SELECT f.id, f.label, f.data_type, } } - 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 5e6a90fb66..305567fcbe 100644 --- a/CRM/Core/BAO/CustomValue.php +++ b/CRM/Core/BAO/CustomValue.php @@ -183,14 +183,14 @@ class CRM_Core_BAO_CustomValue extends CRM_Core_DAO { 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 @@ class CRM_Core_BAO_CustomValue extends CRM_Core_DAO { $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 bd4807cc1c..dac03b0075 100644 --- a/CRM/Core/BAO/CustomValueTable.php +++ b/CRM/Core/BAO/CustomValueTable.php @@ -46,7 +46,7 @@ class CRM_Core_BAO_CustomValueTable { return; } - $paramFieldsExtendContactForEntities = array(); + $paramFieldsExtendContactForEntities = []; foreach ($customParams as $tableName => $tables) { foreach ($tables as $index => $fields) { @@ -55,8 +55,8 @@ class CRM_Core_BAO_CustomValueTable { $hookOP = NULL; $entityID = NULL; $isMultiple = FALSE; - $set = array(); - $params = array(); + $set = []; + $params = []; $count = 1; foreach ($fields as $field) { if (!$sqlOP) { @@ -66,7 +66,7 @@ class CRM_Core_BAO_CustomValueTable { 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 @@ class CRM_Core_BAO_CustomValueTable { 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 @@ class CRM_Core_BAO_CustomValueTable { 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 @@ class CRM_Core_BAO_CustomValueTable { } else { $set[$field['column_name']] = "%{$count}"; - $params[$count] = array($value, $type); + $params[$count] = [$value, $type]; $count++; } @@ -242,7 +242,7 @@ class CRM_Core_BAO_CustomValueTable { } if (!empty($set)) { - $setClause = array(); + $setClause = []; foreach ($set as $n => $v) { $setClause[] = "$n = $v"; } @@ -250,7 +250,7 @@ class CRM_Core_BAO_CustomValueTable { 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 @@ class CRM_Core_BAO_CustomValueTable { } 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 @@ class CRM_Core_BAO_CustomValueTable { * @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 @@ class CRM_Core_BAO_CustomValueTable { '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 @@ class CRM_Core_BAO_CustomValueTable { $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 @@ class CRM_Core_BAO_CustomValueTable { return NULL; } - $cond = array(); + $cond = []; if ($entityType) { $cond[] = "cg.extends IN ( '$entityType' )"; } @@ -471,12 +471,12 @@ AND $cond "; $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 @@ AND $cond $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 @@ AND $cond // 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 @@ AND cf.id IN ( $fieldIDList ) "; $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 @@ AND cf.id IN ( $fieldIDList ) // 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 @@ AND cf.id IN ( $fieldIDList ) '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 @@ AND cf.id IN ( $fieldIDList ) } 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 @@ AND cf.id IN ( $fieldIDList ) 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 @@ AND cf.id IN ( $fieldIDList ) // 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 @@ AND cf.id IN ( $fieldIDList ) // 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 8550e6cafc..1bfd6812d2 100644 --- a/CRM/Core/BAO/Dashboard.php +++ b/CRM/Core/BAO/Dashboard.php @@ -64,7 +64,7 @@ class CRM_Core_BAO_Dashboard extends CRM_Core_DAO_Dashboard { * 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 @@ class CRM_Core_BAO_Dashboard extends CRM_Core_DAO_Dashboard { continue; } - $values = array(); + $values = []; CRM_Core_DAO::storeValues($dao, $values); $dashlets[$dao->id] = $values; } @@ -101,15 +101,15 @@ class CRM_Core_BAO_Dashboard extends CRM_Core_DAO_Dashboard { */ 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 @@ class CRM_Core_BAO_Dashboard extends CRM_Core_DAO_Dashboard { '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 @@ class CRM_Core_BAO_Dashboard extends CRM_Core_DAO_Dashboard { '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 @@ class CRM_Core_BAO_Dashboard extends CRM_Core_DAO_Dashboard { * @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 @@ class CRM_Core_BAO_Dashboard extends CRM_Core_DAO_Dashboard { * @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 @@ class CRM_Core_BAO_Dashboard extends CRM_Core_DAO_Dashboard { 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 @@ class CRM_Core_BAO_Dashboard extends CRM_Core_DAO_Dashboard { 'cache_minutes' => $dashlet['cache_minutes'], 'url' => $dashlet['url'], 'fullscreen_url' => CRM_Utils_Array::value('fullscreen_url', $dashlet), - ); + ]; } } } @@ -271,10 +271,10 @@ class CRM_Core_BAO_Dashboard extends CRM_Core_DAO_Dashboard { } // 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 @@ class CRM_Core_BAO_Dashboard extends CRM_Core_DAO_Dashboard { 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 @@ class CRM_Core_BAO_Dashboard extends CRM_Core_DAO_Dashboard { // 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 @@ class CRM_Core_BAO_Dashboard extends CRM_Core_DAO_Dashboard { */ 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 f2f4faff05..dfef62e328 100644 --- a/CRM/Core/BAO/Discount.php +++ b/CRM/Core/BAO/Discount.php @@ -92,7 +92,7 @@ class CRM_Core_BAO_Discount extends CRM_Core_DAO_Discount { * 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 fd2632785c..bfbb06fc64 100644 --- a/CRM/Core/BAO/Domain.php +++ b/CRM/Core/BAO/Domain.php @@ -103,9 +103,9 @@ class CRM_Core_BAO_Domain extends CRM_Core_DAO_Domain { 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 @@ class CRM_Core_BAO_Domain extends CRM_Core_DAO_Domain { $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 @@ class CRM_Core_BAO_Domain extends CRM_Core_DAO_Domain { $groupID = self::getGroupId(); if ($groupID) { - $contactIDs = array($contactID); + $contactIDs = [$contactID]; CRM_Contact_BAO_GroupContact::addContactsToGroup($contactIDs, $groupID); return $groupID; @@ -257,7 +257,7 @@ class CRM_Core_BAO_Domain extends CRM_Core_DAO_Domain { */ public static function getChildGroupIds() { $domainGroupID = self::getGroupId(); - $childGrps = array(); + $childGrps = []; if ($domainGroupID) { $childGrps = CRM_Contact_BAO_GroupNesting::getChildGroupIds($domainGroupID); @@ -273,7 +273,7 @@ class CRM_Core_BAO_Domain extends CRM_Core_DAO_Domain { */ public static function getContactList() { $siteGroups = CRM_Core_BAO_Domain::getChildGroupIds(); - $siteContacts = array(); + $siteContacts = []; if (!empty($siteGroups)) { $query = " @@ -296,18 +296,18 @@ class CRM_Core_BAO_Domain extends CRM_Core_DAO_Domain { * 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 @@ class CRM_Core_BAO_Domain extends CRM_Core_DAO_Domain { } // 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 7fac7ccfb9..20c6875d6a 100644 --- a/CRM/Core/BAO/Email.php +++ b/CRM/Core/BAO/Email.php @@ -151,25 +151,25 @@ LEFT JOIN civicrm_email ON ( civicrm_email.contact_id = civicrm_contact.id ) 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 @@ AND e.id IN (loc.email_id, loc.email_2_id) 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 @@ ORDER BY e.is_primary DESC, email_id ASC "; //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 @@ AND reset_date IS NULL * @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 5af715734f..e7ec387c79 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 @@ class CRM_Core_BAO_EntityTag extends CRM_Core_DAO_EntityTag { //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 @@ class CRM_Core_BAO_EntityTag extends CRM_Core_DAO_EntityTag { //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 @@ class CRM_Core_BAO_EntityTag extends CRM_Core_DAO_EntityTag { 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 @@ class CRM_Core_BAO_EntityTag extends CRM_Core_DAO_EntityTag { } //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 @@ class CRM_Core_BAO_EntityTag extends CRM_Core_DAO_EntityTag { 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 @@ class CRM_Core_BAO_EntityTag extends CRM_Core_DAO_EntityTag { } //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 @@ class CRM_Core_BAO_EntityTag extends CRM_Core_DAO_EntityTag { // 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 @@ class CRM_Core_BAO_EntityTag extends CRM_Core_DAO_EntityTag { * 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 @@ class CRM_Core_BAO_EntityTag extends CRM_Core_DAO_EntityTag { * @return array */ public static function getContactTags($contactID, $count = FALSE) { - $contactTags = array(); + $contactTags = []; if (!$count) { $select = "SELECT ct.id, ct.name "; } @@ -373,7 +373,7 @@ class CRM_Core_BAO_EntityTag extends CRM_Core_DAO_EntityTag { * @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 @@ class CRM_Core_BAO_EntityTag extends CRM_Core_DAO_EntityTag { $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 @@ class CRM_Core_BAO_EntityTag extends CRM_Core_DAO_EntityTag { * @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 @@ class CRM_Core_BAO_EntityTag extends CRM_Core_DAO_EntityTag { "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 @@ class CRM_Core_BAO_EntityTag extends CRM_Core_DAO_EntityTag { * * @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 @@ class CRM_Core_BAO_EntityTag extends CRM_Core_DAO_EntityTag { // 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 @@ class CRM_Core_BAO_EntityTag extends CRM_Core_DAO_EntityTag { $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 8f461189b2..8bbe63fffa 100644 --- a/CRM/Core/BAO/Extension.php +++ b/CRM/Core/BAO/Extension.php @@ -82,10 +82,10 @@ class CRM_Core_BAO_Extension extends CRM_Core_DAO_Extension { */ 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 @@ class CRM_Core_BAO_Extension extends CRM_Core_DAO_Extension { */ 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 5e1a32def0..8845687292 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 @@ class CRM_Core_BAO_File extends CRM_Core_DAO_File { $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 @@ class CRM_Core_BAO_File extends CRM_Core_DAO_File { // 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 @@ class CRM_Core_BAO_File extends CRM_Core_DAO_File { 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 @@ class CRM_Core_BAO_File extends CRM_Core_DAO_File { 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 @@ class CRM_Core_BAO_File extends CRM_Core_DAO_File { 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 @@ class CRM_Core_BAO_File extends CRM_Core_DAO_File { } //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 @@ WHERE CEF.entity_table = %1 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 @@ AND CEF.entity_id = %2"; $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 @@ AND CEF.entity_id = %2"; $currentAttachments = self::getEntityFile($entityTable, $entityID); if (!empty($currentAttachments)) { - $currentAttachmentURL = array(); + $currentAttachmentURL = []; foreach ($currentAttachments as $fileID => $attach) { $currentAttachmentURL[] = $attach['href']; } @@ -566,7 +566,7 @@ AND CEF.entity_id = %2"; $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 @@ AND CEF.entity_id = %2"; // 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 @@ AND CEF.entity_id = %2"; 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 @@ AND CEF.entity_id = %2"; * */ 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 @@ AND CEF.entity_id = %2"; * @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 f6ec9f6c65..ee5c3267c7 100644 --- a/CRM/Core/BAO/FinancialTrxn.php +++ b/CRM/Core/BAO/FinancialTrxn.php @@ -66,12 +66,12 @@ class CRM_Core_BAO_FinancialTrxn extends CRM_Financial_DAO_FinancialTrxn { } // 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 @@ class CRM_Core_BAO_FinancialTrxn extends CRM_Financial_DAO_FinancialTrxn { $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 @@ class CRM_Core_BAO_FinancialTrxn extends CRM_Financial_DAO_FinancialTrxn { * */ 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 @@ class CRM_Core_BAO_FinancialTrxn extends CRM_Financial_DAO_FinancialTrxn { 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 @@ LEFT JOIN civicrm_entity_financial_trxn AS ceft ON ft.financial_trxn_id = ceft.e 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 @@ WHERE ef2.financial_trxn_id =%1 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 @@ WHERE ef2.financial_trxn_id =%1 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 @@ LEFT JOIN civicrm_financial_item AS fi ON fi.id = ft.entity_id AND fi.entity_tab 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 @@ LEFT JOIN civicrm_entity_financial_trxn ceft1 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 @@ WHERE ceft.entity_id = %1"; $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 @@ WHERE ceft.entity_id = %1"; '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 @@ WHERE ceft.entity_id = %1"; $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 @@ WHERE ceft.entity_id = %1"; '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 @@ WHERE ceft.entity_id = %1"; * @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 @@ WHERE ceft.entity_id = %1"; ) { return; } - $trxnParams = array( + $trxnParams = [ 'contribution_id' => $contributionDetails->id, 'fee_amount' => '0.00', 'currency' => $contributionDetails->currency, @@ -578,9 +578,9 @@ WHERE ceft.entity_id = %1"; '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 @@ WHERE ceft.entity_id = %1"; $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 @@ WHERE ceft.entity_id = %1"; 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 @@ WHERE ceft.entity_id = %1"; $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 @@ WHERE ceft.entity_id = %1"; * */ 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 @@ WHERE ceft.entity_id = %1"; } $financialTrxnId = $financialTrxn['financial_trxn_id']; - $trxnparams = array('id' => $financialTrxnId); + $trxnparams = ['id' => $financialTrxnId]; if (isset($cardType)) { $trxnparams['card_type_id'] = $cardType; } @@ -714,19 +714,19 @@ WHERE ceft.entity_id = %1"; // 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 1fdfe6cd66..a64d22341e 100644 --- a/CRM/Core/BAO/IM.php +++ b/CRM/Core/BAO/IM.php @@ -98,20 +98,20 @@ WHERE 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 @@ AND cim.id IN (loc.im_id, loc.im_2_id) 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 fddea464ae..0b9a32272c 100644 --- a/CRM/Core/BAO/Job.php +++ b/CRM/Core/BAO/Job.php @@ -152,14 +152,14 @@ class CRM_Core_BAO_Job extends CRM_Core_DAO_Job { * * @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 3690980e77..96c4ffbf62 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 @@ class CRM_Core_BAO_LabelFormat extends CRM_Core_DAO_OptionValue { * 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 @@ class CRM_Core_BAO_LabelFormat extends CRM_Core_DAO_OptionValue { * 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 @@ class CRM_Core_BAO_LabelFormat extends CRM_Core_DAO_OptionValue { * array of alignments */ public static function getTextAlignments() { - return array( + return [ 'R' => ts('Right'), 'L' => ts('Left'), 'C' => ts('Center'), - ); + ]; } /** @@ -230,11 +230,11 @@ class CRM_Core_BAO_LabelFormat extends CRM_Core_DAO_OptionValue { * array of alignments */ public static function getFontStyles() { - return array( + return [ '' => ts('Normal'), 'B' => ts('Bold'), 'I' => ts('Italic'), - ); + ]; } /** @@ -283,7 +283,7 @@ class CRM_Core_BAO_LabelFormat extends CRM_Core_DAO_OptionValue { * (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 @@ class CRM_Core_BAO_LabelFormat extends CRM_Core_DAO_OptionValue { * 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 @@ class CRM_Core_BAO_LabelFormat extends CRM_Core_DAO_OptionValue { * (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 @@ class CRM_Core_BAO_LabelFormat extends CRM_Core_DAO_OptionValue { $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 @@ class CRM_Core_BAO_LabelFormat extends CRM_Core_DAO_OptionValue { $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 99b8758540..0cd00b5763 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 @@ class CRM_Core_BAO_Location extends CRM_Core_DAO { 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 @@ class CRM_Core_BAO_Location extends CRM_Core_DAO { */ 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 @@ SELECT e.loc_block_id as locId 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 @@ WHERE e.id = %1"; $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 @@ WHERE e.id = %1"; '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 @@ WHERE e.id = %1"; 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 @@ WHERE e.id = %1"; $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 @@ WHERE e.id = %1"; */ 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 @@ WHERE e.id = %1"; $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 @@ WHERE e.id = %1"; } // 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 @@ WHERE e.id = %1"; */ 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 @@ WHERE e.id = %1"; 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 00c92b4c6b..269284ccca 100644 --- a/CRM/Core/BAO/LocationType.php +++ b/CRM/Core/BAO/LocationType.php @@ -92,8 +92,8 @@ class CRM_Core_BAO_LocationType extends CRM_Core_DAO_LocationType { */ 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 @@ class CRM_Core_BAO_LocationType extends CRM_Core_DAO_LocationType { */ 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 @@ class CRM_Core_BAO_LocationType extends CRM_Core_DAO_LocationType { * */ 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 10b3eb3b1b..a22a4c1eef 100644 --- a/CRM/Core/BAO/Log.php +++ b/CRM/Core/BAO/Log.php @@ -57,12 +57,12 @@ class CRM_Core_BAO_Log extends CRM_Core_DAO_Log { 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 @@ class CRM_Core_BAO_Log extends CRM_Core_DAO_Log { $userID = NULL ) { if (!self::$_processed) { - self::$_processed = array(); + self::$_processed = []; } if (!$userID) { @@ -128,7 +128,7 @@ class CRM_Core_BAO_Log extends CRM_Core_DAO_Log { self::$_processed[$contactID][$userID] = 1; } else { - self::$_processed[$contactID] = array($userID => 1); + self::$_processed[$contactID] = [$userID => 1]; } $logData = "$tableName,$tableID"; @@ -183,8 +183,8 @@ UPDATE civicrm_log $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 c5ec789a77..05168c3e3a 100644 --- a/CRM/Core/BAO/MailSettings.php +++ b/CRM/Core/BAO/MailSettings.php @@ -51,7 +51,7 @@ class CRM_Core_BAO_MailSettings extends CRM_Core_DAO_MailSettings { * 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 @@ class CRM_Core_BAO_MailSettings extends CRM_Core_DAO_MailSettings { //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 faccc831cb..ccf17e6b79 100644 --- a/CRM/Core/BAO/Mapping.php +++ b/CRM/Core/BAO/Mapping.php @@ -115,14 +115,14 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { * 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 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { // 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 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { $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 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { } } - return array( + return [ $mappingName, $mappingContactType, $mappingLocation, @@ -238,7 +238,7 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { $mappingOperator, $mappingValue, $mappingWebsiteType, - ); + ]; } /** @@ -268,7 +268,7 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { * 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 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { */ 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 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { 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 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { $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 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { $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 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { 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 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { } // 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 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { 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 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { 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 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { //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 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { } //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 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { 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 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { 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 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { 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 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { } //special fields that have location, hack for primary location - $specialFields = array( + $specialFields = [ 'street_address', 'supplemental_address_1', 'supplemental_address_2', @@ -714,7 +714,7 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { 'phone', 'email', 'im', - ); + ]; if (isset($mappingId)) { list($mappingName, $mappingContactType, $mappingLocation, $mappingPhoneType, $mappingImProvider, @@ -741,13 +741,13 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { $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 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { $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 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { $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 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { $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 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { 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 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { 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 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { 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 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { $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 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { $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 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { } 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 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { 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 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { * 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 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { // 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 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { } 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 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { * @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 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping { 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 d9fa8f2f7c..31a6f7369f 100644 --- a/CRM/Core/BAO/MessageTemplate.php +++ b/CRM/Core/BAO/MessageTemplate.php @@ -157,7 +157,7 @@ class CRM_Core_BAO_MessageTemplate extends CRM_Core_DAO_MessageTemplate { 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 @@ class CRM_Core_BAO_MessageTemplate extends CRM_Core_DAO_MessageTemplate { * @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 @@ class CRM_Core_BAO_MessageTemplate extends CRM_Core_DAO_MessageTemplate { $domain = CRM_Core_BAO_Domain::getDomain(); $result = NULL; - $hookTokens = array(); + $hookTokens = []; if ($messageTemplates->find(TRUE)) { $body_text = $messageTemplates->msg_text; @@ -219,7 +219,7 @@ class CRM_Core_BAO_MessageTemplate extends CRM_Core_DAO_MessageTemplate { $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 @@ class CRM_Core_BAO_MessageTemplate extends CRM_Core_DAO_MessageTemplate { 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 @@ class CRM_Core_BAO_MessageTemplate extends CRM_Core_DAO_MessageTemplate { $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 @@ class CRM_Core_BAO_MessageTemplate extends CRM_Core_DAO_MessageTemplate { $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 @@ class CRM_Core_BAO_MessageTemplate extends CRM_Core_DAO_MessageTemplate { $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 @@ class CRM_Core_BAO_MessageTemplate extends CRM_Core_DAO_MessageTemplate { $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 @@ class CRM_Core_BAO_MessageTemplate extends CRM_Core_DAO_MessageTemplate { $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 @@ class CRM_Core_BAO_MessageTemplate extends CRM_Core_DAO_MessageTemplate { * 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 @@ class CRM_Core_BAO_MessageTemplate extends CRM_Core_DAO_MessageTemplate { // 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 @@ class CRM_Core_BAO_MessageTemplate extends CRM_Core_DAO_MessageTemplate { '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 @@ class CRM_Core_BAO_MessageTemplate extends CRM_Core_DAO_MessageTemplate { $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 @@ class CRM_Core_BAO_MessageTemplate extends CRM_Core_DAO_MessageTemplate { 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 @@ class CRM_Core_BAO_MessageTemplate extends CRM_Core_DAO_MessageTemplate { 'groupName' => $params['groupName'], 'valueName' => $params['valueName'], 'messageTemplateID' => $params['messageTemplateID'], - ); + ]; $dao->free(); CRM_Utils_Hook::alterMailContent($mailContent); @@ -464,7 +464,7 @@ class CRM_Core_BAO_MessageTemplate extends CRM_Core_DAO_MessageTemplate { // 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 @@ class CRM_Core_BAO_MessageTemplate extends CRM_Core_DAO_MessageTemplate { $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 @@ class CRM_Core_BAO_MessageTemplate extends CRM_Core_DAO_MessageTemplate { $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 @@ class CRM_Core_BAO_MessageTemplate extends CRM_Core_DAO_MessageTemplate { 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 @@ class CRM_Core_BAO_MessageTemplate extends CRM_Core_DAO_MessageTemplate { $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 @@ class CRM_Core_BAO_MessageTemplate extends CRM_Core_DAO_MessageTemplate { 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 @@ class CRM_Core_BAO_MessageTemplate extends CRM_Core_DAO_MessageTemplate { $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 @@ class CRM_Core_BAO_MessageTemplate extends CRM_Core_DAO_MessageTemplate { } } - 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 7e025198b6..56bd323332 100644 --- a/CRM/Core/BAO/Navigation.php +++ b/CRM/Core/BAO/Navigation.php @@ -174,7 +174,7 @@ SELECT id, label, parent_id, weight, is_active, name 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 @@ FROM civicrm_navigation WHERE domain_id = $domainID"; $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 @@ FROM civicrm_navigation WHERE domain_id = $domainID"; 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 @@ FROM civicrm_navigation WHERE domain_id = $domainID"; */ 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 @@ FROM civicrm_navigation WHERE domain_id = $domainID"; */ public static function buildNavigationTree() { $domainID = CRM_Core_Config::domainID(); - $navigationTree = array(); + $navigationTree = []; $navigationMenu = new self(); $navigationMenu->domain_id = $domainID; @@ -255,8 +255,8 @@ FROM civicrm_navigation WHERE domain_id = $domainID"; $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 @@ FROM civicrm_navigation WHERE domain_id = $domainID"; 'parentID' => $navigationMenu->parent_id, 'navID' => $navigationMenu->id, 'active' => $navigationMenu->is_active, - ), - ); + ], + ]; } return self::buildTree($navigationTree); @@ -284,7 +284,7 @@ FROM civicrm_navigation WHERE domain_id = $domainID"; * @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 @@ FROM civicrm_navigation WHERE domain_id = $domainID"; if (isset($val['attributes']['separator']) && $val['attributes']['separator'] == 2) { $navigationString .= ''; } - $removeCharacters = array('/', '!', '&', '*', ' ', '(', ')', '.'); + $removeCharacters = ['/', '!', '&', '*', ' ', '(', ')', '.']; $navigationString .= '
  • ' . $name; self::recurseNavigation($val, $navigationString, $skipMenuItems); } @@ -430,7 +430,7 @@ FROM civicrm_navigation WHERE domain_id = $domainID"; // 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 @@ FROM civicrm_navigation WHERE domain_id = $domainID"; $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 @@ FROM civicrm_navigation WHERE domain_id = $domainID"; 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 @@ FROM civicrm_navigation WHERE domain_id = $domainID"; * @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 @@ FROM civicrm_navigation WHERE domain_id = $domainID"; '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 @@ FROM civicrm_navigation WHERE domain_id = $domainID"; $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 @@ FROM civicrm_navigation WHERE domain_id = $domainID"; 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 @@ FROM civicrm_navigation WHERE domain_id = $domainID"; 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 7dad2b24db..62561838fe 100644 --- a/CRM/Core/BAO/OpenID.php +++ b/CRM/Core/BAO/OpenID.php @@ -116,20 +116,20 @@ WHERE 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 d2b06edd53..ca491c19fc 100644 --- a/CRM/Core/BAO/OptionGroup.php +++ b/CRM/Core/BAO/OptionGroup.php @@ -87,7 +87,7 @@ class CRM_Core_BAO_OptionGroup extends CRM_Core_DAO_OptionGroup { * * @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 @@ class CRM_Core_BAO_OptionGroup extends CRM_Core_DAO_OptionGroup { * 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 @@ class CRM_Core_BAO_OptionGroup extends CRM_Core_DAO_OptionGroup { * 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 959b77d5e4..a681756418 100644 --- a/CRM/Core/BAO/OptionValue.php +++ b/CRM/Core/BAO/OptionValue.php @@ -53,9 +53,9 @@ class CRM_Core_BAO_OptionValue extends CRM_Core_DAO_OptionValue { 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 @@ class CRM_Core_BAO_OptionValue extends CRM_Core_DAO_OptionValue { */ 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 @@ class CRM_Core_BAO_OptionValue extends CRM_Core_DAO_OptionValue { * @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 @@ class CRM_Core_BAO_OptionValue extends CRM_Core_DAO_OptionValue { } } - $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 @@ class CRM_Core_BAO_OptionValue extends CRM_Core_DAO_OptionValue { $dao->fetch(); - return array($dao->label, $dao->description); + return [$dao->label, $dao->description]; } /** @@ -355,18 +355,18 @@ class CRM_Core_BAO_OptionValue extends CRM_Core_DAO_OptionValue { // 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 @@ class CRM_Core_BAO_OptionValue extends CRM_Core_DAO_OptionValue { $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 @@ class CRM_Core_BAO_OptionValue extends CRM_Core_DAO_OptionValue { 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 @@ class CRM_Core_BAO_OptionValue extends CRM_Core_DAO_OptionValue { $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 @@ class CRM_Core_BAO_OptionValue extends CRM_Core_DAO_OptionValue { * @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 fbe2895208..59664fff03 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 @@ class CRM_Core_BAO_PaperSize extends CRM_Core_DAO_OptionValue { * (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 @@ class CRM_Core_BAO_PaperSize extends CRM_Core_DAO_OptionValue { * 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 @@ class CRM_Core_BAO_PaperSize extends CRM_Core_DAO_OptionValue { * (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 @@ class CRM_Core_BAO_PaperSize extends CRM_Core_DAO_OptionValue { $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 @@ class CRM_Core_BAO_PaperSize extends CRM_Core_DAO_OptionValue { $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 0d1fef31d9..21bd66deee 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 @@ class CRM_Core_BAO_PdfFormat extends CRM_Core_DAO_OptionValue { * 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 @@ class CRM_Core_BAO_PdfFormat extends CRM_Core_DAO_OptionValue { * (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 @@ class CRM_Core_BAO_PdfFormat extends CRM_Core_DAO_OptionValue { * 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 @@ class CRM_Core_BAO_PdfFormat extends CRM_Core_DAO_OptionValue { * (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 @@ class CRM_Core_BAO_PdfFormat extends CRM_Core_DAO_OptionValue { $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 @@ class CRM_Core_BAO_PdfFormat extends CRM_Core_DAO_OptionValue { $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 cae5858db9..2694f8bef0 100644 --- a/CRM/Core/BAO/Persistent.php +++ b/CRM/Core/BAO/Persistent.php @@ -88,10 +88,10 @@ class CRM_Core_BAO_Persistent extends CRM_Core_DAO_Persistent { * @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 cece40787d..610cd1afbb 100644 --- a/CRM/Core/BAO/Phone.php +++ b/CRM/Core/BAO/Phone.php @@ -111,7 +111,7 @@ class CRM_Core_BAO_Phone extends CRM_Core_DAO_Phone { * @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 @@ LEFT JOIN civicrm_location_type ON ( civicrm_phone.location_type_id = civicrm_lo 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 @@ AND ph.id IN (loc.phone_id, loc.phone_2_id) 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 @@ ORDER BY ph.is_primary DESC, phone_id ASC "; // 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 ffe16a16fa..fdf0fc467a 100644 --- a/CRM/Core/BAO/PreferencesDate.php +++ b/CRM/Core/BAO/PreferencesDate.php @@ -108,7 +108,7 @@ SET time_format = %1 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 71bc9e74ec..8d5fd872f7 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 @@ WHERE cacheKey = %3 AND 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 @@ WHERE cacheKey = %3 AND $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 @@ WHERE cacheKey = %3 AND //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 @@ WHERE cacheKey = %3 AND */ 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 @@ WHERE cacheKey = %3 AND 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 @@ WHERE cacheKey = %3 AND * * @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 @@ FROM civicrm_prevnext_cache pn $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 @@ FROM civicrm_prevnext_cache pn } 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 @@ FROM civicrm_prevnext_cache pn * * @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 @@ WHERE (pn.cacheKey $op %1 OR pn.cacheKey $op %2) $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 @@ WHERE (pn.cacheKey $op %1 OR pn.cacheKey $op %2) // 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 @@ INNER JOIN civicrm_prevnext_cache pn ON c.path = pn.cacheKey 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 @@ AND c.created_date < date_sub( NOW( ), INTERVAL %2 day ) $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 3dfec02e65..fcc5b4a5e8 100644 --- a/CRM/Core/BAO/RecurringEntity.php +++ b/CRM/Core/BAO/RecurringEntity.php @@ -39,54 +39,54 @@ require_once 'packages/When/When.php'; 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 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { */ 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 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { 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 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { ); 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 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { 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 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { * 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 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { $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 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { 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 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { if ($parentId) { return self::getEntitiesForParent($parentId, $entityTable, $includeParent, $mode, $entityId); } - return array(); + return []; } /** @@ -524,10 +524,10 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { } $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 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { 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 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { } } if ($count) { - return array($position, $count); + return [$position, $count]; } return NULL; } @@ -618,7 +618,7 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { return; } - static $processedEntities = array(); + static $processedEntities = []; $obj =& $event->object; if (empty($obj->id) || empty($obj->__table)) { return; @@ -651,7 +651,7 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { 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 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { return; } - static $processedEntities = array(); + static $processedEntities = []; if (empty($obj->id) || empty($obj->__table)) { return; } @@ -754,12 +754,12 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { } 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 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { return; } - static $processedEntities = array(); + static $processedEntities = []; if (empty($obj->id) || empty($obj->__table) || !$event->result) { return; } @@ -868,8 +868,8 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { * * @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 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { 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 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { * @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 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { * @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 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { 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 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { 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 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { 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 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { * @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 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { 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 @@ class CRM_Core_BAO_RecurringEntity extends CRM_Core_DAO_RecurringEntity { * @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 33840c922d..5fe0666b15 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 @@ ALTER TABLE {$tableName} 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 @@ ALTER TABLE {$tableName} } // 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 @@ ALTER TABLE {$tableName} // 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 @@ ALTER TABLE {$tableName} 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 @@ ADD UNIQUE INDEX `unique_entity_id` ( `entity_id` )"; * @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 @@ ADD UNIQUE INDEX `unique_entity_id` ( `entity_id` )"; $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 @@ ADD UNIQUE INDEX `unique_entity_id` ( `entity_id` )"; $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 @@ ADD UNIQUE INDEX `unique_entity_id` ( `entity_id` )"; * @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 @@ UPDATE civicrm_custom_field 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 @@ MODIFY {$columnName} varchar( $length ) } 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 @@ MODIFY {$columnName} varchar( $length ) 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 @@ MODIFY {$columnName} varchar( $length ) 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 @@ MODIFY {$columnName} varchar( $length ) */ 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 @@ MODIFY {$columnName} varchar( $length ) * 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 @@ MODIFY {$columnName} varchar( $length ) // 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 @@ MODIFY {$columnName} varchar( $length ) } // Get missing indices - $missingIndices = array(); + $missingIndices = []; foreach ($missingSigs as $sig) { $sigParts = explode('::', $sig); if (array_key_exists($sigParts[0], $requiredIndices)) { @@ -761,7 +761,7 @@ MODIFY {$columnName} varchar( $length ) * @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 d5b11242f8..2c4b837bda 100644 --- a/CRM/Core/BAO/Setting.php +++ b/CRM/Core/BAO/Setting.php @@ -118,13 +118,13 @@ class CRM_Core_BAO_Setting extends CRM_Core_DAO_Setting { $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 @@ class CRM_Core_BAO_Setting extends CRM_Core_DAO_Setting { * @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 @@ class CRM_Core_BAO_Setting extends CRM_Core_DAO_Setting { * 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 @@ class CRM_Core_BAO_Setting extends CRM_Core_DAO_Setting { // 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 @@ class CRM_Core_BAO_Setting extends CRM_Core_DAO_Setting { } 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 @@ class CRM_Core_BAO_Setting extends CRM_Core_DAO_Setting { */ public static function getSettingSpecification( $componentID = NULL, - $filters = array(), + $filters = [], $domainID = NULL, $profile = NULL ) { @@ -395,7 +395,7 @@ class CRM_Core_BAO_Setting extends CRM_Core_DAO_Setting { //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 @@ class CRM_Core_BAO_Setting extends CRM_Core_DAO_Setting { } } - $returnValues = array(); + $returnValues = []; foreach ($groupValues as $gn => $gv) { $returnValues[$gv] = 0; } @@ -452,7 +452,7 @@ class CRM_Core_BAO_Setting extends CRM_Core_DAO_Setting { 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 @@ class CRM_Core_BAO_Setting extends CRM_Core_DAO_Setting { } } 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 @@ class CRM_Core_BAO_Setting extends CRM_Core_DAO_Setting { 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 9528336a3b..b54aec9df1 100644 --- a/CRM/Core/BAO/Tag.php +++ b/CRM/Core/BAO/Tag.php @@ -90,7 +90,7 @@ class CRM_Core_BAO_Tag extends CRM_Core_DAO_Tag { 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 @@ class CRM_Core_BAO_Tag extends CRM_Core_DAO_Tag { $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 @@ class CRM_Core_BAO_Tag extends CRM_Core_DAO_Tag { * @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 @@ class CRM_Core_BAO_Tag extends CRM_Core_DAO_Tag { */ 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 @@ class CRM_Core_BAO_Tag extends CRM_Core_DAO_Tag { // $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 @@ class CRM_Core_BAO_Tag extends CRM_Core_DAO_Tag { $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 @@ class CRM_Core_BAO_Tag extends CRM_Core_DAO_Tag { // 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 @@ class CRM_Core_BAO_Tag extends CRM_Core_DAO_Tag { 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 @@ class CRM_Core_BAO_Tag extends CRM_Core_DAO_Tag { // 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 @@ class CRM_Core_BAO_Tag extends CRM_Core_DAO_Tag { * @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 @@ class CRM_Core_BAO_Tag extends CRM_Core_DAO_Tag { * @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 @@ class CRM_Core_BAO_Tag extends CRM_Core_DAO_Tag { $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 @@ class CRM_Core_BAO_Tag extends CRM_Core_DAO_Tag { * 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 @@ class CRM_Core_BAO_Tag extends CRM_Core_DAO_Tag { * 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 @@ class CRM_Core_BAO_Tag extends CRM_Core_DAO_Tag { * 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 @@ class CRM_Core_BAO_Tag extends CRM_Core_DAO_Tag { 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 ecf53c3878..37ee29e17a 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 @@ class CRM_Core_BAO_UFField extends CRM_Core_DAO_UFField { $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 @@ class CRM_Core_BAO_UFField extends CRM_Core_DAO_UFField { $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 @@ class CRM_Core_BAO_UFField extends CRM_Core_DAO_UFField { 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 @@ WHERE cf.id IN (" . $customFieldIds . ") AND is_multiple = 1 LIMIT 0,1"; 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 @@ WHERE cf.id IN (" . $customFieldIds . ") AND is_multiple = 1 LIMIT 0,1"; 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 @@ WHERE cf.id IN (" . $customFieldIds . ") AND is_multiple = 1 LIMIT 0,1"; * @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 @@ WHERE cf.id IN (" . $customFieldIds . ") AND is_multiple = 1 LIMIT 0,1"; 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 @@ WHERE cf.id IN (" . $customFieldIds . ") AND is_multiple = 1 LIMIT 0,1"; } } - $contactTypes = array('Individual', 'Household', 'Organization'); + $contactTypes = ['Individual', 'Household', 'Organization']; $subTypes = CRM_Contact_BAO_ContactType::subTypes(); $profileTypeComponent = array_intersect($components, $profileTypes); @@ -479,7 +479,7 @@ WHERE cf.id IN (" . $customFieldIds . ") AND is_multiple = 1 LIMIT 0,1"; $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 @@ WHERE cf.id IN (" . $customFieldIds . ") AND is_multiple = 1 LIMIT 0,1"; $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 @@ WHERE cf.id IN (" . $customFieldIds . ") AND is_multiple = 1 LIMIT 0,1"; // 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 @@ WHERE cf.id IN (" . $customFieldIds . ") AND is_multiple = 1 LIMIT 0,1"; */ 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 @@ WHERE cf.id IN (" . $customFieldIds . ") AND is_multiple = 1 LIMIT 0,1"; } 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 @@ WHERE cf.id IN (" . $customFieldIds . ") AND is_multiple = 1 LIMIT 0,1"; } //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 @@ SELECT ufg.id as id $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 @@ SELECT id 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 @@ SELECT id '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 @@ SELECT id $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 @@ SELECT id * @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 @@ SELECT id //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 @@ SELECT id 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 @@ SELECT id $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 @@ SELECT id } //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 @@ SELECT id 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 @@ SELECT id */ 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 @@ SELECT id */ 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 9fb799975e..a4fcababf7 100644 --- a/CRM/Core/BAO/UFJoin.php +++ b/CRM/Core/BAO/UFJoin.php @@ -166,7 +166,7 @@ class CRM_Core_BAO_UFJoin extends CRM_Core_DAO_UFJoin { $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 @@ class CRM_Core_BAO_UFJoin extends CRM_Core_DAO_UFJoin { $secondActive[] = $dao->is_active; } } - return array($first, $second, $firstActive, $secondActive); + return [$first, $second, $firstActive, $secondActive]; } /** @@ -186,11 +186,11 @@ class CRM_Core_BAO_UFJoin extends CRM_Core_DAO_UFJoin { * @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 333b12369e..dab5fa3879 100644 --- a/CRM/Core/BAO/UFMatch.php +++ b/CRM/Core/BAO/UFMatch.php @@ -147,11 +147,11 @@ class CRM_Core_BAO_UFMatch extends CRM_Core_DAO_UFMatch { 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 @@ class CRM_Core_BAO_UFMatch extends CRM_Core_DAO_UFMatch { $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 @@ FROM civicrm_uf_match 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 @@ AND domain_id = %2 else { $primary_email = $user->email; } - $params = array('email-Primary' => $primary_email); + $params = ['email-Primary' => $primary_email]; } if ($ctype == 'Organization') { @@ -313,12 +313,12 @@ OR uf_name = %2 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 @@ AND domain_id = %4 } 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 @@ AND domain_id = %4 $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 @@ AND domain_id = %4 * 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 @@ AND domain_id = %4 $ufID = CRM_Utils_System::getLoggedInUfID(); } if (!$ufID) { - return array(); + return []; } static $ufValues; @@ -645,12 +645,12 @@ AND domain_id = %4 $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 @@ AND domain_id = %4 */ 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 29e118b958..f947253594 100644 --- a/CRM/Core/BAO/Website.php +++ b/CRM/Core/BAO/Website.php @@ -155,14 +155,14 @@ class CRM_Core_BAO_Website extends CRM_Core_DAO_Website { * @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 @@ class CRM_Core_BAO_Website extends CRM_Core_DAO_Website { 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 47182a9317..c234f68ccd 100644 --- a/CRM/Core/BAO/WordReplacement.php +++ b/CRM/Core/BAO/WordReplacement.php @@ -153,11 +153,11 @@ SELECT find_word,replace_word,is_active,match_type 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 @@ WHERE domain_id = %1 * @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 @@ WHERE domain_id = %1 * 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 @@ WHERE domain_id = %1 */ 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 @@ WHERE domain_id = %1 * @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 17998d2235..2a9606d527 100644 --- a/CRM/Core/ClassLoader.php +++ b/CRM/Core/ClassLoader.php @@ -71,7 +71,7 @@ class CRM_Core_ClassLoader { */ protected function __construct() { $this->_registered = FALSE; - $this->civiTestClasses = array( + $this->civiTestClasses = [ 'CiviCaseTestCase', 'CiviDBAssert', 'CiviMailUtils', @@ -87,7 +87,7 @@ class CRM_Core_ClassLoader { 'Membership', 'Participant', 'PaypalPro', - ); + ]; } /** @@ -133,16 +133,16 @@ class CRM_Core_ClassLoader { // 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 @@ class CRM_Core_ClassLoader { 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 1d6b2431d1..9adc75a443 100644 --- a/CRM/Core/CodeGen/Config.php +++ b/CRM/Core/CodeGen/Config.php @@ -9,13 +9,13 @@ class CRM_Core_CodeGen_Config extends CRM_Core_CodeGen_BaseTask { } 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 @@ class CRM_Core_CodeGen_Config extends CRM_Core_CodeGen_BaseTask { * 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 1a47be7cc5..69cc8d0e47 100644 --- a/CRM/Core/CodeGen/DAO.php +++ b/CRM/Core/CodeGen/DAO.php @@ -71,7 +71,7 @@ class CRM_Core_CodeGen_DAO extends CRM_Core_CodeGen_BaseTask { $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 @@ class CRM_Core_CodeGen_DAO extends CRM_Core_CodeGen_BaseTask { $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 @@ class CRM_Core_CodeGen_DAO extends CRM_Core_CodeGen_BaseTask { */ 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 e48ea1e937..d34f30a5d2 100644 --- a/CRM/Core/CodeGen/I18n.php +++ b/CRM/Core/CodeGen/I18n.php @@ -12,9 +12,9 @@ class CRM_Core_CodeGen_I18n extends CRM_Core_CodeGen_BaseTask { 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 @@ class CRM_Core_CodeGen_I18n extends CRM_Core_CodeGen_BaseTask { 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 9edd7b7818..978f3e9cae 100644 --- a/CRM/Core/CodeGen/Main.php +++ b/CRM/Core/CodeGen/Main.php @@ -108,7 +108,7 @@ Alternatively you can get a version of CiviCRM that matches your PHP version 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 @@ Alternatively you can get a version of CiviCRM that matches your PHP version 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 48247fd427..b96cb39ebe 100644 --- a/CRM/Core/CodeGen/Schema.php +++ b/CRM/Core/CodeGen/Schema.php @@ -75,14 +75,14 @@ class CRM_Core_CodeGen_Schema extends CRM_Core_CodeGen_BaseTask { $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 @@ class CRM_Core_CodeGen_Schema extends CRM_Core_CodeGen_BaseTask { 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 @@ class CRM_Core_CodeGen_Schema extends CRM_Core_CodeGen_BaseTask { 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 c23b925088..660d8d6192 100644 --- a/CRM/Core/CodeGen/Specification.php +++ b/CRM/Core/CodeGen/Specification.php @@ -29,7 +29,7 @@ class CRM_Core_CodeGen_Specification { } $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 @@ class CRM_Core_CodeGen_Specification { * @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 @@ class CRM_Core_CodeGen_Specification { * @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 @@ class CRM_Core_CodeGen_Specification { * @return array */ public function orderTables(&$tables) { - $ordered = array(); + $ordered = []; while (!empty($tables)) { foreach (array_keys($tables) as $name) { @@ -202,7 +202,7 @@ class CRM_Core_CodeGen_Specification { } } - $table = array( + $table = [ 'name' => $name, 'base' => $daoPath, 'sourceFile' => $sourceFile, @@ -218,9 +218,9 @@ class CRM_Core_CodeGen_Specification { '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 @@ class CRM_Core_CodeGen_Specification { } 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 @@ class CRM_Core_CodeGen_Specification { } 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 @@ class CRM_Core_CodeGen_Specification { } 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 @@ class CRM_Core_CodeGen_Specification { */ 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 @@ class CRM_Core_CodeGen_Specification { $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 @@ class CRM_Core_CodeGen_Specification { '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 @@ class CRM_Core_CodeGen_Specification { } 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 @@ class CRM_Core_CodeGen_Specification { $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 @@ class CRM_Core_CodeGen_Specification { '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 @@ class CRM_Core_CodeGen_Specification { $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 @@ class CRM_Core_CodeGen_Specification { //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 @@ class CRM_Core_CodeGen_Specification { /** 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 @@ class CRM_Core_CodeGen_Specification { // we do this matching in a separate phase (resolveForeignKeys) 'className' => NULL, 'onDelete' => $this->value('onDelete', $foreignXML, FALSE), - ); + ]; $foreignKeys[$name] = &$foreignKey; } @@ -624,11 +624,11 @@ class CRM_Core_CodeGen_Specification { * @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 @@ class CRM_Core_CodeGen_Specification { // 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 @@ class CRM_Core_CodeGen_Specification { 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 5554c6b451..acb274e41e 100644 --- a/CRM/Core/CodeGen/Util/ArraySyntaxConverter.php +++ b/CRM/Core/CodeGen/Util/ArraySyntaxConverter.php @@ -18,7 +18,7 @@ class CRM_Core_CodeGen_Util_ArraySyntaxConverter { $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 @@ class CRM_Core_CodeGen_Util_ArraySyntaxConverter { } 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 @@ class CRM_Core_CodeGen_Util_ArraySyntaxConverter { --$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 a7d5e1e456..c2cedac40c 100644 --- a/CRM/Core/CodeGen/Util/File.php +++ b/CRM/Core/CodeGen/Util/File.php @@ -85,7 +85,7 @@ class CRM_Core_CodeGen_Util_File { * 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 7e22561d9a..68a7077ec7 100644 --- a/CRM/Core/CodeGen/Util/Smarty.php +++ b/CRM/Core/CodeGen/Util/Smarty.php @@ -50,7 +50,7 @@ class CRM_Core_CodeGen_Util_Smarty { 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 999978a2ba..9e7ad56aa3 100644 --- a/CRM/Core/CommunityMessages.php +++ b/CRM/Core/CommunityMessages.php @@ -94,12 +94,12 @@ class CRM_Core_CommunityMessages { $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 @@ class CRM_Core_CommunityMessages { */ 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 @@ class CRM_Core_CommunityMessages { */ 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 @@ class CRM_Core_CommunityMessages { '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 7d8b051f41..f7161bc500 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 @@ class CRM_Core_Component { */ 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 @@ class CRM_Core_Component { * 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 @@ class CRM_Core_Component { 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 @@ class CRM_Core_Component { // 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 @@ class CRM_Core_Component { */ public static function &menu() { $info = self::_info(); - $items = array(); + $items = []; foreach ($info as $name => $comp) { $mnu = $comp->getMenuObject(); @@ -275,7 +275,7 @@ class CRM_Core_Component { */ 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 @@ class CRM_Core_Component { */ public static function &contactSubTypes() { if (self::$_contactSubTypes == NULL) { - self::$_contactSubTypes = array(); + self::$_contactSubTypes = []; } return self::$_contactSubTypes; } @@ -431,7 +431,7 @@ class CRM_Core_Component { * @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 d1563d9f82..fd4b55c5be 100644 --- a/CRM/Core/Component/Info.php +++ b/CRM/Core/Component/Info.php @@ -113,7 +113,7 @@ abstract class CRM_Core_Component_Info { * @see CRM_Utils_Hook::angularModules */ public function getAngularModules() { - return array(); + return []; } /** @@ -134,7 +134,7 @@ abstract class CRM_Core_Component_Info { * @see CRM_Utils_Hook::managedEntities */ public function getManagedEntities() { - return array(); + return []; } /** @@ -145,7 +145,7 @@ abstract class CRM_Core_Component_Info { * @see CRM_Component_Info::getPermissions */ public function getAnonymousPermissionWarnings() { - return array(); + return []; } /** @@ -175,7 +175,7 @@ abstract class CRM_Core_Component_Info { * - 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 2e5c7307da..cd382e17d6 100644 --- a/CRM/Core/Config.php +++ b/CRM/Core/Config.php @@ -102,8 +102,8 @@ class CRM_Core_Config extends CRM_Core_Config_MagicMerge { */ 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 @@ class CRM_Core_Config extends CRM_Core_Config_MagicMerge { // 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 @@ class CRM_Core_Config extends CRM_Core_Config_MagicMerge { $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 @@ class CRM_Core_Config extends CRM_Core_Config_MagicMerge { } 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 @@ class CRM_Core_Config extends CRM_Core_Config_MagicMerge { } 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 @@ class CRM_Core_Config extends CRM_Core_Config_MagicMerge { * 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 @@ class CRM_Core_Config extends CRM_Core_Config_MagicMerge { '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 @@ class CRM_Core_Config extends CRM_Core_Config_MagicMerge { $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 @@ class CRM_Core_Config extends CRM_Core_Config_MagicMerge { * @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 7223816f2d..90aa741bf8 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 @@ class CRM_Core_Config_MagicMerge { // 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 @@ class CRM_Core_Config_MagicMerge { $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 @@ class CRM_Core_Config_MagicMerge { 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 @@ class CRM_Core_Config_MagicMerge { 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 @@ class CRM_Core_Config_MagicMerge { 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 @@ class CRM_Core_Config_MagicMerge { 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 @@ class CRM_Core_Config_MagicMerge { */ 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 a9c39f3e33..51a4cc3d34 100644 --- a/CRM/Core/Config/Runtime.php +++ b/CRM/Core/Config/Runtime.php @@ -133,7 +133,7 @@ class CRM_Core_Config_Runtime extends CRM_Core_Config_MagicMerge { $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 @@ class CRM_Core_Config_Runtime extends CRM_Core_Config_MagicMerge { * 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 @@ class CRM_Core_Config_Runtime extends CRM_Core_Config_MagicMerge { */ 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 b8da3db132..1bd454992d 100644 --- a/CRM/Core/Controller.php +++ b/CRM/Core/Controller.php @@ -214,10 +214,10 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller { // 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 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller { $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 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller { } 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 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller { * @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 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller { '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 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller { * @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 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller { 'valid' => TRUE, 'stepNumber' => $count, 'collapsed' => FALSE, - ); + ]; if ($name == $currentPageName) { $wizard['currentStepNumber'] = $count; @@ -570,7 +570,7 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller { * @param array $wizard */ public function addWizardStyle(&$wizard) { - $wizard['style'] = array( + $wizard['style'] = [ 'barClass' => '', 'stepPrefixCurrent' => '»', 'stepPrefixPast' => '✔', @@ -579,7 +579,7 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller { 'subStepPrefixPast' => '  ', 'subStepPrefixFuture' => '  ', 'showTitle' => 1, - ); + ]; } /** diff --git a/CRM/Core/Controller/Simple.php b/CRM/Core/Controller/Simple.php index d472b9e411..b0a6154ad3 100644 --- a/CRM/Core/Controller/Simple.php +++ b/CRM/Core/Controller/Simple.php @@ -67,7 +67,7 @@ class CRM_Core_Controller_Simple extends CRM_Core_Controller { $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 @@ class CRM_Core_Controller_Simple extends CRM_Core_Controller { ); } 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 02b3d3d158..ea7abcc085 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 @@ class CRM_Core_DAO extends DB_DataObject { $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 @@ class CRM_Core_DAO extends DB_DataObject { 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 @@ class CRM_Core_DAO extends DB_DataObject { $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 @@ class CRM_Core_DAO extends DB_DataObject { } 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 @@ class CRM_Core_DAO extends DB_DataObject { /** * reset the various DB_DAO structures manually */ - $this->_query = array(); + $this->_query = []; $this->whereAdd(); $this->selectAdd(); $this->joinAdd(); @@ -487,7 +487,7 @@ class CRM_Core_DAO extends DB_DataObject { public function keys() { static $keys; if (!isset($keys)) { - $keys = array('id'); + $keys = ['id']; } return $keys; } @@ -502,7 +502,7 @@ class CRM_Core_DAO extends DB_DataObject { public function sequenceKey() { static $sequenceKeys; if (!isset($sequenceKeys)) { - $sequenceKeys = array('id', TRUE); + $sequenceKeys = ['id', TRUE]; } return $sequenceKeys; } @@ -515,7 +515,7 @@ class CRM_Core_DAO extends DB_DataObject { * Array of CRM_Core_Reference_Interface */ public static function getReferenceColumns() { - return array(); + return []; } /** @@ -538,7 +538,7 @@ class CRM_Core_DAO extends DB_DataObject { 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 @@ class CRM_Core_DAO extends DB_DataObject { $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 @@ class CRM_Core_DAO extends DB_DataObject { $cols = 80; } - $attributes = array(); + $attributes = []; $attributes['rows'] = $rows; $attributes['cols'] = $cols; return $attributes; @@ -805,7 +805,7 @@ class CRM_Core_DAO extends DB_DataObject { return self::makeAttribute($field); } else { - $attributes = array(); + $attributes = []; foreach ($fields as $name => $field) { $attribute = self::makeAttribute($field); if ($attribute) { @@ -931,7 +931,7 @@ class CRM_Core_DAO extends DB_DataObject { * 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 @@ class CRM_Core_DAO extends DB_DataObject { * @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 @@ class CRM_Core_DAO extends DB_DataObject { * 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 @@ class CRM_Core_DAO extends DB_DataObject { 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 @@ FROM civicrm_domain * @return array */ public function fetchAll() { - $result = array(); + $result = []; while ($this->fetch()) { $result[] = $this->toArray(); } @@ -1160,7 +1160,7 @@ FROM civicrm_domain * 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 @@ FROM civicrm_domain $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 @@ FROM civicrm_domain */ static public function executeUnbufferedQuery( $query, - $params = array(), + $params = [], $abort = TRUE, $daoName = NULL, $freeDAO = FALSE, @@ -1360,7 +1360,7 @@ FROM civicrm_domain $freeDAO, $i18nRewrite, $trapException, - array('result_buffering' => 0) + ['result_buffering' => 0] ); } @@ -1385,13 +1385,13 @@ FROM civicrm_domain */ 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 @@ FROM civicrm_domain */ public function isValidOption($options) { $isValid = FALSE; - $validOptions = array( + $validOptions = [ 'result_buffering', 'persistent', 'ssl', 'portability', - ); + ]; if (empty($options)) { return $isValid; @@ -1475,7 +1475,7 @@ FROM civicrm_domain */ public static function &singleValueQuery( $query, - $params = array(), + $params = [], $abort = TRUE, $i18nRewrite = TRUE ) { @@ -1512,7 +1512,7 @@ FROM civicrm_domain * @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 @@ FROM civicrm_domain $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 @@ FROM civicrm_domain * * @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 @@ FROM civicrm_domain * @return array */ public static function getContactIDsFromComponent($componentIDs, $tableName, $idField = 'id') { - $contactIDs = array(); + $contactIDs = []; if (empty($componentIDs)) { return $contactIDs; @@ -1782,7 +1782,7 @@ SELECT contact_id $object->find(); while ($object->fetch()) { - $defaults = array(); + $defaults = []; self::storeValues($object, $defaults); $details[$object->id] = $defaults; } @@ -1828,8 +1828,8 @@ SELECT contact_id 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 @@ SELECT contact_id return $default; } - $escapes = array_map(array($_dao, 'escape'), $strings); + $escapes = array_map([$_dao, 'escape'], $strings); return '"' . implode('","', $escapes) . '"'; } @@ -1871,7 +1871,7 @@ SELECT contact_id // 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 @@ SELECT contact_id */ public static function createTestObject( $daoName, - $params = array(), + $params = [], $numObjects = 1, $createOnly = FALSE ) { @@ -1905,14 +1905,14 @@ SELECT contact_id $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 @@ SELECT contact_id * @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 @@ SELECT contact_id $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 @@ SELECT contact_id // 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 @@ SELECT contact_id 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 @@ SELECT contact_id * @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 @@ SELECT contact_id 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 @@ SELECT contact_id 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 @@ SELECT contact_id * 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 @@ SELECT contact_id $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 @@ SELECT contact_id * * @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 @@ SELECT contact_id * @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 @@ SELECT contact_id 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 @@ SELECT contact_id * @return array */ public static function acceptedSQLOperators() { - return array( + return [ '=', '<=', '>=', @@ -2604,7 +2604,7 @@ SELECT contact_id 'NOT BETWEEN', 'IS NOT NULL', 'IS NULL', - ); + ]; } /** @@ -2696,7 +2696,7 @@ SELECT contact_id * @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 @@ SELECT contact_id } // 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 @@ SELECT contact_id 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 @@ SELECT contact_id * @return bool */ public static function requireSafeDBName($database) { - $matches = array(); + $matches = []; preg_match( "/^[\w\-]*[a-z]+[\w\-]*$/i", $database, @@ -2786,7 +2786,7 @@ SELECT contact_id } 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 @@ SELECT contact_id return NULL; } if ($value === '') { - return array(); + return []; } switch ($serializationType) { case self::SERIALIZE_SEPARATOR_BOOKEND: @@ -2828,10 +2828,10 @@ SELECT contact_id 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 03060e11a6..df25312569 100644 --- a/CRM/Core/DAO/AllCoreTables.php +++ b/CRM/Core/DAO/AllCoreTables.php @@ -47,15 +47,15 @@ class CRM_Core_DAO_AllCoreTables { 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 @@ class CRM_Core_DAO_AllCoreTables { 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 @@ class CRM_Core_DAO_AllCoreTables { * 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 @@ class CRM_Core_DAO_AllCoreTables { } $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 @@ class CRM_Core_DAO_AllCoreTables { // $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 @@ class CRM_Core_DAO_AllCoreTables { // $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 @@ class CRM_Core_DAO_AllCoreTables { 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 5c0e841759..6ba337cd1b 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 163a1b44d3..41895ed7c4 100644 --- a/CRM/Core/Error.php +++ b/CRM/Core/Error.php @@ -125,11 +125,11 @@ class CRM_Core_Error extends PEAR_ErrorStack { $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 @@ class CRM_Core_Error extends PEAR_ErrorStack { 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 @@ class CRM_Core_Error extends PEAR_ErrorStack { */ 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 @@ class CRM_Core_Error extends PEAR_ErrorStack { * @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 @@ class CRM_Core_Error extends PEAR_ErrorStack { } 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 @@ class CRM_Core_Error extends PEAR_ErrorStack { // 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 @@ class CRM_Core_Error extends PEAR_ErrorStack { 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 @@ class CRM_Core_Error extends PEAR_ErrorStack { 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 @@ class CRM_Core_Error extends PEAR_ErrorStack { */ 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 @@ class CRM_Core_Error extends PEAR_ErrorStack { */ 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 @@ class CRM_Core_Error extends PEAR_ErrorStack { * @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 @@ class CRM_Core_Error extends PEAR_ErrorStack { // 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 @@ class CRM_Core_Error extends PEAR_ErrorStack { $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 @@ class CRM_Core_Error extends PEAR_ErrorStack { */ 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 @@ class CRM_Core_Error extends PEAR_ErrorStack { 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 @@ class CRM_Core_Error extends PEAR_ErrorStack { */ public static function reset() { $error = self::singleton(); - $error->_errors = array(); - $error->_errorsByLevel = array(); + $error->_errors = []; + $error->_errorsByLevel = []; } /** @@ -979,7 +979,7 @@ class CRM_Core_Error extends PEAR_ErrorStack { throw new Exception($msg, $data); } - $values = array(); + $values = []; $values['is_error'] = 1; $values['error_message'] = $msg; @@ -1040,7 +1040,7 @@ class CRM_Core_Error extends PEAR_ErrorStack { $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 571df81622..fc31c16223 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 @@ class CRM_Core_Error_Log extends \Psr\Log\AbstractLogger { \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 @@ class CRM_Core_Error_Log extends \Psr\Log\AbstractLogger { * @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 8cecf32a51..f87deadb83 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 662580ee4f..e6ecef99e4 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 @@ class CRM_Core_Form extends HTML_QuickForm_Page { * @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 @@ class CRM_Core_Form extends HTML_QuickForm_Page { * 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 @@ class CRM_Core_Form extends HTML_QuickForm_Page { 'settingPath', 'autocomplete', 'validContact', - ); + ]; foreach ($rules as $rule) { $this->registerRule($rule, 'callback', $rule, 'CRM_Utils_Rule'); @@ -377,7 +377,7 @@ class CRM_Core_Form extends HTML_QuickForm_Page { // 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 @@ class CRM_Core_Form extends HTML_QuickForm_Page { 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 @@ class CRM_Core_Form extends HTML_QuickForm_Page { $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 @@ class CRM_Core_Form extends HTML_QuickForm_Page { } 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 @@ class CRM_Core_Form extends HTML_QuickForm_Page { $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 @@ class CRM_Core_Form extends HTML_QuickForm_Page { $this->validateChainSelectFields(); - $hookErrors = array(); + $hookErrors = []; CRM_Utils_Hook::validateForm( get_class($this), @@ -639,13 +639,13 @@ class CRM_Core_Form extends HTML_QuickForm_Page { * 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 @@ class CRM_Core_Form extends HTML_QuickForm_Page { $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 @@ class CRM_Core_Form extends HTML_QuickForm_Page { } } - 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 @@ class CRM_Core_Form extends HTML_QuickForm_Page { // 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 @@ class CRM_Core_Form extends HTML_QuickForm_Page { */ 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 @@ class CRM_Core_Form extends HTML_QuickForm_Page { $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 @@ class CRM_Core_Form extends HTML_QuickForm_Page { CRM_Core_Payment_ProcessorForm::preProcess($this); } else { - $this->_paymentProcessor = array(); + $this->_paymentProcessor = []; } CRM_Financial_Form_Payment::addCreditCardJs($this->_paymentProcessorID); } @@ -977,10 +977,10 @@ class CRM_Core_Form extends HTML_QuickForm_Page { else { $tplname = strtr( CRM_Utils_System::getClassName($this), - array( + [ '_' => DIRECTORY_SEPARATOR, '\\' => DIRECTORY_SEPARATOR, - ) + ] ) . '.tpl'; } return $tplname; @@ -1128,9 +1128,9 @@ class CRM_Core_Form extends HTML_QuickForm_Page { * * @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 @@ class CRM_Core_Form extends HTML_QuickForm_Page { } 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 @@ class CRM_Core_Form extends HTML_QuickForm_Page { * @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 @@ class CRM_Core_Form extends HTML_QuickForm_Page { $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 @@ class CRM_Core_Form extends HTML_QuickForm_Page { $javascriptMethod = NULL, $separator = '
    ', $flipValues = FALSE ) { - $options = array(); + $options = []; if ($javascriptMethod) { foreach ($values as $key => $var) { @@ -1227,7 +1227,7 @@ class CRM_Core_Form extends HTML_QuickForm_Page { 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 @@ class CRM_Core_Form extends HTML_QuickForm_Page { public function resetValues() { $data = $this->controller->container(); - $data['values'][$this->_name] = array(); + $data['values'][$this->_name] = []; } /** @@ -1250,21 +1250,21 @@ class CRM_Core_Form extends HTML_QuickForm_Page { * @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 @@ class CRM_Core_Form extends HTML_QuickForm_Page { */ 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 @@ class CRM_Core_Form extends HTML_QuickForm_Page { */ 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 @@ class CRM_Core_Form extends HTML_QuickForm_Page { * @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 @@ class CRM_Core_Form extends HTML_QuickForm_Page { 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 @@ class CRM_Core_Form extends HTML_QuickForm_Page { * @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 @@ class CRM_Core_Form extends HTML_QuickForm_Page { $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 @@ class CRM_Core_Form extends HTML_QuickForm_Page { $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 @@ class CRM_Core_Form extends HTML_QuickForm_Page { } 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 @@ class CRM_Core_Form extends HTML_QuickForm_Page { 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 @@ class CRM_Core_Form extends HTML_QuickForm_Page { // 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 @@ class CRM_Core_Form extends HTML_QuickForm_Page { //CRM-15427 'data-default' => $default, 'data-usedfor' => json_encode($usedFor), - )); + ]); } /** @@ -1700,7 +1700,7 @@ class CRM_Core_Form extends HTML_QuickForm_Page { 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 @@ class CRM_Core_Form extends HTML_QuickForm_Page { 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 @@ class CRM_Core_Form extends HTML_QuickForm_Page { $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 @@ class CRM_Core_Form extends HTML_QuickForm_Page { * @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 @@ class CRM_Core_Form extends HTML_QuickForm_Page { 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 @@ class CRM_Core_Form extends HTML_QuickForm_Page { // 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 @@ class CRM_Core_Form extends HTML_QuickForm_Page { * * @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 @@ class CRM_Core_Form extends HTML_QuickForm_Page { 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 @@ class CRM_Core_Form extends HTML_QuickForm_Page { * @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 @@ class CRM_Core_Form extends HTML_QuickForm_Page { 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 @@ class CRM_Core_Form extends HTML_QuickForm_Page { // 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 @@ class CRM_Core_Form extends HTML_QuickForm_Page { //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 @@ class CRM_Core_Form extends HTML_QuickForm_Page { * * @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 @@ class CRM_Core_Form extends HTML_QuickForm_Page { */ 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 @@ class CRM_Core_Form extends HTML_QuickForm_Page { */ 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 @@ class CRM_Core_Form extends HTML_QuickForm_Page { 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 @@ class CRM_Core_Form extends HTML_QuickForm_Page { * * @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 @@ class CRM_Core_Form extends HTML_QuickForm_Page { '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 @@ class CRM_Core_Form extends HTML_QuickForm_Page { 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 @@ class CRM_Core_Form extends HTML_QuickForm_Page { $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 @@ class CRM_Core_Form extends HTML_QuickForm_Page { 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 @@ class CRM_Core_Form extends HTML_QuickForm_Page { $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 @@ class CRM_Core_Form extends HTML_QuickForm_Page { $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 @@ class CRM_Core_Form extends HTML_QuickForm_Page { * * @return string */ - public function assignBillingName($params = array()) { + public function assignBillingName($params = []) { $name = ''; if (empty($params)) { $params = $this->_params; @@ -2480,7 +2480,7 @@ class CRM_Core_Form extends HTML_QuickForm_Page { * * @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 4d03e18b4d..354762f65b 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 @@ class CRM_Core_Form_Date { $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 @@ class CRM_Core_Form_Date { 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 @@ class CRM_Core_Form_Date { 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 63e5f781f9..96a15fdcd8 100644 --- a/CRM/Core/Form/EntityFormTrait.php +++ b/CRM/Core/Form/EntityFormTrait.php @@ -133,27 +133,27 @@ trait CRM_Core_Form_EntityFormTrait { */ 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 72088fda32..97f7bfaf13 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 @@ class CRM_Core_Form_RecurringEntity { 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 @@ class CRM_Core_Form_RecurringEntity { */ 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 @@ class CRM_Core_Form_RecurringEntity { */ 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 @@ class CRM_Core_Form_RecurringEntity { '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 @@ class CRM_Core_Form_RecurringEntity { * 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 @@ class CRM_Core_Form_RecurringEntity { } 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 @@ class CRM_Core_Form_RecurringEntity { * * @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 @@ class CRM_Core_Form_RecurringEntity { $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 @@ class CRM_Core_Form_RecurringEntity { 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 @@ class CRM_Core_Form_RecurringEntity { '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 @@ class CRM_Core_Form_RecurringEntity { 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 @@ class CRM_Core_Form_RecurringEntity { $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 @@ class CRM_Core_Form_RecurringEntity { $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 1eeb9f0b7d..201c266f07 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 @@ class CRM_Core_Form_Renderer extends HTML_QuickForm_Renderer_ArraySmarty { } // 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 @@ class CRM_Core_Form_Renderer extends HTML_QuickForm_Renderer_ArraySmarty { 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 @@ class CRM_Core_Form_Renderer extends HTML_QuickForm_Renderer_ArraySmarty { $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 @@ class CRM_Core_Form_Renderer extends HTML_QuickForm_Renderer_ArraySmarty { $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 @@ class CRM_Core_Form_Renderer extends HTML_QuickForm_Renderer_ArraySmarty { 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 @@ class CRM_Core_Form_Renderer extends HTML_QuickForm_Renderer_ArraySmarty { '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 c0defa2ac5..836ed37eec 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 @@ class CRM_Core_Form_Search extends CRM_Core_Form { ->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 @@ class CRM_Core_Form_Search extends CRM_Core_Form { * @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 @@ class CRM_Core_Form_Search extends CRM_Core_Form { * @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 @@ class CRM_Core_Form_Search extends CRM_Core_Form { $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 @@ class CRM_Core_Form_Search extends CRM_Core_Form { $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 46f815539c..8d5d2b1ad1 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 @@ class CRM_Core_Form_ShortCode extends CRM_Core_Form { $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 @@ class CRM_Core_Form_ShortCode extends CRM_Core_Form { 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 b47d0779ca..5f785ddffe 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 @@ class CRM_Core_Form_Tag { } $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 @@ class CRM_Core_Form_Tag { // 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 @@ class CRM_Core_Form_Tag { // 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 @@ class CRM_Core_Form_Tag { 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 7ca43d4a2f..c79fcf5321 100644 --- a/CRM/Core/Form/Task.php +++ b/CRM/Core/Form/Task.php @@ -106,7 +106,7 @@ abstract class CRM_Core_Form_Task extends CRM_Core_Form { * @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 @@ abstract class CRM_Core_Form_Task extends CRM_Core_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 @@ abstract class CRM_Core_Form_Task extends CRM_Core_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/Core/Form/Task/Batch.php b/CRM/Core/Form/Task/Batch.php index 474dd6c83d..76d1b85756 100644 --- a/CRM/Core/Form/Task/Batch.php +++ b/CRM/Core/Form/Task/Batch.php @@ -67,7 +67,7 @@ class CRM_Core_Form_Task_Batch extends CRM_Core_Form_Task { 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 @@ class CRM_Core_Form_Task_Batch extends CRM_Core_Form_Task { 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 @@ class CRM_Core_Form_Task_Batch extends CRM_Core_Form_Task { // 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 @@ class CRM_Core_Form_Task_Batch extends CRM_Core_Form_Task { $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 @@ class CRM_Core_Form_Task_Batch extends CRM_Core_Form_Task { 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 @@ class CRM_Core_Form_Task_Batch extends CRM_Core_Form_Task { // 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 @@ class CRM_Core_Form_Task_Batch extends CRM_Core_Form_Task { */ 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 fdbbeb7781..5fd95efa67 100644 --- a/CRM/Core/Form/Task/PDFLetterCommon.php +++ b/CRM/Core/Form/Task/PDFLetterCommon.php @@ -64,25 +64,25 @@ class CRM_Core_Form_Task_PDFLetterCommon { '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 @@ class CRM_Core_Form_Task_PDFLetterCommon { ts('Orientation'), CRM_Core_BAO_PdfFormat::getPageOrientations(), FALSE, - array('onChange' => "updatePaperDimensions(); showUpdateFormatChkBox();") + ['onChange' => "updatePaperDimensions(); showUpdateFormatChkBox();"] ); $form->add( 'select', @@ -99,34 +99,34 @@ class CRM_Core_Form_Task_PDFLetterCommon { 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 @@ class CRM_Core_Form_Task_PDFLetterCommon { 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 @@ class CRM_Core_Form_Task_PDFLetterCommon { * 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 @@ class CRM_Core_Form_Task_PDFLetterCommon { // 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 @@ class CRM_Core_Form_Task_PDFLetterCommon { * @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 c23af2f000..4043833a55 100644 --- a/CRM/Core/Form/Task/PickProfile.php +++ b/CRM/Core/Form/Task/PickProfile.php @@ -85,11 +85,11 @@ abstract class CRM_Core_Form_Task_PickProfile extends CRM_Core_Form_Task { // 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 @@ abstract class CRM_Core_Form_Task_PickProfile extends CRM_Core_Form_Task { * @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 @@ abstract class CRM_Core_Form_Task_PickProfile extends CRM_Core_Form_Task { $this->add('select', 'uf_group_id', ts('Select Profile'), - array( + [ '' => ts('- select profile -'), - ) + $profiles, + ] + $profiles, TRUE ); $this->addDefaultButtons(ts('Continue')); @@ -137,7 +137,7 @@ abstract class CRM_Core_Form_Task_PickProfile extends CRM_Core_Form_Task { * @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 119ff57f9d..425565de5b 100644 --- a/CRM/Core/I18n.php +++ b/CRM/Core/I18n.php @@ -84,7 +84,7 @@ class CRM_Core_I18n { * - 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 @@ class CRM_Core_I18n { $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 @@ class CRM_Core_I18n { 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 @@ class CRM_Core_I18n { * 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 @@ class CRM_Core_I18n { * @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 @@ class CRM_Core_I18n { 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 @@ class CRM_Core_I18n { } // 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 @@ class CRM_Core_I18n { */ public function localizeArray( &$array, - $params = array() + $params = [] ) { $tsLocale = CRM_Core_I18n::getLocale(); @@ -555,7 +555,7 @@ class CRM_Core_I18n { $array[$key] = $value; } elseif ((string ) $key == 'title') { - $array[$key] = ts($value, array('context' => 'menu')); + $array[$key] = ts($value, ['context' => 'menu']); } } } @@ -686,7 +686,7 @@ class CRM_Core_I18n { */ 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 @@ class CRM_Core_I18n { * 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 @@ class CRM_Core_I18n { 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 @@ class CRM_Core_I18n { * @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 7c191c75f8..8433616cdd 100644 --- a/CRM/Core/I18n/Form.php +++ b/CRM/Core/I18n/Form.php @@ -51,7 +51,7 @@ class CRM_Core_I18n_Form extends CRM_Core_Form { $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 @@ class CRM_Core_I18n_Form extends CRM_Core_Form { $widget = $widgets[$table][$field]; // attributes - $attributes = array('class' => ''); + $attributes = ['class' => '']; if (isset($widget['rows'])) { $attributes['rows'] = $widget['rows']; } @@ -123,12 +123,12 @@ class CRM_Core_I18n_Form extends CRM_Core_Form { 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 8d703ebf6b..1866cf9eac 100644 --- a/CRM/Core/I18n/PseudoConstant.php +++ b/CRM/Core/I18n/PseudoConstant.php @@ -50,10 +50,10 @@ class CRM_Core_I18n_PseudoConstant { 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 @@ class CRM_Core_I18n_PseudoConstant { * @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 0920c4c132..64cb94b08f 100644 --- a/CRM/Core/I18n/Schema.php +++ b/CRM/Core/I18n/Schema.php @@ -73,7 +73,7 @@ class CRM_Core_I18n_Schema { // 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 @@ class CRM_Core_I18n_Schema { $retain, $table, $class = 'CRM_Core_I18n_SchemaStructure', - $triggers = array() + $triggers = [] ) { $domain = new CRM_Core_DAO_Domain(); $domain->find(TRUE); @@ -180,8 +180,8 @@ class CRM_Core_I18n_Schema { $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 @@ class CRM_Core_I18n_Schema { // 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 @@ class CRM_Core_I18n_Schema { } $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 @@ class CRM_Core_I18n_Schema { $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 @@ class CRM_Core_I18n_Schema { $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 @@ class CRM_Core_I18n_Schema { */ 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 @@ class CRM_Core_I18n_Schema { continue; } - $trigger = array(); + $trigger = []; foreach ($hash as $column => $_) { $trigger[] = "IF NEW.{$column}_{$locale} IS NOT NULL THEN"; @@ -569,9 +569,9 @@ class CRM_Core_I18n_Schema { } 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 @@ class CRM_Core_I18n_Schema { } $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 @@ class CRM_Core_I18n_Schema { } 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 @@ class CRM_Core_I18n_Schema { } $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 6b49ab712e..2450e0f277 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 @@ class CRM_Core_I18n_SchemaStructure_4_2_alpha1 { '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 @@ class CRM_Core_I18n_SchemaStructure_4_2_alpha1 { 'waitlist_text' => "text", 'approval_req_text' => "text", 'template_title' => "varchar(255)", - ), - ); + ], + ]; } return $result; } @@ -187,37 +187,37 @@ class CRM_Core_I18n_SchemaStructure_4_2_alpha1 { 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 09bc0977c5..6078d089ed 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 @@ class CRM_Core_I18n_SchemaStructure_4_3_1 { '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 @@ class CRM_Core_I18n_SchemaStructure_4_3_1 { 'waitlist_text' => "text", 'approval_req_text' => "text", 'template_title' => "varchar(255)", - ), - ); + ], + ]; } return $result; } @@ -192,37 +192,37 @@ class CRM_Core_I18n_SchemaStructure_4_3_1 { 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 6fcb086334..0ecc107866 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 @@ class CRM_Core_I18n_SchemaStructure_4_5_alpha1 { '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 @@ class CRM_Core_I18n_SchemaStructure_4_5_alpha1 { 'waitlist_text' => "text", 'approval_req_text' => "text", 'template_title' => "varchar(255)", - ), - ); + ], + ]; } return $result; } @@ -193,37 +193,37 @@ class CRM_Core_I18n_SchemaStructure_4_5_alpha1 { 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 ebde87cd0e..125b6f8030 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 @@ class CRM_Core_I18n_SchemaStructure_4_5_beta2 { '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 @@ class CRM_Core_I18n_SchemaStructure_4_5_beta2 { 'waitlist_text' => "text", 'approval_req_text' => "text", 'template_title' => "varchar(255)", - ), - ); + ], + ]; } return $result; } @@ -200,37 +200,37 @@ class CRM_Core_I18n_SchemaStructure_4_5_beta2 { 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 3bfcb287b4..3b14ff6a0a 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 @@ class CRM_Core_I18n_SchemaStructure_4_7_alpha1 { '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 @@ class CRM_Core_I18n_SchemaStructure_4_7_alpha1 { '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 @@ class CRM_Core_I18n_SchemaStructure_4_7_alpha1 { 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 8d1fed7f04..648b680d22 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 @@ class CRM_Core_IDS { } // 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 @@ class CRM_Core_IDS { $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 @@ class CRM_Core_IDS { * @return array */ public static function createStandardConfig() { - $excs = array( + $excs = [ 'widget_code', 'html_message', 'text_message', @@ -173,7 +173,7 @@ class CRM_Core_IDS { 'suggested_message', 'page_text', 'details', - ); + ]; $result = self::createBaseConfig(); @@ -191,10 +191,10 @@ class CRM_Core_IDS { */ 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 @@ class CRM_Core_IDS { 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 @@ class CRM_Core_IDS { 'ip' => $ip, 'reaction' => $reaction, 'impact' => $result->getImpact(), - ); + ]; } CRM_Core_Error::debug_var('IDS Detector Details', $data); @@ -294,18 +294,18 @@ class CRM_Core_IDS { 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 8d4f2291ca..123792a656 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 @@ class CRM_Core_InnoDBIndexer { 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 @@ class CRM_Core_InnoDBIndexer { 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 @@ class CRM_Core_InnoDBIndexer { 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 @@ class CRM_Core_InnoDBIndexer { * (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 @@ class CRM_Core_InnoDBIndexer { * (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 @@ class CRM_Core_InnoDBIndexer { array_keys($buildIndexSqls) )); - $todoSqls = array(); + $todoSqls = []; foreach ($allIndexNames as $indexName) { if (isset($buildIndexSqls[$indexName]) && isset($dropIndexSqls[$indexName])) { // already exists @@ -272,7 +272,7 @@ class CRM_Core_InnoDBIndexer { * @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 e8c4a4a97c..15ff125b0b 100644 --- a/CRM/Core/Invoke.php +++ b/CRM/Core/Invoke.php @@ -109,7 +109,7 @@ class CRM_Core_Invoke { * @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 @@ class CRM_Core_Invoke { * */ 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 38f6db414c..5d269cf24a 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 @@ class CRM_Core_JobManager { $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 @@ class CRM_Core_JobManager { //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 @@ class CRM_Core_JobManager { * ($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 50766d9fc4..8305fa2241 100644 --- a/CRM/Core/Joomla.php +++ b/CRM/Core/Joomla.php @@ -52,7 +52,7 @@ class CRM_Core_Joomla { return; } - $blockIds = array( + $blockIds = [ CRM_Core_Block::CREATE_NEW, CRM_Core_Block::RECENTLY_VIEWED, CRM_Core_Block::DASHBOARD, @@ -60,9 +60,9 @@ class CRM_Core_Joomla { 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 460475e418..789639506c 100644 --- a/CRM/Core/Lock.php +++ b/CRM/Core/Lock.php @@ -182,10 +182,10 @@ class CRM_Core_Lock implements \Civi\Core\Lock\LockInterface { } $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 @@ class CRM_Core_Lock implements \Civi\Core\Lock\LockInterface { } $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 @@ class CRM_Core_Lock implements \Civi\Core\Lock\LockInterface { */ 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 fe9631d0db..f5ee0c38ca 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 @@ class CRM_Core_ManagedEntities { function () { CRM_Core_ManagedEntities::singleton(TRUE)->reconcile(); }, - array(), + [], 'ManagedEntities::reconcile' ); } @@ -92,9 +92,9 @@ class CRM_Core_ManagedEntities { $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 @@ class CRM_Core_ManagedEntities { * 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 @@ class CRM_Core_ManagedEntities { $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 @@ class CRM_Core_ManagedEntities { // 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 @@ class CRM_Core_ManagedEntities { 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 @@ class CRM_Core_ManagedEntities { } 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 @@ class CRM_Core_ManagedEntities { $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 @@ class CRM_Core_ManagedEntities { */ 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 @@ class CRM_Core_ManagedEntities { * 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 @@ class CRM_Core_ManagedEntities { * 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 @@ class CRM_Core_ManagedEntities { */ 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 @@ class CRM_Core_ManagedEntities { * @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 0f81252978..eca6f6e38d 100644 --- a/CRM/Core/Module.php +++ b/CRM/Core/Module.php @@ -87,7 +87,7 @@ class CRM_Core_Module { * @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 2b80acc673..94368ec6a3 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 @@ class CRM_Core_OptionGroup { $dao, $flip = FALSE, $grouping = FALSE, $localize = FALSE, $valueColumnName = 'label' ) { - self::$_values = array(); + self::$_values = []; while ($dao->fetch()) { if ($flip) { @@ -164,7 +164,7 @@ WHERE v.option_group_id = g.id $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 @@ WHERE v.option_group_id = g.id } $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 @@ WHERE v.option_group_id = g.id 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 @@ WHERE v.option_group_id = g.id 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 @@ WHERE v.option_group_id = g.id 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 @@ WHERE v.option_group_id = g.id 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 @@ WHERE v.option_group_id = g.id $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 @@ SELECT v.id as amount_id, v.value, v.label, v.name, v.description, v.weight 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 @@ DELETE g, v 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 @@ WHERE v.option_group_id = g.id $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 @@ WHERE v.option_group_id = g.id * @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 @@ WHERE v.option_group_id = g.id * 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 007a6ea0b7..7390deb4ce 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 @@ class CRM_Core_OptionValue { $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 @@ class CRM_Core_OptionValue { $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 @@ class CRM_Core_OptionValue { 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 @@ class CRM_Core_OptionValue { 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 @@ class CRM_Core_OptionValue { $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 @@ FROM 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 @@ FROM 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 @@ FROM $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 @@ FROM '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 7db96fb92c..e8908fea50 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 @@ class CRM_Core_Page { $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 @@ class CRM_Core_Page { 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 @@ class CRM_Core_Page { 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 @@ class CRM_Core_Page { public function getTemplateFileName() { return strtr( CRM_Utils_System::getClassName($this), - array( + [ '_' => DIRECTORY_SEPARATOR, '\\' => DIRECTORY_SEPARATOR, - ) + ] ) . '.tpl'; } @@ -420,8 +420,8 @@ class CRM_Core_Page { * @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 a51f0ad3e4..2f11ee1c9d 100644 --- a/CRM/Core/Page/AJAX.php +++ b/CRM/Core/Page/AJAX.php @@ -50,7 +50,7 @@ class CRM_Core_Page_AJAX { } 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 @@ class CRM_Core_Page_AJAX { switch ($type) { case 'method': - call_user_func(array($className, $fnName)); + call_user_func([$className, $fnName]); break; case 'page': @@ -102,7 +102,7 @@ class CRM_Core_Page_AJAX { // 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 @@ class CRM_Core_Page_AJAX { 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 @@ class CRM_Core_Page_AJAX { 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 @@ class CRM_Core_Page_AJAX { * @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 @@ class CRM_Core_Page_AJAX { * * @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 fe71fd8f82..f06559285e 100644 --- a/CRM/Core/Page/AJAX/Attachment.php +++ b/CRM/Core/Page/AJAX/Attachment.php @@ -62,18 +62,18 @@ class CRM_Core_Page_AJAX_Attachment { */ 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 @@ class CRM_Core_Page_AJAX_Attachment { // 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 @@ class CRM_Core_Page_AJAX_Attachment { $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 @@ class CRM_Core_Page_AJAX_Attachment { * @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 @@ class CRM_Core_Page_AJAX_Attachment { */ 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 ecaff14078..04066e4bd1 100644 --- a/CRM/Core/Page/AJAX/Location.php +++ b/CRM/Core/Page/AJAX/Location.php @@ -63,8 +63,8 @@ class CRM_Core_Page_AJAX_Location { 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 @@ class CRM_Core_Page_AJAX_Location { 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 @@ class CRM_Core_Page_AJAX_Location { 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 @@ class CRM_Core_Page_AJAX_Location { '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 @@ class CRM_Core_Page_AJAX_Location { // 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 @@ class CRM_Core_Page_AJAX_Location { $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 f091bf4795..198b22c33e 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 27d4cbdf36..aeeaa199f3 100644 --- a/CRM/Core/Page/Basic.php +++ b/CRM/Core/Page/Basic.php @@ -222,7 +222,7 @@ abstract class CRM_Core_Page_Basic extends CRM_Core_Page { $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 @@ abstract class CRM_Core_Page_Basic extends CRM_Core_Page { $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 @@ abstract class CRM_Core_Page_Basic extends CRM_Core_Page { $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 @@ abstract class CRM_Core_Page_Basic extends CRM_Core_Page { $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 @@ abstract class CRM_Core_Page_Basic extends CRM_Core_Page { } //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 5920d7779c..ae1c90c344 100644 --- a/CRM/Core/Page/QUnit.php +++ b/CRM/Core/Page/QUnit.php @@ -43,7 +43,7 @@ class CRM_Core_Page_QUnit extends CRM_Core_Page { 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 @@ class CRM_Core_Page_QUnit extends CRM_Core_Page { && 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 e3cfb43921..e2505f6a6f 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 @@ class CRM_Core_Page_RecurringEntityPreview extends CRM_Core_Page { 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 98b24af9f7..90be62a20b 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 @@ class CRM_Core_Page_Redirect extends CRM_Core_Page { 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 3a6479cf44..0d39e192ac 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 @@ class CRM_Core_Payment_AuthorizeNet extends CRM_Core_Payment { return $params; } - $postFields = array(); + $postFields = []; $authorizeNetFields = $this->_getAuthorizeNetFields(); // Set up our call for hook_civicrm_paymentProcessor, @@ -198,7 +198,7 @@ class CRM_Core_Payment_AuthorizeNet extends CRM_Core_Payment { // 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 @@ class CRM_Core_Payment_AuthorizeNet extends CRM_Core_Payment { 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 @@ class CRM_Core_Payment_AuthorizeNet extends CRM_Core_Payment { 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 @@ class CRM_Core_Payment_AuthorizeNet extends CRM_Core_Payment { $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 @@ class CRM_Core_Payment_AuthorizeNet extends CRM_Core_Payment { $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 @@ class CRM_Core_Payment_AuthorizeNet extends CRM_Core_Payment { 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 @@ class CRM_Core_Payment_AuthorizeNet extends CRM_Core_Payment { 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 @@ class CRM_Core_Payment_AuthorizeNet extends CRM_Core_Payment { * 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 @@ class CRM_Core_Payment_AuthorizeNet extends CRM_Core_Payment { * * @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 @@ class CRM_Core_Payment_AuthorizeNet extends CRM_Core_Payment { } 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 @@ class CRM_Core_Payment_AuthorizeNet extends CRM_Core_Payment { * * @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 @@ class CRM_Core_Payment_AuthorizeNet extends CRM_Core_Payment { } 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 @@ class CRM_Core_Payment_AuthorizeNet extends CRM_Core_Payment { * * @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 @@ class CRM_Core_Payment_AuthorizeNet extends CRM_Core_Payment { } 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 8455449c8d..b68bd8cf2c 100644 --- a/CRM/Core/Payment/AuthorizeNetIPN.php +++ b/CRM/Core/Payment/AuthorizeNetIPN.php @@ -55,7 +55,7 @@ class CRM_Core_Payment_AuthorizeNetIPN extends CRM_Core_Payment_BaseIPN { //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 @@ class CRM_Core_Payment_AuthorizeNetIPN extends CRM_Core_Payment_BaseIPN { $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 @@ class CRM_Core_Payment_AuthorizeNetIPN extends CRM_Core_Payment_BaseIPN { $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 @@ class CRM_Core_Payment_AuthorizeNetIPN extends CRM_Core_Payment_BaseIPN { $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 @@ class CRM_Core_Payment_AuthorizeNetIPN extends CRM_Core_Payment_BaseIPN { 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 @@ class CRM_Core_Payment_AuthorizeNetIPN extends CRM_Core_Payment_BaseIPN { "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 @@ INNER JOIN civicrm_contribution co ON co.contribution_recur_id = cr.id $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 9dd044fc36..e538c84ecd 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 @@ class CRM_Core_Payment_BaseIPN { // 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 @@ class CRM_Core_Payment_BaseIPN { 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 @@ class CRM_Core_Payment_BaseIPN { * * @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 @@ class CRM_Core_Payment_BaseIPN { $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 @@ class CRM_Core_Payment_BaseIPN { 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 @@ class CRM_Core_Payment_BaseIPN { * * @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 @@ class CRM_Core_Payment_BaseIPN { 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 @@ class CRM_Core_Payment_BaseIPN { 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 @@ class CRM_Core_Payment_BaseIPN { $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 @@ class CRM_Core_Payment_BaseIPN { 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 92f932c273..1fdbd9cda3 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 @@ class CRM_Core_Payment_Dummy extends CRM_Core_Payment { } 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 @@ class CRM_Core_Payment_Dummy extends CRM_Core_Payment { } 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 @@ class CRM_Core_Payment_Dummy extends CRM_Core_Payment { * @return array */ public function getEditableRecurringScheduleFields() { - return array('amount', 'next_sched_contribution_date'); + return ['amount', 'next_sched_contribution_date']; } /** @@ -223,7 +223,7 @@ class CRM_Core_Payment_Dummy extends CRM_Core_Payment { * * @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 eef6b14829..7b91ac4251 100644 --- a/CRM/Core/Payment/Elavon.php +++ b/CRM/Core/Payment/Elavon.php @@ -230,7 +230,7 @@ class CRM_Core_Payment_Elavon extends CRM_Core_Payment { 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 @@ class CRM_Core_Payment_Elavon extends CRM_Core_Payment { * */ 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 @@ class CRM_Core_Payment_Elavon extends CRM_Core_Payment { * @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 6af1f1cea2..38b0b2dc48 100644 --- a/CRM/Core/Payment/FirstData.php +++ b/CRM/Core/Payment/FirstData.php @@ -160,7 +160,7 @@ class CRM_Core_Payment_FirstData extends CRM_Core_Payment { } 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 @@ class CRM_Core_Payment_FirstData extends CRM_Core_Payment { * 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 112f441e84..09b39a2362 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 @@ class CRM_Core_Payment_Form { $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 @@ class CRM_Core_Payment_Form { 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 @@ class CRM_Core_Payment_Form { * @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 @@ class CRM_Core_Payment_Form { '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 8798f5cce9..5621d71280 100644 --- a/CRM/Core/Payment/Manual.php +++ b/CRM/Core/Payment/Manual.php @@ -62,7 +62,7 @@ class CRM_Core_Payment_Manual extends CRM_Core_Payment { // @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 @@ class CRM_Core_Payment_Manual extends CRM_Core_Payment { '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 @@ class CRM_Core_Payment_Manual extends CRM_Core_Payment { */ 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 3b70daea06..0dcbecf453 100644 --- a/CRM/Core/Payment/PayJunction.php +++ b/CRM/Core/Payment/PayJunction.php @@ -66,7 +66,7 @@ class CRM_Core_Payment_PayJunction extends CRM_Core_Payment { $pjpgCustInfo->setEmail($params['email']); - $billing = array( + $billing = [ "logon" => $logon, "password" => $password, "url_site" => $url_site, @@ -77,7 +77,7 @@ class CRM_Core_Payment_PayJunction extends CRM_Core_Payment { "province" => $params['state_province'], "postal_code" => $params['postal_code'], "country" => $params['country'], - ); + ]; $pjpgCustInfo->setBilling($billing); // create pjpgTransaction object @@ -85,7 +85,7 @@ class CRM_Core_Payment_PayJunction extends CRM_Core_Payment { $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 @@ class CRM_Core_Payment_PayJunction extends CRM_Core_Payment { '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 @@ class CRM_Core_Payment_PayJunction extends CRM_Core_Payment { $numRecurs = $params['installments']; - $recurArray = array( + $recurArray = [ 'dc_schedule_create' => $dc_schedule_create, // (day | week | month) 'recur_unit' => $recurUnit, @@ -137,7 +137,7 @@ class CRM_Core_Payment_PayJunction extends CRM_Core_Payment { 'period' => $recurInterval, 'dc_schedule_start' => $dc_schedule_start, 'amount' => sprintf('%01.2f', $params['amount']), - ); + ]; $pjpgRecur = new pjpgRecur($recurArray); @@ -265,7 +265,7 @@ class CRM_Core_Payment_PayJunction extends CRM_Core_Payment { * 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 6af63aaeee..155fae1d57 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 @@ class CRM_Core_Payment_PayPalIPN extends CRM_Core_Payment_BaseIPN { $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 @@ class CRM_Core_Payment_PayPalIPN extends CRM_Core_Payment_BaseIPN { * @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 @@ class CRM_Core_Payment_PayPalIPN extends CRM_Core_Payment_BaseIPN { $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 @@ class CRM_Core_Payment_PayPalIPN extends CRM_Core_Payment_BaseIPN { "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 @@ class CRM_Core_Payment_PayPalIPN extends CRM_Core_Payment_BaseIPN { // 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 a273bbcad7..badb5e22eb 100644 --- a/CRM/Core/Payment/PayPalImpl.php +++ b/CRM/Core/Payment/PayPalImpl.php @@ -148,15 +148,15 @@ class CRM_Core_Payment_PayPalImpl extends CRM_Core_Payment { 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 @@ class CRM_Core_Payment_PayPalImpl extends CRM_Core_Payment { 'image', $form->_expressButtonName, $this->_paymentProcessor['url_button'], - array('class' => 'crm-form-submit') + ['class' => 'crm-form-submit'] ); } } @@ -245,7 +245,7 @@ class CRM_Core_Payment_PayPalImpl extends CRM_Core_Payment { * @throws \Civi\Payment\Exception\PaymentProcessorException */ protected function setExpressCheckOut(&$params) { - $args = array(); + $args = []; $this->initialize($args, 'SetExpressCheckout'); @@ -292,7 +292,7 @@ class CRM_Core_Payment_PayPalImpl extends CRM_Core_Payment { * @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 @@ class CRM_Core_Payment_PayPalImpl extends CRM_Core_Payment { * @throws \Civi\Payment\Exception\PaymentProcessorException */ public function getExpressCheckoutDetails($token) { - $args = array(); + $args = []; $this->initialize($args, 'GetExpressCheckoutDetails'); $args['token'] = $token; @@ -322,7 +322,7 @@ class CRM_Core_Payment_PayPalImpl extends CRM_Core_Payment { } /* Success */ - $fieldMap = array( + $fieldMap = [ 'token' => 'token', 'payer_status' => 'payerstatus', 'payer_id' => 'payerid', @@ -335,7 +335,7 @@ class CRM_Core_Payment_PayPalImpl extends CRM_Core_Payment { 'postal_code' => 'shiptozip', 'state_province' => 'shiptostate', 'country' => 'shiptocountrycode', - ); + ]; return $this->mapPaypalParamsToCivicrmParams($fieldMap, $result); } @@ -356,7 +356,7 @@ class CRM_Core_Payment_PayPalImpl extends CRM_Core_Payment { if (!empty($params['is_recur'])) { return $this->createRecurringPayments($params); } - $args = array(); + $args = []; $this->initialize($args, 'DoExpressCheckoutPayment'); $args['token'] = $params['token']; @@ -411,7 +411,7 @@ class CRM_Core_Payment_PayPalImpl extends CRM_Core_Payment { * @throws \Exception */ public function createRecurringPayments(&$params) { - $args = array(); + $args = []; $this->initialize($args, 'CreateRecurringPaymentsProfile'); $start_time = strtotime(date('m/d/Y')); @@ -524,7 +524,7 @@ class CRM_Core_Payment_PayPalImpl extends CRM_Core_Payment { * @throws \Civi\Payment\Exception\PaymentProcessorException */ public function doDirectPayment(&$params, $component = 'contribute') { - $args = array(); + $args = []; $this->initialize($args, 'DoDirectPayment'); @@ -619,20 +619,20 @@ class CRM_Core_Payment_PayPalImpl extends CRM_Core_Payment { 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 @@ class CRM_Core_Payment_PayPalImpl extends CRM_Core_Payment { * @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 @@ class CRM_Core_Payment_PayPalImpl extends CRM_Core_Payment { * @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 @@ class CRM_Core_Payment_PayPalImpl extends CRM_Core_Payment { 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 @@ class CRM_Core_Payment_PayPalImpl extends CRM_Core_Payment { * @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 @@ class CRM_Core_Payment_PayPalImpl extends CRM_Core_Payment { * @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 @@ class CRM_Core_Payment_PayPalImpl extends CRM_Core_Payment { */ 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 @@ class CRM_Core_Payment_PayPalImpl extends CRM_Core_Payment { */ 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 @@ class CRM_Core_Payment_PayPalImpl extends CRM_Core_Payment { 'accountingCode' => 'accountingCode', 'contributionRecurID' => 'contributionRecurID', 'contributionPageID' => 'contributionPageID', - ); + ]; foreach ($notifyParameterMap as $paramsName => $notifyName) { if (!empty($params[$paramsName])) { $notifyParameters[$notifyName] = $params[$paramsName]; @@ -914,7 +914,7 @@ class CRM_Core_Payment_PayPalImpl extends CRM_Core_Payment { TRUE, NULL, FALSE ); - $paypalParams = array( + $paypalParams = [ 'business' => $this->_paymentProcessor['user_name'], 'notify_url' => $notifyURL, 'item_name' => $this->getPaymentDescription($params, 127), @@ -931,10 +931,10 @@ class CRM_Core_Payment_PayPalImpl extends CRM_Core_Payment { '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 @@ class CRM_Core_Payment_PayPalImpl extends CRM_Core_Payment { '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 @@ class CRM_Core_Payment_PayPalImpl extends CRM_Core_Payment { 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 @@ class CRM_Core_Payment_PayPalImpl extends CRM_Core_Payment { '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 @@ class CRM_Core_Payment_PayPalImpl extends CRM_Core_Payment { $url = $this->_paymentProcessor['url_api'] . 'nvp'; } - $p = array(); + $p = []; foreach ($args as $n => $v) { $p[] = "$n=" . urlencode($v); } @@ -1115,7 +1115,7 @@ class CRM_Core_Payment_PayPalImpl extends CRM_Core_Payment { * @return array */ public static function deformat($str) { - $result = array(); + $result = []; while (strlen($str)) { // position of key @@ -1148,7 +1148,7 @@ class CRM_Core_Payment_PayPalImpl extends CRM_Core_Payment { return $this->getCreditCardFormFields(); } else { - return array(); + return []; } } @@ -1161,7 +1161,7 @@ class CRM_Core_Payment_PayPalImpl extends CRM_Core_Payment { * @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 @@ class CRM_Core_Payment_PayPalImpl extends CRM_Core_Payment { // 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 9fd23b8d5e..4e0bcb46b0 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 @@ class CRM_Core_Payment_PayPalProIPN extends CRM_Core_Payment_BaseIPN { $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 @@ class CRM_Core_Payment_PayPalProIPN extends CRM_Core_Payment_BaseIPN { '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 @@ class CRM_Core_Payment_PayPalProIPN extends CRM_Core_Payment_BaseIPN { $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 @@ class CRM_Core_Payment_PayPalProIPN extends CRM_Core_Payment_BaseIPN { $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 @@ class CRM_Core_Payment_PayPalProIPN extends CRM_Core_Payment_BaseIPN { $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 @@ class CRM_Core_Payment_PayPalProIPN extends CRM_Core_Payment_BaseIPN { $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 @@ class CRM_Core_Payment_PayPalProIPN extends CRM_Core_Payment_BaseIPN { 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 @@ INNER JOIN civicrm_membership_payment mp ON m.id = mp.membership_id AND mp.contr $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 @@ INNER JOIN civicrm_membership_payment mp ON m.id = mp.membership_id AND mp.contr "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 @@ INNER JOIN civicrm_membership_payment mp ON m.id = mp.membership_id AND mp.contr // 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 @@ INNER JOIN civicrm_membership_payment mp ON m.id = mp.membership_id AND mp.contr 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 @@ INNER JOIN civicrm_membership_payment mp ON m.id = mp.membership_id AND mp.contr $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 @@ INNER JOIN civicrm_membership_payment mp ON m.id = mp.membership_id AND mp.contr */ 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 2020b2a8cd..46541a4b16 100644 --- a/CRM/Core/Payment/PayflowPro.php +++ b/CRM/Core/Payment/PayflowPro.php @@ -89,7 +89,7 @@ class CRM_Core_Payment_PayflowPro extends CRM_Core_Payment { * */ - $payflow_query_array = array( + $payflow_query_array = [ 'USER' => $user, 'VENDOR' => $this->_paymentProcessor['user_name'], 'PARTNER' => $this->_paymentProcessor['signature'], @@ -121,7 +121,7 @@ class CRM_Core_Payment_PayflowPro extends CRM_Core_Payment { 'ORDERDESC' => urlencode($params['description']), 'VERBOSITY' => 'MEDIUM', 'BILLTOCOUNTRY' => urlencode($params['country']), - ); + ]; if ($params['installments'] == 1) { $params['is_recur'] = FALSE; @@ -272,7 +272,7 @@ class CRM_Core_Payment_PayflowPro extends CRM_Core_Payment { return self::errorExit(9016, "No RESULT code from PayPal."); } - $nvpArray = array(); + $nvpArray = []; while (strlen($result)) { // name $keypos = strpos($result, '='); @@ -386,13 +386,13 @@ class CRM_Core_Payment_PayflowPro extends CRM_Core_Payment { * 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 07322ed5ba..28552293fe 100644 --- a/CRM/Core/Payment/PaymentExpress.php +++ b/CRM/Core/Payment/PaymentExpress.php @@ -77,7 +77,7 @@ class CRM_Core_Payment_PaymentExpress extends CRM_Core_Payment { 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 @@ class CRM_Core_Payment_PaymentExpress extends CRM_Core_Payment { } - $dpsParams = array( + $dpsParams = [ 'AmountInput' => str_replace(",", "", number_format($params['amount'], 2)), 'CurrencyInput' => $params['currencyID'], 'MerchantReference' => $merchantRef, @@ -171,7 +171,7 @@ class CRM_Core_Payment_PaymentExpress extends CRM_Core_Payment { '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 52bd5ce82e..8683a65f85 100644 --- a/CRM/Core/Payment/PaymentExpressIPN.php +++ b/CRM/Core/Payment/PaymentExpressIPN.php @@ -111,7 +111,7 @@ class CRM_Core_Payment_PaymentExpressIPN extends CRM_Core_Payment_BaseIPN { * @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 @@ class CRM_Core_Payment_PaymentExpressIPN extends CRM_Core_Payment_BaseIPN { } } - return array($isTest, $component, $duplicateTransaction); + return [$isTest, $component, $duplicateTransaction]; } /** @@ -286,11 +286,11 @@ class CRM_Core_Payment_PaymentExpressIPN extends CRM_Core_Payment_BaseIPN { } 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 @@ class CRM_Core_Payment_PaymentExpressIPN extends CRM_Core_Payment_BaseIPN { $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 @@ class CRM_Core_Payment_PaymentExpressIPN extends CRM_Core_Payment_BaseIPN { $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 @@ class CRM_Core_Payment_PaymentExpressIPN extends CRM_Core_Payment_BaseIPN { * @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 ba07a854fc..55ec6ffff4 100644 --- a/CRM/Core/Payment/ProcessorForm.php +++ b/CRM/Core/Payment/ProcessorForm.php @@ -80,12 +80,12 @@ class CRM_Core_Payment_ProcessorForm { } 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 @@ class CRM_Core_Payment_ProcessorForm { ) { 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 c757923468..5a4931d214 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 @@ class CRM_Core_Payment_Realex extends CRM_Core_Payment { 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 @@ class CRM_Core_Payment_Realex extends CRM_Core_Payment { // 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 @@ class CRM_Core_Payment_Realex extends CRM_Core_Payment { * 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 @@ class CRM_Core_Payment_Realex extends CRM_Core_Payment { } 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 @@ class CRM_Core_Payment_Realex extends CRM_Core_Payment { * @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 @@ class CRM_Core_Payment_Realex extends CRM_Core_Payment { break; case 'open': - $children = array(); + $children = []; break; case 'close': @@ -475,7 +475,7 @@ class CRM_Core_Payment_Realex extends CRM_Core_Payment { * 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 97359f040c..4975956980 100644 --- a/CRM/Core/Payment/eWAY.php +++ b/CRM/Core/Payment/eWAY.php @@ -465,7 +465,7 @@ class CRM_Core_Payment_eWAY extends CRM_Core_Payment { * ***************************************************************************************** */ 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 10a9bd10bd..5a3f0eff7a 100644 --- a/CRM/Core/Permission.php +++ b/CRM/Core/Permission.php @@ -254,8 +254,8 @@ class CRM_Core_Permission { */ 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 @@ class CRM_Core_Permission { } } $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 @@ class CRM_Core_Permission { $permissionName = "delete in $module"; } else { - $editPermissions = array( + $editPermissions = [ 'CiviEvent' => 'edit event participants', 'CiviMember' => 'edit memberships', 'CiviPledge' => 'edit pledges', @@ -485,7 +485,7 @@ class CRM_Core_Permission { 'CiviGrant' => 'edit grants', 'CiviMail' => 'access CiviMail', 'CiviAuction' => 'add auction items', - ); + ]; $permissionName = CRM_Utils_Array::value($module, $editPermissions); } @@ -585,7 +585,7 @@ class CRM_Core_Permission { * @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 @@ class CRM_Core_Permission { $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 @@ class CRM_Core_Permission { foreach ($perm as $p => $attr) { if (!is_array($attr)) { - $attr = array($attr); + $attr = [$attr]; } $attr[0] = $info['translatedName'] . ': ' . $attr[0]; @@ -653,11 +653,11 @@ class CRM_Core_Permission { * @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 @@ class CRM_Core_Permission { */ 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 @@ class CRM_Core_Permission { * @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 @@ class CRM_Core_Permission { $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 @@ class CRM_Core_Permission { //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 @@ class CRM_Core_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 7e9336f946..9d4507c5a3 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 @@ class CRM_Core_Permission_Backdrop extends CRM_Core_Permission_DrupalBase { * 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 @@ class CRM_Core_Permission_Backdrop extends CRM_Core_Permission_DrupalBase { $_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 79893ad30e..c14e63e3ae 100644 --- a/CRM/Core/Permission/Base.php +++ b/CRM/Core/Permission/Base.php @@ -240,10 +240,10 @@ class CRM_Core_Permission_Base { * @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 @@ class CRM_Core_Permission_Base { * 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 060c5f2df1..4f67b6ce38 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 @@ class CRM_Core_Permission_Drupal extends CRM_Core_Permission_DrupalBase { * 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 9d524ebca5..d969ed4237 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 @@ class CRM_Core_Permission_Drupal6 extends CRM_Core_Permission_DrupalBase { */ 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 @@ class CRM_Core_Permission_Drupal6 extends CRM_Core_Permission_DrupalBase { * 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 @@ class CRM_Core_Permission_Drupal6 extends CRM_Core_Permission_DrupalBase { * 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 @@ class CRM_Core_Permission_Drupal6 extends CRM_Core_Permission_DrupalBase { * 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 d4d6a81190..2b728bc477 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 @@ class CRM_Core_Permission_Drupal8 extends CRM_Core_Permission_DrupalBase { * 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 @@ class CRM_Core_Permission_Drupal8 extends CRM_Core_Permission_DrupalBase { 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 ac8a530cb9..b691211be2 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 @@ class CRM_Core_Permission_DrupalBase extends CRM_Core_Permission_Base { $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 @@ class CRM_Core_Permission_DrupalBase extends CRM_Core_Permission_Base { $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 @@ class CRM_Core_Permission_DrupalBase extends CRM_Core_Permission_Base { $dao = CRM_Core_DAO::executeQuery($sql); - $emails = array(); + $emails = []; while ($dao->fetch()) { $emails[] = $dao->email; } @@ -292,13 +292,13 @@ class CRM_Core_Permission_DrupalBase extends CRM_Core_Permission_Base { * 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 afe3a5669a..2eea7228a8 100644 --- a/CRM/Core/Permission/Joomla.php +++ b/CRM/Core/Permission/Joomla.php @@ -120,7 +120,7 @@ class CRM_Core_Permission_Joomla extends CRM_Core_Permission_Base { 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 @@ class CRM_Core_Permission_Joomla extends CRM_Core_Permission_Base { * @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 @@ class CRM_Core_Permission_Joomla extends CRM_Core_Permission_Base { // 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 ae52b512f2..18740068a9 100644 --- a/CRM/Core/Permission/Temp.php +++ b/CRM/Core/Permission/Temp.php @@ -103,7 +103,7 @@ class CRM_Core_Permission_Temp { * 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 9fe039fd27..dc5224f7f9 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 8e4ef801ff..a08d9ba0c6 100644 --- a/CRM/Core/PrevNextCache/Redis.php +++ b/CRM/Core/PrevNextCache/Redis.php @@ -249,7 +249,7 @@ class CRM_Core_PrevNextCache_Redis implements CRM_Core_PrevNextCache_Interface { 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 efa1756a02..51f767bee0 100644 --- a/CRM/Core/PrevNextCache/Sql.php +++ b/CRM/Core/PrevNextCache/Sql.php @@ -91,7 +91,7 @@ INSERT INTO civicrm_prevnext_cache (cacheKey, entity_id1, data) if (!$cacheKey) { return; } - $params = array(); + $params = []; if ($ids && $cacheKey && $action) { if (is_array($ids)) { @@ -106,17 +106,17 @@ AND (entity_id1 IN {$cIdFilter} OR entity_id2 IN {$cIdFilter}) 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 @@ UPDATE civicrm_prevnext_cache 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 @@ WHERE cacheKey = %1 AND is_selected = 1 if (!$cacheKey) { return NULL; } - $params = array(); + $params = []; if ($cacheKey && ($action == 'get' || $action == 'getall')) { $actionGet = ($action == "get") ? " AND is_selected = 1 " : ""; @@ -157,9 +157,9 @@ WHERE cacheKey = %1 $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 @@ ORDER BY id */ 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 @@ ORDER BY id * 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 fb59a3c5f8..96f9bba423 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 @@ class CRM_Core_PseudoConstant { // 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 @@ class CRM_Core_PseudoConstant { } // 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 @@ class CRM_Core_PseudoConstant { $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 @@ class CRM_Core_PseudoConstant { } // 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 @@ class CRM_Core_PseudoConstant { 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 @@ class CRM_Core_PseudoConstant { $order = "ORDER BY weight"; } - $output = array(); + $output = []; $query = "$select $from"; if ($wheres) { $query .= " WHERE " . implode($wheres, ' AND '); @@ -381,7 +381,7 @@ class CRM_Core_PseudoConstant { $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 @@ class CRM_Core_PseudoConstant { // 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 @@ class CRM_Core_PseudoConstant { } $object->find(); - $var = array(); + $var = []; while ($object->fetch()) { $var[$object->$key] = $object->$retrieve; } @@ -619,7 +619,7 @@ class CRM_Core_PseudoConstant { $index .= '_' . (int) $onlyComponentActivities; if (NULL === self::$activityType) { - self::$activityType = array(); + self::$activityType = []; } if (!isset(self::$activityType[$index]) || $reset) { @@ -632,7 +632,7 @@ class CRM_Core_PseudoConstant { $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 @@ class CRM_Core_PseudoConstant { 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 @@ class CRM_Core_PseudoConstant { $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 @@ class CRM_Core_PseudoConstant { $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 @@ WHERE id = %1"; 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 @@ WHERE id = %1"; */ 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 @@ WHERE id = %1"; 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 @@ WHERE id = %1"; // 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 @@ WHERE id = %1"; $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 @@ WHERE id = %1"; 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 @@ WHERE id = %1"; $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 @@ WHERE id = %1"; '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 @@ WHERE id = %1"; $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 @@ WHERE id = %1"; */ 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 @@ WHERE id = %1"; */ public static function &visibility($column = 'label') { if (!isset(self::$visibility)) { - self::$visibility = array(); + self::$visibility = []; } if (!isset(self::$visibility[$column])) { @@ -1276,7 +1276,7 @@ WHERE id = %1"; $cacheKey = "{$countryID}_{$field}"; if (!$_cache) { - $_cache = array(); + $_cache = []; } if (!empty($_cache[$cacheKey])) { @@ -1288,16 +1288,16 @@ SELECT civicrm_state_province.{$field} name, civicrm_state_province.id id 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 @@ ORDER BY 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 @@ ORDER BY name"; $dao = CRM_Core_DAO::executeQuery($query); - $result = array(); + $result = []; while ($dao->fetch()) { $result[$dao->id] = $dao->abbreviation . ': ' . $dao->name; } @@ -1348,7 +1348,7 @@ ORDER BY name"; $cacheKey = "{$stateID}_name"; if (!$_cache) { - $_cache = array(); + $_cache = []; } if (!empty($_cache[$cacheKey])) { @@ -1360,16 +1360,16 @@ ORDER BY name"; 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 @@ SELECT country_id 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 @@ WHERE id = %1 */ 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 @@ WHERE id = %1 */ public static function &getExtensions() { if (!self::$extensions) { - self::$extensions = array(); + self::$extensions = []; $sql = ' SELECT full_name, label FROM civicrm_extension @@ -1535,13 +1535,13 @@ WHERE id = %1 */ 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 @@ WHERE id = %1 * @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 578b9c5fae..9118e2f2f3 100644 --- a/CRM/Core/QuickForm/Action/Display.php +++ b/CRM/Core/QuickForm/Action/Display.php @@ -152,7 +152,7 @@ class CRM_Core_QuickForm_Action_Display extends CRM_Core_QuickForm_Action { } if ($controller->_QFResponseType == 'json') { - $response = array('content' => $html); + $response = ['content' => $html]; if (!empty($page->ajaxResponse)) { $response += $page->ajaxResponse; } @@ -169,7 +169,7 @@ class CRM_Core_QuickForm_Action_Display extends CRM_Core_QuickForm_Action { $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 9c60e1cb84..b684036a19 100644 --- a/CRM/Core/QuickForm/Action/Upload.php +++ b/CRM/Core/QuickForm/Action/Upload.php @@ -96,19 +96,19 @@ class CRM_Core_QuickForm_Action_Upload extends CRM_Core_QuickForm_Action { $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 fe20778e80..051ccda217 100644 --- a/CRM/Core/QuickForm/GroupMultiSelect.php +++ b/CRM/Core/QuickForm/GroupMultiSelect.php @@ -65,8 +65,8 @@ class CRM_Core_QuickForm_GroupMultiSelect extends CRM_Core_QuickForm_NestedAdvMu 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 @@ class CRM_Core_QuickForm_GroupMultiSelect extends CRM_Core_QuickForm_NestedAdvMu $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 @@ class CRM_Core_QuickForm_GroupMultiSelect extends CRM_Core_QuickForm_NestedAdvMu // ... 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 @@ class CRM_Core_QuickForm_GroupMultiSelect extends CRM_Core_QuickForm_NestedAdvMu $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 @@ class CRM_Core_QuickForm_GroupMultiSelect extends CRM_Core_QuickForm_NestedAdvMu } } else { - $arrHtmlHidden = array(); + $arrHtmlHidden = []; } // The 'unselected' multi-select which appears on the left @@ -207,43 +207,43 @@ class CRM_Core_QuickForm_GroupMultiSelect extends CRM_Core_QuickForm_NestedAdvMu $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 @@ class CRM_Core_QuickForm_GroupMultiSelect extends CRM_Core_QuickForm_NestedAdvMu $strHtml = preg_replace('/\s*.*\s*/i', '', $strHtml); } - $placeHolders = array( + $placeHolders = [ '{stylesheet}', '{javascript}', '{class}', @@ -284,8 +284,8 @@ class CRM_Core_QuickForm_GroupMultiSelect extends CRM_Core_QuickForm_NestedAdvMu '{toggle}', '{moveup}', '{movedown}', - ); - $htmlElements = array( + ]; + $htmlElements = [ $this->getElementCss(FALSE), $this->getElementJs(FALSE), $this->_tableAttributes, @@ -298,7 +298,7 @@ class CRM_Core_QuickForm_GroupMultiSelect extends CRM_Core_QuickForm_NestedAdvMu $strHtmlToggle, $strHtmlMoveUp, $strHtmlMoveDown, - ); + ]; $strHtml = str_replace($placeHolders, $htmlElements, $strHtml); diff --git a/CRM/Core/QuickForm/NestedAdvMultiSelect.php b/CRM/Core/QuickForm/NestedAdvMultiSelect.php index a210b710b1..84a787a1c6 100644 --- a/CRM/Core/QuickForm/NestedAdvMultiSelect.php +++ b/CRM/Core/QuickForm/NestedAdvMultiSelect.php @@ -67,7 +67,7 @@ class CRM_Core_QuickForm_NestedAdvMultiSelect extends HTML_QuickForm_advmultisel ) { 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 797d5832ab..a3e1fe73f8 100644 --- a/CRM/Core/Reference/Basic.php +++ b/CRM/Core/Reference/Basic.php @@ -83,9 +83,9 @@ class CRM_Core_Reference_Basic implements CRM_Core_Reference_Interface { 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 @@ EOS; */ 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 64fc790ebc..6c5ba398ca 100644 --- a/CRM/Core/Reference/Dynamic.php +++ b/CRM/Core/Reference/Dynamic.php @@ -28,12 +28,12 @@ class CRM_Core_Reference_Dynamic extends CRM_Core_Reference_Basic { $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 = <<getReferenceKey()} = %1 AND {$this->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 77b3e6065b..6ea85bc07a 100644 --- a/CRM/Core/Region.php +++ b/CRM/Core/Region.php @@ -51,15 +51,15 @@ class CRM_Core_Region { 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 @@ class CRM_Core_Region { * @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 @@ class CRM_Core_Region { $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 @@ class CRM_Core_Region { 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 0e4e7755ec..4911057717 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 @@ class CRM_Core_Resources { */ 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 @@ class CRM_Core_Resources { * @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 @@ class CRM_Core_Resources { * @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 @@ class CRM_Core_Resources { * @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 @@ class CRM_Core_Resources { 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 @@ class CRM_Core_Resources { */ 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 @@ class CRM_Core_Resources { */ 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 @@ class CRM_Core_Resources { * @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 @@ class CRM_Core_Resources { * @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 @@ class CRM_Core_Resources { 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 @@ class CRM_Core_Resources { } } // 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 @@ class CRM_Core_Resources { 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 @@ class CRM_Core_Resources { '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 @@ class CRM_Core_Resources { // 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 @@ class CRM_Core_Resources { "js/crm.datepicker.js", "js/crm.ajax.js", "js/wysiwyg/crm.wysiwyg.js", - ); + ]; // Dynamic localization script $items[] = $this->addCacheCode( @@ -733,12 +733,12 @@ class CRM_Core_Resources { $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 @@ class CRM_Core_Resources { // 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 @@ class CRM_Core_Resources { * 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 f8a9175315..4f1315c468 100644 --- a/CRM/Core/Resources/Strings.php +++ b/CRM/Core/Resources/Strings.php @@ -69,14 +69,14 @@ class CRM_Core_Resources_Strings { 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 0802b0e6aa..eb2be0bf13 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 @@ class CRM_Core_ScheduledJob { // 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 @@ class CRM_Core_ScheduledJob { */ 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 87b08e890f..87dd9c37eb 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 @@ class CRM_Core_SelectValues { * @return array */ public static function pmf() { - return array( + return [ 'Both' => ts('Both'), 'HTML' => ts('HTML'), 'Text' => ts('Text'), - ); + ]; } /** @@ -68,14 +68,14 @@ class CRM_Core_SelectValues { * @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 @@ class CRM_Core_SelectValues { * @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 @@ class CRM_Core_SelectValues { * @return array */ public static function periodType() { - return array( + return [ 'rolling' => ts('Rolling'), 'fixed' => ts('Fixed'), - ); + ]; } /** @@ -136,12 +136,12 @@ class CRM_Core_SelectValues { * @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 @@ class CRM_Core_SelectValues { * @return array */ public static function memberVisibility() { - return array( + return [ 'Public' => ts('Public'), 'Admin' => ts('Admin'), - ); + ]; } /** @@ -162,11 +162,11 @@ class CRM_Core_SelectValues { * @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 @@ class CRM_Core_SelectValues { * @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 @@ class CRM_Core_SelectValues { * @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 @@ class CRM_Core_SelectValues { 'Multi-Select' => ts('Multi-Select'), 'Link' => ts('Link'), 'ContactReference' => ts('Autocomplete-Select'), - ); + ]; } /** @@ -215,7 +215,7 @@ class CRM_Core_SelectValues { * */ public static function customGroupExtends() { - $customGroupExtends = array( + $customGroupExtends = [ 'Activity' => ts('Activities'), 'Relationship' => ts('Relationships'), 'Contribution' => ts('Contributions'), @@ -231,9 +231,9 @@ class CRM_Core_SelectValues { '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 @@ class CRM_Core_SelectValues { * @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 @@ class CRM_Core_SelectValues { * @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 @@ class CRM_Core_SelectValues { * @return array */ public static function groupContactStatus() { - return array( + return [ 'Added' => ts('Added'), 'Removed' => ts('Removed'), 'Pending' => ts('Pending'), - ); + ]; } /** @@ -291,10 +291,10 @@ class CRM_Core_SelectValues { * @return array */ public static function groupType() { - return array( + return [ 'query' => ts('Dynamic'), 'static' => ts('Static'), - ); + ]; } /** @@ -312,11 +312,11 @@ class CRM_Core_SelectValues { */ 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 @@ class CRM_Core_SelectValues { * @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 @@ class CRM_Core_SelectValues { * @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 @@ class CRM_Core_SelectValues { * @return array */ public static function mailingComponents() { - return array( + return [ 'Header' => ts('Header'), 'Footer' => ts('Footer'), 'Reply' => ts('Reply Auto-responder'), @@ -400,7 +400,7 @@ class CRM_Core_SelectValues { 'Welcome' => ts('Welcome Message'), 'Unsubscribe' => ts('Unsubscribe Message'), 'Resubscribe' => ts('Resubscribe Message'), - ); + ]; } /** @@ -409,7 +409,7 @@ class CRM_Core_SelectValues { * @return array */ public function getHours() { - $hours = array(); + $hours = []; for ($i = 0; $i <= 6; $i++) { $hours[$i] = $i; } @@ -422,7 +422,7 @@ class CRM_Core_SelectValues { * @return array */ public function getMinutes() { - $minutes = array(); + $minutes = []; for ($i = 0; $i < 60; $i = $i + 15) { $minutes[$i] = $i; } @@ -438,7 +438,7 @@ class CRM_Core_SelectValues { 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 @@ class CRM_Core_SelectValues { 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 @@ class CRM_Core_SelectValues { 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 @@ class CRM_Core_SelectValues { * @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 @@ class CRM_Core_SelectValues { '{mailing.name}' => ts('Mailing name'), '{mailing.group}' => ts('Mailing group'), '{mailing.viewUrl}' => ts('Mailing permalink'), - ); + ]; } /** @@ -503,12 +503,12 @@ class CRM_Core_SelectValues { * @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 @@ class CRM_Core_SelectValues { * @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 @@ class CRM_Core_SelectValues { '{membership.join_date}' => ts('Membership Join Date'), '{membership.end_date}' => ts('Membership End Date'), '{membership.fee}' => ts('Membership Fee'), - ); + ]; } /** @@ -534,7 +534,7 @@ class CRM_Core_SelectValues { * @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 @@ class CRM_Core_SelectValues { '{event.info_url}' => ts('Event Info URL'), '{event.registration_url}' => ts('Event Registration URL'), '{event.balance}' => ts('Event Balance'), - ); + ]; } /** @@ -558,7 +558,7 @@ class CRM_Core_SelectValues { * @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 @@ class CRM_Core_SelectValues { //'{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 @@ class CRM_Core_SelectValues { 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 @@ class CRM_Core_SelectValues { '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 @@ class CRM_Core_SelectValues { } // 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 @@ class CRM_Core_SelectValues { 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 @@ class CRM_Core_SelectValues { 'participant_campaign_id', 'participant_status', 'participant_discount_name', - ); + ]; $customFields = CRM_Core_BAO_CustomField::getFields('Participant'); @@ -728,7 +728,7 @@ class CRM_Core_SelectValues { * @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 @@ class CRM_Core_SelectValues { "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 @@ class CRM_Core_SelectValues { * @return array */ public static function getTimeFormats() { - return array( + return [ '1' => ts('12 Hours'), '2' => ts('24 Hours'), - ); + ]; } /** @@ -783,7 +783,7 @@ class CRM_Core_SelectValues { * @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 @@ class CRM_Core_SelectValues { * @return array */ public static function getBarcodeTypes() { - return array( + return [ 'barcode' => ts('Linear (1D)'), 'qrcode' => ts('QR code'), - ); + ]; } /** @@ -808,11 +808,11 @@ class CRM_Core_SelectValues { * @return array */ public static function getDedupeRuleTypes() { - return array( + return [ 'Unsupervised' => ts('Unsupervised'), 'Supervised' => ts('Supervised'), 'General' => ts('General'), - ); + ]; } /** @@ -821,10 +821,10 @@ class CRM_Core_SelectValues { * @return array */ public static function getCampaignGroupTypes() { - return array( + return [ 'Include' => ts('Include'), 'Exclude' => ts('Exclude'), - ); + ]; } /** @@ -833,12 +833,12 @@ class CRM_Core_SelectValues { * @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 @@ class CRM_Core_SelectValues { * @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 @@ class CRM_Core_SelectValues { * @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 @@ class CRM_Core_SelectValues { * @return array */ public static function getJobFrequency() { - return array( + return [ // CRM-17669 'Yearly' => ts('Yearly'), 'Quarter' => ts('Quarterly'), @@ -886,7 +886,7 @@ class CRM_Core_SelectValues { 'Daily' => ts('Daily'), 'Hourly' => ts('Hourly'), 'Always' => ts('Every time cron job is run'), - ); + ]; } /** @@ -920,14 +920,14 @@ class CRM_Core_SelectValues { * @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 @@ class CRM_Core_SelectValues { * @return array */ public static function getWordReplacementMatchType() { - return array( + return [ 'exactMatch' => ts('Exact Match'), 'wildcardMatch' => ts('Wildcard Match'), - ); + ]; } /** @@ -952,11 +952,11 @@ class CRM_Core_SelectValues { * @return array */ public static function getMailingGroupTypes() { - return array( + return [ 'Include' => ts('Include'), 'Exclude' => ts('Exclude'), 'Base' => ts('Base'), - ); + ]; } /** @@ -965,35 +965,35 @@ class CRM_Core_SelectValues { * @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 @@ class CRM_Core_SelectValues { // @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 @@ class CRM_Core_SelectValues { * @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 @@ class CRM_Core_SelectValues { 'starting' => ts('Upcoming'), 'less' => ts('To End of'), 'next' => ts('Next'), - ); + ]; } /** @@ -1047,14 +1047,14 @@ class CRM_Core_SelectValues { * @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 @@ class CRM_Core_SelectValues { * @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 @@ class CRM_Core_SelectValues { * @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 @@ class CRM_Core_SelectValues { * @return array */ public static function activityTextOptions() { - return array( + return [ 2 => ts('Details Only'), 3 => ts('Subject Only'), 6 => ts('Both'), - ); + ]; } /** @@ -1102,11 +1102,11 @@ class CRM_Core_SelectValues { * @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 @@ class CRM_Core_SelectValues { * @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 202d5ba136..cc4f35342e 100644 --- a/CRM/Core/Selector/Base.php +++ b/CRM/Core/Selector/Base.php @@ -121,7 +121,7 @@ class CRM_Core_Selector_Base { $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 a5082d2917..30a9225b9b 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 @@ class CRM_Core_Selector_Controller { $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 @@ class CRM_Core_Selector_Controller { // 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 7e7957c61f..c9d10d2b3a 100644 --- a/CRM/Core/Session.php +++ b/CRM/Core/Session.php @@ -120,7 +120,7 @@ class CRM_Core_Session { if (!(isset($GLOBALS['lazy_session']) && $GLOBALS['lazy_session'] == TRUE)) { drupal_session_start(); } - $_SESSION = array(); + $_SESSION = []; } else { session_start(); @@ -136,7 +136,7 @@ class CRM_Core_Session { 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 @@ class CRM_Core_Session { $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 @@ class CRM_Core_Session { } if (empty($this->_session[$this->_key][$prefix])) { - $this->_session[$this->_key][$prefix] = array(); + $this->_session[$this->_key][$prefix] = []; } } @@ -465,7 +465,7 @@ class CRM_Core_Session { * 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 @@ class CRM_Core_Session { $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 @@ class CRM_Core_Session { } } 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 @@ class CRM_Core_Session { */ public static function registerAndRetrieveSessionObjects($names) { if (!is_array($names)) { - $names = array($names); + $names = [$names]; } if (!self::$_managedNames) { @@ -561,7 +561,7 @@ class CRM_Core_Session { 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 626074941f..ba2edef206 100644 --- a/CRM/Core/ShowHideBlocks.php +++ b/CRM/Core/ShowHideBlocks.php @@ -68,14 +68,14 @@ class CRM_Core_ShowHideBlocks { $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 @@ class CRM_Core_ShowHideBlocks { $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 @@ class CRM_Core_ShowHideBlocks { * 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 @@ class CRM_Core_ShowHideBlocks { 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 25615fc8a9..06b05313e3 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 @@ class CRM_Core_Smarty extends Smarty { $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 @@ class CRM_Core_Smarty extends Smarty { $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 @@ class CRM_Core_Smarty extends Smarty { $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 @@ class CRM_Core_Smarty extends Smarty { 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 @@ class CRM_Core_Smarty extends Smarty { */ 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 462a056b4e..30074e9b09 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 af203ef9d6..151356f72c 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 12263519ce..7c4db31393 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 20d9832efd..91a40c24ca 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 8c063d44a1..61a9d157c6 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 71d43a2e9b..6b9e823e40 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 72411c998b..ffe9cd0236 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 744df2cffb..ad593e4dd2 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 04d9d4487f..8c3116ea9b 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 6ded8123bd..fee8b7d381 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 38e17dd419..b45e5f85f7 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 bbf0eb31d3..4f1b0cd2b7 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 6c9d80bdcb..0ac2ad8dca 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 a78a3e5450..d4f7407f6f 100644 --- a/CRM/Core/StateMachine.php +++ b/CRM/Core/StateMachine.php @@ -94,7 +94,7 @@ class CRM_Core_StateMachine { $this->_controller = &$controller; $this->_action = $action; - $this->_states = array(); + $this->_states = []; } /** @@ -262,7 +262,7 @@ class CRM_Core_StateMachine { $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 f0d62fae1c..05037234e0 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 4f2a545b1f..1ecace6833 100644 --- a/CRM/Core/Task.php +++ b/CRM/Core/Task.php @@ -98,7 +98,7 @@ abstract class CRM_Core_Task { public static function taskTitles() { static::tasks(); - $titles = array(); + $titles = []; foreach (self::$_tasks as $id => $value) { $titles[$id] = $value['title']; } @@ -175,10 +175,10 @@ abstract class CRM_Core_Task { // 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 @@ abstract class CRM_Core_Task { 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 7f78496083..0aefdbf63d 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 @@ class CRM_Core_TemporaryErrorScope { * @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 @@ class CRM_Core_TemporaryErrorScope { * 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 31f82d4928..89aa390a18 100644 --- a/CRM/Custom/Form/ChangeFieldType.php +++ b/CRM/Custom/Form/ChangeFieldType.php @@ -66,8 +66,8 @@ class CRM_Custom_Form_ChangeFieldType extends CRM_Core_Form { $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 @@ class CRM_Custom_Form_ChangeFieldType extends CRM_Core_Form { $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 @@ class CRM_Custom_Form_ChangeFieldType extends CRM_Core_Form { $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 @@ class CRM_Custom_Form_ChangeFieldType extends CRM_Core_Form { $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 @@ class CRM_Custom_Form_ChangeFieldType extends CRM_Core_Form { '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 @@ class CRM_Custom_Form_ChangeFieldType extends CRM_Core_Form { $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 @@ class CRM_Custom_Form_ChangeFieldType extends CRM_Core_Form { 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 @@ class CRM_Custom_Form_ChangeFieldType extends CRM_Core_Form { 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 @@ class CRM_Custom_Form_ChangeFieldType extends CRM_Core_Form { 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 @@ class CRM_Custom_Form_ChangeFieldType extends CRM_Core_Form { 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 @@ class CRM_Custom_Form_ChangeFieldType extends CRM_Core_Form { $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 @@ class CRM_Custom_Form_ChangeFieldType extends CRM_Core_Form { */ 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 d2a644f7ff..3cc0d279c8 100644 --- a/CRM/Custom/Form/CustomData.php +++ b/CRM/Custom/Form/CustomData.php @@ -173,7 +173,7 @@ class CRM_Custom_Form_CustomData { * @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 @@ class CRM_Custom_Form_CustomData { 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 ddc7bc6c72..c88a29fb16 100644 --- a/CRM/Custom/Form/CustomDataByType.php +++ b/CRM/Custom/Form/CustomDataByType.php @@ -71,7 +71,7 @@ class CRM_Custom_Form_CustomDataByType extends CRM_Core_Form { * @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 44564e3d0c..f196a29b9f 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 @@ class CRM_Custom_Form_DeleteField extends CRM_Core_Form { */ 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 @@ class CRM_Custom_Form_DeleteField extends CRM_Core_Form { 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 c0693c3705..4c6af1a9a4 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 @@ class CRM_Custom_Form_DeleteGroup extends CRM_Core_Form { $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 @@ class CRM_Custom_Form_DeleteGroup extends CRM_Core_Form { */ 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 @@ class CRM_Custom_Form_DeleteGroup extends CRM_Core_Form { $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 1d64aadc8a..f9e25de480 100644 --- a/CRM/Custom/Form/Field.php +++ b/CRM/Custom/Form/Field.php @@ -99,10 +99,10 @@ class CRM_Custom_Form_Field extends CRM_Core_Form { //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 @@ class CRM_Custom_Form_Field extends CRM_Core_Form { } 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 @@ class CRM_Custom_Form_Field extends CRM_Core_Form { $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 @@ class CRM_Custom_Form_Field extends CRM_Core_Form { } 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 @@ class CRM_Custom_Form_Field extends CRM_Core_Form { ); $dt = &self::$_dataTypeValues; - $it = array(); + $it = []; foreach ($dt as $key => $value) { $it[$key] = self::$_dataToLabels[$key]; } @@ -309,7 +309,7 @@ class CRM_Custom_Form_Field extends CRM_Core_Form { 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 @@ class CRM_Custom_Form_Field extends CRM_Core_Form { $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 @@ class CRM_Custom_Form_Field extends CRM_Core_Form { $this->add('select', 'option_group_id', ts('Multiple Choice Option Sets'), - array( + [ '' => ts('- select -'), - ) + $optionGroups + ] + $optionGroups ); } else { @@ -359,9 +359,9 @@ class CRM_Custom_Form_Field extends CRM_Core_Form { $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 @@ class CRM_Custom_Form_Field extends CRM_Core_Form { 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 @@ class CRM_Custom_Form_Field extends CRM_Core_Form { $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 @@ class CRM_Custom_Form_Field extends CRM_Core_Form { $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 @@ class CRM_Custom_Form_Field extends CRM_Core_Form { $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 @@ class CRM_Custom_Form_Field extends CRM_Core_Form { $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 @@ class CRM_Custom_Form_Field extends CRM_Core_Form { ); // 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 @@ class CRM_Custom_Form_Field extends CRM_Core_Form { $this->addElement('button', 'done', ts('Done'), - array('onclick' => "location.href='$url'") + ['onclick' => "location.href='$url'"] ); } } @@ -588,7 +588,7 @@ class CRM_Custom_Form_Field extends CRM_Core_Form { 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 @@ class CRM_Custom_Form_Field extends CRM_Core_Form { $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 @@ class CRM_Custom_Form_Field extends CRM_Core_Form { 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 @@ SELECT count(*) 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 @@ SELECT count(*) $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 @@ SELECT count(*) 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 @@ SELECT count(*) } 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 @@ SELECT count(*) 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 @@ AND option_group_id = %2"; } //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 @@ AND option_group_id = %2"; // 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 @@ SELECT id // 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 57135f0c5c..d57e422557 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 @@ class CRM_Custom_Form_Group extends CRM_Core_Form { // 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 @@ class CRM_Custom_Form_Group extends CRM_Core_Form { * 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 @@ class CRM_Custom_Form_Group extends CRM_Core_Form { $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 @@ class CRM_Custom_Form_Group extends CRM_Core_Form { * @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 @@ class CRM_Custom_Form_Group extends CRM_Core_Form { $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 @@ class CRM_Custom_Form_Group extends CRM_Core_Form { 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 @@ class CRM_Custom_Form_Group extends CRM_Core_Form { $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 @@ class CRM_Custom_Form_Group extends CRM_Core_Form { $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 @@ class CRM_Custom_Form_Group extends CRM_Core_Form { // 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 @@ class CRM_Custom_Form_Group extends CRM_Core_Form { $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 @@ class CRM_Custom_Form_Group extends CRM_Core_Form { } 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 @@ class CRM_Custom_Form_Group extends CRM_Core_Form { 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 @@ class CRM_Custom_Form_Group extends CRM_Core_Form { $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 @@ class CRM_Custom_Form_Group extends CRM_Core_Form { 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 a6be59df5b..d05af627a3 100644 --- a/CRM/Custom/Form/MoveField.php +++ b/CRM/Custom/Form/MoveField.php @@ -95,7 +95,7 @@ class CRM_Custom_Form_MoveField extends CRM_Core_Form { ); 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 @@ class CRM_Custom_Form_MoveField extends CRM_Core_Form { 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 @@ class CRM_Custom_Form_MoveField extends CRM_Core_Form { 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 @@ class CRM_Custom_Form_MoveField extends CRM_Core_Form { 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 @@ class CRM_Custom_Form_MoveField extends CRM_Core_Form { ); $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 dffed8944e..96d8a42058 100644 --- a/CRM/Custom/Form/Option.php +++ b/CRM/Custom/Form/Option.php @@ -105,12 +105,12 @@ class CRM_Custom_Form_Option extends CRM_Core_Form { * 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 @@ class CRM_Custom_Form_Option extends CRM_Core_Form { } if ($this->_action & CRM_Core_Action::ADD) { - $fieldValues = array('option_group_id' => $this->_optionGroupID); + $fieldValues = ['option_group_id' => $this->_optionGroupID]; $defaults['weight'] = CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_OptionValue', $fieldValues); } @@ -150,19 +150,19 @@ class CRM_Custom_Form_Option extends CRM_Core_Form { */ public function buildQuickForm() { if ($this->_action == CRM_Core_Action::DELETE) { - $option = civicrm_api3('option_value', 'getsingle', array('id' => $this->_id)); + $option = civicrm_api3('option_value', 'getsingle', ['id' => $this->_id]); $this->assign('label', $option['label']); - $this->addButtons(array( - array( + $this->addButtons([ + [ 'type' => 'next', 'name' => ts('Delete'), 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'cancel', 'name' => ts('Cancel'), - ), - ) + ], + ] ); } else { @@ -192,25 +192,25 @@ class CRM_Custom_Form_Option extends CRM_Core_Form { $this->add('checkbox', 'default_value', ts('Default')); // add a custom form rule - $this->addFormRule(array('CRM_Custom_Form_Option', 'formRule'), $this); + $this->addFormRule(['CRM_Custom_Form_Option', 'formRule'], $this); // add buttons - $this->addButtons(array( - array( + $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 @@ class CRM_Custom_Form_Option extends CRM_Core_Form { $this->addElement('button', 'done', ts('Done'), - array('onclick' => "location.href='$url'", 'class' => 'crm-form-submit cancel', 'crm-icon' => 'fa-times') + ['onclick' => "location.href='$url'", 'class' => 'crm-form-submit cancel', 'crm-icon' => 'fa-times'] ); } } @@ -248,17 +248,17 @@ class CRM_Custom_Form_Option extends CRM_Core_Form { $fieldId = $form->_fid; $optionGroupId = $form->_optionGroupID; - $temp = array(); + $temp = []; if (empty($form->_id)) { $query = " SELECT count(*) FROM civicrm_option_value WHERE option_group_id = %1 AND label = %2"; - $params = array( - 1 => array($optionGroupId, 'Integer'), - 2 => array($optionLabel, 'String'), - ); + $params = [ + 1 => [$optionGroupId, 'Integer'], + 2 => [$optionLabel, 'String'], + ]; if (CRM_Core_DAO::singleValueQuery($query, $params) > 0) { $errors['label'] = ts('There is an entry with the same label.'); } @@ -268,10 +268,10 @@ SELECT count(*) FROM civicrm_option_value WHERE option_group_id = %1 AND value = %2"; - $params = array( - 1 => array($optionGroupId, 'Integer'), - 2 => array($optionValue, 'String'), - ); + $params = [ + 1 => [$optionGroupId, 'Integer'], + 2 => [$optionValue, 'String'], + ]; if (CRM_Core_DAO::singleValueQuery($query, $params) > 0) { $errors['value'] = ts('There is an entry with the same value.'); } @@ -287,11 +287,11 @@ SELECT count(*) WHERE option_group_id = %1 AND id != %2 AND label = %3"; - $params = array( - 1 => array($optionGroupId, 'Integer'), - 2 => array($optionId, 'Integer'), - 3 => array($optionLabel, 'String'), - ); + $params = [ + 1 => [$optionGroupId, 'Integer'], + 2 => [$optionId, 'Integer'], + 3 => [$optionLabel, 'String'], + ]; if (CRM_Core_DAO::singleValueQuery($query, $params) > 0) { $errors['label'] = ts('There is an entry with the same label.'); } @@ -303,11 +303,11 @@ SELECT count(*) WHERE option_group_id = %1 AND id != %2 AND value = %3"; - $params = array( - 1 => array($optionGroupId, 'Integer'), - 2 => array($optionId, 'Integer'), - 3 => array($optionValue, 'String'), - ); + $params = [ + 1 => [$optionGroupId, 'Integer'], + 2 => [$optionId, 'Integer'], + 3 => [$optionValue, 'String'], + ]; if (CRM_Core_DAO::singleValueQuery($query, $params) > 0) { $errors['value'] = ts('There is an entry with the same value.'); } @@ -317,7 +317,7 @@ SELECT count(*) SELECT data_type FROM civicrm_custom_field WHERE id = %1"; - $params = array(1 => array($fieldId, 'Integer')); + $params = [1 => [$fieldId, 'Integer']]; $dao = CRM_Core_DAO::executeQuery($query, $params); if ($dao->fetch()) { switch ($dao->data_type) { @@ -356,7 +356,7 @@ SELECT data_type case 'Country': if (!empty($fields["value"])) { - $params = array(1 => array($fields['value'], 'String')); + $params = [1 => [$fields['value'], 'String']]; $query = "SELECT count(*) FROM civicrm_country WHERE name = %1 OR iso_code = %1"; if (CRM_Core_DAO::singleValueQuery($query, $params) <= 0) { $errors['value'] = ts('Invalid default value for country.'); @@ -366,7 +366,7 @@ SELECT data_type case 'StateProvince': if (!empty($fields["value"])) { - $params = array(1 => array($fields['value'], 'String')); + $params = [1 => [$fields['value'], 'String']]; $query = " SELECT count(*) FROM civicrm_state_province @@ -393,11 +393,11 @@ SELECT count(*) $params = $this->controller->exportValues('Option'); if ($this->_action == CRM_Core_Action::DELETE) { - $option = civicrm_api3('option_value', 'getsingle', array('id' => $this->_id)); - $fieldValues = array('option_group_id' => $this->_optionGroupID); + $option = civicrm_api3('option_value', 'getsingle', ['id' => $this->_id]); + $fieldValues = ['option_group_id' => $this->_optionGroupID]; CRM_Utils_Weight::delWeight('CRM_Core_DAO_OptionValue', $this->_id, $fieldValues); CRM_Core_BAO_CustomOption::del($this->_id); - CRM_Core_Session::setStatus(ts('Option "%1" has been deleted.', array(1 => $option['label'])), ts('Deleted'), 'success'); + CRM_Core_Session::setStatus(ts('Option "%1" has been deleted.', [1 => $option['label']]), ts('Deleted'), 'success'); return; } @@ -417,7 +417,7 @@ SELECT count(*) $oldWeight = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionValue', $this->_id, 'weight', 'id'); } - $fieldValues = array('option_group_id' => $this->_optionGroupID); + $fieldValues = ['option_group_id' => $this->_optionGroupID]; $customOption->weight = CRM_Utils_Weight::updateOtherWeights( 'CRM_Core_DAO_OptionValue', @@ -443,7 +443,7 @@ SELECT count(*) if (!empty($params['default_value'])) { if (!in_array($customOption->value, $defVal)) { if (empty($defVal[0])) { - $defVal = array($customOption->value); + $defVal = [$customOption->value]; } else { $defVal[] = $customOption->value; @@ -456,7 +456,7 @@ SELECT count(*) } } elseif (in_array($customOption->value, $defVal)) { - $tempVal = array(); + $tempVal = []; foreach ($defVal as $v) { if ($v != $customOption->value) { $tempVal[] = $v; @@ -498,7 +498,7 @@ SELECT count(*) $customOption->save(); - $msg = ts('Your multiple choice option \'%1\' has been saved', array(1 => $customOption->label)); + $msg = ts('Your multiple choice option \'%1\' has been saved', [1 => $customOption->label]); CRM_Core_Session::setStatus($msg, '', 'success'); $buttonName = $this->controller->getButtonName(); $session = CRM_Core_Session::singleton(); diff --git a/CRM/Custom/Form/Preview.php b/CRM/Custom/Form/Preview.php index 1e3296d0dd..4ad064eaf5 100644 --- a/CRM/Custom/Form/Preview.php +++ b/CRM/Custom/Form/Preview.php @@ -63,8 +63,8 @@ class CRM_Custom_Form_Preview extends CRM_Core_Form { $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 @@ class CRM_Custom_Form_Preview extends CRM_Core_Form { 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 @@ class CRM_Custom_Form_Preview extends CRM_Core_Form { * the default array reference */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; CRM_Core_BAO_CustomGroup::setDefaults($this->_groupTree, $defaults, FALSE, FALSE); @@ -117,13 +117,13 @@ class CRM_Custom_Form_Preview extends CRM_Core_Form { $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 a5053f34ef..375991f3f7 100644 --- a/CRM/Custom/Import/Controller.php +++ b/CRM/Custom/Import/Controller.php @@ -26,7 +26,7 @@ class CRM_Custom_Import_Controller extends CRM_Core_Controller { // 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 e592cda3be..91221240fb 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 @@ class CRM_Custom_Import_Form_DataSource extends CRM_Import_Form_DataSource { 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 @@ class CRM_Custom_Import_Form_DataSource extends CRM_Import_Form_DataSource { * @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 abc0138c04..b7a42335c2 100644 --- a/CRM/Custom/Import/Form/MapField.php +++ b/CRM/Custom/Import/Form/MapField.php @@ -23,7 +23,7 @@ class CRM_Custom_Import_Form_MapField extends CRM_Contact_Import_Form_MapField { $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 @@ class CRM_Custom_Import_Form_MapField extends CRM_Contact_Import_Form_MapField { */ 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 @@ class CRM_Custom_Import_Form_MapField extends CRM_Contact_Import_Form_MapField { * 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 @@ class CRM_Custom_Import_Form_MapField extends CRM_Contact_Import_Form_MapField { 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 @@ class CRM_Custom_Import_Form_MapField extends CRM_Contact_Import_Form_MapField { $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 @@ class CRM_Custom_Import_Form_MapField extends CRM_Contact_Import_Form_MapField { $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 @@ class CRM_Custom_Import_Form_MapField extends CRM_Contact_Import_Form_MapField { //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 3d772fcda1..76a5765705 100644 --- a/CRM/Custom/Import/Form/Preview.php +++ b/CRM/Custom/Import/Form/Preview.php @@ -56,7 +56,7 @@ class CRM_Custom_Import_Form_Preview extends CRM_Import_Form_Preview { $this->set('downloadMismatchRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams)); } - $properties = array( + $properties = [ 'mapper', 'dataValues', 'columnCount', @@ -67,7 +67,7 @@ class CRM_Custom_Import_Form_Preview extends CRM_Import_Form_Preview { 'downloadErrorRecordsUrl', 'downloadConflictRecordsUrl', 'downloadMismatchRecordsUrl', - ); + ]; foreach ($properties as $property) { $this->assign($property, $this->get($property)); @@ -90,7 +90,7 @@ class CRM_Custom_Import_Form_Preview extends CRM_Import_Form_Preview { $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 @@ class CRM_Custom_Import_Form_Preview extends CRM_Import_Form_Preview { $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 @@ class CRM_Custom_Import_Form_Preview extends CRM_Import_Form_Preview { $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 29fd491e12..7d8fb5e2ac 100644 --- a/CRM/Custom/Import/Parser.php +++ b/CRM/Custom/Import/Parser.php @@ -115,14 +115,14 @@ abstract class CRM_Custom_Import_Parser extends CRM_Contact_Import_Parser { $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 @@ abstract class CRM_Custom_Import_Parser extends CRM_Contact_Import_Parser { } 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 @@ abstract class CRM_Custom_Import_Parser extends CRM_Contact_Import_Parser { * (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 dad22e5fd5..13f0c2db89 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 @@ class CRM_Custom_Import_Parser_Api extends CRM_Custom_Import_Parser { 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 @@ class CRM_Custom_Import_Parser_Api extends CRM_Custom_Import_Parser { $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 @@ class CRM_Custom_Import_Parser_Api extends CRM_Custom_Import_Parser { 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 @@ class CRM_Custom_Import_Parser_Api extends CRM_Custom_Import_Parser { $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 @@ class CRM_Custom_Import_Parser_Api extends CRM_Custom_Import_Parser { * */ 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 @@ class CRM_Custom_Import_Parser_Api extends CRM_Custom_Import_Parser { /* 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 @@ class CRM_Custom_Import_Parser_Api extends CRM_Custom_Import_Parser { '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 5f3e9530c7..6774b584e8 100644 --- a/CRM/Custom/Page/AJAX.php +++ b/CRM/Custom/Page/AJAX.php @@ -54,7 +54,7 @@ class CRM_Custom_Page_AJAX { $options = CRM_Core_BAO_CustomOption::getOptionListSelector($params); $iFilteredTotal = $iTotal = $params['total']; - $selectorElements = array( + $selectorElements = [ 'label', 'value', 'description', @@ -62,7 +62,7 @@ class CRM_Custom_Page_AJAX { '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 @@ class CRM_Custom_Page_AJAX { 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 @@ class CRM_Custom_Page_AJAX { 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 @@ class CRM_Custom_Page_AJAX { } $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 5fd2159975..328f5d8926 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 @@ class CRM_Custom_Page_Field extends CRM_Core_Page { $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 @@ class CRM_Custom_Page_Field extends CRM_Core_Page { $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 @@ class CRM_Custom_Page_Field extends CRM_Core_Page { $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 @@ class CRM_Custom_Page_Field extends CRM_Core_Page { ); 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 @@ class CRM_Custom_Page_Field extends CRM_Core_Page { $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 @@ class CRM_Custom_Page_Field extends CRM_Core_Page { $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 1d84c711d5..48b9b36f10 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 @@ class CRM_Custom_Page_Group extends CRM_Core_Page { */ 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 @@ class CRM_Custom_Page_Group extends CRM_Core_Page { $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 @@ class CRM_Custom_Page_Group extends CRM_Core_Page { } $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 @@ class CRM_Custom_Page_Group extends CRM_Core_Page { } //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 @@ class CRM_Custom_Page_Group extends CRM_Core_Page { $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 @@ class CRM_Custom_Page_Group extends CRM_Core_Page { $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 @@ class CRM_Custom_Page_Group extends CRM_Core_Page { $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 24e2a6b1f6..bfdfc015bc 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 @@ class CRM_Custom_Page_Option extends CRM_Core_Page { 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 @@ WHERE option_group_id = %1"; 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 @@ WHERE option_group_id = %1"; $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 @@ WHERE option_group_id = %1"; $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 ff9d557c0c..4ea90fdac0 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 f28732c1e8..156ccfb839 100644 --- a/CRM/Cxn/BAO/Cxn.php +++ b/CRM/Cxn/BAO/Cxn.php @@ -71,10 +71,10 @@ class CRM_Cxn_BAO_Cxn extends CRM_Cxn_DAO_Cxn { */ 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 @@ class CRM_Cxn_BAO_Cxn extends CRM_Cxn_DAO_Cxn { $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 0d6024812c..f8acdb9704 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 @@ class CRM_Cxn_CiviCxnHttp extends \Civi\Cxn\Rpc\Http\PhpHttp { * @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 @@ class CRM_Cxn_CiviCxnHttp extends \Civi\Cxn\Rpc\Http\PhpHttp { $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 @@ class CRM_Cxn_CiviCxnHttp extends \Civi\Cxn\Rpc\Http\PhpHttp { 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 dc25dc8c51..972fbfa1db 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 @@ class CRM_Cxn_CiviCxnStore implements Civi\Cxn\Rpc\CxnStore\CxnStoreInterface { 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 @@ class CRM_Cxn_CiviCxnStore implements Civi\Cxn\Rpc\CxnStore\CxnStoreInterface { * @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 @@ class CRM_Cxn_CiviCxnStore implements Civi\Cxn\Rpc\CxnStore\CxnStoreInterface { */ 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 bd0ac05422..50fc6f5cba 100644 --- a/CRM/Dashlet/Page/AllCases.php +++ b/CRM/Dashlet/Page/AllCases.php @@ -62,7 +62,7 @@ class CRM_Dashlet_Page_AllCases extends CRM_Core_Page { $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 5a8b9ac1eb..03ea32f1c4 100644 --- a/CRM/Dashlet/Page/Blog.php +++ b/CRM/Dashlet/Page/Blog.php @@ -95,7 +95,7 @@ class CRM_Dashlet_Page_Blog extends CRM_Core_Page { $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 @@ class CRM_Dashlet_Page_Blog extends CRM_Core_Page { * @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 d6813370f2..29d1e10580 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 c19c057b7d..071102fa3b 100644 --- a/CRM/Dashlet/Page/MyCases.php +++ b/CRM/Dashlet/Page/MyCases.php @@ -62,7 +62,7 @@ class CRM_Dashlet_Page_MyCases extends CRM_Core_Page { $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 00be6f40b0..5f9aa38dce 100644 --- a/CRM/Dedupe/BAO/QueryBuilder/IndividualGeneral.php +++ b/CRM/Dedupe/BAO/QueryBuilder/IndividualGeneral.php @@ -41,7 +41,7 @@ class CRM_Dedupe_BAO_QueryBuilder_IndividualGeneral extends CRM_Dedupe_BAO_Query $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 @@ class CRM_Dedupe_BAO_QueryBuilder_IndividualGeneral extends CRM_Dedupe_BAO_Query 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 e150f44fd0..4928fa0a37 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 @@ class CRM_Dedupe_BAO_QueryBuilder_IndividualSupervised extends CRM_Dedupe_BAO_Qu AND first_name = %1 AND last_name = %2 AND email = %3", $params, TRUE), - ); + ]; } /** @@ -65,9 +65,9 @@ class CRM_Dedupe_BAO_QueryBuilder_IndividualSupervised extends CRM_Dedupe_BAO_Qu 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 d3d931d226..1c2e9b2373 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 @@ class CRM_Dedupe_BAO_QueryBuilder_IndividualUnsupervised extends CRM_Dedupe_BAO_ 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 @@ WHERE contact1.contact_type='Individual' 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 40c6a74448..67ce966cb6 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 @@ class CRM_Dedupe_BAO_Rule extends CRM_Dedupe_DAO_Rule { // 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 @@ class CRM_Dedupe_BAO_Rule extends CRM_Dedupe_DAO_Rule { } $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 @@ class CRM_Dedupe_BAO_Rule extends CRM_Dedupe_DAO_Rule { $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 2c01c60e13..f1bfd1478b 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 @@ class CRM_Dedupe_BAO_RuleGroup extends CRM_Dedupe_DAO_RuleGroup { /** * 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 @@ class CRM_Dedupe_BAO_RuleGroup extends CRM_Dedupe_DAO_RuleGroup { 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 @@ class CRM_Dedupe_BAO_RuleGroup extends CRM_Dedupe_DAO_RuleGroup { '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 @@ class CRM_Dedupe_BAO_RuleGroup extends CRM_Dedupe_DAO_RuleGroup { '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 @@ class CRM_Dedupe_BAO_RuleGroup extends CRM_Dedupe_DAO_RuleGroup { 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 @@ class CRM_Dedupe_BAO_RuleGroup extends CRM_Dedupe_DAO_RuleGroup { // 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 @@ class CRM_Dedupe_BAO_RuleGroup extends CRM_Dedupe_DAO_RuleGroup { // add an empty query fulfilling the pattern if (!$queries) { $this->noRules = TRUE; - return array(); + return []; } return $queries; @@ -219,7 +219,7 @@ class CRM_Dedupe_BAO_RuleGroup extends CRM_Dedupe_DAO_RuleGroup { $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 @@ class CRM_Dedupe_BAO_RuleGroup extends CRM_Dedupe_DAO_RuleGroup { // 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 @@ class CRM_Dedupe_BAO_RuleGroup extends CRM_Dedupe_DAO_RuleGroup { * * @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 @@ class CRM_Dedupe_BAO_RuleGroup extends CRM_Dedupe_DAO_RuleGroup { } 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 @@ class CRM_Dedupe_BAO_RuleGroup extends CRM_Dedupe_DAO_RuleGroup { } } } - return array($totalCombinations == 1, $totalCombinations <= 0); + return [$totalCombinations == 1, $totalCombinations <= 0]; } /** @@ -346,9 +346,9 @@ class CRM_Dedupe_BAO_RuleGroup extends CRM_Dedupe_DAO_RuleGroup { * @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 @@ class CRM_Dedupe_BAO_RuleGroup extends CRM_Dedupe_DAO_RuleGroup { 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 @@ class CRM_Dedupe_BAO_RuleGroup extends CRM_Dedupe_DAO_RuleGroup { $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 @@ class CRM_Dedupe_BAO_RuleGroup extends CRM_Dedupe_DAO_RuleGroup { * @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 @@ class CRM_Dedupe_BAO_RuleGroup extends CRM_Dedupe_DAO_RuleGroup { } $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 @@ class CRM_Dedupe_BAO_RuleGroup extends CRM_Dedupe_DAO_RuleGroup { */ 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 ef50af8ed0..4926760db0 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 @@ class CRM_Dedupe_Finder { 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 @@ class CRM_Dedupe_Finder { $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 @@ class CRM_Dedupe_Finder { $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 @@ class CRM_Dedupe_Finder { if (!empty($cids)) { return self::dupes($rgid, $cids); } - return array(); + return []; } /** @@ -203,16 +203,16 @@ class CRM_Dedupe_Finder { * 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 @@ class CRM_Dedupe_Finder { } // 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 @@ class CRM_Dedupe_Finder { // 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 @@ class CRM_Dedupe_Finder { // 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 @@ class CRM_Dedupe_Finder { } } - $params = array(); + $params = []; $supportedFields = CRM_Dedupe_BAO_RuleGroup::supportedFields($ctype); if (is_array($supportedFields)) { foreach ($supportedFields as $table => $fields) { @@ -293,12 +293,12 @@ class CRM_Dedupe_Finder { // 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 @@ class CRM_Dedupe_Finder { } } 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 @@ class CRM_Dedupe_Finder { * @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 @@ class CRM_Dedupe_Finder { $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 @@ class CRM_Dedupe_Finder { $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 629e17438d..3d34696b85 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 @@ class CRM_Event_ActionMapping extends \Civi\ActionSchedule\Mapping { '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 @@ class CRM_Event_ActionMapping extends \Civi\ActionSchedule\Mapping { '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 @@ class CRM_Event_ActionMapping extends \Civi\ActionSchedule\Mapping { 'entity_value_label' => ts('Event Template'), 'entity_status' => 'civicrm_participant_status_type', 'entity_status_label' => ts('Participant Status'), - ))); + ])); } /** @@ -89,12 +89,12 @@ class CRM_Event_ActionMapping extends \Civi\ActionSchedule\Mapping { * 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 @@ class CRM_Event_ActionMapping extends \Civi\ActionSchedule\Mapping { return \CRM_Event_PseudoConstant::participantRole(); default: - return array(); + return []; } } diff --git a/CRM/Event/BAO/Event.php b/CRM/Event/BAO/Event.php index 755847c056..5a18b77c77 100644 --- a/CRM/Event/BAO/Event.php +++ b/CRM/Event/BAO/Event.php @@ -148,12 +148,12 @@ class CRM_Event_BAO_Event extends CRM_Event_DAO_Event { } // 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 @@ class CRM_Event_BAO_Event extends CRM_Event_DAO_Event { 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 @@ WHERE ( civicrm_event.is_template IS NULL OR civicrm_event.is_template = 0 )"; } $query .= " ORDER BY title asc"; - $events = array(); + $events = []; $dao = CRM_Core_DAO::executeQuery($query); while ($dao->fetch()) { @@ -332,7 +332,7 @@ WHERE ( civicrm_event.is_template IS NULL OR civicrm_event.is_template = 0 )"; * 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 @@ WHERE civicrm_event.is_active = 1 AND $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 @@ WHERE civicrm_event.is_active = 1 AND 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 @@ $event_summary_limit '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 @@ $event_summary_limit 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 @@ $event_summary_limit 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 @@ $event_summary_limit } // 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 @@ $event_summary_limit $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 @@ $event_summary_limit 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 @@ $event_summary_limit } if (!empty($roleTypes)) { - $escapedRoles = array(); + $escapedRoles = []; foreach (array_keys($roleTypes) as $roleType) { $escapedRoles[] = CRM_Utils_Type::escape($roleType, 'String'); } @@ -692,24 +692,24 @@ WHERE civicrm_address.geo_code_1 IS NOT NULL $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 @@ WHERE civicrm_event.is_active = 1 } $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 @@ WHERE civicrm_event.is_active = 1 } 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 @@ WHERE civicrm_event.is_active = 1 $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 @@ WHERE civicrm_event.is_active = 1 '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 @@ WHERE civicrm_event.is_active = 1 * @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 @@ WHERE civicrm_event.is_active = 1 */ 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 @@ WHERE civicrm_event.is_active = 1 // 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 @@ WHERE civicrm_event.is_active = 1 * @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 @@ WHERE civicrm_event.is_active = 1 * @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 @@ WHERE civicrm_event.is_active = 1 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 @@ WHERE civicrm_event.is_active = 1 $participantParams ); list($profileValues) = $profileValues; - $val = array( + $val = [ 'id' => $gId, 'values' => $profileValues, 'email' => $email, - ); + ]; CRM_Core_BAO_UFGroup::commonSendMail($contactID, $val); } } @@ -1174,7 +1174,7 @@ WHERE civicrm_event.is_active = 1 $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 @@ WHERE civicrm_event.is_active = 1 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 @@ WHERE civicrm_event.is_active = 1 $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 @@ WHERE civicrm_event.is_active = 1 // 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 @@ WHERE civicrm_event.is_active = 1 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 @@ WHERE civicrm_event.is_active = 1 $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 @@ WHERE civicrm_event.is_active = 1 $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 @@ WHERE civicrm_event.is_active = 1 ); //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 @@ WHERE civicrm_event.is_active = 1 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 @@ WHERE civicrm_event.is_active = 1 } 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 @@ WHERE civicrm_event.is_active = 1 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 @@ WHERE civicrm_event.is_active = 1 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 @@ WHERE civicrm_event.is_active = 1 //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 @@ WHERE civicrm_event.is_active = 1 * * @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 @@ WHERE civicrm_event.is_active = 1 $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 @@ WHERE civicrm_event.is_active = 1 } 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 @@ WHERE civicrm_event.is_active = 1 } 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 @@ WHERE civicrm_event.is_active = 1 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 @@ WHERE id = $cfID $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 @@ WHERE id = $cfID $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 @@ WHERE id = $cfID $skipCancel = TRUE ) { - $customProfile = $additionalIDs = array(); + $customProfile = $additionalIDs = []; if (!$participantId) { CRM_Core_Error::fatal(ts('Cannot find participant ID')); } @@ -1805,12 +1805,12 @@ WHERE id = $cfID $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 @@ WHERE id = $cfID * @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 @@ WHERE id = $cfID '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 @@ WHERE ce.loc_block_id = $locBlockId"; $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 @@ WHERE ce.loc_block_id = $locBlockId"; 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 @@ WHERE ce.loc_block_id = $locBlockId"; 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 @@ LEFT JOIN civicrm_price_field_value value ON ( value.id = lineItem.price_field {$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 @@ LEFT JOIN civicrm_price_field_value value ON ( value.id = lineItem.price_field * 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 @@ LEFT JOIN civicrm_price_field_value value ON ( value.id = lineItem.price_field 'created_id', 'is_template', 'template_title', - ); + ]; $defaults = array_diff_key($defaults, array_flip($fieldsToExclude)); return $defaults; } @@ -2320,8 +2320,8 @@ LEFT JOIN civicrm_price_field_value value ON ( value.id = lineItem.price_field * @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 @@ LEFT JOIN civicrm_price_field_value value ON ( value.id = lineItem.price_field * 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 @@ LEFT JOIN civicrm_price_field_value value ON ( value.id = lineItem.price_field * * @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 a58eafc6eb..bb6f75f06d 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 @@ class CRM_Event_BAO_Participant extends CRM_Event_DAO_Participant { $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 @@ class CRM_Event_BAO_Participant extends CRM_Event_DAO_Participant { } $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 @@ class CRM_Event_BAO_Participant extends CRM_Event_DAO_Participant { } 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 @@ class CRM_Event_BAO_Participant extends CRM_Event_DAO_Participant { } // 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 @@ class CRM_Event_BAO_Participant extends CRM_Event_DAO_Participant { "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 @@ class CRM_Event_BAO_Participant extends CRM_Event_DAO_Participant { $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 @@ class CRM_Event_BAO_Participant extends CRM_Event_DAO_Participant { $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 @@ SELECT event.event_full_text, */ 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 @@ INNER JOIN civicrm_price_field field ON ( value.price_field_id = field.id {$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 @@ GROUP BY participant.event_id 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 @@ GROUP BY participant.event_id 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 @@ WHERE civicrm_participant.id = {$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 @@ WHERE civicrm_participant.id = {$participantId} $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 @@ WHERE civicrm_participant.id = {$participantId} 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 @@ WHERE civicrm_participant.id = {$participantId} $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 @@ WHERE civicrm_participant.id = {$participantId} * @return array */ public static function getAdditionalParticipantIds($primaryParticipantId, $excludeCancel = TRUE, $oldStatusId = NULL) { - $additionalParticipantIds = array(); + $additionalParticipantIds = []; if (!$primaryParticipantId) { return $additionalParticipantIds; } @@ -1061,21 +1061,21 @@ WHERE civicrm_participant.id = {$participantId} */ 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 @@ WHERE cpf.price_set_id = %1 AND cpfv.label LIKE %2"; * @return array */ public function getFeeDetails($participantIds, $hasLineItems = FALSE) { - $feeDetails = array(); + $feeDetails = []; if (!is_array($participantIds) || empty($participantIds)) { return $feeDetails; } @@ -1126,8 +1126,8 @@ INNER JOIN civicrm_price_field_value value ON ( value.id = lineItem.price_field_ $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 @@ INNER JOIN civicrm_price_field_value value ON ( value.id = lineItem.price_field_ 'participant_count', 'price_field_value_id', 'description', - ); + ]; while ($feeInfo->fetch()) { if ($hasLineItems) { foreach ($lineProperties as $property) { @@ -1167,7 +1167,7 @@ INNER JOIN civicrm_price_field_value value ON ( value.id = lineItem.price_field_ * $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 @@ INNER JOIN civicrm_price_field_value value ON ( value.id = lineItem.price_field_ 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 @@ UPDATE civicrm_participant } //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 @@ UPDATE civicrm_participant $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 @@ UPDATE civicrm_participant $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 @@ UPDATE civicrm_participant '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 @@ UPDATE civicrm_participant 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 @@ UPDATE civicrm_participant // 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 @@ UPDATE civicrm_participant 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 @@ UPDATE civicrm_participant //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 @@ UPDATE civicrm_participant //return result for cron. if ($returnResult) { - $results = array( + $results = [ 'mailedParticipants' => $mailedParticipants, 'updatedParticipantIds' => $processedParticipantIds, - ); + ]; return $results; } @@ -1555,11 +1555,11 @@ UPDATE civicrm_participant } 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 @@ UPDATE civicrm_participant '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 @@ UPDATE civicrm_participant '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 @@ UPDATE civicrm_participant */ public function updateStatusMessage($participantId, $statusChangeTo, $fromStatusId) { $statusMsg = NULL; - $results = self::transitionParticipants(array($participantId), + $results = self::transitionParticipants([$participantId], $statusChangeTo, $fromStatusId, TRUE ); @@ -1627,10 +1627,10 @@ UPDATE civicrm_participant 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 @@ UPDATE civicrm_participant $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 @@ UPDATE civicrm_participant ); $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 @@ UPDATE civicrm_participant */ 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 @@ WHERE civicrm_participant.contact_id = {$contactID} AND */ public static function getParticipantIds($contributionId, $excludeCancelled = FALSE) { - $ids = array(); + $ids = []; if (!$contributionId) { return $ids; } @@ -1796,9 +1796,9 @@ WHERE civicrm_participant.contact_id = {$contactID} AND // 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 @@ WHERE civicrm_participant.contact_id = {$contactID} AND */ 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 @@ WHERE civicrm_participant.contact_id = {$contactID} AND $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 @@ WHERE civicrm_participant.contact_id = {$contactID} AND '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 @@ WHERE civicrm_participant.contact_id = {$contactID} AND * * @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 @@ WHERE civicrm_participant.contact_id = {$contactID} AND 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 f84e6b15ac..a3383bfcad 100644 --- a/CRM/Event/BAO/ParticipantPayment.php +++ b/CRM/Event/BAO/ParticipantPayment.php @@ -79,20 +79,20 @@ class CRM_Event_BAO_ParticipantPayment extends CRM_Event_DAO_ParticipantPayment //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 dcbe3a48ec..b04b0fa1f8 100644 --- a/CRM/Event/BAO/ParticipantStatusType.php +++ b/CRM/Event/BAO/ParticipantStatusType.php @@ -123,7 +123,7 @@ class CRM_Event_BAO_ParticipantStatusType extends CRM_Event_DAO_ParticipantStatu */ 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 @@ class CRM_Event_BAO_ParticipantStatusType extends CRM_Event_DAO_ParticipantStatu //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 @@ LEFT JOIN civicrm_event event ON ( event.id = participant.event_id ) "; $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 @@ LEFT JOIN civicrm_event event ON ( event.id = participant.event_id ) 'end_date' => $dao->end_date, 'expiration_time' => $dao->expiration_time, 'requires_approval' => $dao->requires_approval, - ); + ]; } if (!empty($participantDetails)) { @@ -196,7 +196,7 @@ LEFT JOIN civicrm_event event ON ( event.id = participant.event_id ) //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 @@ LEFT JOIN civicrm_event event ON ( event.id = participant.event_id ) //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 @@ LEFT JOIN civicrm_event event ON ( event.id = participant.event_id ) 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 @@ LEFT JOIN civicrm_event event ON ( event.id = participant.event_id ) } } - 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 8fb89c398e..5f7a1ecf78 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 @@ class CRM_Event_BAO_Query extends CRM_Core_BAO_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 @@ class CRM_Event_BAO_Query extends CRM_Core_BAO_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 @@ class CRM_Event_BAO_Query extends CRM_Core_BAO_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 @@ class CRM_Event_BAO_Query extends CRM_Core_BAO_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 @@ class CRM_Event_BAO_Query extends CRM_Core_BAO_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 @@ class CRM_Event_BAO_Query extends CRM_Core_BAO_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 @@ class CRM_Event_BAO_Query extends CRM_Core_BAO_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 @@ class CRM_Event_BAO_Query extends CRM_Core_BAO_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 @@ class CRM_Event_BAO_Query extends CRM_Core_BAO_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 @@ class CRM_Event_BAO_Query extends CRM_Core_BAO_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 @@ class CRM_Event_BAO_Query extends CRM_Core_BAO_Query { ) { $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 @@ class CRM_Event_BAO_Query extends CRM_Core_BAO_Query { '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 @@ class CRM_Event_BAO_Query extends CRM_Core_BAO_Query { $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 @@ class CRM_Event_BAO_Query extends CRM_Core_BAO_Query { $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 @@ class CRM_Event_BAO_Query extends CRM_Core_BAO_Query { 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 @@ class CRM_Event_BAO_Query extends CRM_Core_BAO_Query { * @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 94d51e15a8..b485fe2872 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 @@ class CRM_Event_Badge { // 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 @@ class CRM_Event_Badge { $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 b6ca8b1bf2..a397f838ab 100644 --- a/CRM/Event/Badge/Logo.php +++ b/CRM/Event/Badge/Logo.php @@ -13,7 +13,7 @@ class CRM_Event_Badge_Logo extends CRM_Event_Badge { $ph = 297; $h = 50; $w = 75; - $this->format = array( + $this->format = [ 'name' => 'Sigel 3C', 'paper-size' => 'A4', 'metric' => 'mm', @@ -26,7 +26,7 @@ class CRM_Event_Badge_Logo extends CRM_Event_Badge { 'width' => $w, 'height' => $h, 'font-size' => 12, - ); + ]; $this->lMarginLogo = 20; $this->tMarginName = 20; // $this->setDebug (); @@ -39,13 +39,13 @@ class CRM_Event_Badge_Logo extends CRM_Event_Badge { $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 411dfc74c5..460b465c70 100644 --- a/CRM/Event/Badge/Logo5395.php +++ b/CRM/Event/Badge/Logo5395.php @@ -13,7 +13,7 @@ class CRM_Event_Badge_Logo5395 extends CRM_Event_Badge { $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 @@ class CRM_Event_Badge_Logo5395 extends CRM_Event_Badge { 'width' => $w, 'height' => $h, 'font-size' => 12, - ); + ]; $this->lMarginLogo = 20; $this->tMarginName = 20; // $this->setDebug (); @@ -39,13 +39,13 @@ class CRM_Event_Badge_Logo5395 extends CRM_Event_Badge { $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 abfbc35a44..33df180f6e 100644 --- a/CRM/Event/Badge/NameTent.php +++ b/CRM/Event/Badge/NameTent.php @@ -49,7 +49,7 @@ class CRM_Event_Badge_NameTent extends CRM_Event_Badge { $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 @@ class CRM_Event_Badge_NameTent extends CRM_Event_Badge { '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 6477e6a9d2..e56a43ae95 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 @@ class CRM_Event_Cart_BAO_Cart extends CRM_Event_Cart_DAO_Cart { 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 @@ class CRM_Event_Cart_BAO_Cart extends CRM_Event_Cart_DAO_Cart { * @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 @@ class CRM_Event_Cart_BAO_Cart extends CRM_Event_Cart_DAO_Cart { } 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 @@ class CRM_Event_Cart_BAO_Cart extends CRM_Event_Cart_DAO_Cart { * @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 @@ class CRM_Event_Cart_BAO_Cart extends CRM_Event_Cart_DAO_Cart { * @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 @@ class CRM_Event_Cart_BAO_Cart extends CRM_Event_Cart_DAO_Cart { */ 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 @@ class CRM_Event_Cart_BAO_Cart extends CRM_Event_Cart_DAO_Cart { * @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 @@ class CRM_Event_Cart_BAO_Cart extends CRM_Event_Cart_DAO_Cart { * @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 @@ class CRM_Event_Cart_BAO_Cart extends CRM_Event_Cart_DAO_Cart { * @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 @@ class CRM_Event_Cart_BAO_Cart extends CRM_Event_Cart_DAO_Cart { 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 @@ class CRM_Event_Cart_BAO_Cart extends CRM_Event_Cart_DAO_Cart { * @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 d332cfe706..a9d9b38941 100644 --- a/CRM/Event/Cart/BAO/Conference.php +++ b/CRM/Event/Cart/BAO/Conference.php @@ -28,9 +28,9 @@ SELECT sub_event.* FROM civicrm_participant main_participant 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 05872c0395..aa33705627 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 @@ class CRM_Event_Cart_BAO_EventInCart extends CRM_Event_Cart_DAO_EventInCart impl */ 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 @@ class CRM_Event_Cart_BAO_EventInCart extends CRM_Event_Cart_DAO_EventInCart impl * @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 @@ class CRM_Event_Cart_BAO_EventInCart extends CRM_Event_Cart_DAO_EventInCart impl 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 @@ class CRM_Event_Cart_BAO_EventInCart extends CRM_Event_Cart_DAO_EventInCart impl * @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 @@ class CRM_Event_Cart_BAO_EventInCart extends CRM_Event_Cart_DAO_EventInCart impl * @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 @@ class CRM_Event_Cart_BAO_EventInCart extends CRM_Event_Cart_DAO_EventInCart impl 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 @@ class CRM_Event_Cart_BAO_EventInCart extends CRM_Event_Cart_DAO_EventInCart impl 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 @@ class CRM_Event_Cart_BAO_EventInCart extends CRM_Event_Cart_DAO_EventInCart impl * @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 @@ class CRM_Event_Cart_BAO_EventInCart extends CRM_Event_Cart_DAO_EventInCart impl * @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 @@ class CRM_Event_Cart_BAO_EventInCart extends CRM_Event_Cart_DAO_EventInCart impl * @return array */ public function waiting_participants() { - $result = array(); + $result = []; foreach ($this->participants as $participant) { if ($participant->must_wait) { $result[] = $participant; @@ -290,18 +290,18 @@ class CRM_Event_Cart_BAO_EventInCart extends CRM_Event_Cart_DAO_EventInCart impl $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 e808496164..9717dea04b 100644 --- a/CRM/Event/Cart/BAO/MerParticipant.php +++ b/CRM/Event/Cart/BAO/MerParticipant.php @@ -52,7 +52,7 @@ class CRM_Event_Cart_BAO_MerParticipant extends CRM_Event_BAO_Participant { * @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 @@ class CRM_Event_Cart_BAO_MerParticipant extends CRM_Event_BAO_Participant { //'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 @@ class CRM_Event_Cart_BAO_MerParticipant extends CRM_Event_BAO_Participant { 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 @@ class CRM_Event_Cart_BAO_MerParticipant extends CRM_Event_BAO_Participant { 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 @@ class CRM_Event_Cart_BAO_MerParticipant extends CRM_Event_BAO_Participant { 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 @@ class CRM_Event_Cart_BAO_MerParticipant extends CRM_Event_BAO_Participant { * @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 8b7fc36326..6e16ac7a31 100644 --- a/CRM/Event/Cart/Form/Cart.php +++ b/CRM/Event/Cart/Form/Cart.php @@ -21,13 +21,13 @@ class CRM_Event_Cart_Form_Cart extends CRM_Core_Form { $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 @@ class CRM_Event_Cart_Form_Cart extends CRM_Core_Form { 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 @@ class CRM_Event_Cart_Form_Cart extends CRM_Core_Form { * @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 @@ class CRM_Event_Cart_Form_Cart extends CRM_Core_Form { * * @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 f1299e3553..57e28b7045 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 @@ EOS; $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 @@ EOS; //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 @@ EOS; $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 @@ EOS; $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 @@ EOS; } $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 c47306a840..35722587e9 100644 --- a/CRM/Event/Cart/Form/Checkout/ParticipantsAndPrices.php +++ b/CRM/Event/Cart/Form/Checkout/ParticipantsAndPrices.php @@ -24,7 +24,7 @@ class CRM_Event_Cart_Form_Checkout_ParticipantsAndPrices extends CRM_Event_Cart_ * 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 @@ class CRM_Event_Cart_Form_Checkout_ParticipantsAndPrices extends CRM_Event_Cart_ $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 @@ class CRM_Event_Cart_Form_Checkout_ParticipantsAndPrices extends CRM_Event_Cart_ * @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 @@ class CRM_Event_Cart_Form_Checkout_ParticipantsAndPrices extends CRM_Event_Cart_ $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 @@ class CRM_Event_Cart_Form_Checkout_ParticipantsAndPrices extends CRM_Event_Cart_ $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 @@ class CRM_Event_Cart_Form_Checkout_ParticipantsAndPrices extends CRM_Event_Cart_ 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 @@ class CRM_Event_Cart_Form_Checkout_ParticipantsAndPrices extends CRM_Event_Cart_ 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 @@ class CRM_Event_Cart_Form_Checkout_ParticipantsAndPrices extends CRM_Event_Cart_ && ($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 @@ class CRM_Event_Cart_Form_Checkout_ParticipantsAndPrices extends CRM_Event_Cart_ 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 @@ class CRM_Event_Cart_Form_Checkout_ParticipantsAndPrices extends CRM_Event_Cart_ $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 @@ class CRM_Event_Cart_Form_Checkout_ParticipantsAndPrices extends CRM_Event_Cart_ } //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 a1a2e85018..d6906fd94c 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 @@ class CRM_Event_Cart_Form_Checkout_Payment extends CRM_Event_Cart_Form_Cart { // 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 @@ class CRM_Event_Cart_Form_Checkout_Payment extends CRM_Event_Cart_Form_Cart { //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 @@ class CRM_Event_Cart_Form_Checkout_Payment extends CRM_Event_Cart_Form_Cart { 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 @@ class CRM_Event_Cart_Form_Checkout_Payment extends CRM_Event_Cart_Form_Cart { $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 @@ class CRM_Event_Cart_Form_Checkout_Payment extends CRM_Event_Cart_Form_Cart { */ public function buildQuickForm() { - $this->line_items = array(); + $this->line_items = []; $this->sub_total = 0; $this->_price_values = $this->getValuesForPage('ParticipantsAndPrices'); @@ -200,18 +200,18 @@ class CRM_Event_Cart_Form_Checkout_Payment extends CRM_Event_Cart_Form_Cart { $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 @@ class CRM_Event_Cart_Form_Checkout_Payment extends CRM_Event_Cart_Form_Cart { } 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 @@ class CRM_Event_Cart_Form_Checkout_Payment extends CRM_Event_Cart_Form_Cart { $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 @@ class CRM_Event_Cart_Form_Checkout_Payment extends CRM_Event_Cart_Form_Cart { } $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 @@ class CRM_Event_Cart_Form_Checkout_Payment extends CRM_Event_Cart_Form_Cart { 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 @@ class CRM_Event_Cart_Form_Checkout_Payment extends CRM_Event_Cart_Form_Cart { 'num_waiting_participants' => count($waiting_participants), 'waiting_participants' => $waiting_participants, 'class' => $class, - ); + ]; $this->sub_total += $amount; } @@ -344,11 +344,11 @@ class CRM_Event_Cart_Form_Checkout_Payment extends CRM_Event_Cart_Form_Cart { $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 @@ class CRM_Event_Cart_Form_Checkout_Payment extends CRM_Event_Cart_Form_Cart { '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 @@ class CRM_Event_Cart_Form_Checkout_Payment extends CRM_Event_Cart_Form_Cart { '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 @@ class CRM_Event_Cart_Form_Checkout_Payment extends CRM_Event_Cart_Form_Cart { '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 @@ class CRM_Event_Cart_Form_Checkout_Payment extends CRM_Event_Cart_Form_Cart { * @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 @@ class CRM_Event_Cart_Form_Checkout_Payment extends CRM_Event_Cart_Form_Cart { $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 @@ class CRM_Event_Cart_Form_Checkout_Payment extends CRM_Event_Cart_Form_Cart { $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 @@ class CRM_Event_Cart_Form_Checkout_Payment extends CRM_Event_Cart_Form_Cart { "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 @@ class CRM_Event_Cart_Form_Checkout_Payment extends CRM_Event_Cart_Form_Cart { // 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 @@ class CRM_Event_Cart_Form_Checkout_Payment extends CRM_Event_Cart_Form_Cart { 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 @@ class CRM_Event_Cart_Form_Checkout_Payment extends CRM_Event_Cart_Form_Cart { $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 @@ class CRM_Event_Cart_Form_Checkout_Payment extends CRM_Event_Cart_Form_Cart { '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 @@ class CRM_Event_Cart_Form_Checkout_Payment extends CRM_Event_Cart_Form_Cart { * 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 @@ class CRM_Event_Cart_Form_Checkout_Payment extends CRM_Event_Cart_Form_Cart { $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 @@ class CRM_Event_Cart_Form_Checkout_Payment extends CRM_Event_Cart_Form_Cart { */ 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 0b1b8d10b4..991e3724e9 100644 --- a/CRM/Event/Cart/Form/Checkout/ThankYou.php +++ b/CRM/Event/Cart/Form/Checkout/ThankYou.php @@ -15,17 +15,17 @@ class CRM_Event_Cart_Form_Checkout_ThankYou extends CRM_Event_Cart_Form_Cart { 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 @@ class CRM_Event_Cart_Form_Checkout_ThankYou extends CRM_Event_Cart_Form_Cart { } 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 @@ class CRM_Event_Cart_Form_Checkout_ThankYou extends CRM_Event_Cart_Form_Cart { '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 b618e78860..b8340e44f5 100644 --- a/CRM/Event/Cart/Form/MerParticipant.php +++ b/CRM/Event/Cart/Form/MerParticipant.php @@ -19,7 +19,7 @@ class CRM_Event_Cart_Form_MerParticipant extends CRM_Core_Form { * @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 @@ class CRM_Event_Cart_Form_MerParticipant extends CRM_Core_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 @@ class CRM_Event_Cart_Form_MerParticipant extends CRM_Core_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 @@ class CRM_Event_Cart_Form_MerParticipant extends CRM_Core_Form { 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 @@ class CRM_Event_Cart_Form_MerParticipant extends CRM_Core_Form { $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 @@ class CRM_Event_Cart_Form_MerParticipant extends CRM_Core_Form { * @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 045d77dbc7..9b3d61554f 100644 --- a/CRM/Event/Cart/Page/AddToCart.php +++ b/CRM/Event/Cart/Page/AddToCart.php @@ -21,10 +21,10 @@ class CRM_Event_Cart_Page_AddToCart extends CRM_Core_Page { $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 73f0982923..fa12bcbc46 100644 --- a/CRM/Event/Cart/Page/CheckoutAJAX.php +++ b/CRM/Event/Cart/Page/CheckoutAJAX.php @@ -11,11 +11,11 @@ class CRM_Event_Cart_Page_CheckoutAJAX { $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 b9d7efbec4..e25ebbd26b 100644 --- a/CRM/Event/Cart/Page/RemoveFromCart.php +++ b/CRM/Event/Cart/Page/RemoveFromCart.php @@ -17,7 +17,7 @@ class CRM_Event_Cart_Page_RemoveFromCart extends CRM_Core_Page { $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 337a68a8cb..8ba98dc22d 100644 --- a/CRM/Event/Cart/StateMachine/Checkout.php +++ b/CRM/Event/Cart/StateMachine/Checkout.php @@ -17,7 +17,7 @@ class CRM_Event_Cart_StateMachine_Checkout extends CRM_Core_StateMachine { 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 @@ class CRM_Event_Cart_StateMachine_Checkout extends CRM_Core_StateMachine { 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 f4caf280f5..655a7b93b2 100644 --- a/CRM/Event/Form/EventFees.php +++ b/CRM/Event/Form/EventFees.php @@ -71,12 +71,12 @@ class CRM_Event_Form_EventFees { * @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 @@ class CRM_Event_Form_EventFees { } 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 @@ class CRM_Event_Form_EventFees { 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 @@ class CRM_Event_Form_EventFees { $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 @@ class CRM_Event_Form_EventFees { * @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 @@ class CRM_Event_Form_EventFees { !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 @@ SELECT id, html_type // 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 @@ SELECT id, html_type } 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 @@ SELECT id, html_type $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 @@ SELECT id, html_type $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 @@ SELECT id, html_type 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 @@ SELECT id, html_type $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 @@ SELECT id, html_type 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 @@ SELECT id, html_type $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 065f499237..08dedbe509 100644 --- a/CRM/Event/Form/ManageEvent.php +++ b/CRM/Event/Form/ManageEvent.php @@ -120,7 +120,7 @@ class CRM_Event_Form_ManageEvent extends CRM_Core_Form { } $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 @@ class CRM_Event_Form_ManageEvent extends CRM_Core_Form { $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 @@ class CRM_Event_Form_ManageEvent extends CRM_Core_Form { // 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 @@ class CRM_Event_Form_ManageEvent extends CRM_Core_Form { $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 @@ class CRM_Event_Form_ManageEvent extends CRM_Core_Form { * 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 @@ class CRM_Event_Form_ManageEvent extends CRM_Core_Form { } 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 @@ class CRM_Event_Form_ManageEvent extends CRM_Core_Form { } 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 @@ class CRM_Event_Form_ManageEvent extends CRM_Core_Form { */ 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 cd4b3e67e6..e03b13a756 100644 --- a/CRM/Event/Form/ManageEvent/Conference.php +++ b/CRM/Event/Form/ManageEvent/Conference.php @@ -50,17 +50,17 @@ class CRM_Event_Form_ManageEvent_Conference extends CRM_Event_Form_ManageEvent { $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 52770c6cd1..9259d1d7b4 100644 --- a/CRM/Event/Form/ManageEvent/Delete.php +++ b/CRM/Event/Form/ManageEvent/Delete.php @@ -67,17 +67,17 @@ class CRM_Event_Form_ManageEvent_Delete extends CRM_Event_Form_ManageEvent { 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 @@ class CRM_Event_Form_ManageEvent_Delete extends CRM_Event_Form_ManageEvent { 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 6fc7fac1c2..c51030db06 100644 --- a/CRM/Event/Form/ManageEvent/EventInfo.php +++ b/CRM/Event/Form/ManageEvent/EventInfo.php @@ -139,11 +139,11 @@ class CRM_Event_Form_ManageEvent_EventInfo extends CRM_Event_Form_ManageEvent { 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 @@ class CRM_Event_Form_ManageEvent_EventInfo extends CRM_Event_Form_ManageEvent { $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 @@ class CRM_Event_Form_ManageEvent_EventInfo extends CRM_Event_Form_ManageEvent { } 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 @@ class CRM_Event_Form_ManageEvent_EventInfo extends CRM_Event_Form_ManageEvent { $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 @@ class CRM_Event_Form_ManageEvent_EventInfo extends CRM_Event_Form_ManageEvent { $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 @@ class CRM_Event_Form_ManageEvent_EventInfo extends CRM_Event_Form_ManageEvent { * 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 @@ class CRM_Event_Form_ManageEvent_EventInfo extends CRM_Event_Form_ManageEvent { $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 c69627a464..7c79b05846 100644 --- a/CRM/Event/Form/ManageEvent/Fee.php +++ b/CRM/Event/Form/ManageEvent/Fee.php @@ -72,10 +72,10 @@ class CRM_Event_Form_ManageEvent_Fee extends CRM_Event_Form_ManageEvent { 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 @@ class CRM_Event_Form_ManageEvent_Fee extends CRM_Event_Form_ManageEvent { 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 @@ class CRM_Event_Form_ManageEvent_Fee extends CRM_Event_Form_ManageEvent { $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 @@ class CRM_Event_Form_ManageEvent_Fee extends CRM_Event_Form_ManageEvent { 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 @@ class CRM_Event_Form_ManageEvent_Fee extends CRM_Event_Form_ManageEvent { $this->addCheckBox('payment_processor', ts('Payment Processor'), array_flip($paymentProcessor), NULL, NULL, NULL, NULL, - array('  ', '  ', '  ', '
    ') + ['  ', '  ', '  ', '
    '] ); // financial type @@ -266,11 +266,11 @@ class CRM_Event_Form_ManageEvent_Fee extends CRM_Event_Form_ManageEvent { } 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 @@ class CRM_Event_Form_ManageEvent_Fee extends CRM_Event_Form_ManageEvent { $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 @@ class CRM_Event_Form_ManageEvent_Fee extends CRM_Event_Form_ManageEvent { $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 @@ class CRM_Event_Form_ManageEvent_Fee extends CRM_Event_Form_ManageEvent { $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 @@ class CRM_Event_Form_ManageEvent_Fee extends CRM_Event_Form_ManageEvent { * 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 @@ class CRM_Event_Form_ManageEvent_Fee extends CRM_Event_Form_ManageEvent { * 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 @@ class CRM_Event_Form_ManageEvent_Fee extends CRM_Event_Form_ManageEvent { 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 @@ class CRM_Event_Form_ManageEvent_Fee extends CRM_Event_Form_ManageEvent { 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 @@ class CRM_Event_Form_ManageEvent_Fee extends CRM_Event_Form_ManageEvent { } 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 @@ class CRM_Event_Form_ManageEvent_Fee extends CRM_Event_Form_ManageEvent { $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 @@ class CRM_Event_Form_ManageEvent_Fee extends CRM_Event_Form_ManageEvent { } } - $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 @@ class CRM_Event_Form_ManageEvent_Fee extends CRM_Event_Form_ManageEvent { 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 @@ class CRM_Event_Form_ManageEvent_Fee extends CRM_Event_Form_ManageEvent { } 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 @@ class CRM_Event_Form_ManageEvent_Fee extends CRM_Event_Form_ManageEvent { } } - $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 50d853972a..e51f1a3f45 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 @@ class CRM_Event_Form_ManageEvent_Location extends CRM_Event_Form_ManageEvent { $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 @@ class CRM_Event_Form_ManageEvent_Location extends CRM_Event_Form_ManageEvent { * 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 @@ class CRM_Event_Form_ManageEvent_Location extends CRM_Event_Form_ManageEvent { 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 @@ class CRM_Event_Form_ManageEvent_Location extends CRM_Event_Form_ManageEvent { ); } - $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 @@ class CRM_Event_Form_ManageEvent_Location extends CRM_Event_Form_ManageEvent { $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 e224a19acf..a3441f82a7 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 @@ class CRM_Event_Form_ManageEvent_Registration extends CRM_Event_Form_ManageEvent $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 @@ class CRM_Event_Form_ManageEvent_Registration extends CRM_Event_Form_ManageEvent 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 @@ class CRM_Event_Form_ManageEvent_Registration extends CRM_Event_Form_ManageEvent * @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 @@ class CRM_Event_Form_ManageEvent_Registration extends CRM_Event_Form_ManageEvent '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 @@ class CRM_Event_Form_ManageEvent_Registration extends CRM_Event_Form_ManageEvent // 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 @@ class CRM_Event_Form_ManageEvent_Registration extends CRM_Event_Form_ManageEvent ); $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 @@ class CRM_Event_Form_ManageEvent_Registration extends CRM_Event_Form_ManageEvent '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 @@ class CRM_Event_Form_ManageEvent_Registration extends CRM_Event_Form_ManageEvent * */ 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 @@ class CRM_Event_Form_ManageEvent_Registration extends CRM_Event_Form_ManageEvent * ['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 @@ class CRM_Event_Form_ManageEvent_Registration extends CRM_Event_Form_ManageEvent 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 @@ class CRM_Event_Form_ManageEvent_Registration extends CRM_Event_Form_ManageEvent $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 @@ class CRM_Event_Form_ManageEvent_Registration extends CRM_Event_Form_ManageEvent 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 @@ class CRM_Event_Form_ManageEvent_Registration extends CRM_Event_Form_ManageEvent 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 @@ class CRM_Event_Form_ManageEvent_Registration extends CRM_Event_Form_ManageEvent 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 @@ class CRM_Event_Form_ManageEvent_Registration extends CRM_Event_Form_ManageEvent } //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 @@ class CRM_Event_Form_ManageEvent_Registration extends CRM_Event_Form_ManageEvent $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 @@ class CRM_Event_Form_ManageEvent_Registration extends CRM_Event_Form_ManageEvent * @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 @@ class CRM_Event_Form_ManageEvent_Registration extends CRM_Event_Form_ManageEvent * @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 @@ class CRM_Event_Form_ManageEvent_Registration extends CRM_Event_Form_ManageEvent */ 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 @@ class CRM_Event_Form_ManageEvent_Registration extends CRM_Event_Form_ManageEvent } // 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 @@ class CRM_Event_Form_ManageEvent_Registration extends CRM_Event_Form_ManageEvent 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 @@ class CRM_Event_Form_ManageEvent_Registration extends CRM_Event_Form_ManageEvent } } // 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 @@ class CRM_Event_Form_ManageEvent_Registration extends CRM_Event_Form_ManageEvent } 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 @@ class CRM_Event_Form_ManageEvent_Registration extends CRM_Event_Form_ManageEvent } // 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 @@ class CRM_Event_Form_ManageEvent_Registration extends CRM_Event_Form_ManageEvent } } 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 e95c2245a0..58ef8f6e20 100644 --- a/CRM/Event/Form/ManageEvent/Repeat.php +++ b/CRM/Event/Form/ManageEvent/Repeat.php @@ -36,13 +36,13 @@ class CRM_Event_Form_ManageEvent_Repeat extends CRM_Event_Form_ManageEvent { */ //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 @@ class CRM_Event_Form_ManageEvent_Repeat extends CRM_Event_Form_ManageEvent { $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 @@ class CRM_Event_Form_ManageEvent_Repeat extends CRM_Event_Form_ManageEvent { } } - $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 @@ class CRM_Event_Form_ManageEvent_Repeat extends CRM_Event_Form_ManageEvent { * @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 @@ class CRM_Event_Form_ManageEvent_Repeat extends CRM_Event_Form_ManageEvent { $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 @@ class CRM_Event_Form_ManageEvent_Repeat extends CRM_Event_Form_ManageEvent { $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 @@ class CRM_Event_Form_ManageEvent_Repeat extends CRM_Event_Form_ManageEvent { * * @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 @@ class CRM_Event_Form_ManageEvent_Repeat extends CRM_Event_Form_ManageEvent { * @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 b00f01834e..483f275de6 100644 --- a/CRM/Event/Form/ManageEvent/ScheduleReminders.php +++ b/CRM/Event/Form/ManageEvent/ScheduleReminders.php @@ -50,9 +50,9 @@ class CRM_Event_Form_ManageEvent_ScheduleReminders extends CRM_Event_Form_Manage $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 @@ class CRM_Event_Form_ManageEvent_ScheduleReminders extends CRM_Event_Form_Manage $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 4e20c16f41..c966147e4f 100644 --- a/CRM/Event/Form/ManageEvent/TabHeader.php +++ b/CRM/Event/Form/ManageEvent/TabHeader.php @@ -55,11 +55,11 @@ class CRM_Event_Form_ManageEvent_TabHeader { $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 @@ class CRM_Event_Form_ManageEvent_TabHeader { 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 @@ class CRM_Event_Form_ManageEvent_TabHeader { $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 @@ WHERE e.id = %1 "; //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 @@ WHERE e.id = %1 // 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 ee2621e601..70b2a84c07 100644 --- a/CRM/Event/Form/Participant.php +++ b/CRM/Event/Form/Participant.php @@ -228,7 +228,7 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment $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 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment $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 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment 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 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment 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 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment } } 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 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment $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 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment } } - $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 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment * @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 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment 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 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment 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 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment } 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 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment //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 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment $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 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment // 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 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment $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 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment $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 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment } 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 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment // 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 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment ); // 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 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment '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 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment $this->_contactIds[] = $this->_contactId; } - $contributions = array(); + $contributions = []; if (!empty($params['record_contribution'])) { if (!empty($params['id'])) { if ($this->_onlinePendingContributionId) { @@ -1359,10 +1359,10 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment //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 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment $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 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment 'campaign_id', 'pan_truncation', 'card_type_id', - ); + ]; foreach ($recordContribution as $f) { $contributionParams[$f] = CRM_Utils_Array::value($f, $this->_params); @@ -1439,12 +1439,12 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment 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 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment ); } - $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 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment $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 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment $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 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment $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 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment $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 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment 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 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment $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 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment 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 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment } 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 e6df3cf3ae..50511fba17 100644 --- a/CRM/Event/Form/ParticipantFeeSelection.php +++ b/CRM/Event/Form/ParticipantFeeSelection.php @@ -111,7 +111,7 @@ class CRM_Event_Form_ParticipantFeeSelection extends CRM_Core_Form { $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 @@ class CRM_Event_Form_ParticipantFeeSelection extends CRM_Core_Form { * @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 @@ class CRM_Event_Form_ParticipantFeeSelection extends CRM_Core_Form { $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 @@ class CRM_Event_Form_ParticipantFeeSelection extends CRM_Core_Form { $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 @@ class CRM_Event_Form_ParticipantFeeSelection extends CRM_Core_Form { $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 @@ class CRM_Event_Form_ParticipantFeeSelection extends CRM_Core_Form { * @return array */ public static function formRule($fields, $files, $self) { - $errors = array(); + $errors = []; return $errors; } @@ -243,7 +243,7 @@ class CRM_Event_Form_ParticipantFeeSelection extends CRM_Core_Form { $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 @@ class CRM_Event_Form_ParticipantFeeSelection extends CRM_Core_Form { // 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 @@ class CRM_Event_Form_ParticipantFeeSelection extends CRM_Core_Form { */ 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 @@ class CRM_Event_Form_ParticipantFeeSelection extends CRM_Core_Form { $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 @@ class CRM_Event_Form_ParticipantFeeSelection extends CRM_Core_Form { $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 @@ class CRM_Event_Form_ParticipantFeeSelection extends CRM_Core_Form { $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 @@ class CRM_Event_Form_ParticipantFeeSelection extends CRM_Core_Form { $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 f5f22bdc44..ddafbc9226 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 @@ class CRM_Event_Form_ParticipantView extends CRM_Core_Form { // 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 @@ class CRM_Event_Form_ParticipantView extends CRM_Core_Form { $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 @@ class CRM_Event_Form_ParticipantView extends CRM_Core_Form { "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 @@ class CRM_Event_Form_ParticipantView extends CRM_Core_Form { $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 @@ class CRM_Event_Form_ParticipantView extends CRM_Core_Form { $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 @@ class CRM_Event_Form_ParticipantView extends CRM_Core_Form { * @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 7162150bee..0d3fd08099 100644 --- a/CRM/Event/Form/Registration/AdditionalParticipant.php +++ b/CRM/Event/Form/Registration/AdditionalParticipant.php @@ -59,7 +59,7 @@ class CRM_Event_Form_Registration_AdditionalParticipant extends CRM_Event_Form_R $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 @@ class CRM_Event_Form_Registration_AdditionalParticipant extends CRM_Event_Form_R 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 @@ class CRM_Event_Form_Registration_AdditionalParticipant extends CRM_Event_Form_R * @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 @@ class CRM_Event_Form_Registration_AdditionalParticipant extends CRM_Event_Form_R 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 @@ class CRM_Event_Form_Registration_AdditionalParticipant extends CRM_Event_Form_R 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 @@ class CRM_Event_Form_Registration_AdditionalParticipant extends CRM_Event_Form_R //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 @@ class CRM_Event_Form_Registration_AdditionalParticipant extends CRM_Event_Form_R $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 @@ class CRM_Event_Form_Registration_AdditionalParticipant extends CRM_Event_Form_R $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 @@ class CRM_Event_Form_Registration_AdditionalParticipant extends CRM_Event_Form_R * 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 @@ class CRM_Event_Form_Registration_AdditionalParticipant extends CRM_Event_Form_R 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 @@ class CRM_Event_Form_Registration_AdditionalParticipant extends CRM_Event_Form_R //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 @@ class CRM_Event_Form_Registration_AdditionalParticipant extends CRM_Event_Form_R 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 @@ class CRM_Event_Form_Registration_AdditionalParticipant extends CRM_Event_Form_R $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 @@ class CRM_Event_Form_Registration_AdditionalParticipant extends CRM_Event_Form_R return TRUE; } - $errors = array(); + $errors = []; CRM_Core_Form::validateMandatoryFields($self->_fields, $fields, $errors); @@ -688,7 +688,7 @@ class CRM_Event_Form_Registration_AdditionalParticipant extends CRM_Event_Form_R $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 @@ class CRM_Event_Form_Registration_AdditionalParticipant extends CRM_Event_Form_R $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 @@ class CRM_Event_Form_Registration_AdditionalParticipant extends CRM_Event_Form_R * @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 3284eb437f..cdff40124f 100644 --- a/CRM/Event/Form/Registration/Confirm.php +++ b/CRM/Event/Form/Registration/Confirm.php @@ -85,7 +85,7 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration { // 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 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration { // 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 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration { ($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 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration { $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 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration { } 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 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration { $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 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration { // 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 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration { * @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 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration { 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 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration { $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 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration { || (!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 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration { "billing_country-{$this->_bltID}", "billing_country_id-{$this->_bltID}", "address_name-{$this->_bltID}", - ); + ]; foreach ($billingFields as $field) { unset($value[$field]); } @@ -696,14 +696,14 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration { 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 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration { } // 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 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration { if (!empty($this->_lineItem)) { $lineItems = $this->_lineItem; - $lineItem = array(); + $lineItem = []; if ($lineItemValue = CRM_Utils_Array::value($participantNum, $lineItems)) { $lineItem[] = $lineItemValue; } @@ -893,8 +893,8 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration { 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 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration { $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 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration { } if ($this->_lineItem) { $lineItems = $this->_lineItem; - $lineItem = array(); + $lineItem = []; if ($lineItemValue = CRM_Utils_Array::value($participantNum, $lineItems)) { $lineItem[] = $lineItemValue; } @@ -920,7 +920,7 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration { $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 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration { // 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 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration { '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 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration { } 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 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration { // 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 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration { //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 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration { } //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 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration { */ 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 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration { 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 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration { } //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 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration { // 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 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration { 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 cb7afb0277..d672a1e956 100644 --- a/CRM/Event/Form/Registration/ParticipantConfirm.php +++ b/CRM/Event/Form/Registration/ParticipantConfirm.php @@ -54,12 +54,12 @@ class CRM_Event_Form_Registration_ParticipantConfirm extends CRM_Event_Form_Regi $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 @@ class CRM_Event_Form_Registration_ParticipantConfirm extends CRM_Event_Form_Regi * @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 @@ class CRM_Event_Form_Registration_ParticipantConfirm extends CRM_Event_Form_Regi $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 @@ class CRM_Event_Form_Registration_ParticipantConfirm extends CRM_Event_Form_Regi 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 @@ class CRM_Event_Form_Registration_ParticipantConfirm extends CRM_Event_Form_Regi $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 @@ class CRM_Event_Form_Registration_ParticipantConfirm extends CRM_Event_Form_Regi 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 22025fd50a..98f2e6ddd4 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 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration { // 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 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration { * 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 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration { 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 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration { 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 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration { ts('How many people are you registering?'), $additionalOptions, NULL, - array('onChange' => "allowParticipant()") + ['onChange' => "allowParticipant()"] ); $isAdditionalParticipants = TRUE; } @@ -335,7 +335,7 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration { //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 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration { 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 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration { } } - $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 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration { $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 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration { $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 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration { $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 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration { } } if (!is_array($form->_feeBlock)) { - $form->_feeBlock = array(); + $form->_feeBlock = []; } //its time to call the hook. @@ -592,7 +592,7 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration { //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 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration { } } - $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 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration { $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 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration { 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 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration { 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 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration { $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 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration { //ignore option full for offline registration. if ($className == 'CRM_Event_Form_Participant') { - $optionFullIds = array(); + $optionFullIds = []; } //finally get option ids in. @@ -781,7 +781,7 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration { * 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 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration { 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 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration { 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 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration { ) { //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 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration { 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 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration { $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 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration { $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 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration { } 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 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration { } } 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 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration { $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 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration { $this->_params[0] = $params; } else { - $this->_params = array(); + $this->_params = []; $this->_params[] = $params; } $this->set('params', $this->_params); @@ -1156,7 +1156,7 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration { 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 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration { $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 600f4891b6..7c13ada6f6 100644 --- a/CRM/Event/Form/Registration/ThankYou.php +++ b/CRM/Event/Form/Registration/ThankYou.php @@ -100,7 +100,7 @@ class CRM_Event_Form_Registration_ThankYou extends CRM_Event_Form_Registration { $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 @@ class CRM_Event_Form_Registration_ThankYou extends CRM_Event_Form_Registration { 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 @@ class CRM_Event_Form_Registration_ThankYou extends CRM_Event_Form_Registration { $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 3f475d417f..d6c28eac5b 100644 --- a/CRM/Event/Form/Search.php +++ b/CRM/Event/Form/Search.php @@ -104,7 +104,7 @@ class CRM_Event_Form_Search extends CRM_Core_Form_Search { ); } - $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 @@ class CRM_Event_Form_Search extends CRM_Core_Form_Search { $rows = $this->get('rows'); if (is_array($rows)) { - $lineItems = $eventIds = array(); + $lineItems = $eventIds = []; if (!$this->_single) { $this->addRowSelectors($rows); } @@ -164,7 +164,7 @@ class CRM_Event_Form_Search extends CRM_Core_Form_Search { $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 @@ class CRM_Event_Form_Search extends CRM_Core_Form_Search { } } 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 @@ class CRM_Event_Form_Search extends CRM_Core_Form_Search { $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 @@ class CRM_Event_Form_Search extends CRM_Core_Form_Search { 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 @@ class CRM_Event_Form_Search extends CRM_Core_Form_Search { ); } - $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 @@ class CRM_Event_Form_Search extends CRM_Core_Form_Search { } $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 @@ class CRM_Event_Form_Search extends CRM_Core_Form_Search { * the default array reference */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; $defaults = $this->_formValues; return $defaults; } @@ -443,7 +443,7 @@ class CRM_Event_Form_Search extends CRM_Core_Form_Search { 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 c8910ab05f..402535ceb8 100644 --- a/CRM/Event/Form/SearchEvent.php +++ b/CRM/Event/Form/SearchEvent.php @@ -45,7 +45,7 @@ class CRM_Event_Form_SearchEvent extends CRM_Core_Form { * @return array */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; $defaults['eventsByDates'] = 0; $this->_showHide = new CRM_Core_ShowHideBlocks(); @@ -64,27 +64,27 @@ class CRM_Event_Form_SearchEvent extends CRM_Core_Form { */ 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 @@ class CRM_Event_Form_SearchEvent extends CRM_Core_Form { $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 8fd10a2127..57821565f1 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 @@ class CRM_Event_Form_SelfSvcTransfer extends CRM_Core_Form { $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 @@ class CRM_Event_Form_SelfSvcTransfer extends CRM_Core_Form { 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 @@ class CRM_Event_Form_SelfSvcTransfer extends CRM_Core_Form { 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 @@ class CRM_Event_Form_SelfSvcTransfer extends CRM_Core_Form { 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 @@ class CRM_Event_Form_SelfSvcTransfer extends CRM_Core_Form { $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 @@ class CRM_Event_Form_SelfSvcTransfer extends CRM_Core_Form { * return @array _defaults */ public function setDefaultValues() { - $this->_defaults = array(); + $this->_defaults = []; return $this->_defaults; } @@ -249,7 +249,7 @@ class CRM_Event_Form_SelfSvcTransfer extends CRM_Core_Form { * 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 @@ class CRM_Event_Form_SelfSvcTransfer extends CRM_Core_Form { } 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 @@ class CRM_Event_Form_SelfSvcTransfer extends CRM_Core_Form { $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 @@ class CRM_Event_Form_SelfSvcTransfer extends CRM_Core_Form { } 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 @@ class CRM_Event_Form_SelfSvcTransfer extends CRM_Core_Form { 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 @@ class CRM_Event_Form_SelfSvcTransfer extends CRM_Core_Form { $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 @@ class CRM_Event_Form_SelfSvcTransfer extends CRM_Core_Form { $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 @@ class CRM_Event_Form_SelfSvcTransfer extends CRM_Core_Form { 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 @@ class CRM_Event_Form_SelfSvcTransfer extends CRM_Core_Form { * 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 @@ class CRM_Event_Form_SelfSvcTransfer extends CRM_Core_Form { '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 @@ class CRM_Event_Form_SelfSvcTransfer extends CRM_Core_Form { $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 @@ class CRM_Event_Form_SelfSvcTransfer extends CRM_Core_Form { '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 @@ class CRM_Event_Form_SelfSvcTransfer extends CRM_Core_Form { * 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 @@ class CRM_Event_Form_SelfSvcTransfer extends CRM_Core_Form { '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 @@ class CRM_Event_Form_SelfSvcTransfer extends CRM_Core_Form { "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 4ef7afc0f5..189cc5b88f 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 @@ class CRM_Event_Form_SelfSvcUpdate extends CRM_Core_Form { $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 @@ class CRM_Event_Form_SelfSvcUpdate extends CRM_Core_Form { 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 @@ class CRM_Event_Form_SelfSvcUpdate extends CRM_Core_Form { 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 @@ class CRM_Event_Form_SelfSvcUpdate extends CRM_Core_Form { $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 @@ class CRM_Event_Form_SelfSvcUpdate extends CRM_Core_Form { * 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 @@ class CRM_Event_Form_SelfSvcUpdate extends CRM_Core_Form { * return @void */ public function setDefaultValues() { - $this->_defaults = array(); + $this->_defaults = []; $this->_defaults['details'] = $this->_details; return $this->_defaults; } @@ -246,7 +246,7 @@ class CRM_Event_Form_SelfSvcUpdate extends CRM_Core_Form { * 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 @@ class CRM_Event_Form_SelfSvcUpdate extends CRM_Core_Form { $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 @@ class CRM_Event_Form_SelfSvcUpdate extends CRM_Core_Form { 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 @@ class CRM_Event_Form_SelfSvcUpdate extends CRM_Core_Form { '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 @@ class CRM_Event_Form_SelfSvcUpdate extends CRM_Core_Form { "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 4d6b5532a4..038e8276d2 100644 --- a/CRM/Event/Form/Task.php +++ b/CRM/Event/Form/Task.php @@ -61,7 +61,7 @@ class CRM_Event_Form_Task extends CRM_Core_Form_Task { * @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 @@ class CRM_Event_Form_Task extends CRM_Core_Form_Task { } $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 @@ class CRM_Event_Form_Task extends CRM_Core_Form_Task { * @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 d6412472d3..79f3d5dce6 100644 --- a/CRM/Event/Form/Task/AddToGroup.php +++ b/CRM/Event/Form/Task/AddToGroup.php @@ -84,16 +84,16 @@ class CRM_Event_Form_Task_AddToGroup extends CRM_Event_Form_Task { 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 @@ class CRM_Event_Form_Task_AddToGroup extends CRM_Event_Form_Task { } // 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 @@ class CRM_Event_Form_Task_AddToGroup extends CRM_Event_Form_Task { $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 @@ class CRM_Event_Form_Task_AddToGroup extends CRM_Event_Form_Task { * the default array reference */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; if ($this->_context === 'amtg') { $defaults['group_id'] = $this->_id; @@ -172,7 +172,7 @@ class CRM_Event_Form_Task_AddToGroup extends CRM_Event_Form_Task { * @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 @@ class CRM_Event_Form_Task_AddToGroup extends CRM_Event_Form_Task { * 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 @@ class CRM_Event_Form_Task_AddToGroup extends CRM_Event_Form_Task { $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 @@ class CRM_Event_Form_Task_AddToGroup extends CRM_Event_Form_Task { 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 62dbfdc05a..836e9364b8 100644 --- a/CRM/Event/Form/Task/Badge.php +++ b/CRM/Event/Form/Task/Badge.php @@ -63,7 +63,7 @@ class CRM_Event_Form_Task_Badge extends CRM_Event_Form_Task { $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 @@ class CRM_Event_Form_Task_Badge extends CRM_Event_Form_Task { $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 73b324d9cb..ce01d3ab39 100644 --- a/CRM/Event/Form/Task/Batch.php +++ b/CRM/Event/Form/Task/Batch.php @@ -70,7 +70,7 @@ class CRM_Event_Form_Task_Batch extends CRM_Event_Form_Task { 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 @@ class CRM_Event_Form_Task_Batch extends CRM_Event_Form_Task { $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 @@ class CRM_Event_Form_Task_Batch extends CRM_Event_Form_Task { // 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 @@ class CRM_Event_Form_Task_Batch extends CRM_Event_Form_Task { $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 @@ class CRM_Event_Form_Task_Batch extends CRM_Event_Form_Task { //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 @@ class CRM_Event_Form_Task_Batch extends CRM_Event_Form_Task { 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 @@ class CRM_Event_Form_Task_Batch extends CRM_Event_Form_Task { 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 @@ class CRM_Event_Form_Task_Batch extends CRM_Event_Form_Task { 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 @@ class CRM_Event_Form_Task_Batch extends CRM_Event_Form_Task { return NULL; } - $input = $ids = $objects = array(); + $input = $ids = $objects = []; //get the required ids. $ids['contribution'] = $contributionId; @@ -393,10 +393,10 @@ class CRM_Event_Form_Task_Batch extends CRM_Event_Form_Task { $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 @@ class CRM_Event_Form_Task_Batch extends CRM_Event_Form_Task { } //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 @@ class CRM_Event_Form_Task_Batch extends CRM_Event_Form_Task { * 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 @@ class CRM_Event_Form_Task_Batch extends CRM_Event_Form_Task { //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 4c1567fe8d..3dd82dbcb8 100644 --- a/CRM/Event/Form/Task/Cancel.php +++ b/CRM/Event/Form/Task/Cancel.php @@ -76,7 +76,7 @@ class CRM_Event_Form_Task_Cancel extends CRM_Event_Form_Task { */ 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 a55b5907e3..ad9acdbddb 100644 --- a/CRM/Event/Form/Task/Delete.php +++ b/CRM/Event/Form/Task/Delete.php @@ -74,13 +74,13 @@ class CRM_Event_Form_Task_Delete extends CRM_Event_Form_Task { * @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 @@ class CRM_Event_Form_Task_Delete extends CRM_Event_Form_Task { $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 @@ class CRM_Event_Form_Task_Delete extends CRM_Event_Form_Task { $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 c5b91a4617..aafe0bfceb 100644 --- a/CRM/Event/Form/Task/ParticipantStatus.php +++ b/CRM/Event/Form/Task/ParticipantStatus.php @@ -44,9 +44,9 @@ class CRM_Event_Form_Task_ParticipantStatus extends CRM_Event_Form_Task_Batch { $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 a7842b027b..0bb08aca8b 100644 --- a/CRM/Event/Form/Task/PickProfile.php +++ b/CRM/Event/Form/Task/PickProfile.php @@ -89,7 +89,7 @@ class CRM_Event_Form_Task_PickProfile extends CRM_Event_Form_Task { * @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 @@ class CRM_Event_Form_Task_PickProfile extends CRM_Event_Form_Task { } $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 @@ class CRM_Event_Form_Task_PickProfile extends CRM_Event_Form_Task { * @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 45b5e2c957..9cc1d1992b 100644 --- a/CRM/Event/Form/Task/Print.php +++ b/CRM/Event/Form/Task/Print.php @@ -77,18 +77,18 @@ class CRM_Event_Form_Task_Print extends CRM_Event_Form_Task { // // 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 ae48092c2e..91c22676f3 100644 --- a/CRM/Event/Form/Task/SaveSearch.php +++ b/CRM/Event/Form/Task/SaveSearch.php @@ -89,7 +89,7 @@ class CRM_Event_Form_Task_SaveSearch extends CRM_Event_Form_Task { // 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 @@ class CRM_Event_Form_Task_SaveSearch extends CRM_Event_Form_Task { } $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 @@ class CRM_Event_Form_Task_SaveSearch extends CRM_Event_Form_Task { $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 e2576f965c..a571716069 100644 --- a/CRM/Event/Form/Task/SaveSearch/Update.php +++ b/CRM/Event/Form/Task/SaveSearch/Update.php @@ -64,10 +64,10 @@ class CRM_Event_Form_Task_SaveSearch_Update extends CRM_Event_Form_Task_SaveSear */ 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 f08ac877b7..e0bf5f5531 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 @@ class CRM_Event_Form_Task_SearchTaskHookSample extends CRM_Event_Form_Task { $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 @@ class CRM_Event_Form_Task_SearchTaskHookSample extends CRM_Event_Form_Task { * @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 608626f3f4..e916a4b0e2 100644 --- a/CRM/Event/Import/Controller.php +++ b/CRM/Event/Import/Controller.php @@ -56,7 +56,7 @@ class CRM_Event_Import_Controller extends CRM_Core_Controller { // 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 f46c6c0dc5..76ebd3b450 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 @@ class CRM_Event_Import_Form_DataSource extends CRM_Import_Form_DataSource { 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 @@ class CRM_Event_Import_Form_DataSource extends CRM_Import_Form_DataSource { * @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 901d656efa..c2e32386fd 100644 --- a/CRM/Event/Import/Form/Preview.php +++ b/CRM/Event/Import/Form/Preview.php @@ -87,7 +87,7 @@ class CRM_Event_Import_Form_Preview extends CRM_Import_Form_Preview { $this->set('downloadMismatchRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams)); } - $properties = array( + $properties = [ 'mapper', 'dataValues', 'columnCount', @@ -98,7 +98,7 @@ class CRM_Event_Import_Form_Preview extends CRM_Import_Form_Preview { 'downloadErrorRecordsUrl', 'downloadConflictRecordsUrl', 'downloadMismatchRecordsUrl', - ); + ]; foreach ($properties as $property) { $this->assign($property, $this->get($property)); @@ -120,7 +120,7 @@ class CRM_Event_Import_Form_Preview extends CRM_Import_Form_Preview { $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 @@ class CRM_Event_Import_Form_Preview extends CRM_Import_Form_Preview { $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 @@ class CRM_Event_Import_Form_Preview extends CRM_Import_Form_Preview { $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 503c1f1dd5..df860af8a0 100644 --- a/CRM/Event/Import/Form/Summary.php +++ b/CRM/Event/Import/Form/Summary.php @@ -93,7 +93,7 @@ class CRM_Event_Import_Form_Summary extends CRM_Import_Form_Summary { } $this->assign('dupeActionString', $dupeActionString); - $properties = array( + $properties = [ 'totalRowCount', 'validRowCount', 'invalidRowCount', @@ -105,7 +105,7 @@ class CRM_Event_Import_Form_Summary extends CRM_Import_Form_Summary { '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 ad644a3407..000d96db6b 100644 --- a/CRM/Event/Import/Parser.php +++ b/CRM/Event/Import/Parser.php @@ -116,14 +116,14 @@ abstract class CRM_Event_Import_Parser extends CRM_Import_Parser { $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 @@ abstract class CRM_Event_Import_Parser extends CRM_Import_Parser { 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 @@ abstract class CRM_Event_Import_Parser extends CRM_Import_Parser { * (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 @@ abstract class CRM_Event_Import_Parser extends CRM_Import_Parser { * @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 ba0cf6dd98..3c328d7e08 100644 --- a/CRM/Event/Import/Parser/Participant.php +++ b/CRM/Event/Import/Parser/Participant.php @@ -82,7 +82,7 @@ class CRM_Event_Import_Parser_Participant extends CRM_Event_Import_Parser { $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 @@ class CRM_Event_Import_Parser_Participant extends CRM_Event_Import_Parser { $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 @@ class CRM_Event_Import_Parser_Participant extends CRM_Event_Import_Parser { } 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 @@ class CRM_Event_Import_Parser_Participant extends CRM_Event_Import_Parser { $indieFields = CRM_Event_BAO_Participant::import(); } - $formatValues = array(); + $formatValues = []; foreach ($params as $key => $field) { if ($field == NULL || $field === '') { continue; @@ -365,11 +365,11 @@ class CRM_Event_Import_Parser_Participant extends CRM_Event_Import_Parser { '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 @@ class CRM_Event_Import_Parser_Participant extends CRM_Event_Import_Parser { } $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 @@ class CRM_Event_Import_Parser_Participant extends CRM_Event_Import_Parser { } 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 @@ class CRM_Event_Import_Parser_Participant extends CRM_Event_Import_Parser { 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 @@ class CRM_Event_Import_Parser_Participant extends CRM_Event_Import_Parser { 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 @@ class CRM_Event_Import_Parser_Participant extends CRM_Event_Import_Parser { // 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 @@ class CRM_Event_Import_Parser_Participant extends CRM_Event_Import_Parser { '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 3d59c3f452..098d6351a8 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 @@ class CRM_Event_Info extends CRM_Core_Component_Info { * @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 @@ class CRM_Event_Info extends CRM_Core_Component_Info { * @return array */ public function getAnonymousPermissionWarnings() { - return array( + return [ 'access CiviEvent', - ); + ]; } /** @@ -122,12 +122,12 @@ class CRM_Event_Info extends CRM_Core_Component_Info { * @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 @@ class CRM_Event_Info extends CRM_Core_Component_Info { * @return array */ public function registerTab() { - return array( + return [ 'title' => ts('Events'), 'id' => 'participant', 'url' => 'participant', 'weight' => 40, - ); + ]; } /** @@ -156,10 +156,10 @@ class CRM_Event_Info extends CRM_Core_Component_Info { * @return array */ public function registerAdvancedSearchPane() { - return array( + return [ 'title' => ts('Events'), 'weight' => 40, - ); + ]; } /** @@ -167,11 +167,11 @@ class CRM_Event_Info extends CRM_Core_Component_Info { * @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 @@ class CRM_Event_Info extends CRM_Core_Component_Info { 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 841be6a282..7227988671 100644 --- a/CRM/Event/Page/AJAX.php +++ b/CRM/Event/Page/AJAX.php @@ -60,9 +60,9 @@ LEFT JOIN civicrm_price_set_entity ce ON ce.price_set_id = cf.price_set_id 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 a9ba940f8d..6cdcab5bdd 100644 --- a/CRM/Event/Page/EventInfo.php +++ b/CRM/Event/Page/EventInfo.php @@ -71,7 +71,7 @@ class CRM_Event_Page_EventInfo extends CRM_Core_Page { ); //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 @@ class CRM_Event_Page_EventInfo extends CRM_Core_Page { } } - $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 @@ class CRM_Event_Page_EventInfo extends CRM_Core_Page { } } - $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 @@ class CRM_Event_Page_EventInfo extends CRM_Core_Page { $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 @@ class CRM_Event_Page_EventInfo extends CRM_Core_Page { $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 3ca63e8f02..03dfcebc0b 100644 --- a/CRM/Event/Page/ManageEvent.php +++ b/CRM/Event/Page/ManageEvent.php @@ -73,32 +73,32 @@ class CRM_Event_Page_ManageEvent extends CRM_Core_Page { $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 @@ class CRM_Event_Page_ManageEvent extends CRM_Core_Page { 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 @@ class CRM_Event_Page_ManageEvent extends CRM_Core_Page { } 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 @@ class CRM_Event_Page_ManageEvent extends CRM_Core_Page { $this->search(); - $params = array(); + $params = []; $this->_force = CRM_Utils_Request::retrieve('force', 'Boolean', $this, FALSE ); @@ -316,7 +316,7 @@ class CRM_Event_Page_ManageEvent extends CRM_Core_Page { $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 @@ class CRM_Event_Page_ManageEvent extends CRM_Core_Page { list($offset, $rowCount) = $this->_pager->getOffsetAndRowCount(); // get all custom groups sorted by weight - $manageEvent = array(); + $manageEvent = []; $query = " SELECT * @@ -342,7 +342,7 @@ ORDER BY start_date desc $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 @@ ORDER BY start_date desc // 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 @@ ORDER BY start_date desc $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 @@ ORDER BY start_date desc ); $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 @@ ORDER BY start_date desc $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 @@ ORDER BY start_date desc $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 @@ ORDER BY start_date desc * @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 @@ ORDER BY start_date desc 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 @@ ORDER BY start_date desc $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 @@ ORDER BY start_date desc $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 57756abe85..c2bf4eb3e2 100644 --- a/CRM/Event/Page/ParticipantListing/NameStatusAndDate.php +++ b/CRM/Event/Page/ParticipantListing/NameStatusAndDate.php @@ -59,7 +59,7 @@ class CRM_Event_Page_ParticipantListing_NameStatusAndDate extends CRM_Core_Page $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 @@ INNER JOIN civicrm_event ON civicrm_participant.event_id = civicrm_event.i $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 @@ SELECT civicrm_contact.id as contact_id , 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 @@ LIMIT $offset, $rowCount"; 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 @@ LIMIT $offset, $rowCount"; */ public function pager($fromClause, $whereClause, $whereParams) { - $params = array(); + $params = []; $params['status'] = ts('Group') . ' %%StatusMessage%%'; $params['csvString'] = NULL; @@ -154,22 +154,22 @@ SELECT count( civicrm_contact.id ) 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 e6677539a6..c2db2255ee 100644 --- a/CRM/Event/Page/ParticipantListing/Simple.php +++ b/CRM/Event/Page/ParticipantListing/Simple.php @@ -50,7 +50,7 @@ class CRM_Event_Page_ParticipantListing_Simple extends CRM_Core_Page { $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 @@ LEFT JOIN civicrm_email ON ( civicrm_contact.id = civicrm_email.contact_i 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 @@ SELECT civicrm_contact.id as contact_id , 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 @@ LIMIT $offset, $rowCount"; */ public function pager($fromClause, $whereClause, $whereParams) { - $params = array(); + $params = []; $params['status'] = ts('Group') . ' %%StatusMessage%%'; $params['csvString'] = NULL; @@ -142,18 +142,18 @@ SELECT count( civicrm_contact.id ) 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 d2d4db40c8..dadc9244d9 100644 --- a/CRM/Event/Page/Tab.php +++ b/CRM/Event/Page/Tab.php @@ -58,9 +58,9 @@ class CRM_Event_Page_Tab extends CRM_Core_Page { $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 abdcb05708..23143f637d 100644 --- a/CRM/Event/PseudoConstant.php +++ b/CRM/Event/PseudoConstant.php @@ -101,7 +101,7 @@ class CRM_Event_PseudoConstant extends CRM_Core_PseudoConstant { $key = "{$id}_{$all}_{$condition}"; if (!isset(self::$event[$key])) { - self::$event[$key] = array(); + self::$event[$key] = []; } if (!self::$event[$key]) { @@ -136,13 +136,13 @@ class CRM_Event_PseudoConstant extends CRM_Core_PseudoConstant { */ 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 @@ class CRM_Event_PseudoConstant extends CRM_Core_PseudoConstant { * @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 @@ class CRM_Event_PseudoConstant extends CRM_Core_PseudoConstant { 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 @@ class CRM_Event_PseudoConstant extends CRM_Core_PseudoConstant { */ 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 @@ class CRM_Event_PseudoConstant extends CRM_Core_PseudoConstant { */ 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 521c143499..2e6532adcb 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 @@ class CRM_Event_Selector_Search extends CRM_Core_Selector_Base implements CRM_Co } 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 @@ class CRM_Event_Selector_Search extends CRM_Core_Selector_Base implements CRM_Co $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 @@ class CRM_Event_Selector_Search extends CRM_Core_Selector_Base implements CRM_Co $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 @@ class CRM_Event_Selector_Search extends CRM_Core_Selector_Base implements CRM_Co $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 @@ class CRM_Event_Selector_Search extends CRM_Core_Selector_Base implements CRM_Co } 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 @@ class CRM_Event_Selector_Search extends CRM_Core_Selector_Base implements CRM_Co */ 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 7d325f17f8..d3120fb61c 100644 --- a/CRM/Event/StateMachine/Registration.php +++ b/CRM/Event/StateMachine/Registration.php @@ -53,7 +53,7 @@ class CRM_Event_StateMachine_Registration extends CRM_Core_StateMachine { $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 @@ class CRM_Event_StateMachine_Registration extends CRM_Core_StateMachine { $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 a2af360cb0..f31b006fba 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 be00a64122..9e8542e103 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 @@ class CRM_Event_Task extends CRM_Core_Task { * @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 d399cbe8f9..fa26f56b61 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 @@ class CRM_Event_Tokens extends \Civi\Token\AbstractTokenSubscriber { '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 @@ LEFT JOIN civicrm_phone phone ON phone.id = lb.phone_id $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 @@ LEFT JOIN civicrm_phone phone ON phone.id = lb.phone_id $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 7e83f46da9..ceaa4cb4ab 100644 --- a/CRM/Export/BAO/Export.php +++ b/CRM/Export/BAO/Export.php @@ -206,7 +206,7 @@ class CRM_Export_BAO_Export { $componentTable = NULL, $mergeSameAddress = FALSE, $mergeSameHousehold = FALSE, - $exportParams = array(), + $exportParams = [], $queryOperator = 'AND' ) { @@ -216,7 +216,7 @@ class CRM_Export_BAO_Export { ); $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 @@ class CRM_Export_BAO_Export { $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 @@ INSERT INTO {$componentTable} SELECT distinct gc.contact_id FROM civicrm_group_c $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 @@ INSERT INTO {$componentTable} SELECT distinct gc.contact_id FROM civicrm_group_c } } - $componentDetails = array(); + $componentDetails = []; $rowCount = self::EXPORT_ROW_COUNT; $offset = 0; @@ -466,7 +466,7 @@ INSERT INTO {$componentTable} SELECT distinct gc.contact_id FROM civicrm_group_c // 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 @@ INSERT INTO {$componentTable} SELECT distinct gc.contact_id FROM civicrm_group_c } 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 @@ INSERT INTO {$componentTable} SELECT distinct gc.contact_id FROM civicrm_group_c $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 @@ FROM $tableName $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 @@ VALUES $sqlValueString $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 @@ ORDER BY r1.id // 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 @@ UPDATE $tableName 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 @@ WHERE id IN ( $deleteIDString ) * @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 @@ WHERE id IN ( $deleteIDString ) $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 @@ WHERE id IN ( $deleteIDString ) * @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 @@ WHERE id IN ( $deleteIDString ) $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 @@ LIMIT $offset, $limit break; } - $componentDetails = array(); + $componentDetails = []; while ($dao->fetch()) { - $row = array(); + $row = []; foreach ($sqlColumns as $column => $dontCare) { $row[$column] = $dao->$column; @@ -1021,13 +1021,13 @@ LIMIT $offset, $limit 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 @@ LIMIT $offset, $limit * 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 @@ LIMIT $offset, $limit } } } - return array($outputColumns, $metadata); + return [$outputColumns, $metadata]; } /** @@ -1131,11 +1131,11 @@ LIMIT $offset, $limit $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 @@ LIMIT $offset, $limit 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 @@ LIMIT $offset, $limit 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 @@ LIMIT $offset, $limit * @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 35968fdd67..6efa6bd413 100644 --- a/CRM/Export/BAO/ExportProcessor.php +++ b/CRM/Export/BAO/ExportProcessor.php @@ -516,7 +516,7 @@ class CRM_Export_BAO_ExportProcessor { $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 @@ class CRM_Export_BAO_ExportProcessor { 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 @@ class CRM_Export_BAO_ExportProcessor { 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 @@ class CRM_Export_BAO_ExportProcessor { 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 b0ef9c5550..f91363906f 100644 --- a/CRM/Export/Controller/Standalone.php +++ b/CRM/Export/Controller/Standalone.php @@ -46,12 +46,12 @@ class CRM_Export_Controller_Standalone extends CRM_Core_Controller { $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 0b6de97771..0d4b16235d 100644 --- a/CRM/Export/Form/Map.php +++ b/CRM/Export/Form/Map.php @@ -93,22 +93,22 @@ class CRM_Export_Form_Map extends CRM_Core_Form { $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 @@ class CRM_Export_Form_Map extends CRM_Core_Form { * 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 @@ class CRM_Export_Form_Map extends CRM_Core_Form { } 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 34a06734bd..5ce06d9976 100644 --- a/CRM/Export/Form/Select.php +++ b/CRM/Export/Form/Select.php @@ -91,11 +91,11 @@ class CRM_Export_Form_Select extends CRM_Core_Form_Task { $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 @@ class CRM_Export_Form_Select extends CRM_Core_Form_Task { $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 @@ FROM {$this->_componentTable} */ 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 @@ FROM {$this->_componentTable} $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 @@ FROM {$this->_componentTable} $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 @@ FROM {$this->_componentTable} * 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 @@ FROM {$this->_componentTable} 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 @@ FROM {$this->_componentTable} $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 @@ FROM {$this->_componentTable} * @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 137750e86b..375013a7f7 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 925b27444e..4227724276 100644 --- a/CRM/Extension/Container/Basic.php +++ b/CRM/Extension/Container/Basic.php @@ -105,19 +105,19 @@ class CRM_Extension_Container_Basic implements CRM_Extension_Container_Interface * @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 @@ class CRM_Extension_Container_Basic implements CRM_Extension_Container_Interface 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 @@ class CRM_Extension_Container_Basic implements CRM_Extension_Container_Interface $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 @@ class CRM_Extension_Container_Basic implements CRM_Extension_Container_Interface $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 @@ class CRM_Extension_Container_Basic implements CRM_Extension_Container_Interface * 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 a3f541cbf2..0258c36896 100644 --- a/CRM/Extension/Container/Collection.php +++ b/CRM/Extension/Container/Collection.php @@ -85,7 +85,7 @@ class CRM_Extension_Container_Collection implements CRM_Extension_Container_Inte * @return array */ public function checkRequirements() { - $errors = array(); + $errors = []; foreach ($this->containers as $container) { $errors = array_merge($errors, $container->checkRequirements()); } @@ -163,7 +163,7 @@ class CRM_Extension_Container_Collection implements CRM_Extension_Container_Inte $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 667b0bfd1d..d0d6c55a9d 100644 --- a/CRM/Extension/Container/Static.php +++ b/CRM/Extension/Container/Static.php @@ -47,7 +47,7 @@ class CRM_Extension_Container_Static implements CRM_Extension_Container_Interfac * @inheritDoc */ public function checkRequirements() { - return array(); + return []; } /** diff --git a/CRM/Extension/Info.php b/CRM/Extension/Info.php index aa8e4ba7a9..06b40588ec 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 @@ class CRM_Extension_Info { * 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 @@ class CRM_Extension_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 @@ class CRM_Extension_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 6a7cefeda0..6524c0a16f 100644 --- a/CRM/Extension/Manager.php +++ b/CRM/Extension/Manager.php @@ -141,10 +141,10 @@ class CRM_Extension_Manager { // 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 @@ class CRM_Extension_Manager { */ 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 @@ class CRM_Extension_Manager { 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 @@ class CRM_Extension_Manager { $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 @@ class CRM_Extension_Manager { * @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 @@ class CRM_Extension_Manager { 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 @@ class CRM_Extension_Manager { $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 @@ class CRM_Extension_Manager { * 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 @@ class CRM_Extension_Manager { $todoKeys = array_merge($todoKeys, $requiredBys); } else { - $sorter->add($key, array()); + $sorter->add($key, []); } } return $sorter->sort(); @@ -668,7 +668,7 @@ class CRM_Extension_Manager { * @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 54cd41a94f..9d2349a7f4 100644 --- a/CRM/Extension/Manager/Payment.php +++ b/CRM/Extension/Manager/Payment.php @@ -178,7 +178,7 @@ class CRM_Extension_Manager_Payment extends CRM_Extension_Manager_Base { * ($attr => $id) */ private function _getAllPaymentProcessorTypes($attr) { - $ppt = array(); + $ppt = []; $dao = new CRM_Financial_DAO_PaymentProcessorType(); $dao->find(); while ($dao->fetch()) { @@ -204,11 +204,11 @@ class CRM_Extension_Manager_Payment extends CRM_Extension_Manager_Base { $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 @@ class CRM_Extension_Manager_Payment extends CRM_Extension_Manager_Base { } } 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 @@ class CRM_Extension_Manager_Payment extends CRM_Extension_Manager_Base { 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 @@ class CRM_Extension_Manager_Payment extends CRM_Extension_Manager_Base { $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 @@ class CRM_Extension_Manager_Payment extends CRM_Extension_Manager_Base { 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 4d61b9d5e8..3302ec2918 100644 --- a/CRM/Extension/Manager/Report.php +++ b/CRM/Extension/Manager/Report.php @@ -67,10 +67,10 @@ class CRM_Extension_Manager_Report extends CRM_Extension_Manager_Base { 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 @@ class CRM_Extension_Manager_Report extends CRM_Extension_Manager_Base { '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 10ce827ff6..1f0b291bf8 100644 --- a/CRM/Extension/Manager/Search.php +++ b/CRM/Extension/Manager/Search.php @@ -58,10 +58,10 @@ class CRM_Extension_Manager_Search extends CRM_Extension_Manager_Base { } $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 @@ class CRM_Extension_Manager_Search extends CRM_Extension_Manager_Base { '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 926d7086c3..358d3a9103 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 @@ class CRM_Extension_Mapper { 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 @@ class CRM_Extension_Mapper { if (!is_array($moduleExtensions)) { // Check canonical module list - $moduleExtensions = array(); + $moduleExtensions = []; $sql = ' SELECT full_name, file FROM civicrm_extension @@ -297,20 +297,20 @@ class CRM_Extension_Mapper { $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 @@ class CRM_Extension_Mapper { */ 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 @@ class CRM_Extension_Mapper { * 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 @@ class CRM_Extension_Mapper { * CRM_Core_Module */ public function getModules() { - $result = array(); + $result = []; $dao = new CRM_Core_DAO_Extension(); $dao->type = 'module'; $dao->find(); @@ -458,7 +458,7 @@ class CRM_Extension_Mapper { } 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 e1b0b0852d..0a521e77e4 100644 --- a/CRM/Extension/System.php +++ b/CRM/Extension/System.php @@ -93,7 +93,7 @@ class CRM_Extension_System { * 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 @@ class CRM_Extension_System { */ public function getFullContainer() { if ($this->fullContainer === NULL) { - $containers = array(); + $containers = []; if ($this->getDefaultContainer()) { $containers['default'] = $this->getDefaultContainer(); @@ -205,12 +205,12 @@ class CRM_Extension_System { */ 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 @@ class CRM_Extension_System { */ 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 8202478248..a81a5b65f7 100644 --- a/CRM/Extension/Upgrades.php +++ b/CRM/Extension/Upgrades.php @@ -59,11 +59,11 @@ class CRM_Extension_Upgrades { * @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 774fddcef3..ac50f54cbd 100644 --- a/CRM/Financial/BAO/ExportFormat.php +++ b/CRM/Financial/BAO/ExportFormat.php @@ -185,8 +185,8 @@ abstract class CRM_Financial_BAO_ExportFormat { */ 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 @@ abstract class CRM_Financial_BAO_ExportFormat { // 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 @@ abstract class CRM_Financial_BAO_ExportFormat { '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 @@ abstract class CRM_Financial_BAO_ExportFormat { * * @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 f0ae5ce83e..ab830e1839 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 @@ class CRM_Financial_BAO_ExportFormat_CSV extends CRM_Financial_BAO_ExportFormat 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 @@ class CRM_Financial_BAO_ExportFormat_CSV extends CRM_Financial_BAO_ExportFormat */ 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 @@ class CRM_Financial_BAO_ExportFormat_CSV extends CRM_Financial_BAO_ExportFormat $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 @@ class CRM_Financial_BAO_ExportFormat_CSV extends CRM_Financial_BAO_ExportFormat $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 @@ class CRM_Financial_BAO_ExportFormat_CSV extends CRM_Financial_BAO_ExportFormat '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 653abb5d0c..920089c5b6 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 @@ class CRM_Financial_BAO_ExportFormat_IIF extends CRM_Financial_BAO_ExportFormat 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 @@ class CRM_Financial_BAO_ExportFormat_IIF extends CRM_Financial_BAO_ExportFormat // 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 @@ class CRM_Financial_BAO_ExportFormat_IIF extends CRM_Financial_BAO_ExportFormat '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 @@ class CRM_Financial_BAO_ExportFormat_IIF extends CRM_Financial_BAO_ExportFormat 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 @@ class CRM_Financial_BAO_ExportFormat_IIF extends CRM_Financial_BAO_ExportFormat '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 @@ class CRM_Financial_BAO_ExportFormat_IIF extends CRM_Financial_BAO_ExportFormat '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 60afb3f998..4e5ff50bbc 100644 --- a/CRM/Financial/BAO/FinancialItem.php +++ b/CRM/Financial/BAO/FinancialItem.php @@ -89,7 +89,7 @@ class CRM_Financial_BAO_FinancialItem extends CRM_Financial_DAO_FinancialItem { 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 @@ class CRM_Financial_BAO_FinancialItem extends CRM_Financial_DAO_FinancialItem { '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 @@ class CRM_Financial_BAO_FinancialItem extends CRM_Financial_DAO_FinancialItem { $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 @@ class CRM_Financial_BAO_FinancialItem extends CRM_Financial_DAO_FinancialItem { } $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 @@ WHERE cc.id IN (' . implode(',', $contactIds) . ') AND con.is_test = 0'; * @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 445475e295..3b09c7cdd1 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 @@ class CRM_Financial_BAO_FinancialType extends CRM_Financial_DAO_FinancialType { * * @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 @@ class CRM_Financial_BAO_FinancialType extends CRM_Financial_DAO_FinancialType { $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 @@ class CRM_Financial_BAO_FinancialType extends CRM_Financial_DAO_FinancialType { } } 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 @@ class CRM_Financial_BAO_FinancialType extends CRM_Financial_DAO_FinancialType { 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 @@ class CRM_Financial_BAO_FinancialType extends CRM_Financial_DAO_FinancialType { } $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 @@ class CRM_Financial_BAO_FinancialType extends CRM_Financial_DAO_FinancialType { $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 @@ class CRM_Financial_BAO_FinancialType extends CRM_Financial_DAO_FinancialType { 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 @@ class CRM_Financial_BAO_FinancialType extends CRM_Financial_DAO_FinancialType { 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 c6c324e012..faa84e3f69 100644 --- a/CRM/Financial/BAO/FinancialTypeAccount.php +++ b/CRM/Financial/BAO/FinancialTypeAccount.php @@ -51,7 +51,7 @@ class CRM_Financial_BAO_FinancialTypeAccount extends CRM_Financial_DAO_EntityFin * * @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 @@ class CRM_Financial_BAO_FinancialTypeAccount extends CRM_Financial_DAO_EntityFin $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 @@ class CRM_Financial_BAO_FinancialTypeAccount extends CRM_Financial_DAO_EntityFin 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 @@ class CRM_Financial_BAO_FinancialTypeAccount extends CRM_Financial_DAO_EntityFin $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 @@ class CRM_Financial_BAO_FinancialTypeAccount extends CRM_Financial_DAO_EntityFin */ 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 @@ class CRM_Financial_BAO_FinancialTypeAccount extends CRM_Financial_DAO_EntityFin * @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 @@ class CRM_Financial_BAO_FinancialTypeAccount extends CRM_Financial_DAO_EntityFin self::add($params); } if (!empty($existingFinancialAccount)) { - $titles = array(); + $titles = []; } return $titles; } @@ -274,9 +274,9 @@ class CRM_Financial_BAO_FinancialTypeAccount extends CRM_Financial_DAO_EntityFin $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 84e01390b8..ed84d2538d 100644 --- a/CRM/Financial/BAO/Payment.php +++ b/CRM/Financial/BAO/Payment.php @@ -101,7 +101,7 @@ class CRM_Financial_BAO_Payment { } 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 @@ class CRM_Financial_BAO_Payment { 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 @@ class CRM_Financial_BAO_Payment { '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 7a0e9f806f..584d1b1068 100644 --- a/CRM/Financial/BAO/PaymentProcessor.php +++ b/CRM/Financial/BAO/PaymentProcessor.php @@ -72,12 +72,12 @@ class CRM_Financial_BAO_PaymentProcessor extends CRM_Financial_DAO_PaymentProces // 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 @@ class CRM_Financial_BAO_PaymentProcessor extends CRM_Financial_DAO_PaymentProces $cards = json_decode($processor->accepted_credit_cards, TRUE); return $cards; } - return array(); + return []; } /** @@ -166,8 +166,8 @@ class CRM_Financial_BAO_PaymentProcessor extends CRM_Financial_DAO_PaymentProces */ 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 @@ class CRM_Financial_BAO_PaymentProcessor extends CRM_Financial_DAO_PaymentProces * 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 @@ class CRM_Financial_BAO_PaymentProcessor extends CRM_Financial_DAO_PaymentProces * 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 @@ class CRM_Financial_BAO_PaymentProcessor extends CRM_Financial_DAO_PaymentProces } } - $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 @@ class CRM_Financial_BAO_PaymentProcessor extends CRM_Financial_DAO_PaymentProces $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 @@ class CRM_Financial_BAO_PaymentProcessor extends CRM_Financial_DAO_PaymentProces '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 @@ class CRM_Financial_BAO_PaymentProcessor extends CRM_Financial_DAO_PaymentProces } // 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 @@ class CRM_Financial_BAO_PaymentProcessor extends CRM_Financial_DAO_PaymentProces // 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 @@ class CRM_Financial_BAO_PaymentProcessor extends CRM_Financial_DAO_PaymentProces * @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 @@ class CRM_Financial_BAO_PaymentProcessor extends CRM_Financial_DAO_PaymentProces * * @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 @@ class CRM_Financial_BAO_PaymentProcessor extends CRM_Financial_DAO_PaymentProces */ 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 @@ INNER JOIN civicrm_contribution con ON ( mp.contribution_id = con.id ) // 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 @@ INNER JOIN civicrm_contribution con ON ( mp.contribution_id = con.id ) } 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 @@ INNER JOIN civicrm_contribution con ON ( mp.contribution_id = con.id ) * @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 @@ INNER JOIN civicrm_contribution con ON ( mp.contribution_id = con.id ) */ 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 88b7102b34..89ca29f159 100644 --- a/CRM/Financial/BAO/PaymentProcessorType.php +++ b/CRM/Financial/BAO/PaymentProcessorType.php @@ -89,8 +89,8 @@ class CRM_Financial_BAO_PaymentProcessorType extends CRM_Financial_DAO_PaymentPr */ 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 @@ SELECT pp.id processor_id 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 @@ WHERE pp.payment_processor_type_id = ppt.id AND ppt.id = %1"; * @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 2691cacad6..0063079379 100644 --- a/CRM/Financial/Form/BatchTransaction.php +++ b/CRM/Financial/Form/BatchTransaction.php @@ -58,20 +58,20 @@ class CRM_Financial_Form_BatchTransaction extends CRM_Contribute_Form { $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 @@ class CRM_Financial_Form_BatchTransaction extends CRM_Contribute_Form { 'total' => ts('Expected Total Amount'), 'assigned_total' => ts('Actual Total Amount'), 'opened_date' => ts('Opened'), - ); + ]; $this->assign('columnHeaders', $columnHeaders); } } @@ -95,7 +95,7 @@ class CRM_Financial_Form_BatchTransaction extends CRM_Contribute_Form { } // 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 @@ class CRM_Financial_Form_BatchTransaction extends CRM_Contribute_Form { // 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 @@ class CRM_Financial_Form_BatchTransaction extends CRM_Contribute_Form { $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 @@ class CRM_Financial_Form_BatchTransaction extends CRM_Contribute_Form { */ 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 @@ class CRM_Financial_Form_BatchTransaction extends CRM_Contribute_Form { */ 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 3aac7a2537..47cb220617 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 @@ class CRM_Financial_Form_Export extends CRM_Core_Form { 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 @@ class CRM_Financial_Form_Export extends CRM_Core_Form { } } - $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 @@ class CRM_Financial_Form_Export extends CRM_Core_Form { } 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 24fc8d43b9..d0627d6b2b 100644 --- a/CRM/Financial/Form/FinancialAccount.php +++ b/CRM/Financial/Form/FinancialAccount.php @@ -51,9 +51,9 @@ class CRM_Financial_Form_FinancialAccount extends CRM_Contribute_Form { 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 @@ class CRM_Financial_Form_FinancialAccount extends CRM_Contribute_Form { $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 @@ class CRM_Financial_Form_FinancialAccount extends CRM_Contribute_Form { $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 @@ class CRM_Financial_Form_FinancialAccount extends CRM_Contribute_Form { 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 @@ class CRM_Financial_Form_FinancialAccount extends CRM_Contribute_Form { * 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 @@ class CRM_Financial_Form_FinancialAccount extends CRM_Contribute_Form { 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 @@ class CRM_Financial_Form_FinancialAccount extends CRM_Contribute_Form { $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 ab7727a65d..283db9a3a2 100644 --- a/CRM/Financial/Form/FinancialBatch.php +++ b/CRM/Financial/Form/FinancialBatch.php @@ -53,22 +53,22 @@ class CRM_Financial_Form_FinancialBatch extends CRM_Contribute_Form { 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 @@ class CRM_Financial_Form_FinancialBatch extends CRM_Contribute_Form { $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 @@ class CRM_Financial_Form_FinancialBatch extends CRM_Contribute_Form { // 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 @@ class CRM_Financial_Form_FinancialBatch extends CRM_Contribute_Form { $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 @@ class CRM_Financial_Form_FinancialBatch extends CRM_Contribute_Form { * 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 @@ class CRM_Financial_Form_FinancialBatch extends CRM_Contribute_Form { $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 @@ class CRM_Financial_Form_FinancialBatch extends CRM_Contribute_Form { 'source_contact_id' => $session->get('userID'), 'source_contact_qid' => $session->get('userID'), 'details' => $details, - ); + ]; CRM_Activity_BAO_Activity::create($activityParams); @@ -251,7 +251,7 @@ class CRM_Financial_Form_FinancialBatch extends CRM_Contribute_Form { $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 @@ class CRM_Financial_Form_FinancialBatch extends CRM_Contribute_Form { 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 959e9912ee..231d91dcde 100644 --- a/CRM/Financial/Form/FinancialTypeAccount.php +++ b/CRM/Financial/Form/FinancialTypeAccount.php @@ -104,12 +104,12 @@ class CRM_Financial_Form_FinancialTypeAccount extends CRM_Contribute_Form { 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 @@ class CRM_Financial_Form_FinancialTypeAccount extends CRM_Contribute_Form { } 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 @@ class CRM_Financial_Form_FinancialTypeAccount extends CRM_Contribute_Form { $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 @@ class CRM_Financial_Form_FinancialTypeAccount extends CRM_Contribute_Form { $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 @@ class CRM_Financial_Form_FinancialTypeAccount extends CRM_Contribute_Form { $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 @@ class CRM_Financial_Form_FinancialTypeAccount extends CRM_Contribute_Form { 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 @@ class CRM_Financial_Form_FinancialTypeAccount extends CRM_Contribute_Form { * 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 @@ class CRM_Financial_Form_FinancialTypeAccount extends CRM_Contribute_Form { $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 @@ class CRM_Financial_Form_FinancialTypeAccount extends CRM_Contribute_Form { 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 9221234fe1..a559e5ec92 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 @@ class CRM_Financial_Form_Payment extends CRM_Core_Form { * * @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 9a09eaeb63..245173ada7 100644 --- a/CRM/Financial/Form/PaymentEdit.php +++ b/CRM/Financial/Form/PaymentEdit.php @@ -69,7 +69,7 @@ class CRM_Financial_Form_PaymentEdit extends CRM_Core_Form { $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 @@ class CRM_Financial_Form_PaymentEdit extends CRM_Core_Form { $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 @@ class CRM_Financial_Form_PaymentEdit extends CRM_Core_Form { } $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 @@ class CRM_Financial_Form_PaymentEdit extends CRM_Core_Form { * 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 @@ class CRM_Financial_Form_PaymentEdit extends CRM_Core_Form { * 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 @@ class CRM_Financial_Form_PaymentEdit extends CRM_Core_Form { $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 @@ class CRM_Financial_Form_PaymentEdit extends CRM_Core_Form { 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 @@ class CRM_Financial_Form_PaymentEdit extends CRM_Core_Form { $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 @@ class CRM_Financial_Form_PaymentEdit extends CRM_Core_Form { * 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 e810640e97..30de0e8866 100644 --- a/CRM/Financial/Form/Search.php +++ b/CRM/Financial/Form/Search.php @@ -47,7 +47,7 @@ class CRM_Financial_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); $defaults['batch_update'] = $status; if ($this->_batchStatus) { @@ -63,17 +63,17 @@ class CRM_Financial_Form_Search extends CRM_Core_Form { $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 @@ class CRM_Financial_Form_Search extends CRM_Core_Form { '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 @@ class CRM_Financial_Form_Search extends CRM_Core_Form { $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 @@ class CRM_Financial_Form_Search extends CRM_Core_Form { $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 7634b5a0c3..27b4b347ca 100644 --- a/CRM/Financial/Page/AJAX.php +++ b/CRM/Financial/Page/AJAX.php @@ -60,23 +60,23 @@ class CRM_Financial_Page_AJAX { $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 @@ class CRM_Financial_Page_AJAX { $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 @@ class CRM_Financial_Page_AJAX { } $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 @@ class CRM_Financial_Page_AJAX { // 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 @@ class CRM_Financial_Page_AJAX { $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 @@ class CRM_Financial_Page_AJAX { $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 @@ class CRM_Financial_Page_AJAX { 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 @@ class CRM_Financial_Page_AJAX { * @return string|wtf?? */ public static function getFinancialTransactionsList() { - $sortMapper = array( + $sortMapper = [ 0 => '', 1 => '', 2 => 'sort_name', @@ -259,7 +259,7 @@ class CRM_Financial_Page_AJAX { 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 @@ class CRM_Financial_Page_AJAX { $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 @@ class CRM_Financial_Page_AJAX { '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 @@ class CRM_Financial_Page_AJAX { 'payment_method' => ts('Payment Method'), 'status' => ts('Status'), 'name' => ts('Type'), - ); + ]; if ($sort && $sortOrder) { $params['sortBy'] = $sort . ' ' . $sortOrder; @@ -349,13 +349,13 @@ class CRM_Financial_Page_AJAX { $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 @@ class CRM_Financial_Page_AJAX { $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 @@ class CRM_Financial_Page_AJAX { $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 @@ class CRM_Financial_Page_AJAX { $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 @@ class CRM_Financial_Page_AJAX { } $iFilteredTotal = $iTotal = $params['total']; - $selectorElements = array( + $selectorElements = [ 'check', 'contact_type', 'sort_name', @@ -463,7 +463,7 @@ class CRM_Financial_Page_AJAX { 'status', 'name', 'action', - ); + ]; if ($return) { return CRM_Utils_JSON::encodeDataTableSelector($financialitems, $sEcho, $iTotal, $iFilteredTotal, $selectorElements); @@ -489,11 +489,11 @@ class CRM_Financial_Page_AJAX { 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 @@ class CRM_Financial_Page_AJAX { } } 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 @@ class CRM_Financial_Page_AJAX { */ 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 @@ class CRM_Financial_Page_AJAX { '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 2816593292..d9e7c42fc0 100644 --- a/CRM/Financial/Page/BatchTransaction.php +++ b/CRM/Financial/Page/BatchTransaction.php @@ -65,19 +65,19 @@ class CRM_Financial_Page_BatchTransaction extends CRM_Core_Page_Basic { */ 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 @@ class CRM_Financial_Page_BatchTransaction extends CRM_Core_Page_Basic { $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 187bd98951..b455f27b6b 100644 --- a/CRM/Financial/Page/FinancialAccount.php +++ b/CRM/Financial/Page/FinancialAccount.php @@ -62,30 +62,30 @@ class CRM_Financial_Page_FinancialAccount extends CRM_Core_Page_Basic { */ 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 @@ class CRM_Financial_Page_FinancialAccount extends CRM_Core_Page_Basic { */ 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 @@ class CRM_Financial_Page_FinancialAccount extends CRM_Core_Page_Basic { } $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 dadd7116bb..2fdd43d00c 100644 --- a/CRM/Financial/Page/FinancialBatch.php +++ b/CRM/Financial/Page/FinancialBatch.php @@ -61,7 +61,7 @@ class CRM_Financial_Page_FinancialBatch extends CRM_Core_Page_Basic { */ 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 d768e3a6ba..638bb412f6 100644 --- a/CRM/Financial/Page/FinancialType.php +++ b/CRM/Financial/Page/FinancialType.php @@ -62,36 +62,36 @@ class CRM_Financial_Page_FinancialType extends CRM_Core_Page_Basic { */ 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 @@ class CRM_Financial_Page_FinancialType extends CRM_Core_Page_Basic { 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 @@ class CRM_Financial_Page_FinancialType extends CRM_Core_Page_Basic { } $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 867db38c75..a0c17c3109 100644 --- a/CRM/Financial/Page/FinancialTypeAccount.php +++ b/CRM/Financial/Page/FinancialTypeAccount.php @@ -67,20 +67,20 @@ class CRM_Financial_Page_FinancialTypeAccount 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/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 @@ class CRM_Financial_Page_FinancialTypeAccount extends CRM_Core_Page { */ 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 @@ class CRM_Financial_Page_FinancialTypeAccount extends CRM_Core_Page { $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 @@ class CRM_Financial_Page_FinancialTypeAccount extends CRM_Core_Page { 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 0daf23ae52..b817cae909 100644 --- a/CRM/Friend/BAO/Friend.php +++ b/CRM/Friend/BAO/Friend.php @@ -98,18 +98,18 @@ class CRM_Friend_BAO_Friend extends CRM_Friend_DAO_Friend { 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 @@ class CRM_Friend_BAO_Friend extends CRM_Friend_DAO_Friend { $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 @@ class CRM_Friend_BAO_Friend extends CRM_Friend_DAO_Friend { '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 @@ class CRM_Friend_BAO_Friend extends CRM_Friend_DAO_Friend { 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 @@ class CRM_Friend_BAO_Friend extends CRM_Friend_DAO_Friend { 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 @@ class CRM_Friend_BAO_Friend extends CRM_Friend_DAO_Friend { $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 @@ class CRM_Friend_BAO_Friend extends CRM_Friend_DAO_Friend { * @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 @@ class CRM_Friend_BAO_Friend extends CRM_Friend_DAO_Friend { $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 @@ class CRM_Friend_BAO_Friend extends CRM_Friend_DAO_Friend { $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 56753c9677..d8d7263b61 100644 --- a/CRM/Friend/Form.php +++ b/CRM/Friend/Form.php @@ -80,14 +80,14 @@ class CRM_Friend_Form extends CRM_Core_Form { $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 @@ class CRM_Friend_Form extends CRM_Core_Form { 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 @@ class CRM_Friend_Form extends CRM_Core_Form { 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 @@ class CRM_Friend_Form extends CRM_Core_Form { * @return void */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; $defaults['entity_id'] = $this->_entityId; $defaults['entity_table'] = $this->_entityTable; @@ -205,7 +205,7 @@ class CRM_Friend_Form extends CRM_Core_Form { $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 @@ class CRM_Friend_Form extends CRM_Core_Form { $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 @@ class CRM_Friend_Form extends CRM_Core_Form { */ public static function formRule($fields) { - $errors = array(); + $errors = []; $valid = FALSE; foreach ($fields['friend'] as $key => $val) { @@ -293,7 +293,7 @@ class CRM_Friend_Form extends CRM_Core_Form { 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 ecb0454161..f4bb397194 100644 --- a/CRM/Friend/Form/Contribute.php +++ b/CRM/Friend/Form/Contribute.php @@ -58,7 +58,7 @@ class CRM_Friend_Form_Contribute extends CRM_Contribute_Form_ContributionPage { * @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 3c901fc1b1..bf5b6cb518 100644 --- a/CRM/Friend/Form/Event.php +++ b/CRM/Friend/Form/Event.php @@ -58,7 +58,7 @@ class CRM_Friend_Form_Event extends CRM_Event_Form_ManageEvent { * @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 154e130286..4db6f2a3c2 100644 --- a/CRM/Grant/BAO/Grant.php +++ b/CRM/Grant/BAO/Grant.php @@ -57,23 +57,23 @@ class CRM_Grant_BAO_Grant extends CRM_Grant_DAO_Grant { $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 @@ class CRM_Grant_BAO_Grant extends CRM_Grant_DAO_Grant { */ 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 @@ class CRM_Grant_BAO_Grant extends CRM_Grant_DAO_Grant { } // 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 @@ class CRM_Grant_BAO_Grant extends CRM_Grant_DAO_Grant { } $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 @@ class CRM_Grant_BAO_Grant extends CRM_Grant_DAO_Grant { $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 @@ class CRM_Grant_BAO_Grant extends CRM_Grant_DAO_Grant { $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 @@ class CRM_Grant_BAO_Grant extends CRM_Grant_DAO_Grant { */ 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 8825dc72e5..eae47c5b47 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 @@ class CRM_Grant_BAO_Query extends CRM_Core_BAO_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 @@ class CRM_Grant_BAO_Query extends CRM_Core_BAO_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 @@ class CRM_Grant_BAO_Query extends CRM_Core_BAO_Query { ) { $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 @@ class CRM_Grant_BAO_Query extends CRM_Core_BAO_Query { 'grant_report_received' => 1, 'grant_money_transfer_date' => 1, 'grant_note' => 1, - ); + ]; } return $properties; @@ -332,25 +332,25 @@ class CRM_Grant_BAO_Query extends CRM_Core_BAO_Query { $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 d6ce411b17..9803669837 100644 --- a/CRM/Grant/Form/Grant.php +++ b/CRM/Grant/Form/Grant.php @@ -154,31 +154,31 @@ class CRM_Grant_Form_Grant extends CRM_Core_Form { 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 @@ class CRM_Grant_Form_Grant extends CRM_Core_Form { // 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 @@ class CRM_Grant_Form_Grant extends CRM_Core_Form { } $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 4f5fc9f938..8dbd187efb 100644 --- a/CRM/Grant/Form/GrantView.php +++ b/CRM/Grant/Form/GrantView.php @@ -50,14 +50,14 @@ class CRM_Grant_Form_GrantView extends CRM_Core_Form { $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 @@ class CRM_Grant_Form_GrantView extends CRM_Core_Form { '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 @@ class CRM_Grant_Form_GrantView extends CRM_Core_Form { $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 @@ class CRM_Grant_Form_GrantView extends CRM_Core_Form { * @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 26ce02f77b..da5458e849 100644 --- a/CRM/Grant/Form/Task.php +++ b/CRM/Grant/Form/Task.php @@ -61,7 +61,7 @@ class CRM_Grant_Form_Task extends CRM_Core_Form_Task { * @param CRM_Core_Form $form */ public static function preProcessCommon(&$form) { - $form->_grantIds = array(); + $form->_grantIds = []; $values = $form->controller->exportValues('Search'); @@ -72,7 +72,7 @@ class CRM_Grant_Form_Task extends CRM_Core_Form_Task { } $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 @@ class CRM_Grant_Form_Task extends CRM_Core_Form_Task { * @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 905b59e6ea..925da7565f 100644 --- a/CRM/Grant/Form/Task/Delete.php +++ b/CRM/Grant/Form/Task/Delete.php @@ -90,12 +90,12 @@ class CRM_Grant_Form_Task_Delete extends CRM_Grant_Form_Task { } 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 3af6fdae68..34d3f2b241 100644 --- a/CRM/Grant/Form/Task/Print.php +++ b/CRM/Grant/Form/Task/Print.php @@ -77,18 +77,18 @@ class CRM_Grant_Form_Task_Print extends CRM_Grant_Form_Task { // // 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 fb11fe6224..5c9f719c10 100644 --- a/CRM/Grant/Form/Task/Result.php +++ b/CRM/Grant/Form/Task/Result.php @@ -70,13 +70,13 @@ class CRM_Grant_Form_Task_Result extends CRM_Grant_Form_Task { * @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 c6b03d7bde..8d448b8412 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 @@ INNER JOIN civicrm_contact ct ON ( grt.contact_id = ct.id ) $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 @@ INNER JOIN civicrm_contact ct ON ( grt.contact_id = ct.id ) * @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 283cde0596..c1d9b4ad37 100644 --- a/CRM/Grant/Form/Task/Update.php +++ b/CRM/Grant/Form/Task/Update.php @@ -62,14 +62,14 @@ class CRM_Grant_Form_Task_Update extends CRM_Grant_Form_Task { */ 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 @@ class CRM_Grant_Form_Task_Update extends CRM_Grant_Form_Task { } } - $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 ba61b19666..b947cbd5c7 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 @@ class CRM_Grant_Info extends CRM_Core_Component_Info { * @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 @@ class CRM_Grant_Info extends CRM_Core_Component_Info { * @return array */ public function registerTab() { - return array( + return [ 'title' => ts('Grants'), 'url' => 'grant', 'weight' => 60, - ); + ]; } /** @@ -134,10 +134,10 @@ class CRM_Grant_Info extends CRM_Core_Component_Info { * @return array */ public function registerAdvancedSearchPane() { - return array( + return [ 'title' => ts('Grants'), 'weight' => 50, - ); + ]; } /** @@ -156,14 +156,14 @@ class CRM_Grant_Info extends CRM_Core_Component_Info { 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 94c24feab7..561261cd09 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 @@ class CRM_Grant_Selector_Search extends CRM_Core_Selector_Base implements CRM_Co $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 @@ class CRM_Grant_Selector_Search extends CRM_Core_Selector_Base implements CRM_Co ); // 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 @@ class CRM_Grant_Selector_Search extends CRM_Core_Selector_Base implements CRM_Co $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 @@ class CRM_Grant_Selector_Search extends CRM_Core_Selector_Base implements CRM_Co $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 @@ class CRM_Grant_Selector_Search extends CRM_Core_Selector_Base implements CRM_Co */ 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 dc30689ab4..6e58903366 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 1348786295..e9a14e59c8 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 @@ class CRM_Grant_Task extends CRM_Core_Task { * @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 d03fef5697..8de0d8beaa 100644 --- a/CRM/Group/Form/Search.php +++ b/CRM/Group/Form/Search.php @@ -44,7 +44,7 @@ class CRM_Group_Form_Search extends CRM_Core_Form { * @return array */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; $defaults['group_status[1]'] = 1; return $defaults; } @@ -71,10 +71,10 @@ class CRM_Group_Form_Search extends CRM_Core_Form { ); $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 @@ class CRM_Group_Form_Search extends CRM_Core_Form { 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 @@ class CRM_Group_Form_Search extends CRM_Core_Form { $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 ba76b3c6fa..f1bf656f61 100644 --- a/CRM/Group/Page/AJAX.php +++ b/CRM/Group/Page/AJAX.php @@ -48,8 +48,8 @@ class CRM_Group_Page_AJAX { $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 @@ class CRM_Group_Page_AJAX { '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 e61b003618..83e86b2c8a 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 9d5e460c18..d51acd5962 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 @@ class CRM_Import_DataSource_CSV extends CRM_Import_DataSource { $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 @@ class CRM_Import_DataSource_CSV extends CRM_Import_DataSource { $table = NULL, $fieldSeparator = ',' ) { - $result = array(); + $result = []; $fd = fopen($file, 'r'); if (!$fd) { CRM_Core_Error::fatal("Could not read $file"); @@ -192,7 +192,7 @@ class CRM_Import_DataSource_CSV extends CRM_Import_DataSource { } } else { - $columns = array(); + $columns = []; foreach ($firstrow as $i => $_) { $columns[] = "col_$i"; } @@ -239,7 +239,7 @@ class CRM_Import_DataSource_CSV extends CRM_Import_DataSource { 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 69bbff1064..0017b5c55a 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 @@ class CRM_Import_DataSource_SQL extends CRM_Import_DataSource { 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 @@ class CRM_Import_DataSource_SQL extends CRM_Import_DataSource { * @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 61f8044a99..bbce168434 100644 --- a/CRM/Import/Form/DataSource.php +++ b/CRM/Import/Form/DataSource.php @@ -68,42 +68,42 @@ abstract class CRM_Import_Form_DataSource extends CRM_Core_Form { $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 @@ abstract class CRM_Import_Form_DataSource extends CRM_Core_Form { */ 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 @@ abstract class CRM_Import_Form_DataSource extends CRM_Core_Form { ts('Contact Type') ); - $this->setDefaults(array( + $this->setDefaults([ 'contactType' => CRM_Import_Parser::CONTACT_INDIVIDUAL, - )); + ]); } /** @@ -168,7 +168,7 @@ abstract class CRM_Import_Form_DataSource extends CRM_Core_Form { $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 bed412784b..4e9dcf71ce 100644 --- a/CRM/Import/Form/Preview.php +++ b/CRM/Import/Form/Preview.php @@ -51,22 +51,22 @@ abstract class CRM_Import_Form_Preview extends CRM_Core_Form { * 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 c37bc4daf2..7062832309 100644 --- a/CRM/Import/Parser.php +++ b/CRM/Import/Parser.php @@ -273,7 +273,7 @@ abstract class CRM_Import_Parser { * (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 @@ abstract class CRM_Import_Parser { 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 @@ abstract class CRM_Import_Parser { $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 @@ abstract class CRM_Import_Parser { * @return array */ public function getSelectValues() { - $values = array(); + $values = []; foreach ($this->_fields as $name => $field) { $values[$name] = $field->_title; } @@ -356,7 +356,7 @@ abstract class CRM_Import_Parser { * @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 @@ abstract class CRM_Import_Parser { * @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 @@ abstract class CRM_Import_Parser { * @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 17329b8f28..2f213198db 100644 --- a/CRM/Import/StateMachine.php +++ b/CRM/Import/StateMachine.php @@ -46,12 +46,12 @@ class CRM_Import_StateMachine extends CRM_Core_StateMachine { 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 18d8473970..59e1330c37 100644 --- a/CRM/Logging/Differ.php +++ b/CRM/Logging/Differ.php @@ -59,7 +59,7 @@ class CRM_Logging_Differ { * @return array */ public function diffsInTables($tables) { - $diffs = array(); + $diffs = []; foreach ($tables as $table) { $diff = $this->diffsInTable($table); if (!empty($diff)) { @@ -76,18 +76,18 @@ class CRM_Logging_Differ { * @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 @@ LEFT JOIN civicrm_activity_contact source ON source.activity_id = lt.id AND sour $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 @@ WHERE lt.log_conn_id = %1 * @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 @@ WHERE lt.log_conn_id = %1 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 @@ WHERE lt.log_conn_id = %1 } // 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 @@ WHERE lt.log_conn_id = %1 // 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 @@ WHERE lt.log_conn_id = %1 } } - $diffs[] = array( + $diffs[] = [ 'action' => $changed['log_action'], 'id' => $id, 'field' => $diff, @@ -261,7 +261,7 @@ WHERE lt.log_conn_id = %1 'table' => $table, 'log_date' => $changed['log_date'], 'log_conn_id' => $changed['log_conn_id'], - ); + ]; } } @@ -280,15 +280,15 @@ WHERE lt.log_conn_id = %1 */ 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 @@ WHERE lt.log_conn_id = %1 '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 @@ WHERE lt.log_conn_id = %1 $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 @@ WHERE lt.log_conn_id = %1 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 @@ WHERE lt.log_conn_id = %1 * @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 @@ ORDER BY log_date 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 @@ ORDER BY log_date } } - return array($titles, $values); + return [$titles, $values]; } /** @@ -424,7 +424,7 @@ ORDER BY log_date * @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 @@ ORDER BY log_date $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 @@ ORDER BY log_date */ 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 @@ ORDER BY log_date 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 dc985b323f..3200b4482b 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 @@ class CRM_Logging_ReportDetail extends CRM_Report_Form { 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 @@ class CRM_Logging_ReportDetail extends CRM_Report_Form { 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 @@ class CRM_Logging_ReportDetail extends CRM_Report_Form { (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 @@ class CRM_Logging_ReportDetail extends CRM_Report_Form { } } - $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 @@ class CRM_Logging_ReportDetail extends CRM_Report_Form { */ 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 396c61f34f..c42f6b3179 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 @@ class CRM_Logging_ReportSummary extends CRM_Report_Form { // 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 @@ class CRM_Logging_ReportSummary extends CRM_Report_Form { 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 @@ SELECT {$this->_logTables[$entity]['bracket_info']['entity_column']} 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 @@ SELECT {$this->_logTables[$entity]['bracket_info']['entity_column']} 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 @@ WHERE log_date <= %1 AND id = %2 ORDER BY log_date DESC LIMIT 1"; 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 @@ WHERE log_date <= %1 AND id = %2 ORDER BY log_date DESC LIMIT 1"; $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 @@ GROUP BY log_civicrm_entity_log_date, log_civicrm_entity_log_type_label, log_civ {$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 61d87c6d4a..7a1085f246 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 @@ class CRM_Logging_Reverter { 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 @@ class CRM_Logging_Reverter { 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 @@ class CRM_Logging_Reverter { 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 @@ class CRM_Logging_Reverter { $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 c75652fa78..149d405516 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 @@ AND TABLE_NAME LIKE 'civicrm_%' $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 @@ AND (TABLE_NAME LIKE 'log_civicrm_%' $nonStandardTableNameString ) * @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 @@ AND (TABLE_NAME LIKE 'log_civicrm_%' $nonStandardTableNameString ) $dao = new CRM_Core_DAO(); if ($tableName) { - $tableNames = array($tableName); + $tableNames = [$tableName]; } else { $tableNames = $this->tables; @@ -308,7 +308,7 @@ AND (TABLE_NAME LIKE 'log_civicrm_%' $nonStandardTableNameString ) 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 @@ AND (TABLE_NAME LIKE 'log_civicrm_%' $nonStandardTableNameString ) } } 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 @@ AND (TABLE_NAME LIKE 'log_civicrm_%' $nonStandardTableNameString ) 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 @@ AND (TABLE_NAME LIKE 'log_civicrm_%' $nonStandardTableNameString ) 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 @@ AND (TABLE_NAME LIKE 'log_civicrm_%' $nonStandardTableNameString ) * * @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 @@ AND (TABLE_NAME LIKE 'log_civicrm_%' $nonStandardTableNameString ) // 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 @@ AND (TABLE_NAME LIKE 'log_civicrm_%' $nonStandardTableNameString ) 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 @@ AND (TABLE_NAME LIKE 'log_civicrm_%' $nonStandardTableNameString ) * @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 @@ AND (TABLE_NAME LIKE 'log_civicrm_%' $nonStandardTableNameString ) * @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 @@ AND (TABLE_NAME LIKE 'log_civicrm_%' $nonStandardTableNameString ) * 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 @@ AND (TABLE_NAME LIKE 'log_civicrm_%' $nonStandardTableNameString ) 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 @@ AND (TABLE_NAME LIKE 'log_civicrm_%' $nonStandardTableNameString ) 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 @@ FROM INFORMATION_SCHEMA.COLUMNS 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 @@ WHERE table_schema IN ('{$this->db}', '{$civiDB}')"; $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 @@ WHERE table_schema IN ('{$this->db}', '{$civiDB}')"; // 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 @@ WHERE table_schema IN ('{$this->db}', '{$civiDB}')"; // 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 @@ COLS; $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 @@ COLS; if (empty($nonStandardTableNames)) { return ''; } - $nonStandardTableLogs = array(); + $nonStandardTableLogs = []; foreach ($nonStandardTableNames as $nonStandardTableName) { $nonStandardTableLogs[] = "'log_{$nonStandardTableName}'"; } @@ -865,12 +865,12 @@ COLS; 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 @@ COLS; $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 @@ COLS; $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 @@ COLS; $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 @@ COLS; 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 e8a4c0b11b..85e893ca4d 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 @@ class CRM_Mailing_ActionTokens extends \Civi\Token\AbstractTokenSubscriber { '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 5a502f6c62..5a255b5c11 100644 --- a/CRM/Mailing/BAO/BouncePattern.php +++ b/CRM/Mailing/BAO/BouncePattern.php @@ -48,7 +48,7 @@ class CRM_Mailing_BAO_BouncePattern extends CRM_Mailing_DAO_BouncePattern { * 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 @@ class CRM_Mailing_BAO_BouncePattern extends CRM_Mailing_DAO_BouncePattern { 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 99646d592a..e2ff2fbdbb 100644 --- a/CRM/Mailing/BAO/MailingAB.php +++ b/CRM/Mailing/BAO/MailingAB.php @@ -55,7 +55,7 @@ class CRM_Mailing_BAO_MailingAB extends CRM_Mailing_DAO_MailingAB { * @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 @@ class CRM_Mailing_BAO_MailingAB extends CRM_Mailing_DAO_MailingAB { * * @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 @@ class CRM_Mailing_BAO_MailingAB extends CRM_Mailing_DAO_MailingAB { $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 @@ class CRM_Mailing_BAO_MailingAB extends CRM_Mailing_DAO_MailingAB { $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 @@ class CRM_Mailing_BAO_MailingAB extends CRM_Mailing_DAO_MailingAB { 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 bd0e8139f3..2fa8b55318 100644 --- a/CRM/Mailing/BAO/MailingComponent.php +++ b/CRM/Mailing/BAO/MailingComponent.php @@ -77,7 +77,7 @@ class CRM_Mailing_BAO_MailingComponent extends CRM_Mailing_DAO_MailingComponent * * @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 @@ class CRM_Mailing_BAO_MailingComponent extends CRM_Mailing_DAO_MailingComponent 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 7c8eefccea..c74785568e 100644 --- a/CRM/Mailing/BAO/MailingJob.php +++ b/CRM/Mailing/BAO/MailingJob.php @@ -188,12 +188,12 @@ class CRM_Mailing_BAO_MailingJob extends CRM_Mailing_DAO_MailingJob { $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 @@ class CRM_Mailing_BAO_MailingJob extends CRM_Mailing_DAO_MailingJob { 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 @@ INSERT INTO civicrm_mailing_job (`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 @@ VALUES (%1, %2, %3, %4, %5, %6, %7) // 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 @@ VALUES (%1, %2, %3, %4, %5, %6, %7) $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 @@ VALUES (%1, %2, %3, %4, %5, %6, %7) } $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 @@ VALUES (%1, %2, %3, %4, %5, %6, %7) } 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 @@ VALUES (%1, %2, %3, %4, %5, %6, %7) // get the return properties $returnProperties = $mailing->getReturnProperties(); - $params = $targetParams = $deliveredParams = array(); + $params = $targetParams = $deliveredParams = []; $count = 0; $retryGroup = FALSE; @@ -624,7 +624,7 @@ VALUES (%1, %2, %3, %4, %5, %6, %7) 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 @@ VALUES (%1, %2, %3, %4, %5, %6, %7) $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 @@ VALUES (%1, %2, %3, %4, %5, %6, %7) // 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 @@ AND is_test = 0 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 @@ AND is_test = 0 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 @@ AND status IN ( 'Scheduled', 'Running', 'Paused' ) 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 @@ AND status IN ( 'Scheduled', 'Running', 'Paused' ) 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 @@ AND status IN ( 'Scheduled', 'Running', 'Paused' ) 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 @@ AND status IN ( 'Scheduled', 'Running', 'Paused' ) 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 @@ AND status IN ( 'Scheduled', 'Running', 'Paused' ) if (!empty($deliveredParams)) { CRM_Mailing_Event_BAO_Delivered::bulkCreate($deliveredParams); - $deliveredParams = array(); + $deliveredParams = []; } if ($writeActivity === NULL) { @@ -997,7 +997,7 @@ AND status IN ( 'Scheduled', 'Running', 'Paused' ) } } - $activity = array( + $activity = [ 'source_contact_id' => $mailing->scheduled_id, // CRM-9519 'target_contact_id' => array_unique($targetParams), @@ -1008,7 +1008,7 @@ AND status IN ( 'Scheduled', 'Running', 'Paused' ) '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 @@ WHERE civicrm_activity.activity_type_id = %1 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 @@ AND record_type_id = $targetRecordID $result = FALSE; } - $targetParams = array(); + $targetParams = []; } return $result; diff --git a/CRM/Mailing/BAO/Query.php b/CRM/Mailing/BAO/Query.php index 031a1cb229..329d9b7932 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 @@ class CRM_Mailing_BAO_Query { $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 @@ class CRM_Mailing_BAO_Query { 'contact_type' => 1, 'contact_sub_type' => 1, 'mailing_recipients_id' => 1, - ); + ]; } return $properties; } @@ -295,7 +295,7 @@ class CRM_Mailing_BAO_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 @@ class CRM_Mailing_BAO_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 @@ class CRM_Mailing_BAO_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 @@ class CRM_Mailing_BAO_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 @@ class CRM_Mailing_BAO_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 @@ class CRM_Mailing_BAO_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 @@ class CRM_Mailing_BAO_Query { 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 @@ class CRM_Mailing_BAO_Query { * @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 356a6271a2..608f83db67 100644 --- a/CRM/Mailing/BAO/Recipients.php +++ b/CRM/Mailing/BAO/Recipients.php @@ -50,7 +50,7 @@ SELECT count(*) as count 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 @@ FROM civicrm_mailing_recipients 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 43f962cf9b..26eb8d3ea3 100644 --- a/CRM/Mailing/BAO/Spool.php +++ b/CRM/Mailing/BAO/Spool.php @@ -60,7 +60,7 @@ class CRM_Mailing_BAO_Spool extends CRM_Mailing_DAO_Spool { * 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 @@ class CRM_Mailing_BAO_Spool extends CRM_Mailing_DAO_Spool { // 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 @@ class CRM_Mailing_BAO_Spool extends CRM_Mailing_DAO_Spool { $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 @@ class CRM_Mailing_BAO_Spool extends CRM_Mailing_DAO_Spool { $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 0c087ae8ef..6c5b6590f2 100644 --- a/CRM/Mailing/BAO/TrackableURL.php +++ b/CRM/Mailing/BAO/TrackableURL.php @@ -55,7 +55,7 @@ class CRM_Mailing_BAO_TrackableURL extends CRM_Mailing_DAO_TrackableURL { */ 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 d62d1fe715..4681c6d283 100644 --- a/CRM/Mailing/Controller/Send.php +++ b/CRM/Mailing/Controller/Send.php @@ -64,7 +64,7 @@ class CRM_Mailing_Controller_Send extends CRM_Core_Controller { 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 5de98c8c3c..16b974429a 100644 --- a/CRM/Mailing/Event/BAO/Confirm.php +++ b/CRM/Mailing/Event/BAO/Confirm.php @@ -91,7 +91,7 @@ class CRM_Mailing_Event_BAO_Confirm extends CRM_Mailing_Event_DAO_Confirm { $ce->save(); CRM_Contact_BAO_GroupContact::addContactsToGroup( - array($contact_id), + [$contact_id], $se->group_id, 'Email', 'Added', @@ -138,7 +138,7 @@ class CRM_Mailing_Event_BAO_Confirm extends CRM_Mailing_Event_DAO_Confirm { $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 @@ class CRM_Mailing_Event_BAO_Confirm extends CRM_Mailing_Event_DAO_Confirm { '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 62f6cbc811..706a65d215 100644 --- a/CRM/Mailing/Event/BAO/Delivered.php +++ b/CRM/Mailing/Event/BAO/Delivered.php @@ -225,18 +225,18 @@ class CRM_Mailing_Event_BAO_Delivered extends CRM_Mailing_Event_DAO_Delivered { $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 @@ class CRM_Mailing_Event_BAO_Delivered extends CRM_Mailing_Event_DAO_Delivered { } // 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 1d1589a083..8d8532ea8d 100644 --- a/CRM/Mailing/Event/BAO/Forward.php +++ b/CRM/Mailing/Event/BAO/Forward.php @@ -105,25 +105,25 @@ class CRM_Mailing_Event_BAO_Forward extends CRM_Mailing_Event_DAO_Forward { } 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 @@ class CRM_Mailing_Event_BAO_Forward extends CRM_Mailing_Event_DAO_Forward { // 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 @@ class CRM_Mailing_Event_BAO_Forward extends CRM_Mailing_Event_DAO_Forward { 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 @@ class CRM_Mailing_Event_BAO_Forward extends CRM_Mailing_Event_DAO_Forward { $dao->query($query); - $results = array(); + $results = []; while ($dao->fetch()) { $from_url = CRM_Utils_System::url('civicrm/contact/view', @@ -371,12 +371,12 @@ class CRM_Mailing_Event_BAO_Forward extends CRM_Mailing_Event_DAO_Forward { $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 3e88468c4e..a2a1e01b30 100644 --- a/CRM/Mailing/Event/BAO/Opened.php +++ b/CRM/Mailing/Event/BAO/Opened.php @@ -138,7 +138,7 @@ class CRM_Mailing_Event_BAO_Opened extends CRM_Mailing_Event_DAO_Opened { */ 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 @@ class CRM_Mailing_Event_BAO_Opened extends CRM_Mailing_Event_DAO_Opened { */ 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 @@ class CRM_Mailing_Event_BAO_Opened extends CRM_Mailing_Event_DAO_Opened { $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 @@ class CRM_Mailing_Event_BAO_Opened extends CRM_Mailing_Event_DAO_Opened { $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 5b68838d0c..41cefaf8ee 100644 --- a/CRM/Mailing/Event/BAO/Queue.php +++ b/CRM/Mailing/Event/BAO/Queue.php @@ -236,17 +236,17 @@ class CRM_Mailing_Event_BAO_Queue extends CRM_Mailing_Event_DAO_Queue { $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 @@ SELECT DISTINCT(civicrm_mailing_event_queue.contact_id) as contact_id, $email = $dao->email; } - return array($displayName, $email); + return [$displayName, $email]; } /** @@ -316,7 +316,7 @@ SELECT DISTINCT(civicrm_mailing_event_queue.contact_id) as contact_id, } // 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 3bfc007104..03a54c9431 100644 --- a/CRM/Mailing/Event/BAO/Reply.php +++ b/CRM/Mailing/Event/BAO/Reply.php @@ -118,7 +118,7 @@ class CRM_Mailing_Event_BAO_Reply extends CRM_Mailing_Event_DAO_Reply { $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 @@ class CRM_Mailing_Event_BAO_Reply extends CRM_Mailing_Event_DAO_Reply { $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 @@ class CRM_Mailing_Event_BAO_Reply extends CRM_Mailing_Event_DAO_Reply { // 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 @@ class CRM_Mailing_Event_BAO_Reply extends CRM_Mailing_Event_DAO_Reply { $message = new Mail_mime("\n"); - $headers = array( + $headers = [ 'Subject' => "Re: {$mailing->subject}", 'To' => $mailing->replyto_email, 'From' => "\"$fromName\" <$fromEmail>", @@ -188,7 +188,7 @@ class CRM_Mailing_Event_BAO_Reply extends CRM_Mailing_Event_DAO_Reply { // 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 @@ class CRM_Mailing_Event_BAO_Reply extends CRM_Mailing_Event_DAO_Reply { $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 @@ class CRM_Mailing_Event_BAO_Reply extends CRM_Mailing_Event_DAO_Reply { $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 d37d492f93..f7b05d127a 100644 --- a/CRM/Mailing/Event/BAO/Resubscribe.php +++ b/CRM/Mailing/Event/BAO/Resubscribe.php @@ -101,8 +101,8 @@ class CRM_Mailing_Event_BAO_Resubscribe { // 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 @@ class CRM_Mailing_Event_BAO_Resubscribe { 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 @@ class CRM_Mailing_Event_BAO_Resubscribe { $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 @@ class CRM_Mailing_Event_BAO_Resubscribe { $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 86bf73e7ba..2df4893a8f 100644 --- a/CRM/Mailing/Event/BAO/Subscribe.php +++ b/CRM/Mailing/Event/BAO/Subscribe.php @@ -65,8 +65,8 @@ class CRM_Mailing_Event_BAO_Subscribe extends CRM_Mailing_Event_DAO_Subscribe { */ 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 @@ class CRM_Mailing_Event_BAO_Subscribe extends CRM_Mailing_Event_DAO_Subscribe { 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 @@ LEFT JOIN civicrm_email ON contact_a.id = civicrm_email.contact_id 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 @@ SELECT civicrm_email.id as email_id 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 @@ SELECT civicrm_email.id as email_id ); $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 @@ SELECT civicrm_email.id as email_id $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 @@ SELECT civicrm_email.id as email_id $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 @@ SELECT civicrm_email.id as email_id 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 @@ SELECT civicrm_email.id as email_id 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 @@ SELECT civicrm_email.id as email_id */ 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 @@ SELECT civicrm_email.id as email_id $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 @@ SELECT civicrm_email.id as email_id } 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 4e6709dfc7..29a907d29a 100644 --- a/CRM/Mailing/Event/BAO/TrackableURLOpen.php +++ b/CRM/Mailing/Event/BAO/TrackableURLOpen.php @@ -64,9 +64,9 @@ class CRM_Mailing_Event_BAO_TrackableURLOpen extends CRM_Mailing_Event_DAO_Track "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 @@ class CRM_Mailing_Event_BAO_TrackableURLOpen extends CRM_Mailing_Event_DAO_Track 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 @@ class CRM_Mailing_Event_BAO_TrackableURLOpen extends CRM_Mailing_Event_DAO_Track "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 @@ class CRM_Mailing_Event_BAO_TrackableURLOpen extends CRM_Mailing_Event_DAO_Track */ 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 @@ class CRM_Mailing_Event_BAO_TrackableURLOpen extends CRM_Mailing_Event_DAO_Track */ 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 @@ class CRM_Mailing_Event_BAO_TrackableURLOpen extends CRM_Mailing_Event_DAO_Track 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 f596a5d264..415ae85350 100644 --- a/CRM/Mailing/Event/BAO/Unsubscribe.php +++ b/CRM/Mailing/Event/BAO/Unsubscribe.php @@ -77,10 +77,10 @@ SET on_hold = 2, 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 @@ WHERE email = %2 $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 @@ WHERE email = %2 $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 @@ WHERE email = %2 // 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 @@ WHERE email = %2 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 @@ WHERE email = %2 )"); 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 @@ WHERE email = %2 } } - $contacts = array($contact_id); + $contacts = [$contact_id]; foreach ($groups as $group_id => $group_name) { $notremoved = FALSE; if ($group_name) { @@ -416,13 +416,13 @@ WHERE email = %2 $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 @@ WHERE email = %2 $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 @@ SELECT DISTINCT(civicrm_mailing_event_queue.contact_id) as contact_id, $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 7490ae6581..acf0b9218f 100644 --- a/CRM/Mailing/Form/Approve.php +++ b/CRM/Mailing/Form/Approve.php @@ -75,7 +75,7 @@ class CRM_Mailing_Form_Approve extends CRM_Core_Form { * 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 @@ class CRM_Mailing_Form_Approve extends CRM_Core_Form { 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 @@ class CRM_Mailing_Form_Approve extends CRM_Core_Form { // 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 12d51b337e..d0c1f8d9c8 100644 --- a/CRM/Mailing/Form/Browse.php +++ b/CRM/Mailing/Form/Browse.php @@ -62,17 +62,17 @@ class CRM_Mailing_Form_Browse extends CRM_Core_Form { * 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 3dcc63b0ff..beb2efee21 100644 --- a/CRM/Mailing/Form/Component.php +++ b/CRM/Mailing/Form/Component.php @@ -59,15 +59,15 @@ class CRM_Mailing_Form_Component extends CRM_Core_Form { * 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 @@ class CRM_Mailing_Form_Component extends CRM_Core_Form { $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 @@ class CRM_Mailing_Form_Component extends CRM_Core_Form { * 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 @@ class CRM_Mailing_Form_Component extends CRM_Core_Form { } $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 @@ class CRM_Mailing_Form_Component extends CRM_Core_Form { */ 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 @@ class CRM_Mailing_Form_Component extends CRM_Core_Form { * 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 f499c381db..0fa6966707 100644 --- a/CRM/Mailing/Form/ForwardMailing.php +++ b/CRM/Mailing/Form/ForwardMailing.php @@ -61,7 +61,7 @@ class CRM_Mailing_Form_ForwardMailing extends CRM_Core_Form { // 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 @@ class CRM_Mailing_Form_ForwardMailing extends CRM_Core_Form { */ 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 @@ class CRM_Mailing_Form_ForwardMailing extends CRM_Core_Form { $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 @@ class CRM_Mailing_Form_ForwardMailing extends CRM_Core_Form { $forwarded = NULL; foreach ($emails as $email) { - $params = array( + $params = [ 'version' => 3, 'job_id' => $job_id, 'event_queue_id' => $queue_id, @@ -131,22 +131,22 @@ class CRM_Mailing_Form_ForwardMailing extends CRM_Core_Form { '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 97c951cc40..7473fe3af3 100644 --- a/CRM/Mailing/Form/Optout.php +++ b/CRM/Mailing/Form/Optout.php @@ -68,17 +68,17 @@ class CRM_Mailing_Form_Optout extends CRM_Core_Form { $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 @@ class CRM_Mailing_Form_Optout extends CRM_Core_Form { } $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 @@ class CRM_Mailing_Form_Optout extends CRM_Core_Form { 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 f9080be13f..c7c3d42eae 100644 --- a/CRM/Mailing/Form/Search.php +++ b/CRM/Mailing/Form/Search.php @@ -64,7 +64,7 @@ class CRM_Mailing_Form_Search extends CRM_Core_Form { $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 @@ class CRM_Mailing_Form_Search extends CRM_Core_Form { } $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 @@ class CRM_Mailing_Form_Search extends CRM_Core_Form { $parent = $this->controller->getParent(); if (!empty($params)) { - $fields = array( + $fields = [ 'mailing_name', 'mailing_from', 'mailing_to', @@ -127,15 +127,15 @@ class CRM_Mailing_Form_Search extends CRM_Core_Form { '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 fa6404943a..91b79e81a3 100644 --- a/CRM/Mailing/Form/Subscribe.php +++ b/CRM/Mailing/Form/Subscribe.php @@ -59,7 +59,7 @@ SELECT title, description $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 @@ SELECT id, title, description 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 @@ ORDER BY title"; 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 @@ ORDER BY title"; $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 @@ ORDER BY title"; 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 3ccb5e1804..e06b8cc1a1 100644 --- a/CRM/Mailing/Form/Task.php +++ b/CRM/Mailing/Form/Task.php @@ -55,7 +55,7 @@ class CRM_Mailing_Form_Task extends CRM_Core_Form_Task { $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 @@ class CRM_Mailing_Form_Task extends CRM_Core_Form_Task { * @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 6dca0f44f1..f08cf49939 100644 --- a/CRM/Mailing/Form/Task/AdhocMailing.php +++ b/CRM/Mailing/Form/Task/AdhocMailing.php @@ -40,25 +40,25 @@ class CRM_Mailing_Form_Task_AdhocMailing extends CRM_Contact_Form_Task { 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 ec97850167..a57f21a40a 100644 --- a/CRM/Mailing/Form/Task/Print.php +++ b/CRM/Mailing/Form/Task/Print.php @@ -70,18 +70,18 @@ class CRM_Mailing_Form_Task_Print extends CRM_Mailing_Form_Task { // // 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 a348b40760..33cee130f2 100644 --- a/CRM/Mailing/Form/Unsubscribe.php +++ b/CRM/Mailing/Form/Unsubscribe.php @@ -70,7 +70,7 @@ class CRM_Mailing_Form_Unsubscribe extends CRM_Core_Form { } 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 @@ class CRM_Mailing_Form_Unsubscribe extends CRM_Core_Form { $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 @@ class CRM_Mailing_Form_Unsubscribe extends CRM_Core_Form { } $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 @@ class CRM_Mailing_Form_Unsubscribe extends CRM_Core_Form { 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 0361dfbaf7..7ed725507d 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 @@ class CRM_Mailing_Info extends CRM_Core_Component_Info { && !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 @@ class CRM_Mailing_Info extends CRM_Core_Component_Info { $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 @@ class CRM_Mailing_Info extends CRM_Core_Component_Info { '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 @@ class CRM_Mailing_Info extends CRM_Core_Component_Info { 'approve mailings', 'delete in CiviMail', 'edit message templates', - )); + ]); return $result; } @@ -207,33 +207,33 @@ class CRM_Mailing_Info extends CRM_Core_Component_Info { * @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 @@ class CRM_Mailing_Info extends CRM_Core_Component_Info { * @return array */ public function registerTab() { - return array( + return [ 'title' => ts('Mailings'), 'id' => 'mailing', 'url' => 'mailing', 'weight' => 45, - ); + ]; } /** @@ -289,10 +289,10 @@ class CRM_Mailing_Info extends CRM_Core_Component_Info { * @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 c2745c63be..bb94c529a1 100644 --- a/CRM/Mailing/MailStore.php +++ b/CRM/Mailing/MailStore.php @@ -122,9 +122,9 @@ class CRM_Mailing_MailStore { 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 @@ class CRM_Mailing_MailStore { 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 eef954a3d1..a805ee43a2 100644 --- a/CRM/Mailing/MailStore/Imap.php +++ b/CRM/Mailing/MailStore/Imap.php @@ -64,13 +64,13 @@ class CRM_Mailing_MailStore_Imap extends CRM_Mailing_MailStore { } - $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 9f46a14902..87a0a4f185 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 @@ class CRM_Mailing_MailStore_Localdir extends CRM_Mailing_MailStore { * 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 @@ class CRM_Mailing_MailStore_Localdir extends CRM_Mailing_MailStore { 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 @@ class CRM_Mailing_MailStore_Localdir extends CRM_Mailing_MailStore { 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 0ff416c04f..c0b5855395 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 @@ class CRM_Mailing_MailStore_Maildir extends CRM_Mailing_MailStore { * 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 @@ class CRM_Mailing_MailStore_Maildir extends CRM_Mailing_MailStore { } - $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 7f0f466c76..c1679a4aaf 100644 --- a/CRM/Mailing/MailStore/Mbox.php +++ b/CRM/Mailing/MailStore/Mbox.php @@ -50,18 +50,18 @@ class CRM_Mailing_MailStore_Mbox extends CRM_Mailing_MailStore { $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 1d244ec001..f30f741a98 100644 --- a/CRM/Mailing/MailStore/Pop3.php +++ b/CRM/Mailing/MailStore/Pop3.php @@ -55,22 +55,22 @@ class CRM_Mailing_MailStore_Pop3 extends CRM_Mailing_MailStore { 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 77cf97467c..c2586c2507 100644 --- a/CRM/Mailing/Page/AJAX.php +++ b/CRM/Mailing/Page/AJAX.php @@ -47,12 +47,12 @@ class CRM_Mailing_Page_AJAX { $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 @@ class CRM_Mailing_Page_AJAX { */ 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 166a50fe7f..65bf2de542 100644 --- a/CRM/Mailing/Page/Browse.php +++ b/CRM/Mailing/Page/Browse.php @@ -94,7 +94,7 @@ class CRM_Mailing_Page_Browse extends CRM_Core_Page { // 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 @@ class CRM_Mailing_Page_Browse extends CRM_Core_Page { * @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 @@ class CRM_Mailing_Page_Browse extends CRM_Core_Page { $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 bf4e9832de..24d90b3386 100644 --- a/CRM/Mailing/Page/Component.php +++ b/CRM/Mailing/Page/Component.php @@ -62,24 +62,24 @@ class CRM_Mailing_Page_Component extends CRM_Core_Page_Basic { */ 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 9c51fbdd7d..cbcf367500 100644 --- a/CRM/Mailing/Page/Preview.php +++ b/CRM/Mailing/Page/Preview.php @@ -46,7 +46,7 @@ class CRM_Mailing_Page_Preview extends CRM_Core_Page { $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 @@ class CRM_Mailing_Page_Preview extends CRM_Core_Page { // 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 6c57a75009..628672a01e 100644 --- a/CRM/Mailing/Page/Report.php +++ b/CRM/Mailing/Page/Report.php @@ -139,7 +139,7 @@ class CRM_Mailing_Page_Report extends CRM_Core_Page_Basic { $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 c5caf89402..66a7200f1c 100644 --- a/CRM/Mailing/Page/Tab.php +++ b/CRM/Mailing/Page/Tab.php @@ -66,7 +66,7 @@ class CRM_Mailing_Page_Tab extends CRM_Contact_Page_View { // 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 91f9164b57..b8282405a3 100644 --- a/CRM/Mailing/Page/View.php +++ b/CRM/Mailing/Page/View.php @@ -143,7 +143,7 @@ class CRM_Mailing_Page_View extends CRM_Core_Page { $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 @@ class CRM_Mailing_Page_View extends CRM_Core_Page { } 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 84dbc6aa0b..d6186b9d34 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 @@ class CRM_Mailing_PseudoConstant extends CRM_Core_PseudoConstant { */ 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 @@ class CRM_Mailing_PseudoConstant extends CRM_Core_PseudoConstant { */ 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 @@ class CRM_Mailing_PseudoConstant extends CRM_Core_PseudoConstant { */ 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 @@ class CRM_Mailing_PseudoConstant extends CRM_Core_PseudoConstant { 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 @@ class CRM_Mailing_PseudoConstant extends CRM_Core_PseudoConstant { } 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 @@ class CRM_Mailing_PseudoConstant extends CRM_Core_PseudoConstant { $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 @@ class CRM_Mailing_PseudoConstant extends CRM_Core_PseudoConstant { 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 b99adbf033..84014a0b1b 100644 --- a/CRM/Mailing/Selector/Browse.php +++ b/CRM/Mailing/Selector/Browse.php @@ -116,78 +116,78 @@ class CRM_Mailing_Selector_Browse extends CRM_Core_Selector_Base implements CRM_ } $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 @@ class CRM_Mailing_Selector_Browse extends CRM_Core_Selector_Base implements CRM_ $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 @@ LEFT JOIN civicrm_contact scheduledContact ON ( $mailing.scheduled_id = schedul $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 @@ LEFT JOIN civicrm_contact scheduledContact ON ( $mailing.scheduled_id = schedul } $mailing = new CRM_Mailing_BAO_Mailing(); - $params = array(); + $params = []; $whereClause = ' AND ' . $this->whereClause($params); @@ -354,7 +354,7 @@ LEFT JOIN civicrm_contact scheduledContact ON ( $mailing.scheduled_id = schedul 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 @@ LEFT JOIN civicrm_contact scheduledContact ON ( $mailing.scheduled_id = schedul $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 @@ LEFT JOIN civicrm_contact scheduledContact ON ( $mailing.scheduled_id = schedul } } - if (in_array($row['status'], array('Complete', 'Canceled')) && + if (in_array($row['status'], ['Complete', 'Canceled']) && !$row['archived'] ) { if ($allAccess || $showCreateLinks) { @@ -441,20 +441,20 @@ LEFT JOIN civicrm_contact scheduledContact ON ( $mailing.scheduled_id = schedul $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 @@ LEFT JOIN civicrm_contact scheduledContact ON ( $mailing.scheduled_id = schedul * @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 @@ LEFT JOIN civicrm_contact scheduledContact ON ( $mailing.scheduled_id = schedul $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 @@ LEFT JOIN civicrm_contact scheduledContact ON ( $mailing.scheduled_id = schedul $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 @@ LEFT JOIN civicrm_contact scheduledContact ON ( $mailing.scheduled_id = schedul 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 @@ LEFT JOIN civicrm_contact scheduledContact ON ( $mailing.scheduled_id = schedul $isDraft = 1; } - $statusClauses = array(); + $statusClauses = []; if ($isDraft) { $statusClauses[] = "civicrm_mailing.scheduled_id IS NULL"; } @@ -620,26 +620,26 @@ LEFT JOIN civicrm_contact scheduledContact ON ( $mailing.scheduled_id = schedul $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 @@ LEFT JOIN civicrm_contact scheduledContact ON ( $mailing.scheduled_id = schedul 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 84b31f19fe..0354321a92 100644 --- a/CRM/Mailing/Selector/Event.php +++ b/CRM/Mailing/Selector/Event.php @@ -119,7 +119,7 @@ class CRM_Mailing_Selector_Event extends CRM_Core_Selector_Base implements CRM_C 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 @@ class CRM_Mailing_Selector_Event extends CRM_Core_Selector_Base implements CRM_C $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 @@ class CRM_Mailing_Selector_Event extends CRM_Core_Selector_Base implements CRM_C 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 @@ class CRM_Mailing_Selector_Event extends CRM_Core_Selector_Base implements CRM_C 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 @@ class CRM_Mailing_Selector_Event extends CRM_Core_Selector_Base implements CRM_C $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 @@ class CRM_Mailing_Selector_Event extends CRM_Core_Selector_Base implements CRM_C 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 @@ class CRM_Mailing_Selector_Event extends CRM_Core_Selector_Base implements CRM_C static $events = NULL; if (empty($events)) { - $events = array( + $events = [ 'queue' => ts('Intended Recipients'), 'delivered' => ts('Successful Deliveries'), 'bounce' => ts('Bounces'), @@ -458,7 +458,7 @@ class CRM_Mailing_Selector_Event extends CRM_Core_Selector_Base implements CRM_C '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 51f41f469d..2417a7ed2a 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 @@ class CRM_Mailing_Selector_Search extends CRM_Core_Selector_Base implements CRM_ $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 @@ class CRM_Mailing_Selector_Search extends CRM_Core_Selector_Base implements CRM_ ); // 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 @@ class CRM_Mailing_Selector_Search extends CRM_Core_Selector_Base implements CRM_ $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 @@ class CRM_Mailing_Selector_Search extends CRM_Core_Selector_Base implements CRM_ $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 @@ class CRM_Mailing_Selector_Search extends CRM_Core_Selector_Base implements CRM_ */ 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 fbfd6077cb..65664796e6 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 @@ class CRM_Mailing_Task extends CRM_Core_Task { * @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 @@ class CRM_Mailing_Task extends CRM_Core_Task { $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 8069d8335e..74cd6adee4 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 @@ class CRM_Mailing_Tokens extends \Civi\Token\AbstractTokenSubscriber { 'approveUrl' => ts('Mailing Approval URL'), 'creator' => ts('Mailing Creator (Name)'), 'creatorEmail' => ts('Mailing Creator (Email)'), - )); + ]); } /** @@ -78,9 +78,9 @@ class CRM_Mailing_Tokens extends \Civi\Token\AbstractTokenSubscriber { ? $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 a33e558871..3546c48f90 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 @@ class CRM_Member_ActionMapping extends \Civi\ActionSchedule\Mapping { 'entity_value_label' => ts('Membership Type'), 'entity_status' => 'auto_renew_options', 'entity_status_label' => ts('Auto Renew Options'), - ))); + ])); } /** @@ -68,11 +68,11 @@ class CRM_Member_ActionMapping extends \Civi\ActionSchedule\Mapping { * 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 3754427676..d80a05d5e4 100644 --- a/CRM/Member/BAO/MembershipLog.php +++ b/CRM/Member/BAO/MembershipLog.php @@ -74,7 +74,7 @@ UPDATE civicrm_membership_log 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 0241b7c454..bacf50d2f7 100644 --- a/CRM/Member/BAO/MembershipPayment.php +++ b/CRM/Member/BAO/MembershipPayment.php @@ -59,7 +59,7 @@ class CRM_Member_BAO_MembershipPayment extends CRM_Member_DAO_MembershipPayment // 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 @@ class CRM_Member_BAO_MembershipPayment extends CRM_Member_DAO_MembershipPayment // 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 @@ class CRM_Member_BAO_MembershipPayment extends CRM_Member_DAO_MembershipPayment 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 0f7f8ae419..8b4b532901 100644 --- a/CRM/Member/BAO/MembershipStatus.php +++ b/CRM/Member/BAO/MembershipStatus.php @@ -92,7 +92,7 @@ class CRM_Member_BAO_MembershipStatus extends CRM_Member_DAO_MembershipStatus { * @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 @@ class CRM_Member_BAO_MembershipStatus extends CRM_Member_DAO_MembershipStatus { * * @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 @@ class CRM_Member_BAO_MembershipStatus extends CRM_Member_DAO_MembershipStatus { * @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 @@ class CRM_Member_BAO_MembershipStatus extends CRM_Member_DAO_MembershipStatus { * @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 @@ class CRM_Member_BAO_MembershipStatus extends CRM_Member_DAO_MembershipStatus { //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 @@ class CRM_Member_BAO_MembershipStatus extends CRM_Member_DAO_MembershipStatus { */ 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 @@ class CRM_Member_BAO_MembershipStatus extends CRM_Member_DAO_MembershipStatus { $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 @@ class CRM_Member_BAO_MembershipStatus extends CRM_Member_DAO_MembershipStatus { //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 @@ class CRM_Member_BAO_MembershipStatus extends CRM_Member_DAO_MembershipStatus { 'membership_type_id' => $membershipTypeID, 'start_event' => $startEvent, 'end_event' => $endEvent, - ); + ]; CRM_Utils_Hook::alterCalculatedMembershipStatus($membershipDetails, $arguments, $membership); return $membershipDetails; } @@ -382,7 +382,7 @@ class CRM_Member_BAO_MembershipStatus extends CRM_Member_DAO_MembershipStatus { * @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 6438cff3c0..521fa621cd 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 @@ class CRM_Member_BAO_MembershipType extends CRM_Member_DAO_MembershipType { * @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 @@ class CRM_Member_BAO_MembershipType extends CRM_Member_DAO_MembershipType { 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 @@ class CRM_Member_BAO_MembershipType extends CRM_Member_DAO_MembershipType { */ 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 @@ class CRM_Member_BAO_MembershipType extends CRM_Member_DAO_MembershipType { 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 @@ class CRM_Member_BAO_MembershipType extends CRM_Member_DAO_MembershipType { 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 @@ class CRM_Member_BAO_MembershipType extends CRM_Member_DAO_MembershipType { * 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 @@ class CRM_Member_BAO_MembershipType extends CRM_Member_DAO_MembershipType { '10' => 'Oct', '11' => 'Nov', '12' => 'Dec', - ); + ]; $membershipType[$id][$pDay] = $monthMap[$month] . ' ' . $day; } else { @@ -270,7 +270,7 @@ class CRM_Member_BAO_MembershipType extends CRM_Member_DAO_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 @@ class CRM_Member_BAO_MembershipType extends CRM_Member_DAO_MembershipType { * @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 @@ class CRM_Member_BAO_MembershipType extends CRM_Member_DAO_MembershipType { $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 @@ class CRM_Member_BAO_MembershipType extends CRM_Member_DAO_MembershipType { } } - $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 @@ class CRM_Member_BAO_MembershipType extends CRM_Member_DAO_MembershipType { * 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 @@ class CRM_Member_BAO_MembershipType extends CRM_Member_DAO_MembershipType { */ 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 @@ class CRM_Member_BAO_MembershipType extends CRM_Member_DAO_MembershipType { * 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 @@ class CRM_Member_BAO_MembershipType extends CRM_Member_DAO_MembershipType { * @return array */ public static function getMembershipTypeOrganization($membershipTypeId = NULL) { - $allMembershipTypes = array(); + $allMembershipTypes = []; $membershipType = new CRM_Member_DAO_MembershipType(); @@ -700,7 +700,7 @@ class CRM_Member_BAO_MembershipType extends CRM_Member_DAO_MembershipType { */ 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 @@ class CRM_Member_BAO_MembershipType extends CRM_Member_DAO_MembershipType { $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 @@ class CRM_Member_BAO_MembershipType extends CRM_Member_DAO_MembershipType { } $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 @@ class CRM_Member_BAO_MembershipType extends CRM_Member_DAO_MembershipType { } 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 @@ class CRM_Member_BAO_MembershipType extends CRM_Member_DAO_MembershipType { $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 @@ class CRM_Member_BAO_MembershipType extends CRM_Member_DAO_MembershipType { * @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 23a3e5d050..19a526d7f8 100644 --- a/CRM/Member/BAO/Query.php +++ b/CRM/Member/BAO/Query.php @@ -174,7 +174,7 @@ class CRM_Member_BAO_Query extends CRM_Core_BAO_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 @@ class CRM_Member_BAO_Query extends CRM_Core_BAO_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 @@ class CRM_Member_BAO_Query extends CRM_Core_BAO_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 @@ class CRM_Member_BAO_Query extends CRM_Core_BAO_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 @@ class CRM_Member_BAO_Query extends CRM_Core_BAO_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 @@ class CRM_Member_BAO_Query extends CRM_Core_BAO_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 @@ class CRM_Member_BAO_Query extends CRM_Core_BAO_Query { ) { $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 @@ class CRM_Member_BAO_Query extends CRM_Core_BAO_Query { '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 @@ class CRM_Member_BAO_Query extends CRM_Core_BAO_Query { */ 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 @@ class CRM_Member_BAO_Query extends CRM_Core_BAO_Query { 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 @@ class CRM_Member_BAO_Query extends CRM_Core_BAO_Query { $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 @@ class CRM_Member_BAO_Query extends CRM_Core_BAO_Query { */ 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 @@ class CRM_Member_BAO_Query extends CRM_Core_BAO_Query { * @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 602a54da65..724aeed552 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 @@ class CRM_Member_Form extends CRM_Contribute_Form_AbstractEditPayment { * * @var array */ - protected $_params = array(); + protected $_params = []; /** * Fields for the entity to be assigned to the template. @@ -151,7 +151,7 @@ class CRM_Member_Form extends CRM_Contribute_Form_AbstractEditPayment { } 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 @@ class CRM_Member_Form extends CRM_Contribute_Form_AbstractEditPayment { $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 @@ class CRM_Member_Form extends CRM_Contribute_Form_AbstractEditPayment { * 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 @@ class CRM_Member_Form extends CRM_Contribute_Form_AbstractEditPayment { $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 @@ class CRM_Member_Form extends CRM_Contribute_Form_AbstractEditPayment { } $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 @@ class CRM_Member_Form extends CRM_Contribute_Form_AbstractEditPayment { $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 @@ class CRM_Member_Form extends CRM_Contribute_Form_AbstractEditPayment { * @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 @@ class CRM_Member_Form extends CRM_Contribute_Form_AbstractEditPayment { */ 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 @@ class CRM_Member_Form extends CRM_Contribute_Form_AbstractEditPayment { '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 c7df8f5bf1..bbf97b31cd 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 @@ class CRM_Member_Form_Membership extends CRM_Member_Form { * @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 @@ class CRM_Member_Form_Membership extends CRM_Member_Form { * @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 @@ class CRM_Member_Form_Membership extends CRM_Member_Form { 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 @@ class CRM_Member_Form_Membership extends CRM_Member_Form { // 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 @@ class CRM_Member_Form_Membership extends CRM_Member_Form { $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 @@ class CRM_Member_Form_Membership extends CRM_Member_Form { $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 @@ class CRM_Member_Form_Membership extends CRM_Member_Form { 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 @@ class CRM_Member_Form_Membership extends CRM_Member_Form { 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 @@ class CRM_Member_Form_Membership extends CRM_Member_Form { // 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 @@ class CRM_Member_Form_Membership extends CRM_Member_Form { $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 @@ class CRM_Member_Form_Membership extends CRM_Member_Form { $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 @@ class CRM_Member_Form_Membership extends CRM_Member_Form { 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 @@ class CRM_Member_Form_Membership extends CRM_Member_Form { $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 @@ class CRM_Member_Form_Membership extends CRM_Member_Form { $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 @@ class CRM_Member_Form_Membership extends CRM_Member_Form { } $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 @@ class CRM_Member_Form_Membership extends CRM_Member_Form { $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 @@ class CRM_Member_Form_Membership extends CRM_Member_Form { * 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 @@ class CRM_Member_Form_Membership extends CRM_Member_Form { 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 @@ class CRM_Member_Form_Membership extends CRM_Member_Form { 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 @@ class CRM_Member_Form_Membership extends CRM_Member_Form { } 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 @@ class CRM_Member_Form_Membership extends CRM_Member_Form { 'isEmailPdf' => $isEmailPdf, 'contributionId' => $formValues['contribution_id'], 'isTest' => (bool) ($form->_action & CRM_Core_Action::PREVIEW), - ) + ] ); return TRUE; @@ -1093,10 +1093,10 @@ class CRM_Member_Form_Membership extends CRM_Member_Form { $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 @@ class CRM_Member_Form_Membership extends CRM_Member_Form { $config = CRM_Core_Config::singleton(); - $membershipTypeValues = array(); + $membershipTypeValues = []; foreach ($this->_memTypeSelected as $memType) { $membershipTypeValues[$memType]['membership_type_id'] = $memType; } @@ -1131,15 +1131,15 @@ class CRM_Member_Form_Membership extends CRM_Member_Form { //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 @@ class CRM_Member_Form_Membership extends CRM_Member_Form { $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 @@ class CRM_Member_Form_Membership extends CRM_Member_Form { $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 @@ class CRM_Member_Form_Membership extends CRM_Member_Form { } // 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 @@ class CRM_Member_Form_Membership extends CRM_Member_Form { $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 @@ class CRM_Member_Form_Membership extends CRM_Member_Form { 'receive_date', 'card_type_id', 'pan_truncation', - ); + ]; foreach ($recordContribution as $f) { $params[$f] = CRM_Utils_Array::value($f, $formValues); @@ -1291,10 +1291,10 @@ class CRM_Member_Form_Membership extends CRM_Member_Form { 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 @@ class CRM_Member_Form_Membership extends CRM_Member_Form { $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 @@ class CRM_Member_Form_Membership extends CRM_Member_Form { $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 @@ class CRM_Member_Form_Membership extends CRM_Member_Form { '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 @@ class CRM_Member_Form_Membership extends CRM_Member_Form { // 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 @@ class CRM_Member_Form_Membership extends CRM_Member_Form { $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 @@ class CRM_Member_Form_Membership extends CRM_Member_Form { $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 @@ class CRM_Member_Form_Membership extends CRM_Member_Form { //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 @@ class CRM_Member_Form_Membership extends CRM_Member_Form { } $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 @@ class CRM_Member_Form_Membership extends CRM_Member_Form { } } 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 @@ class CRM_Member_Form_Membership extends CRM_Member_Form { $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 @@ class CRM_Member_Form_Membership extends CRM_Member_Form { // 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 @@ class CRM_Member_Form_Membership extends CRM_Member_Form { $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 @@ class CRM_Member_Form_Membership extends CRM_Member_Form { 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 c34e535fef..bf0f4554b6 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 @@ class CRM_Member_Form_MembershipBlock extends CRM_Contribute_Form_ContributionPa $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 @@ class CRM_Member_Form_MembershipBlock extends CRM_Contribute_Form_ContributionPa } 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 @@ class CRM_Member_Form_MembershipBlock extends CRM_Contribute_Form_ContributionPa $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 @@ class CRM_Member_Form_MembershipBlock extends CRM_Contribute_Form_ContributionPa } } - $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 @@ class CRM_Member_Form_MembershipBlock extends CRM_Contribute_Form_ContributionPa 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 @@ class CRM_Member_Form_MembershipBlock extends CRM_Contribute_Form_ContributionPa $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 @@ class CRM_Member_Form_MembershipBlock extends CRM_Contribute_Form_ContributionPa $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 @@ class CRM_Member_Form_MembershipBlock extends CRM_Contribute_Form_ContributionPa 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 @@ class CRM_Member_Form_MembershipBlock extends CRM_Contribute_Form_ContributionPa * 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 @@ class CRM_Member_Form_MembershipBlock extends CRM_Contribute_Form_ContributionPa } 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 @@ class CRM_Member_Form_MembershipBlock extends CRM_Contribute_Form_ContributionPa $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 @@ class CRM_Member_Form_MembershipBlock extends CRM_Contribute_Form_ContributionPa $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 @@ class CRM_Member_Form_MembershipBlock extends CRM_Contribute_Form_ContributionPa $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 @@ class CRM_Member_Form_MembershipBlock extends CRM_Contribute_Form_ContributionPa 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 b123c0c064..60dc0a36a0 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 @@ class CRM_Member_Form_MembershipConfig extends CRM_Core_Form { */ 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 d90ea044e7..e3857d1a5d 100644 --- a/CRM/Member/Form/MembershipRenewal.php +++ b/CRM/Member/Form/MembershipRenewal.php @@ -235,7 +235,7 @@ class CRM_Member_Form_MembershipRenewal extends CRM_Member_Form { $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 @@ class CRM_Member_Form_MembershipRenewal extends CRM_Member_Form { // 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 @@ class CRM_Member_Form_MembershipRenewal extends CRM_Member_Form { $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 @@ class CRM_Member_Form_MembershipRenewal extends CRM_Member_Form { $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 @@ class CRM_Member_Form_MembershipRenewal extends CRM_Member_Form { $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 @@ class CRM_Member_Form_MembershipRenewal extends CRM_Member_Form { $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 @@ class CRM_Member_Form_MembershipRenewal extends CRM_Member_Form { ); } } - $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 @@ class CRM_Member_Form_MembershipRenewal extends CRM_Member_Form { * 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 @@ class CRM_Member_Form_MembershipRenewal extends CRM_Member_Form { 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 @@ class CRM_Member_Form_MembershipRenewal extends CRM_Member_Form { $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 @@ class CRM_Member_Form_MembershipRenewal extends CRM_Member_Form { 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 @@ class CRM_Member_Form_MembershipRenewal extends CRM_Member_Form { // 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 @@ class CRM_Member_Form_MembershipRenewal extends CRM_Member_Form { $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 @@ class CRM_Member_Form_MembershipRenewal extends CRM_Member_Form { $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 @@ class CRM_Member_Form_MembershipRenewal extends CRM_Member_Form { } 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 @@ class CRM_Member_Form_MembershipRenewal extends CRM_Member_Form { '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 ef768a0782..030ff03cd9 100644 --- a/CRM/Member/Form/MembershipStatus.php +++ b/CRM/Member/Form/MembershipStatus.php @@ -138,16 +138,16 @@ class CRM_Member_Form_MembershipStatus extends CRM_Core_Form { $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 @@ class CRM_Member_Form_MembershipStatus extends CRM_Core_Form { $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 be97a08810..3e1c01588e 100644 --- a/CRM/Member/Form/MembershipType.php +++ b/CRM/Member/Form/MembershipType.php @@ -132,7 +132,7 @@ class CRM_Member_Form_MembershipType extends CRM_Member_Form_MembershipConfig { ], ]; - 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 @@ class CRM_Member_Form_MembershipType extends CRM_Member_Form_MembershipConfig { // 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 @@ class CRM_Member_Form_MembershipType extends CRM_Member_Form_MembershipConfig { $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 @@ class CRM_Member_Form_MembershipType extends CRM_Member_Form_MembershipConfig { // 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 @@ class CRM_Member_Form_MembershipType extends CRM_Member_Form_MembershipConfig { 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 @@ class CRM_Member_Form_MembershipType extends CRM_Member_Form_MembershipConfig { 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 @@ class CRM_Member_Form_MembershipType extends CRM_Member_Form_MembershipConfig { $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 @@ class CRM_Member_Form_MembershipType extends CRM_Member_Form_MembershipConfig { * 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 @@ class CRM_Member_Form_MembershipType extends CRM_Member_Form_MembershipConfig { $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 @@ class CRM_Member_Form_MembershipType extends CRM_Member_Form_MembershipConfig { 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 @@ class CRM_Member_Form_MembershipType extends CRM_Member_Form_MembershipConfig { 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 @@ class CRM_Member_Form_MembershipType extends CRM_Member_Form_MembershipConfig { $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 @@ class CRM_Member_Form_MembershipType extends CRM_Member_Form_MembershipConfig { $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 @@ class CRM_Member_Form_MembershipType extends CRM_Member_Form_MembershipConfig { */ 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 b5ac847010..3d60d9a9b6 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 @@ class CRM_Member_Form_MembershipView extends CRM_Core_Form { */ 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 @@ class CRM_Member_Form_MembershipView extends CRM_Core_Form { $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 @@ class CRM_Member_Form_MembershipView extends CRM_Core_Form { '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 @@ class CRM_Member_Form_MembershipView extends CRM_Core_Form { * @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 @@ class CRM_Member_Form_MembershipView extends CRM_Core_Form { $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 @@ SELECT r.id, c.id as cid, c.display_name as name, c.job_title as comment, 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 @@ SELECT r.id, c.id as cid, c.display_name as name, c.job_title as comment, } $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 @@ SELECT r.id, c.id as cid, c.display_name as name, c.job_title as comment, '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 @@ SELECT r.id, c.id as cid, c.display_name as name, c.job_title as comment, 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 @@ SELECT r.id, c.id as cid, c.display_name as name, c.job_title as comment, } 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 @@ SELECT r.id, c.id as cid, c.display_name as name, c.job_title as comment, "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 @@ SELECT r.id, c.id as cid, c.display_name as name, c.job_title as comment, * @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 3f98247a5c..46a4acad2f 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 @@ class CRM_Member_Form_Search extends CRM_Core_Form_Search { $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 @@ class CRM_Member_Form_Search extends CRM_Core_Form_Search { //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 b83496d894..7cc08118ee 100644 --- a/CRM/Member/Form/Task.php +++ b/CRM/Member/Form/Task.php @@ -61,7 +61,7 @@ class CRM_Member_Form_Task extends CRM_Core_Form_Task { * @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 @@ class CRM_Member_Form_Task extends CRM_Core_Form_Task { } $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 @@ class CRM_Member_Form_Task extends CRM_Core_Form_Task { * @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 126c66970b..232595017b 100644 --- a/CRM/Member/Form/Task/Batch.php +++ b/CRM/Member/Form/Task/Batch.php @@ -63,7 +63,7 @@ class CRM_Member_Form_Task_Batch extends CRM_Member_Form_Task { 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 @@ class CRM_Member_Form_Task_Batch extends CRM_Member_Form_Task { 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 @@ class CRM_Member_Form_Task_Batch extends CRM_Member_Form_Task { $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 @@ class CRM_Member_Form_Task_Batch extends CRM_Member_Form_Task { 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 @@ class CRM_Member_Form_Task_Batch extends CRM_Member_Form_Task { 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 @@ class CRM_Member_Form_Task_Batch extends CRM_Member_Form_Task { // @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 543e87e03a..a6cbf2235b 100644 --- a/CRM/Member/Form/Task/Delete.php +++ b/CRM/Member/Form/Task/Delete.php @@ -89,12 +89,12 @@ class CRM_Member_Form_Task_Delete extends CRM_Member_Form_Task { } 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 098063395a..b1fa2e453a 100644 --- a/CRM/Member/Form/Task/Label.php +++ b/CRM/Member/Form/Task/Label.php @@ -68,7 +68,7 @@ class CRM_Member_Form_Task_Label extends CRM_Member_Form_Task { * 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 @@ class CRM_Member_Form_Task_Label extends CRM_Member_Form_Task { 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 @@ class CRM_Member_Form_Task_Label extends CRM_Member_Form_Task { } $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 c1db720170..80c83e8f11 100644 --- a/CRM/Member/Form/Task/PDFLetterCommon.php +++ b/CRM/Member/Form/Task/PDFLetterCommon.php @@ -55,13 +55,13 @@ class CRM_Member_Form_Task_PDFLetterCommon extends CRM_Contact_Form_Task_PDFLett */ 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 c2e38a05d0..6648dadadb 100644 --- a/CRM/Member/Form/Task/PickProfile.php +++ b/CRM/Member/Form/Task/PickProfile.php @@ -71,10 +71,10 @@ class CRM_Member_Form_Task_PickProfile extends CRM_Member_Form_Task { $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 @@ class CRM_Member_Form_Task_PickProfile extends CRM_Member_Form_Task { * @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 @@ class CRM_Member_Form_Task_PickProfile extends CRM_Member_Form_Task { * @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 c6b41ea704..423a3d588b 100644 --- a/CRM/Member/Form/Task/Print.php +++ b/CRM/Member/Form/Task/Print.php @@ -77,18 +77,18 @@ class CRM_Member_Form_Task_Print extends CRM_Member_Form_Task { // // 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 e517bb02d8..7f68f5c76f 100644 --- a/CRM/Member/Form/Task/Result.php +++ b/CRM/Member/Form/Task/Result.php @@ -54,13 +54,13 @@ class CRM_Member_Form_Task_Result extends CRM_Member_Form_Task { * @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 5121a69f40..9a780079f6 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 @@ WHERE mem.id IN ( $memberIDs )"; $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 @@ WHERE mem.id IN ( $memberIDs )"; * @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 0b68d13679..f0483d0284 100644 --- a/CRM/Member/Import/Controller.php +++ b/CRM/Member/Import/Controller.php @@ -56,7 +56,7 @@ class CRM_Member_Import_Controller extends CRM_Core_Controller { // 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 c2fa363f93..fe64480430 100644 --- a/CRM/Member/Import/Field.php +++ b/CRM/Member/Import/Field.php @@ -143,7 +143,7 @@ class CRM_Member_Import_Field { 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 76e56da1c1..46342000a6 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 @@ class CRM_Member_Import_Form_DataSource extends CRM_Import_Form_DataSource { $this->addGroup($duplicateOptions, 'onDuplicate', ts('Import mode') ); - $this->setDefaults(array( + $this->setDefaults([ 'onDuplicate' => CRM_Import_Parser::DUPLICATE_SKIP, - )); + ]); $this->addContactTypeSelector(); } @@ -74,12 +74,12 @@ class CRM_Member_Import_Form_DataSource extends CRM_Import_Form_DataSource { * @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 7073ebb5d2..33eba53807 100644 --- a/CRM/Member/Import/Form/Preview.php +++ b/CRM/Member/Import/Form/Preview.php @@ -87,7 +87,7 @@ class CRM_Member_Import_Form_Preview extends CRM_Import_Form_Preview { $this->set('downloadMismatchRecordsUrl', CRM_Utils_System::url('civicrm/export', $urlParams)); } - $properties = array( + $properties = [ 'mapper', 'dataValues', 'columnCount', @@ -98,7 +98,7 @@ class CRM_Member_Import_Form_Preview extends CRM_Import_Form_Preview { 'downloadErrorRecordsUrl', 'downloadConflictRecordsUrl', 'downloadMismatchRecordsUrl', - ); + ]; $this->setStatusUrl(); foreach ($properties as $property) { @@ -121,9 +121,9 @@ class CRM_Member_Import_Form_Preview extends CRM_Import_Form_Preview { $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 @@ class CRM_Member_Import_Form_Preview extends CRM_Import_Form_Preview { $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 @@ class CRM_Member_Import_Form_Preview extends CRM_Import_Form_Preview { // 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 6e87346165..f4940ff02c 100644 --- a/CRM/Member/Import/Form/Summary.php +++ b/CRM/Member/Import/Form/Summary.php @@ -93,7 +93,7 @@ class CRM_Member_Import_Form_Summary extends CRM_Import_Form_Summary { } $this->assign('dupeActionString', $dupeActionString); - $properties = array( + $properties = [ 'totalRowCount', 'validRowCount', 'invalidRowCount', @@ -105,7 +105,7 @@ class CRM_Member_Import_Form_Summary extends CRM_Import_Form_Summary { '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 b36197bbac..d8e631cc97 100644 --- a/CRM/Member/Import/Parser.php +++ b/CRM/Member/Import/Parser.php @@ -118,14 +118,14 @@ abstract class CRM_Member_Import_Parser extends CRM_Import_Parser { $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 @@ abstract class CRM_Member_Import_Parser extends CRM_Import_Parser { } 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 @@ abstract class CRM_Member_Import_Parser extends CRM_Import_Parser { * (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 @@ abstract class CRM_Member_Import_Parser extends CRM_Import_Parser { * @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 9d4a2b65da..974c4294de 100644 --- a/CRM/Member/Import/Parser/Membership.php +++ b/CRM/Member/Import/Parser/Membership.php @@ -82,7 +82,7 @@ class CRM_Member_Import_Parser_Membership extends CRM_Member_Import_Parser { $this->addField($name, $field['title'], $field['type'], $field['headerPattern'], $field['dataPattern']); } - $this->_newMemberships = array(); + $this->_newMemberships = []; $this->setActiveFields($this->_mapperKeys); @@ -289,17 +289,17 @@ class CRM_Member_Import_Parser_Membership extends CRM_Member_Import_Parser { $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 @@ class CRM_Member_Import_Parser_Membership extends CRM_Member_Import_Parser { $indieFields = $tempIndieFields; } - $formatValues = array(); + $formatValues = []; foreach ($params as $key => $field) { if ($field == NULL || $field === '') { continue; @@ -383,7 +383,7 @@ class CRM_Member_Import_Parser_Membership extends CRM_Member_Import_Parser { 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 @@ class CRM_Member_Import_Parser_Membership extends CRM_Member_Import_Parser { '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 @@ class CRM_Member_Import_Parser_Membership extends CRM_Member_Import_Parser { } 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 @@ class CRM_Member_Import_Parser_Membership extends CRM_Member_Import_Parser { * */ 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 @@ class CRM_Member_Import_Parser_Membership extends CRM_Member_Import_Parser { 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 @@ class CRM_Member_Import_Parser_Membership extends CRM_Member_Import_Parser { 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 @@ class CRM_Member_Import_Parser_Membership extends CRM_Member_Import_Parser { // 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 868db37b18..c0f177ca2c 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 @@ class CRM_Member_Info extends CRM_Core_Component_Info { * 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 @@ class CRM_Member_Info extends CRM_Core_Component_Info { * @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 @@ class CRM_Member_Info extends CRM_Core_Component_Info { * @return array|null */ public function registerTab() { - return array( + return [ 'title' => ts('Memberships'), 'url' => 'membership', 'weight' => 30, - ); + ]; } /** @@ -171,10 +171,10 @@ class CRM_Member_Info extends CRM_Core_Component_Info { * @return array|null */ public function registerAdvancedSearchPane() { - return array( + return [ 'title' => ts('Memberships'), 'weight' => 30, - ); + ]; } /** @@ -203,20 +203,20 @@ class CRM_Member_Info extends CRM_Core_Component_Info { 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 922bc80489..b309dc37f4 100644 --- a/CRM/Member/Page/AJAX.php +++ b/CRM/Member/Page/AJAX.php @@ -55,8 +55,8 @@ class CRM_Member_Page_AJAX { 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 0289d93bee..9cf8744240 100644 --- a/CRM/Member/Page/MembershipStatus.php +++ b/CRM/Member/Page/MembershipStatus.php @@ -65,30 +65,30 @@ class CRM_Member_Page_MembershipStatus extends CRM_Core_Page_Basic { */ 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 @@ class CRM_Member_Page_MembershipStatus extends CRM_Core_Page_Basic { */ 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 @@ class CRM_Member_Page_MembershipStatus extends CRM_Core_Page_Basic { $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 5024110517..96c16a60a8 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 @@ class CRM_Member_Page_MembershipType extends CRM_Core_Page { */ 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 @@ class CRM_Member_Page_MembershipType extends CRM_Core_Page { 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 @@ class CRM_Member_Page_MembershipType extends CRM_Core_Page { } $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 7567aa3694..07661c9fb7 100644 --- a/CRM/Member/Page/RecurringContributions.php +++ b/CRM/Member/Page/RecurringContributions.php @@ -54,11 +54,11 @@ class CRM_Member_Page_RecurringContributions extends CRM_Core_Page { * @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 @@ class CRM_Member_Page_RecurringContributions extends CRM_Core_Page { '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 @@ class CRM_Member_Page_RecurringContributions extends CRM_Core_Page { } 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 @@ class CRM_Member_Page_RecurringContributions extends CRM_Core_Page { $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 d646c719f6..f51fdc1325 100644 --- a/CRM/Member/Page/Tab.php +++ b/CRM/Member/Page/Tab.php @@ -56,14 +56,14 @@ class CRM_Member_Page_Tab extends CRM_Core_Page { $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 @@ class CRM_Member_Page_Tab extends CRM_Core_Page { //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 @@ class CRM_Member_Page_Tab extends CRM_Core_Page { //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 @@ class CRM_Member_Page_Tab extends CRM_Core_Page { 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 @@ class CRM_Member_Page_Tab extends CRM_Core_Page { 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 @@ class CRM_Member_Page_Tab extends CRM_Core_Page { 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 @@ class CRM_Member_Page_Tab extends CRM_Core_Page { //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 @@ class CRM_Member_Page_Tab extends CRM_Core_Page { $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 @@ class CRM_Member_Page_Tab extends CRM_Core_Page { $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 @@ class CRM_Member_Page_Tab extends CRM_Core_Page { 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 @@ class CRM_Member_Page_Tab extends CRM_Core_Page { */ 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 26d23e99b7..5240ee9d81 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 b95c78aa03..af904929f7 100644 --- a/CRM/Member/PseudoConstant.php +++ b/CRM/Member/PseudoConstant.php @@ -96,7 +96,7 @@ class CRM_Member_PseudoConstant extends CRM_Core_PseudoConstant { */ 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 0d7c3639c0..7775ecde8c 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 @@ class CRM_Member_Selector_Search extends CRM_Core_Selector_Base implements CRM_C } 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 @@ class CRM_Member_Selector_Search extends CRM_Core_Selector_Base implements CRM_C } 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 @@ class CRM_Member_Selector_Search extends CRM_Core_Selector_Base implements CRM_C ); // 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 @@ class CRM_Member_Selector_Search extends CRM_Core_Selector_Base implements CRM_C $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 @@ class CRM_Member_Selector_Search extends CRM_Core_Selector_Base implements CRM_C } $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 @@ class CRM_Member_Selector_Search extends CRM_Core_Selector_Base implements CRM_C 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 @@ class CRM_Member_Selector_Search extends CRM_Core_Selector_Base implements CRM_C */ 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 ad8bee4fd4..fe95f9dcab 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 8d2cef1297..05770d4da2 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 5e3dbf4d09..0827a26780 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 @@ class CRM_Member_Task extends CRM_Core_Task { * @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 1e22252cda..3e2dc921f8 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 @@ class CRM_Member_Tokens extends \Civi\Token\AbstractTokenSubscriber { 'end_date' => ts('Membership End Date'), 'status' => ts('Membership Status'), 'type' => ts('Membership Type'), - ), + ], CRM_Utils_Token::getCustomFieldTokens('Membership') )); } @@ -92,7 +92,7 @@ class CRM_Member_Tokens extends \Civi\Token\AbstractTokenSubscriber { 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 e2d65e1c10..2b7478d64d 100644 --- a/CRM/Note/Form/Note.php +++ b/CRM/Note/Form/Note.php @@ -94,7 +94,7 @@ class CRM_Note_Form_Note extends CRM_Core_Form { * @return void */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; if ($this->_action & CRM_Core_Action::UPDATE) { if (isset($this->_id)) { @@ -133,17 +133,17 @@ class CRM_Note_Form_Note extends CRM_Core_Form { */ 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 @@ class CRM_Note_Form_Note extends CRM_Core_Form { // 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 @@ class CRM_Note_Form_Note extends CRM_Core_Form { // 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 970ae473b5..f5674c558b 100644 --- a/CRM/PCP/BAO/PCP.php +++ b/CRM/PCP/BAO/PCP.php @@ -113,12 +113,12 @@ WHERE pcp.is_active = 1 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 @@ ORDER BY page_type, page_id"; 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 @@ ORDER BY page_type, page_id"; $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 @@ GROUP BY block.id, pcp.id 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 @@ LEFT JOIN civicrm_contribution_soft cs ON ( pcp.id = cs.pcp_id ) 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 @@ WHERE pcp.id = %1 AND cc.contribution_status_id =1 AND cc.is_test = 0"; 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 @@ WHERE pcp.id = %1 AND cc.contribution_status_id =1 AND cc.is_test = 0"; 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 @@ WHERE pcp.id = %1 AND cc.contribution_status_id =1 AND cc.is_test = 0"; * 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 @@ WHERE pcp.id = %1 AND cc.contribution_status_id =1 AND cc.is_test = 0"; $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 @@ WHERE pcp.id = %1 AND cc.contribution_status_id =1 AND cc.is_test = 0"; */ 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 @@ WHERE pcp.id = %1 AND cc.contribution_status_id =1 AND cc.is_test = 0"; 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 @@ WHERE pcp.id = %1 AND cc.contribution_status_id =1 AND cc.is_test = 0"; $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 @@ WHERE pcp.id = %1 AND cc.contribution_status_id =1 AND cc.is_test = 0"; 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 @@ WHERE pcp.id = %1 AND cc.contribution_status_id =1 AND cc.is_test = 0"; $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 @@ WHERE pcp.id = %1 AND cc.contribution_status_id =1 AND cc.is_test = 0"; "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 @@ WHERE pcp.id = %1 AND cc.contribution_status_id =1 AND cc.is_test = 0"; $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 @@ WHERE pcp.id = %1 AND cc.contribution_status_id =1 AND cc.is_test = 0"; // 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 @@ WHERE pcp.id = %1 AND cc.contribution_status_id =1 AND cc.is_test = 0"; $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 @@ WHERE pcp.id = %1 AND cc.contribution_status_id =1 AND cc.is_test = 0"; 'from' => $receiptFrom, 'toName' => $name, 'toEmail' => $address, - ) + ] ); return $sent; } @@ -735,7 +735,7 @@ WHERE pcp.id = %1 AND cc.contribution_status_id =1 AND cc.is_test = 0"; $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 @@ WHERE pcp.id = %1 AND cc.contribution_status_id =1 AND cc.is_test = 0"; $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 @@ WHERE pcp.id = %1 AND cc.contribution_status_id =1 AND cc.is_test = 0"; 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 @@ SELECT field_name 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 @@ WHERE field_name like 'email%' And is_active = 1 And uf_group_id = %1"; 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 @@ FROM civicrm_pcp pcp 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 @@ WHERE pcp.id = %1"; * @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 @@ INNER JOIN civicrm_uf_group ufgroup 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 @@ INNER JOIN civicrm_uf_group ufgroup 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 b8edaa03cf..fe2bb9880f 100644 --- a/CRM/PCP/Form/Campaign.php +++ b/CRM/PCP/Form/Campaign.php @@ -71,7 +71,7 @@ class CRM_PCP_Form_Campaign extends CRM_Core_Form { * Default values for the form. */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; $dao = new CRM_PCP_DAO_PCP(); if ($this->_pageId) { @@ -110,21 +110,21 @@ class CRM_PCP_Form_Campaign extends CRM_Core_Form { $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 @@ class CRM_PCP_Form_Campaign extends CRM_Core_Form { $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 @@ class CRM_PCP_Form_Campaign extends CRM_Core_Form { } $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 @@ class CRM_PCP_Form_Campaign extends CRM_Core_Form { * 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 @@ class CRM_PCP_Form_Campaign extends CRM_Core_Form { */ 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 @@ class CRM_PCP_Form_Campaign extends CRM_Core_Form { // 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 @@ class CRM_PCP_Form_Campaign extends CRM_Core_Form { $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 @@ class CRM_PCP_Form_Campaign extends CRM_Core_Form { 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 @@ class CRM_PCP_Form_Campaign extends CRM_Core_Form { $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 @@ class CRM_PCP_Form_Campaign extends CRM_Core_Form { } 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 a27e35ae36..4a09ff4cda 100644 --- a/CRM/PCP/Form/Contribute.php +++ b/CRM/PCP/Form/Contribute.php @@ -58,10 +58,10 @@ class CRM_PCP_Form_Contribute extends CRM_Contribute_Form_ContributionPage { * @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 @@ class CRM_PCP_Form_Contribute extends CRM_Contribute_Form_ContributionPage { $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 @@ class CRM_PCP_Form_Contribute extends CRM_Contribute_Form_ContributionPage { * 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 32b0cfd25d..0be13e2b77 100644 --- a/CRM/PCP/Form/Event.php +++ b/CRM/PCP/Form/Event.php @@ -58,12 +58,12 @@ class CRM_PCP_Form_Event extends CRM_Event_Form_ManageEvent { * @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 @@ class CRM_PCP_Form_Event extends CRM_Event_Form_ManageEvent { 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 @@ class CRM_PCP_Form_Event extends CRM_Event_Form_ManageEvent { $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 @@ class CRM_PCP_Form_Event extends CRM_Event_Form_ManageEvent { * 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 7992a24e1b..cf05504152 100644 --- a/CRM/PCP/Form/PCP.php +++ b/CRM/PCP/Form/PCP.php @@ -92,19 +92,19 @@ class CRM_PCP_Form_PCP extends CRM_Core_Form { 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 @@ class CRM_PCP_Form_PCP extends CRM_Core_Form { * 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 @@ class CRM_PCP_Form_PCP extends CRM_Core_Form { */ 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 @@ class CRM_PCP_Form_PCP extends CRM_Core_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 7607dd9106..84c9b316a1 100644 --- a/CRM/PCP/Form/PCPAccount.php +++ b/CRM/PCP/Form/PCPAccount.php @@ -107,7 +107,7 @@ class CRM_PCP_Form_PCPAccount extends CRM_Core_Form { * @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 @@ class CRM_PCP_Form_PCPAccount extends CRM_Core_Form { 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 @@ class CRM_PCP_Form_PCPAccount extends CRM_Core_Form { } 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 @@ class CRM_PCP_Form_PCPAccount extends CRM_Core_Form { * 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 @@ class CRM_PCP_Form_PCPAccount extends CRM_Core_Form { $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 @@ class CRM_PCP_Form_PCPAccount extends CRM_Core_Form { } } - $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 3a3c2b34bf..1327de5a63 100644 --- a/CRM/PCP/Page/PCPInfo.php +++ b/CRM/PCP/Page/PCPInfo.php @@ -61,7 +61,7 @@ class CRM_PCP_Page_PCPInfo extends CRM_Core_Page { $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 @@ class CRM_PCP_Page_PCPInfo extends CRM_Core_Page { $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 @@ class CRM_PCP_Page_PCPInfo extends CRM_Core_Page { } } - $default = array(); + $default = []; if ($pcpBlock->target_entity_type == 'contribute') { $urlBase = 'civicrm/contribute/transact'; @@ -135,19 +135,19 @@ class CRM_PCP_Page_PCPInfo extends CRM_Core_Page { $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 @@ class CRM_PCP_Page_PCPInfo extends CRM_Core_Page { $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 @@ class CRM_PCP_Page_PCPInfo extends CRM_Core_Page { 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 91f6a3b5ea..a1040ffe45 100644 --- a/CRM/PCP/StateMachine/PCP.php +++ b/CRM/PCP/StateMachine/PCP.php @@ -54,10 +54,10 @@ class CRM_PCP_StateMachine_PCP extends CRM_Core_StateMachine { $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 a2f7ec9ecc..ec637d58b7 100644 --- a/CRM/Pledge/BAO/PledgePayment.php +++ b/CRM/Pledge/BAO/PledgePayment.php @@ -70,10 +70,10 @@ LEFT JOIN civicrm_option_value ON ( civicrm_pledge_payment.status_id = civicrm_o 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 @@ WHERE pledge_id = %1 //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 @@ WHERE pledge_id = %1 $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 @@ WHERE pledge_id = %1 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 @@ UPDATE civicrm_pledge 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 @@ WHERE civicrm_pledge.id = %2 * 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 @@ WHERE civicrm_pledge.id = %2 } //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 @@ WHERE civicrm_pledge.id = %2 } // 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 @@ WHERE civicrm_pledge_payment.pledge_id = %1 {$paymentClause} "; - CRM_Core_DAO::executeQuery($query, array(1 => array($pledgeId, 'Integer'))); + CRM_Core_DAO::executeQuery($query, [1 => [$pledgeId, 'Integer']]); } /** @@ -741,20 +741,20 @@ ORDER BY civicrm_pledge_payment.scheduled_date ASC 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 @@ FROM civicrm_pledge_payment 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 @@ WHERE civicrm_pledge_payment.contribution_id = {$paymentContributionId} $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 @@ WHERE civicrm_pledge_payment.contribution_id = {$paymentContributionId} 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 @@ WHERE civicrm_pledge_payment.contribution_id = {$paymentContributionId} * * @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 fd0f831939..960d67c29d 100644 --- a/CRM/Pledge/BAO/Query.php +++ b/CRM/Pledge/BAO/Query.php @@ -322,7 +322,7 @@ class CRM_Pledge_BAO_Query extends CRM_Core_BAO_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 @@ class CRM_Pledge_BAO_Query extends CRM_Core_BAO_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 @@ class CRM_Pledge_BAO_Query extends CRM_Core_BAO_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 @@ class CRM_Pledge_BAO_Query extends CRM_Core_BAO_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 @@ class CRM_Pledge_BAO_Query extends CRM_Core_BAO_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 @@ class CRM_Pledge_BAO_Query extends CRM_Core_BAO_Query { $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 @@ class CRM_Pledge_BAO_Query extends CRM_Core_BAO_Query { 'pledge_frequency_unit' => 1, 'pledge_currency' => 1, 'pledge_campaign_id' => 1, - ); + ]; } return $properties; } @@ -498,7 +498,7 @@ class CRM_Pledge_BAO_Query extends CRM_Core_BAO_Query { $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 @@ class CRM_Pledge_BAO_Query extends CRM_Core_BAO_Query { '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 @@ class CRM_Pledge_BAO_Query extends CRM_Core_BAO_Query { 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 @@ class CRM_Pledge_BAO_Query extends CRM_Core_BAO_Query { 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 9cfbf05e5c..d56b4907bf 100644 --- a/CRM/Pledge/Form/Payment.php +++ b/CRM/Pledge/Form/Payment.php @@ -76,7 +76,7 @@ class CRM_Pledge_Form_Payment extends CRM_Core_Form { * 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 @@ class CRM_Pledge_Form_Payment extends CRM_Core_Form { $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 @@ class CRM_Pledge_Form_Payment extends CRM_Core_Form { } // 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 ac23c1b27c..7f4710d9a2 100644 --- a/CRM/Pledge/Form/Pledge.php +++ b/CRM/Pledge/Form/Pledge.php @@ -100,14 +100,14 @@ class CRM_Pledge_Form_Pledge extends CRM_Core_Form { // 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 @@ class CRM_Pledge_Form_Pledge extends CRM_Core_Form { */ 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 @@ class CRM_Pledge_Form_Pledge extends CRM_Core_Form { $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 @@ class CRM_Pledge_Form_Pledge extends CRM_Core_Form { $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 @@ class CRM_Pledge_Form_Pledge extends CRM_Core_Form { ) { $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 @@ class CRM_Pledge_Form_Pledge extends CRM_Core_Form { $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 @@ class CRM_Pledge_Form_Pledge extends CRM_Core_Form { // 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 @@ class CRM_Pledge_Form_Pledge extends CRM_Core_Form { * 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 @@ class CRM_Pledge_Form_Pledge extends CRM_Core_Form { $session = CRM_Core_Session::singleton(); - $fields = array( + $fields = [ 'frequency_unit', 'frequency_interval', 'frequency_day', @@ -457,7 +457,7 @@ class CRM_Pledge_Form_Pledge extends CRM_Core_Form { 'additional_reminder_day', 'contribution_page_id', 'campaign_id', - ); + ]; foreach ($fields as $f) { $params[$f] = CRM_Utils_Array::value($f, $formValues); } @@ -467,7 +467,7 @@ class CRM_Pledge_Form_Pledge extends CRM_Core_Form { $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 @@ class CRM_Pledge_Form_Pledge extends CRM_Core_Form { ) = 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 @@ class CRM_Pledge_Form_Pledge extends CRM_Core_Form { "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 8c98b88190..3120a7488d 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 @@ class CRM_Pledge_Form_PledgeView extends CRM_Core_Form { "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 @@ class CRM_Pledge_Form_PledgeView extends CRM_Core_Form { * 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 0073fabcf5..3f9bb872ef 100644 --- a/CRM/Pledge/Form/Search.php +++ b/CRM/Pledge/Form/Search.php @@ -231,7 +231,7 @@ class CRM_Pledge_Form_Search extends CRM_Core_Form_Search { $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 @@ class CRM_Pledge_Form_Search extends CRM_Core_Form_Search { * @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 @@ class CRM_Pledge_Form_Search extends CRM_Core_Form_Search { * the default array reference */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; $defaults = $this->_formValues; return $defaults; } @@ -334,8 +334,8 @@ class CRM_Pledge_Form_Search extends CRM_Core_Form_Search { // 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 @@ class CRM_Pledge_Form_Search extends CRM_Core_Form_Search { // 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 18a910c998..c6716dff0d 100644 --- a/CRM/Pledge/Form/Task.php +++ b/CRM/Pledge/Form/Task.php @@ -57,7 +57,7 @@ class CRM_Pledge_Form_Task extends CRM_Core_Form_Task { * @param CRM_Core_Form $form */ public static function preProcessCommon(&$form) { - $form->_pledgeIds = array(); + $form->_pledgeIds = []; $values = $form->controller->exportValues('Search'); @@ -65,7 +65,7 @@ class CRM_Pledge_Form_Task extends CRM_Core_Form_Task { $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 @@ class CRM_Pledge_Form_Task extends CRM_Core_Form_Task { * @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 d3c4c7fc94..deb28e3e39 100644 --- a/CRM/Pledge/Form/Task/Delete.php +++ b/CRM/Pledge/Form/Task/Delete.php @@ -79,12 +79,12 @@ class CRM_Pledge_Form_Task_Delete extends CRM_Pledge_Form_Task { } 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 aedbacc1df..3b5cb4357f 100644 --- a/CRM/Pledge/Form/Task/Print.php +++ b/CRM/Pledge/Form/Task/Print.php @@ -69,18 +69,18 @@ class CRM_Pledge_Form_Task_Print extends CRM_Pledge_Form_Task { */ 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 5301b1bbda..4a4994bfa0 100644 --- a/CRM/Pledge/Form/Task/Result.php +++ b/CRM/Pledge/Form/Task/Result.php @@ -46,13 +46,13 @@ class CRM_Pledge_Form_Task_Result extends CRM_Pledge_Form_Task { * 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 5cc27c7e83..255a0e4b3a 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 @@ INNER JOIN civicrm_contact ct ON ( plg.contact_id = ct.id ) $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 @@ INNER JOIN civicrm_contact ct ON ( plg.contact_id = ct.id ) * 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 169b67b485..d920df827e 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 @@ class CRM_Pledge_Info extends CRM_Core_Component_Info { * 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 @@ class CRM_Pledge_Info extends CRM_Core_Component_Info { * 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 @@ class CRM_Pledge_Info extends CRM_Core_Component_Info { * null if no element offered */ public function registerTab() { - return array( + return [ 'title' => ts('Pledges'), 'url' => 'pledge', 'weight' => 25, - ); + ]; } /** @@ -154,10 +154,10 @@ class CRM_Pledge_Info extends CRM_Core_Component_Info { * null if no element offered */ public function registerAdvancedSearchPane() { - return array( + return [ 'title' => ts('Pledges'), 'weight' => 25, - ); + ]; } /** @@ -182,14 +182,14 @@ class CRM_Pledge_Info extends CRM_Core_Component_Info { 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 d2a95d617e..fc3532cc57 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 2c78ca9f3a..c488e86d46 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 @@ class CRM_Pledge_Page_DashBoard extends CRM_Core_Page { // 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 6feb99e246..3c44c2344b 100644 --- a/CRM/Pledge/Page/Tab.php +++ b/CRM/Pledge/Page/Tab.php @@ -52,10 +52,10 @@ class CRM_Pledge_Page_Tab extends CRM_Core_Page { $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 7b3e151c8e..82a091391d 100644 --- a/CRM/Pledge/Page/UserDashboard.php +++ b/CRM/Pledge/Page/UserDashboard.php @@ -52,7 +52,7 @@ class CRM_Pledge_Page_UserDashboard extends CRM_Contact_Page_View_UserDashBoard $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 f7548ed4d7..5c87aae324 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 @@ class CRM_Pledge_Selector_Search extends CRM_Core_Selector_Base { $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 @@ class CRM_Pledge_Selector_Search extends CRM_Core_Selector_Base { ); // 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 @@ class CRM_Pledge_Selector_Search extends CRM_Core_Selector_Base { $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 @@ class CRM_Pledge_Selector_Search extends CRM_Core_Selector_Base { $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 @@ class CRM_Pledge_Selector_Search extends CRM_Core_Selector_Base { $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 @@ class CRM_Pledge_Selector_Search extends CRM_Core_Selector_Base { $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 @@ class CRM_Pledge_Selector_Search extends CRM_Core_Selector_Base { */ 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 3be9a36a75..1bf31c5c09 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 92001631ca..7becb5a000 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 @@ class CRM_Pledge_Task extends CRM_Core_Task { * @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 b54bd5b775..55af3bcca8 100644 --- a/CRM/Price/BAO/LineItem.php +++ b/CRM/Price/BAO/LineItem.php @@ -85,10 +85,10 @@ class CRM_Price_BAO_LineItem extends CRM_Price_DAO_LineItem { $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 @@ class CRM_Price_BAO_LineItem extends CRM_Price_DAO_LineItem { 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 @@ class CRM_Price_BAO_LineItem extends CRM_Price_DAO_LineItem { $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 @@ class CRM_Price_BAO_LineItem extends CRM_Price_DAO_LineItem { $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 @@ WHERE li.contribution_id = %1"; $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 @@ WHERE li.contribution_id = %1"; 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 @@ WHERE li.contribution_id = %1"; '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 @@ WHERE li.contribution_id = %1"; //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 @@ WHERE li.contribution_id = %1"; $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 @@ WHERE li.contribution_id = %1"; '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 @@ WHERE li.contribution_id = %1"; } 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 @@ WHERE li.contribution_id = %1"; $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 @@ WHERE li.contribution_id = %1"; $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 @@ WHERE li.contribution_id = %1"; 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 @@ WHERE li.contribution_id = %1"; } $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 @@ WHERE li.contribution_id = %1"; 'line_total' => $totalAmount, 'financial_type_id' => $financialType, 'membership_type_id' => $values['membership_type_id'], - ); + ]; break; } } @@ -629,7 +629,7 @@ WHERE li.contribution_id = %1"; * */ 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 @@ WHERE li.contribution_id = %1"; // 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 @@ WHERE li.contribution_id = %1"; $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 @@ WHERE li.contribution_id = %1"; // 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 @@ WHERE li.contribution_id = %1"; 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 @@ WHERE li.contribution_id = %1"; * 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 @@ WHERE li.contribution_id = %1"; $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 @@ WHERE li.contribution_id = %1"; // 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 @@ WHERE li.contribution_id = %1"; } 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 @@ WHERE li.contribution_id = %1"; $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 @@ WHERE li.contribution_id = %1"; $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 @@ WHERE li.contribution_id = %1"; $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 @@ WHERE li.contribution_id = %1"; */ 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 @@ WHERE li.contribution_id = %1"; $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 @@ WHERE li.contribution_id = %1"; '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 @@ WHERE li.contribution_id = %1"; // 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 @@ WHERE li.contribution_id = %1"; // 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 @@ WHERE li.contribution_id = %1"; $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 a357260090..f6bb649921 100644 --- a/CRM/Price/BAO/PriceField.php +++ b/CRM/Price/BAO/PriceField.php @@ -100,14 +100,14 @@ class CRM_Price_BAO_PriceField extends CRM_Price_DAO_PriceField { 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 @@ class CRM_Price_BAO_PriceField extends CRM_Price_DAO_PriceField { } } } - $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 @@ class CRM_Price_BAO_PriceField extends CRM_Price_DAO_PriceField { (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 @@ class CRM_Price_BAO_PriceField extends CRM_Price_DAO_PriceField { '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 @@ class CRM_Price_BAO_PriceField extends CRM_Price_DAO_PriceField { } } 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 @@ class CRM_Price_BAO_PriceField extends CRM_Price_DAO_PriceField { $useRequired = TRUE, $label = NULL, $fieldOptions = NULL, - $freezeOptions = array() + $freezeOptions = [] ) { $field = new CRM_Price_DAO_PriceField(); @@ -348,13 +348,13 @@ class CRM_Price_BAO_PriceField extends CRM_Price_DAO_PriceField { $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 @@ class CRM_Price_BAO_PriceField extends CRM_Price_DAO_PriceField { 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 @@ class CRM_Price_BAO_PriceField extends CRM_Price_DAO_PriceField { $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 @@ class CRM_Price_BAO_PriceField extends CRM_Price_DAO_PriceField { break; case 'Radio': - $choice = array(); + $choice = []; if (!empty($qf->_quickConfig) && !empty($qf->_contributionAmount)) { $qf->assign('contriPriceset', $elementName); @@ -439,34 +439,34 @@ class CRM_Price_BAO_PriceField extends CRM_Price_DAO_PriceField { } $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 @@ class CRM_Price_BAO_PriceField extends CRM_Price_DAO_PriceField { } 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 @@ class CRM_Price_BAO_PriceField extends CRM_Price_DAO_PriceField { } $choice[] = $qf->createElement('radio', NULL, '', $none, '0', - array('price' => json_encode(array($elementName, '0'))) + ['price' => json_encode([$elementName, '0'])] ); } @@ -513,12 +513,12 @@ class CRM_Price_BAO_PriceField extends CRM_Price_DAO_PriceField { } 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 @@ class CRM_Price_BAO_PriceField extends CRM_Price_DAO_PriceField { } } - $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 @@ class CRM_Price_BAO_PriceField extends CRM_Price_DAO_PriceField { $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 @@ class CRM_Price_BAO_PriceField extends CRM_Price_DAO_PriceField { $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 @@ class CRM_Price_BAO_PriceField extends CRM_Price_DAO_PriceField { 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 @@ class CRM_Price_BAO_PriceField extends CRM_Price_DAO_PriceField { } $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 @@ class CRM_Price_BAO_PriceField extends CRM_Price_DAO_PriceField { } $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 @@ class CRM_Price_BAO_PriceField extends CRM_Price_DAO_PriceField { */ 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 @@ WHERE 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 @@ WHERE 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 @@ WHERE 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 @@ WHERE $priceField->price_set_id = $priceSetId; $priceField->find(); - $priceFields = array(); + $priceFields = []; if ($allowNoneSelection) { - $noneSelectedPriceFields = array(); + $noneSelectedPriceFields = []; } while ($priceField->fetch()) { @@ -802,15 +802,15 @@ SELECT id, html_type 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 @@ WHERE id IN (" . implode(',', array_keys($priceFields)) . ')'; // 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 @@ WHERE id IN (" . implode(',', array_keys($priceFields)) . ')'; 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 0aed6a2dbe..071d879aa3 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 @@ class CRM_Price_BAO_PriceFieldValue extends CRM_Price_DAO_PriceFieldValue { } 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 @@ class CRM_Price_BAO_PriceFieldValue extends CRM_Price_DAO_PriceFieldValue { * * @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 @@ class CRM_Price_BAO_PriceFieldValue extends CRM_Price_DAO_PriceFieldValue { 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 @@ class CRM_Price_BAO_PriceFieldValue extends CRM_Price_DAO_PriceFieldValue { * @return array */ public static function getDefaults() { - return array( + return [ 'is_active' => 1, 'weight' => 1, - ); + ]; } @@ -283,11 +283,11 @@ class CRM_Price_BAO_PriceFieldValue extends CRM_Price_DAO_PriceFieldValue { 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 @@ WHERE cpse.id IS NOT NULL {$where}"; 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 1cb42be5f1..cd2908f7b6 100644 --- a/CRM/Price/BAO/PriceSet.php +++ b/CRM/Price/BAO/PriceSet.php @@ -140,9 +140,9 @@ WHERE ps.name = '{$entityName}' "; $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 @@ WHERE ps.name = '{$entityName}' '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 @@ WHERE ps.name = '{$entityName}' * @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 @@ SELECT cli.entity_table, cli.entity_id 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 @@ WHERE cpf.price_set_id = %1"; 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 @@ WHERE cpf.price_set_id = %1"; $query .= ' AND s.domain_id = ' . CRM_Core_Config::domainID(); } - $priceSets = array(); + $priceSets = []; if ($extendComponentName) { $componentId = CRM_Core_Component::getComponentID($extendComponentName); @@ -434,9 +434,9 @@ WHERE cpf.price_set_id = %1"; */ 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 @@ WHERE cpf.price_set_id = %1"; 'javascript', 'visibility_id', 'is_required', - ); + ]; if ($required == TRUE) { $priceFields[] = 'is_required'; } @@ -462,9 +462,9 @@ WHERE cpf.price_set_id = %1"; $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 @@ AND ( expire_on IS NULL OR expire_on >= {$currentTime} ) 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 @@ WHERE id = %1"; //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 @@ WHERE id = %1"; //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 @@ WHERE id = %1"; $amount_override = NULL; if ($component) { - $autoRenew = array(); + $autoRenew = []; $autoRenew[0] = $autoRenew[1] = $autoRenew[2] = 0; } if ($priceSetID) { @@ -716,7 +716,7 @@ WHERE id = %1"; 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 @@ WHERE id = %1"; 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 @@ WHERE id = %1"; 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 @@ WHERE id = %1"; } } - $amount_level = array(); + $amount_level = []; $totalParticipant = 0; if (is_array($lineItem)) { foreach ($lineItem as $values) { @@ -869,7 +869,7 @@ WHERE id = %1"; $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 @@ WHERE id = %1"; */ 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 @@ WHERE id = %1"; $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 @@ WHERE id = %1"; // 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 @@ WHERE id = %1"; } } - $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 @@ WHERE id = %1"; 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 @@ WHERE id = %1"; */ 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 @@ WHERE id = %1"; //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 @@ WHERE id = %1"; $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 @@ INNER JOIN civicrm_price_set pset ON ( pset.id = field.price_set_id ) 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 @@ WHERE pfv.id IN ( $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 @@ GROUP BY mt.member_of_contact_id "; 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 @@ GROUP BY mt.member_of_contact_id "; } $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 @@ GROUP BY mt.member_of_contact_id "; 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 @@ LEFT JOIN civicrm_membership_type mt ON mt.id = pfv.membership_type_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 @@ WHERE ps.id = %1 } 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 @@ WHERE ps.id = %1 CRM_Core_DAO::copyGeneric( 'CRM_Core_DAO_Discount', - array( + [ 'id' => $discountId, - ), - array( + ], + [ 'entity_id' => $newId, 'price_set_id' => $copyPriceSet->id, - ) + ] ); } } @@ -1640,7 +1640,7 @@ WHERE ps.id = %1 */ 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 @@ WHERE ps.id = %1 * 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 @@ WHERE ps.id = %1 * ) */ 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 @@ WHERE price_set_id = %1"; * @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 2f690fe847..23c5dbda70 100644 --- a/CRM/Price/Form/DeleteField.php +++ b/CRM/Price/Form/DeleteField.php @@ -77,17 +77,17 @@ class CRM_Price_Form_DeleteField extends CRM_Core_Form { * @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 @@ class CRM_Price_Form_DeleteField extends CRM_Core_Form { */ 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 278cc47a70..a9045f3da3 100644 --- a/CRM/Price/Form/DeleteSet.php +++ b/CRM/Price/Form/DeleteSet.php @@ -70,17 +70,17 @@ class CRM_Price_Form_DeleteSet extends CRM_Core_Form { */ 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 @@ class CRM_Price_Form_DeleteSet extends CRM_Core_Form { 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 2dbc229fe7..3888e781e8 100644 --- a/CRM/Price/Form/Field.php +++ b/CRM/Price/Form/Field.php @@ -75,9 +75,9 @@ class CRM_Price_Form_Field extends CRM_Core_Form { $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 @@ class CRM_Price_Form_Field extends CRM_Core_Form { * 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 @@ class CRM_Price_Form_Field extends CRM_Core_Form { // 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 @@ class CRM_Price_Form_Field extends CRM_Core_Form { } 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 @@ class CRM_Price_Form_Field extends CRM_Core_Form { $this->add('select', 'financial_type_id', ts('Financial Type'), - array(' ' => ts('- select -')) + $financialType + [' ' => ts('- select -')] + $financialType ); $this->assign('useForMember', FALSE); @@ -267,7 +267,7 @@ class CRM_Price_Form_Field extends CRM_Core_Form { '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 @@ class CRM_Price_Form_Field extends CRM_Core_Form { } 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 @@ class CRM_Price_Form_Field extends CRM_Core_Form { 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 @@ class CRM_Price_Form_Field extends CRM_Core_Form { $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 @@ class CRM_Price_Form_Field extends CRM_Core_Form { $this->addElement('button', 'done', ts('Done'), - array('onclick' => "location.href='$url'") + ['onclick' => "location.href='$url'"] ); } } @@ -389,7 +389,7 @@ class CRM_Price_Form_Field extends CRM_Core_Form { 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 @@ class CRM_Price_Form_Field extends CRM_Core_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 @@ class CRM_Price_Form_Field extends CRM_Core_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 @@ class CRM_Price_Form_Field extends CRM_Core_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 @@ class CRM_Price_Form_Field extends CRM_Core_Form { $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 @@ class CRM_Price_Form_Field extends CRM_Core_Form { $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 @@ class CRM_Price_Form_Field extends CRM_Core_Form { $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 d83eb9d2f3..f159c37bdc 100644 --- a/CRM/Price/Form/Option.php +++ b/CRM/Price/Form/Option.php @@ -84,10 +84,10 @@ class CRM_Price_Form_Option extends CRM_Core_Form { 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 @@ class CRM_Price_Form_Option extends CRM_Core_Form { $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 @@ class CRM_Price_Form_Option extends CRM_Core_Form { } } 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 @@ class CRM_Price_Form_Option extends CRM_Core_Form { 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 @@ class CRM_Price_Form_Option extends CRM_Core_Form { 'select', 'financial_type_id', ts('Financial Type'), - array('' => ts('- select -')) + $financialType, + ['' => ts('- select -')] + $financialType, TRUE ); @@ -253,31 +253,31 @@ class CRM_Price_Form_Option extends CRM_Core_Form { } } // 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 @@ class CRM_Price_Form_Option extends CRM_Core_Form { * 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 @@ class CRM_Price_Form_Option extends CRM_Core_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 @@ class CRM_Price_Form_Option extends CRM_Core_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 @@ class CRM_Price_Form_Option extends CRM_Core_Form { ); 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 @@ class CRM_Price_Form_Option extends CRM_Core_Form { $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 ce97044bfa..4d3cad25e5 100644 --- a/CRM/Price/Form/Preview.php +++ b/CRM/Price/Form/Preview.php @@ -67,12 +67,12 @@ class CRM_Price_Form_Preview extends CRM_Core_Form { $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 @@ class CRM_Price_Form_Preview extends CRM_Core_Form { $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 @@ class CRM_Price_Form_Preview extends CRM_Core_Form { * 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 @@ class CRM_Price_Form_Preview extends CRM_Core_Form { } } - $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 03cd7f385e..1f49fa4e04 100644 --- a/CRM/Price/Form/Set.php +++ b/CRM/Price/Form/Set.php @@ -119,20 +119,20 @@ class CRM_Price_Form_Set extends CRM_Core_Form { $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 @@ class CRM_Price_Form_Set extends CRM_Core_Form { * 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 @@ class CRM_Price_Form_Set extends CRM_Core_Form { $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 @@ class CRM_Price_Form_Set extends CRM_Core_Form { 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 @@ class CRM_Price_Form_Set extends CRM_Core_Form { 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 @@ class CRM_Price_Form_Set extends CRM_Core_Form { 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 @@ class CRM_Price_Form_Set extends CRM_Core_Form { $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 @@ class CRM_Price_Form_Set extends CRM_Core_Form { * 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 @@ class CRM_Price_Form_Set extends CRM_Core_Form { $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 @@ class CRM_Price_Form_Set extends CRM_Core_Form { $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 3a13ffb547..47e1cb1c93 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 @@ class CRM_Price_Page_Field extends CRM_Core_Page { $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 @@ class CRM_Price_Page_Field extends CRM_Core_Page { $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 @@ class CRM_Price_Page_Field extends CRM_Core_Page { $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 @@ class CRM_Price_Page_Field extends CRM_Core_Page { $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 @@ class CRM_Price_Page_Field extends CRM_Core_Page { $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 44acb2bcd5..a8ec96fb8d 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 @@ class CRM_Price_Page_Option extends CRM_Core_Page { * @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 @@ class CRM_Price_Page_Option extends CRM_Core_Page { } $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 @@ class CRM_Price_Page_Option extends CRM_Core_Page { $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 @@ class CRM_Price_Page_Option extends CRM_Core_Page { ); $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 @@ class CRM_Price_Page_Option extends CRM_Core_Page { $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 88ff0aa1d6..accc307829 100644 --- a/CRM/Price/Page/Set.php +++ b/CRM/Price/Page/Set.php @@ -62,50 +62,50 @@ class CRM_Price_Page_Set extends CRM_Core_Page { // 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 @@ class CRM_Price_Page_Set extends CRM_Core_Page { $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 @@ class CRM_Price_Page_Set extends CRM_Core_Page { */ 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 @@ class CRM_Price_Page_Set extends CRM_Core_Page { $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 @@ class CRM_Price_Page_Set extends CRM_Core_Page { $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 ac050c485d..647e86ae9c 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 @@ class CRM_Profile_Form extends CRM_Core_Form { } 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 @@ class CRM_Profile_Form extends CRM_Core_Form { $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 @@ class CRM_Profile_Form extends CRM_Core_Form { && ($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 @@ class CRM_Profile_Form extends CRM_Core_Form { 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 @@ class CRM_Profile_Form extends CRM_Core_Form { } 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 @@ class CRM_Profile_Form extends CRM_Core_Form { * */ public function setDefaultsValues() { - $this->_defaults = array(); + $this->_defaults = []; if ($this->_multiRecordProfile && ($this->_multiRecord == CRM_Core_Action::DELETE)) { return; } @@ -535,7 +535,7 @@ class CRM_Profile_Form extends CRM_Core_Form { 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 @@ class CRM_Profile_Form extends CRM_Core_Form { $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 @@ class CRM_Profile_Form extends CRM_Core_Form { 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 @@ class CRM_Profile_Form extends CRM_Core_Form { $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 @@ class CRM_Profile_Form extends CRM_Core_Form { if ( in_array( $profileType, - array("Membership", "Participant", "Contribution") + ["Membership", "Participant", "Contribution"] ) ) { $return = TRUE; @@ -825,7 +825,7 @@ class CRM_Profile_Form extends CRM_Core_Form { } $this->assign('anonUser', $anonUser); - $addCaptcha = array(); + $addCaptcha = []; $emailPresent = FALSE; // add the form elements @@ -939,14 +939,14 @@ class CRM_Profile_Form extends CRM_Core_Form { * @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 @@ class CRM_Profile_Form extends CRM_Core_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 @@ class CRM_Profile_Form extends CRM_Core_Form { 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 @@ class CRM_Profile_Form extends CRM_Core_Form { 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 @@ class CRM_Profile_Form extends CRM_Core_Form { //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 @@ class CRM_Profile_Form extends CRM_Core_Form { } //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 @@ class CRM_Profile_Form extends CRM_Core_Form { ) { 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 @@ class CRM_Profile_Form extends CRM_Core_Form { $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 @@ class CRM_Profile_Form extends CRM_Core_Form { 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 1ecb44a34f..c1e6c50ac5 100644 --- a/CRM/Profile/Form/Dynamic.php +++ b/CRM/Profile/Form/Dynamic.php @@ -71,19 +71,19 @@ class CRM_Profile_Form_Dynamic extends CRM_Profile_Form { * */ 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 @@ class CRM_Profile_Form_Dynamic extends CRM_Profile_Form { * 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 2e54add702..c5d493bacf 100644 --- a/CRM/Profile/Form/Edit.php +++ b/CRM/Profile/Form/Edit.php @@ -128,7 +128,7 @@ SELECT module,is_reserved 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 @@ SELECT module,is_reserved //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 @@ SELECT module,is_reserved $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 @@ SELECT module,is_reserved // 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 @@ SELECT module,is_reserved } 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 ad8a63da5b..c674f74280 100644 --- a/CRM/Profile/Form/Search.php +++ b/CRM/Profile/Form/Search.php @@ -55,7 +55,7 @@ class CRM_Profile_Form_Search extends CRM_Profile_Form { * 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 @@ class CRM_Profile_Form_Search extends CRM_Profile_Form { 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 @@ class CRM_Profile_Form_Search extends CRM_Profile_Form { } 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 @@ class CRM_Profile_Form_Search extends CRM_Profile_Form { 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 4b265f89ed..a373d15147 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 @@ class CRM_Profile_Page_Dynamic extends CRM_Core_Page { $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 @@ class CRM_Profile_Page_Dynamic extends CRM_Core_Page { $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 @@ class CRM_Profile_Page_Dynamic extends CRM_Core_Page { } 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 @@ class CRM_Profile_Page_Dynamic extends CRM_Core_Page { $activityFields, $values, TRUE, - array(array('activity_id', '=', $this->_activityId, 0, 0)) + [['activity_id', '=', $this->_activityId, 0, 0]] ); } } @@ -311,8 +311,8 @@ class CRM_Profile_Page_Dynamic extends CRM_Core_Page { } // $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 @@ class CRM_Profile_Page_Dynamic extends CRM_Core_Page { } 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 @@ class CRM_Profile_Page_Dynamic extends CRM_Core_Page { 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 @@ class CRM_Profile_Page_Dynamic extends CRM_Core_Page { $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 0b5329cd7b..d5e3c4a116 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 @@ class CRM_Profile_Page_Listings extends CRM_Core_Page { ); $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 @@ class CRM_Profile_Page_Listings extends CRM_Core_Page { '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 @@ class CRM_Profile_Page_Listings extends CRM_Core_Page { 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 @@ class CRM_Profile_Page_Listings extends CRM_Core_Page { 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 @@ class CRM_Profile_Page_Listings extends CRM_Core_Page { // set the prox params // need to ensure proximity searching is enabled - $proximityVars = array( + $proximityVars = [ 'street_address', 'city', 'postal_code', @@ -266,7 +266,7 @@ class CRM_Profile_Page_Listings extends CRM_Core_Page { 'country_id', 'distance', 'distance_unit', - ); + ]; foreach ($proximityVars as $var) { $value = CRM_Utils_Request::retrieve("prox_{$var}", 'String', @@ -416,8 +416,8 @@ class CRM_Profile_Page_Listings extends CRM_Core_Page { $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 @@ class CRM_Profile_Page_Listings extends CRM_Core_Page { $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 8b04c94629..6d50d65b20 100644 --- a/CRM/Profile/Page/MultipleRecordFieldsListing.php +++ b/CRM/Profile/Page/MultipleRecordFieldsListing.php @@ -71,27 +71,27 @@ class CRM_Profile_Page_MultipleRecordFieldsListing extends CRM_Core_Page_Basic { 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 @@ class CRM_Profile_Page_MultipleRecordFieldsListing extends CRM_Core_Page_Basic { // 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 @@ class CRM_Profile_Page_MultipleRecordFieldsListing extends CRM_Core_Page_Basic { 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 @@ class CRM_Profile_Page_MultipleRecordFieldsListing extends CRM_Core_Page_Basic { 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 @@ class CRM_Profile_Page_MultipleRecordFieldsListing extends CRM_Core_Page_Basic { $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 @@ class CRM_Profile_Page_MultipleRecordFieldsListing extends CRM_Core_Page_Basic { '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 @@ class CRM_Profile_Page_MultipleRecordFieldsListing extends CRM_Core_Page_Basic { // 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 @@ class CRM_Profile_Page_MultipleRecordFieldsListing extends CRM_Core_Page_Basic { $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 @@ class CRM_Profile_Page_MultipleRecordFieldsListing extends CRM_Core_Page_Basic { // 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 @@ class CRM_Profile_Page_MultipleRecordFieldsListing extends CRM_Core_Page_Basic { 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 @@ class CRM_Profile_Page_MultipleRecordFieldsListing extends CRM_Core_Page_Basic { $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 @@ class CRM_Profile_Page_MultipleRecordFieldsListing extends CRM_Core_Page_Basic { $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 @@ class CRM_Profile_Page_MultipleRecordFieldsListing extends CRM_Core_Page_Basic { } } - $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 @@ class CRM_Profile_Page_MultipleRecordFieldsListing extends CRM_Core_Page_Basic { $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 194afdd5a2..6687395379 100644 --- a/CRM/Profile/Page/Router.php +++ b/CRM/Profile/Page/Router.php @@ -111,10 +111,10 @@ class CRM_Profile_Page_Router extends CRM_Core_Page { $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 772969bf77..593d656d41 100644 --- a/CRM/Profile/Page/View.php +++ b/CRM/Profile/Page/View.php @@ -72,7 +72,7 @@ class CRM_Profile_Page_View extends CRM_Core_Page { $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 @@ class CRM_Profile_Page_View extends CRM_Core_Page { $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 @@ class CRM_Profile_Page_View extends CRM_Core_Page { 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 4ef71b1311..4d5a2034de 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 @@ class CRM_Profile_Selector_Listings extends CRM_Core_Selector_Base implements CR $this->_gid = $ufGroupIds[0]; } else { - $this->_profileIds = array($ufGroupIds); + $this->_profileIds = [$ufGroupIds]; $this->_gid = $ufGroupIds; } @@ -172,7 +172,7 @@ class CRM_Profile_Selector_Listings extends CRM_Core_Selector_Base implements CR $this->_params['group'][$groupId] = 1; } else { - $this->_params['group'] = array($groupId => 1); + $this->_params['group'] = [$groupId => 1]; } } @@ -211,7 +211,7 @@ class CRM_Profile_Selector_Listings extends CRM_Core_Selector_Base implements CR */ 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 @@ class CRM_Profile_Selector_Listings extends CRM_Core_Selector_Base implements CR } 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 @@ class CRM_Profile_Selector_Listings extends CRM_Core_Selector_Base implements CR * 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 @@ class CRM_Profile_Selector_Listings extends CRM_Core_Selector_Base implements CR $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 @@ class CRM_Profile_Selector_Listings extends CRM_Core_Selector_Base implements CR } } - 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 @@ class CRM_Profile_Selector_Listings extends CRM_Core_Selector_Base implements CR // 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 @@ class CRM_Profile_Selector_Listings extends CRM_Core_Selector_Base implements CR */ 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 @@ class CRM_Profile_Selector_Listings extends CRM_Core_Selector_Base implements CR } // process the result of the query - $rows = array(); + $rows = []; // check if edit is configured in profile settings if ($this->_gid) { @@ -502,7 +502,7 @@ class CRM_Profile_Selector_Listings extends CRM_Core_Selector_Base implements CR } //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 @@ class CRM_Profile_Selector_Listings extends CRM_Core_Selector_Base implements CR $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 @@ class CRM_Profile_Selector_Listings extends CRM_Core_Selector_Base implements CR 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 @@ class CRM_Profile_Selector_Listings extends CRM_Core_Selector_Base implements CR } } - $multipleSelectFields = array('preferred_communication_method' => 1); + $multipleSelectFields = ['preferred_communication_method' => 1]; $multiRecordTableId = NULL; if ($this->_multiRecordTableName) { $multiRecordTableId = "{$this->_multiRecordTableName}_id"; @@ -593,7 +593,7 @@ class CRM_Profile_Selector_Listings extends CRM_Core_Selector_Base implements CR $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 @@ class CRM_Profile_Selector_Listings extends CRM_Core_Selector_Base implements CR 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 @@ class CRM_Profile_Selector_Listings extends CRM_Core_Selector_Base implements CR $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 @@ class CRM_Profile_Selector_Listings extends CRM_Core_Selector_Base implements CR } $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 fc8a08195b..f87c5df773 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 @@ class CRM_Queue_ErrorPolicy { */ 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 @@ class CRM_Queue_ErrorPolicy { 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 @@ class CRM_Queue_ErrorPolicy { * 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 @@ class CRM_Queue_ErrorPolicy { 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 684313e50a..43671437fa 100644 --- a/CRM/Queue/Menu.php +++ b/CRM/Queue/Menu.php @@ -56,31 +56,31 @@ class CRM_Queue_Menu { $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 20d3893182..eeffd9fc6e 100644 --- a/CRM/Queue/Page/Runner.php +++ b/CRM/Queue/Page/Runner.php @@ -56,7 +56,7 @@ class CRM_Queue_Page_Runner extends CRM_Core_Page { } 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 @@ class CRM_Queue_Page_Runner extends CRM_Core_Page { '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 f9266a7e2b..d8c7df0848 100644 --- a/CRM/Queue/Queue.php +++ b/CRM/Queue/Queue.php @@ -99,7 +99,7 @@ abstract class CRM_Queue_Queue { * 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 886638dc0b..0c840c1c36 100644 --- a/CRM/Queue/Queue/Memory.php +++ b/CRM/Queue/Queue/Memory.php @@ -66,8 +66,8 @@ class CRM_Queue_Queue_Memory extends CRM_Queue_Queue { * 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 @@ class CRM_Queue_Queue_Memory extends CRM_Queue_Queue { * 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 056d2062f4..6be0e23aa2 100644 --- a/CRM/Queue/Queue/Sql.php +++ b/CRM/Queue/Queue/Sql.php @@ -69,9 +69,9 @@ class CRM_Queue_Queue_Sql extends CRM_Queue_Queue { 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 @@ class CRM_Queue_Queue_Sql extends CRM_Queue_Queue { * 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 @@ class CRM_Queue_Queue_Sql extends CRM_Queue_Queue { SELECT count(*) FROM civicrm_queue_item WHERE queue_name = %1 - ", array( - 1 => array($this->getName(), 'String'), - )); + ", [ + 1 => [$this->getName(), 'String'], + ]); } /** @@ -133,9 +133,9 @@ class CRM_Queue_Queue_Sql extends CRM_Queue_Queue { 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 @@ class CRM_Queue_Queue_Sql extends CRM_Queue_Queue { 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 @@ class CRM_Queue_Queue_Sql extends CRM_Queue_Queue { 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 @@ class CRM_Queue_Queue_Sql extends CRM_Queue_Queue { */ 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 3015e36336..837a77f8d8 100644 --- a/CRM/Queue/Runner.php +++ b/CRM/Queue/Runner.php @@ -112,7 +112,7 @@ class CRM_Queue_Runner { $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 @@ class CRM_Queue_Runner { */ public function __sleep() { // exclude taskCtx - return array( + return [ 'title', 'queue', 'errorMode', @@ -132,7 +132,7 @@ class CRM_Queue_Runner { 'pathPrefix', 'qrid', 'buttons', - ); + ]; } /** @@ -300,7 +300,7 @@ class CRM_Queue_Runner { } // 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 @@ class CRM_Queue_Runner { 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 d49c64f854..abb0738f85 100644 --- a/CRM/Queue/Service.php +++ b/CRM/Queue/Service.php @@ -77,7 +77,7 @@ class CRM_Queue_Service { /** */ public function __construct() { - $this->queues = array(); + $this->queues = []; } /** diff --git a/CRM/Report/BAO/Hook.php b/CRM/Report/BAO/Hook.php index 4521d65d1a..06e1c64210 100644 --- a/CRM/Report/BAO/Hook.php +++ b/CRM/Report/BAO/Hook.php @@ -65,7 +65,7 @@ class CRM_Report_BAO_Hook { */ 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 @@ class CRM_Report_BAO_Hook { $contactIdClause .= $cidClause; } } - return array($contactIdClause, $join); + return [$contactIdClause, $join]; } } diff --git a/CRM/Report/BAO/HookInterface.php b/CRM/Report/BAO/HookInterface.php index a581f657a3..3b8820c50d 100644 --- a/CRM/Report/BAO/HookInterface.php +++ b/CRM/Report/BAO/HookInterface.php @@ -55,7 +55,7 @@ class CRM_Report_BAO_HookInterface { * @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 abbbd67f56..da56063bc7 100644 --- a/CRM/Report/BAO/ReportInstance.php +++ b/CRM/Report/BAO/ReportInstance.php @@ -53,7 +53,7 @@ class CRM_Report_BAO_ReportInstance extends CRM_Report_DAO_ReportInstance { // 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 @@ class CRM_Report_BAO_ReportInstance extends CRM_Report_DAO_ReportInstance { // 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 @@ class CRM_Report_BAO_ReportInstance extends CRM_Report_DAO_ReportInstance { } // 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 @@ class CRM_Report_BAO_ReportInstance extends CRM_Report_DAO_ReportInstance { * - 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 56e056fb3f..389e7769db 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 @@ class CRM_Report_Form extends CRM_Core_Form { } 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 @@ class CRM_Report_Form extends CRM_Core_Form { // 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 @@ class CRM_Report_Form extends CRM_Core_Form { $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 @@ class CRM_Report_Form extends CRM_Core_Form { 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 @@ class CRM_Report_Form extends CRM_Core_Form { $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 @@ class CRM_Report_Form extends CRM_Core_Form { // 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 @@ class CRM_Report_Form extends CRM_Core_Form { */ 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 @@ class CRM_Report_Form extends CRM_Core_Form { 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 @@ class CRM_Report_Form extends CRM_Core_Form { } } - $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 @@ class CRM_Report_Form extends CRM_Core_Form { $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 @@ class CRM_Report_Form extends CRM_Core_Form { * @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 @@ class CRM_Report_Form extends CRM_Core_Form { 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 @@ class CRM_Report_Form extends CRM_Core_Form { * 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 @@ class CRM_Report_Form extends CRM_Core_Form { 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 @@ class CRM_Report_Form extends CRM_Core_Form { * Add filters to report. */ public function addFilters() { - $filters = $filterGroups = array(); + $filters = $filterGroups = []; $count = 1; foreach ($this->_filters as $table => $attributes) { @@ -1248,11 +1248,11 @@ class CRM_Report_Form extends CRM_Core_Form { // 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 @@ class CRM_Report_Form extends CRM_Core_Form { !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 @@ class CRM_Report_Form extends CRM_Core_Form { 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 @@ class CRM_Report_Form extends CRM_Core_Form { 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 @@ class CRM_Report_Form extends CRM_Core_Form { 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 @@ class CRM_Report_Form extends CRM_Core_Form { * - 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 @@ class CRM_Report_Form extends CRM_Core_Form { 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 @@ class CRM_Report_Form extends CRM_Core_Form { // 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 @@ class CRM_Report_Form extends CRM_Core_Form { (!$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 @@ class CRM_Report_Form extends CRM_Core_Form { * 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 @@ class CRM_Report_Form extends CRM_Core_Form { ); $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 @@ class CRM_Report_Form extends CRM_Core_Form { * 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 @@ class CRM_Report_Form extends CRM_Core_Form { $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 @@ class CRM_Report_Form extends CRM_Core_Form { $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 @@ class CRM_Report_Form extends CRM_Core_Form { 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 @@ class CRM_Report_Form extends CRM_Core_Form { $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 @@ class CRM_Report_Form extends CRM_Core_Form { * * @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 @@ class CRM_Report_Form extends CRM_Core_Form { 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 @@ class CRM_Report_Form extends CRM_Core_Form { '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 @@ class CRM_Report_Form extends CRM_Core_Form { 'neq' => ts('Is not equal to'), 'nll' => ts('Is empty (Null)'), 'nnll' => ts('Is not empty (Null)'), - ); + ]; return $result; } } @@ -1812,19 +1812,19 @@ class CRM_Report_Form extends CRM_Core_Form { 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 @@ class CRM_Report_Form extends CRM_Core_Form { * 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 @@ class CRM_Report_Form extends CRM_Core_Form { 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 @@ class CRM_Report_Form extends CRM_Core_Form { $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 @@ class CRM_Report_Form extends CRM_Core_Form { 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 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND if (empty($this->_noRepeats)) { return; } - $checkList = array(); + $checkList = []; foreach ($rows as $key => $list) { foreach ($list as $colName => $colVal) { @@ -2377,7 +2377,7 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND $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 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND 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 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND 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 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND 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 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND * @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 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND * 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 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND // 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 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND 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 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND */ 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 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND * 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 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND // 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 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND } 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 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND return array_diff_key($this->_sections, $this->getSelectColumns()); } else { - return array(); + return []; } } @@ -3034,7 +3034,7 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND } CRM_Core_DAO::reenableFullGroupByMode(); if (!is_array($rows)) { - $rows = array(); + $rows = []; } // use this method to modify $this->_columnHeaders @@ -3043,7 +3043,7 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND $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 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND // 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 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND implode(", ", $sectionAliases); // initialize array of total counts - $totals = array(); + $totals = []; $dao = CRM_Core_DAO::executeQuery($query); while ($dao->fetch()) { @@ -3109,7 +3109,7 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND $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 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND * @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 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND * @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 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND } } } - $statistics['groups'][] = array( + $statistics['groups'][] = [ 'title' => ts('Grouping(s)'), 'value' => implode(' & ', $combinations), - ); + ]; } } @@ -3256,25 +3256,25 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND 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 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND $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 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND $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 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND } } if ($value && empty($field['no_display'])) { - $statistics['filters'][] = array( + $statistics['filters'][] = [ 'title' => CRM_Utils_Array::value('title', $field), 'value' => $value, - ); + ]; } } } @@ -3363,7 +3363,7 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND if ($this->_sendmail) { $config = CRM_Core_Config::singleton(); - $attachments = array(); + $attachments = []; if ($this->_outputMode == 'csv') { $content @@ -3376,11 +3376,11 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND 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 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND 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 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND 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 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND //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 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND // 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 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND $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 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND $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 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND $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 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND $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 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND } $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 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND * * @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 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND // 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 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND 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 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND 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 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND * 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 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND * @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 @@ ORDER BY cg.weight, cf.weight"; 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 @@ ORDER BY cg.weight, cf.weight"; $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 @@ ORDER BY cg.weight, cf.weight"; 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 @@ ORDER BY cg.weight, cf.weight"; 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 @@ ORDER BY cg.weight, cf.weight"; 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 @@ ORDER BY cg.weight, cf.weight"; // 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 @@ ORDER BY cg.weight, cf.weight"; } 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 @@ ORDER BY cg.weight, cf.weight"; $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 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a 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 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a } } 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 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a $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 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a */ 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 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a 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 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a * @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 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a '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 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a '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 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a 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 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a ), $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 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a $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 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a $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 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a * @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 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a * @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 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a * @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 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a * @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 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a * @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 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a * @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 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a * * @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 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a $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 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a * @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 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a ); $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 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a * @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 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a */ 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 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a * * @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 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a '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 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a * * @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 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a '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 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a '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 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a '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 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a '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 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a * * @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 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a '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 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a '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 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a '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 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a '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 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a '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 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a '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 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a '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 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a '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 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a '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 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a * * @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 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a * @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 b85b2b73ef..0f4facd7cf 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 @@ class CRM_Report_Form_Activity extends CRM_Report_Form { // @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 @@ class CRM_Report_Form_Activity extends CRM_Report_Form { $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 @@ class CRM_Report_Form_Activity extends CRM_Report_Form { {$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 @@ class CRM_Report_Form_Activity extends CRM_Report_Form { $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 @@ GROUP BY civicrm_activity_id $having {$this->_orderBy}"; $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 @@ GROUP BY civicrm_activity_id $having {$this->_orderBy}"; * @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 @@ GROUP BY civicrm_activity_id $having {$this->_orderBy}"; $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 @@ GROUP BY civicrm_activity_id $having {$this->_orderBy}"; // 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 @@ GROUP BY civicrm_activity_id $having {$this->_orderBy}"; $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 @@ GROUP BY civicrm_activity_id $having {$this->_orderBy}"; $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 @@ GROUP BY civicrm_activity_id $having {$this->_orderBy}"; $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 @@ GROUP BY civicrm_activity_id $having {$this->_orderBy}"; $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 @@ GROUP BY civicrm_activity_id $having {$this->_orderBy}"; $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 @@ GROUP BY civicrm_activity_id $having {$this->_orderBy}"; $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 @@ GROUP BY civicrm_activity_id $having {$this->_orderBy}"; // 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 @@ GROUP BY civicrm_activity_id $having {$this->_orderBy}"; 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 @@ GROUP BY civicrm_activity_id $having {$this->_orderBy}"; $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 2450a20eb6..dcf879b60c 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 @@ class CRM_Report_Form_ActivitySummary extends CRM_Report_Form { // 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 @@ class CRM_Report_Form_ActivitySummary extends CRM_Report_Form { {$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 @@ class CRM_Report_Form_ActivitySummary extends CRM_Report_Form { * @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 @@ class CRM_Report_Form_ActivitySummary extends CRM_Report_Form { $append = "YEAR({$field['dbAlias']}),"; if (in_array(strtolower($this->_params['group_bys_freq'][$fieldName]), - array('year') + ['year'] )) { $append = ''; } @@ -468,8 +468,8 @@ class CRM_Report_Form_ActivitySummary extends CRM_Report_Form { * @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 @@ class CRM_Report_Form_ActivitySummary extends CRM_Report_Form { 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 @@ class CRM_Report_Form_ActivitySummary extends CRM_Report_Form { // 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 @@ class CRM_Report_Form_ActivitySummary extends CRM_Report_Form { $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 @@ class CRM_Report_Form_ActivitySummary extends CRM_Report_Form { $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 @@ class CRM_Report_Form_ActivitySummary extends CRM_Report_Form { 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 @@ class CRM_Report_Form_ActivitySummary extends CRM_Report_Form { $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 901ce34529..75c3bd83f8 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 @@ class CRM_Report_Form_Case_Demographics extends CRM_Report_Form { '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 @@ class CRM_Report_Form_Case_Demographics extends CRM_Report_Form { 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 @@ where (cg.extends='Contact' OR cg.extends='Individual' OR cg.extends_entity_colu } 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 @@ where (cg.extends='Contact' OR cg.extends='Individual' OR cg.extends_entity_colu } 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 @@ where (cg.extends='Contact' OR cg.extends='Individual' OR cg.extends_entity_colu * @return array */ public static function formRule($fields, $files, $self) { - $errors = $grouping = array(); + $errors = $grouping = []; return $errors; } @@ -319,7 +319,7 @@ where (cg.extends='Contact' OR cg.extends='Individual' OR cg.extends_entity_colu } public function where() { - $clauses = array(); + $clauses = []; $this->_having = ''; foreach ($this->_columns as $tableName => $table) { if (array_key_exists('filters', $table)) { @@ -371,7 +371,7 @@ where (cg.extends='Contact' OR cg.extends='Individual' OR cg.extends_entity_colu } 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 @@ where (cg.extends='Contact' OR cg.extends='Individual' OR cg.extends_entity_colu $this->beginPostProcess(); $sql = $this->buildQuery(TRUE); - $rows = $graphRows = array(); + $rows = $graphRows = []; $this->buildRows($sql, $rows); $this->formatDisplay($rows); @@ -459,10 +459,10 @@ SELECT v.label 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 33204494aa..ee0bc8150b 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 @@ class CRM_Report_Form_Case_Summary extends CRM_Report_Form { $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 @@ class CRM_Report_Form_Case_Summary extends CRM_Report_Form { } 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 @@ class CRM_Report_Form_Case_Summary extends CRM_Report_Form { * @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 @@ inner join civicrm_contact $c2 on ${c2}.id=${ccc}.contact_id } public function where() { - $clauses = array(); + $clauses = []; $this->_having = ''; foreach ($this->_columns as $tableName => $table) { if (array_key_exists('filters', $table)) { @@ -372,7 +372,7 @@ inner join civicrm_contact $c2 on ${c2}.id=${ccc}.contact_id $sql = $this->buildQuery(TRUE); - $rows = $graphRows = array(); + $rows = $graphRows = []; $this->buildRows($sql, $rows); $this->formatDisplay($rows); @@ -404,7 +404,7 @@ inner join civicrm_contact $c2 on ${c2}.id=${ccc}.contact_id ) { $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 3be70f87ef..17169bf7ab 100644 --- a/CRM/Report/Form/Case/TimeSpent.php +++ b/CRM/Report/Form/Case/TimeSpent.php @@ -41,150 +41,150 @@ class CRM_Report_Form_Case_TimeSpent extends CRM_Report_Form { 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 @@ class CRM_Report_Form_Case_TimeSpent extends CRM_Report_Form { 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 @@ class CRM_Report_Form_Case_TimeSpent extends CRM_Report_Form { $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 @@ class CRM_Report_Form_Case_TimeSpent extends CRM_Report_Form { 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 @@ class CRM_Report_Form_Case_TimeSpent extends CRM_Report_Form { * @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 d61aa5d5e6..b1780c73c9 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 @@ class CRM_Report_Form_Contact_CurrentEmployer extends CRM_Report_Form { 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 @@ class CRM_Report_Form_Contact_CurrentEmployer extends CRM_Report_Form { } 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 @@ FROM civicrm_contact {$this->_aliases['civicrm_contact']} 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 @@ FROM civicrm_contact {$this->_aliases['civicrm_contact']} } 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 @@ FROM civicrm_contact {$this->_aliases['civicrm_contact']} 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 @@ FROM civicrm_contact {$this->_aliases['civicrm_contact']} * 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 e7e6b46085..e4546491d7 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 @@ class CRM_Report_Form_Contact_Detail extends CRM_Report_Form { } 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 @@ class CRM_Report_Form_Contact_Detail extends CRM_Report_Form { * @return array */ public static function formRule($fields, $files, $self) { - $errors = array(); + $errors = []; return $errors; } @@ -537,7 +537,7 @@ class CRM_Report_Form_Contact_Detail extends CRM_Report_Form { } public function where() { - $clauses = array(); + $clauses = []; foreach ($this->_columns as $tableName => $table) { if (array_key_exists('filters', $table)) { @@ -585,7 +585,7 @@ class CRM_Report_Form_Contact_Detail extends CRM_Report_Form { 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 @@ class CRM_Report_Form_Contact_Detail extends CRM_Report_Form { $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 @@ class CRM_Report_Form_Contact_Detail extends CRM_Report_Form { * @return array */ public function statistics(&$rows) { - $statistics = array(); + $statistics = []; $count = count($rows); if ($this->_rollup && ($this->_rollup != '')) { @@ -764,7 +764,7 @@ class CRM_Report_Form_Contact_Detail extends CRM_Report_Form { $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 @@ class CRM_Report_Form_Contact_Detail extends CRM_Report_Form { } 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 7617ad503d..22c5ca634a 100644 --- a/CRM/Report/Form/Contact/Log.php +++ b/CRM/Report/Form/Contact/Log.php @@ -42,97 +42,97 @@ class CRM_Report_Form_Contact_Log extends CRM_Report_Form { $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 @@ class CRM_Report_Form_Contact_Log extends CRM_Report_Form { } 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 @@ class CRM_Report_Form_Contact_Log extends CRM_Report_Form { * @return array */ public static function formRule($fields, $files, $self) { - $errors = $grouping = array(); + $errors = $grouping = []; return $errors; } @@ -189,7 +189,7 @@ class CRM_Report_Form_Contact_Log extends CRM_Report_Form { } 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 27fad50164..61d255fdc9 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 @@ class CRM_Report_Form_Contact_LoggingSummary extends CRM_Logging_ReportSummary { */ 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 2188114f25..c29ec8e505 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 @@ class CRM_Report_Form_Contact_Relationship extends CRM_Report_Form { $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 @@ class CRM_Report_Form_Contact_Relationship extends CRM_Report_Form { } 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 @@ class CRM_Report_Form_Contact_Relationship extends CRM_Report_Form { } 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 @@ class CRM_Report_Form_Contact_Relationship extends CRM_Report_Form { $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 @@ class CRM_Report_Form_Contact_Relationship extends CRM_Report_Form { 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 @@ class CRM_Report_Form_Contact_Relationship extends CRM_Report_Form { } // 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 @@ class CRM_Report_Form_Contact_Relationship extends CRM_Report_Form { $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 @@ class CRM_Report_Form_Contact_Relationship extends CRM_Report_Form { 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 @@ class CRM_Report_Form_Contact_Relationship extends CRM_Report_Form { 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 @@ class CRM_Report_Form_Contact_Relationship extends CRM_Report_Form { 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 @@ class CRM_Report_Form_Contact_Relationship extends CRM_Report_Form { 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 @@ class CRM_Report_Form_Contact_Relationship extends CRM_Report_Form { $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 053b8b3718..753844af98 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 @@ class CRM_Report_Form_Contribute_Bookkeeping extends CRM_Report_Form { } 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 @@ class CRM_Report_Form_Contribute_Bookkeeping extends CRM_Report_Form { 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 @@ class CRM_Report_Form_Contribute_Bookkeeping extends CRM_Report_Form { } 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 @@ class CRM_Report_Form_Contribute_Bookkeeping extends CRM_Report_Form { 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 @@ class CRM_Report_Form_Contribute_Bookkeeping extends CRM_Report_Form { 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 96846184b8..837a417c3a 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 @@ class CRM_Report_Form_Contribute_DeferredRevenue extends CRM_Report_Form { $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 @@ class CRM_Report_Form_Contribute_DeferredRevenue extends CRM_Report_Form { */ 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 @@ class CRM_Report_Form_Contribute_DeferredRevenue extends CRM_Report_Form { '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 @@ class CRM_Report_Form_Contribute_DeferredRevenue extends CRM_Report_Form { // 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 @@ class CRM_Report_Form_Contribute_DeferredRevenue extends CRM_Report_Form { $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 accac0c1e1..82060fafdd 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 @@ class CRM_Report_Form_Contribute_Detail extends CRM_Report_Form { 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 @@ class CRM_Report_Form_Contribute_Detail extends CRM_Report_Form { $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 @@ GROUP BY {$this->_aliases['civicrm_contribution']}.currency"; $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 @@ GROUP BY {$this->_aliases['civicrm_contribution']}.currency"; ) { 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 @@ WHERE civicrm_contribution_contribution_id={$row['civicrm_contribution_contribu // 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 @@ WHERE civicrm_contribution_contribution_id={$row['civicrm_contribution_contribu "$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 @@ WHERE civicrm_contribution_contribution_id={$row['civicrm_contribution_contribu $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 @@ WHERE civicrm_contribution_contribution_id={$row['civicrm_contribution_contribu } } if ($showsumcontribs) { - $totalandsum = array(); + $totalandsum = []; // ts exception to avoid having ts("%1 %2: %3") $title = '%1 contributions / soft-credits: %2'; @@ -902,10 +902,10 @@ WHERE civicrm_contribution_contribution_id={$row['civicrm_contribution_contribu $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 a0e4075612..89b0dfe4b9 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 @@ class CRM_Report_Form_Contribute_History extends CRM_Report_Form { $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 @@ class CRM_Report_Form_Contribute_History extends CRM_Report_Form { $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 @@ class CRM_Report_Form_Contribute_History extends CRM_Report_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('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 @@ class CRM_Report_Form_Contribute_History extends CRM_Report_Form { } 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 @@ class CRM_Report_Form_Contribute_History extends CRM_Report_Form { } public function where() { - $whereClauses = $havingClauses = $relationshipWhere = array(); + $whereClauses = $havingClauses = $relationshipWhere = []; $this->_relationshipWhere = ''; $this->_statusClause = ''; @@ -474,10 +474,10 @@ class CRM_Report_Form_Contribute_History extends CRM_Report_Form { } 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 @@ class CRM_Report_Form_Contribute_History extends CRM_Report_Form { $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 @@ class CRM_Report_Form_Contribute_History extends CRM_Report_Form { * @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 @@ class CRM_Report_Form_Contribute_History extends CRM_Report_Form { $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 @@ class CRM_Report_Form_Contribute_History extends CRM_Report_Form { * @param $rows */ public function buildRows($sql, &$rows) { - $contactIds = array(); + $contactIds = []; $addWhere = ''; @@ -615,7 +615,7 @@ class CRM_Report_Form_Contribute_History extends CRM_Report_Form { $dao->free(); $this->setPager(); - $relationshipRows = array(); + $relationshipRows = []; if (empty($contactIds)) { return; } @@ -631,7 +631,7 @@ class CRM_Report_Form_Contribute_History extends CRM_Report_Form { $relatedContributions = $this->buildContributionRows($relatedContactIds); - $summaryYears = array(); + $summaryYears = []; $summaryYears[] = "civicrm_upto_{$this->_yearStatisticsFrom}"; $yearConter = $this->_yearStatisticsFrom; $yearConter++; @@ -647,7 +647,7 @@ class CRM_Report_Form_Contribute_History extends CRM_Report_Form { $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 @@ class CRM_Report_Form_Contribute_History extends CRM_Report_Form { } 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 @@ class CRM_Report_Form_Contribute_History extends CRM_Report_Form { * @return array */ public function buildContributionRows($contactIds) { - $rows = array(); + $rows = []; if (empty($contactIds)) { return $rows; } @@ -696,7 +696,7 @@ class CRM_Report_Form_Contribute_History extends CRM_Report_Form { $dao = CRM_Core_DAO::executeQuery($sqlContribution); $contributionSum = 0; - $yearcal = array(); + $yearcal = []; while ($dao->fetch()) { if (!$dao->civicrm_contact_id) { continue; @@ -737,9 +737,9 @@ class CRM_Report_Form_Contribute_History extends CRM_Report_Form { * @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 @@ class CRM_Report_Form_Contribute_History extends CRM_Report_Form { $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 @@ class CRM_Report_Form_Contribute_History extends CRM_Report_Form { } } $dao->free(); - return array($relationshipRows, $relatedContactIds); + return [$relationshipRows, $relatedContactIds]; } /** @@ -784,10 +784,10 @@ class CRM_Report_Form_Contribute_History extends CRM_Report_Form { */ 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 dff6c52317..e840921139 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 @@ class CRM_Report_Form_Contribute_HouseholdSummary extends CRM_Report_Form { 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 @@ class CRM_Report_Form_Contribute_HouseholdSummary extends CRM_Report_Form { } 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 @@ class CRM_Report_Form_Contribute_HouseholdSummary extends CRM_Report_Form { } 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 @@ class CRM_Report_Form_Contribute_HouseholdSummary extends CRM_Report_Form { 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 @@ class CRM_Report_Form_Contribute_HouseholdSummary extends CRM_Report_Form { } 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 8bc65e7b59..3b1ed480be 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 @@ class CRM_Report_Form_Contribute_Lybunt extends CRM_Report_Form { $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 @@ class CRM_Report_Form_Contribute_Lybunt extends CRM_Report_Form { $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 @@ class CRM_Report_Form_Contribute_Lybunt extends CRM_Report_Form { $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 @@ class CRM_Report_Form_Contribute_Lybunt extends CRM_Report_Form { } // Reset where clauses to be regenerated in postProcess. - $this->_whereClauses = array(); + $this->_whereClauses = []; } /** @@ -628,9 +628,9 @@ class CRM_Report_Form_Contribute_Lybunt extends CRM_Report_Form { */ protected function resetFormSqlAndWhereHavingClauses() { $this->sql = ''; - $this->_havingClauses = array(); - $this->_whereClauses = array(); - $this->sqlArray = array(); + $this->_havingClauses = []; + $this->_whereClauses = []; + $this->sqlArray = []; } /** @@ -638,9 +638,9 @@ class CRM_Report_Form_Contribute_Lybunt extends CRM_Report_Form { */ 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 @@ class CRM_Report_Form_Contribute_Lybunt extends CRM_Report_Form { $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 @@ class CRM_Report_Form_Contribute_Lybunt extends CRM_Report_Form { */ 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 28ad210763..9e4926a9ad 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 @@ class CRM_Report_Form_Contribute_OrganizationSummary extends CRM_Report_Form { 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 @@ class CRM_Report_Form_Contribute_OrganizationSummary extends CRM_Report_Form { } 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 @@ class CRM_Report_Form_Contribute_OrganizationSummary extends CRM_Report_Form { } 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 @@ class CRM_Report_Form_Contribute_OrganizationSummary extends CRM_Report_Form { 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 @@ class CRM_Report_Form_Contribute_OrganizationSummary extends CRM_Report_Form { } 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 @@ class CRM_Report_Form_Contribute_OrganizationSummary extends CRM_Report_Form { } } - $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 7ae29f131f..abd1972899 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 @@ LEFT JOIN civicrm_event {$this->_aliases['civicrm_event']} } public function where() { - $whereClauses = $havingClauses = array(); + $whereClauses = $havingClauses = []; foreach ($this->_columns as $tableName => $table) { if (array_key_exists('filters', $table)) { @@ -336,26 +336,26 @@ LEFT JOIN civicrm_event {$this->_aliases['civicrm_event']} $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 @@ LEFT JOIN civicrm_event {$this->_aliases['civicrm_event']} */ 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 7d1f6309c5..e3f733f059 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 @@ class CRM_Report_Form_Contribute_Recur extends CRM_Report_Form { // 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 7794739030..af66c0dc68 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 @@ class CRM_Report_Form_Contribute_RecurSummary extends CRM_Report_Form { 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 @@ class CRM_Report_Form_Contribute_RecurSummary extends CRM_Report_Form { // 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 @@ class CRM_Report_Form_Contribute_RecurSummary extends CRM_Report_Form { public function postProcess() { $this->beginPostProcess(); $sql = $this->buildQuery(TRUE); - $rows = array(); + $rows = []; $this->buildRows($sql, $rows); $this->formatDisplay($rows); @@ -325,13 +325,13 @@ class CRM_Report_Form_Contribute_RecurSummary extends CRM_Report_Form { } // 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 5296451542..31d50193cd 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 @@ class CRM_Report_Form_Contribute_SoftCredit extends CRM_Report_Form { } 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 @@ class CRM_Report_Form_Contribute_SoftCredit extends CRM_Report_Form { * @return array */ public static function formRule($fields, $files, $self) { - $errors = $grouping = array(); + $errors = $grouping = []; return $errors; } @@ -473,7 +473,7 @@ class CRM_Report_Form_Contribute_SoftCredit extends CRM_Report_Form { 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 @@ GROUP BY {$this->_aliases['civicrm_contribution']}.currency $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 @@ GROUP BY {$this->_aliases['civicrm_contribution']}.currency 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 e4b59f0d70..22c337eb8c 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 @@ class CRM_Report_Form_Contribute_Sybunt extends CRM_Report_Form { $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 @@ class CRM_Report_Form_Contribute_Sybunt extends CRM_Report_Form { } 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 @@ class CRM_Report_Form_Contribute_Sybunt extends CRM_Report_Form { $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 @@ class CRM_Report_Form_Contribute_Sybunt extends CRM_Report_Form { 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 @@ class CRM_Report_Form_Contribute_Sybunt extends CRM_Report_Form { $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 @@ class CRM_Report_Form_Contribute_Sybunt extends CRM_Report_Form { $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 @@ class CRM_Report_Form_Contribute_Sybunt extends CRM_Report_Form { $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 @@ class CRM_Report_Form_Contribute_Sybunt extends CRM_Report_Form { $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 @@ class CRM_Report_Form_Contribute_Sybunt extends CRM_Report_Form { * @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 @@ class CRM_Report_Form_Contribute_Sybunt extends CRM_Report_Form { $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 @@ class CRM_Report_Form_Contribute_Sybunt extends CRM_Report_Form { */ 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 f489c0f187..9b613bef3c 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 @@ class CRM_Report_Form_Contribute_TopDonor extends CRM_Report_Form { * @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 @@ class CRM_Report_Form_Contribute_TopDonor extends CRM_Report_Form { } 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 @@ class CRM_Report_Form_Contribute_TopDonor extends CRM_Report_Form { 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 41bcc46575..bf62cd0f86 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 @@ class CRM_Report_Form_Event_Income extends CRM_Report_Form { $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 @@ class CRM_Report_Form_Event_Income extends CRM_Report_Form { $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 @@ class CRM_Report_Form_Event_Income extends CRM_Report_Form { $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 @@ class CRM_Report_Form_Event_Income extends CRM_Report_Form { "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 @@ class CRM_Report_Form_Event_Income extends CRM_Report_Form { 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 @@ class CRM_Report_Form_Event_Income extends CRM_Report_Form { * @return array */ public function statistics(&$eventIDs) { - $statistics = array(); + $statistics = []; $count = count($eventIDs); $this->countStat($statistics, $count); if ($this->_setVariable) { @@ -300,14 +300,14 @@ class CRM_Report_Form_Event_Income extends CRM_Report_Form { * @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 @@ class CRM_Report_Form_Event_Income extends CRM_Report_Form { $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 @@ class CRM_Report_Form_Event_Income extends CRM_Report_Form { $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 d8dbeed4f4..25c5c533b2 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 @@ class CRM_Report_Form_Event_IncomeCountSummary extends CRM_Report_Form { } 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 @@ class CRM_Report_Form_Event_IncomeCountSummary extends CRM_Report_Form { } public function where() { - $clauses = array(); + $clauses = []; $this->_participantWhere = ""; foreach ($this->_columns as $tableName => $table) { if (array_key_exists('filters', $table)) { @@ -280,21 +280,21 @@ class CRM_Report_Form_Event_IncomeCountSummary extends CRM_Report_Form { 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 @@ class CRM_Report_Form_Event_IncomeCountSummary extends CRM_Report_Form { //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 @@ class CRM_Report_Form_Event_IncomeCountSummary extends CRM_Report_Form { } 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 a03f9c9c3e..7ff1c1fca6 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 @@ class CRM_Report_Form_Event_ParticipantListCount extends CRM_Report_Form { 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 @@ class CRM_Report_Form_Event_ParticipantListCount extends CRM_Report_Form { * @return array */ public static function formRule($fields, $files, $self) { - $errors = $grouping = array(); + $errors = $grouping = []; return $errors; } @@ -590,7 +590,7 @@ class CRM_Report_Form_Event_ParticipantListCount extends CRM_Report_Form { 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 0d689cc848..ec4d864bb1 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 @@ class CRM_Report_Form_Event_Summary extends CRM_Report_Form { } 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 @@ class CRM_Report_Form_Event_Summary extends CRM_Report_Form { } public function where() { - $clauses = array(); + $clauses = []; $this->_participantWhere = ""; foreach ($this->_columns as $tableName => $table) { if (array_key_exists('filters', $table)) { @@ -206,7 +206,7 @@ class CRM_Report_Form_Event_Summary extends CRM_Report_Form { 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 @@ class CRM_Report_Form_Event_Summary extends CRM_Report_Form { * 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 @@ class CRM_Report_Form_Event_Summary extends CRM_Report_Form { //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 @@ class CRM_Report_Form_Event_Summary extends CRM_Report_Form { //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 @@ class CRM_Report_Form_Event_Summary extends CRM_Report_Form { 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 b698ff7c46..9e04ef659b 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 @@ class CRM_Report_Form_Extended extends CRM_Report_Form { * @return array */ public function fromClauses() { - return array(); + return []; } public function groupBy() { @@ -149,7 +149,7 @@ class CRM_Report_Form_Extended extends CRM_Report_Form { } $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 @@ class CRM_Report_Form_Extended extends CRM_Report_Form { * @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 @@ class CRM_Report_Form_Extended extends CRM_Report_Form { * @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 @@ class CRM_Report_Form_Extended extends CRM_Report_Form { * @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 @@ WHERE line_item_civireport.id IS NOT NULL $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 @@ WHERE line_item_civireport.id IS NOT NULL $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 @@ WHERE line_item_civireport.id IS NOT NULL $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 @@ WHERE line_item_civireport.id IS NOT NULL 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 458bf55766..a70b673e64 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 d579ebc4ec..f4e76f98fd 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 @@ WHERE {$this->_aliases['civicrm_grant']}.amount_total IS NOT NULL * 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 @@ SELECT COUNT({$this->_aliases['civicrm_grant']}.id) as count , $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 @@ SELECT COUNT({$this->_aliases['civicrm_grant']}.id) as count , } } - $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 @@ SELECT COUNT({$this->_aliases['civicrm_grant']}.id) as count , 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 @@ SELECT COUNT({$this->_aliases['civicrm_grant']}.id) as count , } $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 @@ SELECT COUNT({$this->_aliases['civicrm_grant']}.id) as count , 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 7fa815d858..ec2d76e2dc 100644 --- a/CRM/Report/Form/Instance.php +++ b/CRM/Report/Form/Instance.php @@ -85,7 +85,7 @@ class CRM_Report_Form_Instance { $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 @@ class CRM_Report_Form_Instance { ); $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 @@ class CRM_Report_Form_Instance { $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 @@ class CRM_Report_Form_Instance { '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 @@ class CRM_Report_Form_Instance { $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 @@ class CRM_Report_Form_Instance { } $instanceID = $form->getVar('_id'); - $navigationDefaults = array(); + $navigationDefaults = []; if (!isset($defaults['permission'])) { $defaults['permission'] = 'access CiviReport'; @@ -281,7 +281,7 @@ class CRM_Report_Form_Instance { 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 @@ class CRM_Report_Form_Instance { $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 @@ class CRM_Report_Form_Instance { 'report_footer', 'grouprole', 'task', - ); + ]; foreach ($unsetFields as $field) { unset($formValues[$field]); } @@ -383,18 +383,18 @@ class CRM_Report_Form_Instance { 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 37ab9284ee..9cb491a484 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 @@ class CRM_Report_Form_Mailing_Bounce extends CRM_Report_Form { } 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 @@ class CRM_Report_Form_Mailing_Bounce extends CRM_Report_Form { * @return array */ public static function formRule($fields, $files, $self) { - $errors = $grouping = array(); + $errors = $grouping = []; return $errors; } @@ -342,7 +342,7 @@ class CRM_Report_Form_Mailing_Bounce extends CRM_Report_Form { public function where() { - $clauses = array(); + $clauses = []; // Exclude SMS mailing type $clauses[] = "{$this->_aliases['civicrm_mailing']}.sms_provider_id IS NULL"; @@ -401,7 +401,7 @@ class CRM_Report_Form_Mailing_Bounce extends CRM_Report_Form { $sql = $this->buildQuery(TRUE); - $rows = $graphRows = array(); + $rows = $graphRows = []; $this->buildRows($sql, $rows); $this->formatDisplay($rows); @@ -417,13 +417,13 @@ class CRM_Report_Form_Mailing_Bounce extends CRM_Report_Form { 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 @@ class CRM_Report_Form_Mailing_Bounce extends CRM_Report_Form { */ 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 @@ class CRM_Report_Form_Mailing_Bounce extends CRM_Report_Form { } // 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 054463b1fe..b2239e02b2 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 @@ class CRM_Report_Form_Mailing_Clicks extends CRM_Report_Form { } 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 @@ class CRM_Report_Form_Mailing_Clicks extends CRM_Report_Form { * @return array */ public static function formRule($fields, $files, $self) { - $errors = $grouping = array(); + $errors = $grouping = []; return $errors; } @@ -321,7 +321,7 @@ class CRM_Report_Form_Mailing_Clicks extends CRM_Report_Form { $sql = $this->buildQuery(TRUE); - $rows = $graphRows = array(); + $rows = $graphRows = []; $this->buildRows($sql, $rows); $this->formatDisplay($rows); @@ -337,13 +337,13 @@ class CRM_Report_Form_Mailing_Clicks extends CRM_Report_Form { 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 b74e01f1f8..2b3afb4866 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 @@ class CRM_Report_Form_Mailing_Detail extends CRM_Report_Form { } 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 @@ class CRM_Report_Form_Mailing_Detail extends CRM_Report_Form { */ 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 a466f03e5e..f040552ca4 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 @@ class CRM_Report_Form_Mailing_Opened extends CRM_Report_Form { } 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 @@ class CRM_Report_Form_Mailing_Opened extends CRM_Report_Form { * @return array */ public static function formRule($fields, $files, $self) { - $errors = $grouping = array(); + $errors = $grouping = []; return $errors; } @@ -289,11 +289,11 @@ class CRM_Report_Form_Mailing_Opened extends CRM_Report_Form { } 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 @@ class CRM_Report_Form_Mailing_Opened extends CRM_Report_Form { $sql = $this->buildQuery(TRUE); - $rows = $graphRows = array(); + $rows = $graphRows = []; $this->buildRows($sql, $rows); $this->formatDisplay($rows); @@ -328,13 +328,13 @@ class CRM_Report_Form_Mailing_Opened extends CRM_Report_Form { 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 b862ffcc72..ba6acbee02 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 @@ class CRM_Report_Form_Mailing_Summary extends CRM_Report_Form { */ 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 @@ class CRM_Report_Form_Mailing_Summary extends CRM_Report_Form { // 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 @@ class CRM_Report_Form_Mailing_Summary extends CRM_Report_Form { '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 @@ class CRM_Report_Form_Mailing_Summary extends CRM_Report_Form { } 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 @@ class CRM_Report_Form_Mailing_Summary extends CRM_Report_Form { } 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 @@ class CRM_Report_Form_Mailing_Summary extends CRM_Report_Form { // print_r($sql); - $rows = $graphRows = array(); + $rows = $graphRows = []; $this->buildRows($sql, $rows); $this->formatDisplay($rows); @@ -500,24 +500,24 @@ class CRM_Report_Form_Mailing_Summary extends CRM_Report_Form { * @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 @@ class CRM_Report_Form_Mailing_Summary extends CRM_Report_Form { * @return array */ public static function formRule($fields, $files, $self) { - $errors = array(); + $errors = []; if (empty($fields['charts'])) { return $errors; @@ -537,7 +537,7 @@ class CRM_Report_Form_Mailing_Summary extends CRM_Report_Form { $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 @@ class CRM_Report_Form_Mailing_Summary extends CRM_Report_Form { '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 @@ class CRM_Report_Form_Mailing_Summary extends CRM_Report_Form { $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 47ab00637f..beabdbc122 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 @@ class CRM_Report_Form_Member_ContributionDetail extends CRM_Report_Form { } 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 @@ class CRM_Report_Form_Member_ContributionDetail extends CRM_Report_Form { } 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 @@ class CRM_Report_Form_Member_ContributionDetail extends CRM_Report_Form { 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 @@ class CRM_Report_Form_Member_ContributionDetail extends CRM_Report_Form { */ 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 94afd1f197..4d816ee3db 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 @@ class CRM_Report_Form_Member_Detail extends CRM_Report_Form { */ public function alterDisplay(&$rows) { $entryFound = FALSE; - $checkList = array(); + $checkList = []; $contributionTypes = CRM_Contribute_PseudoConstant::financialType(); $contributionStatus = CRM_Contribute_PseudoConstant::contributionStatus(); @@ -307,7 +307,7 @@ class CRM_Report_Form_Member_Detail extends CRM_Report_Form { $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 4a7f744e74..1313c3e744 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 @@ class CRM_Report_Form_Member_Lapse extends CRM_Report_Form { } 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 @@ class CRM_Report_Form_Member_Lapse extends CRM_Report_Form { * @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 @@ class CRM_Report_Form_Member_Lapse extends CRM_Report_Form { } 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 @@ class CRM_Report_Form_Member_Lapse extends CRM_Report_Form { $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 @@ class CRM_Report_Form_Member_Lapse extends CRM_Report_Form { */ 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 cb61d3baa7..9ad2a41fb3 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 @@ class CRM_Report_Form_Member_Summary extends CRM_Report_Form { } 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 @@ class CRM_Report_Form_Member_Summary extends CRM_Report_Form { // 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 @@ class CRM_Report_Form_Member_Summary extends CRM_Report_Form { } } } - $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 @@ class CRM_Report_Form_Member_Summary extends CRM_Report_Form { $append = "YEAR({$field['dbAlias']})"; if (in_array(strtolower($this->_params['group_bys_freq'][$fieldName]), - array('year') + ['year'] )) { $append = ''; } @@ -397,7 +397,7 @@ GROUP BY {$this->_aliases['civicrm_contribution']}.currency $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 @@ GROUP BY {$this->_aliases['civicrm_contribution']}.currency $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 @@ GROUP BY {$this->_aliases['civicrm_contribution']}.currency * @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 @@ GROUP BY {$this->_aliases['civicrm_contribution']}.currency // 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 @@ GROUP BY {$this->_aliases['civicrm_contribution']}.currency $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 96f8cc4b65..34c3a77e3b 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 @@ class CRM_Report_Form_Membership_Summary extends CRM_Report_Form { */ 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 @@ LEFT JOIN civicrm_contribution {$this->_aliases['civicrm_contribution']} * @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 @@ LEFT JOIN civicrm_contribution {$this->_aliases['civicrm_contribution']} * @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 @@ LEFT JOIN civicrm_contribution {$this->_aliases['civicrm_contribution']} $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 @@ LEFT JOIN civicrm_contribution {$this->_aliases['civicrm_contribution']} $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 @@ LEFT JOIN civicrm_contribution {$this->_aliases['civicrm_contribution']} */ 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 a9cba5fc4e..b29c729bad 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 @@ class CRM_Report_Form_Pledge_Detail extends CRM_Report_Form { 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 @@ class CRM_Report_Form_Pledge_Detail extends CRM_Report_Form { 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 @@ class CRM_Report_Form_Pledge_Detail extends CRM_Report_Form { $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 @@ class CRM_Report_Form_Pledge_Detail extends CRM_Report_Form { 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 @@ class CRM_Report_Form_Pledge_Detail extends CRM_Report_Form { $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 @@ class CRM_Report_Form_Pledge_Detail extends CRM_Report_Form { $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 @@ class CRM_Report_Form_Pledge_Detail extends CRM_Report_Form { } 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 @@ class CRM_Report_Form_Pledge_Detail extends CRM_Report_Form { // 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 @@ class CRM_Report_Form_Pledge_Detail extends CRM_Report_Form { 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 @@ class CRM_Report_Form_Pledge_Detail extends CRM_Report_Form { } // 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 @@ class CRM_Report_Form_Pledge_Detail extends CRM_Report_Form { * (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 @@ class CRM_Report_Form_Pledge_Detail extends CRM_Report_Form { // 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 @@ class CRM_Report_Form_Pledge_Detail extends CRM_Report_Form { */ 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 562b1435f3..e796cac5fe 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 @@ class CRM_Report_Form_Pledge_Pbnp extends CRM_Report_Form { } 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 @@ class CRM_Report_Form_Pledge_Pbnp extends CRM_Report_Form { $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 @@ class CRM_Report_Form_Pledge_Pbnp extends CRM_Report_Form { } 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 @@ class CRM_Report_Form_Pledge_Pbnp extends CRM_Report_Form { */ 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 80495afa02..d8ca6b0bde 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 @@ class CRM_Report_Form_Pledge_Summary extends CRM_Report_Form { $append = "YEAR({$field['dbAlias']}),"; if (in_array(strtolower($this->_params['group_bys_freq'][$fieldName]), - array('year') + ['year'] )) { $append = ''; } @@ -299,27 +299,27 @@ class CRM_Report_Form_Pledge_Summary extends CRM_Report_Form { $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 @@ class CRM_Report_Form_Pledge_Summary extends CRM_Report_Form { */ 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 b926f290e2..c99ac77738 100644 --- a/CRM/Report/Form/Register.php +++ b/CRM/Report/Form/Register.php @@ -50,7 +50,7 @@ class CRM_Report_Form_Register extends CRM_Core_Form { 'report_template', 'id', 'name' ); - $instanceInfo = array(); + $instanceInfo = []; } /** @@ -63,18 +63,18 @@ class CRM_Report_Form_Register extends CRM_Core_Form { * 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 @@ class CRM_Report_Form_Register extends CRM_Core_Form { 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 @@ class CRM_Report_Form_Register extends CRM_Core_Form { * @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 @@ class CRM_Report_Form_Register extends CRM_Core_Form { 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 @@ class CRM_Report_Form_Register extends CRM_Core_Form { $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 ec527934d4..efa89aa2b0 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 @@ class CRM_Report_Form_Walklist_Walklist extends CRM_Report_Form { 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 @@ FROM civicrm_contact {$this->_aliases['civicrm_contact']} {$this->_aclFrom } 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 8189997c25..5cd505292f 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 @@ class CRM_Report_Info extends CRM_Core_Component_Info { * 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 89c0adb785..c101c06b18 100644 --- a/CRM/Report/Page/Instance.php +++ b/CRM/Report/Page/Instance.php @@ -73,8 +73,8 @@ class CRM_Report_Page_Instance extends CRM_Core_Page { } 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 3e5147a501..e623e77a5d 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 @@ class CRM_Report_Page_InstanceList extends CRM_Core_Page { } 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 @@ class CRM_Report_Page_InstanceList extends CRM_Core_Page { } 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 @@ class CRM_Report_Page_InstanceList extends CRM_Core_Page { 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 @@ class CRM_Report_Page_InstanceList extends CRM_Core_Page { 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 @@ class CRM_Report_Page_InstanceList extends CRM_Core_Page { 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 @@ class CRM_Report_Page_InstanceList extends CRM_Core_Page { $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 @@ class CRM_Report_Page_InstanceList extends CRM_Core_Page { */ 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 466ba235e1..65374992f1 100644 --- a/CRM/Report/Page/Options.php +++ b/CRM/Report/Page/Options.php @@ -110,30 +110,30 @@ class CRM_Report_Page_Options extends CRM_Core_Page_Basic { */ 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 @@ class CRM_Report_Page_Options extends CRM_Core_Page_Basic { * 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 8284532680..82c95ec674 100644 --- a/CRM/Report/Page/Report.php +++ b/CRM/Report/Page/Report.php @@ -61,7 +61,7 @@ class CRM_Report_Page_Report extends CRM_Core_Page { } 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 5180f3d443..631b5b68b4 100644 --- a/CRM/Report/Page/TemplateList.php +++ b/CRM/Report/Page/TemplateList.php @@ -83,7 +83,7 @@ LEFT JOIN civicrm_component comp $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 30e302183e..02d9b57309 100644 --- a/CRM/Report/Utils/Get.php +++ b/CRM/Report/Utils/Get.php @@ -200,10 +200,10 @@ class CRM_Report_Utils_Get { */ 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 @@ class CRM_Report_Utils_Get { } 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 43a7fcf71d..68f5f69dd9 100644 --- a/CRM/Report/Utils/Report.php +++ b/CRM/Report/Utils/Report.php @@ -71,7 +71,7 @@ class CRM_Report_Utils_Report { 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 @@ class CRM_Report_Utils_Report { * @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 @@ WHERE report_id = %1"; * @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 @@ WHERE report_id = %1"; 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 @@ WHERE TRIM(BOTH '/' FROM CONCAT(report_id, '/', name)) = %1"; * * @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 @@ SELECT count(inst.id) 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 @@ WHERE inst.report_id = %1"; * * @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 @@ WHERE inst.report_id = %1"; $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 @@ WHERE inst.report_id = %1"; $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 @@ WHERE inst.report_id = %1"; $headers ) . "\r\n"; - $displayRows = array(); + $displayRows = []; $value = NULL; foreach ($rows as $row) { foreach ($columnHeaders as $k => $v) { @@ -348,8 +348,8 @@ WHERE inst.report_id = %1"; 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 @@ WHERE inst.report_id = %1"; 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 @@ WHERE inst.report_id = %1"; $_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 @@ WHERE inst.report_id = %1"; } $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 @@ WHERE inst.report_id = %1"; } } - $result = array( + $result = [ 'is_error' => $is_error, 'messages' => implode("\n", $messages), - ); + ]; return $result; } @@ -478,11 +478,11 @@ WHERE inst.report_id = %1"; * @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 @@ WHERE inst.report_id = %1"; * @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 20740a04e3..932d180029 100644 --- a/CRM/SMS/BAO/Provider.php +++ b/CRM/SMS/BAO/Provider.php @@ -44,7 +44,7 @@ class CRM_SMS_BAO_Provider extends CRM_SMS_DAO_Provider { */ 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 @@ class CRM_SMS_BAO_Provider extends CRM_SMS_DAO_Provider { */ 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 @@ class CRM_SMS_BAO_Provider extends CRM_SMS_DAO_Provider { * @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 44adddd5c1..9466a425ff 100644 --- a/CRM/SMS/Controller/Send.php +++ b/CRM/SMS/Controller/Send.php @@ -62,7 +62,7 @@ class CRM_SMS_Controller_Send extends CRM_Core_Controller { $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 ce4e803d60..f3d64d81af 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 @@ class CRM_SMS_Form_Group extends CRM_Contact_Form_Task { $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 @@ class CRM_SMS_Form_Group extends CRM_Contact_Form_Task { $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 @@ class CRM_SMS_Form_Group extends CRM_Contact_Form_Task { $dao = new CRM_Mailing_DAO_MailingGroup(); - $mailingGroups = array(); + $mailingGroups = []; $dao->mailing_id = $mailingID; $dao->find(); while ($dao->fetch()) { @@ -123,18 +123,18 @@ class CRM_SMS_Form_Group extends CRM_Contact_Form_Task { // 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 @@ class CRM_SMS_Form_Group extends CRM_Contact_Form_Task { $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 @@ class CRM_SMS_Form_Group extends CRM_Contact_Form_Task { 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 @@ class CRM_SMS_Form_Group extends CRM_Contact_Form_Task { } } - $mailings = array(); + $mailings = []; if (is_array($inMailings)) { foreach ($inMailings as $key => $id) { if ($id) { @@ -246,7 +246,7 @@ class CRM_SMS_Form_Group extends CRM_Contact_Form_Task { $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 @@ class CRM_SMS_Form_Group extends CRM_Contact_Form_Task { $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 @@ class CRM_SMS_Form_Group extends CRM_Contact_Form_Task { * 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 @@ class CRM_SMS_Form_Group extends CRM_Contact_Form_Task { 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 88107b0737..1ed76a1d02 100644 --- a/CRM/SMS/Form/Provider.php +++ b/CRM/SMS/Form/Provider.php @@ -65,17 +65,17 @@ class CRM_SMS_Form_Provider extends CRM_Core_Form { 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 @@ class CRM_SMS_Form_Provider extends CRM_Core_Form { $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 @@ class CRM_SMS_Form_Provider extends CRM_Core_Form { * @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 f4ddf7d868..82c3e594ff 100644 --- a/CRM/SMS/Form/Schedule.php +++ b/CRM/SMS/Form/Schedule.php @@ -48,7 +48,7 @@ class CRM_SMS_Form_Schedule extends CRM_Core_Form { * Set default values for the form. */ public function setDefaultValues() { - $defaults = array(); + $defaults = []; $count = $this->get('count'); @@ -74,29 +74,29 @@ class CRM_SMS_Form_Schedule extends CRM_Core_Form { $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 @@ class CRM_SMS_Form_Schedule extends CRM_Core_Form { } 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 @@ class CRM_SMS_Form_Schedule extends CRM_Core_Form { * 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 7a0342a5e0..91ba35392f 100644 --- a/CRM/SMS/Form/Upload.php +++ b/CRM/SMS/Form/Upload.php @@ -61,7 +61,7 @@ class CRM_SMS_Form_Upload extends CRM_Core_Form { $this->set('skipTextFile', FALSE); - $defaults = array(); + $defaults = []; if ($mailingID) { $dao = new CRM_Mailing_DAO_Mailing(); @@ -115,7 +115,7 @@ class CRM_SMS_Form_Upload extends CRM_Core_Form { 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 @@ class CRM_SMS_Form_Upload extends CRM_Core_Form { "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 @@ class CRM_SMS_Form_Upload extends CRM_Core_Form { $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 @@ class CRM_SMS_Form_Upload extends CRM_Core_Form { $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 @@ class CRM_SMS_Form_Upload extends CRM_Core_Form { } 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 @@ class CRM_SMS_Form_Upload extends CRM_Core_Form { } 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 @@ class CRM_SMS_Form_Upload extends CRM_Core_Form { 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 @@ class CRM_SMS_Form_Upload extends CRM_Core_Form { $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 @@ class CRM_SMS_Form_Upload extends CRM_Core_Form { 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 @@ class CRM_SMS_Form_Upload extends CRM_Core_Form { $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 @@ class CRM_SMS_Form_Upload extends CRM_Core_Form { } } 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 11668b1385..1d4646114f 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 3cff861b07..b4feead66f 100644 --- a/CRM/Tag/Form/Edit.php +++ b/CRM/Tag/Form/Edit.php @@ -68,14 +68,14 @@ class CRM_Tag_Form_Edit extends CRM_Admin_Form { 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 @@ class CRM_Tag_Form_Edit extends CRM_Admin_Form { 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 @@ class CRM_Tag_Form_Edit extends CRM_Admin_Form { $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 @@ class CRM_Tag_Form_Edit extends CRM_Admin_Form { $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 @@ class CRM_Tag_Form_Edit extends CRM_Admin_Form { $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 @@ class CRM_Tag_Form_Edit extends CRM_Admin_Form { 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 @@ class CRM_Tag_Form_Edit extends CRM_Admin_Form { } 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 @@ class CRM_Tag_Form_Edit extends CRM_Admin_Form { $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 e8ce8b4957..a581bf141f 100644 --- a/CRM/Tag/Form/Merge.php +++ b/CRM/Tag/Form/Merge.php @@ -45,7 +45,7 @@ class CRM_Tag_Form_Merge extends CRM_Core_Form { 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 @@ class CRM_Tag_Form_Merge extends CRM_Core_Form { $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 @@ class CRM_Tag_Form_Merge extends CRM_Core_Form { */ public function setDefaultValues() { $primary = CRM_Utils_Array::first($this->_tags); - return array( + return [ 'name' => $primary['name'], - ); + ]; } /** @@ -106,7 +106,7 @@ class CRM_Tag_Form_Merge extends CRM_Core_Form { } 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 @@ class CRM_Tag_Form_Merge extends CRM_Core_Form { } 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 321bcd9aec..27e5048e21 100644 --- a/CRM/Tag/Form/Tag.php +++ b/CRM/Tag/Form/Tag.php @@ -81,15 +81,15 @@ class CRM_Tag_Form_Tag extends CRM_Core_Form { // 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 6ed3c4181c..11d899a511 100644 --- a/CRM/Tag/Page/Tag.php +++ b/CRM/Tag/Page/Tag.php @@ -43,23 +43,23 @@ class CRM_Tag_Page_Tag extends CRM_Core_Page { 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 a04b5b4c62..2379f2fef6 100644 --- a/CRM/UF/Form/AbstractPreview.php +++ b/CRM/UF/Form/AbstractPreview.php @@ -80,7 +80,7 @@ class CRM_UF_Form_AbstractPreview extends CRM_Core_Form { * 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 f2945f63da..7caff1af5d 100644 --- a/CRM/UF/Form/AdvanceSetting.php +++ b/CRM/UF/Form/AdvanceSetting.php @@ -48,7 +48,7 @@ class CRM_UF_Form_AdvanceSetting extends CRM_UF_Form_Group { $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 @@ class CRM_UF_Form_AdvanceSetting extends CRM_UF_Form_Group { $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 @@ class CRM_UF_Form_AdvanceSetting extends CRM_UF_Form_Group { // 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 @@ class CRM_UF_Form_AdvanceSetting extends CRM_UF_Form_Group { $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 5b0c433a78..7617d6f804 100644 --- a/CRM/UF/Form/Field.php +++ b/CRM/UF/Form/Field.php @@ -105,12 +105,12 @@ class CRM_UF_Form_Field extends CRM_Core_Form { $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 @@ class CRM_UF_Form_Field extends CRM_Core_Form { $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 @@ class CRM_UF_Form_Field extends CRM_Core_Form { */ 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 @@ class CRM_UF_Form_Field extends CRM_Core_Form { $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 @@ class CRM_UF_Form_Field extends CRM_Core_Form { $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 @@ class CRM_UF_Form_Field extends CRM_Core_Form { $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 @@ class CRM_UF_Form_Field extends CRM_Core_Form { 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 @@ class CRM_UF_Form_Field extends CRM_Core_Form { } } - $this->_defaults = array(); + $this->_defaults = []; $js = "