Merge in 5.11
authorSeamus Lee <seamuslee001@gmail.com>
Sun, 3 Mar 2019 00:39:19 +0000 (11:39 +1100)
committerSeamus Lee <seamuslee001@gmail.com>
Sun, 3 Mar 2019 00:39:19 +0000 (11:39 +1100)
284 files changed:
CRM/ACL/BAO/ACL.php
CRM/Activity/BAO/Activity.php
CRM/Activity/Form/Activity.php
CRM/Activity/Form/Search.php
CRM/Activity/Page/AJAX.php
CRM/Activity/Selector/Activity.php
CRM/Activity/Selector/Search.php
CRM/Admin/Form/Preferences/Display.php
CRM/Admin/Form/SettingTrait.php
CRM/Admin/Page/AJAX.php
CRM/Campaign/BAO/Campaign.php
CRM/Campaign/BAO/Survey.php
CRM/Campaign/Form/Petition.php
CRM/Campaign/Form/Survey/Main.php
CRM/Campaign/Form/Task/Interview.php
CRM/Campaign/Selector/Search.php
CRM/Case/BAO/Case.php
CRM/Case/Form/Activity.php
CRM/Case/Form/Activity/ChangeCaseType.php
CRM/Case/Form/Activity/OpenCase.php
CRM/Case/Form/AddToCaseAsRole.php
CRM/Case/Form/Search.php
CRM/Case/Selector/Search.php
CRM/Case/XMLProcessor/Process.php
CRM/Contact/BAO/Contact.php
CRM/Contact/BAO/Group.php
CRM/Contact/BAO/GroupContact.php
CRM/Contact/BAO/Query.php
CRM/Contact/Form/Edit/Address.php
CRM/Contact/Form/Search/Criteria.php
CRM/Contact/Form/Task.php
CRM/Contact/Page/View/UserDashBoard.php
CRM/Contact/Selector.php
CRM/Contribute/BAO/Contribution.php
CRM/Contribute/BAO/ContributionRecur.php
CRM/Contribute/BAO/Query.php
CRM/Contribute/DAO/ContributionRecur.php
CRM/Contribute/Form/AdditionalPayment.php
CRM/Contribute/Form/Contribution/Confirm.php
CRM/Contribute/Form/Contribution/ThankYou.php
CRM/Contribute/Form/ContributionView.php
CRM/Contribute/Form/Search.php
CRM/Contribute/Page/ContributionPage.php
CRM/Contribute/Page/Tab.php
CRM/Contribute/Page/UserDashboard.php
CRM/Contribute/Selector/Search.php
CRM/Core/BAO/Address.php
CRM/Core/BAO/CustomField.php
CRM/Core/BAO/CustomValueTable.php
CRM/Core/BAO/FinancialTrxn.php
CRM/Core/BAO/Navigation.php
CRM/Core/BAO/UFGroup.php
CRM/Core/DAO.php
CRM/Core/DAO/AllCoreTables.php
CRM/Core/Form.php
CRM/Core/Form/EntityFormTrait.php
CRM/Core/Form/Renderer.php
CRM/Core/Form/Tag.php
CRM/Core/PseudoConstant.php
CRM/Core/Resources.php
CRM/Core/Smarty/plugins/function.crmNavigationMenu.php [deleted file]
CRM/Core/xml/Menu/Activity.xml
CRM/Core/xml/Menu/Admin.xml
CRM/Custom/Form/CustomData.php
CRM/Dedupe/BAO/Rule.php
CRM/Dedupe/DAO/Exception.php
CRM/Dedupe/Merger.php
CRM/Event/BAO/Event.php
CRM/Event/BAO/ParticipantPayment.php
CRM/Event/BAO/Query.php
CRM/Event/Form/ManageEvent/Conference.php
CRM/Event/Form/ManageEvent/Location.php
CRM/Event/Form/Participant.php
CRM/Event/Form/Registration/Register.php
CRM/Event/Form/Search.php
CRM/Event/Selector/Search.php
CRM/Export/BAO/Export.php
CRM/Financial/BAO/ExportFormat.php
CRM/Financial/BAO/FinancialType.php
CRM/Financial/BAO/Payment.php
CRM/Grant/Form/Search.php
CRM/Logging/Schema.php
CRM/Mailing/Event/BAO/Reply.php
CRM/Mailing/Selector/Search.php
CRM/Member/BAO/Membership.php
CRM/Member/BAO/MembershipLog.php
CRM/Member/BAO/MembershipStatus.php
CRM/Member/BAO/MembershipType.php
CRM/Member/Form/Search.php
CRM/Member/Page/DashBoard.php
CRM/Member/Selector/Search.php
CRM/Pledge/Form/Search.php
CRM/Profile/Form.php
CRM/Report/Form.php
CRM/Report/Form/Case/Detail.php
CRM/Report/Form/Contribute/Bookkeeping.php
CRM/Report/Form/Contribute/Repeat.php
CRM/Report/Form/Contribute/SoftCredit.php
CRM/Report/Form/Contribute/Summary.php
CRM/Report/Form/Event/Income.php
CRM/Report/Form/Event/IncomeCountSummary.php
CRM/Report/Form/Event/ParticipantListCount.php
CRM/Report/Form/Event/ParticipantListing.php
CRM/Report/Form/Event/Summary.php
CRM/Report/Form/Member/Detail.php
CRM/Upgrade/4.2.alpha1.msg_template/civicrm_msg_template.tpl [deleted file]
CRM/Upgrade/4.2.alpha1.msg_template/message_templates/contribution_online_receipt_html.tpl [deleted file]
CRM/Upgrade/4.2.alpha1.msg_template/message_templates/contribution_online_receipt_text.tpl [deleted file]
CRM/Upgrade/4.2.alpha1.msg_template/message_templates/contribution_recurring_billing_html.tpl [deleted file]
CRM/Upgrade/4.2.alpha1.msg_template/message_templates/contribution_recurring_billing_subject.tpl [deleted file]
CRM/Upgrade/4.2.alpha1.msg_template/message_templates/contribution_recurring_billing_text.tpl [deleted file]
CRM/Upgrade/4.2.alpha1.msg_template/message_templates/contribution_recurring_cancelled_html.tpl [deleted file]
CRM/Upgrade/4.2.alpha1.msg_template/message_templates/contribution_recurring_cancelled_subject.tpl [deleted file]
CRM/Upgrade/4.2.alpha1.msg_template/message_templates/contribution_recurring_cancelled_text.tpl [deleted file]
CRM/Upgrade/4.2.alpha1.msg_template/message_templates/contribution_recurring_edit_html.tpl [deleted file]
CRM/Upgrade/4.2.alpha1.msg_template/message_templates/contribution_recurring_edit_subject.tpl [deleted file]
CRM/Upgrade/4.2.alpha1.msg_template/message_templates/contribution_recurring_edit_text.tpl [deleted file]
CRM/Upgrade/4.2.alpha1.msg_template/message_templates/contribution_recurring_notify_html.tpl [deleted file]
CRM/Upgrade/4.2.alpha1.msg_template/message_templates/contribution_recurring_notify_text.tpl [deleted file]
CRM/Upgrade/4.2.alpha1.msg_template/message_templates/event_online_receipt_html.tpl [deleted file]
CRM/Upgrade/4.2.alpha1.msg_template/message_templates/event_online_receipt_text.tpl [deleted file]
CRM/Upgrade/4.2.alpha1.msg_template/message_templates/membership_autorenew_billing_html.tpl [deleted file]
CRM/Upgrade/4.2.alpha1.msg_template/message_templates/membership_autorenew_billing_subject.tpl [deleted file]
CRM/Upgrade/4.2.alpha1.msg_template/message_templates/membership_autorenew_billing_text.tpl [deleted file]
CRM/Upgrade/4.2.alpha1.msg_template/message_templates/membership_autorenew_cancelled_html.tpl [deleted file]
CRM/Upgrade/4.2.alpha1.msg_template/message_templates/membership_autorenew_cancelled_subject.tpl [deleted file]
CRM/Upgrade/4.2.alpha1.msg_template/message_templates/membership_autorenew_cancelled_text.tpl [deleted file]
CRM/Upgrade/4.2.alpha1.msg_template/message_templates/membership_online_receipt_html.tpl [deleted file]
CRM/Upgrade/4.2.alpha1.msg_template/message_templates/membership_online_receipt_text.tpl [deleted file]
CRM/Upgrade/4.2.alpha1.msg_template/message_templates/pledge_acknowledge_html.tpl [deleted file]
CRM/Upgrade/4.2.alpha1.msg_template/message_templates/pledge_acknowledge_text.tpl [deleted file]
CRM/Upgrade/4.2.alpha1.msg_template/message_templates/pledge_reminder_html.tpl [deleted file]
CRM/Upgrade/4.2.alpha1.msg_template/message_templates/pledge_reminder_text.tpl [deleted file]
CRM/Upgrade/4.2.alpha2.msg_template/civicrm_msg_template.tpl [deleted file]
CRM/Upgrade/4.2.alpha2.msg_template/message_templates/event_offline_receipt_html.tpl [deleted file]
CRM/Upgrade/4.2.alpha2.msg_template/message_templates/event_offline_receipt_text.tpl [deleted file]
CRM/Upgrade/4.2.alpha2.msg_template/message_templates/event_online_receipt_html.tpl [deleted file]
CRM/Upgrade/4.2.alpha2.msg_template/message_templates/event_online_receipt_text.tpl [deleted file]
CRM/Upgrade/4.2.alpha2.msg_template/message_templates/membership_offline_receipt_text.tpl [deleted file]
CRM/Upgrade/4.2.alpha3.msg_template/civicrm_msg_template.tpl [deleted file]
CRM/Upgrade/4.2.alpha3.msg_template/message_templates/contribution_online_receipt_text.tpl [deleted file]
CRM/Upgrade/4.2.beta3.msg_template/civicrm_msg_template.tpl [deleted file]
CRM/Upgrade/4.2.beta3.msg_template/message_templates/event_online_receipt_html.tpl [deleted file]
CRM/Upgrade/4.2.beta3.msg_template/message_templates/event_online_receipt_text.tpl [deleted file]
CRM/Upgrade/Form.php
CRM/Upgrade/Incremental/Base.php
CRM/Upgrade/Incremental/MessageTemplates.php
CRM/Upgrade/Incremental/SmartGroups.php
CRM/Upgrade/Incremental/php/FiveEleven.php
CRM/Upgrade/Incremental/php/FiveTwelve.php [new file with mode: 0644]
CRM/Upgrade/Incremental/php/FourTwo.php [deleted file]
CRM/Upgrade/Incremental/sql/4.2.0.mysql.tpl [deleted file]
CRM/Upgrade/Incremental/sql/4.2.1.mysql.tpl [deleted file]
CRM/Upgrade/Incremental/sql/4.2.2.mysql.tpl [deleted file]
CRM/Upgrade/Incremental/sql/4.2.3.mysql.tpl [deleted file]
CRM/Upgrade/Incremental/sql/4.2.5.mysql.tpl [deleted file]
CRM/Upgrade/Incremental/sql/4.2.6.mysql.tpl [deleted file]
CRM/Upgrade/Incremental/sql/4.2.7.mysql.tpl [deleted file]
CRM/Upgrade/Incremental/sql/4.2.8.mysql.tpl [deleted file]
CRM/Upgrade/Incremental/sql/4.2.9.mysql.tpl [deleted file]
CRM/Upgrade/Incremental/sql/4.2.alpha1.mysql.tpl [deleted file]
CRM/Upgrade/Incremental/sql/4.2.alpha2.mysql.tpl [deleted file]
CRM/Upgrade/Incremental/sql/4.2.alpha3.mysql.tpl [deleted file]
CRM/Upgrade/Incremental/sql/4.2.beta1.mysql.tpl [deleted file]
CRM/Upgrade/Incremental/sql/4.2.beta2.mysql.tpl [deleted file]
CRM/Upgrade/Incremental/sql/4.2.beta3.mysql.tpl [deleted file]
CRM/Upgrade/Incremental/sql/4.2.beta5.mysql.tpl [deleted file]
CRM/Upgrade/Incremental/sql/4.2.beta6.mysql.tpl [deleted file]
CRM/Upgrade/Incremental/sql/4.7.30.mysql.tpl
CRM/Upgrade/Incremental/sql/4.7.32.mysql.tpl
CRM/Upgrade/Incremental/sql/5.12.alpha1.mysql.tpl [new file with mode: 0644]
CRM/Upgrade/Snapshot/V4p2/Price/BAO/Field.php [deleted file]
CRM/Upgrade/Snapshot/V4p2/Price/BAO/FieldValue.php [deleted file]
CRM/Upgrade/Snapshot/V4p2/Price/BAO/LineItem.php [deleted file]
CRM/Upgrade/Snapshot/V4p2/Price/BAO/Set.php [deleted file]
CRM/Upgrade/Snapshot/V4p2/Price/DAO/Field.php [deleted file]
CRM/Upgrade/Snapshot/V4p2/Price/DAO/FieldValue.php [deleted file]
CRM/Upgrade/Snapshot/V4p2/Price/DAO/LineItem.php [deleted file]
CRM/Upgrade/Snapshot/V4p2/Price/DAO/Set.php [deleted file]
CRM/Upgrade/Snapshot/V4p2/Price/DAO/SetEntity.php [deleted file]
CRM/Utils/Address/BatchUpdate.php
CRM/Utils/Check/Component/Env.php
CRM/Utils/PDF/Utils.php
CRM/Utils/PagerAToZ.php
CRM/Utils/ReCAPTCHA.php
CRM/Utils/SQL/TempTable.php
CRM/Utils/Type.php
Civi/API/Subscriber/DynamicFKAuthorization.php
Civi/CCase/Analyzer.php
Civi/CCase/SequenceListener.php
Civi/Install/Requirements.php
Civi/Test/Api3TestTrait.php
ang/crmUtil.js
api/v3/Contact.php
api/v3/Exception.php [moved from CRM/Report/Form/Event.php with 64% similarity]
api/v3/Payment.php
bower.json
composer.json
composer.lock
css/civicrm.css
css/civicrmNavigation.css [deleted file]
css/crm-menubar.css [new file with mode: 0644]
css/joomla.css
css/menubar-backdrop.css [new file with mode: 0644]
css/menubar-drupal7.css [new file with mode: 0644]
css/menubar-drupal8.css [new file with mode: 0644]
css/menubar-joomla.css [new file with mode: 0644]
css/menubar-wordpress.css [new file with mode: 0644]
extension-compatibility.json
install/index.php
js/Common.js
js/crm.backdrop.js
js/crm.drupal7.js
js/crm.drupal8.js
js/crm.menubar.js [new file with mode: 0644]
js/crm.wordpress.js
settings/Core.setting.php
settings/Localization.setting.php
settings/Multisite.setting.php
sql/civicrm_generated.mysql
templates/CRM/Activity/Form/Activity.tpl
templates/CRM/Activity/Form/ActivityJs.tpl [deleted file]
templates/CRM/Admin/Form/Preferences/Display.tpl
templates/CRM/Case/Form/Activity.tpl
templates/CRM/Case/Form/Activity/ChangeCaseType.tpl
templates/CRM/Contact/Form/Contact.hlp
templates/CRM/Contact/Form/Contact.tpl
templates/CRM/Contribute/Form/Selector.tpl
templates/CRM/Contribute/Page/ContributionTotals.tpl
templates/CRM/Contribute/Page/UserDashboard.tpl
templates/CRM/Core/AgeRange.tpl
templates/CRM/Core/Form/Field.tpl
templates/CRM/Group/Form/Search.tpl
templates/CRM/common/CMSPrint.tpl
templates/CRM/common/accesskeys.hlp
templates/CRM/common/accesskeys.tpl
templates/CRM/common/joomla.tpl
templates/CRM/common/l10n.js.tpl
tests/phpunit/CRM/Case/BAO/CaseTypeForkTest.php
tests/phpunit/CRM/Contact/BAO/GroupContactCacheTest.php
tests/phpunit/CRM/Contact/BAO/QueryTest.php
tests/phpunit/CRM/Contact/Import/Parser/ContactTest.php
tests/phpunit/CRM/Contact/Page/View/UserDashBoardTest.php
tests/phpunit/CRM/Contribute/BAO/QueryTest.php [new file with mode: 0644]
tests/phpunit/CRM/Contribute/Form/AdditionalPaymentTest.php
tests/phpunit/CRM/Contribute/Form/Contribution/ThankYouTest.php [new file with mode: 0644]
tests/phpunit/CRM/Contribute/Form/SearchTest.php
tests/phpunit/CRM/Core/BAO/AddressTest.php
tests/phpunit/CRM/Core/BAO/FinancialTrxnTest.php
tests/phpunit/CRM/Core/DAO/AllCoreTablesTest.php
tests/phpunit/CRM/Core/Payment/AuthorizeNetTest.php
tests/phpunit/CRM/Core/ResourcesTest.php
tests/phpunit/CRM/Dedupe/DedupeFinderTest.php
tests/phpunit/CRM/Dedupe/MergerTest.php
tests/phpunit/CRM/Event/BAO/AdditionalPaymentTest.php
tests/phpunit/CRM/Event/BAO/ChangeFeeSelectionTest.php
tests/phpunit/CRM/Export/BAO/ExportTest.php
tests/phpunit/CRM/Financial/BAO/FinancialAccountTest.php
tests/phpunit/CRM/Group/Page/AjaxTest.php
tests/phpunit/CRM/Logging/SchemaTest.php
tests/phpunit/CRM/Member/Form/MembershipTest.php
tests/phpunit/CRM/Report/Form/Contribute/DetailTest.php
tests/phpunit/CRM/Upgrade/Incremental/BaseTest.php
tests/phpunit/CRMTraits/Financial/FinancialACLTrait.php
tests/phpunit/CRMTraits/Financial/PriceSetTrait.php
tests/phpunit/Civi/API/Subscriber/DynamicFKAuthorizationTest.php
tests/phpunit/CiviTest/CiviUnitTestCase.php
tests/phpunit/api/v3/AttachmentTest.php
tests/phpunit/api/v3/ContactTest.php
tests/phpunit/api/v3/FinancialTypeACLTest.php
tests/phpunit/api/v3/MailingTest.php
tests/phpunit/api/v3/PaymentTest.php
tests/phpunit/api/v3/ProfileTest.php
tests/phpunit/api/v3/ReportTemplateTest.php
tools/scripts/composer/patches/pear-mail.patch.txt [new file with mode: 0644]
tools/scripts/composer/patches/phpoffice-common-xml-entity-fix.patch [new file with mode: 0644]
tools/scripts/composer/patches/phpword-libxml-fix-global-handling.patch [new file with mode: 0644]
tools/scripts/composer/pear-mail-fix.sh [new file with mode: 0755]
xml/schema/Contribute/Contribution.xml
xml/schema/Contribute/ContributionRecur.xml
xml/schema/Dedupe/Exception.xml
xml/templates/message_templates/payment_or_refund_notification_html.tpl
xml/templates/message_templates/payment_or_refund_notification_text.tpl
xml/version.xml

index 8e6d14ffb10d75de3a74ad60652b11dd308ff96d..7c0eb1af7cd02d00eae95c2bfdbd5f10f81b1ee1 100644 (file)
@@ -840,6 +840,10 @@ SELECT g.*
       return Civi::$statics[__CLASS__]['permissioned_groups'][$userCacheKey];
     }
 
+    if ($allGroups == NULL) {
+      $allGroups = CRM_Contact_BAO_Contact::buildOptions('group_id', NULL, ['onlyActive' => FALSE]);
+    }
+
     $acls = CRM_ACL_BAO_Cache::build($contactID);
 
     $ids = array();
index 7249a8e6d6bba683e8da3e14b44152a9801a9c1f..090ef3b103f6d54bd5bad1201c50fdf713292dcc 100644 (file)
@@ -2361,7 +2361,6 @@ AND cl.modified_id  = c.id
           $priorActivities[$index][$dao->activityID]['name'] = $dao->name;
           $priorActivities[$index][$dao->activityID]['date'] = $dao->date;
         }
-        $dao->free();
       }
     }
     return $priorActivities[$index];
@@ -2678,10 +2677,8 @@ AND cl.modified_id  = c.id
         $result = self::deleteActivity($activityParams);
       }
 
-      $activityContactOther->free();
     }
 
-    $activityContact->free();
     $transaction->commit();
 
     return $result;
@@ -3231,4 +3228,14 @@ INNER JOIN  civicrm_option_group grp ON (grp.id = option_group_id AND grp.name =
     return FALSE;
   }
 
+  /**
+   * @return array
+   */
+  public static function getEntityRefFilters() {
+    return [
+      ['key' => 'activity_type_id', 'value' => ts('Activity Type')],
+      ['key' => 'status_id', 'value' => ts('Activity Status')],
+    ];
+  }
+
 }
index 6e261d06720381aa57fecb5b228dac34d315384c..94f68c1203e8df81ffac9d52e29cea1ed493fa6e 100644 (file)
@@ -792,31 +792,26 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task {
       // form should be frozen for view mode
       $this->freeze();
 
-      $buttons = array();
-      $buttons[] = array(
-        'type' => 'cancel',
-        'name' => ts('Done'),
-      );
-      $this->addButtons($buttons);
+      $this->addButtons([
+        [
+          'type' => 'cancel',
+          'name' => ts('Done'),
+        ],
+      ]);
     }
     else {
-      $message = array(
-        'completed' => ts('Are you sure? This is a COMPLETED activity with the DATE in the FUTURE. Click Cancel to change the date / status. Otherwise, click OK to save.'),
-        'scheduled' => ts('Are you sure? This is a SCHEDULED activity with the DATE in the PAST. Click Cancel to change the date / status. Otherwise, click OK to save.'),
-      );
-      $js = array('onclick' => "return activityStatus(" . json_encode($message) . ");");
-      $this->addButtons(array(
-        array(
+      $this->addButtons([
+        [
           'type' => 'upload',
           'name' => ts('Save'),
-          'js' => $js,
           'isDefault' => TRUE,
-        ),
-        array(
+          'submitOnce' => TRUE,
+        ],
+        [
           'type' => 'cancel',
           'name' => ts('Cancel'),
-        ),
-      ));
+        ],
+      ]);
     }
 
     if ($this->_activityTypeFile) {
index f59e18c13b8de2ac1f9bab46a373f015d83492b5..93a2ae631ca53c5613f41089c338e7612c038c3f 100644 (file)
@@ -87,7 +87,6 @@ class CRM_Activity_Form_Search extends CRM_Core_Form_Search {
     $this->_actionButtonName = $this->getButtonName('next', 'action');
 
     $this->_done = FALSE;
-    $this->defaults = array();
 
     $this->loadStandardSearchOptionsFromUrl();
 
@@ -323,34 +322,6 @@ class CRM_Activity_Form_Search extends CRM_Core_Form_Search {
       }
     }
 
-    // Added for membership search
-
-    $signupType = CRM_Utils_Request::retrieve('signupType', 'Positive');
-
-    if ($signupType) {
-      $this->_formValues['activity_role'] = 1;
-      $this->_defaults['activity_role'] = 1;
-      $activityTypes = CRM_Core_PseudoConstant::activityType(TRUE, FALSE, FALSE, 'name');
-
-      $renew = CRM_Utils_Array::key('Membership Renewal', $activityTypes);
-      $signup = CRM_Utils_Array::key('Membership Signup', $activityTypes);
-
-      switch ($signupType) {
-        case 3: // signups and renewals
-          $this->_formValues['activity_type_id'][$renew] = 1;
-          $this->_defaults['activity_type_id'][$renew] = 1;
-        case 1: // signups only
-          $this->_formValues['activity_type_id'][$signup] = 1;
-          $this->_defaults['activity_type_id'][$signup] = 1;
-          break;
-
-        case 2: // renewals only
-          $this->_formValues['activity_type_id'][$renew] = 1;
-          $this->_defaults['activity_type_id'][$renew] = 1;
-          break;
-      }
-    }
-
     $dateLow = CRM_Utils_Request::retrieve('dateLow', 'String');
 
     if ($dateLow) {
index 787c18d26d14d0e6a8f53fceb606833a35b44ea1..e8be4c76e38806c7dd9b580ce170ef86a13de535 100644 (file)
@@ -309,7 +309,6 @@ class CRM_Activity_Page_AJAX {
     $mainActivity->save();
     $mainActivityId = $mainActivity->id;
     CRM_Activity_BAO_Activity::logActivityAction($mainActivity);
-    $mainActivity->free();
 
     // Mark previous activity as deleted. If it was a non-case activity
     // then just change the subject.
@@ -330,9 +329,7 @@ class CRM_Activity_Page_AJAX {
       }
       $otherActivity->save();
 
-      $caseActivity->free();
     }
-    $otherActivity->free();
 
     $targetContacts = array();
     if (!empty($params['targetContactIds'])) {
@@ -385,7 +382,6 @@ class CRM_Activity_Page_AJAX {
     $params['mainActivityId'] = $mainActivityId;
     CRM_Activity_BAO_Activity::copyExtendedActivityData($params);
     CRM_Utils_Hook::post('create', 'CaseActivity', $caseActivity->id, $caseActivity);
-    $caseActivity->free();
 
     return (array('error_msg' => $error_msg, 'newId' => $mainActivity->id));
   }
index bdc1b18550c0f77b33650f8bd7ef80c8f65ee4f6..544724ffde994e4a22acc8f86fa5d08dbf8d1657 100644 (file)
@@ -112,8 +112,8 @@ class CRM_Activity_Selector_Activity extends CRM_Core_Selector_Base implements C
     $activityId = NULL,
     $key = NULL,
     $compContext = NULL) {
-    static $activityActTypes = NULL;
-    //CRM-14277 added addtitional param to handle activity search
+
+    //CRM-14277 added additional param to handle activity search
     $extraParams = "&searchContext=activity";
 
     $extraParams .= ($key) ? "&key={$key}" : NULL;
@@ -124,11 +124,10 @@ class CRM_Activity_Selector_Activity extends CRM_Core_Selector_Base implements C
     $showView = TRUE;
     $showUpdate = $showDelete = FALSE;
     $qsUpdate = NULL;
+    $url = NULL;
+    $qsView = NULL;
 
-    if (!$activityActTypes) {
-      $activeActTypes = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'name', TRUE);
-    }
-    $activityTypeName = CRM_Utils_Array::value($activityTypeId, $activeActTypes);
+    $activityTypeName = CRM_Core_PseudoConstant::getName('CRM_Activity_BAO_Activity', 'activity_type_id', $activityTypeId);
 
     // CRM-7607
     // Lets allow to have normal operation for only activity types.
index 340dc7588fb7d2c17e9314cb2f73571059b3b3ca..0d9e36c5d156b789c413fb368eaee6ddb2d8b4d5 100644 (file)
@@ -273,8 +273,7 @@ class CRM_Activity_Selector_Search extends CRM_Core_Selector_Base implements CRM
     $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts);
     $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts);
     $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
-    // Get all activity types
-    $activityTypes = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'name', TRUE);
+    $bulkActivityTypeID = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Bulk Email');
 
     while ($result->fetch()) {
       $row = array();
@@ -313,7 +312,6 @@ class CRM_Activity_Selector_Search extends CRM_Core_Selector_Base implements CRM
       if ($row['activity_is_test']) {
         $row['activity_type'] = $row['activity_type'] . " (test)";
       }
-      $bulkActivityTypeID = CRM_Utils_Array::key('Bulk Email', $activityTypes);
       $row['mailingId'] = '';
       if (
         $accessCiviMail &&
@@ -433,7 +431,7 @@ class CRM_Activity_Selector_Search extends CRM_Core_Selector_Base implements CRM
    * @return mixed
    */
   public function alphabetQuery() {
-    return $this->_query->searchQuery(NULL, NULL, NULL, FALSE, FALSE, TRUE);
+    return $this->_query->alphabetQuery();
   }
 
   /**
index 2273f25b7fe81bfd0eb5dcf31caabf9fcaa3bf16..ea13835328fb5a36ec276fb7c7d23d24630e61f2 100644 (file)
@@ -51,6 +51,7 @@ class CRM_Admin_Form_Preferences_Display extends CRM_Admin_Form_Preferences {
     'ajaxPopupsEnabled' => CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
     '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,
   );
 
   /**
index f124ef72e65aec4fd41dd6c3853d181fd1f0fb47..81fb55fa08c4527852e838cab7ea5484bedb4ad9 100644 (file)
@@ -177,6 +177,12 @@ trait CRM_Admin_Form_SettingTrait {
           $options = civicrm_api3('Setting', 'getoptions', [
             'field' => $setting,
           ])['values'];
+          if ($props['html_type'] === 'Select' && isset($props['is_required']) && $props['is_required'] === FALSE && !isset($options[''])) {
+            // If the spec specifies the field is not required add a null option.
+            // Why not if empty($props['is_required']) - basically this has been added to the spec & might not be set to TRUE
+            // when it is true.
+            $options = ['' => ts('None')] + $options;
+          }
         }
         if ($props['type'] === 'Boolean') {
           $options = [$props['title'] => $props['name']];
index 871b6d3e6d55ccae4ba9554196eae38a3388da44..dc1f065896049f286d978488417e01e98685907f 100644 (file)
 class CRM_Admin_Page_AJAX {
 
   /**
-   * CRM-12337 Output navigation menu as executable javascript.
-   *
-   * @see smarty_function_crmNavigationMenu
+   * Outputs menubar data (json format) for the current user.
    */
-  public static function getNavigationMenu() {
-    $contactID = CRM_Core_Session::singleton()->get('userID');
-    if ($contactID) {
-      CRM_Core_Page_AJAX::setJsHeaders();
-      $smarty = CRM_Core_Smarty::singleton();
-      $smarty->assign('quicksearchOptions', self::getSearchOptions());
-      print $smarty->fetchWith('CRM/common/navigation.js.tpl', array(
-        'navigation' => CRM_Core_BAO_Navigation::createNavigation(),
-      ));
+  public static function navMenu() {
+    if (CRM_Core_Session::getLoggedInContactID()) {
+
+      $menu = CRM_Core_BAO_Navigation::buildNavigationTree();
+      CRM_Core_BAO_Navigation::buildHomeMenu($menu);
+      CRM_Utils_Hook::navigationMenu($menu);
+      CRM_Core_BAO_Navigation::fixNavigationMenu($menu);
+      CRM_Core_BAO_Navigation::orderByWeight($menu);
+      CRM_Core_BAO_Navigation::filterByPermission($menu);
+      self::formatMenuItems($menu);
+
+      $output = [
+        'menu' => $menu,
+        'search' => CRM_Utils_Array::makeNonAssociative(self::getSearchOptions()),
+      ];
+      // Encourage browsers to cache for a long time - 1 year
+      $ttl = 60 * 60 * 24 * 364;
+      CRM_Utils_System::setHttpHeader('Expires', gmdate('D, d M Y H:i:s \G\M\T', time() + $ttl));
+      CRM_Utils_System::setHttpHeader('Cache-Control', "max-age=$ttl, public");
+      CRM_Utils_System::setHttpHeader('Content-Type', 'application/json');
+      print (json_encode($output));
     }
     CRM_Utils_System::civiExit();
   }
 
+  /**
+   * @param array $menu
+   */
+  public static function formatMenuItems(&$menu) {
+    foreach ($menu as $key => &$item) {
+      $props = $item['attributes'];
+      unset($item['attributes']);
+      if (!empty($props['separator'])) {
+        $item['separator'] = ($props['separator'] == 1 ? 'bottom' : 'top');
+      }
+      if (!empty($props['icon'])) {
+        $item['icon'] = $props['icon'];
+      }
+      if (!empty($props['attr'])) {
+        $item['attr'] = $props['attr'];
+      }
+      if (!empty($props['url'])) {
+        $item['url'] = CRM_Utils_System::evalUrl(CRM_Core_BAO_Navigation::makeFullyFormedUrl($props['url']));
+      }
+      if (!empty($props['label'])) {
+        $item['label'] = ts($props['label'], ['context' => 'menu']);
+      }
+      $item['name'] = !empty($props['name']) ? $props['name'] : CRM_Utils_String::munge(CRM_Utils_Array::value('label', $props));
+      if (!empty($item['child'])) {
+        self::formatMenuItems($item['child']);
+      }
+    }
+    $menu = array_values($menu);
+  }
+
   public static function getSearchOptions() {
-    $searchOptions = Civi::settings()->get('quicksearch_options');
-    $searchOptions[] = 'sort_name';
-    $searchOptions = array_intersect_key(CRM_Core_SelectValues::quicksearchOptions(), array_flip($searchOptions));
-    foreach ($searchOptions as $key => $label) {
+    $searchOptions = array_merge(['sort_name'], Civi::settings()->get('quicksearch_options'));
+    $labels = CRM_Core_SelectValues::quicksearchOptions();
+    $result = [];
+    foreach ($searchOptions as $key) {
+      $label = $labels[$key];
       if (strpos($key, 'custom_') === 0) {
-        unset($searchOptions[$key]);
-        $id = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField', substr($key, 7), 'id', 'name');
-        $searchOptions["custom_$id"] = $label;
+        $key = 'custom_' . CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomField', substr($key, 7), 'id', 'name');
+        $label = array_slice(explode(': ', $label, 2), -1);
       }
+      $result[$key] = $label;
     }
-    return $searchOptions;
+    return $result;
   }
 
   /**
index 6929423cbb244b9ce3a9375cd7cc78e9b635b2c2..77440fa746e100df3def57bb2f59905ea3dd517f 100644 (file)
@@ -93,7 +93,6 @@ class CRM_Campaign_BAO_Campaign extends CRM_Campaign_DAO_Campaign {
         $dao->entity_id = $entityId;
         $dao->group_type = 'Include';
         $dao->save();
-        $dao->free();
       }
     }
 
@@ -600,7 +599,7 @@ INNER JOIN  civicrm_group grp ON ( grp.id = campgrp.entity_id )
     if ($connectedCampaignId || ($isCampaignEnabled && $hasAccessCampaign)) {
       $showAddCampaign = TRUE;
       $campaign = $form->addEntityRef('campaign_id', ts('Campaign'), [
-        'entity' => 'campaign',
+        'entity' => 'Campaign',
         'create' => TRUE,
         'select' => ['minimumInputLength' => 0],
       ]);
@@ -666,12 +665,50 @@ INNER JOIN  civicrm_group grp ON ( grp.id = campgrp.entity_id )
     $form->assign('campaignInfo', $campaignInfo);
   }
 
+  /**
+   * @return array
+   */
+  public static function getEntityRefFilters() {
+    return [
+      ['key' => 'campaign_type_id', 'value' => ts('Campaign Type')],
+      ['key' => 'status_id', 'value' => ts('Status')],
+      [
+        'key' => 'start_date',
+        'value' => ts('Start Date'),
+        'options' => [
+          ['key' => '{">":"now"}', 'value' => ts('Upcoming')],
+          [
+            'key' => '{"BETWEEN":["now - 3 month","now"]}',
+            'value' => ts('Past 3 Months'),
+          ],
+          [
+            'key' => '{"BETWEEN":["now - 6 month","now"]}',
+            'value' => ts('Past 6 Months'),
+          ],
+          [
+            'key' => '{"BETWEEN":["now - 1 year","now"]}',
+            'value' => ts('Past Year'),
+          ],
+        ],
+      ],
+      [
+        'key' => 'end_date',
+        'value' => ts('End Date'),
+        'options' => [
+          ['key' => '{">":"now"}', 'value' => ts('In the future')],
+          ['key' => '{"<":"now"}', 'value' => ts('In the past')],
+          ['key' => '{"IS NULL":"1"}', 'value' => ts('Not set')],
+        ],
+      ],
+    ];
+  }
+
   /**
    * Links to create new campaigns from entityRef widget
    *
    * @return array|bool
    */
-  public static function entityRefCreateLinks() {
+  public static function getEntityRefCreateLinks() {
     if (CRM_Core_Permission::check([['administer CiviCampaign', 'manage campaign']])) {
       return [
         [
index 95987c774a288ec7745442f436c5c3c893502ed3..58c45b25e234460fa63543e676bcfc04c27dde16 100644 (file)
@@ -504,7 +504,6 @@ SELECT  survey.id    as id,
         );
         $voterDetails[$contact->contactId]['contact_type'] = $image;
       }
-      $contact->free();
     }
 
     return $voterDetails;
index d04659c297f98344a545aa943da420bbc7d74895..e1e005eda01fc2b4b6e4e3d58bae0c6a5322822c 100644 (file)
@@ -191,7 +191,7 @@ class CRM_Campaign_Form_Petition extends CRM_Core_Form {
     $this->add('wysiwyg', 'instructions', ts('Introduction'), $attributes['instructions']);
 
     $this->addEntityRef('campaign_id', ts('Campaign'), [
-      'entity' => 'campaign',
+      'entity' => 'Campaign',
       'create' => TRUE,
       'select' => ['minimumInputLength' => 0],
     ]);
index 2ef5899ad9f08b2dd0de09cc24b4b24c476a35d2..901981ab07daf975066349c8936b87f82e7276fa 100644 (file)
@@ -130,7 +130,7 @@ class CRM_Campaign_Form_Survey_Main extends CRM_Campaign_Form_Survey {
     $this->addSelect('activity_type_id', array('option_url' => 'civicrm/admin/campaign/surveyType'), TRUE);
 
     $this->addEntityRef('campaign_id', ts('Campaign'), [
-      'entity' => 'campaign',
+      'entity' => 'Campaign',
       'create' => TRUE,
       'select' => ['minimumInputLength' => 0],
     ]);
index 17ffa9cb02ca3c175d1d758998f1887bc3d74f18..82fdf3b6d32429d7d927ea3a894d1c7833ac21b7 100644 (file)
@@ -559,7 +559,6 @@ WHERE {$clause}
     //really this should use Activity BAO& not be here but refactoring will have to be later
     //actually the whole ajax call could be done as an api ajax call & post hook would be sorted
     CRM_Utils_Hook::post('edit', 'Activity', $activity->id, $activity);
-    $activity->free();
 
     return $activityId;
   }
index 8d71c4cd1e1e5f9ecf4722219a4a4e6c99a92ee0..ec046e6ab3602c95f9faf9f88610cedf0192b117 100644 (file)
@@ -273,10 +273,10 @@ class CRM_Campaign_Selector_Search extends CRM_Core_Selector_Base implements CRM
       $cacheKey = "civicrm search {$this->_key}";
       Civi::service('prevnext')->deleteItem(NULL, $cacheKey, 'civicrm_contact');
 
-      $sql = $this->_query->searchQuery(0, 0, $sort,
+      $sql = $this->_query->getSearchSQL(0, 0, $sort,
         FALSE, FALSE,
         FALSE, FALSE,
-        TRUE, $this->_campaignWhereClause,
+        $this->_campaignWhereClause,
         NULL,
         $this->_campaignFromClause
       );
index 06102fe28a38a9990426609a0406a9d972892aac..fb84b9ce3546ea7ce24985d3a304b20a44dfaf6c 100644 (file)
@@ -1061,7 +1061,6 @@ SELECT case_status.label AS case_status, status_id, civicrm_case_type.title AS c
     $caseCount = CRM_Core_DAO::singleValueQuery('SELECT FOUND_ROWS()');
 
     $activityTypes = CRM_Case_PseudoConstant::caseActivityType(FALSE, TRUE);
-    $activityStatuses = CRM_Core_PseudoConstant::activityStatus();
 
     $url = CRM_Utils_System::url("civicrm/case/activity",
       "reset=1&cid={$contactID}&caseid={$caseID}", FALSE, NULL, FALSE
@@ -1096,7 +1095,6 @@ SELECT case_status.label AS case_status, status_id, civicrm_case_type.title AS c
     $caseActivities = array();
 
     while ($dao->fetch()) {
-      $caseActivity = array();
       $caseActivityId = $dao->id;
 
       $allowView = self::checkPermission($caseActivityId, 'view', $dao->activity_type_id, $userID);
@@ -1175,8 +1173,8 @@ SELECT case_status.label AS case_status, status_id, civicrm_case_type.title AS c
         }
       }
 
-      //Activity Status
-      $caseActivities[$caseActivityId]['status_id'] = $activityStatuses[$dao->status];
+      // Activity Status Label for Case activities list
+      $caseActivities[$caseActivityId]['status_id'] = CRM_Core_PseudoConstant::getLabel('CRM_Activity_BAO_Activity', 'activity_status_id', $dao->status);
 
       // FIXME: Why are we not using CRM_Core_Action for these links? This is too much manual work and likely to get out-of-sync with core markup.
       $url = "";
@@ -1977,9 +1975,7 @@ SELECT civicrm_contact.id as casemanager_id,
       return array();
     }
 
-    $linkActType = array_search('Link Cases',
-      CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'name')
-    );
+    $linkActType = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Link Cases');
     if (!$linkActType) {
       return array();
     }
@@ -2138,8 +2134,8 @@ SELECT civicrm_contact.id as casemanager_id,
       return $mainCaseIds;
     }
 
-    $activityTypes = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'name');
-    $activityStatuses = CRM_Core_PseudoConstant::activityStatus('name');
+    $activityTypes = CRM_Activity_BAO_Activity::buildOptions('activity_type_id', 'validate');
+    $completedActivityStatus = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_status_id', 'Completed');
     $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate');
     $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts);
     $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts);
@@ -2195,8 +2191,6 @@ SELECT civicrm_contact.id as casemanager_id,
           }
         }
 
-        $mainCase->free();
-
         $mainCaseIds[] = $mainCaseId;
         //insert record for case contact.
         $otherCaseContact = new CRM_Case_DAO_CaseContact();
@@ -2213,9 +2207,7 @@ SELECT civicrm_contact.id as casemanager_id,
           if (!$mainCaseContact->find(TRUE)) {
             $mainCaseContact->save();
           }
-          $mainCaseContact->free();
         }
-        $otherCaseContact->free();
       }
       elseif (!$otherContactId) {
         $otherContactId = $mainContactId;
@@ -2299,8 +2291,6 @@ SELECT  id
         // insert log of all activities
         CRM_Activity_BAO_Activity::logActivityAction($mainActivity);
 
-        $otherActivity->free();
-        $mainActivity->free();
         $copiedActivityIds[] = $otherActivityId;
 
         //create case activity record.
@@ -2308,7 +2298,6 @@ SELECT  id
         $mainCaseActivity->case_id = $mainCaseId;
         $mainCaseActivity->activity_id = $mainActivityId;
         $mainCaseActivity->save();
-        $mainCaseActivity->free();
 
         //migrate source activity.
         $otherSourceActivity = new CRM_Activity_DAO_ActivityContact();
@@ -2327,9 +2316,7 @@ SELECT  id
           if (!$mainActivitySource->find(TRUE)) {
             $mainActivitySource->save();
           }
-          $mainActivitySource->free();
         }
-        $otherSourceActivity->free();
 
         //migrate target activities.
         $otherTargetActivity = new CRM_Activity_DAO_ActivityContact();
@@ -2348,9 +2335,7 @@ SELECT  id
           if (!$mainActivityTarget->find(TRUE)) {
             $mainActivityTarget->save();
           }
-          $mainActivityTarget->free();
         }
-        $otherTargetActivity->free();
 
         //migrate assignee activities.
         $otherAssigneeActivity = new CRM_Activity_DAO_ActivityContact();
@@ -2369,9 +2354,7 @@ SELECT  id
           if (!$mainAssigneeActivity->find(TRUE)) {
             $mainAssigneeActivity->save();
           }
-          $mainAssigneeActivity->free();
         }
-        $otherAssigneeActivity->free();
 
         // copy custom fields and attachments
         $aparams = array(
@@ -2417,14 +2400,12 @@ SELECT  id
           if (!$mainRelationship->find(TRUE)) {
             $mainRelationship->save();
           }
-          $mainRelationship->free();
 
           //get the other relationship ids to update end date.
           if ($updateOtherRel) {
             $otherRelationshipIds[$otherRelationship->id] = $otherRelationship->id;
           }
         }
-        $otherRelationship->free();
 
         //update other relationships end dates
         if (!empty($otherRelationshipIds)) {
@@ -2486,11 +2467,11 @@ WHERE id IN (' . implode(',', $copiedActivityIds) . ')';
         }
       }
 
-      //Create merge activity record. Source for merge activity is the logged in user's contact ID ($currentUserId).
+      // Create merge activity record. Source for merge activity is the logged in user's contact ID ($currentUserId).
       $activityParams = array(
         'subject' => $mergeActSubject,
         'details' => $mergeActSubjectDetails,
-        'status_id' => array_search('Completed', $activityStatuses),
+        'status_id' => $completedActivityStatus,
         'activity_type_id' => $mergeActType,
         'source_contact_id' => $currentUserId,
         'activity_date_time' => date('YmdHis'),
@@ -2501,7 +2482,6 @@ WHERE id IN (' . implode(',', $copiedActivityIds) . ')';
       if (!$mergeActivityId) {
         continue;
       }
-      $mergeActivity->free();
 
       //connect merge activity to case.
       $mergeCaseAct = array(
@@ -2736,10 +2716,7 @@ WHERE id IN (' . implode(',', $copiedActivityIds) . ')';
 
     //do further only when operation is granted.
     if ($allow) {
-      $activityTypes = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'name');
-
-      //get the activity type name.
-      $actTypeName = CRM_Utils_Array::value($actTypeId, $activityTypes);
+      $actTypeName = CRM_Core_PseudoConstant::getName('CRM_Activity_BAO_Activity', 'activity_type_id', $actTypeId);
 
       //do not allow multiple copy / edit action.
       $singletonNames = array(
@@ -3116,7 +3093,6 @@ WHERE id IN (' . implode(',', $copiedActivityIds) . ')';
       if (!$newRelationship->find(TRUE)) {
         $newRelationship->save();
       }
-      $newRelationship->free();
 
       // store relationship type of newly created relationship
       $relationshipTypes[] = $caseRelationships->relationship_type_id;
@@ -3278,4 +3254,28 @@ WHERE id IN (' . implode(',', $copiedActivityIds) . ')';
     return "$name <$address>";
   }
 
+  /**
+   * @return array
+   */
+  public static function getEntityRefFilters() {
+    $filters = [
+      [
+        'key' => 'case_id.case_type_id',
+        'value' => ts('Case Type'),
+        'entity' => 'Case',
+      ],
+      [
+        'key' => 'case_id.status_id',
+        'value' => ts('Case Status'),
+        'entity' => 'Case',
+      ],
+    ];
+    foreach (CRM_Contact_BAO_Contact::getEntityRefFilters() as $filter) {
+      $filter += ['entity' => 'Contact'];
+      $filter['key'] = 'contact_id.' . $filter['key'];
+      $filters[] = $filter;
+    }
+    return $filters;
+  }
+
 }
index b027243ff4f6b4fc0fbe62a9ec322a5ee96e0ef9..7a7b3b92b6c76f641b6335542f4bbf2ab20b3991 100644 (file)
@@ -70,7 +70,7 @@ class CRM_Case_Form_Activity extends CRM_Activity_Form_Activity {
     $this->_crmDir = 'Case';
     $this->assign('context', $this->_context);
 
-    $result = parent::preProcess();
+    parent::preProcess();
 
     $scheduleStatusId = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_status_id', 'Scheduled');
     $this->assign('scheduleStatusId', $scheduleStatusId);
@@ -573,7 +573,7 @@ class CRM_Case_Form_Activity extends CRM_Activity_Form_Activity {
       unset($caseParams['subject'], $caseParams['details'],
         $caseParams['status_id'], $caseParams['custom']
       );
-      $case = CRM_Case_BAO_Case::create($caseParams);
+      CRM_Case_BAO_Case::create($caseParams);
       // create case activity record
       $caseParams = array(
         'activity_id' => $vval['actId'],
@@ -582,10 +582,6 @@ class CRM_Case_Form_Activity extends CRM_Activity_Form_Activity {
       CRM_Case_BAO_Case::processCaseActivity($caseParams);
     }
 
-    // Insert civicrm_log record for the activity (e.g. store the
-    // created / edited by contact id and date for the activity)
-    // Note - civicrm_log is already created by CRM_Activity_BAO_Activity::create()
-
     // send copy to selected contacts.
     $mailStatus = '';
     $mailToContacts = array();
@@ -593,8 +589,6 @@ class CRM_Case_Form_Activity extends CRM_Activity_Form_Activity {
     //CRM-5695
     //check for notification settings for assignee contacts
     $selectedContacts = array('contact_check');
-    $activityContacts = CRM_Activity_BAO_ActivityContact::buildOptions('record_type_id', 'validate');
-    $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts);
     if (Civi::settings()->get('activity_assignee_notification')) {
       $selectedContacts[] = 'assignee_contact_id';
     }
index 42c2f5bc59b6ff94aa0084fce82a301cf673120d..53fa4a051bbe1405541be445d2384ce9bb4ee825 100644 (file)
@@ -61,8 +61,7 @@ class CRM_Case_Form_Activity_ChangeCaseType {
 
     $defaults['is_reset_timeline'] = 1;
 
-    $defaults['reset_date_time'] = array();
-    list($defaults['reset_date_time'], $defaults['reset_date_time_time']) = CRM_Utils_Date::setDateDefaults(NULL, 'activityDateTime');
+    $defaults['reset_date_time'] = date('Y-m-d H:i:s');
     $defaults['case_type_id'] = $form->_caseTypeId;
 
     return $defaults;
@@ -88,8 +87,8 @@ class CRM_Case_Form_Activity_ChangeCaseType {
     $form->addField('case_type_id', array('context' => 'create', 'entity' => 'Case'));
 
     // timeline
-    $form->addYesNo('is_reset_timeline', ts('Reset Case Timeline?'), NULL, TRUE, array('onclick' => "return showHideByValue('is_reset_timeline','','resetTimeline','table-row','radio',false);"));
-    $form->addDateTime('reset_date_time', ts('Reset Start Date'), FALSE, array('formatType' => 'activityDateTime'));
+    $form->addYesNo('is_reset_timeline', ts('Reset Case Timeline?'), NULL, TRUE);
+    $form->add('datepicker', 'reset_date_time', ts('Reset Start Date'), NULL, FALSE, ['allowClear' => FALSE]);
   }
 
   /**
@@ -123,10 +122,6 @@ class CRM_Case_Form_Activity_ChangeCaseType {
     if (CRM_Utils_Array::value('is_reset_timeline', $params) == 0) {
       unset($params['reset_date_time']);
     }
-    else {
-      // store the date with proper format
-      $params['reset_date_time'] = CRM_Utils_Date::processDate($params['reset_date_time'], $params['reset_date_time_time']);
-    }
   }
 
   /**
index 73f6f5a4c45acf251a93032bbcf35f110c8df677..b2f2c5eaaa1e494b5a61bded01fb4574b2c9f2ce 100644 (file)
@@ -197,11 +197,13 @@ class CRM_Case_Form_Activity_OpenCase {
           'type' => 'upload',
           'name' => ts('Save'),
           'isDefault' => TRUE,
+          'submitOnce' => TRUE,
         ),
         array(
           'type' => 'upload',
           'name' => ts('Save and New'),
           'subName' => 'new',
+          'submitOnce' => TRUE,
         ),
         array(
           'type' => 'cancel',
index d62dd92ad12609d983f84efe5626afb7c061e506..af02512fdd4044ed2b0452db89dd42d69e25fa00 100644 (file)
@@ -23,7 +23,7 @@ class CRM_Case_Form_AddToCaseAsRole extends CRM_Contact_Form_Task {
     $this->addEntityRef(
       'assign_to',
       ts('Assign to'),
-      array('entity' => 'case'),
+      array('entity' => 'Case'),
       TRUE
     );
 
index df38d23fcf0cc00521e119b23098d3ac680d9202..14ca731cc0ff5360c4756b6ec88f3792dae99a13 100644 (file)
@@ -87,7 +87,6 @@ class CRM_Case_Form_Search extends CRM_Core_Form_Search {
     $this->_actionButtonName = $this->getButtonName('next', 'action');
 
     $this->_done = FALSE;
-    $this->defaults = array();
 
     $this->loadStandardSearchOptionsFromUrl();
     $this->loadFormValues();
index 5bba715ceced217becb723ffef1b0311f2eaa297..d068a128af98549fdf69b47269bb4f000d39da94 100644 (file)
@@ -456,7 +456,7 @@ class CRM_Case_Selector_Search extends CRM_Core_Selector_Base {
    * @return mixed
    */
   public function alphabetQuery() {
-    return $this->_query->searchQuery(NULL, NULL, NULL, FALSE, FALSE, TRUE);
+    return $this->_query->alphabetQuery();
   }
 
   /**
index eef735e44a254611d66d52663b9a6810ae32171d..255c7cc02985470434a1e53117fd65d67270837d 100644 (file)
@@ -197,7 +197,7 @@ class CRM_Case_XMLProcessor_Process extends CRM_Case_XMLProcessor {
         if (!$isCaseManager) {
           $result[$relationshipTypeID] = $relationshipTypeName;
         }
-        elseif ($relationshipTypeXML->manager) {
+        elseif ($relationshipTypeXML->manager == 1) {
           return $relationshipTypeID;
         }
       }
index da45da8e39c6714b92bb3e9dec1b327ef97f595b..561f60777f1dfb9fb3244919ac1faad4e1423cba 100644 (file)
@@ -1201,6 +1201,7 @@ WHERE     civicrm_contact.id = " . CRM_Utils_Type::escape($id, 'Integer');
 
     $contact->copyValues($updateParams);
     $contact->save();
+    CRM_Core_BAO_Log::register($contact->id, 'civicrm_contact', $contact->id);
 
     CRM_Utils_Hook::post('update', $contact->contact_type, $contact->id, $contact);
 
@@ -2121,11 +2122,17 @@ ORDER BY civicrm_email.is_primary DESC";
     ) {
       // if profile was used, and had any subtype, we obtain it from there
       //CRM-13596 - add to existing contact types, rather than overwriting
-      $data_contact_sub_type_arr = CRM_Utils_Array::explodePadded($data['contact_sub_type']);
-      if (!in_array($params['contact_sub_type_hidden'], $data_contact_sub_type_arr)) {
-        //CRM-20517 - make sure contact_sub_type gets the correct delimiters
-        $data['contact_sub_type'] = trim($data['contact_sub_type'], CRM_Core_DAO::VALUE_SEPARATOR);
-        $data['contact_sub_type'] = CRM_Core_DAO::VALUE_SEPARATOR . $data['contact_sub_type'] . CRM_Utils_Array::implodePadded($params['contact_sub_type_hidden']);
+      if (empty($data['contact_sub_type'])) {
+        // If we don't have a contact ID the $data['contact_sub_type'] will not be defined...
+        $data['contact_sub_type'] = CRM_Utils_Array::implodePadded($params['contact_sub_type_hidden']);
+      }
+      else {
+        $data_contact_sub_type_arr = CRM_Utils_Array::explodePadded($data['contact_sub_type']);
+        if (!in_array($params['contact_sub_type_hidden'], $data_contact_sub_type_arr)) {
+          //CRM-20517 - make sure contact_sub_type gets the correct delimiters
+          $data['contact_sub_type'] = trim($data['contact_sub_type'], CRM_Core_DAO::VALUE_SEPARATOR);
+          $data['contact_sub_type'] = CRM_Core_DAO::VALUE_SEPARATOR . $data['contact_sub_type'] . CRM_Utils_Array::implodePadded($params['contact_sub_type_hidden']);
+        }
       }
     }
 
@@ -3643,15 +3650,71 @@ LEFT JOIN civicrm_address ON ( civicrm_address.contact_id = civicrm_contact.id )
   }
 
   /**
-   * Checks permission to create new contacts from entityRef widget
+   * @param array $appendProfiles
+   *   Name of profile(s) to append to each link.
    *
-   * Note: other components must return an array of links from this function,
-   * but Contacts are given special treatment - the links are in javascript already.
-   *
-   * @return bool
+   * @return array
+   */
+  public static function getEntityRefCreateLinks($appendProfiles = []) {
+    // You'd think that "create contacts" would be the permission to check,
+    // But new contact popups are profile forms and those use their own permissions.
+    if (!CRM_Core_Permission::check([['profile create', 'profile listings and forms']])) {
+      return FALSE;
+    }
+    $profiles = [];
+    foreach (CRM_Contact_BAO_ContactType::basicTypes() as $contactType) {
+      $profiles[] = 'new_' . strtolower($contactType);
+    }
+    $retrieved = civicrm_api3('uf_group', 'get', [
+      'name' => ['IN' => array_merge($profiles, (array) $appendProfiles)],
+      'is_active' => 1,
+    ]);
+    $links = $append = [];
+    if (!empty($retrieved['values'])) {
+      $icons = [
+        'individual' => 'fa-user',
+        'organization' => 'fa-building',
+        'household' => 'fa-home',
+      ];
+      foreach ($retrieved['values'] as $id => $profile) {
+        if (in_array($profile['name'], $profiles)) {
+          $links[] = array(
+            'label' => $profile['title'],
+            'url' => CRM_Utils_System::url('civicrm/profile/create', "reset=1&context=dialog&gid=$id",
+              NULL, NULL, FALSE, FALSE, TRUE),
+            'type' => ucfirst(str_replace('new_', '', $profile['name'])),
+            'icon' => CRM_Utils_Array::value(str_replace('new_', '', $profile['name']), $icons),
+          );
+        }
+        else {
+          $append[] = $id;
+        }
+      }
+      foreach ($append as $id) {
+        foreach ($links as &$link) {
+          $link['url'] .= ",$id";
+        }
+      }
+    }
+    return $links;
+  }
+
+  /**
+   * @return array
    */
-  public static function entityRefCreateLinks() {
-    return CRM_Core_Permission::check([['profile create', 'profile listings and forms']]);
+  public static function getEntityRefFilters() {
+    return [
+      ['key' => 'contact_type', 'value' => ts('Contact Type')],
+      ['key' => 'group', 'value' => ts('Group'), 'entity' => 'GroupContact'],
+      ['key' => 'tag', 'value' => ts('Tag'), 'entity' => 'EntityTag'],
+      ['key' => 'state_province', 'value' => ts('State/Province'), 'entity' => 'Address'],
+      ['key' => 'country', 'value' => ts('Country'), 'entity' => 'Address'],
+      ['key' => 'gender_id', 'value' => ts('Gender'), 'condition' => ['contact_type' => 'Individual']],
+      ['key' => 'is_deceased', 'value' => ts('Deceased'), 'condition' => ['contact_type' => 'Individual']],
+      ['key' => 'contact_id', 'value' => ts('Contact ID'), 'type' => 'text'],
+      ['key' => 'external_identifier', 'value' => ts('External ID'), 'type' => 'text'],
+      ['key' => 'source', 'value' => ts('Contact Source'), 'type' => 'text'],
+    ];
   }
 
 }
index 2c40bcec5cd4d9d906e76f562cfb6a73708797bf..2b94fe37a493abf8bdf386d2eac8256b922caf22 100644 (file)
@@ -966,18 +966,20 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group {
         }
         $values[$object->id]['group_type'] = implode(', ', $types);
       }
-      $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',
-        'Group',
-        $object->id
-      );
+      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',
+          'Group',
+          $object->id
+        );
+      }
 
       // If group has children, add class for link to view children
       $values[$object->id]['is_parent'] = FALSE;
index 20290e2c690150f6ed2472516c773d609a568e34..9bb1dc439a5f7b794539b2f93a898a693938c801 100644 (file)
@@ -787,9 +787,8 @@ AND    contact_id IN ( $contactStr )
    * @return array|bool
    */
   public static function buildOptions($fieldName, $context = NULL, $props = array()) {
-    $params = array();
 
-    $options = CRM_Core_PseudoConstant::get(__CLASS__, $fieldName, $params, $context);
+    $options = CRM_Core_PseudoConstant::get(__CLASS__, $fieldName, $props, $context);
 
     // Sort group list by hierarchy
     // TODO: This will only work when api.entity is "group_contact". What about others?
index e60884b6f1dcbcde8712d86edf89f28eb1f2eb6a..d30c4bbaab1cf48e8d098b4e63bff5e208745b82 100644 (file)
@@ -413,6 +413,7 @@ class CRM_Contact_BAO_Query {
   public $_pseudoConstantsSelect = array();
 
   public $_groupUniqueKey = NULL;
+  public $_groupKeys = [];
 
   /**
    * Class constructor which also does all the work.
@@ -538,6 +539,7 @@ class CRM_Contact_BAO_Query {
       $component = 'membership';
     }
     if (isset($component)) {
+      // @todo should be if (isset($component && !$this->_skipPermission)
       CRM_Financial_BAO_FinancialType::buildPermissionedClause($this->_whereClause, $component);
     }
 
@@ -869,20 +871,8 @@ class CRM_Contact_BAO_Query {
                 }
               }
               else {
-                // If we have an option group defined then rather than joining the option value table in
-                // (which is an unindexed join) we render the option value on output.
-                // @todo - extend this to other pseudoconstants.
                 if ($this->pseudoConstantNameIsInReturnProperties($field, $name)) {
-                  $pseudoFieldName = $field['pseudoconstant']['optionGroupName'];
-                  $this->_pseudoConstantsSelect[$pseudoFieldName] = array(
-                    'pseudoField' => $field['name'],
-                    'idCol' => $name,
-                    'field_name' => $field['name'],
-                    'bao' => $field['bao'],
-                    'pseudoconstant' => $field['pseudoconstant'],
-                  );
-                  $this->_tables[$tableName] = 1;
-                  $this->_element[$pseudoFieldName] = 1;
+                  $this->addPseudoconstantFieldToSelect($field, $name, $tableName);
                 }
                 $this->_select[$name] = str_replace('civicrm_contact.', 'contact_a.', "{$field['where']} as `$name`");
               }
@@ -1394,7 +1384,7 @@ class CRM_Contact_BAO_Query {
       }
     }
     elseif ($sortByChar) {
-      $select = 'SELECT DISTINCT UPPER(LEFT(contact_a.sort_name, 1)) as sort_name';
+      $select = 'SELECT DISTINCT LEFT(contact_a.sort_name, 1) as sort_name';
       $from = $this->_simpleFromClause;
     }
     elseif ($groupContacts) {
@@ -2041,6 +2031,18 @@ class CRM_Contact_BAO_Query {
         // check for both id and contact_id
         if ($this->_params[$id][0] == 'id' || $this->_params[$id][0] == 'contact_id') {
           $this->_where[0][] = self::buildClause("contact_a.id", $this->_params[$id][1], $this->_params[$id][2]);
+          $field = CRM_Utils_Array::value('id', $this->_fields);
+          list($qillop, $qillVal) = CRM_Contact_BAO_Query::buildQillForFieldValue(
+            'CRM_Contact_BAO_Contact',
+            "contact_a.id",
+            $this->_params[$id][2],
+            $this->_params[$id][1]
+          );
+          $this->_qill[0][] = ts("%1 %2 %3", [
+            1 => $field['title'],
+            2 => $qillop,
+            3 => $qillVal
+          ]);
         }
         else {
           $this->whereClauseSingle($this->_params[$id], $apiEntity);
@@ -3044,6 +3046,7 @@ class CRM_Contact_BAO_Query {
     $groupContactCacheClause = '';
     if (count($smartGroupIDs) || empty($value)) {
       $this->_groupUniqueKey = uniqid();
+      $this->_groupKeys[] = $this->_groupUniqueKey;
       $gccTableAlias = "civicrm_group_contact_cache_{$this->_groupUniqueKey}";
       $groupContactCacheClause = $this->addGroupContactCache($smartGroupIDs, $gccTableAlias, "contact_a", $op);
       if (!empty($groupContactCacheClause)) {
@@ -3075,8 +3078,8 @@ class CRM_Contact_BAO_Query {
     }
   }
 
-  public function getGroupCacheTableKey() {
-    return $this->_groupUniqueKey;
+  public function getGroupCacheTableKeys() {
+    return $this->_groupKeys;
   }
 
   /**
@@ -3909,7 +3912,21 @@ WHERE  $smartGroupClause
     $name = $targetName[4] ? "%$name%" : $name;
     $this->_where[$grouping][] = "contact_b_log.sort_name LIKE '%$name%'";
     $this->_tables['civicrm_log'] = $this->_whereTables['civicrm_log'] = 1;
-    $this->_qill[$grouping][] = ts('Modified By') . " $name";
+    $fieldTitle = ts('Added By');
+    foreach ($this->_params as $params) {
+      if ($params[0] == 'log_date') {
+        if ($params[2] == 2) {
+          $fieldTitle = ts('Modified By');
+        }
+        break;
+      }
+    }
+    list($qillop, $qillVal) = self::buildQillForFieldValue(NULL, 'changed_by', $name, 'LIKE');
+    $this->_qill[$grouping][] = ts("%1 %2 '%3'", [
+      1 => $fieldTitle,
+      2 => $qillop,
+      3 => $qillVal,
+    ]);
   }
 
   /**
@@ -4874,97 +4891,7 @@ civicrm_relationship.start_date > {$today}
     $additionalFromClause = NULL, $skipOrderAndLimit = FALSE
   ) {
 
-    if ($includeContactIds) {
-      $this->_includeContactIds = TRUE;
-      $this->_whereClause = $this->whereClause();
-    }
-
-    $onlyDeleted = in_array(array('deleted_contacts', '=', '1', '0', '0'), $this->_params);
-
-    // if we’re explicitly looking for a certain contact’s contribs, events, etc.
-    // and that contact happens to be deleted, set $onlyDeleted to true
-    foreach ($this->_params as $values) {
-      $name = CRM_Utils_Array::value(0, $values);
-      $op = CRM_Utils_Array::value(1, $values);
-      $value = CRM_Utils_Array::value(2, $values);
-      if ($name == 'contact_id' and $op == '=') {
-        if (CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $value, 'is_deleted')) {
-          $onlyDeleted = TRUE;
-        }
-        break;
-      }
-    }
-
-    // building the query string
-    $groupBy = $groupByCols = NULL;
-    if (!$count) {
-      if (isset($this->_groupByComponentClause)) {
-        $groupBy = $this->_groupByComponentClause;
-        $groupByCols = preg_replace('/^GROUP BY /', '', trim($this->_groupByComponentClause));
-        $groupByCols = explode(', ', $groupByCols);
-      }
-      elseif ($this->_useGroupBy) {
-        $groupByCols = array('contact_a.id');
-      }
-    }
-    if ($this->_mode & CRM_Contact_BAO_Query::MODE_ACTIVITY && (!$count)) {
-      $groupByCols = array('civicrm_activity.id');
-    }
-
-    $order = $orderBy = $limit = '';
-    if (!$count) {
-      list($order, $additionalFromClause) = $this->prepareOrderBy($sort, $sortByChar, $sortOrder, $additionalFromClause);
-
-      if ($rowCount > 0 && $offset >= 0) {
-        $offset = CRM_Utils_Type::escape($offset, 'Int');
-        $rowCount = CRM_Utils_Type::escape($rowCount, 'Int');
-        $limit = " LIMIT $offset, $rowCount ";
-      }
-    }
-    // Two cases where we are disabling FGB (FULL_GROUP_BY_MODE):
-    //   1. Expecting the search query to return all the first single letter characters of contacts ONLY, but when FGB is enabled
-    //      MySQL expect the columns present in GROUP BY, must be present in SELECT clause and that results into error, needless to have other columns.
-    //   2. When GROUP BY columns are present then disable FGB otherwise it demands to add ORDER BY columns in GROUP BY and eventually in SELECT
-    //     clause. This will impact the search query output.
-    $disableFullGroupByMode = ($sortByChar || !empty($groupByCols) || $groupContacts);
-
-    if ($disableFullGroupByMode) {
-      CRM_Core_DAO::disableFullGroupByMode();
-    }
-
-    // CRM-15231
-    $this->_sort = $sort;
-
-    //CRM-15967
-    $this->includePseudoFieldsJoin($sort);
-
-    list($select, $from, $where, $having) = $this->query($count, $sortByChar, $groupContacts, $onlyDeleted);
-
-    if (!empty($groupByCols)) {
-      $groupBy = " GROUP BY " . implode(', ', $groupByCols);
-    }
-
-    if ($additionalWhereClause) {
-      $where = $where . ' AND ' . $additionalWhereClause;
-    }
-
-    //additional from clause should be w/ proper joins.
-    if ($additionalFromClause) {
-      $from .= "\n" . $additionalFromClause;
-    }
-
-    // if we are doing a transform, do it here
-    // use the $from, $where and $having to get the contact ID
-    if ($this->_displayRelationshipType) {
-      $this->filterRelatedContacts($from, $where, $having);
-    }
-
-    if ($skipOrderAndLimit) {
-      $query = "$select $from $where $having $groupBy";
-    }
-    else {
-      $query = "$select $from $where $having $groupBy $order $limit";
-    }
+    $query = $this->getSearchSQL($offset, $rowCount, $sort, $count, $includeContactIds, $sortByChar, $groupContacts, $additionalWhereClause, $sortOrder, $additionalFromClause, $skipOrderAndLimit);
 
     if ($returnQuery) {
       return $query;
@@ -4975,9 +4902,8 @@ civicrm_relationship.start_date > {$today}
 
     $dao = CRM_Core_DAO::executeQuery($query);
 
-    if ($disableFullGroupByMode) {
-      CRM_Core_DAO::reenableFullGroupByMode();
-    }
+    // We can always call this - it will only re-enable if it was originally enabled.
+    CRM_Core_DAO::reenableFullGroupByMode();
 
     if ($groupContacts) {
       $ids = array();
@@ -4990,6 +4916,22 @@ civicrm_relationship.start_date > {$today}
     return $dao;
   }
 
+  /**
+   * Create and query the db for a contact search.
+   *
+   * @return CRM_Core_DAO
+   */
+  public function alphabetQuery() {
+    $query = $this->getSearchSQL(NULL, NULL, NULL, FALSE, FALSE, TRUE);
+
+    $dao = CRM_Core_DAO::executeQuery($query);
+
+    // We can always call this - it will only re-enable if it was originally enabled.
+    CRM_Core_DAO::reenableFullGroupByMode();
+
+    return $dao;
+  }
+
   /**
    * Fetch a list of contacts for displaying a search results page
    *
@@ -5097,15 +5039,8 @@ civicrm_relationship.start_date > {$today}
    *
    * @return array
    */
-  public function &summaryContribution($context = NULL) {
+  public function summaryContribution($context = NULL) {
     list($innerselect, $from, $where, $having) = $this->query(TRUE);
-
-    // hack $select
-    $select = "
-SELECT COUNT( conts.total_amount ) as total_count,
-       SUM(   conts.total_amount ) as total_amount,
-       AVG(   conts.total_amount ) as total_avg,
-       conts.currency              as currency";
     if ($this->_permissionWhereClause) {
       $where .= " AND " . $this->_permissionWhereClause;
     }
@@ -5113,133 +5048,16 @@ SELECT COUNT( conts.total_amount ) as total_count,
       $where .= " AND contact_a.is_deleted = 0 ";
     }
 
-    $query = $this->appendFinancialTypeWhereAndFromToQueryStrings($where, $from);
-
-    // make sure contribution is completed - CRM-4989
-    $completedWhere = $where . " AND civicrm_contribution.contribution_status_id = 1 ";
-
-    $summary = array();
-    $summary['total'] = array();
-    $summary['total']['count'] = $summary['total']['amount'] = $summary['total']['avg'] = "n/a";
-    $innerQuery = "SELECT civicrm_contribution.total_amount, COUNT(civicrm_contribution.total_amount) as civicrm_contribution_total_amount_count,
-      civicrm_contribution.currency $from $completedWhere";
-    $query = "$select FROM (
-      $innerQuery GROUP BY civicrm_contribution.id
-    ) as conts
-    GROUP BY currency";
-
-    $dao = CRM_Core_DAO::executeQuery($query);
-
-    $summary['total']['count'] = 0;
-    $summary['total']['amount'] = $summary['total']['avg'] = array();
-    while ($dao->fetch()) {
-      $summary['total']['count'] += $dao->total_count;
-      $summary['total']['amount'][] = CRM_Utils_Money::format($dao->total_amount, $dao->currency);
-      $summary['total']['avg'][] = CRM_Utils_Money::format($dao->total_avg, $dao->currency);
-    }
-
-    $orderBy = 'ORDER BY civicrm_contribution_total_amount_count DESC';
-    $groupBy = 'GROUP BY currency, civicrm_contribution.total_amount';
-    $modeSQL = "$select, SUBSTRING_INDEX(GROUP_CONCAT(conts.total_amount
-      ORDER BY conts.civicrm_contribution_total_amount_count DESC SEPARATOR ';'), ';', 1) as amount,
-      MAX(conts.civicrm_contribution_total_amount_count) as civicrm_contribution_total_amount_count
-      FROM ($innerQuery
-      $groupBy $orderBy) as conts
-      GROUP BY currency";
-
-    $summary['total']['mode'] = CRM_Contribute_BAO_Contribution::computeStats('mode', $modeSQL);
+    $this->appendFinancialTypeWhereAndFromToQueryStrings($where, $from);
 
-    $medianSQL = "{$from} {$completedWhere}";
-    $summary['total']['median'] = CRM_Contribute_BAO_Contribution::computeStats('median', $medianSQL, 'civicrm_contribution');
-    $summary['total']['currencyCount'] = count($summary['total']['median']);
+    $summary = ['total' => []];
+    $this->addBasicStatsToSummary($summary, $where, $from);
 
-    if (!empty($summary['total']['amount'])) {
-      $summary['total']['amount'] = implode(',&nbsp;', $summary['total']['amount']);
-      $summary['total']['avg'] = implode(',&nbsp;', $summary['total']['avg']);
-      $summary['total']['mode'] = implode(',&nbsp;', $summary['total']['mode']);
-      $summary['total']['median'] = implode(',&nbsp;', $summary['total']['median']);
-    }
-    else {
-      $summary['total']['amount'] = $summary['total']['avg'] = $summary['total']['median'] = 0;
-    }
-
-    // soft credit summary
     if (CRM_Contribute_BAO_Query::isSoftCreditOptionEnabled()) {
-      $softCreditWhere = "{$completedWhere} AND civicrm_contribution_soft.id IS NOT NULL";
-      $query = "
-        $select FROM (
-          SELECT civicrm_contribution_soft.amount as total_amount, civicrm_contribution_soft.currency $from $softCreditWhere
-          GROUP BY civicrm_contribution_soft.id
-        ) as conts
-        GROUP BY currency";
-      $dao = CRM_Core_DAO::executeQuery($query);
-      $summary['soft_credit']['count'] = 0;
-      $summary['soft_credit']['amount'] = $summary['soft_credit']['avg'] = array();
-      while ($dao->fetch()) {
-        $summary['soft_credit']['count'] += $dao->total_count;
-        $summary['soft_credit']['amount'][] = CRM_Utils_Money::format($dao->total_amount, $dao->currency);
-        $summary['soft_credit']['avg'][] = CRM_Utils_Money::format($dao->total_avg, $dao->currency);
-      }
-      if (!empty($summary['soft_credit']['amount'])) {
-        $summary['soft_credit']['amount'] = implode(',&nbsp;', $summary['soft_credit']['amount']);
-        $summary['soft_credit']['avg'] = implode(',&nbsp;', $summary['soft_credit']['avg']);
-      }
-      else {
-        $summary['soft_credit']['amount'] = $summary['soft_credit']['avg'] = 0;
-      }
-    }
-
-    // hack $select
-    //@todo  - this could be one query using the IF in mysql - eg
-    //  SELECT sum(total_completed), sum(count_completed), sum(count_cancelled), sum(total_cancelled) FROM (
-    //   SELECT civicrm_contribution.total_amount, civicrm_contribution.currency  ,
-    //  IF(civicrm_contribution.contribution_status_id = 1, 1, 0 ) as count_completed,
-    //  IF(civicrm_contribution.contribution_status_id = 1, total_amount, 0 ) as total_completed,
-    //  IF(civicrm_contribution.cancel_date IS NOT NULL = 1, 1, 0 ) as count_cancelled,
-    //  IF(civicrm_contribution.cancel_date IS NOT NULL = 1, total_amount, 0 ) as total_cancelled
-    // FROM civicrm_contact contact_a
-    //  LEFT JOIN civicrm_contribution ON civicrm_contribution.contact_id = contact_a.id
-    // WHERE  ( ... where clause....
-    // AND (civicrm_contribution.cancel_date IS NOT NULL OR civicrm_contribution.contribution_status_id = 1)
-    //  ) as conts
-
-    $select = "
-SELECT COUNT( conts.total_amount ) as cancel_count,
-       SUM(   conts.total_amount ) as cancel_amount,
-       AVG(   conts.total_amount ) as cancel_avg,
-       conts.currency              as currency";
-
-    $where .= " AND civicrm_contribution.cancel_date IS NOT NULL ";
-    if ($context == 'search') {
-      $where .= " AND contact_a.is_deleted = 0 ";
+      $this->addBasicSoftCreditStatsToStats($summary, $where, $from);
     }
 
-    $query = "$select FROM (
-      SELECT civicrm_contribution.total_amount, civicrm_contribution.currency $from $where
-      GROUP BY civicrm_contribution.id
-    ) as conts
-    GROUP BY currency";
-
-    $dao = CRM_Core_DAO::executeQuery($query);
-
-    if ($dao->N <= 1) {
-      if ($dao->fetch()) {
-        $summary['cancel']['count'] = $dao->cancel_count;
-        $summary['cancel']['amount'] = CRM_Utils_Money::format($dao->cancel_amount, $dao->currency);
-        $summary['cancel']['avg'] = CRM_Utils_Money::format($dao->cancel_avg, $dao->currency);
-      }
-    }
-    else {
-      $summary['cancel']['count'] = 0;
-      $summary['cancel']['amount'] = $summary['cancel']['avg'] = array();
-      while ($dao->fetch()) {
-        $summary['cancel']['count'] += $dao->cancel_count;
-        $summary['cancel']['amount'][] = CRM_Utils_Money::format($dao->cancel_amount, $dao->currency);
-        $summary['cancel']['avg'][] = CRM_Utils_Money::format($dao->cancel_avg, $dao->currency);
-      }
-      $summary['cancel']['amount'] = implode(',&nbsp;', $summary['cancel']['amount']);
-      $summary['cancel']['avg'] = implode(',&nbsp;', $summary['cancel']['avg']);
-    }
+    $this->addBasicCancelStatsToSummary($summary, $where, $from);
 
     return $summary;
   }
@@ -6431,10 +6249,10 @@ AND   displayRelType.is_active = 1
    *   list(string $orderByClause, string $additionalFromClause).
    */
   protected function prepareOrderBy($sort, $sortByChar, $sortOrder, $additionalFromClause) {
-    $order = NULL;
-    $orderByArray = array();
-    $config = CRM_Core_Config::singleton();
-    if ($config->includeOrderByClause ||
+    $orderByArray = [];
+    $orderBy = '';
+
+    if (CRM_Core_Config::singleton()->includeOrderByClause ||
       isset($this->_distinctComponentClause)
     ) {
       if ($sort) {
@@ -6455,39 +6273,31 @@ AND   displayRelType.is_active = 1
             $orderBy = str_replace('sort_name', 'contact_a.sort_name', $orderBy);
           }
 
-          $order = " ORDER BY $orderBy";
-
           if ($sortOrder) {
-            $order .= " $sortOrder";
+            $orderBy .= " $sortOrder";
           }
 
           // always add contact_a.id to the ORDER clause
           // so the order is deterministic
-          if (strpos('contact_a.id', $order) === FALSE) {
-            $order .= ", contact_a.id";
+          if (strpos('contact_a.id', $orderBy) === FALSE) {
+            $orderBy .= ", contact_a.id";
           }
         }
       }
       elseif ($sortByChar) {
-        $orderByArray = array("UPPER(LEFT(contact_a.sort_name, 1)) asc");
+        $orderBy = " sort_name asc";
       }
       else {
-        $order = " ORDER BY contact_a.sort_name ASC, contact_a.id";
+        $orderBy = " contact_a.sort_name ASC, contact_a.id";
       }
     }
-    if (!$order && empty($orderByArray)) {
-      return array($order, $additionalFromClause);
+    if (!$orderBy) {
+      return [NULL, $additionalFromClause];
     }
     // Remove this here & add it at the end for simplicity.
-    $order = trim(str_replace('ORDER BY', '', $order));
+    $order = trim($orderBy);
+    $orderByArray = explode(',', $order);
 
-    // hack for order clause
-    if (!empty($orderByArray)) {
-      $order = implode(', ', $orderByArray);
-    }
-    else {
-      $orderByArray = explode(',', $order);
-    }
     foreach ($orderByArray as $orderByClause) {
       $orderByClauseParts = explode(' ', trim($orderByClause));
       $field = $orderByClauseParts[0];
@@ -6524,24 +6334,25 @@ AND   displayRelType.is_active = 1
             $this->_select = array_merge($this->_select, $this->_customQuery->_select);
             $this->_tables = array_merge($this->_tables, $this->_customQuery->_tables);
           }
-          foreach ($this->_pseudoConstantsSelect as $key => $pseudoConstantMetadata) {
-            // By replacing the join to the option value table with the mysql construct
-            // ORDER BY field('contribution_status_id', 2,1,4)
-            // we can remove a join. In the case of the option value join it is
-            /// a join known to cause slow queries.
-            // @todo cover other pseudoconstant types. Limited to option group ones in the
-            // first instance for scope reasons. They require slightly different handling as the column (label)
-            // is not declared for them.
-            // @todo so far only integer fields are being handled. If we add string fields we need to look at
-            // escaping.
-            if (isset($pseudoConstantMetadata['pseudoconstant'])
-              && isset($pseudoConstantMetadata['pseudoconstant']['optionGroupName'])
-              && $field === CRM_Utils_Array::value('optionGroupName', $pseudoConstantMetadata['pseudoconstant'])
-            ) {
-              $sortedOptions = $pseudoConstantMetadata['bao']::buildOptions($pseudoConstantMetadata['pseudoField'], NULL, array(
+
+          // By replacing the join to the option value table with the mysql construct
+          // ORDER BY field('contribution_status_id', 2,1,4)
+          // we can remove a join. In the case of the option value join it is
+          /// a join known to cause slow queries.
+          // @todo cover other pseudoconstant types. Limited to option group ones in the
+          // first instance for scope reasons. They require slightly different handling as the column (label)
+          // is not declared for them.
+          // @todo so far only integer fields are being handled. If we add string fields we need to look at
+          // escaping.
+          $fieldSpec = $this->getMetadataForRealField($field);
+          $pseudoConstantMetadata = CRM_Utils_Array::value('pseudoconstant', $fieldSpec, FALSE);
+          if (!empty($pseudoConstantMetadata)
+          ) {
+            if (!empty($pseudoConstantMetadata['optionGroupName'])) {
+              $sortedOptions = $fieldSpec['bao']::buildOptions($fieldSpec['name'], NULL, [
                 'orderColumn' => 'label',
-              ));
-              $order = str_replace("$field $direction", "field({$pseudoConstantMetadata['pseudoField']}," . implode(',', array_keys($sortedOptions)) . ") $direction", $order);
+              ]);
+              $order = str_replace("$field", "field({$fieldSpec['name']}," . implode(',', array_keys($sortedOptions)) . ")", $order);
             }
             //CRM-12565 add "`" around $field if it is a pseudo constant
             // This appears to be for 'special' fields like locations with appended numbers or hyphens .. maybe.
@@ -6633,7 +6444,7 @@ AND   displayRelType.is_active = 1
       return TRUE;
     }
     // Is this still required - the above goes off the unique name. Test with things like
-    // communication_prefferences & prefix_id.
+    // communication_preferences & prefix_id.
     if (CRM_Utils_Array::value($field['name'], $this->_returnProperties)) {
       return TRUE;
     }
@@ -6654,4 +6465,320 @@ AND   displayRelType.is_active = 1
     return $select;
   }
 
+  /**
+   * Add basic statistics to the summary.
+   *
+   * @param array $summary
+   * @param string $where
+   * @param string $from
+   *
+   * @return array
+   */
+  protected function addBasicStatsToSummary(&$summary, $where, $from) {
+    $summary['total']['count'] = 0;
+    $summary['total']['amount'] = $summary['total']['avg'] = [];
+
+    $query = "
+      SELECT COUNT( conts.total_amount ) as total_count,
+        SUM(   conts.total_amount ) as total_amount,
+        AVG(   conts.total_amount ) as total_avg,
+        conts.currency              as currency
+      FROM (
+        SELECT civicrm_contribution.total_amount, COUNT(civicrm_contribution.total_amount) as civicrm_contribution_total_amount_count,
+        civicrm_contribution.currency
+        $from
+        $where AND civicrm_contribution.contribution_status_id = 1
+      GROUP BY civicrm_contribution.id
+    ) as conts
+    GROUP BY currency";
+
+    $dao = CRM_Core_DAO::executeQuery($query);
+
+    while ($dao->fetch()) {
+      $summary['total']['count'] += $dao->total_count;
+      $summary['total']['amount'][] = CRM_Utils_Money::format($dao->total_amount, $dao->currency);
+      $summary['total']['avg'][] = CRM_Utils_Money::format($dao->total_avg, $dao->currency);
+    }
+
+    if (!empty($summary['total']['amount'])) {
+      $summary['total']['amount'] = implode(',&nbsp;', $summary['total']['amount']);
+      $summary['total']['avg'] = implode(',&nbsp;', $summary['total']['avg']);
+    }
+    else {
+      $summary['total']['amount'] = $summary['total']['avg'] = 0;
+    }
+    return $summary;
+  }
+
+  /**
+   * Add basic soft credit statistics to summary array.
+   *
+   * @param array $summary
+   * @param string $where
+   * @param string $from
+   */
+  protected function addBasicSoftCreditStatsToStats(&$summary, $where, $from) {
+    $query = "
+      SELECT COUNT( conts.total_amount ) as total_count,
+      SUM(   conts.total_amount ) as total_amount,
+      AVG(   conts.total_amount ) as total_avg,
+      conts.currency as currency
+      FROM (
+        SELECT civicrm_contribution_soft.amount as total_amount, civicrm_contribution_soft.currency
+        $from
+        $where AND civicrm_contribution.contribution_status_id = 1 AND civicrm_contribution_soft.id IS NOT NULL
+        GROUP BY civicrm_contribution_soft.id
+      ) as conts
+      GROUP BY currency";
+
+    $dao = CRM_Core_DAO::executeQuery($query);
+    $summary['soft_credit']['count'] = 0;
+    $summary['soft_credit']['amount'] = $summary['soft_credit']['avg'] = [];
+    while ($dao->fetch()) {
+      $summary['soft_credit']['count'] += $dao->total_count;
+      $summary['soft_credit']['amount'][] = CRM_Utils_Money::format($dao->total_amount, $dao->currency);
+      $summary['soft_credit']['avg'][] = CRM_Utils_Money::format($dao->total_avg, $dao->currency);
+    }
+    if (!empty($summary['soft_credit']['amount'])) {
+      $summary['soft_credit']['amount'] = implode(',&nbsp;', $summary['soft_credit']['amount']);
+      $summary['soft_credit']['avg'] = implode(',&nbsp;', $summary['soft_credit']['avg']);
+    }
+    else {
+      $summary['soft_credit']['amount'] = $summary['soft_credit']['avg'] = 0;
+    }
+  }
+
+  /**
+   * Add basic stats about cancelled contributions to the summary.
+   *
+   * @param array $summary
+   * @param string $where
+   * @param string $from
+   */
+  protected function addBasicCancelStatsToSummary(&$summary, $where, $from) {
+    $query = "
+      SELECT COUNT( conts.total_amount ) as cancel_count,
+       SUM(   conts.total_amount ) as cancel_amount,
+       AVG(   conts.total_amount ) as cancel_avg,
+       conts.currency              as currency
+        FROM (
+      SELECT civicrm_contribution.total_amount, civicrm_contribution.currency
+      $from
+      $where  AND civicrm_contribution.cancel_date IS NOT NULL 
+      GROUP BY civicrm_contribution.id
+    ) as conts
+    GROUP BY currency";
+
+    $dao = CRM_Core_DAO::executeQuery($query);
+
+    if ($dao->N <= 1) {
+      if ($dao->fetch()) {
+        $summary['cancel']['count'] = $dao->cancel_count;
+        $summary['cancel']['amount'] = CRM_Utils_Money::format($dao->cancel_amount, $dao->currency);
+        $summary['cancel']['avg'] = CRM_Utils_Money::format($dao->cancel_avg, $dao->currency);
+      }
+    }
+    else {
+      $summary['cancel']['count'] = 0;
+      $summary['cancel']['amount'] = $summary['cancel']['avg'] = [];
+      while ($dao->fetch()) {
+        $summary['cancel']['count'] += $dao->cancel_count;
+        $summary['cancel']['amount'][] = CRM_Utils_Money::format($dao->cancel_amount, $dao->currency);
+        $summary['cancel']['avg'][] = CRM_Utils_Money::format($dao->cancel_avg, $dao->currency);
+      }
+      $summary['cancel']['amount'] = implode(',&nbsp;', $summary['cancel']['amount']);
+      $summary['cancel']['avg'] = implode(',&nbsp;', $summary['cancel']['avg']);
+    }
+  }
+
+  /**
+   * Create the sql query for an contact search.
+   *
+   * @param int $offset
+   *   The offset for the query.
+   * @param int $rowCount
+   *   The number of rows to return.
+   * @param string|CRM_Utils_Sort $sort
+   *   The order by string.
+   * @param bool $count
+   *   Is this a count only query ?.
+   * @param bool $includeContactIds
+   *   Should we include contact ids?.
+   * @param bool $sortByChar
+   *   If true returns the distinct array of first characters for search results.
+   * @param bool $groupContacts
+   *   If true, return only the contact ids.
+   * @param string $additionalWhereClause
+   *   If the caller wants to further restrict the search (used for components).
+   * @param null $sortOrder
+   * @param string $additionalFromClause
+   *   Should be clause with proper joins, effective to reduce where clause load.
+   *
+   * @param bool $skipOrderAndLimit
+   * @return string
+   */
+  public function getSearchSQL(
+    $offset = 0, $rowCount = 0, $sort = NULL,
+    $count = FALSE, $includeContactIds = FALSE,
+    $sortByChar = FALSE, $groupContacts = FALSE,
+    $additionalWhereClause = NULL, $sortOrder = NULL,
+    $additionalFromClause = NULL, $skipOrderAndLimit = FALSE) {
+    if ($includeContactIds) {
+      $this->_includeContactIds = TRUE;
+      $this->_whereClause = $this->whereClause();
+    }
+
+    $onlyDeleted = in_array([
+      'deleted_contacts',
+      '=',
+      '1',
+      '0',
+      '0'
+    ], $this->_params);
+
+    // if we’re explicitly looking for a certain contact’s contribs, events, etc.
+    // and that contact happens to be deleted, set $onlyDeleted to true
+    foreach ($this->_params as $values) {
+      $name = CRM_Utils_Array::value(0, $values);
+      $op = CRM_Utils_Array::value(1, $values);
+      $value = CRM_Utils_Array::value(2, $values);
+      if ($name == 'contact_id' and $op == '=') {
+        if (CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $value, 'is_deleted')) {
+          $onlyDeleted = TRUE;
+        }
+        break;
+      }
+    }
+
+    // building the query string
+    $groupBy = $groupByCols = NULL;
+    if (!$count) {
+      if (isset($this->_groupByComponentClause)) {
+        $groupByCols = preg_replace('/^GROUP BY /', '', trim($this->_groupByComponentClause));
+        $groupByCols = explode(', ', $groupByCols);
+      }
+      elseif ($this->_useGroupBy) {
+        $groupByCols = ['contact_a.id'];
+      }
+    }
+    if ($this->_mode & CRM_Contact_BAO_Query::MODE_ACTIVITY && (!$count)) {
+      $groupByCols = ['civicrm_activity.id'];
+    }
+    if (!empty($groupByCols)) {
+      $groupBy = " GROUP BY " . implode(', ', $groupByCols);
+    }
+
+    $order = $orderBy = $limit = '';
+    if (!$count) {
+      list($order, $additionalFromClause) = $this->prepareOrderBy($sort, $sortByChar, $sortOrder, $additionalFromClause);
+
+      if ($rowCount > 0 && $offset >= 0) {
+        $offset = CRM_Utils_Type::escape($offset, 'Int');
+        $rowCount = CRM_Utils_Type::escape($rowCount, 'Int');
+        $limit = " LIMIT $offset, $rowCount ";
+      }
+    }
+    // Two cases where we are disabling FGB (FULL_GROUP_BY_MODE):
+    //   1. Expecting the search query to return all the first single letter characters of contacts ONLY, but when FGB is enabled
+    //      MySQL expect the columns present in GROUP BY, must be present in SELECT clause and that results into error, needless to have other columns.
+    //   2. When GROUP BY columns are present then disable FGB otherwise it demands to add ORDER BY columns in GROUP BY and eventually in SELECT
+    //     clause. This will impact the search query output.
+    $disableFullGroupByMode = ($sortByChar || !empty($groupBy) || $groupContacts);
+
+    if ($disableFullGroupByMode) {
+      CRM_Core_DAO::disableFullGroupByMode();
+    }
+
+    // CRM-15231
+    $this->_sort = $sort;
+
+    //CRM-15967
+    $this->includePseudoFieldsJoin($sort);
+
+    list($select, $from, $where, $having) = $this->query($count, $sortByChar, $groupContacts, $onlyDeleted);
+
+    if ($additionalWhereClause) {
+      $where = $where . ' AND ' . $additionalWhereClause;
+    }
+
+    //additional from clause should be w/ proper joins.
+    if ($additionalFromClause) {
+      $from .= "\n" . $additionalFromClause;
+    }
+
+    // if we are doing a transform, do it here
+    // use the $from, $where and $having to get the contact ID
+    if ($this->_displayRelationshipType) {
+      $this->filterRelatedContacts($from, $where, $having);
+    }
+
+    if ($skipOrderAndLimit) {
+      $query = "$select $from $where $having $groupBy";
+    }
+    else {
+      $query = "$select $from $where $having $groupBy $order $limit";
+    }
+    return $query;
+  }
+
+  /**
+   * Get the metadata for a given field.
+   *
+   * @param string $fieldName
+   *
+   * @return array
+   */
+  protected function getMetadataForField($fieldName) {
+    if ($fieldName === 'contact_a.id') {
+      // This seems to be the only anomaly.
+      $fieldName = 'id';
+    }
+    $pseudoField = isset($this->_pseudoConstantsSelect[$fieldName]) ? $this->_pseudoConstantsSelect[$fieldName] : [];
+    $field = isset($this->_fields[$fieldName]) ? $this->_fields[$fieldName] : $pseudoField;
+    $field = array_merge($field, $pseudoField);
+    if (!empty($field) && empty($field['name'])) {
+      // standardising field formatting here - over time we can phase out variants.
+      // all paths using this currently unit tested
+      $field['name'] = CRM_Utils_Array::value('field_name', $field, $field['idCol']);
+    }
+    return $field;
+  }
+
+  /**
+   * Get the metadata for a given field, returning the 'real field' if it is a pseudofield.
+   *
+   * @param string $fieldName
+   *
+   * @return array
+   */
+  protected function getMetadataForRealField($fieldName) {
+    $field = $this->getMetadataForField($fieldName);
+    return empty($field['is_pseudofield_for']) ? $field : $this->getMetadataForField($field['is_pseudofield_for']);
+  }
+
+  /**
+   * If we have a field that is better rendered via the pseudoconstant handled them here.
+   *
+   * Rather than joining in the additional table we render the option value on output.
+   *
+   * @todo - so far this applies to a narrow range of pseudocontants. We are adding them
+   * carefully with test coverage but aim to extend.
+   *
+   * @param array $field
+   * @param string $name
+   * @param string $tableName
+   */
+  protected function addPseudoconstantFieldToSelect($field, $name, $tableName) {
+    $pseudoFieldName = $field['pseudoconstant']['optionGroupName'];
+    $this->_pseudoConstantsSelect[$pseudoFieldName] = [
+      'pseudoField' => $field['name'],
+      'idCol' => $name,
+      'field_name' => $field['name'],
+      'bao' => $field['bao'],
+      'pseudoconstant' => $field['pseudoconstant'],
+    ];
+    $this->_tables[$tableName] = 1;
+    $this->_element[$pseudoFieldName] = 1;
+  }
+
 }
index 1f80087afc5a21922bd7c1dfad77df72b9a06835..9dad5533f51bed7e78718929920f22141cb91982 100644 (file)
@@ -165,7 +165,7 @@ class CRM_Contact_Form_Edit_Address {
       $form->addElement('checkbox', "address[$blockId][use_shared_address]", NULL, ts('Use another contact\'s address'));
 
       // Override the default profile links to add address form
-      $profileLinks = CRM_Contact_BAO_Contact::entityRefCreateLinks() ? CRM_Core_BAO_UFGroup::getCreateLinks('', 'shared_address') : FALSE;
+      $profileLinks = CRM_Contact_BAO_Contact::getEntityRefCreateLinks('shared_address');
       $form->addEntityRef("address[$blockId][master_contact_id]", ts('Share With'), array('create' => $profileLinks));
     }
   }
index 019ee5f3dac2eb5e12840308a79c11cc9de5bb1b..7862472f7f709e4f9d84ae1926a38cbc6abd1ff4 100644 (file)
@@ -494,7 +494,7 @@ class CRM_Contact_Form_Search_Criteria {
   }
 
   /**
-   * @param $form
+   * @param CRM_Core_Form_Search $form
    */
   public static function demographics(&$form) {
     $form->add('hidden', 'hidden_demographics', 1);
@@ -509,11 +509,11 @@ class CRM_Contact_Form_Search_Criteria {
     }
     $form->addGroup($genderOptions, 'gender_id', ts('Gender'))->setAttribute('allowClear', TRUE);
 
-    $form->add('text', 'age_low', ts('Min Age'), array('size' => 6));
+    $form->add('number', 'age_low', ts('Min Age'), ['class' => 'four', 'min' => 0]);
     $form->addRule('age_low', ts('Please enter a positive integer'), 'positiveInteger');
-    $form->add('text', 'age_high', ts('Max Age'), array('size' => 6));
+    $form->add('number', 'age_high', ts('Max Age'), ['class' => 'four', 'min' => 0]);
     $form->addRule('age_high', ts('Please enter a positive integer'), 'positiveInteger');
-    $form->addDate('age_asof_date', ts('Age as of Date'), FALSE, array('formatType' => 'searchDate'));
+    $form->add('datepicker', 'age_asof_date', ts('As of'), NULL, FALSE, ['time' => FALSE]);
 
     CRM_Core_Form_Date::buildDateRange($form, 'birth_date', 1, '_low', '_high', ts('From'), FALSE, FALSE, 'birth');
 
index a8b9691776af14bdc20988f688e80b8031a60ec4..74a62c32a00fe059bcdcaee0c57e6216e941a573 100644 (file)
@@ -544,7 +544,9 @@ class CRM_Contact_Form_Task extends CRM_Core_Form_Task {
       $ssId = $this->get('ssID');
       $hiddenSmartParams = array(
         'group_type' => array('2' => 1),
-        'form_values' => $this->get('formValues'),
+        // 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'),
index d446882c7da3b22f5888cf3858dfb6e03be3267e..b9863de1986169d15680481fe9e32571f40cc102 100644 (file)
@@ -58,16 +58,12 @@ class CRM_Contact_Page_View_UserDashBoard extends CRM_Core_Page {
   public function __construct() {
     parent::__construct();
 
-    $check = CRM_Core_Permission::check('access Contact Dashboard');
-
-    if (!$check) {
+    if (!CRM_Core_Permission::check('access Contact Dashboard')) {
       CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/dashboard', 'reset=1'));
     }
 
     $this->_contactId = CRM_Utils_Request::retrieve('id', 'Positive', $this);
-
-    $session = CRM_Core_Session::singleton();
-    $userID = $session->get('userID');
+    $userID = CRM_Core_Session::singleton()->getLoggedInContactID();
 
     $userChecksum = $this->getUserChecksum();
     $validUser = FALSE;
@@ -115,10 +111,9 @@ class CRM_Contact_Page_View_UserDashBoard extends CRM_Core_Page {
    */
   public function buildUserDashBoard() {
     //build component selectors
-    $dashboardElements = array();
-    $config = CRM_Core_Config::singleton();
+    $dashboardElements = [];
 
-    $this->_userOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
+    $dashboardOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
       'user_dashboard_options'
     );
 
@@ -130,7 +125,7 @@ class CRM_Contact_Page_View_UserDashBoard extends CRM_Core_Page {
         continue;
       }
 
-      if (!empty($this->_userOptions[$name]) &&
+      if (!empty($dashboardOptions[$name]) &&
         (CRM_Core_Permission::access($component->name) ||
           CRM_Core_Permission::check($elem['perm'][0])
         )
@@ -148,7 +143,7 @@ class CRM_Contact_Page_View_UserDashBoard extends CRM_Core_Page {
     }
 
     // CRM-16512 - Hide related contact table if user lacks permission to view self
-    if (!empty($this->_userOptions['Permissioned Orgs']) && CRM_Core_Permission::check('view my contact')) {
+    if (!empty($dashboardOptions['Permissioned Orgs']) && CRM_Core_Permission::check('view my contact')) {
       $dashboardElements[] = array(
         'class' => 'crm-dashboard-permissionedOrgs',
         'templatePath' => 'CRM/Contact/Page/View/RelationshipSelector.tpl',
@@ -158,7 +153,7 @@ class CRM_Contact_Page_View_UserDashBoard extends CRM_Core_Page {
 
     }
 
-    if (!empty($this->_userOptions['PCP'])) {
+    if (!empty($dashboardOptions['PCP'])) {
       $dashboardElements[] = array(
         'class' => 'crm-dashboard-pcp',
         'templatePath' => 'CRM/Contribute/Page/PcpUserDashboard.tpl',
@@ -170,7 +165,7 @@ class CRM_Contact_Page_View_UserDashBoard extends CRM_Core_Page {
       $this->assign('pcpInfo', $pcpInfo);
     }
 
-    if (!empty($this->_userOptions['Assigned Activities']) && empty($this->_isChecksumUser)) {
+    if (!empty($dashboardOptions['Assigned Activities']) && empty($this->_isChecksumUser)) {
       // Assigned Activities section
       $dashboardElements[] = array(
         'class' => 'crm-dashboard-assignedActivities',
@@ -186,9 +181,9 @@ class CRM_Contact_Page_View_UserDashBoard extends CRM_Core_Page {
     $this->assign('dashboardElements', $dashboardElements);
 
     // return true when 'Invoices / Credit Notes' checkbox is checked
-    $this->assign('invoices', $this->_userOptions['Invoices / Credit Notes']);
+    $this->assign('invoices', $dashboardOptions['Invoices / Credit Notes']);
 
-    if (!empty($this->_userOptions['Groups'])) {
+    if (!empty($dashboardOptions['Groups'])) {
       $this->assign('showGroup', TRUE);
       //build group selector
       $gContact = new CRM_Contact_Page_View_UserDashBoard_GroupContact();
index b11e19e6e37bdd1378c176e461cc829dd64fc053..7f3952a1692caad4026095f4cf3e82de871fc60a 100644 (file)
@@ -1028,8 +1028,8 @@ class CRM_Contact_Selector extends CRM_Core_Selector_Base implements CRM_Core_Se
     }
     // For core searches use the searchQuery method
     else {
-      $sql = $this->_query->searchQuery($start, $end, $sort, FALSE, $this->_query->_includeContactIds,
-        FALSE, TRUE, TRUE);
+      $sql = $this->_query->getSearchSQL($start, $end, $sort, FALSE, $this->_query->_includeContactIds,
+        FALSE, TRUE);
     }
 
     // CRM-9096
@@ -1192,7 +1192,7 @@ class CRM_Contact_Selector extends CRM_Core_Selector_Base implements CRM_Core_Se
    * @return CRM_Contact_DAO_Contact
    */
   public function alphabetQuery() {
-    return $this->_query->searchQuery(NULL, NULL, NULL, FALSE, FALSE, TRUE);
+    return $this->_query->alphabetQuery();
   }
 
   /**
index fb5d87f6fca6dfd121ba9634228116fe09393a0a..d906b9fbac6f27e45134bac1d04e28891bec43f6 100644 (file)
@@ -787,9 +787,23 @@ class CRM_Contribute_BAO_Contribution extends CRM_Contribute_DAO_Contribution {
         self::$_exportableFields = array();
       }
 
-      $impFields = CRM_Contribute_DAO_Contribution::export();
-      $expFieldProduct = CRM_Contribute_DAO_Product::export();
-      $expFieldsContrib = CRM_Contribute_DAO_ContributionProduct::export();
+      $fields = CRM_Contribute_DAO_Contribution::export();
+      if (CRM_Contribute_BAO_Query::isSiteHasProducts()) {
+        $fields = array_merge(
+          $fields,
+          CRM_Contribute_DAO_Product::export(),
+          CRM_Contribute_DAO_ContributionProduct::export(),
+          // CRM-16713 - contribution search by Premiums on 'Find Contribution' form.
+          [
+            'contribution_product_id' => [
+              'title' => ts('Premium'),
+              'name' => 'contribution_product_id',
+              'where' => 'civicrm_product.id',
+              'data_type' => CRM_Utils_Type::T_INT,
+            ],
+          ]
+        );
+      }
       $typeField = CRM_Financial_DAO_FinancialType::export();
       $financialAccount = CRM_Financial_DAO_FinancialAccount::export();
 
@@ -858,18 +872,8 @@ class CRM_Contribute_BAO_Contribution extends CRM_Contribute_DAO_Contribution {
         ),
       );
 
-      // CRM-16713 - contribution search by Premiums on 'Find Contribution' form.
-      $premiums = array(
-        'contribution_product_id' => array(
-          'title' => ts('Premium'),
-          'name' => 'contribution_product_id',
-          'where' => 'civicrm_product.id',
-          'data_type' => CRM_Utils_Type::T_INT,
-        ),
-      );
-
-      $fields = array_merge($impFields, $typeField, $contributionPage, $expFieldProduct,
-        $expFieldsContrib, $contributionNote, $extraFields, $softCreditFields, $financialAccount, $premiums, $campaignTitle,
+      $fields = array_merge($fields, $typeField, $contributionPage,
+        $contributionNote, $extraFields, $softCreditFields, $financialAccount, $campaignTitle,
         CRM_Core_BAO_CustomField::getFieldsForImport('Contribution', FALSE, FALSE, FALSE, $checkPermission)
       );
 
@@ -879,6 +883,33 @@ class CRM_Contribute_BAO_Contribution extends CRM_Contribute_DAO_Contribution {
     return self::$_exportableFields;
   }
 
+  /**
+   * @inheritDoc
+   */
+  public function addSelectWhereClause() {
+    $whereClauses = parent::addSelectWhereClause();
+    if ($whereClauses !== []) {
+      // In this case permisssions have been applied & we assume the
+      // financialaclreport is applying these
+      // https://github.com/JMAConsulting/biz.jmaconsulting.financialaclreport/blob/master/financialaclreport.php#L107
+      return $whereClauses;
+    }
+
+    if (!CRM_Financial_BAO_FinancialType::isACLFinancialTypeStatus()) {
+      return $whereClauses;
+    }
+    $types = CRM_Financial_BAO_FinancialType::getAllEnabledAvailableFinancialTypes();
+    if (empty($types)) {
+      $whereClauses['financial_type_id'] = 'IN (0)';
+    }
+    else {
+      $whereClauses['financial_type_id'] = [
+        'IN (' . implode(',', array_keys($types)) . ')'
+      ];
+    }
+    return $whereClauses;
+  }
+
   /**
    * @param null $status
    * @param null $startDate
@@ -3084,7 +3115,7 @@ INNER JOIN civicrm_activity ON civicrm_activity_contact.activity_id = civicrm_ac
    *
    * @param array $financialTrxnValues
    *
-   * @return null|object
+   * @return null|\CRM_Core_BAO_FinancialTrxn
    */
   public static function recordFinancialAccounts(&$params, $financialTrxnValues = NULL) {
     $skipRecords = $update = $return = $isRelatedId = FALSE;
@@ -3765,154 +3796,15 @@ INNER JOIN civicrm_activity ON civicrm_activity_contact.activity_id = civicrm_ac
    * @return null|object
    */
   public static function recordAdditionalPayment($contributionId, $trxnsData, $paymentType = 'owed', $participantId = NULL, $updateStatus = TRUE) {
-    $getInfoOf['id'] = $contributionId;
-    $defaults = array();
-    $contributionDAO = CRM_Contribute_BAO_Contribution::retrieve($getInfoOf, $defaults, CRM_Core_DAO::$_nullArray);
-    if (!$participantId) {
-      $participantId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $contributionId, 'participant_id', 'contribution_id');
-    }
-
-    // load related memberships on basis of $contributionDAO object
-    $contributionDAO->loadRelatedMembershipObjects();
-
-    // build params for recording financial trxn entry
-    $params['contribution'] = $contributionDAO;
-    $params = array_merge($defaults, $params);
-    $params['skipLineItem'] = TRUE;
-    $trxnsData['trxn_date'] = !empty($trxnsData['trxn_date']) ? $trxnsData['trxn_date'] : date('YmdHis');
-    $params['payment_instrument_id'] = CRM_Utils_Array::value('payment_instrument_id', $trxnsData, CRM_Utils_Array::value('payment_instrument_id', $params));
-    $arAccountId = CRM_Contribute_PseudoConstant::getRelationalFinancialAccount($contributionDAO->financial_type_id, 'Accounts Receivable Account is');
-
-    $completedStatusId = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Completed');
-    $paidStatus = CRM_Core_PseudoConstant::getKey('CRM_Financial_DAO_FinancialItem', 'status_id', 'Paid');
 
     if ($paymentType == 'owed') {
-      $params['partial_payment_total'] = $contributionDAO->total_amount;
-      $params['partial_amount_to_pay'] = $trxnsData['total_amount'];
-      $trxnsData['net_amount'] = !empty($trxnsData['net_amount']) ? $trxnsData['net_amount'] : $trxnsData['total_amount'];
-      $params['pan_truncation'] = CRM_Utils_Array::value('pan_truncation', $trxnsData);
-      $params['card_type_id'] = CRM_Utils_Array::value('card_type_id', $trxnsData);
-      $params['check_number'] = CRM_Utils_Array::value('check_number', $trxnsData);
-
-      // record the entry
-      $financialTrxn = CRM_Contribute_BAO_Contribution::recordFinancialAccounts($params, $trxnsData);
-      $toFinancialAccount = $arAccountId;
-      $trxnId = CRM_Core_BAO_FinancialTrxn::getBalanceTrxnAmt($contributionId, $contributionDAO->financial_type_id);
-      if (!empty($trxnId)) {
-        $trxnId = $trxnId['trxn_id'];
-      }
-      elseif (!empty($contributionDAO->payment_instrument_id)) {
-        $trxnId = CRM_Financial_BAO_FinancialTypeAccount::getInstrumentFinancialAccount($contributionDAO->payment_instrument_id);
-      }
-      else {
-        $relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('financial_account_type', NULL, " AND v.name LIKE 'Asset' "));
-        $queryParams = array(1 => array($relationTypeId, 'Integer'));
-        $trxnId = CRM_Core_DAO::singleValueQuery("SELECT id FROM civicrm_financial_account WHERE is_default = 1 AND financial_account_type_id = %1", $queryParams);
-      }
-
-      // update statuses
-      // criteria for updates contribution total_amount == financial_trxns of partial_payments
-      $sql = "SELECT SUM(ft.total_amount) as sum_of_payments, SUM(ft.net_amount) as net_amount_total
-FROM civicrm_financial_trxn ft
-LEFT JOIN civicrm_entity_financial_trxn eft
-  ON (ft.id = eft.financial_trxn_id)
-WHERE eft.entity_table = 'civicrm_contribution'
-  AND eft.entity_id = {$contributionId}
-  AND ft.to_financial_account_id != {$toFinancialAccount}
-  AND ft.status_id = {$completedStatusId}
-";
-      $query = CRM_Core_DAO::executeQuery($sql);
-      $query->fetch();
-      $sumOfPayments = $query->sum_of_payments;
-
-      // update statuses
-      if ($contributionDAO->total_amount == $sumOfPayments) {
-        // update contribution status and
-        // clean cancel info (if any) if prev. contribution was updated in case of 'Refunded' => 'Completed'
-        $contributionDAO->contribution_status_id = $completedStatusId;
-        $contributionDAO->cancel_date = 'null';
-        $contributionDAO->cancel_reason = NULL;
-        $netAmount = !empty($trxnsData['net_amount']) ? NULL : $trxnsData['total_amount'];
-        $contributionDAO->net_amount = $query->net_amount_total + $netAmount;
-        $contributionDAO->fee_amount = $contributionDAO->total_amount - $contributionDAO->net_amount;
-        $contributionDAO->save();
-
-        //Change status of financial record too
-        $financialTrxn->status_id = $completedStatusId;
-        $financialTrxn->save();
-
-        // note : not using the self::add method,
-        // the reason because it performs 'status change' related code execution for financial records
-        // which in 'Partial Paid' => 'Completed' is not useful, instead specific financial record updates
-        // are coded below i.e. just updating financial_item status to 'Paid'
-
-        if ($participantId) {
-          // update participant status
-          $participantStatuses = CRM_Event_PseudoConstant::participantStatus();
-          $ids = CRM_Event_BAO_Participant::getParticipantIds($contributionId);
-          foreach ($ids as $val) {
-            $participantUpdate['id'] = $val;
-            $participantUpdate['status_id'] = array_search('Registered', $participantStatuses);
-            CRM_Event_BAO_Participant::add($participantUpdate);
-          }
-        }
-
-        self::updateMembershipBasedOnCompletionOfContribution(
-          $contributionDAO,
-          $contributionId,
-          $trxnsData['trxn_date']
-        );
-
-        // update financial item statuses
-        $baseTrxnId = CRM_Core_BAO_FinancialTrxn::getFinancialTrxnId($contributionId);
-        $sqlFinancialItemUpdate = "
-UPDATE civicrm_financial_item fi
-  LEFT JOIN civicrm_entity_financial_trxn eft
-    ON (eft.entity_id = fi.id AND eft.entity_table = 'civicrm_financial_item')
-SET status_id = {$paidStatus}
-WHERE eft.financial_trxn_id IN ({$trxnId}, {$baseTrxnId['financialTrxnId']})
-";
-        CRM_Core_DAO::executeQuery($sqlFinancialItemUpdate);
-      }
+      $financialTrxn = CRM_Financial_BAO_Payment::recordPayment($contributionId, $trxnsData, $participantId);
     }
     elseif ($paymentType == 'refund') {
-      $trxnsData['total_amount'] = $trxnsData['net_amount'] = -$trxnsData['total_amount'];
-      $trxnsData['from_financial_account_id'] = $arAccountId;
-      $trxnsData['status_id'] = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Refunded');
-      // record the entry
-      $financialTrxn = CRM_Contribute_BAO_Contribution::recordFinancialAccounts($params, $trxnsData);
-
-      // note : not using the self::add method,
-      // the reason because it performs 'status change' related code execution for financial records
-      // which in 'Pending Refund' => 'Completed' is not useful, instead specific financial record updates
-      // are coded below i.e. just updating financial_item status to 'Paid'
-      if ($updateStatus) {
-        CRM_Core_DAO::setFieldValue('CRM_Contribute_BAO_Contribution', $contributionId, 'contribution_status_id', $completedStatusId);
-      }
-      // add financial item entry
-      $lineItems = CRM_Price_BAO_LineItem::getLineItemsByContributionID($contributionDAO->id);
-      if (!empty($lineItems)) {
-        foreach ($lineItems as $lineItemId => $lineItemValue) {
-          // don't record financial item for cancelled line-item
-          if ($lineItemValue['qty'] == 0) {
-            continue;
-          }
-          $paid = $lineItemValue['line_total'] * ($financialTrxn->total_amount / $contributionDAO->total_amount);
-          $addFinancialEntry = array(
-            'transaction_date' => $financialTrxn->trxn_date,
-            'contact_id' => $contributionDAO->contact_id,
-            'amount' => round($paid, 2),
-            'currency' => $contributionDAO->currency,
-            'status_id' => $paidStatus,
-            'entity_id' => $lineItemId,
-            'entity_table' => 'civicrm_line_item',
-          );
-          $trxnIds['id'] = $financialTrxn->id;
-          CRM_Financial_BAO_FinancialItem::create($addFinancialEntry, NULL, $trxnIds);
-        }
-      }
+      $financialTrxn = CRM_Financial_BAO_Payment::recordRefundPayment($contributionId, $trxnsData, $updateStatus);
       if ($participantId) {
         // update participant status
+        // @todo this doesn't make sense...
         $participantStatuses = CRM_Event_PseudoConstant::participantStatus();
         $ids = CRM_Event_BAO_Participant::getParticipantIds($contributionId);
         foreach ($ids as $val) {
@@ -3934,7 +3826,9 @@ WHERE eft.financial_trxn_id IN ({$trxnId}, {$baseTrxnId['financialTrxnId']})
         $entityObj = $entityObj[$participantId];
       }
       else {
-        $entityObj = $contributionDAO;
+        $entityObj = new CRM_Contribute_BAO_Contribution();
+        $entityObj->id = $contributionId;
+        $entityObj->find(TRUE);
         $component = 'contribution';
       }
       $activityType = ($paymentType == 'refund') ? 'Refund' : 'Payment';
@@ -4000,10 +3894,9 @@ WHERE eft.financial_trxn_id IN ({$trxnId}, {$baseTrxnId['financialTrxnId']})
    *
    * @return mixed
    */
-  public static function getPaymentInfo($id, $component, $getTrxnInfo = FALSE, $usingLineTotal = FALSE) {
+  public static function getPaymentInfo($id, $component = 'contribution', $getTrxnInfo = FALSE, $usingLineTotal = FALSE) {
+    // @todo deprecate passing in component - always call with contribution.
     if ($component == 'event') {
-      $entity = 'participant';
-      $entityTable = 'civicrm_participant';
       $contributionId = CRM_Core_DAO::getFieldValue('CRM_Event_BAO_ParticipantPayment', $id, 'contribution_id', 'participant_id');
 
       if (!$contributionId) {
@@ -4017,14 +3910,10 @@ WHERE eft.financial_trxn_id IN ({$trxnId}, {$baseTrxnId['financialTrxnId']})
       }
     }
     elseif ($component == 'membership') {
-      $entity = $component;
-      $entityTable = 'civicrm_membership';
       $contributionId = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipPayment', $id, 'contribution_id', 'membership_id');
     }
     else {
       $contributionId = $id;
-      $entity = 'contribution';
-      $entityTable = 'civicrm_contribution';
     }
 
     $total = CRM_Core_BAO_FinancialTrxn::getBalanceTrxnAmt($contributionId);
@@ -4041,7 +3930,8 @@ WHERE eft.financial_trxn_id IN ({$trxnId}, {$baseTrxnId['financialTrxnId']})
       $total = $total['total_amount'];
     }
 
-    $paymentBalance = CRM_Core_BAO_FinancialTrxn::getPartialPaymentWithType($id, $entity, FALSE, $total);
+    $paymentBalance = CRM_Contribute_BAO_Contribution::getContributionBalance($contributionId, $total);
+
     $contribution = civicrm_api3('Contribution', 'getsingle', array('id' => $contributionId, 'return' => array('currency', 'is_pay_later', 'contribution_status_id', 'financial_type_id')));
 
     $info['payLater'] = $contribution['is_pay_later'];
@@ -4156,27 +4046,15 @@ WHERE eft.financial_trxn_id IN ({$trxnId}, {$baseTrxnId['financialTrxnId']})
    * @return float
    */
   public static function getContributionBalance($contributionId, $contributionTotal = NULL) {
-
     if ($contributionTotal === NULL) {
       $contributionTotal = CRM_Price_BAO_LineItem::getLineTotal($contributionId);
     }
-    $statusId = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Completed');
-    $refundStatusId = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Refunded');
 
-    $sqlFtTotalAmt = "
-SELECT SUM(ft.total_amount)
-FROM civicrm_financial_trxn ft
-  INNER JOIN civicrm_entity_financial_trxn eft ON (ft.id = eft.financial_trxn_id AND eft.entity_table = 'civicrm_contribution' AND eft.entity_id = {$contributionId})
-WHERE ft.is_payment = 1
-  AND ft.status_id IN ({$statusId}, {$refundStatusId})
-";
-
-    $ftTotalAmt = CRM_Core_DAO::singleValueQuery($sqlFtTotalAmt);
-    if (!$ftTotalAmt) {
-      $ftTotalAmt = 0;
-    }
-    $currency = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $contributionId, 'currency');
-    return CRM_Utils_Money::subtractCurrencies($contributionTotal, $ftTotalAmt, $currency);
+    return CRM_Utils_Money::subtractCurrencies(
+      $contributionTotal,
+      CRM_Core_BAO_FinancialTrxn::getTotalPayments($contributionId, TRUE) ?: 0,
+      CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $contributionId, 'currency')
+    );
   }
 
   /**
@@ -4389,6 +4267,8 @@ WHERE ft.is_payment = 1
   /**
    * Compute the stats values
    *
+   * @deprecated
+   *
    * @param string $stat either 'mode' or 'median'
    * @param string $sql
    * @param string $alias of civicrm_contribution
@@ -4396,58 +4276,8 @@ WHERE ft.is_payment = 1
    * @return array|null
    */
   public static function computeStats($stat, $sql, $alias = NULL) {
-    $mode = $median = array();
-    switch ($stat) {
-      case 'mode':
-        $modeDAO = CRM_Core_DAO::executeQuery($sql);
-        while ($modeDAO->fetch()) {
-          if ($modeDAO->civicrm_contribution_total_amount_count > 1) {
-            $mode[] = CRM_Utils_Money::format($modeDAO->amount, $modeDAO->currency);
-          }
-          else {
-            $mode[] = 'N/A';
-          }
-        }
-        return $mode;
-
-      case 'median':
-        $currencies = CRM_Core_OptionGroup::values('currencies_enabled');
-        foreach ($currencies as $currency => $val) {
-          $midValue = 0;
-          $where = "AND {$alias}.currency = '{$currency}'";
-          $rowCount = CRM_Core_DAO::singleValueQuery("SELECT count(*) as count {$sql} {$where}");
-
-          $even = FALSE;
-          $offset = 1;
-          $medianRow = floor($rowCount / 2);
-          if ($rowCount % 2 == 0 && !empty($medianRow)) {
-            $even = TRUE;
-            $offset++;
-            $medianRow--;
-          }
-
-          $medianValue = "SELECT {$alias}.total_amount as median
-             {$sql} {$where}
-             ORDER BY median LIMIT {$medianRow},{$offset}";
-          $medianValDAO = CRM_Core_DAO::executeQuery($medianValue);
-          while ($medianValDAO->fetch()) {
-            if ($even) {
-              $midValue = $midValue + $medianValDAO->median;
-            }
-            else {
-              $median[] = CRM_Utils_Money::format($medianValDAO->median, $currency);
-            }
-          }
-          if ($even) {
-            $midValue = $midValue / 2;
-            $median[] = CRM_Utils_Money::format($midValue, $currency);
-          }
-        }
-        return $median;
-
-      default:
-        return NULL;
-    }
+    CRM_Core_Error::deprecatedFunctionWarning('computeStats is now deprecated');
+    return [];
   }
 
   /**
@@ -4843,7 +4673,7 @@ WHERE ft.is_payment = 1
     $balanceTrxnParams['from_financial_account_id'] = $fromFinancialAccountId;
     $balanceTrxnParams['total_amount'] = $params['total_amount'];
     $balanceTrxnParams['contribution_id'] = $params['contribution_id'];
-    $balanceTrxnParams['trxn_date'] = !empty($params['contribution_receive_date']) ? $params['contribution_receive_date'] : date('YmdHis');
+    $balanceTrxnParams['trxn_date'] = CRM_Utils_Array::value('trxn_date', $params, CRM_Utils_Array::value('contribution_receive_date', $params, date('YmdHis')));
     $balanceTrxnParams['fee_amount'] = CRM_Utils_Array::value('fee_amount', $params);
     $balanceTrxnParams['net_amount'] = CRM_Utils_Array::value('total_amount', $params);
     $balanceTrxnParams['currency'] = $contribution['currency'];
@@ -5371,7 +5201,7 @@ LEFT JOIN  civicrm_contribution on (civicrm_contribution.contact_id = civicrm_co
    * @throws \CRM_Core_Exception
    * @throws \CiviCRM_API3_Exception
    */
-  protected static function updateMembershipBasedOnCompletionOfContribution($contribution, $primaryContributionID, $changeDate) {
+  public static function updateMembershipBasedOnCompletionOfContribution($contribution, $primaryContributionID, $changeDate) {
     $contribution->loadRelatedMembershipObjects();
     if (empty($contribution->_relatedObjects['membership'])) {
       return;
index 510849b0b92659a146d335ad769ab41cfb90ec9e..126cf8f67d95edd9513a52303fd3f6f58b9166a7 100644 (file)
@@ -173,14 +173,7 @@ class CRM_Contribute_BAO_ContributionRecur extends CRM_Contribute_DAO_Contributi
    * @return array|null
    */
   public static function getPaymentProcessor($id, $mode = NULL) {
-    $sql = "
-SELECT r.payment_processor_id
-  FROM civicrm_contribution_recur r
- WHERE r.id = %1";
-    $params = array(1 => array($id, 'Integer'));
-    $paymentProcessorID = CRM_Core_DAO::singleValueQuery($sql,
-      $params
-    );
+    $paymentProcessorID = self::getPaymentProcessorID($id);
     if (!$paymentProcessorID) {
       return NULL;
     }
@@ -188,6 +181,23 @@ SELECT r.payment_processor_id
     return CRM_Financial_BAO_PaymentProcessor::getPayment($paymentProcessorID, $mode);
   }
 
+  /**
+   * Get the payment processor for the given recurring contribution.
+   *
+   * @param int $recurID
+   *
+   * @return int
+   *   Payment processor id. If none found return 0 which represents the
+   *   pseudo processor used for pay-later.
+   */
+  public static function getPaymentProcessorID($recurID) {
+    $recur = civicrm_api3('ContributionRecur', 'getsingle', [
+      'id' => $recurID,
+      'return' => ['payment_processor_id']
+    ]);
+    return (int) CRM_Utils_Array::value('payment_processor_id', $recur, 0);
+  }
+
   /**
    * Get the number of installment done/completed for each recurring contribution.
    *
@@ -954,7 +964,7 @@ INNER JOIN civicrm_contribution       con ON ( con.id = mp.contribution_id )
 
   /**
    * Returns array with statuses that are considered to make a recurring
-   * contribution inacteve.
+   * contribution inactive.
    *
    * @return array
    */
index 0ce9b3586483554bf0ce54ee568993dc377c7eae..16578481e35d06e39a30298895ef6c0840f00213 100644 (file)
@@ -48,7 +48,8 @@ class CRM_Contribute_BAO_Query extends CRM_Core_BAO_Query {
    */
   public static function getFields($checkPermission = TRUE) {
     if (!isset(\Civi::$statics[__CLASS__]) || !isset(\Civi::$statics[__CLASS__]['fields']) || !isset(\Civi::$statics[__CLASS__]['contribution'])) {
-      $fields  = CRM_Contribute_BAO_Contribution::exportableFields($checkPermission);
+      $fields = CRM_Contribute_BAO_Contribution::exportableFields($checkPermission);
+      CRM_Contribute_BAO_Contribution::appendPseudoConstantsToFields($fields);
       unset($fields['contribution_contact_id']);
       \Civi::$statics[__CLASS__]['fields']['contribution'] = $fields;
     }
@@ -155,8 +156,6 @@ class CRM_Contribute_BAO_Query extends CRM_Core_BAO_Query {
       $quoteValue = "\"$value\"";
     }
 
-    $strtolower = function_exists('mb_strtolower') ? 'mb_strtolower' : 'strtolower';
-
     $recurrringFields = CRM_Contribute_BAO_ContributionRecur::getRecurringFields();
     unset($recurrringFields['contribution_recur_payment_made']);
     foreach ($recurrringFields as $dateField => $dateFieldTitle) {
@@ -239,9 +238,6 @@ class CRM_Contribute_BAO_Query extends CRM_Core_BAO_Query {
         return;
 
       case 'financial_type_id':
-        // @todo we need to make this resemble a hook approach.
-        CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes($financialTypes);
-        $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("civicrm_contribution.$name", 'IN', array_keys($financialTypes), 'String');
       case 'invoice_id':
       case 'invoice_number':
       case 'payment_instrument_id':
@@ -418,14 +414,12 @@ class CRM_Contribute_BAO_Query extends CRM_Core_BAO_Query {
         return;
 
       case 'contribution_note':
-        $value = $strtolower(CRM_Core_DAO::escapeString($value));
+        $value = CRM_Core_DAO::escapeString($value);
         if ($wildcard) {
           $value = "%$value%";
           $op = 'LIKE';
         }
-        // LOWER roughly translates to 'hurt my database without deriving any benefit' See CRM-19811.
-        $wc = ($op != 'LIKE') ? "LOWER(civicrm_note.note)" : "civicrm_note.note";
-        $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause($wc, $op, $value, "String");
+        $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->_tables['civicrm_contribution'] = $query->_whereTables['civicrm_contribution'] = $query->_whereTables['contribution_note'] = 1;
         return;
@@ -777,16 +771,14 @@ class CRM_Contribute_BAO_Query extends CRM_Core_BAO_Query {
       'contribution_status_id' => 1,
       // @todo return this & fix query to do pseudoconstant thing.
       'contribution_status' => 1,
-      // @todo the product field got added because it suited someone's use case.
-      // ideally we would have some configurability here because I think 90% of sites would
-      // disagree this is the right field to show - but they wouldn't agree with each other
-      // on what field to show instead.
-      'contribution_product_id' => 1,
-      'product_name' => 1,
       'currency' => 1,
       'cancel_date' => 1,
       'contribution_recur_id' => 1,
     );
+    if (self::isSiteHasProducts()) {
+      $properties['product_name'] = 1;
+      $properties['contribution_product_id'] = 1;
+    }
     if (self::isSoftCreditOptionEnabled($queryParams)) {
       $properties = array_merge($properties, self::softCreditReturnProperties());
     }
@@ -794,6 +786,18 @@ class CRM_Contribute_BAO_Query extends CRM_Core_BAO_Query {
     return $properties;
   }
 
+  /**
+   * Do any products exist in this site's database.
+   *
+   * @return bool
+   */
+  public static function isSiteHasProducts() {
+    if (!isset(\Civi::$statics[__CLASS__]['has_products'])) {
+      \Civi::$statics[__CLASS__]['has_products'] = (bool) CRM_Core_DAO::singleValueQuery('SELECT id FROM civicrm_contribution_product LIMIT 1');
+    }
+    return \Civi::$statics[__CLASS__]['has_products'];
+  }
+
   /**
    * Function you should avoid.
    *
@@ -858,17 +862,11 @@ class CRM_Contribute_BAO_Query extends CRM_Core_BAO_Query {
         //every
         'receipt_date' => 1,
         // query
-        'product_name' => 1,
         //whether
-        'sku' => 1,
         // or
-        'product_option' => 1,
         // not
-        'fulfilled_date' => 1,
         // the
-        'contribution_start_date' => 1,
         // field
-        'contribution_end_date' => 1,
         // is
         'is_test' => 1,
         // actually
@@ -890,9 +888,17 @@ class CRM_Contribute_BAO_Query extends CRM_Core_BAO_Query {
         // on
         'contribution_campaign_id' => 1,
         // calling
-        'contribution_product_id' => 1,
         //function
       );
+      if (self::isSiteHasProducts()) {
+        $properties['fulfilled_date'] = 1;
+        $properties['product_name'] = 1;
+        $properties['contribution_product_id'] = 1;
+        $properties['product_option'] = 1;
+        $properties['sku'] = 1;
+        $properties['contribution_start_date'] = 1;
+        $properties['contribution_end_date'] = 1;
+      }
       if (self::isSoftCreditOptionEnabled()) {
         $properties = array_merge($properties, self::softCreditReturnProperties());
       }
@@ -1018,12 +1024,18 @@ class CRM_Contribute_BAO_Query extends CRM_Core_BAO_Query {
       'autocomplete' => 'off',
     ));
 
-    // CRM-16713 - contribution search by premiums on 'Find Contribution' form.
-    $form->add('select', 'contribution_product_id',
-      ts('Premium'),
-      CRM_Contribute_PseudoConstant::products(),
-      FALSE, array('class' => 'crm-select2', 'multiple' => 'multiple', 'placeholder' => ts('- any -'))
-    );
+    if (CRM_Contribute_BAO_Query::isSiteHasProducts()) {
+      // CRM-16713 - contribution search by premiums on 'Find Contribution' form.
+      $form->add('select', 'contribution_product_id',
+        ts('Premium'),
+        CRM_Contribute_PseudoConstant::products(),
+        FALSE, [
+          'class' => 'crm-select2',
+          'multiple' => 'multiple',
+          'placeholder' => ts('- any -')
+        ]
+      );
+    }
 
     self::addCustomFormFields($form, array('Contribution'));
 
index e2011b92e1e0985f05566e7beb0f3b532dd3b251..c87f48afa0e2948d4a1d94fac726edea26bad442 100644 (file)
@@ -6,7 +6,7 @@
  *
  * Generated from xml/schema/CRM/Contribute/ContributionRecur.xml
  * DO NOT EDIT.  Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:d3bbedd50918aaf27f7177cceb6593b4)
+ * (GenCodeChecksum:e69f645ae471e887f56e95ee10a8678d)
  */
 
 /**
@@ -36,7 +36,7 @@ class CRM_Contribute_DAO_ContributionRecur extends CRM_Core_DAO {
   public $id;
 
   /**
-   * Foreign key to civicrm_contact.id .
+   * Foreign key to civicrm_contact.id.
    *
    * @var int unsigned
    */
@@ -269,14 +269,17 @@ class CRM_Contribute_DAO_ContributionRecur extends CRM_Core_DAO {
         'contact_id' => [
           'name' => 'contact_id',
           'type' => CRM_Utils_Type::T_INT,
-          'title' => ts('Contact ID'),
-          'description' => ts('Foreign key to civicrm_contact.id .'),
+          'title' => ts('Contact'),
+          'description' => ts('Foreign key to civicrm_contact.id.'),
           'required' => TRUE,
           'table_name' => 'civicrm_contribution_recur',
           'entity' => 'ContributionRecur',
           'bao' => 'CRM_Contribute_BAO_ContributionRecur',
           'localizable' => 0,
           'FKClassName' => 'CRM_Contact_DAO_Contact',
+          'html' => [
+            'type' => 'EntityRef',
+          ],
         ],
         'amount' => [
           'name' => 'amount',
@@ -369,7 +372,7 @@ class CRM_Contribute_DAO_ContributionRecur extends CRM_Core_DAO {
         'start_date' => [
           'name' => 'start_date',
           'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
-          'title' => ts('Recurring Contribution Started Date'),
+          'title' => ts('Start Date'),
           'description' => ts('The date the first scheduled recurring contribution occurs.'),
           'required' => TRUE,
           'table_name' => 'civicrm_contribution_recur',
@@ -378,13 +381,13 @@ class CRM_Contribute_DAO_ContributionRecur extends CRM_Core_DAO {
           'localizable' => 0,
           'html' => [
             'type' => 'Select Date',
-            'formatType' => 'activityDate',
+            'formatType' => 'activityDateTime',
           ],
         ],
         'create_date' => [
           'name' => 'create_date',
           'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
-          'title' => ts('Recurring Contribution Created Date'),
+          'title' => ts('Created Date'),
           'description' => ts('When this recurring contribution record was created.'),
           'required' => TRUE,
           'table_name' => 'civicrm_contribution_recur',
@@ -393,13 +396,13 @@ class CRM_Contribute_DAO_ContributionRecur extends CRM_Core_DAO {
           'localizable' => 0,
           'html' => [
             'type' => 'Select Date',
-            'formatType' => 'activityDate',
+            'formatType' => 'activityDateTime',
           ],
         ],
         'modified_date' => [
           'name' => 'modified_date',
           'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
-          'title' => ts('Recurring Contribution Modified Date'),
+          'title' => ts('Modified Date'),
           'description' => ts('Last updated date for this record. mostly the last time a payment was received'),
           'table_name' => 'civicrm_contribution_recur',
           'entity' => 'ContributionRecur',
@@ -407,13 +410,13 @@ class CRM_Contribute_DAO_ContributionRecur extends CRM_Core_DAO {
           'localizable' => 0,
           'html' => [
             'type' => 'Select Date',
-            'formatType' => 'activityDate',
+            'formatType' => 'activityDateTime',
           ],
         ],
         'cancel_date' => [
           'name' => 'cancel_date',
           'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
-          'title' => ts('Recurring Contribution Cancel Date'),
+          'title' => ts('Cancel Date'),
           'description' => ts('Date this recurring contribution was cancelled by contributor- if we can get access to it'),
           'table_name' => 'civicrm_contribution_recur',
           'entity' => 'ContributionRecur',
@@ -449,6 +452,9 @@ class CRM_Contribute_DAO_ContributionRecur extends CRM_Core_DAO {
           'entity' => 'ContributionRecur',
           'bao' => 'CRM_Contribute_BAO_ContributionRecur',
           'localizable' => 0,
+          'html' => [
+            'type' => 'Text',
+          ],
         ],
         'payment_token_id' => [
           'name' => 'payment_token_id',
@@ -472,6 +478,9 @@ class CRM_Contribute_DAO_ContributionRecur extends CRM_Core_DAO {
           'entity' => 'ContributionRecur',
           'bao' => 'CRM_Contribute_BAO_ContributionRecur',
           'localizable' => 0,
+          'html' => [
+            'type' => 'Text',
+          ],
         ],
         'invoice_id' => [
           'name' => 'invoice_id',
@@ -484,11 +493,14 @@ class CRM_Contribute_DAO_ContributionRecur extends CRM_Core_DAO {
           'entity' => 'ContributionRecur',
           'bao' => 'CRM_Contribute_BAO_ContributionRecur',
           'localizable' => 0,
+          'html' => [
+            'type' => 'Text',
+          ],
         ],
         'contribution_status_id' => [
           'name' => 'contribution_status_id',
           'type' => CRM_Utils_Type::T_INT,
-          'title' => ts('Recurring Contribution Status'),
+          'title' => ts('Status'),
           'import' => TRUE,
           'where' => 'civicrm_contribution_recur.contribution_status_id',
           'headerPattern' => '',
@@ -499,6 +511,9 @@ class CRM_Contribute_DAO_ContributionRecur extends CRM_Core_DAO {
           'entity' => 'ContributionRecur',
           'bao' => 'CRM_Contribute_BAO_ContributionRecur',
           'localizable' => 0,
+          'html' => [
+            'type' => 'Select',
+          ],
           'pseudoconstant' => [
             'optionGroupName' => 'contribution_status',
             'optionEditPath' => 'civicrm/admin/options/contribution_status',
@@ -525,7 +540,7 @@ class CRM_Contribute_DAO_ContributionRecur extends CRM_Core_DAO {
         'cycle_day' => [
           'name' => 'cycle_day',
           'type' => CRM_Utils_Type::T_INT,
-          'title' => ts('Number of Cycle Day'),
+          'title' => ts('Cycle Day'),
           'description' => ts('Day in the period when the payment should be charged e.g. 1st of month, 15th etc.'),
           'required' => TRUE,
           'default' => '1',
@@ -604,6 +619,14 @@ class CRM_Contribute_DAO_ContributionRecur extends CRM_Core_DAO {
           'bao' => 'CRM_Contribute_BAO_ContributionRecur',
           'localizable' => 0,
           'FKClassName' => 'CRM_Financial_DAO_PaymentProcessor',
+          'html' => [
+            'type' => 'Select',
+          ],
+          'pseudoconstant' => [
+            'table' => 'civicrm_payment_processor',
+            'keyColumn' => 'id',
+            'labelColumn' => 'name',
+          ]
         ],
         'financial_type_id' => [
           'name' => 'financial_type_id',
@@ -619,6 +642,9 @@ class CRM_Contribute_DAO_ContributionRecur extends CRM_Core_DAO {
           'bao' => 'CRM_Contribute_BAO_ContributionRecur',
           'localizable' => 0,
           'FKClassName' => 'CRM_Financial_DAO_FinancialType',
+          'html' => [
+            'type' => 'Select',
+          ],
           'pseudoconstant' => [
             'table' => 'civicrm_financial_type',
             'keyColumn' => 'id',
@@ -657,6 +683,9 @@ class CRM_Contribute_DAO_ContributionRecur extends CRM_Core_DAO {
           'bao' => 'CRM_Contribute_BAO_ContributionRecur',
           'localizable' => 0,
           'FKClassName' => 'CRM_Campaign_DAO_Campaign',
+          'html' => [
+            'type' => 'Select',
+          ],
           'pseudoconstant' => [
             'table' => 'civicrm_campaign',
             'keyColumn' => 'id',
index 16c6ba562b368961150c2394cad23bec18e774e3..93cb1e0ee9a76e835b8635ea90bc72db39b03de6 100644 (file)
@@ -384,11 +384,8 @@ class CRM_Contribute_Form_AdditionalPayment extends CRM_Contribute_Form_Abstract
     $statusMsg = ts('The payment record has been processed.');
     // send email
     if (!empty($result) && !empty($this->_params['is_email_receipt'])) {
-      $this->_params['contact_id'] = $this->_contactId;
-      $this->_params['contribution_id'] = $this->_contributionId;
-
-      $sendReceipt = $this->emailReceipt($this->_params);
-      if ($sendReceipt) {
+      $sendResult = civicrm_api3('Payment', 'sendconfirmation', ['id' => $result->id])['values'][$result->id];
+      if ($sendResult['is_sent']) {
         $statusMsg .= ' ' . ts('A receipt has been emailed to the contributor.');
       }
     }
@@ -498,88 +495,6 @@ class CRM_Contribute_Form_AdditionalPayment extends CRM_Contribute_Form_Abstract
     }
   }
 
-  /**
-   * Function to send email receipt.
-   *
-   * @param array $params
-   *
-   * @return bool
-   */
-  public function emailReceipt(&$params) {
-    $templateEngine = CRM_Core_Smarty::singleton();
-    // email receipt sending
-    list($contributorDisplayName, $contributorEmail, $doNotMail) = CRM_Contact_BAO_Contact::getContactDetails($params['contact_id']);
-    if (!$contributorEmail || $doNotMail) {
-      return FALSE;
-    }
-    $templateEngine->assign('contactDisplayName', $contributorDisplayName);
-    // send message template
-    if ($this->_component == 'event') {
-
-      // fetch event information from participant ID using API
-      $eventId = civicrm_api3('Participant', 'getvalue', array(
-        'return' => "event_id",
-        'id' => $this->_id,
-      ));
-      $event = civicrm_api3('Event', 'getsingle', array('id' => $eventId));
-
-      $templateEngine->assign('event', $event);
-      $templateEngine->assign('isShowLocation', $event['is_show_location']);
-      if (CRM_Utils_Array::value('is_show_location', $event) == 1) {
-        $locationParams = array(
-          'entity_id' => $eventId,
-          'entity_table' => 'civicrm_event',
-        );
-        $location = CRM_Core_BAO_Location::getValues($locationParams, TRUE);
-        $templateEngine->assign('location', $location);
-      }
-    }
-
-    // assign payment info here
-    $paymentConfig['confirm_email_text'] = CRM_Utils_Array::value('confirm_email_text', $params);
-    $templateEngine->assign('paymentConfig', $paymentConfig);
-
-    $templateEngine->assign('totalAmount', $this->_amtTotal);
-
-    $isRefund = ($this->_paymentType == 'refund') ? TRUE : FALSE;
-    $templateEngine->assign('isRefund', $isRefund);
-    if ($isRefund) {
-      $templateEngine->assign('totalPaid', $this->_amtPaid);
-      $templateEngine->assign('refundAmount', $params['total_amount']);
-    }
-    else {
-      $balance = $this->_amtTotal - ($this->_amtPaid + $params['total_amount']);
-      $paymentsComplete = ($balance == 0) ? 1 : 0;
-      $templateEngine->assign('amountOwed', $balance);
-      $templateEngine->assign('paymentAmount', $params['total_amount']);
-      $templateEngine->assign('paymentsComplete', $paymentsComplete);
-    }
-
-    // assign trxn details
-    $templateEngine->assign('trxn_id', CRM_Utils_Array::value('trxn_id', $params));
-    $templateEngine->assign('receive_date', CRM_Utils_Array::value('trxn_date', $params));
-    $templateEngine->assign('paidBy', CRM_Core_PseudoConstant::getLabel(
-      'CRM_Contribute_BAO_Contribution',
-      'payment_instrument_id',
-      $params['payment_instrument_id']
-    ));
-    $templateEngine->assign('checkNumber', CRM_Utils_Array::value('check_number', $params));
-
-    $sendTemplateParams = array(
-      'groupName' => 'msg_tpl_workflow_contribution',
-      'valueName' => 'payment_or_refund_notification',
-      'contactId' => $params['contact_id'],
-      'PDFFilename' => ts('notification') . '.pdf',
-    );
-
-    $sendTemplateParams['from'] = $params['from_email_address'];
-    $sendTemplateParams['toName'] = $contributorDisplayName;
-    $sendTemplateParams['toEmail'] = $contributorEmail;
-
-    list($mailSent) = CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams);
-    return $mailSent;
-  }
-
   /**
    * Wrapper for unit testing the post process submit function.
    *
index ba5555f3d19b07bc7c8eb065a6a70c4e4cca1603..14b5efbe79cb743fe86f8e2da8e3cf50aac3cbbc 100644 (file)
@@ -158,7 +158,6 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
    *
    * @param array $params
    * @param int $financialTypeID
-   * @param bool $pending
    * @param array $paymentProcessorOutcome
    * @param string $receiptDate
    * @param int $recurringContributionID
@@ -166,7 +165,7 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
    * @return array
    */
   public static function getContributionParams(
-    $params, $financialTypeID, $pending,
+    $params, $financialTypeID,
     $paymentProcessorOutcome, $receiptDate, $recurringContributionID) {
     $contributionParams = array(
       'financial_type_id' => $financialTypeID,
@@ -193,22 +192,12 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
         'receipt_date' => $receiptDate,
       );
     }
-    if (!$pending && $paymentProcessorOutcome) {
-      $contributionParams += array(
-        'fee_amount' => CRM_Utils_Array::value('fee_amount', $paymentProcessorOutcome),
-        'net_amount' => CRM_Utils_Array::value('net_amount', $paymentProcessorOutcome, $params['amount']),
-        'trxn_id' => $paymentProcessorOutcome['trxn_id'],
-        'receipt_date' => $receiptDate,
-        // also add financial_trxn details as part of fix for CRM-4724
-        'trxn_result_code' => CRM_Utils_Array::value('trxn_result_code', $paymentProcessorOutcome),
-      );
-    }
 
     if ($recurringContributionID) {
       $contributionParams['contribution_recur_id'] = $recurringContributionID;
     }
 
-    $contributionParams['contribution_status_id'] = $pending ? 2 : 1;
+    $contributionParams['contribution_status_id'] = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Pending');
     if (isset($contributionParams['invoice_id'])) {
       $contributionParams['id'] = CRM_Core_DAO::getFieldValue(
         'CRM_Contribute_DAO_Contribution',
@@ -957,7 +946,7 @@ class CRM_Contribute_Form_Contribution_Confirm extends CRM_Contribute_Form_Contr
 
     if (isset($params['amount'])) {
       $contributionParams = array_merge(self::getContributionParams(
-        $params, $financialType->id, TRUE,
+        $params, $financialType->id,
         $result, $receiptDate,
         $recurringContributionID), $contributionParams
       );
index 8591f8be32bb0677a5a9b7df4410f10581b8cf66..05efdae2266671facc5c31239ae2e22f8573ff6c 100644 (file)
@@ -301,6 +301,7 @@ class CRM_Contribute_Form_Contribution_ThankYou extends CRM_Contribute_Form_Cont
       $contributionStatusID = civicrm_api3('Contribution', 'getvalue', array(
         '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'
index 5b860d8d9410c11bca95155ae7138c1910f8670a..aee9f0ec37e929eaa2ffc674c1f02fff424137bd 100644 (file)
@@ -256,7 +256,6 @@ class CRM_Contribute_Form_ContributionView extends CRM_Core_Form {
    * Build the form object.
    */
   public function buildQuickForm() {
-
     $this->addButtons(array(
       array(
         'type' => 'cancel',
index 9e55c4839a4955d95bdbe6e58255eec25ff236bd..f00ec966214bdc71435bfd192979bd4950aeba14 100644 (file)
@@ -80,8 +80,6 @@ class CRM_Contribute_Form_Search extends CRM_Core_Form_Search {
     $this->_actionButtonName = $this->getButtonName('next', 'action');
 
     $this->_done = FALSE;
-    // @todo - is this an error - $this->_defaults is used.
-    $this->defaults = array();
 
     $this->loadStandardSearchOptionsFromUrl();
 
index 81a0521cc6b46c8c46ea83220d248d3084db4010..7771184f1947ed7a8ebc4b6a9d976836c971fbcf 100644 (file)
@@ -420,8 +420,10 @@ AND         cp.page_type = 'contribute'
     $params = array();
 
     $whereClause = $this->whereClause($params, FALSE);
-    $this->pagerAToZ($whereClause, $params);
-
+    $config = CRM_Core_Config::singleton();
+    if ($config->includeAlphabeticalPager) {
+      $this->pagerAToZ($whereClause, $params);
+    }
     $params = array();
     $whereClause = $this->whereClause($params, TRUE);
     $this->pager($whereClause, $params);
index ed5200a852430d02ab4894118bff084e5cf86208..2a08ede086e79de6b4c6197b629978c51e46c747 100644 (file)
@@ -243,9 +243,14 @@ class CRM_Contribute_Page_Tab extends CRM_Core_Page {
   private function buildRecurringContributionsArray($recurContributions) {
     $liveRecurringContributionCount = 0;
     foreach ($recurContributions as $recurId => $recurDetail) {
-      $action = array_sum(array_keys($this->recurLinks($recurId)));
-      // no action allowed if it's not active
-      $recurContributions[$recurId]['is_active'] = (!CRM_Contribute_BAO_Contribution::isContributionStatusNegative($recurDetail['contribution_status_id']));
+      // Is recurring contribution active?
+      $recurContributions[$recurId]['is_active'] = !in_array(CRM_Contribute_PseudoConstant::contributionStatus($recurDetail['contribution_status_id'], 'name'), CRM_Contribute_BAO_ContributionRecur::getInactiveStatuses());
+      if ($recurContributions[$recurId]['is_active']) {
+        $actionMask = array_sum(array_keys(self::recurLinks($recurId)));
+      }
+      else {
+        $actionMask = CRM_Core_Action::mask([CRM_Core_Permission::VIEW]);
+      }
 
       if (empty($recurDetail['is_test'])) {
         $liveRecurringContributionCount++;
@@ -260,20 +265,18 @@ class CRM_Contribute_Page_Tab extends CRM_Core_Page {
         $recurContributions[$recurId]['contribution_status'] = CRM_Core_PseudoConstant::getLabel('CRM_Contribute_BAO_ContributionRecur', 'contribution_status_id', $recurDetail['contribution_status_id']);
       }
 
-      if ($recurContributions[$recurId]['is_active']) {
-        $recurContributions[$recurId]['action'] = CRM_Core_Action::formLink(self::recurLinks($recurId), $action,
-          array(
-            'cid' => $this->_contactId,
-            'crid' => $recurId,
-            'cxt' => 'contribution',
-          ),
-          ts('more'),
-          FALSE,
-          'contribution.selector.recurring',
-          'Contribution',
-          $recurId
-        );
-      }
+      $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',
+        'Contribution',
+        $recurId
+      );
     }
 
     return [$recurContributions, $liveRecurringContributionCount];
index 68af603cf224374cf2f5248578bad7cf987a7d3c..9b4e614c389f901c3613ce800bf178ad9efbe8dd 100644 (file)
@@ -36,20 +36,33 @@ class CRM_Contribute_Page_UserDashboard extends CRM_Contact_Page_View_UserDashBo
    * called when action is browse.
    */
   public function listContribution() {
-    $controller = new CRM_Core_Controller_Simple(
-      'CRM_Contribute_Form_Search',
-      ts('Contributions'),
-      NULL,
-      FALSE, FALSE, TRUE, FALSE
-    );
-    $controller->setEmbedded(TRUE);
-    $controller->reset();
-    $controller->set('limit', 12);
-    $controller->set('cid', $this->_contactId);
-    $controller->set('context', 'user');
-    $controller->set('force', 1);
-    $controller->process();
-    $controller->run();
+    $rows = civicrm_api3('Contribution', 'get', [
+      'options' => ['limit' => 12],
+      'sequential' => 1,
+      'contact_id' => $this->_contactId,
+      'return' => [
+        'total_amount',
+        'contribution_recur_id',
+        'financial_type',
+        'receive_date',
+        'receipt_date',
+        'contribution_status',
+        'currency',
+        'amount_level',
+        'contact_id,',
+        'contribution_source',
+      ],
+    ])['values'];
+
+    foreach ($rows as $index => $row) {
+      // This is required for tpl logic. We should move away from hard-code this to adding an array of actions to the row
+      // which the tpl can iterate through - this should allow us to cope with competing attempts to add new buttons
+      // and allow extensions to assign new ones through the pageRun hook
+      $row[0]['contribution_status_name'] = CRM_Core_PseudoConstant::getName('CRM_Contribute_BAO_Contribution', 'contribution_status_id', $row['contribution_status_id']);;
+    }
+
+    $this->assign('contribute_rows', $rows);
+    $this->assign('contributionSummary', ['total_amount' => civicrm_api3('Contribution', 'getcount', ['contact_id' => $this->_contactId])]);
 
     //add honor block
     $params = CRM_Contribute_BAO_Contribution::getHonorContacts($this->_contactId);
@@ -65,18 +78,14 @@ class CRM_Contribute_Page_UserDashboard extends CRM_Contact_Page_View_UserDashBo
     $recur->is_test = 0;
     $recur->find();
 
-    $config = CRM_Core_Config::singleton();
-
     $recurStatus = CRM_Contribute_PseudoConstant::contributionStatus();
 
     $recurRow = array();
     $recurIDs = array();
     while ($recur->fetch()) {
-      $mode = $recur->is_test ? 'test' : 'live';
-      $paymentProcessor = CRM_Contribute_BAO_ContributionRecur::getPaymentProcessor($recur->id,
-        $mode
-      );
-      if (!$paymentProcessor) {
+      if (empty($recur->payment_processor_id)) {
+        // it's not clear why we continue here as any without a processor id would likely
+        // be imported from another system & still seem valid.
         continue;
       }
 
@@ -110,10 +119,6 @@ class CRM_Contribute_Page_UserDashboard extends CRM_Contact_Page_View_UserDashBo
       );
 
       $recurIDs[] = $values['id'];
-
-      //reset $paymentObject for checking other paymenet processor
-      //recurring url
-      $paymentObject = NULL;
     }
     if (is_array($recurIDs) && !empty($recurIDs)) {
       $getCount = CRM_Contribute_BAO_ContributionRecur::getCount($recurIDs);
index 6bfc54f5ba375bfec7a791ffbea6168d18870f32..0606f9a20774cc2a607bf022bea58ccef2f1eabe 100644 (file)
@@ -563,14 +563,16 @@ class CRM_Contribute_Selector_Search extends CRM_Core_Selector_Base implements C
             'field_name' => 'contribution_status',
             'direction' => CRM_Utils_Sort::DONTCARE,
           ),
-          array(
-            'name' => ts('Premium'),
-            'sort' => 'product_name',
-            'field_name' => 'product_name',
-            'direction' => CRM_Utils_Sort::DONTCARE,
-          ),
         )
       );
+    if (CRM_Contribute_BAO_Query::isSiteHasProducts()) {
+      self::$_columnHeaders[] = [
+        'name' => ts('Premium'),
+        'sort' => 'product_name',
+        'field_name' => 'product_name',
+        'direction' => CRM_Utils_Sort::DONTCARE,
+      ];
+    }
     if (!$this->_single) {
       $pre = array(
         array(
@@ -617,7 +619,7 @@ class CRM_Contribute_Selector_Search extends CRM_Core_Selector_Base implements C
    * @return mixed
    */
   public function alphabetQuery() {
-    return $this->_query->searchQuery(NULL, NULL, NULL, FALSE, FALSE, TRUE);
+    return $this->_query->alphabetQuery();
   }
 
   /**
index 4ada8f0bdffce193cefd355d2d0f5055e6750704..2ff74bbb3740a2ed0726826795635103670f18b9 100644 (file)
@@ -771,6 +771,11 @@ ORDER BY civicrm_address.is_primary DESC, civicrm_address.location_type_id DESC,
       $streetAddress = trim($streetAddress);
     }
 
+    // If street number is too large, we cannot store it.
+    if ($parseFields['street_number'] > CRM_Utils_Type::INT_MAX) {
+      return $emptyParseFields;
+    }
+
     // suffix might be like 1/2
     $matches = array();
     if (preg_match('/^\d\/\d/', $streetAddress, $matches)) {
index f110870e632be12749c08f176ba6654f8ed82d46..82038c39e4c6634c1f55a4647bff727aaf0c4129 100644 (file)
@@ -1093,7 +1093,7 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
         else {
           // FIXME: This won't work with customFieldOptions hook
           $attributes += array(
-            'entity' => 'option_value',
+            'entity' => 'OptionValue',
             'placeholder' => $placeholder,
             'multiple' => $search,
             'api' => array(
index 69ea71606e3e273f087ac08486bf1dbef8c839a7..84417ab6f6649ced6656f4b55cf2385085059c87 100644 (file)
@@ -219,7 +219,7 @@ class CRM_Core_BAO_CustomValueTable {
             default:
               break;
           }
-          if (strtolower($value) === "null") {
+          if ($value === 'null') {
             // when unsetting a value to null, we don't need to validate the type
             // https://projectllr.atlassian.net/browse/VGQBMP-20
             $set[$field['column_name']] = $value;
index 3eb7aecadce4137e00d41cd34cd15dd0c08de141..f6ec9f6c65e56e7a61e2a00c8400c080476965ec 100644 (file)
@@ -437,23 +437,27 @@ WHERE ceft.entity_id = %1";
   }
 
   /**
-   * get partial payment amount and type of it.
+   * get partial payment amount.
+   *
+   * @deprecated
+   *
+   * This function basically calls CRM_Contribute_BAO_Contribution::getContributionBalance
+   * - just do that. If need be we could have a fn to get the contribution id but
+   * chances are the calling functions already know it anyway.
    *
    * @param int $entityId
    * @param string $entityName
-   * @param bool $returnType
    * @param int $lineItemTotal
    *
-   * @return array|int|NULL|string
-   *   [payment type => amount]
-   *   payment type: 'amount_owed' or 'refund_due'
+   * @return array
    */
-  public static function getPartialPaymentWithType($entityId, $entityName = 'participant', $returnType = TRUE, $lineItemTotal = NULL) {
+  public static function getPartialPaymentWithType($entityId, $entityName = 'participant', $lineItemTotal = NULL) {
     $value = NULL;
     if (empty($entityName)) {
       return $value;
     }
 
+    // @todo - deprecate passing in entity & type - just figure out contribution id FIRST
     if ($entityName == 'participant') {
       $contributionId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $entityId, 'contribution_id', 'participant_id');
     }
@@ -467,60 +471,39 @@ WHERE ceft.entity_id = %1";
 
     if ($contributionId && $financialTypeId) {
 
-      $value = CRM_Contribute_BAO_Contribution::getContributionBalance($contributionId, $lineItemTotal);
-
-      $paymentVal = $value;
-      if ($returnType) {
-        $value = array();
-        if ($paymentVal < 0) {
-          $value['refund_due'] = $paymentVal;
-        }
-        elseif ($paymentVal > 0) {
-          $value['amount_owed'] = $paymentVal;
-        }
+      $paymentVal = CRM_Contribute_BAO_Contribution::getContributionBalance($contributionId, $lineItemTotal);
+      $value = [];
+      if ($paymentVal < 0) {
+        $value['refund_due'] = $paymentVal;
+      }
+      elseif ($paymentVal > 0) {
+        $value['amount_owed'] = $paymentVal;
       }
     }
     return $value;
   }
 
   /**
-   * @param int $contributionId
+   * @param int $contributionID
+   * @param bool $includeRefund
    *
    * @return string
    */
-  public static function getTotalPayments($contributionId) {
-    $statusId = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Completed');
+  public static function getTotalPayments($contributionID, $includeRefund = FALSE) {
+    $statusIDs = [CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Completed')];
+
+    if ($includeRefund) {
+      $statusIDs[] = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Refunded');
+    }
 
     $sql = "SELECT SUM(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.is_payment = 1 AND ft.status_id = %2";
+      WHERE eft.entity_id = %1 AND ft.is_payment = 1 AND ft.status_id IN (%2) ";
 
-    $params = array(
-      1 => array($contributionId, 'Integer'),
-      2 => array($statusId, 'Integer'),
-    );
-
-    return CRM_Core_DAO::singleValueQuery($sql, $params);
-  }
-
-  /**
-   * Function records partial payment, complete's contribution if payment is fully paid
-   * and returns latest payment ie financial trxn
-   *
-   * @param array $contribution
-   * @param array $params
-   *
-   * @return \CRM_Financial_DAO_FinancialTrxn
-   */
-  public static function getPartialPaymentTrxn($contribution, $params) {
-    $trxn = CRM_Contribute_BAO_Contribution::recordPartialPayment($contribution, $params);
-    $paid = CRM_Core_BAO_FinancialTrxn::getTotalPayments($params['contribution_id']);
-    $total = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $params['contribution_id'], 'total_amount');
-    $cmp = bccomp($total, $paid, 5);
-    if ($cmp == 0 || $cmp == -1) {// If paid amount is greater or equal to total amount
-      civicrm_api3('Contribution', 'completetransaction', array('id' => $contribution['id']));
-    }
-    return $trxn;
+    return CRM_Core_DAO::singleValueQuery($sql, [
+      1 => [$contributionID, 'Integer'],
+      2 => [implode(',', $statusIDs), 'CommaSeparatedIntegers'],
+    ]);
   }
 
   /**
index 4006a300fef5fc5554323cabc29a6803b03f0db7..7e025198b67b698be300373f66c332cfabbda6a6 100644 (file)
@@ -299,51 +299,6 @@ FROM civicrm_navigation WHERE domain_id = $domainID";
     return $branch;
   }
 
-  /**
-   * Build menu.
-   *
-   * @return string
-   */
-  public static function buildNavigation() {
-    $navigations = self::buildNavigationTree();
-    $navigationString = '';
-
-    // run the Navigation  through a hook so users can modify it
-    CRM_Utils_Hook::navigationMenu($navigations);
-    self::fixNavigationMenu($navigations);
-
-    // Hooks have added menu items in an arbitrary order. We need to order by
-    // weight again. I would put this function directly after
-    // CRM_Utils_Hook::navigationMenu but for some reason, fixNavigationMenu is
-    // moving items added by hooks on the end of the menu. Hence I do it
-    // afterwards
-    self::orderByWeight($navigations);
-
-    //skip children menu item if user don't have access to parent menu item
-    $skipMenuItems = array();
-    foreach ($navigations as $key => $value) {
-      // Home is a special case
-      if ($value['attributes']['name'] != 'Home') {
-        $name = self::getMenuName($value, $skipMenuItems);
-        if ($name) {
-          //separator before
-          if (isset($value['attributes']['separator']) && $value['attributes']['separator'] == 2) {
-            $navigationString .= '<li class="menu-separator"></li>';
-          }
-          $removeCharacters = array('/', '!', '&', '*', ' ', '(', ')', '.');
-          $navigationString .= '<li class="menumain crm-' . str_replace($removeCharacters, '_', $value['attributes']['label']) . '">' . $name;
-        }
-      }
-      self::recurseNavigation($value, $navigationString, $skipMenuItems);
-    }
-
-    // clean up - Need to remove empty <ul>'s, this happens when user don't have
-    // permission to access parent
-    $navigationString = str_replace('<ul></ul></li>', '', $navigationString);
-
-    return $navigationString;
-  }
-
   /**
    * buildNavigationTree retreives items in order. We call this function to
    * ensure that any items added by the hook are also in the correct order.
@@ -560,52 +515,6 @@ FROM civicrm_navigation WHERE domain_id = $domainID";
     return TRUE;
   }
 
-  /**
-   * Create navigation for CiviCRM Admin Menu.
-   *
-   * @return string
-   *   returns navigation html
-   */
-  public static function createNavigation() {
-    $navigation = self::buildNavigation();
-
-    if ($navigation) {
-
-      //add additional navigation items
-      $logoutURL = CRM_Utils_System::url('civicrm/logout', 'reset=1');
-
-      // get home menu from db
-      $homeParams = array('name' => 'Home');
-      $homeNav = array();
-      $homeIcon = '<span class="crm-logo-sm" ></span>';
-      self::retrieve($homeParams, $homeNav);
-      if ($homeNav) {
-        $homeURL = self::makeFullyFormedUrl($homeNav['url']);
-        $homeLabel = $homeNav['label'];
-        // CRM-6804 (we need to special-case this as we don’t ts()-tag variables)
-        if ($homeLabel == 'Home') {
-          $homeLabel = ts('CiviCRM Home');
-        }
-      }
-      else {
-        $homeURL = CRM_Utils_System::url('civicrm/dashboard', 'reset=1');
-        $homeLabel = ts('CiviCRM Home');
-      }
-      // Link to hide the menubar
-      $hideLabel = ts('Hide Menu');
-
-      $prepandString = "
-        <li class='menumain crm-link-home'>$homeIcon
-          <ul id='civicrm-home'>
-            <li><a href='$homeURL'>$homeLabel</a></li>
-            <li><a href='#' class='crm-hidemenu'>$hideLabel</a></li>
-            <li><a href='$logoutURL' class='crm-logout-link'>" . ts('Log out') . "</a></li>
-          </ul>";
-      // <li> tag doesn't need to be closed
-    }
-    return $prepandString . $navigation;
-  }
-
   /**
    * Turns relative URLs (like civicrm/foo/bar) into fully-formed
    * ones (i.e. example.com/wp-admin?q=civicrm/dashboard).
@@ -1051,4 +960,64 @@ FROM civicrm_navigation WHERE domain_id = $domainID";
     return $key;
   }
 
+  /**
+   * Unset menu items for disabled components and non-permissioned users
+   *
+   * @param $menu
+   */
+  public static function filterByPermission(&$menu) {
+    foreach ($menu as $key => $item) {
+      if (
+        (array_key_exists('active', $item['attributes']) && !$item['attributes']['active']) ||
+        !CRM_Core_BAO_Navigation::checkPermission($item['attributes'])
+      ) {
+        unset($menu[$key]);
+        continue;
+      }
+      if (!empty($item['child'])) {
+        self::filterByPermission($menu[$key]['child']);
+      }
+    }
+  }
+
+  /**
+   * @param array $menu
+   */
+  public static function buildHomeMenu(&$menu) {
+    foreach ($menu as &$item) {
+      if (CRM_Utils_Array::value('name', $item['attributes']) === 'Home') {
+        unset($item['attributes']['label'], $item['attributes']['url']);
+        $item['attributes']['icon'] = 'crm-logo-sm';
+        $item['attributes']['attr']['accesskey'] = 'm';
+        $item['child'] = [
+          [
+            'attributes' => [
+              'label' => 'CiviCRM Home',
+              'name' => 'CiviCRM Home',
+              'url' => 'civicrm/dashboard?reset=1',
+              'weight' => 1,
+            ]
+          ],
+          [
+            'attributes' => [
+              'label' => 'Hide Menu',
+              'name' => 'Hide Menu',
+              'url' => '#hidemenu',
+              'weight' => 2,
+            ]
+          ],
+          [
+            'attributes' => [
+              'label' => 'Log out',
+              'name' => 'Log out',
+              'url' => 'civicrm/logout?reset=1',
+              'weight' => 3,
+            ]
+          ],
+        ];
+        return;
+      }
+    }
+  }
+
 }
index 952e70aedfefdfebb0b1b5e2951f96123bfa1054..ed8f31cec9fa3346b514816bf23781530a5d87f0 100644 (file)
@@ -993,8 +993,10 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup {
 
     $details = $query->searchQuery(0, 0, NULL, FALSE, FALSE,
       FALSE, FALSE, FALSE, $additionalWhereClause);
-    if (!$details->fetch()) {
-      return;
+    while ($details->fetch()) {
+      if (!$details) {
+        return;
+      }
     }
     $query->convertToPseudoNames($details);
     $config = CRM_Core_Config::singleton();
@@ -3320,57 +3322,6 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
     }
   }
 
-  /**
-   * @param array|string $profiles - name of profile(s) to create links for
-   * @param array $appendProfiles
-   *   Name of profile(s) to append to each link.
-   *
-   * @return array
-   */
-  public static function getCreateLinks($profiles = '', $appendProfiles = array()) {
-    if (!CRM_Contact_BAO_Contact::entityRefCreateLinks()) {
-      return [];
-    }
-    // Default to contact profiles
-    if (!$profiles) {
-      $profiles = array('new_individual', 'new_organization', 'new_household');
-    }
-    $profiles = (array) $profiles;
-    $toGet = array_merge($profiles, (array) $appendProfiles);
-    $retrieved = civicrm_api3('uf_group', 'get', array(
-      'name' => array('IN' => $toGet),
-      'is_active' => 1,
-    ));
-    $links = $append = array();
-    if (!empty($retrieved['values'])) {
-      $icons = [
-        'individual' => 'fa-user',
-        'organization' => 'fa-building',
-        'household' => 'fa-home',
-      ];
-      foreach ($retrieved['values'] as $id => $profile) {
-        if (in_array($profile['name'], $profiles)) {
-          $links[] = array(
-            'label' => $profile['title'],
-            'url' => CRM_Utils_System::url('civicrm/profile/create', "reset=1&context=dialog&gid=$id",
-              NULL, NULL, FALSE, FALSE, TRUE),
-            'type' => ucfirst(str_replace('new_', '', $profile['name'])),
-            'icon' => CRM_Utils_Array::value(str_replace('new_', '', $profile['name']), $icons),
-          );
-        }
-        else {
-          $append[] = $id;
-        }
-      }
-      foreach ($append as $id) {
-        foreach ($links as &$link) {
-          $link['url'] .= ",$id";
-        }
-      }
-    }
-    return $links;
-  }
-
   /**
    * Retrieve groups of  profiles.
    *
index 3f0d19b886a3827577b45a486cb0442ff7576411..54ac1e4be7e04c53e54e3e3367a0f7b7524a5a1c 100644 (file)
@@ -2367,13 +2367,14 @@ SELECT contact_id
    *
    * @param array $fields
    */
-  protected static function appendPseudoConstantsToFields(&$fields) {
+  public static function appendPseudoConstantsToFields(&$fields) {
     foreach ($fields as $field) {
       if (!empty($field['pseudoconstant']) && !empty($field['pseudoconstant']['optionGroupName'])) {
         $fields[$field['pseudoconstant']['optionGroupName']] = array(
           'title' => CRM_Core_BAO_OptionGroup::getTitleByName($field['pseudoconstant']['optionGroupName']),
           'name' => $field['pseudoconstant']['optionGroupName'],
           'data_type' => CRM_Utils_Type::T_STRING,
+          'is_pseudofield_for' => $field['name'],
         );
       }
     }
@@ -2810,6 +2811,13 @@ SELECT contact_id
     }
   }
 
+  /**
+   * @return array
+   */
+  public static function getEntityRefFilters() {
+    return [];
+  }
+
   /**
    * Get exportable fields with pseudoconstants rendered as an extra field.
    *
index 4d74ea35d34348afd1c31c689aa118584de5c390..03060e11a6b548fb5c9ac581ba06b4ac2efe9b23 100644 (file)
@@ -198,7 +198,7 @@ class CRM_Core_DAO_AllCoreTables {
    * @return bool
    */
   public static function isCoreTable($tableName) {
-    return FALSE !== array_search($tableName, self::tables());
+    return array_key_exists($tableName, self::tables());
   }
 
   /**
index 7f225f4c6f6be29869bafceff5c45cf6dcfe8f00..597e54378852be378b54642ec698e248f7bc9e6c 100644 (file)
@@ -641,6 +641,10 @@ class CRM_Core_Form extends HTML_QuickForm_Page {
   public function addButtons($params) {
     $prevnext = $spacing = array();
     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);
 
       if (!empty($button['class'])) {
@@ -1932,10 +1936,10 @@ class CRM_Core_Form extends HTML_QuickForm_Page {
    * @param array $props
    *   Mix of html and widget properties, including:.
    *   - select - params to give to select2 widget
-   *   - entity - defaults to contact
+   *   - entity - defaults to Contact
    *   - create - can the user create a new entity on-the-fly?
    *             Set to TRUE if entity is contact and you want the default profiles,
-   *             or pass in your own set of links. @see CRM_Core_BAO_UFGroup::getCreateLinks for format
+   *             or pass in your own set of links. @see CRM_Campaign_BAO_Campaign::getEntityRefCreateLinks for format
    *             note that permissions are checked automatically
    *   - api - array of settings for the getlist api wrapper
    *          note that it accepts a 'params' setting which will be passed to the underlying api
@@ -1947,18 +1951,11 @@ class CRM_Core_Form extends HTML_QuickForm_Page {
    * @return HTML_QuickForm_Element
    */
   public function addEntityRef($name, $label = '', $props = array(), $required = FALSE) {
-    require_once "api/api.php";
-    $config = CRM_Core_Config::singleton();
     // Default properties
     $props['api'] = CRM_Utils_Array::value('api', $props, array());
-    $props['entity'] = _civicrm_api_get_entity_name_from_camel(CRM_Utils_Array::value('entity', $props, 'contact'));
+    $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');
 
-    if (isset($props['create']) && $props['create'] === TRUE) {
-      require_once "api/v3/utils.php";
-      $baoClass = _civicrm_api3_get_BAO($props['entity']);
-      $props['create'] = $baoClass && is_callable([$baoClass, 'entityRefCreateLinks']) ? $baoClass::entityRefCreateLinks() : FALSE;
-    }
     if (array_key_exists('create', $props) && empty($props['create'])) {
       unset($props['create']);
     }
index 6693f88dfafe341bf3554f854c0edf7c5d6240d8..63e5f781f992a1e74451b1aa470f9540b288909b 100644 (file)
@@ -114,6 +114,10 @@ trait CRM_Core_Form_EntityFormTrait {
     $this->assign('entityTable', CRM_Core_DAO_AllCoreTables::getTableForClass(CRM_Core_DAO_AllCoreTables::getFullName($this->getDefaultEntity())));
     $this->addCustomDataToForm();
     $this->addFormButtons();
+
+    if ($this->isViewContext()) {
+      $this->freeze();
+    }
   }
 
   /**
@@ -128,7 +132,7 @@ trait CRM_Core_Form_EntityFormTrait {
    * Add relevant buttons to the form.
    */
   protected function addFormButtons() {
-    if ($this->_action & CRM_Core_Action::VIEW || $this->_action & CRM_Core_Action::PREVIEW) {
+    if ($this->isViewContext() || $this->_action & CRM_Core_Action::PREVIEW) {
       $this->addButtons(array(
           array(
             'type' => 'cancel',
@@ -142,7 +146,7 @@ trait CRM_Core_Form_EntityFormTrait {
       $this->addButtons(array(
           array(
             'type' => 'next',
-            'name' => $this->_action & CRM_Core_Action::DELETE ? ts('Delete') : ts('Save'),
+            'name' => $this->isDeleteContext() ? ts('Delete') : ts('Save'),
             'isDefault' => TRUE,
           ),
           array(
@@ -158,20 +162,34 @@ trait CRM_Core_Form_EntityFormTrait {
    * Get the defaults for the entity.
    */
   protected function getEntityDefaults() {
-    $defaults = [];
-    if ($this->_action != CRM_Core_Action::DELETE &&
+    $defaults = $moneyFields = [];
+
+    if (!$this->isDeleteContext() &&
       $this->getEntityId()
     ) {
       $params = ['id' => $this->getEntityId()];
       $baoName = $this->_BAOName;
       $baoName::retrieve($params, $defaults);
     }
-    foreach ($this->entityFields as $fieldSpec) {
+    foreach ($this->entityFields as $entityFieldName => $fieldSpec) {
       $value = CRM_Utils_Request::retrieveValue($fieldSpec['name'], $this->getValidationTypeForField($fieldSpec['name']));
       if ($value !== FALSE && $value !== NULL) {
         $defaults[$fieldSpec['name']] = $value;
       }
+      // Store a list of fields with money formatters
+      if (CRM_Utils_Array::value('formatter', $fieldSpec) == 'crmMoney') {
+        $moneyFields[] = $entityFieldName;
+      }
     }
+    if (!empty($defaults['currency'])) {
+      // If we have a money formatter we need to pass the specified currency or it will render as the default
+      foreach ($moneyFields as $entityFieldName) {
+        $this->entityFields[$entityFieldName]['formatterParam'] = $defaults['currency'];
+      }
+    }
+
+    // Assign again as we may have modified above
+    $this->assign('entityFields', $this->entityFields);
     return $defaults;
   }
 
@@ -244,6 +262,15 @@ trait CRM_Core_Form_EntityFormTrait {
     return ($this->_action & CRM_Core_Action::DELETE);
   }
 
+  /**
+   * Is the form being used in the context of a view.
+   *
+   * @return bool
+   */
+  protected function isViewContext() {
+    return ($this->_action & CRM_Core_Action::VIEW);
+  }
+
   protected function setEntityFieldsMetadata() {
     foreach ($this->entityFields as $field => &$props) {
       if (!empty($props['not-auto-addable'])) {
index 82847220267918fede00c27adff8e6d09021bde6..1eeb9f0b7d6400782f4826baa92baa644cac5361 100644 (file)
@@ -322,20 +322,20 @@ class CRM_Core_Form_Renderer extends HTML_QuickForm_Renderer_ArraySmarty {
    * @param HTML_QuickForm_element $field
    */
   public function renderFrozenEntityRef(&$el, $field) {
-    $entity = strtolower($field->getAttribute('data-api-entity'));
+    $entity = $field->getAttribute('data-api-entity');
     $vals = json_decode($field->getAttribute('data-entity-value'), TRUE);
     $display = array();
 
     // Custom fields of type contactRef store their data in a slightly different format
-    if ($field->getAttribute('data-crm-custom') && $entity == 'contact') {
+    if ($field->getAttribute('data-crm-custom') && $entity == 'Contact') {
       $vals = array(array('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)) {
+      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']));
-        $val['label'] = '<a class="view-' . $entity . ' no-popup" href="' . $url . '" title="' . ts('View Contact') . '">' . CRM_Utils_String::purifyHTML($val['label']) . '</a>';
+        $val['label'] = '<a class="view-contact no-popup" href="' . $url . '" title="' . ts('View Contact') . '">' . CRM_Utils_String::purifyHTML($val['label']) . '</a>';
       }
       $display[] = $val['label'];
     }
index 0ff005ca959641d8a2dc1718210c412b20271c41..b47d0779ca4d2b9241eb7a685a47520002711a9a 100644 (file)
@@ -78,7 +78,7 @@ class CRM_Core_Form_Tag {
         $tagset[$tagsetItem]['tagsetElementName'] = $tagsetElementName;
 
         $form->addEntityRef("{$tagsetElementName}[{$parentId}]", $parentNameItem, array(
-          'entity' => 'tag',
+          'entity' => 'Tag',
           'multiple' => TRUE,
           'create' => !$skipTagCreate,
           'api' => array('params' => array('parent_id' => $parentId)),
index 076068079206d672ccc52787a09b719b37de394e..fb59a3c5f86afd8d30ff338719fff0455d9e9ca2 100644 (file)
@@ -499,7 +499,7 @@ class CRM_Core_PseudoConstant {
   }
 
   /**
-   * DEPRECATED generic populate method.
+   * @deprecated generic populate method.
    * All pseudoconstant functions that use this method are also @deprecated
    *
    * The static array $var is populated from the db
index 21401e24e6a93fad0499ece7cf64dc669bb1785f..3c9ecf006e9e6e2afa5acb219b135a32c0d1de16 100644 (file)
@@ -591,34 +591,24 @@ class CRM_Core_Resources {
         if (is_array($item)) {
           $this->addSetting($item);
         }
-        elseif (substr($item, -2) == 'js') {
+        elseif (strpos($item, '.css')) {
+          $this->isFullyFormedUrl($item) ? $this->addStyleUrl($item, -100, $region) : $this->addStyleFile('civicrm', $item, -100, $region);
+        }
+        elseif ($this->isFullyFormedUrl($item)) {
+          $this->addScriptUrl($item, $jsWeight++, $region);
+        }
+        else {
           // Don't bother  looking for ts() calls in packages, there aren't any
           $translate = (substr($item, 0, 3) == 'js/');
           $this->addScriptFile('civicrm', $item, $jsWeight++, $region, $translate);
         }
-        else {
-          $this->addStyleFile('civicrm', $item, -100, $region);
-        }
       }
-
-      $tsLocale = CRM_Core_I18n::getLocale();
-      // Dynamic localization script
-      $args = [
-        'r' => $this->getCacheCode(),
-        'cid' => CRM_Core_Session::getLoggedInContactID(),
-      ];
-      $this->addScriptUrl(CRM_Utils_System::url('civicrm/ajax/l10n-js/' . $tsLocale, $args, FALSE, NULL, FALSE), $jsWeight++, $region);
-
       // Add global settings
       $settings = array(
         'config' => array(
           'isFrontend' => $config->userFrameworkFrontend,
         ),
       );
-      $contactID = CRM_Core_Session::getLoggedInContactID();
-      if ($contactID) {
-        $settings['config']['menuCacheCode'] = CRM_Core_BAO_Navigation::getCacheKey($contactID);
-      }
       // 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;
@@ -687,13 +677,12 @@ class CRM_Core_Resources {
       '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...')),
-      'entityRef' => array(
-        'contactCreate' => CRM_Core_BAO_UFGroup::getCreateLinks(),
-        'filters' => self::getEntityRefFilters(),
-      ),
+      'entityRef' => self::getEntityRefMetadata(),
       'ajaxPopupsEnabled' => self::singleton()->ajaxPopupsEnabled,
       'allowAlertAutodismissal' => (bool) Civi::settings()->get('allow_alert_autodismissal'),
       '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();
@@ -733,6 +722,13 @@ class CRM_Core_Resources {
       "js/crm.ajax.js",
       "js/wysiwyg/crm.wysiwyg.js",
     );
+
+    // Dynamic localization script
+    $items[] = $this->addCacheCode(
+      CRM_Utils_System::url('civicrm/ajax/l10n-js/' . CRM_Core_I18n::getLocale(),
+        ['cid' => CRM_Core_Session::getLoggedInContactID()], FALSE, NULL, FALSE)
+    );
+
     // add wysiwyg editor
     $editor = Civi::settings()->get('editor_id');
     if ($editor == "CKEditor") {
@@ -748,11 +744,31 @@ class CRM_Core_Resources {
     // These scripts are only needed by back-office users
     if (CRM_Core_Permission::check('access CiviCRM')) {
       $items[] = "packages/jquery/plugins/jquery.tableHeader.js";
-      $items[] = "packages/jquery/plugins/jquery.menu.min.js";
-      $items[] = "css/civicrmNavigation.css";
       $items[] = "packages/jquery/plugins/jquery.notify.min.js";
     }
 
+    $contactID = CRM_Core_Session::getLoggedInContactID();
+
+    // Menubar
+    $position = $contactID && CRM_Core_Permission::check('access CiviCRM') ? Civi::settings()->get('menubar_position') : 'none';
+    if ($position !== 'none' && !@constant('CIVICRM_DISABLE_DEFAULT_MENU') && !CRM_Core_Config::isUpgradeMode()) {
+      $cms = strtolower(CRM_Core_Config::singleton()->userFramework);
+      $cms = $cms === 'drupal' ? 'drupal7' : $cms;
+      $items[] = 'bower_components/smartmenus/dist/jquery.smartmenus.min.js';
+      $items[] = 'bower_components/smartmenus/dist/addons/keyboard/jquery.smartmenus.keyboard.min.js';
+      $items[] = 'js/crm.menubar.js';
+      $items[] = 'bower_components/smartmenus/dist/css/sm-core-css.css';
+      $items[] = 'css/crm-menubar.css';
+      $items[] = "css/menubar-$cms.css";
+      $items[] = [
+        'menubar' => [
+          'position' => $position ?: 'over-cms-menu',
+          'qfKey' => CRM_Core_Key::get('CRM_Contact_Controller_Search', TRUE),
+          'cacheCode' => CRM_Core_BAO_Navigation::getCacheKey($contactID),
+        ],
+      ];
+    }
+
     // JS for multilingual installations
     if (!empty($config->languageLimit) && count($config->languageLimit) > 1 && CRM_Core_Permission::check('translate CiviCRM')) {
       $items[] = "js/crm.multilingual.js";
@@ -803,115 +819,49 @@ class CRM_Core_Resources {
 
   /**
    * Provide a list of available entityRef filters.
-   * @todo: move component filters into their respective components (e.g. CiviEvent)
    *
    * @return array
    */
-  public static function getEntityRefFilters() {
-    $filters = array();
-    $config = CRM_Core_Config::singleton();
-
-    if (in_array('CiviEvent', $config->enableComponents)) {
-      $filters['event'] = array(
-        array('key' => 'event_type_id', 'value' => ts('Event Type')),
-        array(
-          'key' => 'start_date',
-          'value' => ts('Start Date'),
-          'options' => array(
-            array('key' => '{">":"now"}', 'value' => ts('Upcoming')),
-            array(
-              'key' => '{"BETWEEN":["now - 3 month","now"]}',
-              'value' => ts('Past 3 Months'),
-            ),
-            array(
-              'key' => '{"BETWEEN":["now - 6 month","now"]}',
-              'value' => ts('Past 6 Months'),
-            ),
-            array(
-              'key' => '{"BETWEEN":["now - 1 year","now"]}',
-              'value' => ts('Past Year'),
-            ),
-          ),
-        ),
-      );
-    }
-
-    $filters['activity'] = array(
-      array('key' => 'activity_type_id', 'value' => ts('Activity Type')),
-      array('key' => 'status_id', 'value' => ts('Activity Status')),
-    );
-
-    $filters['contact'] = [
-      ['key' => 'contact_type', 'value' => ts('Contact Type')],
-      ['key' => 'group', 'value' => ts('Group'), 'entity' => 'group_contact'],
-      ['key' => 'tag', 'value' => ts('Tag'), 'entity' => 'entity_tag'],
-      ['key' => 'state_province', 'value' => ts('State/Province'), 'entity' => 'address'],
-      ['key' => 'country', 'value' => ts('Country'), 'entity' => 'address'],
-      ['key' => 'gender_id', 'value' => ts('Gender'), 'condition' => ['contact_type' => 'Individual']],
-      ['key' => 'is_deceased', 'value' => ts('Deceased'), 'condition' => ['contact_type' => 'Individual']],
-      ['key' => 'contact_id', 'value' => ts('Contact ID'), 'type' => 'text'],
-      ['key' => 'external_identifier', 'value' => ts('External ID'), 'type' => 'text'],
-      ['key' => 'source', 'value' => ts('Contact Source'), 'type' => 'text'],
+  public static function getEntityRefMetadata() {
+    $data = [
+      'filters' => [],
+      'links' => [],
     ];
+    $config = CRM_Core_Config::singleton();
 
-    if (in_array('CiviCase', $config->enableComponents)) {
-      $filters['case'] = array(
-        array(
-          'key' => 'case_id.case_type_id',
-          'value' => ts('Case Type'),
-          'entity' => 'Case',
-        ),
-        array(
-          'key' => 'case_id.status_id',
-          'value' => ts('Case Status'),
-          'entity' => 'Case',
-        ),
-      );
-      foreach ($filters['contact'] as $filter) {
-        $filter += array('entity' => 'contact');
-        $filter['key'] = 'contact_id.' . $filter['key'];
-        $filters['case'][] = $filter;
+    $disabledComponents = [];
+    $dao = CRM_Core_DAO::executeQuery("SELECT name, namespace FROM civicrm_component");
+    while ($dao->fetch()) {
+      if (!in_array($dao->name, $config->enableComponents)) {
+        $disabledComponents[$dao->name] = $dao->namespace;
       }
     }
 
-    if (in_array('CiviCampaign', $config->enableComponents)) {
-      $filters['campaign'] = [
-        ['key' => 'campaign_type_id', 'value' => ts('Campaign Type')],
-        ['key' => 'status_id', 'value' => ts('Status')],
-        [
-          'key' => 'start_date',
-          'value' => ts('Start Date'),
-          'options' => [
-            ['key' => '{">":"now"}', 'value' => ts('Upcoming')],
-            [
-              'key' => '{"BETWEEN":["now - 3 month","now"]}',
-              'value' => ts('Past 3 Months'),
-            ],
-            [
-              'key' => '{"BETWEEN":["now - 6 month","now"]}',
-              'value' => ts('Past 6 Months'),
-            ],
-            [
-              'key' => '{"BETWEEN":["now - 1 year","now"]}',
-              'value' => ts('Past Year'),
-            ],
-          ],
-        ],
-        [
-          'key' => 'end_date',
-          'value' => ts('End Date'),
-          'options' => [
-            ['key' => '{">":"now"}', 'value' => ts('In the future')],
-            ['key' => '{"<":"now"}', 'value' => ts('In the past')],
-            ['key' => '{"IS NULL":"1"}', 'value' => ts('Not set')],
-          ],
-        ],
-      ];
+    foreach (CRM_Core_DAO_AllCoreTables::daoToClass() as $entity => $daoName) {
+      // Skip DAOs of disabled components
+      foreach ($disabledComponents as $nameSpace) {
+        if (strpos($daoName, $nameSpace) === 0) {
+          continue 2;
+        }
+      }
+      $baoName = str_replace('_DAO_', '_BAO_', $daoName);
+      if (class_exists($baoName)) {
+        $filters = $baoName::getEntityRefFilters();
+        if ($filters) {
+          $data['filters'][$entity] = $filters;
+        }
+        if (is_callable([$baoName, 'getEntityRefCreateLinks'])) {
+          $createLinks = $baoName::getEntityRefCreateLinks();
+          if ($createLinks) {
+            $data['links'][$entity] = $createLinks;
+          }
+        }
+      }
     }
 
-    CRM_Utils_Hook::entityRefFilters($filters);
+    CRM_Utils_Hook::entityRefFilters($data['filters']);
 
-    return $filters;
+    return $data;
   }
 
   /**
@@ -940,4 +890,15 @@ class CRM_Core_Resources {
     return $url . $operator . 'r=' . $this->cacheCode;
   }
 
+  /**
+   * Checks if the given URL is fully-formed
+   *
+   * @param string $url
+   *
+   * @return bool
+   */
+  public static function isFullyFormedUrl($url) {
+    return (substr($url, 0, 4) === 'http') || (substr($url, 0, 1) === '/');
+  }
+
 }
diff --git a/CRM/Core/Smarty/plugins/function.crmNavigationMenu.php b/CRM/Core/Smarty/plugins/function.crmNavigationMenu.php
deleted file mode 100644 (file)
index de8f873..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5                                                  |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019                                |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM.                                    |
- |                                                                    |
- | CiviCRM is free software; you can copy, modify, and distribute it  |
- | under the terms of the GNU Affero General Public License           |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
- |                                                                    |
- | CiviCRM is distributed in the hope that it will be useful, but     |
- | WITHOUT ANY WARRANTY; without even the implied warranty of         |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
- | See the GNU Affero General Public License for more details.        |
- |                                                                    |
- | You should have received a copy of the GNU Affero General Public   |
- | License and the CiviCRM Licensing Exception along                  |
- | with this program; if not, contact CiviCRM LLC                     |
- | at info[AT]civicrm[DOT]org. If you have questions about the        |
- | GNU Affero General Public License or the licensing of CiviCRM,     |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
- +--------------------------------------------------------------------+
- */
-
-/**
- *
- * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2019
- * $Id$
- *
- */
-
-/**
- * Output navigation script tag
- *
- * @param array $params
- *   - is_default: bool, true if this is normal/default instance of the menu (which may be subject to CIVICRM_DISABLE_DEFAULT_MENU)
- * @param CRM_Core_Smarty $smarty
- *   The Smarty object.
- *
- * @return string
- *   HTML
- */
-function smarty_function_crmNavigationMenu($params, &$smarty) {
-  $config = CRM_Core_Config::singleton();
-  //check if logged in user has access CiviCRM permission and build menu
-  $buildNavigation = !CRM_Core_Config::isUpgradeMode() && CRM_Core_Permission::check('access CiviCRM');
-  if (defined('CIVICRM_DISABLE_DEFAULT_MENU') && CRM_Utils_Array::value('is_default', $params, FALSE)) {
-    $buildNavigation = FALSE;
-  }
-  if ($config->userFrameworkFrontend) {
-    $buildNavigation = FALSE;
-  }
-  if ($buildNavigation) {
-    $session = CRM_Core_Session::singleton();
-    $contactID = $session->get('userID');
-    if ($contactID) {
-      // These params force the browser to refresh the js file when switching user, domain, or language
-      // We don't put them as a query string because some browsers will refuse to cache a page with a ? in the url
-      // @see CRM_Admin_Page_AJAX::getNavigationMenu
-      $lang = CRM_Core_I18n::getLocale();
-      $domain = CRM_Core_Config::domainID();
-      $key = CRM_Core_BAO_Navigation::getCacheKey($contactID);
-      $src = CRM_Utils_System::url("civicrm/ajax/menujs/$contactID/$lang/$domain/$key");
-      // CRM-15493 QFkey needed for quicksearch bar - must be unique on each page refresh so adding it directly to markup
-      $qfKey = CRM_Core_Key::get('CRM_Contact_Controller_Search', TRUE);
-      return '<script id="civicrm-navigation-menu" type="text/javascript" src="' . $src . '" data-qfkey=' . json_encode($qfKey) . '></script>';
-    }
-  }
-  return '';
-}
index b4532199202188bf59a9f68e6116adee40257432..774be6105d798486297b7c6ffbd4592849848372 100644 (file)
@@ -7,7 +7,7 @@
      <page_callback>CRM_Activity_Form_Activity</page_callback>
      <access_arguments>access CiviCRM</access_arguments>
      <page_arguments>attachUpload=1</page_arguments>
-     <path_arguments>action=add&amp;context=standalone</path_arguments>
+     <path_arguments>action=add,context=standalone</path_arguments>
   </item>
   <item>
      <path>civicrm/activity/view</path>
index 918d372cae3e350bd9f3aa68837ad5c34b1e62c0..d23a10910bee29594132d9f217f38e0b89fa99da 100644 (file)
      <weight>9000</weight>
   </item>
   <item>
-     <path>civicrm/ajax/menujs</path>
-     <page_callback>CRM_Admin_Page_AJAX::getNavigationMenu</page_callback>
-     <access_arguments>access CiviCRM</access_arguments>
+    <path>civicrm/ajax/navmenu</path>
+    <page_callback>CRM_Admin_Page_AJAX::navMenu</page_callback>
+    <access_arguments>access CiviCRM</access_arguments>
   </item>
   <item>
      <path>civicrm/ajax/menutree</path>
index 532a11ef8181bf8a0eb7f9904c5f51cae32ba40e..d2a644f7ff184b41f2c6e102c9710d54ffaad8fc 100644 (file)
@@ -63,11 +63,18 @@ class CRM_Custom_Form_CustomData {
       $entitySubType = $form->getEntitySubTypeId($subType);
     }
 
-    // when custom data is included in this page
-    if (!empty($_POST['hidden_custom'])) {
-      self::preProcess($form, $subName, $entitySubType, $groupCount, $entityName, $entityID);
-      self::buildQuickForm($form);
-      self::setDefaultValues($form);
+    if ($form->getAction() == CRM_Core_Action::VIEW) {
+      // Viewing custom data (Use with {include file="CRM/Custom/Page/CustomDataView.tpl"} in template)
+      $groupTree = CRM_Core_BAO_CustomGroup::getTree($entityName, NULL, $entityID, 0, $entitySubType);
+      CRM_Core_BAO_CustomGroup::buildCustomDataView($form, $groupTree, FALSE, NULL, NULL, NULL, $entityID);
+    }
+    else {
+      // Editing custom data (Use with {include file="CRM/common/customDataBlock.tpl"} in template)
+      if (!empty($_POST['hidden_custom'])) {
+        self::preProcess($form, $subName, $entitySubType, $groupCount, $entityName, $entityID);
+        self::buildQuickForm($form);
+        self::setDefaultValues($form);
+      }
     }
     // need to assign custom data type and subtype to the template
     $form->assign('customDataType', $entityName);
index 4a3bbade67b111a6ff8ab776ef14628576c2490a..40c6a7444805ff55f43b454988d7b5a17ea09df9 100644 (file)
@@ -72,7 +72,22 @@ class CRM_Dedupe_BAO_Rule extends CRM_Dedupe_DAO_Rule {
     // 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})");
-    $using = array($this->rule_field);
+    $entity = CRM_Core_DAO_AllCoreTables::getBriefName(CRM_Core_DAO_AllCoreTables::getClassForTable($this->rule_table));
+    $fields = civicrm_api3($entity, 'getfields', ['action' => 'create'])['values'];
+
+    $innerJoinClauses = [
+      "t1.{$this->rule_field} IS NOT NULL",
+      "t2.{$this->rule_field} IS NOT NULL",
+      "t1.{$this->rule_field} = t2.{$this->rule_field}"
+    ];
+    if ($fields[$this->rule_field]['type'] === CRM_Utils_Type::T_DATE) {
+      $innerJoinClauses[] = "t1.{$this->rule_field} > '1000-01-01'";
+      $innerJoinClauses[] = "t2.{$this->rule_field} > '1000-01-01'";
+    }
+    else {
+      $innerJoinClauses[] = "t1.{$this->rule_field} <> ''";
+      $innerJoinClauses[] = "t2.{$this->rule_field} <> ''";
+    }
 
     switch ($this->rule_table) {
       case 'civicrm_contact':
@@ -92,7 +107,7 @@ class CRM_Dedupe_BAO_Rule extends CRM_Dedupe_DAO_Rule {
       case 'civicrm_address':
         $id = 'contact_id';
         $on[] = 't1.location_type_id = t2.location_type_id';
-        $using[] = 'location_type_id';
+        $innerJoinClauses[] = ['t1.location_type_id = t2.location_type_id'];
         if ($this->params['civicrm_address']['location_type_id']) {
           $locTypeId = CRM_Utils_Type::escape($this->params['civicrm_address']['location_type_id'], 'Integer', FALSE);
           if ($locTypeId) {
@@ -152,7 +167,6 @@ class CRM_Dedupe_BAO_Rule extends CRM_Dedupe_DAO_Rule {
       if ($this->rule_length) {
         $where[] = "SUBSTR(t1.{$this->rule_field}, 1, {$this->rule_length}) = SUBSTR('$str', 1, {$this->rule_length})";
         $where[] = "t1.{$this->rule_field} IS NOT NULL";
-        $where[] = "t1.{$this->rule_field} <> ''";
       }
       else {
         $where[] = "t1.{$this->rule_field} = '$str'";
@@ -163,15 +177,13 @@ class CRM_Dedupe_BAO_Rule extends CRM_Dedupe_DAO_Rule {
         $from = "{$this->rule_table} t1 JOIN {$this->rule_table} t2 ON (" . implode(' AND ', $on) . ")";
       }
       else {
-        $from = "{$this->rule_table} t1 JOIN {$this->rule_table} t2 USING (" . implode(', ', $using) . ")";
+        $from = "{$this->rule_table} t1 INNER JOIN {$this->rule_table} t2 ON (" . implode(' AND ', $innerJoinClauses) . ")";
       }
     }
 
     // finish building WHERE, also limit the results if requested
     if (!$this->params) {
       $where[] = "t1.$id < t2.$id";
-      $where[] = "t1.{$this->rule_field} IS NOT NULL";
-      $where[] = "t1.{$this->rule_field} <> ''";
     }
     $query = "SELECT $select FROM $from WHERE " . implode(' AND ', $where);
     if ($this->contactIds) {
index 03dac72f30819191f522bad166c3a2f1c498ce49..3e824fa3e6a914b536215275459fe12b1a385fa3 100644 (file)
@@ -6,7 +6,7 @@
  *
  * Generated from xml/schema/CRM/Dedupe/Exception.xml
  * DO NOT EDIT.  Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:8be54351020230bbff872ebf033c811b)
+ * (GenCodeChecksum:1f39e9ee1f80da1b62c054f6ca4119c5)
  */
 
 /**
@@ -97,6 +97,7 @@ class CRM_Dedupe_DAO_Exception extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('First Dupe Contact ID'),
           'description' => ts('FK to Contact ID'),
+          'required' => TRUE,
           'table_name' => 'civicrm_dedupe_exception',
           'entity' => 'Exception',
           'bao' => 'CRM_Dedupe_DAO_Exception',
@@ -108,6 +109,7 @@ class CRM_Dedupe_DAO_Exception extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Second Dupe Contact ID'),
           'description' => ts('FK to Contact ID'),
+          'required' => TRUE,
           'table_name' => 'civicrm_dedupe_exception',
           'entity' => 'Exception',
           'bao' => 'CRM_Dedupe_DAO_Exception',
index 8563d3603f8fb638837ae5be1fe35566e2a45eca..1c82527efb695024a44d7c6885fbbd7d65fff88d 100644 (file)
@@ -1433,7 +1433,16 @@ INNER JOIN  civicrm_membership membership2 ON membership1.membership_type_id = m
         }
       }
       if ($name == 'rel_table_memberships') {
-        $elements[] = array('checkbox', "operation[move_{$name}][add]", NULL, ts('add new'));
+        //Enable 'add new' checkbox if main contact does not contain any membership similar to duplicate contact.
+        $attributes = ['checked' => 'checked'];
+        $otherContactMemberships = CRM_Member_BAO_Membership::getAllContactMembership($otherId);
+        foreach ($otherContactMemberships as $membership) {
+          $mainMembership = CRM_Member_BAO_Membership::getContactMembership($mainId, $membership['membership_type_id'], FALSE);
+          if ($mainMembership) {
+            $attributes = [];
+          }
+        }
+        $elements[] = array('checkbox', "operation[move_{$name}][add]", NULL, ts('add new'), $attributes);
         $migrationInfo["operation"]["move_{$name}"]['add'] = 1;
       }
     }
index 68216a7e5f59c6b52ed3bdf95cbab9cd94d50ecc..755847c056adf10f5635ff540c336dd2b4884d40 100644 (file)
@@ -2370,4 +2370,32 @@ LEFT  JOIN  civicrm_price_field_value value ON ( value.id = lineItem.price_field
     return CRM_Core_PseudoConstant::get(__CLASS__, $fieldName, $params, $context);
   }
 
+  /**
+   * @return array
+   */
+  public static function getEntityRefFilters() {
+    return [
+      ['key' => 'event_type_id', 'value' => ts('Event Type')],
+      [
+        'key' => 'start_date',
+        'value' => ts('Start Date'),
+        'options' => [
+          ['key' => '{">":"now"}', 'value' => ts('Upcoming')],
+          [
+            'key' => '{"BETWEEN":["now - 3 month","now"]}',
+            'value' => ts('Past 3 Months'),
+          ],
+          [
+            'key' => '{"BETWEEN":["now - 6 month","now"]}',
+            'value' => ts('Past 6 Months'),
+          ],
+          [
+            'key' => '{"BETWEEN":["now - 1 year","now"]}',
+            'value' => ts('Past Year'),
+          ],
+        ],
+      ],
+    ];
+  }
+
 }
index 0051038aaa3a3f7960d60d5a5a451b89e1b4c87e..f84e6b15ace48fa8bdbcd0d6449a1d200850dbac 100644 (file)
@@ -71,10 +71,10 @@ class CRM_Event_BAO_ParticipantPayment extends CRM_Event_DAO_ParticipantPayment
       $participantPayment->find(TRUE);
     }
     if ($id) {
-      CRM_Utils_Hook::post('edit', 'ParticipantPayment', $id, $participantPayment);
+      CRM_Utils_Hook::post('edit', 'ParticipantPayment', $participantPayment->id, $participantPayment);
     }
     else {
-      CRM_Utils_Hook::post('create', 'ParticipantPayment', NULL, $participantPayment);
+      CRM_Utils_Hook::post('create', 'ParticipantPayment', $participantPayment->id, $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
index 1c5c9a0ecf5abc07cdbc7f453878079311549967..e43e38377cfe8e195aae2765216e65194603144f 100644 (file)
@@ -581,14 +581,14 @@ class CRM_Event_BAO_Query extends CRM_Core_BAO_Query {
     $form->assign('dataURLEventFee', $dataURLEventFee);
 
     $form->addEntityRef('event_id', ts('Event Name'), array(
-        'entity' => 'event',
+        'entity' => 'Event',
         'placeholder' => ts('- any -'),
         'multiple' => 1,
         'select' => array('minimumInputLength' => 0),
       )
     );
     $form->addEntityRef('event_type_id', ts('Event Type'), array(
-        'entity' => 'option_value',
+        'entity' => 'OptionValue',
         'placeholder' => ts('- any -'),
         'select' => array('minimumInputLength' => 0),
         'api' => array(
index cf6eee93c0d67d6d98da28ed2b0809e1e0f5981a..cd4b3e67e610aa72f69ca6f3d102bd37a222a821 100644 (file)
@@ -57,7 +57,7 @@ class CRM_Event_Form_ManageEvent_Conference extends CRM_Event_Form_ManageEvent {
     );
 
     $this->addEntityRef('parent_event_id', ts('Parent Event'), array(
-        'entity' => 'event',
+        'entity' => 'Event',
         'placeholder' => ts('- any -'),
         'select' => array('minimumInputLength' => 0),
       )
index 58d27ed775dcf1ff0d2ade7c985f675318cf7c36..50d853972a9a9f8275ac42b310dc5d7a0cc50cad 100644 (file)
@@ -228,8 +228,8 @@ class CRM_Event_Form_ManageEvent_Location extends CRM_Event_Form_ManageEvent {
       );
     }
 
-    $this->_values['address'] = array();
-    // if 'create new loc' optioin is selected OR selected new loc is different
+    $this->_values['address'] = $this->_values['phone'] = $this->_values['email'] = array();
+    // 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
     if ($this->_oldLocBlockId && $deleteOldBlock) {
index fdb9cacd845afaa6d50c377ba35221856404283b..ee2621e60123ae35b587a2cb452c90f32a92d8a6 100644 (file)
@@ -635,7 +635,7 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment
     }
 
     $eventFieldParams = array(
-      'entity' => 'event',
+      'entity' => 'Event',
       'select' => array('minimumInputLength' => 0),
       'api' => array(
         'extra' => array('campaign_id', 'default_role_id', 'event_type_id'),
index 6018ce14a85142e07da786060d4be0225c26578b..da54819b40cec8294af7543d07e051560f135d8b 100644 (file)
@@ -70,6 +70,11 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration {
    */
   public $_noFees;
 
+  /**
+   * @var array Fee Block
+   */
+  public $_feeBlock;
+
   /**
    * Array of payment related fields to potentially display on this form (generally credit card or debit card fields).
    *
@@ -83,19 +88,18 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration {
    * Get the contact id for the registration.
    *
    * @param array $fields
-   * @param CRM_Core_Form $self
+   * @param CRM_Event_Form_Registration $form
    * @param bool $isAdditional
    *
    * @return int|null
    */
-  public static function getRegistrationContactID($fields, $self, $isAdditional) {
-
+  public static function getRegistrationContactID($fields, $form, $isAdditional) {
     $contactID = NULL;
     if (!$isAdditional) {
-      $contactID = $self->getContactID();
+      $contactID = $form->getContactID();
     }
     if (!$contactID && is_array($fields) && $fields) {
-      $contactID = CRM_Contact_BAO_Contact::getFirstDuplicateContact($fields, 'Individual', 'Unsupervised', array(), FALSE, CRM_Utils_Array::value('dedupe_rule_group_id', $self->_values['event']));
+      $contactID = CRM_Contact_BAO_Contact::getFirstDuplicateContact($fields, 'Individual', 'Unsupervised', array(), FALSE, CRM_Utils_Array::value('dedupe_rule_group_id', $form->_values['event']));
     }
     return $contactID;
   }
@@ -497,7 +501,7 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration {
   /**
    * Build the radio/text form elements for the amount field
    *
-   * @param CRM_Core_Form $form
+   * @param CRM_Event_Form_Registration_Register $form
    *   Form object.
    * @param bool $required
    *   True if you want to add formRule.
@@ -661,7 +665,7 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration {
   }
 
   /**
-   * @param CRM_Core_Form $form
+   * @param CRM_Event_Form_Registration $form
    */
   public static function formatFieldsForOptionFull(&$form) {
     $priceSet = $form->get('priceSet');
@@ -770,40 +774,40 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration {
    *   The input form values.
    * @param array $files
    *   The uploaded files if any.
-   * @param $self
+   * @param CRM_Event_Form_Registration $form
    *
    *
    * @return bool|array
    *   true if no errors, else array of errors
    */
-  public static function formRule($fields, $files, $self) {
+  public static function formRule($fields, $files, $form) {
     $errors = array();
     //check that either an email or firstname+lastname is included in the form(CRM-9587)
-    self::checkProfileComplete($fields, $errors, $self->_eventId);
+    self::checkProfileComplete($fields, $errors, $form->_eventId);
     //To check if the user is already registered for the event(CRM-2426)
-    if (!$self->_skipDupeRegistrationCheck) {
-      self::checkRegistration($fields, $self);
+    if (!$form->_skipDupeRegistrationCheck) {
+      self::checkRegistration($fields, $form);
     }
     //check for availability of registrations.
-    if (!$self->_allowConfirmation && empty($fields['bypass_payment']) &&
-      is_numeric($self->_availableRegistrations) &&
-      CRM_Utils_Array::value('additional_participants', $fields) >= $self->_availableRegistrations
+    if (!$form->_allowConfirmation && empty($fields['bypass_payment']) &&
+      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 => $self->_availableRegistrations));
+      $errors['additional_participants'] = ts("There is only enough space left on this event for %1 participant(s).", array(1 => $form->_availableRegistrations));
     }
 
     // during confirmation don't allow to increase additional participants, CRM-4320
-    if ($self->_allowConfirmation && !empty($fields['additional_participants']) &&
-      is_array($self->_additionalParticipantIds) &&
-      $fields['additional_participants'] > count($self->_additionalParticipantIds)
+    if ($form->_allowConfirmation && !empty($fields['additional_participants']) &&
+      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($self->_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)));
     }
 
     //don't allow to register w/ waiting if enough spaces available.
-    if (!empty($fields['bypass_payment']) && $self->_allowConfirmation) {
-      if (!is_numeric($self->_availableRegistrations) ||
-        (empty($fields['priceSetId']) && CRM_Utils_Array::value('additional_participants', $fields) < $self->_availableRegistrations)
+    if (!empty($fields['bypass_payment']) && $form->_allowConfirmation) {
+      if (!is_numeric($form->_availableRegistrations) ||
+        (empty($fields['priceSetId']) && CRM_Utils_Array::value('additional_participants', $fields) < $form->_availableRegistrations)
       ) {
         $errors['bypass_payment'] = ts("Oops. There are enough available spaces in this event. You can not add yourself to the waiting list.");
       }
@@ -817,13 +821,13 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration {
 
     // priceset validations
     if (!empty($fields['priceSetId']) &&
-     !$self->_requireApproval && !$self->_allowWaitlist
+     !$form->_requireApproval && !$form->_allowWaitlist
      ) {
       //format params.
-      $formatted = self::formatPriceSetParams($self, $fields);
+      $formatted = self::formatPriceSetParams($form, $fields);
       $ppParams = array($formatted);
-      $priceSetErrors = self::validatePriceSet($self, $ppParams);
-      $primaryParticipantCount = self::getParticipantCount($self, $ppParams);
+      $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()));
@@ -834,15 +838,15 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration {
       }
 
       if (empty($fields['bypass_payment']) &&
-        !$self->_allowConfirmation &&
-        is_numeric($self->_availableRegistrations) &&
-        $self->_availableRegistrations < $totalParticipants
+        !$form->_allowConfirmation &&
+        is_numeric($form->_availableRegistrations) &&
+        $form->_availableRegistrations < $totalParticipants
       ) {
-        $errors['_qf_default'] = ts("Only %1 Registrations available.", array(1 => $self->_availableRegistrations));
+        $errors['_qf_default'] = ts("Only %1 Registrations available.", array(1 => $form->_availableRegistrations));
       }
 
       $lineItem = array();
-      CRM_Price_BAO_PriceSet::processAmount($self->_values['fee'], $fields, $lineItem);
+      CRM_Price_BAO_PriceSet::processAmount($form->_values['fee'], $fields, $lineItem);
 
       $minAmt = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_PriceSet', $fields['priceSetId'], 'min_amount');
       if ($fields['amount'] < 0) {
@@ -856,8 +860,8 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration {
     }
 
     // @todo - can we remove the 'is_monetary' concept?
-    if ($self->_values['event']['is_monetary']) {
-      if (empty($self->_requireApproval) && !empty($fields['amount']) && $fields['amount'] > 0 &&
+    if ($form->_values['event']['is_monetary']) {
+      if (empty($form->_requireApproval) && !empty($fields['amount']) && $fields['amount'] > 0 &&
         !isset($fields['payment_processor_id'])) {
         $errors['payment_processor_id'] = ts('Please select a Payment Method');
       }
@@ -869,28 +873,28 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration {
         }
       }
       elseif (!empty($fields['amount']) &&
-        (isset($self->_values['discount'][$fields['amount']])
-          && CRM_Utils_Array::value('value', $self->_values['discount'][$fields['amount']]) == 0
+        (isset($form->_values['discount'][$fields['amount']])
+          && CRM_Utils_Array::value('value', $form->_values['discount'][$fields['amount']]) == 0
         )
       ) {
         $isZeroAmount = TRUE;
       }
       elseif (!empty($fields['amount']) &&
-        (isset($self->_values['fee'][$fields['amount']])
-          && CRM_Utils_Array::value('value', $self->_values['fee'][$fields['amount']]) == 0
+        (isset($form->_values['fee'][$fields['amount']])
+          && CRM_Utils_Array::value('value', $form->_values['fee'][$fields['amount']]) == 0
         )
       ) {
         $isZeroAmount = TRUE;
       }
 
-      if ($isZeroAmount && !($self->_forcePayement && !empty($fields['additional_participants']))) {
+      if ($isZeroAmount && !($form->_forcePayement && !empty($fields['additional_participants']))) {
         $skipPaymentValidation = TRUE;
       }
 
       // also return if zero fees for valid members
       if (!empty($fields['bypass_payment']) ||
         $skipPaymentValidation ||
-        (!$self->_allowConfirmation && ($self->_requireApproval || $self->_allowWaitlist))
+        (!$form->_allowConfirmation && ($form->_requireApproval || $form->_allowWaitlist))
       ) {
         return empty($errors) ? TRUE : $errors;
       }
@@ -898,7 +902,7 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration {
         $fields['payment_processor_id'],
         $fields,
         $errors,
-        (!$self->_isBillingAddressRequiredForPayLater ? NULL : 'billing')
+        (!$form->_isBillingAddressRequiredForPayLater ? NULL : 'billing')
       );
     }
 
@@ -1177,58 +1181,58 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration {
    *
    * @param array $fields
    *   The input form values(anonymous user).
-   * @param CRM_Event_Form_Registration_Register $self
+   * @param CRM_Event_Form_Registration_Register $form
    *   Event data.
    * @param bool $isAdditional
    *   Treat isAdditional participants a bit differently.
    *
    * @return int
    */
-  public static function checkRegistration($fields, &$self, $isAdditional = FALSE) {
+  public static function checkRegistration($fields, $form, $isAdditional = FALSE) {
     // CRM-3907, skip check for preview registrations
     // CRM-4320 participant need to walk wizard
     if (
-      ($self->_mode == 'test' || $self->_allowConfirmation)
+      ($form->_mode == 'test' || $form->_allowConfirmation)
     ) {
       return FALSE;
     }
 
-    $contactID = self::getRegistrationContactID($fields, $self, $isAdditional);
+    $contactID = self::getRegistrationContactID($fields, $form, $isAdditional);
 
     if ($contactID) {
       $participant = new CRM_Event_BAO_Participant();
       $participant->contact_id = $contactID;
-      $participant->event_id = $self->_values['event']['id'];
+      $participant->event_id = $form->_values['event']['id'];
       if (!empty($fields['participant_role']) && is_numeric($fields['participant_role'])) {
         $participant->role_id = $fields['participant_role'];
       }
       else {
-        $participant->role_id = $self->_values['event']['default_role_id'];
+        $participant->role_id = $form->_values['event']['default_role_id'];
       }
       $participant->is_test = 0;
       $participant->find();
       $statusTypes = CRM_Event_PseudoConstant::participantStatus(NULL, 'is_counted = 1');
       while ($participant->fetch()) {
         if (array_key_exists($participant->status_id, $statusTypes)) {
-          if (!$isAdditional && !$self->_values['event']['allow_same_participant_emails']) {
+          if (!$isAdditional && !$form->_values['event']['allow_same_participant_emails']) {
             $registerUrl = CRM_Utils_System::url('civicrm/event/register',
-              "reset=1&id={$self->_values['event']['id']}&cid=0"
+              "reset=1&id={$form->_values['event']['id']}&cid=0"
             );
-            if ($self->_pcpId) {
-              $registerUrl .= '&pcpId=' . $self->_pcpId;
+            if ($form->_pcpId) {
+              $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 <a href="%1">register another participant</a>.', array(1 => $registerUrl));
             CRM_Core_Session::singleton()->setStatus($status, ts('Oops.'), 'alert');
             $url = CRM_Utils_System::url('civicrm/event/info',
-              "reset=1&id={$self->_values['event']['id']}&noFullMsg=true"
+              "reset=1&id={$form->_values['event']['id']}&noFullMsg=true"
             );
-            if ($self->_action & CRM_Core_Action::PREVIEW) {
+            if ($form->_action & CRM_Core_Action::PREVIEW) {
               $url .= '&action=preview';
             }
 
-            if ($self->_pcpId) {
-              $url .= '&pcpId=' . $self->_pcpId;
+            if ($form->_pcpId) {
+              $url .= '&pcpId=' . $form->_pcpId;
             }
 
             CRM_Utils_System::redirect($url);
index 5b28568a91add3102fa86094eb24e0317c58e13f..0f13d9eb8d8b415dab9fa0e1e92b03d6d2bb26f7 100644 (file)
@@ -88,7 +88,6 @@ class CRM_Event_Form_Search extends CRM_Core_Form_Search {
     $this->_actionButtonName = $this->getButtonName('next', 'action');
 
     $this->_done = FALSE;
-    $this->defaults = array();
 
     $this->loadStandardSearchOptionsFromUrl();
     $this->loadFormValues();
index 5a71846be4ff52c4b5ee4daf22e9fa2ef8ff3754..cbe2da518284efc786298df7beda85cd02274844 100644 (file)
@@ -530,7 +530,7 @@ class CRM_Event_Selector_Search extends CRM_Core_Selector_Base implements CRM_Co
    * @return mixed
    */
   public function alphabetQuery() {
-    return $this->_query->searchQuery(NULL, NULL, NULL, FALSE, FALSE, TRUE);
+    return $this->_query->alphabetQuery();
   }
 
   /**
index 5ef3763257e7938fb808a6738bdd5dfd5932e3b8..44d8e7ee75e5de650135519adb1a96ae5e8aab86 100644 (file)
@@ -652,14 +652,12 @@ VALUES $sqlValueString
    */
   public static function createTempTable($sqlColumns) {
     //creating a temporary table for the search result that need be exported
-    $exportTempTable = CRM_Utils_SQL_TempTable::build()->setDurable()->setCategory('export')->getName();
+    $exportTempTable = CRM_Utils_SQL_TempTable::build()->setDurable()->setCategory('export')->setUtf8();
 
     // also create the sql table
-    $sql = "DROP TABLE IF EXISTS {$exportTempTable}";
-    CRM_Core_DAO::executeQuery($sql);
+    $exportTempTable->drop();
 
     $sql = "
-CREATE TABLE {$exportTempTable} (
      id int unsigned NOT NULL AUTO_INCREMENT,
 ";
     $sql .= implode(",\n", array_values($sqlColumns));
@@ -682,12 +680,8 @@ CREATE TABLE {$exportTempTable} (
       }
     }
 
-    $sql .= "
-) ENGINE=InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci
-";
-
-    CRM_Core_DAO::executeQuery($sql);
-    return $exportTempTable;
+    $exportTempTable->createWithColumns($sql);
+    return $exportTempTable->getName();
   }
 
   /**
index ae05788a40a5284bc3eee8fc74a1a522ee1a9763..774fddcef3bfd516688e9192efa28f525ec3f6fa 100644 (file)
@@ -251,7 +251,7 @@ abstract class CRM_Financial_BAO_ExportFormat {
     }
     if (count($validFiles)) {
       $zip = new ZipArchive();
-      if ($zip->open($destination, $overwrite ? ZIPARCHIVE::OVERWRITE : ZIPARCHIVE::CREATE) !== TRUE) {
+      if ($zip->open($destination, $overwrite ? ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE : ZIPARCHIVE::CREATE) !== TRUE) {
         return FALSE;
       }
       foreach ($validFiles as $file) {
index 1b81f316fcbee1160371a073a9fe4c6b754594c3..445475e29585749cb4e6e1150513920a9bf68ffd 100644 (file)
@@ -360,27 +360,9 @@ class CRM_Financial_BAO_FinancialType extends CRM_Financial_DAO_FinancialType {
    * @param array $whereClauses
    */
   public static function addACLClausesToWhereClauses(&$whereClauses) {
-    $originalWhereClauses = $whereClauses;
-    CRM_Utils_Hook::selectWhereClause('Contribution', $whereClauses);
-    if ($whereClauses !== $originalWhereClauses) {
-      // In this case permisssions have been applied & we assume the
-      // financialaclreport is applying these
-      // https://github.com/JMAConsulting/biz.jmaconsulting.financialaclreport/blob/master/financialaclreport.php#L107
-      return;
-    }
+    $contributionBAO = new CRM_Contribute_BAO_Contribution();
+    $whereClauses = array_merge($whereClauses, $contributionBAO->addSelectWhereClause());
 
-    if (!self::isACLFinancialTypeStatus()) {
-      return;
-    }
-    $types = self::getAllEnabledAvailableFinancialTypes();
-    if (empty($types)) {
-      $whereClauses['financial_type_id'] = 'IN (0)';
-    }
-    else {
-      $whereClauses['financial_type_id'] = [
-        'IN (' . implode(',', array_keys($types)) . ')'
-      ];
-    }
   }
 
   /**
@@ -395,6 +377,7 @@ class CRM_Financial_BAO_FinancialType extends CRM_Financial_DAO_FinancialType {
    *
    */
   public static function buildPermissionedClause(&$whereClauses, $component = NULL, $alias = NULL) {
+    // @todo the relevant addSelectWhere clause should be called.
     if (!self::isACLFinancialTypeStatus()) {
       return FALSE;
     }
index 656f2a03e4dd1f0561479d974d7f78874f0f8cdc..a5d4ea4de340c9a29ea1cf98d9a616cb05d9338c 100644 (file)
@@ -79,7 +79,14 @@ class CRM_Financial_BAO_Payment {
       }
     }
     if (!$fullyPaidPayLater) {
-      $trxn = CRM_Core_BAO_FinancialTrxn::getPartialPaymentTrxn($contribution, $params);
+      $trxn = CRM_Contribute_BAO_Contribution::recordPartialPayment($contribution, $params);
+      $paid = CRM_Core_BAO_FinancialTrxn::getTotalPayments($params['contribution_id']);
+      $total = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $params['contribution_id'], 'total_amount');
+      $cmp = bccomp($total, $paid, 5);
+      if ($cmp == 0 || $cmp == -1) {// If paid amount is greater or equal to total amount
+        civicrm_api3('Contribution', 'completetransaction', array('id' => $contribution['id']));
+      }
+
       if (CRM_Utils_Array::value('line_item', $params) && !empty($trxn)) {
         foreach ($params['line_item'] as $values) {
           foreach ($values as $id => $amount) {
@@ -117,4 +124,370 @@ class CRM_Financial_BAO_Payment {
     return $trxn;
   }
 
+  /**
+   * Send an email confirming a payment that has been received.
+   *
+   * @param array $params
+   *
+   * @return array
+   */
+  public static function sendConfirmation($params) {
+
+    $entities = self::loadRelatedEntities($params['id']);
+    $sendTemplateParams = array(
+      'groupName' => 'msg_tpl_workflow_contribution',
+      'valueName' => 'payment_or_refund_notification',
+      'PDFFilename' => ts('notification') . '.pdf',
+      'contactId' => $entities['contact']['id'],
+      'toName' => $entities['contact']['display_name'],
+      'toEmail' => $entities['contact']['email'],
+      'tplParams' => self::getConfirmationTemplateParameters($entities),
+    );
+    return CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams);
+  }
+
+  /**
+   * Load entities related to the current payment id.
+   *
+   * This gives us all the data we need to send an email confirmation but avoiding
+   * getting anything not tested for the confirmations. We retrieve the 'full' event as
+   * it has been traditionally assigned in full.
+   *
+   * @param int $id
+   *
+   * @return array
+   *   - contact = ['id' => x, 'display_name' => y, 'email' => z]
+   *   - event = [.... full event details......]
+   *   - contribution = ['id' => x],
+   *   - payment = [payment info + payment summary info]
+   */
+  protected static function loadRelatedEntities($id) {
+    $entities = [];
+    $contributionID = (int) civicrm_api3('EntityFinancialTrxn', 'getvalue', [
+      'financial_trxn_id' => $id,
+      'entity_table' => 'civicrm_contribution',
+      'return' => 'entity_id',
+    ]);
+    $entities['contribution'] = ['id' => $contributionID];
+    $entities['payment'] = array_merge(civicrm_api3('FinancialTrxn', 'getsingle', ['id' => $id]),
+      CRM_Contribute_BAO_Contribution::getPaymentInfo($contributionID)
+    );
+
+    $contactID = self::getPaymentContactID($contributionID);
+    list($displayName, $email)  = CRM_Contact_BAO_Contact_Location::getEmailDetails($contactID);
+    $entities['contact'] = ['id' => $contactID, 'display_name' => $displayName, 'email' => $email];
+    $contact = civicrm_api3('Contact', 'getsingle', ['id' => $contactID, 'return' => 'email_greeting']);
+    $entities['contact']['email_greeting'] = $contact['email_greeting_display'];
+
+    $participantRecords = civicrm_api3('ParticipantPayment', 'get', [
+      'contribution_id' => $contributionID,
+      'api.Participant.get' => ['return' => 'event_id'],
+      'sequential' => 1,
+    ])['values'];
+    if (!empty($participantRecords)) {
+      $entities['event'] = civicrm_api3('Event', 'getsingle', ['id' => $participantRecords[0]['api.Participant.get']['values'][0]['event_id']]);
+      if (!empty($entities['event']['is_show_location'])) {
+        $locationParams = [
+          'entity_id' => $entities['event']['id'],
+          'entity_table' => 'civicrm_event',
+        ];
+        $entities['location'] = CRM_Core_BAO_Location::getValues($locationParams, TRUE);
+      }
+    }
+
+    return $entities;
+  }
+
+  /**
+   * @param int $contributionID
+   *
+   * @return int
+   */
+  public static function getPaymentContactID($contributionID) {
+    $contribution = civicrm_api3('Contribution', 'getsingle', [
+      'id' => $contributionID ,
+      'return' => ['contact_id'],
+    ]);
+    return (int) $contribution['contact_id'];
+  }
+  /**
+   * @param array $entities
+   *   Related entities as an array keyed by the various entities.
+   *
+   * @return array
+   *   Values required for the notification
+   *   - contact_id
+   *   - template_variables
+   *     - event (DAO of event if relevant)
+   */
+  public static function getConfirmationTemplateParameters($entities) {
+    $templateVariables = [
+      'contactDisplayName' => $entities['contact']['display_name'],
+      'emailGreeting' => $entities['contact']['email_greeting'],
+      'totalAmount' => $entities['payment']['total'],
+      'amountOwed' => $entities['payment']['balance'],
+      'totalPaid' => $entities['payment']['paid'],
+      'paymentAmount' => $entities['payment']['total_amount'],
+      'checkNumber' => CRM_Utils_Array::value('check_number', $entities['payment']),
+      'receive_date' => $entities['payment']['trxn_date'],
+      'paidBy' => CRM_Core_PseudoConstant::getLabel('CRM_Core_BAO_FinancialTrxn', 'payment_instrument_id', $entities['payment']['payment_instrument_id']),
+      'isShowLocation' => (!empty($entities['event']) ? $entities['event']['is_show_location'] : FALSE),
+      'location' => CRM_Utils_Array::value('location', $entities),
+      'event' => CRM_Utils_Array::value('event', $entities),
+      'component' => (!empty($entities['event']) ? 'event' : 'contribution'),
+      'isRefund' => $entities['payment']['total_amount'] < 0,
+      'isAmountzero' => $entities['payment']['total_amount'] === 0,
+      'refundAmount' => ($entities['payment']['total_amount'] < 0 ? $entities['payment']['total_amount'] : NULL),
+      'paymentsComplete' => ($entities['payment']['balance'] == 0),
+    ];
+
+    return self::filterUntestedTemplateVariables($templateVariables);
+  }
+
+  /**
+   * Filter out any untested variables.
+   *
+   * This just serves to highlight if any variables are added without a unit test also being added.
+   *
+   * (if hit then add a unit test for the param & add to this array).
+   *
+   * @param array $params
+   *
+   * @return array
+   */
+  public static function filterUntestedTemplateVariables($params) {
+    $testedTemplateVariables = [
+      'contactDisplayName',
+      'totalAmount',
+      'amountOwed',
+      'paymentAmount',
+      'event',
+      'component',
+      'checkNumber',
+      'receive_date',
+      'paidBy',
+      'isShowLocation',
+      'location',
+      'isRefund',
+      'isAmountzero',
+      'refundAmount',
+      'totalPaid',
+      'paymentsComplete',
+      'emailGreeting'
+    ];
+    // These are assigned by the payment form - they still 'get through' from the
+    // form for now without being in here but we should ideally load
+    // and assign. Note we should update the tpl to use {if $billingName}
+    // and ditch contributeMode - although it might need to be deprecated rather than removed.
+    $todoParams = [
+      'contributeMode',
+      'billingName',
+      'address',
+      'credit_card_type',
+      'credit_card_number',
+      'credit_card_exp_date',
+    ];
+    $filteredParams = [];
+    foreach ($testedTemplateVariables as $templateVariable) {
+      // This will cause an a-notice if any are NOT set - by design. Ensuring
+      // they are set prevents leakage.
+      $filteredParams[$templateVariable] = $params[$templateVariable];
+    }
+    return $filteredParams;
+  }
+
+  /**
+   * @param $contributionId
+   * @param $trxnData
+   * @param $updateStatus
+   *   - deprecate this param
+   *
+   * @todo  - make this protected once recordAdditionalPayment no longer calls it.
+   *
+   * @return CRM_Financial_DAO_FinancialTrxn
+   */
+  public static function recordRefundPayment($contributionId, $trxnData, $updateStatus) {
+    list($contributionDAO, $params) = self::getContributionAndParamsInFormatForRecordFinancialTransaction($contributionId);
+
+    $params['payment_instrument_id'] = CRM_Utils_Array::value('payment_instrument_id', $trxnData, CRM_Utils_Array::value('payment_instrument_id', $params));
+
+    $paidStatus = CRM_Core_PseudoConstant::getKey('CRM_Financial_DAO_FinancialItem', 'status_id', 'Paid');
+    $arAccountId = CRM_Contribute_PseudoConstant::getRelationalFinancialAccount($contributionDAO->financial_type_id, 'Accounts Receivable Account is');
+    $completedStatusId = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Completed');
+
+    $trxnData['total_amount'] = $trxnData['net_amount'] = -$trxnData['total_amount'];
+    $trxnData['from_financial_account_id'] = $arAccountId;
+    $trxnData['status_id'] = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Refunded');
+    // record the entry
+    $financialTrxn = CRM_Contribute_BAO_Contribution::recordFinancialAccounts($params, $trxnData);
+
+    // note : not using the self::add method,
+    // the reason because it performs 'status change' related code execution for financial records
+    // which in 'Pending Refund' => 'Completed' is not useful, instead specific financial record updates
+    // are coded below i.e. just updating financial_item status to 'Paid'
+    if ($updateStatus) {
+      CRM_Core_DAO::setFieldValue('CRM_Contribute_BAO_Contribution', $contributionId, 'contribution_status_id', $completedStatusId);
+    }
+    // add financial item entry
+    $lineItems = CRM_Price_BAO_LineItem::getLineItemsByContributionID($contributionDAO->id);
+    if (!empty($lineItems)) {
+      foreach ($lineItems as $lineItemId => $lineItemValue) {
+        // don't record financial item for cancelled line-item
+        if ($lineItemValue['qty'] == 0) {
+          continue;
+        }
+        $paid = $lineItemValue['line_total'] * ($financialTrxn->total_amount / $contributionDAO->total_amount);
+        $addFinancialEntry = [
+          'transaction_date' => $financialTrxn->trxn_date,
+          'contact_id' => $contributionDAO->contact_id,
+          'amount' => round($paid, 2),
+          'currency' => $contributionDAO->currency,
+          'status_id' => $paidStatus,
+          'entity_id' => $lineItemId,
+          'entity_table' => 'civicrm_line_item',
+        ];
+        $trxnIds = ['id' => $financialTrxn->id];
+        CRM_Financial_BAO_FinancialItem::create($addFinancialEntry, NULL, $trxnIds);
+      }
+    }
+    return $financialTrxn;
+  }
+
+  /**
+   * @param int $contributionId
+   * @param array $trxnData
+   * @param int $participantId
+   *
+   * @return \CRM_Core_BAO_FinancialTrxn
+   */
+  public static function recordPayment($contributionId, $trxnData, $participantId) {
+    list($contributionDAO, $params) = self::getContributionAndParamsInFormatForRecordFinancialTransaction($contributionId);
+    // load related memberships on basis of $contributionDAO object
+    // @todo - this is done in the function that completes payments so it's being done twice.
+    // test & remove.
+    $contributionDAO->loadRelatedMembershipObjects();
+
+    if (!$participantId) {
+      $participantId = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_ParticipantPayment', $contributionId, 'participant_id', 'contribution_id');
+    }
+
+    $trxnData['trxn_date'] = !empty($trxnData['trxn_date']) ? $trxnData['trxn_date'] : date('YmdHis');
+    $params['payment_instrument_id'] = CRM_Utils_Array::value('payment_instrument_id', $trxnData, CRM_Utils_Array::value('payment_instrument_id', $params));
+
+    $paidStatus = CRM_Core_PseudoConstant::getKey('CRM_Financial_DAO_FinancialItem', 'status_id', 'Paid');
+    $arAccountId = CRM_Contribute_PseudoConstant::getRelationalFinancialAccount($contributionDAO->financial_type_id, 'Accounts Receivable Account is');
+    $completedStatusId = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Completed');
+
+    $params['partial_payment_total'] = $contributionDAO->total_amount;
+    $params['partial_amount_to_pay'] = $trxnData['total_amount'];
+    $trxnData['net_amount'] = !empty($trxnData['net_amount']) ? $trxnData['net_amount'] : $trxnData['total_amount'];
+    $params['pan_truncation'] = CRM_Utils_Array::value('pan_truncation', $trxnData);
+    $params['card_type_id'] = CRM_Utils_Array::value('card_type_id', $trxnData);
+    $params['check_number'] = CRM_Utils_Array::value('check_number', $trxnData);
+
+    // record the entry
+    $financialTrxn = CRM_Contribute_BAO_Contribution::recordFinancialAccounts($params, $trxnData);
+    $toFinancialAccount = $arAccountId;
+    $trxnId = CRM_Core_BAO_FinancialTrxn::getBalanceTrxnAmt($contributionId, $contributionDAO->financial_type_id);
+    if (!empty($trxnId)) {
+      $trxnId = $trxnId['trxn_id'];
+    }
+    elseif (!empty($contributionDAO->payment_instrument_id)) {
+      $trxnId = CRM_Financial_BAO_FinancialTypeAccount::getInstrumentFinancialAccount($contributionDAO->payment_instrument_id);
+    }
+    else {
+      $relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('financial_account_type', NULL, " AND v.name LIKE 'Asset' "));
+      $queryParams = [1 => [$relationTypeId, 'Integer']];
+      $trxnId = CRM_Core_DAO::singleValueQuery("SELECT id FROM civicrm_financial_account WHERE is_default = 1 AND financial_account_type_id = %1", $queryParams);
+    }
+
+    // update statuses
+    // criteria for updates contribution total_amount == financial_trxns of partial_payments
+    $sql = "SELECT SUM(ft.total_amount) as sum_of_payments, SUM(ft.net_amount) as net_amount_total
+FROM civicrm_financial_trxn ft
+LEFT JOIN civicrm_entity_financial_trxn eft
+  ON (ft.id = eft.financial_trxn_id)
+WHERE eft.entity_table = 'civicrm_contribution'
+  AND eft.entity_id = {$contributionId}
+  AND ft.to_financial_account_id != {$toFinancialAccount}
+  AND ft.status_id = {$completedStatusId}
+";
+    $query = CRM_Core_DAO::executeQuery($sql);
+    $query->fetch();
+    $sumOfPayments = $query->sum_of_payments;
+
+    // update statuses
+    if ($contributionDAO->total_amount == $sumOfPayments) {
+      // update contribution status and
+      // clean cancel info (if any) if prev. contribution was updated in case of 'Refunded' => 'Completed'
+      $contributionDAO->contribution_status_id = $completedStatusId;
+      $contributionDAO->cancel_date = 'null';
+      $contributionDAO->cancel_reason = NULL;
+      $netAmount = !empty($trxnData['net_amount']) ? NULL : $trxnData['total_amount'];
+      $contributionDAO->net_amount = $query->net_amount_total + $netAmount;
+      $contributionDAO->fee_amount = $contributionDAO->total_amount - $contributionDAO->net_amount;
+      $contributionDAO->save();
+
+      //Change status of financial record too
+      $financialTrxn->status_id = $completedStatusId;
+      $financialTrxn->save();
+
+      // note : not using the self::add method,
+      // the reason because it performs 'status change' related code execution for financial records
+      // which in 'Partial Paid' => 'Completed' is not useful, instead specific financial record updates
+      // are coded below i.e. just updating financial_item status to 'Paid'
+
+      if ($participantId) {
+        // update participant status
+        $participantStatuses = CRM_Event_PseudoConstant::participantStatus();
+        $ids = CRM_Event_BAO_Participant::getParticipantIds($contributionId);
+        foreach ($ids as $val) {
+          $participantUpdate['id'] = $val;
+          $participantUpdate['status_id'] = array_search('Registered', $participantStatuses);
+          CRM_Event_BAO_Participant::add($participantUpdate);
+        }
+      }
+
+      // Remove this - completeOrder does it.
+      CRM_Contribute_BAO_Contribution::updateMembershipBasedOnCompletionOfContribution(
+        $contributionDAO,
+        $contributionId,
+        $trxnData['trxn_date']
+      );
+
+      // update financial item statuses
+      $baseTrxnId = CRM_Core_BAO_FinancialTrxn::getFinancialTrxnId($contributionId);
+      $sqlFinancialItemUpdate = "
+UPDATE civicrm_financial_item fi
+  LEFT JOIN civicrm_entity_financial_trxn eft
+    ON (eft.entity_id = fi.id AND eft.entity_table = 'civicrm_financial_item')
+SET status_id = {$paidStatus}
+WHERE eft.financial_trxn_id IN ({$trxnId}, {$baseTrxnId['financialTrxnId']})
+";
+      CRM_Core_DAO::executeQuery($sqlFinancialItemUpdate);
+    }
+    return $financialTrxn;
+  }
+
+  /**
+   * The recordFinancialTransactions function has capricious requirements for input parameters - load them.
+   *
+   * The function needs rework but for now we need to give it what it wants.
+   *
+   * @param int $contributionId
+   *
+   * @return array
+   */
+  protected static function getContributionAndParamsInFormatForRecordFinancialTransaction($contributionId) {
+    $getInfoOf['id'] = $contributionId;
+    $defaults = [];
+    $contributionDAO = CRM_Contribute_BAO_Contribution::retrieve($getInfoOf, $defaults, CRM_Core_DAO::$_nullArray);
+
+    // build params for recording financial trxn entry
+    $params['contribution'] = $contributionDAO;
+    $params = array_merge($defaults, $params);
+    $params['skipLineItem'] = TRUE;
+    return [$contributionDAO, $params];
+  }
+
 }
index 2f52f3e3b6f9e584c3ea02d3d8bfdf9f49cbe218..5981f0d2134f380c3db1d8b7593117d5be5815be 100644 (file)
@@ -89,7 +89,6 @@ class CRM_Grant_Form_Search extends CRM_Core_Form_Search {
     $this->_actionButtonName = $this->getButtonName('next', 'action');
 
     $this->_done = FALSE;
-    $this->defaults = array();
 
     $this->loadStandardSearchOptionsFromUrl();
     $this->loadFormValues();
index daf6df9a050b0f4e2a1fb472cd5372e91c71b3ec..c540c93fbf94ab71220f488d00b3bf14ef2c2d0f 100644 (file)
@@ -363,12 +363,22 @@ AND    (TABLE_NAME LIKE 'log_civicrm_%' $nonStandardTableNameString )
    * @return array
    */
   public function getIndexesForTable($table) {
-    return CRM_Core_DAO::executeQuery("
-      SELECT constraint_name
-      FROM information_schema.key_column_usage
-      WHERE table_schema = %2 AND table_name = %1",
+    $indexes = [];
+    $result = CRM_Core_DAO::executeQuery("
+        SELECT constraint_name AS index_name
+        FROM information_schema.key_column_usage
+        WHERE table_schema = %2 AND table_name = %1
+      UNION
+        SELECT index_name AS index_name
+        FROM information_schema.statistics
+        WHERE table_schema = %2 AND table_name = %1
+      ",
       array(1 => array($table, 'String'), 2 => array($this->db, 'String'))
-    )->fetchAll();
+    );
+    while ($result->fetch()) {
+      $indexes[] = $result->index_name;
+    }
+    return $indexes;
   }
 
   /**
@@ -597,9 +607,20 @@ WHERE  table_schema IN ('{$this->db}', '{$civiDB}')";
           'EXTRA' => $dao->EXTRA,
         );
         if (($first = strpos($dao->COLUMN_TYPE, '(')) != 0) {
-          \Civi::$statics[__CLASS__]['columnSpecs'][$dao->TABLE_NAME][$dao->COLUMN_NAME]['LENGTH'] = substr(
-            $dao->COLUMN_TYPE, $first, strpos($dao->COLUMN_TYPE, ')')
+          // this extracts the value between parentheses after the column type.
+          // it could be the column length, i.e. "int(8)", "decimal(20,2)")
+          // or the permitted values of an enum (e.g. "enum('A','B')")
+          $parValue = substr(
+            $dao->COLUMN_TYPE, $first + 1, strpos($dao->COLUMN_TYPE, ')') - $first - 1
           );
+          if (strpos($parValue, "'") === FALSE) {
+            // no quote in value means column length
+            \Civi::$statics[__CLASS__]['columnSpecs'][$dao->TABLE_NAME][$dao->COLUMN_NAME]['LENGTH'] = $parValue;
+          }
+          else {
+            // single quote means enum permitted values
+            \Civi::$statics[__CLASS__]['columnSpecs'][$dao->TABLE_NAME][$dao->COLUMN_NAME]['ENUM_VALUES'] = $parValue;
+          }
         }
       }
     }
@@ -639,6 +660,12 @@ WHERE  table_schema IN ('{$this->db}', '{$civiDB}')";
             // if data-type is different, surely consider the column
             $diff['MODIFY'][] = $col;
           }
+          elseif ($civiTableSpecs[$col]['DATA_TYPE'] == 'enum' &&
+            CRM_Utils_Array::value('ENUM_VALUES', $civiTableSpecs[$col]) != CRM_Utils_Array::value('ENUM_VALUES', $logTableSpecs[$col])
+          ) {
+            // column is enum and the permitted values have changed
+            $diff['MODIFY'][] = $col;
+          }
           elseif ($civiTableSpecs[$col]['IS_NULLABLE'] != CRM_Utils_Array::value('IS_NULLABLE', $logTableSpecs[$col]) &&
             $logTableSpecs[$col]['IS_NULLABLE'] == 'NO'
           ) {
@@ -858,7 +885,11 @@ COLS;
       foreach ($columns as $column) {
         $tableExceptions = array_key_exists('exceptions', $this->logTableSpec[$table]) ? $this->logTableSpec[$table]['exceptions'] : array();
         // ignore modified_date changes
-        if ($column != 'modified_date' && !in_array($column, $tableExceptions)) {
+        $tableExceptions[] = 'modified_date';
+        // exceptions may be provided with or without backticks
+        $excludeColumn = in_array($column, $tableExceptions) ||
+          in_array(str_replace('`', '', $column), $tableExceptions);
+        if (!$excludeColumn) {
           $cond[] = "IFNULL(OLD.$column,'') <> IFNULL(NEW.$column,'')";
         }
       }
index 31f2bae2c39f3d112768146eaccfa5aadea73bb2..3bfc007104065f9a40d99ddc0094280e64bd0701 100644 (file)
@@ -119,6 +119,7 @@ class CRM_Mailing_Event_BAO_Reply extends CRM_Mailing_Event_DAO_Reply {
     $contacts = CRM_Contact_BAO_Contact::getTableName();
     $domain_id = CRM_Core_Config::domainID();
     $domainValues = civicrm_api3('Domain', 'get', array('sequential' => 1, 'id' => $domain_id));
+    $fromEmail = CRM_Core_BAO_Domain::getNoReplyEmailAddress();
 
     $eq = new CRM_Core_DAO();
     $eq->query("SELECT     $contacts.display_name as display_name,
@@ -145,10 +146,16 @@ class CRM_Mailing_Event_BAO_Reply extends CRM_Mailing_Event_DAO_Reply {
       // to the forward goes to the sender of the reply
       $parsed->setHeader('Reply-To', $replyto instanceof ezcMailAddress ? $replyto : $parsed->from->__toString());
 
+      // Using the original from address may not be permitted by the mailer.
+      $fromName = empty($parsed->from->name) ? $parsed->from->email : "{$parsed->from->name} ({$parsed->from->email})";
+      $parsed->from = new ezcMailAddress($fromEmail, $fromName);
+
       // CRM-17754 Include re-sent headers to indicate that we have forwarded on the email
       $domainEmail = $domainValues['values'][0]['from_email'];
       $parsed->setHeader('Resent-From', $domainEmail);
       $parsed->setHeader('Resent-Date', date('r'));
+      // Rewrite any invalid Return-Path headers.
+      $parsed->setHeader('Return-Path', $fromEmail);
 
       // $h must be an array, so we can't use generateHeaders()'s result,
       // but we have to regenerate the headers because we changed To
@@ -156,11 +163,6 @@ class CRM_Mailing_Event_BAO_Reply extends CRM_Mailing_Event_DAO_Reply {
       $h = $parsed->headers->getCaseSensitiveArray();
       $b = $parsed->generateBody();
 
-      // strip Return-Path of possible bounding brackets, CRM-4502
-      if (!empty($h['Return-Path'])) {
-        $h['Return-Path'] = trim($h['Return-Path'], '<>');
-      }
-
       // FIXME: ugly hack - find the first MIME boundary in
       // the body and make the boundary in the header match it
       $ct = $h['Content-Type'];
@@ -173,19 +175,14 @@ class CRM_Mailing_Event_BAO_Reply extends CRM_Mailing_Event_DAO_Reply {
       }
     }
     else {
-      if (empty($eq->display_name)) {
-        $from = $eq->email;
-      }
-      else {
-        $from = "\"{$eq->display_name}\" <{$eq->email}>";
-      }
+      $fromName = empty($eq->display_name) ? $eq->email : "{$eq->display_name} ({$eq->email})";
 
       $message = new Mail_mime("\n");
 
       $headers = array(
         'Subject' => "Re: {$mailing->subject}",
         'To' => $mailing->replyto_email,
-        'From' => $from,
+        'From' => "\"$fromName\" <$fromEmail>",
         'Reply-To' => empty($replyto) ? $eq->email : $replyto,
         'Return-Path' => CRM_Core_BAO_Domain::getNoReplyEmailAddress(),
         // CRM-17754 Include re-sent headers to indicate that we have forwarded on the email
index 5621f891916cea712f4e052de98bb01ecb14da55..51f41f469d2be30fe006d0378c3ac4b7c74ea15e 100644 (file)
@@ -389,7 +389,7 @@ class CRM_Mailing_Selector_Search extends CRM_Core_Selector_Base implements CRM_
    * @return mixed
    */
   public function alphabetQuery() {
-    return $this->_query->searchQuery(NULL, NULL, NULL, FALSE, FALSE, TRUE);
+    return $this->_query->alphabetQuery();
   }
 
   /**
index 00548c146e80cb0574c2eccd32c18bf0e429c93e..cbc07cf2b641cbd3de5d1ba6675fc8eb6cd78bfe 100644 (file)
@@ -94,7 +94,6 @@ class CRM_Member_BAO_Membership extends CRM_Member_DAO_Membership {
     $membership->id = $id;
 
     $membership->save();
-    $membership->free();
 
     if (empty($membership->contact_id) || empty($membership->status_id)) {
       // this means we are in renewal mode and are just updating the membership
@@ -545,8 +544,6 @@ class CRM_Member_BAO_Membership extends CRM_Member_DAO_Membership {
         $defaults['active'] = TRUE;
       }
 
-      $membership->free();
-
       return $membership;
     }
 
@@ -702,7 +699,6 @@ INNER JOIN  civicrm_membership_type type ON ( type.id = membership.membership_ty
       self::deleteRelatedMemberships($membership->id);
       self::deleteMembership($membership->id);
     }
-    $membership->free();
   }
 
   /**
@@ -1184,7 +1180,6 @@ AND civicrm_membership.is_test = %2";
       $memberDAO->end_date = CRM_Utils_Date::isoToMysql($memberDAO->end_date);
       $memberDAO->save();
       CRM_Core_DAO::storeValues($memberDAO, $currentMembership);
-      $memberDAO->free();
 
       $currentMembership['is_current_member'] = CRM_Core_DAO::getFieldValue(
         'CRM_Member_DAO_MembershipStatus',
@@ -1277,10 +1272,8 @@ SELECT c.contribution_page_id as pageID
       $relatedMembership->id = $membership->id;
       $relatedMembership->copyValues($params);
       $relatedMembership->save();
-      $relatedMembership->free();
     }
 
-    $membership->free();
   }
 
   /**
@@ -1407,7 +1400,6 @@ WHERE  civicrm_membership.contact_id = civicrm_contact.id
           $nestedRelMembership->id = $membership->owner_membership_id;
           $nestedRelMembership->contact_id = $cid;
           $nestedRelationship = $nestedRelMembership->find(TRUE);
-          $nestedRelMembership->free();
         }
         if (!$nestedRelationship) {
           $relatedContacts[$cid] = $status;
@@ -1610,7 +1602,6 @@ FROM   civicrm_membership_type
         $membershipTypeValues[$dao->id][$mtField] = $dao->$mtField;
       }
     }
-    $dao->free();
 
     CRM_Utils_Hook::membershipTypeValues($form, $membershipTypeValues);
 
@@ -2168,7 +2159,6 @@ INNER JOIN  civicrm_contact contact ON ( contact.id = membership.contact_id AND
       ]);
       $count++;
     }
-    $deceasedDAO->free();
     return $count;
   }
 
@@ -2279,7 +2269,6 @@ WHERE      civicrm_membership.is_test = 0
     while ($dao1->fetch()) {
       self::processOverriddenUntilDateMembership($dao1);
     }
-    $dao1->free();
 
     $query = $baseQuery . " AND civicrm_membership.is_override IS NULL
      AND civicrm_membership.status_id NOT IN (%1, %2, %3, %4)
@@ -2351,7 +2340,6 @@ WHERE      civicrm_membership.is_test = 0
         $updateCount++;
       }
     }
-    $dao2->free();
     $result['is_error'] = 0;
     $result['messages'] = ts('Processed %1 membership records. Updated %2 records.', array(
       1 => $processCount,
index 686183c10b9fd4d1477ed50138e2284e45abaaff..37544276768b634fc978ca7225f2d631a114a057 100644 (file)
@@ -46,7 +46,6 @@ class CRM_Member_BAO_MembershipLog extends CRM_Member_DAO_MembershipLog {
     $membershipLog = new CRM_Member_DAO_MembershipLog();
     $membershipLog->copyValues($params);
     $membershipLog->save();
-    $membershipLog->free();
 
     return $membershipLog;
   }
index 30e00ec715692a4bf84365bf706b99a44ddf2bcb..0f7f8ae4197068520b9e722945925e56c940f27e 100644 (file)
@@ -212,7 +212,6 @@ class CRM_Member_BAO_MembershipStatus extends CRM_Member_DAO_MembershipStatus {
     }
     $membershipStatus->delete();
     CRM_Member_PseudoConstant::flush('membershipStatus');
-    $membershipStatus->free();
   }
 
   /**
@@ -361,8 +360,6 @@ class CRM_Member_BAO_MembershipStatus extends CRM_Member_DAO_MembershipStatus {
     }
     //end fetch
 
-    $membershipStatus->free();
-
     //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(
@@ -394,7 +391,6 @@ class CRM_Member_BAO_MembershipStatus extends CRM_Member_DAO_MembershipStatus {
     while ($membershipStatus->fetch()) {
       $statusIds[] = $membershipStatus->id;
     }
-    $membershipStatus->free();
     return $statusIds;
   }
 
index 1d119d742eedea40a4753c84138cdd6bd98da695..6438cff3c0ec6403df4ff84c2be14a6cd5dbfac3 100644 (file)
@@ -281,7 +281,6 @@ class CRM_Member_BAO_MembershipType extends CRM_Member_DAO_MembershipType {
     while ($membershipType->fetch()) {
       $membershipTypes[$membershipType->id] = $membershipType->name;
     }
-    $membershipType->free();
     return $membershipTypes;
   }
 
@@ -300,7 +299,6 @@ class CRM_Member_BAO_MembershipType extends CRM_Member_DAO_MembershipType {
     $membershipType->id = $membershipTypeId;
     if ($membershipType->find(TRUE)) {
       CRM_Core_DAO::storeValues($membershipType, $membershipTypeDetails);
-      $membershipType->free();
       return $membershipTypeDetails;
     }
     else {
index ed2894040ad8de5fd7b18851289ae44475594318..3f98247a5c8e4bfb0fd77d81f28ab49b4fd978b6 100644 (file)
@@ -82,8 +82,6 @@ class CRM_Member_Form_Search extends CRM_Core_Form_Search {
 
     $this->_done = FALSE;
 
-    $this->defaults = array();
-
     $this->loadStandardSearchOptionsFromUrl();
 
     // get user submitted values
index 13510225ec557d7f9d59cda997d302884ee7dcb1..b9bf7885fd6036226da799e84b44218795fd704f 100644 (file)
@@ -181,84 +181,6 @@ class CRM_Member_Page_DashBoard extends CRM_Core_Page {
     $status = CRM_Member_BAO_MembershipStatus::getMembershipStatusCurrent();
     $status = implode(',', $status);
 
-    /*@codingStandardsIgnoreStart
-     Disabled for lack of appropriate search
-
-       The Membership search isn't able to properly filter by join or renewal events.
-       Until that works properly, the subtotals shouldn't get links.
-
-    foreach ($membershipSummary as $typeID => $details) {
-      foreach ($details as $key => $value) {
-        switch ($key) {
-          case 'premonth':
-            $membershipSummary[$typeID][$key]['new']['url'] = CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status=$status&type=$typeID&join=$preMonth&joinEnd=$preMonthEnd&start=$preMonth&end=$preMonthEnd");
-            $membershipSummary[$typeID][$key]['renew']['url'] = CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status=$status&type=$typeID&joinEnd=$prePreMonthEnd&start=$preMonth&end=$preMonthEnd");
-            $membershipSummary[$typeID][$key]['total']['url'] = CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status=$status&type=$typeID&start=$preMonth&end=$preMonthEnd");
-            break;
-
-          case 'month':
-            $membershipSummary[$typeID][$key]['new']['url'] = CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status=$status&type=$typeID&join=$monthStart&joinEnd=$ymd&start=$monthStart&end=$ymd");
-            $membershipSummary[$typeID][$key]['renew']['url'] = CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status=$status&type=$typeID&joinEnd=$preMonthStart&start=$monthStart&end=$ymd");
-            $membershipSummary[$typeID][$key]['total']['url'] = CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status=$status&type=$typeID&start=$monthStart&end=$ymd");
-            break;
-
-          case 'year':
-            $membershipSummary[$typeID][$key]['new']['url'] = CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status=$status&type=$typeID&join=$yearStart&joinEnd=$ymd&start=$yearStart&end=$ymd");
-            $membershipSummary[$typeID][$key]['renew']['url'] = CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status=$status&type=$typeID&joinEnd=$preYearStart&start=$yearStart&end=$ymd");
-            $membershipSummary[$typeID][$key]['total']['url'] = CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status=$status&type=$typeID&start=$yearStart&end=$ymd");
-            break;
-
-          case 'current':
-            $membershipSummary[$typeID][$key]['total']['url'] = CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status=$status&type=$typeID");
-            break;
-
-          case 'total':
-            if (!$isCurrentMonth) {
-              $membershipSummary[$typeID][$key]['total']['url'] = CRM_Utils_System::url('civicrm/member/search',
-                "reset=1&force=1&start=&end=$ymd&status=$status&type=$typeID"
-              );
-            }
-            else {
-              $membershipSummary[$typeID][$key]['total']['url'] = CRM_Utils_System::url('civicrm/member/search',
-                "reset=1&force=1&status=$status"
-              );
-            }
-            break;
-
-          //LCD add owner urls
-
-          case 'premonth_owner':
-            $membershipSummary[$typeID][$key]['premonth_owner']['url'] = CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status=$status&type=$typeID&start=$preMonth&end=$preMonthEnd&owner=1");
-            break;
-
-          case 'month_owner':
-            $membershipSummary[$typeID][$key]['month_owner']['url'] = CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status=$status&type=$typeID&start=$monthStart&end=$ymd&owner=1");
-            break;
-
-          case 'year_owner':
-            $membershipSummary[$typeID][$key]['year_owner']['url'] = CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status=$status&type=$typeID&start=$yearStart&end=$ymd&owner=1");
-            break;
-
-          case 'current_owner':
-            $membershipSummary[$typeID][$key]['current_owner']['url'] = CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status=$status&type=$typeID&owner=1");
-            break;
-
-          case 'total_owner':
-            if (!$isCurrentMonth) {
-              $membershipSummary[$typeID][$key]['total_owner']['url'] = CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&start=&end=$ymd&status=$status&type=$typeID&owner=1");
-            }
-            else {
-              $membershipSummary[$typeID][$key]['total_owner']['url'] = CRM_Utils_System::url('civicrm/member/search', "reset=1&force=1&status=$status&owner=1");
-            }
-            break;
-          //LCD end
-        }
-      }
-    }
-    @codingStandardsIgnoreEnd */
-
-    // Temporary replacement for current totals column
-
     foreach ($membershipSummary as $typeID => $details) {
       if (!$isCurrentMonth) {
         $membershipSummary[$typeID]['total']['total']['url'] = CRM_Utils_System::url('civicrm/member/search',
@@ -306,65 +228,38 @@ class CRM_Member_Page_DashBoard extends CRM_Core_Page {
 
     $totalCount['premonth']['new'] = array(
       'count' => $newCountPreMonth,
-      //'url' => CRM_Utils_System::url('civicrm/activity/search',
-      //  "reset=1&force=1&signupType=1&dateLow=$preMonth&dateHigh=$preMonthEnd"
-      //),
     );
 
     $totalCount['premonth']['renew'] = array(
       'count' => $renewCountPreMonth,
-      //'url' => CRM_Utils_System::url('civicrm/activity/search',
-      //  "reset=1&force=1&signupType=2&dateLow=$preMonth&dateHigh=$preMonthEnd"
-      //),
     );
 
     $totalCount['premonth']['total'] = array(
       'count' => $totalCountPreMonth,
-      //'url' => CRM_Utils_System::url('civicrm/activity/search',
-      //  "reset=1&force=1&signupType=3&dateLow=$preMonth&dateHigh=$preMonthEnd"
-      //),
     );
 
     $totalCount['month']['new'] = array(
       'count' => $newCountMonth,
-      //'url' => CRM_Utils_System::url('civicrm/activity/search',
-      //  "reset=1&force=1&signupType=1&dateLow=$monthStart&dateHigh=$ymd"
-      //),
     );
 
     $totalCount['month']['renew'] = array(
       'count' => $renewCountMonth,
-      //'url' => CRM_Utils_System::url('civicrm/activity/search',
-      //  "reset=1&force=1&signupType=2&dateLow=$monthStart&dateHigh=$ymd"
-      //),
     );
 
     $totalCount['month']['total'] = array(
       'count' => $totalCountMonth,
-      //'url' => CRM_Utils_System::url('civicrm/activity/search',
-      //  "reset=1&force=1&signupType=3&dateLow=$monthStart&dateHigh=$ymd"
-      //),
     );
 
     $totalCount['year']['new'] = array(
       'count' => $newCountYear,
-      //'url' => CRM_Utils_System::url('civicrm/activity/search',
-      //  "reset=1&force=1&signupType=1&dateLow=$yearStart&dateHigh=$ymd"
-      //),
     );
 
     $totalCount['year']['renew'] = array(
       'count' => $renewCountYear,
-      //'url' => CRM_Utils_System::url('civicrm/activity/search',
-      //  "reset=1&force=1&signupType=2&dateLow=$yearStart&dateHigh=$ymd"
-      //),
     );
 
     $totalCount['year']['total'] = array(
       'count' => $totalCountYear,
-      //'url' => CRM_Utils_System::url('civicrm/activity/search',
-      //  "reset=1&force=1&signupType=3&dateLow=$yearStart&dateHigh=$ymd"
-      //),
     );
 
     $totalCount['current']['total'] = array(
index a52b96b4c94e9f7390251f3aa1dabc9b00bc6623..f46782627aa18d05db6a396cdb232ef29a2c6441 100644 (file)
@@ -543,7 +543,7 @@ class CRM_Member_Selector_Search extends CRM_Core_Selector_Base implements CRM_C
    * @return mixed
    */
   public function alphabetQuery() {
-    return $this->_query->searchQuery(NULL, NULL, NULL, FALSE, FALSE, TRUE);
+    return $this->_query->alphabetQuery();
   }
 
   /**
index 33291408d4bf0ede5157ccfecaa1b4dc9800d4b1..3d00901f122c7d9849c69975f078461fb06f56a6 100644 (file)
@@ -71,7 +71,6 @@ class CRM_Pledge_Form_Search extends CRM_Core_Form_Search {
     $this->_actionButtonName = $this->getButtonName('next', 'action');
 
     $this->_done = FALSE;
-    $this->defaults = array();
 
     $this->loadStandardSearchOptionsFromUrl();
 
index 330b50890a0d3232eb4d985aa93acf6925af920d..9b5beb25cff9be6abc9ab7f0ca3416717a5cf0b8 100644 (file)
@@ -179,6 +179,104 @@ class CRM_Profile_Form extends CRM_Core_Form {
   protected $_currentUserID = NULL;
   protected $_session = NULL;
 
+  /**
+   * Check for any duplicates.
+   *
+   * Depending on form settings & usage scenario we potentially use the found id,
+   * create links to found ids or add an error.
+   *
+   * @param array $errors
+   * @param array $fields
+   * @param CRM_Profile_Form $form
+   *
+   * @return array
+   */
+  protected static function handleDuplicateChecking(&$errors, $fields, $form) {
+    if ($form->_mode == CRM_Profile_Form::MODE_CREATE) {
+      // fix for CRM-2888
+      $exceptions = [];
+    }
+    else {
+      // for edit mode we need to allow our own record to be a dupe match!
+      $exceptions = [$form->_session->get('userID')];
+    }
+    $contactType = CRM_Core_BAO_UFGroup::getContactType($form->_gid);
+    // If all profile fields is of Contact Type then consider
+    // profile is of Individual type(default).
+    if (!$contactType) {
+      $contactType = 'Individual';
+    }
+
+    $ids = CRM_Contact_BAO_Contact::getDuplicateContacts(
+      $fields, $contactType,
+      ($form->_context === 'dialog' ? 'Supervised' : 'Unsupervised'),
+      $exceptions,
+      FALSE,
+      $form->_ruleGroupID
+    );
+    if ($ids) {
+      if ($form->_isUpdateDupe == 2) {
+        CRM_Core_Session::setStatus(ts('Note: this contact may be a duplicate of an existing record.'), ts('Possible Duplicate Detected'), 'alert');
+      }
+      elseif ($form->_isUpdateDupe == 1) {
+        $form->_id = $ids[0];
+      }
+      else {
+        if ($form->_context == 'dialog') {
+          $contactLinks = CRM_Contact_BAO_Contact_Utils::formatContactIDSToLinks($ids, TRUE, TRUE);
+
+          $duplicateContactsLinks = '<div class="matching-contacts-found">';
+          $duplicateContactsLinks .= ts('One matching contact was found. ', [
+            'count' => count($contactLinks['rows']),
+            'plural' => '%count matching contacts were found.<br />',
+          ]);
+          if ($contactLinks['msg'] == 'view') {
+            $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.', [
+              'count' => count($contactLinks['rows']),
+              'plural' => 'You can View or Edit the existing contacts.',
+            ]);
+          }
+          $duplicateContactsLinks .= '</div>';
+          $duplicateContactsLinks .= '<table class="matching-contacts-actions">';
+          $row = '';
+          for ($i = 0; $i < count($contactLinks['rows']); $i++) {
+            $row .= '  <tr>   ';
+            $row .= '    <td class="matching-contacts-name"> ';
+            $row .= $contactLinks['rows'][$i]['display_name'];
+            $row .= '    </td>';
+            $row .= '    <td class="matching-contacts-email"> ';
+            $row .= $contactLinks['rows'][$i]['primary_email'];
+            $row .= '    </td>';
+            $row .= '    <td class="action-items"> ';
+            $row .= $contactLinks['rows'][$i]['view'] . ' ';
+            $row .= $contactLinks['rows'][$i]['edit'];
+            $row .= '    </td>';
+            $row .= '  </tr>   ';
+          }
+
+          $duplicateContactsLinks .= $row . '</table>';
+          $duplicateContactsLinks .= "If you're sure this record is not a duplicate, click the 'Save Matching Contact' button below.";
+
+          $errors['_qf_default'] = $duplicateContactsLinks;
+
+          // let smarty know that there are duplicates
+          $template = CRM_Core_Smarty::singleton();
+          $template->assign('isDuplicate', 1);
+        }
+        else {
+          $errors['_qf_default'] = ts('A record already exists with the same information.');
+        }
+      }
+    }
+    return $errors;
+  }
+
   /**
    * Explicitly declare the entity api name.
    */
@@ -895,16 +993,21 @@ class CRM_Profile_Form extends CRM_Core_Form {
   public static function formRule($fields, $files, $form) {
     CRM_Utils_Hook::validateProfile($form->_ufGroup['name']);
 
-    $errors = array();
     // if no values, return
     if (empty($fields)) {
       return TRUE;
     }
 
+    $errors = [];
     $register = NULL;
 
     // hack we use a -1 in options to indicate that its registration
+    // ... and I can't remove that comment because even though it's clear as mud
+    // perhaps someone will find it helpful in the absence of ANY OTHER EXPLANATION
+    // as to what it means....
     if ($form->_id) {
+      // @todo - wonder if it ever occurred to someone that if they didn't document this param
+      // it might not be crystal clear why we have it....
       $form->_isUpdateDupe = 1;
     }
 
@@ -924,90 +1027,8 @@ class CRM_Profile_Form extends CRM_Core_Form {
         $fields['phone-Primary'] = $fields['phone-Primary-1'];
       }
 
-      $ctype = CRM_Core_BAO_UFGroup::getContactType($form->_gid);
-      // If all profile fields is of Contact Type then consider
-      // profile is of Individual type(default).
-      if (!$ctype) {
-        $ctype = 'Individual';
-      }
-
-      if ($form->_mode == CRM_Profile_Form::MODE_CREATE) {
-        // fix for CRM-2888
-        $exceptions = array();
-      }
-      else {
-        // for edit mode we need to allow our own record to be a dupe match!
-        $exceptions = array($form->_session->get('userID'));
-      }
-
-      $ids = CRM_Contact_BAO_Contact::getDuplicateContacts(
-        $fields, $ctype,
-        ($form->_context === 'dialog' ? 'Supervised' : 'Unsupervised'),
-        $exceptions,
-        FALSE,
-        $form->_ruleGroupID
-      );
-      if ($ids) {
-        if ($form->_isUpdateDupe == 2) {
-          CRM_Core_Session::setStatus(ts('Note: this contact may be a duplicate of an existing record.'), ts('Possible Duplicate Detected'), 'alert');
-        }
-        elseif ($form->_isUpdateDupe == 1) {
-          if (!$form->_id) {
-            $form->_id = $ids[0];
-          }
-        }
-        else {
-          if ($form->_context == 'dialog') {
-            $contactLinks = CRM_Contact_BAO_Contact_Utils::formatContactIDSToLinks($ids, TRUE, TRUE);
-
-            $duplicateContactsLinks = '<div class="matching-contacts-found">';
-            $duplicateContactsLinks .= ts('One matching contact was found. ', array(
-              'count' => count($contactLinks['rows']),
-              'plural' => '%count matching contacts were found.<br />',
-            ));
-            if ($contactLinks['msg'] == 'view') {
-              $duplicateContactsLinks .= ts('You can View the existing contact.', array(
-                'count' => count($contactLinks['rows']),
-                'plural' => 'You can View the existing contacts.',
-              ));
-            }
-            else {
-              $duplicateContactsLinks .= ts('You can View or Edit the existing contact.', array(
-                'count' => count($contactLinks['rows']),
-                'plural' => 'You can View or Edit the existing contacts.',
-              ));
-            }
-            $duplicateContactsLinks .= '</div>';
-            $duplicateContactsLinks .= '<table class="matching-contacts-actions">';
-            $row = '';
-            for ($i = 0; $i < count($contactLinks['rows']); $i++) {
-              $row .= '  <tr>   ';
-              $row .= '    <td class="matching-contacts-name"> ';
-              $row .= $contactLinks['rows'][$i]['display_name'];
-              $row .= '    </td>';
-              $row .= '    <td class="matching-contacts-email"> ';
-              $row .= $contactLinks['rows'][$i]['primary_email'];
-              $row .= '    </td>';
-              $row .= '    <td class="action-items"> ';
-              $row .= $contactLinks['rows'][$i]['view'] . ' ';
-              $row .= $contactLinks['rows'][$i]['edit'];
-              $row .= '    </td>';
-              $row .= '  </tr>   ';
-            }
-
-            $duplicateContactsLinks .= $row . '</table>';
-            $duplicateContactsLinks .= "If you're sure this record is not a duplicate, click the 'Save Matching Contact' button below.";
-
-            $errors['_qf_default'] = $duplicateContactsLinks;
-
-            // let smarty know that there are duplicates
-            $template = CRM_Core_Smarty::singleton();
-            $template->assign('isDuplicate', 1);
-          }
-          else {
-            $errors['_qf_default'] = ts('A record already exists with the same information.');
-          }
-        }
+      if (!$form->_id) {
+        self::handleDuplicateChecking($errors, $fields, $form);
       }
     }
 
index 6fb50c2f6db59a4af3867f96da819b7bf8fd2fe9..900a35d4936c87866107e410e3156cfedad3a0d9 100644 (file)
@@ -1577,7 +1577,7 @@ class CRM_Report_Form extends CRM_Core_Form {
 
     // CRM-16274 Determine if user has 'edit all contacts' or equivalent
     $permission = CRM_Core_Permission::getPermission();
-    if ($permission == CRM_Core_Permission::EDIT &&
+    if ($this->_instanceForm && $permission == CRM_Core_Permission::EDIT &&
       $this->_add2groupSupported
     ) {
       $this->addElement('select', 'groups', ts('Group'),
@@ -4758,7 +4758,7 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a
 
   /**
    * Get a standard set of contact fields.
-   *
+   * @deprecated - use getColumns('Contact') instead
    * @return array
    */
   public function getBasicContactFields() {
@@ -5398,7 +5398,45 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a
         'is_filters' => TRUE,
         'is_group_bys' => FALSE,
       ),
+      $options['prefix'] . 'external_identifier' => array(
+        '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(
+        '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(
+        '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] = [
+        'name' => $field,
+        'type' => CRM_Utils_Type::T_BOOLEAN,
+        'is_fields' => TRUE,
+        'is_filters' => TRUE,
+        'is_group_bys' => FALSE,
+      ];
+    }
     $individualFields = array(
       $options['prefix'] . 'first_name' => array(
         'name' => 'first_name',
@@ -5468,6 +5506,20 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a
         'is_filters' => TRUE,
         'is_group_bys' => FALSE,
       ),
+      $options['prefix'] . 'job_title' => array(
+        'name' => 'job_title',
+        'is_fields' => TRUE,
+        'is_filters' => FALSE,
+        'is_group_bys' => FALSE,
+      ),
+      $options['prefix'] . 'employer_id' => array(
+        '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);
index cf582f6c722dbe2884c0c99acb30e868a6f95210..0a38995fcba8cc2066eb3cb071baf00e34e45870 100644 (file)
@@ -44,9 +44,9 @@ class CRM_Report_Form_Case_Detail extends CRM_Report_Form {
 
   protected $_includeCaseDetailExtra = FALSE;
 
-  protected $_caseDetailExtra = array();
+  protected $_caseDetailExtra = [];
 
-  protected $_customGroupExtends = array('Case');
+  protected $_customGroupExtends = ['Case'];
 
   protected $_caseTypeNameOrderBy = FALSE;
 
@@ -60,253 +60,258 @@ class CRM_Report_Form_Case_Detail 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->caseActivityTypes = array();
+    $this->caseActivityTypes = [];
     foreach (CRM_Case_PseudoConstant::caseActivityType() as $typeDetail) {
       $this->caseActivityTypes[$typeDetail['id']] = $typeDetail['label'];
     }
 
-    $this->_columns = array(
-      'civicrm_case' => array(
+    $this->_columns = [
+      'civicrm_case' => [
         'dao' => 'CRM_Case_DAO_Case',
-        'fields' => array(
-          'id' => array(
+        'fields' => [
+          'id' => [
             'title' => ts('Case ID'),
             'no_display' => TRUE,
             'required' => TRUE,
-          ),
-          'subject' => array(
+          ],
+          'subject' => [
             'title' => ts('Subject'),
             'required' => TRUE,
-          ),
-          '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,
-          ),
-          'status_id' => array('title' => ts('Case Status')),
-          'case_type_id' => array('title' => ts('Case Type')),
-          'is_deleted' => array(
+          ],
+          'status_id' => ['title' => ts('Case Status')],
+          'case_type_id' => ['title' => ts('Case Type')],
+          '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,
-          ),
-          'status_id' => array(
+          ],
+          'status_id' => [
             'title' => ts('Case Status'),
             'type' => CRM_Utils_Type::T_INT,
             'operatorType' => CRM_Report_Form::OP_MULTISELECT,
             'options' => CRM_Case_BAO_Case::buildOptions('status_id', 'search'),
-          ),
-          'case_type_id' => array(
+          ],
+          'case_type_id' => [
             'title' => ts('Case Type'),
             'type' => CRM_Utils_Type::T_INT,
             'operatorType' => CRM_Report_Form::OP_MULTISELECT,
             'options' => CRM_Case_BAO_Case::buildOptions('case_type_id', 'search'),
-          ),
-          'is_deleted' => array(
+          ],
+          'is_deleted' => [
             'title' => ts('Deleted?'),
             'type' => CRM_Utils_Type::T_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'),
             'default_weight' => 1,
-          ),
-          'end_date' => array(
+          ],
+          'end_date' => [
             'title' => ts('End Date'),
-          ),
-          'status_id' => array(
+          ],
+          'status_id' => [
             'title' => ts('Status'),
-          ),
-          'case_type_name' => array(
+          ],
+        ],
+      ],
+      'civicrm_case_type' => [
+        'dao' => 'CRM_Case_DAO_Case',
+        'order_bys' => [
+          'case_type_title' => [
             'title' => 'Case Type',
-          ),
-        ),
-      ),
-      'civicrm_contact' => array(
+            'name' => 'title',
+        ]]
+      ],
+      'civicrm_contact' => [
         'dao' => 'CRM_Contact_DAO_Contact',
-        'fields' => array(
-          'client_sort_name' => array(
+        'fields' => [
+          'client_sort_name' => [
             'name' => 'sort_name',
             'title' => ts('Client Name'),
             'required' => TRUE,
-          ),
-          'id' => array(
+          ],
+          'id' => [
             'no_display' => TRUE,
             'required' => TRUE,
-          ),
-        ),
-        'filters' => array(
-          'sort_name' => array('title' => ts('Client Name')),
-        ),
-      ),
-      'civicrm_relationship' => array(
+          ],
+        ],
+        'filters' => [
+          'sort_name' => ['title' => ts('Client Name')],
+        ],
+      ],
+      'civicrm_relationship' => [
         'dao' => 'CRM_Contact_DAO_Relationship',
-        'fields' => array(
-          'case_role' => array(
+        'fields' => [
+          'case_role' => [
             'name' => 'relationship_type_id',
             'title' => ts('Case Role(s)'),
-          ),
-        ),
-        'filters' => array(
-          'case_role' => array(
+          ],
+        ],
+        'filters' => [
+          'case_role' => [
             'name' => 'relationship_type_id',
             'title' => ts('Case Role(s)'),
             'type' => CRM_Utils_Type::T_INT,
             'operatorType' => CRM_Report_Form::OP_MULTISELECT,
             'options' => $this->rel_types,
-          ),
-          'is_active' => array(
+          ],
+          'is_active' => [
             'title' => ts('Active Role?'),
             'type' => CRM_Utils_Type::T_BOOLEAN,
             'default' => TRUE,
             'options' => CRM_Core_SelectValues::boolean(),
-          ),
-        ),
-      ),
-      '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_address' => array(
+      ],
+      'civicrm_address' => [
         'dao' => 'CRM_Core_DAO_Address',
-        'fields' => array(
+        'fields' => [
           'street_address' => NULL,
-          'state_province_id' => array(
+          'state_province_id' => [
             'title' => ts('State/Province'),
-          ),
-          'country_id' => array('title' => ts('Country')),
-        ),
+          ],
+          'country_id' => ['title' => ts('Country')],
+        ],
         'grouping' => 'contact-fields',
-        '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(),
-          ),
-        ),
-      ),
-      'civicrm_worldregion' => array(
+          ],
+        ],
+      ],
+      'civicrm_worldregion' => [
         'dao' => 'CRM_Core_DAO_Worldregion',
-        'filters' => array(
-          'worldregion_id' => array(
+        'filters' => [
+          'worldregion_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_country' => array(
+          ],
+        ],
+      ],
+      'civicrm_country' => [
         'dao' => 'CRM_Core_DAO_Country',
-      ),
-      'civicrm_activity_last' => array(
+      ],
+      'civicrm_activity_last' => [
         'dao' => 'CRM_Activity_DAO_Activity',
-        'fields' => array(
-          'last_activity_activity_subject' => array(
+        'fields' => [
+          'last_activity_activity_subject' => [
             'name' => 'subject',
             'title' => ts('Subject of the last activity in the case'),
-          ),
-          'last_activity_activity_type' => array(
+          ],
+          'last_activity_activity_type' => [
             'name' => 'activity_type_id',
             'title' => ts('Activity type of the last activity'),
-          ),
-          'last_activity_date_time' => array(
+          ],
+          'last_activity_date_time' => [
             'name' => 'activity_date_time',
             'title' => ts('Last Action Date'),
             'operatorType' => CRM_Report_Form::OP_DATE,
-          ),
-        ),
-        'filters' => array(
-          'last_activity_date_time' => array(
+          ],
+        ],
+        'filters' => [
+          'last_activity_date_time' => [
             'name' => 'activity_date_time',
             'title' => ts('Last Action Date'),
             'operatorType' => CRM_Report_Form::OP_DATE,
-          ),
-        ),
+          ],
+        ],
         'alias' => 'civireport_activity_last',
-      ),
-      'civicrm_activity_last_completed' => array(
+      ],
+      'civicrm_activity_last_completed' => [
         'dao' => 'CRM_Activity_DAO_Activity',
-        'fields' => array(
-          'last_completed_activity_subject' => array(
+        'fields' => [
+          'last_completed_activity_subject' => [
             'name' => 'subject',
             'title' => ts('Subject of the last completed activity in the case'),
-          ),
-          'last_completed_activity_type' => array(
+          ],
+          'last_completed_activity_type' => [
             'name' => 'activity_type_id',
             'title' => ts('Activity type of the last completed activity'),
-          ),
-          'last_completed_date_time' => array(
+          ],
+          'last_completed_date_time' => [
             'name' => 'activity_date_time',
             'title' => ts('Last Completed Action Date'),
             'operatorType' => CRM_Report_Form::OP_DATE,
-          ),
-        ),
-        'filters' => array(
-          'last_completed_date_time' => array(
+          ],
+        ],
+        'filters' => [
+          'last_completed_date_time' => [
             'name' => 'activity_date_time',
             'title' => ts('Last Completed Action Date'),
             'operatorType' => CRM_Report_Form::OP_DATE,
-          ),
-        ),
-      ),
-    );
+          ],
+        ],
+      ],
+    ];
 
-    $this->_options = array(
-      'my_cases' => array(
+    $this->_options = [
+      'my_cases' => [
         'title' => ts('My Cases'),
         'type' => 'checkbox',
-      ),
-    );
+      ],
+    ];
     parent::__construct();
   }
 
@@ -320,27 +325,29 @@ class CRM_Report_Form_Case_Detail extends CRM_Report_Form {
   }
 
   public function caseDetailSpecialColumnsAdd() {
-    $elements = array();
+    $elements = [];
     $elements[] = &$this->createElement('select', 'case_activity_all_dates', NULL,
-      array(
+      [
         '' => ts('- select -'),
-      ) + $this->caseActivityTypes
+      ] + $this->caseActivityTypes
     );
     $this->addGroup($elements, 'case_detail_extra');
 
-    $this->_caseDetailExtra = array(
-      'case_activity_all_dates' => array(
+    $this->_caseDetailExtra = [
+      'case_activity_all_dates' => [
         'title' => ts('List of all dates of activities of Type'),
         'name' => 'activity_date_time',
-      ),
-    );
+      ],
+    ];
 
     $this->assign('caseDetailExtra', $this->_caseDetailExtra);
   }
 
   public function select() {
-    $select = array();
-    $this->_columnHeaders = array();
+    // @todo - get rid of this function & use parent. Use selectWhere to setthe clause for the
+    // few fields that need custom handling.
+    $select = [];
+    $this->_columnHeaders = [];
     foreach ($this->_columns as $tableName => $table) {
       if (array_key_exists('fields', $table)) {
         foreach ($table['fields'] as $fieldName => $field) {
@@ -375,15 +382,6 @@ class CRM_Report_Form_Case_Detail extends CRM_Report_Form {
       }
     }
 
-    if ($orderBys = $this->_params['order_bys']) {
-      foreach ($orderBys as $orderBy) {
-        if ($orderBy['column'] == 'case_type_name') {
-          $select[] = "civireport_case_types.title as case_type_name";
-          $this->_caseTypeNameOrderBy = TRUE;
-        }
-      }
-    }
-
     $this->_selectClauses = $select;
 
     $this->_select = 'SELECT ' . implode(', ', $select) . ' ';
@@ -427,17 +425,16 @@ class CRM_Report_Form_Case_Detail extends CRM_Report_Form {
       $this->_from .= " LEFT JOIN civicrm_activity {$this->_aliases['civicrm_activity_last_completed']} ON ( {$this->_aliases['civicrm_activity_last_completed']}.id = ( SELECT max(activity_id) FROM civicrm_case_activity cca, civicrm_activity ca WHERE ca.id = cca.activity_id AND cca.case_id = {$case}.id AND ca.status_id = 2 ) )";
     }
 
-    //include case type name
-    if ($this->_caseTypeNameOrderBy) {
+    if ($this->isTableSelected('civicrm_case_type')) {
       $this->_from .= "
-        LEFT JOIN civicrm_case_type civireport_case_types
-          ON {$case}.case_type_id = civireport_case_types.id
+        LEFT JOIN civicrm_case_type {$this->_aliases['civicrm_case_type']}
+          ON {$this->_aliases['civicrm_case']}.case_type_id = {$this->_aliases['civicrm_case_type']}.id
       ";
     }
   }
 
   public function where() {
-    $clauses = array();
+    $clauses = [];
     $this->_having = '';
     foreach ($this->_columns as $tableName => $table) {
       if (array_key_exists('filters', $table)) {
@@ -509,35 +506,24 @@ class CRM_Report_Form_Case_Detail extends CRM_Report_Form {
     $sql = "{$select} {$this->_from} {$this->_where}";
     $countryCount = CRM_Core_DAO::singleValueQuery($sql);
 
-    $statistics['counts']['case'] = array(
+    $statistics['counts']['case'] = [
       'title' => ts('Total Number of Cases '),
       'value' => isset($statistics['counts']['rowsFound']) ? $statistics['counts']['rowsFound']['value'] : count($rows),
-    );
-    $statistics['counts']['country'] = array(
+    ];
+    $statistics['counts']['country'] = [
       'title' => ts('Total Number of Countries '),
       'value' => $countryCount,
-    );
+    ];
 
     return $statistics;
   }
 
-  public function orderBy() {
-    parent::orderBy();
-
-    if ($this->_caseTypeNameOrderBy) {
-      $this->_orderBy = str_replace('case_civireport.case_type_name', 'civireport_case_types.title', $this->_orderBy);
-      if (isset($this->_sections['civicrm_case_case_type_name'])) {
-        $this->_sections['civicrm_case_case_type_name']['dbAlias'] = 'civireport_case_types.title';
-      }
-    }
-  }
-
   public function caseDetailSpecialColumnProcess() {
     if (!$this->_includeCaseDetailExtra) {
       return;
     }
 
-    $from = $select = array();
+    $from = $select = [];
     $case = $this->_aliases['civicrm_case'];
 
     if ($activityType = CRM_Utils_Array::value('case_activity_all_dates', $this->_params['case_detail_extra'])) {
@@ -546,10 +532,10 @@ class CRM_Report_Form_Case_Detail extends CRM_Report_Form {
       $from[] = " LEFT JOIN civicrm_case_activity civireport_case_activity_all_{$activityType} ON ( civireport_case_activity_all_{$activityType}.case_id = {$case}.id)
                         LEFT JOIN civicrm_activity civireport_activity_all_{$activityType} ON ( civireport_activity_all_{$activityType}.id = civireport_case_activity_all_{$activityType}.activity_id AND civireport_activity_all_{$activityType}.activity_type_id = {$activityType})";
 
-      $this->_columnHeaders['case_activity_all_dates'] = array(
+      $this->_columnHeaders['case_activity_all_dates'] = [
         'title' => $this->_caseDetailExtra['case_activity_all_dates']['title'] . ": {$this->caseActivityTypes[$activityType]}",
         'type' => CRM_Utils_Array::value('type', $this->_caseDetailExtra['case_activity_all_dates']),
-      );
+      ];
     }
 
     $this->_select .= ', ' . implode(', ', $select) . ' ';
@@ -568,7 +554,7 @@ class CRM_Report_Form_Case_Detail extends CRM_Report_Form {
 
     $sql = "{$this->_select} {$this->_from} {$this->_where} {$this->_groupBy} {$this->_having} {$this->_orderBy} {$this->_limit}";
 
-    $rows = $graphRows = array();
+    $rows = $graphRows = [];
     $this->buildRows($sql, $rows);
 
     $this->formatDisplay($rows);
@@ -580,7 +566,7 @@ class CRM_Report_Form_Case_Detail extends CRM_Report_Form {
   public function checkEnabledFields() {
     if ((isset($this->_params['case_role_value'])
         && !empty($this->_params['case_role_value'])) ||
-        (isset($this->_params['is_active_value']))
+      (isset($this->_params['is_active_value']))
     ) {
       $this->_relField = TRUE;
     }
index 240fc1dea81fe4a19ca3167690c88a0e8ce0950b..ee117af7a4b7b690596999073acda0303083f75f 100644 (file)
@@ -354,7 +354,7 @@ class CRM_Report_Form_Contribute_Bookkeeping extends CRM_Report_Form {
           'trxn_date' => array(
             'title' => ts('Transaction Date'),
             'default' => TRUE,
-            'type' => CRM_Utils_Type::T_DATE,
+            'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
           ),
           'trxn_id' => array(
             'title' => ts('Trans #'),
@@ -381,7 +381,7 @@ class CRM_Report_Form_Contribute_Bookkeeping extends CRM_Report_Form {
           'trxn_date' => array(
             'title' => ts('Transaction Date'),
             'operatorType' => CRM_Report_Form::OP_DATE,
-            'type' => CRM_Utils_Type::T_DATE,
+            'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
           ),
           'status_id' => array(
             'title' => ts('Financial Transaction Status'),
index c5466dd4b901f4b73ef5210c71c843116f1a5673..e9f0d418212ff82c25bd0e8b1c4cf952fc0a0740 100644 (file)
@@ -99,41 +99,27 @@ class CRM_Report_Form_Contribute_Repeat extends CRM_Report_Form {
       'civicrm_contact' => array(
         'dao' => 'CRM_Contact_DAO_Contact',
         'grouping' => 'contact-fields',
-        'fields' => array(
-          'sort_name' => array(
-            'title' => ts('Contact Name'),
-            'no_repeat' => TRUE,
-            'default' => TRUE,
-          ),
-          'display_name' => array(
-            'title' => ts('Display Name'),
-            'no_repeat' => TRUE,
-          ),
-          'addressee_display' => array(
-            'title' => ts('Addressee Name'),
-            'no_repeat' => TRUE,
-          ),
-          'id' => array(
-            'no_display' => TRUE,
-            'required' => TRUE,
-          ),
-          'contact_type' => array(
-            'title' => ts('Contact Type'),
-            'no_repeat' => TRUE,
-          ),
-          'contact_sub_type' => array(
-            'title' => ts('Contact Subtype'),
-            'no_repeat' => TRUE,
-          ),
+        'fields' => array_merge(
+          $this->getBasicContactFields(),
+          array(
+            'sort_name' => array(
+              'title' => ts('Contact Name'),
+              'no_repeat' => TRUE,
+              'default' => TRUE,
+            ),
+          )
         ),
-        'filters' => array(
-          'percentage_change' => array(
-            'title' => ts('Percentage Change'),
-            'type' => CRM_Utils_Type::T_INT,
-            'operatorType' => CRM_Report_Form::OP_INT,
-            'name' => 'percentage_change',
-            'dbAlias' => '( ( contribution_civireport2.total_amount_sum - contribution_civireport1.total_amount_sum ) * 100 / contribution_civireport1.total_amount_sum )',
-          ),
+        'filters' => array_merge(
+          $this->getBasicContactFilters(array('deceased' => NULL)),
+          array(
+            'percentage_change' => array(
+              'title' => ts('Percentage Change'),
+              'type' => CRM_Utils_Type::T_INT,
+              'operatorType' => CRM_Report_Form::OP_INT,
+              'name' => 'percentage_change',
+              'dbAlias' => '( ( contribution_civireport2.total_amount_sum - contribution_civireport1.total_amount_sum ) * 100 / contribution_civireport1.total_amount_sum )',
+            ),
+          )
         ),
         'group_bys' => array(
           'id' => array(
@@ -187,24 +173,6 @@ class CRM_Report_Form_Contribute_Repeat extends CRM_Report_Form {
         ),
         'grouping' => 'contact-fields',
       ),
-      'civicrm_address' => array(
-        'dao' => 'CRM_Core_DAO_Address',
-        'grouping' => 'contact-fields',
-        'fields' => array(
-          'street_address' => array('title' => ts('Street Address')),
-          'supplemental_address_1' => array('title' => ts('Supplemental Address 1')),
-          'city' => array('title' => ts('City')),
-          'country_id' => array('title' => ts('Country')),
-          'state_province_id' => array('title' => ts('State/Province')),
-          'postal_code' => array('title' => ts('Postal Code')),
-        ),
-        'group_bys' => array(
-          'country_id' => array('title' => ts('Country')),
-          'state_province_id' => array(
-            'title' => ts('State/Province'),
-          ),
-        ),
-      ),
       'civicrm_financial_type' => array(
         'dao' => 'CRM_Financial_DAO_FinancialType',
         'fields' => array('financial_type' => array('title' => ts('Financial Type'))),
@@ -280,7 +248,7 @@ class CRM_Report_Form_Contribute_Repeat extends CRM_Report_Form {
         ),
         'group_bys' => array('contribution_source' => NULL),
       ),
-    );
+    ) + $this->addAddressFields(TRUE, FALSE, TRUE, array('country_id' => FALSE));
 
     $this->_groupFilter = TRUE;
     $this->_tagFilter = TRUE;
@@ -531,6 +499,7 @@ LEFT JOIN $this->tempTableRepeat2 {$this->_aliases['civicrm_contribution']}2
     $rules = array(
       'id' => array(
         'sort_name',
+        'exposed_id',
         'display_name',
         'addressee_display',
         'contact_type',
@@ -540,9 +509,38 @@ LEFT JOIN $this->tempTableRepeat2 {$this->_aliases['civicrm_contribution']}2
         'state_province_id',
         'country_id',
         'city',
+        'county_id',
         'street_address',
         'supplemental_address_1',
+        'supplemental_address_2',
+        'supplemental_address_3',
+        'street_number',
+        'street_name',
+        'street_unit',
         'postal_code',
+        'postal_code_suffix',
+        'prefix_id',
+        'first_name',
+        'nick_name',
+        'middle_name',
+        'last_name',
+        'suffix_id',
+        'postal_greeting_display',
+        'email_greeting_display',
+        'addressee_display',
+        'gender_id',
+        'birth_date',
+        'age',
+        'job_title',
+        'organization_name',
+        'external_identifier',
+        'do_not_email',
+        'do_not_phone',
+        'do_not_mail',
+        'do_not_sms',
+        'is_opt_out',
+        'is_deceased',
+        'preferred_language',
       ),
       'country_id' => array('country_id'),
       'state_province_id' => array('country_id', 'state_province_id'),
@@ -1037,7 +1035,7 @@ GROUP BY contribution2.{$this->contributionJoinTableColumn}, currency";
 CREATE TEMPORARY TABLE $this->tempTableRepeat1 (
 {$create}
 {$this->contributionJoinTableColumn} int unsigned,
-total_amount_sum int,
+total_amount_sum decimal(20,2),
 total_amount_count int
 ) ENGINE=HEAP {$this->_databaseAttributes}";
     $this->executeReportQuery($sql);
@@ -1052,7 +1050,7 @@ total_amount_count int
 CREATE TEMPORARY TABLE  $this->tempTableRepeat2 (
 {$create}
 {$this->contributionJoinTableColumn} int unsigned,
-total_amount_sum int,
+total_amount_sum decimal(20,2),
 total_amount_count int,
 currency varchar(3)
 ) ENGINE=HEAP {$this->_databaseAttributes}";
index 983d4795127b2eef9485bac4825566ada43257e7..5296451542ab974dfdd600746e1f42f849029fd2 100644 (file)
@@ -535,21 +535,10 @@ GROUP BY   {$this->_aliases['civicrm_contribution']}.currency
     $this->buildACLClause(array('constituentname', 'contact_civireport'));
     $sql = $this->buildQuery();
 
-    $dao = CRM_Core_DAO::executeQuery($sql);
     $rows = $graphRows = array();
-    $count = 0;
-    while ($dao->fetch()) {
-      $row = array();
-      foreach ($this->_columnHeaders as $key => $value) {
-        $row[$key] = $dao->$key;
-      }
-      $rows[] = $row;
-    }
-    $this->formatDisplay($rows);
+    $this->buildRows($sql, $rows);
 
-    // to hide the contact ID field from getting displayed
-    unset($this->_columnHeaders['civicrm_contact_id_constituent']);
-    unset($this->_columnHeaders['civicrm_contact_id_creditor']);
+    $this->formatDisplay($rows);
 
     // assign variables to templates
     $this->doTemplateAssignment($rows);
index b5f682a98773b08d5502c5e8cd6258f1d38f028a..11a7773b47376f13aa49dfcf0f3aaea040a3dad7 100644 (file)
@@ -649,10 +649,8 @@ ROUND(AVG({$this->_aliases['civicrm_contribution_soft']}.amount), 2) as civicrm_
       FROM (SELECT {$this->_aliases['civicrm_contribution']}.total_amount as amount,
     {$contriQuery} {$groupBy} {$orderBy}) as mode GROUP BY currency";
 
-    $mode = CRM_Contribute_BAO_Contribution::computeStats('mode', $modeSQL);
-
-    $medianSQL = "{$this->_from} {$this->_where}";
-    $median = CRM_Contribute_BAO_Contribution::computeStats('median', $medianSQL, $this->_aliases['civicrm_contribution']);
+    $mode = $this->calculateMode($modeSQL);
+    $median = $this->calculateMedian();
 
     if ($softCredit) {
       $softDAO = CRM_Core_DAO::executeQuery($softSQL);
@@ -961,4 +959,71 @@ ROUND(AVG({$this->_aliases['civicrm_contribution_soft']}.amount), 2) as civicrm_
     }
   }
 
+  /**
+   * Calculate mode.
+   *
+   * Note this is a slow query. Alternative is extended reports.
+   *
+   * @param string $sql
+   * @return array|null
+   */
+  protected function calculateMode($sql) {
+    $mode = [];
+    $modeDAO = CRM_Core_DAO::executeQuery($sql);
+    while ($modeDAO->fetch()) {
+      if ($modeDAO->civicrm_contribution_total_amount_count > 1) {
+        $mode[] = CRM_Utils_Money::format($modeDAO->amount, $modeDAO->currency);
+      }
+      else {
+        $mode[] = 'N/A';
+      }
+    }
+    return $mode;
+  }
+
+  /**
+   * Calculate mode.
+   *
+   * Note this is a slow query. Alternative is extended reports.
+   *
+   * @return array|null
+   */
+  protected function calculateMedian() {
+    $sql = "{$this->_from} {$this->_where}";
+    $currencies = CRM_Core_OptionGroup::values('currencies_enabled');
+    $median = [];
+    foreach ($currencies as $currency => $val) {
+      $midValue = 0;
+      $where = "AND {$this->_aliases['civicrm_contribution']}.currency = '{$currency}'";
+      $rowCount = CRM_Core_DAO::singleValueQuery("SELECT count(*) as count {$sql} {$where}");
+
+      $even = FALSE;
+      $offset = 1;
+      $medianRow = floor($rowCount / 2);
+      if ($rowCount % 2 == 0 && !empty($medianRow)) {
+        $even = TRUE;
+        $offset++;
+        $medianRow--;
+      }
+
+      $medianValue = "SELECT {$this->_aliases['civicrm_contribution']}.total_amount as median
+             {$sql} {$where}
+             ORDER BY median LIMIT {$medianRow},{$offset}";
+      $medianValDAO = CRM_Core_DAO::executeQuery($medianValue);
+      while ($medianValDAO->fetch()) {
+        if ($even) {
+          $midValue = $midValue + $medianValDAO->median;
+        }
+        else {
+          $median[] = CRM_Utils_Money::format($medianValDAO->median, $currency);
+        }
+      }
+      if ($even) {
+        $midValue = $midValue / 2;
+        $median[] = CRM_Utils_Money::format($midValue, $currency);
+      }
+    }
+    return $median;
+  }
+
 }
index b22d17e4cc871082ff11d75abe477617343721da..41bcc465758c212d657cfce68f354e3d931e5eb4 100644 (file)
@@ -32,7 +32,7 @@
  * $Id$
  *
  */
-class CRM_Report_Form_Event_Income extends CRM_Report_Form_Event {
+class CRM_Report_Form_Event_Income extends CRM_Report_Form {
   const ROW_COUNT_LIMIT = 2;
 
   protected $_summary = NULL;
index 7762669298ceef55eeefcd918c9608ce4cdb6afc..d8dbeed4f4a7a017103ea932cb512551251bfd78 100644 (file)
@@ -30,7 +30,7 @@
  * @package CRM
  * @copyright CiviCRM LLC (c) 2004-2019
  */
-class CRM_Report_Form_Event_IncomeCountSummary extends CRM_Report_Form_Event {
+class CRM_Report_Form_Event_IncomeCountSummary extends CRM_Report_Form {
 
   protected $_summary = NULL;
 
index 1bae9c1341a181640e2e3587a4b37360e5915fdf..a03f9c9c3e5059614bf1f7479a20f7774878db17 100644 (file)
@@ -30,7 +30,7 @@
  * @package CRM
  * @copyright CiviCRM LLC (c) 2004-2019
  */
-class CRM_Report_Form_Event_ParticipantListCount extends CRM_Report_Form_Event {
+class CRM_Report_Form_Event_ParticipantListCount extends CRM_Report_Form {
 
   protected $_summary = NULL;
   protected $_groupFilter = TRUE;
@@ -238,7 +238,7 @@ class CRM_Report_Form_Event_ParticipantListCount extends CRM_Report_Form_Event {
             'operatorType' => CRM_Report_Form::OP_ENTITYREF,
             'type' => CRM_Utils_Type::T_INT,
             'attributes' => array(
-              'entity' => 'event',
+              'entity' => 'Event',
               'select' => array('minimumInputLength' => 0),
             ),
           ),
index 33a7a17329f2e62b8db2186fccd5003385ff3aa9..23f8762a142849bc23418ce584f58bb4e08f4598 100644 (file)
@@ -30,7 +30,7 @@
  * @package CRM
  * @copyright CiviCRM LLC (c) 2004-2019
  */
-class CRM_Report_Form_Event_ParticipantListing extends CRM_Report_Form_Event {
+class CRM_Report_Form_Event_ParticipantListing extends CRM_Report_Form {
 
   protected $_summary = NULL;
 
@@ -180,7 +180,7 @@ class CRM_Report_Form_Event_ParticipantListing extends CRM_Report_Form_Event {
             'operatorType' => CRM_Report_Form::OP_ENTITYREF,
             'type' => CRM_Utils_Type::T_INT,
             'attributes' => array(
-              'entity' => 'event',
+              'entity' => 'Event',
               'select' => array('minimumInputLength' => 0),
             ),
           ),
index 11a3a8c0af660e2bca55130db77e459ad343f0c6..0d689cc848b29a4700cb7368b18c95d3ea2f188c 100644 (file)
@@ -30,7 +30,7 @@
  * @package CRM
  * @copyright CiviCRM LLC (c) 2004-2019
  */
-class CRM_Report_Form_Event_Summary extends CRM_Report_Form_Event {
+class CRM_Report_Form_Event_Summary extends CRM_Report_Form {
 
   protected $_summary = NULL;
 
index 13a286ada49dc07351d6ef865341e61ac35bb3d0..94afd1f197636acd1bff7bd6b55ad8ca95f4b4c7 100644 (file)
@@ -104,6 +104,10 @@ class CRM_Report_Form_Member_Detail extends CRM_Report_Form {
             'title' => ts('End Date'),
             'default' => TRUE,
           ),
+          'owner_membership_id' => array(
+            'title' => ts('Primary/Inherited?'),
+            'default' => TRUE,
+          ),
           'join_date' => array(
             'title' => ts('Join Date'),
             'default' => TRUE,
@@ -363,6 +367,12 @@ class CRM_Report_Form_Member_Detail extends CRM_Report_Form {
         $entryFound = TRUE;
       }
 
+      if (array_key_exists('civicrm_membership_owner_membership_id', $row)) {
+        $value = $row['civicrm_membership_owner_membership_id'];
+        $rows[$rowNum]['civicrm_membership_owner_membership_id'] = ($value != '') ? 'Inherited' : 'Primary';
+        $entryFound = TRUE;
+      }
+
       // Convert campaign_id to campaign title
       if (array_key_exists('civicrm_membership_campaign_id', $row)) {
         if ($value = $row['civicrm_membership_campaign_id']) {
diff --git a/CRM/Upgrade/4.2.alpha1.msg_template/civicrm_msg_template.tpl b/CRM/Upgrade/4.2.alpha1.msg_template/civicrm_msg_template.tpl
deleted file mode 100644 (file)
index 9f7a745..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-{php}
-  $dir = SMARTY_DIR . '/../../CRM/Upgrade/4.2.alpha1.msg_template/message_templates';
-
-  $ovNames = array(
-    'contribution' => array(
-      'contribution_recurring_cancelled' => ts('Contributions - Recurring Cancellation Notification',         array('escape' => 'sql')),
-      'contribution_recurring_billing' => ts('Contributions - Recurring Billing Updates',                     array('escape' => 'sql')),
-      'contribution_recurring_edit'    => ts('Contributions - Recurring Updates',                             array('escape' => 'sql')),
-    ),
-    'membership' => array(
-      'membership_autorenew_cancelled' => ts('Memberships - Auto-renew Cancellation Notification', array('escape' => 'sql')),
-      'membership_autorenew_billing' => ts('Memberships - Auto-renew Billing Updates',           array('escape' => 'sql')),
-    ),
-  );
-
-  $ignoreTemplate = array_merge(array_keys($ovNames['contribution']), array_keys($ovNames['membership']));
-
-  $this->assign('ovNames', $ovNames);
-  $this->assign('dir', $dir);
-  $templates = array();
-  foreach (preg_grep('/\.tpl$/', scandir($dir)) as $filename) {
-    $parts = explode('_', basename($filename, '.tpl'));
-    $type  = array_pop($parts);
-    $name  = implode('_', $parts);
-      if (!in_array($name,$ignoreTemplate)) {
-        $templates[] = array('type' => $type, 'name' => $name, 'filename' => "$dir/$filename");
-      }
-  }
-  $this->assign('templates', $templates);
-{/php}
-
-{foreach from=$templates item=tpl}
-  {fetch assign=content file=$tpl.filename}
-  SELECT @workflow_id := MAX(id) FROM civicrm_option_value WHERE name = '{$tpl.name}';
-  SELECT @content := msg_{$tpl.type} FROM civicrm_msg_template WHERE workflow_id = @workflow_id AND is_reserved = 1 LIMIT 1;
-  UPDATE civicrm_msg_template SET msg_{$tpl.type} = '{$content|escape:"quotes"}' WHERE workflow_id = @workflow_id AND (is_reserved = 1 OR (is_default = 1 AND msg_{$tpl.type} = @content));
-{/foreach}
-
-{foreach from=$ovNames key=name item=ignore}
-  SELECT @tpl_ogid_{$name} := MAX(id) FROM civicrm_option_group WHERE name = 'msg_tpl_workflow_{$name}';
-{/foreach}
-
-INSERT INTO civicrm_option_value
-  (option_group_id,        name,       {localize field='label'}label{/localize},   value,                                  weight) VALUES
-{foreach from=$ovNames key=gName item=ovs name=for_groups}
-{foreach from=$ovs key=vName item=label name=for_values}
-      (@tpl_ogid_{$gName}, '{$vName}', {localize}'{$label}'{/localize},            {$smarty.foreach.for_values.iteration}, {$smarty.foreach.for_values.iteration}) {if $smarty.foreach.for_groups.last and $smarty.foreach.for_values.last};{else},{/if}
-{/foreach}
-{/foreach}
-
-{foreach from=$ovNames key=gName item=ovs}
-{foreach from=$ovs key=vName item=label}
-    SELECT @tpl_ovid_{$vName} := MAX(id) FROM civicrm_option_value WHERE option_group_id = @tpl_ogid_{$gName} AND name = '{$vName}';
-{/foreach}
-{/foreach}
-
-INSERT INTO civicrm_msg_template
-  (msg_title,      msg_subject,                  msg_text,                  msg_html,                  workflow_id,        is_default, is_reserved) VALUES
-{foreach from=$ovNames key=gName item=ovs name=for_groups}
-{foreach from=$ovs key=vName item=title name=for_values}
-      {fetch assign=subject file="`$smarty.const.SMARTY_DIR`/../../CRM/Upgrade/4.2.alpha1.msg_template/message_templates/`$vName`_subject.tpl"}
-      {fetch assign=text    file="`$smarty.const.SMARTY_DIR`/../../CRM/Upgrade/4.2.alpha1.msg_template/message_templates/`$vName`_text.tpl"}
-      {fetch assign=html    file="`$smarty.const.SMARTY_DIR`/../../CRM/Upgrade/4.2.alpha1.msg_template/message_templates/`$vName`_html.tpl"}
-      ('{$title}', '{$subject|escape:"quotes"}', '{$text|escape:"quotes"}', '{$html|escape:"quotes"}', @tpl_ovid_{$vName}, 1,          0),
-      ('{$title}', '{$subject|escape:"quotes"}', '{$text|escape:"quotes"}', '{$html|escape:"quotes"}', @tpl_ovid_{$vName}, 0,          1) {if $smarty.foreach.for_groups.last and $smarty.foreach.for_values.last};{else},{/if}
-{/foreach}
-{/foreach}
diff --git a/CRM/Upgrade/4.2.alpha1.msg_template/message_templates/contribution_online_receipt_html.tpl b/CRM/Upgrade/4.2.alpha1.msg_template/message_templates/contribution_online_receipt_html.tpl
deleted file mode 100644 (file)
index a1c91b1..0000000
+++ /dev/null
@@ -1,395 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <title></title>
-</head>
-<body>
-
-{capture assign=headerStyle}colspan="2" style="text-align: left; padding: 4px; border-bottom: 1px solid #999; background-color: #eee;"{/capture}
-{capture assign=labelStyle }style="padding: 4px; border-bottom: 1px solid #999; background-color: #f7f7f7;"{/capture}
-{capture assign=valueStyle }style="padding: 4px; border-bottom: 1px solid #999;"{/capture}
-
-<center>
- <table width="500" border="0" cellpadding="0" cellspacing="0" id="crm-event_receipt" style="font-family: Arial, Verdana, sans-serif; text-align: left;">
-
-  <!-- BEGIN HEADER -->
-  <!-- You can add table row(s) here with logo or other header elements -->
-  <!-- END HEADER -->
-
-  <!-- BEGIN CONTENT -->
-
-  <tr>
-   <td>
-
-    {if $receipt_text}
-     <p>{$receipt_text|htmlize}</p>
-    {/if}
-
-    {if $is_pay_later}
-     <p>{$pay_later_receipt}</p> {* FIXME: this might be text rather than HTML *}
-    {else}
-     <p>{ts}Please print this confirmation for your records.{/ts}</p>
-    {/if}
-
-   </td>
-  </tr>
-  </table>
-  <table width="500" style="border: 1px solid #999; margin: 1em 0em 1em; border-collapse: collapse;">
-
-     {if $amount}
-
-
-      <tr>
-       <th {$headerStyle}>
-        {ts}Contribution Information{/ts}
-       </th>
-      </tr>
-
-      {if $lineItem and $priceSetID and !$is_quick_config}
-
-       {foreach from=$lineItem item=value key=priceset}
-        <tr>
-         <td colspan="2" {$valueStyle}>
-          <table> {* FIXME: style this table so that it looks like the text version (justification, etc.) *}
-           <tr>
-            <th>{ts}Item{/ts}</th>
-            <th>{ts}Qty{/ts}</th>
-            <th>{ts}Each{/ts}</th>
-            <th>{ts}Total{/ts}</th>
-           </tr>
-           {foreach from=$value item=line}
-            <tr>
-             <td>
-             {if $line.html_type eq 'Text'}{$line.label}{else}{$line.field_title} - {$line.label}{/if} {if $line.description}<div>{$line.description|truncate:30:"..."}</div>{/if}
-             </td>
-             <td>
-              {$line.qty}
-             </td>
-             <td>
-              {$line.unit_price|crmMoney:$currency}
-             </td>
-             <td>
-              {$line.line_total|crmMoney:$currency}
-             </td>
-            </tr>
-           {/foreach}
-          </table>
-         </td>
-        </tr>
-       {/foreach}
-       <tr>
-        <td {$labelStyle}>
-         {ts}Total Amount{/ts}
-        </td>
-        <td {$valueStyle}>
-         {$amount|crmMoney:$currency}
-        </td>
-       </tr>
-
-      {else}
-
-       <tr>
-        <td {$labelStyle}>
-         {ts}Amount{/ts}
-        </td>
-        <td {$valueStyle}>
-         {$amount|crmMoney:$currency} {if $amount_level} - {$amount_level}{/if}
-        </td>
-       </tr>
-
-      {/if}
-
-
-     {/if}
-
-
-     {if $receive_date}
-      <tr>
-       <td {$labelStyle}>
-        {ts}Date{/ts}
-       </td>
-       <td {$valueStyle}>
-        {$receive_date|crmDate}
-       </td>
-      </tr>
-     {/if}
-
-     {if $is_monetary and $trxn_id}
-      <tr>
-       <td {$labelStyle}>
-        {ts}Transaction #{/ts}
-       </td>
-       <td {$valueStyle}>
-        {$trxn_id}
-       </td>
-      </tr>
-     {/if}
-
-     {if $is_recur}
-      {if $contributeMode eq 'notify' or $contributeMode eq 'directIPN'}
-       <tr>
-        <td  colspan="2" {$labelStyle}>
-         {ts 1=$cancelSubscriptionUrl}This is a recurring contribution. You can cancel future contributions by <a href="%1">visiting this web page</a>.{/ts}
-        </td>
-       <tr>
-       </tr>
-        <td colspan="2" {$labelStyle}>
-         {ts 1=$updateSubscriptionBillingUrl}You can update billing details for this recurring contribution by <a href="%1">visiting this web page</a>.{/ts}
-        </td>
-       <tr>
-       </tr>
-        <td colspan="2" {$labelStyle}>
-         {ts 1=$updateSubscriptionUrl}You can update recurring contribution amount or change the number of installments for this recurring contribution by <a href="%1">visiting this web page</a>.{/ts}
-        </td>
-       </tr>
-      {/if}
-     {/if}
-
-     {if $honor_block_is_active}
-      <tr>
-       <th {$headerStyle}>
-        {$honor_type}
-       </th>
-      </tr>
-      <tr>
-       <td colspan="2" {$labelStyle}>
-        {$honor_prefix} {$honor_first_name} {$honor_last_name}
-       </td>
-      </tr>
-      {if $honor_email}
-       <tr>
-        <td {$labelStyle}>
-         {ts}Honoree Email{/ts}
-        </td>
-        <td {$valueStyle}>
-         {$honor_email}
-        </td>
-       </tr>
-      {/if}
-     {/if}
-
-     {if $pcpBlock}
-      <tr>
-       <th {$headerStyle}>
-        {ts}Personal Campaign Page{/ts}
-       </th>
-      </tr>
-      <tr>
-       <td {$labelStyle}>
-        {ts}Display In Honor Roll{/ts}
-       </td>
-       <td {$valueStyle}>
-        {if $pcp_display_in_roll}{ts}Yes{/ts}{else}{ts}No{/ts}{/if}
-       </td>
-      </tr>
-      {if $pcp_roll_nickname}
-       <tr>
-        <td {$labelStyle}>
-         {ts}Nickname{/ts}
-        </td>
-        <td {$valueStyle}>
-         {$pcp_roll_nickname}
-        </td>
-       </tr>
-      {/if}
-      {if $pcp_personal_note}
-       <tr>
-        <td {$labelStyle}>
-         {ts}Personal Note{/ts}
-        </td>
-        <td {$valueStyle}>
-         {$pcp_personal_note}
-        </td>
-       </tr>
-      {/if}
-     {/if}
-
-     {if $onBehalfProfile}
-      <tr>
-       <th {$headerStyle}>
-        {$onBehalfProfile_grouptitle}
-       </th>
-      </tr>
-      {foreach from=$onBehalfProfile item=onBehalfValue key=onBehalfName}
-        <tr>
-         <td {$labelStyle}>
-          {$onBehalfName}
-         </td>
-         <td {$valueStyle}>
-          {$onBehalfValue}
-         </td>
-        </tr>
-      {/foreach}
-     {/if}
-
-     {if $isShare}
-      <tr>
-        <td colspan="2" {$valueStyle}>
-            {capture assign=contributionUrl}{crmURL p='civicrm/contribute/transact' q="reset=1&id=`$contributionPageId`" a=true fe=1 h=1}{/capture}
-            {include file="CRM/common/SocialNetwork.tpl" emailMode=true url=$contributionUrl title=$title pageURL=$contributionUrl}
-        </td>
-      </tr>
-     {/if}
-
-     {if ! ($contributeMode eq 'notify' OR $contributeMode eq 'directIPN') and $is_monetary}
-      {if $is_pay_later}
-       <tr>
-        <th {$headerStyle}>
-         {ts}Registered Email{/ts}
-        </th>
-       </tr>
-       <tr>
-        <td colspan="2" {$valueStyle}>
-         {$email}
-        </td>
-       </tr>
-      {elseif $amount GT 0}
-       <tr>
-        <th {$headerStyle}>
-         {ts}Billing Name and Address{/ts}
-        </th>
-       </tr>
-       <tr>
-        <td colspan="2" {$valueStyle}>
-         {$billingName}<br />
-         {$address|nl2br}<br />
-         {$email}
-        </td>
-       </tr>
-      {/if}
-     {/if}
-
-     {if $contributeMode eq 'direct' AND !$is_pay_later AND $amount GT 0}
-      <tr>
-       <th {$headerStyle}>
-        {ts}Credit Card Information{/ts}
-       </th>
-      </tr>
-      <tr>
-       <td colspan="2" {$valueStyle}>
-        {$credit_card_type}<br />
-        {$credit_card_number}<br />
-        {ts}Expires{/ts}: {$credit_card_exp_date|truncate:7:''|crmDate}<br />
-       </td>
-      </tr>
-     {/if}
-
-     {if $selectPremium}
-      <tr>
-       <th {$headerStyle}>
-        {ts}Premium Information{/ts}
-       </th>
-      </tr>
-      <tr>
-       <td colspan="2" {$labelStyle}>
-        {$product_name}
-       </td>
-      </tr>
-      {if $option}
-       <tr>
-        <td {$labelStyle}>
-         {ts}Option{/ts}
-        </td>
-        <td {$valueStyle}>
-         {$option}
-        </td>
-       </tr>
-      {/if}
-      {if $sku}
-       <tr>
-        <td {$labelStyle}>
-         {ts}SKU{/ts}
-        </td>
-        <td {$valueStyle}>
-         {$sku}
-        </td>
-       </tr>
-      {/if}
-      {if $start_date}
-       <tr>
-        <td {$labelStyle}>
-         {ts}Start Date{/ts}
-        </td>
-        <td {$valueStyle}>
-         {$start_date|crmDate}
-        </td>
-       </tr>
-      {/if}
-      {if $end_date}
-       <tr>
-        <td {$labelStyle}>
-         {ts}End Date{/ts}
-        </td>
-        <td {$valueStyle}>
-         {$end_date|crmDate}
-        </td>
-       </tr>
-      {/if}
-      {if $contact_email OR $contact_phone}
-       <tr>
-        <td colspan="2" {$valueStyle}>
-         <p>{ts}For information about this premium, contact:{/ts}</p>
-         {if $contact_email}
-          <p>{$contact_email}</p>
-         {/if}
-         {if $contact_phone}
-          <p>{$contact_phone}</p>
-         {/if}
-        </td>
-       </tr>
-      {/if}
-      {if $is_deductible AND $price}
-        <tr>
-         <td colspan="2" {$valueStyle}>
-          <p>{ts 1=$price|crmMoney:$currency}The value of this premium is %1. This may affect the amount of the tax deduction you can claim. Consult your tax advisor for more information.{/ts}</p>
-         </td>
-        </tr>
-      {/if}
-     {/if}
-
-     {if $customPre}
-      <tr>
-       <th {$headerStyle}>
-        {$customPre_grouptitle}
-       </th>
-      </tr>
-      {foreach from=$customPre item=customValue key=customName}
-       {if ($trackingFields and ! in_array($customName, $trackingFields)) or ! $trackingFields}
-        <tr>
-         <td {$labelStyle}>
-          {$customName}
-         </td>
-         <td {$valueStyle}>
-          {$customValue}
-         </td>
-        </tr>
-       {/if}
-      {/foreach}
-     {/if}
-
-     {if $customPost}
-      <tr>
-       <th {$headerStyle}>
-        {$customPost_grouptitle}
-       </th>
-      </tr>
-      {foreach from=$customPost item=customValue key=customName}
-       {if ($trackingFields and ! in_array($customName, $trackingFields)) or ! $trackingFields}
-        <tr>
-         <td {$labelStyle}>
-          {$customName}
-         </td>
-         <td {$valueStyle}>
-          {$customValue}
-         </td>
-        </tr>
-       {/if}
-      {/foreach}
-     {/if}
-
-  </table>
-</center>
-
-</body>
-</html>
diff --git a/CRM/Upgrade/4.2.alpha1.msg_template/message_templates/contribution_online_receipt_text.tpl b/CRM/Upgrade/4.2.alpha1.msg_template/message_templates/contribution_online_receipt_text.tpl
deleted file mode 100644 (file)
index 27463ee..0000000
+++ /dev/null
@@ -1,179 +0,0 @@
-{if $receipt_text}
-{$receipt_text}
-{/if}
-{if $is_pay_later}
-
-===========================================================
-{$pay_later_receipt}
-===========================================================
-{else}
-
-{ts}Please print this receipt for your records.{/ts}
-{/if}
-
-{if $amount}
-===========================================================
-{ts}Contribution Information{/ts}
-
-===========================================================
-{if $lineItem and $priceSetID}
-{foreach from=$lineItem item=value key=priceset}
----------------------------------------------------------
-{capture assign=ts_item}{ts}Item{/ts}{/capture}
-{capture assign=ts_qty}{ts}Qty{/ts}{/capture}
-{capture assign=ts_each}{ts}Each{/ts}{/capture}
-{capture assign=ts_total}{ts}Total{/ts}{/capture}
-{$ts_item|string_format:"%-30s"} {$ts_qty|string_format:"%5s"} {$ts_each|string_format:"%10s"} {$ts_total|string_format:"%10s"}
-----------------------------------------------------------
-{foreach from=$value item=line}
-{capture assign=ts_item}{if $line.html_type eq 'Text'}{$line.label}{else}{$line.field_title} - {$line.label}{/if} {if $line.description} {$line.description}{/if}{/capture}{$ts_item|truncate:30:"..."|string_format:"%-30s"} {$line.qty|string_format:"%5s"} {$line.unit_price|crmMoney:$currency|string_format:"%10s"} {$line.line_total|crmMoney:$currency|string_format:"%10s"}
-{/foreach}
-{/foreach}
-
-{ts}Total Amount{/ts}: {$amount|crmMoney:$currency}
-{else}
-{ts}Amount{/ts}: {$amount|crmMoney:$currency} {if $amount_level } - {$amount_level} {/if}
-{/if}
-{/if}
-{if $receive_date}
-
-{ts}Date{/ts}: {$receive_date|crmDate}
-{/if}
-{if $is_monetary and $trxn_id}
-{ts}Transaction #{/ts}: {$trxn_id}
-{/if}
-
-{if $is_recur and ($contributeMode eq 'notify' or $contributeMode eq 'directIPN')}
-{ts}This is a recurring contribution. You can cancel future contributions at:{/ts}
-
-{$cancelSubscriptionUrl}
-
-{ts}You can update billing details for this recurring contribution at:{/ts}
-
-{$updateSubscriptionBillingUrl}
-
-{ts}You can update recurring contribution amount or change the number of installments for this recurring contribution at:{/ts}
-
-{$updateSubscriptionUrl}
-
-{/if}
-
-{if $honor_block_is_active }
-===========================================================
-{$honor_type}
-===========================================================
-{$honor_prefix} {$honor_first_name} {$honor_last_name}
-{if $honor_email}
-{ts}Honoree Email{/ts}: {$honor_email}
-{/if}
-
-{/if}
-{if $pcpBlock}
-===========================================================
-{ts}Personal Campaign Page{/ts}
-
-===========================================================
-{ts}Display In Honor Roll{/ts}: {if $pcp_display_in_roll}{ts}Yes{/ts}{else}{ts}No{/ts}{/if}
-
-{if $pcp_roll_nickname}{ts}Nickname{/ts}: {$pcp_roll_nickname}{/if}
-
-{if $pcp_personal_note}{ts}Personal Note{/ts}: {$pcp_personal_note}{/if}
-
-{/if}
-{if $onBehalfProfile}
-===========================================================
-{ts}On Behalf Of{/ts}
-
-===========================================================
-{foreach from=$onBehalfProfile item=onBehalfValue key=onBehalfName}
-{$onBehalfName}: {$onBehalfValue}
-{/foreach}
-{/if}
-
-{if !( $contributeMode eq 'notify' OR $contributeMode eq 'directIPN' ) and $is_monetary}
-{if $is_pay_later}
-===========================================================
-{ts}Registered Email{/ts}
-
-===========================================================
-{$email}
-{elseif $amount GT 0}
-===========================================================
-{ts}Billing Name and Address{/ts}
-
-===========================================================
-{$billingName}
-{$address}
-
-{$email}
-{/if} {* End ! is_pay_later condition. *}
-{/if}
-{if $contributeMode eq 'direct' AND !$is_pay_later AND $amount GT 0}
-
-===========================================================
-{ts}Credit Card Information{/ts}
-
-===========================================================
-{$credit_card_type}
-{$credit_card_number}
-{ts}Expires{/ts}: {$credit_card_exp_date|truncate:7:''|crmDate}
-{/if}
-
-{if $selectPremium }
-===========================================================
-{ts}Premium Information{/ts}
-
-===========================================================
-{$product_name}
-{if $option}
-{ts}Option{/ts}: {$option}
-{/if}
-{if $sku}
-{ts}SKU{/ts}: {$sku}
-{/if}
-{if $start_date}
-{ts}Start Date{/ts}: {$start_date|crmDate}
-{/if}
-{if $end_date}
-{ts}End Date{/ts}: {$end_date|crmDate}
-{/if}
-{if $contact_email OR $contact_phone}
-
-{ts}For information about this premium, contact:{/ts}
-
-{if $contact_email}
-  {$contact_email}
-{/if}
-{if $contact_phone}
-  {$contact_phone}
-{/if}
-{/if}
-{if $is_deductible AND $price}
-
-{ts 1=$price|crmMoney:$currency}The value of this premium is %1. This may affect the amount of the tax deduction you can claim. Consult your tax advisor for more information.{/ts}{/if}
-{/if}
-
-{if $customPre}
-===========================================================
-{$customPre_grouptitle}
-
-===========================================================
-{foreach from=$customPre item=customValue key=customName}
-{if ( $trackingFields and ! in_array( $customName, $trackingFields ) ) or ! $trackingFields}
- {$customName}: {$customValue}
-{/if}
-{/foreach}
-{/if}
-
-
-{if $customPost}
-===========================================================
-{$customPost_grouptitle}
-
-===========================================================
-{foreach from=$customPost item=customValue key=customName}
-{if ( $trackingFields and ! in_array( $customName, $trackingFields ) ) or ! $trackingFields}
- {$customName}: {$customValue}
-{/if}
-{/foreach}
-{/if}
diff --git a/CRM/Upgrade/4.2.alpha1.msg_template/message_templates/contribution_recurring_billing_html.tpl b/CRM/Upgrade/4.2.alpha1.msg_template/message_templates/contribution_recurring_billing_html.tpl
deleted file mode 100644 (file)
index f2b9d48..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <title></title>
-</head>
-<body>
-
-{capture assign=headerStyle}colspan="2" style="text-align: left; padding: 4px; border-bottom: 1px solid #999; background-color: #eee;"{/capture}
-{capture assign=labelStyle }style="padding: 4px; border-bottom: 1px solid #999; background-color: #f7f7f7;"{/capture}
-{capture assign=valueStyle }style="padding: 4px; border-bottom: 1px solid #999;"{/capture}
-
-<center>
- <table width="620" border="0" cellpadding="0" cellspacing="0" id="crm-event_receipt" style="font-family: Arial, Verdana, sans-serif; text-align: left;">
-
-  <!-- BEGIN HEADER -->
-  <!-- You can add table row(s) here with logo or other header elements -->
-  <!-- END HEADER -->
-
-  <!-- BEGIN CONTENT -->
-
-  <tr>
-   <td>
-    <p>{ts 1=$contact.display_name}Dear %1{/ts},</p>
-    <p>{ts 1=$amount 2=$recur_frequency_interval 3=$recur_frequency_unit}Billing details for your recurring contribution of %1, every %2 %3 have been updated.{/ts}</p>
-   </td>
-  </tr>
-  <tr>
- </table>
-
-  <table width="500" style="border: 1px solid #999; margin: 1em 0em 1em; border-collapse: collapse;">
-<tr>
-        <th {$headerStyle}>
-         {ts}Billing Name and Address{/ts}
-        </th>
-       </tr>
-       <tr>
-        <td colspan="2" {$valueStyle}>
-         {$billingName}<br />
-         {$address|nl2br}<br />
-         {$email}
-        </td>
-       </tr>
-        <tr>
-       <th {$headerStyle}>
-        {ts}Credit Card Information{/ts}
-       </th>
-      </tr>
-      <tr>
-       <td colspan="2" {$valueStyle}>
-        {$credit_card_type}<br />
-        {$credit_card_number}<br />
-        {ts}Expires{/ts}: {$credit_card_exp_date|truncate:7:''|crmDate}<br />
-       </td>
-      </tr>
-      <tr>
-        <td {$labelStyle}>
-            {ts 1=$receipt_from_email}If you have questions please contact us at %1{/ts}
-        </td>
-       </tr>
-  </table>
-</center>
-
-</body>
-</html>
\ No newline at end of file
diff --git a/CRM/Upgrade/4.2.alpha1.msg_template/message_templates/contribution_recurring_billing_subject.tpl b/CRM/Upgrade/4.2.alpha1.msg_template/message_templates/contribution_recurring_billing_subject.tpl
deleted file mode 100644 (file)
index 32f2c0f..0000000
+++ /dev/null
@@ -1 +0,0 @@
-{ts}Recurring Contribution Updates{/ts}
\ No newline at end of file
diff --git a/CRM/Upgrade/4.2.alpha1.msg_template/message_templates/contribution_recurring_billing_text.tpl b/CRM/Upgrade/4.2.alpha1.msg_template/message_templates/contribution_recurring_billing_text.tpl
deleted file mode 100644 (file)
index 37e7ed7..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-{ts 1=$contact.display_name}Dear %1{/ts},
-
-{ts 1=$amount 2=$recur_frequency_interval 3=$recur_frequency_unit}Billing details for your recurring contribution of %1, every %2 %3 have been updated.{/ts}
-
-===========================================================
-{ts}Billing Name and Address{/ts}
-
-===========================================================
-{$billingName}
-{$address}
-
-{$email}
-
-===========================================================
-{ts}Credit Card Information{/ts}
-
-===========================================================
-{$credit_card_type}
-{$credit_card_number}
-{ts}Expires{/ts}: {$credit_card_exp_date|truncate:7:''|crmDate}
-
-
-{ts 1=$receipt_from_email}If you have questions please contact us at %1{/ts}
\ No newline at end of file
diff --git a/CRM/Upgrade/4.2.alpha1.msg_template/message_templates/contribution_recurring_cancelled_html.tpl b/CRM/Upgrade/4.2.alpha1.msg_template/message_templates/contribution_recurring_cancelled_html.tpl
deleted file mode 100644 (file)
index 606ecda..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <title></title>
-</head>
-<body>
-
-{capture assign=headerStyle}colspan="2" style="text-align: left; padding: 4px; border-bottom: 1px solid #999; background-color: #eee;"{/capture}
-{capture assign=labelStyle }style="padding: 4px; border-bottom: 1px solid #999; background-color: #f7f7f7;"{/capture}
-{capture assign=valueStyle }style="padding: 4px; border-bottom: 1px solid #999;"{/capture}
-
-<center>
- <table width="620" border="0" cellpadding="0" cellspacing="0" id="crm-event_receipt" style="font-family: Arial, Verdana, sans-serif; text-align: left;">
-
-  <!-- BEGIN HEADER -->
-  <!-- You can add table row(s) here with logo or other header elements -->
-  <!-- END HEADER -->
-
-  <!-- BEGIN CONTENT -->
-
-  <tr>
-   <td>
-    <p>{ts 1=$contact.display_name}Dear %1{/ts},</p>
-    <p>{ts 1=$amount 2=$recur_frequency_interval 3=$recur_frequency_unit}Your recurring contribution of %1, every %2 %3 has been cancelled.{/ts}</p>
-   </td>
-  </tr>
-  <tr>
- </table>
-</center>
-
-</body>
-</html>
diff --git a/CRM/Upgrade/4.2.alpha1.msg_template/message_templates/contribution_recurring_cancelled_subject.tpl b/CRM/Upgrade/4.2.alpha1.msg_template/message_templates/contribution_recurring_cancelled_subject.tpl
deleted file mode 100644 (file)
index d389480..0000000
+++ /dev/null
@@ -1 +0,0 @@
-{ts}Recurring Contribution Cancellation Notification{/ts}
diff --git a/CRM/Upgrade/4.2.alpha1.msg_template/message_templates/contribution_recurring_cancelled_text.tpl b/CRM/Upgrade/4.2.alpha1.msg_template/message_templates/contribution_recurring_cancelled_text.tpl
deleted file mode 100644 (file)
index e964799..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-{ts 1=$contact.display_name}Dear %1{/ts},
-
-{ts 1=$amount 2=$recur_frequency_interval 3=$recur_frequency_unit}Your recurring contribution of %1, every %2 %3 has been cancelled.{/ts}
diff --git a/CRM/Upgrade/4.2.alpha1.msg_template/message_templates/contribution_recurring_edit_html.tpl b/CRM/Upgrade/4.2.alpha1.msg_template/message_templates/contribution_recurring_edit_html.tpl
deleted file mode 100644 (file)
index 7c894be..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <title></title>
-</head>
-<body>
-
-{capture assign=headerStyle}colspan="2" style="text-align: left; padding: 4px; border-bottom: 1px solid #999; background-color: #eee;"{/capture}
-{capture assign=labelStyle }style="padding: 4px; border-bottom: 1px solid #999; background-color: #f7f7f7;"{/capture}
-{capture assign=valueStyle }style="padding: 4px; border-bottom: 1px solid #999;"{/capture}
-
-<center>
- <table width="620" border="0" cellpadding="0" cellspacing="0" id="crm-event_receipt" style="font-family: Arial, Verdana, sans-serif; text-align: left;">
-
-  <!-- BEGIN HEADER -->
-  <!-- You can add table row(s) here with logo or other header elements -->
-  <!-- END HEADER -->
-
-  <!-- BEGIN CONTENT -->
-
-  <tr>
-   <td>
-    <p>{ts 1=$contact.display_name}Dear %1{/ts},</p>
-    <p>{ts 1=$amount 2=$recur_frequency_interval 3=$recur_frequency_unit}Recurring contribution is for %1, every %2(s) %3{/ts}</p>
-    <p>{if $installments}{ts 1=$installments} for %1 installments.{/ts}{/if}</p>
-
-    <p>{ts 1=$receipt_from_email}If you have questions please contact us at %1.{/ts}</p>
-   </td>
-  </tr>
-  <tr>
- </table>
-</center>
-
-</body>
-</html>
diff --git a/CRM/Upgrade/4.2.alpha1.msg_template/message_templates/contribution_recurring_edit_subject.tpl b/CRM/Upgrade/4.2.alpha1.msg_template/message_templates/contribution_recurring_edit_subject.tpl
deleted file mode 100644 (file)
index d4a5da1..0000000
+++ /dev/null
@@ -1 +0,0 @@
-{ts}Recurring Contribution Update Notification{/ts}
\ No newline at end of file
diff --git a/CRM/Upgrade/4.2.alpha1.msg_template/message_templates/contribution_recurring_edit_text.tpl b/CRM/Upgrade/4.2.alpha1.msg_template/message_templates/contribution_recurring_edit_text.tpl
deleted file mode 100644 (file)
index 423b00c..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-{ts 1=$contact.display_name}Dear %1{/ts},
-
-{ts}Your recurring contribution has been updated as requested:{/ts}
-
-{ts 1=$amount 2=$recur_frequency_interval 3=$recur_frequency_unit}Recurring contribution is for %1, every %2(s) %3{/ts}
-{if $installments}{ts 1=$installments} for %1 installments.{/ts}{/if}
-
-{ts 1=$receipt_from_email}If you have questions please contact us at %1.{/ts}
\ No newline at end of file
diff --git a/CRM/Upgrade/4.2.alpha1.msg_template/message_templates/contribution_recurring_notify_html.tpl b/CRM/Upgrade/4.2.alpha1.msg_template/message_templates/contribution_recurring_notify_html.tpl
deleted file mode 100644 (file)
index 3a6b18b..0000000
+++ /dev/null
@@ -1,125 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <title></title>
-</head>
-<body>
-
-{capture assign=headerStyle}colspan="2" style="text-align: left; padding: 4px; border-bottom: 1px solid #999; background-color: #eee;"{/capture}
-{capture assign=labelStyle }style="padding: 4px; border-bottom: 1px solid #999; background-color: #f7f7f7;"{/capture}
-{capture assign=valueStyle }style="padding: 4px; border-bottom: 1px solid #999;"{/capture}
-
-<center>
- <table width="620" border="0" cellpadding="0" cellspacing="0" id="crm-event_receipt" style="font-family: Arial, Verdana, sans-serif; text-align: left;">
-
-  <!-- BEGIN HEADER -->
-  <!-- You can add table row(s) here with logo or other header elements -->
-  <!-- END HEADER -->
-
-  <!-- BEGIN CONTENT -->
-
-  <tr>
-   <td>
-    <p>{ts 1=$displayName}Dear %1{/ts},</p>
-   </td>
-  </tr>
-
-  <tr>
-   <td>&nbsp;</td>
-  </tr>
-
-    {if $recur_txnType eq 'START'}
-     {if $auto_renew_membership}
-       <tr>
-        <td>
-         <p>{ts}Thanks for your auto renew membership sign-up.{/ts}</p>
-         <p>{ts 1=$recur_frequency_interval 2=$recur_frequency_unit}This membership will be automatically renewed every %1 %2(s). {/ts}</p>
-        </td>
-       </tr>
-       <tr>
-        <td {$labelStyle}>
-         {ts 1=$cancelSubscriptionUrl}This membership will be renewed automatically. You can cancel the auto-renewal option by <a href="%1">visiting this web page</a>.{/ts}
-        </td>
-       </tr>
-       <tr>
-        <td {$labelStyle}>
-         {ts 1=$updateSubscriptionBillingUrl}You can update billing details for this automatically renewed membership by <a href="%1">visiting this web page</a>.{/ts}
-        </td>
-       </tr>
-     {else}
-      <tr>
-       <td>
-        <p>{ts}Thanks for your recurring contribution sign-up.{/ts}</p>
-        <p>{ts 1=$recur_frequency_interval 2=$recur_frequency_unit 3=$recur_installments}This recurring contribution will be automatically processed every %1 %2(s) for a total of %3 installment(s).{/ts}</p>
-        <p>{ts}Start Date{/ts}: {$recur_start_date|crmDate}</p>
-       </td>
-      </tr>
-      <tr>
-        <td {$labelStyle}>
-         {ts 1=$cancelSubscriptionUrl} You can cancel the recurring contribution option by <a href="%1">visiting this web page</a>.{/ts}
-        </td>
-      </tr>
-      <tr>
-        <td {$labelStyle}>
-         {ts 1=$updateSubscriptionBillingUrl}You can update billing details for this recurring contribution by <a href="%1">visiting this web page</a>.{/ts}
-        </td>
-       </tr>
-       <tr>
-        <td {$labelStyle}>
-   {ts 1=$updateSubscriptionUrl}You can update recurring contribution amount or change the number of installments details for this recurring contribution by <a href="%1">visiting this web page</a>.{/ts}
-        </td>
-       </tr>
-     {/if}
-
-    {elseif $recur_txnType eq 'END'}
-
-     {if $auto_renew_membership}
-      <tr>
-       <td>
-        <p>{ts}Your auto renew membership sign-up has ended and your membership will not be automatically renewed.{/ts}</p>
-       </td>
-      </tr>
-     {else}
-      <tr>
-       <td>
-        <p>{ts}Your recurring contribution term has ended.{/ts}</p>
-        <p>{ts 1=$recur_installments}You have successfully completed %1 recurring contributions. Thank you for your support.{/ts}</p>
-       </td>
-      </tr>
-      <tr>
-       <td>
-     <table style="border: 1px solid #999; margin: 1em 0em 1em; border-collapse: collapse; width:100%;">
-      <tr>
-       <th {$headerStyle}>
-        {ts 1=$recur_installments}Interval of Subscription for %1 installment(s){/ts}
-       </th>
-      </tr>
-      <tr>
-       <td {$labelStyle}>
-        {ts}Start Date{/ts}
-       </td>
-       <td {$valueStyle}>
-        {$recur_start_date|crmDate}
-       </td>
-      </tr>
-      <tr>
-       <td {$labelStyle}>
-        {ts}End Date{/ts}
-       </td>
-       <td {$valueStyle}>
-        {$recur_end_date|crmDate}
-       </td>
-      </tr>
-     </table>
-       </td>
-      </tr>
-
-     {/if}
-    {/if}
-
- </table>
-</center>
-
-</body>
-</html>
diff --git a/CRM/Upgrade/4.2.alpha1.msg_template/message_templates/contribution_recurring_notify_text.tpl b/CRM/Upgrade/4.2.alpha1.msg_template/message_templates/contribution_recurring_notify_text.tpl
deleted file mode 100644 (file)
index 5f54ca1..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-{ts 1=$displayName}Dear %1{/ts},
-
-{if $recur_txnType eq 'START'}
-{if $auto_renew_membership}
-{ts}Thanks for your auto renew membership sign-up.{/ts}
-
-
-{ts 1=$recur_frequency_interval 2=$recur_frequency_unit}This membership will be automatically renewed every %1 %2(s).{/ts}
-
-{ts 1=$cancelSubscriptionUrl}This membership will be renewed automatically. You can cancel the auto-renewal option by <a href="%1">visiting this web page</a>.{/ts}
-
-{ts 1=$updateSubscriptionBillingUrl}You can update billing details for this automatically renewed membership by <a href="%1">visiting this web page</a>.{/ts}
-
-{else}
-{ts}Thanks for your recurring contribution sign-up.{/ts}
-
-
-{ts 1=$recur_frequency_interval 2=$recur_frequency_unit 3=$recur_installments}This recurring contribution will be automatically processed every %1 %2(s) for a total of %3 installment(s).{/ts}
-
-{ts}Start Date{/ts}:  {$recur_start_date|crmDate}
-
-{ts 1=$cancelSubscriptionUrl}You can cancel the recurring contribution option by <a href="%1">visiting this web page</a>.{/ts}
-
-{ts 1=$updateSubscriptionBillingUrl}You can update billing details for this recurring contribution by <a href="%1">visiting this web page</a>.{/ts}
-
-{ts 1=$updateSubscriptionUrl}You can update recurring contribution amount or change the number of installments for this recurring contribution by <a href="%1">visiting this web page</a>.{/ts}
-{/if}
-
-{elseif $recur_txnType eq 'END'}
-{if $auto_renew_membership}
-{ts}Your auto renew membership sign-up has ended and your membership will not be automatically renewed.{/ts}
-
-
-{else}
-{ts}Your recurring contribution term has ended.{/ts}
-
-
-{ts 1=$recur_installments}You have successfully completed %1 recurring contributions. Thank you for your support.{/ts}
-
-
-==================================================
-{ts 1=$recur_installments}Interval of Subscription for %1 installment(s){/ts}
-
-==================================================
-{ts}Start Date{/ts}: {$recur_start_date|crmDate}
-
-{ts}End Date{/ts}: {$recur_end_date|crmDate}
-
-{/if}
-{/if}
diff --git a/CRM/Upgrade/4.2.alpha1.msg_template/message_templates/event_online_receipt_html.tpl b/CRM/Upgrade/4.2.alpha1.msg_template/message_templates/event_online_receipt_html.tpl
deleted file mode 100644 (file)
index 2ee5f29..0000000
+++ /dev/null
@@ -1,447 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <title></title>
-</head>
-<body>
-
-{capture assign=headerStyle}colspan="2" style="text-align: left; padding: 4px; border-bottom: 1px solid #999; background-color: #eee;"{/capture}
-{capture assign=labelStyle }style="padding: 4px; border-bottom: 1px solid #999; background-color: #f7f7f7;"{/capture}
-{capture assign=valueStyle }style="padding: 4px; border-bottom: 1px solid #999;"{/capture}
-
-<center>
- <table width="500" border="0" cellpadding="0" cellspacing="0" id="crm-event_receipt" style="font-family: Arial, Verdana, sans-serif; text-align: left;">
-
-  <!-- BEGIN HEADER -->
-  <!-- You can add table row(s) here with logo or other header elements -->
-  <!-- END HEADER -->
-
-  <!-- BEGIN CONTENT -->
-
-  <tr>
-   <td>
-  <p>Dear {contact.display_name},</p>
-
-    {if $event.confirm_email_text AND (not $isOnWaitlist AND not $isRequireApproval)}
-     <p>{$event.confirm_email_text|htmlize}</p>
-
-    {else}
-  <p>Thank you for your participation.  This letter is a confirmation that your registration has been received and your status has been updated to <strong>{if $isOnWaitlist}waitlisted{else}registered{/if}</strong> for the following:</p>
-
-    {/if}
-
-    <p>
-    {if $isOnWaitlist}
-     <p>{ts}You have been added to the WAIT LIST for this event.{/ts}</p>
-     {if $isPrimary}
-       <p>{ts}If space becomes available you will receive an email with a link to a web page where you can complete your registration.{/ts}</p>
-     {/if}
-    {elseif $isRequireApproval}
-     <p>{ts}Your registration has been submitted.{/ts}</p>
-     {if $isPrimary}
-      <p>{ts}Once your registration has been reviewed, you will receive an email with a link to a web page where you can complete the registration process.{/ts}</p>
-     {/if}
-    {elseif $is_pay_later && !$isAmountzero}
-     <p>{$pay_later_receipt}</p> {* FIXME: this might be text rather than HTML *}
-    {else}
-     <p>{ts}Please print this confirmation for your records.{/ts}</p>
-    {/if}
-
-   </td>
-  </tr>
-  <tr>
-   <td>
-    <table width="500" style="border: 1px solid #999; margin: 1em 0em 1em; border-collapse: collapse;">
-     <tr>
-      <th {$headerStyle}>
-       {ts}Event Information and Location{/ts}
-      </th>
-     </tr>
-     <tr>
-      <td colspan="2" {$valueStyle}>
-       {$event.event_title}<br />
-       {$event.event_start_date|date_format:"%A"} {$event.event_start_date|crmDate}{if $event.event_end_date}-{if $event.event_end_date|date_format:"%Y%m%d" == $event.event_start_date|date_format:"%Y%m%d"}{$event.event_end_date|crmDate:0:1}{else}{$event.event_end_date|date_format:"%A"} {$event.event_end_date|crmDate}{/if}{/if}
-      </td>
-     </tr>
-
-
-     {if $conference_sessions}
-      <tr>
-       <td colspan="2" {$labelStyle}>
-  {ts}Your schedule:{/ts}
-       </td>
-      </tr>
-      <tr>
-       <td colspan="2" {$valueStyle}>
-  {assign var='group_by_day' value='NA'}
-  {foreach from=$conference_sessions item=session}
-   {if $session.start_date|date_format:"%Y/%m/%d" != $group_by_day|date_format:"%Y/%m/%d"}
-    {assign var='group_by_day' value=$session.start_date}
-          <em>{$group_by_day|date_format:"%m/%d/%Y"}</em><br />
-   {/if}
-   {$session.start_date|crmDate:0:1}{if $session.end_date}-{$session.end_date|crmDate:0:1}{/if} {$session.title}<br />
-   {if $session.location}&nbsp;&nbsp;&nbsp;&nbsp;{$session.location}<br />{/if}
-  {/foreach}
-       </td>
-      </tr>
-     {/if}
-
-     {if $event.participant_role neq 'Attendee' and $defaultRole}
-      <tr>
-       <td {$labelStyle}>
-        {ts}Participant Role{/ts}
-       </td>
-       <td {$valueStyle}>
-        {$event.participant_role}
-       </td>
-      </tr>
-     {/if}
-
-     {if $isShowLocation}
-      <tr>
-       <td colspan="2" {$valueStyle}>
-        {if $location.address.1.name}
-         {$location.address.1.name}<br />
-        {/if}
-        {if $location.address.1.street_address}
-         {$location.address.1.street_address}<br />
-        {/if}
-        {if $location.address.1.supplemental_address_1}
-         {$location.address.1.supplemental_address_1}<br />
-        {/if}
-        {if $location.address.1.supplemental_address_2}
-         {$location.address.1.supplemental_address_2}<br />
-        {/if}
-        {if $location.address.1.city}
-         {$location.address.1.city}, {$location.address.1.state_province} {$location.address.1.postal_code}{if $location.address.1.postal_code_suffix} - {$location.address.1.postal_code_suffix}{/if}<br />
-        {/if}
-       </td>
-      </tr>
-     {/if}
-
-     {if $location.phone.1.phone || $location.email.1.email}
-      <tr>
-       <td colspan="2" {$labelStyle}>
-        {ts}Event Contacts:{/ts}
-       </td>
-      </tr>
-      {foreach from=$location.phone item=phone}
-       {if $phone.phone}
-        <tr>
-         <td {$labelStyle}>
-          {if $phone.phone_type}
-           {$phone.phone_type_display}
-          {else}
-           {ts}Phone{/ts}
-          {/if}
-         </td>
-         <td {$valueStyle}>
-          {$phone.phone}
-         </td>
-        </tr>
-       {/if}
-      {/foreach}
-      {foreach from=$location.email item=eventEmail}
-       {if $eventEmail.email}
-        <tr>
-         <td {$labelStyle}>
-          {ts}Email{/ts}
-         </td>
-         <td {$valueStyle}>
-          {$eventEmail.email}
-         </td>
-        </tr>
-       {/if}
-      {/foreach}
-     {/if}
-     <tr>
-      <td colspan="2" {$valueStyle}>
-       {capture assign=icalFeed}{crmURL p='civicrm/event/ical' q="reset=1&id=`$event.id`" h=0 a=1 fe=1}{/capture}
-       <a href="{$icalFeed}">{ts}Download iCalendar File{/ts}</a>
-      </td>
-     </tr>
-    {if $event.is_share}
-        <tr>
-            <td colspan="2" {$valueStyle}>
-                {capture assign=eventUrl}{crmURL p='civicrm/event/info' q="id=`$event.id`&reset=1" a=true fe=1 h=1}{/capture}
-                {include file="CRM/common/SocialNetwork.tpl" emailMode=true url=$eventUrl title=$event.title pageURL=$eventUrl}
-            </td>
-        </tr>
-    {/if}
-    {if $payer.name}
-     <tr>
-       <th {$headerStyle}>
-         {ts}You were registered by:{/ts}
-       </th>
-     </tr>
-     <tr>
-       <td colspan="2" {$valueStyle}>
-        {$payer.name}
-       </td>
-     </tr>
-    {/if}
-    {if $event.is_monetary}
-
-      <tr>
-       <th {$headerStyle}>
-        {$event.fee_label}
-       </th>
-      </tr>
-
-      {if $lineItem}
-       {foreach from=$lineItem item=value key=priceset}
-        {if $value neq 'skip'}
-         {if $isPrimary}
-          {if $lineItem|@count GT 1} {* Header for multi participant registration cases. *}
-           <tr>
-            <td colspan="2" {$labelStyle}>
-             {ts 1=$priceset+1}Participant %1{/ts} {$part.$priceset.info}
-            </td>
-           </tr>
-          {/if}
-         {/if}
-         <tr>
-          <td colspan="2" {$valueStyle}>
-           <table> {* FIXME: style this table so that it looks like the text version (justification, etc.) *}
-            <tr>
-             <th>{ts}Item{/ts}</th>
-             <th>{ts}Qty{/ts}</th>
-             <th>{ts}Each{/ts}</th>
-             <th>{ts}Total{/ts}</th>
-       {if  $pricesetFieldsCount }<th>{ts}Total Participants{/ts}</th>{/if}
-            </tr>
-            {foreach from=$value item=line}
-             <tr>
-              <td>
-              {if $line.html_type eq 'Text'}{$line.label}{else}{$line.field_title} - {$line.label}{/if} {if $line.description}<div>{$line.description|truncate:30:"..."}</div>{/if}
-              </td>
-              <td>
-               {$line.qty}
-              </td>
-              <td>
-               {$line.unit_price|crmMoney}
-              </td>
-              <td>
-               {$line.line_total|crmMoney}
-              </td>
-        {if $pricesetFieldsCount }<td>{$line.participant_count}</td> {/if}
-             </tr>
-            {/foreach}
-           </table>
-          </td>
-         </tr>
-        {/if}
-       {/foreach}
-      {/if}
-
-
-      {if $isPrimary}
-       <tr>
-        <td {$labelStyle}>
-         {ts}Total Amount{/ts}
-        </td>
-        <td {$valueStyle}>
-         {$totalAmount|crmMoney} {if $hookDiscount.message}({$hookDiscount.message}){/if}
-        </td>
-       </tr>
-       {if $pricesetFieldsCount }
-     <tr>
-       <td {$labelStyle}>
-      {ts}Total Participants{/ts}</td>
-      <td {$valueStyle}>
-      {assign var="count" value= 0}
-      {foreach from=$lineItem item=pcount}
-      {assign var="lineItemCount" value=0}
-      {if $pcount neq 'skip'}
-        {foreach from=$pcount item=p_count}
-        {assign var="lineItemCount" value=$lineItemCount+$p_count.participant_count}
-        {/foreach}
-      {if $lineItemCount < 1 }
-        {assign var="lineItemCount" value=1}
-      {/if}
-      {assign var="count" value=$count+$lineItemCount}
-      {/if}
-      {/foreach}
-     {$count}
-     </td> </tr>
-      {/if}
-       {if $is_pay_later}
-        <tr>
-         <td colspan="2" {$labelStyle}>
-          {$pay_later_receipt}
-         </td>
-        </tr>
-       {/if}
-
-       {if $register_date}
-        <tr>
-         <td {$labelStyle}>
-          {ts}Registration Date{/ts}
-         </td>
-         <td {$valueStyle}>
-          {$register_date|crmDate}
-         </td>
-        </tr>
-       {/if}
-
-       {if $receive_date}
-        <tr>
-         <td {$labelStyle}>
-          {ts}Transaction Date{/ts}
-         </td>
-         <td {$valueStyle}>
-          {$receive_date|crmDate}
-         </td>
-        </tr>
-       {/if}
-
-       {if $contributionTypeName}
-        <tr>
-         <td {$labelStyle}>
-          {ts}Contribution Type{/ts}
-         </td>
-         <td {$valueStyle}>
-          {$contributionTypeName}
-         </td>
-        </tr>
-       {/if}
-
-       {if $trxn_id}
-        <tr>
-         <td {$labelStyle}>
-          {ts}Transaction #{/ts}
-         </td>
-         <td {$valueStyle}>
-          {$trxn_id}
-         </td>
-        </tr>
-       {/if}
-
-       {if $paidBy}
-        <tr>
-         <td {$labelStyle}>
-          {ts}Paid By{/ts}
-         </td>
-         <td {$valueStyle}>
-         {$paidBy}
-         </td>
-        </tr>
-       {/if}
-
-       {if $checkNumber}
-        <tr>
-         <td {$labelStyle}>
-          {ts}Check Number{/ts}
-         </td>
-         <td {$valueStyle}>
-          {$checkNumber}
-         </td>
-        </tr>
-       {/if}
-
-       {if $contributeMode ne 'notify' and !$isAmountzero and !$is_pay_later and !$isOnWaitlist and !$isRequireApproval}
-        <tr>
-         <th {$headerStyle}>
-          {ts}Billing Name and Address{/ts}
-         </th>
-        </tr>
-        <tr>
-         <td colspan="2" {$valueStyle}>
-          {$billingName}<br />
-          {$address|nl2br}
-         </td>
-        </tr>
-       {/if}
-
-       {if $contributeMode eq 'direct' and !$isAmountzero and !$is_pay_later and !$isOnWaitlist and !$isRequireApproval}
-        <tr>
-         <th {$headerStyle}>
-          {ts}Credit Card Information{/ts}
-         </th>
-        </tr>
-        <tr>
-         <td colspan="2" {$valueStyle}>
-          {$credit_card_type}<br />
-          {$credit_card_number}<br />
-          {ts}Expires{/ts}: {$credit_card_exp_date|truncate:7:''|crmDate}
-         </td>
-        </tr>
-       {/if}
-
-      {/if}
-
-     {/if} {* End of conditional section for Paid events *}
-
-
-{if $customPre}
-{foreach from=$customPre item=customPr key=i}
-   <tr> <th {$headerStyle}>{$customPre_grouptitle.$i}</th></tr>
-   {foreach from=$customPr item=customValue key=customName}
-   {if ( $trackingFields and ! in_array( $customName, $trackingFields ) ) or ! $trackingFields}
-     <tr>
-         <td {$labelStyle}>{$customName}</td>
-         <td {$valueStyle}>{$customValue}</td>
-     </tr>
-   {/if}
-   {/foreach}
-{/foreach}
-{/if}
-
-{if $customPost}
-{foreach from=$customPost item=customPos key=j}
-   <tr> <th {$headerStyle}>{$customPost_grouptitle.$j}</th></tr>
-   {foreach from=$customPos item=customValue key=customName}
-   {if ( $trackingFields and ! in_array( $customName, $trackingFields ) ) or ! $trackingFields}
-     <tr>
-         <td {$labelStyle}>{$customName}</td>
-         <td {$valueStyle}>{$customValue}</td>
-     </tr>
-{/if}
-{/foreach}
-{/foreach}
-{/if}
-
-{if $customProfile}
-{foreach from=$customProfile.profile item=eachParticipant key=participantID}
-     <tr><th {$headerStyle}>{ts 1=$participantID+2}Participant %1{/ts} </th></tr>
-     {foreach from=$eachParticipant item=eachProfile key=pid}
-     <tr><th {$headerStyle}>{$customProfile.title.$pid}</th></tr>
-     {foreach from=$eachProfile item=val key=field}
-     <tr>{foreach from=$val item=v key=f}
-         <td {$labelStyle}>{$field}</td>
-         <td {$valueStyle}>{$v}</td>
-         {/foreach}
-     </tr>
-     {/foreach}
-{/foreach}
-{/foreach}
-{/if}
-
-    {if $customGroup}
-      {foreach from=$customGroup item=value key=customName}
-       <tr>
-        <th {$headerStyle}>
-         {$customName}
-        </th>
-       </tr>
-       {foreach from=$value item=v key=n}
-        <tr>
-         <td {$labelStyle}>
-          {$n}
-         </td>
-         <td {$valueStyle}>
-          {$v}
-         </td>
-        </tr>
-       {/foreach}
-      {/foreach}
-     {/if}
-    </table>
-   </td>
-  </tr>
- </table>
-</center>
-
-</body>
-</html>
diff --git a/CRM/Upgrade/4.2.alpha1.msg_template/message_templates/event_online_receipt_text.tpl b/CRM/Upgrade/4.2.alpha1.msg_template/message_templates/event_online_receipt_text.tpl
deleted file mode 100644 (file)
index 27c3762..0000000
+++ /dev/null
@@ -1,282 +0,0 @@
-Dear {contact.display_name},
-
-{if $event.confirm_email_text AND (not $isOnWaitlist AND not $isRequireApproval)}
-{$event.confirm_email_text}
-
-{else}
-Thank you for your participation.  This letter is a confirmation that your registration has been received and your status has been updated to {if $participant_status}$participant_status{else}{if $isOnWaitlist}waitlisted{else}registered{/if}{/if} for the following:
-
-{/if}
-
-{if $isOnWaitlist}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{ts}You have been added to the WAIT LIST for this event.{/ts}
-
-{if $isPrimary}
-{ts}If space becomes available you will receive an email with a link to a web page where you can complete your registration.{/ts}
-{/if}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{elseif $isRequireApproval}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{ts}Your registration has been submitted.{/ts}
-
-{if $isPrimary}
-{ts}Once your registration has been reviewed, you will receive an email with a link to a web page where you can complete the registration process.{/ts}
-
-{/if}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{elseif $is_pay_later && !$isAmountzero}
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$pay_later_receipt}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{else}
-
-{ts}Please print this confirmation for your records.{/ts}
-{/if}
-
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{ts}Event Information and Location{/ts}
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$event.event_title}
-{$event.event_start_date|date_format:"%A"} {$event.event_start_date|crmDate}{if $event.event_end_date}-{if $event.event_end_date|date_format:"%Y%m%d" == $event.event_start_date|date_format:"%Y%m%d"}{$event.event_end_date|crmDate:0:1}{else}{$event.event_end_date|date_format:"%A"} {$event.event_end_date|crmDate}{/if}{/if}
-{if $conference_sessions}
-
-
-{ts}Your schedule:{/ts}
-{assign var='group_by_day' value='NA'}
-{foreach from=$conference_sessions item=session}
-{if $session.start_date|date_format:"%Y/%m/%d" != $group_by_day|date_format:"%Y/%m/%d"}
-{assign var='group_by_day' value=$session.start_date}
-
-{$group_by_day|date_format:"%m/%d/%Y"}
-
-
-{/if}
-{$session.start_date|crmDate:0:1}{if $session.end_date}-{$session.end_date|crmDate:0:1}{/if} {$session.title}
-{if $session.location}    {$session.location}{/if}
-{/foreach}
-{/if}
-
-{if $event.participant_role neq 'Attendee' and $defaultRole}
-{ts}Participant Role{/ts}: {$event.participant_role}
-{/if}
-
-{if $isShowLocation}
-{if $location.address.1.name}
-
-{$location.address.1.name}
-{/if}
-{if $location.address.1.street_address}{$location.address.1.street_address}
-{/if}
-{if $location.address.1.supplemental_address_1}{$location.address.1.supplemental_address_1}
-{/if}
-{if $location.address.1.supplemental_address_2}{$location.address.1.supplemental_address_2}
-{/if}
-{if $location.address.1.city}{$location.address.1.city}, {$location.address.1.state_province} {$location.address.1.postal_code}{if $location.address.1.postal_code_suffix} - {$location.address.1.postal_code_suffix}{/if}
-{/if}
-
-{/if}{*End of isShowLocation condition*}
-
-{if $location.phone.1.phone || $location.email.1.email}
-
-{ts}Event Contacts:{/ts}
-{foreach from=$location.phone item=phone}
-{if $phone.phone}
-
-{if $phone.phone_type}{$phone.phone_type_display}{else}{ts}Phone{/ts}{/if}: {$phone.phone}{/if}
-{/foreach}
-{foreach from=$location.email item=eventEmail}
-{if $eventEmail.email}
-
-{ts}Email{/ts}: {$eventEmail.email}{/if}{/foreach}
-{/if}
-
-{capture assign=icalFeed}{crmURL p='civicrm/event/ical' q="reset=1&id=`$event.id`" h=0 a=1 fe=1}{/capture}
-{ts}Download iCalendar File:{/ts} {$icalFeed}
-
-{if $payer.name}
-You were registered by: {$payer.name}
-{/if}
-{if $event.is_monetary} {* This section for Paid events only.*}
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$event.fee_label}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{if $lineItem}{foreach from=$lineItem item=value key=priceset}
-
-{if $value neq 'skip'}
-{if $isPrimary}
-{if $lineItem|@count GT 1} {* Header for multi participant registration cases. *}
-{ts 1=$priceset+1}Participant %1{/ts} {$part.$priceset.info}
-
-{/if}
-{/if}
------------------------------------------------------------{if $pricesetFieldsCount }--------------------{/if}
-
-{capture assign=ts_item}{ts}Item{/ts}{/capture}
-{capture assign=ts_qty}{ts}Qty{/ts}{/capture}
-{capture assign=ts_each}{ts}Each{/ts}{/capture}
-{capture assign=ts_total}{ts}Total{/ts}{/capture}
-{if $pricesetFieldsCount }{capture assign=ts_participant_total}{ts}Total Participants{/ts}{/capture}{/if}
-{$ts_item|string_format:"%-30s"} {$ts_qty|string_format:"%5s"} {$ts_each|string_format:"%10s"} {$ts_total|string_format:"%10s"} {$ts_participant_total|string_format:"%10s"}
------------------------------------------------------------{if $pricesetFieldsCount }--------------------{/if}
-
-{foreach from=$value item=line}
-{if $pricesetFieldsCount }{capture assign=ts_participant_count}{$line.participant_count}{/capture}{/if}
-{capture assign=ts_item}{if $line.html_type eq 'Text'}{$line.label}{else}{$line.field_title} - {$line.label}{/if} {if $line.description} {$line.description}{/if}{/capture}{$ts_item|truncate:30:"..."|string_format:"%-30s"} {$line.qty|string_format:"%5s"} {$line.unit_price|crmMoney|string_format:"%10s"} {$line.line_total|crmMoney|string_format:"%10s"}{$ts_participant_count|string_format:"%10s"}
-{/foreach}
-{/if}
-{/foreach}
-{/if}
-{if $isPrimary }
-
-{ts}Total Amount{/ts}: {$totalAmount|crmMoney} {if $hookDiscount.message}({$hookDiscount.message}){/if}
-
-{if $pricesetFieldsCount }
-      {assign var="count" value= 0}
-      {foreach from=$lineItem item=pcount}
-      {assign var="lineItemCount" value=0}
-      {if $pcount neq 'skip'}
-        {foreach from=$pcount item=p_count}
-        {assign var="lineItemCount" value=$lineItemCount+$p_count.participant_count}
-        {/foreach}
-      {if $lineItemCount < 1 }
-        {assign var="lineItemCount" value=1}
-      {/if}
-      {assign var="count" value=$count+$lineItemCount}
-      {/if}
-      {/foreach}
-
-{ts}Total Participants{/ts}: {$count}
-{/if}
-
-{if $is_pay_later}
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$pay_later_receipt}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{/if}
-
-{if $register_date}
-{ts}Registration Date{/ts}: {$register_date|crmDate}
-{/if}
-{if $receive_date}
-{ts}Transaction Date{/ts}: {$receive_date|crmDate}
-{/if}
-{if $contributionTypeName}
-{ts}Contribution Type{/ts}: {$contributionTypeName}
-{/if}
-{if $trxn_id}
-{ts}Transaction #{/ts}: {$trxn_id}
-{/if}
-{if $paidBy}
-{ts}Paid By{/ts}: {$paidBy}
-{/if}
-{if $checkNumber}
-{ts}Check Number{/ts}: {$checkNumber}
-{/if}
-{if $contributeMode ne 'notify' and !$isAmountzero and !$is_pay_later and !$isOnWaitlist and !$isRequireApproval}
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{ts}Billing Name and Address{/ts}
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$billingName}
-{$address}
-{/if}
-
-{if $contributeMode eq 'direct' and !$isAmountzero and !$is_pay_later and !$isOnWaitlist and !$isRequireApproval}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{ts}Credit Card Information{/ts}
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$credit_card_type}
-{$credit_card_number}
-{ts}Expires{/ts}: {$credit_card_exp_date|truncate:7:''|crmDate}
-{/if}
-{/if}
-{/if} {* End of conditional section for Paid events *}
-
-{if $customPre}
-{foreach from=$customPre item=customPr key=i}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$customPre_grouptitle.$i}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{foreach from=$customPr item=customValue key=customName}
-{if ( $trackingFields and ! in_array( $customName, $trackingFields ) ) or ! $trackingFields}
- {$customName}: {$customValue}
-{/if}
-{/foreach}
-{/foreach}
-{/if}
-
-{if $customPost}
-{foreach from=$customPost item=customPos key=j}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$customPost_grouptitle.$j}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{foreach from=$customPos item=customValue key=customName}
-{if ( $trackingFields and ! in_array( $customName, $trackingFields ) ) or ! $trackingFields}
- {$customName}: {$customValue}
-{/if}
-{/foreach}
-{/foreach}
-{/if}
-{if $customProfile}
-
-{foreach from=$customProfile.profile item=eachParticipant key=participantID}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{ts 1=$participantID+2}Participant Information - Participant %1{/ts}
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{foreach from=$eachParticipant item=eachProfile key=pid}
-----------------------------------------------------------{if $pricesetFieldsCount }--------------------{/if}
-
-{$customProfile.title.$pid}
-----------------------------------------------------------{if $pricesetFieldsCount }--------------------{/if}
-
-{foreach from=$eachProfile item=val key=field}
-{foreach from=$val item=v key=f}
-{$field}: {$v}
-{/foreach}
-{/foreach}
-{/foreach}
-{/foreach}
-{/if}
-{if $customGroup}
-{foreach from=$customGroup item=value key=customName}
-=========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$customName}
-=========================================================={if $pricesetFieldsCount }===================={/if}
-
-{foreach from=$value item=v key=n}
-{$n}: {$v}
-{/foreach}
-{/foreach}
-{/if}
diff --git a/CRM/Upgrade/4.2.alpha1.msg_template/message_templates/membership_autorenew_billing_html.tpl b/CRM/Upgrade/4.2.alpha1.msg_template/message_templates/membership_autorenew_billing_html.tpl
deleted file mode 100644 (file)
index 0277abc..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <title></title>
-</head>
-<body>
-
-{capture assign=headerStyle}colspan="2" style="text-align: left; padding: 4px; border-bottom: 1px solid #999; background-color: #eee;"{/capture}
-{capture assign=labelStyle }style="padding: 4px; border-bottom: 1px solid #999; background-color: #f7f7f7;"{/capture}
-{capture assign=valueStyle }style="padding: 4px; border-bottom: 1px solid #999;"{/capture}
-
-<center>
- <table width="620" border="0" cellpadding="0" cellspacing="0" id="crm-event_receipt" style="font-family: Arial, Verdana, sans-serif; text-align: left;">
-
-  <!-- BEGIN HEADER -->
-  <!-- You can add table row(s) here with logo or other header elements -->
-  <!-- END HEADER -->
-
-  <!-- BEGIN CONTENT -->
-
-  <tr>
-   <td>
-    <p>{ts 1=$contact.display_name}Dear %1{/ts},</p>
-    <p>{ts 1=$membershipType}Billing details for your automatically renewed %1 membership have been updated.{/ts}</p>
-   </td>
-  </tr>
-  <tr>
- </table>
-
-  <table width="500" style="border: 1px solid #999; margin: 1em 0em 1em; border-collapse: collapse;">
-<tr>
-        <th {$headerStyle}>
-         {ts}Billing Name and Address{/ts}
-        </th>
-       </tr>
-       <tr>
-        <td colspan="2" {$valueStyle}>
-         {$billingName}<br />
-         {$address|nl2br}<br />
-         {$email}
-        </td>
-       </tr>
-        <tr>
-       <th {$headerStyle}>
-        {ts}Credit Card Information{/ts}
-       </th>
-      </tr>
-      <tr>
-       <td colspan="2" {$valueStyle}>
-        {$credit_card_type}<br />
-        {$credit_card_number}<br />
-        {ts}Expires{/ts}: {$credit_card_exp_date|truncate:7:''|crmDate}<br />
-       </td>
-      </tr>
-      <tr>
-        <td {$labelStyle}>
-         {ts 1=$receipt_from_email}If you have questions please contact us at %1{/ts}
-        </td>
-      </tr>
-  </table>
-</center>
-
-</body>
-</html>
diff --git a/CRM/Upgrade/4.2.alpha1.msg_template/message_templates/membership_autorenew_billing_subject.tpl b/CRM/Upgrade/4.2.alpha1.msg_template/message_templates/membership_autorenew_billing_subject.tpl
deleted file mode 100644 (file)
index ca21f40..0000000
+++ /dev/null
@@ -1 +0,0 @@
-{ts}Membership Autorenewal Updates{/ts}
\ No newline at end of file
diff --git a/CRM/Upgrade/4.2.alpha1.msg_template/message_templates/membership_autorenew_billing_text.tpl b/CRM/Upgrade/4.2.alpha1.msg_template/message_templates/membership_autorenew_billing_text.tpl
deleted file mode 100644 (file)
index 8df337a..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-{ts 1=$contact.display_name}Dear %1{/ts},
-
-{ts 1=$membershipType}Billing details for your automatically renewed %1 membership have been updated.{/ts}
-
-===========================================================
-{ts}Billing Name and Address{/ts}
-
-===========================================================
-{$billingName}
-{$address}
-
-{$email}
-
-===========================================================
-{ts}Credit Card Information{/ts}
-
-===========================================================
-{$credit_card_type}
-{$credit_card_number}
-{ts}Expires{/ts}: {$credit_card_exp_date|truncate:7:''|crmDate}
-
-
-{ts 1=$receipt_from_email}If you have questions please contact us at %1{/ts}
\ No newline at end of file
diff --git a/CRM/Upgrade/4.2.alpha1.msg_template/message_templates/membership_autorenew_cancelled_html.tpl b/CRM/Upgrade/4.2.alpha1.msg_template/message_templates/membership_autorenew_cancelled_html.tpl
deleted file mode 100644 (file)
index 77e11ff..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <title></title>
-</head>
-<body>
-
-{capture assign=headerStyle}colspan="2" style="text-align: left; padding: 4px; border-bottom: 1px solid #999; background-color: #eee;"{/capture}
-{capture assign=labelStyle }style="padding: 4px; border-bottom: 1px solid #999; background-color: #f7f7f7;"{/capture}
-{capture assign=valueStyle }style="padding: 4px; border-bottom: 1px solid #999;"{/capture}
-
-<center>
- <table width="500" border="0" cellpadding="0" cellspacing="0" id="crm-event_receipt" style="font-family: Arial, Verdana, sans-serif; text-align: left;">
-
-  <!-- BEGIN HEADER -->
-  <!-- You can add table row(s) here with logo or other header elements -->
-  <!-- END HEADER -->
-
-  <!-- BEGIN CONTENT -->
-
-  <tr>
-   <td>
-
-    <p>{ts 1=$membershipType}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.{/ts}</p>
-
-   </td>
-  </tr>
- </table>
- <table width="500" style="border: 1px solid #999; margin: 1em 0em 1em; border-collapse: collapse;">
-
-      <tr>
-       <th {$headerStyle}>
-        {ts}Membership Information{/ts}
-       </th>
-      </tr>
-      <tr>
-       <td {$labelStyle}>
-        {ts}Membership Status{/ts}
-       </td>
-       <td {$valueStyle}>
-        {$membership_status}
-       </td>
-      </tr>
-      {if $mem_start_date}
-       <tr>
-        <td {$labelStyle}>
-         {ts}Membership Start Date{/ts}
-        </td>
-        <td {$valueStyle}>
-         {$mem_start_date|crmDate}
-        </td>
-       </tr>
-      {/if}
-      {if $mem_end_date}
-       <tr>
-        <td {$labelStyle}>
-         {ts}Membership End Date{/ts}
-        </td>
-        <td {$valueStyle}>
-          {$mem_end_date|crmDate}
-        </td>
-       </tr>
-      {/if}
-
- </table>
-</center>
-
-</body>
-</html>
diff --git a/CRM/Upgrade/4.2.alpha1.msg_template/message_templates/membership_autorenew_cancelled_subject.tpl b/CRM/Upgrade/4.2.alpha1.msg_template/message_templates/membership_autorenew_cancelled_subject.tpl
deleted file mode 100644 (file)
index ccfb0de..0000000
+++ /dev/null
@@ -1 +0,0 @@
-{ts}Autorenew Membership Cancellation Notification{/ts}
diff --git a/CRM/Upgrade/4.2.alpha1.msg_template/message_templates/membership_autorenew_cancelled_text.tpl b/CRM/Upgrade/4.2.alpha1.msg_template/message_templates/membership_autorenew_cancelled_text.tpl
deleted file mode 100644 (file)
index 51cec8c..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-{ts 1=$membershipType}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.{/ts}
-
-===========================================================
-{ts}Membership Information{/ts}
-
-===========================================================
-{ts}Membership Status{/ts}: {$membership_status}
-{if $mem_start_date}{ts}Membership Start Date{/ts}: {$mem_start_date|crmDate}
-{/if}
-{if $mem_end_date}{ts}Membership End Date{/ts}: {$mem_end_date|crmDate}
-{/if}
-
diff --git a/CRM/Upgrade/4.2.alpha1.msg_template/message_templates/membership_online_receipt_html.tpl b/CRM/Upgrade/4.2.alpha1.msg_template/message_templates/membership_online_receipt_html.tpl
deleted file mode 100644 (file)
index 7182d55..0000000
+++ /dev/null
@@ -1,517 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <title></title>
-</head>
-<body>
-
-{capture assign=headerStyle}colspan="2" style="text-align: left; padding: 4px; border-bottom: 1px solid #999; background-color: #eee;"{/capture}
-{capture assign=labelStyle }style="padding: 4px; border-bottom: 1px solid #999; background-color: #f7f7f7;"{/capture}
-{capture assign=valueStyle }style="padding: 4px; border-bottom: 1px solid #999;"{/capture}
-
-<center>
- <table width="500" border="0" cellpadding="0" cellspacing="0" id="crm-event_receipt" style="font-family: Arial, Verdana, sans-serif; text-align: left;">
-
-  <!-- BEGIN HEADER -->
-  <!-- You can add table row(s) here with logo or other header elements -->
-  <!-- END HEADER -->
-
-  <!-- BEGIN CONTENT -->
-
-  <tr>
-   <td>
-
-    {if $receipt_text}
-     <p>{$receipt_text|htmlize}</p>
-    {/if}
-
-    {if $is_pay_later}
-     <p>{$pay_later_receipt}</p> {* FIXME: this might be text rather than HTML *}
-    {else}
-     <p>{ts}Please print this confirmation for your records.{/ts}</p>
-    {/if}
-
-   </td>
-  </tr>
-  </table>
-  <table width="500" style="border: 1px solid #999; margin: 1em 0em 1em; border-collapse: collapse;">
-
-     {if $membership_assign}
-      <tr>
-       <th {$headerStyle}>
-        {ts}Membership Information{/ts}
-       </th>
-      </tr>
-      <tr>
-       <td {$labelStyle}>
-        {ts}Membership Type{/ts}
-       </td>
-       <td {$valueStyle}>
-        {$membership_name}
-       </td>
-      </tr>
-      {if $mem_start_date}
-       <tr>
-        <td {$labelStyle}>
-         {ts}Membership Start Date{/ts}
-        </td>
-        <td {$valueStyle}>
-         {$mem_start_date|crmDate}
-        </td>
-       </tr>
-      {/if}
-      {if $mem_end_date}
-       <tr>
-        <td {$labelStyle}>
-         {ts}Membership End Date{/ts}
-        </td>
-        <td {$valueStyle}>
-          {$mem_end_date|crmDate}
-        </td>
-       </tr>
-      {/if}
-     {/if}
-
-
-     {if $amount}
-
-
-      <tr>
-       <th {$headerStyle}>
-        {ts}Membership Fee{/ts}
-       </th>
-      </tr>
-
-      {if $membership_amount and $is_quick_config}
-
-       <tr>
-        <td {$labelStyle}>
-         {ts 1=$membership_name}%1 Membership{/ts}
-        </td>
-        <td {$valueStyle}>
-         {$membership_amount|crmMoney}
-        </td>
-       </tr>
-       {if $amount}
-        {if ! $is_separate_payment }
-         <tr>
-          <td {$labelStyle}>
-           {ts}Contribution Amount{/ts}
-          </td>
-          <td {$valueStyle}>
-           {$amount|crmMoney}
-          </td>
-         </tr>
-        {else}
-         <tr>
-          <td {$labelStyle}>
-           {ts}Additional Contribution{/ts}
-          </td>
-          <td {$valueStyle}>
-           {$amount|crmMoney}
-          </td>
-         </tr>
-        {/if}
-       {/if}
-       <tr>
-        <td {$labelStyle}>
-         {ts}Total{/ts}
-        </td>
-        <td {$valueStyle}>
-         {$amount+$membership_amount|crmMoney}
-        </td>
-       </tr>
-
-      {elseif !$useForMember && $lineItem and $priceSetID and !$is_quick_config}
-
-       {foreach from=$lineItem item=value key=priceset}
-        <tr>
-         <td colspan="2" {$valueStyle}>
-          <table> {* FIXME: style this table so that it looks like the text version (justification, etc.) *}
-           <tr>
-            <th>{ts}Item{/ts}</th>
-            <th>{ts}Qty{/ts}</th>
-            <th>{ts}Each{/ts}</th>
-            <th>{ts}Total{/ts}</th>
-           </tr>
-           {foreach from=$value item=line}
-            <tr>
-             <td>
-              {$line.description|truncate:30:"..."}
-             </td>
-             <td>
-              {$line.qty}
-             </td>
-             <td>
-              {$line.unit_price|crmMoney}
-             </td>
-             <td>
-              {$line.line_total|crmMoney}
-             </td>
-            </tr>
-           {/foreach}
-          </table>
-         </td>
-        </tr>
-       {/foreach}
-       <tr>
-        <td {$labelStyle}>
-         {ts}Total Amount{/ts}
-        </td>
-        <td {$valueStyle}>
-         {$amount|crmMoney}
-        </td>
-       </tr>
-
-      {else}
-       {if $useForMember && $lineItem and !$is_quick_config}
-       {foreach from=$lineItem item=value key=priceset}
-        <tr>
-         <td colspan="2" {$valueStyle}>
-          <table> {* FIXME: style this table so that it looks like the text version (justification, etc.) *}
-           <tr>
-            <th>{ts}Item{/ts}</th>
-            <th>{ts}Fee{/ts}</th>
-      <th>{ts}Membership Start Date{/ts}</th>
-      <th>{ts}Membership End Date{/ts}</th>
-           </tr>
-           {foreach from=$value item=line}
-            <tr>
-             <td>
-             {if $line.html_type eq 'Text'}{$line.label}{else}{$line.field_title} - {$line.label}{/if} {if $line.description}<div>{$line.description|truncate:30:"..."}</div>{/if}
-             </td>
-             <td>
-              {$line.line_total|crmMoney}
-             </td>
-             <td>
-              {$line.start_date}
-             </td>
-       <td>
-              {$line.end_date}
-             </td>
-            </tr>
-           {/foreach}
-          </table>
-         </td>
-        </tr>
-       {/foreach}
-       {/if}
-       <tr>
-        <td {$labelStyle}>
-         {ts}Amount{/ts}
-        </td>
-        <td {$valueStyle}>
-         {$amount|crmMoney} {if $amount_level} - {$amount_level}{/if}
-        </td>
-       </tr>
-
-      {/if}
-
-
-     {elseif $membership_amount}
-
-
-      <tr>
-       <th {$headerStyle}>
-        {ts}Membership Fee{/ts}
-       </th>
-      </tr>
-      <tr>
-       <td {$labelStyle}>
-        {ts 1=$membership_name}%1 Membership{/ts}
-       </td>
-       <td {$valueStyle}>
-        {$membership_amount|crmMoney}
-       </td>
-      </tr>
-
-
-     {/if}
-
-
-     {if $receive_date}
-      <tr>
-       <td {$labelStyle}>
-        {ts}Date{/ts}
-       </td>
-       <td {$valueStyle}>
-        {$receive_date|crmDate}
-       </td>
-      </tr>
-     {/if}
-
-     {if $is_monetary and $trxn_id}
-      <tr>
-       <td {$labelStyle}>
-        {ts}Transaction #{/ts}
-       </td>
-       <td {$valueStyle}>
-        {$trxn_id}
-       </td>
-      </tr>
-     {/if}
-
-     {if $membership_trx_id}
-      <tr>
-       <td {$labelStyle}>
-        {ts}Membership Transaction #{/ts}
-       </td>
-       <td {$valueStyle}>
-        {$membership_trx_id}
-       </td>
-      </tr>
-     {/if}
-     {if $is_recur}
-      {if $contributeMode eq 'notify' or $contributeMode eq 'directIPN'}
-       <tr>
-        <td colspan="2" {$labelStyle}>
-         {ts 1=$cancelSubscriptionUrl}This membership will be renewed automatically. You can cancel the auto-renewal option by <a href="%1">visiting this web page</a>.{/ts}
-        </td>
-       </tr>
-       <tr>
-        <td colspan="2" {$labelStyle}>
-         {ts 1=$updateSubscriptionBillingUrl}You can update billing details for this automatically renewed membership by <a href="%1">visiting this web page</a>.{/ts}
-        </td>
-       </tr>
-      {/if}
-     {/if}
-
-     {if $honor_block_is_active}
-      <tr>
-       <th {$headerStyle}>
-        {$honor_type}
-       </th>
-      </tr>
-      <tr>
-       <td colspan="2" {$labelStyle}>
-        {$honor_prefix} {$honor_first_name} {$honor_last_name}
-       </td>
-      </tr>
-      {if $honor_email}
-       <tr>
-        <td {$labelStyle}>
-         {ts}Honoree Email{/ts}
-        </td>
-        <td {$valueStyle}>
-         {$honor_email}
-        </td>
-       </tr>
-      {/if}
-     {/if}
-
-     {if $pcpBlock}
-      <tr>
-       <th {$headerStyle}>
-        {ts}Personal Campaign Page{/ts}
-       </th>
-      </tr>
-      <tr>
-       <td {$labelStyle}>
-        {ts}Display In Honor Roll{/ts}
-       </td>
-       <td {$valueStyle}>
-        {if $pcp_display_in_roll}{ts}Yes{/ts}{else}{ts}No{/ts}{/if}
-       </td>
-      </tr>
-      {if $pcp_roll_nickname}
-       <tr>
-        <td {$labelStyle}>
-         {ts}Nickname{/ts}
-        </td>
-        <td {$valueStyle}>
-         {$pcp_roll_nickname}
-        </td>
-       </tr>
-      {/if}
-      {if $pcp_personal_note}
-       <tr>
-        <td {$labelStyle}>
-         {ts}Personal Note{/ts}
-        </td>
-        <td {$valueStyle}>
-         {$pcp_personal_note}
-        </td>
-       </tr>
-      {/if}
-     {/if}
-
-     {if $onBehalfProfile}
-      <tr>
-       <th {$headerStyle}>
-        {$onBehalfProfile_grouptitle}
-       </th>
-      </tr>
-      {foreach from=$onBehalfProfile item=onBehalfValue key=onBehalfName}
-        <tr>
-         <td {$labelStyle}>
-          {$onBehalfName}
-         </td>
-         <td {$valueStyle}>
-          {$onBehalfValue}
-         </td>
-        </tr>
-      {/foreach}
-     {/if}
-
-     {if ! ($contributeMode eq 'notify' OR $contributeMode eq 'directIPN') and $is_monetary}
-      {if $is_pay_later}
-       <tr>
-        <th {$headerStyle}>
-         {ts}Registered Email{/ts}
-        </th>
-       </tr>
-       <tr>
-        <td colspan="2" {$valueStyle}>
-         {$email}
-        </td>
-       </tr>
-      {elseif $amount GT 0 OR $membership_amount GT 0}
-       <tr>
-        <th {$headerStyle}>
-         {ts}Billing Name and Address{/ts}
-        </th>
-       </tr>
-       <tr>
-        <td colspan="2" {$valueStyle}>
-         {$billingName}<br />
-         {$address|nl2br}<br />
-         {$email}
-        </td>
-       </tr>
-      {/if}
-     {/if}
-
-     {if $contributeMode eq 'direct' AND !$is_pay_later AND ($amount GT 0 OR $membership_amount GT 0)}
-      <tr>
-       <th {$headerStyle}>
-        {ts}Credit Card Information{/ts}
-       </th>
-      </tr>
-      <tr>
-       <td colspan="2" {$valueStyle}>
-        {$credit_card_type}<br />
-        {$credit_card_number}<br />
-        {ts}Expires{/ts}: {$credit_card_exp_date|truncate:7:''|crmDate}<br />
-       </td>
-      </tr>
-     {/if}
-
-     {if $selectPremium}
-      <tr>
-       <th {$headerStyle}>
-        {ts}Premium Information{/ts}
-       </th>
-      </tr>
-      <tr>
-       <td colspan="2" {$labelStyle}>
-        {$product_name}
-       </td>
-      </tr>
-      {if $option}
-       <tr>
-        <td {$labelStyle}>
-         {ts}Option{/ts}
-        </td>
-        <td {$valueStyle}>
-         {$option}
-        </td>
-       </tr>
-      {/if}
-      {if $sku}
-       <tr>
-        <td {$labelStyle}>
-         {ts}SKU{/ts}
-        </td>
-        <td {$valueStyle}>
-         {$sku}
-        </td>
-       </tr>
-      {/if}
-      {if $start_date}
-       <tr>
-        <td {$labelStyle}>
-         {ts}Start Date{/ts}
-        </td>
-        <td {$valueStyle}>
-         {$start_date|crmDate}
-        </td>
-       </tr>
-      {/if}
-      {if $end_date}
-       <tr>
-        <td {$labelStyle}>
-         {ts}End Date{/ts}
-        </td>
-        <td {$valueStyle}>
-         {$end_date|crmDate}
-        </td>
-       </tr>
-      {/if}
-      {if $contact_email OR $contact_phone}
-       <tr>
-        <td colspan="2" {$valueStyle}>
-         <p>{ts}For information about this premium, contact:{/ts}</p>
-         {if $contact_email}
-          <p>{$contact_email}</p>
-         {/if}
-         {if $contact_phone}
-          <p>{$contact_phone}</p>
-         {/if}
-        </td>
-       </tr>
-      {/if}
-      {if $is_deductible AND $price}
-        <tr>
-         <td colspan="2" {$valueStyle}>
-          <p>{ts 1=$price|crmMoney}The value of this premium is %1. This may affect the amount of the tax deduction you can claim. Consult your tax advisor for more information.{/ts}</p>
-         </td>
-        </tr>
-      {/if}
-     {/if}
-
-     {if $customPre}
-      <tr>
-       <th {$headerStyle}>
-        {$customPre_grouptitle}
-       </th>
-      </tr>
-      {foreach from=$customPre item=customValue key=customName}
-       {if ($trackingFields and ! in_array($customName, $trackingFields)) or ! $trackingFields}
-        <tr>
-         <td {$labelStyle}>
-          {$customName}
-         </td>
-         <td {$valueStyle}>
-          {$customValue}
-         </td>
-        </tr>
-       {/if}
-      {/foreach}
-     {/if}
-
-     {if $customPost}
-      <tr>
-       <th {$headerStyle}>
-        {$customPost_grouptitle}
-       </th>
-      </tr>
-      {foreach from=$customPost item=customValue key=customName}
-       {if ($trackingFields and ! in_array($customName, $trackingFields)) or ! $trackingFields}
-        <tr>
-         <td {$labelStyle}>
-          {$customName}
-         </td>
-         <td {$valueStyle}>
-          {$customValue}
-         </td>
-        </tr>
-       {/if}
-      {/foreach}
-     {/if}
-
-  </table>
-</center>
-
-</body>
-</html>
diff --git a/CRM/Upgrade/4.2.alpha1.msg_template/message_templates/membership_online_receipt_text.tpl b/CRM/Upgrade/4.2.alpha1.msg_template/message_templates/membership_online_receipt_text.tpl
deleted file mode 100644 (file)
index 4e2427b..0000000
+++ /dev/null
@@ -1,220 +0,0 @@
-{if $receipt_text}
-{$receipt_text}
-{/if}
-{if $is_pay_later}
-
-===========================================================
-{$pay_later_receipt}
-===========================================================
-{else}
-
-{ts}Please print this receipt for your records.{/ts}
-{/if}
-
-{if $membership_assign && !$useForMember}
-===========================================================
-{ts}Membership Information{/ts}
-
-===========================================================
-{ts}Membership Type{/ts}: {$membership_name}
-{if $mem_start_date}{ts}Membership Start Date{/ts}: {$mem_start_date|crmDate}
-{/if}
-{if $mem_end_date}{ts}Membership End Date{/ts}: {$mem_end_date|crmDate}
-{/if}
-
-{/if}
-{if $amount}
-===========================================================
-{ts}Membership Fee{/ts}
-
-===========================================================
-{if !$useForMember && $membership_amount }
-{ts 1=$membership_name}%1 Membership{/ts}: {$membership_amount|crmMoney}
-{if $amount}
-{if ! $is_separate_payment }
-{ts}Contribution Amount{/ts}: {$amount|crmMoney}
-{else}
-{ts}Additional Contribution{/ts}: {$amount|crmMoney}
-{/if}
-{/if}
--------------------------------------------
-{ts}Total{/ts}: {$amount+$membership_amount|crmMoney}
-{elseif !$useForMember && $lineItem and $priceSetID}
-{foreach from=$lineItem item=value key=priceset}
----------------------------------------------------------
-{capture assign=ts_item}{ts}Item{/ts}{/capture}
-{capture assign=ts_qty}{ts}Qty{/ts}{/capture}
-{capture assign=ts_each}{ts}Each{/ts}{/capture}
-{capture assign=ts_total}{ts}Total{/ts}{/capture}
-{$ts_item|string_format:"%-30s"} {$ts_qty|string_format:"%5s"} {$ts_each|string_format:"%10s"} {$ts_total|string_format:"%10s"}
-----------------------------------------------------------
-{foreach from=$value item=line}
-{$line.description|truncate:30:"..."|string_format:"%-30s"} {$line.qty|string_format:"%5s"} {$line.unit_price|crmMoney|string_format:"%10s"} {$line.line_total|crmMoney|string_format:"%10s"}
-{/foreach}
-{/foreach}
-
-{ts}Total Amount{/ts}: {$amount|crmMoney}
-{else}
-{if $useForMember && $lineItem}
-{foreach from=$lineItem item=value key=priceset}
-{capture assign=ts_item}{ts}Item{/ts}{/capture}
-{capture assign=ts_total}{ts}Fee{/ts}{/capture}
-{capture assign=ts_start_date}{ts}Membership Start Date{/ts}{/capture}
-{capture assign=ts_end_date}{ts}Membership End Date{/ts}{/capture}
-{$ts_item|string_format:"%-30s"} {$ts_total|string_format:"%10s"} {$ts_start_date|string_format:"%20s"} {$ts_end_date|string_format:"%20s"}
---------------------------------------------------------------------------------------------------
-
-{foreach from=$value item=line}
-{capture assign=ts_item}{if $line.html_type eq 'Text'}{$line.label}{else}{$line.field_title} - {$line.label}{/if} {if $line.description} {$line.description}{/if}{/capture}{$ts_item|truncate:30:"..."|string_format:"%-30s"} {$line.line_total|crmMoney|string_format:"%10s"} {$line.start_date|string_format:"%20s"} {$line.end_date|string_format:"%20s"}
-{/foreach}
-{/foreach}
---------------------------------------------------------------------------------------------------
-{/if}
-{ts}Amount{/ts}: {$amount|crmMoney} {if $amount_level } - {$amount_level} {/if}
-{/if}
-{elseif $membership_amount}
-===========================================================
-{ts}Membership Fee{/ts}
-
-===========================================================
-{ts 1=$membership_name}%1 Membership{/ts}: {$membership_amount|crmMoney}
-{/if}
-{if $receive_date}
-
-{ts}Date{/ts}: {$receive_date|crmDate}
-{/if}
-{if $is_monetary and $trxn_id}
-{ts}Transaction #{/ts}: {$trxn_id}
-
-{/if}
-{if $membership_trx_id}
-{ts}Membership Transaction #{/ts}: {$membership_trx_id}
-
-{/if}
-{if $is_recur}
-{if $contributeMode eq 'notify' or $contributeMode eq 'directIPN'}
-{ts 1=$cancelSubscriptionUrl}This membership will be renewed automatically. You can cancel the auto-renewal option by visiting this web page: %1.{/ts}
-
-{ts 1=$updateSubscriptionBillingUrl}You can update billing details for this automatically renewed membership by <a href="%1">visiting this web page</a>.{/ts}
-{/if}
-{/if}
-
-{if $honor_block_is_active }
-===========================================================
-{$honor_type}
-===========================================================
-{$honor_prefix} {$honor_first_name} {$honor_last_name}
-{if $honor_email}
-{ts}Honoree Email{/ts}: {$honor_email}
-{/if}
-
-{/if}
-{if $pcpBlock}
-===========================================================
-{ts}Personal Campaign Page{/ts}
-
-===========================================================
-{ts}Display In Honor Roll{/ts}: {if $pcp_display_in_roll}{ts}Yes{/ts}{else}{ts}No{/ts}{/if}
-
-{if $pcp_roll_nickname}{ts}Nickname{/ts}: {$pcp_roll_nickname}{/if}
-
-{if $pcp_personal_note}{ts}Personal Note{/ts}: {$pcp_personal_note}{/if}
-
-{/if}
-{if $onBehalfProfile}
-===========================================================
-{ts}On Behalf Of{/ts}
-
-===========================================================
-{foreach from=$onBehalfProfile item=onBehalfValue key=onBehalfName}
-{$onBehalfName}: {$onBehalfValue}
-{/foreach}
-{/if}
-
-{if !( $contributeMode eq 'notify' OR $contributeMode eq 'directIPN' ) and $is_monetary}
-{if $is_pay_later}
-===========================================================
-{ts}Registered Email{/ts}
-
-===========================================================
-{$email}
-{elseif $amount GT 0 OR $membership_amount GT 0 }
-===========================================================
-{ts}Billing Name and Address{/ts}
-
-===========================================================
-{$billingName}
-{$address}
-
-{$email}
-{/if} {* End ! is_pay_later condition. *}
-{/if}
-{if $contributeMode eq 'direct' AND !$is_pay_later AND ( $amount GT 0 OR $membership_amount GT 0 ) }
-
-===========================================================
-{ts}Credit Card Information{/ts}
-
-===========================================================
-{$credit_card_type}
-{$credit_card_number}
-{ts}Expires{/ts}: {$credit_card_exp_date|truncate:7:''|crmDate}
-{/if}
-
-{if $selectPremium }
-===========================================================
-{ts}Premium Information{/ts}
-
-===========================================================
-{$product_name}
-{if $option}
-{ts}Option{/ts}: {$option}
-{/if}
-{if $sku}
-{ts}SKU{/ts}: {$sku}
-{/if}
-{if $start_date}
-{ts}Start Date{/ts}: {$start_date|crmDate}
-{/if}
-{if $end_date}
-{ts}End Date{/ts}: {$end_date|crmDate}
-{/if}
-{if $contact_email OR $contact_phone}
-
-{ts}For information about this premium, contact:{/ts}
-
-{if $contact_email}
-  {$contact_email}
-{/if}
-{if $contact_phone}
-  {$contact_phone}
-{/if}
-{/if}
-{if $is_deductible AND $price}
-
-{ts 1=$price|crmMoney}The value of this premium is %1. This may affect the amount of the tax deduction you can claim. Consult your tax advisor for more information.{/ts}{/if}
-{/if}
-
-{if $customPre}
-===========================================================
-{$customPre_grouptitle}
-
-===========================================================
-{foreach from=$customPre item=customValue key=customName}
-{if ( $trackingFields and ! in_array( $customName, $trackingFields ) ) or ! $trackingFields}
- {$customName}: {$customValue}
-{/if}
-{/foreach}
-{/if}
-
-
-{if $customPost}
-===========================================================
-{$customPost_grouptitle}
-
-===========================================================
-{foreach from=$customPost item=customValue key=customName}
-{if ( $trackingFields and ! in_array( $customName, $trackingFields ) ) or ! $trackingFields}
- {$customName}: {$customValue}
-{/if}
-{/foreach}
-{/if}
diff --git a/CRM/Upgrade/4.2.alpha1.msg_template/message_templates/pledge_acknowledge_html.tpl b/CRM/Upgrade/4.2.alpha1.msg_template/message_templates/pledge_acknowledge_html.tpl
deleted file mode 100644 (file)
index b4e42e1..0000000
+++ /dev/null
@@ -1,132 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <title></title>
-</head>
-<body>
-
-{capture assign=headerStyle}colspan="2" style="text-align: left; padding: 4px; border-bottom: 1px solid #999; background-color: #eee;"{/capture}
-{capture assign=labelStyle }style="padding: 4px; border-bottom: 1px solid #999; background-color: #f7f7f7;"{/capture}
-{capture assign=valueStyle }style="padding: 4px; border-bottom: 1px solid #999;"{/capture}
-
-<center>
- <table width="620" border="0" cellpadding="0" cellspacing="0" id="crm-event_receipt" style="font-family: Arial, Verdana, sans-serif; text-align: left;">
-
-  <!-- BEGIN HEADER -->
-  <!-- You can add table row(s) here with logo or other header elements -->
-  <!-- END HEADER -->
-
-  <!-- BEGIN CONTENT -->
-
-  <tr>
-   <td>
-    <p>{ts 1=$contact.display_name}dear %1{/ts},</p>
-    <p>{ts}thank you for your generous pledge. please print this acknowledgment for your records.{/ts}</p>
-   </td>
-  </tr>
-  <tr>
-   <td>
-    <table style="border: 1px solid #999; margin: 1em 0em 1em; border-collapse: collapse; width:100%;">
-     <tr>
-      <th {$headerStyle}>
-       {ts}Pledge Information{/ts}
-      </th>
-     </tr>
-     <tr>
-      <td {$labelStyle}>
-       {ts}Pledge Received{/ts}
-      </td>
-      <td {$valueStyle}>
-       {$create_date|truncate:10:''|crmDate}
-      </td>
-     </tr>
-     <tr>
-      <td {$labelStyle}>
-       {ts}Total Pledge Amount{/ts}
-      </td>
-      <td {$valueStyle}>
-       {$total_pledge_amount|crmMoney:$currency}
-      </td>
-     </tr>
-     <tr>
-      <th {$headerStyle}>
-       {ts}Payment Schedule{/ts}
-      </th>
-     </tr>
-     <tr>
-      <td colspan="2" {$valueStyle}>
-       <p>{ts 1=$scheduled_amount|crmMoney:$currency 2=$frequency_interval 3=$frequency_unit 4=$installments}%1 every %2 %3 for %4 installments.{/ts}</p>
-
-       {if $frequency_day}
-        <p>{ts 1=$frequency_day 2=$frequency_unit}Payments are due on day %1 of the %2.{/ts}</p>
-       {/if}
-      </td>
-     </tr>
-
-     {if $payments}
-      {assign var="count" value="1"}
-      {foreach from=$payments item=payment}
-       <tr>
-        <td {$labelStyle}>
-         {ts 1=$count}Payment %1{/ts}
-        </td>
-        <td {$valueStyle}>
-         {$payment.amount|crmMoney:$currency} {if $payment.status eq 1}{ts}paid{/ts} {$payment.receive_date|truncate:10:''|crmDate}{else}{ts}due{/ts} {$payment.due_date|truncate:10:''|crmDate}{/if}
-        </td>
-       </tr>
-       {assign var="count" value=`$count+1`}
-      {/foreach}
-     {/if}
-
-     <tr>
-      <td colspan="2" {$valueStyle}>
-       <p>{ts 1=$domain.phone 2=$domain.email}Please contact us at %1 or send email to %2 if you have questions
-or need to modify your payment schedule.{/ts}</p>
-      </td>
-     </tr>
-     {if $honor_block_is_active}
-      <tr>
-       <th {$headerStyle}>
-        {$honor_type}
-       </th>
-      </tr>
-      <tr>
-       <td colspan="2" {$valueStyle}>
-        <p>{$honor_prefix} {$honor_first_name} {$honor_last_name}</p>
-        {if $honor_email}
-         <p>{ts}Honoree Email{/ts}: {$honor_email}</p>
-        {/if}
-       </td>
-      </tr>
-     {/if}
-
-     {if $customGroup}
-      {foreach from=$customGroup item=value key=customName}
-       <tr>
-        <th {$headerStyle}>
-         {$customName}
-        </th>
-       </tr>
-       {foreach from=$value item=v key=n}
-        <tr>
-         <td {$labelStyle}>
-          {$n}
-         </td>
-         <td {$valueStyle}>
-          {$v}
-         </td>
-        </tr>
-       {/foreach}
-      {/foreach}
-     {/if}
-
-    </table>
-   </td>
-  </tr>
-
- </table>
-</center>
-
-</body>
-</html>
diff --git a/CRM/Upgrade/4.2.alpha1.msg_template/message_templates/pledge_acknowledge_text.tpl b/CRM/Upgrade/4.2.alpha1.msg_template/message_templates/pledge_acknowledge_text.tpl
deleted file mode 100644 (file)
index f8803f5..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-{ts 1=$contact.display_name}Dear %1{/ts},
-
-{ts}Thank you for your generous pledge. Please print this acknowledgment for your records.{/ts}
-
-===========================================================
-{ts}Pledge Information{/ts}
-
-===========================================================
-{ts}Pledge Received{/ts}: {$create_date|truncate:10:''|crmDate}
-{ts}Total Pledge Amount{/ts}: {$total_pledge_amount|crmMoney:$currency}
-
-===========================================================
-{ts}Payment Schedule{/ts}
-
-===========================================================
-{ts 1=$scheduled_amount|crmMoney:$currency 2=$frequency_interval 3=$frequency_unit 4=$installments}%1 every %2 %3 for %4 installments.{/ts}
-
-{if $frequency_day}
-
-{ts 1=$frequency_day 2=$frequency_unit}Payments are due on day %1 of the %2.{/ts}
-{/if}
-
-{if $payments}
-{assign var="count" value="1"}
-{foreach from=$payments item=payment}
-
-{ts 1=$count}Payment %1{/ts}: {$payment.amount|crmMoney:$currency} {if $payment.status eq 1}{ts}paid{/ts} {$payment.receive_date|truncate:10:''|crmDate}{else}{ts}due{/ts} {$payment.due_date|truncate:10:''|crmDate}{/if}
-{assign var="count" value=`$count+1`}
-{/foreach}
-{/if}
-
-
-{ts 1=$domain.phone 2=$domain.email}Please contact us at %1 or send email to %2 if you have questions
-or need to modify your payment schedule.{/ts}
-
-{if $honor_block_is_active}
-===========================================================
-{$honor_type}
-===========================================================
-{$honor_prefix} {$honor_first_name} {$honor_last_name}
-{if $honor_email}
-{ts}Honoree Email{/ts}: {$honor_email}
-{/if}
-{/if}
-
-{if $customGroup}
-{foreach from=$customGroup item=value key=customName}
-===========================================================
-{$customName}
-===========================================================
-{foreach from=$value item=v key=n}
-{$n}: {$v}
-{/foreach}
-{/foreach}
-{/if}
diff --git a/CRM/Upgrade/4.2.alpha1.msg_template/message_templates/pledge_reminder_html.tpl b/CRM/Upgrade/4.2.alpha1.msg_template/message_templates/pledge_reminder_html.tpl
deleted file mode 100644 (file)
index c2e42a5..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <title></title>
-</head>
-<body>
-
-{capture assign=headerStyle}colspan="2" style="text-align: left; padding: 4px; border-bottom: 1px solid #999; background-color: #eee;"{/capture}
-{capture assign=labelStyle }style="padding: 4px; border-bottom: 1px solid #999; background-color: #f7f7f7;"{/capture}
-{capture assign=valueStyle }style="padding: 4px; border-bottom: 1px solid #999;"{/capture}
-
-<center>
- <table width="620" border="0" cellpadding="0" cellspacing="0" id="crm-event_receipt" style="font-family: Arial, Verdana, sans-serif; text-align: left;">
-
-  <!-- BEGIN HEADER -->
-  <!-- You can add table row(s) here with logo or other header elements -->
-  <!-- END HEADER -->
-
-  <!-- BEGIN CONTENT -->
-
-  <tr>
-   <td>
-    <p>{ts 1=$contact.display_name}Dear %1{/ts},</p>
-    <p>{ts 1=$next_payment|truncate:10:''|crmDate}This is a reminder that the next payment on your pledge is due on %1.{/ts}</p>
-   </td>
-  </tr>
-  <tr>
-   <td>
-    <table style="border: 1px solid #999; margin: 1em 0em 1em; border-collapse: collapse; width:100%;">
-     <tr>
-      <th {$headerStyle}>
-       {ts}Payment Due{/ts}
-      </th>
-     </tr>
-     <tr>
-      <td {$labelStyle}>
-       {ts}Amount Due{/ts}
-      </td>
-      <td {$valueStyle}>
-       {$amount_due|crmMoney:$currency}
-      </td>
-     </tr>
-    </table>
-   </td>
-  </tr>
-
-  <tr>
-   <td>
-    {if $contribution_page_id}
-     {capture assign=contributionUrl}{crmURL p='civicrm/contribute/transact' q="reset=1&id=`$contribution_page_id`&cid=`$contact.contact_id`&pledgeId=`$pledge_id`&cs=`$checksumValue`" a=true h=0}{/capture}
-     <p><a href="{$contributionUrl}">{ts}Go to a web page where you can make your payment online{/ts}</a></p>
-    {else}
-     <p>{ts}Please mail your payment to{/ts}: {$domain.address}</p>
-    {/if}
-   </td>
-  </tr>
-
-  <tr>
-   <td>
-    <table style="border: 1px solid #999; margin: 1em 0em 1em; border-collapse: collapse; width:100%;">
-     <tr>
-      <th {$headerStyle}>
-       {ts}Pledge Information{/ts}
-      </th>
-     </tr>
-     <tr>
-      <td {$labelStyle}>
-       {ts}Pledge Received{/ts}
-      </td>
-      <td {$valueStyle}>
-       {$create_date|truncate:10:''|crmDate}
-      </td>
-     </tr>
-     <tr>
-      <td {$labelStyle}>
-       {ts}Total Pledge Amount{/ts}
-      </td>
-      <td {$valueStyle}>
-       {$amount|crmMoney:$currency}
-      </td>
-     </tr>
-     <tr>
-      <td {$labelStyle}>
-       {ts}Total Paid{/ts}
-      </td>
-      <td {$valueStyle}>
-       {$amount_paid|crmMoney:$currency}
-      </td>
-     </tr>
-    </table>
-   </td>
-  </tr>
-
-  <tr>
-   <td>
-    <p>{ts 1=$domain.phone 2=$domain.email}Please contact us at %1 or send email to %2 if you have questions
-or need to modify your payment schedule.{/ts}</p>
-    <p>{ts}Thank your for your generous support.{/ts}</p>
-   </td>
-  </tr>
-
- </table>
-</center>
-
-</body>
-</html>
diff --git a/CRM/Upgrade/4.2.alpha1.msg_template/message_templates/pledge_reminder_text.tpl b/CRM/Upgrade/4.2.alpha1.msg_template/message_templates/pledge_reminder_text.tpl
deleted file mode 100644 (file)
index 2761c3d..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-{ts 1=$contact.display_name}Dear %1{/ts},
-
-{ts 1=$next_payment|truncate:10:''|crmDate}This is a reminder that the next payment on your pledge is due on %1.{/ts}
-
-===========================================================
-{ts}Payment Due{/ts}
-
-===========================================================
-{ts}Amount Due{/ts}: {$amount_due|crmMoney:$currency}
-{ts}Due Date{/ts}: {$scheduled_payment_date|truncate:10:''|crmDate}
-
-{if $contribution_page_id}
-{capture assign=contributionUrl}{crmURL p='civicrm/contribute/transact' q="reset=1&id=`$contribution_page_id`&cid=`$contact.contact_id`&pledgeId=`$pledge_id`&cs=`$checksumValue`" a=true h=0}{/capture}
-Click this link to go to a web page where you can make your payment online:
-{$contributionUrl}
-{else}
-{ts}Please mail your payment to{/ts}:
-{$domain.address}
-{/if}
-
-===========================================================
-{ts}Pledge Information{/ts}
-
-===========================================================
-{ts}Pledge Received{/ts}: {$create_date|truncate:10:''|crmDate}
-{ts}Total Pledge Amount{/ts}: {$amount|crmMoney:$currency}
-{ts}Total Paid{/ts}: {$amount_paid|crmMoney:$currency}
-
-{ts 1=$domain.phone 2=$domain.email}Please contact us at %1 or send email to %2 if you have questions
-or need to modify your payment schedule.{/ts}
-
-
-{ts}Thank your for your generous support.{/ts}
diff --git a/CRM/Upgrade/4.2.alpha2.msg_template/civicrm_msg_template.tpl b/CRM/Upgrade/4.2.alpha2.msg_template/civicrm_msg_template.tpl
deleted file mode 100644 (file)
index b9bdf57..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-{php}
-  $dir = SMARTY_DIR . '/../../CRM/Upgrade/4.2.alpha2.msg_template/message_templates';
-  $templates = array();
-  foreach (preg_grep('/\.tpl$/', scandir($dir)) as $filename) {
-    $parts = explode('_', basename($filename, '.tpl'));
-    $templates[] = array('type' => array_pop($parts), 'name' => implode('_', $parts), 'filename' => "$dir/$filename");
-  }
-  $this->assign('templates', $templates);
-{/php}
-
-{foreach from=$templates item=tpl}
-  {fetch assign=content file=$tpl.filename}
-  SELECT @workflow_id := MAX(id) FROM civicrm_option_value WHERE name = '{$tpl.name}';
-  SELECT @content := msg_{$tpl.type} FROM civicrm_msg_template WHERE workflow_id = @workflow_id AND is_reserved = 1 LIMIT 1;
-  UPDATE civicrm_msg_template SET msg_{$tpl.type} = '{$content|escape:"quotes"}' WHERE workflow_id = @workflow_id AND (is_reserved = 1 OR (is_default = 1 AND msg_{$tpl.type} = @content));
-{/foreach}
diff --git a/CRM/Upgrade/4.2.alpha2.msg_template/message_templates/event_offline_receipt_html.tpl b/CRM/Upgrade/4.2.alpha2.msg_template/message_templates/event_offline_receipt_html.tpl
deleted file mode 100644 (file)
index 54d770b..0000000
+++ /dev/null
@@ -1,456 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <title></title>
-</head>
-<body>
-
-{capture assign=headerStyle}colspan="2" style="text-align: left; padding: 4px; border-bottom: 1px solid #999; background-color: #eee;"{/capture}
-{capture assign=labelStyle }style="padding: 4px; border-bottom: 1px solid #999; background-color: #f7f7f7;"{/capture}
-{capture assign=valueStyle }style="padding: 4px; border-bottom: 1px solid #999;"{/capture}
-
-<center>
- <table width="620" border="0" cellpadding="0" cellspacing="0" id="crm-event_receipt" style="font-family: Arial, Verdana, sans-serif; text-align: left;">
-
-  <!-- BEGIN HEADER -->
-  <!-- You can add table row(s) here with logo or other header elements -->
-  <!-- END HEADER -->
-
-  <!-- BEGIN CONTENT -->
-
-  <tr>
-   <td>
-
-    {if $event.confirm_email_text AND (not $isOnWaitlist AND not $isRequireApproval)}
-     <p>{$event.confirm_email_text|htmlize}</p>
-    {/if}
-
-    {if $isOnWaitlist}
-     <p>{ts}You have been added to the WAIT LIST for this event.{/ts}</p>
-     {if $isPrimary}
-       <p>{ts}If space becomes available you will receive an email with a link to a web page where you can complete your registration.{/ts}</p>
-     {/if}
-    {elseif $isRequireApproval}
-     <p>{ts}Your registration has been submitted.{/ts}</p>
-     {if $isPrimary}
-      <p>{ts}Once your registration has been reviewed, you will receive an email with a link to a web page where you can complete the registration process.{/ts}</p>
-     {/if}
-    {elseif $is_pay_later}
-     <p>{$pay_later_receipt}</p> {* FIXME: this might be text rather than HTML *}
-    {else}
-     <p>{ts}Please print this confirmation for your records.{/ts}</p>
-    {/if}
-
-   </td>
-  </tr>
-  <tr>
-   <td>
-    <table style="border: 1px solid #999; margin: 1em 0em 1em; border-collapse: collapse; width:100%;">
-     <tr>
-      <th {$headerStyle}>
-       {ts}Event Information and Location{/ts}
-      </th>
-     </tr>
-     <tr>
-      <td colspan="2" {$valueStyle}>
-       {$event.event_title}<br />
-       {$event.event_start_date|crmDate}{if $event.event_end_date}-{if $event.event_end_date|date_format:"%Y%m%d" == $event.event_start_date|date_format:"%Y%m%d"}{$event.event_end_date|crmDate:0:1}{else}{$event.event_end_date|crmDate}{/if}{/if}
-      </td>
-     </tr>
-
-     {if $event.participant_role neq 'Attendee' and $defaultRole}
-      <tr>
-       <td {$labelStyle}>
-        {ts}Participant Role{/ts}
-       </td>
-       <td {$valueStyle}>
-        {$event.participant_role}
-       </td>
-      </tr>
-     {/if}
-
-     {if $isShowLocation}
-      <tr>
-       <td colspan="2" {$valueStyle}>
-        {if $location.address.1.name}
-         {$location.address.1.name}<br />
-        {/if}
-        {if $location.address.1.street_address}
-         {$location.address.1.street_address}<br />
-        {/if}
-        {if $location.address.1.supplemental_address_1}
-         {$location.address.1.supplemental_address_1}<br />
-        {/if}
-        {if $location.address.1.supplemental_address_2}
-         {$location.address.1.supplemental_address_2}<br />
-        {/if}
-        {if $location.address.1.city}
-         {$location.address.1.city} {$location.address.1.postal_code}{if $location.address.1.postal_code_suffix} - {$location.address.1.postal_code_suffix}{/if}<br />
-        {/if}
-       </td>
-      </tr>
-     {/if}
-
-     {if $location.phone.1.phone || $location.email.1.email}
-      <tr>
-       <td colspan="2" {$labelStyle}>
-        {ts}Event Contacts:{/ts}
-       </td>
-      </tr>
-      {foreach from=$location.phone item=phone}
-       {if $phone.phone}
-        <tr>
-         <td {$labelStyle}>
-          {if $phone.phone_type}
-           {$phone.phone_type_display}
-          {else}
-           {ts}Phone{/ts}
-          {/if}
-         </td>
-         <td {$valueStyle}>
-          {$phone.phone}
-         </td>
-        </tr>
-       {/if}
-      {/foreach}
-      {foreach from=$location.email item=eventEmail}
-       {if $eventEmail.email}
-        <tr>
-         <td {$labelStyle}>
-          {ts}Email{/ts}
-         </td>
-         <td {$valueStyle}>
-          {$eventEmail.email}
-         </td>
-        </tr>
-       {/if}
-      {/foreach}
-     {/if}
-     <tr>
-      <td colspan="2" {$valueStyle}>
-       {capture assign=icalFeed}{crmURL p='civicrm/event/ical' q="reset=1&id=`$event.id`" h=0 a=1 fe=1}{/capture}
-       <a href="{$icalFeed}">{ts}Download iCalendar File{/ts}</a>
-      </td>
-     </tr>
-     {if $email}
-      <tr>
-       <th {$headerStyle}>
-        {ts}Registered Email{/ts}
-       </th>
-      </tr>
-      <tr>
-       <td colspan="2" {$valueStyle}>
-        {$email}
-       </td>
-      </tr>
-     {/if}
-
-
-     {if $event.is_monetary}
-
-      <tr>
-       <th {$headerStyle}>
-        {$event.fee_label}
-       </th>
-      </tr>
-
-      {if $lineItem}
-       {foreach from=$lineItem item=value key=priceset}
-        {if $value neq 'skip'}
-         {if $isPrimary}
-          {if $lineItem|@count GT 1} {* Header for multi participant registration cases. *}
-           <tr>
-            <td colspan="2" {$labelStyle}>
-             {ts 1=$priceset+1}Participant %1{/ts}
-            </td>
-           </tr>
-          {/if}
-         {/if}
-         <tr>
-          <td colspan="2" {$valueStyle}>
-           <table> {* FIXME: style this table so that it looks like the text version (justification, etc.) *}
-            <tr>
-             <th>{ts}Item{/ts}</th>
-             <th>{ts}Qty{/ts}</th>
-             <th>{ts}Each{/ts}</th>
-             <th>{ts}Total{/ts}</th>
-       {if $pricesetFieldsCount }<th>{ts}Total Participants{/ts}</th>{/if}
-            </tr>
-            {foreach from=$value item=line}
-             <tr>
-              <td>
-        {if $line.html_type eq 'Text'}{$line.label}{else}{$line.field_title} - {$line.label}{/if} {if $line.description}<div>{$line.description|truncate:30:"..."}</div>{/if}
-              </td>
-              <td>
-               {$line.qty}
-              </td>
-              <td>
-               {$line.unit_price|crmMoney}
-              </td>
-              <td>
-               {$line.line_total|crmMoney}
-              </td>
-        {if  $pricesetFieldsCount }
-        <td>
-    {$line.participant_count}
-              </td>
-        {/if}
-             </tr>
-            {/foreach}
-           </table>
-          </td>
-         </tr>
-        {/if}
-       {/foreach}
-      {/if}
-
-      {if $amount && !$lineItem}
-       {foreach from=$amount item=amnt key=level}
-        <tr>
-         <td colspan="2" {$valueStyle}>
-          {$amnt.amount|crmMoney} {$amnt.label}
-         </td>
-        </tr>
-       {/foreach}
-      {/if}
-      {if $isPrimary}
-       <tr>
-        <td {$labelStyle}>
-         {ts}Total Amount{/ts}
-        </td>
-        <td {$valueStyle}>
-         {$totalAmount|crmMoney} {if $hookDiscount.message}({$hookDiscount.message}){/if}
-        </td>
-       </tr>
-       {if $pricesetFieldsCount }
-     <tr>
-       <td {$labelStyle}>
-   {ts}Total Participants{/ts}</td>
-       <td {$valueStyle}>
-   {assign var="count" value= 0}
-         {foreach from=$lineItem item=pcount}
-         {assign var="lineItemCount" value=0}
-         {if $pcount neq 'skip'}
-           {foreach from=$pcount item=p_count}
-           {assign var="lineItemCount" value=$lineItemCount+$p_count.participant_count}
-           {/foreach}
-           {if $lineItemCount < 1 }
-           assign var="lineItemCount" value=1}
-           {/if}
-           {assign var="count" value=$count+$lineItemCount}
-         {/if}
-         {/foreach}
-   {$count}
-       </td>
-     </tr>
-     {/if}
-       {if $is_pay_later}
-        <tr>
-         <td colspan="2" {$labelStyle}>
-          {$pay_later_receipt}
-         </td>
-        </tr>
-       {/if}
-
-       {if $register_date}
-        <tr>
-         <td {$labelStyle}>
-          {ts}Registration Date{/ts}
-         </td>
-         <td {$valueStyle}>
-          {$register_date|crmDate}
-         </td>
-        </tr>
-       {/if}
-
-       {if $receive_date}
-        <tr>
-         <td {$labelStyle}>
-          {ts}Transaction Date{/ts}
-         </td>
-         <td {$valueStyle}>
-          {$receive_date|crmDate}
-         </td>
-        </tr>
-       {/if}
-
-       {if $contributionTypeName}
-        <tr>
-         <td {$labelStyle}>
-          {ts}Contribution Type{/ts}
-         </td>
-         <td {$valueStyle}>
-          {$contributionTypeName}
-         </td>
-        </tr>
-       {/if}
-
-       {if $trxn_id}
-        <tr>
-         <td {$labelStyle}>
-          {ts}Transaction #{/ts}
-         </td>
-         <td {$valueStyle}>
-          {$trxn_id}
-         </td>
-        </tr>
-       {/if}
-
-       {if $paidBy}
-        <tr>
-         <td {$labelStyle}>
-          {ts}Paid By{/ts}
-         </td>
-         <td {$valueStyle}>
-         {$paidBy}
-         </td>
-        </tr>
-       {/if}
-
-       {if $checkNumber}
-        <tr>
-         <td {$labelStyle}>
-          {ts}Check Number{/ts}
-         </td>
-         <td {$valueStyle}>
-          {$checkNumber}
-         </td>
-        </tr>
-       {/if}
-
-       {if $contributeMode ne 'notify' and !$isAmountzero and !$is_pay_later and !$isOnWaitlist and !$isRequireApproval}
-        <tr>
-         <th {$headerStyle}>
-          {ts}Billing Name and Address{/ts}
-         </th>
-        </tr>
-        <tr>
-         <td colspan="2" {$valueStyle}>
-          {$billingName}<br />
-          {$address|nl2br}
-         </td>
-        </tr>
-       {/if}
-
-       {if $contributeMode eq 'direct' and !$isAmountzero and !$is_pay_later and !$isOnWaitlist and !$isRequireApproval}
-        <tr>
-         <th {$headerStyle}>
-          {ts}Credit Card Information{/ts}
-         </th>
-        </tr>
-        <tr>
-         <td colspan="2" {$valueStyle}>
-          {$credit_card_type}<br />
-          {$credit_card_number}<br />
-          {ts}Expires{/ts}: {$credit_card_exp_date|truncate:7:''|crmDate}
-         </td>
-        </tr>
-       {/if}
-
-      {/if}
-
-     {/if} {* End of conditional section for Paid events *}
-
-     {if $customPre}
-      <tr>
-       <th {$headerStyle}>
-        {$customPre_grouptitle}
-       </th>
-      </tr>
-      {foreach from=$customPre item=value key=customName}
-       {if ( $trackingFields and ! in_array( $customName, $trackingFields ) ) or ! $trackingFields}
-        <tr>
-         <td {$labelStyle}>
-          {$customName}
-         </td>
-         <td {$valueStyle}>
-          {$value}
-         </td>
-        </tr>
-       {/if}
-      {/foreach}
-     {/if}
-
-     {if $customPost}
-      <tr>
-       <th {$headerStyle}>
-        {$customPost_grouptitle}
-       </th>
-      </tr>
-      {foreach from=$customPost item=value key=customName}
-       {if ( $trackingFields and ! in_array( $customName, $trackingFields ) ) or ! $trackingFields}
-        <tr>
-         <td {$labelStyle}>
-          {$customName}
-         </td>
-         <td {$valueStyle}>
-          {$value}
-         </td>
-        </tr>
-       {/if}
-      {/foreach}
-     {/if}
-
-     {if $customProfile}
-      {foreach from=$customProfile item=value key=customName}
-       <tr>
-        <th {$headerStyle}>
-         {ts 1=$customName+1}Participant Information - Participant %1{/ts}
-        </th>
-       </tr>
-       {foreach from=$value item=val key=field}
-        {if $field eq 'additionalCustomPre' or $field eq 'additionalCustomPost'}
-         <tr>
-          <td colspan="2" {$labelStyle}>
-           {if $field eq 'additionalCustomPre'}
-            {$additionalCustomPre_grouptitle}
-           {else}
-            {$additionalCustomPost_grouptitle}
-           {/if}
-          </td>
-         </tr>
-         {foreach from=$val item=v key=f}
-          <tr>
-           <td {$labelStyle}>
-            {$f}
-           </td>
-           <td {$valueStyle}>
-            {$v}
-           </td>
-          </tr>
-         {/foreach}
-        {/if}
-       {/foreach}
-      {/foreach}
-     {/if}
-
-     {if $customGroup}
-      {foreach from=$customGroup item=value key=customName}
-       <tr>
-        <th {$headerStyle}>
-         {$customName}
-        </th>
-       </tr>
-       {foreach from=$value item=v key=n}
-        <tr>
-         <td {$labelStyle}>
-          {$n}
-         </td>
-         <td {$valueStyle}>
-          {$v}
-         </td>
-        </tr>
-       {/foreach}
-      {/foreach}
-     {/if}
-
-    </table>
-   </td>
-  </tr>
-
- </table>
-</center>
-
-</body>
-</html>
diff --git a/CRM/Upgrade/4.2.alpha2.msg_template/message_templates/event_offline_receipt_text.tpl b/CRM/Upgrade/4.2.alpha2.msg_template/message_templates/event_offline_receipt_text.tpl
deleted file mode 100644 (file)
index 32879bb..0000000
+++ /dev/null
@@ -1,274 +0,0 @@
-{if $event.confirm_email_text AND (not $isOnWaitlist AND not $isRequireApproval)}
-{$event.confirm_email_text}
-{/if}
-
-{if $isOnWaitlist}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{ts}You have been added to the WAIT LIST for this event.{/ts}
-
-{if $isPrimary}
-{ts}If space becomes available you will receive an email with a link to a web page where you can complete your registration.{/ts}
-
-{/if}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{elseif $isRequireApproval}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{ts}Your registration has been submitted.{/ts}
-
-{if $isPrimary}
-{ts}Once your registration has been reviewed, you will receive an email with a link to a web page where you can complete the registration process.{/ts}
-
-{/if}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{elseif $is_pay_later}
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$pay_later_receipt}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{else}
-
-{ts}Please print this confirmation for your records.{/ts}
-{/if}
-
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{ts}Event Information and Location{/ts}
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$event.event_title}
-{$event.event_start_date|crmDate}{if $event.event_end_date}-{if $event.event_end_date|date_format:"%Y%m%d" == $event.event_start_date|date_format:"%Y%m%d"}{$event.event_end_date|crmDate:0:1}{else}{$event.event_end_date|crmDate}{/if}{/if}
-
-{if $event.participant_role neq 'Attendee' and $defaultRole}
-{ts}Participant Role{/ts}: {$event.participant_role}
-{/if}
-
-{if $isShowLocation}
-{if $location.address.1.name}
-
-{$location.address.1.name}
-{/if}
-{if $location.address.1.street_address}{$location.address.1.street_address}
-{/if}
-{if $location.address.1.supplemental_address_1}{$location.address.1.supplemental_address_1}
-{/if}
-{if $location.address.1.supplemental_address_2}{$location.address.1.supplemental_address_2}
-{/if}
-{if $location.address.1.city}{$location.address.1.city} {$location.address.1.postal_code}{if $location.address.1.postal_code_suffix} - {$location.address.1.postal_code_suffix}{/if}
-{/if}
-
-{/if}{*End of isShowLocation condition*}
-
-{if $location.phone.1.phone || $location.email.1.email}
-
-{ts}Event Contacts:{/ts}
-{foreach from=$location.phone item=phone}
-{if $phone.phone}
-
-{if $phone.phone_type}{$phone.phone_type_display}{else}{ts}Phone{/ts}{/if}: {$phone.phone}{/if}
-{/foreach}
-{foreach from=$location.email item=eventEmail}
-{if $eventEmail.email}
-
-{ts}Email{/ts}: {$eventEmail.email}{/if}{/foreach}
-{/if}
-
-{capture assign=icalFeed}{crmURL p='civicrm/event/ical' q="reset=1&id=`$event.id`" h=0 a=1 fe=1}{/capture}
-{ts}Download iCalendar File:{/ts} {$icalFeed}
-{if $email}
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{ts}Registered Email{/ts}
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$email}
-{/if}
-{if $event.is_monetary} {* This section for Paid events only.*}
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$event.fee_label}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{if $lineItem}{foreach from=$lineItem item=value key=priceset}
-
-{if $value neq 'skip'}
-{if $isPrimary}
-{if $lineItem|@count GT 1} {* Header for multi participant registration cases. *}
-{ts 1=$priceset+1}Participant %1{/ts}
-{/if}
-{/if}
----------------------------------------------------------{if $pricesetFieldsCount }--------------------{/if}
-
-{capture assign=ts_item}{ts}Item{/ts}{/capture}
-{capture assign=ts_qty}{ts}Qty{/ts}{/capture}
-{capture assign=ts_each}{ts}Each{/ts}{/capture}
-{capture assign=ts_total}{ts}Total{/ts}{/capture}
-{capture assign=ts_participant_total}{if $pricesetFieldsCount }{ts}Total Participants{/ts}{/if}{/capture}
-{$ts_item|string_format:"%-30s"} {$ts_qty|string_format:"%5s"} {$ts_each|string_format:"%10s"} {$ts_total|string_format:"%10s"} {$ts_participant_total|string_format:"%10s"}
-----------------------------------------------------------{if $pricesetFieldsCount }--------------------{/if}
-
-{foreach from=$value item=line}
-{if $pricesetFieldsCount }{capture assign=ts_participant_count}{$line.participant_count}{/capture}{/if}
-{capture assign=ts_item}{if $line.html_type eq 'Text'}{$line.label}{else}{$line.field_title} - {$line.label}{/if} {if $line.description} {$line.description}{/if}{/capture}{$ts_item|truncate:30:"..."|string_format:"%-30s"} {$line.qty|string_format:"%5s"} {$line.unit_price|crmMoney|string_format:"%10s"} {$line.line_total|crmMoney|string_format:"%10s"} {$ts_participant_count|string_format:"%10s"}
-{/foreach}
-{/if}
-{/foreach}
-{/if}
-{if $amount && !$lineItem}
-{foreach from=$amount item=amnt key=level}{$amnt.amount|crmMoney} {$amnt.label}
-{/foreach}
-{/if}
-{if $isPrimary }
-
-{ts}Total Amount{/ts}: {$totalAmount|crmMoney} {if $hookDiscount.message}({$hookDiscount.message}){/if}
-
-{if $pricesetFieldsCount }
-      {assign var="count" value= 0}
-      {foreach from=$lineItem item=pcount}
-      {assign var="lineItemCount" value=0}
-      {if $pcount neq 'skip'}
-        {foreach from=$pcount item=p_count}
-        {assign var="lineItemCount" value=$lineItemCount+$p_count.participant_count}
-        {/foreach}
-        {if $lineItemCount < 1 }
-        {assign var="lineItemCount" value=1}
-        {/if}
-      {assign var="count" value=$count+$lineItemCount}
-      {/if}
-      {/foreach}
-
-{ts}Total Participants{/ts}: {$count}
-{/if}
-
-{if $is_pay_later }
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$pay_later_receipt}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{/if}
-
-{if $register_date}
-{ts}Registration Date{/ts}: {$register_date|crmDate}
-{/if}
-{if $receive_date}
-{ts}Transaction Date{/ts}: {$receive_date|crmDate}
-{/if}
-{if $contributionTypeName}
-{ts}Contribution Type{/ts}: {$contributionTypeName}
-{/if}
-{if $trxn_id}
-{ts}Transaction #{/ts}: {$trxn_id}
-{/if}
-{if $paidBy}
-{ts}Paid By{/ts}: {$paidBy}
-{/if}
-{if $checkNumber}
-{ts}Check Number{/ts}: {$checkNumber}
-{/if}
-{if $contributeMode ne 'notify' and !$isAmountzero and !$is_pay_later and !$isOnWaitlist and !$isRequireApproval}
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{ts}Billing Name and Address{/ts}
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$billingName}
-{$address}
-{/if}
-
-{if $contributeMode eq 'direct' and !$isAmountzero and !$is_pay_later and !$isOnWaitlist and !$isRequireApproval}
-===========================================================
-{ts}Credit Card Information{/ts}
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$credit_card_type}
-{$credit_card_number}
-{ts}Expires{/ts}: {$credit_card_exp_date|truncate:7:''|crmDate}
-{/if}
-{/if}
-{/if} {* End of conditional section for Paid events *}
-
-{if $customPre}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$customPre_grouptitle}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{foreach from=$customPre item=value key=customName}
-{if ( $trackingFields and ! in_array( $customName, $trackingFields ) ) or ! $trackingFields}
-{$customName}: {$value}
-{/if}
-{/foreach}
-{/if}
-
-{if $customPost}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$customPost_grouptitle}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{foreach from=$customPost item=value key=customName}
-{if ( $trackingFields and ! in_array( $customName, $trackingFields ) ) or ! $trackingFields}
-{$customName}: {$value}
-{/if}
-{/foreach}
-{/if}
-{if $customProfile}
-
-{foreach from=$customProfile item=value key=customName}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{ts 1=$customName+1}Participant Information - Participant %1{/ts}
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{foreach from=$value item=val key=field}
-{if $field eq 'additionalCustomPre' or $field eq 'additionalCustomPost' }
-{if $field eq 'additionalCustomPre' }
-----------------------------------------------------------{if $pricesetFieldsCount }--------------------{/if}
-
-{$additionalCustomPre_grouptitle}
-----------------------------------------------------------{if $pricesetFieldsCount }--------------------{/if}
-
-{else}
-----------------------------------------------------------{if $pricesetFieldsCount }--------------------{/if}
-
-{$additionalCustomPost_grouptitle}
-----------------------------------------------------------{if $pricesetFieldsCount }--------------------{/if}
-
-{/if}
-{foreach from=$val item=v key=f}
-{$f}: {$v}
-{/foreach}
-{/if}
-{/foreach}
-{/foreach}
-{/if}
-{if $customGroup}
-{foreach from=$customGroup item=value key=customName}
-=========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$customName}
-=========================================================={if $pricesetFieldsCount }===================={/if}
-
-{foreach from=$value item=v key=n}
-{$n}: {$v}
-{/foreach}
-{/foreach}
-{/if}
-
-
diff --git a/CRM/Upgrade/4.2.alpha2.msg_template/message_templates/event_online_receipt_html.tpl b/CRM/Upgrade/4.2.alpha2.msg_template/message_templates/event_online_receipt_html.tpl
deleted file mode 100644 (file)
index f48fc26..0000000
+++ /dev/null
@@ -1,457 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <title></title>
-</head>
-<body>
-
-{capture assign=headerStyle}colspan="2" style="text-align: left; padding: 4px; border-bottom: 1px solid #999; background-color: #eee;"{/capture}
-{capture assign=labelStyle }style="padding: 4px; border-bottom: 1px solid #999; background-color: #f7f7f7;"{/capture}
-{capture assign=valueStyle }style="padding: 4px; border-bottom: 1px solid #999;"{/capture}
-
-<center>
- <table width="500" border="0" cellpadding="0" cellspacing="0" id="crm-event_receipt" style="font-family: Arial, Verdana, sans-serif; text-align: left;">
-
-  <!-- BEGIN HEADER -->
-  <!-- You can add table row(s) here with logo or other header elements -->
-  <!-- END HEADER -->
-
-  <!-- BEGIN CONTENT -->
-
-  <tr>
-   <td>
-  <p>Dear {contact.display_name},</p>
-
-    {if $event.confirm_email_text AND (not $isOnWaitlist AND not $isRequireApproval)}
-     <p>{$event.confirm_email_text|htmlize}</p>
-
-    {else}
-  <p>Thank you for your participation.  This letter is a confirmation that your registration has been received and your status has been updated to <strong>{if $isOnWaitlist}waitlisted{else}registered{/if}</strong> for the following:</p>
-
-    {/if}
-
-    <p>
-    {if $isOnWaitlist}
-     <p>{ts}You have been added to the WAIT LIST for this event.{/ts}</p>
-     {if $isPrimary}
-       <p>{ts}If space becomes available you will receive an email with a link to a web page where you can complete your registration.{/ts}</p>
-     {/if}
-    {elseif $isRequireApproval}
-     <p>{ts}Your registration has been submitted.{/ts}</p>
-     {if $isPrimary}
-      <p>{ts}Once your registration has been reviewed, you will receive an email with a link to a web page where you can complete the registration process.{/ts}</p>
-     {/if}
-    {elseif $is_pay_later && !$isAmountzero}
-     <p>{$pay_later_receipt}</p> {* FIXME: this might be text rather than HTML *}
-    {else}
-     <p>{ts}Please print this confirmation for your records.{/ts}</p>
-    {/if}
-
-   </td>
-  </tr>
-  <tr>
-   <td>
-    <table width="500" style="border: 1px solid #999; margin: 1em 0em 1em; border-collapse: collapse;">
-     <tr>
-      <th {$headerStyle}>
-       {ts}Event Information and Location{/ts}
-      </th>
-     </tr>
-     <tr>
-      <td colspan="2" {$valueStyle}>
-       {$event.event_title}<br />
-       {$event.event_start_date|date_format:"%A"} {$event.event_start_date|crmDate}{if $event.event_end_date}-{if $event.event_end_date|date_format:"%Y%m%d" == $event.event_start_date|date_format:"%Y%m%d"}{$event.event_end_date|crmDate:0:1}{else}{$event.event_end_date|date_format:"%A"} {$event.event_end_date|crmDate}{/if}{/if}
-      </td>
-     </tr>
-
-
-     {if $conference_sessions}
-      <tr>
-       <td colspan="2" {$labelStyle}>
-  {ts}Your schedule:{/ts}
-       </td>
-      </tr>
-      <tr>
-       <td colspan="2" {$valueStyle}>
-  {assign var='group_by_day' value='NA'}
-  {foreach from=$conference_sessions item=session}
-   {if $session.start_date|date_format:"%Y/%m/%d" != $group_by_day|date_format:"%Y/%m/%d"}
-    {assign var='group_by_day' value=$session.start_date}
-          <em>{$group_by_day|date_format:"%m/%d/%Y"}</em><br />
-   {/if}
-   {$session.start_date|crmDate:0:1}{if $session.end_date}-{$session.end_date|crmDate:0:1}{/if} {$session.title}<br />
-   {if $session.location}&nbsp;&nbsp;&nbsp;&nbsp;{$session.location}<br />{/if}
-  {/foreach}
-       </td>
-      </tr>
-     {/if}
-
-     {if $event.participant_role neq 'Attendee' and $defaultRole}
-      <tr>
-       <td {$labelStyle}>
-        {ts}Participant Role{/ts}
-       </td>
-       <td {$valueStyle}>
-        {$event.participant_role}
-       </td>
-      </tr>
-     {/if}
-
-     {if $isShowLocation}
-      <tr>
-       <td colspan="2" {$valueStyle}>
-        {if $location.address.1.name}
-         {$location.address.1.name}<br />
-        {/if}
-        {if $location.address.1.street_address}
-         {$location.address.1.street_address}<br />
-        {/if}
-        {if $location.address.1.supplemental_address_1}
-         {$location.address.1.supplemental_address_1}<br />
-        {/if}
-        {if $location.address.1.supplemental_address_2}
-         {$location.address.1.supplemental_address_2}<br />
-        {/if}
-        {if $location.address.1.city}
-         {$location.address.1.city}, {$location.address.1.state_province} {$location.address.1.postal_code}{if $location.address.1.postal_code_suffix} - {$location.address.1.postal_code_suffix}{/if}<br />
-        {/if}
-       </td>
-      </tr>
-     {/if}
-
-     {if $location.phone.1.phone || $location.email.1.email}
-      <tr>
-       <td colspan="2" {$labelStyle}>
-        {ts}Event Contacts:{/ts}
-       </td>
-      </tr>
-      {foreach from=$location.phone item=phone}
-       {if $phone.phone}
-        <tr>
-         <td {$labelStyle}>
-          {if $phone.phone_type}
-           {$phone.phone_type_display}
-          {else}
-           {ts}Phone{/ts}
-          {/if}
-         </td>
-         <td {$valueStyle}>
-          {$phone.phone}
-         </td>
-        </tr>
-       {/if}
-      {/foreach}
-      {foreach from=$location.email item=eventEmail}
-       {if $eventEmail.email}
-        <tr>
-         <td {$labelStyle}>
-          {ts}Email{/ts}
-         </td>
-         <td {$valueStyle}>
-          {$eventEmail.email}
-         </td>
-        </tr>
-       {/if}
-      {/foreach}
-     {/if}
-     <tr>
-      <td colspan="2" {$valueStyle}>
-       {capture assign=icalFeed}{crmURL p='civicrm/event/ical' q="reset=1&id=`$event.id`" h=0 a=1 fe=1}{/capture}
-       <a href="{$icalFeed}">{ts}Download iCalendar File{/ts}</a>
-      </td>
-     </tr>
-    {if $event.is_share}
-        <tr>
-            <td colspan="2" {$valueStyle}>
-                {capture assign=eventUrl}{crmURL p='civicrm/event/info' q="id=`$event.id`&reset=1" a=true fe=1 h=1}{/capture}
-                {include file="CRM/common/SocialNetwork.tpl" emailMode=true url=$eventUrl title=$event.title pageURL=$eventUrl}
-            </td>
-        </tr>
-    {/if}
-    {if $payer.name}
-     <tr>
-       <th {$headerStyle}>
-         {ts}You were registered by:{/ts}
-       </th>
-     </tr>
-     <tr>
-       <td colspan="2" {$valueStyle}>
-        {$payer.name}
-       </td>
-     </tr>
-    {/if}
-    {if $event.is_monetary}
-
-      <tr>
-       <th {$headerStyle}>
-        {$event.fee_label}
-       </th>
-      </tr>
-
-      {if $lineItem}
-       {foreach from=$lineItem item=value key=priceset}
-        {if $value neq 'skip'}
-         {if $isPrimary}
-          {if $lineItem|@count GT 1} {* Header for multi participant registration cases. *}
-           <tr>
-            <td colspan="2" {$labelStyle}>
-             {ts 1=$priceset+1}Participant %1{/ts} {$part.$priceset.info}
-            </td>
-           </tr>
-          {/if}
-         {/if}
-         <tr>
-          <td colspan="2" {$valueStyle}>
-           <table> {* FIXME: style this table so that it looks like the text version (justification, etc.) *}
-            <tr>
-             <th>{ts}Item{/ts}</th>
-             <th>{ts}Qty{/ts}</th>
-             <th>{ts}Each{/ts}</th>
-             <th>{ts}Total{/ts}</th>
-       {if  $pricesetFieldsCount }<th>{ts}Total Participants{/ts}</th>{/if}
-            </tr>
-            {foreach from=$value item=line}
-             <tr>
-              <td>
-              {if $line.html_type eq 'Text'}{$line.label}{else}{$line.field_title} - {$line.label}{/if} {if $line.description}<div>{$line.description|truncate:30:"..."}</div>{/if}
-              </td>
-              <td>
-               {$line.qty}
-              </td>
-              <td>
-               {$line.unit_price|crmMoney}
-              </td>
-              <td>
-               {$line.line_total|crmMoney}
-              </td>
-        {if $pricesetFieldsCount }<td>{$line.participant_count}</td> {/if}
-             </tr>
-            {/foreach}
-           </table>
-          </td>
-         </tr>
-        {/if}
-       {/foreach}
-      {/if}
-
-      {if $amounts && !$lineItem}
-       {foreach from=$amounts item=amnt key=level}
-        <tr>
-         <td colspan="2" {$valueStyle}>
-          {$amnt.amount|crmMoney} {$amnt.label}
-         </td>
-        </tr>
-       {/foreach}
-      {/if}
-
-      {if $isPrimary}
-       <tr>
-        <td {$labelStyle}>
-         {ts}Total Amount{/ts}
-        </td>
-        <td {$valueStyle}>
-         {$totalAmount|crmMoney} {if $hookDiscount.message}({$hookDiscount.message}){/if}
-        </td>
-       </tr>
-       {if $pricesetFieldsCount }
-     <tr>
-       <td {$labelStyle}>
-      {ts}Total Participants{/ts}</td>
-      <td {$valueStyle}>
-      {assign var="count" value= 0}
-      {foreach from=$lineItem item=pcount}
-      {assign var="lineItemCount" value=0}
-      {if $pcount neq 'skip'}
-        {foreach from=$pcount item=p_count}
-        {assign var="lineItemCount" value=$lineItemCount+$p_count.participant_count}
-        {/foreach}
-      {if $lineItemCount < 1 }
-        {assign var="lineItemCount" value=1}
-      {/if}
-      {assign var="count" value=$count+$lineItemCount}
-      {/if}
-      {/foreach}
-     {$count}
-     </td> </tr>
-      {/if}
-       {if $is_pay_later}
-        <tr>
-         <td colspan="2" {$labelStyle}>
-          {$pay_later_receipt}
-         </td>
-        </tr>
-       {/if}
-
-       {if $register_date}
-        <tr>
-         <td {$labelStyle}>
-          {ts}Registration Date{/ts}
-         </td>
-         <td {$valueStyle}>
-          {$register_date|crmDate}
-         </td>
-        </tr>
-       {/if}
-
-       {if $receive_date}
-        <tr>
-         <td {$labelStyle}>
-          {ts}Transaction Date{/ts}
-         </td>
-         <td {$valueStyle}>
-          {$receive_date|crmDate}
-         </td>
-        </tr>
-       {/if}
-
-       {if $contributionTypeName}
-        <tr>
-         <td {$labelStyle}>
-          {ts}Contribution Type{/ts}
-         </td>
-         <td {$valueStyle}>
-          {$contributionTypeName}
-         </td>
-        </tr>
-       {/if}
-
-       {if $trxn_id}
-        <tr>
-         <td {$labelStyle}>
-          {ts}Transaction #{/ts}
-         </td>
-         <td {$valueStyle}>
-          {$trxn_id}
-         </td>
-        </tr>
-       {/if}
-
-       {if $paidBy}
-        <tr>
-         <td {$labelStyle}>
-          {ts}Paid By{/ts}
-         </td>
-         <td {$valueStyle}>
-         {$paidBy}
-         </td>
-        </tr>
-       {/if}
-
-       {if $checkNumber}
-        <tr>
-         <td {$labelStyle}>
-          {ts}Check Number{/ts}
-         </td>
-         <td {$valueStyle}>
-          {$checkNumber}
-         </td>
-        </tr>
-       {/if}
-
-       {if $contributeMode ne 'notify' and !$isAmountzero and !$is_pay_later and !$isOnWaitlist and !$isRequireApproval}
-        <tr>
-         <th {$headerStyle}>
-          {ts}Billing Name and Address{/ts}
-         </th>
-        </tr>
-        <tr>
-         <td colspan="2" {$valueStyle}>
-          {$billingName}<br />
-          {$address|nl2br}
-         </td>
-        </tr>
-       {/if}
-
-       {if $contributeMode eq 'direct' and !$isAmountzero and !$is_pay_later and !$isOnWaitlist and !$isRequireApproval}
-        <tr>
-         <th {$headerStyle}>
-          {ts}Credit Card Information{/ts}
-         </th>
-        </tr>
-        <tr>
-         <td colspan="2" {$valueStyle}>
-          {$credit_card_type}<br />
-          {$credit_card_number}<br />
-          {ts}Expires{/ts}: {$credit_card_exp_date|truncate:7:''|crmDate}
-         </td>
-        </tr>
-       {/if}
-
-      {/if}
-
-     {/if} {* End of conditional section for Paid events *}
-
-
-{if $customPre}
-{foreach from=$customPre item=customPr key=i}
-   <tr> <th {$headerStyle}>{$customPre_grouptitle.$i}</th></tr>
-   {foreach from=$customPr item=customValue key=customName}
-   {if ( $trackingFields and ! in_array( $customName, $trackingFields ) ) or ! $trackingFields}
-     <tr>
-         <td {$labelStyle}>{$customName}</td>
-         <td {$valueStyle}>{$customValue}</td>
-     </tr>
-   {/if}
-   {/foreach}
-{/foreach}
-{/if}
-
-{if $customPost}
-{foreach from=$customPost item=customPos key=j}
-   <tr> <th {$headerStyle}>{$customPost_grouptitle.$j}</th></tr>
-   {foreach from=$customPos item=customValue key=customName}
-   {if ( $trackingFields and ! in_array( $customName, $trackingFields ) ) or ! $trackingFields}
-     <tr>
-         <td {$labelStyle}>{$customName}</td>
-         <td {$valueStyle}>{$customValue}</td>
-     </tr>
-{/if}
-{/foreach}
-{/foreach}
-{/if}
-
-{if $customProfile}
-{foreach from=$customProfile.profile item=eachParticipant key=participantID}
-     <tr><th {$headerStyle}>{ts 1=$participantID+2}Participant %1{/ts} </th></tr>
-     {foreach from=$eachParticipant item=eachProfile key=pid}
-     <tr><th {$headerStyle}>{$customProfile.title.$pid}</th></tr>
-     {foreach from=$eachProfile item=val key=field}
-     <tr>{foreach from=$val item=v key=f}
-         <td {$labelStyle}>{$field}</td>
-         <td {$valueStyle}>{$v}</td>
-         {/foreach}
-     </tr>
-     {/foreach}
-{/foreach}
-{/foreach}
-{/if}
-
-    {if $customGroup}
-      {foreach from=$customGroup item=value key=customName}
-       <tr>
-        <th {$headerStyle}>
-         {$customName}
-        </th>
-       </tr>
-       {foreach from=$value item=v key=n}
-        <tr>
-         <td {$labelStyle}>
-          {$n}
-         </td>
-         <td {$valueStyle}>
-          {$v}
-         </td>
-        </tr>
-       {/foreach}
-      {/foreach}
-     {/if}
-
-    </table>
-   </td>
-  </tr>
- </table>
-</center>
-
-</body>
-</html>
diff --git a/CRM/Upgrade/4.2.alpha2.msg_template/message_templates/event_online_receipt_text.tpl b/CRM/Upgrade/4.2.alpha2.msg_template/message_templates/event_online_receipt_text.tpl
deleted file mode 100644 (file)
index 8696c6d..0000000
+++ /dev/null
@@ -1,286 +0,0 @@
-Dear {contact.display_name},
-
-{if $event.confirm_email_text AND (not $isOnWaitlist AND not $isRequireApproval)}
-{$event.confirm_email_text}
-
-{else}
-Thank you for your participation.  This letter is a confirmation that your registration has been received and your status has been updated to {if $participant_status}$participant_status{else}{if $isOnWaitlist}waitlisted{else}registered{/if}{/if} for the following:
-
-{/if}
-
-{if $isOnWaitlist}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{ts}You have been added to the WAIT LIST for this event.{/ts}
-
-{if $isPrimary}
-{ts}If space becomes available you will receive an email with a link to a web page where you can complete your registration.{/ts}
-{/if}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{elseif $isRequireApproval}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{ts}Your registration has been submitted.{/ts}
-
-{if $isPrimary}
-{ts}Once your registration has been reviewed, you will receive an email with a link to a web page where you can complete the registration process.{/ts}
-
-{/if}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{elseif $is_pay_later && !$isAmountzero}
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$pay_later_receipt}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{else}
-
-{ts}Please print this confirmation for your records.{/ts}
-{/if}
-
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{ts}Event Information and Location{/ts}
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$event.event_title}
-{$event.event_start_date|date_format:"%A"} {$event.event_start_date|crmDate}{if $event.event_end_date}-{if $event.event_end_date|date_format:"%Y%m%d" == $event.event_start_date|date_format:"%Y%m%d"}{$event.event_end_date|crmDate:0:1}{else}{$event.event_end_date|date_format:"%A"} {$event.event_end_date|crmDate}{/if}{/if}
-{if $conference_sessions}
-
-
-{ts}Your schedule:{/ts}
-{assign var='group_by_day' value='NA'}
-{foreach from=$conference_sessions item=session}
-{if $session.start_date|date_format:"%Y/%m/%d" != $group_by_day|date_format:"%Y/%m/%d"}
-{assign var='group_by_day' value=$session.start_date}
-
-{$group_by_day|date_format:"%m/%d/%Y"}
-
-
-{/if}
-{$session.start_date|crmDate:0:1}{if $session.end_date}-{$session.end_date|crmDate:0:1}{/if} {$session.title}
-{if $session.location}    {$session.location}{/if}
-{/foreach}
-{/if}
-
-{if $event.participant_role neq 'Attendee' and $defaultRole}
-{ts}Participant Role{/ts}: {$event.participant_role}
-{/if}
-
-{if $isShowLocation}
-{if $location.address.1.name}
-
-{$location.address.1.name}
-{/if}
-{if $location.address.1.street_address}{$location.address.1.street_address}
-{/if}
-{if $location.address.1.supplemental_address_1}{$location.address.1.supplemental_address_1}
-{/if}
-{if $location.address.1.supplemental_address_2}{$location.address.1.supplemental_address_2}
-{/if}
-{if $location.address.1.city}{$location.address.1.city}, {$location.address.1.state_province} {$location.address.1.postal_code}{if $location.address.1.postal_code_suffix} - {$location.address.1.postal_code_suffix}{/if}
-{/if}
-
-{/if}{*End of isShowLocation condition*}
-
-{if $location.phone.1.phone || $location.email.1.email}
-
-{ts}Event Contacts:{/ts}
-{foreach from=$location.phone item=phone}
-{if $phone.phone}
-
-{if $phone.phone_type}{$phone.phone_type_display}{else}{ts}Phone{/ts}{/if}: {$phone.phone}{/if}
-{/foreach}
-{foreach from=$location.email item=eventEmail}
-{if $eventEmail.email}
-
-{ts}Email{/ts}: {$eventEmail.email}{/if}{/foreach}
-{/if}
-
-{capture assign=icalFeed}{crmURL p='civicrm/event/ical' q="reset=1&id=`$event.id`" h=0 a=1 fe=1}{/capture}
-{ts}Download iCalendar File:{/ts} {$icalFeed}
-
-{if $payer.name}
-You were registered by: {$payer.name}
-{/if}
-{if $event.is_monetary} {* This section for Paid events only.*}
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$event.fee_label}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{if $lineItem}{foreach from=$lineItem item=value key=priceset}
-
-{if $value neq 'skip'}
-{if $isPrimary}
-{if $lineItem|@count GT 1} {* Header for multi participant registration cases. *}
-{ts 1=$priceset+1}Participant %1{/ts} {$part.$priceset.info}
-
-{/if}
-{/if}
------------------------------------------------------------{if $pricesetFieldsCount }--------------------{/if}
-
-{capture assign=ts_item}{ts}Item{/ts}{/capture}
-{capture assign=ts_qty}{ts}Qty{/ts}{/capture}
-{capture assign=ts_each}{ts}Each{/ts}{/capture}
-{capture assign=ts_total}{ts}Total{/ts}{/capture}
-{if $pricesetFieldsCount }{capture assign=ts_participant_total}{ts}Total Participants{/ts}{/capture}{/if}
-{$ts_item|string_format:"%-30s"} {$ts_qty|string_format:"%5s"} {$ts_each|string_format:"%10s"} {$ts_total|string_format:"%10s"} {$ts_participant_total|string_format:"%10s"}
------------------------------------------------------------{if $pricesetFieldsCount }--------------------{/if}
-
-{foreach from=$value item=line}
-{if $pricesetFieldsCount }{capture assign=ts_participant_count}{$line.participant_count}{/capture}{/if}
-{capture assign=ts_item}{if $line.html_type eq 'Text'}{$line.label}{else}{$line.field_title} - {$line.label}{/if} {if $line.description} {$line.description}{/if}{/capture}{$ts_item|truncate:30:"..."|string_format:"%-30s"} {$line.qty|string_format:"%5s"} {$line.unit_price|crmMoney|string_format:"%10s"} {$line.line_total|crmMoney|string_format:"%10s"}{$ts_participant_count|string_format:"%10s"}
-{/foreach}
-{/if}
-{/foreach}
-{/if}
-{if $amounts && !$lineItem}
-{foreach from=$amounts item=amnt key=level}{$amnt.amount|crmMoney} {$amnt.label}
-{/foreach}
-{/if}
-{if $isPrimary }
-
-{ts}Total Amount{/ts}: {$totalAmount|crmMoney} {if $hookDiscount.message}({$hookDiscount.message}){/if}
-
-{if $pricesetFieldsCount }
-      {assign var="count" value= 0}
-      {foreach from=$lineItem item=pcount}
-      {assign var="lineItemCount" value=0}
-      {if $pcount neq 'skip'}
-        {foreach from=$pcount item=p_count}
-        {assign var="lineItemCount" value=$lineItemCount+$p_count.participant_count}
-        {/foreach}
-      {if $lineItemCount < 1 }
-        {assign var="lineItemCount" value=1}
-      {/if}
-      {assign var="count" value=$count+$lineItemCount}
-      {/if}
-      {/foreach}
-
-{ts}Total Participants{/ts}: {$count}
-{/if}
-
-{if $is_pay_later}
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$pay_later_receipt}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{/if}
-
-{if $register_date}
-{ts}Registration Date{/ts}: {$register_date|crmDate}
-{/if}
-{if $receive_date}
-{ts}Transaction Date{/ts}: {$receive_date|crmDate}
-{/if}
-{if $contributionTypeName}
-{ts}Contribution Type{/ts}: {$contributionTypeName}
-{/if}
-{if $trxn_id}
-{ts}Transaction #{/ts}: {$trxn_id}
-{/if}
-{if $paidBy}
-{ts}Paid By{/ts}: {$paidBy}
-{/if}
-{if $checkNumber}
-{ts}Check Number{/ts}: {$checkNumber}
-{/if}
-{if $contributeMode ne 'notify' and !$isAmountzero and !$is_pay_later and !$isOnWaitlist and !$isRequireApproval}
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{ts}Billing Name and Address{/ts}
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$billingName}
-{$address}
-{/if}
-
-{if $contributeMode eq 'direct' and !$isAmountzero and !$is_pay_later and !$isOnWaitlist and !$isRequireApproval}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{ts}Credit Card Information{/ts}
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$credit_card_type}
-{$credit_card_number}
-{ts}Expires{/ts}: {$credit_card_exp_date|truncate:7:''|crmDate}
-{/if}
-{/if}
-{/if} {* End of conditional section for Paid events *}
-
-{if $customPre}
-{foreach from=$customPre item=customPr key=i}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$customPre_grouptitle.$i}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{foreach from=$customPr item=customValue key=customName}
-{if ( $trackingFields and ! in_array( $customName, $trackingFields ) ) or ! $trackingFields}
- {$customName}: {$customValue}
-{/if}
-{/foreach}
-{/foreach}
-{/if}
-
-{if $customPost}
-{foreach from=$customPost item=customPos key=j}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$customPost_grouptitle.$j}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{foreach from=$customPos item=customValue key=customName}
-{if ( $trackingFields and ! in_array( $customName, $trackingFields ) ) or ! $trackingFields}
- {$customName}: {$customValue}
-{/if}
-{/foreach}
-{/foreach}
-{/if}
-{if $customProfile}
-
-{foreach from=$customProfile.profile item=eachParticipant key=participantID}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{ts 1=$participantID+2}Participant Information - Participant %1{/ts}
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{foreach from=$eachParticipant item=eachProfile key=pid}
-----------------------------------------------------------{if $pricesetFieldsCount }--------------------{/if}
-
-{$customProfile.title.$pid}
-----------------------------------------------------------{if $pricesetFieldsCount }--------------------{/if}
-
-{foreach from=$eachProfile item=val key=field}
-{foreach from=$val item=v key=f}
-{$field}: {$v}
-{/foreach}
-{/foreach}
-{/foreach}
-{/foreach}
-{/if}
-{if $customGroup}
-{foreach from=$customGroup item=value key=customName}
-=========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$customName}
-=========================================================={if $pricesetFieldsCount }===================={/if}
-
-{foreach from=$value item=v key=n}
-{$n}: {$v}
-{/foreach}
-{/foreach}
-{/if}
diff --git a/CRM/Upgrade/4.2.alpha2.msg_template/message_templates/membership_offline_receipt_text.tpl b/CRM/Upgrade/4.2.alpha2.msg_template/message_templates/membership_offline_receipt_text.tpl
deleted file mode 100644 (file)
index 171fea2..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-{if $formValues.receipt_text_signup}
-{$formValues.receipt_text_signup}
-{elseif $formValues.receipt_text_renewal}
-{$formValues.receipt_text_renewal}
-{else}{ts}Thank you for your support.{/ts}{/if}
-
-{if ! $cancelled}{ts}Please print this receipt for your records.{/ts}
-
-
-{/if}
-{if !$lineItem}
-===========================================================
-{ts}Membership Information{/ts}
-
-===========================================================
-{ts}Membership Type{/ts}: {$membership_name}
-{/if}
-{if ! $cancelled}
-{if !$lineItem}
-{ts}Membership Start Date{/ts}: {$mem_start_date}
-{ts}Membership End Date{/ts}: {$mem_end_date}
-{/if}
-
-{if $formValues.total_amount}
-===========================================================
-{ts}Membership Fee{/ts}
-
-===========================================================
-{if $formValues.contributionType_name}
-{ts}Contribution Type{/ts}: {$formValues.contributionType_name}
-{/if}
-{if $lineItem}
-{foreach from=$lineItem item=value key=priceset}
-{capture assign=ts_item}{ts}Item{/ts}{/capture}
-{capture assign=ts_total}{ts}Fee{/ts}{/capture}
-{capture assign=ts_start_date}{ts}Membership Start Date{/ts}{/capture}
-{capture assign=ts_end_date}{ts}Membership End Date{/ts}{/capture}
-{$ts_item|string_format:"%-30s"} {$ts_total|string_format:"%10s"} {$ts_start_date|string_format:"%20s"} {$ts_end_date|string_format:"%20s"}
---------------------------------------------------------------------------------------------------
-
-{foreach from=$value item=line}
-{capture assign=ts_item}{if $line.html_type eq 'Text'}{$line.label}{else}{$line.field_title} - {$line.label}{/if} {if $line.description} {$line.description}{/if}{/capture}{$ts_item|truncate:30:"..."|string_format:"%-30s"} {$line.line_total|crmMoney|string_format:"%10s"} {$line.start_date|string_format:"%20s"} {$line.end_date|string_format:"%20s"}
-{/foreach}
-{/foreach}
---------------------------------------------------------------------------------------------------
-{/if}
-{ts}Amount{/ts}: {$formValues.total_amount|crmMoney}
-{if $receive_date}
-{ts}Received Date{/ts}: {$receive_date|truncate:10:''|crmDate}
-{/if}
-{if $formValues.paidBy}
-{ts}Paid By{/ts}: {$formValues.paidBy}
-{if $formValues.check_number}
-{ts}Check Number{/ts}: {$formValues.check_number}
-{/if}
-{/if}
-{/if}
-{/if}
-
-{if $isPrimary }
-{if $contributeMode ne 'notify' and !$isAmountzero and !$is_pay_later  }
-
-===========================================================
-{ts}Billing Name and Address{/ts}
-
-===========================================================
-{$billingName}
-{$address}
-{/if}
-
-{if $contributeMode eq 'direct' and !$isAmountzero and !$is_pay_later}
-===========================================================
-{ts}Credit Card Information{/ts}
-
-===========================================================
-{$credit_card_type}
-{$credit_card_number}
-{ts}Expires{/ts}: {$credit_card_exp_date|truncate:7:''|crmDate}
-{/if}
-{/if}
-
-{if $customValues}
-===========================================================
-{ts}Membership Options{/ts}
-
-===========================================================
-{foreach from=$customValues item=value key=customName}
- {$customName} : {$value}
-{/foreach}
-{/if}
diff --git a/CRM/Upgrade/4.2.alpha3.msg_template/civicrm_msg_template.tpl b/CRM/Upgrade/4.2.alpha3.msg_template/civicrm_msg_template.tpl
deleted file mode 100644 (file)
index 9ae70aa..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-{php}
-  $dir = SMARTY_DIR . '/../../CRM/Upgrade/4.2.alpha3.msg_template/message_templates';
-  $templates = array();
-  foreach (preg_grep('/\.tpl$/', scandir($dir)) as $filename) {
-    $parts = explode('_', basename($filename, '.tpl'));
-    $templates[] = array('type' => array_pop($parts), 'name' => implode('_', $parts), 'filename' => "$dir/$filename");
-  }
-  $this->assign('templates', $templates);
-{/php}
-
-{foreach from=$templates item=tpl}
-  {fetch assign=content file=$tpl.filename}
-  SELECT @workflow_id := MAX(id) FROM civicrm_option_value WHERE name = '{$tpl.name}';
-  SELECT @content := msg_{$tpl.type} FROM civicrm_msg_template WHERE workflow_id = @workflow_id AND is_reserved = 1 LIMIT 1;
-  UPDATE civicrm_msg_template SET msg_{$tpl.type} = '{$content|escape:"quotes"}' WHERE workflow_id = @workflow_id AND (is_reserved = 1 OR (is_default = 1 AND msg_{$tpl.type} = @content));
-{/foreach}
diff --git a/CRM/Upgrade/4.2.alpha3.msg_template/message_templates/contribution_online_receipt_text.tpl b/CRM/Upgrade/4.2.alpha3.msg_template/message_templates/contribution_online_receipt_text.tpl
deleted file mode 100644 (file)
index bcd6e97..0000000
+++ /dev/null
@@ -1,179 +0,0 @@
-{if $receipt_text}
-{$receipt_text}
-{/if}
-{if $is_pay_later}
-
-===========================================================
-{$pay_later_receipt}
-===========================================================
-{else}
-
-{ts}Please print this receipt for your records.{/ts}
-{/if}
-
-{if $amount}
-===========================================================
-{ts}Contribution Information{/ts}
-
-===========================================================
-{if $lineItem and $priceSetID and !$is_quick_config}
-{foreach from=$lineItem item=value key=priceset}
----------------------------------------------------------
-{capture assign=ts_item}{ts}Item{/ts}{/capture}
-{capture assign=ts_qty}{ts}Qty{/ts}{/capture}
-{capture assign=ts_each}{ts}Each{/ts}{/capture}
-{capture assign=ts_total}{ts}Total{/ts}{/capture}
-{$ts_item|string_format:"%-30s"} {$ts_qty|string_format:"%5s"} {$ts_each|string_format:"%10s"} {$ts_total|string_format:"%10s"}
-----------------------------------------------------------
-{foreach from=$value item=line}
-{capture assign=ts_item}{if $line.html_type eq 'Text'}{$line.label}{else}{$line.field_title} - {$line.label}{/if} {if $line.description} {$line.description}{/if}{/capture}{$ts_item|truncate:30:"..."|string_format:"%-30s"} {$line.qty|string_format:"%5s"} {$line.unit_price|crmMoney:$currency|string_format:"%10s"} {$line.line_total|crmMoney:$currency|string_format:"%10s"}
-{/foreach}
-{/foreach}
-
-{ts}Total Amount{/ts}: {$amount|crmMoney:$currency}
-{else}
-{ts}Amount{/ts}: {$amount|crmMoney:$currency} {if $amount_level } - {$amount_level} {/if}
-{/if}
-{/if}
-{if $receive_date}
-
-{ts}Date{/ts}: {$receive_date|crmDate}
-{/if}
-{if $is_monetary and $trxn_id}
-{ts}Transaction #{/ts}: {$trxn_id}
-{/if}
-
-{if $is_recur and ($contributeMode eq 'notify' or $contributeMode eq 'directIPN')}
-{ts}This is a recurring contribution. You can cancel future contributions at:{/ts}
-
-{$cancelSubscriptionUrl}
-
-{ts}You can update billing details for this recurring contribution at:{/ts}
-
-{$updateSubscriptionBillingUrl}
-
-{ts}You can update recurring contribution amount or change the number of installments for this recurring contribution at:{/ts}
-
-{$updateSubscriptionUrl}
-
-{/if}
-
-{if $honor_block_is_active }
-===========================================================
-{$honor_type}
-===========================================================
-{$honor_prefix} {$honor_first_name} {$honor_last_name}
-{if $honor_email}
-{ts}Honoree Email{/ts}: {$honor_email}
-{/if}
-
-{/if}
-{if $pcpBlock}
-===========================================================
-{ts}Personal Campaign Page{/ts}
-
-===========================================================
-{ts}Display In Honor Roll{/ts}: {if $pcp_display_in_roll}{ts}Yes{/ts}{else}{ts}No{/ts}{/if}
-
-{if $pcp_roll_nickname}{ts}Nickname{/ts}: {$pcp_roll_nickname}{/if}
-
-{if $pcp_personal_note}{ts}Personal Note{/ts}: {$pcp_personal_note}{/if}
-
-{/if}
-{if $onBehalfProfile}
-===========================================================
-{ts}On Behalf Of{/ts}
-
-===========================================================
-{foreach from=$onBehalfProfile item=onBehalfValue key=onBehalfName}
-{$onBehalfName}: {$onBehalfValue}
-{/foreach}
-{/if}
-
-{if !( $contributeMode eq 'notify' OR $contributeMode eq 'directIPN' ) and $is_monetary}
-{if $is_pay_later}
-===========================================================
-{ts}Registered Email{/ts}
-
-===========================================================
-{$email}
-{elseif $amount GT 0}
-===========================================================
-{ts}Billing Name and Address{/ts}
-
-===========================================================
-{$billingName}
-{$address}
-
-{$email}
-{/if} {* End ! is_pay_later condition. *}
-{/if}
-{if $contributeMode eq 'direct' AND !$is_pay_later AND $amount GT 0}
-
-===========================================================
-{ts}Credit Card Information{/ts}
-
-===========================================================
-{$credit_card_type}
-{$credit_card_number}
-{ts}Expires{/ts}: {$credit_card_exp_date|truncate:7:''|crmDate}
-{/if}
-
-{if $selectPremium }
-===========================================================
-{ts}Premium Information{/ts}
-
-===========================================================
-{$product_name}
-{if $option}
-{ts}Option{/ts}: {$option}
-{/if}
-{if $sku}
-{ts}SKU{/ts}: {$sku}
-{/if}
-{if $start_date}
-{ts}Start Date{/ts}: {$start_date|crmDate}
-{/if}
-{if $end_date}
-{ts}End Date{/ts}: {$end_date|crmDate}
-{/if}
-{if $contact_email OR $contact_phone}
-
-{ts}For information about this premium, contact:{/ts}
-
-{if $contact_email}
-  {$contact_email}
-{/if}
-{if $contact_phone}
-  {$contact_phone}
-{/if}
-{/if}
-{if $is_deductible AND $price}
-
-{ts 1=$price|crmMoney:$currency}The value of this premium is %1. This may affect the amount of the tax deduction you can claim. Consult your tax advisor for more information.{/ts}{/if}
-{/if}
-
-{if $customPre}
-===========================================================
-{$customPre_grouptitle}
-
-===========================================================
-{foreach from=$customPre item=customValue key=customName}
-{if ( $trackingFields and ! in_array( $customName, $trackingFields ) ) or ! $trackingFields}
- {$customName}: {$customValue}
-{/if}
-{/foreach}
-{/if}
-
-
-{if $customPost}
-===========================================================
-{$customPost_grouptitle}
-
-===========================================================
-{foreach from=$customPost item=customValue key=customName}
-{if ( $trackingFields and ! in_array( $customName, $trackingFields ) ) or ! $trackingFields}
- {$customName}: {$customValue}
-{/if}
-{/foreach}
-{/if}
diff --git a/CRM/Upgrade/4.2.beta3.msg_template/civicrm_msg_template.tpl b/CRM/Upgrade/4.2.beta3.msg_template/civicrm_msg_template.tpl
deleted file mode 100644 (file)
index 66f5a65..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-{php}
-  $dir = SMARTY_DIR . '/../../CRM/Upgrade/4.2.beta3.msg_template/message_templates';
-  $templates = array();
-  foreach (preg_grep('/\.tpl$/', scandir($dir)) as $filename) {
-    $parts = explode('_', basename($filename, '.tpl'));
-    $templates[] = array('type' => array_pop($parts), 'name' => implode('_', $parts), 'filename' => "$dir/$filename");
-  }
-  $this->assign('templates', $templates);
-{/php}
-
-{foreach from=$templates item=tpl}
-  {fetch assign=content file=$tpl.filename}
-  SELECT @workflow_id := MAX(id) FROM civicrm_option_value WHERE name = '{$tpl.name}';
-  SELECT @content := msg_{$tpl.type} FROM civicrm_msg_template WHERE workflow_id = @workflow_id AND is_reserved = 1 LIMIT 1;
-  UPDATE civicrm_msg_template SET msg_{$tpl.type} = '{$content|escape:"quotes"}' WHERE workflow_id = @workflow_id AND (is_reserved = 1 OR (is_default = 1 AND msg_{$tpl.type} = @content));
-{/foreach}
diff --git a/CRM/Upgrade/4.2.beta3.msg_template/message_templates/event_online_receipt_html.tpl b/CRM/Upgrade/4.2.beta3.msg_template/message_templates/event_online_receipt_html.tpl
deleted file mode 100644 (file)
index 9b257e5..0000000
+++ /dev/null
@@ -1,450 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <title></title>
-</head>
-<body>
-
-{capture assign=headerStyle}colspan="2" style="text-align: left; padding: 4px; border-bottom: 1px solid #999; background-color: #eee;"{/capture}
-{capture assign=labelStyle }style="padding: 4px; border-bottom: 1px solid #999; background-color: #f7f7f7;"{/capture}
-{capture assign=valueStyle }style="padding: 4px; border-bottom: 1px solid #999;"{/capture}
-
-<center>
- <table width="500" border="0" cellpadding="0" cellspacing="0" id="crm-event_receipt" style="font-family: Arial, Verdana, sans-serif; text-align: left;">
-
-  <!-- BEGIN HEADER -->
-  <!-- You can add table row(s) here with logo or other header elements -->
-  <!-- END HEADER -->
-
-  <!-- BEGIN CONTENT -->
-
-  <tr>
-   <td>
-  <p>Dear {contact.display_name},</p>
-
-    {if $event.confirm_email_text AND (not $isOnWaitlist AND not $isRequireApproval)}
-     <p>{$event.confirm_email_text|htmlize}</p>
-
-    {else}
-  <p>Thank you for your participation.  This letter is a confirmation that your registration has been received and your status has been updated to <strong>{if $isOnWaitlist}waitlisted{else}registered{/if}</strong> for the following:</p>
-
-    {/if}
-
-    <p>
-    {if $isOnWaitlist}
-     <p>{ts}You have been added to the WAIT LIST for this event.{/ts}</p>
-     {if $isPrimary}
-       <p>{ts}If space becomes available you will receive an email with a link to a web page where you can complete your registration.{/ts}</p>
-     {/if}
-    {elseif $isRequireApproval}
-     <p>{ts}Your registration has been submitted.{/ts}</p>
-     {if $isPrimary}
-      <p>{ts}Once your registration has been reviewed, you will receive an email with a link to a web page where you can complete the registration process.{/ts}</p>
-     {/if}
-    {elseif $is_pay_later && !$isAmountzero}
-     <p>{$pay_later_receipt}</p> {* FIXME: this might be text rather than HTML *}
-    {else}
-     <p>{ts}Please print this confirmation for your records.{/ts}</p>
-    {/if}
-
-   </td>
-  </tr>
-  <tr>
-   <td>
-    <table width="500" style="border: 1px solid #999; margin: 1em 0em 1em; border-collapse: collapse;">
-     <tr>
-      <th {$headerStyle}>
-       {ts}Event Information and Location{/ts}
-      </th>
-     </tr>
-     <tr>
-      <td colspan="2" {$valueStyle}>
-       {$event.event_title}<br />
-       {$event.event_start_date|date_format:"%A"} {$event.event_start_date|crmDate}{if $event.event_end_date}-{if $event.event_end_date|date_format:"%Y%m%d" == $event.event_start_date|date_format:"%Y%m%d"}{$event.event_end_date|crmDate:0:1}{else}{$event.event_end_date|date_format:"%A"} {$event.event_end_date|crmDate}{/if}{/if}
-      </td>
-     </tr>
-
-
-     {if $conference_sessions}
-      <tr>
-       <td colspan="2" {$labelStyle}>
-  {ts}Your schedule:{/ts}
-       </td>
-      </tr>
-      <tr>
-       <td colspan="2" {$valueStyle}>
-  {assign var='group_by_day' value='NA'}
-  {foreach from=$conference_sessions item=session}
-   {if $session.start_date|date_format:"%Y/%m/%d" != $group_by_day|date_format:"%Y/%m/%d"}
-    {assign var='group_by_day' value=$session.start_date}
-          <em>{$group_by_day|date_format:"%m/%d/%Y"}</em><br />
-   {/if}
-   {$session.start_date|crmDate:0:1}{if $session.end_date}-{$session.end_date|crmDate:0:1}{/if} {$session.title}<br />
-   {if $session.location}&nbsp;&nbsp;&nbsp;&nbsp;{$session.location}<br />{/if}
-  {/foreach}
-       </td>
-      </tr>
-     {/if}
-
-     {if $event.participant_role neq 'Attendee' and $defaultRole}
-      <tr>
-       <td {$labelStyle}>
-        {ts}Participant Role{/ts}
-       </td>
-       <td {$valueStyle}>
-        {$event.participant_role}
-       </td>
-      </tr>
-     {/if}
-
-     {if $isShowLocation}
-      <tr>
-       <td colspan="2" {$valueStyle}>
-        {if $location.address.1.name}
-         {$location.address.1.name}<br />
-        {/if}
-        {if $location.address.1.street_address}
-         {$location.address.1.street_address}<br />
-        {/if}
-        {if $location.address.1.supplemental_address_1}
-         {$location.address.1.supplemental_address_1}<br />
-        {/if}
-        {if $location.address.1.supplemental_address_2}
-         {$location.address.1.supplemental_address_2}<br />
-        {/if}
-        {if $location.address.1.city}
-         {$location.address.1.city}, {$location.address.1.state_province} {$location.address.1.postal_code}{if $location.address.1.postal_code_suffix} - {$location.address.1.postal_code_suffix}{/if}<br />
-        {/if}
-       </td>
-      </tr>
-     {/if}
-
-     {if $location.phone.1.phone || $location.email.1.email}
-      <tr>
-       <td colspan="2" {$labelStyle}>
-        {ts}Event Contacts:{/ts}
-       </td>
-      </tr>
-      {foreach from=$location.phone item=phone}
-       {if $phone.phone}
-        <tr>
-         <td {$labelStyle}>
-          {if $phone.phone_type}
-           {$phone.phone_type_display}
-          {else}
-           {ts}Phone{/ts}
-          {/if}
-         </td>
-         <td {$valueStyle}>
-          {$phone.phone}
-         </td>
-        </tr>
-       {/if}
-      {/foreach}
-      {foreach from=$location.email item=eventEmail}
-       {if $eventEmail.email}
-        <tr>
-         <td {$labelStyle}>
-          {ts}Email{/ts}
-         </td>
-         <td {$valueStyle}>
-          {$eventEmail.email}
-         </td>
-        </tr>
-       {/if}
-      {/foreach}
-     {/if}
-     <tr>
-      <td colspan="2" {$valueStyle}>
-       {capture assign=icalFeed}{crmURL p='civicrm/event/ical' q="reset=1&id=`$event.id`" h=0 a=1 fe=1}{/capture}
-       <a href="{$icalFeed}">{ts}Download iCalendar File{/ts}</a>
-      </td>
-     </tr>
-    {if $event.is_share}
-        <tr>
-            <td colspan="2" {$valueStyle}>
-                {capture assign=eventUrl}{crmURL p='civicrm/event/info' q="id=`$event.id`&reset=1" a=true fe=1 h=1}{/capture}
-                {include file="CRM/common/SocialNetwork.tpl" emailMode=true url=$eventUrl title=$event.title pageURL=$eventUrl}
-            </td>
-        </tr>
-    {/if}
-    {if $payer.name}
-     <tr>
-       <th {$headerStyle}>
-         {ts}You were registered by:{/ts}
-       </th>
-     </tr>
-     <tr>
-       <td colspan="2" {$valueStyle}>
-        {$payer.name}
-       </td>
-     </tr>
-    {/if}
-    {if $event.is_monetary}
-
-      <tr>
-       <th {$headerStyle}>
-        {$event.fee_label}
-       </th>
-      </tr>
-
-      {if $lineItem}
-       {foreach from=$lineItem item=value key=priceset}
-        {if $value neq 'skip'}
-         {if $isPrimary}
-          {if $lineItem|@count GT 1} {* Header for multi participant registration cases. *}
-           <tr>
-            <td colspan="2" {$labelStyle}>
-             {ts 1=$priceset+1}Participant %1{/ts} {$part.$priceset.info}
-            </td>
-           </tr>
-          {/if}
-         {/if}
-         <tr>
-          <td colspan="2" {$valueStyle}>
-           <table> {* FIXME: style this table so that it looks like the text version (justification, etc.) *}
-            <tr>
-             <th>{ts}Item{/ts}</th>
-             <th>{ts}Qty{/ts}</th>
-             <th>{ts}Each{/ts}</th>
-             <th>{ts}Total{/ts}</th>
-       {if  $pricesetFieldsCount }<th>{ts}Total Participants{/ts}</th>{/if}
-            </tr>
-            {foreach from=$value item=line}
-             <tr>
-              <td>
-              {if $line.html_type eq 'Text'}{$line.label}{else}{$line.field_title} - {$line.label}{/if} {if $line.description}<div>{$line.description|truncate:30:"..."}</div>{/if}
-              </td>
-              <td>
-               {$line.qty}
-              </td>
-              <td>
-               {$line.unit_price|crmMoney}
-              </td>
-              <td>
-               {$line.line_total|crmMoney}
-              </td>
-        {if $pricesetFieldsCount }<td>{$line.participant_count}</td> {/if}
-             </tr>
-            {/foreach}
-           </table>
-          </td>
-         </tr>
-        {/if}
-       {/foreach}
-      {/if}
-
-      {if $amounts && !$lineItem}
-       {foreach from=$amounts item=amnt key=level}
-        <tr>
-         <td colspan="2" {$valueStyle}>
-          {$amnt.amount|crmMoney} {$amnt.label}
-         </td>
-        </tr>
-       {/foreach}
-      {/if}
-
-      {if $isPrimary}
-       <tr>
-        <td {$labelStyle}>
-         {ts}Total Amount{/ts}
-        </td>
-        <td {$valueStyle}>
-         {$totalAmount|crmMoney} {if $hookDiscount.message}({$hookDiscount.message}){/if}
-        </td>
-       </tr>
-       {if $pricesetFieldsCount }
-     <tr>
-       <td {$labelStyle}>
-      {ts}Total Participants{/ts}</td>
-      <td {$valueStyle}>
-      {assign var="count" value= 0}
-      {foreach from=$lineItem item=pcount}
-      {assign var="lineItemCount" value=0}
-      {if $pcount neq 'skip'}
-        {foreach from=$pcount item=p_count}
-        {assign var="lineItemCount" value=$lineItemCount+$p_count.participant_count}
-        {/foreach}
-      {if $lineItemCount < 1 }
-        {assign var="lineItemCount" value=1}
-      {/if}
-      {assign var="count" value=$count+$lineItemCount}
-      {/if}
-      {/foreach}
-     {$count}
-     </td> </tr>
-      {/if}
-
-       {if $register_date}
-        <tr>
-         <td {$labelStyle}>
-          {ts}Registration Date{/ts}
-         </td>
-         <td {$valueStyle}>
-          {$register_date|crmDate}
-         </td>
-        </tr>
-       {/if}
-
-       {if $receive_date}
-        <tr>
-         <td {$labelStyle}>
-          {ts}Transaction Date{/ts}
-         </td>
-         <td {$valueStyle}>
-          {$receive_date|crmDate}
-         </td>
-        </tr>
-       {/if}
-
-       {if $contributionTypeName}
-        <tr>
-         <td {$labelStyle}>
-          {ts}Contribution Type{/ts}
-         </td>
-         <td {$valueStyle}>
-          {$contributionTypeName}
-         </td>
-        </tr>
-       {/if}
-
-       {if $trxn_id}
-        <tr>
-         <td {$labelStyle}>
-          {ts}Transaction #{/ts}
-         </td>
-         <td {$valueStyle}>
-          {$trxn_id}
-         </td>
-        </tr>
-       {/if}
-
-       {if $paidBy}
-        <tr>
-         <td {$labelStyle}>
-          {ts}Paid By{/ts}
-         </td>
-         <td {$valueStyle}>
-         {$paidBy}
-         </td>
-        </tr>
-       {/if}
-
-       {if $checkNumber}
-        <tr>
-         <td {$labelStyle}>
-          {ts}Check Number{/ts}
-         </td>
-         <td {$valueStyle}>
-          {$checkNumber}
-         </td>
-        </tr>
-       {/if}
-
-       {if $contributeMode ne 'notify' and !$isAmountzero and !$is_pay_later and !$isOnWaitlist and !$isRequireApproval}
-        <tr>
-         <th {$headerStyle}>
-          {ts}Billing Name and Address{/ts}
-         </th>
-        </tr>
-        <tr>
-         <td colspan="2" {$valueStyle}>
-          {$billingName}<br />
-          {$address|nl2br}
-         </td>
-        </tr>
-       {/if}
-
-       {if $contributeMode eq 'direct' and !$isAmountzero and !$is_pay_later and !$isOnWaitlist and !$isRequireApproval}
-        <tr>
-         <th {$headerStyle}>
-          {ts}Credit Card Information{/ts}
-         </th>
-        </tr>
-        <tr>
-         <td colspan="2" {$valueStyle}>
-          {$credit_card_type}<br />
-          {$credit_card_number}<br />
-          {ts}Expires{/ts}: {$credit_card_exp_date|truncate:7:''|crmDate}
-         </td>
-        </tr>
-       {/if}
-
-      {/if}
-
-     {/if} {* End of conditional section for Paid events *}
-
-
-{if $customPre}
-{foreach from=$customPre item=customPr key=i}
-   <tr> <th {$headerStyle}>{$customPre_grouptitle.$i}</th></tr>
-   {foreach from=$customPr item=customValue key=customName}
-   {if ( $trackingFields and ! in_array( $customName, $trackingFields ) ) or ! $trackingFields}
-     <tr>
-         <td {$labelStyle}>{$customName}</td>
-         <td {$valueStyle}>{$customValue}</td>
-     </tr>
-   {/if}
-   {/foreach}
-{/foreach}
-{/if}
-
-{if $customPost}
-{foreach from=$customPost item=customPos key=j}
-   <tr> <th {$headerStyle}>{$customPost_grouptitle.$j}</th></tr>
-   {foreach from=$customPos item=customValue key=customName}
-   {if ( $trackingFields and ! in_array( $customName, $trackingFields ) ) or ! $trackingFields}
-     <tr>
-         <td {$labelStyle}>{$customName}</td>
-         <td {$valueStyle}>{$customValue}</td>
-     </tr>
-{/if}
-{/foreach}
-{/foreach}
-{/if}
-
-{if $customProfile}
-{foreach from=$customProfile.profile item=eachParticipant key=participantID}
-     <tr><th {$headerStyle}>{ts 1=$participantID+2}Participant %1{/ts} </th></tr>
-     {foreach from=$eachParticipant item=eachProfile key=pid}
-     <tr><th {$headerStyle}>{$customProfile.title.$pid}</th></tr>
-     {foreach from=$eachProfile item=val key=field}
-     <tr>{foreach from=$val item=v key=f}
-         <td {$labelStyle}>{$field}</td>
-         <td {$valueStyle}>{$v}</td>
-         {/foreach}
-     </tr>
-     {/foreach}
-{/foreach}
-{/foreach}
-{/if}
-
-    {if $customGroup}
-      {foreach from=$customGroup item=value key=customName}
-       <tr>
-        <th {$headerStyle}>
-         {$customName}
-        </th>
-       </tr>
-       {foreach from=$value item=v key=n}
-        <tr>
-         <td {$labelStyle}>
-          {$n}
-         </td>
-         <td {$valueStyle}>
-          {$v}
-         </td>
-        </tr>
-       {/foreach}
-      {/foreach}
-     {/if}
-
-    </table>
-   </td>
-  </tr>
- </table>
-</center>
-
-</body>
-</html>
diff --git a/CRM/Upgrade/4.2.beta3.msg_template/message_templates/event_online_receipt_text.tpl b/CRM/Upgrade/4.2.beta3.msg_template/message_templates/event_online_receipt_text.tpl
deleted file mode 100644 (file)
index 56527f5..0000000
+++ /dev/null
@@ -1,277 +0,0 @@
-Dear {contact.display_name},
-
-{if $event.confirm_email_text AND (not $isOnWaitlist AND not $isRequireApproval)}
-{$event.confirm_email_text}
-
-{else}
-Thank you for your participation.  This letter is a confirmation that your registration has been received and your status has been updated to {if $participant_status}$participant_status{else}{if $isOnWaitlist}waitlisted{else}registered{/if}{/if} for the following:
-
-{/if}
-
-{if $isOnWaitlist}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{ts}You have been added to the WAIT LIST for this event.{/ts}
-
-{if $isPrimary}
-{ts}If space becomes available you will receive an email with a link to a web page where you can complete your registration.{/ts}
-{/if}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{elseif $isRequireApproval}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{ts}Your registration has been submitted.{/ts}
-
-{if $isPrimary}
-{ts}Once your registration has been reviewed, you will receive an email with a link to a web page where you can complete the registration process.{/ts}
-
-{/if}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{elseif $is_pay_later && !$isAmountzero}
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$pay_later_receipt}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{else}
-
-{ts}Please print this confirmation for your records.{/ts}
-{/if}
-
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{ts}Event Information and Location{/ts}
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$event.event_title}
-{$event.event_start_date|date_format:"%A"} {$event.event_start_date|crmDate}{if $event.event_end_date}-{if $event.event_end_date|date_format:"%Y%m%d" == $event.event_start_date|date_format:"%Y%m%d"}{$event.event_end_date|crmDate:0:1}{else}{$event.event_end_date|date_format:"%A"} {$event.event_end_date|crmDate}{/if}{/if}
-{if $conference_sessions}
-
-
-{ts}Your schedule:{/ts}
-{assign var='group_by_day' value='NA'}
-{foreach from=$conference_sessions item=session}
-{if $session.start_date|date_format:"%Y/%m/%d" != $group_by_day|date_format:"%Y/%m/%d"}
-{assign var='group_by_day' value=$session.start_date}
-
-{$group_by_day|date_format:"%m/%d/%Y"}
-
-
-{/if}
-{$session.start_date|crmDate:0:1}{if $session.end_date}-{$session.end_date|crmDate:0:1}{/if} {$session.title}
-{if $session.location}    {$session.location}{/if}
-{/foreach}
-{/if}
-
-{if $event.participant_role neq 'Attendee' and $defaultRole}
-{ts}Participant Role{/ts}: {$event.participant_role}
-{/if}
-
-{if $isShowLocation}
-{if $location.address.1.name}
-
-{$location.address.1.name}
-{/if}
-{if $location.address.1.street_address}{$location.address.1.street_address}
-{/if}
-{if $location.address.1.supplemental_address_1}{$location.address.1.supplemental_address_1}
-{/if}
-{if $location.address.1.supplemental_address_2}{$location.address.1.supplemental_address_2}
-{/if}
-{if $location.address.1.city}{$location.address.1.city}, {$location.address.1.state_province} {$location.address.1.postal_code}{if $location.address.1.postal_code_suffix} - {$location.address.1.postal_code_suffix}{/if}
-{/if}
-
-{/if}{*End of isShowLocation condition*}
-
-{if $location.phone.1.phone || $location.email.1.email}
-
-{ts}Event Contacts:{/ts}
-{foreach from=$location.phone item=phone}
-{if $phone.phone}
-
-{if $phone.phone_type}{$phone.phone_type_display}{else}{ts}Phone{/ts}{/if}: {$phone.phone}{/if}
-{/foreach}
-{foreach from=$location.email item=eventEmail}
-{if $eventEmail.email}
-
-{ts}Email{/ts}: {$eventEmail.email}{/if}{/foreach}
-{/if}
-
-{capture assign=icalFeed}{crmURL p='civicrm/event/ical' q="reset=1&id=`$event.id`" h=0 a=1 fe=1}{/capture}
-{ts}Download iCalendar File:{/ts} {$icalFeed}
-
-{if $payer.name}
-You were registered by: {$payer.name}
-{/if}
-{if $event.is_monetary} {* This section for Paid events only.*}
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$event.fee_label}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{if $lineItem}{foreach from=$lineItem item=value key=priceset}
-
-{if $value neq 'skip'}
-{if $isPrimary}
-{if $lineItem|@count GT 1} {* Header for multi participant registration cases. *}
-{ts 1=$priceset+1}Participant %1{/ts} {$part.$priceset.info}
-
-{/if}
-{/if}
------------------------------------------------------------{if $pricesetFieldsCount }--------------------{/if}
-
-{capture assign=ts_item}{ts}Item{/ts}{/capture}
-{capture assign=ts_qty}{ts}Qty{/ts}{/capture}
-{capture assign=ts_each}{ts}Each{/ts}{/capture}
-{capture assign=ts_total}{ts}Total{/ts}{/capture}
-{if $pricesetFieldsCount }{capture assign=ts_participant_total}{ts}Total Participants{/ts}{/capture}{/if}
-{$ts_item|string_format:"%-30s"} {$ts_qty|string_format:"%5s"} {$ts_each|string_format:"%10s"} {$ts_total|string_format:"%10s"} {$ts_participant_total|string_format:"%10s"}
------------------------------------------------------------{if $pricesetFieldsCount }--------------------{/if}
-
-{foreach from=$value item=line}
-{if $pricesetFieldsCount }{capture assign=ts_participant_count}{$line.participant_count}{/capture}{/if}
-{capture assign=ts_item}{if $line.html_type eq 'Text'}{$line.label}{else}{$line.field_title} - {$line.label}{/if} {if $line.description} {$line.description}{/if}{/capture}{$ts_item|truncate:30:"..."|string_format:"%-30s"} {$line.qty|string_format:"%5s"} {$line.unit_price|crmMoney|string_format:"%10s"} {$line.line_total|crmMoney|string_format:"%10s"}{$ts_participant_count|string_format:"%10s"}
-{/foreach}
-{/if}
-{/foreach}
-{/if}
-{if $amounts && !$lineItem}
-{foreach from=$amounts item=amnt key=level}{$amnt.amount|crmMoney} {$amnt.label}
-{/foreach}
-{/if}
-{if $isPrimary }
-
-{ts}Total Amount{/ts}: {$totalAmount|crmMoney} {if $hookDiscount.message}({$hookDiscount.message}){/if}
-
-{if $pricesetFieldsCount }
-      {assign var="count" value= 0}
-      {foreach from=$lineItem item=pcount}
-      {assign var="lineItemCount" value=0}
-      {if $pcount neq 'skip'}
-        {foreach from=$pcount item=p_count}
-        {assign var="lineItemCount" value=$lineItemCount+$p_count.participant_count}
-        {/foreach}
-      {if $lineItemCount < 1 }
-        {assign var="lineItemCount" value=1}
-      {/if}
-      {assign var="count" value=$count+$lineItemCount}
-      {/if}
-      {/foreach}
-
-{ts}Total Participants{/ts}: {$count}
-{/if}
-
-{if $register_date}
-{ts}Registration Date{/ts}: {$register_date|crmDate}
-{/if}
-{if $receive_date}
-{ts}Transaction Date{/ts}: {$receive_date|crmDate}
-{/if}
-{if $contributionTypeName}
-{ts}Contribution Type{/ts}: {$contributionTypeName}
-{/if}
-{if $trxn_id}
-{ts}Transaction #{/ts}: {$trxn_id}
-{/if}
-{if $paidBy}
-{ts}Paid By{/ts}: {$paidBy}
-{/if}
-{if $checkNumber}
-{ts}Check Number{/ts}: {$checkNumber}
-{/if}
-{if $contributeMode ne 'notify' and !$isAmountzero and !$is_pay_later and !$isOnWaitlist and !$isRequireApproval}
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{ts}Billing Name and Address{/ts}
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$billingName}
-{$address}
-{/if}
-
-{if $contributeMode eq 'direct' and !$isAmountzero and !$is_pay_later and !$isOnWaitlist and !$isRequireApproval}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{ts}Credit Card Information{/ts}
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$credit_card_type}
-{$credit_card_number}
-{ts}Expires{/ts}: {$credit_card_exp_date|truncate:7:''|crmDate}
-{/if}
-{/if}
-{/if} {* End of conditional section for Paid events *}
-
-{if $customPre}
-{foreach from=$customPre item=customPr key=i}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$customPre_grouptitle.$i}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{foreach from=$customPr item=customValue key=customName}
-{if ( $trackingFields and ! in_array( $customName, $trackingFields ) ) or ! $trackingFields}
- {$customName}: {$customValue}
-{/if}
-{/foreach}
-{/foreach}
-{/if}
-
-{if $customPost}
-{foreach from=$customPost item=customPos key=j}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$customPost_grouptitle.$j}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{foreach from=$customPos item=customValue key=customName}
-{if ( $trackingFields and ! in_array( $customName, $trackingFields ) ) or ! $trackingFields}
- {$customName}: {$customValue}
-{/if}
-{/foreach}
-{/foreach}
-{/if}
-{if $customProfile}
-
-{foreach from=$customProfile.profile item=eachParticipant key=participantID}
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{ts 1=$participantID+2}Participant Information - Participant %1{/ts}
-
-==========================================================={if $pricesetFieldsCount }===================={/if}
-
-{foreach from=$eachParticipant item=eachProfile key=pid}
-----------------------------------------------------------{if $pricesetFieldsCount }--------------------{/if}
-
-{$customProfile.title.$pid}
-----------------------------------------------------------{if $pricesetFieldsCount }--------------------{/if}
-
-{foreach from=$eachProfile item=val key=field}
-{foreach from=$val item=v key=f}
-{$field}: {$v}
-{/foreach}
-{/foreach}
-{/foreach}
-{/foreach}
-{/if}
-{if $customGroup}
-{foreach from=$customGroup item=value key=customName}
-=========================================================={if $pricesetFieldsCount }===================={/if}
-
-{$customName}
-=========================================================={if $pricesetFieldsCount }===================={/if}
-
-{foreach from=$value item=v key=n}
-{$n}: {$v}
-{/foreach}
-{/foreach}
-{/if}
index b13361347cc851e1c98e270d21b95afb635565dd..01bc78a704409aadff75a95b22f7ec755f612b95 100644 (file)
@@ -45,7 +45,7 @@ class CRM_Upgrade_Form extends CRM_Core_Form {
   /**
    * Minimum previous CiviCRM version we can directly upgrade from
    */
-  const MINIMUM_UPGRADABLE_VERSION = '4.1.3';
+  const MINIMUM_UPGRADABLE_VERSION = '4.2.9';
 
   /**
    * Minimum php version required to run (equal to or lower than the minimum install version)
index 5a7770673bec79002e41fabdae7b3c2461c0e3db..4d53374bd264605b8148d4221d4e2bddff367d40 100644 (file)
@@ -199,13 +199,13 @@ class CRM_Upgrade_Incremental_Base {
    * Do any relevant smart group updates.
    *
    * @param CRM_Queue_TaskContext $ctx
-   * @param string $version
+   * @param array $actions
    *
    * @return bool
    */
-  public function updateSmartGroups($ctx, $version) {
-    $groupUpdateObject = new CRM_Upgrade_Incremental_SmartGroups($version);
-    $groupUpdateObject->updateGroups();
+  public function updateSmartGroups($ctx, $actions) {
+    $groupUpdateObject = new CRM_Upgrade_Incremental_SmartGroups();
+    $groupUpdateObject->updateGroups($actions);
     return TRUE;
   }
 
index 407cfa7a2f25403e55244175f6c258c0de858035..ba754a3bb7710891933ade3888ce1ed912b0ca8b 100644 (file)
@@ -102,7 +102,16 @@ class CRM_Upgrade_Incremental_MessageTemplates {
           ['name' => 'membership_online_receipt', 'type' => 'text'],
           ['name' => 'membership_online_receipt', 'type' => 'html'],
         ]
-      ]
+      ],
+      [
+        'version' => '5.12.alpha1',
+        'upgrade_descriptor' => ts('Update payment notification to remove print text, use email greeting'),
+        'label' => ts('Payment notification'),
+        'templates' => [
+          ['name' => 'payment_or_refund_notification', 'type' => 'text'],
+          ['name' => 'payment_or_refund_notification', 'type' => 'html'],
+        ]
+      ],
     ];
   }
 
index f4181d83192b8e76c18c60ae435808a7c1938d82..3c0500a6ec5c7b4676ca8aeeb068f78b5c39b70f 100644 (file)
 class CRM_Upgrade_Incremental_SmartGroups {
 
   /**
-   * Version we are upgrading to.
-   *
-   * @var string
-   */
-  protected $upgradeVersion;
-
-  /**
-   * @return string
-   */
-  public function getUpgradeVersion() {
-    return $this->upgradeVersion;
-  }
-
-  /**
-   * @param string $upgradeVersion
-   */
-  public function setUpgradeVersion($upgradeVersion) {
-    $this->upgradeVersion = $upgradeVersion;
-  }
-
-  /**
-   * CRM_Upgrade_Incremental_MessageTemplates constructor.
-   *
-   * @param string $upgradeVersion
-   */
-  public function __construct($upgradeVersion) {
-    $this->setUpgradeVersion($upgradeVersion);
-  }
-
-  /**
-   * Get any conversions required for saved smart groups.
-   *
-   * @return array
+   * Perform updates specified by upgrade function.
    */
-  public function getSmartGroupConversions() {
-    return [
-      [
-        'version' => '5.11.alpha1',
-        'upgrade_descriptors' => [ts('Upgrade grant smart groups to datepicker format')],
-        'actions' => [
-          'function' => 'datepickerConversion',
-          'fields' => [
-            'grant_application_received_date',
-            'grant_decision_date',
-            'grant_money_transfer_date',
-            'grant_due_date'
-          ]
-        ]
-      ]
-    ];
+  public function updateGroups($actions) {
+    foreach ($actions as $func => $fields) {
+      $this->{$func}($fields);
+    }
   }
 
   /**
@@ -138,33 +94,6 @@ class CRM_Upgrade_Incremental_SmartGroups {
     }
   }
 
-  /**
-   * Update message templates.
-   */
-  public function updateGroups() {
-    $conversions = $this->getSmartGroupConversionsToApply();
-    foreach ($conversions as $conversion) {
-      $function = $conversion['function'];
-      $this->{$function}($conversion['fields']);
-    }
-  }
-
-  /**
-   * Get any required template updates.
-   *
-   * @return array
-   */
-  public function getSmartGroupConversionsToApply() {
-    $conversions = $this->getSmartGroupConversions();
-    $return = [];
-    foreach ($conversions as $conversion) {
-      if ($conversion['version'] === $this->getUpgradeVersion()) {
-        $return[] = $conversion['actions'];
-      }
-    }
-    return $return;
-  }
-
   /**
    * Get converted date value.
    *
index 2f34ba0962e6795c20f32af3b353a1bc2b07f428..8928d08132a5e7bc548b721769f0f8fb683b80af 100644 (file)
@@ -74,7 +74,14 @@ class CRM_Upgrade_Incremental_php_FiveEleven extends CRM_Upgrade_Incremental_Bas
    */
   public function upgrade_5_11_alpha1($rev) {
     $this->addTask(ts('Upgrade DB to %1: SQL', array(1 => $rev)), 'runSql', $rev);
-    $this->addTask('Update smart groups where jcalendar fields have been converted to datepicker', 'updateSmartGroups', $rev);
+    $this->addTask('Update smart groups where jcalendar fields have been converted to datepicker', 'updateSmartGroups', [
+      'datepickerConversion' => [
+        'grant_application_received_date',
+        'grant_decision_date',
+        'grant_money_transfer_date',
+        'grant_due_date'
+      ]
+    ]);
     if (Civi::settings()->get('civimail_multiple_bulk_emails')) {
       $this->addTask('Update any on hold groups to reflect field change', 'updateOnHold', $rev);
     }
diff --git a/CRM/Upgrade/Incremental/php/FiveTwelve.php b/CRM/Upgrade/Incremental/php/FiveTwelve.php
new file mode 100644 (file)
index 0000000..e514d65
--- /dev/null
@@ -0,0 +1,84 @@
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 5                                                  |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2019                                |
+ +--------------------------------------------------------------------+
+ | This file is a part of CiviCRM.                                    |
+ |                                                                    |
+ | CiviCRM is free software; you can copy, modify, and distribute it  |
+ | under the terms of the GNU Affero General Public License           |
+ | Version 3, 19 November 2007.                                       |
+ |                                                                    |
+ | CiviCRM is distributed in the hope that it will be useful, but     |
+ | WITHOUT ANY WARRANTY; without even the implied warranty of         |
+ | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
+ | See the GNU Affero General Public License for more details.        |
+ |                                                                    |
+ | You should have received a copy of the GNU Affero General Public   |
+ | License along with this program; if not, contact CiviCRM LLC       |
+ | at info[AT]civicrm[DOT]org. If you have questions about the        |
+ | GNU Affero General Public License or the licensing of CiviCRM,     |
+ | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
+ +--------------------------------------------------------------------+
+ */
+
+/**
+ * Upgrade logic for FiveTwelve */
+class CRM_Upgrade_Incremental_php_FiveTwelve extends CRM_Upgrade_Incremental_Base {
+
+  /**
+   * Compute any messages which should be displayed beforeupgrade.
+   *
+   * Note: This function is called iteratively for each upcoming
+   * revision to the database.
+   *
+   * @param string $preUpgradeMessage
+   * @param string $rev
+   *   a version number, e.g. '4.4.alpha1', '4.4.beta3', '4.4.0'.
+   * @param null $currentVer
+   */
+  public function setPreUpgradeMessage(&$preUpgradeMessage, $rev, $currentVer = NULL) {
+    // Example: Generate a pre-upgrade message.
+    // if ($rev == '5.12.34') {
+    //   $preUpgradeMessage .= '<p>' . ts('A new permission, "%1", has been added. This permission is now used to control access to the Manage Tags screen.', array(1 => ts('manage tags'))) . '</p>';
+    // }
+  }
+
+  /**
+   * Compute any messages which should be displayed after upgrade.
+   *
+   * @param string $postUpgradeMessage
+   *   alterable.
+   * @param string $rev
+   *   an intermediate version; note that setPostUpgradeMessage is called repeatedly with different $revs.
+   */
+  public function setPostUpgradeMessage(&$postUpgradeMessage, $rev) {
+    // Example: Generate a post-upgrade message.
+    // if ($rev == '5.12.34') {
+    //   $postUpgradeMessage .= '<br /><br />' . ts("By default, CiviCRM now disables the ability to import directly from SQL. To use this feature, you must explicitly grant permission 'import SQL datasource'.");
+    // }
+  }
+
+  /*
+   * Important! All upgrade functions MUST add a 'runSql' task.
+   * Uncomment and use the following template for a new upgrade version
+   * (change the x in the function name):
+   */
+
+  /**
+   * Upgrade function.
+   *
+   * @param string $rev
+   */
+  public function upgrade_5_12_alpha1($rev) {
+    $this->addTask(ts('Upgrade DB to %1: SQL', array(1 => $rev)), 'runSql', $rev);
+    $this->addTask('Update smart groups where jcalendar fields have been converted to datepicker', 'updateSmartGroups', [
+      'datepickerConversion' => [
+        'age_asof_date',
+      ]
+    ]);
+  }
+
+}
diff --git a/CRM/Upgrade/Incremental/php/FourTwo.php b/CRM/Upgrade/Incremental/php/FourTwo.php
deleted file mode 100644 (file)
index d8b8641..0000000
+++ /dev/null
@@ -1,948 +0,0 @@
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5                                                  |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019                                |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM.                                    |
- |                                                                    |
- | CiviCRM is free software; you can copy, modify, and distribute it  |
- | under the terms of the GNU Affero General Public License           |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
- |                                                                    |
- | CiviCRM is distributed in the hope that it will be useful, but     |
- | WITHOUT ANY WARRANTY; without even the implied warranty of         |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
- | See the GNU Affero General Public License for more details.        |
- |                                                                    |
- | You should have received a copy of the GNU Affero General Public   |
- | License and the CiviCRM Licensing Exception along                  |
- | with this program; if not, contact CiviCRM LLC                     |
- | at info[AT]civicrm[DOT]org. If you have questions about the        |
- | GNU Affero General Public License or the licensing of CiviCRM,     |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
- +--------------------------------------------------------------------+
- */
-
-/**
- * Upgrade logic for 4.2
- */
-class CRM_Upgrade_Incremental_php_FourTwo extends CRM_Upgrade_Incremental_Base {
-  const SETTINGS_SNIPPET_PATTERN = '/CRM_Core_ClassLoader::singleton\(\)-\>register/';
-  const SETTINGS_SNIPPET = "\nrequire_once 'CRM/Core/ClassLoader.php';\nCRM_Core_ClassLoader::singleton()->register();\n";
-
-  /**
-   * Compute any messages which should be displayed beforeupgrade.
-   *
-   * Note: This function is called iteratively for each upcoming
-   * revision to the database.
-   *
-   * @param string $preUpgradeMessage
-   * @param string $rev
-   *   a version number, e.g. '4.2.alpha1', '4.2.beta3', '4.2.0'.
-   * @param null $currentVer
-   *
-   * @return bool
-   */
-  public function setPreUpgradeMessage(&$preUpgradeMessage, $rev, $currentVer = NULL) {
-    if ($rev == '4.2.alpha1') {
-      $tables = array('civicrm_contribution_page', 'civicrm_event', 'civicrm_group', 'civicrm_contact');
-      if (!CRM_Core_DAO::schemaRequiresRebuilding($tables)) {
-        $errors = "The upgrade has identified some schema integrity issues in the database. It seems some of your constraints are missing. You will have to rebuild your schema before re-trying the upgrade. Please refer to " . CRM_Utils_System::docURL2("Ensuring Schema Integrity on Upgrades", FALSE, "Ensuring Schema Integrity on Upgrades", NULL, NULL, "wiki");
-        CRM_Core_Error::fatal($errors);
-        return FALSE;
-      }
-
-      // CRM-10613, CRM-11120
-      $query = "
-SELECT mp.contribution_id, mp.membership_id, mem.membership_type_id, mem.start_date, mem.end_date, mem.status_id, mem.contact_id
-FROM civicrm_membership_payment mp
-INNER JOIN ( SELECT cmp.contribution_id
-              FROM civicrm_membership_payment cmp
-              LEFT JOIN civicrm_line_item cli ON cmp.contribution_id=cli.entity_id and cli.entity_table = 'civicrm_contribution'
-              WHERE cli.entity_id IS NULL
-              GROUP BY cmp.contribution_id
-              HAVING COUNT(cmp.membership_id) > 1) submp ON submp.contribution_id = mp.contribution_id
-INNER JOIN civicrm_membership mem ON mem.id = mp.membership_id
-ORDER BY mp.contribution_id, mp.membership_id";
-      $invalidData = CRM_Core_DAO::executeQuery($query);
-      if ($invalidData->N) {
-        $invalidDataMessage = "<br /><strong>" . 'The upgrade is being aborted due to data integrity issues in your database. There are multiple membership records linked to the same contribution record. This is unexpected, and some of the membership records may be duplicates. The problem record sets are listed below. Refer to <a href="http://wiki.civicrm.org/confluence/display/CRMDOC42/Repair+database+script+for+4.2+upgrades">this wiki page for instructions on repairing your database</a> so that you can run the upgrade successfully.' . "</strong>";
-        $membershipType = CRM_Member_PseudoConstant::membershipType();
-        $membershipStatus = CRM_Member_PseudoConstant::membershipStatus();
-        $invalidDataMessage .= "<table border=1><tr><th>Contact-ID</th><th>Contribution-ID</th><th>Membership-ID</th><th>Membership Type</th><th>Start Date</th><th>End Date</th><th>Membership Status</th></tr>";
-        while ($invalidData->fetch()) {
-          $invalidDataMessage .= "<tr>";
-          $invalidDataMessage .= "<td>{$invalidData->contact_id}</td>";
-          $invalidDataMessage .= "<td>{$invalidData->contribution_id}</td>";
-          $invalidDataMessage .= "<td>{$invalidData->membership_id}</td>";
-          $invalidDataMessage .= "<td>" . CRM_Utils_Array::value($invalidData->membership_type_id, $membershipType) . "</td>";
-          $invalidDataMessage .= "<td>{$invalidData->start_date}</td>";
-          $invalidDataMessage .= "<td>{$invalidData->end_date}</td>";
-          $invalidDataMessage .= "<td>" . CRM_Utils_Array::value($invalidData->status_id, $membershipStatus) . "</td>";
-          $invalidDataMessage .= "</tr>";
-        }
-        $clickHere = CRM_Utils_System::url('civicrm/upgrade/cleanup425', 'reset=1');
-        $invalidDataMessage .= "</table><p>If you have reviewed the cleanup script documentation on the wiki and you are ready to run the cleanup now - <a href='$clickHere'>click here</a>.</p>";
-        CRM_Core_Error::fatal($invalidDataMessage);
-        return FALSE;
-      }
-    }
-
-    if ($rev == '4.2.beta2') {
-      // note: error conditions are also checked in upgrade_4_2_beta2()
-      if (!defined('CIVICRM_SETTINGS_PATH')) {
-        $preUpgradeMessage .= '<br />' . ts('Could not determine path to civicrm.settings.php. Please manually locate it and add these lines at the bottom: <pre>%1</pre>', array(
-            1 => self::SETTINGS_SNIPPET,
-          ));
-      }
-      elseif (preg_match(self::SETTINGS_SNIPPET_PATTERN, file_get_contents(CIVICRM_SETTINGS_PATH))) {
-        // OK, nothing to do
-      }
-      elseif (!is_writable(CIVICRM_SETTINGS_PATH)) {
-        $preUpgradeMessage .= '<br />' . ts('The settings file (%1) must be updated. Please make it writable or manually add these lines:<pre>%2</pre>', array(
-            1 => CIVICRM_SETTINGS_PATH,
-            2 => self::SETTINGS_SNIPPET,
-          ));
-      }
-    }
-    if ($rev == '4.2.2' && version_compare($currentVer, '3.3.alpha1') >= 0) {
-      $query = " SELECT cli.id
-FROM `civicrm_line_item` cli
-INNER JOIN civicrm_membership_payment cmp ON cmp.contribution_id = cli.entity_id AND cli.entity_table = 'civicrm_contribution'
-INNER JOIN civicrm_price_field_value cpfv ON cpfv.id = cli.price_field_value_id
-INNER JOIN civicrm_price_field cpf ON cpf.id = cpfv.price_field_id and cpf.id != cli.price_field_id
-INNER JOIN civicrm_price_set cps ON cps.id = cpf.price_set_id AND cps.name <>'default_membership_type_amount' ";
-      $dao = CRM_Core_DAO::executeQuery($query);
-      if ($dao->N) {
-        $preUpgradeMessage .= "<br /><strong>We have identified extraneous data in your database that a previous upgrade likely introduced. We STRONGLY recommend making a backup of your site before continuing. We also STRONGLY suggest fixing this issue with unneeded records BEFORE you upgrade. You can find more information about this issue and the way to fix it by visiting <a href='http://forum.civicrm.org/index.php/topic,26181.0.html'>http://forum.civicrm.org/index.php/topic,26181.0.html</a>.</strong>";
-      }
-    }
-
-    if (version_compare($rev, '4.2.9') >= 0) {
-      //CRM-11980
-      $sql = "SELECT id FROM civicrm_option_group WHERE name LIKE 'civicrm_price_field.amount.%' LIMIT 1";
-      $dao = CRM_Core_DAO::executeQuery($sql);
-      if ($dao->fetch()) {
-        $errors = "We found unexpected data values from an older version of CiviCRM in your database. The upgrade can not be run until this condition is corrected.<br /><br />Details: One or more rows are present in the civicrm_option_group with name like 'civicrm_price_field.amount.%'. <a href='http://forum.civicrm.org/index.php/topic,27744.msg118748.html#msg118748'>Check here for information on diagnosing and correcting this problem.</a>";
-        CRM_Core_Error::fatal($errors);
-        return FALSE;
-      }
-    }
-  }
-
-  /**
-   * Compute any messages which should be displayed after upgrade.
-   *
-   * @param string $postUpgradeMessage
-   *   alterable.
-   * @param string $rev
-   *   an intermediate version; note that setPostUpgradeMessage is called repeatedly with different $revs.
-   */
-  public function setPostUpgradeMessage(&$postUpgradeMessage, $rev) {
-    if ($rev == '4.2.beta5') {
-      $config = CRM_Core_Config::singleton();
-      if (!empty($config->extensionsDir)) {
-        $postUpgradeMessage .= '<br />' . ts('Please <a href="%1" target="_blank">configure the Extension Resource URL</a>.', array(
-            1 => CRM_Utils_System::url('civicrm/admin/setting/url', 'reset=1'),
-          ));
-      }
-    }
-    if ($rev == '4.2.7') {
-      $postUpgradeMessage .= '<br />' . ts('If you have configured a report instance to allow anonymous access, you will need to reset the permission to Everyone for that instance (under the Report Settings pane).');
-    }
-  }
-
-  /**
-   * @param $rev
-   */
-  public function upgrade_4_2_alpha1($rev) {
-    //checking whether the foreign key exists before dropping it
-    //drop foreign key queries of CRM-9850
-    $params = array();
-    $tables = array(
-      'civicrm_contribution_page' => 'FK_civicrm_contribution_page_payment_processor_id',
-      'civicrm_event' => 'FK_civicrm_event_payment_processor_id',
-      'civicrm_group' => 'FK_civicrm_group_saved_search_id',
-    );
-    foreach ($tables as $tableName => $fKey) {
-      $foreignKeyExists = CRM_Core_DAO::checkConstraintExists($tableName, $fKey);
-      if ($foreignKeyExists) {
-        CRM_Core_DAO::executeQuery("ALTER TABLE {$tableName} DROP FOREIGN KEY {$fKey}", $params, TRUE, NULL, FALSE, FALSE);
-        CRM_Core_DAO::executeQuery("ALTER TABLE {$tableName} DROP INDEX {$fKey}", $params, TRUE, NULL, FALSE, FALSE);
-      }
-    }
-    // Drop index UI_title for civicrm_price_set
-    $domain = new CRM_Core_DAO_Domain();
-    $domain->find(TRUE);
-    if ($domain->locales) {
-      $locales = explode(CRM_Core_DAO::VALUE_SEPARATOR, $domain->locales);
-      foreach ($locales as $locale) {
-        $query = "SHOW KEYS FROM `civicrm_price_set` WHERE key_name = 'UI_title_{$locale}'";
-        $dao = CRM_Core_DAO::executeQuery($query, $params, TRUE, NULL, FALSE, FALSE);
-        if ($dao->N) {
-          CRM_Core_DAO::executeQuery("ALTER TABLE `civicrm_price_set` DROP INDEX `UI_title_{$locale}`", $params, TRUE, NULL, FALSE, FALSE);
-        }
-      }
-    }
-    else {
-      $query = "SHOW KEYS FROM `civicrm_price_set` WHERE key_name = 'UI_title'";
-      $dao = CRM_Core_DAO::executeQuery($query);
-      if ($dao->N) {
-        CRM_Core_DAO::executeQuery("ALTER TABLE `civicrm_price_set` DROP INDEX `UI_title`");
-      }
-    }
-
-    // Some steps take a long time, so we break them up into separate
-    // tasks and enqueue them separately.
-    $this->addTask(ts('Upgrade DB to %1: SQL', array(1 => '4.2.alpha1')), 'runSql', $rev);
-    $this->addTask('Upgrade DB to 4.2.alpha1: Price Sets', 'task_4_2_alpha1_createPriceSets', $rev);
-    self::convertContribution();
-    $this->addTask('Upgrade DB to 4.2.alpha1: Event Profile', 'task_4_2_alpha1_eventProfile');
-  }
-
-  /**
-   * @param $rev
-   */
-  public function upgrade_4_2_beta2($rev) {
-    // note: error conditions are also checked in setPreUpgradeMessage()
-    if (defined('CIVICRM_SETTINGS_PATH')) {
-      if (!preg_match(self::SETTINGS_SNIPPET_PATTERN, file_get_contents(CIVICRM_SETTINGS_PATH))) {
-        if (is_writable(CIVICRM_SETTINGS_PATH)) {
-          file_put_contents(CIVICRM_SETTINGS_PATH, self::SETTINGS_SNIPPET, FILE_APPEND);
-        }
-      }
-    }
-  }
-
-  /**
-   * @param $rev
-   */
-  public function upgrade_4_2_beta3($rev) {
-    $this->addTask(ts('Upgrade DB to %1: SQL', array(1 => '4.2.beta3')), 'runSql', $rev);
-    $minParticipantId = CRM_Core_DAO::singleValueQuery('SELECT coalesce(min(id),0) FROM civicrm_participant');
-    $maxParticipantId = CRM_Core_DAO::singleValueQuery('SELECT coalesce(max(id),0) FROM civicrm_participant');
-
-    for ($startId = $minParticipantId; $startId <= $maxParticipantId; $startId += self::BATCH_SIZE) {
-      $endId = $startId + self::BATCH_SIZE - 1;
-      $title = "Upgrade DB to 4.2.alpha1: Participant ($startId => $endId)";
-      $this->addTask($title, 'task_4_2_alpha1_convertParticipants', $startId, $endId);
-    }
-  }
-
-  /**
-   * @param $rev
-   */
-  public function upgrade_4_2_beta5($rev) {
-    // CRM-10629 Create a setting for extension URLs
-    // For some reason, this isn't working when placed in the .sql file
-    CRM_Core_DAO::executeQuery("
-      INSERT INTO civicrm_setting(group_name,name,value,domain_id,is_domain)
-      VALUES ('URL Preferences', 'extensionsURL',NULL,1,1);
-    ");
-  }
-
-  /**
-   * @param $rev
-   */
-  public function upgrade_4_2_0($rev) {
-    $this->addTask(ts('Upgrade DB to %1: SQL', array(1 => '4.2.0')), 'runSql', $rev);
-  }
-
-  /**
-   * @param $rev
-   */
-  public function upgrade_4_2_2($rev) {
-    $this->addTask(ts('Upgrade DB to %1: SQL', array(1 => '4.2.2')), 'runSql', $rev);
-    //create line items for memberships and participants for api/import
-    self::convertContribution();
-
-    // CRM-10937 Fix the title on civicrm_dedupe_rule_group
-    $upgrade = new CRM_Upgrade_Form();
-    if ($upgrade->multilingual) {
-      // Check if the 'title' field exists
-      $query = "SELECT column_name
-                  FROM information_schema.COLUMNS
-                 WHERE table_name = 'civicrm_dedupe_rule_group'
-                   AND table_schema = DATABASE()
-                   AND column_name = 'title'";
-
-      $dao = CRM_Core_DAO::executeQuery($query);
-
-      if (!$dao->N) {
-        $domain = new CRM_Core_DAO_Domain();
-        $domain->find(TRUE);
-
-        if ($domain->locales) {
-          $locales = explode(CRM_Core_DAO::VALUE_SEPARATOR, $domain->locales);
-          $locale = array_shift($locales);
-
-          // Use the first language (they should all have the same value)
-          CRM_Core_DAO::executeQuery("ALTER TABLE `civicrm_dedupe_rule_group` CHANGE `title_{$locale}` `title` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Label of the rule group'", $params, TRUE, NULL, FALSE, FALSE);
-
-          // Drop remaining the column for the remaining languages
-          foreach ($locales as $locale) {
-            CRM_Core_DAO::executeQuery("ALTER TABLE `civicrm_dedupe_rule_group` DROP `title_{$locale}`", $params, TRUE, NULL, FALSE, FALSE);
-          }
-        }
-      }
-    }
-  }
-
-  /**
-   * @param $rev
-   */
-  public function upgrade_4_2_3($rev) {
-    $this->addTask(ts('Upgrade DB to %1: SQL', array(1 => '4.2.3')), 'runSql', $rev);
-    // CRM-10953 Remove duplicate activity type for 'Reminder Sent' which is mistakenly inserted by 4.2.alpha1 upgrade script
-    $queryMin = "
-SELECT coalesce(min(value),0) from civicrm_option_value ov
-WHERE ov.option_group_id =
-  (SELECT id from civicrm_option_group og WHERE og.name = 'activity_type') AND
-ov.name = 'Reminder Sent'";
-
-    $minReminderSent = CRM_Core_DAO::singleValueQuery($queryMin);
-
-    $queryMax = "
-SELECT coalesce(max(value),0) from civicrm_option_value ov
-WHERE ov.option_group_id =
-  (SELECT id from civicrm_option_group og WHERE og.name = 'activity_type') AND
-ov.name = 'Reminder Sent'";
-
-    $maxReminderSent = CRM_Core_DAO::singleValueQuery($queryMax);
-
-    // If we have two different values, replace new value with original in any activities
-    if ($maxReminderSent > $minReminderSent) {
-      $query = "
-UPDATE civicrm_activity
-SET activity_type_id = {$minReminderSent}
-WHERE activity_type_id = {$maxReminderSent}";
-
-      CRM_Core_DAO::executeQuery($query);
-
-      // Then delete the newer (duplicate) option_value row
-      $query = "
-DELETE from civicrm_option_value
-  WHERE option_group_id =
-    (SELECT id from civicrm_option_group og WHERE og.name = 'activity_type') AND
-  value = '{$maxReminderSent}'";
-
-      CRM_Core_DAO::executeQuery($query);
-    }
-  }
-
-  /**
-   * @param $rev
-   */
-  public function upgrade_4_2_5($rev) {
-    $this->addTask(ts('Upgrade DB to %1: SQL', array(1 => '4.2.5')), 'runSql', $rev);
-    //CRM-11077
-    $sql = " SELECT cpse.entity_id, cpse.price_set_id
-FROM `civicrm_price_set_entity` cpse
-LEFT JOIN civicrm_price_set cps ON cps.id = cpse.price_set_id
-LEFT JOIN civicrm_price_set_entity cpse1 ON cpse1.price_set_id = cpse.price_set_id
-WHERE cpse.entity_table = 'civicrm_event'  AND cps.is_quick_config = 1
-GROUP BY cpse.id
-HAVING COUNT(cpse.price_set_id) > 1 AND MIN(cpse1.id) <> cpse.id ";
-
-    $dao = CRM_Core_DAO::executeQuery($sql);
-    while ($dao->fetch()) {
-      if ($dao->price_set_id) {
-        $copyPriceSet = &CRM_Upgrade_Snapshot_V4p2_Price_BAO_Set::copy($dao->price_set_id);
-        CRM_Upgrade_Snapshot_V4p2_Price_BAO_Set::addTo('civicrm_event', $dao->entity_id, $copyPriceSet->id);
-      }
-    }
-  }
-
-  public function convertContribution() {
-    $minContributionId = CRM_Core_DAO::singleValueQuery('SELECT coalesce(min(id),0) FROM civicrm_contribution');
-    $maxContributionId = CRM_Core_DAO::singleValueQuery('SELECT coalesce(max(id),0) FROM civicrm_contribution');
-    for ($startId = $minContributionId; $startId <= $maxContributionId; $startId += self::BATCH_SIZE) {
-      $endId = $startId + self::BATCH_SIZE - 1;
-      $title = "Upgrade DB to 4.2.alpha1: Contributions ($startId => $endId)";
-      $this->addTask($title, 'task_4_2_alpha1_convertContributions', $startId, $endId);
-    }
-    $minParticipantId = CRM_Core_DAO::singleValueQuery('SELECT coalesce(min(id),0) FROM civicrm_participant');
-    $maxParticipantId = CRM_Core_DAO::singleValueQuery('SELECT coalesce(max(id),0) FROM civicrm_participant');
-
-    for ($startId = $minParticipantId; $startId <= $maxParticipantId; $startId += self::BATCH_SIZE) {
-      $endId = $startId + self::BATCH_SIZE - 1;
-      $title = "Upgrade DB to 4.2.alpha1: Participant ($startId => $endId)";
-      $this->addTask($title, 'task_4_2_alpha1_convertParticipants', $startId, $endId);
-    }
-  }
-
-  /**
-   * (Queue Task Callback)
-   *
-   * Upgrade code to create priceset for contribution pages and events
-   *
-   * @param \CRM_Queue_TaskContext $ctx
-   * @param string $rev
-   *
-   * @return bool
-   */
-  public static function task_4_2_alpha1_createPriceSets(CRM_Queue_TaskContext $ctx, $rev) {
-    $upgrade = new CRM_Upgrade_Form();
-    $daoName = array(
-      'civicrm_contribution_page' => array(
-        'CRM_Contribute_BAO_ContributionPage',
-        CRM_Core_Component::getComponentID('CiviContribute'),
-      ),
-      'civicrm_event' => array(
-        'CRM_Event_BAO_Event',
-        CRM_Core_Component::getComponentID('CiviEvent'),
-      ),
-    );
-
-    // get all option group used for event and contribution page
-    $query = "
-SELECT id, name
-FROM   civicrm_option_group
-WHERE  name LIKE '%.amount.%' ";
-    $dao = CRM_Core_DAO::executeQuery($query);
-    while ($dao->fetch()) {
-      $addTo = explode('.', $dao->name);
-      if (!empty($addTo[2])) {
-        $options = array('optionGroup' => $dao->name);
-        self::createPriceSet($daoName, $addTo, $options);
-      }
-      CRM_Core_OptionGroup::deleteAssoc($dao->name);
-    }
-
-    //create pricesets for contribution with only other amount
-    $query = "
-SELECT    ccp.id as contribution_page_id, ccp.is_allow_other_amount, cmb.id as membership_block_id
-FROM      civicrm_contribution_page ccp
-LEFT JOIN civicrm_membership_block cmb ON  cmb.entity_id = ccp.id AND cmb.entity_table = 'civicrm_contribution_page'
-LEFT JOIN civicrm_price_set_entity cpse ON cpse.entity_id = ccp.id and cpse.entity_table = 'civicrm_contribution_page'
-WHERE     cpse.price_set_id IS NULL";
-    $dao = CRM_Core_DAO::executeQuery($query);
-    $addTo = array('civicrm_contribution_page');
-    while ($dao->fetch()) {
-      $addTo[2] = $dao->contribution_page_id;
-      $options = array(
-        'otherAmount' => $dao->is_allow_other_amount,
-        'membership' => $dao->membership_block_id,
-      );
-      self::createPriceSet($daoName, $addTo, $options);
-    }
-
-    return TRUE;
-  }
-
-  /**
-   * Create price sets.
-   *
-   * @param string $daoName
-   * @param string $addTo
-   * @param array $options
-   */
-  public static function createPriceSet($daoName, $addTo, $options = array()) {
-    $query = "SELECT title FROM {$addTo[0]} where id =%1";
-    $setParams['title'] = CRM_Core_DAO::singleValueQuery($query,
-      array(1 => array($addTo[2], 'Integer'))
-    );
-    $pageTitle = strtolower(CRM_Utils_String::munge($setParams['title'], '_', 245));
-
-    // an event or contrib page has been deleted but left the option group behind - (this may be fixed in later versions?)
-    // we should probably delete the option group - but at least early exit here as the code following it does not fatal
-    // CRM-10298
-    if (empty($pageTitle)) {
-      return;
-    }
-
-    $optionValue = array();
-    if (!empty($options['optionGroup'])) {
-      CRM_Core_OptionGroup::getAssoc($options['optionGroup'], $optionValue);
-      if (empty($optionValue)) {
-        return;
-      }
-    }
-    elseif (empty($options['otherAmount']) && empty($options['membership'])) {
-      //CRM-12273
-      //if options group, otherAmount, membersip is empty then return, contribution should be default price set
-      return;
-    }
-
-    if (!CRM_Core_DAO::getFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_BAO_Set', $pageTitle, 'id', 'name', TRUE)) {
-      $setParams['name'] = $pageTitle;
-    }
-    else {
-      $timeSec = explode(".", microtime(TRUE));
-      $setParams['name'] = $pageTitle . '_' . date('is', $timeSec[0]) . $timeSec[1];
-    }
-    $setParams['extends'] = $daoName[$addTo[0]][1];
-    $setParams['is_quick_config'] = 1;
-    $priceSet = CRM_Upgrade_Snapshot_V4p2_Price_BAO_Set::create($setParams);
-    CRM_Upgrade_Snapshot_V4p2_Price_BAO_Set::addTo($addTo[0], $addTo[2], $priceSet->id, 1);
-
-    $fieldParams['price_set_id'] = $priceSet->id;
-    if (!empty($options['optionGroup'])) {
-      $fieldParams['html_type'] = 'Radio';
-      $fieldParams['is_required'] = 1;
-      if ($addTo[0] == 'civicrm_event') {
-        $query = "SELECT fee_label FROM civicrm_event where id =%1";
-        $fieldParams['name'] = $fieldParams['label'] = CRM_Core_DAO::singleValueQuery($query,
-          array(1 => array($addTo[2], 'Integer'))
-        );
-        $defaultAmountColumn = 'default_fee_id';
-      }
-      else {
-        $options['membership'] = 1;
-        $fieldParams['name'] = strtolower(CRM_Utils_String::munge("Contribution Amount", '_', 245));
-        $fieldParams['label'] = "Contribution Amount";
-        $defaultAmountColumn = 'default_amount_id';
-        $options['otherAmount'] = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $addTo[2], 'is_allow_other_amount');
-        if (!empty($options['otherAmount'])) {
-          $fieldParams['is_required'] = 0;
-        }
-      }
-      $fieldParams['option_label'] = $optionValue['label'];
-      $fieldParams['option_amount'] = $optionValue['value'];
-      $fieldParams['option_weight'] = $optionValue['weight'];
-      $fieldParams['is_quick_config'] = $setParams['is_quick_config'];
-      if ($defaultAmount = CRM_Core_DAO::getFieldValue($daoName[$addTo[0]][0], $addTo[2], $defaultAmountColumn)) {
-        $fieldParams['default_option'] = array_search($defaultAmount, $optionValue['amount_id']);
-      }
-      $priceField = CRM_Upgrade_Snapshot_V4p2_Price_BAO_Field::create($fieldParams);
-
-    }
-    if (!empty($options['membership'])) {
-      $dao = new CRM_Member_DAO_MembershipBlock();
-      $dao->entity_table = 'civicrm_contribution_page';
-      $dao->entity_id = $addTo[2];
-
-      if ($dao->find(TRUE)) {
-        if ($dao->membership_types) {
-          $fieldParams = array(
-            'name' => strtolower(CRM_Utils_String::munge("Membership Amount", '_', 245)),
-            'label' => "Membership Amount",
-            'is_required' => $dao->is_required,
-            'is_display_amounts' => $dao->display_min_fee,
-            'is_active' => $dao->is_active,
-            'price_set_id' => $priceSet->id,
-            'html_type' => 'Radio',
-            'weight' => 1,
-          );
-          $membershipTypes = unserialize($dao->membership_types);
-          $rowcount = 0;
-          foreach ($membershipTypes as $membershipType => $autoRenew) {
-            $membershipTypeDetail = CRM_Member_BAO_MembershipType::getMembershipTypeDetails($membershipType);
-            $rowcount++;
-            $fieldParams['option_label'][$rowcount] = $membershipTypeDetail['name'];
-            $fieldParams['option_amount'][$rowcount] = $membershipTypeDetail['minimum_fee'];
-            $fieldParams['option_weight'][$rowcount] = $rowcount;
-            $fieldParams['membership_type_id'][$rowcount] = $membershipType;
-            if ($membershipType == $dao->membership_type_default) {
-              $fieldParams['default_option'] = $rowcount;
-            }
-          }
-          $priceField = CRM_Upgrade_Snapshot_V4p2_Price_BAO_Field::create($fieldParams);
-
-          $setParams = array(
-            'id' => $priceSet->id,
-            'extends' => CRM_Core_Component::getComponentID('CiviMember'),
-            'contribution_type_id' => CRM_Core_DAO::getFieldValue($daoName[$addTo[0]][0], $addTo[2], 'contribution_type_id'),
-          );
-          CRM_Upgrade_Snapshot_V4p2_Price_BAO_Set::create($setParams);
-        }
-      }
-    }
-    if (!empty($options['otherAmount'])) {
-
-      $fieldParams = array(
-        'name' => strtolower(CRM_Utils_String::munge("Other Amount", '_', 245)),
-        'label' => "Other Amount",
-        'is_required' => 0,
-        'is_display_amounts' => 0,
-        'is_active' => 1,
-        'price_set_id' => $priceSet->id,
-        'html_type' => 'Text',
-        'weight' => 3,
-      );
-      $fieldParams['option_label'][1] = "Other Amount";
-      $fieldParams['option_amount'][1] = 1;
-      $fieldParams['option_weight'][1] = 1;
-      $priceField = CRM_Upgrade_Snapshot_V4p2_Price_BAO_Field::create($fieldParams);
-    }
-  }
-
-  /**
-   * (Queue Task Callback)
-   *
-   * Find any contribution records and create corresponding line-item
-   * records.
-   *
-   * @param CRM_Queue_TaskContext $ctx
-   * @param int $startId
-   *   the first/lowest contribution ID to convert.
-   * @param int $endId
-   *   the last/highest contribution ID to convert.
-   *
-   * @return bool
-   */
-  public static function task_4_2_alpha1_convertContributions(CRM_Queue_TaskContext $ctx, $startId, $endId) {
-    $upgrade = new CRM_Upgrade_Form();
-    $query = "
- INSERT INTO civicrm_line_item(`entity_table` ,`entity_id` ,`price_field_id` ,`label` , `qty` ,`unit_price` ,`line_total` ,`participant_count` ,`price_field_value_id`)
- SELECT 'civicrm_contribution',cc.id, cpf.id as price_field_id, cpfv.label, 1, cc.total_amount, cc.total_amount line_total, 0, cpfv.id as price_field_value
- FROM civicrm_membership_payment cmp
- LEFT JOIN `civicrm_contribution` cc ON cc.id = cmp.contribution_id
- LEFT JOIN civicrm_line_item cli ON cc.id=cli.entity_id and cli.entity_table = 'civicrm_contribution'
- LEFT JOIN civicrm_membership cm ON cm.id=cmp.membership_id
- LEFT JOIN civicrm_membership_type cmt ON cmt.id = cm.membership_type_id
- LEFT JOIN civicrm_price_field cpf ON BINARY cpf.name = cmt.member_of_contact_id
- LEFT JOIN civicrm_price_field_value cpfv ON cpfv.membership_type_id = cm.membership_type_id AND cpf.id = cpfv.price_field_id
- WHERE (cc.id BETWEEN %1 AND %2) AND cli.entity_id IS NULL ;
- ";
-    $sqlParams = array(
-      1 => array($startId, 'Integer'),
-      2 => array($endId, 'Integer'),
-    );
-    CRM_Core_DAO::executeQuery($query, $sqlParams);
-
-    // create lineitems for contribution done for membership
-    $sql = "
-SELECT    cc.id, cmp.membership_id, cpse.price_set_id, cc.total_amount
-FROM      civicrm_contribution cc
-LEFT JOIN civicrm_line_item cli ON cc.id=cli.entity_id AND cli.entity_table = 'civicrm_contribution'
-LEFT JOIN civicrm_membership_payment cmp ON cc.id = cmp.contribution_id
-LEFT JOIN civicrm_participant_payment cpp ON cc.id = cpp.contribution_id
-LEFT JOIN civicrm_price_set_entity cpse on cpse.entity_table = 'civicrm_contribution_page' AND cpse.entity_id = cc.contribution_page_id
-WHERE     (cc.id BETWEEN %1 AND %2)
-AND       cli.entity_id IS NULL AND cc.contribution_page_id IS NOT NULL AND cpp.contribution_id IS NULL
-GROUP BY  cc.id, cmp.membership_id
-";
-    $result = CRM_Core_DAO::executeQuery($sql, $sqlParams);
-
-    while ($result->fetch()) {
-      $sql = "
-SELECT    cpf.id, cpfv.id as price_field_value_id, cpfv.label, cpfv.amount, cpfv.count
-FROM      civicrm_price_field cpf
-LEFT JOIN civicrm_price_field_value cpfv ON cpf.id = cpfv.price_field_id
-WHERE     cpf.price_set_id = %1
-";
-      $lineParams = array(
-        'entity_table' => 'civicrm_contribution',
-        'entity_id' => $result->id,
-      );
-      if ($result->membership_id) {
-        $sql .= " AND cpf.name = %2 AND cpfv.membership_type_id = %3 ";
-        $params = array(
-          '1' => array($result->price_set_id, 'Integer'),
-          '2' => array('membership_amount', 'String'),
-          '3' => array(
-            CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $result->membership_id, 'membership_type_id'),
-            'Integer',
-          ),
-        );
-        $res = CRM_Core_DAO::executeQuery($sql, $params);
-        if ($res->fetch()) {
-          $lineParams += array(
-            'price_field_id' => $res->id,
-            'label' => $res->label,
-            'qty' => 1,
-            'unit_price' => $res->amount,
-            'line_total' => $res->amount,
-            'participant_count' => $res->count ? $res->count : 0,
-            'price_field_value_id' => $res->price_field_value_id,
-          );
-        }
-        else {
-          $lineParams['price_field_id'] = CRM_Core_DAO::getFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_DAO_Field', $result->price_set_id, 'id', 'price_set_id');
-          $lineParams['label'] = 'Membership Amount';
-          $lineParams['qty'] = 1;
-          $lineParams['unit_price'] = $lineParams['line_total'] = $result->total_amount;
-          $lineParams['participant_count'] = 0;
-        }
-      }
-      else {
-        $sql .= "AND cpfv.amount = %2";
-
-        //CRM-12273
-        //check if price_set_id is exist, if not use the default contribution amount
-        if (isset($result->price_set_id)) {
-          $priceSetId = $result->price_set_id;
-        }
-        else {
-          $defaultPriceSets = CRM_Price_BAO_PriceSet::getDefaultPriceSet();
-          foreach ($defaultPriceSets as $key => $pSet) {
-            if ($pSet['name'] == 'contribution_amount') {
-              $priceSetId = $pSet['setID'];
-            }
-          }
-        }
-
-        $params = array(
-          '1' => array($priceSetId, 'Integer'),
-          '2' => array($result->total_amount, 'String'),
-        );
-        $res = CRM_Core_DAO::executeQuery($sql, $params);
-        if ($res->fetch()) {
-          $lineParams += array(
-            'price_field_id' => $res->id,
-            'label' => $res->label,
-            'qty' => 1,
-            'unit_price' => $res->amount,
-            'line_total' => $res->amount,
-            'participant_count' => $res->count ? $res->count : 0,
-            'price_field_value_id' => $res->price_field_value_id,
-          );
-        }
-        else {
-          $params = array(
-            'price_set_id' => $priceSetId,
-            'name' => 'other_amount',
-          );
-          $defaults = array();
-          CRM_Upgrade_Snapshot_V4p2_Price_BAO_Field::retrieve($params, $defaults);
-          if (!empty($defaults)) {
-            $lineParams['price_field_id'] = $defaults['id'];
-            $lineParams['label'] = $defaults['label'];
-            $lineParams['price_field_value_id']
-              = CRM_Core_DAO::getFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_DAO_FieldValue', $defaults['id'], 'id', 'price_field_id');
-          }
-          else {
-            $lineParams['price_field_id']
-              = CRM_Core_DAO::getFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_DAO_Field', $priceSetId, 'id', 'price_set_id');
-            $lineParams['label'] = 'Contribution Amount';
-          }
-          $lineParams['qty'] = 1;
-          $lineParams['participant_count'] = 0;
-          $lineParams['unit_price'] = $lineParams['line_total'] = $result->total_amount;
-        }
-      }
-      CRM_Upgrade_Snapshot_V4p2_Price_BAO_LineItem::create($lineParams);
-    }
-
-    return TRUE;
-  }
-
-  /**
-   * (Queue Task Callback)
-   *
-   * Find any participant records and create corresponding line-item
-   * records.
-   *
-   * @param CRM_Queue_TaskContext $ctx
-   * @param int $startId
-   *   the first/lowest participant ID to convert.
-   * @param int $endId
-   *   the last/highest participant ID to convert.
-   *
-   * @return bool
-   */
-  public static function task_4_2_alpha1_convertParticipants(CRM_Queue_TaskContext $ctx, $startId, $endId) {
-    $upgrade = new CRM_Upgrade_Form();
-    //create lineitems for participant in edge cases using default price set for contribution.
-    $query = "
-SELECT    cp.id as participant_id, cp.fee_amount, cp.fee_level,ce.is_monetary,
-          cpse.price_set_id, cpf.id as price_field_id, cpfv.id as price_field_value_id
-FROM      civicrm_participant cp
-LEFT JOIN civicrm_line_item cli ON cli.entity_id=cp.id and cli.entity_table = 'civicrm_participant'
-LEFT JOIN civicrm_event ce ON ce.id=cp.event_id
-LEFT JOIN civicrm_price_set_entity cpse ON cp.event_id = cpse.entity_id and cpse.entity_table = 'civicrm_event'
-LEFT JOIN civicrm_price_field cpf ON cpf.price_set_id = cpse.price_set_id
-LEFT JOIN civicrm_price_field_value cpfv ON cpfv.price_field_id = cpf.id AND cpfv.label = cp.fee_level
-WHERE     (cp.id BETWEEN %1 AND %2)
-AND       cli.entity_id IS NULL AND cp.fee_amount IS NOT NULL";
-    $sqlParams = array(
-      1 => array($startId, 'Integer'),
-      2 => array($endId, 'Integer'),
-    );
-    $dao = CRM_Core_DAO::executeQuery($query, $sqlParams);
-    if ($dao->N) {
-      $defaultPriceSetId = CRM_Core_DAO::getFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_DAO_Set', 'default_contribution_amount', 'id', 'name');
-      $priceSets = current(CRM_Upgrade_Snapshot_V4p2_Price_BAO_Set::getSetDetail($defaultPriceSetId));
-      $fieldID = key($priceSets['fields']);
-    }
-
-    while ($dao->fetch()) {
-      $lineParams = array(
-        'entity_table' => 'civicrm_participant',
-        'entity_id' => $dao->participant_id,
-        'label' => $dao->fee_level ? $dao->fee_level : ts('Default'),
-        'qty' => 1,
-        'unit_price' => $dao->fee_amount,
-        'line_total' => $dao->fee_amount,
-        'participant_count' => 1,
-      );
-      if ($dao->is_monetary && $dao->price_field_id) {
-        $lineParams += array(
-          'price_field_id' => $dao->price_field_id,
-          'price_field_value_id' => $dao->price_field_value_id,
-        );
-        $priceSetId = $dao->price_set_id;
-      }
-      else {
-        $lineParams['price_field_id'] = $fieldID;
-        $priceSetId = $defaultPriceSetId;
-      }
-      CRM_Upgrade_Snapshot_V4p2_Price_BAO_LineItem::create($lineParams);
-    }
-    return TRUE;
-  }
-
-  /**
-   * (Queue Task Callback)
-   *
-   * Create an event registration profile with a single email field CRM-9587
-   *
-   * @param \CRM_Queue_TaskContext $ctx
-   *
-   * @return bool
-   */
-  public static function task_4_2_alpha1_eventProfile(CRM_Queue_TaskContext $ctx) {
-    $upgrade = new CRM_Upgrade_Form();
-    $profileTitle = ts('Your Registration Info');
-
-    $sql = "
-INSERT INTO civicrm_uf_group
-  (is_active, group_type, title, help_pre, help_post, limit_listings_group_id, post_URL, add_to_group_id, add_captcha, is_map, is_edit_link, is_uf_link, is_update_dupe, cancel_URL, is_cms_user, notify, is_reserved, name, created_id, created_date, is_proximity_search)
-VALUES
-  (1, 'Individual, Contact', %1, NULL, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, 0, NULL, 0, 'event_registration', NULL, NULL, 0);
-";
-
-    $params = array(
-      1 => array($profileTitle, 'String'),
-    );
-
-    CRM_Core_DAO::executeQuery($sql, $params);
-
-    $eventRegistrationId = CRM_Core_DAO::singleValueQuery('SELECT LAST_INSERT_ID()');
-    $sql = "
-INSERT INTO civicrm_uf_field
-  (uf_group_id, field_name, is_active, is_view, is_required, weight, help_post, help_pre, visibility, in_selector, is_searchable, location_type_id, phone_type_id, label, field_type, is_reserved)
-VALUES
-  ({$eventRegistrationId}, 'email', 1, 0, 1, 1, NULL, NULL, 'User and User Admin Only', 0, 0, NULL, NULL, 'Email Address', 'Contact', 0);
-";
-    CRM_Core_DAO::executeQuery($sql);
-
-    $sql = "SELECT * FROM civicrm_event WHERE is_online_registration = 1;";
-    $events = CRM_Core_DAO::executeQuery($sql);
-    while ($events->fetch()) {
-      // Get next weights for the event registration profile
-      $nextMainWeight = $nextAdditionalWeight = 1;
-      $sql = "
-SELECT   weight
-FROM     civicrm_uf_join
-WHERE    entity_id = {$events->id} AND module = 'CiviEvent'
-ORDER BY weight DESC LIMIT 1";
-      $weights = CRM_Core_DAO::executeQuery($sql);
-      $weights->fetch();
-      if (isset($weights->weight)) {
-        $nextMainWeight += $weights->weight;
-      }
-      $sql = "
-SELECT   weight
-FROM     civicrm_uf_join
-WHERE    entity_id = {$events->id} AND module = 'CiviEvent_Additional'
-ORDER BY weight DESC LIMIT 1";
-      $weights = CRM_Core_DAO::executeQuery($sql);
-      $weights->fetch();
-      if (isset($weights->weight)) {
-        $nextAdditionalWeight += $weights->weight;
-      }
-      // Add an event registration profile to the event
-      $sql = "
-INSERT INTO civicrm_uf_join
-  (is_active, module, entity_table, entity_id, weight, uf_group_id)
-VALUES
-  (1, 'CiviEvent', 'civicrm_event', {$events->id}, {$nextMainWeight}, {$eventRegistrationId});
-";
-      CRM_Core_DAO::executeQuery($sql);
-      $sql = "
-INSERT INTO civicrm_uf_join
-  (is_active, module, entity_table, entity_id, weight, uf_group_id)
-VALUES
-  (1, 'CiviEvent_Additional', 'civicrm_event', {$events->id}, {$nextAdditionalWeight}, {$eventRegistrationId});";
-      CRM_Core_DAO::executeQuery($sql);
-    }
-    return TRUE;
-  }
-
-  /**
-   * @return array
-   */
-  public static function deleteInvalidPairs() {
-    require_once 'CRM/Member/PseudoConstant.php';
-    require_once 'CRM/Contribute/PseudoConstant.php';
-    $processedRecords = array();
-
-    $tempTableName1 = CRM_Core_DAO::createTempTableName();
-    // 1. collect all duplicates
-    $sql = "
-  CREATE TEMPORARY TABLE {$tempTableName1} SELECT mp.id as payment_id, mp.contribution_id, mp.membership_id, mem.membership_type_id, mem.start_date, mem.end_date, mem.status_id, mem.contact_id, con.contribution_status_id
-  FROM civicrm_membership_payment mp
-  INNER JOIN ( SELECT cmp.contribution_id
-                FROM civicrm_membership_payment cmp
-                LEFT JOIN civicrm_line_item cli ON cmp.contribution_id=cli.entity_id and cli.entity_table = 'civicrm_contribution'
-                WHERE cli.entity_id IS NULL
-                GROUP BY cmp.contribution_id
-                HAVING COUNT(cmp.membership_id) > 1) submp ON submp.contribution_id = mp.contribution_id
-  INNER JOIN civicrm_membership mem ON mem.id = mp.membership_id
-  INNER JOIN civicrm_contribution con ON con.id = mp.contribution_id
-  ORDER BY mp.contribution_id, mp.membership_id";
-    $dao = CRM_Core_DAO::executeQuery($sql);
-
-    $tempTableName2 = CRM_Core_DAO::createTempTableName();
-    // 2. collect all records that are going to be retained
-    $sql = "
-  CREATE TEMPORARY TABLE {$tempTableName2}
-  SELECT MAX(payment_id) as payment_id FROM {$tempTableName1} GROUP BY contribution_id HAVING COUNT(*) > 1";
-    CRM_Core_DAO::executeQuery($sql);
-
-    // 3. do the un-linking
-    $sql = "
-  DELETE cmp.*
-  FROM   civicrm_membership_payment cmp
-  INNER JOIN $tempTableName1 temp1 ON temp1.payment_id = cmp.id
-  LEFT JOIN  $tempTableName2 temp2 ON temp1.payment_id = temp2.payment_id
-  WHERE temp2.payment_id IS NULL";
-    CRM_Core_DAO::executeQuery($sql);
-
-    // 4. show all records that were Processed, i.e Retained vs Un-linked
-    $sql = "
-  SELECT temp1.contact_id, temp1.contribution_id, temp1.contribution_status_id, temp1.membership_id, temp1.membership_type_id, temp1.start_date, temp1.end_date, temp1.status_id, temp2.payment_id as retain_id
-  FROM $tempTableName1 temp1
-  LEFT JOIN  $tempTableName2 temp2 ON temp1.payment_id = temp2.payment_id";
-    $dao = CRM_Core_DAO::executeQuery($sql);
-    if ($dao->N) {
-      $membershipType = CRM_Member_PseudoConstant::membershipType();
-      $membershipStatus = CRM_Member_PseudoConstant::membershipStatus();
-      $contributionStatus = CRM_Contribute_PseudoConstant::contributionStatus();
-      while ($dao->fetch()) {
-        $status = $dao->retain_id ? 'Retained' : 'Un-linked';
-        $memType = CRM_Utils_Array::value($dao->membership_type_id, $membershipType);
-        $memStatus = CRM_Utils_Array::value($dao->status_id, $membershipStatus);
-        $contribStatus = CRM_Utils_Array::value($dao->contribution_status_id, $contributionStatus);
-        $processedRecords[] = array(
-          $dao->contact_id,
-          $dao->contribution_id,
-          $contribStatus,
-          $dao->membership_id,
-          $memType,
-          $dao->start_date,
-          $dao->end_date,
-          $memStatus,
-          $status,
-        );
-      }
-    }
-
-    if (!empty($processedRecords)) {
-      CRM_Core_Error::debug_log_message("deleteInvalidPairs() - The following records have been processed. Membership records with action:");
-      CRM_Core_Error::debug_log_message("Contact ID, ContributionID, Contribution Status, MembershipID, Membership Type, Start Date, End Date, Membership Status, Action");
-      foreach ($processedRecords as $record) {
-        CRM_Core_Error::debug_log_message(implode(', ', $record));
-      }
-    }
-    else {
-      CRM_Core_Error::debug_log_message("deleteInvalidPairs() - Could not find any records to process.");
-    }
-    return $processedRecords;
-  }
-
-}
diff --git a/CRM/Upgrade/Incremental/sql/4.2.0.mysql.tpl b/CRM/Upgrade/Incremental/sql/4.2.0.mysql.tpl
deleted file mode 100644 (file)
index ba1ac76..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
--- CRM-10641 (fix duplicate option values)
-
-SELECT @option_group_id_act := max(id) from civicrm_option_group where name = 'activity_type';
-SELECT @maxValue            := MAX(ROUND(value)) FROM civicrm_option_value WHERE option_group_id = @option_group_id_act;
-SELECT @clientSMSValue     := value FROM civicrm_option_value WHERE name = 'BULK SMS' AND option_group_id = @option_group_id_act;
-
-SELECT @smsVal := value FROM civicrm_option_value  WHERE option_group_id = @option_group_id_act GROUP BY value
-HAVING count(value) > 1 AND value = @clientSMSValue;
-
-UPDATE civicrm_option_value
-SET value = @maxValue + 1
-WHERE value = @smsVal
-AND name = 'BULK SMS' AND option_group_id = @option_group_id_act;
-
-SELECT @newClientSMSValue     := value FROM civicrm_option_value WHERE name = 'BULK SMS' AND option_group_id = @option_group_id_act;
-
-UPDATE civicrm_activity
-INNER JOIN civicrm_mailing ON civicrm_activity.source_record_id = civicrm_mailing.id
-SET   civicrm_activity.activity_type_id = @newClientSMSValue
-WHERE civicrm_activity.activity_type_id = @clientSMSValue;
-
--- CRM-10671 remove incomplete price set reports (inserted in 4.2 alpha 1)
-SELECT @option_group_id_report := MAX(id) FROM civicrm_option_group WHERE name = 'report_template';
-DELETE from civicrm_option_value
-WHERE name = 'CRM_Report_Form_Price_Lineitem' AND
-option_group_id = @option_group_id_report;
-
-DELETE from civicrm_option_value
-WHERE name = 'CRM_Report_Form_Price_Contributionbased' AND
-option_group_id = @option_group_id_report;
-
-DELETE from civicrm_option_value
-WHERE name = 'CRM_Report_Form_Price_Lineitemparticipant' AND
-option_group_id = @option_group_id_report;
\ No newline at end of file
diff --git a/CRM/Upgrade/Incremental/sql/4.2.1.mysql.tpl b/CRM/Upgrade/Incremental/sql/4.2.1.mysql.tpl
deleted file mode 100644 (file)
index 85d51e1..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
--- CRM-10794
-DELETE FROM civicrm_payment_processor_type WHERE name = 'ClickAndPledge';
-DELETE FROM civicrm_payment_processor WHERE payment_processor_type = 'ClickAndPledge';
-
diff --git a/CRM/Upgrade/Incremental/sql/4.2.2.mysql.tpl b/CRM/Upgrade/Incremental/sql/4.2.2.mysql.tpl
deleted file mode 100644 (file)
index 8317795..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
--- CRM-10810
-SELECT @max_strict := max(id), @cnt_strict := count(*) FROM `civicrm_dedupe_rule_group` WHERE `contact_type` = 'Individual' AND `level` = 'Strict' AND `is_default` = 1;
-UPDATE `civicrm_dedupe_rule_group` SET  `is_default` = 0 WHERE @cnt_strict > 1 AND id = @max_strict;
-
-SELECT @max_fuzzy := max(id), @cnt_fuzzy := count(*) FROM `civicrm_dedupe_rule_group` WHERE `contact_type` = 'Individual' AND `level` = 'Fuzzy' AND `is_default` = 1;
-UPDATE `civicrm_dedupe_rule_group` SET  `is_default` = 0 WHERE @cnt_fuzzy > 1 AND id = @max_fuzzy;
-
--- Insert line items for contribution for api/import
-SELECT @fieldID := cpf.id, @fieldValueID := cpfv.id FROM civicrm_price_set cps
-LEFT JOIN civicrm_price_field cpf ON  cps.id = cpf.price_set_id
-LEFT JOIN civicrm_price_field_value cpfv ON cpf.id = cpfv.price_field_id
-WHERE cps.name = 'default_contribution_amount';
-
-INSERT INTO civicrm_line_item ( entity_table, entity_id, price_field_id,label, qty, unit_price, line_total, participant_count, price_field_value_id )
-SELECT 'civicrm_contribution', cc.id, @fieldID, 'Contribution Amount', 1, total_amount, total_amount , 0, @fieldValueID
-FROM `civicrm_contribution` cc
-LEFT JOIN civicrm_line_item cli ON cc.id=cli.entity_id and cli.entity_table = 'civicrm_contribution'
-LEFT JOIN civicrm_membership_payment cmp ON cc.id = cmp.contribution_id
-LEFT JOIN civicrm_participant_payment cpp ON cc.id = cpp.contribution_id
-WHERE cli.entity_id IS NULL AND cc.contribution_page_id IS NULL AND cmp.contribution_id IS NULL AND cpp.contribution_id IS NULL
-GROUP BY cc.id;
diff --git a/CRM/Upgrade/Incremental/sql/4.2.3.mysql.tpl b/CRM/Upgrade/Incremental/sql/4.2.3.mysql.tpl
deleted file mode 100644 (file)
index 4721762..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
--- CRM-10969
-SELECT @mailingsID := MAX(id) FROM civicrm_navigation WHERE name = 'Mailings' AND domain_id = {$domainID};
-SELECT @navWeight := MAX(id) FROM civicrm_navigation WHERE name = 'New SMS' AND parent_id = @mailingsID;
-
-UPDATE civicrm_navigation SET has_separator = NULL
-WHERE name = 'New SMS' AND parent_id = @mailingsID AND has_separator = 1;
-
-INSERT INTO civicrm_navigation
-    ( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight )
-VALUES
-    ( {$domainID}, 'civicrm/mailing/browse?reset=1&sms=1', '{ts escape="sql" skip="true"}Find Mass SMS{/ts}', 'Find Mass SMS', 'administer CiviCRM', NULL, @mailingsID, '1', 1, @navWeight+1 );
-
--- CRM-10980 and CRM-11014
-SELECT @optionID := max(id) FROM civicrm_option_value WHERE name = 'BULK SMS';
-{if $multilingual}
-    {foreach from=$locales item=locale}
-    UPDATE `civicrm_option_value` SET label_{$locale} = '{ts escape="sql"}Mass SMS{/ts}',name = 'Mass SMS',description_{$locale} = '{ts escape="sql"}Mass SMS{/ts}' WHERE id = @optionID;
-      ALTER TABLE `civicrm_price_field_value` CHANGE name name VARCHAR(255) NULL DEFAULT NULL, CHANGE label_{$locale} label_{$locale} VARCHAR(255)  NULL DEFAULT NULL;
-    {/foreach}
-{else}
-  UPDATE `civicrm_option_value` SET label = '{ts escape="sql"}Mass SMS{/ts}',name = 'Mass SMS',description = '{ts escape="sql"}Mass SMS{/ts}' WHERE name = 'BULK SMS';
-  ALTER TABLE `civicrm_price_field_value` CHANGE `name` `name` VARCHAR(255) NULL DEFAULT NULL, CHANGE `label` `label` VARCHAR(255)  NULL DEFAULT NULL;
-{/if}
-
--- CRM-11014
-  ALTER TABLE `civicrm_line_item` CHANGE `label` `label` VARCHAR(255) NULL DEFAULT NULL;
-
--- CRM-10986: Rename Batches UI elements to Bulk Data Entry
--- update reserved profile titles
-{if $multilingual}
-  {foreach from=$locales item=locale}
-    UPDATE `civicrm_uf_group` SET title_{$locale} = '{ts escape="sql"}Contribution Bulk Entry{/ts}' WHERE name = 'contribution_batch_entry';
-    UPDATE `civicrm_uf_group` SET title_{$locale} = '{ts escape="sql"}Membership Bulk Entry{/ts}' WHERE name = 'membership_batch_entry';
-  {/foreach}
-{else}
-  UPDATE `civicrm_uf_group` SET title = '{ts escape="sql"}Contribution Bulk Entry{/ts}' WHERE name = 'contribution_batch_entry';
-  UPDATE `civicrm_uf_group` SET title = '{ts escape="sql"}Membership Bulk Entry{/ts}' WHERE name = 'membership_batch_entry';
-{/if}
-
--- update navigation menu items and fix typo in permission column
-UPDATE `civicrm_navigation` SET label = '{ts escape="sql"}Bulk Data Entry{/ts}', name = 'Bulk Data Entry',
-permission = 'access CiviMember, access CiviContribute'
-WHERE url = 'civicrm/batch&reset=1';
-
--- CRM-11018
-ALTER TABLE civicrm_discount DROP FOREIGN KEY FK_civicrm_discount_option_group_id;
-ALTER TABLE `civicrm_discount`
-  ADD CONSTRAINT `FK_civicrm_discount_option_group_id` FOREIGN KEY (`option_group_id`) REFERENCES `civicrm_price_set` (`id`) ON DELETE CASCADE;
-ALTER TABLE `civicrm_discount` CHANGE `option_group_id` `option_group_id` int(10) unsigned NOT NULL COMMENT 'FK to civicrm_price_set';
\ No newline at end of file
diff --git a/CRM/Upgrade/Incremental/sql/4.2.5.mysql.tpl b/CRM/Upgrade/Incremental/sql/4.2.5.mysql.tpl
deleted file mode 100644 (file)
index f60a29a..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
--- Placeholder which ensures that PHP upgrade tasks are executed
-
--- Get domain id
-SELECT  @domainID := min(id) FROM civicrm_domain;
-
--- CRM-11060
-INSERT INTO `civicrm_job`
-    ( domain_id, run_frequency, last_run, name, description, api_prefix, api_entity, api_action, parameters, is_active )
-VALUES
-    ( @domainID, 'Always' , NULL, '{ts escape="sql" skip="true"}Send Scheduled SMS{/ts}', '{ts escape="sql" skip="true"}Sends out scheduled SMS{/ts}',  'civicrm_api3', 'job', 'process_sms', NULL, 0);
diff --git a/CRM/Upgrade/Incremental/sql/4.2.6.mysql.tpl b/CRM/Upgrade/Incremental/sql/4.2.6.mysql.tpl
deleted file mode 100644 (file)
index fb658a6..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
--- Placeholder which ensures that PHP upgrade tasks are executed
-
diff --git a/CRM/Upgrade/Incremental/sql/4.2.7.mysql.tpl b/CRM/Upgrade/Incremental/sql/4.2.7.mysql.tpl
deleted file mode 100644 (file)
index f93262a..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
--- CRM-11354 Fix empty permissions for report instances
-UPDATE civicrm_report_instance SET permission = 'access CiviReport'
-WHERE report_id = 'survey/detail' and permission = '';
-
-UPDATE civicrm_report_instance SET permission = 'access CiviMail'
-WHERE report_id = 'mailing/detail' and permission = '';
-
-UPDATE civicrm_report_instance SET permission = 'access CiviMember'
-WHERE report_id = 'member/contributionDetail' and permission = '';
-
-UPDATE civicrm_report_instance SET permission = 'access CiviGrant'
-WHERE report_id = 'grant/statistics' and permission = '';
-
-UPDATE civicrm_report_instance SET permission = 'access CiviReport'
-WHERE permission = '0' OR permission = '' OR permission IS NULL;
\ No newline at end of file
diff --git a/CRM/Upgrade/Incremental/sql/4.2.8.mysql.tpl b/CRM/Upgrade/Incremental/sql/4.2.8.mysql.tpl
deleted file mode 100644 (file)
index fb658a6..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
--- Placeholder which ensures that PHP upgrade tasks are executed
-
diff --git a/CRM/Upgrade/Incremental/sql/4.2.9.mysql.tpl b/CRM/Upgrade/Incremental/sql/4.2.9.mysql.tpl
deleted file mode 100644 (file)
index fb658a6..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
--- Placeholder which ensures that PHP upgrade tasks are executed
-
diff --git a/CRM/Upgrade/Incremental/sql/4.2.alpha1.mysql.tpl b/CRM/Upgrade/Incremental/sql/4.2.alpha1.mysql.tpl
deleted file mode 100644 (file)
index 8f7c319..0000000
+++ /dev/null
@@ -1,409 +0,0 @@
-{include file='../CRM/Upgrade/4.2.alpha1.msg_template/civicrm_msg_template.tpl'}
-
--- CRM-9542 mailing detail report template
-SELECT @option_group_id_report := MAX(id)     FROM civicrm_option_group WHERE name = 'report_template';
-SELECT @weight                 := MAX(weight) FROM civicrm_option_value WHERE option_group_id = @option_group_id_report;
-SELECT @mailCompId       := MAX(id)     FROM civicrm_component where name = 'CiviMail';
-INSERT INTO civicrm_option_value
-  (option_group_id, {localize field='label'}label{/localize}, value, name, weight, {localize field='description'}description{/localize}, is_active, component_id) VALUES
-  (@option_group_id_report, {localize}'Mail Detail Report'{/localize}, 'mailing/detail', 'CRM_Report_Form_Mailing_Detail', @weight := @weight + 1, {localize}'Provides reporting on Intended and Successful Deliveries, Unsubscribes and Opt-outs, Replies and Forwards.'{/localize}, 1, @mailCompId);
-
-INSERT INTO `civicrm_report_instance`
-    ( `domain_id`, `title`, `report_id`, `description`, `permission`, `form_values`)
-VALUES
-    ( {$domainID}, 'Mailing Detail Report', 'mailing/detail', 'Provides reporting on Intended and Successful Deliveries, Unsubscribes and Opt-outs, Replies and Forwards.', 'access CiviMail', '{literal}a:30:{s:6:"fields";a:6:{s:9:"sort_name";s:1:"1";s:12:"mailing_name";s:1:"1";s:11:"delivery_id";s:1:"1";s:14:"unsubscribe_id";s:1:"1";s:9:"optout_id";s:1:"1";s:5:"email";s:1:"1";}s:12:"sort_name_op";s:3:"has";s:15:"sort_name_value";s:0:"";s:6:"id_min";s:0:"";s:6:"id_max";s:0:"";s:5:"id_op";s:3:"lte";s:8:"id_value";s:0:"";s:13:"mailing_id_op";s:2:"in";s:16:"mailing_id_value";a:0:{}s:18:"delivery_status_op";s:2:"eq";s:21:"delivery_status_value";s:0:"";s:18:"is_unsubscribed_op";s:2:"eq";s:21:"is_unsubscribed_value";s:0:"";s:12:"is_optout_op";s:2:"eq";s:15:"is_optout_value";s:0:"";s:13:"is_replied_op";s:2:"eq";s:16:"is_replied_value";s:0:"";s:15:"is_forwarded_op";s:2:"eq";s:18:"is_forwarded_value";s:0:"";s:6:"gid_op";s:2:"in";s:9:"gid_value";a:0:{}s:9:"order_bys";a:1:{i:1;a:2:{s:6:"column";s:9:"sort_name";s:5:"order";s:3:"ASC";}}s:11:"description";s:21:"Mailing Detail Report";s:13:"email_subject";s:0:"";s:8:"email_to";s:0:"";s:8:"email_cc";s:0:"";s:10:"permission";s:15:"access CiviMail";s:9:"parent_id";s:0:"";s:6:"groups";s:0:"";s:9:"domain_id";i:1;}{/literal}');
-
-SELECT @reportlastID       := MAX(id) FROM civicrm_navigation where name = 'Reports' AND domain_id = {$domainID};
-SELECT @nav_max_weight     := MAX(ROUND(weight)) from civicrm_navigation WHERE parent_id = @reportlastID;
-
-SET @instanceID:=LAST_INSERT_ID();
-INSERT INTO civicrm_navigation
-    ( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight )
-VALUES
-    ( {$domainID}, CONCAT('civicrm/report/instance/', @instanceID,'&reset=1'), '{ts escape="sql"}Mailing Detail Report{/ts}', 'Mailing Detail Report', 'access CiviMail', 'OR', @reportlastID, '1', NULL, @nav_max_weight+1 );
-UPDATE civicrm_report_instance SET navigation_id = LAST_INSERT_ID() WHERE id = @instanceID;
-
--- CRM-9600
-ALTER TABLE `civicrm_custom_group` CHANGE `extends_entity_column_value` `extends_entity_column_value` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT 'linking custom group for dynamic object.';
-
--- CRM-9534
-ALTER TABLE `civicrm_prevnext_cache` ADD COLUMN is_selected tinyint(4) DEFAULT '0';
-
--- CRM-9834
--- civicrm_batch table changes
-ALTER TABLE `civicrm_batch` ADD UNIQUE KEY `UI_name` ( name );
-
-
-ALTER TABLE `civicrm_batch` ADD `saved_search_id` int(10) unsigned DEFAULT NULL COMMENT 'FK to Saved Search ID';
-ALTER TABLE `civicrm_batch` ADD `status_id` int(10) unsigned NOT NULL COMMENT 'fk to Batch Status options in civicrm_option_values';
-ALTER TABLE `civicrm_batch` ADD `type_id` int(10) unsigned NOT NULL COMMENT 'fk to Batch Type options in civicrm_option_values';
-ALTER TABLE `civicrm_batch` ADD `mode_id` int(10) unsigned DEFAULT NULL COMMENT 'fk to Batch mode options in civicrm_option_values';
-ALTER TABLE `civicrm_batch` ADD `total` decimal(20,2) DEFAULT NULL COMMENT 'Total amount for this batch.';
-ALTER TABLE `civicrm_batch` ADD `item_count` int(10) unsigned NOT NULL COMMENT 'Number of items in a batch.';
-
-ALTER TABLE `civicrm_batch` ADD CONSTRAINT `FK_civicrm_batch_saved_search_id` FOREIGN KEY (`saved_search_id`) REFERENCES `civicrm_saved_search` (`id`) ON DELETE SET NULL;
-
---batch type and batch status option groups
-INSERT INTO
-   `civicrm_option_group` (`name`, {localize field='title'}title{/localize}, `is_reserved`, `is_active`)
-VALUES
-  ('batch_type'          , {localize}'Batch Type'{/localize}                         , 1, 1),
-  ('batch_status'        , {localize}'Batch Status'{/localize}                       , 1, 1);
-
-SELECT @option_group_id_batch_type     := max(id) from civicrm_option_group where name = 'batch_type';
-SELECT @option_group_id_batch_status   := max(id) from civicrm_option_group where name = 'batch_status';
-
-INSERT INTO
-   `civicrm_option_value` (`option_group_id`, {localize field='label'}label{/localize}, `value`, `name`, `grouping`, `filter`, `is_default`, `weight`)
-VALUES
-   (@option_group_id_batch_type, {localize}'Contribution'{/localize}, 1, 'Contribution', NULL, 0, 0, 1),
-   (@option_group_id_batch_type, {localize}'Membership'{/localize}, 2, 'Membership', NULL, 0, 0, 2),
-   (@option_group_id_batch_status, {localize}'Open'{/localize}, 1, 'Open', NULL, 0, 0, 1),
-   (@option_group_id_batch_status, {localize}'Closed'{/localize}, 2, 'Closed', NULL, 0, 0, 2);
-
---default profile for contribution and membership batch entry
-INSERT INTO civicrm_uf_group
-    ( name, group_type, {localize field='title'}title{/localize}, is_cms_user, is_reserved)
- VALUES
-    ( 'contribution_batch_entry', 'Contribution', {localize}'Contribution Batch Entry'{/localize} , 0, 1),
-    ( 'membership_batch_entry',   'Membership',   {localize}'Membership Batch Entry'{/localize} ,   0, 1);
-
-SELECT @uf_group_contribution_batch_entry     := max(id) FROM civicrm_uf_group WHERE name = 'contribution_batch_entry';
-SELECT @uf_group_membership_batch_entry       := max(id) FROM civicrm_uf_group WHERE name = 'membership_batch_entry';
-
-INSERT INTO civicrm_uf_join
-   (is_active, module, entity_table, entity_id, weight, uf_group_id)
-VALUES
-   (1, 'Profile', NULL, NULL, 9, @uf_group_contribution_batch_entry),
-   (1, 'Profile', NULL, NULL, 9, @uf_group_membership_batch_entry);
-
-INSERT INTO civicrm_uf_field
-       ( uf_group_id, field_name,              is_required, is_reserved, weight, visibility,                  in_selector, is_searchable, location_type_id, {localize field='label'}label{/localize},  field_type )
-VALUES
-       ( @uf_group_contribution_batch_entry,     'contribution_type',           1, 1, 1, 'User and User Admin Only', 0, 0, NULL, {localize}'Type'{/localize}, 'Contribution'),
-       ( @uf_group_contribution_batch_entry,     'total_amount',                1, 1, 2, 'User and User Admin Only', 0, 0, NULL, {localize}'Amount'{/localize}, 'Contribution' ),
-       ( @uf_group_contribution_batch_entry,     'contribution_status_id',      1, 1, 3, 'User and User Admin Only', 0, 0, NULL, {localize}'Status'{/localize}, 'Contribution' ),
-       ( @uf_group_contribution_batch_entry,     'receive_date',                1, 1, 4, 'User and User Admin Only', 0, 0, NULL, {localize}'Received'{/localize}, 'Contribution'),
-       ( @uf_group_contribution_batch_entry,     'contribution_source',         0, 0, 5, 'User and User Admin Only', 0, 0, NULL, {localize}'Source'{/localize}, 'Contribution' ),
-       ( @uf_group_contribution_batch_entry,     'payment_instrument',          0, 0, 6, 'User and User Admin Only', 0, 0, NULL, {localize}'Payment Instrument'{/localize}, 'Contribution' ),
-       ( @uf_group_contribution_batch_entry,     'check_number',                0, 0, 7, 'User and User Admin Only', 0, 0, NULL, {localize}'Check Number'{/localize}, 'Contribution' ),
-       ( @uf_group_contribution_batch_entry,     'send_receipt',                0, 0, 8, 'User and User Admin Only', 0, 0, NULL, {localize}'Send Receipt'{/localize}, 'Contribution' ),
-       ( @uf_group_contribution_batch_entry,     'invoice_id',                  0, 0, 9, 'User and User Admin Only', 0, 0, NULL, {localize}'Invoice ID'{/localize}, 'Contribution' ),
-       ( @uf_group_membership_batch_entry,     'membership_type',             1, 1, 1, 'User and User Admin Only', 0, 0, NULL, {localize}'Type'{/localize}, 'Membership' ),
-       ( @uf_group_membership_batch_entry,     'join_date',                   1, 1, 2, 'User and User Admin Only', 0, 0, NULL, {localize}'Member Since'{/localize}, 'Membership' ),
-       ( @uf_group_membership_batch_entry,     'membership_start_date',       0, 1, 3, 'User and User Admin Only', 0, 0, NULL, {localize}'Start Date'{/localize}, 'Membership' ),
-       ( @uf_group_membership_batch_entry,     'membership_end_date',         0, 1, 4, 'User and User Admin Only', 0, 0, NULL, {localize}'End Date'{/localize}, 'Membership' ),
-       ( @uf_group_membership_batch_entry,     'membership_source',           0, 0, 5, 'User and User Admin Only', 0, 0, NULL, {localize}'Source'{/localize}, 'Membership' ),
-       ( @uf_group_membership_batch_entry,     'send_receipt',                0, 0, 6, 'User and User Admin Only', 0, 0, NULL, {localize}'Send Receipt'{/localize}, 'Membership' ),
-       ( @uf_group_membership_batch_entry,     'contribution_type',           1, 1, 7, 'User and User Admin Only', 0, 0, NULL, {localize}'Contribution Type'{/localize}, 'Membership' ),
-       ( @uf_group_membership_batch_entry,     'total_amount',                1, 1, 8, 'User and User Admin Only', 0, 0, NULL, {localize}'Amount'{/localize}, 'Membership' ),
-       ( @uf_group_membership_batch_entry,     'receive_date',                1, 1, 9, 'User and User Admin Only', 0, 0, NULL, {localize}'Received'{/localize}, 'Membership' ),
-       ( @uf_group_membership_batch_entry,     'payment_instrument',          0, 0, 10, 'User and User Admin Only', 0, 0, NULL, {localize}'Payment Instrument'{/localize}, 'Membership' ),
-       ( @uf_group_membership_batch_entry,     'contribution_status_id',      1, 1, 11, 'User and User Admin Only', 0, 0, NULL, {localize}'Payment Status'{/localize}, 'Membership' );
-
---navigation menu entries
-SELECT @navContributionsID := MAX(id) FROM civicrm_navigation where name = 'Contributions' AND domain_id = {$domainID};
-SELECT @navMembershipsID := MAX(id) FROM civicrm_navigation where name = 'Memberships' AND domain_id = {$domainID};
-
-INSERT INTO civicrm_navigation
-    ( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight )
-VALUES
-    ( {$domainID}, 'civicrm/batch&reset=1', '{ts escape="sql" skip="true"}Batches{/ts}', 'Batches', 'access CiviContribute,access CiviMember', '', @navContributionsID, '1', NULL, 4 ),
-    ( {$domainID}, 'civicrm/batch&reset=1', '{ts escape="sql" skip="true"}Batches{/ts}', 'Batches', 'access CiviMember,access CiviContribute',  '', @navMembershipsID, '1', NULL, 4 );
-
--- CRM-9686
-INSERT INTO `civicrm_state_province`(`country_id`, `abbreviation`, `name`) VALUES(1097, "LP", "La Paz");
-
--- CRM-9905
-ALTER TABLE civicrm_contribution_page CHANGE COLUMN is_email_receipt is_email_receipt TINYINT(4) DEFAULT 0;
-
--- CRM-9850
- ALTER TABLE `civicrm_contribution_page` CHANGE `payment_processor_id` `payment_processor` VARCHAR( 128 ) NULL DEFAULT NULL COMMENT 'Payment Processor for this contribution Page ';
-
- ALTER TABLE `civicrm_event` CHANGE `payment_processor_id` `payment_processor` VARCHAR( 128 ) NULL DEFAULT NULL COMMENT 'Payment Processor for this event ';
-
--- CRM-9783
-CREATE TABLE `civicrm_sms_provider` (
-  `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'SMS Provider ID',
-  `name` varchar(64) DEFAULT NULL COMMENT 'Provider internal name points to option_value of option_group sms_provider_name',
-  `title` varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Provider name visible to user',
-  `username` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
-  `password` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
-  `api_type` int(10) unsigned NOT NULL COMMENT 'points to value in civicrm_option_value for group sms_api_type',
-  `api_url` varchar(128) COLLATE utf8_unicode_ci DEFAULT NULL,
-  `api_params` text COLLATE utf8_unicode_ci COMMENT 'the api params in xml, http or smtp format',
-  `is_default` tinyint(4) DEFAULT '0',
-  `is_active` tinyint(4) DEFAULT '0',
-  PRIMARY KEY (`id`)
-) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1;
-
-ALTER TABLE `civicrm_mailing` ADD `sms_provider_id` int(10) unsigned NULL COMMENT 'FK to civicrm_sms_provider id ';
-ALTER TABLE `civicrm_mailing` ADD CONSTRAINT `FK_civicrm_mailing_sms_provider_id` FOREIGN KEY (`sms_provider_id`) REFERENCES `civicrm_sms_provider` (`id`) ON DELETE SET NULL;
-
-INSERT INTO
-   `civicrm_option_group` (`name`, {localize field='title'}`title`{/localize}, `is_reserved`, `is_active`)
-VALUES
-   ('sms_provider_name', {localize}'Sms provider Internal Name'{/localize} , 1, 1);
-SELECT @option_group_id_sms_provider_name := max(id) from civicrm_option_group where name = 'sms_provider_name';
-
-INSERT INTO civicrm_option_value
-     (option_group_id, {localize field='label'}label{/localize}, value, name, weight, filter, is_default, component_id)
-VALUES
-     (@option_group_id_sms_provider_name, {localize}'Clickatell'{/localize}, 'Clickatell', 'Clickatell', 1, 0, NULL, NULL);
-
-INSERT INTO
-   `civicrm_option_group` (`name`, {localize field='title'}`title`{/localize}, `is_reserved`, `is_active`)
-VALUES
-    ( 'sms_api_type', {localize}'{ts escape="sql"}Api Type{/ts}'{/localize} , 1, 1 );
-SELECT @option_group_id_sms_api_type := max(id) from civicrm_option_group where name = 'sms_api_type';
-
-INSERT INTO civicrm_option_value
-     (option_group_id, {localize field='label'}label{/localize}, value, name, weight, filter, is_default, is_reserved, component_id)
-VALUES
-     (@option_group_id_sms_api_type, {localize}'http'{/localize},  1, 'http',  1, NULL, 0, 1, NULL),
-     (@option_group_id_sms_api_type, {localize}'xml'{/localize},   2, 'xml',   2, NULL, 0, 1, NULL),
-     (@option_group_id_sms_api_type, {localize}'smtp'{/localize},  3, 'smtp',  3, NULL, 0, 1, NULL);
-
--- CRM-9784
-SELECT @adminSystemSettingsID := MAX(id) FROM civicrm_navigation where name = 'System Settings' AND domain_id = {$domainID};
-
-INSERT INTO civicrm_navigation
-    ( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight )
-VALUES
-    ( {$domainID}, 'civicrm/admin/sms/provider?reset=1', '{ts escape="sql" skip="true"}SMS Providers{/ts}', 'SMS Providers', 'administer CiviCRM', '', @adminSystemSettingsID, '1', NULL, 16 );
-
--- CRM-9799
-
-SELECT @mailingsID := MAX(id) FROM civicrm_navigation where name = 'Mailings' AND domain_id = {$domainID};
-
-INSERT INTO civicrm_navigation
-    ( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight )
-VALUES
-    ( {$domainID}, 'civicrm/sms/send?reset=1', '{ts escape="sql" skip="true"}New SMS{/ts}', 'New SMS', 'administer CiviCRM', NULL, @mailingsID, '1', 1, 8 );
-
-SELECT @fromEmailAddressesID := MAX(id) FROM civicrm_navigation where name = 'From Email Addresses' AND domain_id = {$domainID};
-
-UPDATE civicrm_navigation SET has_separator = 1 WHERE parent_id = @mailingsID AND name = 'From Email Addresses';
-
-SELECT @option_group_id_act := max(id) from civicrm_option_group where name = 'activity_type';
-SELECT @max_wt              := MAX(weight) FROM civicrm_option_value WHERE option_group_id = @option_group_id_act;
-
-INSERT INTO
-   `civicrm_option_value` (`option_group_id`, {localize field='label'}`label`{/localize}, `value`, `name`, `grouping`, `filter`, `is_default`, `weight`, {localize field='description'}`description`{/localize}, `is_optgroup`, `is_reserved`, `is_active`, `component_id`, `visibility_id`)
-VALUES
-   (@option_group_id_act, {localize}'BULK SMS'{/localize}, @max_wt, 'BULK SMS', NULL, 1, NULL, @max_wt, {localize}'BULK SMS'{/localize}, 0, 1, 1, NULL, NULL);
-
-ALTER TABLE `civicrm_mailing_recipients` ADD `phone_id` int(10) unsigned DEFAULT NULL;
-
-ALTER TABLE `civicrm_mailing_recipients` ADD CONSTRAINT `FK_civicrm_mailing_recipients_phone_id` FOREIGN KEY (`phone_id`) REFERENCES `civicrm_phone` (`id`) ON DELETE CASCADE;
-
-ALTER TABLE `civicrm_mailing_event_queue` ADD `phone_id` int(10) unsigned DEFAULT NULL;
-
-ALTER TABLE `civicrm_mailing_event_queue` ADD CONSTRAINT `FK_civicrm_mailing_event_queue_phone_id` FOREIGN KEY (`phone_id`) REFERENCES `civicrm_phone` (`id`) ON DELETE CASCADE;
-
-ALTER TABLE `civicrm_mailing_event_queue` CHANGE `email_id` `email_id` int(10) unsigned DEFAULT NULL;
-ALTER TABLE `civicrm_mailing_recipients` CHANGE `email_id` `email_id` int(10) unsigned DEFAULT NULL;
-
--- CRM-9982
-ALTER TABLE `civicrm_contribution_page` ADD COLUMN is_confirm_enabled tinyint(4) DEFAULT '1';
-
--- CRM-9980
-{if $multilingual}
-  {foreach from=$locales item=locale}
-  {if !$loc}
-  {assign var=loc value="_$locale"}
-  {/if}
-    ALTER TABLE civicrm_group ADD title_{$locale} VARCHAR(64);
-    ALTER TABLE civicrm_group ADD UNIQUE KEY `UI_title_{$locale}` (title_{$locale});
-
-    ALTER TABLE `civicrm_batch` CHANGE `label_{$locale}` `title_{$locale}` varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Friendly Name.';
-    UPDATE civicrm_group SET title_{$locale} = title;
-
-    ALTER TABLE civicrm_survey
-     ADD COLUMN thankyou_title_{$locale} varchar(255)    COMMENT 'Title for Thank-you page (header title tag, and display at the top of the page).',
-     ADD COLUMN thankyou_text_{$locale}  text    COMMENT 'text and html allowed. displayed above result on success page';
-  {/foreach}
-
-  ALTER TABLE civicrm_group DROP INDEX `UI_title`;
-  ALTER TABLE civicrm_group DROP title;
-{else}
-  ALTER TABLE `civicrm_batch` CHANGE `label` `title` varchar(64) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Friendly Name.';
-  ALTER TABLE civicrm_survey
-     ADD COLUMN thankyou_title varchar(255)    COMMENT 'Title for Thank-you page (header title tag, and display at the top of the page).',
-     ADD COLUMN thankyou_text  text    COMMENT 'text and html allowed. displayed above result on success page';
-{/if}
-
--- CRM-9780
-SELECT @country_id   := max(id) from civicrm_country where iso_code = "AN";
-DELETE FROM civicrm_state_province WHERE country_id = @country_id;
-DELETE FROM civicrm_country WHERE id = @country_id;
-
-SELECT @region_id   := max(id) from civicrm_worldregion where name = "America South, Central, North and Caribbean";
-
-INSERT INTO civicrm_country (name,iso_code,region_id,is_province_abbreviated) VALUES("Curaçao", "CW", @region_id, 0);
-INSERT INTO civicrm_country (name,iso_code,region_id,is_province_abbreviated) VALUES("Sint Maarten (Dutch Part)", "SX", @region_id, 0);
-INSERT INTO civicrm_country (name,iso_code,region_id,is_province_abbreviated) VALUES("Bonaire, Saint Eustatius and Saba", "BQ", @region_id, 0);
-
--- CRM-12428
-{if $multilingual}
-    {foreach from=$locales item=locale}
-      ALTER TABLE `civicrm_price_field_value` CHANGE label_{$locale} label_{$locale} VARCHAR(255)  NULL DEFAULT NULL;
-    {/foreach}
-{else}
-  ALTER TABLE `civicrm_price_field_value` CHANGE `label` `label` VARCHAR(255)  NULL DEFAULT NULL;
-{/if}
-
--- CRM-9714 create a default price set for contribution and membership
-ALTER TABLE `civicrm_price_set`
-ADD         `is_quick_config` TINYINT(4) NOT NULL DEFAULT '0'
-                              COMMENT 'Is set if edited on Contribution or Event Page rather than through Manage Price Sets'
-                              AFTER `contribution_type_id`,
-ADD         `is_reserved`     TINYINT(4) DEFAULT '0'
-                              COMMENT 'Is this a predefined system price set  (i.e. it can not be deleted, edited)?';
-
-SELECT @contribution_type_id := max(id) FROM `civicrm_contribution_type` WHERE `name` = 'Member Dues';
-INSERT INTO `civicrm_price_set` ( `name`, {localize field='title'}`title`{/localize}, `is_active`, `extends`, `is_quick_config`, `is_reserved`, `contribution_type_id`)
-VALUES ( 'default_contribution_amount', {localize}'Contribution Amount'{/localize}, '1', '2', '1', '1', null),
- ( 'default_membership_type_amount', {localize}'Membership Amount'{/localize}, '1', '3', '1', '1', @contribution_type_id);
-
-SELECT @setID := max(id) FROM civicrm_price_set WHERE name = 'default_contribution_amount' AND extends = 2 AND is_quick_config = 1 ;
-
-INSERT INTO `civicrm_price_field` (`price_set_id`, `name`, {localize field='label'}`label`{/localize}, `html_type`,`weight`, `is_display_amounts`, `options_per_line`, `is_active`, `is_required`,`visibility_id` )
-VALUES ( @setID, 'contribution_amount', {localize}'Contribution Amount'{/localize}, 'Text', '1', '1', '1', '1', '1', '1' );
-
-SELECT @fieldID := max(id) FROM civicrm_price_field WHERE name = 'contribution_amount' AND price_set_id = @setID;
-
-INSERT INTO `civicrm_price_field_value` (  `price_field_id`, `name`, {localize field='label'}`label`{/localize}, `amount`, `weight`, `is_default`, `is_active`)
-VALUES ( @fieldID, 'contribution_amount', {localize}'Contribution Amount'{/localize}, '1', '1', '0', '1');
-ALTER TABLE `civicrm_custom_group` CHANGE `extends_entity_column_value` `extends_entity_column_value` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL COMMENT 'linking custom group for dynamic object.';
-
--- CRM-9714 create price fields for all membershiptype
-SELECT @setID := max(id) FROM civicrm_price_set WHERE name = 'default_membership_type_amount' AND extends = 3 AND is_quick_config = 1 ;
-
-INSERT INTO civicrm_price_field ( price_set_id, name, {localize field='label'}label{/localize}, html_type, is_display_amounts, is_required )
-SELECT @setID as price_set_id,  cmt.member_of_contact_id as name, {localize}'Membership Amount'{/localize}, 'Radio' as html_type, 0 as is_display_amounts, 0 as is_required
-FROM `civicrm_membership_type` cmt
-GROUP BY cmt.member_of_contact_id;
-
-INSERT INTO civicrm_price_field_value ( price_field_id, name, {localize field='label'}label{/localize}, {localize field='description'}description{/localize}, amount, membership_type_id)
-SELECT
-cpf.id, cmt.name{$loc} as label1, {localize field='name'}cmt.name as label2{/localize},{localize field='description'}cmt.description{/localize}, cmt.minimum_fee, cmt.id
-FROM `civicrm_membership_type` cmt
-LEFT JOIN civicrm_price_field cpf ON cmt.member_of_contact_id = BINARY cpf.name;
-
--- CRM-9714
-SELECT @fieldID := cpf.id, @fieldValueID := cpfv.id FROM civicrm_price_set cps
-LEFT JOIN civicrm_price_field cpf ON  cps.id = cpf.price_set_id
-LEFT JOIN civicrm_price_field_value cpfv ON cpf.id = cpfv.price_field_id
-WHERE cps.name = 'default_contribution_amount';
-
-INSERT INTO civicrm_line_item ( entity_table, entity_id, price_field_id, label, qty, unit_price, line_total, participant_count, price_field_value_id )
-SELECT 'civicrm_contribution', cc.id, @fieldID, 'Contribution Amount', 1, total_amount, total_amount , 0, @fieldValueID
-FROM `civicrm_contribution` cc
-LEFT JOIN civicrm_line_item cli ON cc.id=cli.entity_id and cli.entity_table = 'civicrm_contribution'
-LEFT JOIN civicrm_membership_payment cmp ON cc.id = cmp.contribution_id
-LEFT JOIN civicrm_participant_payment cpp ON cc.id = cpp.contribution_id
-WHERE cli.entity_id IS NULL AND cc.contribution_page_id IS NULL AND cmp.contribution_id IS NULL AND cpp.contribution_id IS NULL
-GROUP BY cc.id;
-
--- CRM-10071 contribution membership detail report template
-SELECT @option_group_id_report := MAX(id)     FROM civicrm_option_group WHERE name = 'report_template';
-SELECT @weight                 := MAX(weight) FROM civicrm_option_value WHERE option_group_id = @option_group_id_report;
-SELECT @memberCompId := max(id) FROM civicrm_component where name = 'CiviMember';
-INSERT INTO civicrm_option_value
-  (option_group_id, {localize field='label'}label{/localize}, value, name, weight, {localize field='description'}description{/localize}, is_active, component_id) VALUES
-  (@option_group_id_report, {localize}'Contribution and Membership Details'{/localize}, 'member/contributionDetail', 'CRM_Report_Form_Member_ContributionDetail', @weight := @weight + 1, {localize}'Contribution details for any type of contribution, plus associated membership information for contributions which are in payment for memberships.'{/localize}, 1, @memberCompId);
-
-INSERT INTO `civicrm_report_instance`
-    ( `domain_id`, `title`, `report_id`, `description`, `permission`, `form_values`)
-VALUES
-    ( {$domainID}, 'Contribution and Membership Details', 'member/contributionDetail', 'Contribution details for any type of contribution, plus associated membership information for contributions which are in payment for memberships.', 'access CiviMember', '{literal}a:67:{s:6:"fields";a:12:{s:9:"sort_name";s:1:"1";s:5:"email";s:1:"1";s:5:"phone";s:1:"1";s:20:"contribution_type_id";s:1:"1";s:12:"receive_date";s:1:"1";s:12:"total_amount";s:1:"1";s:18:"membership_type_id";s:1:"1";s:21:"membership_start_date";s:1:"1";s:19:"membership_end_date";s:1:"1";s:9:"join_date";s:1:"1";s:22:"membership_status_name";s:1:"1";s:10:"country_id";s:1:"1";}s:12:"sort_name_op";s:3:"has";s:15:"sort_name_value";s:0:"";s:6:"id_min";s:0:"";s:6:"id_max";s:0:"";s:5:"id_op";s:3:"lte";s:8:"id_value";s:0:"";s:21:"receive_date_relative";s:1:"0";s:17:"receive_date_from";s:0:"";s:15:"receive_date_to";s:0:"";s:23:"contribution_type_id_op";s:2:"in";s:26:"contribution_type_id_value";a:0:{}s:24:"payment_instrument_id_op";s:2:"in";s:27:"payment_instrument_id_value";a:0:{}s:25:"contribution_status_id_op";s:2:"in";s:28:"contribution_status_id_value";a:0:{}s:16:"total_amount_min";s:0:"";s:16:"total_amount_max";s:0:"";s:15:"total_amount_op";s:3:"lte";s:18:"total_amount_value";s:0:"";s:6:"gid_op";s:2:"in";s:9:"gid_value";a:0:{}s:13:"ordinality_op";s:2:"in";s:16:"ordinality_value";a:0:{}s:18:"join_date_relative";s:1:"0";s:14:"join_date_from";s:0:"";s:12:"join_date_to";s:0:"";s:30:"membership_start_date_relative";s:1:"0";s:26:"membership_start_date_from";s:0:"";s:24:"membership_start_date_to";s:0:"";s:28:"membership_end_date_relative";s:1:"0";s:24:"membership_end_date_from";s:0:"";s:22:"membership_end_date_to";s:0:"";s:23:"owner_membership_id_min";s:0:"";s:23:"owner_membership_id_max";s:0:"";s:22:"owner_membership_id_op";s:3:"lte";s:25:"owner_membership_id_value";s:0:"";s:6:"tid_op";s:2:"in";s:9:"tid_value";a:0:{}s:6:"sid_op";s:2:"in";s:9:"sid_value";a:0:{}s:17:"street_number_min";s:0:"";s:17:"street_number_max";s:0:"";s:16:"street_number_op";s:3:"lte";s:19:"street_number_value";s:0:"";s:14:"street_name_op";s:3:"has";s:17:"street_name_value";s:0:"";s:15:"postal_code_min";s:0:"";s:15:"postal_code_max";s:0:"";s:14:"postal_code_op";s:3:"lte";s:17:"postal_code_value";s:0:"";s:7:"city_op";s:3:"has";s:10:"city_value";s:0:"";s:12:"county_id_op";s:2:"in";s:15:"county_id_value";a:0:{}s:20:"state_province_id_op";s:2:"in";s:23:"state_province_id_value";a:0:{}s:13:"country_id_op";s:2:"in";s:16:"country_id_value";a:0:{}s:8:"tagid_op";s:2:"in";s:11:"tagid_value";a:0:{}s:11:"description";s:35:"Contribution and Membership Details";s:13:"email_subject";s:0:"";s:8:"email_to";s:0:"";s:8:"email_cc";s:0:"";s:10:"permission";s:17:"access CiviMember";s:9:"domain_id";i:1;}{s:6:"fields";a:12:{s:9:"sort_name";s:1:"1";s:5:"email";s:1:"1";s:5:"phone";s:1:"1";s:20:"contribution_type_id";s:1:"1";s:12:"receive_date";s:1:"1";s:12:"total_amount";s:1:"1";s:18:"membership_type_id";s:1:"1";s:21:"membership_start_date";s:1:"1";s:19:"membership_end_date";s:1:"1";s:9:"join_date";s:1:"1";s:22:"membership_status_name";s:1:"1";s:10:"country_id";s:1:"1";}s:12:"sort_name_op";s:3:"has";s:15:"sort_name_value";s:0:"";s:6:"id_min";s:0:"";s:6:"id_max";s:0:"";s:5:"id_op";s:3:"lte";s:8:"id_value";s:0:"";s:21:"receive_date_relative";s:1:"0";s:17:"receive_date_from";s:0:"";s:15:"receive_date_to";s:0:"";s:23:"contribution_type_id_op";s:2:"in";s:26:"contribution_type_id_value";a:0:{}s:24:"payment_instrument_id_op";s:2:"in";s:27:"payment_instrument_id_value";a:0:{}s:25:"contribution_status_id_op";s:2:"in";s:28:"contribution_status_id_value";a:0:{}s:16:"total_amount_min";s:0:"";s:16:"total_amount_max";s:0:"";s:15:"total_amount_op";s:3:"lte";s:18:"total_amount_value";s:0:"";s:6:"gid_op";s:2:"in";s:9:"gid_value";a:0:{}s:13:"ordinality_op";s:2:"in";s:16:"ordinality_value";a:0:{}s:18:"join_date_relative";s:1:"0";s:14:"join_date_from";s:0:"";s:12:"join_date_to";s:0:"";s:30:"membership_start_date_relative";s:1:"0";s:26:"membership_start_date_from";s:0:"";s:24:"membership_start_date_to";s:0:"";s:28:"membership_end_date_relative";s:1:"0";s:24:"membership_end_date_from";s:0:"";s:22:"membership_end_date_to";s:0:"";s:23:"owner_membership_id_min";s:0:"";s:23:"owner_membership_id_max";s:0:"";s:22:"owner_membership_id_op";s:3:"lte";s:25:"owner_membership_id_value";s:0:"";s:6:"tid_op";s:2:"in";s:9:"tid_value";a:0:{}s:6:"sid_op";s:2:"in";s:9:"sid_value";a:0:{}s:17:"street_number_min";s:0:"";s:17:"street_number_max";s:0:"";s:16:"street_number_op";s:3:"lte";s:19:"street_number_value";s:0:"";s:14:"street_name_op";s:3:"has";s:17:"street_name_value";s:0:"";s:15:"postal_code_min";s:0:"";s:15:"postal_code_max";s:0:"";s:14:"postal_code_op";s:3:"lte";s:17:"postal_code_value";s:0:"";s:7:"city_op";s:3:"has";s:10:"city_value";s:0:"";s:12:"county_id_op";s:2:"in";s:15:"county_id_value";a:0:{}s:20:"state_province_id_op";s:2:"in";s:23:"state_province_id_value";a:0:{}s:13:"country_id_op";s:2:"in";s:16:"country_id_value";a:0:{}s:8:"tagid_op";s:2:"in";s:11:"tagid_value";a:0:{}s:11:"description";s:35:"Contribution and Membership Details";s:13:"email_subject";s:0:"";s:8:"email_to";s:0:"";s:8:"email_cc";s:0:"";s:10:"permission";s:1:"0";s:9:"domain_id";i:1;}{/literal}');
-
-SELECT @reportlastID       := MAX(id) FROM civicrm_navigation where name = 'Reports' AND domain_id = {$domainID};
-SELECT @nav_max_weight     := MAX(ROUND(weight)) from civicrm_navigation WHERE parent_id = @reportlastID;
-
-SET @instanceID:=LAST_INSERT_ID();
-INSERT INTO civicrm_navigation
-    ( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight )
-VALUES
-    ( {$domainID}, CONCAT('civicrm/report/instance/', @instanceID,'&reset=1'), '{ts escape="sql" skip="true"}Contribution and Membership Details{/ts}', 'Contribution and Membership Details', 'access CiviMember', 'AND', @reportlastID, '1', NULL, @instanceID+2 );
-UPDATE civicrm_report_instance SET navigation_id = LAST_INSERT_ID() WHERE id = @instanceID;
-
--- CRM-9936
-ALTER TABLE civicrm_group ADD is_reserved TINYINT( 4 ) NULL DEFAULT '0' ;
-
--- CRM-9501 price set report templates
-SELECT @option_group_id_report := MAX(id)     FROM civicrm_option_group WHERE name = 'report_template';
-SELECT @weight                 := MAX(weight) FROM civicrm_option_value WHERE option_group_id = @option_group_id_report;
-SELECT @CompId       := MAX(id)     FROM civicrm_component where name = 'CiviContribute';
-INSERT INTO civicrm_option_value
-  (option_group_id, {localize field='label'}label{/localize}, value, name, weight, {localize field='description'}description{/localize}, is_active, component_id) VALUES
-  (@option_group_id_report, {localize}'Line Item Report'{/localize}, 'price/lineitem', 'CRM_Report_Form_Price_Lineitem', @weight := @weight + 1, {localize}'Price set report by line item.'{/localize}, 1, @CompId);
-SELECT @weight                 := MAX(weight) FROM civicrm_option_value WHERE option_group_id = @option_group_id_report;
-INSERT INTO civicrm_option_value
-  (option_group_id, {localize field='label'}label{/localize}, value, name, weight, {localize field='description'}description{/localize}, is_active, component_id) VALUES
-  (@option_group_id_report, {localize}'Contribution Report with Line Item information'{/localize}, 'price/contributionbased', 'CRM_Report_Form_Price_Contributionbased', @weight := @weight + 1, {localize}'Contribution Line Item Report.'{/localize}, 1, @CompId);
-SELECT @weight                 := MAX(weight) FROM civicrm_option_value WHERE option_group_id = @option_group_id_report;
-INSERT INTO civicrm_option_value
-  (option_group_id, {localize field='label'}label{/localize}, value, name, weight, {localize field='description'}description{/localize}, is_active, component_id) VALUES
-  (@option_group_id_report, {localize}'Participant Report with Line Item information'{/localize}, 'price/lineitemparticipant', 'CRM_Report_Form_Price_Lineitemparticipant', @weight := @weight + 1, {localize}'Participant Line Item Report.'{/localize}, 1, @CompId);
-
--- CRM-10148
-ALTER TABLE civicrm_report_instance ADD is_reserved TINYINT( 4 ) NULL DEFAULT '0' ;
-
--- CRM-9438
-SELECT @option_group_id_act := MAX(id)     FROM civicrm_option_group WHERE name = 'activity_type';
-SELECT @max_val    := MAX(ROUND(op.value)) FROM civicrm_option_value op WHERE op.option_group_id  = @option_group_id_act;
-SELECT @max_wt     := MAX(weight) FROM civicrm_option_value WHERE option_group_id = @option_group_id_act;
-SELECT @CompId     := MAX(id)     FROM civicrm_component where name = 'CiviMember';
-INSERT INTO civicrm_option_value
-  (option_group_id, {localize field='label'}label{/localize}, value, name, weight, {localize field='description'}description{/localize}, is_active, is_reserved, component_id)
-VALUES
-  (@option_group_id_act, {localize field='label'}'Change Membership Status'{/localize}, (SELECT @max_val := @max_val+1), 'Change Membership Status', (SELECT @max_wt := @max_wt+1), {localize field='description'}'Change Membership Status.'{/localize}, 1, 1, @CompId),
-  (@option_group_id_act, {localize field='label'}'Change Membership Type'{/localize}, (SELECT @max_val := @max_val+1), 'Change Membership Type', (SELECT @max_wt := @max_wt+1), {localize field='description'}'Change Membership Type.'{/localize}, 1, 1, @CompId);
-
--- CRM-10084
-INSERT INTO
-   `civicrm_option_value` (`option_group_id`, {localize field='label'}`label`{/localize}, `value`, `name`, `grouping`, `filter`, `is_default`, `weight`, {localize field='description'}`description`{/localize}, `is_optgroup`, `is_reserved`, `is_active`, `component_id`, `visibility_id`)
-VALUES
-   (@option_group_id_act, {localize}'Cancel Recurring Contribution'{/localize}, (SELECT @max_val := @max_val+1), 'Cancel Recurring Contribution', NULL,1, 0, (SELECT @max_wt := @max_wt+1), {localize}''{/localize}, 0, 1, 1, NULL, NULL);
-
--- CRM-10090
-INSERT INTO
-   `civicrm_option_value` (`option_group_id`, {localize field='label'}`label`{/localize}, `value`, `name`, `grouping`, `filter`, `is_default`, `weight`, {localize field='description'}`description`{/localize}, `is_optgroup`, `is_reserved`, `is_active`, `component_id`, `visibility_id`)
-VALUES
-(@option_group_id_act, {localize}'Update Recurring Contribution Billing Details'{/localize}, (SELECT @max_val := @max_val+1), 'Update Recurring Contribution Billing Details', NULL,1, 0, (SELECT @max_wt := @max_wt+1), {localize}''{/localize}, 0, 1, 1, NULL, NULL),
-(@option_group_id_act, {localize}'Update Recurring Contribution'{/localize}, (SELECT @max_val := @max_val+1), 'Update Recurring Contribution', NULL,1, 0, (SELECT @max_wt := @max_wt+1), {localize}''{/localize}, 0, 1, 1, NULL, NULL);
-
--- CRM-10117
-ALTER TABLE `civicrm_price_field_value` CHANGE `is_active` `is_active` TINYINT( 4 ) NULL DEFAULT '1' COMMENT 'Is this price field value active';
-
-
--- CRM-8359
-INSERT INTO
-   `civicrm_action_mapping` (`entity`, `entity_value`, `entity_value_label`, `entity_status`, `entity_status_label`, `entity_date_start`, `entity_date_end`, `entity_recipient`) VALUES
-   ('civicrm_membership', 'civicrm_membership_type', 'Membership Type', 'auto_renew_options', 'Auto Renew Options', 'membership_join_date', 'membership_end_date', NULL);
-
-INSERT INTO
-   `civicrm_option_group` (`name`, {localize field='title'}title{/localize}, `is_reserved`, `is_active`)
-VALUES
-  ('auto_renew_options', {localize}'Auto Renew Options'{/localize}, 1, 1);
-
-SELECT @option_group_id_aro := max(id) from civicrm_option_group where name = 'auto_renew_options';
-
-INSERT INTO
-   `civicrm_option_value` (`option_group_id`, {localize field='label'}label{/localize}, `value`, `name`, `grouping`, `filter`, `is_default`, `weight`)
-VALUES
-   (@option_group_id_aro, {localize}'Renewal Reminder (non-auto-renew memberships only)'{/localize}, 1, 'Renewal Reminder (non-auto-renew memberships only)', NULL, 0, 0, 1),
-   (@option_group_id_aro, {localize}'Auto-renew Memberships Only'{/localize}, 2, 'Auto-renew Memberships Only', NULL, 0, 0, 2),
-   (@option_group_id_aro, {localize}'Reminder for Both'{/localize}, 3, 'Reminder for Both', NULL, 0, 0, 3);
-
--- CRM-10335, truncate cache to begin to speed the alter table
-TRUNCATE civicrm_cache;
-ALTER TABLE civicrm_cache
-  DROP INDEX UI_group_path,
-  ADD UNIQUE INDEX `UI_group_path_date` (`group_name`, `path`, `created_date`);
-
--- CRM-10337
-ALTER TABLE civicrm_survey
-  ADD COLUMN bypass_confirm tinyint(4) DEFAULT '0' COMMENT 'Used to store option group id.';
diff --git a/CRM/Upgrade/Incremental/sql/4.2.alpha2.mysql.tpl b/CRM/Upgrade/Incremental/sql/4.2.alpha2.mysql.tpl
deleted file mode 100644 (file)
index a70e5eb..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-{include file='../CRM/Upgrade/4.2.alpha2.msg_template/civicrm_msg_template.tpl'}
-
--- CRM-10326
-DELETE FROM `civicrm_price_set_entity` WHERE entity_table = "civicrm_contribution" or entity_table = "civicrm_participant";
-
--- When deleting saved searches, null-out references from groups
-ALTER TABLE civicrm_group ADD CONSTRAINT `FK_civicrm_group_saved_search_id`
-  FOREIGN KEY (`saved_search_id`) REFERENCES `civicrm_saved_search` (`id`)
-  ON DELETE SET NULL;
diff --git a/CRM/Upgrade/Incremental/sql/4.2.alpha3.mysql.tpl b/CRM/Upgrade/Incremental/sql/4.2.alpha3.mysql.tpl
deleted file mode 100644 (file)
index ab39079..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-{include file='../CRM/Upgrade/4.2.alpha3.msg_template/civicrm_msg_template.tpl'}
-
diff --git a/CRM/Upgrade/Incremental/sql/4.2.beta1.mysql.tpl b/CRM/Upgrade/Incremental/sql/4.2.beta1.mysql.tpl
deleted file mode 100644 (file)
index 1d461f5..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
--- /*******************************************************
--- * CRM-10477 - Extensions updates
--- *******************************************************/
-CREATE TABLE `civicrm_extension` (
-     `id` int unsigned NOT NULL AUTO_INCREMENT  COMMENT 'Local Extension ID',
-     `type` enum('payment', 'search', 'report', 'module') NOT NULL   ,
-     `full_name` varchar(255) NOT NULL   COMMENT 'Fully qualified extension name',
-     `name` varchar(255)    COMMENT 'Short name',
-     `label` varchar(255)    COMMENT 'Short, printable name',
-     `file` varchar(255)    COMMENT 'Primary PHP file',
-     `schema_version` varchar(63)    COMMENT 'Revision code of the database schema; the format is module-defined',
-     `is_active` tinyint   DEFAULT 1 COMMENT 'Is this extension active?' ,
-    PRIMARY KEY ( `id` ) ,
-    UNIQUE INDEX `UI_extension_full_name`(
-        `full_name`
-    ),
-    INDEX `UI_extension_name`(
-        `name`
-    )
-) ENGINE=InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
-
--- assuming first value of array $locales is always en_US
-{if $multilingual}
-    INSERT INTO civicrm_extension (label, full_name, name, type, file, is_active)
-    SELECT ov.label_{$locales.0}, ov.value, ov.name, ov.grouping, ov.description_{$locales.0}, ov.is_active
-    FROM civicrm_option_group og
-    INNER JOIN civicrm_option_value ov ON og.id = ov.option_group_id
-    WHERE og.name = "system_extensions";
-{else}
-    INSERT INTO civicrm_extension (label, full_name, name, type, file, is_active)
-    SELECT ov.label, ov.value, ov.name, ov.grouping, ov.description, ov.is_active
-    FROM civicrm_option_group og
-    INNER JOIN civicrm_option_value ov ON og.id = ov.option_group_id
-    WHERE og.name = "system_extensions";
-{/if}
-DELETE FROM civicrm_option_group WHERE name = "system_extensions";
--- Note: Deletion cascades to civicrm_option_value
diff --git a/CRM/Upgrade/Incremental/sql/4.2.beta2.mysql.tpl b/CRM/Upgrade/Incremental/sql/4.2.beta2.mysql.tpl
deleted file mode 100644 (file)
index b7bddf4..0000000
+++ /dev/null
@@ -1 +0,0 @@
--- Placeholder which ensures that PHP upgrade tasks are executed
diff --git a/CRM/Upgrade/Incremental/sql/4.2.beta3.mysql.tpl b/CRM/Upgrade/Incremental/sql/4.2.beta3.mysql.tpl
deleted file mode 100644 (file)
index 47a5a52..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-{include file='../CRM/Upgrade/4.2.beta3.msg_template/civicrm_msg_template.tpl'}
-
diff --git a/CRM/Upgrade/Incremental/sql/4.2.beta5.mysql.tpl b/CRM/Upgrade/Incremental/sql/4.2.beta5.mysql.tpl
deleted file mode 100644 (file)
index b7bddf4..0000000
+++ /dev/null
@@ -1 +0,0 @@
--- Placeholder which ensures that PHP upgrade tasks are executed
diff --git a/CRM/Upgrade/Incremental/sql/4.2.beta6.mysql.tpl b/CRM/Upgrade/Incremental/sql/4.2.beta6.mysql.tpl
deleted file mode 100644 (file)
index 5151adf..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
--- FIXME: the final release version is uncertain -- could 4.2.0 or 4.2.1; make sure this fixed before merging
--- CRM-10660
-CREATE TABLE `civicrm_managed` (
-
-
-     `id` int unsigned NOT NULL AUTO_INCREMENT  COMMENT 'Surrogate Key',
-     `module` varchar(127) NOT NULL   COMMENT 'Name of the module which declared this object',
-     `name` varchar(127)    COMMENT 'Symbolic name used by the module to identify the object',
-     `entity_type` varchar(64) NOT NULL   COMMENT 'API entity type',
-     `entity_id` int unsigned NOT NULL   COMMENT 'Foreign key to the referenced item.',
-    PRIMARY KEY ( `id` )
-
-    ,     INDEX `UI_managed_module_name`(
-        `module`
-      , `name`
-  )
-  ,     INDEX `UI_managed_entity`(
-        `entity_type`
-      , `entity_id`
-  )
-
-
-)  ENGINE=InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci  ;
index bd097d6381316dfd862bcb69387d1cff0cad09eb..e9a748170c58a781fa52a0081ad783daba8b8a59 100644 (file)
@@ -12,5 +12,5 @@ INSERT INTO civicrm_mailing_bounce_pattern (bounce_type_id, pattern) VALUES (@bo
 
 -- CRM-21532 Add French state/departments
 SELECT @country_id := id from civicrm_country where name = 'France' AND iso_code = 'FR';
-INSERT INTO `civicrm_state_province` (`id`, `country_id`, `abbreviation`, `name`) VALUES
+INSERT IGNORE INTO `civicrm_state_province` (`id`, `country_id`, `abbreviation`, `name`) VALUES
 (NULL, @country_id, "52", "Haute-Marne");
\ No newline at end of file
index 08267008b5ba5e26dee55564dd991f318e85db57..b542246f427e7b44b42756e47b39a97292084c83 100644 (file)
@@ -2,7 +2,7 @@
 
 -- CRM-21837 - Missing states for Gabon
 SELECT @country_id := id from civicrm_country where name = 'Gabon' AND iso_code = 'GA';
-INSERT INTO `civicrm_state_province` (`id`, `country_id`, `abbreviation`, `name`) VALUES
+INSERT IGNORE INTO `civicrm_state_province` (`id`, `country_id`, `abbreviation`, `name`) VALUES
 (NULL, @country_id, "01", "Estuaire"),
 (NULL, @country_id, "02", "Haut-Ogooué"),
 (NULL, @country_id, "03", "Moyen-Ogooué"),
diff --git a/CRM/Upgrade/Incremental/sql/5.12.alpha1.mysql.tpl b/CRM/Upgrade/Incremental/sql/5.12.alpha1.mysql.tpl
new file mode 100644 (file)
index 0000000..7b80664
--- /dev/null
@@ -0,0 +1,396 @@
+{* file to handle db changes in 5.12.alpha1 during upgrade *}
+
+-- dev/core#683 Incorrectly encoded state and country names
+UPDATE civicrm_country SET name = 'Åland Islands' WHERE iso_code = 'AX';
+UPDATE civicrm_country SET name = 'Côte d’Ivoire' WHERE iso_code = 'CI';
+UPDATE civicrm_country SET name = 'Curaçao' WHERE iso_code = 'CW';
+UPDATE civicrm_country SET name = 'Saint Barthélemy' WHERE iso_code = 'BL';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'dolnośląskie' WHERE iso_code = 'PL' AND abbreviation = 'DS';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'łódzkie' WHERE iso_code = 'PL' AND abbreviation = 'LD';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'małopolskie' WHERE iso_code = 'PL' AND abbreviation = 'MA';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'śląskie' WHERE iso_code = 'PL' AND abbreviation = 'SL';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'świętokrzyskie' WHERE iso_code = 'PL' AND abbreviation = 'SK';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'warmińsko-mazurskie' WHERE iso_code = 'PL' AND abbreviation = 'WN';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Bulqizë' WHERE iso_code = 'AL' AND abbreviation = 'BU';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Delvinë' WHERE iso_code = 'AL' AND abbreviation = 'DL';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Dibër' WHERE iso_code = 'AL' AND abbreviation = 'DI';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Durrës' WHERE iso_code = 'AL' AND abbreviation = 'DR';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Gjirokastër' WHERE iso_code = 'AL' AND abbreviation = 'GJ';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Kavajë' WHERE iso_code = 'AL' AND abbreviation = 'KA';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Kolonjë' WHERE iso_code = 'AL' AND abbreviation = 'ER';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Korçë' WHERE iso_code = 'AL' AND abbreviation = 'KO';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Krujë' WHERE iso_code = 'AL' AND abbreviation = 'KR';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Kuçovë' WHERE iso_code = 'AL' AND abbreviation = 'KC';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Kukës' WHERE iso_code = 'AL' AND abbreviation = 'KU';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Lezhë' WHERE iso_code = 'AL' AND abbreviation = 'LE';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Lushnjë' WHERE iso_code = 'AL' AND abbreviation = 'LU';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Malësi e Madhe' WHERE iso_code = 'AL' AND abbreviation = 'MM';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Mallakastër' WHERE iso_code = 'AL' AND abbreviation = 'MK';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Mirditë' WHERE iso_code = 'AL' AND abbreviation = 'MR';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Përmet' WHERE iso_code = 'AL' AND abbreviation = 'PR';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Pukë' WHERE iso_code = 'AL' AND abbreviation = 'PU';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Sarandë' WHERE iso_code = 'AL' AND abbreviation = 'SR';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Shkodër' WHERE iso_code = 'AL' AND abbreviation = 'SH';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Tepelenë' WHERE iso_code = 'AL' AND abbreviation = 'TE';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Tiranë' WHERE iso_code = 'AL' AND abbreviation = 'TR';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Tropojë' WHERE iso_code = 'AL' AND abbreviation = 'TP';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Vlorë' WHERE iso_code = 'AL' AND abbreviation = 'VL';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Kärnten' WHERE iso_code = 'AT' AND abbreviation = '2';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Niederösterreich' WHERE iso_code = 'AT' AND abbreviation = '3';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Oberösterreich' WHERE iso_code = 'AT' AND abbreviation = '4';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Brèsckaja voblasc\'' WHERE iso_code = 'BY' AND abbreviation = 'BR';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Mahilëuskaja voblasc\'' WHERE iso_code = 'BY' AND abbreviation = 'MA';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Distrito Capital de Bogotá' WHERE iso_code = 'CO' AND abbreviation = 'DC';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Atlántico' WHERE iso_code = 'CO' AND abbreviation = 'ATL';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Bolívar' WHERE iso_code = 'CO' AND abbreviation = 'BOL';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Boyacá' WHERE iso_code = 'CO' AND abbreviation = 'BOY';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Caquetá' WHERE iso_code = 'CO' AND abbreviation = 'CAQ';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Córdoba' WHERE iso_code = 'CO' AND abbreviation = 'COR';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Chocó' WHERE iso_code = 'CO' AND abbreviation = 'CHO';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Guainía' WHERE iso_code = 'CO' AND abbreviation = 'GUA';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Nariño' WHERE iso_code = 'CO' AND abbreviation = 'NAR';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'San Andrés, Providencia y Santa Catalina' WHERE iso_code = 'CO' AND abbreviation = 'SAP';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Vaupés' WHERE iso_code = 'CO' AND abbreviation = 'VAU';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Jihočeský kraj' WHERE iso_code = 'CZ' AND abbreviation = 'JC';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Jihomoravský kraj' WHERE iso_code = 'CZ' AND abbreviation = 'JM';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Karlovarský kraj' WHERE iso_code = 'CZ' AND abbreviation = 'KA';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Královéhradecký kraj' WHERE iso_code = 'CZ' AND abbreviation = 'KR';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Liberecký kraj' WHERE iso_code = 'CZ' AND abbreviation = 'LI';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Moravskoslezský kraj' WHERE iso_code = 'CZ' AND abbreviation = 'MO';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Olomoucký kraj' WHERE iso_code = 'CZ' AND abbreviation = 'OL';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Pardubický kraj' WHERE iso_code = 'CZ' AND abbreviation = 'PA';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Plzeňský kraj' WHERE iso_code = 'CZ' AND abbreviation = 'PL';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Praha, hlavní město' WHERE iso_code = 'CZ' AND abbreviation = 'PR';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Středočeský kraj' WHERE iso_code = 'CZ' AND abbreviation = 'ST';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Ústecký kraj' WHERE iso_code = 'CZ' AND abbreviation = 'US';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Vysočina' WHERE iso_code = 'CZ' AND abbreviation = 'VY';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Zlínský kraj' WHERE iso_code = 'CZ' AND abbreviation = 'ZL';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Baden-Württemberg' WHERE iso_code = 'DE' AND abbreviation = 'BW';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Thüringen' WHERE iso_code = 'DE' AND abbreviation = 'TH';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Vestsjælland' WHERE iso_code = 'DK' AND abbreviation = '030';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Storstrøm' WHERE iso_code = 'DK' AND abbreviation = '035';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Ringkjøbing' WHERE iso_code = 'DK' AND abbreviation = '065';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Århus' WHERE iso_code = 'DK' AND abbreviation = '070';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Dajabón' WHERE iso_code = 'DO' AND abbreviation = '05';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Maroia Trinidad Sánchez' WHERE iso_code = 'DO' AND abbreviation = '14';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Monseñor Nouel' WHERE iso_code = 'DO' AND abbreviation = '28';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Samaná' WHERE iso_code = 'DO' AND abbreviation = '20';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'San Cristóbal' WHERE iso_code = 'DO' AND abbreviation = '21';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'San Pedro de Macorís' WHERE iso_code = 'DO' AND abbreviation = '23';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Sánchez Ramírez' WHERE iso_code = 'DO' AND abbreviation = '24';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Santiago Rodríguez' WHERE iso_code = 'DO' AND abbreviation = '26';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Jõgevamaa' WHERE iso_code = 'EE' AND abbreviation = '49';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Järvamaa' WHERE iso_code = 'EE' AND abbreviation = '51';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Läänemaa' WHERE iso_code = 'EE' AND abbreviation = '57';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Lääne-Virumaa' WHERE iso_code = 'EE' AND abbreviation = '59';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Põlvamaa' WHERE iso_code = 'EE' AND abbreviation = '65';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Pärnumaa' WHERE iso_code = 'EE' AND abbreviation = '67';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Võrumaa' WHERE iso_code = 'EE' AND abbreviation = '86';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Álava' WHERE iso_code = 'ES' AND abbreviation = 'VI';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Almería' WHERE iso_code = 'ES' AND abbreviation = 'AL';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Ávila' WHERE iso_code = 'ES' AND abbreviation = 'AV';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Cáceres' WHERE iso_code = 'ES' AND abbreviation = 'CC';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Cádiz' WHERE iso_code = 'ES' AND abbreviation = 'CA';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Castellón' WHERE iso_code = 'ES' AND abbreviation = 'CS';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Guipúzcoa' WHERE iso_code = 'ES' AND abbreviation = 'SS';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Jaén' WHERE iso_code = 'ES' AND abbreviation = 'J';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'La Coruña' WHERE iso_code = 'ES' AND abbreviation = 'C';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'León' WHERE iso_code = 'ES' AND abbreviation = 'LE';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Lleida [Lérida]' WHERE iso_code = 'ES' AND abbreviation = 'L';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Málaga' WHERE iso_code = 'ES' AND abbreviation = 'MA';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Ardèche' WHERE iso_code = 'FR' AND abbreviation = '07';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Ariège' WHERE iso_code = 'FR' AND abbreviation = '09';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Bouches-du-Rhône' WHERE iso_code = 'FR' AND abbreviation = '13';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Corrèze' WHERE iso_code = 'FR' AND abbreviation = '19';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Côte-d\'Or' WHERE iso_code = 'FR' AND abbreviation = '21';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Côtes-d\'Armor' WHERE iso_code = 'FR' AND abbreviation = '22';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Deux-Sèvres' WHERE iso_code = 'FR' AND abbreviation = '79';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Drôme' WHERE iso_code = 'FR' AND abbreviation = '26';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Finistère' WHERE iso_code = 'FR' AND abbreviation = '29';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Haute-Saône' WHERE iso_code = 'FR' AND abbreviation = '70';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Hautes-Pyrénées' WHERE iso_code = 'FR' AND abbreviation = '65';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Hérault' WHERE iso_code = 'FR' AND abbreviation = '34';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Isère' WHERE iso_code = 'FR' AND abbreviation = '38';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Lozère' WHERE iso_code = 'FR' AND abbreviation = '48';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Nièvre' WHERE iso_code = 'FR' AND abbreviation = '58';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Puy-de-Dôme' WHERE iso_code = 'FR' AND abbreviation = '63';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Pyrénées-Atlantiques' WHERE iso_code = 'FR' AND abbreviation = '64';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Pyrénées-Orientales' WHERE iso_code = 'FR' AND abbreviation = '66';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Rhône' WHERE iso_code = 'FR' AND abbreviation = '69';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Saône-et-Loire' WHERE iso_code = 'FR' AND abbreviation = '71';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Vendée' WHERE iso_code = 'FR' AND abbreviation = '85';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Achaïa' WHERE iso_code = 'GR' AND abbreviation = '13';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Sololá' WHERE iso_code = 'GT' AND abbreviation = 'SO';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Bács-Kiskun' WHERE iso_code = 'HU' AND abbreviation = 'BK';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Békés' WHERE iso_code = 'HU' AND abbreviation = 'BE';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Borsod-Abaúj-Zemplén' WHERE iso_code = 'HU' AND abbreviation = 'BZ';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Csongrád' WHERE iso_code = 'HU' AND abbreviation = 'CS';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Fejér' WHERE iso_code = 'HU' AND abbreviation = 'FE';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Győr-Moson-Sopron' WHERE iso_code = 'HU' AND abbreviation = 'GS';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Jász-Nagykun-Szolnok' WHERE iso_code = 'HU' AND abbreviation = 'JN';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Komárom-Esztergom' WHERE iso_code = 'HU' AND abbreviation = 'KE';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Nográd' WHERE iso_code = 'HU' AND abbreviation = 'NO';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Szabolcs-Szatmár-Bereg' WHERE iso_code = 'HU' AND abbreviation = 'SZ';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Veszprém' WHERE iso_code = 'HU' AND abbreviation = 'VE';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Békéscsaba' WHERE iso_code = 'HU' AND abbreviation = 'BC';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Dunaújváros' WHERE iso_code = 'HU' AND abbreviation = 'DU';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Győr' WHERE iso_code = 'HU' AND abbreviation = 'GY';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Hódmezővásárhely' WHERE iso_code = 'HU' AND abbreviation = 'HV';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Kaposvár' WHERE iso_code = 'HU' AND abbreviation = 'KV';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Kecskemét' WHERE iso_code = 'HU' AND abbreviation = 'KM';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Nyiregyháza' WHERE iso_code = 'HU' AND abbreviation = 'NY';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Pécs' WHERE iso_code = 'HU' AND abbreviation = 'PS';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Salgótarján' WHERE iso_code = 'HU' AND abbreviation = 'ST';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Székesfehérvár' WHERE iso_code = 'HU' AND abbreviation = 'SF';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Szekszárd' WHERE iso_code = 'HU' AND abbreviation = 'SS';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Tatabánya' WHERE iso_code = 'HU' AND abbreviation = 'TB';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Forlì-Cesena' WHERE iso_code = 'IT' AND abbreviation = 'FC';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Klaipėdos Apskritis' WHERE iso_code = 'LT' AND abbreviation = 'KL';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Marijampolės Apskritis' WHERE iso_code = 'LT' AND abbreviation = 'MR';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Panevėžio Apskritis' WHERE iso_code = 'LT' AND abbreviation = 'PN';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Šiaulių Apskritis' WHERE iso_code = 'LT' AND abbreviation = 'SA';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Tauragės Apskritis' WHERE iso_code = 'LT' AND abbreviation = 'TA';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Telšių Apskritis' WHERE iso_code = 'LT' AND abbreviation = 'TE';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Jūrmala' WHERE iso_code = 'LV' AND abbreviation = 'JUR';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Liepāja' WHERE iso_code = 'LV' AND abbreviation = 'LPX';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Rēzekne' WHERE iso_code = 'LV' AND abbreviation = 'REZ';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Rīga' WHERE iso_code = 'LV' AND abbreviation = 'RIX';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Ajdābiyā' WHERE iso_code = 'LY' AND abbreviation = 'AJ';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Al Buţnān' WHERE iso_code = 'LY' AND abbreviation = 'BU';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Al Hizām al Akhdar' WHERE iso_code = 'LY' AND abbreviation = 'HZ';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Al Jifārah' WHERE iso_code = 'LY' AND abbreviation = 'JI';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Al Qaţrūn' WHERE iso_code = 'LY' AND abbreviation = 'QT';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Al Wāhah' WHERE iso_code = 'LY' AND abbreviation = 'WA';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'An Nuqaţ al Khams' WHERE iso_code = 'LY' AND abbreviation = 'NQ';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Ash Shāţi\'' WHERE iso_code = 'LY' AND abbreviation = 'SH';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Az Zāwiyah' WHERE iso_code = 'LY' AND abbreviation = 'ZA';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Banghāzī' WHERE iso_code = 'LY' AND abbreviation = 'BA';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Banī Walīd' WHERE iso_code = 'LY' AND abbreviation = 'BW';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Ghadāmis' WHERE iso_code = 'LY' AND abbreviation = 'GD';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Gharyān' WHERE iso_code = 'LY' AND abbreviation = 'GR';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Ghāt' WHERE iso_code = 'LY' AND abbreviation = 'GT';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Jaghbūb' WHERE iso_code = 'LY' AND abbreviation = 'JB';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Mişrātah' WHERE iso_code = 'LY' AND abbreviation = 'MI';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Nālūt' WHERE iso_code = 'LY' AND abbreviation = 'NL';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Sabhā' WHERE iso_code = 'LY' AND abbreviation = 'SB';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Şabrātah Şurmān' WHERE iso_code = 'LY' AND abbreviation = 'SS';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Tājūrā\' wa an Nawāhī al Arbāh' WHERE iso_code = 'LY' AND abbreviation = 'TN';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Ţarābulus' WHERE iso_code = 'LY' AND abbreviation = 'TB';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Tarhūnah-Masallātah' WHERE iso_code = 'LY' AND abbreviation = 'TM';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Wādī al hayāt' WHERE iso_code = 'LY' AND abbreviation = 'WD';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Yafran-Jādū' WHERE iso_code = 'LY' AND abbreviation = 'YJ';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Aït Baha' WHERE iso_code = 'MA' AND abbreviation = 'BAH';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Aït Melloul' WHERE iso_code = 'MA' AND abbreviation = 'MEL';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Al Hoceïma' WHERE iso_code = 'MA' AND abbreviation = 'HOC';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Casablanca  [Dar el Beïda]' WHERE iso_code = 'MA' AND abbreviation = 'CAS';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Fès' WHERE iso_code = 'MA' AND abbreviation = 'FES';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Kénitra' WHERE iso_code = 'MA' AND abbreviation = 'KEN';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Laâyoune (EH)' WHERE iso_code = 'MA' AND abbreviation = 'LAA';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Meknsès' WHERE iso_code = 'MA' AND abbreviation = 'MEK';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Rabat-Salé' WHERE iso_code = 'MA' AND abbreviation = 'RBA';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Tétouan' WHERE iso_code = 'MA' AND abbreviation = 'TET';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Møre og Romsdal' WHERE iso_code = 'NO' AND abbreviation = '15';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Nord-Trøndelag' WHERE iso_code = 'NO' AND abbreviation = '17';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Sør-Trøndelag' WHERE iso_code = 'NO' AND abbreviation = '16';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Østfold' WHERE iso_code = 'NO' AND abbreviation = '01';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Argeș' WHERE iso_code = 'RO' AND abbreviation = 'AG';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Bacău' WHERE iso_code = 'RO' AND abbreviation = 'BC';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Bistrița-Năsăud' WHERE iso_code = 'RO' AND abbreviation = 'BN';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Botoșani' WHERE iso_code = 'RO' AND abbreviation = 'BT';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Brașov' WHERE iso_code = 'RO' AND abbreviation = 'BV';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Brăila' WHERE iso_code = 'RO' AND abbreviation = 'BR';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Buzău' WHERE iso_code = 'RO' AND abbreviation = 'BZ';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Caraș-Severin' WHERE iso_code = 'RO' AND abbreviation = 'CS';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Călărași' WHERE iso_code = 'RO' AND abbreviation = 'CL';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Constanța' WHERE iso_code = 'RO' AND abbreviation = 'CT';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Dâmbovița' WHERE iso_code = 'RO' AND abbreviation = 'DB';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Galați' WHERE iso_code = 'RO' AND abbreviation = 'GL';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Ialomița' WHERE iso_code = 'RO' AND abbreviation = 'IL';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Iași' WHERE iso_code = 'RO' AND abbreviation = 'IS';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Maramureș' WHERE iso_code = 'RO' AND abbreviation = 'MM';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Mehedinți' WHERE iso_code = 'RO' AND abbreviation = 'MH';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Mureș' WHERE iso_code = 'RO' AND abbreviation = 'MS';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Neamț' WHERE iso_code = 'RO' AND abbreviation = 'NT';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Sălaj' WHERE iso_code = 'RO' AND abbreviation = 'SJ';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Timiș' WHERE iso_code = 'RO' AND abbreviation = 'TM';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Vâlcea' WHERE iso_code = 'RO' AND abbreviation = 'VL';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Blekinge län' WHERE iso_code = 'SE' AND abbreviation = 'K';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Dalarnas län' WHERE iso_code = 'SE' AND abbreviation = 'W';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Gotlands län' WHERE iso_code = 'SE' AND abbreviation = 'I';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Gävleborgs län' WHERE iso_code = 'SE' AND abbreviation = 'X';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Hallands län' WHERE iso_code = 'SE' AND abbreviation = 'N';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Jämtlands län' WHERE iso_code = 'SE' AND abbreviation = 'Z';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Jönkopings län' WHERE iso_code = 'SE' AND abbreviation = 'F';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Kalmar län' WHERE iso_code = 'SE' AND abbreviation = 'H';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Kronobergs län' WHERE iso_code = 'SE' AND abbreviation = 'G';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Norrbottens län' WHERE iso_code = 'SE' AND abbreviation = 'BD';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Skåne län' WHERE iso_code = 'SE' AND abbreviation = 'M';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Stockholms län' WHERE iso_code = 'SE' AND abbreviation = 'AB';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Södermanlands län' WHERE iso_code = 'SE' AND abbreviation = 'D';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Uppsala län' WHERE iso_code = 'SE' AND abbreviation = 'C';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Värmlands län' WHERE iso_code = 'SE' AND abbreviation = 'S';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Västerbottens län' WHERE iso_code = 'SE' AND abbreviation = 'AC';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Västernorrlands län' WHERE iso_code = 'SE' AND abbreviation = 'Y';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Västmanlands län' WHERE iso_code = 'SE' AND abbreviation = 'U';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Västra Götalands län' WHERE iso_code = 'SE' AND abbreviation = 'Q';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Örebro län' WHERE iso_code = 'SE' AND abbreviation = 'T';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Östergötlands län' WHERE iso_code = 'SE' AND abbreviation = 'E';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Ajdovščina' WHERE iso_code = 'SI' AND abbreviation = '001';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Braslovče' WHERE iso_code = 'SI' AND abbreviation = '151';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Brežice' WHERE iso_code = 'SI' AND abbreviation = '009';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Črenšovci' WHERE iso_code = 'SI' AND abbreviation = '015';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Črna na Koroškem' WHERE iso_code = 'SI' AND abbreviation = '016';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Črnomelj' WHERE iso_code = 'SI' AND abbreviation = '017';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Divača' WHERE iso_code = 'SI' AND abbreviation = '019';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Domžale' WHERE iso_code = 'SI' AND abbreviation = '023';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Gorišnica' WHERE iso_code = 'SI' AND abbreviation = '028';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Hoče-Slivnica' WHERE iso_code = 'SI' AND abbreviation = '160';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Hodoš' WHERE iso_code = 'SI' AND abbreviation = '161';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Ivančna Gorica' WHERE iso_code = 'SI' AND abbreviation = '039';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Juršinci' WHERE iso_code = 'SI' AND abbreviation = '042';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Kidričevo' WHERE iso_code = 'SI' AND abbreviation = '045';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Kočevje' WHERE iso_code = 'SI' AND abbreviation = '048';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Križevci' WHERE iso_code = 'SI' AND abbreviation = '166';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Krško' WHERE iso_code = 'SI' AND abbreviation = '054';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Laško' WHERE iso_code = 'SI' AND abbreviation = '057';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Loška dolina' WHERE iso_code = 'SI' AND abbreviation = '065';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Loški Potok' WHERE iso_code = 'SI' AND abbreviation = '066';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Luče' WHERE iso_code = 'SI' AND abbreviation = '067';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Majšperk' WHERE iso_code = 'SI' AND abbreviation = '069';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Mengeš' WHERE iso_code = 'SI' AND abbreviation = '072';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Mežica' WHERE iso_code = 'SI' AND abbreviation = '074';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Miklavž na Dravskem polju' WHERE iso_code = 'SI' AND abbreviation = '169';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Mirna Peč' WHERE iso_code = 'SI' AND abbreviation = '170';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Moravče' WHERE iso_code = 'SI' AND abbreviation = '077';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Sveti Andraž v Slovenskih goricah' WHERE iso_code = 'SI' AND abbreviation = '182';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Šalovci' WHERE iso_code = 'SI' AND abbreviation = '033';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Šempeter-Vrtojba' WHERE iso_code = 'SI' AND abbreviation = '183';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Šenčur' WHERE iso_code = 'SI' AND abbreviation = '117';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Šentilj' WHERE iso_code = 'SI' AND abbreviation = '118';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Šentjernej' WHERE iso_code = 'SI' AND abbreviation = '119';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Šentjur' WHERE iso_code = 'SI' AND abbreviation = '120';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Škocjan' WHERE iso_code = 'SI' AND abbreviation = '121';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Škofja Loka' WHERE iso_code = 'SI' AND abbreviation = '122';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Škofljica' WHERE iso_code = 'SI' AND abbreviation = '123';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Šmarje pri Jelšah' WHERE iso_code = 'SI' AND abbreviation = '124';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Šmartno ob Paki' WHERE iso_code = 'SI' AND abbreviation = '125';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Šmartno pri Litiji' WHERE iso_code = 'SI' AND abbreviation = '194';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Šoštanj' WHERE iso_code = 'SI' AND abbreviation = '126';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Štore' WHERE iso_code = 'SI' AND abbreviation = '127';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Tišina' WHERE iso_code = 'SI' AND abbreviation = '010';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Tržič' WHERE iso_code = 'SI' AND abbreviation = '131';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Turnišče' WHERE iso_code = 'SI' AND abbreviation = '132';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Velike Lašče' WHERE iso_code = 'SI' AND abbreviation = '134';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Veržej' WHERE iso_code = 'SI' AND abbreviation = '188';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Zavrč' WHERE iso_code = 'SI' AND abbreviation = '143';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Zreče' WHERE iso_code = 'SI' AND abbreviation = '144';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Žalec' WHERE iso_code = 'SI' AND abbreviation = '190';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Železniki' WHERE iso_code = 'SI' AND abbreviation = '146';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Žetale' WHERE iso_code = 'SI' AND abbreviation = '191';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Žiri' WHERE iso_code = 'SI' AND abbreviation = '147';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Žirovnica' WHERE iso_code = 'SI' AND abbreviation = '192';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Žužemberk' WHERE iso_code = 'SI' AND abbreviation = '193';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Banskobystrický kraj' WHERE iso_code = 'SK' AND abbreviation = 'BC';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Bratislavský kraj' WHERE iso_code = 'SK' AND abbreviation = 'BL';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Košický kraj' WHERE iso_code = 'SK' AND abbreviation = 'KI';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Prešovský kraj' WHERE iso_code = 'SK' AND abbreviation = 'PV';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Trenčiansky kraj' WHERE iso_code = 'SK' AND abbreviation = 'TC';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Trnavský kraj' WHERE iso_code = 'SK' AND abbreviation = 'TA';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Žilinský kraj' WHERE iso_code = 'SK' AND abbreviation = 'ZI';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Béja' WHERE iso_code = 'TN' AND abbreviation = '31';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Gabès' WHERE iso_code = 'TN' AND abbreviation = '81';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Etelä-Savo' WHERE iso_code = 'FI' AND abbreviation = 'ES';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Häme' WHERE iso_code = 'FI' AND abbreviation = 'HH';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Itä-Uusimaa' WHERE iso_code = 'FI' AND abbreviation = 'IU';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Päijät-Häme' WHERE iso_code = 'FI' AND abbreviation = 'PH';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Åland' WHERE iso_code = 'FI' AND abbreviation = 'AL';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Al Manāmah (Al ‘Āşimah)' WHERE iso_code = 'BH' AND abbreviation = '13';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Al Janūbīyah' WHERE iso_code = 'BH' AND abbreviation = '14';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Al Wusţá' WHERE iso_code = 'BH' AND abbreviation = '16';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Ash Shamālīyah' WHERE iso_code = 'BH' AND abbreviation = '17';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Córdoba' WHERE iso_code = 'ES' AND abbreviation = 'CO';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Pļaviņu novads' WHERE iso_code = 'LV' AND abbreviation = '072';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Skrīveru novads' WHERE iso_code = 'LV' AND abbreviation = '092';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Alūksnes novads' WHERE iso_code = 'LV' AND abbreviation = '007';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Viļakas novads' WHERE iso_code = 'LV' AND abbreviation = '108';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Rugāju novads' WHERE iso_code = 'LV' AND abbreviation = '082';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Rundāles novads' WHERE iso_code = 'LV' AND abbreviation = '083';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Cēsu novads' WHERE iso_code = 'LV' AND abbreviation = '022';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Līgatnes novads' WHERE iso_code = 'LV' AND abbreviation = '055';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Priekuļu novads' WHERE iso_code = 'LV' AND abbreviation = '075';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Pārgaujas novads' WHERE iso_code = 'LV' AND abbreviation = '070';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Ilūkstes novads' WHERE iso_code = 'LV' AND abbreviation = '036';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Tērvetes novads' WHERE iso_code = 'LV' AND abbreviation = '098';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Jēkabpils novads' WHERE iso_code = 'LV' AND abbreviation = '042';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Aknīstes novads' WHERE iso_code = 'LV' AND abbreviation = '004';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Viesītes novads' WHERE iso_code = 'LV' AND abbreviation = '107';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Krāslavas novads' WHERE iso_code = 'LV' AND abbreviation = '047';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Kuldīgas novads' WHERE iso_code = 'LV' AND abbreviation = '050';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Grobiņas novads' WHERE iso_code = 'LV' AND abbreviation = '032';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Pāvilostas novads' WHERE iso_code = 'LV' AND abbreviation = '071';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Nīcas novads' WHERE iso_code = 'LV' AND abbreviation = '066';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Vaiņodes novads' WHERE iso_code = 'LV' AND abbreviation = '100';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Limbažu novads' WHERE iso_code = 'LV' AND abbreviation = '054';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Salacgrīvas novads' WHERE iso_code = 'LV' AND abbreviation = '086';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Kārsavas novads' WHERE iso_code = 'LV' AND abbreviation = '044';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Lubānas novads' WHERE iso_code = 'LV' AND abbreviation = '057';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Varakļānu novads' WHERE iso_code = 'LV' AND abbreviation = '102';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Ērgļu novads' WHERE iso_code = 'LV' AND abbreviation = '030';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Ikšķiles novads' WHERE iso_code = 'LV' AND abbreviation = '035';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Ķeguma novads' WHERE iso_code = 'LV' AND abbreviation = '051';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Lielvārdes novads' WHERE iso_code = 'LV' AND abbreviation = '053';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Preiļu novads' WHERE iso_code = 'LV' AND abbreviation = '073';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Līvānu novads' WHERE iso_code = 'LV' AND abbreviation = '056';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Riebiņu novads' WHERE iso_code = 'LV' AND abbreviation = '078';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Vārkavas novads' WHERE iso_code = 'LV' AND abbreviation = '103';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Rēzeknes novads' WHERE iso_code = 'LV' AND abbreviation = '077';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Viļānu novads' WHERE iso_code = 'LV' AND abbreviation = '109';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Ķekavas novads' WHERE iso_code = 'LV' AND abbreviation = '052';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Inčukalna novads' WHERE iso_code = 'LV' AND abbreviation = '037';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Ādažu novads' WHERE iso_code = 'LV' AND abbreviation = '011';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Babītes novads' WHERE iso_code = 'LV' AND abbreviation = '012';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Mālpils novads' WHERE iso_code = 'LV' AND abbreviation = '061';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Mārupes novads' WHERE iso_code = 'LV' AND abbreviation = '062';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Ropažu novads' WHERE iso_code = 'LV' AND abbreviation = '080';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Sējas novads' WHERE iso_code = 'LV' AND abbreviation = '090';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Stopiņu novads' WHERE iso_code = 'LV' AND abbreviation = '095';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Brocēnu novads' WHERE iso_code = 'LV' AND abbreviation = '018';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Mērsraga novads' WHERE iso_code = 'LV' AND abbreviation = '063';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Strenču novads' WHERE iso_code = 'LV' AND abbreviation = '096';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Kocēnu novads' WHERE iso_code = 'LV' AND abbreviation = '045';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Rūjienas novads' WHERE iso_code = 'LV' AND abbreviation = '084';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Beverīnas novads' WHERE iso_code = 'LV' AND abbreviation = '017';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Naukšēnu novads' WHERE iso_code = 'LV' AND abbreviation = '064';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Jēkabpils' WHERE iso_code = 'LV' AND abbreviation = 'JKB';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Apače' WHERE iso_code = 'SI' AND abbreviation = '87';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Ormož' WHERE iso_code = 'SI' AND abbreviation = '97';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Podčetrtek' WHERE iso_code = 'SI' AND abbreviation = '102';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Poljčane' WHERE iso_code = 'SI' AND abbreviation = '105';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Rače-Fram' WHERE iso_code = 'SI' AND abbreviation = '113';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Radeče' WHERE iso_code = 'SI' AND abbreviation = '114';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Ravne na Koroškem' WHERE iso_code = 'SI' AND abbreviation = '171';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Razkrižje' WHERE iso_code = 'SI' AND abbreviation = '172';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Rečica ob Savinji' WHERE iso_code = 'SI' AND abbreviation = '173';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Renče-Vogrsko' WHERE iso_code = 'SI' AND abbreviation = '174';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Rogaška Slatina' WHERE iso_code = 'SI' AND abbreviation = '177';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Rogašovci' WHERE iso_code = 'SI' AND abbreviation = '178';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Ruše' WHERE iso_code = 'SI' AND abbreviation = '180';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Semič' WHERE iso_code = 'SI' AND abbreviation = '196';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Šentrupert' WHERE iso_code = 'SI' AND abbreviation = '197';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Sežana' WHERE iso_code = 'SI' AND abbreviation = '199';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Šmarješke Toplice' WHERE iso_code = 'SI' AND abbreviation = '203';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Sodražica' WHERE iso_code = 'SI' AND abbreviation = '204';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Solčava' WHERE iso_code = 'SI' AND abbreviation = '205';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Središče ob Dravi' WHERE iso_code = 'SI' AND abbreviation = '206';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Starše' WHERE iso_code = 'SI' AND abbreviation = '207';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Straža' WHERE iso_code = 'SI' AND abbreviation = '208';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Sveti Tomaž' WHERE iso_code = 'SI' AND abbreviation = '211';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'La Réunion' WHERE iso_code = 'FR' AND abbreviation = 'RE';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Nohiyahoi Tobei Jumhurí' WHERE iso_code = 'TJ' AND abbreviation = 'RA';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Nouvelle-Calédonie' WHERE iso_code = 'FR' AND abbreviation = 'NC';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Haut-Ogooué' WHERE iso_code = 'GA' AND abbreviation = '02';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Moyen-Ogooué' WHERE iso_code = 'GA' AND abbreviation = '03';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Ngounié' WHERE iso_code = 'GA' AND abbreviation = '04';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Ogooué-Ivindo' WHERE iso_code = 'GA' AND abbreviation = '06';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Ogooué-Lolo' WHERE iso_code = 'GA' AND abbreviation = '07';
+UPDATE civicrm_state_province INNER JOIN civicrm_country ON civicrm_state_province.country_id = civicrm_country.id SET civicrm_state_province.name = 'Ogooué-Maritime' WHERE iso_code = 'GA' AND abbreviation = '08';
diff --git a/CRM/Upgrade/Snapshot/V4p2/Price/BAO/Field.php b/CRM/Upgrade/Snapshot/V4p2/Price/BAO/Field.php
deleted file mode 100644 (file)
index 0944c4a..0000000
+++ /dev/null
@@ -1,634 +0,0 @@
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5                                                  |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019                                |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM.                                    |
- |                                                                    |
- | CiviCRM is free software; you can copy, modify, and distribute it  |
- | under the terms of the GNU Affero General Public License           |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
- |                                                                    |
- | CiviCRM is distributed in the hope that it will be useful, but     |
- | WITHOUT ANY WARRANTY; without even the implied warranty of         |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
- | See the GNU Affero General Public License for more details.        |
- |                                                                    |
- | You should have received a copy of the GNU Affero General Public   |
- | License and the CiviCRM Licensing Exception along                  |
- | with this program; if not, contact CiviCRM LLC                     |
- | at info[AT]civicrm[DOT]org. If you have questions about the        |
- | GNU Affero General Public License or the licensing of CiviCRM,     |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
- +--------------------------------------------------------------------+
- */
-
-/**
- *
- * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2019
- */
-
-/**
- * Business objects for managing price fields.
- */
-class CRM_Upgrade_Snapshot_V4p2_Price_BAO_Field extends CRM_Upgrade_Snapshot_V4p2_Price_DAO_Field {
-
-  protected $_options;
-
-  /**
-   * Takes an associative array and creates a price field object.
-   *
-   * the function extract all the params it needs to initialize the create a
-   * price field object. the params array could contain additional unused name/value
-   * pairs
-   *
-   * @param array $params
-   *   (reference ) an assoc array of name/value pairs.
-   *
-   * @return CRM_Upgrade_Snapshot_V4p2_Price_BAO_Field
-   */
-  public static function &add(&$params) {
-    $priceFieldBAO = new CRM_Upgrade_Snapshot_V4p2_Price_BAO_Field();
-
-    $priceFieldBAO->copyValues($params);
-
-    if ($id = CRM_Utils_Array::value('id', $params)) {
-      $priceFieldBAO->id = $id;
-    }
-
-    $priceFieldBAO->save();
-    return $priceFieldBAO;
-  }
-
-  /**
-   * Takes an associative array and creates a price field object.
-   *
-   * This function is invoked from within the web form layer and also from the api layer
-   *
-   * @param array $params
-   *   (reference) an assoc array of name/value pairs.
-   *
-   * @return CRM_Upgrade_Snapshot_V4p2_Price_DAO_Field
-   */
-  public static function create(&$params) {
-
-    $transaction = new CRM_Core_Transaction();
-
-    $priceField = self::add($params);
-
-    if (is_a($priceField, 'CRM_Core_Error')) {
-      $transaction->rollback();
-      return $priceField;
-    }
-
-    $options = $optionsIds = array();
-    $maxIndex = CRM_Price_Form_Field::NUM_OPTION;
-
-    if ($priceField->html_type == 'Text') {
-      $maxIndex = 1;
-
-      $fieldValue = new CRM_Upgrade_Snapshot_V4p2_Price_DAO_FieldValue();
-      $fieldValue->price_field_id = $priceField->id;
-
-      // update previous field values( if any )
-      if ($fieldValue->find(TRUE)) {
-        $optionsIds['id'] = $fieldValue->id;
-      }
-    }
-    $defaultArray = array();
-    if ($params['html_type'] == 'CheckBox' && isset($params['default_checkbox_option'])) {
-      $tempArray = array_keys($params['default_checkbox_option']);
-      foreach ($tempArray as $v) {
-        if ($params['option_amount'][$v]) {
-          $defaultArray[$v] = 1;
-        }
-      }
-    }
-    else {
-      if (!empty($params['default_option'])) {
-        $defaultArray[$params['default_option']] = 1;
-      }
-    }
-
-    for ($index = 1; $index <= $maxIndex; $index++) {
-
-      if (array_key_exists('option_amount', $params) &&
-        array_key_exists($index, $params['option_amount']) &&
-        (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(
-          'price_field_id' => $priceField->id,
-          'label' => trim($params['option_label'][$index]),
-          'name' => CRM_Utils_String::munge($params['option_label'][$index], '_', 64),
-          'amount' => CRM_Utils_Rule::cleanMoney(trim($params['option_amount'][$index])),
-          'count' => CRM_Utils_Array::value($index, CRM_Utils_Array::value('option_count', $params), NULL),
-          'max_value' => CRM_Utils_Array::value($index, CRM_Utils_Array::value('option_max_value', $params), NULL),
-          'description' => CRM_Utils_Array::value($index, CRM_Utils_Array::value('option_description', $params), NULL),
-          'membership_type_id' => CRM_Utils_Array::value($index, CRM_Utils_Array::value('membership_type_id', $params), NULL),
-          'weight' => $params['option_weight'][$index],
-          'is_active' => 1,
-          'is_default' => CRM_Utils_Array::value($params['option_weight'][$index], $defaultArray) ? $defaultArray[$params['option_weight'][$index]] : 0,
-        );
-
-        if ($opIds = CRM_Utils_Array::value('option_id', $params)) {
-          if ($opId = CRM_Utils_Array::value($index, $opIds)) {
-            $optionsIds['id'] = $opId;
-          }
-          else {
-            $optionsIds['id'] = NULL;
-          }
-        }
-        CRM_Upgrade_Snapshot_V4p2_Price_BAO_FieldValue::create($options, $optionsIds);
-      }
-    }
-
-    $transaction->commit();
-    return $priceField;
-  }
-
-  /**
-   * Fetch object based on array of properties.
-   *
-   * @param array $params
-   *   (reference ) an assoc array of name/value pairs.
-   * @param array $defaults
-   *   (reference ) an assoc array to hold the flattened values.
-   *
-   * @return CRM_Upgrade_Snapshot_V4p2_Price_DAO_Field
-   */
-  public static function retrieve(&$params, &$defaults) {
-    return CRM_Core_DAO::commonRetrieve('CRM_Upgrade_Snapshot_V4p2_Price_DAO_Field', $params, $defaults);
-  }
-
-  /**
-   * Update the is_active flag in the db.
-   *
-   * @param int $id
-   *   Id of the database record.
-   * @param bool $is_active
-   *   Value we want to set the is_active field.
-   *
-   * @return bool
-   *   true if we found and updated the object, else false
-   */
-  public static function setIsActive($id, $is_active) {
-    return CRM_Core_DAO::setFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_DAO_Field', $id, 'is_active', $is_active);
-  }
-
-  /**
-   * Get the field title.
-   *
-   * @param int $id
-   *   Id of field.
-   *
-   * @return string
-   *   name
-   */
-  public static function getTitle($id) {
-    return CRM_Core_DAO::getFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_DAO_Field', $id, 'label');
-  }
-
-  /**
-   * This function for building custom fields.
-   *
-   * @param CRM_Core_Form $qf
-   *   Form object (reference).
-   * @param string $elementName
-   *   Name of the custom field.
-   * @param int $fieldId
-   * @param bool $inactiveNeeded
-   * @param bool $useRequired
-   *   True if required else false.
-   * @param string $label
-   *   Label for custom field.
-   * @param null $fieldOptions
-   * @param array $freezeOptions
-   *
-   * @return null
-   */
-  public static function addQuickFormElement(
-    &$qf,
-    $elementName,
-    $fieldId,
-    $inactiveNeeded,
-    $useRequired = TRUE,
-    $label = NULL,
-    $fieldOptions = NULL,
-    $freezeOptions = array()
-  ) {
-
-    $field = new CRM_Upgrade_Snapshot_V4p2_Price_DAO_Field();
-    $field->id = $fieldId;
-    if (!$field->find(TRUE)) {
-      /* FIXME: failure! */
-
-      return NULL;
-    }
-
-    $otherAmount = $qf->get('values');
-    $config = CRM_Core_Config::singleton();
-    $qf->assign('currencySymbol', CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Currency', $config->defaultCurrency, 'symbol', 'name'));
-    // get currency name for price field and option attributes
-    $currencyName = $config->defaultCurrency;
-
-    if (!isset($label)) {
-      $label = (property_exists($qf, '_membershipBlock') && !empty($qf->_membershipBlock['is_separate_payment']) && $field->name == 'contribution_amount' && empty($otherAmount['is_allow_other_amount'])) ? ts('Additional Contribution') : $field->label;
-    }
-
-    if ($field->name == 'contribution_amount') {
-      $qf->_contributionAmount = 1;
-    }
-
-    if (isset($qf->_online) && $qf->_online) {
-      $useRequired = FALSE;
-    }
-
-    $customOption = $fieldOptions;
-    if (!is_array($customOption)) {
-      $customOption = CRM_Upgrade_Snapshot_V4p2_Price_BAO_Field::getOptions($field->id, $inactiveNeeded);
-    }
-
-    //use value field.
-    $valueFieldName = 'amount';
-    $seperator = '|';
-    switch ($field->html_type) {
-      case 'Text':
-        $optionKey = key($customOption);
-        $count = CRM_Utils_Array::value('count', $customOption[$optionKey], '');
-        $max_value = CRM_Utils_Array::value('max_value', $customOption[$optionKey], '');
-        $priceVal = implode($seperator, array($customOption[$optionKey][$valueFieldName], $count, $max_value));
-
-        $extra = array();
-        if (property_exists($qf, '_quickConfig') && $qf->_quickConfig && property_exists($qf, '_contributionAmount') && $qf->_contributionAmount) {
-          $qf->assign('priceset', $elementName);
-          $extra = array('onclick' => 'useAmountOther();');
-        }
-
-        // if separate membership payment is used with quick config priceset then change the other amount label
-        if (property_exists($qf, '_membershipBlock') && !empty($qf->_membershipBlock['is_separate_payment']) && $qf->_quickConfig && $field->name == 'other_amount' && !property_exists($qf, '_contributionAmount')) {
-          $label = ts('Additional Contribution');
-          $useRequired = 0;
-        }
-        elseif (!empty($fieldOptions[$optionKey]['label'])) {
-          $label = $fieldOptions[$optionKey]['label'];
-        }
-
-        if ($field->is_display_amounts) {
-          $label .= '&nbsp;-&nbsp;';
-          $label .= CRM_Utils_Money::format(CRM_Utils_Array::value($valueFieldName, $customOption[$optionKey]));
-        }
-
-        $element = &$qf->add('text', $elementName, $label,
-          array_merge($extra,
-            array(
-              'price' => json_encode(array($optionKey, $priceVal)),
-              'size' => '4',
-            )
-          ),
-          $useRequired && $field->is_required
-        );
-
-        // CRM-6902
-        if (in_array($optionKey, $freezeOptions)) {
-          $element->freeze();
-        }
-
-        //CRM-10117
-        if (property_exists($qf, '_quickConfig') && $qf->_quickConfig) {
-          $message = ts("Please enter a valid amount.");
-          $type = "money";
-        }
-        else {
-          $message = ts('%1 must be an integer (whole number).', array(1 => $label));
-          $type = "positiveInteger";
-        }
-        // integers will have numeric rule applied to them.
-        $qf->addRule($elementName, $message, $type);
-        break;
-
-      case 'Radio':
-        $choice = array();
-
-        if (property_exists($qf, '_quickConfig') && $qf->_quickConfig && property_exists($qf, '_contributionAmount') && $qf->_contributionAmount) {
-          $qf->assign('contriPriceset', $elementName);
-        }
-
-        foreach ($customOption as $opId => $opt) {
-          if ($field->is_display_amounts) {
-            $opt['label'] = !empty($opt['label']) ? $opt['label'] . '&nbsp;-&nbsp;' : '';
-            $opt['label'] .= CRM_Utils_Money::format($opt[$valueFieldName]);
-          }
-          $count = CRM_Utils_Array::value('count', $opt, '');
-          $max_value = CRM_Utils_Array::value('max_value', $opt, '');
-          $priceVal = implode($seperator, array($opt[$valueFieldName], $count, $max_value));
-          $extra = array(
-            'price' => json_encode(array($elementName, $priceVal)),
-            'data-amount' => $opt[$valueFieldName],
-            'data-currency' => $currencyName,
-          );
-          if (property_exists($qf, '_quickConfig') && $qf->_quickConfig && $field->name == 'contribution_amount') {
-            $extra += array('onclick' => 'clearAmountOther();');
-          }
-          elseif (property_exists($qf, '_quickConfig') && $qf->_quickConfig && $field->name == 'membership_amount') {
-            $extra += array(
-              '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);
-
-          // CRM-6902
-          if (in_array($opId, $freezeOptions)) {
-            $choice[$opId]->freeze();
-          }
-        }
-
-        if (property_exists($qf, '_membershipBlock') && !empty($qf->_membershipBlock['is_separate_payment']) && $field->name == 'contribution_amount') {
-          $choice[] = $qf->createElement('radio', NULL, '', 'No thank you', '-1',
-            array(
-              'onclick' => 'clearAmountOther();',
-            )
-          );
-        }
-
-        if (!$field->is_required) {
-          // add "none" option
-          if (!empty($otherAmount['is_allow_other_amount']) && $field->name == 'contribution_amount') {
-            $none = ts('Other Amount');
-          }
-          elseif (property_exists($qf, '_membershipBlock') && empty($qf->_membershipBlock['is_required']) && $field->name == 'membership_amount') {
-            $none = ts('No thank you');
-          }
-          else {
-            $none = ts('-none-');
-          }
-
-          $choice[] = $qf->createElement('radio', NULL, '', $none, '0',
-            array('price' => json_encode(array($elementName, "0")))
-          );
-        }
-
-        $element = &$qf->addGroup($choice, $elementName, $label);
-
-        // make contribution field required for quick config when membership block is enabled
-        if (($field->name == 'contribution_amount' || $field->name == 'membership_amount') && property_exists($qf, '_membershipBlock') && !empty($qf->_membershipBlock) && !$field->is_required) {
-          $useRequired = $field->is_required = TRUE;
-        }
-
-        if ($useRequired && $field->is_required) {
-          $qf->addRule($elementName, ts('%1 is a required field.', array(1 => $label)), 'required');
-        }
-        break;
-
-      case 'Select':
-        $selectOption = $allowedOptions = $priceVal = array();
-
-        foreach ($customOption as $opt) {
-          $count = CRM_Utils_Array::value('count', $opt, '');
-          $max_value = CRM_Utils_Array::value('max_value', $opt, '');
-          $priceVal[$opt['id']] = implode($seperator, array($opt[$valueFieldName], $count, $max_value));
-
-          if ($field->is_display_amounts) {
-            $opt['label'] .= '&nbsp;-&nbsp;';
-            $opt['label'] .= CRM_Utils_Money::format($opt[$valueFieldName]);
-          }
-          $selectOption[$opt['id']] = $opt['label'];
-
-          if (!in_array($opt['id'], $freezeOptions)) {
-            $allowedOptions[] = $opt['id'];
-          }
-        }
-        $element = &$qf->add('select', $elementName, $label,
-          array('' => ts('- select -')) + $selectOption,
-          $useRequired && $field->is_required,
-          array('price' => json_encode($priceVal))
-        );
-
-        // CRM-6902
-        $button = substr($qf->controller->getButtonName(), -4);
-        if (!empty($freezeOptions) && $button != 'skip') {
-          $qf->addRule($elementName, ts('Sorry, this option is currently sold out.'), 'regex', "/" . implode('|', $allowedOptions) . "/");
-        }
-        break;
-
-      case 'CheckBox':
-
-        $check = array();
-        foreach ($customOption as $opId => $opt) {
-          $count = CRM_Utils_Array::value('count', $opt, '');
-          $max_value = CRM_Utils_Array::value('max_value', $opt, '');
-          $priceVal = implode($seperator, array($opt[$valueFieldName], $count, $max_value));
-
-          if ($field->is_display_amounts) {
-            $opt['label'] .= '&nbsp;-&nbsp;';
-            $opt['label'] .= CRM_Utils_Money::format($opt[$valueFieldName]);
-          }
-          $check[$opId] = &$qf->createElement('checkbox', $opt['id'], NULL, $opt['label'],
-            array(
-              'price' => json_encode(array($opt['id'], $priceVal)),
-              'data-amount' => $opt[$valueFieldName],
-              'data-currency' => $currencyName,
-            )
-          );
-
-          // CRM-6902
-          if (in_array($opId, $freezeOptions)) {
-            $check[$opId]->freeze();
-          }
-        }
-        $element = &$qf->addGroup($check, $elementName, $label);
-        if ($useRequired && $field->is_required) {
-          $qf->addRule($elementName, ts('%1 is a required field.', array(1 => $label)), 'required');
-        }
-        break;
-    }
-    if (isset($qf->_online) && $qf->_online) {
-      $element->freeze();
-    }
-  }
-
-  /**
-   * Retrieve a list of options for the specified field.
-   *
-   * @param int $fieldId
-   *   Price field ID.
-   * @param bool $inactiveNeeded
-   *   Include inactive options.
-   * @param bool $reset
-   *   Ignore stored values\.
-   *
-   * @return array
-   *   array of options
-   */
-  public static function getOptions($fieldId, $inactiveNeeded = FALSE, $reset = FALSE) {
-    static $options = array();
-
-    if ($reset || empty($options[$fieldId])) {
-      $values = array();
-      CRM_Upgrade_Snapshot_V4p2_Price_BAO_FieldValue::getValues($fieldId, $values, 'weight', !$inactiveNeeded);
-      $options[$fieldId] = $values;
-    }
-
-    return $options[$fieldId];
-  }
-
-  /**
-   * @param $optionLabel
-   * @param int $fid
-   *
-   * @return mixed
-   */
-  public static function getOptionId($optionLabel, $fid) {
-    if (!$optionLabel || !$fid) {
-      return;
-    }
-
-    $optionGroupName = "civicrm_price_field.amount.{$fid}";
-
-    $query = "
-SELECT
-        option_value.id as id
-FROM
-        civicrm_option_value option_value,
-        civicrm_option_group option_group
-WHERE
-        option_group.name  = %1
-    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'),
-      ));
-
-    while ($dao->fetch()) {
-      return $dao->id;
-    }
-  }
-
-  /**
-   * Delete the price set field.
-   *
-   * @param int $id
-   *   Field Id.
-   *
-   * @return mixed
-   *   Boolean-ish
-   */
-  public static function deleteField($id) {
-    $field = new CRM_Upgrade_Snapshot_V4p2_Price_DAO_Field();
-    $field->id = $id;
-
-    if ($field->find(TRUE)) {
-      // delete the options for this field
-      CRM_Upgrade_Snapshot_V4p2_Price_BAO_FieldValue::deleteValues($id);
-
-      // reorder the weight before delete
-      $fieldValues = array('price_set_id' => $field->price_set_id);
-
-      CRM_Utils_Weight::delWeight('CRM_Upgrade_Snapshot_V4p2_Price_DAO_Field', $field->id, $fieldValues);
-
-      // now delete the field
-      return $field->delete();
-    }
-
-    return NULL;
-  }
-
-  /**
-   * @return array
-   */
-  public static function &htmlTypes() {
-    static $htmlTypes = NULL;
-    if (!$htmlTypes) {
-      $htmlTypes = array(
-        'Text' => ts('Text / Numeric Quantity'),
-        'Select' => ts('Select'),
-        'Radio' => ts('Radio'),
-        'CheckBox' => ts('CheckBox'),
-      );
-    }
-    return $htmlTypes;
-  }
-
-  /**
-   * Validate the priceset.
-   *
-   * @param int $priceSetId
-   * @param array $fields
-   * @param array $error
-   */
-  public static function priceSetValidation($priceSetId, $fields, &$error) {
-    // check for at least one positive
-    // amount price field should be selected.
-    $priceField = new CRM_Upgrade_Snapshot_V4p2_Price_DAO_Field();
-    $priceField->price_set_id = $priceSetId;
-    $priceField->find();
-
-    $priceFields = array();
-
-    while ($priceField->fetch()) {
-      $key = "price_{$priceField->id}";
-      if (!empty($fields[$key])) {
-        $priceFields[$priceField->id] = $fields[$key];
-      }
-    }
-
-    if (!empty($priceFields)) {
-      // we should has to have positive amount.
-      $sql = "
-SELECT  id, html_type
-FROM  civicrm_price_field
-WHERE  id IN (" . implode(',', array_keys($priceFields)) . ')';
-      $fieldDAO = CRM_Core_DAO::executeQuery($sql);
-      $htmlTypes = array();
-      while ($fieldDAO->fetch()) {
-        $htmlTypes[$fieldDAO->id] = $fieldDAO->html_type;
-      }
-
-      $selectedAmounts = array();
-
-      foreach ($htmlTypes as $fieldId => $type) {
-        $options = array();
-        CRM_Upgrade_Snapshot_V4p2_Price_BAO_FieldValue::getValues($fieldId, $options);
-
-        if (empty($options)) {
-
-          continue;
-
-        }
-
-        if ($type == 'Text') {
-          foreach ($options as $opId => $option) {
-            $selectedAmounts[$opId] = $priceFields[$fieldId] * $option['amount'];
-            break;
-          }
-        }
-        elseif (is_array($fields["price_{$fieldId}"])) {
-          foreach (array_keys($fields["price_{$fieldId}"]) as $opId) {
-            $selectedAmounts[$opId] = $options[$opId]['amount'];
-          }
-        }
-        elseif (in_array($fields["price_{$fieldId}"], array_keys($options))) {
-          $selectedAmounts[$fields["price_{$fieldId}"]] = $options[$fields["price_{$fieldId}"]]['amount'];
-        }
-      }
-
-      list($componentName) = explode(':', $fields['_qf_default']);
-      // now we have all selected amount in hand.
-      $totalAmount = array_sum($selectedAmounts);
-      if ($totalAmount < 0) {
-        $error['_qf_default'] = ts('%1 amount can not be less than zero. Please select the options accordingly.', array(1 => $componentName));
-      }
-    }
-    else {
-      $error['_qf_default'] = ts("Please select at least one option from price set.");
-    }
-  }
-
-}
diff --git a/CRM/Upgrade/Snapshot/V4p2/Price/BAO/FieldValue.php b/CRM/Upgrade/Snapshot/V4p2/Price/BAO/FieldValue.php
deleted file mode 100644 (file)
index 5ca834e..0000000
+++ /dev/null
@@ -1,225 +0,0 @@
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5                                                  |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019                                |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM.                                    |
- |                                                                    |
- | CiviCRM is free software; you can copy, modify, and distribute it  |
- | under the terms of the GNU Affero General Public License           |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
- |                                                                    |
- | CiviCRM is distributed in the hope that it will be useful, but     |
- | WITHOUT ANY WARRANTY; without even the implied warranty of         |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
- | See the GNU Affero General Public License for more details.        |
- |                                                                    |
- | You should have received a copy of the GNU Affero General Public   |
- | License and the CiviCRM Licensing Exception along                  |
- | with this program; if not, contact CiviCRM LLC                     |
- | at info[AT]civicrm[DOT]org. If you have questions about the        |
- | GNU Affero General Public License or the licensing of CiviCRM,     |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
- +--------------------------------------------------------------------+
- */
-
-/**
- *
- * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2019
- * $Id$
- *
- */
-
-/**
- * Business objects for managing price fields values.
- *
- */
-class CRM_Upgrade_Snapshot_V4p2_Price_BAO_FieldValue extends CRM_Upgrade_Snapshot_V4p2_Price_DAO_FieldValue {
-
-  /**
-   * Insert/update a new entry in the database.
-   *
-   * @param array $params
-   *   (reference), array $ids.
-   *
-   * @param $ids
-   *
-   * @return CRM_Upgrade_Snapshot_V4p2_Price_DAO_FieldValue
-   */
-  public static function &add(&$params, $ids) {
-
-    $fieldValueBAO = new CRM_Upgrade_Snapshot_V4p2_Price_BAO_FieldValue();
-    $fieldValueBAO->copyValues($params);
-
-    if ($id = CRM_Utils_Array::value('id', $ids)) {
-      $fieldValueBAO->id = $id;
-    }
-    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'));
-      CRM_Core_DAO::executeQuery($query, $p);
-    }
-
-    $fieldValueBAO->save();
-    return $fieldValueBAO;
-  }
-
-  /**
-   * Creates a new entry in the database.
-   *
-   * @param array $params
-   *   (reference), array $ids.
-   *
-   * @param $ids
-   *
-   * @return CRM_Upgrade_Snapshot_V4p2_Price_DAO_FieldValue
-   */
-  public static function create(&$params, $ids) {
-
-    if (!is_array($params) || empty($params)) {
-      return NULL;
-    }
-
-    if ($id = CRM_Utils_Array::value('id', $ids)) {
-      if (isset($params['name'])) {
-        unset($params['name']);
-      }
-
-      $oldWeight = NULL;
-      if ($id) {
-        $oldWeight = CRM_Core_DAO::getFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_DAO_FieldValue', $id, 'weight', 'id');
-      }
-
-      $fieldValues = array('price_field_id' => CRM_Utils_Array::value('price_field_id', $params, 0));
-      $params['weight'] = CRM_Utils_Weight::updateOtherWeights('CRM_Upgrade_Snapshot_V4p2_Price_DAO_FieldValue', $oldWeight, $params['weight'], $fieldValues);
-    }
-    else {
-      if (empty($params['name'])) {
-        $params['name'] = CRM_Utils_String::munge(CRM_Utils_Array::value('label', $params), '_', 64);
-      }
-      if (empty($params['weight'])) {
-        $params['weight'] = 1;
-      }
-    }
-    $params['is_active'] = CRM_Utils_Array::value('is_active', $params, 0);
-
-    return self::add($params, $ids);
-  }
-
-  /**
-   * Retrieve DB object based on input parameters.
-   *
-   * It also stores all the retrieved values in the default array.
-   *
-   * @param array $params
-   *   (reference ) an assoc array.
-   * @param array $defaults
-   *   (reference ) an assoc array to hold the flattened values.
-   *
-   * @return CRM_Upgrade_Snapshot_V4p2_Price_DAO_FieldValue
-   */
-  public static function retrieve(&$params, &$defaults) {
-    return CRM_Core_DAO::commonRetrieve('CRM_Upgrade_Snapshot_V4p2_Price_DAO_FieldValue', $params, $defaults);
-  }
-
-  /**
-   * Retrive the all values for given field id.
-   *
-   * @param int $fieldId
-   *   Price_field_id.
-   * @param array $values
-   *   (reference ) to hold the values.
-   * @param string $orderBy
-   *   For order by, default weight.
-   * @param bool|int $isActive is_active, default false
-   *
-   * @return array
-   *
-   */
-  public static function getValues($fieldId, &$values, $orderBy = 'weight', $isActive = FALSE) {
-    $fieldValueDAO = new CRM_Upgrade_Snapshot_V4p2_Price_DAO_FieldValue();
-    $fieldValueDAO->price_field_id = $fieldId;
-    $fieldValueDAO->orderBy($orderBy, 'label');
-    if ($isActive) {
-      $fieldValueDAO->is_active = 1;
-    }
-    $fieldValueDAO->find();
-
-    while ($fieldValueDAO->fetch()) {
-      CRM_Core_DAO::storeValues($fieldValueDAO, $values[$fieldValueDAO->id]);
-    }
-
-    return $values;
-  }
-
-  /**
-   * Get the price field option label.
-   *
-   * @param int $id
-   *   Id of field option.
-   *
-   * @return string
-   *   name
-   *
-   */
-  public static function getOptionLabel($id) {
-    return CRM_Core_DAO::getFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_DAO_FieldValue', $id, 'label');
-  }
-
-  /**
-   * Update the is_active flag in the db.
-   *
-   * @param int $id
-   *   Id of the database record.
-   * @param bool $is_active
-   *   Value we want to set the is_active field.
-   *
-   * @return bool
-   *   true if we found and updated the object, else false
-   */
-  public static function setIsActive($id, $is_active) {
-    return CRM_Core_DAO::setFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_DAO_FieldValue', $id, 'is_active', $is_active);
-  }
-
-  /**
-   * Delete all values of the given field id.
-   *
-   * @param int $fieldId
-   *   Price field id.
-   *
-   * @return bool
-   *
-   */
-  public static function deleteValues($fieldId) {
-    if (!$fieldId) {
-      return FALSE;
-    }
-
-    $fieldValueDAO = new CRM_Upgrade_Snapshot_V4p2_Price_DAO_FieldValue();
-    $fieldValueDAO->price_field_id = $fieldId;
-    $fieldValueDAO->delete();
-  }
-
-  /**
-   * Delete the value.
-   *
-   * @param int $id
-   *   Id.
-   *
-   * @return bool
-   *
-   */
-  public static function del($id) {
-    if (!$id) {
-      return FALSE;
-    }
-
-    $fieldValueDAO = new CRM_Upgrade_Snapshot_V4p2_Price_DAO_FieldValue();
-    $fieldValueDAO->id = $id;
-    return $fieldValueDAO->delete();
-  }
-
-}
diff --git a/CRM/Upgrade/Snapshot/V4p2/Price/BAO/LineItem.php b/CRM/Upgrade/Snapshot/V4p2/Price/BAO/LineItem.php
deleted file mode 100644 (file)
index c406fe5..0000000
+++ /dev/null
@@ -1,311 +0,0 @@
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5                                                  |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019                                |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM.                                    |
- |                                                                    |
- | CiviCRM is free software; you can copy, modify, and distribute it  |
- | under the terms of the GNU Affero General Public License           |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
- |                                                                    |
- | CiviCRM is distributed in the hope that it will be useful, but     |
- | WITHOUT ANY WARRANTY; without even the implied warranty of         |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
- | See the GNU Affero General Public License for more details.        |
- |                                                                    |
- | You should have received a copy of the GNU Affero General Public   |
- | License and the CiviCRM Licensing Exception along                  |
- | with this program; if not, contact CiviCRM LLC                     |
- | at info[AT]civicrm[DOT]org. If you have questions about the        |
- | GNU Affero General Public License or the licensing of CiviCRM,     |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
- +--------------------------------------------------------------------+
- */
-
-/**
- *
- * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2019
- * $Id$
- *
- */
-
-/**
- *
- * @package CRM
- * @author Marshal Newrock <marshal@idealso.com>
- * $Id$
- */
-
-/**
- * Business objects for Line Items generated by monetary transactions
- */
-class CRM_Upgrade_Snapshot_V4p2_Price_BAO_LineItem extends CRM_Upgrade_Snapshot_V4p2_Price_DAO_LineItem {
-
-  /**
-   * Creates a new entry in the database.
-   *
-   * @param array $params
-   *   (reference) an assoc array of name/value pairs.
-   *
-   * @return CRM_Upgrade_Snapshot_V4p2_Price_DAO_LineItem
-   */
-  public static function create(&$params) {
-    //create mode only as we don't support editing line items
-
-    CRM_Utils_Hook::pre('create', 'LineItem', $params['entity_id'], $params);
-
-    $lineItemBAO = new CRM_Upgrade_Snapshot_V4p2_Price_BAO_LineItem();
-    $lineItemBAO->copyValues($params);
-
-    $return = $lineItemBAO->save();
-
-    CRM_Utils_Hook::post('create', 'LineItem', $params['entity_id'], $params);
-
-    return $return;
-  }
-
-  /**
-   * Retrieve DB object based on input parameters.
-   *
-   * It also stores all the retrieved values in the default array.
-   *
-   * @param array $params
-   *   (reference ) an assoc array of name/value pairs.
-   * @param array $defaults
-   *   (reference ) an assoc array to hold the flattened values.
-   *
-   * @return CRM_Upgrade_Snapshot_V4p2_Price_BAO_LineItem
-   */
-  public static function retrieve(&$params, &$defaults) {
-    $lineItem = new CRM_Upgrade_Snapshot_V4p2_Price_BAO_LineItem();
-    $lineItem->copyValues($params);
-    if ($lineItem->find(TRUE)) {
-      CRM_Core_DAO::storeValues($lineItem, $defaults);
-      return $lineItem;
-    }
-    return NULL;
-  }
-
-  /**
-   * Given a participant id/contribution id,
-   * return contribution/fee line items
-   *
-   * @param int $entityId
-   *   participant/contribution id.
-   * @param string $entity
-   *   participant/contribution.
-   *
-   * @param null $isQuick
-   *
-   * @return array
-   *   Array of line items
-   */
-  public static function getLineItems($entityId, $entity = 'participant', $isQuick = NULL) {
-    $selectClause = $whereClause = $fromClause = NULL;
-
-    $selectClause = "
-SELECT    li.id,
-          li.label,
-          li.qty,
-          li.unit_price,
-          li.line_total,
-          pf.label as field_title,
-          pf.html_type,
-          pfv.membership_type_id,
-          li.price_field_id,
-          li.participant_count,
-          li.price_field_value_id,
-          pfv.description";
-
-    $fromClause = "
-FROM      civicrm_%2 as %2
-LEFT JOIN civicrm_line_item li ON ( li.entity_id = %2.id AND li.entity_table = 'civicrm_%2')
-LEFT JOIN civicrm_price_field_value pfv ON ( pfv.id = li.price_field_value_id )
-LEFT JOIN civicrm_price_field pf ON (pf.id = li.price_field_id )";
-    $whereClause = "
-WHERE     %2.id = %1";
-
-    if ($isQuick) {
-      $fromClause .= " LEFT JOIN civicrm_price_set cps on cps.id = pf.price_set_id ";
-      $whereClause .= " and cps.is_quick_config = 0";
-    }
-    $lineItems = array();
-
-    if (!$entityId || !$entity || !$fromClause) {
-      return $lineItems;
-    }
-
-    $params = array(
-      1 => array($entityId, 'Integer'),
-      2 => array($entity, 'Text'),
-    );
-
-    $dao = CRM_Core_DAO::executeQuery("$selectClause $fromClause $whereClause", $params);
-    while ($dao->fetch()) {
-      if (!$dao->id) {
-        continue;
-      }
-      $lineItems[$dao->id] = array(
-        'qty' => $dao->qty,
-        'label' => $dao->label,
-        'unit_price' => $dao->unit_price,
-        'line_total' => $dao->line_total,
-        'price_field_id' => $dao->price_field_id,
-        'participant_count' => $dao->participant_count,
-        'price_field_value_id' => $dao->price_field_value_id,
-        'field_title' => $dao->field_title,
-        'html_type' => $dao->html_type,
-        'description' => $dao->description,
-        'entity_id' => $entityId,
-        'membership_type_id' => $dao->membership_type_id,
-      );
-    }
-    return $lineItems;
-  }
-
-  /**
-   * This method will create the lineItem array required for.
-   * processAmount method
-   *
-   * @param int $fid
-   *   Price set field id.
-   * @param array $params
-   *   Reference to form values.
-   * @param array $fields
-   *   Reference to array of fields belonging.
-   *                          to the price set used for particular event
-   * @param array $values
-   *   Reference to the values array(.
-   *   this is lineItem array)
-   */
-  public static function format($fid, &$params, &$fields, &$values) {
-    if (empty($params["price_{$fid}"])) {
-      return;
-    }
-
-    $optionIDs = implode(',', array_keys($params["price_{$fid}"]));
-
-    //lets first check in fun parameter,
-    //since user might modified w/ hooks.
-    $options = array();
-    if (array_key_exists('options', $fields)) {
-      $options = $fields['options'];
-    }
-    else {
-      CRM_Upgrade_Snapshot_V4p2_Price_BAO_FieldValue::getValues($fid, $options, 'weight', TRUE);
-    }
-    $fieldTitle = CRM_Utils_Array::value('label', $fields);
-    if (!$fieldTitle) {
-      $fieldTitle = CRM_Core_DAO::getFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_DAO_Field', $fid, 'label');
-    }
-
-    foreach ($params["price_{$fid}"] as $oid => $qty) {
-      $price = $options[$oid]['amount'];
-
-      // lets clean the price in case it is not yet cleaned
-      // CRM-10974
-      $price = CRM_Utils_Rule::cleanMoney($price);
-
-      $participantsPerField = CRM_Utils_Array::value('count', $options[$oid], 0);
-
-      $values[$oid] = array(
-        'price_field_id' => $fid,
-        'price_field_value_id' => $oid,
-        'label' => CRM_Utils_Array::value('label', $options[$oid]),
-        'field_title' => $fieldTitle,
-        'description' => CRM_Utils_Array::value('description', $options[$oid]),
-        'qty' => $qty,
-        'unit_price' => $price,
-        'line_total' => $qty * $price,
-        'participant_count' => $qty * $participantsPerField,
-        'max_value' => CRM_Utils_Array::value('max_value', $options[$oid]),
-        'membership_type_id' => CRM_Utils_Array::value('membership_type_id', $options[$oid]),
-        'auto_renew' => CRM_Utils_Array::value('auto_renew', $options[$oid]),
-        'html_type' => $fields['html_type'],
-      );
-    }
-  }
-
-  /**
-   * Delete line items for given entity.
-   *
-   * @param int $entityId
-   * @param int $entityTable
-   *
-   * @return bool
-   */
-  public static function deleteLineItems($entityId, $entityTable) {
-    $result = FALSE;
-    if (!$entityId || !$entityTable) {
-      return $result;
-    }
-
-    if ($entityId && !is_array($entityId)) {
-      $entityId = array($entityId);
-    }
-
-    $query = "DELETE FROM civicrm_line_item where entity_id IN ('" . implode("','", $entityId) . "') AND entity_table = '$entityTable'";
-    $dao = CRM_Core_DAO::executeQuery($query);
-    return $result;
-  }
-
-  /**
-   * @param int $entityId
-   * @param string $entityTable
-   * @param $amount
-   * @param array $otherParams
-   */
-  public static function syncLineItems($entityId, $entityTable = 'civicrm_contribution', $amount, $otherParams = NULL) {
-    if (!$entityId || CRM_Utils_System::isNull($amount)) {
-      return;
-    }
-
-    $from = " civicrm_line_item li
-LEFT JOIN   civicrm_price_field pf ON pf.id = li.price_field_id
-LEFT JOIN   civicrm_price_set ps ON ps.id = pf.price_set_id ";
-
-    $set = " li.unit_price = %3,
-             li.line_total = %3 ";
-
-    $where = " li.entity_id = %1 AND
-               li.entity_table = %2 ";
-
-    $params = array(
-      1 => array($entityId, 'Integer'),
-      2 => array($entityTable, 'String'),
-      3 => array($amount, 'Float'),
-    );
-
-    if ($entityTable == 'civicrm_contribution') {
-      $entityName = 'default_contribution_amount';
-      $where .= " AND ps.name = %4 ";
-      $params[4] = array($entityName, 'String');
-    }
-    elseif ($entityTable == 'civicrm_participant') {
-      $from .= "
-LEFT JOIN civicrm_price_set_entity cpse ON cpse.price_set_id = ps.id
-LEFT JOIN civicrm_price_field_value cpfv ON cpfv.price_field_id = pf.id and cpfv.label = %4 ";
-      $set .= " ,li.label = %4,
-                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'),
-      );
-    }
-
-    $query = "
-UPDATE $from
-SET    $set
-WHERE  $where
-";
-
-    CRM_Core_DAO::executeQuery($query, $params);
-  }
-
-}
diff --git a/CRM/Upgrade/Snapshot/V4p2/Price/BAO/Set.php b/CRM/Upgrade/Snapshot/V4p2/Price/BAO/Set.php
deleted file mode 100644 (file)
index e5c1282..0000000
+++ /dev/null
@@ -1,1144 +0,0 @@
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5                                                  |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019                                |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM.                                    |
- |                                                                    |
- | CiviCRM is free software; you can copy, modify, and distribute it  |
- | under the terms of the GNU Affero General Public License           |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
- |                                                                    |
- | CiviCRM is distributed in the hope that it will be useful, but     |
- | WITHOUT ANY WARRANTY; without even the implied warranty of         |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
- | See the GNU Affero General Public License for more details.        |
- |                                                                    |
- | You should have received a copy of the GNU Affero General Public   |
- | License and the CiviCRM Licensing Exception along                  |
- | with this program; if not, contact CiviCRM LLC                     |
- | at info[AT]civicrm[DOT]org. If you have questions about the        |
- | GNU Affero General Public License or the licensing of CiviCRM,     |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
- +--------------------------------------------------------------------+
- */
-
-/**
- *
- * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2019
- */
-
-/**
- * Business object for managing price sets.
- */
-class CRM_Upgrade_Snapshot_V4p2_Price_BAO_Set extends CRM_Upgrade_Snapshot_V4p2_Price_DAO_Set {
-
-  /**
-   * Class constructor.
-   */
-  public function __construct() {
-    parent::__construct();
-  }
-
-  /**
-   * Takes an associative array and creates a price set object.
-   *
-   * @param array $params
-   *   (reference) an assoc array of name/value pairs.
-   *
-   * @return CRM_Upgrade_Snapshot_V4p2_Price_DAO_Set
-   */
-  public static function create(&$params) {
-    $priceSetBAO = new CRM_Upgrade_Snapshot_V4p2_Price_BAO_Set();
-    $priceSetBAO->copyValues($params);
-    if (self::eventPriceSetDomainID()) {
-      $priceSetBAO->domain_id = CRM_Core_Config::domainID();
-    }
-    return $priceSetBAO->save();
-  }
-
-  /**
-   * Fetch object based on array of properties.
-   *
-   * @param array $params
-   *   (reference ) an assoc array of name/value pairs.
-   * @param array $defaults
-   *   (reference ) an assoc array to hold the flattened values.
-   *
-   * @return CRM_Upgrade_Snapshot_V4p2_Price_DAO_Set
-   */
-  public static function retrieve(&$params, &$defaults) {
-    return CRM_Core_DAO::commonRetrieve('CRM_Upgrade_Snapshot_V4p2_Price_DAO_Set', $params, $defaults);
-  }
-
-  /**
-   * Update the is_active flag in the db.
-   *
-   * @param int $id
-   *   Id of the database record.
-   * @param bool $isActive
-   *   Value we want to set the is_active field.
-   *
-   * @return bool
-   *   true if we found and updated the object, else false
-   */
-  public static function setIsActive($id, $isActive) {
-    return CRM_Core_DAO::setFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_DAO_Set', $id, 'is_active', $isActive);
-  }
-
-  /**
-   * Calculate the default price set id assigned to the contribution/membership etc.
-   *
-   * @param string $entity
-   *
-   * @return int
-   *   priceSetID
-   */
-  public static function getDefaultPriceSet($entity = 'contribution') {
-    if ($entity == 'contribution') {
-      $entityName = 'default_contribution_amount';
-    }
-    elseif ($entity == 'membership') {
-      $entityName = 'default_membership_type_amount';
-    }
-
-    $sql = "
-SELECT      ps.id AS setID, pfv.price_field_id AS priceFieldID, pfv.id AS priceFieldValueID, pfv.name, pfv.label
-FROM        civicrm_price_set ps
-LEFT JOIN   civicrm_price_field pf ON pf.`price_set_id` = ps.id
-LEFT JOIN   civicrm_price_field_value pfv ON pfv.price_field_id = pf.id
-WHERE       ps.name = '{$entityName}'
-";
-
-    $dao = CRM_Core_DAO::executeQuery($sql);
-    $defaultPriceSet = array();
-    while ($dao->fetch()) {
-      $defaultPriceSet[$dao->priceFieldValueID]['setID'] = $dao->setID;
-      $defaultPriceSet[$dao->priceFieldValueID]['priceFieldID'] = $dao->priceFieldID;
-      $defaultPriceSet[$dao->priceFieldValueID]['name'] = $dao->name;
-      $defaultPriceSet[$dao->priceFieldValueID]['label'] = $dao->label;
-    }
-
-    return $defaultPriceSet;
-  }
-
-  /**
-   * Get the price set title.
-   *
-   * @param int $id
-   *   Id of price set.
-   *
-   * @return string
-   *   title
-   */
-  public static function getTitle($id) {
-    return CRM_Core_DAO::getFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_DAO_Set', $id, 'title');
-  }
-
-  /**
-   * Return a list of all forms which use this price set.
-   *
-   * @param int $id
-   *   Id of price set.
-   * @param bool|\str $simpleReturn - get raw data. Possible values: 'entity', 'table'
-   *
-   * @return array
-   */
-  public static function &getUsedBy($id, $simpleReturn = FALSE) {
-    $usedBy = $forms = $tables = array();
-    $queryString = "
-SELECT   entity_table, entity_id
-FROM     civicrm_price_set_entity
-WHERE    price_set_id = %1";
-    $params = array(1 => array($id, 'Integer'));
-    $crmFormDAO = CRM_Core_DAO::executeQuery($queryString, $params);
-
-    while ($crmFormDAO->fetch()) {
-      $forms[$crmFormDAO->entity_table][] = $crmFormDAO->entity_id;
-      $tables[] = $crmFormDAO->entity_table;
-    }
-    // Return only tables
-    if ($simpleReturn == 'table') {
-      return $tables;
-    }
-    if (empty($forms)) {
-      $queryString = "
-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'));
-      $crmFormDAO = CRM_Core_DAO::executeQuery($queryString, $params);
-      while ($crmFormDAO->fetch()) {
-        $forms[$crmFormDAO->entity_table][] = $crmFormDAO->entity_id;
-        $tables[] = $crmFormDAO->entity_table;
-      }
-      if (empty($forms)) {
-        return $usedBy;
-      }
-    }
-    // Return only entity data
-    if ($simpleReturn == 'entity') {
-      return $forms;
-    }
-    foreach ($forms as $table => $entities) {
-      switch ($table) {
-        case 'civicrm_event':
-          $ids = implode(',', $entities);
-          $queryString = "SELECT ce.id as id, ce.title as title, ce.is_public as isPublic, ce.start_date as startDate, ce.end_date as endDate, civicrm_option_value.label as eventType
-FROM       civicrm_event ce
-LEFT JOIN  civicrm_option_value ON
-           ( ce.event_type_id = civicrm_option_value.value )
-LEFT JOIN  civicrm_option_group ON
-           ( civicrm_option_group.id = civicrm_option_value.option_group_id )
-WHERE
-         civicrm_option_group.name = 'event_type' AND
-           ( ce.is_template IS NULL OR ce.is_template = 0) AND
-           ce.id IN ($ids) AND
-           ce.is_active = 1;";
-          $crmDAO = CRM_Core_DAO::executeQuery($queryString);
-          while ($crmDAO->fetch()) {
-            $usedBy[$table][$crmDAO->id]['title'] = $crmDAO->title;
-            $usedBy[$table][$crmDAO->id]['eventType'] = $crmDAO->eventType;
-            $usedBy[$table][$crmDAO->id]['startDate'] = $crmDAO->startDate;
-            $usedBy[$table][$crmDAO->id]['endDate'] = $crmDAO->endDate;
-            $usedBy[$table][$crmDAO->id]['isPublic'] = $crmDAO->isPublic;
-          }
-          break;
-
-        case 'civicrm_contribution_page':
-          $ids = implode(',', $entities);
-          $queryString = "SELECT cp.id as id, cp.title as title, cp.start_date as startDate, cp.end_date as endDate,ct.name as type
-FROM      civicrm_contribution_page cp, civicrm_contribution_type ct
-WHERE     ct.id = cp.contribution_type_id AND
-          cp.id IN ($ids) AND
-          cp.is_active = 1;";
-          $crmDAO = CRM_Core_DAO::executeQuery($queryString);
-          while ($crmDAO->fetch()) {
-            $usedBy[$table][$crmDAO->id]['title'] = $crmDAO->title;
-            $usedBy[$table][$crmDAO->id]['type'] = $crmDAO->type;
-            $usedBy[$table][$crmDAO->id]['startDate'] = $crmDAO->startDate;
-            $usedBy[$table][$crmDAO->id]['endDate'] = $crmDAO->endDate;
-          }
-          break;
-
-        case 'civicrm_contribution':
-        case 'civicrm_membership':
-        case 'civicrm_participant':
-          $usedBy[$table] = 1;
-          break;
-
-        default:
-          CRM_Core_Error::fatal("$table is not supported in PriceSet::usedBy()");
-          break;
-      }
-    }
-
-    return $usedBy;
-  }
-
-  /**
-   * Delete the price set.
-   *
-   * @param int $id
-   *   Price Set id.
-   *
-   * @return bool
-   *   false if fields exist for this set, true if the
-   *   set could be deleted
-   */
-  public static function deleteSet($id) {
-    // remove from all inactive forms
-    $usedBy = self::getUsedBy($id);
-    if (isset($usedBy['civicrm_event'])) {
-      foreach ($usedBy['civicrm_event'] as $eventId => $unused) {
-        $eventDAO = new CRM_Event_DAO_Event();
-        $eventDAO->id = $eventId;
-        $eventDAO->find();
-        while ($eventDAO->fetch()) {
-          self::removeFrom('civicrm_event', $eventDAO->id);
-        }
-      }
-    }
-
-    // delete price fields
-    $priceField = new CRM_Upgrade_Snapshot_V4p2_Price_DAO_Field();
-    $priceField->price_set_id = $id;
-    $priceField->find();
-    while ($priceField->fetch()) {
-      // delete options first
-      CRM_Upgrade_Snapshot_V4p2_Price_BAO_Field::deleteField($priceField->id);
-    }
-
-    $set = new CRM_Upgrade_Snapshot_V4p2_Price_DAO_Set();
-    $set->id = $id;
-    return $set->delete();
-  }
-
-  /**
-   * Link the price set with the specified table and id.
-   *
-   * @param string $entityTable
-   * @param int $entityId
-   * @param int $priceSetId
-   *
-   * @return bool
-   */
-  public static function addTo($entityTable, $entityId, $priceSetId) {
-    // verify that the price set exists
-    $dao = new CRM_Upgrade_Snapshot_V4p2_Price_DAO_Set();
-    $dao->id = $priceSetId;
-    if (!$dao->find()) {
-      return FALSE;
-    }
-    unset($dao);
-
-    $dao = new CRM_Upgrade_Snapshot_V4p2_Price_DAO_SetEntity();
-    // find if this already exists
-    $dao->entity_id = $entityId;
-    $dao->entity_table = $entityTable;
-    $dao->find(TRUE);
-
-    // add or update price_set_id
-    $dao->price_set_id = $priceSetId;
-    return $dao->save();
-  }
-
-  /**
-   * Delete price set for the given entity and id.
-   *
-   * @param string $entityTable
-   * @param int $entityId
-   *
-   * @return mixed
-   */
-  public static function removeFrom($entityTable, $entityId) {
-    $dao = new CRM_Upgrade_Snapshot_V4p2_Price_DAO_SetEntity();
-    $dao->entity_table = $entityTable;
-    $dao->entity_id = $entityId;
-    return $dao->delete();
-  }
-
-  /**
-   * Find a price_set_id associated with the given details.
-   *
-   * Used For value for events:1, contribution:2, membership:3
-   *
-   * @param string $entityTable
-   * @param int $entityId
-   * @param int $usedFor
-   *   ( price set that extends/used for particular component ).
-   *
-   * @param null $isQuickConfig
-   * @param null $setName
-   *
-   * @return int|false
-   *   price_set_id, or false if none found
-   */
-  public static function getFor($entityTable, $entityId, $usedFor = NULL, $isQuickConfig = NULL, &$setName = NULL) {
-    if (!$entityTable || !$entityId) {
-      return FALSE;
-    }
-
-    $sql = 'SELECT ps.id as price_set_id, ps.name as price_set_name
-                FROM civicrm_price_set ps
-                INNER JOIN civicrm_price_set_entity pse ON ps.id = pse.price_set_id
-                WHERE pse.entity_table = %1 AND pse.entity_id = %2 ';
-    if ($isQuickConfig) {
-      $sql .= " AND ps.is_quick_config = 0 ";
-    }
-    $params = array(
-      1 => array($entityTable, 'String'),
-      2 => array($entityId, 'Integer'),
-    );
-    if ($usedFor) {
-      $sql .= " AND ps.extends LIKE '%%3%' ";
-      $params[3] = array($usedFor, 'Integer');
-    }
-
-    $dao = CRM_Core_DAO::executeQuery($sql, $params);
-    $dao->fetch();
-    $setName = (isset($dao->price_set_name)) ? $dao->price_set_name : FALSE;
-    return (isset($dao->price_set_id)) ? $dao->price_set_id : FALSE;
-  }
-
-  /**
-   * Find a price_set_id associatied with the given option value or  field ID.
-   *
-   * @param array $params
-   *   (reference) an assoc array of name/value pairs.
-   *   array may contain either option id or
-   *   price field id
-   *
-   * @return int|null
-   *   price set id on success, null otherwise
-   */
-  public static function getSetId(&$params) {
-    $fid = NULL;
-
-    if ($oid = CRM_Utils_Array::value('oid', $params)) {
-      $fieldValue = new CRM_Upgrade_Snapshot_V4p2_Price_DAO_FieldValue();
-      $fieldValue->id = $oid;
-      if ($fieldValue->find(TRUE)) {
-        $fid = $fieldValue->price_field_id;
-      }
-    }
-    else {
-      $fid = CRM_Utils_Array::value('fid', $params);
-    }
-
-    if (isset($fid)) {
-      return CRM_Core_DAO::getFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_DAO_Field', $fid, 'price_set_id');
-    }
-
-    return NULL;
-  }
-
-  /**
-   * Return an associative array of all price sets.
-   *
-   * @param bool $withInactive
-   *   Whether or not to include inactive entries.
-   * @param bool|string $extendComponentName name of the component like 'CiviEvent','CiviContribute'
-   *
-   * @return array
-   *   associative array of id => name
-   */
-  public static function getAssoc($withInactive = FALSE, $extendComponentName = FALSE) {
-    $query = "
-    SELECT
-       DISTINCT ( price_set_id ) as id, title
-    FROM
-       civicrm_price_field,
-       civicrm_price_set
-    WHERE
-       civicrm_price_set.id = civicrm_price_field.price_set_id  AND is_quick_config = 0 ";
-
-    if (!$withInactive) {
-      $query .= " AND civicrm_price_set.is_active = 1 ";
-    }
-
-    if (self::eventPriceSetDomainID()) {
-      $query .= " AND civicrm_price_set.domain_id = " . CRM_Core_Config::domainID();
-    }
-
-    $priceSets = array();
-
-    if ($extendComponentName) {
-      $componentId = CRM_Core_Component::getComponentID($extendComponentName);
-      if (!$componentId) {
-        return $priceSets;
-      }
-      $query .= " AND civicrm_price_set.extends LIKE '%$componentId%' ";
-    }
-
-    $dao = CRM_Core_DAO::executeQuery($query);
-    while ($dao->fetch()) {
-      $priceSets[$dao->id] = $dao->title;
-    }
-    return $priceSets;
-  }
-
-  /**
-   * Get price set details.
-   *
-   * An array containing price set details (including price fields) is returned
-   *
-   * @param int $setID
-   *   Price set id whose details are needed.
-   * @param bool $required
-   * @param bool $validOnly
-   *
-   * @return array
-   *   array consisting of field details
-   */
-  public static function getSetDetail($setID, $required = TRUE, $validOnly = FALSE) {
-    // create a new tree
-    $setTree = array();
-    $select = $from = $where = $orderBy = '';
-
-    $priceFields = array(
-      'id',
-      'name',
-      'label',
-      'html_type',
-      'is_enter_qty',
-      'help_pre',
-      'help_post',
-      'weight',
-      'is_display_amounts',
-      'options_per_line',
-      'is_active',
-      'active_on',
-      'expire_on',
-      'javascript',
-      'visibility_id',
-      'is_required',
-    );
-    if ($required == TRUE) {
-      $priceFields[] = 'is_required';
-    }
-
-    // create select
-    $select = 'SELECT ' . implode(',', $priceFields);
-    $from = ' FROM civicrm_price_field';
-
-    $params = array();
-    $params[1] = array($setID, 'Integer');
-    $where = '
-WHERE price_set_id = %1
-AND is_active = 1
-';
-    $dateSelect = '';
-    if ($validOnly) {
-      $currentTime = date('YmdHis');
-      $dateSelect = "
-AND ( active_on IS NULL OR active_on <= {$currentTime} )
-AND ( expire_on IS NULL OR expire_on >= {$currentTime} )
-";
-    }
-
-    $orderBy = ' ORDER BY weight';
-
-    $sql = $select . $from . $where . $dateSelect . $orderBy;
-
-    $dao = CRM_Core_DAO::executeQuery($sql, $params);
-
-    $visibility = CRM_Core_PseudoConstant::visibility('name');
-    while ($dao->fetch()) {
-      $fieldID = $dao->id;
-
-      $setTree[$setID]['fields'][$fieldID] = array();
-      $setTree[$setID]['fields'][$fieldID]['id'] = $fieldID;
-
-      foreach ($priceFields as $field) {
-        if ($field == 'id' || is_null($dao->$field)) {
-          continue;
-        }
-
-        if ($field == 'visibility_id') {
-          $setTree[$setID]['fields'][$fieldID]['visibility'] = $visibility[$dao->$field];
-        }
-        $setTree[$setID]['fields'][$fieldID][$field] = $dao->$field;
-      }
-      $setTree[$setID]['fields'][$fieldID]['options'] = CRM_Upgrade_Snapshot_V4p2_Price_BAO_Field::getOptions($fieldID, FALSE);
-    }
-
-    // also get the pre and post help from this price set
-    $sql = "
-SELECT extends, contribution_type_id, help_pre, help_post, is_quick_config
-FROM   civicrm_price_set
-WHERE  id = %1";
-    $dao = CRM_Core_DAO::executeQuery($sql, $params);
-    if ($dao->fetch()) {
-      $setTree[$setID]['extends'] = $dao->extends;
-      $setTree[$setID]['contribution_type_id'] = $dao->contribution_type_id;
-      $setTree[$setID]['help_pre'] = $dao->help_pre;
-      $setTree[$setID]['help_post'] = $dao->help_post;
-      $setTree[$setID]['is_quick_config'] = $dao->is_quick_config;
-    }
-    return $setTree;
-  }
-
-  /**
-   * Initialise set.
-   *
-   * @param CRM_Core_Form $form
-   * @param int $id
-   * @param string $entityTable
-   * @param bool $validOnly
-   * @param int $priceSetId
-   *
-   * @return bool|false|int|null
-   */
-  public static function initSet(&$form, $id, $entityTable = 'civicrm_event', $validOnly = FALSE, $priceSetId = NULL) {
-    if (!$priceSetId) {
-      $priceSetId = self::getFor($entityTable, $id);
-    }
-
-    //check if priceset is is_config
-    if (is_numeric($priceSetId)) {
-      if (CRM_Core_DAO::getFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_DAO_Set', $priceSetId, 'is_quick_config') && $form->getVar('_name') != 'Participant') {
-        $form->assign('quickConfig', 1);
-      }
-    }
-    // get price info
-    if ($priceSetId) {
-      if ($form->_action & CRM_Core_Action::UPDATE) {
-        $entityId = $entity = NULL;
-
-        switch ($entityTable) {
-          case 'civicrm_event':
-            $entity = 'participant';
-            if (CRM_Utils_System::getClassName($form) == 'CRM_Event_Form_Participant') {
-              $entityId = $form->_id;
-            }
-            else {
-              $entityId = $form->_participantId;
-            }
-            break;
-
-          case 'civicrm_contribution_page':
-          case 'civicrm_contribution':
-            $entity = 'contribution';
-            $entityId = $form->_id;
-            break;
-        }
-
-        if ($entityId && $entity) {
-          $form->_values['line_items'] = CRM_Upgrade_Snapshot_V4p2_Price_BAO_LineItem::getLineItems($entityId, $entity);
-        }
-        $required = FALSE;
-      }
-      else {
-        $required = TRUE;
-      }
-
-      $form->_priceSetId = $priceSetId;
-      $priceSet = self::getSetDetail($priceSetId, $required, $validOnly);
-      $form->_priceSet = CRM_Utils_Array::value($priceSetId, $priceSet);
-      $form->_values['fee'] = CRM_Utils_Array::value('fields', $form->_priceSet);
-
-      //get the price set fields participant count.
-      if ($entityTable == 'civicrm_event') {
-        //get option count info.
-        $form->_priceSet['optionsCountTotal'] = self::getPricesetCount($priceSetId);
-        if ($form->_priceSet['optionsCountTotal']) {
-          $optionsCountDeails = array();
-          if (!empty($form->_priceSet['fields'])) {
-            foreach ($form->_priceSet['fields'] as $field) {
-              foreach ($field['options'] as $option) {
-                $count = CRM_Utils_Array::value('count', $option, 0);
-                $optionsCountDeails['fields'][$field['id']]['options'][$option['id']] = $count;
-              }
-            }
-          }
-          $form->_priceSet['optionsCountDetails'] = $optionsCountDeails;
-        }
-
-        //get option max value info.
-        $optionsMaxValueTotal = 0;
-        $optionsMaxValueDetails = array();
-
-        if (!empty($form->_priceSet['fields'])) {
-          foreach ($form->_priceSet['fields'] as $field) {
-            foreach ($field['options'] as $option) {
-              $maxVal = CRM_Utils_Array::value('max_value', $option, 0);
-              $optionsMaxValueDetails['fields'][$field['id']]['options'][$option['id']] = $maxVal;
-              $optionsMaxValueTotal += $maxVal;
-            }
-          }
-        }
-
-        $form->_priceSet['optionsMaxValueTotal'] = $optionsMaxValueTotal;
-        if ($optionsMaxValueTotal) {
-          $form->_priceSet['optionsMaxValueDetails'] = $optionsMaxValueDetails;
-        }
-      }
-      $form->set('priceSetId', $form->_priceSetId);
-      $form->set('priceSet', $form->_priceSet);
-
-      return $priceSetId;
-    }
-    return FALSE;
-  }
-
-  /**
-   * Process amount.
-   *
-   * @param array $fields
-   * @param array $params
-   * @param array $lineItem
-   */
-  public static function processAmount(&$fields, &$params, &$lineItem) {
-    // using price set
-    $totalPrice = 0;
-    $radioLevel = $checkboxLevel = $selectLevel = $textLevel = array();
-
-    foreach ($fields as $id => $field) {
-      if (empty($params["price_{$id}"]) ||
-        (empty($params["price_{$id}"]) && $params["price_{$id}"] == NULL)
-      ) {
-        // skip if nothing was submitted for this field
-        continue;
-      }
-
-      switch ($field['html_type']) {
-        case 'Text':
-          $params["price_{$id}"] = array(key($field['options']) => $params["price_{$id}"]);
-          CRM_Upgrade_Snapshot_V4p2_Price_BAO_LineItem::format($id, $params, $field, $lineItem);
-          $totalPrice += $lineItem[key($field['options'])]['line_total'];
-          break;
-
-        case 'Radio':
-          //special case if user select -none-
-          if ($params["price_{$id}"] <= 0) {
-            continue;
-          }
-          $params["price_{$id}"] = array($params["price_{$id}"] => 1);
-          $optionValueId = CRM_Utils_Array::key(1, $params["price_{$id}"]);
-          $optionLabel = CRM_Utils_Array::value('label', $field['options'][$optionValueId]);
-          $params['amount_priceset_level_radio'] = array();
-          $params['amount_priceset_level_radio'][$optionValueId] = $optionLabel;
-          if (isset($radioLevel)) {
-            $radioLevel = array_merge($radioLevel,
-              array_keys($params['amount_priceset_level_radio'])
-            );
-          }
-          else {
-            $radioLevel = array_keys($params['amount_priceset_level_radio']);
-          }
-          CRM_Upgrade_Snapshot_V4p2_Price_BAO_LineItem::format($id, $params, $field, $lineItem);
-          $totalPrice += $lineItem[$optionValueId]['line_total'];
-          break;
-
-        case 'Select':
-          $params["price_{$id}"] = array($params["price_{$id}"] => 1);
-          $optionValueId = CRM_Utils_Array::key(1, $params["price_{$id}"]);
-          $optionLabel = $field['options'][$optionValueId]['label'];
-          $params['amount_priceset_level_select'] = array();
-          $params['amount_priceset_level_select'][CRM_Utils_Array::key(1, $params["price_{$id}"])] = $optionLabel;
-          if (isset($selectLevel)) {
-            $selectLevel = array_merge($selectLevel, array_keys($params['amount_priceset_level_select']));
-          }
-          else {
-            $selectLevel = array_keys($params['amount_priceset_level_select']);
-          }
-          CRM_Upgrade_Snapshot_V4p2_Price_BAO_LineItem::format($id, $params, $field, $lineItem);
-          $totalPrice += $lineItem[$optionValueId]['line_total'];
-          break;
-
-        case 'CheckBox':
-          $params['amount_priceset_level_checkbox'] = $optionIds = array();
-          foreach ($params["price_{$id}"] as $optionId => $option) {
-            $optionIds[] = $optionId;
-            $optionLabel = $field['options'][$optionId]['label'];
-            $params['amount_priceset_level_checkbox']["{$field['options'][$optionId]['id']}"] = $optionLabel;
-            if (isset($checkboxLevel)) {
-              $checkboxLevel = array_unique(array_merge(
-                  $checkboxLevel,
-                  array_keys($params['amount_priceset_level_checkbox'])
-                )
-              );
-            }
-            else {
-              $checkboxLevel = array_keys($params['amount_priceset_level_checkbox']);
-            }
-          }
-          CRM_Upgrade_Snapshot_V4p2_Price_BAO_LineItem::format($id, $params, $field, $lineItem);
-          foreach ($optionIds as $optionId) {
-            $totalPrice += $lineItem[$optionId]['line_total'];
-          }
-          break;
-      }
-    }
-
-    $amount_level = array();
-    $totalParticipant = 0;
-    if (is_array($lineItem)) {
-      foreach ($lineItem as $values) {
-        $totalParticipant += $values['participant_count'];
-        if ($values['html_type'] == 'Text') {
-          $amount_level[] = $values['label'] . ' - ' . $values['qty'];
-          continue;
-        }
-        $amount_level[] = $values['label'];
-      }
-    }
-
-    $displayParticipantCount = '';
-    if ($totalParticipant > 0) {
-      $displayParticipantCount = ' Participant Count -' . $totalParticipant;
-    }
-
-    $params['amount_level'] = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR, $amount_level) . $displayParticipantCount . CRM_Core_DAO::VALUE_SEPARATOR;
-    $params['amount'] = $totalPrice;
-  }
-
-  /**
-   * Build the price set form.
-   *
-   * @param CRM_Core_Form $form
-   */
-  public static function buildPriceSet(&$form) {
-    $priceSetId = $form->get('priceSetId');
-    $userid = $form->getVar('_userID');
-    if (!$priceSetId) {
-      return;
-    }
-
-    $validFieldsOnly = TRUE;
-    $className = CRM_Utils_System::getClassName($form);
-    if (in_array($className, array(
-      'CRM_Contribute_Form_Contribution',
-      'CRM_Member_Form_Membership',
-    ))) {
-      $validFieldsOnly = FALSE;
-    }
-
-    $priceSet = self::getSetDetail($priceSetId, TRUE, $validFieldsOnly);
-    $form->_priceSet = CRM_Utils_Array::value($priceSetId, $priceSet);
-    $form->_quickConfig = $quickConfig = 0;
-    if (CRM_Core_DAO::getFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_DAO_Set', $priceSetId, 'is_quick_config')) {
-      $quickConfig = 1;
-    }
-
-    $form->assign('quickConfig', $quickConfig);
-    if ($className == "CRM_Contribute_Form_Contribution_Main") {
-      $form->_quickConfig = $quickConfig;
-    }
-    $form->assign('priceSet', $form->_priceSet);
-
-    $component = 'contribution';
-    if ($className == 'CRM_Member_Form_Membership') {
-      $component = 'membership';
-    }
-
-    if ($className == 'CRM_Contribute_Form_Contribution_Main') {
-      $feeBlock = &$form->_values['fee'];
-      if (!empty($form->_useForMember)) {
-        $component = 'membership';
-      }
-    }
-    else {
-      $feeBlock = &$form->_priceSet['fields'];
-    }
-
-    // call the hook.
-    CRM_Utils_Hook::buildAmount($component, $form, $feeBlock);
-
-    foreach ($feeBlock as $field) {
-      if (CRM_Utils_Array::value('visibility', $field) == 'public' ||
-        !$validFieldsOnly
-      ) {
-        $options = CRM_Utils_Array::value('options', $field);
-        if ($className == 'CRM_Contribute_Form_Contribution_Main' && $component = 'membership') {
-          $checklifetime = self::checkCurrentMembership($options, $userid);
-          if ($checklifetime) {
-            $form->assign('ispricelifetime', TRUE);
-          }
-        }
-        if (!is_array($options)) {
-          continue;
-        }
-        CRM_Upgrade_Snapshot_V4p2_Price_BAO_Field::addQuickFormElement($form,
-          'price_' . $field['id'],
-          $field['id'],
-          FALSE,
-          CRM_Utils_Array::value('is_required', $field, FALSE),
-          NULL,
-          $options
-        );
-      }
-    }
-  }
-
-  /**
-   * Check the current Membership.
-   *
-   * @param array $options
-   * @param int $userid
-   *
-   * @return bool
-   */
-  public static function checkCurrentMembership(&$options, $userid) {
-    if (!$userid || empty($options)) {
-      return FALSE;
-    }
-    static $_contact_memberships = array();
-    $checklifetime = FALSE;
-    foreach ($options as $key => $value) {
-      if (!empty($value['membership_type_id'])) {
-        if (!isset($_contact_memberships[$userid][$value['membership_type_id']])) {
-          $_contact_memberships[$userid][$value['membership_type_id']] = CRM_Member_BAO_Membership::getContactMembership($userid, $value['membership_type_id'], FALSE);
-        }
-        $currentMembership = $_contact_memberships[$userid][$value['membership_type_id']];
-        if (!empty($currentMembership) && empty($currentMembership['end_date'])) {
-          unset($options[$key]);
-          $checklifetime = TRUE;
-        }
-      }
-    }
-    if ($checklifetime) {
-      return TRUE;
-    }
-    else {
-      return FALSE;
-    }
-  }
-
-  /**
-   * Set default the price set fields.
-   *
-   * @param CRM_Core_Form $form
-   * @param array $defaults
-   *
-   * @return array
-   */
-  public static function setDefaultPriceSet(&$form, &$defaults) {
-    if (!isset($form->_priceSet) || empty($form->_priceSet['fields'])) {
-      return $defaults;
-    }
-
-    foreach ($form->_priceSet['fields'] as $key => $val) {
-      foreach ($val['options'] as $keys => $values) {
-        if ($values['is_default']) {
-          if ($val['html_type'] == 'CheckBox') {
-            $defaults["price_{$key}"][$keys] = 1;
-          }
-          else {
-            $defaults["price_{$key}"] = $keys;
-          }
-        }
-      }
-    }
-    return $defaults;
-  }
-
-  /**
-   * Get field ids of a price set.
-   *
-   * @param int $id Price Set id
-   *
-   * @return array
-   *   Array of the field ids
-   */
-  public static function getFieldIds($id) {
-    $priceField = new CRM_Upgrade_Snapshot_V4p2_Price_DAO_Field();
-    $priceField->price_set_id = $id;
-    $priceField->find();
-    while ($priceField->fetch()) {
-      $var[] = $priceField->id;
-    }
-    return $var;
-  }
-
-  /**
-   * Copy a price set, including all the fields.
-   *
-   * @param int $id
-   *   The price set id to copy.
-   *
-   * @return CRM_Upgrade_Snapshot_V4p2_Price_DAO_Field
-   */
-  public static function copy($id) {
-    $maxId = CRM_Core_DAO::singleValueQuery("SELECT max(id) FROM civicrm_price_set");
-
-    $title = ts('[Copy id %1]', array(1 => $maxId + 1));
-    $fieldsFix = array(
-      'suffix' => array(
-        'title' => ' ' . $title,
-        'name' => '__Copy_id_' . ($maxId + 1) . '_',
-      ),
-    );
-
-    $copy = &CRM_Core_DAO::copyGeneric('CRM_Upgrade_Snapshot_V4p2_Price_DAO_Set',
-      array('id' => $id),
-      NULL,
-      $fieldsFix
-    );
-
-    //copying all the blocks pertaining to the price set
-    $copyPriceField = &CRM_Core_DAO::copyGeneric('CRM_Upgrade_Snapshot_V4p2_Price_DAO_Field',
-      array('price_set_id' => $id),
-      array('price_set_id' => $copy->id)
-    );
-    if (!empty($copyPriceField)) {
-      $price = array_combine(self::getFieldIds($id), self::getFieldIds($copy->id));
-
-      //copy option group and values
-      foreach ($price as $originalId => $copyId) {
-        CRM_Core_DAO::copyGeneric('CRM_Upgrade_Snapshot_V4p2_Price_DAO_FieldValue',
-          array('price_field_id' => $originalId),
-          array('price_field_id' => $copyId)
-        );
-      }
-    }
-    $copy->save();
-
-    CRM_Utils_Hook::copy('Set', $copy);
-    return $copy;
-  }
-
-  /**
-   * Check price set permission.
-   *
-   * @param int $sid
-   *   The price set id.
-   *
-   * @return bool
-   */
-  public function checkPermission($sid) {
-    if ($sid &&
-      self::eventPriceSetDomainID()
-    ) {
-      $domain_id = CRM_Core_DAO::getFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_DAO_Set', $sid, 'domain_id', 'id');
-      if (CRM_Core_Config::domainID() != $domain_id) {
-        CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
-      }
-    }
-    return TRUE;
-  }
-
-  /**
-   * Get the sum of participant count for all fields of given price set.
-   *
-   * @param int $sid
-   *   The price set id.
-   *
-   * @param bool $onlyActive
-   *
-   * @return int|null|string
-   */
-  public static function getPricesetCount($sid, $onlyActive = TRUE) {
-    $count = 0;
-    if (!$sid) {
-      return $count;
-    }
-
-    $where = NULL;
-    if ($onlyActive) {
-      $where = 'AND  value.is_active = 1 AND field.is_active = 1';
-    }
-
-    static $pricesetFieldCount;
-    if (!isset($pricesetFieldCount[$sid])) {
-      $sql = "
-    SELECT  sum(value.count) as totalCount
-      FROM  civicrm_price_field_value  value
-INNER JOIN  civicrm_price_field field ON ( field.id = value.price_field_id )
-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')));
-      $pricesetFieldCount[$sid] = ($count) ? $count : 0;
-    }
-
-    return $pricesetFieldCount[$sid];
-  }
-
-  /**
-   * Get membership count.
-   *
-   * @param array $ids
-   *
-   * @return array
-   */
-  public static function getMembershipCount($ids) {
-    $queryString = "
-SELECT       count( pfv.id ) AS count, pfv.id AS id
-FROM         civicrm_price_field_value pfv
-INNER JOIN    civicrm_membership_type mt ON mt.id = pfv.membership_type_id
-WHERE        pfv.id IN ( $ids )
-GROUP BY     mt.member_of_contact_id";
-
-    $crmDAO = CRM_Core_DAO::executeQuery($queryString);
-    $count = array();
-
-    while ($crmDAO->fetch()) {
-      $count[$crmDAO->id] = $crmDAO->count;
-    }
-
-    return $count;
-  }
-
-  /**
-   * Function to check if auto renew option should be shown.
-   *
-   * @param int $priceSetId
-   *   Price set id.
-   *
-   * @return int
-   *   $autoRenewOption ( 0:hide, 1:optional 2:required )
-   */
-  public static function checkAutoRenewForPriceSet($priceSetId) {
-    // auto-renew option should be visible if membership types associated with all the fields has
-    // been set for auto-renew option
-    // Auto renew checkbox should be frozen if for all the membership type auto renew is required
-
-    // get the membership type auto renew option and check if required or optional
-    $query = 'SELECT mt.auto_renew, mt.duration_interval, mt.duration_unit
-            FROM civicrm_price_field_value pfv
-            INNER JOIN civicrm_membership_type mt ON pfv.membership_type_id = mt.id
-            INNER JOIN civicrm_price_field pf ON pfv.price_field_id = pf.id
-            WHERE pf.price_set_id = %1
-            AND   pf.is_active = 1
-            AND   pfv.is_active = 1';
-
-    $params = array(1 => array($priceSetId, 'Integer'));
-
-    $dao = CRM_Core_DAO::executeQuery($query, $params);
-    $autoRenewOption = 2;
-    $interval = $unit = array();
-    while ($dao->fetch()) {
-      if (!$dao->auto_renew) {
-        $autoRenewOption = 0;
-        break;
-      }
-      if ($dao->auto_renew == 1) {
-        $autoRenewOption = 1;
-      }
-
-      $interval[$dao->duration_interval] = $dao->duration_interval;
-      $unit[$dao->duration_unit] = $dao->duration_unit;
-    }
-
-    if (count($interval) == 1 && count($unit) == 1 && $autoRenewOption > 0) {
-      return $autoRenewOption;
-    }
-    else {
-      return 0;
-    }
-  }
-
-  /**
-   * Retrieve auto renew frequency and interval.
-   *
-   * @param int $priceSetId
-   *   Price set id.
-   *
-   * @return array
-   *   associate array of frequency interval and unit
-   */
-  public static function getRecurDetails($priceSetId) {
-    $query = 'SELECT mt.duration_interval, mt.duration_unit
-            FROM civicrm_price_field_value pfv
-            INNER JOIN civicrm_membership_type mt ON pfv.membership_type_id = mt.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'));
-    $dao = CRM_Core_DAO::executeQuery($query, $params);
-    $dao->fetch();
-    return array($dao->duration_interval, $dao->duration_unit);
-  }
-
-  /**
-   * Get event price set for domain.
-   *
-   * @return object
-   */
-  public static function eventPriceSetDomainID() {
-    return Civi::settings()->get('event_price_set_domain_id');
-  }
-
-  /**
-   * Update the is_quick_config flag in the db.
-   *
-   * @param int $id
-   *   Id of the database record.
-   * @param bool $isQuickConfig we want to set the is_quick_config field.
-   *   Value we want to set the is_quick_config field.
-   *
-   * @return bool
-   *   true if we found and updated the object, else false
-   */
-  public static function setIsQuickConfig($id, $isQuickConfig) {
-    return CRM_Core_DAO::setFieldValue('CRM_Upgrade_Snapshot_V4p2_Price_DAO_Set', $id, 'is_quick_config', $isQuickConfig);
-  }
-
-}
diff --git a/CRM/Upgrade/Snapshot/V4p2/Price/DAO/Field.php b/CRM/Upgrade/Snapshot/V4p2/Price/DAO/Field.php
deleted file mode 100644 (file)
index 120c4bd..0000000
+++ /dev/null
@@ -1,444 +0,0 @@
-<?php
-/*
-+--------------------------------------------------------------------+
-| CiviCRM version 5                                                  |
-+--------------------------------------------------------------------+
-| Copyright CiviCRM LLC (c) 2004-2019                                |
-+--------------------------------------------------------------------+
-| This file is a part of CiviCRM.                                    |
-|                                                                    |
-| CiviCRM is free software; you can copy, modify, and distribute it  |
-| under the terms of the GNU Affero General Public License           |
-| Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
-|                                                                    |
-| CiviCRM is distributed in the hope that it will be useful, but     |
-| WITHOUT ANY WARRANTY; without even the implied warranty of         |
-| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
-| See the GNU Affero General Public License for more details.        |
-|                                                                    |
-| You should have received a copy of the GNU Affero General Public   |
-| License and the CiviCRM Licensing Exception along                  |
-| with this program; if not, contact CiviCRM LLC                     |
-| at info[AT]civicrm[DOT]org. If you have questions about the        |
-| GNU Affero General Public License or the licensing of CiviCRM,     |
-| see the CiviCRM license FAQ at http://civicrm.org/licensing        |
-+--------------------------------------------------------------------+
- */
-/**
- *
- * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2019
- * $Id$
- *
- */
-require_once 'CRM/Core/DAO.php';
-require_once 'CRM/Utils/Type.php';
-
-/**
- * Class CRM_Upgrade_Snapshot_V4p2_Price_DAO_Field
- */
-class CRM_Upgrade_Snapshot_V4p2_Price_DAO_Field extends CRM_Core_DAO {
-  /**
-   * static instance to hold the table name
-   *
-   * @var string
-   */
-  static $_tableName = 'civicrm_price_field';
-  /**
-   * static instance to hold the field values
-   *
-   * @var array
-   */
-  static $_fields = NULL;
-  /**
-   * static instance to hold the FK relationships
-   *
-   * @var string
-   */
-  static $_links = NULL;
-  /**
-   * static instance to hold the values that can
-   * be imported
-   *
-   * @var array
-   */
-  static $_import = NULL;
-  /**
-   * static instance to hold the values that can
-   * be exported
-   *
-   * @var array
-   */
-  static $_export = NULL;
-  /**
-   * static value to see if we should log any modifications to
-   * this table in the civicrm_log table
-   *
-   * @var bool
-   */
-  static $_log = TRUE;
-  /**
-   * Price Field
-   *
-   * @var int unsigned
-   */
-  public $id;
-  /**
-   * FK to civicrm_price_set
-   *
-   * @var int unsigned
-   */
-  public $price_set_id;
-  /**
-   * Variable name/programmatic handle for this field.
-   *
-   * @var string
-   */
-  public $name;
-  /**
-   * Text for form field label (also friendly name for administering this field).
-   *
-   * @var string
-   */
-  public $label;
-  /**
-   *
-   * @var enum('Text', 'Select', 'Radio', 'CheckBox')
-   */
-  public $html_type;
-  /**
-   * Enter a quantity for this field?
-   *
-   * @var bool
-   */
-  public $is_enter_qty;
-  /**
-   * Description and/or help text to display before this field.
-   *
-   * @var text
-   */
-  public $help_pre;
-  /**
-   * Description and/or help text to display after this field.
-   *
-   * @var text
-   */
-  public $help_post;
-  /**
-   * Order in which the fields should appear
-   *
-   * @var int
-   */
-  public $weight;
-  /**
-   * Should the price be displayed next to the label for each option?
-   *
-   * @var boolean
-   */
-  public $is_display_amounts;
-  /**
-   * number of options per line for checkbox and radio
-   *
-   * @var int unsigned
-   */
-  public $options_per_line;
-  /**
-   * Is this price field active
-   *
-   * @var boolean
-   */
-  public $is_active;
-  /**
-   * Is this price field required (value must be > 1)
-   *
-   * @var boolean
-   */
-  public $is_required;
-  /**
-   * If non-zero, do not show this field before the date specified
-   *
-   * @var datetime
-   */
-  public $active_on;
-  /**
-   * If non-zero, do not show this field after the date specified
-   *
-   * @var datetime
-   */
-  public $expire_on;
-  /**
-   * Optional scripting attributes for field
-   *
-   * @var string
-   */
-  public $javascript;
-  /**
-   * Implicit FK to civicrm_option_group with name = \'visibility\'
-   *
-   * @var int unsigned
-   */
-  public $visibility_id;
-
-  /**
-   * Class constructor.
-   *
-   * @return \CRM_Upgrade_Snapshot_V4p2_Price_DAO_Field
-   */
-  public function __construct() {
-    $this->__table = 'civicrm_price_field';
-    parent::__construct();
-  }
-
-  /**
-   * Return foreign links.
-   *
-   * @return array
-   */
-  public function links() {
-    if (!(self::$_links)) {
-      self::$_links = array(
-        'price_set_id' => 'civicrm_price_set:id',
-      );
-    }
-    return self::$_links;
-  }
-
-  /**
-   * Returns all the column names of this table.
-   *
-   * @return array
-   */
-  public static function &fields() {
-    if (!(self::$_fields)) {
-      self::$_fields = array(
-        'id' => array(
-          'name' => 'id',
-          'type' => CRM_Utils_Type::T_INT,
-          'required' => TRUE,
-        ),
-        'price_set_id' => array(
-          'name' => 'price_set_id',
-          'type' => CRM_Utils_Type::T_INT,
-          'required' => TRUE,
-          'FKClassName' => 'Snapshot_v4p2_Price_DAO_Set',
-        ),
-        'name' => array(
-          'name' => 'name',
-          'type' => CRM_Utils_Type::T_STRING,
-          'title' => ts('Name'),
-          'required' => TRUE,
-          'maxlength' => 255,
-          'size' => CRM_Utils_Type::HUGE,
-        ),
-        'label' => array(
-          'name' => 'label',
-          'type' => CRM_Utils_Type::T_STRING,
-          'title' => ts('Label'),
-          'required' => TRUE,
-          'maxlength' => 255,
-          'size' => CRM_Utils_Type::HUGE,
-        ),
-        'html_type' => array(
-          'name' => 'html_type',
-          'type' => CRM_Utils_Type::T_ENUM,
-          'title' => ts('Html Type'),
-          'required' => TRUE,
-          'enumValues' => 'Text, Select, Radio, CheckBox',
-        ),
-        'is_enter_qty' => array(
-          'name' => 'is_enter_qty',
-          'type' => CRM_Utils_Type::T_BOOLEAN,
-        ),
-        'help_pre' => array(
-          'name' => 'help_pre',
-          'type' => CRM_Utils_Type::T_TEXT,
-          'title' => ts('Help Pre'),
-          'rows' => 4,
-          'cols' => 80,
-        ),
-        'help_post' => array(
-          'name' => 'help_post',
-          'type' => CRM_Utils_Type::T_TEXT,
-          'title' => ts('Help Post'),
-          'rows' => 4,
-          'cols' => 80,
-        ),
-        'weight' => array(
-          'name' => 'weight',
-          'type' => CRM_Utils_Type::T_INT,
-          'title' => ts('Weight'),
-          'default' => '',
-        ),
-        'is_display_amounts' => array(
-          'name' => 'is_display_amounts',
-          'type' => CRM_Utils_Type::T_BOOLEAN,
-          'default' => '',
-        ),
-        'options_per_line' => array(
-          'name' => 'options_per_line',
-          'type' => CRM_Utils_Type::T_INT,
-          'title' => ts('Options Per Line'),
-          'default' => '',
-        ),
-        'is_active' => array(
-          'name' => 'is_active',
-          'type' => CRM_Utils_Type::T_BOOLEAN,
-          'default' => '',
-        ),
-        'is_required' => array(
-          'name' => 'is_required',
-          'type' => CRM_Utils_Type::T_BOOLEAN,
-          'default' => '',
-        ),
-        'active_on' => array(
-          'name' => 'active_on',
-          'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
-          'title' => ts('Active On'),
-          'default' => 'UL',
-        ),
-        'expire_on' => array(
-          'name' => 'expire_on',
-          'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
-          'title' => ts('Expire On'),
-          'default' => 'UL',
-        ),
-        'javascript' => array(
-          'name' => 'javascript',
-          'type' => CRM_Utils_Type::T_STRING,
-          'title' => ts('Javascript'),
-          'maxlength' => 255,
-          'size' => CRM_Utils_Type::HUGE,
-        ),
-        'visibility_id' => array(
-          'name' => 'visibility_id',
-          'type' => CRM_Utils_Type::T_INT,
-          'default' => '',
-        ),
-      );
-    }
-    return self::$_fields;
-  }
-
-  /**
-   * returns the names of this table.
-   *
-   * @return string
-   */
-  public static function getTableName() {
-    return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
-  }
-
-  /**
-   * returns if this table needs to be logged.
-   *
-   * @return bool
-   */
-  public function getLog() {
-    return self::$_log;
-  }
-
-  /**
-   * returns the list of fields that can be imported.
-   *
-   * @param bool $prefix
-   *
-   * @return array
-   */
-  public static function &import($prefix = FALSE) {
-    if (!(self::$_import)) {
-      self::$_import = array();
-      $fields = self::fields();
-      foreach ($fields as $name => $field) {
-        if (!empty($field['import'])) {
-          if ($prefix) {
-            self::$_import['price_field'] = &$fields[$name];
-          }
-          else {
-            self::$_import[$name] = &$fields[$name];
-          }
-        }
-      }
-    }
-    return self::$_import;
-  }
-
-  /**
-   * Returns the list of fields that can be exported.
-   *
-   * @param bool $prefix
-   *
-   * @return array
-   */
-  public static function &export($prefix = FALSE) {
-    if (!(self::$_export)) {
-      self::$_export = array();
-      $fields = self::fields();
-      foreach ($fields as $name => $field) {
-        if (!empty($field['export'])) {
-          if ($prefix) {
-            self::$_export['price_field'] = &$fields[$name];
-          }
-          else {
-            self::$_export[$name] = &$fields[$name];
-          }
-        }
-      }
-    }
-    return self::$_export;
-  }
-
-  /**
-   * returns an array containing the enum fields of the civicrm_price_field table.
-   *
-   * @return array
-   *   (reference)  the array of enum fields
-   */
-  public static function &getEnums() {
-    static $enums = array(
-      'html_type',
-    );
-    return $enums;
-  }
-
-  /**
-   * returns a ts()-translated enum value for display purposes
-   *
-   * @param string $field
-   *   The enum field in question.
-   * @param string $value
-   *   The enum value up for translation.
-   *
-   * @return string
-   *   the display value of the enum
-   */
-  public static function tsEnum($field, $value) {
-    static $translations = NULL;
-    if (!$translations) {
-      $translations = array(
-        'html_type' => array(
-          'Text' => ts('Text'),
-          'Select' => ts('Select'),
-          'Radio' => ts('Radio'),
-          'CheckBox' => ts('CheckBox'),
-        ),
-      );
-    }
-    return $translations[$field][$value];
-  }
-
-  /**
-   * adds $value['foo_display'] for each $value['foo'] enum from civicrm_price_field
-   *
-   * @param array $values
-   *   (reference) the array up for enhancing.
-   */
-  public static function addDisplayEnums(&$values) {
-    $enumFields = &Snapshot_v4p2_Price_DAO_Field::getEnums();
-    foreach ($enumFields as $enum) {
-      if (isset($values[$enum])) {
-        $values[$enum . '_display'] = Snapshot_v4p2_Price_DAO_Field::tsEnum($enum, $values[$enum]);
-      }
-    }
-  }
-
-}
diff --git a/CRM/Upgrade/Snapshot/V4p2/Price/DAO/FieldValue.php b/CRM/Upgrade/Snapshot/V4p2/Price/DAO/FieldValue.php
deleted file mode 100644 (file)
index a333aa4..0000000
+++ /dev/null
@@ -1,332 +0,0 @@
-<?php
-/*
-+--------------------------------------------------------------------+
-| CiviCRM version 5                                                  |
-+--------------------------------------------------------------------+
-| Copyright CiviCRM LLC (c) 2004-2019                                |
-+--------------------------------------------------------------------+
-| This file is a part of CiviCRM.                                    |
-|                                                                    |
-| CiviCRM is free software; you can copy, modify, and distribute it  |
-| under the terms of the GNU Affero General Public License           |
-| Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
-|                                                                    |
-| CiviCRM is distributed in the hope that it will be useful, but     |
-| WITHOUT ANY WARRANTY; without even the implied warranty of         |
-| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
-| See the GNU Affero General Public License for more details.        |
-|                                                                    |
-| You should have received a copy of the GNU Affero General Public   |
-| License and the CiviCRM Licensing Exception along                  |
-| with this program; if not, contact CiviCRM LLC                     |
-| at info[AT]civicrm[DOT]org. If you have questions about the        |
-| GNU Affero General Public License or the licensing of CiviCRM,     |
-| see the CiviCRM license FAQ at http://civicrm.org/licensing        |
-+--------------------------------------------------------------------+
-*/
-/**
- *
- * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2019
- * $Id$
- *
- */
-require_once 'CRM/Core/DAO.php';
-require_once 'CRM/Utils/Type.php';
-
-/**
- * Class CRM_Upgrade_Snapshot_V4p2_Price_DAO_FieldValue
- */
-class CRM_Upgrade_Snapshot_V4p2_Price_DAO_FieldValue extends CRM_Core_DAO {
-  /**
-   * static instance to hold the table name
-   *
-   * @var string
-   */
-  static $_tableName = 'civicrm_price_field_value';
-  /**
-   * static instance to hold the field values
-   *
-   * @var array
-   */
-  static $_fields = NULL;
-  /**
-   * static instance to hold the FK relationships
-   *
-   * @var string
-   */
-  static $_links = NULL;
-  /**
-   * static instance to hold the values that can
-   * be imported
-   *
-   * @var array
-   */
-  static $_import = NULL;
-  /**
-   * static instance to hold the values that can
-   * be exported
-   *
-   * @var array
-   */
-  static $_export = NULL;
-  /**
-   * static value to see if we should log any modifications to
-   * this table in the civicrm_log table
-   *
-   * @var boolean
-   */
-  static $_log = FALSE;
-  /**
-   * Price Field Value
-   *
-   * @var int unsigned
-   */
-  public $id;
-  /**
-   * FK to civicrm_price_field
-   *
-   * @var int unsigned
-   */
-  public $price_field_id;
-  /**
-   * Price field option name
-   *
-   * @var string
-   */
-  public $name;
-  /**
-   * Price field option label
-   *
-   * @var string
-   */
-  public $label;
-  /**
-   * >Price field option description.
-   *
-   * @var text
-   */
-  public $description;
-  /**
-   * Price field option amount
-   *
-   * @var string
-   */
-  public $amount;
-  /**
-   * Number of participants per field option
-   *
-   * @var int unsigned
-   */
-  public $count;
-  /**
-   * Max number of participants per field options
-   *
-   * @var int unsigned
-   */
-  public $max_value;
-  /**
-   * Order in which the field options should appear
-   *
-   * @var int
-   */
-  public $weight;
-  /**
-   * FK to Membership Type
-   *
-   * @var int unsigned
-   */
-  public $membership_type_id;
-  /**
-   * Is this default price field option
-   *
-   * @var boolean
-   */
-  public $is_default;
-  /**
-   * Is this price field value active
-   *
-   * @var boolean
-   */
-  public $is_active;
-
-  /**
-   * Class constructor.
-   *
-   * @return \CRM_Upgrade_Snapshot_V4p2_Price_DAO_FieldValue
-   */
-  public function __construct() {
-    $this->__table = 'civicrm_price_field_value';
-    parent::__construct();
-  }
-
-  /**
-   * Return foreign links.
-   *
-   * @return array
-   */
-  public function links() {
-    if (!(self::$_links)) {
-      self::$_links = array(
-        'price_field_id' => 'civicrm_price_field:id',
-        'membership_type_id' => 'civicrm_membership_type:id',
-      );
-    }
-    return self::$_links;
-  }
-
-  /**
-   * Returns all the column names of this table.
-   *
-   * @return array
-   */
-  public static function &fields() {
-    if (!(self::$_fields)) {
-      self::$_fields = array(
-        'id' => array(
-          'name' => 'id',
-          'type' => CRM_Utils_Type::T_INT,
-          'required' => TRUE,
-        ),
-        'price_field_id' => array(
-          'name' => 'price_field_id',
-          'type' => CRM_Utils_Type::T_INT,
-          'required' => TRUE,
-          'FKClassName' => 'Snapshot_v4p2_Price_DAO_Field',
-        ),
-        'name' => array(
-          'name' => 'name',
-          'type' => CRM_Utils_Type::T_STRING,
-          'title' => ts('Name'),
-          'maxlength' => 255,
-          'size' => CRM_Utils_Type::HUGE,
-        ),
-        'label' => array(
-          'name' => 'label',
-          'type' => CRM_Utils_Type::T_STRING,
-          'title' => ts('Label'),
-          'maxlength' => 255,
-          'size' => CRM_Utils_Type::HUGE,
-        ),
-        'description' => array(
-          'name' => 'description',
-          'type' => CRM_Utils_Type::T_TEXT,
-          'title' => ts('Description'),
-          'rows' => 2,
-          'cols' => 60,
-          'default' => 'UL',
-        ),
-        'amount' => array(
-          'name' => 'amount',
-          'type' => CRM_Utils_Type::T_STRING,
-          'title' => ts('Amount'),
-          'required' => TRUE,
-          'maxlength' => 512,
-          'size' => CRM_Utils_Type::HUGE,
-        ),
-        'count' => array(
-          'name' => 'count',
-          'type' => CRM_Utils_Type::T_INT,
-          'title' => ts('Count'),
-          'default' => 'UL',
-        ),
-        'max_value' => array(
-          'name' => 'max_value',
-          'type' => CRM_Utils_Type::T_INT,
-          'title' => ts('Max Value'),
-          'default' => 'UL',
-        ),
-        'weight' => array(
-          'name' => 'weight',
-          'type' => CRM_Utils_Type::T_INT,
-          'title' => ts('Weight'),
-          'default' => '',
-        ),
-        'membership_type_id' => array(
-          'name' => 'membership_type_id',
-          'type' => CRM_Utils_Type::T_INT,
-          'default' => 'UL',
-          'FKClassName' => 'CRM_Member_DAO_MembershipType',
-        ),
-        'is_default' => array(
-          'name' => 'is_default',
-          'type' => CRM_Utils_Type::T_BOOLEAN,
-        ),
-        'is_active' => array(
-          'name' => 'is_active',
-          'type' => CRM_Utils_Type::T_BOOLEAN,
-          'default' => '',
-        ),
-      );
-    }
-    return self::$_fields;
-  }
-
-  /**
-   * returns the names of this table.
-   *
-   * @return string
-   */
-  public static function getTableName() {
-    return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
-  }
-
-  /**
-   * returns if this table needs to be logged.
-   *
-   * @return boolean
-   */
-  public function getLog() {
-    return self::$_log;
-  }
-
-  /**
-   * Returns the list of fields that can be imported.
-   *
-   * @param bool $prefix
-   *
-   * @return array
-   */
-  static function &import($prefix = FALSE) {
-    if (!(self::$_import)) {
-      self::$_import = array();
-      $fields = self::fields();
-      foreach ($fields as $name => $field) {
-        if (!empty($field['import'])) {
-          if ($prefix) {
-            self::$_import['price_field_value'] = &$fields[$name];
-          }
-          else {
-            self::$_import[$name] = &$fields[$name];
-          }
-        }
-      }
-    }
-    return self::$_import;
-  }
-
-  /**
-   * Returns the list of fields that can be exported.
-   *
-   * @param bool $prefix
-   *
-   * @return array
-   */
-  static function &export($prefix = FALSE) {
-    if (!(self::$_export)) {
-      self::$_export = array();
-      $fields = self::fields();
-      foreach ($fields as $name => $field) {
-        if (!empty($field['export'])) {
-          if ($prefix) {
-            self::$_export['price_field_value'] = &$fields[$name];
-          }
-          else {
-            self::$_export[$name] = &$fields[$name];
-          }
-        }
-      }
-    }
-    return self::$_export;
-  }
-}
diff --git a/CRM/Upgrade/Snapshot/V4p2/Price/DAO/LineItem.php b/CRM/Upgrade/Snapshot/V4p2/Price/DAO/LineItem.php
deleted file mode 100644 (file)
index ec0fe23..0000000
+++ /dev/null
@@ -1,308 +0,0 @@
-<?php
-/*
-+--------------------------------------------------------------------+
-| CiviCRM version 5                                                  |
-+--------------------------------------------------------------------+
-| Copyright CiviCRM LLC (c) 2004-2019                                |
-+--------------------------------------------------------------------+
-| This file is a part of CiviCRM.                                    |
-|                                                                    |
-| CiviCRM is free software; you can copy, modify, and distribute it  |
-| under the terms of the GNU Affero General Public License           |
-| Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
-|                                                                    |
-| CiviCRM is distributed in the hope that it will be useful, but     |
-| WITHOUT ANY WARRANTY; without even the implied warranty of         |
-| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
-| See the GNU Affero General Public License for more details.        |
-|                                                                    |
-| You should have received a copy of the GNU Affero General Public   |
-| License and the CiviCRM Licensing Exception along                  |
-| with this program; if not, contact CiviCRM LLC                     |
-| at info[AT]civicrm[DOT]org. If you have questions about the        |
-| GNU Affero General Public License or the licensing of CiviCRM,     |
-| see the CiviCRM license FAQ at http://civicrm.org/licensing        |
-+--------------------------------------------------------------------+
-*/
-/**
- *
- * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2019
- * $Id$
- *
- */
-require_once 'CRM/Core/DAO.php';
-require_once 'CRM/Utils/Type.php';
-
-/**
- * Class CRM_Upgrade_Snapshot_V4p2_Price_DAO_LineItem
- */
-class CRM_Upgrade_Snapshot_V4p2_Price_DAO_LineItem extends CRM_Core_DAO {
-  /**
-   * static instance to hold the table name
-   *
-   * @var string
-   */
-  static $_tableName = 'civicrm_line_item';
-  /**
-   * static instance to hold the field values
-   *
-   * @var array
-   */
-  static $_fields = NULL;
-  /**
-   * static instance to hold the FK relationships
-   *
-   * @var string
-   */
-  static $_links = NULL;
-  /**
-   * static instance to hold the values that can
-   * be imported
-   *
-   * @var array
-   */
-  static $_import = NULL;
-  /**
-   * static instance to hold the values that can
-   * be exported
-   *
-   * @var array
-   */
-  static $_export = NULL;
-  /**
-   * static value to see if we should log any modifications to
-   * this table in the civicrm_log table
-   *
-   * @var boolean
-   */
-  static $_log = TRUE;
-  /**
-   * Line Item
-   *
-   * @var int unsigned
-   */
-  public $id;
-  /**
-   * table which has the transaction
-   *
-   * @var string
-   */
-  public $entity_table;
-  /**
-   * entry in table
-   *
-   * @var int unsigned
-   */
-  public $entity_id;
-  /**
-   * FK to price_field
-   *
-   * @var int unsigned
-   */
-  public $price_field_id;
-  /**
-   * descriptive label for item - from price_field_value.label
-   *
-   * @var string
-   */
-  public $label;
-  /**
-   * How many items ordered
-   *
-   * @var int unsigned
-   */
-  public $qty;
-  /**
-   * price of each item
-   *
-   * @var float
-   */
-  public $unit_price;
-  /**
-   * qty * unit_price
-   *
-   * @var float
-   */
-  public $line_total;
-  /**
-   * Participant count for field
-   *
-   * @var int unsigned
-   */
-  public $participant_count;
-  /**
-   * Implicit FK to civicrm_option_value
-   *
-   * @var int unsigned
-   */
-  public $price_field_value_id;
-
-  /**
-   * Class constructor.
-   *
-   * @return \CRM_Upgrade_Snapshot_V4p2_Price_DAO_LineItem
-   */
-  public function __construct() {
-    $this->__table = 'civicrm_line_item';
-    parent::__construct();
-  }
-
-  /**
-   * Return foreign links.
-   *
-   * @return array
-   */
-  public function links() {
-    if (!(self::$_links)) {
-      self::$_links = array(
-        'price_field_id' => 'civicrm_price_field:id',
-        'price_field_value_id' => 'civicrm_price_field_value:id',
-      );
-    }
-    return self::$_links;
-  }
-
-  /**
-   * Returns all the column names of this table.
-   *
-   * @return array
-   */
-  public static function &fields() {
-    if (!(self::$_fields)) {
-      self::$_fields = array(
-        'id' => array(
-          'name' => 'id',
-          'type' => CRM_Utils_Type::T_INT,
-          'required' => TRUE,
-        ),
-        'entity_table' => array(
-          'name' => 'entity_table',
-          'type' => CRM_Utils_Type::T_STRING,
-          'title' => ts('Entity Table'),
-          'required' => TRUE,
-          'maxlength' => 64,
-          'size' => CRM_Utils_Type::BIG,
-        ),
-        'entity_id' => array(
-          'name' => 'entity_id',
-          'type' => CRM_Utils_Type::T_INT,
-          'required' => TRUE,
-        ),
-        'price_field_id' => array(
-          'name' => 'price_field_id',
-          'type' => CRM_Utils_Type::T_INT,
-          'required' => TRUE,
-          'FKClassName' => 'Snapshot_v4p2_Price_DAO_Field',
-        ),
-        'label' => array(
-          'name' => 'label',
-          'type' => CRM_Utils_Type::T_STRING,
-          'title' => ts('Label'),
-          'maxlength' => 255,
-          'size' => CRM_Utils_Type::HUGE,
-          'default' => 'UL',
-        ),
-        'qty' => array(
-          'name' => 'qty',
-          'type' => CRM_Utils_Type::T_INT,
-          'title' => ts('Qty'),
-          'required' => TRUE,
-        ),
-        'unit_price' => array(
-          'name' => 'unit_price',
-          'type' => CRM_Utils_Type::T_MONEY,
-          'title' => ts('Unit Price'),
-          'required' => TRUE,
-        ),
-        'line_total' => array(
-          'name' => 'line_total',
-          'type' => CRM_Utils_Type::T_MONEY,
-          'title' => ts('Line Total'),
-          'required' => TRUE,
-        ),
-        'participant_count' => array(
-          'name' => 'participant_count',
-          'type' => CRM_Utils_Type::T_INT,
-          'title' => ts('Participant Count'),
-          'default' => 'UL',
-        ),
-        'price_field_value_id' => array(
-          'name' => 'price_field_value_id',
-          'type' => CRM_Utils_Type::T_INT,
-          'default' => 'UL',
-          'FKClassName' => 'Snapshot_v4p2_Price_DAO_FieldValue',
-        ),
-      );
-    }
-    return self::$_fields;
-  }
-
-  /**
-   * returns the names of this table.
-   *
-   * @return string
-   */
-  public static function getTableName() {
-    return self::$_tableName;
-  }
-
-  /**
-   * returns if this table needs to be logged.
-   *
-   * @return boolean
-   */
-  public function getLog() {
-    return self::$_log;
-  }
-
-  /**
-   * returns the list of fields that can be imported.
-   *
-   * @param bool $prefix
-   *
-   * @return array
-   */
-  static function &import($prefix = FALSE) {
-    if (!(self::$_import)) {
-      self::$_import = array();
-      $fields = self::fields();
-      foreach ($fields as $name => $field) {
-        if (!empty($field['import'])) {
-          if ($prefix) {
-            self::$_import['line_item'] = &$fields[$name];
-          }
-          else {
-            self::$_import[$name] = &$fields[$name];
-          }
-        }
-      }
-    }
-    return self::$_import;
-  }
-
-  /**
-   * Returns the list of fields that can be exported.
-   *
-   * @param bool $prefix
-   *
-   * @return array
-   */
-  static function &export($prefix = FALSE) {
-    if (!(self::$_export)) {
-      self::$_export = array();
-      $fields = self::fields();
-      foreach ($fields as $name => $field) {
-        if (!empty($field['export'])) {
-          if ($prefix) {
-            self::$_export['line_item'] = &$fields[$name];
-          }
-          else {
-            self::$_export[$name] = &$fields[$name];
-          }
-        }
-      }
-    }
-    return self::$_export;
-  }
-}
diff --git a/CRM/Upgrade/Snapshot/V4p2/Price/DAO/Set.php b/CRM/Upgrade/Snapshot/V4p2/Price/DAO/Set.php
deleted file mode 100644 (file)
index 48e3380..0000000
+++ /dev/null
@@ -1,332 +0,0 @@
-<?php
-/*
-+--------------------------------------------------------------------+
-| CiviCRM version 5                                                  |
-+--------------------------------------------------------------------+
-| Copyright CiviCRM LLC (c) 2004-2019                                |
-+--------------------------------------------------------------------+
-| This file is a part of CiviCRM.                                    |
-|                                                                    |
-| CiviCRM is free software; you can copy, modify, and distribute it  |
-| under the terms of the GNU Affero General Public License           |
-| Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
-|                                                                    |
-| CiviCRM is distributed in the hope that it will be useful, but     |
-| WITHOUT ANY WARRANTY; without even the implied warranty of         |
-| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
-| See the GNU Affero General Public License for more details.        |
-|                                                                    |
-| You should have received a copy of the GNU Affero General Public   |
-| License and the CiviCRM Licensing Exception along                  |
-| with this program; if not, contact CiviCRM LLC                     |
-| at info[AT]civicrm[DOT]org. If you have questions about the        |
-| GNU Affero General Public License or the licensing of CiviCRM,     |
-| see the CiviCRM license FAQ at http://civicrm.org/licensing        |
-+--------------------------------------------------------------------+
-*/
-/**
- *
- * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2019
- * $Id$
- *
- */
-require_once 'CRM/Core/DAO.php';
-require_once 'CRM/Utils/Type.php';
-
-/**
- * Class CRM_Upgrade_Snapshot_V4p2_Price_DAO_Set
- */
-class CRM_Upgrade_Snapshot_V4p2_Price_DAO_Set extends CRM_Core_DAO {
-  /**
-   * static instance to hold the table name
-   *
-   * @var string
-   */
-  static $_tableName = 'civicrm_price_set';
-  /**
-   * static instance to hold the field values
-   *
-   * @var array
-   */
-  static $_fields = NULL;
-  /**
-   * static instance to hold the FK relationships
-   *
-   * @var string
-   */
-  static $_links = NULL;
-  /**
-   * static instance to hold the values that can
-   * be imported
-   *
-   * @var array
-   */
-  static $_import = NULL;
-  /**
-   * static instance to hold the values that can
-   * be exported
-   *
-   * @var array
-   */
-  static $_export = NULL;
-  /**
-   * static value to see if we should log any modifications to
-   * this table in the civicrm_log table
-   *
-   * @var boolean
-   */
-  static $_log = TRUE;
-  /**
-   * Price Set
-   *
-   * @var int unsigned
-   */
-  public $id;
-  /**
-   * Which Domain is this price-set for
-   *
-   * @var int unsigned
-   */
-  public $domain_id;
-  /**
-   * Variable name/programmatic handle for this set of price fields.
-   *
-   * @var string
-   */
-  public $name;
-  /**
-   * Displayed title for the Price Set.
-   *
-   * @var string
-   */
-  public $title;
-  /**
-   * Is this price set active
-   *
-   * @var boolean
-   */
-  public $is_active;
-  /**
-   * Description and/or help text to display before fields in form.
-   *
-   * @var text
-   */
-  public $help_pre;
-  /**
-   * Description and/or help text to display after fields in form.
-   *
-   * @var text
-   */
-  public $help_post;
-  /**
-   * Optional Javascript script function(s) included on the form with this price_set. Can be used for conditional
-   *
-   * @var string
-   */
-  public $javascript;
-  /**
-   * What components are using this price set?
-   *
-   * @var string
-   */
-  public $extends;
-  /**
-   * FK to Contribution Type(for membership price sets only).
-   *
-   * @var int unsigned
-   */
-  public $contribution_type_id;
-  /**
-   * Is set if edited on Contribution or Event Page rather than through Manage Price Sets
-   *
-   * @var boolean
-   */
-  public $is_quick_config;
-  /**
-   * Is this a predefined system price set  (i.e. it can not be deleted, edited)?
-   *
-   * @var boolean
-   */
-  public $is_reserved;
-
-  /**
-   * Class constructor.
-   *
-   * @return \CRM_Upgrade_Snapshot_V4p2_Price_DAO_Set
-   */
-  public function __construct() {
-    $this->__table = 'civicrm_price_set';
-    parent::__construct();
-  }
-
-  /**
-   * Return foreign links.
-   *
-   * @return array
-   */
-  public function links() {
-    if (!(self::$_links)) {
-      self::$_links = array(
-        'domain_id' => 'civicrm_domain:id',
-        'contribution_type_id' => 'civicrm_contribution_type:id',
-      );
-    }
-    return self::$_links;
-  }
-
-  /**
-   * Returns all the column names of this table.
-   *
-   * @return array
-   */
-  public static function &fields() {
-    if (!(self::$_fields)) {
-      self::$_fields = array(
-        'id' => array(
-          'name' => 'id',
-          'type' => CRM_Utils_Type::T_INT,
-          'required' => TRUE,
-        ),
-        'domain_id' => array(
-          'name' => 'domain_id',
-          'type' => CRM_Utils_Type::T_INT,
-          'FKClassName' => 'CRM_Core_DAO_Domain',
-        ),
-        'name' => array(
-          'name' => 'name',
-          'type' => CRM_Utils_Type::T_STRING,
-          'title' => ts('Name'),
-          'required' => TRUE,
-          'maxlength' => 255,
-          'size' => CRM_Utils_Type::HUGE,
-        ),
-        'title' => array(
-          'name' => 'title',
-          'type' => CRM_Utils_Type::T_STRING,
-          'title' => ts('Title'),
-          'required' => TRUE,
-          'maxlength' => 255,
-          'size' => CRM_Utils_Type::HUGE,
-        ),
-        'is_active' => array(
-          'name' => 'is_active',
-          'type' => CRM_Utils_Type::T_BOOLEAN,
-          'default' => '',
-        ),
-        'help_pre' => array(
-          'name' => 'help_pre',
-          'type' => CRM_Utils_Type::T_TEXT,
-          'title' => ts('Help Pre'),
-          'rows' => 4,
-          'cols' => 80,
-        ),
-        'help_post' => array(
-          'name' => 'help_post',
-          'type' => CRM_Utils_Type::T_TEXT,
-          'title' => ts('Help Post'),
-          'rows' => 4,
-          'cols' => 80,
-        ),
-        'javascript' => array(
-          'name' => 'javascript',
-          'type' => CRM_Utils_Type::T_STRING,
-          'title' => ts('Javascript'),
-          'maxlength' => 64,
-          'size' => CRM_Utils_Type::BIG,
-        ),
-        'extends' => array(
-          'name' => 'extends',
-          'type' => CRM_Utils_Type::T_STRING,
-          'title' => ts('Extends'),
-          'required' => TRUE,
-          'maxlength' => 255,
-          'size' => CRM_Utils_Type::HUGE,
-        ),
-        'contribution_type_id' => array(
-          'name' => 'contribution_type_id',
-          'type' => CRM_Utils_Type::T_INT,
-          'default' => 'UL',
-          'FKClassName' => 'CRM_Contribute_DAO_ContributionType',
-        ),
-        'is_quick_config' => array(
-          'name' => 'is_quick_config',
-          'type' => CRM_Utils_Type::T_BOOLEAN,
-        ),
-        'is_reserved' => array(
-          'name' => 'is_reserved',
-          'type' => CRM_Utils_Type::T_BOOLEAN,
-        ),
-      );
-    }
-    return self::$_fields;
-  }
-
-  /**
-   * returns the names of this table.
-   *
-   * @return string
-   */
-  public static function getTableName() {
-    return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
-  }
-
-  /**
-   * returns if this table needs to be logged.
-   *
-   * @return boolean
-   */
-  public function getLog() {
-    return self::$_log;
-  }
-
-  /**
-   * Returns the list of fields that can be imported.
-   *
-   * @param bool $prefix
-   *
-   * @return array
-   */
-  static function &import($prefix = FALSE) {
-    if (!(self::$_import)) {
-      self::$_import = array();
-      $fields = self::fields();
-      foreach ($fields as $name => $field) {
-        if (!empty($field['import'])) {
-          if ($prefix) {
-            self::$_import['price_set'] = &$fields[$name];
-          }
-          else {
-            self::$_import[$name] = &$fields[$name];
-          }
-        }
-      }
-    }
-    return self::$_import;
-  }
-
-  /**
-   * returns the list of fields that can be exported.
-   *
-   * @param bool $prefix
-   *
-   * @return array
-   */
-  static function &export($prefix = FALSE) {
-    if (!(self::$_export)) {
-      self::$_export = array();
-      $fields = self::fields();
-      foreach ($fields as $name => $field) {
-        if (!empty($field['export'])) {
-          if ($prefix) {
-            self::$_export['price_set'] = &$fields[$name];
-          }
-          else {
-            self::$_export[$name] = &$fields[$name];
-          }
-        }
-      }
-    }
-    return self::$_export;
-  }
-}
diff --git a/CRM/Upgrade/Snapshot/V4p2/Price/DAO/SetEntity.php b/CRM/Upgrade/Snapshot/V4p2/Price/DAO/SetEntity.php
deleted file mode 100644 (file)
index f5d46d6..0000000
+++ /dev/null
@@ -1,233 +0,0 @@
-<?php
-/*
-+--------------------------------------------------------------------+
-| CiviCRM version 5                                                  |
-+--------------------------------------------------------------------+
-| Copyright CiviCRM LLC (c) 2004-2019                                |
-+--------------------------------------------------------------------+
-| This file is a part of CiviCRM.                                    |
-|                                                                    |
-| CiviCRM is free software; you can copy, modify, and distribute it  |
-| under the terms of the GNU Affero General Public License           |
-| Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
-|                                                                    |
-| CiviCRM is distributed in the hope that it will be useful, but     |
-| WITHOUT ANY WARRANTY; without even the implied warranty of         |
-| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
-| See the GNU Affero General Public License for more details.        |
-|                                                                    |
-| You should have received a copy of the GNU Affero General Public   |
-| License and the CiviCRM Licensing Exception along                  |
-| with this program; if not, contact CiviCRM LLC                     |
-| at info[AT]civicrm[DOT]org. If you have questions about the        |
-| GNU Affero General Public License or the licensing of CiviCRM,     |
-| see the CiviCRM license FAQ at http://civicrm.org/licensing        |
-+--------------------------------------------------------------------+
-*/
-/**
- *
- * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2019
- * $Id$
- *
- */
-require_once 'CRM/Core/DAO.php';
-require_once 'CRM/Utils/Type.php';
-
-/**
- * Class CRM_Upgrade_Snapshot_V4p2_Price_DAO_SetEntity
- */
-class CRM_Upgrade_Snapshot_V4p2_Price_DAO_SetEntity extends CRM_Core_DAO {
-  /**
-   * static instance to hold the table name
-   *
-   * @var string
-   */
-  static $_tableName = 'civicrm_price_set_entity';
-  /**
-   * static instance to hold the field values
-   *
-   * @var array
-   */
-  static $_fields = NULL;
-  /**
-   * static instance to hold the FK relationships
-   *
-   * @var string
-   */
-  static $_links = NULL;
-  /**
-   * static instance to hold the values that can
-   * be imported
-   *
-   * @var array
-   */
-  static $_import = NULL;
-  /**
-   * static instance to hold the values that can
-   * be exported
-   *
-   * @var array
-   */
-  static $_export = NULL;
-  /**
-   * static value to see if we should log any modifications to
-   * this table in the civicrm_log table
-   *
-   * @var boolean
-   */
-  static $_log = TRUE;
-  /**
-   * Price Set Entity
-   *
-   * @var int unsigned
-   */
-  public $id;
-  /**
-   * Table which uses this price set
-   *
-   * @var string
-   */
-  public $entity_table;
-  /**
-   * Item in table
-   *
-   * @var int unsigned
-   */
-  public $entity_id;
-  /**
-   * price set being used
-   *
-   * @var int unsigned
-   */
-  public $price_set_id;
-
-  /**
-   * Class constructor.
-   *
-   * @return \CRM_Upgrade_Snapshot_V4p2_Price_DAO_SetEntity
-   */
-  public function __construct() {
-    $this->__table = 'civicrm_price_set_entity';
-    parent::__construct();
-  }
-
-  /**
-   * Return foreign links.
-   *
-   * @return array
-   */
-  public function links() {
-    if (!(self::$_links)) {
-      self::$_links = array(
-        'price_set_id' => 'civicrm_price_set:id',
-      );
-    }
-    return self::$_links;
-  }
-
-  /**
-   * Returns all the column names of this table.
-   *
-   * @return array
-   */
-  public static function &fields() {
-    if (!(self::$_fields)) {
-      self::$_fields = array(
-        'id' => array(
-          'name' => 'id',
-          'type' => CRM_Utils_Type::T_INT,
-          'required' => TRUE,
-        ),
-        'entity_table' => array(
-          'name' => 'entity_table',
-          'type' => CRM_Utils_Type::T_STRING,
-          'title' => ts('Entity Table'),
-          'required' => TRUE,
-          'maxlength' => 64,
-          'size' => CRM_Utils_Type::BIG,
-        ),
-        'entity_id' => array(
-          'name' => 'entity_id',
-          'type' => CRM_Utils_Type::T_INT,
-          'required' => TRUE,
-        ),
-        'price_set_id' => array(
-          'name' => 'price_set_id',
-          'type' => CRM_Utils_Type::T_INT,
-          'required' => TRUE,
-          'FKClassName' => 'Snapshot_v4p2_Price_DAO_Set',
-        ),
-      );
-    }
-    return self::$_fields;
-  }
-
-  /**
-   * returns the names of this table.
-   *
-   * @return string
-   */
-  public static function getTableName() {
-    return self::$_tableName;
-  }
-
-  /**
-   * returns if this table needs to be logged.
-   *
-   * @return boolean
-   */
-  public function getLog() {
-    return self::$_log;
-  }
-
-  /**
-   * Returns the list of fields that can be imported.
-   *
-   * @param bool $prefix
-   *
-   * @return array
-   */
-  static function &import($prefix = FALSE) {
-    if (!(self::$_import)) {
-      self::$_import = array();
-      $fields = self::fields();
-      foreach ($fields as $name => $field) {
-        if (!empty($field['import'])) {
-          if ($prefix) {
-            self::$_import['price_set_entity'] = &$fields[$name];
-          }
-          else {
-            self::$_import[$name] = &$fields[$name];
-          }
-        }
-      }
-    }
-    return self::$_import;
-  }
-
-  /**
-   * returns the list of fields that can be exported.
-   *
-   * @param bool $prefix
-   *
-   * @return array
-   */
-  static function &export($prefix = FALSE) {
-    if (!(self::$_export)) {
-      self::$_export = array();
-      $fields = self::fields();
-      foreach ($fields as $name => $field) {
-        if (!empty($field['export'])) {
-          if ($prefix) {
-            self::$_export['price_set_entity'] = &$fields[$name];
-          }
-          else {
-            self::$_export[$name] = &$fields[$name];
-          }
-        }
-      }
-    }
-    return self::$_export;
-  }
-}
index 0851276ccf1cc76fe96ff1361f58cb9227476375..1c421a5e78cd0bae38b88960332ae718222def01 100644 (file)
@@ -289,7 +289,18 @@ class CRM_Utils_Address_BatchUpdate {
   public function returnResult() {
     $result = array();
     $result['is_error'] = $this->returnError;
-    $result['messages'] = implode("", $this->returnMessages);
+    $result['messages'] = '';
+    // Pad message size to allow for prefix added by CRM_Core_JobManager.
+    $messageSize = 255;
+    // Ensure that each message can fit in the civicrm_job_log.data column.
+    foreach ($this->returnMessages as $message) {
+      $messageSize += strlen($message);
+      if ($messageSize > CRM_Utils_Type::BLOB_SIZE) {
+        $result['messages'] .= '...';
+        break;
+      }
+      $result['messages'] .= $message;
+    }
     return $result;
   }
 
index 8e13d3e9a22b5820393deed95bca4e7fc45d7d3c..e20795502b7be77adc8426799db04dc92a28899d 100644 (file)
@@ -927,4 +927,63 @@ class CRM_Utils_Check_Component_Env extends CRM_Utils_Check_Component {
     return $messages;
   }
 
+  /**
+   * Check for utf8mb4 support by MySQL.
+   *
+   * @return array<CRM_Utils_Check_Message> an empty array, or a list of warnings
+   */
+  public function checkMysqlUtf8mb4() {
+    $messages = array();
+
+    if (CRM_Core_DAO::getConnection()->phptype != 'mysqli') {
+      return $messages;
+    }
+
+    // Force utf8mb4 query to throw exception as the check expects.
+    $errorScope = CRM_Core_TemporaryErrorScope::useException();
+    try {
+      // Create a temporary table to avoid implicit commit.
+      CRM_Core_DAO::executeQuery('CREATE TEMPORARY TABLE civicrm_utf8mb4_test (id VARCHAR(255), PRIMARY KEY(id(255))) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC ENGINE=INNODB');
+      CRM_Core_DAO::executeQuery('DROP TEMPORARY TABLE civicrm_utf8mb4_test');
+    }
+    catch (PEAR_Exception $e) {
+      $messages[] = new CRM_Utils_Check_Message(
+        __FUNCTION__,
+        ts('Future versions of CiviCRM may require MySQL utf8mb4 support. It is recommended, though not yet required, to configure your MySQL server for utf8mb4 support. You will need the following MySQL server configuration: innodb_large_prefix=true innodb_file_format=barracuda innodb_file_per_table=true'),
+        ts('MySQL utf8mb4 Support'),
+        \Psr\Log\LogLevel::WARNING,
+        'fa-database'
+      );
+    }
+    // Ensure that the MySQL driver supports utf8mb4 encoding.
+    $version = mysqli_get_client_info(CRM_Core_DAO::getConnection()->connection);
+    if (strpos($version, 'mysqlnd') !== FALSE) {
+      // The mysqlnd driver supports utf8mb4 starting at version 5.0.9.
+      $version = preg_replace('/^\D+([\d.]+).*/', '$1', $version);
+      if (version_compare($version, '5.0.9', '<')) {
+        $messages[] = new CRM_Utils_Check_Message(
+          __FUNCTION__ . 'mysqlnd',
+          ts('It is recommended, though not yet required, to upgrade your PHP MySQL driver (mysqlnd) to >= 5.0.9 for utf8mb4 support.'),
+          ts('PHP MySQL Driver (mysqlnd)'),
+          \Psr\Log\LogLevel::WARNING,
+          'fa-server'
+        );
+      }
+    }
+    else {
+      // The libmysqlclient driver supports utf8mb4 starting at version 5.5.3.
+      if (version_compare($version, '5.5.3', '<')) {
+        $messages[] = new CRM_Utils_Check_Message(
+          __FUNCTION__ . 'libmysqlclient',
+          ts('It is recommended, though not yet required, to upgrade your PHP MySQL driver (libmysqlclient) to >= 5.5.3 for utf8mb4 support.'),
+          ts('PHP MySQL Driver (libmysqlclient)'),
+          \Psr\Log\LogLevel::WARNING,
+          'fa-server'
+        );
+      }
+    }
+
+    return $messages;
+  }
+
 }
index 1a7d449621d27740eaad98bfbbab5e33ab35b076..f2ac0a3e2f8cc5a709cc244a6301126693e27110 100644 (file)
@@ -48,7 +48,7 @@ class CRM_Utils_PDF_Utils {
    *
    * @return string|void
    */
-  public static function html2pdf(&$text, $fileName = 'civicrm.pdf', $output = FALSE, $pdfFormat = NULL) {
+  public static function html2pdf($text, $fileName = 'civicrm.pdf', $output = FALSE, $pdfFormat = NULL) {
     if (is_array($text)) {
       $pages = &$text;
     }
@@ -61,7 +61,7 @@ class CRM_Utils_PDF_Utils {
       // PDF Page Format parameters passed in
       $format = array_merge($format, $pdfFormat);
     }
-    else {
+    elseif (!empty($pdfFormat)) {
       // PDF Page Format ID passed in
       $format = CRM_Core_BAO_PdfFormat::getById($pdfFormat);
     }
@@ -77,18 +77,8 @@ class CRM_Utils_PDF_Utils {
     $b = CRM_Core_BAO_PdfFormat::getValue('margin_bottom', $format);
     $l = CRM_Core_BAO_PdfFormat::getValue('margin_left', $format);
 
-    $stationery_path_partial = CRM_Core_BAO_PdfFormat::getValue('stationery', $format);
-
-    $stationery_path = NULL;
-    if (strlen($stationery_path_partial)) {
-      $doc_root = $_SERVER['DOCUMENT_ROOT'];
-      $stationery_path = $doc_root . "/" . $stationery_path_partial;
-    }
-
     $margins = array($metric, $t, $r, $b, $l);
 
-    $config = CRM_Core_Config::singleton();
-
     // Add a special region for the HTML header of PDF files:
     $pdfHeaderRegion = CRM_Core_Region::instance('export-document-header', FALSE);
     $htmlHeader = ($pdfHeaderRegion) ? $pdfHeaderRegion->render('', FALSE) : '';
@@ -98,14 +88,14 @@ class CRM_Utils_PDF_Utils {
   <head>
     <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>
     <style>@page { margin: {$t}{$metric} {$r}{$metric} {$b}{$metric} {$l}{$metric}; }</style>
-    <style type=\"text/css\">@import url({$config->userFrameworkResourceURL}css/print.css);</style>
+    <style type=\"text/css\">@import url(" . CRM_Core_Config::singleton()->userFrameworkResourceURL . "css/print.css);</style>
     {$htmlHeader}
   </head>
   <body>
     <div id=\"crm-container\">\n";
 
     // Strip <html>, <header>, and <body> tags from each page
-    $htmlElementstoStrip = array(
+    $htmlElementstoStrip = [
       '@<head[^>]*?>.*?</head>@siu',
       '@<script[^>]*?>.*?</script>@siu',
       '@<body>@siu',
@@ -113,8 +103,8 @@ class CRM_Utils_PDF_Utils {
       '@<html[^>]*?>@siu',
       '@</html>@siu',
       '@<!DOCTYPE[^>]*?>@siu',
-    );
-    $htmlElementsInstead = array('', '', '', '', '', '');
+    ];
+    $htmlElementsInstead = ['', '', '', '', '', ''];
     foreach ($pages as & $page) {
       $page = preg_replace($htmlElementstoStrip,
         $htmlElementsInstead,
@@ -127,12 +117,11 @@ class CRM_Utils_PDF_Utils {
     </div>
   </body>
 </html>";
-    if ($config->wkhtmltopdfPath) {
+    if (CRM_Core_Config::singleton()->wkhtmltopdfPath) {
       return self::_html2pdf_wkhtmltopdf($paper_size, $orientation, $margins, $html, $output, $fileName);
     }
     else {
       return self::_html2pdf_dompdf($paper_size, $orientation, $html, $output, $fileName);
-      //return self::_html2pdf_tcpdf($paper_size, $orientation, $margins, $html, $output, $fileName,  $stationery_path);
     }
   }
 
index 2176b5b00294c3040b970e80668fbfbe9752a7be..e73e46fd48bafe55c8c4cd988ea9d1291a6362e9 100644 (file)
@@ -113,7 +113,7 @@ class CRM_Utils_PagerAToZ {
 
     $dynamicAlphabets = array();
     while ($result->fetch()) {
-      $dynamicAlphabets[] = $result->sort_name;
+      $dynamicAlphabets[] = strtoupper($result->sort_name);
     }
     return $dynamicAlphabets;
   }
index 4cb2045944e52a0504513728e5f57d6123cac968..d1afe457a1c785ae8a2935725dd877f839676f71 100644 (file)
@@ -98,11 +98,10 @@ class CRM_Utils_ReCAPTCHA {
       require_once 'packages/recaptcha/recaptchalib.php';
     }
 
-    // See if we are using SSL
-    if (CRM_Utils_System::isSSL()) {
-      $useSSL = TRUE;
-    }
-    $html = recaptcha_get_html($config->recaptchaPublicKey, $error, $useSSL);
+    // Load the Recaptcha api.js over HTTPS
+    $useHTTPS = TRUE;
+
+    $html = recaptcha_get_html($config->recaptchaPublicKey, $error, $useHTTPS);
 
     $form->assign('recaptchaHTML', $html);
     $form->assign('recaptchaOptions', $config->recaptchaOptions);
index cfcdbac514c1cef613fdd813de1147747b3a4d6d..7f1955003c7e6734287c7e7cda69e634afa6b008 100644 (file)
@@ -72,6 +72,8 @@ class CRM_Utils_SQL_TempTable {
   const CATEGORY_REGEXP = ';^[a-zA-Z0-9]+$;';
   const ID_LENGTH = 37; // MAX{64} - CATEGORY_LENGTH{12} - CONST_LENGHTH{15} = 37
   const ID_REGEXP = ';^[a-zA-Z0-9_]+$;';
+  const INNODB = 'ENGINE=InnoDB';
+  const MEMORY = 'ENGINE=MEMORY';
 
   /**
    * @var bool
@@ -84,6 +86,8 @@ class CRM_Utils_SQL_TempTable {
 
   protected $autodrop;
 
+  protected $memory;
+
   /**
    * @return CRM_Utils_SQL_TempTable
    */
@@ -93,9 +97,10 @@ class CRM_Utils_SQL_TempTable {
     $t->id = md5(uniqid('', TRUE));
     // The constant CIVICRM_TEMP_FORCE_DURABLE is for local debugging.
     $t->durable = CRM_Utils_Constant::value('CIVICRM_TEMP_FORCE_DURABLE', FALSE);
-    // I suspect it would be better to just say utf8=true, but a lot of existing queries don't do the utf8 bit.
-    $t->utf8 = CRM_Utils_Constant::value('CIVICRM_TEMP_FORCE_UTF8', FALSE);
+    // @deprecated This constant is deprecated and will be removed.
+    $t->utf8 = CRM_Utils_Constant::value('CIVICRM_TEMP_FORCE_UTF8', TRUE);
     $t->autodrop = FALSE;
+    $t->memory = FALSE;
     return $t;
   }
 
@@ -126,8 +131,9 @@ class CRM_Utils_SQL_TempTable {
    * @return CRM_Utils_SQL_TempTable
    */
   public function createWithQuery($selectQuery) {
-    $sql = sprintf('%s %s AS %s',
+    $sql = sprintf('%s %s %s AS %s',
       $this->toSQL('CREATE'),
+      $this->memory ? self::MEMORY : self::INNODB,
       $this->utf8 ? self::UTF8 : '',
       ($selectQuery instanceof CRM_Utils_SQL_Select ? $selectQuery->toSQL() : $selectQuery)
     );
@@ -144,9 +150,10 @@ class CRM_Utils_SQL_TempTable {
    * @return CRM_Utils_SQL_TempTable
    */
   public function createWithColumns($columns) {
-    $sql = sprintf('%s (%s) %s',
+    $sql = sprintf('%s (%s) %s %s',
       $this->toSQL('CREATE'),
       $columns,
+      $this->memory ? self::MEMORY : self::INNODB,
       $this->utf8 ? self::UTF8 : ''
     );
     CRM_Core_DAO::executeQuery($sql, array(), TRUE, NULL, TRUE, FALSE);
@@ -215,6 +222,13 @@ class CRM_Utils_SQL_TempTable {
     return $this->durable;
   }
 
+  /**
+   * @return bool
+   */
+  public function isMemory() {
+    return $this->memory;
+  }
+
   /**
    * @return bool
    */
@@ -273,6 +287,18 @@ class CRM_Utils_SQL_TempTable {
     return $this;
   }
 
+  /**
+   * Set table engine to MEMORY.
+   *
+   * @param bool $value
+   *
+   * @return $this
+   */
+  public function setMemory($value = TRUE) {
+    $this->memory = $value;
+    return $this;
+  }
+
   /**
    * Set table collation to UTF8.
    *
index 7b0aeb5133d235aa8603bb59623b15db6d861222..d45392353d4b799e2eb4d85ef4a0cec082313173 100644 (file)
@@ -67,6 +67,16 @@ class CRM_Utils_Type {
     FORTYFIVE = 45,
     HUGE = 45;
 
+  /**
+   * Maximum size of a MySQL BLOB or TEXT column in bytes.
+   */
+  const BLOB_SIZE = 65535;
+
+  /**
+   * Maximum value of a MySQL signed INT column.
+   */
+  const INT_MAX = 2147483647;
+
   /**
    * Gets the string representation for a data type.
    *
index a00802e65e52a720e50f623d36dd8fc1ec8da482..daddd72af9373d3f71016b4d64549800092ffa94 100644 (file)
@@ -179,6 +179,9 @@ class DynamicFKAuthorization implements EventSubscriberInterface {
       }
 
       if (isset($apiRequest['params']['entity_table'])) {
+        if (!\CRM_Core_DAO_AllCoreTables::isCoreTable($apiRequest['params']['entity_table'])) {
+          throw new \API_Exception("Unrecognized target entity table {$apiRequest['params']['entity_table']}");
+        }
         $this->authorizeDelegate(
           $apiRequest['action'],
           $apiRequest['params']['entity_table'],
@@ -206,6 +209,10 @@ class DynamicFKAuthorization implements EventSubscriberInterface {
    * @throws \Civi\API\Exception\UnauthorizedException
    */
   public function authorizeDelegate($action, $entityTable, $entityId, $apiRequest) {
+    if ($this->isTrusted($apiRequest)) {
+      return;
+    }
+
     $entity = $this->getDelegatedEntityName($entityTable);
     if (!$entity) {
       throw new \API_Exception("Failed to run permission check: Unrecognized target entity table ($entityTable)");
@@ -214,10 +221,6 @@ class DynamicFKAuthorization implements EventSubscriberInterface {
       throw new \Civi\API\Exception\UnauthorizedException("Authorization failed on ($entity): Missing entity_id");
     }
 
-    if ($this->isTrusted($apiRequest)) {
-      return;
-    }
-
     /**
      * @var \Exception $exception
      */
index 678936040470ede6ec3d265ae9feb8ae157e3b78..f4d1569bb1ea01f07b0140924a7e4d9a1d9c7b12 100644 (file)
@@ -132,6 +132,7 @@ class Analyzer {
 
   /**
    * Get a single activity record by type.
+   * This function is only used by SequenceListenerTest
    *
    * @param string $type
    * @throws \Civi\CCase\Exception\MultipleActivityException
@@ -139,7 +140,7 @@ class Analyzer {
    */
   public function getSingleActivity($type) {
     $idx = $this->getActivityIndex(array('activity_type_id', 'id'));
-    $actTypes = array_flip(\CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'name'));
+    $actTypes = array_flip(\CRM_Activity_BAO_Activity::buildOptions('activity_type_id', 'validate'));
     $typeId = $actTypes[$type];
     $count = isset($idx[$typeId]) ? count($idx[$typeId]) : 0;
 
index cd60e81575bcf5e948dee7629795be0e66193117..7135c84b540c373e094d516dab8951bb060e10b0 100644 (file)
@@ -51,7 +51,7 @@ class SequenceListener implements CaseChangeListener {
       return;
     }
 
-    $actTypes = array_flip(\CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'name'));
+    $actTypes = array_flip(\CRM_Activity_BAO_Activity::buildOptions('activity_type_id', 'validate'));
     $actStatuses = array_flip(\CRM_Activity_BAO_Activity::getStatusesByType(\CRM_Activity_BAO_Activity::COMPLETED));
 
     $actIndex = $analyzer->getActivityIndex(array('activity_type_id', 'status_id'));
index 13506a22b276cc2767e0e5a6c6f66d6762f45312..4d2d3f72d423a3af9ab9497d850b315185765123 100644 (file)
@@ -40,6 +40,7 @@ class Requirements {
     'checkMysqlTrigger',
     'checkMysqlThreadStack',
     'checkMysqlLockTables',
+    'checkMysqlUtf8mb4',
   );
 
   /**
@@ -582,4 +583,65 @@ class Requirements {
     return $results;
   }
 
+  /**
+   * @param $db_config
+   *
+   * @return array
+   */
+  public function checkMysqlUtf8mb4($db_config) {
+    $results = array(
+      'title' => 'CiviCRM MySQL utf8mb4 Support',
+      'severity' => $this::REQUIREMENT_OK,
+      'details' => 'Your system supports the MySQL utf8mb4 character set.',
+    );
+
+    $conn = $this->connect($db_config);
+    if (!$conn) {
+      $results['severity'] = $this::REQUIREMENT_ERROR;
+      $results['details'] = 'Could not connect to database';
+      return $results;
+    }
+
+    if (!@mysqli_select_db($conn, $db_config['database'])) {
+      $results['severity'] = $this::REQUIREMENT_ERROR;
+      $results['details'] = 'Could not select the database';
+      mysqli_close($conn);
+      return $results;
+    }
+
+    $r = mysqli_query($conn, 'CREATE TABLE civicrm_utf8mb4_test (id VARCHAR(255), PRIMARY KEY(id(255))) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC ENGINE=INNODB');
+    if (!$r) {
+      $results['severity'] = $this::REQUIREMENT_WARNING;
+      $results['details'] = 'It is recommended, though not yet required, to configure your MySQL server for utf8mb4 support. You will need the following MySQL server configuration: innodb_large_prefix=true innodb_file_format=barracuda innodb_file_per_table=true';
+      mysqli_close($conn);
+      return $results;
+    }
+    mysqli_query('DROP TABLE civicrm_utf8mb4_test');
+
+    // Ensure that the MySQL driver supports utf8mb4 encoding.
+    $version = mysqli_get_client_info($conn);
+    if (strpos($version, 'mysqlnd') !== FALSE) {
+      // The mysqlnd driver supports utf8mb4 starting at version 5.0.9.
+      $version = preg_replace('/^\D+([\d.]+).*/', '$1', $version);
+      if (version_compare($version, '5.0.9', '<')) {
+        $results['severity'] = $this::REQUIREMENT_WARNING;
+        $results['details'] = 'It is recommended, though not yet required, to upgrade your PHP MySQL driver (mysqlnd) to >= 5.0.9 for utf8mb4 support.';
+        mysqli_close($conn);
+        return $results;
+      }
+    }
+    else {
+      // The libmysqlclient driver supports utf8mb4 starting at version 5.5.3.
+      if (version_compare($version, '5.5.3', '<')) {
+        $results['severity'] = $this::REQUIREMENT_WARNING;
+        $results['details'] = 'It is recommended, though not yet required, to upgrade your PHP MySQL driver (libmysqlclient) to >= 5.5.3 for utf8mb4 support.';
+        mysqli_close($conn);
+        return $results;
+      }
+    }
+
+    mysqli_close($conn);
+    return $results;
+  }
+
 }
index 2a10abf7e7357f7fc2a13c7dbbba3c7618ab6e4e..96e41b9d7a73d7a04a5e1bd06eb837586437c704 100644 (file)
@@ -202,7 +202,12 @@ trait Api3TestTrait {
     );
     $result = $this->civicrm_api($entity, 'getsingle', $params);
     if (!is_array($result) || !empty($result['is_error']) || isset($result['values'])) {
-      throw new \Exception('Invalid getsingle result' . print_r($result, TRUE));
+      $unfilteredResult = $this->civicrm_api($entity, 'get', $params);
+      throw new \Exception(
+        'Invalid getsingle result' . print_r($result, TRUE)
+        . "\n entity: $entity . \n params \n " . print_r($params, TRUE)
+        . "\n entities retrieved with blank params \n" .  print_r($unfilteredResult, TRUE)
+      );
     }
     if ($checkAgainst) {
       // @todo - have gone with the fn that unsets id? should we check id?
index a8b0370ad409aa7f3936b9181bba09dbe984146f..ab460ab7e9c51a5f0e779449c1a8314cd77c17c3 100644 (file)
     };
   });
 
+  angular.module('crmUtil').factory('crmLoadScript', function($q) {
+    return function(url) {
+      var deferred = $q.defer();
+
+      CRM.loadScript(url).done(function() {
+        deferred.resolve(true);
+      });
+
+      return deferred.promise;
+    };
+  });
+
 })(angular, CRM.$, CRM._);
index 07913f90017762b010cd6bd21901be04df7bc196..e2781de7142033c4ebfc5304c764c567173b98e1 100644 (file)
@@ -430,13 +430,15 @@ function _civicrm_api3_contact_get_supportanomalies(&$params, &$options) {
   }
   if (isset($params['group'])) {
     $groups = $params['group'];
-    $allGroups = CRM_Core_PseudoConstant::group();
+    $groupsByTitle = CRM_Core_PseudoConstant::group();
+    $groupsByName = CRM_Contact_BAO_GroupContact::buildOptions('group_id', 'validate');
+    $allGroups = array_merge(array_flip($groupsByTitle), array_flip($groupsByName));
     if (is_array($groups) && in_array(key($groups), CRM_Core_DAO::acceptedSQLOperators(), TRUE)) {
       // Get the groups array.
       $groupsArray = $groups[key($groups)];
       foreach ($groupsArray as &$group) {
-        if (!is_numeric($group) && array_search($group, $allGroups)) {
-          $group = array_search($group, $allGroups);
+        if (!is_numeric($group) && !empty($allGroups[$group])) {
+          $group = $allGroups[$group];
         }
       }
       // Now reset the $groups array with the ids not the titles.
@@ -445,17 +447,17 @@ function _civicrm_api3_contact_get_supportanomalies(&$params, &$options) {
     // handle format like 'group' => array('title1', 'title2').
     elseif (is_array($groups)) {
       foreach ($groups as $k => &$group) {
-        if (!is_numeric($group) && array_search($group, $allGroups)) {
-          $group = array_search($group, $allGroups);
+        if (!is_numeric($group) && !empty($allGroups[$group])) {
+          $group = $allGroups[$group];
         }
-        if (!is_numeric($k) && array_search($k, $allGroups)) {
+        if (!is_numeric($k) && !empty($allGroups[$k])) {
           unset($groups[$k]);
-          $groups[array_search($k, $allGroups)] = $group;
+          $groups[$allGroups[$k]] = $group;
         }
       }
     }
-    elseif (!is_numeric($groups) &&  array_search($groups, $allGroups)) {
-      $groups = array_search($groups, $allGroups);
+    elseif (!is_numeric($groups) &&  !empty($allGroups[$groups])) {
+      $groups = $allGroups[$groups];
     }
     $params['group'] = $groups;
   }
similarity index 64%
rename from CRM/Report/Form/Event.php
rename to api/v3/Exception.php
index 4e459783d63953484770fca36d76a6abab796b7f..9c50d4a35c1b25f814591978ba90cea98c11aef1 100644 (file)
  | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
  +--------------------------------------------------------------------+
  */
-
 /**
+ * Get a Dedupe Exception.
  *
- * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2019
- * $Id$
+ * @param array $params
+ *   Array per getfields metadata.
  *
+ * @return array
+ *   Array of all found dedupe exception object property values.
  */
-class CRM_Report_Form_Event extends CRM_Report_Form {
-  // Nothing here.
-  // FIXME: Do these reports really have nothing in common? Really?
-
+function civicrm_api3_exception_get($params) {
+  return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
+}
+/**
+ * Create or update an dedupe exception.
+ *
+ * @param array $params
+ *          Array per getfields metadata.
+ *
+ * @return array api result array
+ */
+function civicrm_api3_exception_create($params) {
+  return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'Exception');
+}
+/**
+ * Delete an existing Exception.
+ *
+ * This method is used to delete any existing Exception given its id.
+ *
+ * @param array $params
+ *          [id]
+ *
+ * @return array api result array
+ */
+function civicrm_api3_exception_delete($params) {
+  return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params);
 }
index 355ea7ad50c5e2cc7da99f7685e8fc91f5e4a426..a4292a5b6b719e52c24ba52e565cce07fdc5c1c3 100644 (file)
@@ -235,3 +235,49 @@ function _civicrm_api3_payment_cancel_spec(&$params) {
     ),
   );
 }
+
+/**
+ * Send a payment confirmation.
+ *
+ * @param array $params
+ *   Input parameters.
+ *
+ * @return array
+ * @throws Exception
+ */
+function civicrm_api3_payment_sendconfirmation($params) {
+  $allowedParams = [
+    'receipt_from_email',
+    'receipt_from_name',
+    'cc_receipt',
+    'bcc_receipt',
+    'receipt_text',
+    'id',
+  ];
+  $input = array_intersect_key($params, array_flip($allowedParams));
+  // use either the contribution or membership receipt, based on whether it’s a membership-related contrib or not
+  $result = CRM_Financial_BAO_Payment::sendConfirmation($input);
+  return civicrm_api3_create_success([
+    $params['id'] => [
+      'is_sent' => $result[0],
+      'subject' => $result[1],
+      'message_txt' => $result[2],
+      'message_html' => $result[3],
+  ]]);
+}
+
+/**
+ * Adjust Metadata for sendconfirmation action.
+ *
+ * The metadata is used for setting defaults, documentation & validation.
+ *
+ * @param array $params
+ *   Array of parameters determined by getfields.
+ */
+function _civicrm_api3_payment_sendconfirmation_spec(&$params) {
+  $params['id'] = array(
+    'api.required' => 1,
+    'title' => ts('Payment ID'),
+    'type' => CRM_Utils_Type::T_INT,
+  );
+}
index fbd2229b43449f989b5db64bb91c6c0b3a8cfd6a..e40429345d856401fef94a3cfb949329ad9531ca 100644 (file)
@@ -30,6 +30,7 @@
     "font-awesome": "~4",
     "angular-bootstrap": "^2.5.0",
     "angular-sanitize": "~1.5.0",
+    "smartmenus": "~1.1",
     "phantomjs-polyfill": "^0.0.2"
   },
   "resolutions": {
index 829f8ae59f820ba24374d436f98ee6e103a72374..0a2bb8786f40056bd3f93bada35d44cbbbf54bd5 100644 (file)
     "zetacomponents/base": "1.7.*",
     "zetacomponents/mail": "dev-1.7-civi",
     "marcj/topsort": "~1.1",
-    "phpoffice/phpword": "^0.14.0",
+    "phpoffice/phpword": "^0.15.0",
     "pear/Validate_Finance_CreditCard": "dev-master",
     "civicrm/civicrm-cxn-rpc": "~0.19.01.08",
     "pear/Auth_SASL": "1.1.0",
     "pear/Net_SMTP": "1.6.*",
     "pear/Net_socket": "1.0.*",
+    "pear/mail": "^1.4",
     "civicrm/civicrm-setup": "~0.2.0",
     "guzzlehttp/guzzle": "^6.3",
-    "psr/simple-cache": "~1.0.1"
+    "psr/simple-cache": "~1.0.1",
+    "cweagans/composer-patches": "~1.0"
   },
   "repositories": [
     {
@@ -71,6 +73,7 @@
       "bash tools/scripts/composer/tcpdf-cleanup.sh",
       "bash tools/scripts/composer/pear-exception-fix.sh",
       "bash tools/scripts/composer/net-smtp-fix.sh",
+      "bash tools/scripts/composer/pear-mail-fix.sh",
       "bash tools/scripts/composer/phpword-jquery.sh"
     ],
     "post-update-cmd": [
       "bash tools/scripts/composer/tcpdf-cleanup.sh",
       "bash tools/scripts/composer/pear-exception-fix.sh",
       "bash tools/scripts/composer/net-smtp-fix.sh",
+      "bash tools/scripts/composer/pear-mail-fix.sh",
       "bash tools/scripts/composer/phpword-jquery.sh"
     ]
+  },
+  "extra": {
+    "patches": {
+      "phpoffice/common": {
+        "Fix handling of libxml_disable_entity_loader": "tools/scripts/composer/patches/phpoffice-common-xml-entity-fix.patch"
+      },
+      "phpoffice/phpword": {
+        "Fix handling of libxml_disable_entity_loader": "tools/scripts/composer/patches/phpword-libxml-fix-global-handling.patch"
+      }
+    }
   }
 }
index b3028039cf7f540ebd21c4925d0413e8b6758497..5e4c864c041d9da7b83547bc40bb059850dd629a 100644 (file)
@@ -4,7 +4,7 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
         "This file is @generated automatically"
     ],
-    "content-hash": "3a5a920dad6f16458645ee4b5944716a",
+    "content-hash": "55c8f835d55c424d93e0e9dad1efc729",
     "packages": [
         {
             "name": "civicrm/civicrm-cxn-rpc",
             "description": "CiviCRM installation library",
             "time": "2018-01-23T06:26:55+00:00"
         },
+        {
+            "name": "cweagans/composer-patches",
+            "version": "1.6.5",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/cweagans/composer-patches.git",
+                "reference": "2ec4f00ff5fb64de584c8c4aea53bf9053ecb0b3"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/cweagans/composer-patches/zipball/2ec4f00ff5fb64de584c8c4aea53bf9053ecb0b3",
+                "reference": "2ec4f00ff5fb64de584c8c4aea53bf9053ecb0b3",
+                "shasum": ""
+            },
+            "require": {
+                "composer-plugin-api": "^1.0",
+                "php": ">=5.3.0"
+            },
+            "require-dev": {
+                "composer/composer": "~1.0",
+                "phpunit/phpunit": "~4.6"
+            },
+            "type": "composer-plugin",
+            "extra": {
+                "class": "cweagans\\Composer\\Patches"
+            },
+            "autoload": {
+                "psr-4": {
+                    "cweagans\\Composer\\": "src"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "license": [
+                "BSD-3-Clause"
+            ],
+            "authors": [
+                {
+                    "name": "Cameron Eagans",
+                    "email": "me@cweagans.net"
+                }
+            ],
+            "description": "Provides a way to patch Composer packages.",
+            "time": "2018-05-11T18:00:16+00:00"
+        },
         {
             "name": "dompdf/dompdf",
             "version": "v0.8.0",
             "extra": {
                 "branch-alias": {
                     "dev-develop": "0.7-dev"
-                },
-                "patches_applied": {
-                    "Fix Fatal error: Uncaught Dompdf Exception: No block-level parent found.": "tools/scripts/composer/patches/dompdf_no_block_level_parent_fix.patch"
                 }
             },
             "autoload": {
             "description": "Abstraction of various SASL mechanism responses",
             "time": "2017-03-07T14:37:05+00:00"
         },
+        {
+            "name": "pear/console_getopt",
+            "version": "v1.4.1",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/pear/Console_Getopt.git",
+                "reference": "82f05cd1aa3edf34e19aa7c8ca312ce13a6a577f"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/pear/Console_Getopt/zipball/82f05cd1aa3edf34e19aa7c8ca312ce13a6a577f",
+                "reference": "82f05cd1aa3edf34e19aa7c8ca312ce13a6a577f",
+                "shasum": ""
+            },
+            "type": "library",
+            "autoload": {
+                "psr-0": {
+                    "Console": "./"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "include-path": [
+                "./"
+            ],
+            "license": [
+                "BSD-2-Clause"
+            ],
+            "authors": [
+                {
+                    "name": "Greg Beaver",
+                    "email": "cellog@php.net",
+                    "role": "Helper"
+                },
+                {
+                    "name": "Andrei Zmievski",
+                    "email": "andrei@php.net",
+                    "role": "Lead"
+                },
+                {
+                    "name": "Stig Bakken",
+                    "email": "stig@php.net",
+                    "role": "Developer"
+                }
+            ],
+            "description": "More info available on: http://pear.php.net/package/Console_Getopt",
+            "time": "2015-07-20T20:28:12+00:00"
+        },
+        {
+            "name": "pear/mail",
+            "version": "v1.4.1",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/pear/Mail.git",
+                "reference": "9609ed5e42ac5b221dfd9af85de005c59d418ee7"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/pear/Mail/zipball/9609ed5e42ac5b221dfd9af85de005c59d418ee7",
+                "reference": "9609ed5e42ac5b221dfd9af85de005c59d418ee7",
+                "shasum": ""
+            },
+            "require": {
+                "pear/pear-core-minimal": "~1.9",
+                "php": ">=5.2.1"
+            },
+            "require-dev": {
+                "pear/pear": "*"
+            },
+            "suggest": {
+                "pear/net_smtp": "Install optionally via your project's composer.json"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-0": {
+                    "Mail": "./"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "include-path": [
+                "./"
+            ],
+            "license": [
+                "BSD-2-Clause"
+            ],
+            "authors": [
+                {
+                    "name": "Chuck Hagenbuch",
+                    "email": "chuck@horde.org",
+                    "role": "Lead"
+                },
+                {
+                    "name": "Richard Heyes",
+                    "email": "richard@phpguru.org",
+                    "role": "Developer"
+                },
+                {
+                    "name": "Aleksander Machniak",
+                    "email": "alec@alec.pl",
+                    "role": "Developer"
+                }
+            ],
+            "description": "Class that provides multiple interfaces for sending emails.",
+            "homepage": "http://pear.php.net/package/Mail",
+            "time": "2017-04-11T17:27:29+00:00"
+        },
         {
             "name": "pear/net_smtp",
             "version": "1.6.3",
                 "pear/auth_sasl": "Install optionally via your project's composer.json"
             },
             "type": "library",
-            "extra": {
-                "patches_applied": {
-                    "CRM-8744 Display CiviCRM Specific error message": "tools/scripts/composer/patches/net-smtp-patch.patch",
-                    "Fix PHP7 Compliance": "tools/scripts/composer/patches/net-smtp-php7-patch.patch",
-                    "Fix Pass by reference issues": "tools/scripts/composer/patches/net-smtp-ref-patch.patch",
-                    "Fix TLS support issue in PHP5.6": "tools/scripts/composer/patches/net-smtp-tls-patch.patch"
-                }
-            },
             "autoload": {
                 "psr-0": {
                     "Net": "./"
             "description": "More info available on: http://pear.php.net/package/Net_Socket",
             "time": "2014-02-20T19:27:06+00:00"
         },
+        {
+            "name": "pear/pear-core-minimal",
+            "version": "v1.10.7",
+            "source": {
+                "type": "git",
+                "url": "https://github.com/pear/pear-core-minimal.git",
+                "reference": "19a3e0fcd50492c4357372f623f55f1b144346da"
+            },
+            "dist": {
+                "type": "zip",
+                "url": "https://api.github.com/repos/pear/pear-core-minimal/zipball/19a3e0fcd50492c4357372f623f55f1b144346da",
+                "reference": "19a3e0fcd50492c4357372f623f55f1b144346da",
+                "shasum": ""
+            },
+            "require": {
+                "pear/console_getopt": "~1.4",
+                "pear/pear_exception": "~1.0"
+            },
+            "replace": {
+                "rsky/pear-core-min": "self.version"
+            },
+            "type": "library",
+            "autoload": {
+                "psr-0": {
+                    "": "src/"
+                }
+            },
+            "notification-url": "https://packagist.org/downloads/",
+            "include-path": [
+                "src/"
+            ],
+            "license": [
+                "BSD-3-Clause"
+            ],
+            "authors": [
+                {
+                    "name": "Christian Weiske",
+                    "email": "cweiske@php.net",
+                    "role": "Lead"
+                }
+            ],
+            "description": "Minimal set of PEAR core files to be used as composer dependency",
+            "time": "2018-12-05T20:03:52+00:00"
+        },
         {
             "name": "pear/pear_exception",
             "version": "v1.0.0",
         },
         {
             "name": "phpoffice/common",
-            "version": "v0.2.6",
+            "version": "0.2.9",
             "source": {
                 "type": "git",
                 "url": "https://github.com/PHPOffice/Common.git",
-                "reference": "c9be70c80637c28c728be78e66aad4878a34f8dd"
+                "reference": "edb5d32b1e3400a35a5c91e2539ed6f6ce925e4d"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/PHPOffice/Common/zipball/c9be70c80637c28c728be78e66aad4878a34f8dd",
-                "reference": "c9be70c80637c28c728be78e66aad4878a34f8dd",
+                "url": "https://api.github.com/repos/PHPOffice/Common/zipball/edb5d32b1e3400a35a5c91e2539ed6f6ce925e4d",
+                "reference": "edb5d32b1e3400a35a5c91e2539ed6f6ce925e4d",
                 "shasum": ""
             },
             "require": {
                 "phpdocumentor/phpdocumentor": "2.*",
                 "phploc/phploc": "2.*",
                 "phpmd/phpmd": "2.*",
-                "phpunit/phpunit": "3.7.*",
+                "phpunit/phpunit": "^4.8.36 || ^7.0",
                 "sebastian/phpcpd": "2.*",
                 "squizlabs/php_codesniffer": "2.*"
             },
             "type": "library",
+            "extra": {
+                "patches_applied": {
+                    "Fix handling of libxml_disable_entity_loader": "tools/scripts/composer/patches/phpoffice-common-xml-entity-fix.patch"
+                }
+            },
             "autoload": {
                 "psr-4": {
                     "PhpOffice\\Common\\": "src/Common/"
                 "office",
                 "php"
             ],
-            "time": "2016-07-07T17:26:55+00:00"
+            "time": "2018-07-13T14:12:34+00:00"
         },
         {
             "name": "phpoffice/phpword",
-            "version": "v0.14.0",
+            "version": "0.15.0",
             "source": {
                 "type": "git",
                 "url": "https://github.com/PHPOffice/PHPWord.git",
-                "reference": "b614497ae6dd44280be1c2dda56772198bcd25ae"
+                "reference": "dfa2f36cad2b632b7ab1c56473e4f5db9a7caf7f"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/PHPOffice/PHPWord/zipball/b614497ae6dd44280be1c2dda56772198bcd25ae",
-                "reference": "b614497ae6dd44280be1c2dda56772198bcd25ae",
+                "url": "https://api.github.com/repos/PHPOffice/PHPWord/zipball/dfa2f36cad2b632b7ab1c56473e4f5db9a7caf7f",
+                "reference": "dfa2f36cad2b632b7ab1c56473e4f5db9a7caf7f",
                 "shasum": ""
             },
             "require": {
                 "ext-xml": "*",
                 "php": "^5.3.3 || ^7.0",
-                "phpoffice/common": "^0.2",
-                "zendframework/zend-escaper": "^2.2",
-                "zendframework/zend-stdlib": "^2.2 || ^3.0"
+                "phpoffice/common": "^0.2.9",
+                "zendframework/zend-escaper": "^2.2"
             },
             "require-dev": {
                 "dompdf/dompdf": "0.8.*",
-                "friendsofphp/php-cs-fixer": "^2.0",
-                "mpdf/mpdf": "5.* || 6.* || 7.*",
-                "phpdocumentor/phpdocumentor": "2.*",
+                "ext-gd": "*",
+                "ext-zip": "*",
+                "friendsofphp/php-cs-fixer": "^2.2",
+                "mpdf/mpdf": "5.7.4 || 6.* || 7.*",
+                "php-coveralls/php-coveralls": "1.1.0 || ^2.0",
                 "phploc/phploc": "2.* || 3.* || 4.*",
                 "phpmd/phpmd": "2.*",
-                "phpunit/phpunit": "^4.8.36 || ^5.0",
-                "squizlabs/php_codesniffer": "^2.7",
+                "phpunit/phpunit": "^4.8.36 || ^7.0",
+                "squizlabs/php_codesniffer": "^2.9",
                 "tecnickcom/tcpdf": "6.*"
             },
             "suggest": {
                 "ext-zip": "Allows writing OOXML and ODF"
             },
             "type": "library",
+            "extra": {
+                "branch-alias": {
+                    "dev-develop": "0.16-dev"
+                },
+                "patches_applied": {
+                    "Fix handling of libxml_disable_entity_loader": "tools/scripts/composer/patches/phpword-libxml-fix-global-handling.patch"
+                }
+            },
             "autoload": {
                 "psr-4": {
                     "PhpOffice\\PhpWord\\": "src/PhpWord"
                 "word",
                 "writer"
             ],
-            "time": "2017-12-29T01:30:53+00:00"
+            "time": "2018-07-14T16:59:43+00:00"
         },
         {
             "name": "phpseclib/phpseclib",
index 73e5e72fd82cfc6155123e35a5e23aca0688b54b..087f64c56c4858c91fb83bbdbd88e2ce406a1024 100644 (file)
@@ -5,8 +5,7 @@
  * Other civi blocks outside the main container also have the class crm-container (but not the id)
  * All styles should start with .crm-container unless they are specific to the main div only
  */
-.crm-container input,
-#civicrm-menu input {
+.crm-container input {
   box-sizing: content-box;
 }
 
@@ -2922,7 +2921,6 @@ tbody.scrollContent tr.alternateRow {
 
 
 .crm-container div.status,
-div.m ul#civicrm-menu,
 .crm-container #help,
 .crm-container .help,
 .crm-container .ui-tabs-panel,
diff --git a/css/civicrmNavigation.css b/css/civicrmNavigation.css
deleted file mode 100644 (file)
index 5cf48d3..0000000
+++ /dev/null
@@ -1,181 +0,0 @@
-html>body div.outerbox
-{
-  padding: 0 5px 5px 0;
-  z-index:999999;
-  font-size: 13px;
-  margin-top:2px;
-}
-html>body div.outerbox div.shadowbox1
-{
-  position: absolute;
-  right: 0;
-  bottom: 5px;
-  width: 5px;
-  height: 100%;
-  background: url(../i/myshadow.png) no-repeat right top;
-}
-html>body div.outerbox div.shadowbox2
-{
-  position: absolute;
-  bottom: 0;
-  right: 5px;
-  height: 5px;
-  width: 100%;
-  background: url(../i/myshadow.png) left bottom;
-}
-html>body div.outerbox div.shadowbox3
-{
-  position: absolute;
-  bottom: 0;
-  right: 0;
-  height: 5px;
-  width: 5px;
-  background: url(../i/myshadow.png) no-repeat right bottom;
-}
-html>body .innerbox
-{
-  margin: 0;
-  z-index:999999;
-  margin-left:10px;
-}
-
-#root-menu-div ul {
-  border: 1px solid #000;
-}
-#root-menu-div li{
-  white-space:nowrap;
-  background-image: none;
-  text-align: left;
-}
-* html #root-menu-div li{
-  height: 1.5em; /* fixing ie6 problem */
-}
-#civicrm-menu,
-#root-menu-div ul {
-  list-style: none;
-  margin: 0;
-  padding: 0;
-  background:#5D5D5D;
-  color: white;
-  cursor: default;
-  font-size: 12px;
-  font-family: Tahoma, Verdana, Arial, sans-serif;
-}
-
-#civicrm-menu {
-  position:fixed;
-  top:0;
-  left:0;
-  background:#1B1B1B repeat-x;
-  width:100%;
-  height:27px;
-  z-index:99999;
-  overflow: hidden;
-}
-
-li.menu-separator.active{
-  background-color: transparent;
-}
-
-.menu-ul li.active {
-  background-color: #aaa;
-}
-
-#civicrm-menu .activetarget{
-  background-color: #aaa;
-}
-
-#civicrm-menu li a, #root-menu-div li a {
-  color:white;
-  cursor:pointer;
-  display:block;
-  font-weight:normal;
-  text-decoration:none;
-  border:0;
-}
-
-* html div.menu-item {
-  display: inline; /* fixes problem in ie6 */
-}
-
-li.menumain {
-  float: left;
-  padding: 3px 10px;
-  background-image: none;
-  border-right: 1px solid #5D5D5D;
-  margin:0;
-}
-
-#root-menu-div .menu-ul li {
-  margin: 0;
-  padding: 0 20px 0 2px;
-}
-
-div.menu-item {
-  padding: 1px 10px 1px 4px;
-  height: auto;
-}
-#civicrm-menu .menu-item-arrow,
-#root-menu-div .menu-item-arrow {
-  position: absolute;
-  right: 4px;
-  top: 6px;
-}
-#civicrm-menu i,
-#root-menu-div i {
-  margin-right: 5px;
-}
-li.menu-separator{
-  border-bottom: 1px solid #000;
-  font-size: 0; /* for ie */
-  height: 0;
-  line-height: 0; /* for ie */
-  margin: 2px 0;
-}
-#civicrm-menu .crm-logo-sm,
-.crm-container .crm-logo-sm {
-  background: url('../i/logo_sm.png') no-repeat;
-  display: inline-block;
-  width: 16px;
-  height: 16px;
-  vertical-align: middle;
-}
-
-#civicrm-menu .ui-autocomplete-input,
-.crm-container .ui-autocomplete-input {
-  background: white url("../bower_components/select2/select2.png") no-repeat scroll right -23px;
-  padding-right: 16px;
-  /* so that text doesn't flow on top of icon */
-}
-
-#civicrm-menu #crm-qsearch {
-  padding: 1px 0 1px 2px;
-  background-color: transparent !important;
-  border-right: none;
-}
-
-#civicrm-menu #crm-qsearch input {
-  background-color: #eaeaea;
-  border: 1px solid black;
-  margin: 0;
-  padding: 2px 16px 3px 2px;
-  height: 17px;
-}
-#civicrm-menu #crm-qsearch input:hover,
-#civicrm-menu #crm-qsearch input:focus,
-#civicrm-menu #crm-qsearch.activetarget input {
-  background-color: #ffffff;
-}
-/* This ensures the drop-down menus appear at the right height */
-#civicrm-menu > li.menumain {
-  height: 19px !important;
-}
-
-/* No results */
-.crm-quickSearch-results.ui-menu-disabled {
-  opacity: .9;
-  background-color: #f8f8f8;
-}
-.crm-quickSearch-results.ui-menu-disabled li {
-  cursor: default;
-}
diff --git a/css/crm-menubar.css b/css/crm-menubar.css
new file mode 100644 (file)
index 0000000..0680077
--- /dev/null
@@ -0,0 +1,347 @@
+/* CiviCRM navigation menu stylesheet */
+
+#civicrm-menu-nav {
+  line-height: 0;
+  text-align: left;
+  font-size: 13px;
+}
+#civicrm-menu {
+  background-color: #f2f2f2;
+       width: 100%;
+  z-index: 500;
+  height: auto;
+  margin: 0;
+}
+#civicrm-menu i {
+  margin-right: 3px;
+}
+#civicrm-menu li {
+  border: none;
+  padding: 0;
+}
+#civicrm-menu li a {
+  padding: 12px 8px;
+  text-decoration: none;
+  color: #333;
+  box-shadow: none;
+  border: none;
+}
+#civicrm-menu li a[href="#"] {
+  cursor: default;
+}
+#civicrm-menu li li a {
+  padding: 6px 36px 6px 10px;
+}
+#civicrm-menu li.crm-menu-border-bottom:not(:last-child) {
+  border-bottom: 1px solid #bbb;
+}
+#civicrm-menu li:not(.crm-menu-border-bottom) + li.crm-menu-border-top {
+  border-top: 1px solid #bbb;
+}
+#civicrm-menu li a:focus,
+#civicrm-menu li a:hover,
+#civicrm-menu li a.highlighted {
+  text-decoration: none;
+  background-color: #fff;
+}
+#civicrm-menu li li .sub-arrow:before {
+  content: "\f0da";
+       font-family: 'FontAwesome';
+  color: #666;
+       float: right;
+       margin-right: -25px;
+}
+/* x icon */
+#crm-menubar-state:checked ~ .crm-menubar-toggle-btn .crm-menubar-toggle-btn-icon {
+  height: 0;
+  background: transparent;
+}
+#crm-menubar-state:checked ~ .crm-menubar-toggle-btn .crm-menubar-toggle-btn-icon:before {
+  top: 0;
+  -webkit-transform: rotate(-45deg);
+  transform: rotate(-45deg);
+}
+#crm-menubar-state:checked ~ .crm-menubar-toggle-btn .crm-menubar-toggle-btn-icon:after {
+  top: 0;
+  -webkit-transform: rotate(45deg);
+  transform: rotate(45deg);
+}
+/* hide menu state checkbox (keep it visible to screen readers) */
+#civicrm-menu-nav #crm-menubar-state {
+  position: absolute;
+  width: 1px;
+  height: 1px;
+  margin: -1px;
+  border: 0;
+  padding: 0;
+  overflow: hidden;
+  clip: rect(1px,1px,1px,1px);
+}
+#civicrm-menu-nav .crm-menubar-toggle-btn {
+  position: relative;
+  display: inline-block;
+  width: 57px;
+  height: 28px;
+  text-indent: 28px;
+  white-space: nowrap;
+  overflow: hidden;
+  cursor: pointer;
+  color: transparent;
+  -webkit-tap-highlight-color: rgba(0,0,0,0);
+  background-color: #333;
+}
+
+/* responsive icon */
+
+#civicrm-menu-nav .crm-menubar-toggle-btn-icon,
+#civicrm-menu-nav .crm-menubar-toggle-btn-icon:before,
+#civicrm-menu-nav .crm-menubar-toggle-btn-icon:after {
+  position: absolute;
+  top: 50%;
+  left: 27px;
+  height: 2px;
+  width: 24px;
+  background: #bbb;
+  -webkit-transition: all 0.25s;
+  transition: all 0.25s;
+}
+#civicrm-menu-nav .crm-menubar-toggle-btn-icon:before {
+  content: '';
+  top: -7px;
+  left: 0;
+}
+#civicrm-menu-nav .crm-menubar-toggle-btn-icon:after {
+  content: '';
+  top: 7px;
+  left: 0;
+}
+
+/* Quicksearch */
+#crm-qsearch {
+  padding: 1px 0 1px 2px;
+  background-color: transparent !important;
+}
+#civicrm-menu #crm-qsearch > a {
+  padding: 2px 0 0 2px;
+}
+
+input#crm-qsearch-input {
+  box-sizing: border-box;
+  background-color: #eaeaea;
+  font-size: 13px;
+  border: 1px solid #ccc;
+  margin: 4px 4px 0;
+  padding: 2px 8px;
+  height: 30px;
+  width: 30px;
+  transition: width .5s .05s, background-color .3s .05s;
+}
+a.highlighted #crm-qsearch-input,
+#crm-qsearch-input:focus,
+#crm-qsearch-input.has-user-input {
+  background-color: white;
+  width: 130px;
+}
+input#crm-qsearch-input:-ms-input-placeholder {
+  font-family: 'FontAwesome';
+}
+input#crm-qsearch-input::-webkit-input-placeholder {
+  font-family: 'FontAwesome';
+}
+input#crm-qsearch-input::-moz-placeholder {
+  font-family: 'FontAwesome';
+}
+input#crm-qsearch-input::placeholder {
+  font-family: 'FontAwesome';
+}
+
+ul.crm-quickSearch-results {
+  z-index: 100001;
+}
+ul.crm-quickSearch-results.ui-state-disabled {
+  opacity: .8;
+}
+
+#civicrm-menu-nav .crm-logo-sm {
+  background: url(../i/logo_sm.png) no-repeat;
+  display: inline-block;
+  width: 16px;
+  height: 16px;
+  margin: 0 2px;
+}
+
+#civicrm-menu #crm-menubar-toggle-position {
+  float: right;
+}
+#civicrm-menu #crm-menubar-toggle-position a i {
+  color: #888;
+  margin: 0;
+  border-top: 2px solid #888;
+  font-size: 11px;
+}
+body.crm-menubar-over-cms-menu #crm-menubar-toggle-position a i {
+  transform: rotate(180deg);
+}
+
+@media (min-width: 768px) {
+
+  /* Switch to desktop layout
+  -----------------------------------------------
+     These transform the menu tree from
+     collapsible to desktop (navbar + dropdowns)
+  -----------------------------------------------*/
+  /* start... (it's not recommended editing these rules) */
+  #civicrm-menu ul{position:absolute;width:12em;}
+  #civicrm-menu li{float:left;}
+  #civicrm-menu.sm-rtl li{float:right;}
+  #civicrm-menu ul li,#civicrm-menu.sm-rtl ul li,#civicrm-menu.sm-vertical li{float:none;}
+  #civicrm-menu a{white-space:nowrap;}
+  #civicrm-menu ul a,#civicrm-menu.sm-vertical a{white-space:normal;}
+  #civicrm-menu .sm-nowrap > li > a,#civicrm-menu .sm-nowrap > li > :not(ul) a{white-space:nowrap;}
+  /* ...end */
+
+  /* hide the button in desktop view */
+  #civicrm-menu-nav .crm-menubar-toggle-btn {
+    position: absolute;
+    top: -99999px;
+  }
+
+  #civicrm-menu {
+    border-bottom: 1px solid #ccc;
+  }
+
+  body.crm-menubar-below-cms-menu > #civicrm-menu-nav #civicrm-menu {
+    top: 30px;
+  }
+
+  #civicrm-menu ul {
+    background-color: #fff;
+    box-shadow: 0px 0px 2px 0 rgba(0,0,0,0.3);
+  }
+
+  #civicrm-menu > li > a {
+    height: 40px;
+  }
+
+  #civicrm-menu > li > a.highlighted {
+    z-index: 200000;
+  }
+
+  #civicrm-menu ul li a:focus,
+  #civicrm-menu ul li a:hover,
+  #civicrm-menu ul li a.highlighted {
+    background-color: #f2f2f2;
+    color: #222;
+  }
+
+  body.crm-menubar-over-cms-menu #civicrm-menu,
+  body.crm-menubar-below-cms-menu #civicrm-menu {
+    position: fixed;
+    top: 0;
+  }
+
+  body.crm-menubar-over-cms-menu #civicrm-menu {
+    z-index: 99999;
+  }
+
+  body.crm-menubar-hidden #civicrm-menu {
+    display: none;
+  }
+}
+
+@media (max-width: 768px) {
+  /* hide the menu in mobile view */
+  #crm-menubar-state:not(:checked) ~ #civicrm-menu {
+    display: none;
+  }
+  #civicrm-menu {
+    z-index: 100000;
+    background-color: #333;
+  }
+       #civicrm-menu ul {
+               background-color: #444;
+       }
+       #civicrm-menu ul ul {
+               background-color: #555;
+       }
+       #civicrm-menu ul ul ul {
+               background-color: #666;
+       }
+  #civicrm-menu li {
+    padding: 5px;
+  }
+       #civicrm-menu li a {
+               text-align: center;
+               font-size: 14px;
+    color: #ddd;
+       }
+  #civicrm-menu li a:focus,
+  #civicrm-menu li a:hover,
+  #civicrm-menu li a.highlighted {
+    background-color: #676767;
+    color: #fff;
+  }
+  #civicrm-menu li .sub-arrow:before,
+  #civicrm-menu li li .sub-arrow:before {
+    content: "\f0da";
+    font-family: 'FontAwesome';
+    color: #bbb;
+    float: none;
+    margin-left: 10px;
+  }
+  #civicrm-menu li a.highlighted .sub-arrow:before {
+    content: "\f0d7";
+  }
+  #civicrm-menu-nav {
+    position: fixed;
+    background: transparent;
+    pointer-events: none;
+    top: 0;
+    left: 0;
+    height: 50px;
+    width: 100%;
+    z-index: 100000;
+  }
+  #civicrm-menu-nav > * {
+    pointer-events: auto;
+  }
+  #civicrm-menu-nav .crm-menubar-toggle-btn {
+    margin-left: 20px;
+    z-index: 110000;
+    margin-top: 10px;
+  }
+  #civicrm-menu-nav .crm-menubar-toggle-btn span.crm-menu-logo {
+    display: block;
+    position: absolute;
+    left: 5px;
+    width: 18px;
+    height: 18px;
+    background: url(../i/logo_lg.png) no-repeat;
+    background-size: 18px;
+    top: 6px;
+  }
+  #crm-qsearch {
+    text-align: center;
+  }
+  #crm-qsearch .sub-arrow {
+    display: none;
+  }
+
+  #civicrm-menu li[data-name="Hide Menu"] {
+    display: none;
+  }
+
+  #crm-qsearch-input {
+    width: 14em !important;
+  }
+
+  #crm-menubar-toggle-position {
+    display: none;
+  }
+
+  /* Make sure we can click overlapped submenus in responsive mode */
+  #civicrm-menu li ul li {
+    z-index: 110000;
+    background-color: inherit;
+  }
+}
index 5c5d55e41576ad77ae75a8a363d8148c995a99b4..d49a764898243566d1713debc017d32c8fae5e83 100644 (file)
@@ -294,10 +294,6 @@ br.clear {
 /* Joomla Admin Menu alterations */
 /* Moved from civicrm.css in v3.2 */
 
-ul#civicrm-menu {
-  position:relative;
-  z-index: 1;
-}
 
 div#toolbar-box div.m {
   padding: 0px !important;
@@ -310,9 +306,6 @@ div#toolbar-box, div#toolbar-box div.m{
   height: auto;
 }
 
-ul#civicrm-menu li#crm-qsearch {
-  height:0px;
-}
 .crm-tab-button,
 .ui-tabs .ui-tabs-nav li {
   border: 1px;
@@ -390,25 +383,12 @@ body.admin.com_civicrm .container-fluid.container-main {
        padding: 0;
        border-top: 1px solid #787878;
 }
+body.admin.com_civicrm.task-civicrmupgrade .container-fluid.container-main {
+       padding: 10px 25px 25px;
+}
 body.admin.com_civicrm #crm-nav-menu-container {
        padding-bottom: 0 !important;
 }
 body.admin.com_civicrm #content-right {
        padding: 12px;
 }
-body.admin.com_civicrm #civicrm-menu #crm-qsearch {
-  padding-left: 20px;
-}
-body.admin.com_civicrm #root-menu-div div.outerbox:first-of-type {
-       margin-left: 20px;
-} 
-body.admin.com_civicrm div.outerbox {
-       z-index: 1000;
-}
-
-/* Shoreditch-specific */
-
-body.admin.com_civicrm {
-       padding-top: 0px !important;
-       margin-top: 30px !important; 
-}
diff --git a/css/menubar-backdrop.css b/css/menubar-backdrop.css
new file mode 100644 (file)
index 0000000..b238c51
--- /dev/null
@@ -0,0 +1,44 @@
+@media (min-width: 768px) {
+
+  body.crm-menubar-visible.crm-menubar-over-cms-menu {
+    border-top: 0 none !important;
+    margin-top: 40px;
+  }
+  body.crm-menubar-visible.crm-menubar-over-cms-menu.crm-menubar-wrapped {
+    margin-top: 80px;
+  }
+  body.crm-menubar-visible.crm-menubar-over-cms-menu #admin-bar {
+    visibility: hidden;
+  }
+
+  body.crm-menubar-visible.crm-menubar-below-cms-menu {
+    padding-top: 37px;
+  }
+  body.crm-menubar-visible.crm-menubar-below-cms-menu.crm-menubar-wrapped {
+    padding-top: 77px;
+  }
+  .admin-bar body.crm-menubar-below-cms-menu #civicrm-menu {
+    z-index: 999;
+  }
+  .admin-bar body.backdrop-admin-bar-position-absolute #civicrm-menu {
+    position: absolute;
+  }
+  body.crm-menubar-below-cms-menu #admin-bar {
+    z-index: 1000;
+  }
+
+}
+@media (max-width: 768px) {
+
+  body.backdrop-admin-bar-position-absolute #civicrm-menu-nav {
+    position: absolute;
+  }
+
+  body #civicrm-menu-nav .crm-menubar-toggle-btn {
+    position: absolute;
+    right: 120px;
+    top: 0;
+    margin-top: 3px;
+  }
+
+}
diff --git a/css/menubar-drupal7.css b/css/menubar-drupal7.css
new file mode 100644 (file)
index 0000000..8317feb
--- /dev/null
@@ -0,0 +1,115 @@
+@media (min-width: 768px) {
+
+  body.crm-menubar-visible.crm-menubar-over-cms-menu #toolbar {
+    display: none;
+  }
+
+  body.crm-menubar-visible.crm-menubar-over-cms-menu {
+    padding-top: 40px !important;
+  }
+  body.crm-menubar-visible.crm-menubar-over-cms-menu.crm-menubar-wrapped {
+    padding-top: 80px !important;
+  }
+
+  body.crm-menubar-visible.crm-menubar-over-cms-menu #toolbar .toolbar-drawer {
+    display: none !important;
+  }
+
+  body.toolbar.crm-menubar-visible.crm-menubar-below-cms-menu {
+    padding-top: 70px !important;
+  }
+  body.toolbar.crm-menubar-visible.crm-menubar-below-cms-menu.crm-menubar-wrapped {
+    padding-top: 110px !important;
+  }
+
+  body.toolbar.toolbar-drawer.crm-menubar-visible.crm-menubar-below-cms-menu {
+    padding-top: 104px !important;
+  }
+  body.toolbar.toolbar-drawer.crm-menubar-visible.crm-menubar-below-cms-menu.crm-menubar-wrapped {
+    padding-top: 144px !important;
+  }
+
+  body.toolbar.crm-menubar-visible.crm-menubar-below-cms-menu #toolbar {
+    -moz-box-shadow: none;
+    -webkit-box-shadow: none;
+    box-shadow: none;
+  }
+
+  body.toolbar.toolbar-drawer.crm-menubar-below-cms-menu #civicrm-menu {
+    top: 64px !important;
+  }
+
+  /* For admin_menu */
+  body.admin-menu.crm-menubar-visible.crm-menubar-over-cms-menu {
+    margin-top: 0 !important;
+  }
+  body.crm-menubar-visible.crm-menubar-below-cms-menu #admin-menu {
+    min-height: 30px;
+  }
+  body.crm-menubar-visible.crm-menubar-below-cms-menu.admin-menu {
+    padding-top: 40px !important;
+  }
+  body.crm-menubar-visible.crm-menubar-below-cms-menu.crm-menubar-wrapped.admin-menu {
+    padding-top: 80px !important;
+  }
+  body.crm-menubar-visible.crm-menubar-over-cms-menu #admin-menu {
+    display: none;
+  }
+
+  /* For adminimal_admin_menu */
+  body.crm-menubar-visible.crm-menubar-over-cms-menu.admin-menu.adminimal-menu:before {
+    height: 0;
+  }
+  body.crm-menubar-visible.crm-menubar-below-cms-menu.admin-menu.adminimal-menu.menu-render-newline #civicrm-menu-nav #civicrm-menu {
+    top: 55px;
+  }
+
+}
+
+/* For adminimal_admin_menu */
+@media (min-width: 768px) and (max-width: 1024px) {
+
+  body.crm-menubar-visible.crm-menubar-over-cms-menu.admin-menu.adminimal-menu > .slicknav_menu {
+    display: none;
+  }
+  body.crm-menubar-visible.crm-menubar-below-cms-menu.admin-menu.adminimal-menu {
+    padding-top: 0px !important;
+  }
+  body.crm-menubar-below-cms-menu.admin-menu.adminimal-menu > #civicrm-menu-nav #civicrm-menu {
+    top: 0px !important;
+  }
+}
+
+@media (max-width: 768px) {
+
+  body.toolbar.crm-menubar-visible #toolbar-home {
+    visibility: hidden;
+  }
+  body.crm-menubar-visible #toolbar-menu {
+    display: none;
+  }
+
+  body #civicrm-menu-nav .crm-menubar-toggle-btn {
+    margin-top: 0;
+  }
+
+  /* For admin_menu */
+  body.admin-menu  #civicrm-menu-nav .crm-menubar-toggle-btn {
+    margin-left: 0;
+  }
+  body.admin-menu.crm-menubar-visible #admin-menu-icon > li.admin-menu-icon > a {
+    visibility: hidden;
+    width: 40px;
+  }
+
+  /* For adminimal_admin_menu */
+  body.admin-menu.adminimal-menu  #civicrm-menu-nav {
+    position: absolute;
+  }
+  body.admin-menu.adminimal-menu  #civicrm-menu-nav .crm-menubar-toggle-btn {
+    float: right;
+    margin-top: 9px;
+    margin-right: 50px;
+  }
+
+}
diff --git a/css/menubar-drupal8.css b/css/menubar-drupal8.css
new file mode 100644 (file)
index 0000000..868a786
--- /dev/null
@@ -0,0 +1,55 @@
+#toolbar-tray-civicrm {
+  display: none;
+}
+
+body.crm-menubar-visible.crm-menubar-over-cms-menu,
+body.crm-menubar-visible.crm-menubar-below-cms-menu {
+  margin-left: 0 !important;
+}
+
+nav#civicrm-menu-nav .crm-menubar-toggle-btn {
+  margin: 0;
+  position: absolute;
+  top: 0;
+  height: 38px;
+}
+#crm-menubar-state:checked ~ .crm-menubar-toggle-btn {
+  left: 0!important;
+}
+nav#civicrm-menu-nav .crm-menubar-toggle-btn span.crm-menu-logo {
+  top: 10px;
+  left: 20px;
+}
+nav#civicrm-menu-nav .crm-menubar-toggle-btn-icon {
+  left: 44px;
+}
+
+@media (min-width: 768px) {
+
+  body.crm-menubar-visible.crm-menubar-over-cms-menu #toolbar-administration  {
+    display: none;
+  }
+
+  body.crm-menubar-visible.crm-menubar-over-cms-menu {
+    padding-top: 40px !important;
+  }
+  body.crm-menubar-visible.crm-menubar-over-cms-menu.crm-menubar-wrapped,
+  body.crm-menubar-visible.crm-menubar-below-cms-menu {
+    padding-top: 80px !important;
+  }
+  body.crm-menubar-visible.crm-menubar-below-cms-menu.crm-menubar-wrapped {
+    padding-top: 120px !important;
+  }
+
+  body.crm-menubar-below-cms-menu > #civicrm-menu-nav ul#civicrm-menu {
+    z-index: 1000;
+    top: 40px;
+  }
+
+}
+
+@media (max-width: 609px) {
+  nav#civicrm-menu-nav {
+    position: absolute;
+  }
+}
diff --git a/css/menubar-joomla.css b/css/menubar-joomla.css
new file mode 100644 (file)
index 0000000..482f8c2
--- /dev/null
@@ -0,0 +1,29 @@
+@media (min-width: 768px) {
+
+  body.crm-menubar-over-cms-menu.crm-menubar-visible {
+    padding-top: 40px;
+  }
+  body.crm-menubar-over-cms-menu.crm-menubar-visible.crm-menubar-wrapped {
+    padding-top: 80px;
+  }
+
+  body.crm-menubar-below-cms-menu.crm-menubar-visible {
+    margin-top: 40px;
+  }
+  body.crm-menubar-below-cms-menu.crm-menubar-visible.crm-menubar-wrapped {
+    margin-top: 80px;
+  }
+
+}
+@media (max-width: 768px) {
+
+  body #civicrm-menu-nav {
+    position: absolute;
+  }
+
+  body #civicrm-menu-nav .crm-menubar-toggle-btn {
+    margin-top: 3px;
+    margin-left: 6px;
+  }
+
+}
diff --git a/css/menubar-wordpress.css b/css/menubar-wordpress.css
new file mode 100644 (file)
index 0000000..33d2274
--- /dev/null
@@ -0,0 +1,59 @@
+@media (min-width: 768px) {
+
+  body.crm-menubar-over-cms-menu.crm-menubar-visible #wpbody {
+    padding-top: 8px;
+  }
+  body.crm-menubar-over-cms-menu.crm-menubar-visible.crm-menubar-wrapped #wpbody {
+    padding-top: 48px;
+  }
+
+  body.crm-menubar-over-cms-menu.crm-menubar-visible #wpadminbar {
+    visibility: hidden;
+  }
+
+  .wp-toolbar body.crm-menubar-below-cms-menu > #civicrm-menu-nav #civicrm-menu {
+    top: 32px;
+    left: 160px;
+    width: calc(100% - 160px);
+  }
+
+  .wp-toolbar body.crm-menubar-below-cms-menu.folded > #civicrm-menu-nav #civicrm-menu {
+    left: 36px;
+    width: calc(100% - 36px);
+  }
+
+  body.crm-menubar-below-cms-menu.crm-menubar-visible #wpbody {
+    padding-top: 40px;
+  }
+  body.crm-menubar-below-cms-menu.crm-menubar-visible.crm-menubar-wrapped #wpbody {
+    padding-top: 80px;
+  }
+  body.crm-menubar-over-cms-menu.crm-menubar-visible.crm-menubar-wrapped #adminmenuwrap {
+    margin-top: 40px;
+  }
+
+}
+@media (min-width: 768px) and (max-width: 960px) {
+
+  /* For the auto-fold toolbar */
+  .wp-toolbar body.crm-menubar-below-cms-menu.auto-fold > #civicrm-menu-nav #civicrm-menu {
+    left: 36px;
+    width: calc(100% - 36px);
+  }
+
+}
+@media (max-width: 768px) {
+
+  body #civicrm-menu-nav .crm-menubar-toggle-btn {
+    position: absolute;
+    right: 50px;
+  }
+
+}
+@media (max-width: 600px) {
+
+  body #civicrm-menu-nav {
+    position: absolute;
+  }
+
+}
index 2f8bd4b81332c00d85a24e8abd5c75ed5ef56400..4192e68e5acd2fdb7706e5062a16a904313e21bf 100644 (file)
@@ -1,4 +1,13 @@
 {
+  "uk.squiffle.kam": {
+    "obsolete": "5.12"
+  },
+  "com.aghstrategies.slicknav": {
+    "obsolete": "5.12"
+  },
+  "de.systopia.recentitems": {
+    "obsolete": "5.12"
+  },
   "com.ixiam.modules.quicksearch": {
     "obsolete": "5.8"
   }
index 994786d193aaabf8c9dd562488855b39a2458fad..1bded4d2bb2f81d5bf34ed092c688897da034793 100644 (file)
@@ -557,6 +557,16 @@ class InstallRequirements {
             ts('Unable to create triggers. This MySQL user is missing the CREATE TRIGGERS  privilege.'),
           )
         );
+        $this->requireMySQLUtf8mb4($databaseConfig['server'],
+          $databaseConfig['username'],
+          $databaseConfig['password'],
+          $databaseConfig['database'],
+          array(
+            ts("MySQL %1 Configuration", array(1 => $dbName)),
+            ts('Is the <code>utf8mb4</code> character set supported?'),
+            ts('This MySQL server does not support the <code>utf8mb4</code> character set.'),
+          )
+        );
       }
     }
   }
@@ -1333,6 +1343,57 @@ class InstallRequirements {
     }
   }
 
+  /**
+   * @param $server
+   * @param string $username
+   * @param $password
+   * @param $database
+   * @param $testDetails
+   */
+  public function requireMysqlUtf8mb4($server, $username, $password, $database, $testDetails) {
+    $this->testing($testDetails);
+    $conn = $this->connect($server, $username, $password);
+    if (!$conn) {
+      $testDetails[2] = ts('Could not connect to the database server.');
+      $this->error($testDetails);
+      return;
+    }
+
+    if (!@mysqli_select_db($conn, $database)) {
+      $testDetails[2] = ts('Could not select the database.');
+      $this->error($testDetails);
+      return;
+    }
+
+    $result = mysqli_query($conn, 'CREATE TABLE civicrm_utf8mb4_test (id VARCHAR(255), PRIMARY KEY(id(255))) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC ENGINE=INNODB');
+    if (!$result) {
+      $testDetails[2] = ts('It is recommended, though not yet required, to configure your MySQL server for utf8mb4 support. You will need the following MySQL server configuration: innodb_large_prefix=true innodb_file_format=barracuda innodb_file_per_table=true');
+      $this->warning($testDetails);
+      return;
+    }
+    $result = mysqli_query($conn, 'DROP TABLE civicrm_utf8mb4_test');
+
+    // Ensure that the MySQL driver supports utf8mb4 encoding.
+    $version = mysqli_get_client_info($conn);
+    if (strpos($version, 'mysqlnd') !== FALSE) {
+      // The mysqlnd driver supports utf8mb4 starting at version 5.0.9.
+      $version = preg_replace('/^\D+([\d.]+).*/', '$1', $version);
+      if (version_compare($version, '5.0.9', '<')) {
+        $testDetails[2] = 'It is recommended, though not yet required, to upgrade your PHP MySQL driver (mysqlnd) to >= 5.0.9 for utf8mb4 support.';
+        $this->warning($testDetails);
+        return;
+      }
+    }
+    else {
+      // The libmysqlclient driver supports utf8mb4 starting at version 5.5.3.
+      if (version_compare($version, '5.5.3', '<')) {
+        $testDetails[2] = 'It is recommended, though not yet required, to upgrade your PHP MySQL driver (libmysqlclient) to >= 5.5.3 for utf8mb4 support.';
+        $this->warning($testDetails);
+        return;
+      }
+    }
+  }
+
   /**
    * @param $testDetails
    *
index 93f7b1032f3574e03a46b012ca8f7a3f91df05af..c090e9ceefe2b2b9f9cfb66db8fc14474045bca5 100644 (file)
@@ -256,7 +256,7 @@ if (!CRM.vars) CRM.vars = {};
         CRM.CMSjQuery = window.jQuery;
         window.jQuery = CRM.$;
       }
-      script.src = url;
+      script.src = url + (_.includes(url, '?') ? '&r=' : '?r=') + CRM.config.resourceCacheCode;
       document.getElementsByTagName("head")[0].appendChild(script);
     }
     return scriptsLoaded[url];
@@ -466,7 +466,7 @@ if (!CRM.vars) CRM.vars = {};
         var entity = $(this).data('api-entity') || '';
         $(this)
           .off('.crmEntity')
-          .removeClass('crm-form-entityref crm-' + entity.toLowerCase() + '-ref')
+          .removeClass('crm-form-entityref crm-' + _.kebabCase(entity) + '-ref')
           .crmSelect2('destroy');
       });
     }
@@ -475,13 +475,17 @@ if (!CRM.vars) CRM.vars = {};
     return $(this).each(function() {
       var
         $el = $(this).off('.crmEntity'),
-        entity = options.entity || $el.data('api-entity') || 'contact',
+        entity = options.entity || $el.data('api-entity') || 'Contact',
         selectParams = {};
+      // Legacy: fix entity name if passed in as snake case
+      if (entity.charAt(0).toUpperCase() !== entity.charAt(0)) {
+        entity = _.capitalize(_.camelCase(entity));
+      }
       $el.data('api-entity', entity);
       $el.data('select-params', $.extend({}, $el.data('select-params') || {}, options.select));
       $el.data('api-params', $.extend(true, {}, $el.data('api-params') || {}, options.api));
       $el.data('create-links', options.create || $el.data('create-links'));
-      $el.addClass('crm-form-entityref crm-' + entity.toLowerCase() + '-ref');
+      $el.addClass('crm-form-entityref crm-' + _.kebabCase(entity) + '-ref');
       var settings = {
         // Use select2 ajax helper instead of CRM.api3 because it provides more value
         ajax: {
@@ -527,7 +531,7 @@ if (!CRM.vars) CRM.vars = {};
         }
       };
       // Create new items inline - works for tags
-      if ($el.data('create-links') && entity.toLowerCase() === 'tag') {
+      if ($el.data('create-links') && entity === 'Tag') {
         selectParams.createSearchChoice = function(term, data) {
           if (!_.findKey(data, {label: term})) {
             return {id: "0", term: term, label: term + ' (' + ts('new tag') + ')'};
@@ -685,12 +689,13 @@ if (!CRM.vars) CRM.vars = {};
     var
       createLinks = $el.data('create-links'),
       params = getEntityRefApiParams($el).params,
+      entity = $el.data('api-entity'),
       markup = '<div class="crm-entityref-links">';
-    if (!createLinks || (createLinks === true && $el.data('api-entity').toLowerCase() !== 'contact')) {
+    if (!createLinks || (createLinks === true && !CRM.config.entityRef.links[entity])) {
       return '';
     }
     if (createLinks === true) {
-      createLinks = params.contact_type ? _.where(CRM.config.entityRef.contactCreate, {type: params.contact_type}) : CRM.config.entityRef.contactCreate;
+      createLinks = params.contact_type ? _.where(CRM.config.entityRef.links[entity], {type: params.contact_type}) : CRM.config.entityRef.links[entity];
     }
     _.each(createLinks, function(link) {
       markup += ' <a class="crm-add-entity crm-hover-button" href="' + link.url + '">' +
@@ -703,13 +708,12 @@ if (!CRM.vars) CRM.vars = {};
 
   function getEntityRefFilters($el) {
     var
-      entity = $el.data('api-entity').toLowerCase(),
+      entity = $el.data('api-entity'),
       filters = CRM.config.entityRef.filters[entity] || [],
       params = $.extend({params: {}}, $el.data('api-params') || {}).params,
       result = [];
-    $.each(filters, function() {
-      var filter = $.extend({type: 'select', 'attributes': {}, entity: entity}, this);
-      $.extend(this, filter);
+    _.each(filters, function(filter) {
+      _.defaults(filter, {type: 'select', 'attributes': {}, entity: entity});
       if (!params[filter.key]) {
         // Filter out options if params don't match its condition
         if (filter.condition && !_.isMatch(params, _.pick(filter.condition, _.keys(params)))) {
@@ -773,7 +777,6 @@ if (!CRM.vars) CRM.vars = {};
    */
   function renderEntityRefFilterValue($el) {
     var
-      entity = $el.data('api-entity').toLowerCase(),
       filter = $el.data('user-filter') || {},
       filterSpec = filter.key ? _.find(getEntityRefFilters($el), {key: filter.key}) : null,
       $keyField = $('.crm-entityref-filter-key', '#select2-drop'),
index 911982de03666dbbe37878a6d7086d48ba53e1b2..9620b4e30cfd468f0386bc94907894b889f42a71 100644 (file)
@@ -1,10 +1,8 @@
 // http://civicrm.org/licensing
-CRM.$(function($) {
-  $('#admin-bar').css('display', 'none');
-  $('.crm-hidemenu').click(function(e) {
-    $('#admin-bar').css('display', 'block');
+(function($) {
+  $(document).on('crmLoad', '#civicrm-menu', function() {
+    if (Backdrop.settings.admin_bar && !Backdrop.settings.admin_bar.position_fixed) {
+      $('body').addClass('backdrop-admin-bar-position-absolute');
+    }
   });
-  $('#crm-notification-container').on('click', '#crm-restore-menu', function() {
-    $('#admin-bar').css('display', 'none');
-  });
-});
+})(CRM.$);
index fe3c5b9ec637d0527b82f5496daa30ce08ac20fd..8dc539d5027927ac2505b432e85b3150be3499d7 100644 (file)
         // D7 hack, restore toolbar position (CRM-15341)
         $('#toolbar').css('z-index', '');
       }
-    })
-    .on('crmLoad', '#civicrm-menu', function(e) {
-      if ($('#toolbar a.toggle').length) {
-        $('#civicrm-menu').css({width: 'calc(100% - 40px)'});
-      }
     });
 })(CRM.$);
index d141841815eda0f1f94ae23c37106f8574a37463..74e64cb779290f261b403dddcce74bd3f54a3afa 100644 (file)
@@ -1,17 +1,29 @@
 // http://civicrm.org/licensing
-CRM.$(function($) {
-   // d8 Hack to hide title when it should be (CRM-19960)
-   var pageTitle = $('.page-title');
-   if ('<span id="crm-remove-title" style="display:none">CiviCRM</span>' == pageTitle.text()) {
-     pageTitle.hide();
-   }
 
-   $('#toolbar-bar').hide();
+// When on a CiviCRM page the CiviCRM toolbar tab should be active
+localStorage.setItem('Drupal.toolbar.activeTabID', JSON.stringify('toolbar-item-civicrm'));
 
-   $('body').on('click', '.crm-hidemenu', function() {
-     $('#toolbar-bar').slideDown();
-   });
-   $('#crm-notification-container').on('click', '#crm-restore-menu', function() {
-     $('#toolbar-bar').slideUp();
-   });
-});
+(function($) {
+  function adjustToggle() {
+    if ($(window).width() < 768) {
+      $('#civicrm-menu-nav .crm-menubar-toggle-btn').css({
+        left: '' + $('#toolbar-item-civicrm').offset().left + 'px',
+        width: '' + $('#toolbar-item-civicrm').innerWidth() + 'px'
+      });
+    }
+  }
+  $(window).resize(adjustToggle);
+  $(document).on('crmLoad', adjustToggle);
+
+  // Wait for document.ready so Drupal's jQuery is available to this script
+  $(function($) {
+    // Need Drupal's jQuery to listen to this event
+    jQuery(document).on('drupalToolbarTabChange', function(event, tab) {
+      if (CRM.menubar && CRM.menubar.position === 'below-cms-menu') {
+        var action = jQuery(tab).is('#toolbar-item-civicrm') ? 'show' : 'hide';
+        CRM.menubar[action]();
+      }
+    });
+  });
+
+})(CRM.$);
diff --git a/js/crm.menubar.js b/js/crm.menubar.js
new file mode 100644 (file)
index 0000000..ad5fccb
--- /dev/null
@@ -0,0 +1,485 @@
+// https://civicrm.org/licensing
+(function($, _) {
+  "use strict";
+  var templates, initialized,
+    ENTER_KEY = 13,
+    SPACE_KEY = 32;
+  CRM.menubar = _.extend({
+    data: null,
+    settings: {collapsibleBehavior: 'accordion'},
+    position: 'over-cms-menu',
+    attachTo: (CRM.menubar && CRM.menubar.position === 'above-crm-container') ? '#crm-container' : 'body',
+    initialize: function() {
+      var cache = CRM.cache.get('menubar');
+      if (cache && cache.code === CRM.menubar.cacheCode && cache.locale === CRM.config.locale && cache.cid === CRM.config.cid && localStorage.civiMenubar) {
+        CRM.menubar.data = cache.data;
+        insert(localStorage.civiMenubar);
+      } else {
+        $.getJSON(CRM.url('civicrm/ajax/navmenu', {code: CRM.menubar.cacheCode, locale: CRM.config.locale, cid: CRM.config.cid}))
+          .done(function(data) {
+            var markup = getTpl('tree')(data);
+            CRM.cache.set('menubar', {code: CRM.menubar.cacheCode, locale: CRM.config.locale, cid: CRM.config.cid, data: data});
+            CRM.menubar.data = data;
+            localStorage.setItem('civiMenubar', markup);
+            insert(markup);
+          });
+      }
+
+      // Wait for crm-container present on the page as it's faster than document.ready
+      function insert(markup) {
+        if ($('#crm-container').length) {
+          render(markup);
+        } else {
+          new MutationObserver(function(mutations, observer) {
+            _.each(mutations, function(mutant) {
+              _.each(mutant.addedNodes, function(node) {
+                if ($(node).is('#crm-container')) {
+                  render(markup);
+                  observer.disconnect();
+                }
+              });
+            });
+          }).observe(document, {childList: true, subtree: true});
+        }
+      }
+
+      function render(markup) {
+        var position = CRM.menubar.attachTo === 'body' ? 'beforeend' : 'afterbegin';
+        $(CRM.menubar.attachTo)[0].insertAdjacentHTML(position, markup);
+        CRM.menubar.initializePosition();
+        $('#civicrm-menu').trigger('crmLoad');
+        $(document).ready(function() {
+          handleResize();
+          $('#civicrm-menu')
+            .on('click', 'a[href="#"]', function() {
+              // For empty links - keep the menu open and don't jump the page anchor
+              return false;
+            })
+            .on('click', 'a:not([href^="#"])', function(e) {
+              if (e.ctrlKey || e.altKey || e.shiftKey || e.metaKey) {
+                // Prevent menu closing when link is clicked with a keyboard modifier.
+                e.stopPropagation();
+              }
+            })
+            .on('dragstart', function() {
+              // Stop user from accidentally dragging menu links
+              // This was added because a user noticed they could drag the civi icon into the quicksearch box.
+              return false;
+            })
+            .on('click', 'a[href="#hidemenu"]', function(e) {
+              e.preventDefault();
+              CRM.menubar.hide(250, true);
+            })
+            .on('keyup', 'a', function(e) {
+              // Simulate a click when spacebar key is pressed
+              if (e.which == SPACE_KEY) {
+                $(e.currentTarget)[0].click();
+              }
+            })
+            .on('show.smapi', function(e, menu) {
+              // Focus menu when opened with an accesskey
+              $(menu).siblings('a[accesskey]:not(:hover)').focus();
+            })
+            .smartmenus(CRM.menubar.settings);
+          initialized = true;
+          CRM.menubar.initializeResponsive();
+          CRM.menubar.initializeSearch();
+        });
+      }
+    },
+    destroy: function() {
+      $.SmartMenus.destroy();
+      $('#civicrm-menu-nav').remove();
+      initialized = false;
+      $('body[class]').attr('class', function(i, c) {
+        return c.replace(/(^|\s)crm-menubar-\S+/g, '');
+      });
+    },
+    show: function(speed) {
+      if (typeof speed === 'number') {
+        $('#civicrm-menu').slideDown(speed, function() {
+          $(this).css('display', '');
+        });
+      }
+      $('body')
+        .removeClass('crm-menubar-hidden')
+        .addClass('crm-menubar-visible');
+    },
+    hide: function(speed, showMessage) {
+      if (typeof speed === 'number') {
+        $('#civicrm-menu').slideUp(speed, function() {
+          $(this).css('display', '');
+        });
+      }
+      $('body')
+        .addClass('crm-menubar-hidden')
+        .removeClass('crm-menubar-visible');
+      if (showMessage === true && $('#crm-notification-container').length && initialized) {
+        var alert = CRM.alert('<a href="#" id="crm-restore-menu" style="text-align: center; margin-top: -8px;">' + _.escape(ts('Restore CiviCRM Menu')) + '</a>', '', 'none', {expires: 10000});
+        $('#crm-restore-menu')
+          .button({icons: {primary: 'fa-undo'}})
+          .click(function(e) {
+            e.preventDefault();
+            alert.close();
+            CRM.menubar.show(speed);
+          })
+          .parent().css('text-align', 'center').find('.ui-button-text').css({'padding-top': '4px', 'padding-bottom': '4px'});
+      }
+    },
+    open: function(itemName) {
+      var $item = $('li[data-name="' + itemName + '"] > a', '#civicrm-menu');
+      if ($item.length) {
+        $('#civicrm-menu').smartmenus('itemActivate', $item);
+        $item[0].focus();
+      }
+    },
+    close: $.SmartMenus.hideAll,
+    isOpen: function(itemName) {
+      if (itemName) {
+        return !!$('li[data-name="' + itemName + '"] > ul[aria-expanded="true"]', '#civicrm-menu').length;
+      }
+      return !!$('ul[aria-expanded="true"]', '#civicrm-menu').length;
+    },
+    spin: function(spin) {
+      $('.crm-logo-sm', '#civicrm-menu').toggleClass('fa-spin', spin);
+    },
+    getItem: function(itemName) {
+      return traverse(CRM.menubar.data.menu, itemName, 'get');
+    },
+    addItems: function(position, targetName, items) {
+      var list, container, $ul;
+      if (position === 'before' || position === 'after') {
+        if (!targetName) {
+          throw 'Cannot add sibling of main menu';
+        }
+        list = traverse(CRM.menubar.data.menu, targetName, 'parent');
+        if (!list) {
+          throw targetName + ' not found';
+        }
+        var offset = position === 'before' ? 0 : 1;
+        position = offset + _.findIndex(list, {name: targetName});
+        $ul = $('li[data-name="' + targetName + '"]', '#civicrm-menu').closest('ul');
+      } else if (targetName) {
+        container = traverse(CRM.menubar.data.menu, targetName, 'get');
+        if (!container) {
+          throw targetName + ' not found';
+        }
+        container.child = container.child || [];
+        list = container.child;
+        var $target = $('li[data-name="' + targetName + '"]', '#civicrm-menu');
+        if (!$target.children('ul').length) {
+          $target.append('<ul>');
+        }
+        $ul = $target.children('ul').first();
+      } else {
+        list = CRM.menubar.data.menu;
+      }
+      if (position < 0) {
+        position = list.length + 1 + position;
+      }
+      if (position >= list.length) {
+        list.push.apply(list, items);
+        position = list.length - 1;
+      } else {
+        list.splice.apply(list, [position, 0].concat(items));
+      }
+      if (targetName && !$ul.is('#civicrm-menu')) {
+        $ul.html(getTpl('branch')({items: list, branchTpl: getTpl('branch')}));
+      } else {
+        $('#civicrm-menu > li').eq(position).after(getTpl('branch')({items: items, branchTpl: getTpl('branch')}));
+      }
+      CRM.menubar.refresh();
+    },
+    removeItem: function(itemName) {
+      var item = traverse(CRM.menubar.data.menu, itemName, 'delete');
+      if (item) {
+        $('li[data-name="' + itemName + '"]', '#civicrm-menu').remove();
+        CRM.menubar.refresh();
+      }
+      return item;
+    },
+    updateItem: function(item) {
+      if (!item.name) {
+        throw 'No name passed to CRM.menubar.updateItem';
+      }
+      var menuItem = CRM.menubar.getItem(item.name);
+      if (!menuItem) {
+        throw item.name + ' not found';
+      }
+      _.extend(menuItem, item);
+      $('li[data-name="' + item.name + '"]', '#civicrm-menu').replaceWith(getTpl('branch')({items: [menuItem], branchTpl: getTpl('branch')}));
+      CRM.menubar.refresh();
+    },
+    refresh: function() {
+      if (initialized) {
+        $('#civicrm-menu').smartmenus('refresh');
+        handleResize();
+      }
+    },
+    togglePosition: function(persist) {
+      $('body').toggleClass('crm-menubar-over-cms-menu crm-menubar-below-cms-menu');
+      CRM.menubar.position = CRM.menubar.position === 'over-cms-menu' ? 'below-cms-menu' : 'over-cms-menu';
+      handleResize();
+      if (persist !== false) {
+        CRM.cache.set('menubarPosition', CRM.menubar.position);
+      }
+    },
+    initializePosition: function() {
+      if (CRM.menubar.position === 'over-cms-menu' || CRM.menubar.position === 'below-cms-menu') {
+        $('#civicrm-menu')
+          .on('click', 'a[href="#toggle-position"]', function(e) {
+            e.preventDefault();
+            CRM.menubar.togglePosition();
+          })
+          .append('<li id="crm-menubar-toggle-position"><a href="#toggle-position" title="' + ts('Adjust menu position') + '"><i class="crm-i fa-arrow-up"></i></a>');
+        CRM.menubar.position = CRM.cache.get('menubarPosition', CRM.menubar.position);
+      }
+      $('body').addClass('crm-menubar-visible crm-menubar-' + CRM.menubar.position);
+    },
+    initializeResponsive: function() {
+      var $mainMenuState = $('#crm-menubar-state');
+      // hide mobile menu beforeunload
+      $(window).on('beforeunload unload', function() {
+        CRM.menubar.spin(true);
+        if ($mainMenuState[0].checked) {
+          $mainMenuState[0].click();
+        }
+      })
+        .on('resize', function() {
+          if ($(window).width() >= 768 && $mainMenuState[0].checked) {
+            $mainMenuState[0].click();
+          }
+          handleResize();
+        });
+      $mainMenuState.click(function() {
+        // Use absolute position instead of fixed when open to allow scrolling menu
+        var open = $(this).is(':checked');
+        if (open) {
+          window.scroll({top: 0});
+        }
+        $('#civicrm-menu-nav')
+          .css('position', open ? 'absolute' : '')
+          .parentsUntil('body')
+          .css('position', open ? 'static' : '');
+      });
+    },
+    initializeSearch: function() {
+      $('input[name=qfKey]', '#crm-qsearch').attr('value', CRM.menubar.qfKey);
+      $('#crm-qsearch-input')
+        .autocomplete({
+          source: function(request, response) {
+            //start spinning the civi logo
+            CRM.menubar.spin(true);
+            var
+              option = $('input[name=quickSearchField]:checked'),
+              params = {
+                name: request.term,
+                field_name: option.val()
+              };
+            CRM.api3('contact', 'getquick', params).done(function(result) {
+              var ret = [];
+              if (result.values.length > 0) {
+                $('#crm-qsearch-input').autocomplete('widget').menu('option', 'disabled', false);
+                $.each(result.values, function(k, v) {
+                  ret.push({value: v.id, label: v.data});
+                });
+              } else {
+                $('#crm-qsearch-input').autocomplete('widget').menu('option', 'disabled', true);
+                var label = option.closest('label').text();
+                var msg = ts('%1 not found.', {1: label});
+                // Remind user they are not searching by contact name (unless they enter a number)
+                if (params.field_name !== 'sort_name' && !(/[\d].*/.test(params.name))) {
+                  msg += ' ' + ts('Did you mean to search by Name/Email instead?');
+                }
+                ret.push({value: '0', label: msg});
+              }
+              response(ret);
+              //stop spinning the civi logo
+              CRM.menubar.spin(false);
+              CRM.menubar.close();
+            });
+          },
+          focus: function (event, ui) {
+            return false;
+          },
+          select: function (event, ui) {
+            if (ui.item.value > 0) {
+              document.location = CRM.url('civicrm/contact/view', {reset: 1, cid: ui.item.value});
+            }
+            return false;
+          },
+          create: function() {
+            $(this).autocomplete('widget').addClass('crm-quickSearch-results');
+          }
+        })
+        .on('keyup change', function() {
+          $(this).toggleClass('has-user-input', !!$(this).val());
+        })
+        .keyup(function(e) {
+          CRM.menubar.close();
+          if (e.which === ENTER_KEY) {
+            if (!$(this).val()) {
+              CRM.menubar.open('QuickSearch');
+            }
+          }
+        });
+      $('#crm-qsearch > a').keyup(function(e) {
+        if ($(e.target).is(this)) {
+          $('#crm-qsearch-input').focus();
+          CRM.menubar.close();
+        }
+      });
+      $('#crm-qsearch form[name=search_block]').on('submit', function() {
+        if (!$('#crm-qsearch-input').val()) {
+          return false;
+        }
+        var $menu = $('#crm-qsearch-input').autocomplete('widget');
+        if ($('li.ui-menu-item', $menu).length === 1) {
+          var cid = $('li.ui-menu-item', $menu).data('ui-autocomplete-item').value;
+          if (cid > 0) {
+            document.location = CRM.url('civicrm/contact/view', {reset: 1, cid: cid});
+            return false;
+          }
+        }
+      });
+      $('#civicrm-menu').on('show.smapi', function(e, menu) {
+        if ($(menu).parent().attr('data-name') === 'QuickSearch') {
+          $('#crm-qsearch-input').focus();
+        }
+      });
+      function setQuickSearchValue() {
+        var $selection = $('.crm-quickSearchField input:checked'),
+          label = $selection.parent().text(),
+          value = $selection.val();
+        // These fields are not supported by advanced search
+        if (!value || value === 'first_name' || value === 'last_name') {
+          value = 'sort_name';
+        }
+        $('#crm-qsearch-input').attr({name: value, placeholder: '\uf002 ' + label});
+      }
+      $('.crm-quickSearchField').click(function() {
+        var input = $('input', this);
+        // Wait for event - its default was prevented by our link handler which interferes with checking the radio input
+        window.setTimeout(function() {
+          input.prop('checked', true);
+          CRM.cache.set('quickSearchField', input.val());
+          setQuickSearchValue();
+          $('#crm-qsearch-input').focus().autocomplete("search");
+        }, 1);
+      });
+      $('.crm-quickSearchField input[value="' + CRM.cache.get('quickSearchField', 'sort_name') + '"]').prop('checked', true);
+      setQuickSearchValue();
+      $('#civicrm-menu').on('activate.smapi', function(e, item) {
+        return !$('ul.crm-quickSearch-results').is(':visible:not(.ui-state-disabled)');
+      });
+    },
+    treeTpl:
+      '<nav id="civicrm-menu-nav">' +
+        '<input id="crm-menubar-state" type="checkbox" />' +
+        '<label class="crm-menubar-toggle-btn" for="crm-menubar-state">' +
+          '<span class="crm-menu-logo"></span>' +
+          '<span class="crm-menubar-toggle-btn-icon"></span>' +
+          '<%- ts("Toggle main menu") %>' +
+        '</label>' +
+        '<ul id="civicrm-menu" class="sm sm-civicrm">' +
+          '<%= searchTpl({items: search}) %>' +
+          '<%= branchTpl({items: menu, branchTpl: branchTpl}) %>' +
+        '</ul>' +
+      '</nav>',
+    searchTpl:
+      '<li id="crm-qsearch" data-name="QuickSearch">' +
+        '<a href="#"> ' +
+          '<form action="<%= CRM.url(\'civicrm/contact/search/advanced\') %>" name="search_block" method="post">' +
+            '<div>' +
+              '<input type="text" id="crm-qsearch-input" name="sort_name" placeholder="\uf002" accesskey="q" />' +
+              '<input type="hidden" name="hidden_location" value="1" />' +
+              '<input type="hidden" name="hidden_custom" value="1" />' +
+              '<input type="hidden" name="qfKey" />' +
+              '<input type="hidden" name="_qf_Advanced_refresh" value="Search" />' +
+            '</div>' +
+          '</form>' +
+        '</a>' +
+        '<ul>' +
+          '<% _.forEach(items, function(item) { %>' +
+            '<li><a href="#" class="crm-quickSearchField"><label><input type="radio" value="<%= item.key %>" name="quickSearchField"> <%- item.value %></label></a></li>' +
+          '<% }) %>' +
+        '</ul>' +
+      '</li>',
+    branchTpl:
+      '<% _.forEach(items, function(item) { %>' +
+        '<li <%= attr("li", item) %>>' +
+          '<a <%= attr("a", item) %>>' +
+            '<% if (item.icon) { %>' +
+              '<i class="<%- item.icon %>"></i>' +
+            '<% } %>' +
+            '<% if (item.label) { %>' +
+              '<span><%- item.label %></span>' +
+            '<% } %>' +
+          '</a>' +
+          '<% if (item.child) { %>' +
+            '<ul><%= branchTpl({items: item.child, branchTpl: branchTpl}) %></ul>' +
+          '<% } %>' +
+        '</li>' +
+      '<% }) %>'
+  }, CRM.menubar || {});
+
+  function getTpl(name) {
+    if (!templates) {
+      templates = {
+        branch: _.template(CRM.menubar.branchTpl, {imports: {_: _, attr: attr}}),
+        search: _.template(CRM.menubar.searchTpl, {imports: {_: _, ts: ts, CRM: CRM}})
+      };
+      templates.tree = _.template(CRM.menubar.treeTpl, {imports: {branchTpl: templates.branch, searchTpl: templates.search, ts: ts}});
+    }
+    return templates[name];
+  }
+
+  function handleResize() {
+    if ($(window).width() >= 768 && $('#civicrm-menu').height() > 50) {
+      $('body').addClass('crm-menubar-wrapped');
+    } else {
+      $('body').removeClass('crm-menubar-wrapped');
+    }
+  }
+
+  function traverse(items, itemName, op) {
+    var found;
+    _.each(items, function(item, index) {
+      if (item.name === itemName) {
+        found = (op === 'parent' ? items : item);
+        if (op === 'delete') {
+          items.splice(index, 1);
+        }
+        return false;
+      }
+      if (item.child) {
+        found = traverse(item.child, itemName, op);
+        if (found) {
+          return false;
+        }
+      }
+    });
+    return found;
+  }
+
+  function attr(el, item) {
+    var ret = [], attr = _.cloneDeep(item.attr || {}), a = ['rel', 'accesskey'];
+    if (el === 'a') {
+      attr = _.pick(attr, a);
+      attr.href = item.url || "#";
+    } else {
+      attr = _.omit(attr, a);
+      attr['data-name'] = item.name;
+      if (item.separator) {
+        attr.class = (attr.class ? attr.class + ' ' : '') + 'crm-menu-border-' + item.separator;
+      }
+    }
+    _.each(attr, function(val, name) {
+      ret.push(name + '="' + val + '"');
+    });
+    return ret.join(' ');
+  }
+
+  CRM.menubar.initialize();
+
+})(CRM.$, CRM._);
index 774b24a35fd0a3b52189bbf0b19b190dfd1516af..740b2246500cbf68979d4dad16a13103383678c0 100644 (file)
@@ -18,4 +18,20 @@ CRM.$(function($) {
         });
       }
     });
+  // Prevent screen reader shortcuts from changing the document hash and breaking angular routes
+  $('a.screen-reader-shortcut').click(function() {
+    var href = $(this).attr('href');
+    // Show toolbar if hidden
+    if (href === '#wp-toolbar' && CRM.menubar.position === 'over-cms-menu') {
+      CRM.menubar.togglePosition(false);
+    }
+    $(href).focus();
+    return false;
+  });
+  $('<a href="#crm-qsearch-input" class="screen-reader-shortcut">' + ts("Open CiviCRM Menu") + '</a>')
+    .prependTo('#adminmenumain')
+    .click(function() {
+      CRM.menubar.open('Home');
+      return false;
+    });
 });
index b332f3b8e18d1e174ccac9d7d9ea03dce495bb4b..8d4cdc09686fce91b2824ec40dba6f6945a509d6 100644 (file)
@@ -1017,4 +1017,24 @@ return array(
     ),
     'quick_form_type' => 'Select',
   ),
+  'menubar_position' => array(
+    'group_name' => 'CiviCRM Preferences',
+    'group' => 'core',
+    'name' => 'menubar_position',
+    'type' => 'String',
+    'html_type' => 'select',
+    'default' => 'over-cms-menu',
+    'add' => '5.9',
+    'title' => ts('Menubar position'),
+    'is_domain' => 1,
+    'is_contact' => 0,
+    'description' => ts('Location of the CiviCRM main menu.'),
+    'help_text' => NULL,
+    'options' => array(
+      'over-cms-menu' => ts('Replace website menu'),
+      'below-cms-menu' => ts('Below website menu'),
+      'above-crm-container' => ts('Above content area'),
+      'none' => ts('None - disable menu'),
+    ),
+  ),
 );
index 54f05b29716a72f36476338cc2ba0d1fb5ddb24f..3d15ee0f2278abfbdb54d14e7f7eaf5e30aca0bb 100644 (file)
@@ -156,11 +156,11 @@ return array(
     'html_attributes' => array(
       //'class' => 'crm-select2',
     ),
-    'default' => '1228',
     'add' => '4.4',
     'title' => 'Default Country',
     'is_domain' => 1,
     'is_contact' => 0,
+    'is_required' => FALSE,
     'description' => 'This value is selected by default when adding a new contact address.',
     'help_text' => NULL,
     'pseudoconstant' => array(
index 7325a95b1808063214cce9c4f8f1bce83491d4a5..6f4770bba19905c848315efa3248b78f7d196674 100644 (file)
@@ -58,7 +58,7 @@ return array(
     'title' => ts('Multisite Domain Group'),
     'type' => 'Integer',
     'html_type' => 'entity_reference',
-    'entity_reference_options' => ['entity' => 'group', 'select' => array('minimumInputLength' => 0)],
+    'entity_reference_options' => ['entity' => 'Group', 'select' => array('minimumInputLength' => 0)],
     'default' => '0',
     'add' => '4.1',
     'is_domain' => 1,
index a884d46832323847017fa2f2de2c17b7dcae49de..8306beb0ef944644c8817d0caff82bfa4c900e6d 100644 (file)
@@ -399,7 +399,7 @@ UNLOCK TABLES;
 
 LOCK TABLES `civicrm_domain` WRITE;
 /*!40000 ALTER TABLE `civicrm_domain` DISABLE KEYS */;
-INSERT INTO `civicrm_domain` (`id`, `name`, `description`, `config_backend`, `version`, `contact_id`, `locales`, `locale_custom_strings`) VALUES (1,'Default Domain Name',NULL,NULL,'5.11.beta1',1,NULL,'a:1:{s:5:\"en_US\";a:0:{}}');
+INSERT INTO `civicrm_domain` (`id`, `name`, `description`, `config_backend`, `version`, `contact_id`, `locales`, `locale_custom_strings`) VALUES (1,'Default Domain Name',NULL,NULL,'5.12.alpha1',1,NULL,'a:1:{s:5:\"en_US\";a:0:{}}');
 /*!40000 ALTER TABLE `civicrm_domain` ENABLE KEYS */;
 UNLOCK TABLES;
 
index 28f91454954959cc558c939d1b84c51bebfc8257..9069edfc8887d7f1c139c97ba56e55bba2ed27be 100644 (file)
@@ -32,8 +32,6 @@
     {/if}
     <div class="crm-block crm-form-block crm-activity-form-block">
   {/if}
-  {* added onload javascript for source contact*}
-  {include file="CRM/Activity/Form/ActivityJs.tpl" tokenContext="activity"}
   {if !$action or ( $action eq 1 ) or ( $action eq 2 ) }
   <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="top"}</div>
   {/if}
diff --git a/templates/CRM/Activity/Form/ActivityJs.tpl b/templates/CRM/Activity/Form/ActivityJs.tpl
deleted file mode 100644 (file)
index d3d517a..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-{*
- +--------------------------------------------------------------------+
- | CiviCRM version 5                                                  |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019                                |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM.                                    |
- |                                                                    |
- | CiviCRM is free software; you can copy, modify, and distribute it  |
- | under the terms of the GNU Affero General Public License           |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
- |                                                                    |
- | CiviCRM is distributed in the hope that it will be useful, but     |
- | WITHOUT ANY WARRANTY; without even the implied warranty of         |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
- | See the GNU Affero General Public License for more details.        |
- |                                                                    |
- | You should have received a copy of the GNU Affero General Public   |
- | License and the CiviCRM Licensing Exception along                  |
- | with this program; if not, contact CiviCRM LLC                     |
- | at info[AT]civicrm[DOT]org. If you have questions about the        |
- | GNU Affero General Public License or the licensing of CiviCRM,     |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
- +--------------------------------------------------------------------+
-*}
-{* added onload javascript for source contact*}
-{literal}
-<script type="text/javascript">
-  /**
-   * Function to check activity status in relavent to activity date
-   *
-   * @param message JSON object.
-   */
-  function activityStatus(message) {
-    var activityDate =  cj("#activity_date_time_display").datepicker('getDate');
-    if (activityDate) {
-      var
-        // Ignore time, only compare dates
-        today = new Date().setHours(0,0,0,0),
-        activityStatusId = cj('#status_id').val();
-      if (activityStatusId == 2 && today < activityDate) {
-        return confirm(message.completed);
-      }
-      else if (activityStatusId == 1 && today > activityDate) {
-        return confirm(message.scheduled);
-      }
-    }
-  }
-
-</script>
-{/literal}
index de8986889fac94ac98d6b957408ca473352a805e..02f0f38f7e087c400737883a6b81b1e0dbdd43de 100644 (file)
       <td>&nbsp;</td>
       <td class="description">{$settings_fields.sort_name_format.description}</td>
     </tr>
+    <tr class="crm-preferences-display-form-block_menubar_position">
+      <td class="label">{$form.menubar_position.label}</td>
+      <td>
+        {$form.menubar_position.html}
+        <div class="description">{ts}Default position for the CiviCRM menubar.{/ts}</div>
+      </td>
+    </tr>
   </table>
   <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
 </div>
index fff7efa8341003439ec3b6ac332eea95f07f7bb4..dc48f6202e601a77fcda6ba6ccb42fbd3b6955cb 100644 (file)
   {if $action neq 8 and $action  neq 32768 }
   {* Include form buttons on top for new and edit modes. *}
   <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="top"}</div>
-
-    {* added onload javascript for source contact*}
-    {include file="CRM/Activity/Form/ActivityJs.tpl" tokenContext="case_activity"}
-
   {/if}
 
   {if $action eq 8 or $action eq 32768 }
index 000cccb578e184a37eed1facd6b83b6556868561..34630c50f516d875d3cccb3f35a21ec4679be81b 100644 (file)
   <td class="label">{$form.is_reset_timeline.label}</td>
   <td>{$form.is_reset_timeline.html}</td>
     </tr>
-    <tr class="crm-case-changecasetype-form-block-reset_date_time" id="resetTimeline">
-        <td class="label">{$form.reset_date_time.label}</td>
-        <td>{include file="CRM/common/jcalendar.tpl" elementName=reset_date_time}</td>
+    <tr class="crm-case-changecasetype-form-block-reset_date_time">
+        <td class="label">{$form.reset_date_time.label} <span class="crm-marker">*</span></td>
+        <td>{$form.reset_date_time.html}</td>
     </tr>
-
-{include file="CRM/common/showHideByFieldValue.tpl"
-trigger_field_id    ="is_reset_timeline"
-trigger_value       = true
-target_element_id   ="resetTimeline"
-target_element_type ="table-row"
-field_type          ="radio"
-invert              = 0
-}
   </div>
+{literal}
+  <script type="text/javascript">
+    CRM.$(function($) {
+      var $form = $('form.{/literal}{$form.formClass}{literal}');
+      $('input[name=is_reset_timeline]', $form).click(function() {
+        $('.crm-case-changecasetype-form-block-reset_date_time').toggle($(this).val() === '1');
+      })
+    })
+  </script>
+{/literal}
index cfa949c9776aa37961fcc4aa5d68723378bb760d..3aae0d213217e69ed3e91ec874582181c4859dca 100644 (file)
 <p>{ts}Upload a photo or icon that you want to be displayed when viewing this contact.{/ts}</p>
 {/htxt}
 
-{htxt id="id-internal-id-title"}
+{htxt id="id-contact-id-title"}
   {ts}Contact ID{/ts}
 {/htxt}
-{htxt id="id-internal-id"}
+{htxt id="id-contact-id"}
 <p>{ts}Every contact in CiviCRM has a unique ID number. This number will never change and is the most accurate way of identifying a contact.{/ts}</p>
 {/htxt}
 
index 4849891d35fbf8a45ae0b918832cf5768dd8fd46..bdb352af049d8cf9b21126fa59d3cb94da67fe89 100644 (file)
@@ -63,7 +63,7 @@
               </td>
               {if $contactId}
                 <td>
-                  <label for="internal_identifier_display">{ts}Contact ID{/ts} {help id="id-internal-id"}</label><br />
+                  <label for="internal_identifier_display">{ts}Contact ID{/ts} {help id="id-contact-id"}</label><br />
                   <input id="internal_identifier_display" type="text" class="crm-form-text six" size="6" readonly="readonly" value="{$contactId}">
                 </td>
               {/if}
index 41d19cedcec77d5207e0c3fdced08f4b61903537..144d6544db43661bf2e6e125d00ac0afb43da6ac 100644 (file)
           <td><a href="{crmURL p='civicrm/contact/view' q="reset=1&cid=`$row.contact_id`"}">{$row.sort_name}</a></td>
         {/if}
         <td class="crm-contribution-amount">
-          {if !$row.contribution_soft_credit_amount}
              <a class="nowrap bold crm-expand-row" title="{ts}view payments{/ts}" href="{crmURL p='civicrm/payment' q="view=transaction&component=contribution&action=browse&cid=`$row.contact_id`&id=`$row.contribution_id`&selector=1"}">
                &nbsp; {$row.total_amount|crmMoney:$row.currency}
             </a>
-          {/if}
           {if $row.amount_level }<br/>({$row.amount_level}){/if}
           {if $row.contribution_recur_id}<br/>{ts}(Recurring){/ts}{/if}
         </td>
-        {if $softCreditColumns}
-          <td class="right bold crm-contribution-soft_credit_amount">
-            <span class="nowrap">{$row.contribution_soft_credit_amount|crmMoney:$row.currency}</span>
-          </td>
-        {/if}
       {foreach from=$columnHeaders item=column}
         {assign var='columnName' value=$column.field_name}
         {if !$columnName}{* if field_name has not been set skip, this helps with not changing anything not specifically edited *}
index d5735b74f0951dc40fc6342bed3594b20643ee32..e98e57f954893cd3e7406de625a744a0a37a0e7f 100644 (file)
     {if $contributionSummary }
       <tr>
           {if $contributionSummary.total.amount}
-            {if $contributionSummary.total.currencyCount gt 1}
-              <th class="contriTotalLeft right">{ts}Total{/ts} &ndash; {$contributionSummary.total.amount}</th>
-              <th class="left contriTotalRight"> &nbsp; {ts}# Completed{/ts} &ndash; {$contributionSummary.total.count}</th>
-            </tr><tr>
-              <th class="contriTotalLeft">{ts}Avg{/ts} &ndash; {$contributionSummary.total.avg}</th>
-              <th class="right"> &nbsp; {ts}Median{/ts} &ndash; {$contributionSummary.total.median}</th>
-              <th class="right contriTotalRight"> &nbsp; {ts}Mode{/ts} &ndash; {$contributionSummary.total.mode}</th>
-            {else}
-              <th class="contriTotalLeft right">{ts}Total{/ts} &ndash; {$contributionSummary.total.amount}</th>
-              <th class="right"> &nbsp; {ts}# Completed{/ts} &ndash; {$contributionSummary.total.count}</th>
-              <th class="right"> &nbsp; {ts}Avg{/ts} &ndash; {$contributionSummary.total.avg}</th>
-              <th class="right"> &nbsp; {ts}Median{/ts} &ndash; {$contributionSummary.total.median}</th>
-              <th class="right contriTotalRight"> &nbsp; {ts}Mode{/ts} &ndash; {$contributionSummary.total.mode}</th>
-            {/if}
+            <th class="contriTotalLeft right">{ts}Total{/ts} &ndash; {$contributionSummary.total.amount}</th>
+            <th class="right"> &nbsp; {ts}# Completed{/ts} &ndash; {$contributionSummary.total.count}</th>
+            <th class="right contriTotalRight"> &nbsp; {ts}Avg{/ts} &ndash; {$contributionSummary.total.avg}</th>
           {/if}
           {if $contributionSummary.cancel.amount}
             <th class="disabled right contriTotalRight"> &nbsp; {ts}Cancelled/Refunded{/ts} &ndash; {$contributionSummary.cancel.amount}</th>
index 182dd22679ae45caa38830416805c005d99574eb..0c25b8f39366cb9a1662f08380fe05e61e4e86d0 100644 (file)
@@ -58,6 +58,7 @@
                         <td>{$row.contribution_status}</td>
                         {if $invoicing && $invoices}
                           <td>
+                            {* @todo Instead of this tpl handling assign actions as an array attached the row, iterate through - will better accomodate extension overrides and competition for scarce real estate on this page*}
                             {assign var='id' value=$row.contribution_id}
                             {assign var='contact_id' value=$row.contact_id}
                             {assign var='urlParams' value="reset=1&id=$id&cid=$contact_id"}
@@ -75,6 +76,7 @@
                           </td>
                         {/if}
                         {if $defaultInvoicePage && $row.contribution_status_name == 'Pending' }
+                          {* @todo Instead of this tpl handling assign actions as an array attached the row, iterate through - will better accomodate extension overrides and competition for scarce real estate on this page*}
                           <td>
                             {assign var='checksum_url' value=""}
                             {if $userChecksum}
index a76ad74a9720ef7b2096cb90a8e269c35141f576..beddf36277cc73fc61ddad3b987ab1df96971208 100644 (file)
       {$form.$maxName.html}
     </span>
   </span>
-</td>
-<td>
   <span class="crm-age-range-asofdate">
-      {assign var=dateName   value=$fieldName|cat:$date}
-      {$form.$dateName.label}
-      {include file="CRM/common/jcalendar.tpl" elementName=$dateName}
+    {assign var=dateName value=$fieldName|cat:$date}
+    {$form.$dateName.label}
+    {$form.$dateName.html}
   </span>
   {literal}
     <script type="text/javascript">
-      cj(".crm-age-range").change(function() {
-        if (cj('.crm-age-range-min :text').val() || cj('.crm-age-range-max :text').val()) {
-          cj(".crm-age-range-asofdate").show();
-        } else {
-          cj(".crm-age-range-asofdate").hide();
+      CRM.$(function($) {
+        var $form = $('form.{/literal}{$form.formClass}{literal}');
+        function toggleDate() {
+          $(".crm-age-range-asofdate").toggle(!!($('.crm-age-range-min input', $form).val() || $('.crm-age-range-max input', $form).val()));
         }
-      }).change();
+        $('.crm-age-range input', $form).on('keyup change', toggleDate);
+        toggleDate();
+      });
+
     </script>
   {/literal}
 </td>
index 210454b5751d586e6697ad44d7320edaed1f39f7..cc2a90472f061ab1194838369aa8f5146cb6182d 100644 (file)
@@ -33,7 +33,7 @@
     {/capture}{help id=$help.id file=$help.file}{/if}
     {if $action == 2 && $fieldSpec.is_add_translate_dialog}{include file='CRM/Core/I18n/Dialog.tpl' table=$entityTable field=$fieldName id=$entityID}{/if}
   </td>
-  <td>{$fieldSpec.pre_html_text}{if $form.$fieldName.html}{if $fieldSpec.formatter === 'crmMoney'}{$form.$fieldName.html|crmMoney}{else}{$form.$fieldName.html}{/if}{else}{$fieldSpec.place_holder}{/if}{$fieldSpec.post_html_text}<br />
+  <td>{$fieldSpec.pre_html_text}{if $form.$fieldName.html}{if $fieldSpec.formatter === 'crmMoney'}{$form.$fieldName.html|crmMoney:$fieldSpec.formatterParam}{else}{$form.$fieldName.html}{/if}{else}{$fieldSpec.place_holder}{/if}{$fieldSpec.post_html_text}<br />
     {if $fieldSpec.description}<span class="description">{$fieldSpec.description}</span>{/if}
     {if $fieldSpec.documentation_link}{docURL page=$fieldSpec.documentation_link.page resource=$fieldSpec.documentation_link.resource}{/if}
   </td>
index d9da5ed2962a822eb18f85f66178fb0cfa83413b..f73fd4b10e9f8bdd6f77851910215e10fb4b321c 100644 (file)
 <div class="css_right">
   <a class="crm-hover-button action-item" href="{crmURL q="reset=1&update_smart_groups=1"}">{ts}Update Smart Group Counts{/ts}</a> {help id="update_smart_groups"}
 </div>
+{if call_user_func(array('CRM_Core_Permission','check'), 'edit groups')}
+  {assign var='editableClass' value='crm-editable'}
+{/if}
 <table class="crm-group-selector crm-ajax-table" data-order='[[0,"asc"]]'>
   <thead>
     <tr>
-      <th data-data="title" cell-class="crm-group-name crm-editable crmf-title" class='crm-group-name'>{ts}Name{/ts}</th>
+      <th data-data="title" cell-class="crm-group-name {$editableClass} crmf-title" class='crm-group-name'>{ts}Name{/ts}</th>
       <th data-data="count" cell-class="crm-group-count right" class='crm-group-count'>{ts}Count{/ts}</th>
       <th data-data="created_by" cell-class="crm-group-created_by" class='crm-group-created_by'>{ts}Created By{/ts}</th>
-      <th data-data="description" data-orderable="false" cell-class="crm-group-description crmf-description crm-editable" class='crm-group-description'>{ts}Description{/ts}</th>
+      <th data-data="description" data-orderable="false" cell-class="crm-group-description crmf-description {$editableClass}" class='crm-group-description'>{ts}Description{/ts}</th>
       <th data-data="group_type" cell-class="crm-group-group_type" class='crm-group-group_type'>{ts}Group Type{/ts}</th>
-      <th data-data="visibility" cell-class="crm-group-visibility crmf-visibility crm-editable" cell-data-type="select" class='crm-group-visibility'>{ts}Visibility{/ts}</th>
+      <th data-data="visibility" cell-class="crm-group-visibility crmf-visibility {$editableClass}" cell-data-type="select" class='crm-group-visibility'>{ts}Visibility{/ts}</th>
       {if $showOrgInfo}
         <th data-data="org_info" data-orderable="false" cell-class="crm-group-org_info" class='crm-group-org_info'>{ts}Organization{/ts}</th>
       {/if}
               $.each( response.data, function( i, val ) {
                 appendHTML += '<tr id="row_'+val.group_id+'_'+parent_id+'" data-entity="group" data-id="'+val.group_id+'" class="crm-entity parent_is_'+parent_id+' crm-row-child">';
                 if ( val.is_parent ) {
-                  appendHTML += '<td class="crm-group-name crmf-title ' + levelClass + '">' + '{/literal}<span class="collapsed show-children" title="{ts}show child groups{/ts}"/></span><div class="crmf-title crm-editable" style="display:inline">{literal}' + val.title + '</div></td>';
+                  appendHTML += '<td class="crm-group-name crmf-title ' + levelClass + '">' + '{/literal}<span class="collapsed show-children" title="{ts}show child groups{/ts}"/></span><div class="crmf-title {$editableClass}" style="display:inline">{literal}' + val.title + '</div></td>';
                 }
                 else {
-                  appendHTML += '<td class="crm-group-name  crmf-title crm-editable ' + levelClass + '"><span class="crm-no-children"></span>' + val.title + '</td>';
+                  appendHTML += '<td class="crm-group-name  crmf-title {/literal}{$editableClass}{literal} ' + levelClass + '"><span class="crm-no-children"></span>' + val.title + '</td>';
                 }
                 appendHTML += '<td class="right">' + val.count + "</td>";
                 appendHTML += "<td>" + val.created_by + "</td>";
-                appendHTML += '<td class="crm-editable crmf-description">' + (val.description || '') + "</td>";
+                appendHTML += '<td class="{/literal}{$editableClass}{literal} crmf-description">' + (val.description || '') + "</td>";
                 appendHTML += "<td>" + val.group_type + "</td>";
-                appendHTML += '<td class="crm-editable crmf-visibility" data-type="select">' + val.visibility + "</td>";
+                appendHTML += '<td class="{/literal}{$editableClass}{literal} crmf-visibility" data-type="select">' + val.visibility + "</td>";
                 if (showOrgInfo) {
                   appendHTML += "<td>" + val.org_info + "</td>";
                 }
index 03ec8cdce5d140aa6d4d904b7242935b1adfb3f8..f091432f4734c437c5ed7ce4834766ddf4db508c 100644 (file)
@@ -29,8 +29,6 @@
 
 <div id="crm-container" class="crm-container{if $urlIsPublic} crm-public{/if}" lang="{$config->lcMessages|truncate:2:"":true}" xml:lang="{$config->lcMessages|truncate:2:"":true}">
 
-{crmNavigationMenu is_default=1}
-
 {if $breadcrumb}
   <div class="breadcrumb">
     {foreach from=$breadcrumb item=crumb key=key}
index da9a8501f4b5ee4ee021c5c0143c249f14637d1e..2db8fc0506b886e20ba0e019a3d86a7831fa943f 100644 (file)
  | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
  +--------------------------------------------------------------------+
 *}
-{htxt id="accesskeys-title"}
-  {ts}Access Keys{/ts}
-{/htxt}
 {htxt id="accesskeys"}
-<p></p>
-<ul>
-  <li>ALT+SHIFT+E - <em>{ts}Edit Contact (View Contact Summary Page){/ts}</em></li>
-  <li>ALT+SHIFT+S - <em>{ts}Save Button{/ts}</em></li>
-  <li>ALT+SHIFT+N - <em>{ts}Add a new record in each tab (Activities, Tags,..etc){/ts}</em></li>
-</ul>
+  {php}
+    $ua = strtolower($_SERVER['HTTP_USER_AGENT']);
+    if (strstr($ua, 'mac')) {
+      $key = '<span>CTRL</span>+<span>ALT</span>';
+    }
+    else {
+      $key = strstr($ua, 'firefox') ? '<span>ALT</span>+<span>SHIFT</span>' : '<span>ALT</span>';
+    }
+    $this->assign('accessKey', $key);
+  {/php}
+  <p></p>
+  <ul id="crmAccessKeyList">
+    <li>{$accessKey}+<span>E</span> - {ts}Edit Contact (View Contact Summary Page){/ts}</li>
+    <li>{$accessKey}+<span>S</span> - {ts}Save Button{/ts}</li>
+    <li>{$accessKey}+<span>N</span> - {ts}Add a new record in each tab (Activities, Tags,..etc){/ts}</li>
+    <li>{$accessKey}+<span>M</span> - {ts}Open the CiviCRM menubar{/ts}</li>
+    <li>{$accessKey}+<span>Q</span> - {ts}Quicksearch{/ts}</li>
+  </ul>
+  {literal}<style type="text/css">
+    #crmAccessKeyList li {
+      margin-top: 5px;
+    }
+    #crmAccessKeyList span {
+      display: inline-block;
+      background: grey;
+      font-size: 80%;
+      border: 2px groove #eee;
+      padding: 0 4px;
+    }
+  </style>{/literal}
 {/htxt}
index 025b3d46750672291863751fd60ddfe74c895542..8da5207ae3c295552f9a402166ed54167bf0c773 100644 (file)
@@ -24,7 +24,9 @@
  +--------------------------------------------------------------------+
 *}
 {if not $urlIsPublic}
- <div class="footer" id="access">
- {ts}Access Keys:{/ts}{help id='accesskeys' file='CRM/common/accesskeys'}
- </div>
+  <div class="footer" id="access">
+    {capture assign='accessKeysHelpTitle'}{ts}Access Keys{/ts}{/capture}
+    {ts}Access Keys:{/ts}
+    {help id='accesskeys' file='CRM/common/accesskeys' title=$accessKeysHelpTitle}
+  </div>
 {/if}
index d3b81f5a6270ba0499b09eb99d2a050ce96ddee0..71f11c2b84c0717f73676476754773a8caea24f3 100644 (file)
 
 <div id="crm-container" class="crm-container{if $urlIsPublic} crm-public{/if}" lang="{$config->lcMessages|truncate:2:"":true}" xml:lang="{$config->lcMessages|truncate:2:"":true}">
 
-{* Joomla-only container to hold the civicrm menu *}
-<div id="crm-nav-menu-container"></div>
-{crmNavigationMenu is_default=1}
-
 <table border="0" cellpadding="0" cellspacing="0" id="crm-content">
   <tr>
 {if $sidebarLeft}
index 2ee5fb3a25f51e23991893b777b90b33aba6909c..27338c8dfc9aad4646a3ae781b37a197a4613a28 100644 (file)
@@ -30,6 +30,8 @@
   CRM.config.userFramework = {$config->userFramework|@json_encode};
   CRM.config.resourceBase = {$config->userFrameworkResourceURL|@json_encode};
   CRM.config.lcMessages = {$config->lcMessages|@json_encode};
+  CRM.config.locale = {$locale|@json_encode};
+  CRM.config.cid = {$cid|@json_encode};
   $.datepicker._defaults.dateFormat = CRM.config.dateInputFormat = {$config->dateInputFormat|@json_encode};
   CRM.config.timeIs24Hr = {if $config->timeInputFormat eq 2}true{else}false{/if};
   CRM.config.ajaxPopupsEnabled = {$ajaxPopupsEnabled|@json_encode};
index f91da9823df1e295c2c8f88f78808293d7799a15..21f0c46eb63952aa4812627f4b7fc5fde3cc38b3 100644 (file)
@@ -16,6 +16,31 @@ class CRM_Case_BAO_CaseTypeForkTest extends CiviCaseTestCase {
     CRM_Core_ManagedEntities::singleton(TRUE)->reconcile();
   }
 
+  /**
+   * Test Manager contact is correctly assigned via case type def.
+   */
+  public function testManagerContact() {
+    $caseTypeId = CRM_Core_DAO::getFieldValue('CRM_Case_DAO_CaseType', 'ForkableCaseType', 'id', 'name');
+    $this->assertTrue(is_numeric($caseTypeId) && $caseTypeId > 0);
+
+    $this->callAPISuccess('CaseType', 'create', [
+      'id' => $caseTypeId,
+      'definition' => [
+        'caseRoles' => [
+          ['name' => 'First role', 'manager' => 0],
+          ['name' => 'Second role', 'creator' => 1, 'manager' => 1],
+        ],
+      ],
+    ]);
+    $relTypeID = $this->callAPISuccessGetValue('RelationshipType', [
+      'return' => "id",
+      'name_b_a' => "Second role",
+    ]);
+    //Check if manager is correctly retrieved from xml processor.
+    $xmlProcessor = new CRM_Case_XMLProcessor_Process();
+    $this->assertEquals($relTypeID, $xmlProcessor->getCaseManagerRoleId('ForkableCaseType'));
+  }
+
 
   /**
    * Edit the definition of ForkableCaseType.
index fc1acf50a6a1670115e2b46b8667a561dbe5353f..faf560bd736c3330f5197118833e7cc8c02297c8 100644 (file)
@@ -441,7 +441,7 @@ class CRM_Contact_BAO_GroupContactCacheTest extends CiviUnitTestCase {
       FALSE, FALSE, FALSE,
       TRUE, FALSE
     );
-    $key = $query->getGroupCacheTableKey();
+    $key = $query->getGroupCacheTableKeys()[0];
     $expectedWhere = "civicrm_group_contact_cache_{$key}.group_id IN (\"{$group2->id}\")";
     $this->assertContains($expectedWhere, $query->_whereClause);
     $this->_assertContactIds($query, "group_id = {$group2->id}");
@@ -453,7 +453,7 @@ class CRM_Contact_BAO_GroupContactCacheTest extends CiviUnitTestCase {
       FALSE,
       FALSE, FALSE
     );
-    $key = $query->getGroupCacheTableKey();
+    $key = $query->getGroupCacheTableKeys()[0];
     //Assert if proper where clause is present.
     $expectedWhere = "civicrm_group_contact_{$key}.group_id != {$group->id} AND civicrm_group_contact_cache_{$key}.group_id IS NULL OR  ( civicrm_group_contact_cache_{$key}.contact_id NOT IN (SELECT contact_id FROM civicrm_group_contact_cache cgcc WHERE cgcc.group_id IN ( {$group->id} ) ) )";
     $this->assertContains($expectedWhere, $query->_whereClause);
@@ -466,7 +466,7 @@ class CRM_Contact_BAO_GroupContactCacheTest extends CiviUnitTestCase {
       FALSE,
       FALSE, FALSE
     );
-    $key = $query->getGroupCacheTableKey();
+    $key = $query->getGroupCacheTableKeys()[0];
     $expectedWhere = "civicrm_group_contact_cache_{$key}.group_id IN (\"{$group->id}\", \"{$group2->id}\")";
     $this->assertContains($expectedWhere, $query->_whereClause);
     $this->_assertContactIds($query, "group_id IN ({$group->id}, {$group2->id})");
@@ -478,10 +478,55 @@ class CRM_Contact_BAO_GroupContactCacheTest extends CiviUnitTestCase {
       FALSE,
       FALSE, FALSE
     );
-    $key = $query->getGroupCacheTableKey();
+    $key = $query->getGroupCacheTableKeys()[0];
     $expectedWhere = "civicrm_group_contact_{$key}.group_id NOT IN ( {$group->id} ) AND civicrm_group_contact_cache_{$key}.group_id IS NULL OR  ( civicrm_group_contact_cache_{$key}.contact_id NOT IN (SELECT contact_id FROM civicrm_group_contact_cache cgcc WHERE cgcc.group_id IN ( {$group->id} ) ) )";
     $this->assertContains($expectedWhere, $query->_whereClause);
     $this->_assertContactIds($query, "group_id NOT IN ({$group->id})");
+    $this->callAPISuccess('group', 'delete', ['id' => $group->id]);
+    $this->callAPISuccess('group', 'delete', ['id' => $group2->id]);
+  }
+
+
+  public function testMultipleGroupWhereClause() {
+    $returnProperties = array(
+      'contact_type' => 1,
+      'contact_sub_type' => 1,
+      'sort_name' => 1,
+      'group' => 1,
+    );
+    list($group, $living, $deceased) = $this->setupSmartGroup();
+
+    $params = array(
+      'name' => 'Living Contacts',
+      'title' => 'Living Contacts',
+      'is_active' => 1,
+      'formValues' => array('is_deceased' => 0),
+    );
+    $group2 = CRM_Contact_BAO_Group::createSmartGroup($params);
+
+    //Filter on smart group with =, !=, IN and NOT IN operator.
+    $params = array(array('group', '=', $group2->id, 1, 0), array('group', '=', $group->id, 1, 0));
+    $query = new CRM_Contact_BAO_Query(
+      $params, $returnProperties,
+      NULL, FALSE, FALSE, CRM_Contact_BAO_Query::MODE_CONTACTS,
+      FALSE,
+      FALSE, FALSE
+    );
+    $ids = $query->searchQuery(0, 0, NULL,
+      FALSE, FALSE, FALSE,
+      TRUE, FALSE
+    );
+    $key1 = $query->getGroupCacheTableKeys()[0];
+    $key2 = $query->getGroupCacheTableKeys()[1];
+    $expectedWhere = 'civicrm_group_contact_cache_' . $key1 . '.group_id IN ("' . $group2->id . '") )  )  AND  (  ( civicrm_group_contact_cache_' . $key2 . '.group_id IN ("' . $group->id . '")';
+    $this->assertContains($expectedWhere, $query->_whereClause);
+    // Check that we have 3 joins to the group contact cache 1 for each of the group where clauses and 1 for the fact we are returning groups in the select.
+    $expectedFrom1 = 'LEFT JOIN civicrm_group_contact_cache civicrm_group_contact_cache_' . $key1 . ' ON contact_a.id = civicrm_group_contact_cache_' . $key1 . '.contact_id';
+    $this->assertContains($expectedFrom1, $query->_fromClause);
+    $expectedFrom2 = 'LEFT JOIN civicrm_group_contact_cache civicrm_group_contact_cache_' . $key2 . ' ON contact_a.id = civicrm_group_contact_cache_' . $key2 . '.contact_id';
+    $this->assertContains($expectedFrom2, $query->_fromClause);
+    $expectedFrom3 = 'LEFT JOIN civicrm_group_contact_cache ON contact_a.id = civicrm_group_contact_cache.contact_id';
+    $this->assertContains($expectedFrom3, $query->_fromClause);
   }
 
   /**
index d6a038bd9e897f9cdbd5f422965d63089cd8be5f..1f94137f69f0f8e2804bad32ef36d3d60bee956f 100644 (file)
@@ -6,6 +6,7 @@
  */
 class CRM_Contact_BAO_QueryTest extends CiviUnitTestCase {
   use CRMTraits_Financial_FinancialACLTrait;
+  use CRMTraits_Financial_PriceSetTrait;
 
   /**
    * @return CRM_Contact_BAO_QueryTestDataProvider
@@ -19,6 +20,7 @@ class CRM_Contact_BAO_QueryTest extends CiviUnitTestCase {
   }
 
   public function tearDown() {
+    $this->quickCleanUpFinancialEntities();
     $tablesToTruncate = array(
       'civicrm_group_contact',
       'civicrm_group',
@@ -97,10 +99,7 @@ class CRM_Contact_BAO_QueryTest extends CiviUnitTestCase {
 
     $queryObj = new CRM_Contact_BAO_Query($params, $returnProperties);
     try {
-      $resultDAO = $queryObj->searchQuery(0, 0, NULL,
-        FALSE, FALSE,
-        FALSE, FALSE,
-        FALSE);
+      $resultDAO = $queryObj->searchQuery();
       $this->assertTrue($resultDAO->fetch());
     }
     catch (PEAR_Exception $e) {
@@ -139,10 +138,7 @@ class CRM_Contact_BAO_QueryTest extends CiviUnitTestCase {
 
     $queryObj = new CRM_Contact_BAO_Query($params, $returnProperties);
     try {
-      $resultDAO = $queryObj->searchQuery(0, 0, NULL,
-        FALSE, FALSE,
-        FALSE, FALSE,
-        FALSE);
+      $resultDAO = $queryObj->searchQuery();
       $this->assertFalse($resultDAO->fetch());
     }
     catch (PEAR_Exception $e) {
@@ -187,10 +183,7 @@ class CRM_Contact_BAO_QueryTest extends CiviUnitTestCase {
       );
 
       $queryObj = new CRM_Contact_BAO_Query($params, $returnProperties);
-      $resultDAO = $queryObj->searchQuery(0, 0, NULL,
-        FALSE, FALSE,
-        FALSE, FALSE,
-        FALSE);
+      $resultDAO = $queryObj->searchQuery();
 
       if ($searchPrimary) {
         $this->assertEquals($resultDAO->N, 0);
@@ -245,10 +238,7 @@ class CRM_Contact_BAO_QueryTest extends CiviUnitTestCase {
 
     $queryObj = new CRM_Contact_BAO_Query($params, $returnProperties);
 
-    $resultDAO = $queryObj->searchQuery(0, 0, NULL,
-      FALSE, FALSE,
-      FALSE, FALSE,
-      FALSE);
+    $resultDAO = $queryObj->searchQuery();
     $resultDAO->fetch();
   }
 
@@ -280,10 +270,7 @@ class CRM_Contact_BAO_QueryTest extends CiviUnitTestCase {
     $expectedSQL = "SELECT contact_a.id as contact_id, contact_a.contact_type as `contact_type`, contact_a.contact_sub_type as `contact_sub_type`, contact_a.sort_name as `sort_name`, civicrm_address.id as address_id, " . $selectClause . "  FROM civicrm_contact contact_a LEFT JOIN civicrm_address ON ( contact_a.id = civicrm_address.contact_id AND civicrm_address.is_primary = 1 ) WHERE  (  ( " . $whereClause . " )  )  AND (contact_a.is_deleted = 0)    ORDER BY `contact_a`.`sort_name` ASC, `contact_a`.`id` ";
     $queryObj = new CRM_Contact_BAO_Query($params, $returnProperties);
     try {
-      $this->assertEquals($expectedSQL, $queryObj->searchQuery(0, 0, NULL,
-        FALSE, FALSE,
-        FALSE, FALSE,
-        TRUE));
+      $this->assertEquals($expectedSQL, $queryObj->getSearchSQL());
       list($select, $from, $where, $having) = $queryObj->query();
       $dao = CRM_Core_DAO::executeQuery("$select $from $where $having");
       $dao->fetch();
@@ -714,12 +701,31 @@ civicrm_relationship.is_active = 1 AND
    * Test the summary query does not add an acl clause when acls not enabled..
    */
   public function testGetSummaryQueryWithFinancialACLDisabled() {
+    $this->createContributionsForSummaryQueryTests();
+
+    // Test the function directly
     $where = $from = NULL;
     $queryObject = new CRM_Contact_BAO_Query();
-    $query = $queryObject->appendFinancialTypeWhereAndFromToQueryStrings($where,
+    $queryObject->appendFinancialTypeWhereAndFromToQueryStrings($where,
       $from);
-    $this->assertEquals($where, $query[0]);
-    $this->assertEquals($from, $query[1]);
+    $this->assertEquals(NULL, $where);
+    $this->assertEquals(NULL, $from);
+
+    // Test the function in action
+    $queryObject = new CRM_Contact_BAO_Query([['contribution_source', '=', 'SSF', '', '']]);
+    $summary = $queryObject->summaryContribution();
+    $this->assertEquals([
+      'total' => [
+        'avg' => '$ 233.33',
+        'amount' => '$ 1,400.00',
+        'count' => 6,
+        ],
+      'cancel' => [
+        'count' => 2,
+        'amount' => '$ 100.00',
+        'avg' => '$ 50.00',
+      ],
+    ], $summary);
   }
 
   /**
@@ -727,16 +733,35 @@ civicrm_relationship.is_active = 1 AND
    */
   public function testGetSummaryQueryWithFinancialACLEnabled() {
     $where = $from = NULL;
+    $this->createContributionsForSummaryQueryTests();
     $this->enableFinancialACLs();
     $this->createLoggedInUserWithFinancialACL();
+
+    // Test the function directly
     $queryObject = new CRM_Contact_BAO_Query();
-    $query = $queryObject->appendFinancialTypeWhereAndFromToQueryStrings($where,
+    $queryObject->appendFinancialTypeWhereAndFromToQueryStrings($where,
       $from);
     $donationTypeID = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'financial_type_id', 'Donation');
     $this->assertEquals(
       " LEFT JOIN civicrm_line_item li
                   ON civicrm_contribution.id = li.contribution_id AND
                      li.entity_table = 'civicrm_contribution' AND li.financial_type_id NOT IN ({$donationTypeID}) ", $from);
+
+    // Test the function in action
+    $queryObject = new CRM_Contact_BAO_Query([['contribution_source', '=', 'SSF', '', '']]);
+    $summary = $queryObject->summaryContribution();
+    $this->assertEquals([
+      'total' => [
+        'avg' => '$ 200.00',
+        'amount' => '$ 400.00',
+        'count' => 2,
+      ],
+      'cancel' => [
+        'count' => 1,
+        'amount' => '$ 50.00',
+        'avg' => '$ 50.00',
+      ],
+    ], $summary);
     $this->disableFinancialACLs();
   }
 
@@ -778,4 +803,53 @@ civicrm_relationship.is_active = 1 AND
     $this->assertEquals($modparams['member_is_primary'][2], $fv_orig['member_is_primary']);
   }
 
+  /**
+   * Create contributions to test summary calculations.
+   *
+   * financial type     | cancel_date        |total_amount| source    | line_item_financial_types  |number_line_items| line_amounts
+   * Donation           |NULL                | 100.00     |SSF         | Donation                  | 1                | 100.00
+   * Member Dues        |NULL                | 100.00     |SSF         | Member Dues               | 1                | 100.00
+   * Donation           |NULL                | 300.00     |SSF         | Event Fee,Event Fee       | 2                | 200.00,100.00
+   * Donation           |NULL                | 300.00     |SSF         | Event Fee,Donation        | 2                | 200.00,100.00
+   * Donation           |NULL                | 300.00     |SSF         | Donation,Donation         | 2                | 200.00,100.00
+   * Donation           |2019-02-13 00:00:00 | 50.00      |SSF         | Donation                  | 1                | 50.00
+   * Member Dues        |2019-02-13 00:00:00 | 50.00      |SSF         | Member Dues               | 1                | 50.00
+   */
+  protected function createContributionsForSummaryQueryTests() {
+    $contactID = $this->individualCreate();
+    $this->contributionCreate(['contact_id' => $contactID]);
+    $this->contributionCreate([
+      'contact_id' => $contactID,
+      'total_amount' => 100,
+      'financial_type_id' => 'Member Dues',
+    ]);
+    $eventFeeType = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'financial_type_id', 'Event Fee');
+    $this->createContributionWithTwoLineItemsAgainstPriceSet(['contact_id' => $contactID, 'source' => 'SSF']);
+    $this->createContributionWithTwoLineItemsAgainstPriceSet(['contact_id' => $contactID, 'source' => 'SSF'], [
+      CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'financial_type_id', 'Donation'),
+      $eventFeeType,
+    ]);
+    $this->createContributionWithTwoLineItemsAgainstPriceSet(['contact_id' => $contactID, 'source' => 'SSF'], [
+      CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'financial_type_id', 'Donation'),
+      CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'financial_type_id', 'Donation'),
+    ]);
+    $this->createContributionWithTwoLineItemsAgainstPriceSet(['contact_id' => $contactID, 'source' => 'SSF', 'financial_type_id' => $eventFeeType], [
+      CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'financial_type_id', 'Donation'),
+      CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'financial_type_id', 'Donation'),
+    ]);
+    $this->contributionCreate([
+      'contact_id' => $contactID,
+      'total_amount' => 50,
+      'contribution_status_id' => 'Cancelled',
+      'cancel_date' => 'yesterday',
+    ]);
+    $this->contributionCreate([
+      'contact_id' => $contactID,
+      'total_amount' => 50,
+      'contribution_status_id' => 'Cancelled',
+      'cancel_date' => 'yesterday',
+      'financial_type_id' => 'Member Dues',
+    ]);
+  }
+
 }
index 0f059129d66de6d8d4839ea7aaaf95c516012676..e1312ea1d8e0135c21e7242bb5cbbd8dcb31f7d5 100644 (file)
@@ -509,6 +509,7 @@ class CRM_Contact_Import_Parser_ContactTest extends CiviUnitTestCase {
    * CRM-19888 default country should be used if ambigous.
    */
   public function testImportAmbiguousStateCountry() {
+    $this->callAPISuccess('Setting', 'create', ['defaultContactCountry' => 1228]);
     $countries = CRM_Core_PseudoConstant::country(FALSE, FALSE);
     $this->callAPISuccess('Setting', 'create', array('countryLimit' => array(array_search('United States', $countries), array_search('Guyana', $countries), array_search('Netherlands', $countries))));
     $this->callAPISuccess('Setting', 'create', array('provinceLimit' => array(array_search('United States', $countries), array_search('Guyana', $countries), array_search('Netherlands', $countries))));
index d8e7625797967726e92157dfdf2511df55490a24..d699dbf5729b0fa6f03b5f2c100ecbe50b3eac21 100644 (file)
@@ -134,7 +134,7 @@ class CRM_Contact_Page_View_UserDashBoardTest extends CiviUnitTestCase {
       'receive_date' => '2018-11-21 00:00:00',
       'contribution_status' => 'Completed',
       'currency' => 'USD',
-      //'receipt_date' => '2018-11-22 00:00:00',
+      'receipt_date' => '2018-11-22 00:00:00',
     ]);
 
   }
diff --git a/tests/phpunit/CRM/Contribute/BAO/QueryTest.php b/tests/phpunit/CRM/Contribute/BAO/QueryTest.php
new file mode 100644 (file)
index 0000000..928ac2b
--- /dev/null
@@ -0,0 +1,57 @@
+<?php
+
+/**
+ *  Include dataProvider for tests
+ * @group headless
+ */
+class CRM_Contribute_BAO_QueryTest extends CiviUnitTestCase {
+  public function tearDown() {
+    $this->quickCleanUpFinancialEntities();
+  }
+
+  /**
+   * Check that we get a successful trying to return by pseudo-fields
+   *  - financial_type.
+   *
+   * @param string $sort
+   *
+   * @dataProvider getSortFields
+   */
+  public function testSearchPseudoReturnProperties($sort) {
+    $contactID = $this->individualCreate();
+    $this->contributionCreate(['contact_id' => $contactID, 'financial_type_id' => 'Campaign Contribution']);
+    $this->contributionCreate(['contact_id' => $contactID, 'financial_type_id' => 'Donation']);
+    $donationTypeID = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'financial_type_id', 'Donation');
+
+    $params = [
+      ['financial_type_id', '=', $donationTypeID , 1, 0],
+    ];
+
+    $queryObj = new CRM_Contact_BAO_Query($params);
+    try {
+      $resultDAO = $queryObj->searchQuery(0, 0, $sort . ' asc');
+      $this->assertTrue($resultDAO->fetch());
+      $this->assertEquals(1, $resultDAO->N);
+    }
+    catch (PEAR_Exception $e) {
+      $err = $e->getCause();
+      $this->fail('invalid SQL created' . $e->getMessage() . " " . $err->userinfo);
+
+    }
+  }
+
+  /**
+   * Data provider for sort fields
+   */
+  public function getSortFields() {
+    return [
+      ['payment_instrument'],
+      ['individual_prefix'],
+      ['communication_style'],
+      ['gender'],
+      ['state_province'],
+      ['country'],
+    ];
+  }
+
+}
index 8bf35e2609388d287c9b053bd9eeb770f61121e3..362dc43875de297db32011cffb01995f988c4887 100644 (file)
@@ -122,6 +122,7 @@ class CRM_Contribute_Form_AdditionalPaymentTest extends CiviUnitTestCase {
    */
   public function tearDown() {
     $this->quickCleanUpFinancialEntities();
+    CRM_Core_DAO::executeQuery('DELETE FROM civicrm_mailing_spool ORDER BY id DESC');
     parent::tearDown();
   }
 
@@ -137,14 +138,20 @@ class CRM_Contribute_Form_AdditionalPaymentTest extends CiviUnitTestCase {
     $this->checkResults(array(30, 70), 2);
     $mut->assertSubjects(['Payment Receipt -']);
     $mut->checkMailLog([
-      'Dear Anthony Anderson',
+      'Dear Anthony,',
       'Payment Details',
       'Total Fees: $ 100.00',
       'This Payment Amount: $ 70.00',
       'Balance Owed: $ 0.00 ',
+      'Billing Name and Address',
+      'Vancouver, AE 1321312',
+      'Visa',
+      '***********1111',
+      'Expires: May 2025',
     ]);
 
     $mut->stop();
+    $mut->clearMessages();
   }
 
   /**
@@ -178,16 +185,41 @@ class CRM_Contribute_Form_AdditionalPaymentTest extends CiviUnitTestCase {
    * Test the submit function that completes the partially paid Contribution with multiple payments.
    */
   public function testMultiplePaymentForPartiallyPaidContributionWithOneCreditCardPayment() {
+    $mut = new CiviMailUtils($this, TRUE);
     $this->createContribution('Partially paid');
+    // In general when there is tpl leakage we try to fix. At the moment, however,
+    // the tpl leakage on credit card related things is kind of 'by-design' - or
+    // at least we haven't found a way to replace the way in with Payment.send_confirmation
+    // picks them up from the form process so we will just clear templates here to stop leakage
+    // from previous tests causing a fail.
+    // The reason this is hard to fix is that we save a billing address per contribution not
+    // per payment so it's a problem with the data model
+    CRM_Core_Smarty::singleton()->clearTemplateVars();
 
     // pay additional amount
-    $this->submitPayment(50);
+    $this->submitPayment(50, NULL, TRUE);
     $contribution = $this->callAPISuccessGetSingle('Contribution', array('id' => $this->_contributionId));
     $this->assertEquals('Partially paid', $contribution['contribution_status']);
 
     // pay additional amount by using credit card
     $this->submitPayment(20, 'live');
     $this->checkResults(array(30, 50, 20), 3);
+    $mut->assertSubjects(array('Payment Receipt -'));
+    $mut->checkMailLog([
+      'Dear Anthony,',
+      'A payment has been received',
+      'Total Fees: $ 100.00',
+      'This Payment Amount: $ 50.00',
+      'Balance Owed: $ 20.00 ',
+      'Paid By: Check',
+      'Check Number: check-12345',
+    ],
+    [
+      'Billing Name and Address',
+      'Visa',
+    ]);
+    $mut->stop();
+    $mut->clearMessages();
   }
 
   /**
diff --git a/tests/phpunit/CRM/Contribute/Form/Contribution/ThankYouTest.php b/tests/phpunit/CRM/Contribute/Form/Contribution/ThankYouTest.php
new file mode 100644 (file)
index 0000000..efe98b0
--- /dev/null
@@ -0,0 +1,134 @@
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 5                                                  |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2019                                |
+ +--------------------------------------------------------------------+
+ | This file is a part of CiviCRM.                                    |
+ |                                                                    |
+ | CiviCRM is free software; you can copy, modify, and distribute it  |
+ | under the terms of the GNU Affero General Public License           |
+ | Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
+ |                                                                    |
+ | CiviCRM is distributed in the hope that it will be useful, but     |
+ | WITHOUT ANY WARRANTY; without even the implied warranty of         |
+ | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
+ | See the GNU Affero General Public License for more details.        |
+ |                                                                    |
+ | You should have received a copy of the GNU Affero General Public   |
+ | License and the CiviCRM Licensing Exception along                  |
+ | with this program; if not, contact CiviCRM LLC                     |
+ | at info[AT]civicrm[DOT]org. If you have questions about the        |
+ | GNU Affero General Public License or the licensing of CiviCRM,     |
+ | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
+ +--------------------------------------------------------------------+
+ */
+
+/**
+ *  Test CRM_Contribute_Form_Contribution_ThankYou
+ *
+ * @package CiviCRM_APIv3
+ * @subpackage API_Contribution
+ * @group headless
+ */
+class CRM_Contribute_Form_Contribution_ThankYouTest extends CiviUnitTestCase {
+
+  /**
+   * Clean up DB.
+   */
+  public function tearDown() {
+    $this->quickCleanUpFinancialEntities();
+  }
+
+  /**
+   * Test that correct contribution status is fetched for both live and test contributions.
+   */
+  public function testLiveAndTestContributionStatus() {
+    $paymentProcessorID = $this->paymentProcessorCreate(array('payment_processor_type_id' => 'Dummy'));
+
+    $form = $this->getThankYouFormWithContribution($paymentProcessorID, FALSE, FALSE);
+    $form->buildQuickForm();
+    $isPendingOutcome = $form->get_template_vars('isPendingOutcome');
+
+    $this->assertEquals(FALSE, $isPendingOutcome, 'Outcome should not be pending.');
+
+    $form = $this->getThankYouFormWithContribution($paymentProcessorID, TRUE, FALSE);
+    $form->buildQuickForm();
+    $isPendingOutcome = $form->get_template_vars('isPendingOutcome');
+
+    $this->assertEquals(TRUE, $isPendingOutcome, 'Outcome should be pending.');
+
+    $form = $this->getThankYouFormWithContribution($paymentProcessorID, FALSE, TRUE);
+    $form->buildQuickForm();
+    $isPendingOutcome = $form->get_template_vars('isPendingOutcome');
+
+    $this->assertEquals(FALSE, $isPendingOutcome, 'Outcome should not be pending.');
+
+    $form = $this->getThankYouFormWithContribution($paymentProcessorID, TRUE, TRUE);
+    $form->buildQuickForm();
+    $isPendingOutcome = $form->get_template_vars('isPendingOutcome');
+
+    $this->assertEquals(TRUE, $isPendingOutcome, 'Outcome should be pending.');
+  }
+
+  /**
+   * Get CRM_Contribute_Form_Contribution_ThankYou form with attached contribution.
+   *
+   * @param $paymentProcessorID
+   * @param bool $withPendingContribution
+   * @param bool $isTestContribution
+   * @return CRM_Contribute_Form_Contribution_ThankYou
+   */
+  private function getThankYouFormWithContribution($paymentProcessorID, $withPendingContribution = FALSE, $isTestContribution = FALSE) {
+    $pageContribution = $this->getPageContribution((($withPendingContribution) ? 2 : 1), $isTestContribution);
+    $form = $this->getThankYouForm();
+    $form->_lineItem = array();
+
+    $form->_params['contributionID'] = $pageContribution['contribution_id'];
+    $form->_params['invoiceID'] = $pageContribution['invoice_id'];
+    $form->_params['payment_processor_id'] = $paymentProcessorID;
+    if ($isTestContribution) {
+      $form->_mode = 'test';
+    }
+
+    return $form;
+  }
+
+  /**
+   * Get Contribution and Invoice ID.
+   *
+   * @param $contributionStatus
+   * @param bool $isTest
+   * @return array
+   */
+  private function getPageContribution($contributionStatus, $isTest = FALSE) {
+    $individualId = $this->individualCreate();
+    $invoiceId = rand(100000, 999999);
+
+    $contributionId = $this->contributionCreate(array(
+      'contact_id'             => $individualId,
+      'invoice_id'             => $invoiceId,
+      'contribution_status_id' => $contributionStatus,
+      'is_test'                => ($isTest) ? 1 : 0,
+    ));
+
+    return array(
+      'contribution_id' => $contributionId,
+      'invoice_id'      => $invoiceId,
+    );
+  }
+
+  /**
+   * Get CRM_Contribute_Form_Contribution_ThankYou Form
+   *
+   * @return CRM_Contribute_Form_Contribution_ThankYou
+   */
+  private function getThankYouForm() {
+    $form = new CRM_Contribute_Form_Contribution_ThankYou();
+    $_SERVER['REQUEST_METHOD'] = 'GET';
+    $form->controller = new CRM_Contribute_Controller_Contribution();
+    return $form;
+  }
+
+}
index 9bbf4dda1a11634267dcd86167c2e39f5417bdd4..5d2237e158396e48b2ae561526abcd317532ba85 100644 (file)
@@ -37,7 +37,7 @@
 class CRM_Contribute_Form_SearchTest extends CiviUnitTestCase {
 
   protected $_individual;
-  protected $_tablesToTruncate = array('civicrm_contribution', 'civicrm_line_item');
+  protected $_tablesToTruncate = ['civicrm_contribution', 'civicrm_line_item'];
 
   public function setUp() {
     parent::setUp();
@@ -52,12 +52,12 @@ class CRM_Contribute_Form_SearchTest extends CiviUnitTestCase {
    */
   public function testBatchFilter() {
     $this->quickCleanup($this->_tablesToTruncate);
-    $contactID1 = $this->individualCreate(array(), 1);
-    $contactID2 = $this->individualCreate(array(), 2);
+    $contactID1 = $this->individualCreate([], 1);
+    $contactID2 = $this->individualCreate([], 2);
     $batchTitle = CRM_Batch_BAO_Batch::generateBatchName();
 
     // create batch
-    $batch = $this->callAPISuccess('Batch', 'create', array(
+    $batch = $this->callAPISuccess('Batch', 'create', [
       'created_id' => $this->_individual,
       'created_date' => CRM_Utils_Date::processDate(date("Y-m-d"), date("H:i:s")),
       'status_id' => CRM_Core_Pseudoconstant::getKey('CRM_Batch_BAO_Batch', 'status_id', 'Data Entry'),
@@ -65,17 +65,17 @@ class CRM_Contribute_Form_SearchTest extends CiviUnitTestCase {
       'item_count' => 2,
       'total' => 100,
       'type_id' => array_search('Contribution', CRM_Batch_BAO_Batch::buildOptions('type_id')),
-    ));
+    ]);
     $batchID = $batch['id'];
 
-    $batchEntry = array(
-      'primary_profiles' => array(1 => NULL, 2 => NULL, 3 => NULL),
-      'primary_contact_id' => array(
+    $batchEntry = [
+      'primary_profiles' => [1 => NULL, 2 => NULL, 3 => NULL],
+      'primary_contact_id' => [
         1 => $contactID1,
         2 => $contactID2,
-      ),
-      'field' => array(
-        1 => array(
+      ],
+      'field' => [
+        1 => [
           'financial_type' => 1,
           'total_amount' => 70,
           'receive_date' => '2013-07-24',
@@ -83,8 +83,8 @@ class CRM_Contribute_Form_SearchTest extends CiviUnitTestCase {
           'payment_instrument' => 1,
           'check_number' => NULL,
           'contribution_status_id' => 1,
-        ),
-        2 => array(
+        ],
+        2 => [
           'financial_type' => 1,
           'total_amount' => 30,
           'receive_date' => '2014-07-24',
@@ -92,13 +92,13 @@ class CRM_Contribute_Form_SearchTest extends CiviUnitTestCase {
           'payment_instrument' => 1,
           'check_number' => NULL,
           'contribution_status_id' => 1,
-        ),
-      ),
+        ],
+      ],
       'actualBatchTotal' => 100,
-    );
+    ];
 
     // create random contribution to check IS NULL filter more precisely
-    $nonBatchContri = $this->callAPISuccess('Contribution', 'create', array(
+    $nonBatchContri = $this->callAPISuccess('Contribution', 'create', [
       'financial_type_id' => 1,
       'total_amount' => 123,
       'receive_date' => '2014-07-24',
@@ -107,7 +107,7 @@ class CRM_Contribute_Form_SearchTest extends CiviUnitTestCase {
       'check_number' => NULL,
       'contribution_status_id' => 1,
       'contact_id' => $this->_individual,
-    ));
+    ]);
     $nonBatchContriID = $nonBatchContri['id'];
 
     // process batch entries
@@ -117,40 +117,40 @@ class CRM_Contribute_Form_SearchTest extends CiviUnitTestCase {
 
     // fetch created contributions
     $entities = $this->callAPISuccess('EntityBatch', 'get', array('batch_id' => $batchID));
-    $ids = array();
+    $ids = [];
     foreach ($entities['values'] as $value) {
       $ids[] = $value['entity_id'];
     }
     list($batchContriID1, $batchContriID2) = $ids;
 
-    $useCases = array(
+    $useCases = [
       // Case 1: Search for ONLY those contributions which are created from batch
-      array(
+      [
         'form_value' => array('contribution_batch_id' => 'IS NOT NULL'),
         'expected_count' => 2,
         'expected_contribution' => array($batchContriID1, $batchContriID2),
         'expected_qill' => 'Batch Name Not Null',
-      ),
+      ],
       // Case 2: Search for ONLY those contributions which are NOT created from batch
-      array(
+      [
         'form_value' => array('contribution_batch_id' => 'IS NULL'),
         'expected_count' => 1,
         'expected_contribution' => array($nonBatchContriID),
         'expected_qill' => 'Batch Name Is Null',
-      ),
+      ],
       // Case 3: Search for ONLY those contributions which are created from batch ID - $batchID
-      array(
+      [
         'form_value' => array('contribution_batch_id' => $batchID),
         'expected_count' => 2,
         'expected_contribution' => array($batchContriID1, $batchContriID2),
         'expected_qill' => 'Batch Name = ' . $batchTitle,
-      ),
-    );
+      ],
+    ];
     foreach ($useCases as $case) {
       $fv = $case['form_value'];
       CRM_Contact_BAO_Query::processSpecialFormValue($fv, array('contribution_batch_id'));
       $query = new CRM_Contact_BAO_Query(CRM_Contact_BAO_Query::convertFormValues($fv));
-      list($select, $from, $where, $having) = $query->query();
+      list($select, $from, $where) = $query->query();
 
       // get and assert contribution count
       $contributions = CRM_Core_DAO::executeQuery(sprintf('SELECT DISTINCT civicrm_contribution.id %s %s AND civicrm_contribution.id IS NOT NULL', $from, $where))->fetchAll();
@@ -192,7 +192,7 @@ class CRM_Contribute_Form_SearchTest extends CiviUnitTestCase {
       'total_amount' => 100,
     );
     CRM_Core_BAO_FinancialTrxn::create($params);
-    $Contribution2 = $this->callAPISuccess('Contribution', 'create', array(
+    $this->callAPISuccess('Contribution', 'create', array(
       'financial_type_id' => 1,
       'total_amount' => 150,
       'receive_date' => date('Ymd'),
@@ -255,7 +255,7 @@ class CRM_Contribute_Form_SearchTest extends CiviUnitTestCase {
       $fv = $case['form_value'];
       CRM_Contact_BAO_Query::processSpecialFormValue($fv, array('financial_trxn_card_type_id'));
       $query = new CRM_Contact_BAO_Query(CRM_Contact_BAO_Query::convertFormValues($fv));
-      list($select, $from, $where, $having) = $query->query();
+      list($select, $from, $where) = $query->query();
 
       // get and assert contribution count
       $contributions = CRM_Core_DAO::executeQuery(sprintf('SELECT DISTINCT civicrm_contribution.id %s %s AND civicrm_contribution.id IS NOT NULL', $from, $where))->fetchAll();
@@ -298,7 +298,7 @@ class CRM_Contribute_Form_SearchTest extends CiviUnitTestCase {
       'pan_truncation' => 1234,
     );
     CRM_Core_BAO_FinancialTrxn::create($params);
-    $Contribution2 = $this->callAPISuccess('Contribution', 'create', array(
+    $this->callAPISuccess('Contribution', 'create', array(
       'financial_type_id' => 1,
       'total_amount' => 150,
       'receive_date' => date('Ymd'),
@@ -355,7 +355,7 @@ class CRM_Contribute_Form_SearchTest extends CiviUnitTestCase {
       $fv = $case['form_value'];
       CRM_Contact_BAO_Query::processSpecialFormValue($fv, array('financial_trxn_pan_truncation'));
       $query = new CRM_Contact_BAO_Query(CRM_Contact_BAO_Query::convertFormValues($fv));
-      list($select, $from, $where, $having) = $query->query();
+      list($select, $from, $where) = $query->query();
 
       // get and assert contribution count
       $contributions = CRM_Core_DAO::executeQuery(sprintf('SELECT DISTINCT civicrm_contribution.id %s %s AND civicrm_contribution.id IS NOT NULL', $from, $where))->fetchAll();
@@ -377,10 +377,10 @@ class CRM_Contribute_Form_SearchTest extends CiviUnitTestCase {
    */
   public function testContributionRecurStatusFilter() {
     $this->quickCleanup($this->_tablesToTruncate);
-    $contactID1 = $this->individualCreate(array(), 1);
-    $contactID2 = $this->individualCreate(array(), 2);
+    $contactID1 = $this->individualCreate([], 1);
+    $contactID2 = $this->individualCreate([], 2);
     // "In Progress" recurring contribution for contactID1
-    $ContributionRecur1 = $this->callAPISuccess('ContributionRecur', 'create', array(
+    $ContributionRecur1 = $this->callAPISuccess('ContributionRecur', 'create', [
       'sequential' => 1,
       'contact_id' => $contactID1,
       'frequency_interval' => 1,
@@ -390,9 +390,9 @@ class CRM_Contribute_Form_SearchTest extends CiviUnitTestCase {
       'payment_instrument_id' => 1,
       'contribution_status_id' => 5,
       'financial_type_id' => "Donation",
-    ));
-    $Contribution1 = $this->callAPISuccess('Contribution', 'create', array(
-      'financial_type_id' => 1,
+    ]);
+    $Contribution1 = $this->callAPISuccess('Contribution', 'create', [
+      'financial_type_id' => 'Donation',
       'total_amount' => 11,
       'receive_date' => date('Ymd'),
       'receive_date_time' => NULL,
@@ -400,19 +400,18 @@ class CRM_Contribute_Form_SearchTest extends CiviUnitTestCase {
       'contribution_status_id' => 1,
       'contact_id' => $contactID1,
       'contribution_recur_id' => $ContributionRecur1['id'],
-      'financial_type_id' => "Donation",
-    ));
-    $params = array(
+    ]);
+    $params = [
       'to_financial_account_id' => 1,
       'status_id' => 1,
       'contribution_id' => $Contribution1['id'],
       'payment_instrument_id' => 1,
       'card_type_id' => 1,
       'total_amount' => 11,
-    );
+    ];
     CRM_Core_BAO_FinancialTrxn::create($params);
     // "Completed" recurring contribution for contactID2
-    $ContributionRecur2 = $this->callAPISuccess('ContributionRecur', 'create', array(
+    $ContributionRecur2 = $this->callAPISuccess('ContributionRecur', 'create', [
       'sequential' => 1,
       'contact_id' => $contactID2,
       'frequency_interval' => 1,
@@ -422,9 +421,9 @@ class CRM_Contribute_Form_SearchTest extends CiviUnitTestCase {
       'payment_instrument_id' => 1,
       'contribution_status_id' => 1,
       'financial_type_id' => "Donation",
-    ));
-    $Contribution2 = $this->callAPISuccess('Contribution', 'create', array(
-      'financial_type_id' => 1,
+    ]);
+    $Contribution2 = $this->callAPISuccess('Contribution', 'create', [
+      'financial_type_id' => 'Donation',
       'total_amount' => 22,
       'receive_date' => date('Ymd'),
       'receive_date_time' => NULL,
@@ -432,41 +431,40 @@ class CRM_Contribute_Form_SearchTest extends CiviUnitTestCase {
       'contribution_status_id' => 1,
       'contact_id' => $contactID2,
       'contribution_recur_id' => $ContributionRecur2['id'],
-      'financial_type_id' => "Donation",
-    ));
-    $params = array(
+    ]);
+    $params = [
       'to_financial_account_id' => 1,
       'status_id' => 1,
       'contribution_id' => $Contribution2['id'],
       'payment_instrument_id' => 1,
       'card_type_id' => 1,
       'total_amount' => 22,
-    );
+    ];
     CRM_Core_BAO_FinancialTrxn::create($params);
 
-    $useCases = array(
+    $useCases = [
       // Case 1: Search for ONLY those recurring contributions with status "In Progress"
-      array(
-        'form_value' => array('contribution_recur_contribution_status_id' => 5),
+      [
+        'form_value' => ['contribution_recur_contribution_status_id' => 5],
         'expected_count' => 1,
-        'expected_contact' => array($contactID1),
+        'expected_contact' => [$contactID1],
         'expected_qill' => "Recurring Contribution Status = 'In Progress'",
-      ),
+      ],
       // Case 2: Search for ONLY those recurring contributions with status "Completed"
-      array(
-        'form_value' => array('contribution_recur_contribution_status_id' => 1),
+      [
+        'form_value' => ['contribution_recur_contribution_status_id' => 1],
         'expected_count' => 1,
-        'expected_contact' => array($contactID2),
+        'expected_contact' => [$contactID2],
         'expected_qill' => "Recurring Contribution Status = 'Completed'",
-      ),
+      ],
       // Case 3: Search for ONLY those recurring contributions with status "Cancelled"
-      array(
-        'form_value' => array('contribution_recur_contribution_status_id' => 3),
+      [
+        'form_value' => ['contribution_recur_contribution_status_id' => 3],
         'expected_count' => 0,
-        'expected_contact' => array(),
+        'expected_contact' => [],
         'expected_qill' => "Recurring Contribution Status = 'Cancelled'",
-      ),
-    );
+      ],
+    ];
 
     foreach ($useCases as $case) {
       $fv = $case['form_value'];
@@ -493,9 +491,9 @@ class CRM_Contribute_Form_SearchTest extends CiviUnitTestCase {
    */
   public function testCancelledFilter() {
     $this->quickCleanup($this->_tablesToTruncate);
-    $contactID1 = $this->individualCreate(array(), 1);
-    $contactID2 = $this->individualCreate(array(), 2);
-    $Contribution1 = $this->callAPISuccess('Contribution', 'create', array(
+    $contactID1 = $this->individualCreate([], 1);
+    $contactID2 = $this->individualCreate([], 2);
+    $Contribution1 = $this->callAPISuccess('Contribution', 'create', [
       'financial_type_id' => 1,
       'total_amount' => 100,
       'receive_date' => date('Ymd'),
@@ -505,8 +503,8 @@ class CRM_Contribute_Form_SearchTest extends CiviUnitTestCase {
       'cancel_date' => date('Ymd'),
       'cancel_reason' => 'Insufficient funds',
       'contact_id' => $contactID1,
-    ));
-    $Contribution2 = $this->callAPISuccess('Contribution', 'create', array(
+    ]);
+    $this->callAPISuccess('Contribution', 'create', [
       'financial_type_id' => 1,
       'total_amount' => 150,
       'receive_date' => date('Ymd', strtotime(date('Y-m-d') . ' - 1 days')),
@@ -516,8 +514,8 @@ class CRM_Contribute_Form_SearchTest extends CiviUnitTestCase {
       'cancel_date' => date('Ymd', strtotime(date('Y-m-d') . ' - 1 days')),
       'cancel_reason' => 'Insufficient funds',
       'contact_id' => $contactID2,
-    ));
-    $Contribution3 = $this->callAPISuccess('Contribution', 'create', array(
+    ]);
+    $Contribution3 = $this->callAPISuccess('Contribution', 'create', [
       'financial_type_id' => 1,
       'total_amount' => 200,
       'receive_date' => date('Ymd'),
@@ -527,37 +525,37 @@ class CRM_Contribute_Form_SearchTest extends CiviUnitTestCase {
       'cancel_date' => date('Ymd'),
       'cancel_reason' => 'Invalid Credit Card Number',
       'contact_id' => $contactID1,
-    ));
+    ]);
 
-    $useCases = array(
+    $useCases = [
       // Case 1: Search for Cancelled Date
-      array(
-        'form_value' => array('cancel_date' => date('Y-m-d')),
+      [
+        'form_value' => ['cancel_date' => date('Y-m-d')],
         'expected_count' => 2,
-        'expected_contribution' => array($Contribution1['id'], $Contribution3['id']),
+        'expected_contribution' => [$Contribution1['id'], $Contribution3['id']],
         'expected_qill' => "Cancel Date Like '%" . date('Y-m-d') . "%'",
-      ),
+      ],
       // Case 2: Search for Cancelled Reason
-      array(
-        'form_value' => array('cancel_reason' => 'Invalid Credit Card Number'),
+      [
+        'form_value' => ['cancel_reason' => 'Invalid Credit Card Number'],
         'expected_count' => 1,
-        'expected_contribution' => array($Contribution3['id']),
+        'expected_contribution' => [$Contribution3['id']],
         'expected_qill' => "Cancellation / Refund Reason Like '%Invalid Credit Card Number%'",
-      ),
+      ],
       // Case 3: Search for Cancelled Date and Cancelled Reason
-      array(
-        'form_value' => array('cancel_date' => date('Y-m-d'), 'cancel_reason' => 'Insufficient funds'),
+      [
+        'form_value' => ['cancel_date' => date('Y-m-d'), 'cancel_reason' => 'Insufficient funds'],
         'expected_count' => 1,
-        'expected_contribution' => array($Contribution1['id']),
+        'expected_contribution' => [$Contribution1['id']],
         'expected_qill' => "Cancel Date Like '%" . date('Y-m-d') . "%'ANDCancellation / Refund Reason Like '%Insufficient funds%'",
-      ),
-    );
+      ],
+    ];
 
     foreach ($useCases as $case) {
       $fv = $case['form_value'];
-      CRM_Contact_BAO_Query::processSpecialFormValue($fv, array('cancel_date', 'cancel_reason'));
+      CRM_Contact_BAO_Query::processSpecialFormValue($fv, ['cancel_date', 'cancel_reason']);
       $query = new CRM_Contact_BAO_Query(CRM_Contact_BAO_Query::convertFormValues($fv));
-      list($select, $from, $where, $having) = $query->query();
+      list($select, $from, $where) = $query->query();
 
       // get and assert contribution count
       $contributions = CRM_Core_DAO::executeQuery(sprintf('SELECT DISTINCT civicrm_contribution.id %s %s AND civicrm_contribution.id IS NOT NULL AND civicrm_contribution.contribution_status_id = 3', $from, $where))->fetchAll();
index 5edd9d564fe7b7f7ad83bbf867933799cd0daa64..53c5c40eb582aa4dd1defa3b3743e93ea6c238ca 100644 (file)
@@ -345,6 +345,14 @@ class CRM_Core_BAO_AddressTest extends CiviUnitTestCase {
     $this->assertEquals($parsedStreetAddress['street_number'], '54');
     $this->assertEquals($parsedStreetAddress['street_number_suffix'], 'A');
 
+    // Out-of-range street number to be parsed.
+    $street_address = "505050505050 Main St";
+    $parsedStreetAddress = CRM_Core_BAO_Address::parseStreetAddress($street_address);
+    $this->assertEquals($parsedStreetAddress['street_name'], '');
+    $this->assertEquals($parsedStreetAddress['street_unit'], '');
+    $this->assertEquals($parsedStreetAddress['street_number'], '');
+    $this->assertEquals($parsedStreetAddress['street_number_suffix'], '');
+
     // valid Street address to be parsed ( $locale = 'en_US' )
     $street_address = "54A Excelsior Ave. Apt 1C";
     $locale = 'en_US';
index e09a2db940d577d261b2f911855792faa57021aa..94de1d4d10efea88c742d6cff964d6cfdd8941fa 100644 (file)
@@ -106,9 +106,9 @@ class CRM_Core_BAO_FinancialTrxnTest extends CiviUnitTestCase {
   }
 
   /**
-   * Test getPartialPaymentTrxn function.
+   * Tests the lines of code that used to be in the getPartialPaymentTrxn fn.
    */
-  public function testGetPartialPaymentTrxn() {
+  public function testGetExPartialPaymentTrxn() {
     $contributionTest = new CRM_Contribute_BAO_ContributionTest();
     list($lineItems, $contribution) = $contributionTest->addParticipantWithContribution();
     $contribution = (array) $contribution;
@@ -116,7 +116,13 @@ class CRM_Core_BAO_FinancialTrxnTest extends CiviUnitTestCase {
       'contribution_id' => $contribution['id'],
       'total_amount' => 100.00,
     );
-    $trxn = CRM_Core_BAO_FinancialTrxn::getPartialPaymentTrxn($contribution, $params);
+    $trxn = CRM_Contribute_BAO_Contribution::recordPartialPayment($contribution, $params);
+    $paid = CRM_Core_BAO_FinancialTrxn::getTotalPayments($params['contribution_id']);
+    $total = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_Contribution', $params['contribution_id'], 'total_amount');
+    $cmp = bccomp($total, $paid, 5);
+    if ($cmp == 0 || $cmp == -1) {// If paid amount is greater or equal to total amount
+      civicrm_api3('Contribution', 'completetransaction', array('id' => $contribution['id']));
+    }
 
     $this->assertEquals('100.00', $trxn->total_amount, 'Amount does not match.');
 
index 7503e5a1060f240c01e9ade51847c9037082267a..2ad560ec98e24b91dbd62e9b515f9f8c44bba20f 100644 (file)
@@ -204,4 +204,12 @@ class CRM_Core_DAO_AllCoreTablesTest extends CiviUnitTestCase {
     $this->assertEquals($newIndices, $expectedIndices);
   }
 
+  /**
+   * Test CRM_Core_DAO_AllCoreTables::isCoreTable
+   */
+  public function testIsCoreTable() {
+    $this->assertTrue(CRM_Core_DAO_AllCoreTables::isCoreTable('civicrm_contact'), 'civicrm_contact should be a core table');
+    $this->assertFalse(CRM_Core_DAO_AllCoreTables::isCoreTable('civicrm_invalid_table'), 'civicrm_invalid_table should NOT be a core table');
+  }
+
 }
index e7f68600ef80d3c2271f7c4c65892cbfef9907ab..080a8d720d64f2e603ebe0f038e7ac15b44b60db 100644 (file)
@@ -53,8 +53,8 @@ class CRM_Core_Payment_AuthorizeNetTest extends CiviUnitTestCase {
    * Test works but not both due to some form of caching going on in the SmartySingleton
    */
   public function testCreateSingleNowDated() {
-    $firstName = 'John_' . substr(sha1(rand()), 0, 7);
-    $lastName = 'Smith_' . substr(sha1(rand()), 0, 7);
+    $firstName = 'John_' . substr(sha1(rand()), 0, 7)  . uniqid();
+    $lastName = 'Smith_' . substr(sha1(rand()), 0, 7) . uniqid();
     $nameParams = array('first_name' => $firstName, 'last_name' => $lastName);
     $contactId = $this->individualCreate($nameParams);
 
@@ -145,7 +145,7 @@ class CRM_Core_Payment_AuthorizeNetTest extends CiviUnitTestCase {
       'first_name' => $firstName,
       'middle_name' => '',
       'last_name' => $lastName,
-      'street_address' => '8 Hobbiton Road',
+      'street_address' => '8 Hobbiton Road' . uniqid(),
       'city' => 'The Shire',
       'state_province' => 'IL',
       'postal_code' => 5010,
@@ -238,7 +238,7 @@ class CRM_Core_Payment_AuthorizeNetTest extends CiviUnitTestCase {
       'cvv2' => 123,
       'credit_card_exp_date' => array(
         'M' => 11,
-        'Y' => 2019,
+        'Y' => 2022,
       ),
       'credit_card_type' => 'Visa',
       'is_recur' => 1,
@@ -261,7 +261,7 @@ class CRM_Core_Payment_AuthorizeNetTest extends CiviUnitTestCase {
       'state_province-5' => 'IL',
       'billing_country-5' => 'US',
       'country-5' => 'US',
-      'year' => 2019,
+      'year' => 2022,
       'month' => 10,
       'ip_address' => '127.0.0.1',
       'amount' => 70,
@@ -281,18 +281,15 @@ class CRM_Core_Payment_AuthorizeNetTest extends CiviUnitTestCase {
       'first_name' => $firstName,
       'middle_name' => 'bob',
       'last_name' => $lastName,
-      'street_address' => '8 Hobbiton Road',
+      'street_address' => '8 Hobbiton Road' . uniqid(),
       'city' => 'The Shire',
       'state_province' => 'IL',
       'postal_code' => 5010,
       'country' => 'US',
-      'contributionType_name' => 'My precious',
-      'contributionType_accounting_code' => '',
       'contributionPageID' => '',
       'email' => "{$firstName}.{$lastName}@example.com",
       'contactID' => $contactId,
       'contributionID' => $contribution['id'],
-      'contributionTypeID' => $this->_financialTypeId,
       'contributionRecurID' => $recur->id,
     );
 
index 99890e95410f86fdd98264e148deaecd3adf3198..8feda007962370da7d100a545cb553b8aaf0e829 100644 (file)
@@ -397,4 +397,28 @@ class CRM_Core_ResourcesTest extends CiviUnitTestCase {
     );
   }
 
+  /**
+   * return array
+   */
+  public function urlsToCheckIfFullyFormed() {
+    return [
+      ['civicrm/test/page', FALSE],
+      ['#', FALSE],
+      ['', FALSE],
+      ['/civicrm/test/page', TRUE],
+      ['http://test.com/civicrm/test/page', TRUE],
+      ['https://test.com/civicrm/test/page', TRUE],
+    ];
+  }
+
+  /**
+   * @param string $url
+   * @param string $expected
+   *
+   * @dataProvider urlsToCheckIfFullyFormed
+   */
+  public function testIsFullyFormedUrl($url, $expected) {
+    $this->assertEquals($expected, CRM_Core_Resources::isFullyFormedUrl($url));
+  }
+
 }
index 947e52f831bbb53103a46c4a454674baff86971f..00382553ea67d6550a640fb174fa1e118c228efe 100644 (file)
@@ -85,7 +85,6 @@ class CRM_Dedupe_DedupeFinderTest extends CiviUnitTestCase {
     }
     $foundDupes = CRM_Dedupe_Finder::dupesInGroup($ruleGroup['id'], $this->groupID);
     $this->assertEquals(count($foundDupes), 4);
-    $this->markTestIncomplete('This currenctly fails - see https://lab.civicrm.org/dev/core/issues/397');
     CRM_Dedupe_Finder::dupes($ruleGroup['id']);
 
   }
index 7f3f03435bdb28f4edbfced94bbe78d314a68f1d..e98380a807f32232f32c014df15186af704b4e38 100644 (file)
@@ -483,6 +483,44 @@ class CRM_Dedupe_MergerTest extends CiviUnitTestCase {
     ), $pairs);
   }
 
+  /**
+   * Test migration of Membership.
+   */
+  public function testMergeMembership() {
+    // Contacts setup
+    $this->setupMatchData();
+    $originalContactID = $this->contacts[0]['id'];
+    $duplicateContactID = $this->contacts[1]['id'];
+
+    //Add Membership for the duplicate contact.
+    $memTypeId = $this->membershipTypeCreate();
+    $membership = $this->callAPISuccess('Membership', 'create', [
+      'membership_type_id' => $memTypeId,
+      'contact_id' => $duplicateContactID,
+    ]);
+    //Assert if 'add new' checkbox is enabled on the merge form.
+    $rowsElementsAndInfo = CRM_Dedupe_Merger::getRowsElementsAndInfo($originalContactID, $duplicateContactID);
+    foreach ($rowsElementsAndInfo['elements'] as $element) {
+      if (!empty($element[3]) && $element[3] == 'add new') {
+        $checkedAttr = ['checked' => 'checked'];
+        $this->checkArrayEquals($element[4], $checkedAttr);
+      }
+    }
+
+    //Merge and move the mem to the main contact.
+    $this->mergeContacts($originalContactID, $duplicateContactID, [
+      'move_rel_table_memberships' => 1,
+      'operation' => ['move_rel_table_memberships' => ['add' => 1]]
+    ]);
+
+    //Check if membership is correctly transferred to original contact.
+    $originalContactMembership = $this->callAPISuccess('Membership', 'get', [
+      'membership_type_id' => $memTypeId,
+      'contact_id' => $originalContactID,
+    ]);
+    $this->assertEquals(1, $originalContactMembership['count']);
+  }
+
   /**
    * CRM-19653 : Test that custom field data should/shouldn't be overriden on
    *   selecting/not selecting option to migrate data respectively
index a062e726d61c82b31c522cfdc51f72567b8f454a..8c05c65f9ba6e6ed95fa4aa50764254484da3b8a 100644 (file)
@@ -40,20 +40,7 @@ class CRM_Event_BAO_AdditionalPaymentTest extends CiviUnitTestCase {
 
   public function tearDown() {
     $this->eventDelete($this->_eventId);
-    $this->quickCleanup(
-      array(
-        'civicrm_contact',
-        'civicrm_contribution',
-        'civicrm_participant',
-        'civicrm_participant_payment',
-        'civicrm_line_item',
-        'civicrm_financial_item',
-        'civicrm_financial_trxn',
-        'civicrm_price_set',
-        'civicrm_entity_financial_trxn',
-      ),
-      TRUE
-    );
+    $this->quickCleanUpFinancialEntities();
   }
 
   /**
@@ -165,10 +152,9 @@ class CRM_Event_BAO_AdditionalPaymentTest extends CiviUnitTestCase {
       ]
     );
     $contributionID = $result['contribution']['id'];
-    extract($result);
 
     // check payment info
-    $paymentInfo = CRM_Contribute_BAO_Contribution::getPaymentInfo($participant['id'], 'event');
+    $paymentInfo = CRM_Contribute_BAO_Contribution::getPaymentInfo($result['participant']['id'], 'event');
     $this->assertEquals(round($paymentInfo['total']), $feeAmt, 'Total amount recorded is not proper');
     $this->assertEquals(round($paymentInfo['paid']), $amtPaid, 'Amount paid is not proper');
     $this->assertEquals(round($paymentInfo['balance']), $feeAmt, 'Balance amount is not proper');
@@ -190,7 +176,7 @@ class CRM_Event_BAO_AdditionalPaymentTest extends CiviUnitTestCase {
     $form->testSubmit($submitParams);
 
     // check payment info again and see if the payment is completed
-    $paymentInfo = CRM_Contribute_BAO_Contribution::getPaymentInfo($participant['id'], 'event');
+    $paymentInfo = CRM_Contribute_BAO_Contribution::getPaymentInfo($result['participant']['id'], 'event');
     $this->assertEquals(round($paymentInfo['total']), $feeAmt, 'Total amount recorded is not proper');
     $this->assertEquals(round($paymentInfo['paid']), $feeAmt, 'Amount paid is not proper');
     $this->assertEquals(round($paymentInfo['balance']), 0, 'Balance amount is not proper');
@@ -227,23 +213,22 @@ class CRM_Event_BAO_AdditionalPaymentTest extends CiviUnitTestCase {
     $amtPaid = 80;
     $result = $this->addParticipantWithPayment($feeAmt, $amtPaid);
     $contributionID = $result['contribution']['id'];
-    extract($result);
 
     //Complete the partial payment.
     $submittedValues = array(
       'total_amount' => 20,
       'payment_instrument_id' => 3,
     );
-    CRM_Contribute_BAO_Contribution::recordAdditionalPayment($contributionID, $submittedValues, 'owed', $participant['id']);
+    CRM_Contribute_BAO_Contribution::recordAdditionalPayment($contributionID, $submittedValues, 'owed', $result['participant']['id']);
 
     //Change selection to a lower amount.
     $params['price_2'] = 50;
-    CRM_Price_BAO_LineItem::changeFeeSelections($params, $participant['id'], 'participant', $contributionID, $feeBlock, $lineItem, $feeAmt);
+    CRM_Price_BAO_LineItem::changeFeeSelections($params, $result['participant']['id'], 'participant', $contributionID, $result['feeBlock'], $result['lineItem']);
 
     //Record a refund of the remaining amount.
     $submittedValues['total_amount'] = 50;
-    CRM_Contribute_BAO_Contribution::recordAdditionalPayment($contributionID, $submittedValues, 'refund', $participant['id']);
-    $paymentInfo = CRM_Contribute_BAO_Contribution::getPaymentInfo($participant['id'], 'event', TRUE);
+    CRM_Contribute_BAO_Contribution::recordAdditionalPayment($contributionID, $submittedValues, 'refund', $result['participant']['id']);
+    $paymentInfo = CRM_Contribute_BAO_Contribution::getPaymentInfo($result['participant']['id'], 'event', TRUE);
     $transaction = $paymentInfo['transaction'];
 
     //Assert all transaction(owed and refund) are listed on view payments.
index d1bb54736189cea313b8729efc9f2354f4832de7..d3002c716ec91f9312ffb4c792fcb6a54101af70 100644 (file)
@@ -30,6 +30,21 @@ class CRM_Event_BAO_ChangeFeeSelectionTest extends CiviUnitTestCase {
    */
   protected $priceSetFieldID;
 
+  /**
+   * @var int
+   */
+  private $_contactId;
+
+  /**
+   * @var int
+   */
+  private $_eventId;
+
+  /**
+   * @var array
+   */
+  private $_feeBlock;
+
   /**
    * Set up for test.
    */
@@ -234,6 +249,8 @@ class CRM_Event_BAO_ChangeFeeSelectionTest extends CiviUnitTestCase {
     $lineItemVal[$this->_priceSetID] = $lineItems;
     CRM_Price_BAO_LineItem::processPriceSet($participant['id'], $lineItemVal, $this->getContributionObject($contribution['id']), 'civicrm_participant');
     $this->balanceCheck($this->_expensiveFee);
+    $this->assertEquals(($this->_expensiveFee - $actualPaidAmt), CRM_Contribute_BAO_Contribution::getContributionBalance($this->_contributionId));
+
   }
 
   public function testCRM19273() {
@@ -276,15 +293,20 @@ class CRM_Event_BAO_ChangeFeeSelectionTest extends CiviUnitTestCase {
    */
   public function testCRM20611() {
     $this->registerParticipantAndPay();
+    $actualPaidAmount = 100;
     $priceSetParams['price_' . $this->priceSetFieldID] = $this->expensiveFeeValueID;
     $lineItem = CRM_Price_BAO_LineItem::getLineItems($this->participantID, 'participant');
     CRM_Price_BAO_LineItem::changeFeeSelections($priceSetParams, $this->_participantId, 'participant', $this->_contributionId, $this->_feeBlock, $lineItem);
     $this->balanceCheck($this->_expensiveFee);
+    $contributionBalance = ($this->_expensiveFee - $actualPaidAmount);
+    $this->assertEquals($contributionBalance, CRM_Contribute_BAO_Contribution::getContributionBalance($this->_contributionId));
 
     $priceSetParams['price_' . $this->priceSetFieldID] = $this->cheapFeeValueID;
     $lineItem = CRM_Price_BAO_LineItem::getLineItems($this->participantID, 'participant');
     CRM_Price_BAO_LineItem::changeFeeSelections($priceSetParams, $this->_participantId, 'participant', $this->_contributionId, $this->_feeBlock, $lineItem);
     $this->balanceCheck($this->_cheapFee);
+    $contributionBalance = ($this->_cheapFee - $actualPaidAmount);
+    $this->assertEquals($contributionBalance, CRM_Contribute_BAO_Contribution::getContributionBalance($this->_contributionId));
 
     //Complete the refund payment.
     $submittedValues = array(
@@ -292,6 +314,8 @@ class CRM_Event_BAO_ChangeFeeSelectionTest extends CiviUnitTestCase {
       'payment_instrument_id' => 3,
     );
     CRM_Contribute_BAO_Contribution::recordAdditionalPayment($this->_contributionId, $submittedValues, 'refund', $this->_participantId);
+    $contributionBalance += 120;
+    $this->assertEquals($contributionBalance, CRM_Contribute_BAO_Contribution::getContributionBalance($this->_contributionId));
 
     // retrieve the cancelled line-item information
     $cancelledLineItem = $this->callAPISuccessGetSingle('LineItem', array(
index e698fc550b668db38d2d91f1b89fa55aad7c8c28..fe4ae5b9fc394f2ed183626d4a0c4f33d96e0bfb 100644 (file)
@@ -1634,12 +1634,6 @@ class CRM_Export_BAO_ExportTest extends CiviUnitTestCase {
       'currency' => 1,
       'cancel_reason' => 1,
       'receipt_date' => 1,
-      'product_name' => 1,
-      'sku' => 1,
-      'product_option' => 1,
-      'fulfilled_date' => 1,
-      'contribution_start_date' => 1,
-      'contribution_end_date' => 1,
       'is_test' => 1,
       'is_pay_later' => 1,
       'contribution_status' => 1,
@@ -1649,7 +1643,6 @@ class CRM_Export_BAO_ExportTest extends CiviUnitTestCase {
       'contribution_batch' => 1,
       'contribution_campaign_title' => 1,
       'contribution_campaign_id' => 1,
-      'contribution_product_id' => 1,
       'contribution_soft_credit_name' => 1,
       'contribution_soft_credit_amount' => 1,
       'contribution_soft_credit_type' => 1,
@@ -2192,7 +2185,7 @@ class CRM_Export_BAO_ExportTest extends CiviUnitTestCase {
       85 => 'Cancel Date',
       86 => 'Total Amount',
       87 => 'Accounting Code',
-      88 => 'payment_instrument',
+      88 => 'Payment Methods',
       89 => 'Payment Method ID',
       90 => 'Check Number',
       91 => 'Non-deductible Amount',
@@ -2204,22 +2197,15 @@ class CRM_Export_BAO_ExportTest extends CiviUnitTestCase {
       97 => 'Currency',
       98 => 'Cancellation / Refund Reason',
       99 => 'Receipt Date',
-      100 => 'Product Name',
-      101 => 'SKU',
-      102 => 'Product Option',
-      103 => 'Fulfilled Date',
-      104 => 'Start date for premium',
-      105 => 'End date for premium',
       106 => 'Test',
       107 => 'Is Pay Later',
-      108 => 'contribution_status',
+      108 => 'Contribution Status',
       109 => 'Recurring Contribution ID',
       110 => 'Amount Label',
       111 => 'Contribution Note',
       112 => 'Batch Name',
       113 => 'Campaign Title',
       114 => 'Campaign ID',
-      115 => 'Premium',
       116 => 'Soft Credit For',
       117 => 'Soft Credit Amount',
       118 => 'Soft Credit Type',
@@ -2600,7 +2586,7 @@ class CRM_Export_BAO_ExportTest extends CiviUnitTestCase {
       'cancel_date' => 'cancel_date varchar(32)',
       'total_amount' => 'total_amount varchar(32)',
       'accounting_code' => 'accounting_code varchar(64)',
-      'payment_instrument' => 'payment_instrument text',
+      'payment_instrument' => 'payment_instrument varchar(255)',
       'payment_instrument_id' => 'payment_instrument_id varchar(16)',
       'contribution_check_number' => 'contribution_check_number varchar(255)',
       'non_deductible_amount' => 'non_deductible_amount varchar(32)',
@@ -2612,22 +2598,15 @@ class CRM_Export_BAO_ExportTest extends CiviUnitTestCase {
       'currency' => 'currency varchar(3)',
       'cancel_reason' => 'cancel_reason longtext',
       'receipt_date' => 'receipt_date varchar(32)',
-      'product_name' => 'product_name varchar(255)',
-      'sku' => 'sku varchar(50)',
-      'product_option' => 'product_option varchar(255)',
-      'fulfilled_date' => 'fulfilled_date varchar(32)',
-      'contribution_start_date' => 'contribution_start_date varchar(32)',
-      'contribution_end_date' => 'contribution_end_date varchar(32)',
       'is_test' => 'is_test varchar(16)',
       'is_pay_later' => 'is_pay_later varchar(16)',
-      'contribution_status' => 'contribution_status text',
+      'contribution_status' => 'contribution_status varchar(255)',
       'contribution_recur_id' => 'contribution_recur_id varchar(16)',
       'amount_level' => 'amount_level longtext',
       'contribution_note' => 'contribution_note text',
       'contribution_batch' => 'contribution_batch text',
       'contribution_campaign_title' => 'contribution_campaign_title varchar(255)',
       'contribution_campaign_id' => 'contribution_campaign_id varchar(128)',
-      'contribution_product_id' => 'contribution_product_id varchar(255)',
       'contribution_soft_credit_name' => 'contribution_soft_credit_name varchar(255)',
       'contribution_soft_credit_amount' => 'contribution_soft_credit_amount varchar(255)',
       'contribution_soft_credit_type' => 'contribution_soft_credit_type varchar(255)',
index 4f86263d98e68b3c12253f20c5ab9770fc82d576..6f2851a98af33ed15ace64f4c4167757cf772a09 100644 (file)
@@ -371,7 +371,7 @@ class CRM_Financial_BAO_FinancialAccountTest extends CiviUnitTestCase {
       'source' => 'SSF',
       'contribution_status_id' => 1,
     ));
-    $balance = CRM_Core_BAO_FinancialTrxn::getPartialPaymentWithType($contribution['id'], 'contribution', FALSE, $totalAmount);
+    $balance = CRM_Contribute_BAO_Contribution::getContributionBalance($contribution['id'], $totalAmount);
     $this->assertEquals(0.0, $balance);
     Civi::settings()->revert('contribution_invoice_settings');
   }
index 42222be567c7ece92e5fd5c074fbb14fd84d595d..b6eb77718be88d49acbc06d39b2cff966364c79a 100644 (file)
@@ -650,4 +650,60 @@ class CRM_Group_Page_AjaxTest extends CiviUnitTestCase {
     }
   }
 
+  public function testEditAllGroupsACL() {
+    $this->setupEditAllGroupsACL();
+    $params = $this->_params;
+    $groups = CRM_Contact_BAO_Group::getGroupListSelector($params);
+    $this->assertNotEmpty($groups, 'If Edit All Groups is granted, at least one group should be visible');
+  }
+
+  /**
+   * Set up an acl allowing Authenticated contacts to Edit All Groups
+   *
+   *  You need to have pre-created these groups & created the user e.g
+   *  $this->createLoggedInUser();
+   *
+   */
+  public function setupEditAllGroupsACL() {
+    global $_REQUEST;
+    $_REQUEST = $this->_params;
+
+    CRM_Core_Config::singleton()->userPermissionClass->permissions = array('access CiviCRM');
+    $optionGroupID = $this->callAPISuccessGetValue('option_group', array('return' => 'id', 'name' => 'acl_role'));
+    $ov = new CRM_Core_DAO_OptionValue();
+    $ov->option_group_id = $optionGroupID;
+    $ov->value = 55;
+    if ($ov->find(TRUE)) {
+      CRM_Core_DAO::executeQuery("DELETE FROM civicrm_option_value WHERE id = {$ov->id}");
+    }
+    $optionValue = $this->callAPISuccess('option_value', 'create', array(
+      'option_group_id' => $optionGroupID,
+      'label' => 'groupmaster',
+      'value' => 55,
+    ));
+    $groupId = $this->groupCreate(['name' => 'groupmaster group']);
+    // Assign groupmaster to groupmaster group in civicrm_acl_entity_role
+    CRM_Core_DAO::executeQuery("
+      INSERT INTO civicrm_acl_entity_role (
+      `acl_role_id`, `entity_table`, `entity_id`, `is_active`
+      ) VALUES (55, 'civicrm_group', $groupId, 1);
+    ");
+    // Put the user into this group
+    $this->_loggedInUser = CRM_Core_Session::singleton()->get('userID');
+    $this->callAPISuccess('group_contact', 'create', array(
+      'group_id' => $groupId,
+      'contact_id' => $this->_loggedInUser,
+    ));
+    // Add the ACL
+    CRM_Core_DAO::executeQuery("
+      INSERT INTO civicrm_acl (
+      `name`, `entity_table`, `entity_id`, `operation`, `object_table`, `object_id`, `is_active`
+      )
+      VALUES (
+      'core-580', 'civicrm_acl_role', 55, 'Edit', 'civicrm_saved_search', 0, 1
+      );
+      ");
+
+  }
+
 }
index 2b238077e13d2f364366e935f8425535ed554711..efdd8ccb2b5cc40040ee6ce770dae91c4d8c3776 100644 (file)
@@ -16,6 +16,9 @@ class CRM_Logging_SchemaTest extends CiviUnitTestCase {
     $schema->disableLogging();
     $schema->dropAllLogTables();
     CRM_Core_DAO::executeQuery("DROP TABLE IF EXISTS civicrm_test_table");
+    CRM_Core_DAO::executeQuery("DROP TABLE IF EXISTS civicrm_test_column_info");
+    CRM_Core_DAO::executeQuery("DROP TABLE IF EXISTS civicrm_test_length_change");
+    CRM_Core_DAO::executeQuery("DROP TABLE IF EXISTS civicrm_test_enum_change");
   }
 
   public function queryExamples() {
@@ -100,4 +103,134 @@ class CRM_Logging_SchemaTest extends CiviUnitTestCase {
     $this->assertTrue(empty($diffs['OBSOLETE']));
   }
 
+  /**
+   * Test logging trigger definition
+   */
+  public function testTriggerInfo() {
+    $info = [];
+    $schema = new CRM_Logging_Schema();
+    $schema->enableLogging();
+    $schema->triggerInfo($info, 'civicrm_group');
+    // should have 3 triggers (insert/update/delete)
+    $this->assertCount(3, $info);
+    foreach ($info as $trigger) {
+      // table for trigger should be civicrm_group
+      $this->assertEquals('civicrm_group', $trigger['table'][0]);
+      if ($trigger['event'][0] == 'UPDATE') {
+        // civicrm_group.cache_date should be an exception, i.e. not logged
+        $this->assertNotContains(
+          "IFNULL(OLD.`cache_date`,'') <> IFNULL(NEW.`cache_date`,'')",
+          $trigger['sql']
+        );
+      }
+    }
+  }
+
+  public function testColumnInfo() {
+    CRM_Core_DAO::executeQuery("CREATE TABLE `civicrm_test_column_info` (
+      test_id  int(10) unsigned NOT NULL AUTO_INCREMENT,
+      test_varchar varchar(42) NOT NULL,
+      test_integer int(8) NULL,
+      test_decimal decimal(20,2),
+      test_enum enum('A','B','C'),
+      test_integer_default int(8) DEFAULT 42,
+      test_date date DEFAULT NULL,
+      PRIMARY KEY (`test_id`)
+    ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci");
+    $schema = new CRM_Logging_Schema();
+    $schema->enableLogging();
+    $schema->updateLogTableSchema();
+    $ci = \Civi::$statics['CRM_Logging_Schema']['columnSpecs']['civicrm_test_column_info'];
+
+    $this->assertEquals('test_id', $ci['test_id']['COLUMN_NAME']);
+    $this->assertEquals('int', $ci['test_id']['DATA_TYPE']);
+    $this->assertEquals('NO', $ci['test_id']['IS_NULLABLE']);
+    $this->assertEquals('auto_increment', $ci['test_id']['EXTRA']);
+    $this->assertEquals('10', $ci['test_id']['LENGTH']);
+
+    $this->assertEquals('varchar', $ci['test_varchar']['DATA_TYPE']);
+    $this->assertEquals('42', $ci['test_varchar']['LENGTH']);
+
+    $this->assertEquals('int', $ci['test_integer']['DATA_TYPE']);
+    $this->assertEquals('8', $ci['test_integer']['LENGTH']);
+    $this->assertEquals('YES', $ci['test_integer']['IS_NULLABLE']);
+
+    $this->assertEquals('decimal', $ci['test_decimal']['DATA_TYPE']);
+    $this->assertEquals('20,2', $ci['test_decimal']['LENGTH']);
+
+    $this->assertEquals('enum', $ci['test_enum']['DATA_TYPE']);
+    $this->assertEquals("'A','B','C'", $ci['test_enum']['ENUM_VALUES']);
+    $this->assertArrayNotHasKey('LENGTH', $ci['test_enum']);
+
+    $this->assertEquals('42', $ci['test_integer_default']['COLUMN_DEFAULT']);
+
+    $this->assertEquals('date', $ci['test_date']['DATA_TYPE']);
+  }
+
+  public function testIndexes() {
+    $schema = new CRM_Logging_Schema();
+    $indexes = $schema->getIndexesForTable('civicrm_contact');
+    $this->assertContains('PRIMARY', $indexes);
+    $this->assertContains('UI_external_identifier', $indexes);
+    $this->assertContains('FK_civicrm_contact_employer_id', $indexes);
+    $this->assertContains('index_sort_name', $indexes);
+  }
+
+  public function testLengthChange() {
+    CRM_Core_DAO::executeQuery("CREATE TABLE `civicrm_test_length_change` (
+      test_id int(10) unsigned NOT NULL AUTO_INCREMENT,
+      test_integer int(4) NULL,
+      test_decimal decimal(20,2) NULL,
+      PRIMARY KEY (`test_id`)
+    ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci");
+    $schema = new CRM_Logging_Schema();
+    $schema->enableLogging();
+    CRM_Core_DAO::executeQuery(
+      "ALTER TABLE civicrm_test_length_change
+      CHANGE COLUMN test_integer test_integer int(6) NULL,
+      CHANGE COLUMN test_decimal test_decimal decimal(22,2) NULL"
+    );
+    \Civi::$statics['CRM_Logging_Schema']['columnSpecs'] = [];
+    $schema->fixSchemaDifferences();
+    // need to do it twice so the columnSpecs static is refreshed
+    \Civi::$statics['CRM_Logging_Schema']['columnSpecs'] = [];
+    $schema->fixSchemaDifferences();
+    $ci = \Civi::$statics['CRM_Logging_Schema']['columnSpecs'];
+    // length should increase
+    $this->assertEquals(6, $ci['log_civicrm_test_length_change']['test_integer']['LENGTH']);
+    $this->assertEquals('22,2', $ci['log_civicrm_test_length_change']['test_decimal']['LENGTH']);
+    CRM_Core_DAO::executeQuery(
+      "ALTER TABLE civicrm_test_length_change
+      CHANGE COLUMN test_integer test_integer int(4) NULL,
+      CHANGE COLUMN test_decimal test_decimal decimal(20,2) NULL"
+    );
+    \Civi::$statics['CRM_Logging_Schema']['columnSpecs'] = [];
+    $schema->fixSchemaDifferences();
+    \Civi::$statics['CRM_Logging_Schema']['columnSpecs'] = [];
+    $schema->fixSchemaDifferences();
+    $ci = \Civi::$statics['CRM_Logging_Schema']['columnSpecs'];
+    // length should not decrease
+    $this->assertEquals(6, $ci['log_civicrm_test_length_change']['test_integer']['LENGTH']);
+    $this->assertEquals('22,2', $ci['log_civicrm_test_length_change']['test_decimal']['LENGTH']);
+  }
+
+  public function testEnumChange() {
+    CRM_Core_DAO::executeQuery("CREATE TABLE `civicrm_test_enum_change` (
+      test_id int(10) unsigned NOT NULL AUTO_INCREMENT,
+      test_enum enum('A','B','C') NULL,
+      PRIMARY KEY (`test_id`)
+    ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci");
+    $schema = new CRM_Logging_Schema();
+    $schema->enableLogging();
+    CRM_Core_DAO::executeQuery("ALTER TABLE civicrm_test_enum_change CHANGE COLUMN test_enum test_enum enum('A','B','C','D') NULL");
+    \Civi::$statics['CRM_Logging_Schema']['columnSpecs'] = [];
+    $schema->fixSchemaDifferences();
+    // need to do it twice so the columnSpecs static is refreshed
+    \Civi::$statics['CRM_Logging_Schema']['columnSpecs'] = [];
+    $schema->fixSchemaDifferences();
+    $ci = \Civi::$statics['CRM_Logging_Schema']['columnSpecs'];
+    // new enum value should be included
+    $this->assertEquals("'A','B','C','D'", $ci['civicrm_test_enum_change']['test_enum']['ENUM_VALUES']);
+  }
+
 }
index 8535fb2ea5be78ffafd4af672fdccff4b49fa536..4348bc26adc9908830584afb09c1e55bf850c78c 100644 (file)
@@ -144,14 +144,6 @@ class CRM_Member_Form_MembershipTest extends CiviUnitTestCase {
     $this->callAPISuccess('relationship_type', 'delete', array('id' => 20));
   }
 
-  /**
-   *  Test CRM_Member_Form_Membership::buildQuickForm()
-   */
-  //function testCRMMemberFormMembershipBuildQuickForm()
-  //{
-  //    throw new PHPUnit_Framework_IncompleteTestError( "not implemented" );
-  //}
-
   /**
    *  Test CRM_Member_Form_Membership::formRule() with a parameter
    *  that has an empty contact_select_id value
@@ -1112,6 +1104,9 @@ Expires: ',
    * @return \CRM_Member_Form_Membership
    */
   protected function getForm() {
+    if (isset($_REQUEST['cid'])) {
+      unset($_REQUEST['cid']);
+    }
     $form = new CRM_Member_Form_Membership();
     $_SERVER['REQUEST_METHOD'] = 'GET';
     $form->controller = new CRM_Core_Controller();
index f3fbefcda9f23533f8a9528775b3326c2c41f97a..af89473113a8071e68c3dd6cbf53742729544e03 100644 (file)
@@ -96,6 +96,24 @@ class CRM_Report_Form_Contribute_DetailTest extends CiviReportTestCase {
     $this->assertCsvArraysEqual($expectedOutputCsvArray, $reportCsvArray);
   }
 
+  /**
+   * Test that the pagination widget is present.
+   *
+   * @dataProvider dataProvider
+   * @param $reportClass
+   * @param $inputParams
+   * @throws \Exception
+   */
+  public function testPager($reportClass, $inputParams) {
+    $contactID = $this->individualCreate();
+    for ($i = 1; $i <= 51; $i++) {
+      $this->contributionCreate(['contact_id' => $contactID, 'total_amount' => 50 + $i]);
+    }
+    $reportObj = $this->getReportObject($reportClass, $inputParams);
+    $pager = $reportObj->getTemplate()->_tpl_vars['pager'];
+    $this->assertEquals($pager->_response['numPages'], 2, "Pages in Pager");
+  }
+
   /**
    * @return array
    */
index 1640575cf8278cb38f9723ba571cd9b6479e77bf..362fd5babe49207bd45befeba1fb6e1c78ea376b 100644 (file)
@@ -94,8 +94,15 @@ class CRM_Upgrade_Incremental_BaseTest extends CiviUnitTestCase {
          ['grant_due_date_low', '=', '01/22/2019'],
        ]
     ]);
-    $smartGroupConversionObject = new CRM_Upgrade_Incremental_SmartGroups('5.11.alpha1');
-    $smartGroupConversionObject->updateGroups();
+    $smartGroupConversionObject = new CRM_Upgrade_Incremental_SmartGroups();
+    $smartGroupConversionObject->updateGroups([
+      'datepickerConversion' => [
+        'grant_application_received_date',
+        'grant_decision_date',
+        'grant_money_transfer_date',
+        'grant_due_date'
+      ]
+    ]);
     $savedSearch = $this->callAPISuccessGetSingle('SavedSearch', []);
     $this->assertEquals('grant_application_received_date_high', $savedSearch['form_values'][0][0]);
     $this->assertEquals('2019-01-20 00:00:00', $savedSearch['form_values'][0][2]);
index b3f57b62b11ba9da6c66cdc82b152f1f68ca3656..9a7b49da9b98398a3d2c32cdce504aab9a1ee4d5 100644 (file)
@@ -66,7 +66,7 @@ trait CRMTraits_Financial_FinancialACLTrait {
    * @return int Contact ID
    */
   protected function createLoggedInUserWithFinancialACL($aclPermissions = [['view', 'Donation']]) {
-    CRM_Core_Config::singleton()->userPermissionClass->permissions = ['access CiviCRM'];
+    CRM_Core_Config::singleton()->userPermissionClass->permissions = ['access CiviCRM', 'view all contacts'];
     $contactID = $this->createLoggedInUser();
     $this->addFinancialAclPermissions($aclPermissions);
     return $contactID;
index 48d102066960bb4f71fae0abcd468ae139a8358f..082881b0320685541bd5bf4e44bab12e5d32118a 100644 (file)
@@ -38,11 +38,14 @@ trait CRMTraits_Financial_PriceSetTrait {
    * This also involves creating t
    *
    * @param $params
+   * @param array $lineItemFinancialTypes
+   *   Financial Types, if an override is intended.
    */
-  protected function createContributionWithTwoLineItemsAgainstPriceSet($params) {
+  protected function createContributionWithTwoLineItemsAgainstPriceSet($params, $lineItemFinancialTypes = []) {
     $params = array_merge(['total_amount' => 300, 'financial_type_id' => 'Donation'], $params);
     $priceFields = $this->createPriceSet('contribution');
     foreach ($priceFields['values'] as $key => $priceField) {
+      $financialTypeID = (!empty($lineItemFinancialTypes) ? array_shift($lineItemFinancialTypes) : $priceField['financial_type_id']);
       $params['line_items'][]['line_item'][$key] = [
         'price_field_id' => $priceField['price_field_id'],
         'price_field_value_id' => $priceField['id'],
@@ -51,7 +54,7 @@ trait CRMTraits_Financial_PriceSetTrait {
         'qty' => 1,
         'unit_price' => $priceField['amount'],
         'line_total' => $priceField['amount'],
-        'financial_type_id' => $priceField['financial_type_id'],
+        'financial_type_id' => $financialTypeID,
         'entity_table' => 'civicrm_contribution',
       ];
     }
index df0b5becf50062563aafe351fcdfddfbd54a3890..3e0a32f47044c016e6269102305ec051bbc11d61 100644 (file)
@@ -11,6 +11,8 @@ class DynamicFKAuthorizationTest extends \CiviUnitTestCase {
 
   const FILE_FORBIDDEN_ID = 11;
 
+  const FILE_UNDELEGATED_ENTITY = 12;
+
   const WIDGET_ID = 20;
 
   const FORBIDDEN_ID = 30;
@@ -214,4 +216,28 @@ class DynamicFKAuthorizationTest extends \CiviUnitTestCase {
     $this->assertRegExp($expectedError, $result['error_message']);
   }
 
+  /**
+   * Test whether trusted API calls bypass the permission check
+   *
+   */
+  public function testNotDelegated() {
+    $entity = 'FakeFile';
+    $action = 'create';
+    $params = [
+      'entity_id' => self::FILE_UNDELEGATED_ENTITY,
+      'entity_table' => 'civicrm_membership',
+      'version' => 3,
+      'debug' => 1,
+      'check_permissions' => 1,
+    ];
+    // run with permission check
+    $result = $this->kernel->run('FakeFile', 'create', $params);
+    $this->assertTrue((bool) $result['is_error'], 'Undelegated entity with check_permissions = 1 should fail');
+    $this->assertRegExp('/Unrecognized target entity table \(civicrm_membership\)/', $result['error_message']);
+    // repeat without permission check
+    $params['check_permissions'] = 0;
+    $result = $this->kernel->run('FakeFile', 'create', $params);
+    $this->assertFalse((bool) $result['is_error'], 'Undelegated entity with check_permissions = 0 should succeed');
+  }
+
 }
index 50e363fc40a4d4f320e39758d9a73abf1927f8f8..a0f04fe81af54bcdd21cecc5bc687a573d09c2ef 100644 (file)
@@ -1981,6 +1981,7 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
       'defaultValue' => 'Default Value',
       'lowercasevalue' => 'Lowercase Value',
       1 => 'Integer Value',
+      'NULL' => 'NULL',
     ];
     $custom_field_params = ['sequential' => 1, 'id' => $customField['id']];
     $custom_field_api_result = $this->callAPISuccess('custom_field', 'get', $custom_field_params);
@@ -3133,7 +3134,7 @@ AND    ( TABLE_NAME LIKE 'civicrm_value_%' )
     $paramsSet['title'] = 'Price Set' . substr(sha1(rand()), 0, 7);
     $paramsSet['name'] = CRM_Utils_String::titleToVar($paramsSet['title']);
     $paramsSet['is_active'] = TRUE;
-    $paramsSet['financial_type_id'] = 4;
+    $paramsSet['financial_type_id'] = 'Event Fee';
     $paramsSet['extends'] = 1;
     $priceSet = $this->callAPISuccess('price_set', 'create', $paramsSet);
     $priceSetId = $priceSet['id'];
@@ -3395,13 +3396,13 @@ AND    ( TABLE_NAME LIKE 'civicrm_value_%' )
       ),
       $params
     );
-    $newPaymentInstrument = $this->callAPISuccess('OptionValue', 'create', $params);
+    $newPaymentInstrument = $this->callAPISuccess('OptionValue', 'create', $params)['id'];
 
     $relationTypeID = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Asset Account is' "));
 
     $financialAccountParams = [
       'entity_table' => 'civicrm_option_value',
-      'entity_id' => key($newPaymentInstrument),
+      'entity_id' => $newPaymentInstrument,
       'account_relationship' => $relationTypeID,
       'financial_account_id' => $this->callAPISuccess('FinancialAccount', 'getValue', ['name' => $financialAccountName, 'return' => 'id']),
     ];
index f2721ec852fc3751dd53cf58aacd4f5ddf5904c3..9e313db638d00bff689711fa9cdcb642add5c972 100644 (file)
@@ -160,6 +160,7 @@ class api_v3_AttachmentTest extends CiviUnitTestCase {
         'mime_type' => 'text/plain',
         'description' => 'My test description',
         'content' => 'My test content',
+        'check_permissions' => 1,
       ),
       "/Unrecognized target entity/",
     );
index f2f53c32ec962d79a8d80bb6cca86b4fc894a840..16bac6e300fcd51b464e1d4118bf9515ecc07e59 100644 (file)
@@ -3842,6 +3842,31 @@ class api_v3_ContactTest extends CiviUnitTestCase {
     $this->assertEquals(array('external_identifier'), $result['values']['UI_external_identifier']);
   }
 
+  /**
+   * API test to retrieve contact from group having different group title and name.
+   */
+  public function testContactGetFromGroup() {
+    $groupId = $this->groupCreate([
+      'name' => 'Test_Group',
+      'domain_id' => 1,
+      'title' => 'New Test Group Created',
+      'description' => 'New Test Group Created',
+      'is_active' => 1,
+      'visibility' => 'User and User Admin Only',
+    ]);
+    $contact = $this->callAPISuccess('contact', 'create', $this->_params);
+    $groupContactCreateParams = array(
+      'contact_id' => $contact['id'],
+      'group_id' => $groupId,
+      'status' => 'Pending',
+    );
+    $groupContact = $this->callAPISuccess('groupContact', 'create', $groupContactCreateParams);
+    $groupGetContact = $this->CallAPISuccess('groupContact', 'get', $groupContactCreateParams);
+    $this->CallAPISuccess('Contact', 'getcount', [
+      'group' => "Test_Group",
+    ]);
+  }
+
   public function testSmartGroupsForRelatedContacts() {
     $rtype1 = $this->callAPISuccess('relationship_type', 'create', array(
       "name_a_b" => uniqid() . " Child of",
index b64abb1cbc19c4fd0e129bb413ed589a5e4fe8c8..b275df4e06653354973ba2dfa16fcb6d317253f3 100644 (file)
@@ -188,6 +188,7 @@ class api_v3_FinancialTypeACLTest extends CiviUnitTestCase {
       'add contributions of type Donation',
     ]);
     $contribution = $this->callAPISuccess('Contribution', 'create', $this->_params);
+    $this->callAPISuccess('Contribution', 'create', array_merge($this->_params, ['financial_type_id' => 'Member Dues']));
 
     $params = array(
       'id' => $contribution['id'],
@@ -197,9 +198,10 @@ class api_v3_FinancialTypeACLTest extends CiviUnitTestCase {
     $this->assertEquals($contribution['count'], 0);
 
     $this->addFinancialAclPermissions([['view', 'Donation']]);
-    $contribution = $this->callAPISuccess('contribution', 'get', $params);
-
-    $this->assertEquals($contribution['count'], 1);
+    $this->callAPISuccessGetSingle('contribution', $params);
+    $this->callAPISuccessGetCount('contribution', ['financial_type_id' => 'Member Dues', 'check_permissions' => 1], 0);
+    $this->markTestIncomplete('check_permissions = 0 should be respected but is not - I have added a todo at the right place but not changed it as yet');
+    $this->callAPISuccessGetCount('contribution', ['financial_type_id' => 'Member Dues'], 1);
   }
 
   /**
index 18032ef7fe5b228267e06cf627778c91f5d02285..5c7a16f9410cdc272e0488647cc8e616a3209bea 100644 (file)
@@ -195,11 +195,11 @@ class api_v3_MailingTest extends CiviUnitTestCase {
 
     // ** Pass 1: Create
     $createParams = $this->_params;
-    $createParams['groups']['include'] = array($groupIDs['a']);
-    $createParams['groups']['exclude'] = array();
-    $createParams['mailings']['include'] = array();
-    $createParams['mailings']['exclude'] = array();
-    $createParams['api.mailing_job.create'] = 1;
+    $createParams['groups']['include'] = [$groupIDs['a']];
+    $createParams['groups']['exclude'] = [];
+    $createParams['mailings']['include'] = [];
+    $createParams['mailings']['exclude'] = [];
+    $createParams['scheduled_date'] = 'now';
     $createResult = $this->callAPISuccess('Mailing', 'create', $createParams);
     $getGroup1 = $this->callAPISuccess('MailingGroup', 'get', array('mailing_id' => $createResult['id']));
     $getGroup1_ids = array_values(CRM_Utils_Array::collect('entity_id', $getGroup1['values']));
@@ -225,7 +225,7 @@ class api_v3_MailingTest extends CiviUnitTestCase {
     $updateParams = $createParams;
     $updateParams['id'] = $createResult['id'];
     $updateParams['groups']['include'] = array($groupIDs['b']);
-    $updateParams['api.mailing_job.create'] = 1;
+    $updateParams['scheduled_date'] = 'now';
     $this->callAPISuccess('Mailing', 'create', $updateParams);
     $getGroup3 = $this->callAPISuccess('MailingGroup', 'get', array('mailing_id' => $createResult['id']));
     $getGroup3_ids = array_values(CRM_Utils_Array::collect('entity_id', $getGroup3['values']));
index 85a3786745ff74aec7ffd422254ba33db0e0ac93..fbb5261cfc30e06b59aea417547ffe1f9beda267 100644 (file)
@@ -104,6 +104,127 @@ class api_v3_PaymentTest extends CiviUnitTestCase {
     ));
   }
 
+  /**
+   * Test email receipt for partial payment.
+   */
+  public function testPaymentEmailReceipt() {
+    $mut = new CiviMailUtils($this);
+    list($lineItems, $contribution) = $this->createParticipantWithContribution();
+    $event = $this->callAPISuccess('Event', 'get', []);
+    $this->addLocationToEvent($event['id']);
+    $params = [
+      'contribution_id' => $contribution['id'],
+      'total_amount' => 50,
+      'check_number' => '345',
+      'trxn_date' => '2018-08-13 17:57:56',
+    ];
+    $payment = $this->callAPISuccess('payment', 'create', $params);
+    $this->checkPaymentResult($payment, [
+      $payment['id'] => [
+        'from_financial_account_id' => 7,
+        'to_financial_account_id' => 6,
+        'total_amount' => 50,
+        'status_id' => 1,
+        'is_payment' => 1,
+      ],
+    ]);
+
+    $this->callAPISuccess('Payment', 'sendconfirmation', ['id' => $payment['id']]);
+    $mut->assertSubjects(['Payment Receipt - Annual CiviCRM meet']);
+    $mut->checkMailLog(array(
+      'Dear Anthony,',
+      'Total Fees: $ 300.00',
+      'This Payment Amount: $ 50.00',
+      'Balance Owed: $ 100.00', //150 was paid in the 1st payment.
+      'Event Information and Location',
+      'Paid By: Check',
+      'Check Number: 345',
+      'Transaction Date: August 13th, 2018  5:57 PM',
+      'event place',
+      'streety street',
+    ));
+    $mut->stop();
+    $mut->clearMessages();
+  }
+
+  /**
+   * Test email receipt for partial payment.
+   */
+  public function testPaymentEmailReceiptFullyPaid() {
+    $mut = new CiviMailUtils($this);
+    list($lineItems, $contribution) = $this->createParticipantWithContribution();
+
+    $params = [
+      'contribution_id' => $contribution['id'],
+      'total_amount' => 150,
+    ];
+    $payment = $this->callAPISuccess('payment', 'create', $params);
+
+    $this->callAPISuccess('Payment', 'sendconfirmation', ['id' => $payment['id']]);
+    $mut->assertSubjects(['Payment Receipt - Annual CiviCRM meet']);
+    $mut->checkMailLog(array(
+      'Dear Anthony,',
+      'A payment has been received.',
+      'Total Fees: $ 300.00',
+      'This Payment Amount: $ 150.00',
+      'Balance Owed: $ 0.00',
+      'Thank you for completing payment.',
+    ));
+    $mut->stop();
+    $mut->clearMessages();
+  }
+
+  /**
+   * Test email receipt for partial payment.
+   *
+   * @dataProvider getThousandSeparators
+   *
+   * @param string $thousandSeparator
+   */
+  public function testRefundEmailReceipt($thousandSeparator) {
+    $this->setCurrencySeparators($thousandSeparator);
+    $decimalSeparator = ($thousandSeparator === ',' ? '.' : ',');
+    $mut = new CiviMailUtils($this);
+    list($lineItems, $contribution) = $this->createParticipantWithContribution();
+    $this->callAPISuccess('payment', 'create', [
+      'contribution_id' => $contribution['id'],
+      'total_amount' => 50,
+      'check_number' => '345',
+      'trxn_date' => '2018-08-13 17:57:56',
+    ]);
+
+    $payment = $this->callAPISuccess('payment', 'create', [
+      'contribution_id' => $contribution['id'],
+      'total_amount' => -30,
+      'trxn_date' => '2018-11-13 12:01:56',
+    ]);
+
+    $this->checkPaymentResult($payment, [
+      $payment['id'] => [
+        'from_financial_account_id' => 7,
+        'to_financial_account_id' => 6,
+        'total_amount' => -30,
+        'status_id' => 1,
+        'is_payment' => 1,
+      ],
+    ]);
+
+    $this->callAPISuccess('Payment', 'sendconfirmation', ['id' => $payment['id']]);
+    $mut->assertSubjects(['Refund Notification - Annual CiviCRM meet']);
+    $mut->checkMailLog(array(
+      'Dear Anthony,',
+      'A refund has been issued based on changes in your registration selections.',
+      'Total Fees: $ 300' . $decimalSeparator . '00',
+      'Refund Amount: $ -30' . $decimalSeparator . '00',
+      'Event Information and Location',
+      'Paid By: Check',
+      'Transaction Date: November 13th, 2018 12:01 PM',
+      'You Paid: $ 170' . $decimalSeparator . '00',
+    ));
+    $mut->stop();
+    $mut->clearMessages();
+  }
+
   /**
    * Test create payment api with no line item in params
    */
@@ -592,4 +713,27 @@ class api_v3_PaymentTest extends CiviUnitTestCase {
     ));
   }
 
+  /**
+   * Add a location to our event.
+   *
+   * @param int $eventID
+   */
+  protected function addLocationToEvent($eventID) {
+    $addressParams = [
+      'name' => 'event place',
+      'street_address' => 'streety street',
+      'location_type_id' => 1,
+      'is_primary' => 1,
+    ];
+    // api requires contact_id - perhaps incorrectly but use add to get past that.
+    $address = CRM_Core_BAO_Address::add($addressParams);
+
+    $location = $this->callAPISuccess('LocBlock', 'create', ['address_id' => $address->id]);
+    $this->callAPISuccess('Event', 'create', [
+      'id' => $eventID,
+      'loc_block_id' => $location['id'],
+      'is_show_location' => TRUE,
+    ]);
+  }
+
 }
index d7551c484ca3481d6859b86cd3af5289614edf65..ce7af69fdf7dd3650dc977e3bc53dc004e8da971 100644 (file)
@@ -198,7 +198,7 @@ class api_v3_ProfileTest extends CiviUnitTestCase {
    * Get Billing empty contact - this will return generic defaults
    */
   public function testProfileGetBillingEmptyContact() {
-
+    $this->callAPISuccess('Setting', 'create', ['defaultContactCountry' => 1228]);
     $params = array(
       'profile_id' => array('Billing'),
     );
index 00b257d998c4ee3bd639817efcb099e58dabfa67..2f02b1409a04966fa4c69c31619e5b5f8d1e65d6 100644 (file)
@@ -552,6 +552,23 @@ class api_v3_ReportTemplateTest extends CiviUnitTestCase {
     $this->assertEquals(2, $rows['values'][0]['civicrm_contribution_total_amount_count']);
   }
 
+  /**
+   * Test no fatal on order by per https://lab.civicrm.org/dev/core/issues/739
+   */
+  public function testCaseDetailsCaseTypeHeader() {
+    $this->callAPISuccess('report_template', 'getrows', [
+      'report_id' => 'case/detail',
+      'fields' => ['subject' => 1, 'client_sort_name' => 1],
+       'order_bys' => [
+         1 => [
+          'column' => 'case_type_title',
+          'order' => 'ASC',
+          'section' => '1',
+        ],
+      ],
+    ]);
+  }
+
   /**
    * Test the group filter works on the contribution summary.
    */
diff --git a/tools/scripts/composer/patches/pear-mail.patch.txt b/tools/scripts/composer/patches/pear-mail.patch.txt
new file mode 100644 (file)
index 0000000..e2f488d
--- /dev/null
@@ -0,0 +1,86 @@
+diff --git a/Mail.php b/Mail.php
+index b04bc01..0e7da00 100644
+--- a/Mail.php
++++ b/Mail.php
+@@ -155,6 +155,10 @@ class Mail
+                 preg_replace('=((<CR>|<LF>|0x0A/%0A|0x0D/%0D|\\n|\\r)\S).*=i',
+                              null, $value);
+         }
++        // fix for CRM-1367
++        if (!array_key_exists('Date', $headers)) {
++            $headers['Date'] = date('r');
++        }
+     }
+     /**
+diff --git a/Mail/mail.php b/Mail/mail.php
+index ee1ecef..ae6e2e8 100644
+--- a/Mail/mail.php
++++ b/Mail/mail.php
+@@ -114,6 +114,14 @@ class Mail_mail extends Mail {
+      */
+     public function send($recipients, $headers, $body)
+     {
++        if (defined('CIVICRM_MAIL_LOG')) {
++            CRM_Utils_Mail::logger($recipients, $headers, $body);
++            // Note: "CIVICRM_MAIL_LOG_AND SEND" (space not underscore) was a typo that existed for some years, so kept here for compatibility, but it should not be used.
++            if (!defined('CIVICRM_MAIL_LOG_AND_SEND') && !defined('CIVICRM_MAIL_LOG_AND SEND')) {
++                return true;
++            }
++        }
++
+         if (!is_array($headers)) {
+             return PEAR::raiseError('$headers must be an array');
+         }
+@@ -145,7 +153,12 @@ class Mail_mail extends Mail {
+         if (is_a($headerElements, 'PEAR_Error')) {
+             return $headerElements;
+         }
+-        list(, $text_headers) = $headerElements;
++        list($from, $text_headers) = $headerElements;
++        // use Return-Path for SMTP envelope’s FROM address (if set), CRM-5946
++        if (!empty($headers['Return-Path'])) {
++            $from = $headers['Return-Path'];
++        }
++        $this->_params = "-f".$from;
+         // We only use mail()'s optional fifth parameter if the additional
+         // parameters have been provided and we're not running in safe mode.
+diff --git a/Mail/sendmail.php b/Mail/sendmail.php
+index 7e8f804..e0300a0 100644
+--- a/Mail/sendmail.php
++++ b/Mail/sendmail.php
+@@ -132,6 +132,14 @@ class Mail_sendmail extends Mail {
+      */
+     public function send($recipients, $headers, $body)
+     {
++        if (defined('CIVICRM_MAIL_LOG')) {
++            CRM_Utils_Mail::logger($recipients, $headers, $body);
++            // Note: "CIVICRM_MAIL_LOG_AND SEND" (space not underscore) was a typo that existed for some years, so kept here for compatibility, but it should not be used.
++            if (!defined('CIVICRM_MAIL_LOG_AND_SEND') && !defined('CIVICRM_MAIL_LOG_AND SEND')) {
++                return true;
++            }
++        }
++
+         if (!is_array($headers)) {
+             return PEAR::raiseError('$headers must be an array');
+         }
+diff --git a/Mail/smtp.php b/Mail/smtp.php
+index 5e698fe..5f057e2 100644
+--- a/Mail/smtp.php
++++ b/Mail/smtp.php
+@@ -255,6 +255,14 @@ class Mail_smtp extends Mail {
+      */
+     public function send($recipients, $headers, $body)
+     {
++        if (defined('CIVICRM_MAIL_LOG')) {
++            CRM_Utils_Mail::logger($recipients, $headers, $body);
++            // Note: "CIVICRM_MAIL_LOG_AND SEND" (space not underscore) was a typo that existed for some years, so kept here for compatibility, but it should not be used.
++            if (!defined('CIVICRM_MAIL_LOG_AND_SEND') && !defined('CIVICRM_MAIL_LOG_AND SEND')) {
++                return true;
++            }
++        }
++
+         $result = $this->send_or_fail($recipients, $headers, $body);
+         /* If persistent connections are disabled, destroy our SMTP object. */
diff --git a/tools/scripts/composer/patches/phpoffice-common-xml-entity-fix.patch b/tools/scripts/composer/patches/phpoffice-common-xml-entity-fix.patch
new file mode 100644 (file)
index 0000000..c3da55e
--- /dev/null
@@ -0,0 +1,15 @@
+--- src/Common/XMLReader.php   2019-02-24 13:35:42.895637978 +1100
++++ src/Common/XMLReader.php   2019-02-24 11:41:29.462449569 +1100
+@@ -71,10 +71,11 @@
+      */
+     public function getDomFromString($content)
+     {
++        $original = libxml_disable_entity_loader();
+         libxml_disable_entity_loader(true);
+         $this->dom = new \DOMDocument();
+         $this->dom->loadXML($content);
+-
++        libxml_disable_entity_loader($original);
+         return $this->dom;
+     }
diff --git a/tools/scripts/composer/patches/phpword-libxml-fix-global-handling.patch b/tools/scripts/composer/patches/phpword-libxml-fix-global-handling.patch
new file mode 100644 (file)
index 0000000..da6f8f0
--- /dev/null
@@ -0,0 +1,51 @@
+From 27ee4bef48def2e3b966b6d5ff8cc8c56b1fac2c Mon Sep 17 00:00:00 2001
+From: Seamus Lee <seamuslee001@gmail.com>
+Date: Sun, 24 Feb 2019 09:06:51 +1100
+Subject: [PATCH] Ensure that entity_loader disable variable is re-set back to
+ the original setting
+
+---
+ src/PhpWord/Shared/Html.php             | 2 ++
+ src/PhpWord/TemplateProcessor.php       | 2 ++
+ 3 files changed, 6 insertions(+), 1 deletion(-)
+
+diff --git a/src/PhpWord/Shared/Html.php b/src/PhpWord/Shared/Html.php
+index 89881822ca..f25cf5f4a6 100644
+--- a/src/PhpWord/Shared/Html.php
++++ b/src/PhpWord/Shared/Html.php
+@@ -72,6 +72,7 @@ public static function addHtml($element, $html, $fullHTML = false, $preserveWhit
+         }
+         // Load DOM
++        $orignalLibEntityLoader = libxml_disable_entity_loader();
+         libxml_disable_entity_loader(true);
+         $dom = new \DOMDocument();
+         $dom->preserveWhiteSpace = $preserveWhiteSpace;
+@@ -80,6 +81,7 @@ public static function addHtml($element, $html, $fullHTML = false, $preserveWhit
+         $node = $dom->getElementsByTagName('body');
+         self::parseNode($node->item(0), $element);
++        libxml_disable_entity_loader($orignalLibEntityLoader);
+     }
+     /**
+diff --git a/src/PhpWord/TemplateProcessor.php b/src/PhpWord/TemplateProcessor.php
+index 0f685bc45b..fa605b19c5 100644
+--- a/src/PhpWord/TemplateProcessor.php
++++ b/src/PhpWord/TemplateProcessor.php
+@@ -170,6 +170,7 @@ protected function readPartWithRels($fileName)
+      */
+     protected function transformSingleXml($xml, $xsltProcessor)
+     {
++        $orignalLibEntityLoader = libxml_disable_entity_loader();
+         libxml_disable_entity_loader(true);
+         $domDocument = new \DOMDocument();
+         if (false === $domDocument->loadXML($xml)) {
+@@ -180,6 +181,7 @@ protected function transformSingleXml($xml, $xsltProcessor)
+         if (false === $transformedXml) {
+             throw new Exception('Could not transform the given XML document.');
+         }
++        libxml_disable_entity_loader($orignalLibEntityLoader);
+         return $transformedXml;
+     }
diff --git a/tools/scripts/composer/pear-mail-fix.sh b/tools/scripts/composer/pear-mail-fix.sh
new file mode 100755 (executable)
index 0000000..890dc61
--- /dev/null
@@ -0,0 +1,35 @@
+#!/bin/bash
+
+## Cleanup the vendor tree. The main issue here is that civi Civi is
+## deployed as a module inside a CMS, so all its source-code gets published.
+## Some libraries distribute admin tools and sample files which should not
+## be published.
+##
+## This script should be idempotent -- if you rerun it several times, it
+## should always produce the same post-condition.
+
+## Replace a line in a file
+## This is a bit like 'sed -i', but dumber and more cross-platform.
+
+##############################################################################
+## usage: safe_delete <relpath...>
+function safe_delete() {
+  for file in "$@" ; do
+    if [ -z "$file" ]; then
+      echo "Skip: empty file name"
+    elif [ -e "$file" ]; then
+      rm -rf "$file"
+    fi
+  done
+}
+
+
+##############################################################################
+# @fixme Extend pear/mail rather than patching it.
+if ! grep -q 'CRM-1367' vendor/pear/mail/Mail.php; then
+  patch -d vendor/pear/mail -p1 < tools/scripts/composer/patches/pear-mail.patch.txt
+fi
+
+safe_delete vendor/pear/console_getopt/{package.xml,README.rst,tests}
+safe_delete vendor/pear/mail/{package.xml,README.rst,tests}
+safe_delete vendor/pear/pear-core-minimal/{package.xml,README.rst}
index 5ea0ccc0fd8a2e0216253007e3440b9e2fd42253..63b8d1302313f167e71165ed7d46b4abe7ec56eb 100644 (file)
@@ -31,8 +31,8 @@
     <dataPattern>/^\d+$/</dataPattern>
     <comment>FK to Contact ID</comment>
     <html>
-       <type>EntityRef</type>
-     </html>
+      <type>EntityRef</type>
+    </html>
     <add>1.3</add>
   </field>
   <foreignKey>
index 9a8e4ba9eba907628b7cc58918285b2228bfd456..9e9145cf8a7286a6a96fed01d9e394d2ccbb7cc8 100644 (file)
   </primaryKey>
   <field>
     <name>contact_id</name>
-    <title>Contact ID</title>
+    <title>Contact</title>
     <type>int unsigned</type>
     <required>true</required>
-    <comment>Foreign key to civicrm_contact.id .</comment>
+    <comment>Foreign key to civicrm_contact.id.</comment>
     <add>1.6</add>
+    <html>
+      <type>EntityRef</type>
+    </html>
   </field>
   <foreignKey>
     <name>contact_id</name>
   </field>
   <field>
     <name>start_date</name>
-    <title>Recurring Contribution Started Date</title>
+    <title>Start Date</title>
     <type>datetime</type>
     <required>true</required>
     <comment>The date the first scheduled recurring contribution occurs.</comment>
     <add>1.6</add>
     <html>
       <type>Select Date</type>
-      <formatType>activityDate</formatType>
+      <formatType>activityDateTime</formatType>
     </html>
   </field>
   <field>
     <name>create_date</name>
-    <title>Recurring Contribution Created Date</title>
+    <title>Created Date</title>
     <type>datetime</type>
     <required>true</required>
     <comment>When this recurring contribution record was created.</comment>
     <add>1.6</add>
     <html>
       <type>Select Date</type>
-      <formatType>activityDate</formatType>
+      <formatType>activityDateTime</formatType>
     </html>
   </field>
   <field>
     <name>modified_date</name>
-    <title>Recurring Contribution Modified Date</title>
+    <title>Modified Date</title>
     <type>datetime</type>
     <comment>Last updated date for this record. mostly the last time a payment was received</comment>
     <add>1.6</add>
     <html>
       <type>Select Date</type>
-      <formatType>activityDate</formatType>
+      <formatType>activityDateTime</formatType>
     </html>
   </field>
   <field>
     <name>cancel_date</name>
-    <title>Recurring Contribution Cancel Date</title>
+    <title>Cancel Date</title>
     <type>datetime</type>
     <comment>Date this recurring contribution was cancelled by contributor- if we can get access to it</comment>
     <add>1.6</add>
     <length>255</length>
     <comment>Possibly needed to store a unique identifier for this recurring payment order - if this is available from the processor??</comment>
     <add>1.6</add>
+    <html>
+      <type>Text</type>
+    </html>
   </field>
   <field>
     <name>payment_token_id</name>
     <length>255</length>
     <comment>unique transaction id. may be processor id, bank id + trans id, or account number + check number... depending on payment_method</comment>
     <add>1.6</add>
+    <html>
+      <type>Text</type>
+    </html>
   </field>
   <field>
     <name>invoice_id</name>
     <length>255</length>
     <comment>unique invoice id, system generated or passed in</comment>
     <add>1.6</add>
+    <html>
+      <type>Text</type>
+    </html>
   </field>
   <index>
     <name>UI_contrib_trxn_id</name>
   </index>
   <field>
     <name>contribution_status_id</name>
-    <title>Recurring Contribution Status</title>
+    <title>Status</title>
     <type>int unsigned</type>
     <default>1</default>
     <import>true</import>
     <pseudoconstant>
       <optionGroupName>contribution_status</optionGroupName>
     </pseudoconstant>
+    <html>
+      <type>Select</type>
+    </html>
   </field>
   <index>
     <name>index_contribution_status</name>
   </field>
   <field>
     <name>cycle_day</name>
-    <title>Number of Cycle Day</title>
+    <title>Cycle Day</title>
     <type>int unsigned</type>
     <default>1</default>
     <required>true</required>
     <type>int unsigned</type>
     <comment>Foreign key to civicrm_payment_processor.id</comment>
     <add>3.3</add>
+    <pseudoconstant>
+      <table>civicrm_payment_processor</table>
+      <keyColumn>id</keyColumn>
+      <labelColumn>name</labelColumn>
+    </pseudoconstant>
+    <html>
+      <type>Select</type>
+    </html>
   </field>
   <foreignKey>
     <name>payment_processor_id</name>
       <keyColumn>id</keyColumn>
       <labelColumn>name</labelColumn>
     </pseudoconstant>
+    <html>
+      <type>Select</type>
+    </html>
   </field>
   <foreignKey>
     <name>financial_type_id</name>
       <labelColumn>title</labelColumn>
     </pseudoconstant>
     <add>4.1</add>
+    <html>
+      <type>Select</type>
+    </html>
   </field>
   <foreignKey>
     <name>campaign_id</name>
index bf65f319de0faf57cd700bad57320f51b5c725b3..77afb22248115e9cfd10492dbad333738bfbbe8c 100644 (file)
@@ -23,6 +23,7 @@
     <type>int unsigned</type>
     <comment>FK to Contact ID</comment>
     <add>3.3</add>
+    <required>TRUE</required>
   </field>
   <foreignKey>
     <name>contact_id1</name>
@@ -37,6 +38,7 @@
     <type>int unsigned</type>
     <comment>FK to Contact ID</comment>
     <add>3.3</add>
+    <required>TRUE</required>
   </field>
   <foreignKey>
     <name>contact_id2</name>
index 709d7915d99e9e01db62d7954d7eb034904cd5bf..6095b4d23fec06f7f223647494675c56a4d5fa90 100644 (file)
@@ -12,7 +12,6 @@
 {capture assign=emptyBlockStyle }style="padding: 10px; border-bottom: 1px solid #999;background-color: #f7f7f7;"{/capture}
 {capture assign=emptyBlockValueStyle }style="padding: 10px; border-bottom: 1px solid #999;"{/capture}
 
-<p>Dear {$contactDisplayName}</p>
 <center>
  <table width="620" border="0" cellpadding="0" cellspacing="0" id="crm-event_receipt" style="font-family: Arial, Verdana, sans-serif; text-align: left;">
 
@@ -21,7 +20,7 @@
   <!-- END HEADER -->
 
   <!-- BEGIN CONTENT -->
-
+   {if $emailGreeting}<tr><td>{$emailGreeting},</td></tr>{/if}
   <tr>
     <td>
       {if $isRefund}
@@ -29,7 +28,6 @@
       {else}
       <p>{ts}A payment has been received.{/ts}</p>
       {/if}
-      <p>{ts}Please print this confirmation for your records.{/ts}</p>
     </td>
   </tr>
   <tr>
     <tr>
       <td>
   <table style="border: 1px solid #999; margin: 1em 0em 1em; border-collapse: collapse; width:100%;">
-    {if $contributeMode eq 'direct' and !$isAmountzero}
+    {if $billingName || $address}
           <tr>
             <th {$headerStyle}>
         {ts}Billing Name and Address{/ts}
             </td>
           </tr>
     {/if}
-    {if $contributeMode eq'direct' and !$isAmountzero}
+    {if $credit_card_number}
           <tr>
             <th {$headerStyle}>
         {ts}Credit Card Information{/ts}
index c713864c05f4d230dac5eed3179a7886c1deb306..2f166dd3d44b4abc5f4cc56df8c58fcca955e6bd 100644 (file)
@@ -1,12 +1,10 @@
-Dear {$contactDisplayName}
-{if $isRefund}
+{if $emailGreeting}{$emailGreeting},
+{/if}{if $isRefund}
 {ts}A refund has been issued based on changes in your registration selections.{/ts}
 {else}
 {ts}A payment has been received.{/ts}
 {/if}
 
-{ts}Please print this confirmation for your records.{/ts}
-
 {if $isRefund}
 ===============================================================================
 
@@ -46,7 +44,7 @@ Dear {$contactDisplayName}
 {if $checkNumber}
 {ts}Check Number{/ts}: {$checkNumber}
 {/if}
-{if $contributeMode eq 'direct' and !$isAmountzero}
+{if $billingName || $address}
 
 ===============================================================================
 
@@ -58,7 +56,7 @@ Dear {$contactDisplayName}
 {$address}
 {/if}
 
-{if $contributeMode eq 'direct' and !$isAmountzero}
+{if $credit_card_number}
 ===========================================================
 {ts}Credit Card Information{/ts}
 
index 1324a6e7852f1441da9f72947deb845f499eea21..0a9661f343346a41b2a5c1a33cca32ecd663f7b5 100644 (file)
@@ -1,4 +1,4 @@
 <?xml version="1.0" encoding="iso-8859-1" ?>
 <version>
-  <version_no>5.11.beta1</version_no>
+  <version_no>5.12.alpha1</version_no>
 </version>