Merge pull request #9769 from scardinius/crm-19958
authorcolemanw <coleman@civicrm.org>
Thu, 9 Mar 2017 02:55:35 +0000 (21:55 -0500)
committerGitHub <noreply@github.com>
Thu, 9 Mar 2017 02:55:35 +0000 (21:55 -0500)
CRM-19958 Fix invalid name of variable subtype

403 files changed:
.editorconfig [new file with mode: 0644]
CRM/Activity/DAO/Activity.php
CRM/Activity/Form/Task/Batch.php
CRM/Activity/Import/Parser/Activity.php
CRM/Admin/Form.php
CRM/Admin/Form/Navigation.php
CRM/Admin/Form/Setting.php
CRM/Admin/Form/Setting/Search.php
CRM/Admin/Form/Setting/UF.php
CRM/Admin/Page/AJAX.php
CRM/Admin/Page/Navigation.php
CRM/Batch/BAO/Batch.php
CRM/Batch/Form/Entry.php
CRM/Contact/BAO/Contact.php
CRM/Contact/BAO/Contact/Permission.php
CRM/Contact/BAO/Group.php
CRM/Contact/BAO/Query.php
CRM/Contact/DAO/Contact.php
CRM/Contact/Form/Edit/Demographics.php
CRM/Contact/Form/Merge.php
CRM/Contact/Form/Search/Criteria.php
CRM/Contact/Page/DedupeFind.php
CRM/Contact/Page/DedupeMerge.php
CRM/Contact/Page/Inline/Demographics.php
CRM/Contact/Page/SavedSearch.php
CRM/Contact/Page/View/Summary.php
CRM/Contact/Page/View/Vcard.php
CRM/Contact/Selector.php
CRM/Contribute/BAO/Contribution.php
CRM/Contribute/BAO/Contribution/Utils.php
CRM/Contribute/BAO/Query.php
CRM/Contribute/DAO/Contribution.php
CRM/Contribute/Form/AdditionalPayment.php
CRM/Contribute/Form/Contribution.php
CRM/Contribute/Form/Search.php
CRM/Contribute/Form/Task/Batch.php
CRM/Contribute/Selector/Search.php
CRM/Core/BAO/CustomField.php
CRM/Core/BAO/EntityTag.php
CRM/Core/BAO/Mapping.php
CRM/Core/BAO/MessageTemplate.php
CRM/Core/BAO/Navigation.php
CRM/Core/BAO/OptionGroup.php
CRM/Core/BAO/PrevNextCache.php
CRM/Core/BAO/Tag.php
CRM/Core/BAO/UFGroup.php
CRM/Core/BAO/UFMatch.php
CRM/Core/CodeGen/Specification.php
CRM/Core/DAO.php
CRM/Core/DAO/AllCoreTables.data.php
CRM/Core/Error.php
CRM/Core/Form.php
CRM/Core/OptionGroup.php
CRM/Core/Page.php
CRM/Core/Payment/PayPalIPN.php
CRM/Core/Resources.php
CRM/Core/SelectValues.php
CRM/Core/Smarty/plugins/function.crmStyle.php
CRM/Core/xml/Menu/Admin.xml
CRM/Core/xml/Menu/Contact.xml
CRM/Core/xml/Menu/Tag.xml
CRM/Dedupe/Merger.php
CRM/Event/BAO/Participant.php
CRM/Event/DAO/Participant.php
CRM/Event/Form/Participant.php
CRM/Event/Form/Registration.php
CRM/Event/Form/Registration/Confirm.php
CRM/Event/Form/Registration/Register.php
CRM/Event/Form/Task/Batch.php
CRM/Export/BAO/Export.php
CRM/Financial/BAO/PaymentProcessor.php
CRM/Financial/DAO/FinancialTrxn.php
CRM/Financial/Form/Payment.php
CRM/Financial/Page/AJAX.php
CRM/Group/Page/Group.php
CRM/Logging/Reverter.php
CRM/Mailing/ActionTokens.php
CRM/Mailing/BAO/Mailing.php
CRM/Mailing/Event/BAO/Bounce.php
CRM/Member/DAO/Membership.php
CRM/Price/BAO/LineItem.php
CRM/Price/BAO/PriceSet.php
CRM/Price/Form/Field.php
CRM/Profile/Form.php
CRM/Profile/Page/MultipleRecordFieldsListing.php
CRM/Report/Form.php
CRM/Report/Form/Activity.php
CRM/Report/Form/ActivitySummary.php
CRM/Report/Form/Contact/Relationship.php
CRM/Report/Form/Contribute/DeferredRevenue.php
CRM/Report/Form/Contribute/Lybunt.php
CRM/Report/Form/Contribute/Summary.php
CRM/Report/Form/Event/Summary.php
CRM/Report/Form/Member/ContributionDetail.php
CRM/Tag/Form/Edit.php
CRM/Tag/Form/Merge.php [new file with mode: 0644]
CRM/Tag/Form/Tag.php
CRM/Tag/Page/Tag.php
CRM/Upgrade/Incremental/php/FourSeven.php
CRM/Upgrade/Incremental/sql/4.7.17.mysql.tpl
CRM/Upgrade/Incremental/sql/4.7.18.mysql.tpl [new file with mode: 0644]
CRM/Upgrade/Incremental/sql/4.7.alpha1.mysql.tpl
CRM/Utils/Date.php
CRM/Utils/Hook/UnitTests.php
CRM/Utils/Mail/EmailProcessor.php
CRM/Utils/PDF/Document.php
CRM/Utils/Pager.php
CRM/Utils/Rule.php
CRM/Utils/System.php
CRM/Utils/System/Drupal8.php
CRM/Utils/System/DrupalBase.php
CRM/Utils/System/Joomla.php
CRM/Utils/Type.php
Civi/API/Api3SelectQuery.php
Civi/API/Events.php
Civi/API/Subscriber/WrapperAdapter.php
Civi/ActionSchedule/Events.php
Civi/Core/Container.php
api/v3/Activity.php
api/v3/Case.php
api/v3/Contact.php
api/v3/Contribution.php
api/v3/Extension.php
api/v3/GroupContact.php
api/v3/Job.php
api/v3/Logging.php
api/v3/MailingGroup.php
api/v3/MembershipType.php
api/v3/examples/Activity/ContactRefCustomField.php
api/v3/examples/Activity/ContactRefCustomFieldGet.php
api/v3/examples/Activity/Create.php
api/v3/examples/Activity/DateTimeHigh.php
api/v3/examples/Activity/DateTimeLow.php
api/v3/examples/Activity/Get.php
api/v3/examples/Activity/GetFields.php
api/v3/examples/Activity/GetTargetandAssigneeName.php
api/v3/examples/Activity/ReturnAssigneeContact.php
api/v3/examples/ActivityType/Create.php
api/v3/examples/ActivityType/Get.php
api/v3/examples/Constant/Get.php
api/v3/examples/Contact/APIChainedArray.php
api/v3/examples/Contact/APIChainedArrayFormats.php
api/v3/examples/Contact/APIChainedArrayMultipleCustom.php
api/v3/examples/Contact/APIChainedArrayValuesFromSiblingFunction.php
api/v3/examples/Contact/ChainTwoWebsites.php
api/v3/examples/Contact/ChainTwoWebsitesSyntax2.php
api/v3/examples/Contact/Create.php
api/v3/examples/Contact/CreateParticipantPayment.php
api/v3/examples/Contact/CustomFieldGet.php
api/v3/examples/Contact/CustomFieldGetReturnSyntaxVariation.php
api/v3/examples/Contact/Delete.php
api/v3/examples/Contact/Get.php
api/v3/examples/Contact/GetActions.php
api/v3/examples/Contact/GetFieldsOptions.php
api/v3/examples/Contact/GroupFilterUsingContactAPI.php
api/v3/examples/Contribution/ContributionCreateWithHonoreeContact.php
api/v3/examples/Contribution/ContributionCreateWithNote.php
api/v3/examples/Contribution/ContributionCreateWithSoftCredit.php
api/v3/examples/Contribution/ContributionCreateWithSoftCreditDefaults.php
api/v3/examples/Contribution/Create.php
api/v3/examples/Contribution/CreateWithNestedLineItems.php
api/v3/examples/Contribution/Delete.php
api/v3/examples/Contribution/Get.php
api/v3/examples/ContributionPage/Create.php
api/v3/examples/ContributionPage/Get.php
api/v3/examples/ContributionPage/Submit.php
api/v3/examples/ContributionRecur/Delete.php
api/v3/examples/Country/Create.php
api/v3/examples/Country/Delete.php
api/v3/examples/Country/Get.php
api/v3/examples/EntityTag/Delete.php
api/v3/examples/EntityTag/Get.php
api/v3/examples/Event/IsFullOption.php
api/v3/examples/Group/GetFields.php
api/v3/examples/Job/Create.php
api/v3/examples/Job/Delete.php
api/v3/examples/Logging/Get.php
api/v3/examples/Logging/Revert.php
api/v3/examples/Mailing/Create.php
api/v3/examples/Mailing/Delete.php
api/v3/examples/Mailing/Submit.php
api/v3/examples/MailingAB/Create.php
api/v3/examples/Membership/Create.php
api/v3/examples/Membership/CreateWithCustomData.php
api/v3/examples/Membership/FilterIsCurrent.php
api/v3/examples/Membership/Get.php
api/v3/examples/Membership/UpdateCustomData.php
api/v3/examples/MembershipType/Create.php
api/v3/examples/MembershipType/Get.php
api/v3/examples/MessageTemplate/Create.php
api/v3/examples/MessageTemplate/Delete.php
api/v3/examples/MessageTemplate/Get.php
api/v3/examples/OptionGroup/Create.php
api/v3/examples/OptionGroup/Delete.php
api/v3/examples/Order/Cancel.php
api/v3/examples/Order/Create.php
api/v3/examples/Order/CreateOrderParticipant.php
api/v3/examples/Order/Get.php
api/v3/examples/Participant/Create.php
api/v3/examples/Participant/Get.php
api/v3/examples/Participant/NestedDelete.php
api/v3/examples/Participant/NestedEventGet.php
api/v3/examples/ParticipantStatusType/Create.php
api/v3/examples/ParticipantStatusType/Delete.php
api/v3/examples/ParticipantStatusType/Get.php
api/v3/examples/Payment/Cancel.php
api/v3/examples/Payment/Create.php
api/v3/examples/Payment/CreatePaymentWithLineItems.php
api/v3/examples/Payment/Delete.php
api/v3/examples/Payment/Get.php
api/v3/examples/Payment/UpdatePayment.php
api/v3/examples/PaymentProcessor/Create.php
api/v3/examples/PaymentProcessor/Delete.php
api/v3/examples/PaymentProcessorType/Create.php
api/v3/examples/PaymentProcessorType/Delete.php
api/v3/examples/PaymentToken/Create.php [new file with mode: 0644]
api/v3/examples/PaymentToken/Delete.php [new file with mode: 0644]
api/v3/examples/PaymentToken/Get.php [new file with mode: 0644]
api/v3/examples/Pcp/Create.php [new file with mode: 0644]
api/v3/examples/Phone/Create.php
api/v3/examples/Phone/Delete.php
api/v3/examples/Phone/Get.php
api/v3/examples/Pledge/Create.php
api/v3/examples/Pledge/Delete.php
api/v3/examples/Pledge/Get.php
api/v3/examples/Pledge/GetFilterHighDate.php
api/v3/examples/PledgePayment/Create.php
api/v3/examples/PledgePayment/Delete.php
api/v3/examples/PledgePayment/Get.php
api/v3/examples/PledgePayment/Update.php
api/v3/examples/PriceField/Create.php
api/v3/examples/PriceField/Delete.php
api/v3/examples/PriceField/Get.php
api/v3/examples/PriceFieldValue/Create.php
api/v3/examples/PriceFieldValue/Delete.php
api/v3/examples/PriceFieldValue/Get.php
api/v3/examples/PriceSet/Create.php
api/v3/examples/PriceSet/Delete.php
api/v3/examples/PriceSet/Get.php
api/v3/examples/Profile/Apply.php
api/v3/examples/Profile/Get.php
api/v3/examples/Profile/GetFields.php
api/v3/examples/Profile/Submit.php
api/v3/examples/Relationship/BetweenRelationshipType.php
api/v3/examples/Relationship/Create.php
api/v3/examples/Relationship/Delete.php
api/v3/examples/Relationship/Get.php
api/v3/examples/Relationship/INRelationshipType.php
api/v3/examples/Relationship/NotBetweenRelationshipType.php
api/v3/examples/Relationship/NotInRelationshipType.php
api/v3/examples/Relationship/filterIsCurrent.php
api/v3/examples/RelationshipType/Create.php
api/v3/examples/RelationshipType/Delete.php
api/v3/examples/ReportTemplate/Getrows.php
api/v3/examples/ReportTemplate/Getstatistics.php
api/v3/examples/SavedSearch/Create.php [new file with mode: 0644]
api/v3/examples/SavedSearch/Delete.php [new file with mode: 0644]
api/v3/examples/SavedSearch/Get.php [new file with mode: 0644]
api/v3/examples/Setting/Create.php
api/v3/examples/Setting/CreateAllDomains.php
api/v3/examples/Setting/CreateSettingCurrentDomain.php
api/v3/examples/Setting/CreateSpecifiedDomains.php
api/v3/examples/Setting/Get.php
api/v3/examples/Setting/GetAllDomains.php
api/v3/examples/Setting/GetDefaults.php
api/v3/examples/Setting/GetFields.php
api/v3/examples/Setting/GetSettingCurrentDomain.php
api/v3/examples/Setting/GetSpecifiedDomains.php
api/v3/examples/Setting/GetValue.php
api/v3/examples/Setting/Revert.php
api/v3/examples/StateProvince/Create.php [new file with mode: 0644]
api/v3/examples/StateProvince/Delete.php [new file with mode: 0644]
api/v3/examples/StateProvince/Get.php [new file with mode: 0644]
api/v3/examples/StatusPreference/Create.php [new file with mode: 0644]
api/v3/examples/StatusPreference/Delete.php [new file with mode: 0644]
api/v3/examples/StatusPreference/Get.php [new file with mode: 0644]
api/v3/examples/Survey/ChainedGetDelete.php
api/v3/examples/Survey/Create.php
api/v3/examples/Survey/Delete.php
api/v3/examples/Survey/Get.php
api/v3/examples/SurveyRespondant/Get.php
api/v3/examples/System/Flush.php
api/v3/examples/Tag/Create.php
api/v3/examples/Tag/Delete.php
api/v3/examples/Tag/Get.php
api/v3/examples/Tag/GetFields.php
api/v3/examples/Tag/GetList.php
api/v3/examples/Tag/GetReturnArray.php
api/v3/examples/UFField/Create.php
api/v3/examples/UFField/Delete.php
api/v3/examples/UFField/Get.php
api/v3/examples/UFField/Replace.php
api/v3/examples/UFGroup/Create.php
api/v3/examples/UFGroup/Delete.php
api/v3/examples/UFGroup/Get.php
api/v3/examples/UFJoin/Create.php
api/v3/examples/UFJoin/Get.php
api/v3/examples/UFMatch/Get.php
api/v3/examples/Website/Create.php
api/v3/examples/Website/Delete.php
api/v3/examples/Website/Get.php
api/v3/examples/Website/GetFields.php
api/v3/examples/Website/GetWithMetadata.php
api/v3/utils.php
bower.json
contributor-key.yml
css/civicrmNavigation.css
css/contactSummary.css
css/print.css
docs/api.md [deleted file]
docs/build.md [deleted file]
docs/customize.md [deleted file]
docs/develop.md [deleted file]
docs/extend.md [deleted file]
docs/hook.md [deleted file]
docs/index.md [deleted file]
docs/requirements.md [deleted file]
docs/test.md [deleted file]
js/Common.js
js/crm.ajax.js
js/crm.drupal.js
js/jquery/jquery.crmAjaxTable.js [new file with mode: 0644]
js/jquery/jquery.crmEditable.js [moved from js/jquery/jquery.crmeditable.js with 97% similarity]
release-notes.md
release-notes/4.7.16.md [new file with mode: 0644]
settings/Core.setting.php
settings/Search.setting.php
sql/civicrm_generated.mysql
templates/CRM/Activity/Form/ActivityLinks.tpl
templates/CRM/Activity/Form/Task/Batch.tpl
templates/CRM/Admin/Form/Setting/Search.tpl
templates/CRM/Admin/Form/Setting/UF.tpl
templates/CRM/Admin/Page/APIExplorer.js
templates/CRM/Admin/Page/APIExplorer.tpl
templates/CRM/Admin/Page/Navigation.tpl
templates/CRM/Batch/Form/Entry.js
templates/CRM/Campaign/Form/Search/Campaign.tpl
templates/CRM/Campaign/Form/Search/Petition.tpl
templates/CRM/Campaign/Form/Search/Survey.tpl
templates/CRM/Contact/Form/Edit/Demographics.tpl
templates/CRM/Contact/Form/Edit/TagsAndGroups.tpl
templates/CRM/Contact/Form/Inline/Demographics.tpl
templates/CRM/Contact/Form/Merge.tpl
templates/CRM/Contact/Form/Search/Criteria/Location.tpl
templates/CRM/Contact/Form/Task/Batch.tpl
templates/CRM/Contact/Page/Inline/Demographics.tpl
templates/CRM/Contribute/Form/Contribution.tpl
templates/CRM/Core/BillingBlock.js
templates/CRM/Custom/Page/Option.tpl
templates/CRM/Event/Form/Task/Batch.tpl
templates/CRM/Financial/Form/Search.tpl
templates/CRM/Price/Form/Calculate.tpl
templates/CRM/Price/Page/LineItem.tpl
templates/CRM/Profile/Form/Dynamic.tpl
templates/CRM/Profile/Form/Search.tpl
templates/CRM/Tag/Form/Edit.tpl
templates/CRM/Tag/Form/Merge.tpl [new file with mode: 0644]
templates/CRM/Tag/Form/Tag.tpl
templates/CRM/Tag/Form/Tagtree.tpl
templates/CRM/Tag/Page/Tag.tpl
templates/CRM/UF/Form/Block.tpl
templates/CRM/UF/Form/Fields.tpl [new file with mode: 0644]
templates/CRM/UF/Form/Preview.tpl
templates/CRM/common/enableDisableApi.tpl
tests/phpunit/CRM/Contact/BAO/QueryStateNameTest.php [new file with mode: 0644]
tests/phpunit/CRM/Contact/BAO/QueryTest.php
tests/phpunit/CRM/Core/BAO/UFFieldTest.php
tests/phpunit/CRM/Core/OptionGroupTest.php
tests/phpunit/CRM/Core/PseudoConstantTest.php
tests/phpunit/CRM/Dedupe/MergerTest.php
tests/phpunit/CRM/Event/Form/Registration/ConfirmTest.php
tests/phpunit/CRM/Utils/Mail/EmailProcessorTest.php [new file with mode: 0644]
tests/phpunit/CRM/Utils/Mail/data/bounces/bounce_no_verp.txt [new file with mode: 0644]
tests/phpunit/CRM/Utils/TypeTest.php
tests/phpunit/CiviTest/CiviUnitTestCase.php
tests/phpunit/api/v3/ACLPermissionTest.php
tests/phpunit/api/v3/ActivityTest.php
tests/phpunit/api/v3/ActivityTypeTest.php
tests/phpunit/api/v3/CaseTest.php
tests/phpunit/api/v3/ContactTest.php
tests/phpunit/api/v3/ContributionPageTest.php
tests/phpunit/api/v3/ContributionTest.php
tests/phpunit/api/v3/EventTest.php
tests/phpunit/api/v3/GroupContactTest.php
tests/phpunit/api/v3/LoggingTest.php
tests/phpunit/api/v3/MailingTest.php
tests/phpunit/api/v3/MembershipTypeTest.php
tests/phpunit/api/v3/OptionValueTest.php
tests/phpunit/api/v3/PaymentProcessorTest.php
tests/phpunit/api/v3/PcpTest.php
tests/phpunit/api/v3/ProfileTest.php
tests/phpunit/api/v3/ReportTemplateTest.php
tests/phpunit/api/v3/TaxContributionPageTest.php
tests/phpunit/api/v3/UFMatchTest.php
tools/drupal/modules/civicrm_webtest/civicrm_webtest.install
xml/schema/Activity/Activity.xml
xml/schema/Contact/Contact.xml
xml/schema/Contribute/Contribution.xml
xml/schema/Event/Participant.xml
xml/schema/Financial/FinancialTrxn.xml
xml/schema/Member/Membership.xml
xml/templates/civicrm_country.tpl
xml/templates/civicrm_state_province.tpl

diff --git a/.editorconfig b/.editorconfig
new file mode 100644 (file)
index 0000000..ce303ed
--- /dev/null
@@ -0,0 +1,14 @@
+# CiviCRM editor configuration normalization
+# @see http://editorconfig.org/
+
+# This is the top-most .editorconfig file; do not search in parent directories.
+root = true
+
+# All files.
+[*]
+end_of_line = LF
+indent_style = space
+indent_size = 2
+charset = utf-8
+trim_trailing_whitespace = true
+insert_final_newline = true
index 5cbc7a0d8c3357a067fdfbc14b419aa6e8a99e6a..26a5ec64c860989627f6facc803209e501a90f37 100644 (file)
@@ -30,7 +30,7 @@
  *
  * Generated from xml/schema/CRM/Activity/Activity.xml
  * DO NOT EDIT.  Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:0dd661946f59d928e2b928c3c3f67d44)
+ * (GenCodeChecksum:e29dddab1cbaae042d11ea6e022f3dd5)
  */
 require_once 'CRM/Core/DAO.php';
 require_once 'CRM/Utils/Type.php';
@@ -309,7 +309,7 @@ class CRM_Activity_DAO_Activity extends CRM_Core_DAO {
           'bao' => 'CRM_Activity_BAO_Activity',
           'html' => array(
             'type' => 'Select Date',
-            'format' => 'activityDateTime',
+            'formatType' => 'activityDateTime',
           ) ,
         ) ,
         'activity_duration' => array(
index 5e0598cb96abc728963f51a711079c713143d4dd..72a72febc180decfde0989cabbe1b581999d6759 100644 (file)
@@ -78,8 +78,8 @@ class CRM_Activity_Form_Task_Batch extends CRM_Activity_Form_Task {
     if (!empty($contactDetails)) {
       foreach ($contactDetails as $key => $value) {
         $assignee = CRM_Activity_BAO_ActivityAssignment::retrieveAssigneeIdsByActivityId($key);
-        foreach ($assignee as $keys => $values) {
-          $assigneeContact[] = CRM_Contact_BAO_Contact::displayname($values);
+        foreach ($assignee as $values) {
+          $assigneeContact[] = CRM_Contact_BAO_Contact::displayName($values);
         }
         $contactDetails[$key]['assignee_display_name'] = !empty($assigneeContact) ? implode(';', $assigneeContact) : NULL;
       }
@@ -95,7 +95,7 @@ class CRM_Activity_Form_Task_Batch extends CRM_Activity_Form_Task {
     $ufGroupId = $this->get('ufGroupId');
 
     if (!$ufGroupId) {
-      CRM_Core_Error::fatal('ufGroupId is missing');
+      throw new CRM_Core_Exception('The profile id is missing');
     }
     $this->_title = ts('Update multiple activities') . ' - ' . CRM_Core_BAO_UFGroup::getTitle($ufGroupId);
     CRM_Utils_System::setTitle($this->_title);
@@ -108,7 +108,7 @@ class CRM_Activity_Form_Task_Batch extends CRM_Activity_Form_Task {
     $suppressFields = FALSE;
     $removehtmlTypes = array('File', 'Autocomplete-Select');
     foreach ($this->_fields as $name => $field) {
-      if ($cfID = CRM_Core_BAO_CustomField::getKeyID($name) &&
+      if (CRM_Core_BAO_CustomField::getKeyID($name) &&
         in_array($this->_fields[$name]['html_type'], $removehtmlTypes)
       ) {
         $suppressFields = TRUE;
@@ -138,7 +138,6 @@ class CRM_Activity_Form_Task_Batch extends CRM_Activity_Form_Task {
 
     $this->assign('profileTitle', $this->_title);
     $this->assign('componentIds', $this->_activityHolderIds);
-    $fileFieldExists = FALSE;
 
     // Load all campaigns.
     if (array_key_exists('activity_campaign_id', $this->_fields)) {
@@ -151,6 +150,10 @@ class CRM_Activity_Form_Task_Batch extends CRM_Activity_Form_Task {
     }
 
     $customFields = CRM_Core_BAO_CustomField::getFields('Activity');
+    // It is possible to have fields that are required in CiviCRM not be required in the
+    // profile. Overriding that here. Perhaps a better approach would be to
+    // make them required in the schema & read that up through getFields functionality.
+    $requiredFields = array('activity_date_time');
 
     foreach ($this->_activityHolderIds as $activityId) {
       $typeId = CRM_Core_DAO::getFieldValue("CRM_Activity_DAO_Activity", $activityId, 'activity_type_id');
@@ -170,6 +173,9 @@ class CRM_Activity_Form_Task_Batch extends CRM_Activity_Form_Task {
         }
         else {
           // Handle non custom fields.
+          if (in_array($field['name'], $requiredFields)) {
+            $field['is_required'] = TRUE;
+          }
           CRM_Core_BAO_UFGroup::buildProfile($this, $field, NULL, $activityId);
         }
       }
@@ -197,7 +203,6 @@ class CRM_Activity_Form_Task_Batch extends CRM_Activity_Form_Task {
 
     $defaults = array();
     foreach ($this->_activityHolderIds as $activityId) {
-      $details[$activityId] = array();
       CRM_Core_BAO_UFGroup::setProfileDefaults(NULL, $this->_fields, $defaults, FALSE, $activityId, 'Activity');
     }
 
@@ -218,10 +223,6 @@ class CRM_Activity_Form_Task_Batch extends CRM_Activity_Form_Task {
         );
         $value['id'] = $key;
 
-        if (!empty($value['activity_date_time'])) {
-          $value['activity_date_time'] = CRM_Utils_Date::processDate($value['activity_date_time'], $value['activity_date_time_time']);
-        }
-
         if (!empty($value['activity_status_id'])) {
           $value['status_id'] = $value['activity_status_id'];
         }
@@ -230,10 +231,6 @@ class CRM_Activity_Form_Task_Batch extends CRM_Activity_Form_Task {
           $value['details'] = $value['activity_details'];
         }
 
-        if (!empty($value['activity_duration'])) {
-          $value['duration'] = $value['activity_duration'];
-        }
-
         if (!empty($value['activity_location'])) {
           $value['location'] = $value['activity_location'];
         }
@@ -242,30 +239,9 @@ class CRM_Activity_Form_Task_Batch extends CRM_Activity_Form_Task {
           $value['subject'] = $value['activity_subject'];
         }
 
-        $query = "
-SELECT a.activity_type_id, ac.contact_id
-FROM   civicrm_activity a
-JOIN   civicrm_activity_contact ac ON ( ac.activity_id = a.id
-AND    ac.record_type_id = %2 )
-WHERE  a.id = %1 ";
-        $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name');
-        $sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts);
-        $params = array(1 => array($key, 'Integer'), 2 => array($sourceID, 'Integer'));
-        $dao = CRM_Core_DAO::executeQuery($query, $params);
-        $dao->fetch();
-
-        // Get Activity Type ID
-        $value['activity_type_id'] = $dao->activity_type_id;
-
-        // Get Conatct ID
-        $value['source_contact_id'] = $dao->contact_id;
-
-        // make call use API 3
-        $value['version'] = 3;
-
-        $activityId = civicrm_api('activity', 'update', $value);
+        $activityId = civicrm_api3('activity', 'create', $value);
 
-        // add custom field values
+        // @todo this would be done by the api call above if the parames were passed through.
         if (!empty($value['custom']) &&
           is_array($value['custom'])
         ) {
index ea2ac9d2880a8054c11d9971ca35140a44b2d00a..4e41cf675b20d3d7c8c884f46636febe494b674d 100644 (file)
@@ -267,7 +267,7 @@ class CRM_Activity_Import_Parser_Activity extends CRM_Activity_Import_Parser {
       $params['source_contact_id'] = $session->get('userID');
     }
 
-    $customFields = CRM_Core_BAO_CustomField::getFields(CRM_Utils_Array::value('contact_type', $params));
+    $customFields = CRM_Core_BAO_CustomField::getFields('Activity');
 
     foreach ($params as $key => $val) {
       if ($customFieldID = CRM_Core_BAO_CustomField::getKeyID($key)) {
index cc3186887fcc6cf3cce791421ca49978d3b14808..8129e3f18466135d86ae47c8b3df74a0c91b9f92 100644 (file)
@@ -91,7 +91,7 @@ class CRM_Admin_Form extends CRM_Core_Form {
    */
   public function setDefaultValues() {
     // Fetch defaults from the db
-    if (isset($this->_id) && empty($this->_values)) {
+    if (!empty($this->_id) && empty($this->_values) && CRM_Utils_Rule::positiveInteger($this->_id)) {
       $this->_values = array();
       $params = array('id' => $this->_id);
       $baoName = $this->_BAOName;
index 37c08225363439d29d2ae95c5f17e11319e0855a..1441b7d7a030335b9898c77af5f00587c74d08c9 100644 (file)
@@ -106,7 +106,7 @@ class CRM_Admin_Form_Navigation extends CRM_Admin_Form {
    * @return array
    */
   public function setDefaultValues() {
-    $defaults = $this->_defaults;
+    $defaults = parent::setDefaultValues();
     if (isset($this->_id)) {
       //Take parent id in object variable to calculate the menu
       //weight if menu parent id changed
index 16df7ca1e2dcddc8c4ffff7dc62c25872e88d230..671c8fe7ed3fb7cccadaf4b84370871568c78e6f 100644 (file)
@@ -203,16 +203,11 @@ class CRM_Admin_Form_Setting extends CRM_Core_Form {
       unset($params['enableComponents']);
     }
 
-    // verify ssl peer option
-    if (isset($params['verifySSL'])) {
-      Civi::settings()->set('verifySSL', $params['verifySSL']);
-      unset($params['verifySSL']);
-    }
-
-    // force secure URLs
-    if (isset($params['enableSSL'])) {
-      Civi::settings()->set('enableSSL', $params['enableSSL']);
-      unset($params['enableSSL']);
+    foreach (array('verifySSL', 'enableSSL') as $name) {
+      if (isset($params[$name])) {
+        Civi::settings()->set($name, $params[$name]);
+        unset($params[$name]);
+      }
     }
     $settings = array_intersect_key($params, $this->_settings);
     $result = civicrm_api('setting', 'create', $settings + array('version' => 3));
index 006aca2de0375cf7bb87234cd695266cd346cb20..5d4a3b2245c56dde82c284edd98dec573d9ce7b9 100644 (file)
@@ -49,6 +49,7 @@ class CRM_Admin_Form_Setting_Search extends CRM_Admin_Form_Setting {
     'includeOrderByClause' => CRM_Core_BAO_Setting::SEARCH_PREFERENCES_NAME,
     'smartGroupCacheTimeout' => CRM_Core_BAO_Setting::SEARCH_PREFERENCES_NAME,
     'defaultSearchProfileID' => CRM_Core_BAO_Setting::SEARCH_PREFERENCES_NAME,
+    'searchPrimaryDetailsOnly' => CRM_Core_BAO_Setting::SEARCH_PREFERENCES_NAME,
   );
 
   /**
index 342d6f357ae4a24716fa40aaa22653d0397c4a50..ab290514d38b8b657ce64717c4c84e39c587e242 100644 (file)
@@ -46,6 +46,7 @@ class CRM_Admin_Form_Setting_UF extends CRM_Admin_Form_Setting {
   public function buildQuickForm() {
     $config = CRM_Core_Config::singleton();
     $this->_uf = $config->userFramework;
+    $this->_settings['syncCMSEmail'] = CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME;
 
     if ($this->_uf == 'WordPress') {
       $this->_settings['wpBasePage'] = CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME;
index 5740851eaa28ade287e360a12b5305d75f499d02..35f5f2aabd567ed603b412846db8899c148f68b5 100644 (file)
@@ -54,14 +54,6 @@ class CRM_Admin_Page_AJAX {
     CRM_Utils_System::civiExit();
   }
 
-  /**
-   * Return menu tree as json data for editing.
-   */
-  public static function getNavigationList() {
-    echo CRM_Core_BAO_Navigation::buildNavigation(TRUE, FALSE);
-    CRM_Utils_System::civiExit();
-  }
-
   /**
    * Process drag/move action for menu tree.
    */
@@ -247,55 +239,6 @@ class CRM_Admin_Page_AJAX {
     CRM_Core_Page_AJAX::returnJsonResponse($ret);
   }
 
-  public static function mergeTagList() {
-    $name = CRM_Utils_Type::escape($_GET['term'], 'String');
-    $fromId = CRM_Utils_Type::escape($_GET['fromId'], 'Integer');
-    $limit = Civi::settings()->get('search_autocomplete_count');
-
-    // build used-for clause to be used in main query
-    $usedForTagA = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Tag', $fromId, 'used_for');
-    $usedForClause = array();
-    if ($usedForTagA) {
-      $usedForTagA = explode(",", $usedForTagA);
-      foreach ($usedForTagA as $key => $value) {
-        $usedForClause[] = "t1.used_for LIKE '%{$value}%'";
-      }
-    }
-    $usedForClause = !empty($usedForClause) ? implode(' OR ', $usedForClause) : '1';
-    sort($usedForTagA);
-
-    // query to list mergable tags
-    $query = "
-SELECT t1.name, t1.id, t1.used_for, t1.color, t2.name as parent
-FROM   civicrm_tag t1
-LEFT JOIN civicrm_tag t2 ON t1.parent_id = t2.id
-WHERE  t1.id <> {$fromId} AND
-       t1.name LIKE '%{$name}%' AND
-       ({$usedForClause})
-LIMIT $limit";
-    $dao = CRM_Core_DAO::executeQuery($query);
-    $result = array();
-
-    while ($dao->fetch()) {
-      $row = array(
-        'id' => $dao->id,
-        'text' => ($dao->parent ? "{$dao->parent} :: " : '') . $dao->name,
-        'color' => isset($dao->color) ? $dao->color : NULL,
-      );
-      // Add warning about used_for types
-      if (!empty($dao->used_for)) {
-        $usedForTagB = explode(',', $dao->used_for);
-        sort($usedForTagB);
-        $usedForDiff = array_diff($usedForTagA, $usedForTagB);
-        if (!empty($usedForDiff)) {
-          $row['warning'] = TRUE;
-        }
-      }
-      $result[] = $row;
-    }
-    CRM_Utils_JSON::output($result);
-  }
-
   /**
    * Get a list of mappings.
    *
@@ -352,24 +295,53 @@ LIMIT $limit";
     ));
   }
 
-  public static function mergeTags() {
-    $tagAId = CRM_Utils_Type::escape($_POST['fromId'], 'Integer');
-    $tagBId = CRM_Utils_Type::escape($_POST['toId'], 'Integer');
-
-    $result = CRM_Core_BAO_EntityTag::mergeTags($tagAId, $tagBId);
+  /**
+   * Outputs one branch in the tag tree
+   *
+   * Used by jstree to incrementally load tags
+   */
+  public static function getTagTree() {
+    $parent = CRM_Utils_Type::escape(CRM_Utils_Array::value('parent_id', $_GET, 0), 'Integer');
+    $result = array();
 
-    if (!empty($result['tagB_used_for'])) {
-      $usedFor = CRM_Core_OptionGroup::values('tag_used_for');
-      foreach ($result['tagB_used_for'] as & $val) {
-        $val = $usedFor[$val];
+    $parentClause = $parent ? "AND tag.parent_id = $parent" : 'AND tag.parent_id IS NULL';
+    $sql = "SELECT tag.*, child.id AS child, COUNT(et.id) as usages
+      FROM civicrm_tag tag
+      LEFT JOIN civicrm_entity_tag et ON et.tag_id = tag.id
+      LEFT JOIN civicrm_tag child ON child.parent_id = tag.id
+      WHERE tag.is_tagset <> 1 $parentClause
+      GROUP BY tag.id
+      ORDER BY tag.name";
+    $dao = CRM_Core_DAO::executeQuery($sql);
+    while ($dao->fetch()) {
+      $style = '';
+      if ($dao->color) {
+        $style = "background-color: {$dao->color}; color: " . CRM_Utils_Color::getContrast($dao->color);
       }
-      $result['tagB_used_for'] = implode(', ', $result['tagB_used_for']);
+      $result[] = array(
+        'id' => $dao->id,
+        'text' => $dao->name,
+        'icon' => FALSE,
+        'li_attr' => array(
+          'title' => ((string) $dao->description) . ($dao->is_reserved ? ' (*' . ts('Reserved') . ')' : ''),
+          'class' => $dao->is_reserved ? 'is-reserved' : '',
+        ),
+        'a_attr' => array(
+          'style' => $style,
+          'class' => 'crm-tag-item',
+        ),
+        'children' => (bool) $dao->child,
+        'data' => array(
+          'description' => (string) $dao->description,
+          'is_selectable' => (bool) $dao->is_selectable,
+          'is_reserved' => (bool) $dao->is_reserved,
+          'used_for' => $dao->used_for ? explode(',', $dao->used_for) : array(),
+          'color' => $dao->color ? $dao->color : '#ffffff',
+          'usages' => (int) $dao->usages,
+        ),
+      );
     }
 
-    $result['message'] = ts('"%1" has been merged with "%2". All records previously tagged "%1" are now tagged "%2".',
-      array(1 => $result['tagA'], 2 => $result['tagB'])
-    );
-
     CRM_Utils_JSON::output($result);
   }
 
index 22561bee50db5848b3b9f1b85f57057a3b275b4e..d22d8be7cd22f40c20af7149176fc6d9953a1f39 100644 (file)
@@ -105,8 +105,8 @@ class CRM_Admin_Page_Navigation extends CRM_Core_Page_Basic {
 
     // Add jstree support
     CRM_Core_Resources::singleton()
-      ->addScriptFile('civicrm', 'packages/jquery/plugins/jstree/jquery.jstree.js', 0, 'html-header', FALSE)
-      ->addStyleFile('civicrm', 'packages/jquery/plugins/jstree/themes/default/style.css', 0, 'html-header');
+      ->addScriptFile('civicrm', 'bower_components/jstree/dist/jstree.min.js', 0, 'html-header')
+      ->addStyleFile('civicrm', 'bower_components/jstree/dist/themes/default/style.min.css');
   }
 
 }
index f5ce3e4e042e3a772c8ff68631aec0a9b19640f7..cd9f06f509d815d639623d4cdfc0a8ed0f611f80 100644 (file)
@@ -648,10 +648,11 @@ class CRM_Batch_BAO_Batch extends CRM_Batch_DAO_Batch {
     }
 
     $from = "civicrm_financial_trxn
-LEFT JOIN civicrm_entity_financial_trxn ON civicrm_entity_financial_trxn.financial_trxn_id = civicrm_financial_trxn.id
+INNER JOIN civicrm_entity_financial_trxn ON civicrm_entity_financial_trxn.financial_trxn_id = civicrm_financial_trxn.id
+INNER JOIN civicrm_contribution ON (civicrm_contribution.id = civicrm_entity_financial_trxn.entity_id
+  AND civicrm_entity_financial_trxn.entity_table='civicrm_contribution')
 LEFT JOIN civicrm_entity_batch ON civicrm_entity_batch.entity_table = 'civicrm_financial_trxn'
 AND civicrm_entity_batch.entity_id = civicrm_financial_trxn.id
-LEFT JOIN civicrm_contribution ON civicrm_contribution.id = civicrm_entity_financial_trxn.entity_id
 LEFT JOIN civicrm_financial_type ON civicrm_financial_type.id = civicrm_contribution.financial_type_id
 LEFT JOIN civicrm_contact contact_a ON contact_a.id = civicrm_contribution.contact_id
 LEFT JOIN civicrm_contribution_soft ON civicrm_contribution_soft.contribution_id = civicrm_contribution.id
@@ -722,24 +723,15 @@ LEFT JOIN civicrm_contribution_soft ON civicrm_contribution_soft.contribution_id
     }
     if (!empty($query->_where[0])) {
       $where = implode(' AND ', $query->_where[0]) .
-        " AND civicrm_entity_batch.batch_id IS NULL
-         AND civicrm_entity_financial_trxn.entity_table = 'civicrm_contribution'";
+        " AND civicrm_entity_batch.batch_id IS NULL ";
       $where = str_replace('civicrm_contribution.payment_instrument_id', 'civicrm_financial_trxn.payment_instrument_id', $where);
-      $searchValue = TRUE;
     }
     else {
-      $searchValue = FALSE;
-    }
-
-    if (!$searchValue) {
       if (!$notPresent) {
-        $where = " ( civicrm_entity_batch.batch_id = {$entityID}
-        AND civicrm_entity_batch.entity_table = 'civicrm_financial_trxn'
-        AND civicrm_entity_financial_trxn.entity_table = 'civicrm_contribution') ";
+        $where = " civicrm_entity_batch.batch_id = {$entityID} ";
       }
       else {
-        $where = " ( civicrm_entity_batch.batch_id IS NULL
-        AND civicrm_entity_financial_trxn.entity_table = 'civicrm_contribution')";
+        $where = " civicrm_entity_batch.batch_id IS NULL ";
       }
     }
 
index dd61256132df7041de1b6823cad11d4b318decc6..60e967723ddb5b7caa45597acd3e1f25454fcbfc 100644 (file)
@@ -382,9 +382,7 @@ class CRM_Batch_Form_Entry extends CRM_Core_Form {
     if ($this->_action & CRM_Core_Action::ADD) {
       list($currentDate, $currentTime) = CRM_Utils_Date::setDateDefaults(NULL, 'activityDateTime');
 
-      //get all status
-      $allStatus = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
-      $completeStatus = array_search('Completed', $allStatus);
+      $completeStatus = CRM_Contribute_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Completed');
       $specialFields = array(
         'join_date' => $currentDate,
         'receive_date' => $currentDate,
index e1f299cc63019348822013852926e8200d7904d5..7f834eb93fab5ffe969a5e087cd8c8853433c33d 100644 (file)
@@ -2517,6 +2517,7 @@ AND       civicrm_openid.is_primary = 1";
         ),
       );
 
+      // @todo This can be figured out from metadata & we can avoid the uncached query.
       CRM_Core_OptionGroup::lookupValues($temp, $names, FALSE);
 
       $values['preferred_communication_method'] = $preffComm;
@@ -2540,14 +2541,6 @@ AND       civicrm_openid.is_primary = 1";
           $values['age']['y'] = CRM_Utils_Array::value('years', $age);
           $values['age']['m'] = CRM_Utils_Array::value('months', $age);
         }
-
-        list($values['birth_date']) = CRM_Utils_Date::setDateDefaults($contact->birth_date, 'birth');
-        $values['birth_date_display'] = $contact->birth_date;
-      }
-
-      if ($contact->deceased_date) {
-        list($values['deceased_date']) = CRM_Utils_Date::setDateDefaults($contact->deceased_date, 'birth');
-        $values['deceased_date_display'] = $contact->deceased_date;
       }
 
       $contact->contact_id = $contact->id;
index 3948de9dd8b9625f67096a6133370fad596f93eb..a37e40e7f8bc9a200a2c2c5a08cf79f313560ad3 100644 (file)
@@ -170,7 +170,7 @@ WHERE contact_id IN ({$contact_id_list})
     $tables = array();
     $whereTables = array();
 
-    $permission = CRM_ACL_API::whereClause($type, $tables, $whereTables);
+    $permission = CRM_ACL_API::whereClause($type, $tables, $whereTables, NULL, FALSE, FALSE, TRUE);
     $from = CRM_Contact_BAO_Query::fromClause($whereTables);
 
     $query = "
index fe781a5cc35baf0442c8b73bb6f51b93e38f9ddd..aab9bc9cd9f7d7102b4d1385c8826d6ed3a8bd7e 100644 (file)
@@ -900,7 +900,7 @@ class CRM_Contact_BAO_Group extends CRM_Contact_DAO_Group {
     $visibility = CRM_Core_SelectValues::ufVisibility();
 
     while ($object->fetch()) {
-      $permission = CRM_Contact_BAO_Group::checkPermission($object->id, $object->title);
+      $permission = CRM_Contact_BAO_Group::checkPermission($object->id, TRUE);
       //@todo CRM-12209 introduced an ACL check in the whereClause function
       // it may be that this checking is now obsolete - or that what remains
       // should be removed to the whereClause (which is also accessed by getCount)
index 7999d1e841f4157e08c2ee326c40def2c525eede..24c6c046a2549a11550e0602bad6c5800365d6a4 100644 (file)
@@ -514,7 +514,7 @@ class CRM_Contact_BAO_Query {
       CRM_Financial_BAO_FinancialType::buildPermissionedClause($this->_whereClause, $component);
     }
 
-    $this->_fromClause = self::fromClause($this->_tables, NULL, NULL, $this->_primaryLocation, $this->_mode);
+    $this->_fromClause = self::fromClause($this->_tables, NULL, NULL, $this->_primaryLocation, $this->_mode, $apiEntity);
     $this->_simpleFromClause = self::fromClause($this->_whereTables, NULL, NULL, $this->_primaryLocation, $this->_mode);
 
     $this->openedSearchPanes(TRUE);
@@ -653,8 +653,7 @@ class CRM_Contact_BAO_Query {
       if (
         (substr($name, 0, 12) == 'participant_') ||
         (substr($name, 0, 7) == 'pledge_') ||
-        (substr($name, 0, 5) == 'case_') ||
-        (substr($name, 0, 8) == 'payment_')
+        (substr($name, 0, 5) == 'case_')
       ) {
         continue;
       }
@@ -698,15 +697,12 @@ class CRM_Contact_BAO_Query {
         }
       }
 
-      if (in_array($name, array('prefix_id', 'suffix_id', 'gender_id', 'communication_style_id'))) {
-        if (CRM_Utils_Array::value($field['pseudoconstant']['optionGroupName'], $this->_returnProperties)) {
-          $makeException = TRUE;
-        }
-      }
-
       $cfID = CRM_Core_BAO_CustomField::getKeyID($name);
-      if (!empty($this->_paramLookup[$name]) || !empty($this->_returnProperties[$name]) ||
-        $makeException
+      if (
+        !empty($this->_paramLookup[$name])
+        || !empty($this->_returnProperties[$name])
+        || $this->pseudoConstantNameIsInReturnProperties($field)
+        || $makeException
       ) {
         if ($cfID) {
           // add to cfIDs array if not present
@@ -826,42 +822,12 @@ class CRM_Contact_BAO_Query {
                 $this->_element['provider_id'] = 1;
               }
 
-              if ($tName == 'contact') {
+              if ($tName == 'contact' && $fieldName == 'organization_name') {
                 // special case, when current employer is set for Individual contact
-                if ($fieldName == 'organization_name') {
-                  $this->_select[$name] = "IF ( contact_a.contact_type = 'Individual', NULL, contact_a.organization_name ) as organization_name";
-                }
-                elseif ($fieldName != 'id') {
-                  if ($fieldName == 'prefix_id') {
-                    $this->_pseudoConstantsSelect['individual_prefix'] = array(
-                      'pseudoField' => 'prefix_id',
-                      'idCol' => "prefix_id",
-                      'bao' => 'CRM_Contact_BAO_Contact',
-                    );
-                  }
-                  if ($fieldName == 'suffix_id') {
-                    $this->_pseudoConstantsSelect['individual_suffix'] = array(
-                      'pseudoField' => 'suffix_id',
-                      'idCol' => "suffix_id",
-                      'bao' => 'CRM_Contact_BAO_Contact',
-                    );
-                  }
-                  if ($fieldName == 'gender_id') {
-                    $this->_pseudoConstantsSelect['gender'] = array(
-                      'pseudoField' => 'gender_id',
-                      'idCol' => "gender_id",
-                      'bao' => 'CRM_Contact_BAO_Contact',
-                    );
-                  }
-                  if ($name == 'communication_style_id') {
-                    $this->_pseudoConstantsSelect['communication_style'] = array(
-                      'pseudoField' => 'communication_style_id',
-                      'idCol' => "communication_style_id",
-                      'bao' => 'CRM_Contact_BAO_Contact',
-                    );
-                  }
-                  $this->_select[$name] = "contact_a.{$fieldName}  as `$name`";
-                }
+                $this->_select[$name] = "IF ( contact_a.contact_type = 'Individual', NULL, contact_a.organization_name ) as organization_name";
+              }
+              elseif ($tName == 'contact' && $fieldName === 'id') {
+                // Handled elsewhere, explicitly ignore. Possibly for all tables...
               }
               elseif (in_array($tName, array('country', 'county'))) {
                 $this->_pseudoConstantsSelect[$name]['select'] = "{$field['where']} as `$name`";
@@ -877,7 +843,22 @@ class CRM_Contact_BAO_Query {
                 }
               }
               else {
-                $this->_select[$name] = "{$field['where']} as `$name`";
+                // 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)) {
+                  $pseudoFieldName = $field['pseudoconstant']['optionGroupName'];
+                  $this->_pseudoConstantsSelect[$pseudoFieldName] = array(
+                    'pseudoField' => $field['name'],
+                    'idCol' => $field['name'],
+                    'field_name' => $field['name'],
+                    'bao' => $field['bao'],
+                    'pseudoconstant' => $field['pseudoconstant'],
+                  );
+                  $this->_tables[$tableName] = 1;
+                  $this->_element[$pseudoFieldName] = 1;
+                }
+                $this->_select[$name] = str_replace('civicrm_contact.', 'contact_a.', "{$field['where']} as `$name`");
               }
               if (!in_array($tName, array('state_province', 'country', 'county'))) {
                 $this->_element[$name] = 1;
@@ -2528,11 +2509,12 @@ class CRM_Contact_BAO_Query {
    *
    * @param bool $primaryLocation
    * @param int $mode
+   * @param string|NULL $apiEntity
    *
    * @return string
    *   the from clause
    */
-  public static function fromClause(&$tables, $inner = NULL, $right = NULL, $primaryLocation = TRUE, $mode = 1) {
+  public static function fromClause(&$tables, $inner = NULL, $right = NULL, $primaryLocation = TRUE, $mode = 1, $apiEntity = NULL) {
 
     $from = ' FROM civicrm_contact contact_a';
     if (empty($tables)) {
@@ -2623,27 +2605,29 @@ class CRM_Contact_BAO_Query {
         }
         continue;
       }
+      $searchPrimary = '';
+      if (Civi::settings()->get('searchPrimaryDetailsOnly') || $apiEntity) {
+        $searchPrimary = "AND {$name}.is_primary = 1";
+      }
       switch ($name) {
         case 'civicrm_address':
-          if ($primaryLocation) {
-            $from .= " $side JOIN civicrm_address ON ( contact_a.id = civicrm_address.contact_id AND civicrm_address.is_primary = 1 )";
-          }
-          else {
-            //CRM-14263 further handling of address joins further down...
-            $from .= " $side JOIN civicrm_address ON ( contact_a.id = civicrm_address.contact_id ) ";
+          //CRM-14263 further handling of address joins further down...
+          if (!$primaryLocation) {
+            $searchPrimary = '';
           }
+          $from .= " $side JOIN civicrm_address ON ( contact_a.id = civicrm_address.contact_id {$searchPrimary} )";
           continue;
 
         case 'civicrm_phone':
-          $from .= " $side JOIN civicrm_phone ON (contact_a.id = civicrm_phone.contact_id AND civicrm_phone.is_primary = 1) ";
+          $from .= " $side JOIN civicrm_phone ON (contact_a.id = civicrm_phone.contact_id {$searchPrimary}) ";
           continue;
 
         case 'civicrm_email':
-          $from .= " $side JOIN civicrm_email ON (contact_a.id = civicrm_email.contact_id AND civicrm_email.is_primary = 1) ";
+          $from .= " $side JOIN civicrm_email ON (contact_a.id = civicrm_email.contact_id {$searchPrimary})";
           continue;
 
         case 'civicrm_im':
-          $from .= " $side JOIN civicrm_im ON (contact_a.id = civicrm_im.contact_id AND civicrm_im.is_primary = 1) ";
+          $from .= " $side JOIN civicrm_im ON (contact_a.id = civicrm_im.contact_id {$searchPrimary}) ";
           continue;
 
         case 'im_provider':
@@ -2653,7 +2637,7 @@ class CRM_Contact_BAO_Query {
           continue;
 
         case 'civicrm_openid':
-          $from .= " $side JOIN civicrm_openid ON ( civicrm_openid.contact_id = contact_a.id AND civicrm_openid.is_primary = 1 )";
+          $from .= " $side JOIN civicrm_openid ON ( civicrm_openid.contact_id = contact_a.id {$searchPrimary} )";
           continue;
 
         case 'civicrm_worldregion':
@@ -2966,7 +2950,6 @@ class CRM_Contact_BAO_Query {
     else {
       $statii[] = "'Added'";
     }
-
     $groupClause = array();
     if (count($regularGroupIDs) || empty($value)) {
       $groupIds = implode(',', (array) $regularGroupIDs);
@@ -4401,7 +4384,7 @@ civicrm_relationship.is_permission_a_b = 0
         return array($noRows, NULL);
       }
       $val = $query->store($dao);
-      $convertedVals = $query->convertToPseudoNames($dao, TRUE);
+      $convertedVals = $query->convertToPseudoNames($dao, TRUE, TRUE);
 
       if (!empty($convertedVals)) {
         $val = array_replace_recursive($val, $convertedVals);
@@ -5830,19 +5813,47 @@ AND   displayRelType.is_active = 1
         $val = $dao->{$value['idCol']};
         if ($key == 'groups') {
           $dao->groups = $this->convertGroupIDStringToLabelString($dao, $val);
-          return;
+          continue;
         }
 
         if (CRM_Utils_System::isNull($val)) {
           $dao->$key = NULL;
         }
+        elseif (!empty($value['pseudoconstant'])) {
+          // If pseudoconstant is set that is kind of defacto for 'we have a bit more info about this'
+          // and we can use the metadata to figure it out.
+          // ideally this bit of IF will absorb & replace all the rest in time as we move to
+          // more metadata based choices.
+          if (strpos($val, CRM_Core_DAO::VALUE_SEPARATOR) !== FALSE) {
+            $dbValues = explode(CRM_Core_DAO::VALUE_SEPARATOR, trim($val, CRM_Core_DAO::VALUE_SEPARATOR));
+            foreach ($dbValues as $pseudoValue) {
+              $convertedValues[] = CRM_Core_PseudoConstant::getLabel($value['bao'], $value['idCol'], $pseudoValue);
+            }
+
+            $dao->$key = ($usedForAPI) ? $convertedValues : implode(', ', $convertedValues);
+            $realFieldName = CRM_Utils_Array::value('field_name', $this->_pseudoConstantsSelect[$key]);
+            if ($usedForAPI && $realFieldName) {
+              // normally we would see 2 fields returned for pseudoConstants. An exception is
+              // preferred_communication_method where there is no id-variant.
+              // For the api we prioritise getting the real data returned.
+              // over the resolved version
+              $dao->$realFieldName = $dbValues;
+            }
+
+          }
+          else {
+            // This is basically the same as the default but since we have the bao we can use
+            // a cached function.
+            $dao->$key = CRM_Core_PseudoConstant::getLabel($value['bao'], $value['idCol'], $val);
+          }
+        }
         elseif ($baoName = CRM_Utils_Array::value('bao', $value, NULL)) {
           //preserve id value
           $idColumn = "{$key}_id";
           $dao->$idColumn = $val;
 
           if ($key == 'state_province_name') {
-            $dao->{$value['pseudoField']} = $dao->$key = CRM_Core_PseudoConstant::stateProvinceAbbreviation($val);
+            $dao->{$value['pseudoField']} = $dao->$key = CRM_Core_PseudoConstant::stateProvince($val);
           }
           else {
             $dao->{$value['pseudoField']} = $dao->$key = CRM_Core_PseudoConstant::getLabel($baoName, $value['pseudoField'], $val);
@@ -5851,8 +5862,7 @@ AND   displayRelType.is_active = 1
         elseif ($value['pseudoField'] == 'state_province_abbreviation') {
           $dao->$key = CRM_Core_PseudoConstant::stateProvinceAbbreviation($val);
         }
-        // FIX ME: we should potentially move this to component Query and write a wrapper function that
-        // handles pseudoconstant fixes for all component
+        // @todo handle this in the section above for pseudoconstants.
         elseif (in_array($value['pseudoField'], array('participant_role_id', 'participant_role'))) {
           // @todo define bao on this & merge into the above condition.
           $viewValues = explode(CRM_Core_DAO::VALUE_SEPARATOR, $val);
@@ -5890,6 +5900,21 @@ AND   displayRelType.is_active = 1
         }
       }
     }
+    if (!$usedForAPI) {
+      foreach (array(
+         'gender_id' => 'gender',
+          'prefix_id' => 'individual_prefix',
+          'suffix_id' => 'individual_suffix',
+          'communication_style_id' => 'communication_style',
+        ) as $realField => $labelField) {
+        // This is a temporary routine for handling these fields while
+        // we figure out how to handled them based on metadata in
+        /// export and search builder. CRM-19815, CRM-19830.
+        if (isset($dao->$realField) && is_numeric($dao->$realField) && isset($dao->$labelField)) {
+          $dao->$realField = $dao->$labelField;
+        }
+      }
+    }
     return $values;
   }
 
@@ -6180,10 +6205,17 @@ AND   displayRelType.is_active = 1
     $order = trim(str_replace('ORDER BY', '', $order));
 
     // hack for order clause
-    $fieldOrder = explode(' ', $order);
-    $field = $fieldOrder[0];
+    if (!empty($orderByArray)) {
+      $order = implode(', ', $orderByArray);
+    }
+    else {
+      $orderByArray = explode(',', $order);
+    }
+    foreach ($orderByArray as $orderByClause) {
+      $orderByClauseParts = explode(' ', trim($orderByClause));
+      $field = $orderByClauseParts[0];
+      $direction = isset($orderByClauseParts[1]) ? $orderByClauseParts[1] : 'asc';
 
-    if ($field) {
       switch ($field) {
         case 'city':
         case 'postal_code':
@@ -6206,25 +6238,47 @@ AND   displayRelType.is_active = 1
           break;
 
         default:
-          //CRM-12565 add "`" around $field if it is a pseudo constant
-          foreach ($this->_pseudoConstantsSelect as $key => $value) {
-            if (!empty($value['element']) && $value['element'] == $field) {
+          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(
+                'orderColumn' => 'label',
+              ));
+              $order = str_replace("$field $direction", "field({$pseudoConstantMetadata['pseudoField']}," . implode(',', array_keys($sortedOptions)) . ") $direction", $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.
+            if (!empty($pseudoConstantMetadata['element']) && $pseudoConstantMetadata['element'] == $field) {
               $order = str_replace($field, "`{$field}`", $order);
             }
           }
       }
-      $this->_fromClause = self::fromClause($this->_tables, NULL, NULL, $this->_primaryLocation, $this->_mode);
-      $this->_simpleFromClause = self::fromClause($this->_whereTables, NULL, NULL, $this->_primaryLocation, $this->_mode);
     }
 
+    $this->_fromClause = self::fromClause($this->_tables, NULL, NULL, $this->_primaryLocation, $this->_mode);
+    $this->_simpleFromClause = self::fromClause($this->_whereTables, NULL, NULL, $this->_primaryLocation, $this->_mode);
+
     // The above code relies on crazy brittle string manipulation of a peculiarly-encoded ORDER BY
     // clause. But this magic helper which forgivingly reescapes ORDER BY.
     // Note: $sortByChar implies that $order was hard-coded/trusted, so it can do funky things.
-    if ($order && !$sortByChar) {
+    if ($sortByChar) {
+      return array(' ORDER BY ' . $order, $additionalFromClause);
+    }
+    if ($order) {
       $order = CRM_Utils_Type::escape($order, 'MysqlOrderBy');
       return array(' ORDER BY ' . $order, $additionalFromClause);
     }
-    return array(' ORDER BY ' . $order, $additionalFromClause);
   }
 
   /**
@@ -6274,4 +6328,29 @@ AND   displayRelType.is_active = 1
     ));
   }
 
+  /**
+   * Has the pseudoconstant of the field been requested.
+   *
+   * For example if the field is payment_instrument_id then it
+   * has been requested if either payment_instrument_id or payment_instrument
+   * have been requested. Payment_instrument is the option groun name field value.
+   *
+   * @param array $field
+   *
+   * @return bool
+   */
+  private function pseudoConstantNameIsInReturnProperties($field) {
+    if (!isset($field['pseudoconstant']['optionGroupName'])) {
+      return FALSE;
+    }
+
+    if (CRM_Utils_Array::value($field['pseudoconstant']['optionGroupName'], $this->_returnProperties)) {
+      return TRUE;
+    }
+    if (CRM_Utils_Array::value($field['name'], $this->_returnProperties)) {
+      return TRUE;
+    }
+    return FALSE;
+  }
+
 }
index dd66d1e92464143ffc6b9a6c67cdef8a57f44b92..0f375714fc7d0bb112e78e28912cac960958530a 100644 (file)
@@ -30,7 +30,7 @@
  *
  * Generated from xml/schema/CRM/Contact/Contact.xml
  * DO NOT EDIT.  Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:0c8e687501dbd8f44354ee5f5cdf9b52)
+ * (GenCodeChecksum:b16421c318c1224c65e18a9e2aa15a5e)
  */
 require_once 'CRM/Core/DAO.php';
 require_once 'CRM/Utils/Type.php';
@@ -1114,7 +1114,7 @@ class CRM_Contact_DAO_Contact extends CRM_Core_DAO {
           'bao' => 'CRM_Contact_BAO_Contact',
           'html' => array(
             'type' => 'Select Date',
-            'format' => 'birth',
+            'formatType' => 'birth',
           ) ,
         ) ,
         'is_deceased' => array(
@@ -1148,7 +1148,7 @@ class CRM_Contact_DAO_Contact extends CRM_Core_DAO {
           'bao' => 'CRM_Contact_BAO_Contact',
           'html' => array(
             'type' => 'Select Date',
-            'format' => 'birth',
+            'formatType' => 'birth',
           ) ,
         ) ,
         'household_name' => array(
index d01495d597a31ad5913e09ff11ba5847de8e7528..e96acc7e2246ad780c26a1d2b3ab7a68f2d0beb7 100644 (file)
@@ -45,10 +45,10 @@ class CRM_Contact_Form_Edit_Demographics {
   public static function buildQuickForm(&$form) {
     $form->addField('gender_id', array('entity' => 'contact', 'type' => 'Radio', 'allowClear' => TRUE));
 
-    $form->addField('birth_date', array('entity' => 'contact', 'formatType' => 'birth'));
+    $form->addField('birth_date', array('entity' => 'contact'), FALSE, FALSE);
 
     $form->addField('is_deceased', array('entity' => 'contact', 'label' => ts('Contact is Deceased'), 'onclick' => "showDeceasedDate()"));
-    $form->addField('deceased_date', array('entity' => 'contact', 'formatType' => 'birth'));
+    $form->addField('deceased_date', array('entity' => 'contact'), FALSE, FALSE);
   }
 
   /**
index ad9a8e6563dc512b23e59401e7a859769f30d862..a026f35d328d5977c0b9c36892a06ff679adc16d 100644 (file)
@@ -64,197 +64,166 @@ class CRM_Contact_Form_Merge extends CRM_Core_Form {
   var $_qfZeroBug = 'e8cddb72-a257-11dc-b9cc-0016d3330ee9';
 
   public function preProcess() {
-    if (!CRM_Core_Permission::check('merge duplicate contacts')) {
-      CRM_Core_Error::fatal(ts('You do not have access to this page'));
-    }
+    try {
 
-    $cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
-    $oid = CRM_Utils_Request::retrieve('oid', 'Positive', $this, TRUE);
-    $flip = CRM_Utils_Request::retrieve('flip', 'Positive', $this, FALSE);
+      $this->_cid = CRM_Utils_Request::retrieve('cid', 'Positive', $this, TRUE);
+      $this->_oid = CRM_Utils_Request::retrieve('oid', 'Positive', $this, TRUE);
+      $flip = CRM_Utils_Request::retrieve('flip', 'Positive', $this, FALSE);
 
-    $this->_rgid = CRM_Utils_Request::retrieve('rgid', 'Positive', $this, FALSE);
-    $this->_gid = $gid = CRM_Utils_Request::retrieve('gid', 'Positive', $this, FALSE);
-    $this->_mergeId = CRM_Utils_Request::retrieve('mergeId', 'Positive', $this, FALSE);
-    $this->limit = CRM_Utils_Request::retrieve('limit', 'Positive', $this, FALSE);
-    $urlParams = "reset=1&rgid={$this->_rgid}&gid={$this->_gid}&limit=" . $this->limit;
+      $this->_rgid = CRM_Utils_Request::retrieve('rgid', 'Positive', $this, FALSE);
+      $this->_gid = $gid = CRM_Utils_Request::retrieve('gid', 'Positive', $this, FALSE);
+      $this->_mergeId = CRM_Utils_Request::retrieve('mergeId', 'Positive', $this, FALSE);
+      $this->limit = CRM_Utils_Request::retrieve('limit', 'Positive', $this, FALSE);
+      $urlParams = "reset=1&rgid={$this->_rgid}&gid={$this->_gid}&limit=" . $this->limit;
 
-    // Sanity check
-    if ($cid == $oid) {
-      CRM_Core_Error::statusBounce(ts('Cannot merge a contact with itself.'));
-    }
+      $this->bounceIfInvalid($this->_cid, $this->_oid);
 
-    if (!CRM_Dedupe_BAO_Rule::validateContacts($cid, $oid)) {
-      CRM_Core_Error::statusBounce(ts('The selected pair of contacts are marked as non duplicates. If these records should be merged, you can remove this exception on the <a href="%1">Dedupe Exceptions</a> page.', array(1 => CRM_Utils_System::url('civicrm/dedupe/exception', 'reset=1'))));
-    }
-    $this->_contactType = civicrm_api3('Contact', 'getvalue', array('id' => $cid, 'return' => 'contact_type'));
-    $isFromDedupeScreen = TRUE;
-    if (!$this->_rgid) {
-      $isFromDedupeScreen = FALSE;
-      $this->_rgid = civicrm_api3('RuleGroup', 'getvalue', array(
-        'contact_type' => $this->_contactType,
-        'used' => 'Supervised',
-        'return' => 'id',
+      $this->_contactType = civicrm_api3('Contact', 'getvalue', array(
+        'id' => $this->_cid,
+        'return' => 'contact_type',
       ));
-    }
 
-    $cacheKey = CRM_Dedupe_Merger::getMergeCacheKeyString($this->_rgid, $gid);
+      $browseUrl = CRM_Utils_System::url('civicrm/contact/dedupefind', $urlParams . '&action=browse');
 
-    $join = CRM_Dedupe_Merger::getJoinOnDedupeTable();
-    $where = "de.id IS NULL";
+      if (!$this->_rgid) {
+        // Unset browse URL as we have come from the search screen.
+        $browseUrl = '';
+        $this->_rgid = civicrm_api3('RuleGroup', 'getvalue', array(
+          'contact_type' => $this->_contactType,
+          'used' => 'Supervised',
+          'return' => 'id',
+        ));
+      }
+      $this->assign('browseUrl', $browseUrl);
+      if ($browseUrl) {
+        CRM_Core_Session::singleton()->pushUserContext($browseUrl);
+      }
 
-    $pos = CRM_Core_BAO_PrevNextCache::getPositions($cacheKey, $cid, $oid, $this->_mergeId, $join, $where, $flip);
+      $cacheKey = CRM_Dedupe_Merger::getMergeCacheKeyString($this->_rgid, $gid);
 
-    // Block access if user does not have EDIT permissions for both contacts.
-    if (!(CRM_Contact_BAO_Contact_Permission::allow($cid, CRM_Core_Permission::EDIT) &&
-      CRM_Contact_BAO_Contact_Permission::allow($oid, CRM_Core_Permission::EDIT)
-    )
-    ) {
-      CRM_Utils_System::permissionDenied();
-    }
+      $join = CRM_Dedupe_Merger::getJoinOnDedupeTable();
+      $where = "de.id IS NULL";
 
-    // get user info of main contact.
-    $config = CRM_Core_Config::singleton();
-    $config->doNotResetCache = 1;
-
-    $viewUser = CRM_Core_Permission::check('access user profiles');
-    $mainUfId = CRM_Core_BAO_UFMatch::getUFId($cid);
-    $mainUser = NULL;
-    if ($mainUfId) {
-      // d6 compatible
-      if ($config->userSystem->is_drupal == '1') {
-        $mainUser = user_load($mainUfId);
-      }
-      elseif ($config->userFramework == 'Joomla') {
-        $mainUser = JFactory::getUser($mainUfId);
-      }
+      $pos = CRM_Core_BAO_PrevNextCache::getPositions($cacheKey, $this->_cid, $this->_oid, $this->_mergeId, $join, $where, $flip);
 
-      $this->assign('mainUfId', $mainUfId);
-      $this->assign('mainUfName', $mainUser ? $mainUser->name : NULL);
-    }
+      // get user info of main contact.
+      $config = CRM_Core_Config::singleton();
+      $config->doNotResetCache = 1;
 
-    $flipUrl = CRM_Utils_System::url('civicrm/contact/merge',
-      "reset=1&action=update&cid={$oid}&oid={$cid}&rgid={$this->_rgid}&gid={$gid}"
-    );
-    if (!$flip) {
-      $flipUrl .= '&flip=1';
-    }
-    $this->assign('flip', $flipUrl);
-
-    $this->prev = $this->next = NULL;
-    foreach (array(
-               'prev',
-               'next',
-             ) as $position) {
-      if (!empty($pos[$position])) {
-        if ($pos[$position]['id1'] && $pos[$position]['id2']) {
-          $urlParams .= "&cid={$pos[$position]['id1']}&oid={$pos[$position]['id2']}&mergeId={$pos[$position]['mergeId']}&action=update";
-          $this->$position = CRM_Utils_System::url('civicrm/contact/merge', $urlParams);
-          $this->assign($position, $this->$position);
+      $mainUfId = CRM_Core_BAO_UFMatch::getUFId($this->_cid);
+      $mainUser = NULL;
+      if ($mainUfId) {
+        // d6 compatible
+        if ($config->userSystem->is_drupal == '1') {
+          $mainUser = user_load($mainUfId);
+        }
+        elseif ($config->userFramework == 'Joomla') {
+          $mainUser = JFactory::getUser($mainUfId);
         }
-      }
-    }
 
-    // get user info of other contact.
-    $otherUfId = CRM_Core_BAO_UFMatch::getUFId($oid);
-    $otherUser = NULL;
+        $this->assign('mainUfId', $mainUfId);
+        $this->assign('mainUfName', $mainUser ? $mainUser->name : NULL);
+      }
 
-    if ($otherUfId) {
-      // d6 compatible
-      if ($config->userSystem->is_drupal == '1') {
-        $otherUser = user_load($otherUfId);
+      $flipUrl = CRM_Utils_System::url('civicrm/contact/merge',
+        "reset=1&action=update&cid={$this->_oid}&oid={$this->_cid}&rgid={$this->_rgid}&gid={$gid}"
+      );
+      if (!$flip) {
+        $flipUrl .= '&flip=1';
       }
-      elseif ($config->userFramework == 'Joomla') {
-        $otherUser = JFactory::getUser($otherUfId);
+      $this->assign('flip', $flipUrl);
+
+      $this->prev = $this->next = NULL;
+      foreach (array(
+                 'prev',
+                 'next',
+               ) as $position) {
+        if (!empty($pos[$position])) {
+          if ($pos[$position]['id1'] && $pos[$position]['id2']) {
+            $urlParams .= "&cid={$pos[$position]['id1']}&oid={$pos[$position]['id2']}&mergeId={$pos[$position]['mergeId']}&action=update";
+            $this->$position = CRM_Utils_System::url('civicrm/contact/merge', $urlParams);
+            $this->assign($position, $this->$position);
+          }
+        }
       }
 
-      $this->assign('otherUfId', $otherUfId);
-      $this->assign('otherUfName', $otherUser ? $otherUser->name : NULL);
-    }
-
-    $cmsUser = ($mainUfId && $otherUfId) ? TRUE : FALSE;
-    $this->assign('user', $cmsUser);
-
-    $session = CRM_Core_Session::singleton();
-
-    // context fixed.
-    if ($isFromDedupeScreen) {
-      $browseUrl = CRM_Utils_System::url('civicrm/contact/dedupefind', $urlParams . '&action=browse');
-      $session->pushUserContext($browseUrl);
-    }
-    $this->assign('browseUrl', empty($browseUrl) ? '' : $browseUrl);
+      // get user info of other contact.
+      $otherUfId = CRM_Core_BAO_UFMatch::getUFId($this->_oid);
+      $otherUser = NULL;
 
-    // ensure that oid is not the current user, if so refuse to do the merge
-    if ($session->get('userID') == $oid) {
-      $display_name = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $oid, 'display_name');
-      $message = ts('The contact record which is linked to the currently logged in user account - \'%1\' - cannot be deleted.',
-        array(1 => $display_name)
-      );
-      CRM_Core_Error::statusBounce($message);
-    }
+      if ($otherUfId) {
+        // d6 compatible
+        if ($config->userSystem->is_drupal == '1') {
+          $otherUser = user_load($otherUfId);
+        }
+        elseif ($config->userFramework == 'Joomla') {
+          $otherUser = JFactory::getUser($otherUfId);
+        }
 
-    $rowsElementsAndInfo = CRM_Dedupe_Merger::getRowsElementsAndInfo($cid, $oid);
-    $main = $this->_mainDetails = &$rowsElementsAndInfo['main_details'];
-    $other = $this->_otherDetails = &$rowsElementsAndInfo['other_details'];
+        $this->assign('otherUfId', $otherUfId);
+        $this->assign('otherUfName', $otherUser ? $otherUser->name : NULL);
+      }
 
-    if ($main['contact_id'] != $cid) {
-      CRM_Core_Error::fatal(ts('The main contact record does not exist'));
-    }
+      $cmsUser = ($mainUfId && $otherUfId) ? TRUE : FALSE;
+      $this->assign('user', $cmsUser);
+
+      $rowsElementsAndInfo = CRM_Dedupe_Merger::getRowsElementsAndInfo($this->_cid, $this->_oid);
+      $main = $this->_mainDetails = $rowsElementsAndInfo['main_details'];
+      $other = $this->_otherDetails = $rowsElementsAndInfo['other_details'];
+
+      $this->assign('contact_type', $main['contact_type']);
+      $this->assign('main_name', $main['display_name']);
+      $this->assign('other_name', $other['display_name']);
+      $this->assign('main_cid', $main['contact_id']);
+      $this->assign('other_cid', $other['contact_id']);
+      $this->assign('rgid', $this->_rgid);
+
+      $this->addElement('checkbox', 'toggleSelect', NULL, NULL, array('class' => 'select-rows'));
+
+      $this->assign('mainLocBlock', json_encode($rowsElementsAndInfo['main_details']['location_blocks']));
+      $this->assign('locationBlockInfo', json_encode(CRM_Dedupe_Merger::getLocationBlockInfo()));
+      $this->assign('rows', $rowsElementsAndInfo['rows']);
+
+      // add elements
+      foreach ($rowsElementsAndInfo['elements'] as $element) {
+        // We could push this down to the getRowsElementsAndInfo function but it's
+        // already so overloaded - let's start moving towards doing form-things
+        // on the form.
+        if (substr($element[1], 0, 13) === 'move_location') {
+          $element[4] = array_merge(
+            (array) CRM_Utils_Array::value(4, $element, array()),
+            array(
+              'data-location' => substr($element[1], 14),
+              'data-is_location' => TRUE,
+            ));
+        }
+        if (substr($element[1], 0, 15) === 'location_blocks') {
+          // @todo We could add some data elements here to make jquery manipulation more straight-forward
+          // @todo consider enabling if it is an add & defaulting to true.
+          $element[4] = array_merge((array) CRM_Utils_Array::value(4, $element, array()), array('disabled' => TRUE));
+        }
+        $this->addElement($element[0],
+          $element[1],
+          array_key_exists('2', $element) ? $element[2] : NULL,
+          array_key_exists('3', $element) ? $element[3] : NULL,
+          array_key_exists('4', $element) ? $element[4] : NULL,
+          array_key_exists('5', $element) ? $element[5] : NULL
+        );
+      }
 
-    if ($other['contact_id'] != $oid) {
-      CRM_Core_Error::fatal(ts('The other contact record does not exist'));
-    }
+      // add related table elements
+      foreach ($rowsElementsAndInfo['rel_table_elements'] as $relTableElement) {
+        $element = $this->addElement($relTableElement[0], $relTableElement[1]);
+        $element->setChecked(TRUE);
+      }
 
-    $this->assign('contact_type', $main['contact_type']);
-    $this->assign('main_name', $main['display_name']);
-    $this->assign('other_name', $other['display_name']);
-    $this->assign('main_cid', $main['contact_id']);
-    $this->assign('other_cid', $other['contact_id']);
-    $this->assign('rgid', $this->_rgid);
-
-    $this->_cid = $cid;
-    $this->_oid = $oid;
-
-    $this->addElement('checkbox', 'toggleSelect', NULL, NULL, array('class' => 'select-rows'));
-
-    $this->assign('mainLocBlock', json_encode($rowsElementsAndInfo['main_details']['location_blocks']));
-    $this->assign('locationBlockInfo', json_encode(CRM_Dedupe_Merger::getLocationBlockInfo()));
-    $this->assign('rows', $rowsElementsAndInfo['rows']);
-
-    // add elements
-    foreach ($rowsElementsAndInfo['elements'] as $element) {
-      $this->addElement($element[0],
-        $element[1],
-        array_key_exists('2', $element) ? $element[2] : NULL,
-        array_key_exists('3', $element) ? $element[3] : NULL,
-        array_key_exists('4', $element) ? $element[4] : NULL,
-        array_key_exists('5', $element) ? $element[5] : NULL
-      );
+      $this->assign('rel_tables', $rowsElementsAndInfo['rel_tables']);
+      $this->assign('userContextURL', CRM_Core_Session::singleton()
+        ->readUserContext());
     }
-
-    // add related table elements
-    foreach ($rowsElementsAndInfo['rel_table_elements'] as $relTableElement) {
-      $element = $this->addElement($relTableElement[0], $relTableElement[1]);
-      $element->setChecked(TRUE);
+    catch (CRM_Core_Exception $e) {
+      CRM_Core_Error::statusBounce(ts($e->getMessage()));
     }
-
-    $this->assign('rel_tables', $rowsElementsAndInfo['rel_tables']);
-    $this->assign('userContextURL', $session->readUserContext());
-  }
-
-  /**
-   * This virtual function is used to set the default values of
-   * various form elements
-   *
-   * access        public
-   *
-   * @return array
-   *   reference to the array of default values
-   */
-  /**
-   * @return array
-   */
-  public function setDefaultValues() {
-    return array('deleteOther' => 1);
   }
 
   public function addRules() {
@@ -366,4 +335,39 @@ class CRM_Contact_Form_Merge extends CRM_Core_Form {
     CRM_Utils_System::redirect($url);
   }
 
+  /**
+   * Bounce if the merge action is invalid.
+   *
+   * We don't allow the merge if it is nonsensical, marked as a duplicate
+   * or outside the user's permission.
+   *
+   * @param int $cid
+   *   Contact ID to retain
+   * @param int $oid
+   *   Contact ID to delete.
+   */
+  public function bounceIfInvalid($cid, $oid) {
+    if ($cid == $oid) {
+      CRM_Core_Error::statusBounce(ts('Cannot merge a contact with itself.'));
+    }
+
+    if (!CRM_Dedupe_BAO_Rule::validateContacts($cid, $oid)) {
+      CRM_Core_Error::statusBounce(ts('The selected pair of contacts are marked as non duplicates. If these records should be merged, you can remove this exception on the <a href="%1">Dedupe Exceptions</a> page.', array(1 => CRM_Utils_System::url('civicrm/dedupe/exception', 'reset=1'))));
+    }
+
+    if (!(CRM_Contact_BAO_Contact_Permission::allow($cid, CRM_Core_Permission::EDIT) &&
+      CRM_Contact_BAO_Contact_Permission::allow($oid, CRM_Core_Permission::EDIT)
+    )
+    ) {
+      CRM_Utils_System::permissionDenied();
+    }
+    // ensure that oid is not the current user, if so refuse to do the merge
+    if (CRM_Core_Session::singleton()->getLoggedInContactID() == $oid) {
+      $message = ts('The contact record which is linked to the currently logged in user account - \'%1\' - cannot be deleted.',
+        array(1 => CRM_Core_Session::singleton()->getLoggedInContactDisplayName())
+      );
+      CRM_Core_Error::statusBounce($message);
+    }
+  }
+
 }
index b658ee6e6db56874eb952d26c0fab6fe111e83da..d0f892cb6b39bba78a9a73dd5888dafa2f6d90aa 100644 (file)
@@ -297,6 +297,8 @@ class CRM_Contact_Form_Search_Criteria {
 
     $elements = array(
       'street_address' => array(ts('Street Address'), $attributes['street_address'], NULL, NULL),
+      'supplemental_address_1' => array(ts('Supplemental Address 1'), $attributes['supplemental_address_1'], NULL, NULL),
+      'supplemental_address_2' => array(ts('Supplemental Address 2'), $attributes['supplemental_address_2'], NULL, NULL),
       'city' => array(ts('City'), $attributes['city'], NULL, NULL),
       'postal_code' => array(ts('Postal Code'), $attributes['postal_code'], NULL, NULL),
       'country' => array(ts('Country'), $attributes['country_id'], 'country', FALSE),
index aaaebefe4bca38f3d7b280e657ba2112ff8858ee..affce8e20d297a38ad6df425214988111da7c2cb 100644 (file)
@@ -88,7 +88,7 @@ class CRM_Contact_Page_DedupeFind extends CRM_Core_Page_Basic {
     }
     elseif ($action & CRM_Core_Action::MAP) {
       // do a batch merge if requested
-      $result = CRM_Dedupe_Merger::batchMerge($rgid, $gid, 'safe', TRUE, 75);
+      $result = CRM_Dedupe_Merger::batchMerge($rgid, $gid, 'safe', 75);
 
       $skippedCount = CRM_Utils_Request::retrieve('skipped', 'Positive', $this, FALSE, 0);
       $skippedCount = $skippedCount + count($result['skipped']);
index ffcd028def6f1965c13bcc382c796fca1d5566fa..df91a146f4a8596ebc605ef44545ea5192e27efe 100644 (file)
@@ -98,7 +98,7 @@ class CRM_Contact_Page_DedupeMerge extends CRM_Core_Page {
     for ($i = 1; $i <= ceil($total / self::BATCHLIMIT); $i++) {
       $task  = new CRM_Queue_Task(
         array('CRM_Contact_Page_DedupeMerge', 'callBatchMerge'),
-        array($rgid, $gid, $mode, FALSE, self::BATCHLIMIT, $isSelected),
+        array($rgid, $gid, $mode, self::BATCHLIMIT, $isSelected),
         "Processed " . $i * self::BATCHLIMIT . " pair of duplicates out of " . $total
       );
 
@@ -126,17 +126,13 @@ class CRM_Contact_Page_DedupeMerge extends CRM_Core_Page {
    * @param int $gid
    * @param string $mode
    *   'safe' mode or 'force' mode.
-   * @param bool $autoFlip
-   *   Override the values in the prevnext table & use the lowest value?
-   *   As the form offers the user to flip the values themselves this should
-   *   only be TRUE if you wish to ignore the user.
    * @param int $batchLimit
    * @param int $isSelected
    *
    * @return int
    */
-  public static function callBatchMerge(CRM_Queue_TaskContext $ctx, $rgid, $gid, $mode = 'safe', $autoFlip, $batchLimit, $isSelected) {
-    CRM_Dedupe_Merger::batchMerge($rgid, $gid, $mode, $autoFlip, $batchLimit, $isSelected);
+  public static function callBatchMerge(CRM_Queue_TaskContext $ctx, $rgid, $gid, $mode = 'safe', $batchLimit, $isSelected) {
+    CRM_Dedupe_Merger::batchMerge($rgid, $gid, $mode, $batchLimit, $isSelected);
     return CRM_Queue_Task::TASK_SUCCESS;
   }
 
index 33a43adbb4cc2dcc958999e88dce7cd6cbda4eb1..373ff401883c249aa843482dacc86fc3e0c1dad8 100644 (file)
@@ -54,13 +54,11 @@ class CRM_Contact_Page_Inline_Demographics extends CRM_Core_Page {
       $gender = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id');
       $defaults['gender_display'] = $gender[CRM_Utils_Array::value('gender_id', $defaults)];
     }
+    $this->assignFieldMetadataToTemplate('Contact');
 
     $this->assign('contactId', $contactId);
     $this->assign($defaults);
 
-    //for birthdate format with respect to birth format set
-    $this->assign('birthDateViewFormat', CRM_Utils_Array::value('qfMapping', CRM_Utils_Date::checkBirthDateFormat()));
-
     // check logged in user permission
     CRM_Contact_Page_View::checkUserPermission($this, $contactId);
 
index 950531d28b6da9fb428133d4fe84c6b5ce56ef6e..ab9f39bd2deef84913ed2d05c3df51d9b3693006 100644 (file)
@@ -83,7 +83,7 @@ class CRM_Contact_Page_SavedSearch extends CRM_Core_Page {
       $group = new CRM_Contact_DAO_Group();
       $group->saved_search_id = $savedSearch->id;
       if ($group->find(TRUE)) {
-        $permissions = CRM_Group_Page_Group::checkPermission($group->id, $group->title);
+        $permissions = CRM_Contact_BAO_Group::checkPermission($group->id, TRUE);
         if (!CRM_Utils_System::isNull($permissions)) {
           $row = array();
 
index 7a633d1e49cee1d7687c3130843729f8392c74b5..ef4b9c6dfdc91a00d247de36a57b74cc7d55ab17 100644 (file)
@@ -119,8 +119,6 @@ class CRM_Contact_Page_View_Summary extends CRM_Contact_Page_View {
     CRM_Core_Resources::singleton()
       ->addScriptFile('civicrm', 'templates/CRM/Contact/Page/View/Summary.js', 2, 'html-header')
       ->addStyleFile('civicrm', 'css/contactSummary.css', 2, 'html-header')
-      ->addScriptFile('civicrm', 'packages/jquery/plugins/jstree/jquery.jstree.js', 0, 'html-header', FALSE)
-      ->addStyleFile('civicrm', 'packages/jquery/plugins/jstree/themes/default/style.css', 0, 'html-header')
       ->addScriptFile('civicrm', 'templates/CRM/common/TabHeader.js', 1, 'html-header')
       ->addSetting(array(
         'summaryPrint' => array('mode' => $this->_print),
@@ -130,10 +128,10 @@ class CRM_Contact_Page_View_Summary extends CRM_Contact_Page_View {
     $session = CRM_Core_Session::singleton();
     $url = CRM_Utils_System::url('civicrm/contact/view', 'reset=1&cid=' . $this->_contactId);
     $session->pushUserContext($url);
+    $this->assignFieldMetadataToTemplate('Contact');
 
     $params = array();
     $defaults = array();
-    $ids = array();
 
     $params['id'] = $params['contact_id'] = $this->_contactId;
     $params['noRelationships'] = $params['noNotes'] = $params['noGroups'] = TRUE;
@@ -259,9 +257,6 @@ class CRM_Contact_Page_View_Summary extends CRM_Contact_Page_View {
         $defaults['current_employer'] = $contact->organization_name;
         $defaults['current_employer_id'] = $contact->employer_id;
       }
-
-      //for birthdate format with respect to birth format set
-      $this->assign('birthDateViewFormat', CRM_Utils_Array::value('qfMapping', CRM_Utils_Date::checkBirthDateFormat()));
     }
 
     $defaults['external_identifier'] = $contact->external_identifier;
index 100278ef2f7824cb41e61fe31a1f8ac8b3bd1bc9..0a7b2cce4f162bd22b5577dfe81e051c09e6193d 100644 (file)
@@ -88,8 +88,8 @@ class CRM_Contact_Page_View_Vcard extends CRM_Contact_Page_View {
       $vcard->setTitle($defaults['job_title']);
     }
 
-    if (!empty($defaults['birth_date_display'])) {
-      $vcard->setBirthday(CRM_Utils_Array::value('birth_date_display', $defaults));
+    if (!empty($defaults['birth_date'])) {
+      $vcard->setBirthday(CRM_Utils_Array::value('birth_date', $defaults));
     }
 
     if (!empty($defaults['home_URL'])) {
index 8a92ce1a099b364d3e862771bb3d6bfb7c629894..9d1ceb8f69c0a426ddf3a3bd9fa37f917c200c44 100644 (file)
@@ -488,6 +488,9 @@ class CRM_Contact_Selector extends CRM_Core_Selector_Base implements CRM_Core_Se
         elseif (isset($this->_query->_fields[$prop]) && isset($this->_query->_fields[$prop]['title'])) {
           $title = $this->_query->_fields[$prop]['title'];
         }
+        elseif (isset($this->_query->_pseudoConstantsSelect[$prop]) && isset($this->_query->_pseudoConstantsSelect[$prop]['pseudoconstant']['optionGroupName'])) {
+          $title = CRM_Core_BAO_OptionGroup::getTitleByName($this->_query->_pseudoConstantsSelect[$prop]['pseudoconstant']['optionGroupName']);
+        }
         else {
           $title = '';
         }
@@ -637,8 +640,6 @@ class CRM_Contact_Selector extends CRM_Core_Selector_Base implements CRM_Core_Se
       $names = self::$_properties;
     }
 
-    $multipleSelectFields = array('preferred_communication_method' => 1);
-
     $links = self::links($this->_context, $this->_contextMenu, $this->_key);
 
     //check explicitly added contact to a Smart Group.
@@ -656,7 +657,6 @@ class CRM_Contact_Selector extends CRM_Core_Selector_Base implements CRM_Core_Se
     while ($result->fetch()) {
       $row = array();
       $this->_query->convertToPseudoNames($result);
-
       // the columns we are interested in
       foreach ($names as $property) {
         if ($property == 'status') {
@@ -669,17 +669,6 @@ class CRM_Contact_Selector extends CRM_Core_Selector_Base implements CRM_Core_Se
             $result->contact_id
           );
         }
-        elseif (
-          $multipleSelectFields &&
-          array_key_exists($property, $multipleSelectFields)
-        ) {
-          $key = $property;
-          $paramsNew = array($key => $result->$property);
-          $name = array($key => array('newName' => $key, 'groupName' => $key));
-
-          CRM_Core_OptionGroup::lookupValues($paramsNew, $name, FALSE);
-          $row[$key] = $paramsNew[$key];
-        }
         elseif (strpos($property, '-im')) {
           $row[$property] = $result->$property;
           if (!empty($result->$property)) {
index 09f57773ecf6fb62219535dfb771eb88894b7d23..d76de521415adb4de1a68a975d6c6ae12393f113 100644 (file)
@@ -780,6 +780,15 @@ class CRM_Contribute_BAO_Contribution extends CRM_Contribute_DAO_Contribution {
     return self::$_importableFields;
   }
 
+  /**
+   * Get exportable fields with pseudoconstants rendered as an extra field.
+   */
+  public static function getExportableFieldsWithPseudoConstants() {
+    $fields = self::exportableFields();
+    CRM_Core_DAO::appendPseudoConstantsToFields($fields);
+    return $fields;
+  }
+
   /**
    * Combine all the exportable fields from the lower level objects.
    *
@@ -799,14 +808,6 @@ class CRM_Contribute_BAO_Contribution extends CRM_Contribute_DAO_Contribution {
       $expFieldsContrib = CRM_Contribute_DAO_ContributionProduct::export();
       $typeField = CRM_Financial_DAO_FinancialType::export();
       $financialAccount = CRM_Financial_DAO_FinancialAccount::export();
-      $optionField = CRM_Core_OptionValue::getFields($mode = 'contribute');
-      $contributionStatus = array(
-        'contribution_status' => array(
-          'title' => ts('Contribution Status'),
-          'name' => 'contribution_status',
-          'data_type' => CRM_Utils_Type::T_STRING,
-        ),
-      );
 
       $contributionPage = array(
         'contribution_page' => array(
@@ -883,7 +884,7 @@ class CRM_Contribute_BAO_Contribution extends CRM_Contribute_DAO_Contribution {
         ),
       );
 
-      $fields = array_merge($impFields, $typeField, $contributionStatus, $contributionPage, $optionField, $expFieldProduct,
+      $fields = array_merge($impFields, $typeField, $contributionPage, $expFieldProduct,
         $expFieldsContrib, $contributionNote, $extraFields, $softCreditFields, $financialAccount, $premiums, $campaignTitle,
         CRM_Core_BAO_CustomField::getFieldsForImport('Contribution', FALSE, FALSE, FALSE, $checkPermission)
       );
@@ -1137,6 +1138,8 @@ LEFT JOIN  civicrm_line_item i ON ( i.contribution_id = c.id AND i.entity_table
    */
   public static function getContributionFields($addExtraFields = TRUE) {
     $contributionFields = CRM_Contribute_DAO_Contribution::export();
+    // @todo remove this - this line was added because payment_instrument_id was not
+    // set to exportable - but now it is.
     $contributionFields = array_merge($contributionFields, CRM_Core_OptionValue::getFields($mode = 'contribute'));
 
     if ($addExtraFields) {
@@ -3702,6 +3705,9 @@ INNER JOIN civicrm_activity ON civicrm_activity_contact.activity_id = civicrm_ac
   public static function buildOptions($fieldName, $context = NULL, $props = array()) {
     $className = __CLASS__;
     $params = array();
+    if (isset($props['orderColumn'])) {
+      $params['orderColumn'] = $props['orderColumn'];
+    }
     switch ($fieldName) {
       // This field is not part of this object but the api supports it
       case 'payment_processor':
@@ -4467,6 +4473,12 @@ WHERE eft.financial_trxn_id IN ({$trxnId}, {$baseTrxnId['financialTrxnId']})
     ));
     $contributionParams['payment_processor'] = $input['payment_processor'] = $paymentProcessorId;
 
+    // If paymentProcessor is not set then the payment_instrument_id would not be correct.
+    // not clear when or if this would occur if you encounter this please fix here & add a unit test.
+    if (empty($contributionParams['payment_instrument_id']) && isset($contribution->_relatedObjects['paymentProcessor']['payment_instrument_id'])) {
+      $contributionParams['payment_instrument_id'] = $contribution->_relatedObjects['paymentProcessor']['payment_instrument_id'];
+    }
+
     if ($recurringContributionID) {
       $contributionParams['contribution_recur_id'] = $recurringContributionID;
     }
@@ -4709,14 +4721,8 @@ LIMIT 1;";
     $contribution->loadRelatedObjects($input, $ids, TRUE);
     // set receipt from e-mail and name in value
     if (!$returnMessageText) {
-      $userID = CRM_Core_Session::singleton()->getLoggedInContactID();
-      if (!empty($userID)) {
-        list($userName, $userEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($userID);
-        $values['receipt_from_email'] = CRM_Utils_Array::value('receipt_from_email', $input, $userEmail);
-        $values['receipt_from_name'] = CRM_Utils_Array::value('receipt_from_name', $input, $userName);
-      }
+      list($values['receipt_from_name'], $values['receipt_from_email']) = self::generateFromEmailAndName($input, $contribution);
     }
-
     $return = $contribution->composeMessageArray($input, $ids, $values, $recur, $returnMessageText);
     // Contribution ID should really always be set. But ?
     if (!$returnMessageText && (!isset($input['receipt_update']) || $input['receipt_update']) && empty($contribution->receipt_date)) {
@@ -4725,6 +4731,42 @@ LIMIT 1;";
     return $return;
   }
 
+  /**
+   * Generate From email and from name in an array values
+   */
+  public static function generateFromEmailAndName($input, $contribution) {
+    // Use input valuse if supplied.
+    if (!empty($input['receipt_from_email'])) {
+      return array(CRM_Utils_array::value('receipt_from_name', $input, ''), $input['receipt_from_email']);
+    }
+    // if we are still empty see if we can use anything from a contribution page.
+    $pageValues = array();
+    if (!empty($contribution->contribution_page_id)) {
+      $pageValues = civicrm_api3('ContributionPage', 'getsingle', array('id' => $contribution->contribution_page_id));
+    }
+    // if we are still empty see if we can use anything from a contribution page.
+    if (!empty($pageValues['receipt_from_email'])) {
+      return array($pageValues['receipt_from_name'], $pageValues['receipt_from_email']);
+    }
+    // If we are still empty fall back to the domain.
+    $domain = civicrm_api3('domain', 'getsingle', array('id' => CRM_Core_Config::domainID()));
+    if (!empty($domain['from_email'])) {
+      return array($domain['from_name'], $domain['from_email']);
+    }
+    if (!empty($domain['domain_email'])) {
+      return array($domain['name'], $domain['domain_email']);
+    }
+    $userID = CRM_Core_Session::singleton()->getLoggedInContactID();
+    $userName = '';
+    $userEmail = '';
+    if (!empty($userID)) {
+      list($userName, $userEmail) = CRM_Contact_BAO_Contact_Location::getEmailDetails($userID);
+    }
+    // If still empty fall back to the logged in user details.
+    // return empty values no matter what.
+    return array($userName, $userEmail);
+  }
+
   /**
    * Generate credit note id with next avaible number
    *
@@ -5381,8 +5423,8 @@ LEFT JOIN  civicrm_contribution on (civicrm_contribution.contact_id = civicrm_co
    */
   public static function createProportionalEntry($entityParams, $eftParams) {
     $paid = $entityParams['line_item_amount'] * ($entityParams['trxn_total_amount'] / $entityParams['contribution_total_amount']);
-    // Record Entity Financial Trxn
-    $eftParams['amount'] = round($paid, 2);
+    // Record Entity Financial Trxn; CRM-20145
+    $eftParams['amount'] = CRM_Contribute_BAO_Contribution_Utils::formatAmount($paid);
     civicrm_api3('EntityFinancialTrxn', 'create', $eftParams);
   }
 
index 6ea7c5b271fdd09248d021d08cbe18f8a6619de2..6633d2fe43b64586a5c590091cfaf90111813280 100644 (file)
@@ -475,9 +475,26 @@ LIMIT 1
    */
   public static function calculateTaxAmount($amount, $taxRate) {
     $taxAmount = array();
-    $taxAmount['tax_amount'] = round(($taxRate / 100) * CRM_Utils_Rule::cleanMoney($amount), 2);
+    // There can not be any rounding at this stage - as this is prior to quantity multiplication
+    $taxAmount['tax_amount'] = ($taxRate / 100) * CRM_Utils_Rule::cleanMoney($amount);
 
     return $taxAmount;
   }
 
+  /**
+   * Format monetary amount: round and return to desired decimal place
+   * CRM-20145
+   *
+   * @param float $amount
+   *   Monetary amount
+   * @param int $decimals
+   *   How many decimal places to round to and return
+   *
+   * @return float
+   *   Amount rounded and returned with the desired decimal places
+   */
+  public static function formatAmount($amount, $decimals = 2) {
+    return number_format((float) round($amount, (int) $decimals), (int) $decimals, '.', '');
+  }
+
 }
index e6cccdae67142a7cd93438b623ae8bd48a8c9c30..e31a87f67da97a0637e920029c6a5e9d584cd811 100644 (file)
@@ -97,45 +97,6 @@ class CRM_Contribute_BAO_Query extends CRM_Core_BAO_Query {
       $query->_tables['contribution_batch'] = 1;
     }
 
-    // get contribution_status
-    if (!empty($query->_returnProperties['contribution_status_id'])) {
-      $query->_select['contribution_status_id'] = "contribution_status.value as contribution_status_id";
-      $query->_element['contribution_status_id'] = 1;
-      $query->_tables['civicrm_contribution'] = 1;
-      $query->_tables['contribution_status'] = 1;
-    }
-
-    // get contribution_status label
-    if (!empty($query->_returnProperties['contribution_status'])) {
-      $query->_select['contribution_status'] = "contribution_status.label as contribution_status";
-      $query->_element['contribution_status'] = 1;
-      $query->_tables['civicrm_contribution'] = 1;
-      $query->_tables['contribution_status'] = 1;
-    }
-
-    // get payment instrument
-    if (!empty($query->_returnProperties['payment_instrument'])) {
-      $query->_select['payment_instrument'] = "contribution_payment_instrument.label as payment_instrument";
-      $query->_element['payment_instrument'] = 1;
-      $query->_tables['civicrm_contribution'] = 1;
-      $query->_tables['contribution_payment_instrument'] = 1;
-    }
-
-    // get payment instrument id
-    if (!empty($query->_returnProperties['payment_instrument_id'])) {
-      $query->_select['instrument_id'] = "contribution_payment_instrument.value as instrument_id";
-      $query->_select['payment_instrument_id'] = "contribution_payment_instrument.value as payment_instrument_id";
-      $query->_element['instrument_id'] = $query->_element['payment_instrument_id'] = 1;
-      $query->_tables['civicrm_contribution'] = 1;
-      $query->_tables['contribution_payment_instrument'] = 1;
-    }
-
-    if (!empty($query->_returnProperties['contribution_campaign_id'])) {
-      $query->_select['contribution_campaign_id'] = 'civicrm_contribution.campaign_id as contribution_campaign_id';
-      $query->_element['contribution_campaign_id'] = 1;
-      $query->_tables['civicrm_contribution'] = 1;
-    }
-
     if (!empty($query->_returnProperties['contribution_campaign_title'])) {
       $query->_select['contribution_campaign_title'] = "civicrm_campaign.title as contribution_campaign_title";
       $query->_element['contribution_campaign_title'] = $query->_tables['civicrm_campaign'] = 1;
@@ -187,7 +148,7 @@ class CRM_Contribute_BAO_Query extends CRM_Core_BAO_Query {
     list($name, $op, $value, $grouping, $wildcard) = $values;
 
     $quoteValue = NULL;
-    $fields = array_merge(CRM_Contribute_BAO_Contribution::fields(), self::getFields());
+    $fields = self::getFields();
 
     if (!empty($value) && !is_array($value)) {
       $quoteValue = "\"$value\"";
@@ -202,7 +163,17 @@ class CRM_Contribute_BAO_Query extends CRM_Core_BAO_Query {
         return;
       }
     }
-
+    // These are legacy names.
+    // @todo enotices when these are hit so we can start to elimnate them.
+    $fieldAliases = array(
+      'financial_type' => 'financial_type_id',
+      'contribution_page' => 'contribution_page_id',
+      'payment_instrument' => 'payment_instrument_id',
+      // or payment_instrument_id?
+      'contribution_payment_instrument' => 'contribution_payment_instrument_id',
+      'contribution_status' => 'contribution_status_id',
+    );
+    $name = isset($fieldAliases[$name]) ? $fieldAliases[$name] : $name;
     $qillName = $name;
     $pseudoExtraParam = array();
 
@@ -255,12 +226,6 @@ class CRM_Contribute_BAO_Query extends CRM_Core_BAO_Query {
         $query->_tables['civicrm_contribution'] = $query->_whereTables['civicrm_contribution'] = 1;
         return;
 
-      case 'financial_type':
-      case 'contribution_page':
-      case 'payment_instrument':
-      case 'contribution_payment_instrument':
-      case 'contribution_status':
-        $name .= '_id';
       case 'financial_type_id':
         // @todo we need to make this resemble a hook approach.
         CRM_Financial_BAO_FinancialType::getAvailableFinancialTypes($financialTypes);
@@ -281,19 +246,13 @@ class CRM_Contribute_BAO_Query extends CRM_Core_BAO_Query {
       case (strpos($name, '_date') !== FALSE && $name != 'contribution_fulfilled_date'):
       case 'contribution_campaign_id':
 
-        // @todo including names using a switch statement & then using an 'if' to filter them out is ... odd!
-        if ((strpos($name, '_amount') !== FALSE) || (strpos($name, '_date') !== FALSE) || in_array($name,
-            array(
-              'contribution_id',
-              'contribution_currency',
-              'contribution_source',
-              'contribution_trxn_id',
-              'contribution_check_number',
-              'contribution_payment_instrument_id',
-              'contribution_contact_id',
-              'contribution_campaign_id',
-            )
-          )
+        $fieldNamesNotToStripContributionFrom = array(
+          'contribution_currency_type',
+          'contribution_status_id',
+          'contribution_page_id',
+        );
+        // @todo these are mostly legacy params. Find a better way to deal with them.
+        if (!in_array($name, $fieldNamesNotToStripContributionFrom)
         ) {
           if (!isset($fields[$name])) {
             $qillName = str_replace('contribution_', '', $qillName);
@@ -586,18 +545,6 @@ class CRM_Contribute_BAO_Query extends CRM_Core_BAO_Query {
         $from .= " $side  JOIN civicrm_product ON civicrm_contribution_product.product_id =civicrm_product.id ";
         break;
 
-      case 'contribution_payment_instrument':
-        $from = " $side JOIN civicrm_option_group option_group_payment_instrument ON ( option_group_payment_instrument.name = 'payment_instrument')";
-        $from .= " $side JOIN civicrm_option_value contribution_payment_instrument ON (civicrm_contribution.payment_instrument_id = contribution_payment_instrument.value
-                               AND option_group_payment_instrument.id = contribution_payment_instrument.option_group_id ) ";
-        break;
-
-      case 'contribution_status':
-        $from = " $side JOIN civicrm_option_group option_group_contribution_status ON (option_group_contribution_status.name = 'contribution_status')";
-        $from .= " $side JOIN civicrm_option_value contribution_status ON (civicrm_contribution.contribution_status_id = contribution_status.value
-                               AND option_group_contribution_status.id = contribution_status.option_group_id ) ";
-        break;
-
       case 'contribution_softcredit_type':
         $from = " $side JOIN civicrm_option_group option_group_contribution_softcredit_type ON
           (option_group_contribution_softcredit_type.name = 'soft_credit_type')";
index 5dbd758464197bc60492f7b31fef0c771bc7bfdd..13d752e08122463b51da070f4c3af90cce402737 100644 (file)
@@ -30,7 +30,7 @@
  *
  * Generated from xml/schema/CRM/Contribute/Contribution.xml
  * DO NOT EDIT.  Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:00dd1e00a61c69190a0eefd88d49415e)
+ * (GenCodeChecksum:3e387ab5c998da1bbb367ed526e84289)
  */
 require_once 'CRM/Core/DAO.php';
 require_once 'CRM/Utils/Type.php';
@@ -334,8 +334,12 @@ class CRM_Contribute_DAO_Contribution extends CRM_Core_DAO {
         'payment_instrument_id' => array(
           'name' => 'payment_instrument_id',
           'type' => CRM_Utils_Type::T_INT,
-          'title' => ts('Payment Method') ,
+          'title' => ts('Payment Method ID') ,
           'description' => 'FK to Payment Instrument',
+          'export' => true,
+          'where' => 'civicrm_contribution.payment_instrument_id',
+          'headerPattern' => '/^payment|(p(ayment\s)?instrument)$/i',
+          'dataPattern' => '',
           'table_name' => 'civicrm_contribution',
           'entity' => 'Contribution',
           'bao' => 'CRM_Contribute_BAO_Contribution',
@@ -362,7 +366,7 @@ class CRM_Contribute_DAO_Contribution extends CRM_Core_DAO {
           'bao' => 'CRM_Contribute_BAO_Contribution',
           'html' => array(
             'type' => 'Select Date',
-            'format' => 'activityDateTime',
+            'formatType' => 'activityDateTime',
           ) ,
         ) ,
         'non_deductible_amount' => array(
@@ -529,7 +533,7 @@ class CRM_Contribute_DAO_Contribution extends CRM_Core_DAO {
           'bao' => 'CRM_Contribute_BAO_Contribution',
           'html' => array(
             'type' => 'Select Date',
-            'format' => 'activityDateTime',
+            'formatType' => 'activityDateTime',
           ) ,
         ) ,
         'cancel_reason' => array(
@@ -563,7 +567,7 @@ class CRM_Contribute_DAO_Contribution extends CRM_Core_DAO {
           'bao' => 'CRM_Contribute_BAO_Contribution',
           'html' => array(
             'type' => 'Select Date',
-            'format' => 'activityDateTime',
+            'formatType' => 'activityDateTime',
           ) ,
         ) ,
         'thankyou_date' => array(
@@ -581,7 +585,7 @@ class CRM_Contribute_DAO_Contribution extends CRM_Core_DAO {
           'bao' => 'CRM_Contribute_BAO_Contribution',
           'html' => array(
             'type' => 'Select Date',
-            'format' => 'activityDateTime',
+            'formatType' => 'activityDateTime',
           ) ,
         ) ,
         'contribution_source' => array(
@@ -796,7 +800,7 @@ class CRM_Contribute_DAO_Contribution extends CRM_Core_DAO {
           'bao' => 'CRM_Contribute_BAO_Contribution',
           'html' => array(
             'type' => 'Select Date',
-            'format' => 'activityDateTime',
+            'formatType' => 'activityDateTime',
           ) ,
         ) ,
       );
index 993af0b77c73f0405af1259b6470faefa3befd92..b6cee86c1b75f7e8fd99350e96e6fa5fa8c2d788 100644 (file)
@@ -429,15 +429,6 @@ class CRM_Contribute_Form_AdditionalPayment extends CRM_Contribute_Form_Abstract
       if (!empty($submittedValues['is_email_receipt']) && $sendReceipt) {
         $statusMsg .= ' ' . ts('A receipt has been emailed to the contributor.');
       }
-      // email sending
-      if (!empty($result) && !empty($submittedValues['is_email_receipt'])) {
-        $submittedValues['contact_id'] = $this->_contactId;
-        $submittedValues['contribution_id'] = $this->_contributionId;
-        // to get 'from email id' for send receipt
-        $this->fromEmailId = $submittedValues['from_email_address'];
-        $sendReceipt = $this->emailReceipt($submittedValues);
-      }
-
       CRM_Core_Session::setStatus($statusMsg, ts('Saved'), 'success');
 
       $session = CRM_Core_Session::singleton();
index 450c1bac94faf613e58387d697755c6272dd39a5..6990f977b2a905b8af9bce2ff40da658d3b6d597 100644 (file)
@@ -649,10 +649,11 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
 
     $paymentInstrument = FALSE;
     if (!$this->_mode) {
+      $checkPaymentID = array_search('Check', CRM_Contribute_PseudoConstant::paymentInstrument('name'));
       $paymentInstrument = $this->add('select', 'payment_instrument_id',
         ts('Payment Method'),
         array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::paymentInstrument(),
-        TRUE, array('onChange' => "return showHideByValue('payment_instrument_id','4','checkNumber','table-row','select',false);")
+        TRUE, array('onChange' => "return showHideByValue('payment_instrument_id','{$checkPaymentID}','checkNumber','table-row','select',false);")
       );
     }
 
@@ -776,7 +777,7 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
     if ($this->_online) {
       $this->assign('hideCalender', TRUE);
     }
-    $checkNumber = $this->add('text', 'check_number', ts('Check Number'), $attributes['check_number']);
+    $checkNumber = $this->add('text', 'check_number', ts('Check Number'), $attributes['contribution_check_number']);
 
     $this->addDateTime('receipt_date', ts('Receipt Date'), FALSE, array('formatType' => 'activityDateTime'));
     $this->addDateTime('cancel_date', ts('Cancelled / Refunded Date'), FALSE, array('formatType' => 'activityDateTime'));
index e4e2df3d840176cced48e190d5385bed53f984c6..14c3ace64a7742ab57533c369c984787740893f4 100644 (file)
@@ -297,20 +297,19 @@ class CRM_Contribute_Form_Search extends CRM_Core_Form_Search {
         }
       }
 
-      if (!defined('CIVICRM_GROUPTREE')) {
-        $group = CRM_Utils_Array::value('group', $this->_formValues);
-        if ($group && !is_array($group)) {
-          unset($this->_formValues['group']);
-          $this->_formValues['group'][$group] = 1;
-        }
+      $group = CRM_Utils_Array::value('group', $this->_formValues);
+      if ($group && !is_array($group)) {
+        unset($this->_formValues['group']);
+        $this->_formValues['group'][$group] = 1;
+      }
 
-        if ($group && is_array($group)) {
-          unset($this->_formValues['group']);
-          foreach ($group as $notImportant => $groupID) {
-            $this->_formValues['group'][$groupID] = 1;
-          }
+      if ($group && is_array($group)) {
+        unset($this->_formValues['group']);
+        foreach ($group as $groupID) {
+          $this->_formValues['group'][$groupID] = 1;
         }
       }
+
     }
 
     CRM_Core_BAO_CustomValue::fixCustomFieldValue($this->_formValues);
index ca6c15eeb99ec373eb9653b326663f9a007167ba..f1b47a4375ebb2e1518c97cc4fcf1a9ba43050ed 100644 (file)
@@ -187,7 +187,6 @@ class CRM_Contribute_Form_Task_Batch extends CRM_Contribute_Form_Task {
 
     $defaults = array();
     foreach ($this->_contributionIds as $contributionId) {
-      $details[$contributionId] = array();
       CRM_Core_BAO_UFGroup::setProfileDefaults(NULL, $this->_fields, $defaults, FALSE, $contributionId, 'Contribute');
     }
 
index 23181c272cef49c44de01502e500e41c52e9686d..81beacae28575d828d44157fc18435da5de3b938 100644 (file)
@@ -366,6 +366,7 @@ class CRM_Contribute_Selector_Search extends CRM_Core_Selector_Base implements C
     $allCampaigns = CRM_Campaign_BAO_Campaign::getCampaigns(NULL, NULL, FALSE, FALSE, FALSE, TRUE);
 
     while ($result->fetch()) {
+      $this->_query->convertToPseudoNames($result);
       $links = self::links($componentId,
           $componentAction,
           $qfKey,
index 82bfee3e06f85f7b84da22756e56324374af02d2..b5dff555e58838ba52eb27834c87f0d3060c1c01 100644 (file)
@@ -1218,7 +1218,7 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
         // Or should we throw an exception here if it is?
         $value = is_array($value) ? CRM_Utils_Array::first($value) : $value;
 
-        $actualPHPFormats = CRM_Core_SelectValues::datePluginToPHPFormats();
+        $actualPHPFormats = CRM_Utils_Date::datePluginToPHPFormats();
         $format = CRM_Utils_Array::value('date_format', $field);
 
         if ($format) {
index f4b9921ab4bc34a09568995feb46320ce9b30f73..accc5d6d082602e23019fa27aa4321238183ca79 100644 (file)
@@ -392,7 +392,10 @@ class CRM_Core_BAO_EntityTag extends CRM_Core_DAO_EntityTag {
   }
 
   /**
-   * Merge two tags: tag B into tag A.
+   * Merge two tags
+   *
+   * Tag A will inherit all of tag B's properties.
+   * Tag B will be deleted.
    *
    * @param int $tagAId
    * @param int $tagBId
@@ -401,8 +404,8 @@ class CRM_Core_BAO_EntityTag extends CRM_Core_DAO_EntityTag {
    */
   public function mergeTags($tagAId, $tagBId) {
     $queryParams = array(
-      1 => array($tagBId, 'Integer'),
-      2 => array($tagAId, 'Integer'),
+      1 => array($tagAId, 'Integer'),
+      2 => array($tagBId, 'Integer'),
     );
 
     // re-compute used_for field
@@ -416,19 +419,21 @@ class CRM_Core_BAO_EntityTag extends CRM_Core_DAO_EntityTag {
     }
     $usedFor = array_merge($tags["tagA_used_for"], $tags["tagB_used_for"]);
     $usedFor = implode(',', array_unique($usedFor));
-    $tags["tagB_used_for"] = explode(",", $usedFor);
+    $tags["used_for"] = explode(",", $usedFor);
 
     // get all merge queries together
     $sqls = array(
       // 1. update entity tag entries
       "UPDATE IGNORE civicrm_entity_tag SET tag_id = %1 WHERE tag_id = %2",
-      // 2. update used_for info for tag B
-      "UPDATE civicrm_tag SET used_for = '{$usedFor}' WHERE id = %1",
-      // 3. remove tag A, if tag A is getting merged into B
+      // 2. move children
+      "UPDATE civicrm_tag SET parent_id = %1 WHERE parent_id = %2",
+      // 3. update used_for info for tag A & children
+      "UPDATE civicrm_tag SET used_for = '{$usedFor}' WHERE id = %1 OR parent_id = %1",
+      // 4. delete tag B
       "DELETE FROM civicrm_tag WHERE id = %2",
-      // 4. remove duplicate entity tag records
+      // 5. remove duplicate entity tag records
       "DELETE et2.* from civicrm_entity_tag et1 INNER JOIN civicrm_entity_tag et2 ON et1.entity_table = et2.entity_table AND et1.entity_id = et2.entity_id AND et1.tag_id = et2.tag_id WHERE et1.id < et2.id",
-      // 5. remove orphaned entity_tags
+      // 6. remove orphaned entity_tags
       "DELETE FROM civicrm_entity_tag WHERE tag_id = %2",
     );
     $tables = array('civicrm_entity_tag', 'civicrm_tag');
index 4b0d9106ed24a02ccf0debe2b865c11c25aa8d2d..d45ef17529c997fbcfb439b56d9a15f760509565 100644 (file)
@@ -381,7 +381,7 @@ class CRM_Core_BAO_Mapping extends CRM_Core_DAO_Mapping {
 
     if (($mappingType == 'Search Builder') || ($exportMode == CRM_Export_Form_Select::CONTRIBUTE_EXPORT)) {
       if (CRM_Core_Permission::access('CiviContribute')) {
-        $fields['Contribution'] = CRM_Contribute_BAO_Contribution::exportableFields();
+        $fields['Contribution'] = CRM_Contribute_BAO_Contribution::getExportableFieldsWithPseudoConstants();
         unset($fields['Contribution']['contribution_contact_id']);
         $compArray['Contribution'] = ts('Contribution');
       }
index 25dc4e0c4dc4cc991da329a48f191573f01ee5f6..2b87046c0eb8b8b3a895917f245acc1df25fcbc1 100644 (file)
@@ -476,12 +476,12 @@ class CRM_Core_BAO_MessageTemplate extends CRM_Core_DAO_MessageTemplate {
       $contact = $contact[$contactID];
     }
 
-    $mailContent['subject'] = CRM_Utils_Token::replaceDomainTokens($mailContent['subject'], $domain, FALSE, $tokens['text'], TRUE);
+    $mailContent['subject'] = CRM_Utils_Token::replaceDomainTokens($mailContent['subject'], $domain, FALSE, $tokens['subject'], TRUE);
     $mailContent['text'] = CRM_Utils_Token::replaceDomainTokens($mailContent['text'], $domain, FALSE, $tokens['text'], TRUE);
     $mailContent['html'] = CRM_Utils_Token::replaceDomainTokens($mailContent['html'], $domain, TRUE, $tokens['html'], TRUE);
 
     if ($contactID) {
-      $mailContent['subject'] = CRM_Utils_Token::replaceContactTokens($mailContent['subject'], $contact, FALSE, $tokens['text'], FALSE, TRUE);
+      $mailContent['subject'] = CRM_Utils_Token::replaceContactTokens($mailContent['subject'], $contact, FALSE, $tokens['subject'], FALSE, TRUE);
       $mailContent['text'] = CRM_Utils_Token::replaceContactTokens($mailContent['text'], $contact, FALSE, $tokens['text'], FALSE, TRUE);
       $mailContent['html'] = CRM_Utils_Token::replaceContactTokens($mailContent['html'], $contact, FALSE, $tokens['html'], FALSE, TRUE);
 
index 82cd56bbe2adb250c383d5fe7621ca012380c794..a4ae608bbdb9729397dd4f81ac26ae552943eaf3 100644 (file)
@@ -264,45 +264,25 @@ FROM civicrm_navigation WHERE domain_id = $domainID {$whereClause} ORDER BY pare
   /**
    * Build navigation tree.
    *
-   * @param array $navigationTree
-   *   Nested array of menus.
-   * @param int $parentID
-   *   Parent id.
-   * @param bool $navigationMenu
-   *   True when called for building top navigation menu.
-   *
    * @return array
    *   nested array of menus
    */
-  public static function buildNavigationTree(&$navigationTree, $parentID, $navigationMenu = TRUE) {
-    $whereClause = " parent_id IS NULL";
-
-    if ($parentID) {
-      $whereClause = " parent_id = {$parentID}";
-    }
-
+  public static function buildNavigationTree() {
     $domainID = CRM_Core_Config::domainID();
+    $navigationTree = array();
 
     // get the list of menus
     $query = "
 SELECT id, label, url, permission, permission_operator, has_separator, parent_id, is_active, name
 FROM civicrm_navigation
-WHERE {$whereClause}
-AND domain_id = $domainID
+WHERE domain_id = $domainID
 ORDER BY parent_id, weight";
 
     $navigation = CRM_Core_DAO::executeQuery($query);
-    $config = CRM_Core_Config::singleton();
     while ($navigation->fetch()) {
-      $label = $navigation->label;
-      if (!$navigationMenu) {
-        $label = addcslashes($label, '"');
-      }
-
-      // for each menu get their children
       $navigationTree[$navigation->id] = array(
         'attributes' => array(
-          'label' => $label,
+          'label' => $navigation->label,
           'name' => $navigation->name,
           'url' => $navigation->url,
           'permission' => $navigation->permission,
@@ -313,75 +293,69 @@ ORDER BY parent_id, weight";
           'active' => $navigation->is_active,
         ),
       );
-      self::buildNavigationTree($navigationTree[$navigation->id]['child'], $navigation->id, $navigationMenu);
     }
 
-    return $navigationTree;
+    return self::buildTree($navigationTree);
   }
 
   /**
-   * Build menu.
+   * Convert flat array to nested.
+   *
+   * @param array $elements
+   * @param int|null $parentId
    *
-   * @param bool $json
-   *   By default output is html.
-   * @param bool $navigationMenu
-   *   True when called for building top navigation menu.
+   * @return array
+   */
+  private static function buildTree($elements, $parentId = NULL) {
+    $branch = array();
+
+    foreach ($elements as $id => $element) {
+      if ($element['attributes']['parentID'] == $parentId) {
+        $children = self::buildTree($elements, $id);
+        if ($children) {
+          $element['child'] = $children;
+        }
+        $branch[$id] = $element;
+      }
+    }
+
+    return $branch;
+  }
+
+  /**
+   * Build menu.
    *
    * @return string
-   *   html or json string
    */
-  public static function buildNavigation($json = FALSE, $navigationMenu = TRUE) {
-    $navigations = array();
-    self::buildNavigationTree($navigations, $parent = NULL, $navigationMenu);
-    $navigationString = NULL;
+  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);
 
-    $i18n = CRM_Core_I18n::singleton();
-
     //skip children menu item if user don't have access to parent menu item
     $skipMenuItems = array();
     foreach ($navigations as $key => $value) {
-      if ($json) {
-        if ($navigationString) {
-          $navigationString .= '},';
-        }
-        $data = $value['attributes']['label'];
-        $class = '';
-        if (!$value['attributes']['active']) {
-          $class = ', "attr": { "class" : "disabled"} ';
-        }
-        $l10nName = $i18n->crm_translate($data, array('context' => 'menu'));
-        $navigationString .= ' { "attr": { "id" : "node_' . $key . '"}, "data": { "title":"' . $l10nName . '"' . $class . '}';
-      }
-      else {
-        // 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;
+      // 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, $json, $skipMenuItems);
+      self::recurseNavigation($value, $navigationString, $skipMenuItems);
     }
 
-    if ($json) {
-      $navigationString = '[' . $navigationString . '}]';
-    }
-    else {
-      // 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);
-    }
+    // 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;
   }
@@ -391,74 +365,40 @@ ORDER BY parent_id, weight";
    *
    * @param array $value
    * @param string $navigationString
-   * @param bool $json
-   * @param bool $skipMenuItems
+   * @param array $skipMenuItems
    *
    * @return string
    */
-  public static function recurseNavigation(&$value, &$navigationString, $json, $skipMenuItems) {
-    if ($json) {
-      if (!empty($value['child'])) {
-        $navigationString .= ', "children": [ ';
-      }
-      else {
-        return $navigationString;
-      }
-
-      if (!empty($value['child'])) {
-        $appendComma = TRUE;
-        $count = 1;
-        foreach ($value['child'] as $k => $val) {
-          if ($count == count($value['child'])) {
-            $appendComma = FALSE;
-          }
-          $data = $val['attributes']['label'];
-          $class = '';
-          if (!$val['attributes']['active']) {
-            $class = ', "attr": { "class" : "disabled"} ';
-          }
-          $navigationString .= ' { "attr": { "id" : "node_' . $k . '"}, "data": { "title":"' . $data . '"' . $class . '}';
-          self::recurseNavigation($val, $navigationString, $json, $skipMenuItems);
-          $navigationString .= $appendComma ? ' },' : ' }';
-          $count++;
-        }
-      }
-
-      if (!empty($value['child'])) {
-        $navigationString .= ' ]';
-      }
+  public static function recurseNavigation(&$value, &$navigationString, $skipMenuItems) {
+    if (!empty($value['child'])) {
+      $navigationString .= '<ul>';
     }
     else {
-      if (!empty($value['child'])) {
-        $navigationString .= '<ul>';
-      }
-      else {
-        $navigationString .= '</li>';
-        //locate separator after
-        if (isset($value['attributes']['separator']) && $value['attributes']['separator'] == 1) {
-          $navigationString .= '<li class="menu-separator"></li>';
-        }
+      $navigationString .= '</li>';
+      //locate separator after
+      if (isset($value['attributes']['separator']) && $value['attributes']['separator'] == 1) {
+        $navigationString .= '<li class="menu-separator"></li>';
       }
+    }
 
-      if (!empty($value['child'])) {
-        foreach ($value['child'] as $val) {
-          $name = self::getMenuName($val, $skipMenuItems);
-          if ($name) {
-            //locate separator before
-            if (isset($val['attributes']['separator']) && $val['attributes']['separator'] == 2) {
-              $navigationString .= '<li class="menu-separator"></li>';
-            }
-            $removeCharacters = array('/', '!', '&', '*', ' ', '(', ')', '.');
-            $navigationString .= '<li class="crm-' . str_replace($removeCharacters, '_', $val['attributes']['label']) . '">' . $name;
-            self::recurseNavigation($val, $navigationString, $json, $skipMenuItems);
+    if (!empty($value['child'])) {
+      foreach ($value['child'] as $val) {
+        $name = self::getMenuName($val, $skipMenuItems);
+        if ($name) {
+          //locate separator before
+          if (isset($val['attributes']['separator']) && $val['attributes']['separator'] == 2) {
+            $navigationString .= '<li class="menu-separator"></li>';
           }
+          $removeCharacters = array('/', '!', '&', '*', ' ', '(', ')', '.');
+          $navigationString .= '<li class="crm-' . str_replace($removeCharacters, '_', $val['attributes']['label']) . '">' . $name;
+          self::recurseNavigation($val, $navigationString, $skipMenuItems);
         }
       }
-      if (!empty($value['child'])) {
-        $navigationString .= '</ul></li>';
-        if (isset($value['attributes']['separator']) && $value['attributes']['separator'] == 1) {
-          $navigationString .= '<li class="menu-separator"></li>';
-        }
+    }
+    if (!empty($value['child'])) {
+      $navigationString .= '</ul></li>';
+      if (isset($value['attributes']['separator']) && $value['attributes']['separator'] == 1) {
+        $navigationString .= '<li class="menu-separator"></li>';
       }
     }
     return $navigationString;
@@ -836,26 +776,6 @@ ORDER BY parent_id, weight";
     CRM_Core_DAO::executeQuery($query);
   }
 
-  /**
-   * Get the info on navigation item.
-   *
-   * @param int $navigationID
-   *   Navigation id.
-   *
-   * @return array
-   *   associated array
-   */
-  public static function getNavigationInfo($navigationID) {
-    $query = "SELECT parent_id, weight FROM civicrm_navigation WHERE id = %1";
-    $params = array($navigationID, 'Integer');
-    $dao = CRM_Core_DAO::executeQuery($query, array(1 => $params));
-    $dao->fetch();
-    return array(
-      'parent_id' => $dao->parent_id,
-      'weight' => $dao->weight,
-    );
-  }
-
   /**
    * Update menu.
    *
index 7a6931400c535b966aae4ff4bb8ea0f152e43177..d0f0afc71b45f901d632606f9d4de40622ff9f57 100644 (file)
@@ -184,4 +184,39 @@ class CRM_Core_BAO_OptionGroup extends CRM_Core_DAO_OptionGroup {
     }
   }
 
+  /**
+   * Get the title of an option group by name.
+   *
+   * @param string $name
+   *   The name value for the option group table.
+   *
+   * @return string
+   *   The relevant title.
+   */
+  public static function getTitleByName($name) {
+    $groups = self::getTitlesByNames();
+    return $groups[$name];
+  }
+
+  /**
+   * Get a cached mapping of all group titles indexed by their unique name.
+   *
+   * We tend to only have a limited number of option groups so memory caching
+   * makes more sense than multiple look-ups.
+   *
+   * @return array
+   *   Array of all group titles by name.
+   *   e.g
+   *   array('activity_status' => 'Activity Status', 'msg_mode' => 'Message Mode'....)
+   */
+  public static function getTitlesByNames() {
+    if (!isset(\Civi::$statics[__CLASS__]) || !isset(\Civi::$statics[__CLASS__]['titles_by_name'])) {
+      $dao = CRM_Core_DAO::executeQuery("SELECT name, title FROM civicrm_option_group");
+      while ($dao->fetch()) {
+        \Civi::$statics[__CLASS__]['titles_by_name'][$dao->name] = $dao->title;
+      }
+    }
+    return \Civi::$statics[__CLASS__]['titles_by_name'];
+  }
+
 }
index ed1e367bd41d28c9e36183937e45361abc1fdd99..b6e19a8c6b4158a7f008157290cba33cf9e1b0b6 100644 (file)
@@ -282,7 +282,7 @@ FROM   civicrm_prevnext_cache pn
 
       if (!empty($select)) {
         $extraData = array();
-        foreach ($select as $dfield => $sfield) {
+        foreach ($select as $sfield) {
           $extraData[$sfield]  = $dao->$sfield;
         }
         $main[$count] = array(
index c1b4ae44f41b3c543e4f011b6acdb9cf9a9f2da2..936998aa9919e99741665f694cf8dcccdcf1154e 100644 (file)
@@ -395,8 +395,8 @@ class CRM_Core_BAO_Tag extends CRM_Core_DAO_Tag {
    *   (optional) the array that holds all the db ids - we are moving away from this in bao.
    * signatures
    *
-   * @return object
-   *   CRM_Core_DAO_Tag object on success, otherwise null
+   * @return CRM_Core_DAO_Tag|null
+   *   object on success, otherwise null
    */
   public static function add(&$params, $ids = array()) {
     $id = CRM_Utils_Array::value('id', $params, CRM_Utils_Array::value('tag', $ids));
@@ -411,6 +411,13 @@ class CRM_Core_BAO_Tag extends CRM_Core_DAO_Tag {
       // get parent details
       $params['used_for'] = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Tag', $params['parent_id'], 'used_for');
     }
+    elseif (isset($params['used_for']) && is_array($params['used_for'])) {
+      $params['used_for'] = implode(',', $params['used_for']);
+    }
+
+    if (isset($params['color']) && strtolower($params['color']) === '#ffffff') {
+      $params['color'] = '';
+    }
 
     $tag->copyValues($params);
     $tag->id = $id;
@@ -428,10 +435,11 @@ class CRM_Core_BAO_Tag extends CRM_Core_DAO_Tag {
     CRM_Utils_Hook::post($hook, 'Tag', $tag->id, $tag);
 
     // if we modify parent tag, then we need to update all children
-    if ($tag->parent_id === 'null') {
+    $tag->find(TRUE);
+    if (!$tag->parent_id && $tag->used_for) {
       CRM_Core_DAO::executeQuery("UPDATE civicrm_tag SET used_for=%1 WHERE parent_id = %2",
         array(
-          1 => array($params['used_for'], 'String'),
+          1 => array($tag->used_for, 'String'),
           2 => array($tag->id, 'Integer'),
         )
       );
index de3cb70ce0dd7fe8bd5fb50f0e19de093dfb635c..a1f53680799b07e029d929ca30700d62b9ce00fe 100644 (file)
@@ -348,9 +348,7 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup {
       $query = self::createUFFieldQuery($group->id, $searchable, $showAll, $visibility, $orderBy);
       $field = CRM_Core_DAO::executeQuery($query);
 
-      $profileType = CRM_Core_BAO_UFField::getProfileType($group->id);
-      $contactActivityProfile = CRM_Core_BAO_UFField::checkContactActivityProfileType($group->id);
-      $importableFields = self::getImportableFields($showAll, $profileType, $contactActivityProfile);
+      $importableFields = self::getProfileFieldMetadata($showAll);
       list($customFields, $addressCustomFields) = self::getCustomFields($ctype);
 
       while ($field->fetch()) {
@@ -478,6 +476,7 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup {
     if (isset($field->phone_type_id)) {
       $name .= "-{$field->phone_type_id}";
     }
+    $fieldMetaData = CRM_Utils_Array::value($name, $importableFields, (isset($importableFields[$field->field_name]) ? $importableFields[$field->field_name] : array()));
 
     // No lie: this is bizarre; why do we need to mix so many UFGroup properties into UFFields?
     // I guess to make field self sufficient with all the required data and avoid additional calls
@@ -515,8 +514,15 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup {
         CRM_Utils_Array::value($field->field_name, $importableFields)
       ),
       'skipDisplay' => 0,
+      'data_type' => CRM_Utils_Type::getDataTypeFromFieldMetadata($fieldMetaData),
+      'bao' => CRM_Utils_Array::value('bao', $fieldMetaData),
     );
 
+    $formattedField = CRM_Utils_Date::addDateMetadataToField($fieldMetaData, $formattedField);
+    if (in_array($name, array_keys(self::getNonUpgradedDateFields()))) {
+      $formattedField['is_legacy_date'] = 1;
+    }
+
     //adding custom field property
     if (substr($field->field_name, 0, 6) == 'custom' ||
       substr($field->field_name, 0, 14) === 'address_custom'
@@ -527,12 +533,13 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup {
         $formattedField['is_search_range'] = $customFields[$field->field_name]['is_search_range'];
         // fix for CRM-1994
         $formattedField['options_per_line'] = $customFields[$field->field_name]['options_per_line'];
-        $formattedField['data_type'] = $customFields[$field->field_name]['data_type'];
         $formattedField['html_type'] = $customFields[$field->field_name]['html_type'];
 
         if (CRM_Utils_Array::value('html_type', $formattedField) == 'Select Date') {
           $formattedField['date_format'] = $customFields[$field->field_name]['date_format'];
           $formattedField['time_format'] = $customFields[$field->field_name]['time_format'];
+          $formattedField['is_datetime_field'] = TRUE;
+          $formattedField['smarty_view_format'] = CRM_Utils_Date::getDateFieldViewFormat($formattedField['date_format']);
         }
 
         $formattedField['is_multi_summary'] = $field->is_multi_summary;
@@ -636,13 +643,24 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup {
   }
 
   /**
+   * Get a list of filtered field metadata.
+   *
+   * @deprecated use getProfileFieldMetadata
+   *
    * @param $showAll
    * @param $profileType
    * @param $contactActivityProfile
+   * @param bool $filterMode
+   *   Filter mode means you are using importable fields for filtering rather than just getting metadata.
+   *   With filter mode = FALSE BOTH activity fields and component fields are returned.
+   *   I can't see why you would ever want to use this function in filter mode as the component fields are
+   *   still unfiltered. However, I feel scared enough to leave it as it is. I have marked this function as
+   *   deprecated and am recommending the wrapper 'getProfileFieldMetadata' in order to try to
+   *   send this confusion to history.
    *
    * @return array
    */
-  protected static function getImportableFields($showAll, $profileType, $contactActivityProfile) {
+  protected static function getImportableFields($showAll, $profileType, $contactActivityProfile, $filterMode = TRUE) {
     if (!$showAll) {
       $importableFields = CRM_Contact_BAO_Contact::importableFields('All', FALSE, FALSE, FALSE, TRUE, TRUE);
     }
@@ -650,15 +668,20 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup {
       $importableFields = CRM_Contact_BAO_Contact::importableFields('All', FALSE, TRUE, FALSE, TRUE, TRUE);
     }
 
-    if ($profileType == 'Activity' || $contactActivityProfile) {
-      $componentFields = CRM_Activity_BAO_Activity::getProfileFields();
+    $activityFields = CRM_Activity_BAO_Activity::getProfileFields();
+    $componentFields = CRM_Core_Component::getQueryFields();
+    if ($filterMode == TRUE) {
+      if ($profileType == 'Activity' || $contactActivityProfile) {
+        $importableFields = array_merge($importableFields, $activityFields);
+      }
+      else {
+        $importableFields = array_merge($importableFields, $componentFields);
+      }
     }
     else {
-      $componentFields = CRM_Core_Component::getQueryFields();
+      $importableFields = array_merge($importableFields, $activityFields, $componentFields);
     }
 
-    $importableFields = array_merge($importableFields, $componentFields);
-
     $importableFields['group']['title'] = ts('Group(s)');
     $importableFields['group']['where'] = NULL;
     $importableFields['tag']['title'] = ts('Tag(s)');
@@ -666,6 +689,19 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup {
     return $importableFields;
   }
 
+  /**
+   * Get the metadata for all potential profile fields.
+   *
+   * @param bool $isIncludeInactive
+   *   Should disabled fields be included.
+   *
+   * @return array
+   *   Field metadata for all fields that might potentially be in a profile.
+   */
+  protected static function getProfileFieldMetadata($isIncludeInactive) {
+    return self::getImportableFields($isIncludeInactive, NULL, NULL, NULL, TRUE);
+  }
+
   /**
    * Get the fields relating to locations.
    *
@@ -1039,19 +1075,6 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup {
           $idx = $name . '_id';
           $params[$index] = $details->$idx;
         }
-        elseif ($name === 'preferred_communication_method') {
-          $communicationFields = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'preferred_communication_method');
-          $compref = array();
-          $pref = explode(CRM_Core_DAO::VALUE_SEPARATOR, $details->$name);
-
-          foreach ($pref as $k) {
-            if ($k) {
-              $compref[] = $communicationFields[$k];
-            }
-          }
-          $params[$index] = $details->$name;
-          $values[$index] = implode(',', $compref);
-        }
         elseif ($name === 'preferred_language') {
           $params[$index] = $details->$name;
           $values[$index] = CRM_Core_PseudoConstant::getLabel('CRM_Contact_DAO_Contact', 'preferred_language', $details->$name);
@@ -1063,7 +1086,7 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup {
           foreach ($groups as $g) {
             // CRM-8362: User and User Admin visibility groups should be included in display if user has
             // VIEW permission on that group
-            $groupPerm = CRM_Contact_BAO_Group::checkPermission($g['group_id'], $g['title']);
+            $groupPerm = CRM_Contact_BAO_Group::checkPermission($g['group_id'], TRUE);
 
             if ($g['visibility'] != 'User and User Admin Only' ||
               CRM_Utils_Array::key(CRM_Core_Permission::VIEW, $groupPerm)
@@ -1197,6 +1220,7 @@ class CRM_Core_BAO_UFGroup extends CRM_Core_DAO_UFGroup {
               'membership_end_date',
               'join_date',
             ))) {
+              // @todo this set should be determined from metadata, not hard-coded.
               $values[$index] = CRM_Utils_Date::customFormat($details->$name);
               $params[$index] = CRM_Utils_Date::isoToMysql($details->$name);
             }
@@ -1869,6 +1893,7 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
     $addressOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
       'address_options', TRUE, NULL, TRUE
     );
+    $legacyHandledDateFields = self::getNonUpgradedDateFields();
 
     if (substr($fieldName, 0, 14) === 'state_province') {
       $form->addChainSelect($name, array('label' => $title, 'required' => $required));
@@ -1931,15 +1956,8 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
         }
       }
     }
-    elseif (($fieldName === 'birth_date') || ($fieldName === 'deceased_date')) {
-      $form->addDate($name, $title, $required, array('formatType' => 'birth'));
-    }
-    elseif (in_array($fieldName, array(
-      'membership_start_date',
-      'membership_end_date',
-      'join_date',
-    ))) {
-      $form->addDate($name, $title, $required, array('formatType' => 'activityDate'));
+    elseif (isset($legacyHandledDateFields[$fieldName])) {
+      $form->addDate($name, $title, $required, array('formatType' => $legacyHandledDateFields[$fieldName]));
     }
     elseif (CRM_Utils_Array::value('name', $field) == 'membership_type') {
       list($orgInfo, $types) = CRM_Member_BAO_MembershipType::getMembershipTypeInfo();
@@ -2115,14 +2133,6 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
         CRM_Core_BAO_CustomField::addQuickFormElement($form, $name, $customFieldID, $required, $search, $title);
       }
     }
-    elseif (in_array($fieldName, array(
-      'receive_date',
-      'receipt_date',
-      'thankyou_date',
-      'cancel_date',
-    ))) {
-      $form->addDateTime($name, $title, $required, array('formatType' => 'activityDateTime'));
-    }
     elseif ($fieldName == 'send_receipt') {
       $form->addElement('checkbox', $name, $title);
     }
@@ -2194,9 +2204,6 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
         ) + CRM_Contribute_PseudoConstant::contributionPage(), $required, 'class="big"'
       );
     }
-    elseif ($fieldName == 'participant_register_date') {
-      $form->addDateTime($name, $title, $required, array('formatType' => 'activityDateTime'));
-    }
     elseif ($fieldName == 'activity_status_id') {
       $form->add('select', $name, $title,
         array(
@@ -2211,9 +2218,6 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
         ) + CRM_Campaign_PseudoConstant::engagementLevel(), $required
       );
     }
-    elseif ($fieldName == 'activity_date_time') {
-      $form->addDateTime($name, $title, $required, array('formatType' => 'activityDateTime'));
-    }
     elseif ($fieldName == 'participant_status') {
       $cond = NULL;
       if ($online == TRUE) {
@@ -2269,6 +2273,11 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
       if (substr($fieldName, 0, 3) === 'is_' or substr($fieldName, 0, 7) === 'do_not_') {
         $form->add('advcheckbox', $name, $title, $attributes, $required);
       }
+      elseif (CRM_Utils_Array::value('html_type', $field) === 'Select Date') {
+        $extra = isset($field['datepicker']) ? $field['datepicker']['extra'] : CRM_Utils_Date::getDatePickerExtra($field);
+        $attributes = isset($field['datepicker']) ? $field['datepicker']['attributes'] : CRM_Utils_Date::getDatePickerAttributes($field);
+        $form->add('datepicker', $name, $title, $attributes, $required, $extra);
+      }
       else {
         $form->add('text', $name, $title, $attributes, $required);
       }
@@ -2311,6 +2320,26 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
     }
   }
 
+  /**
+   * Get fields that have not been upgraded to use datepicker.
+   *
+   * Fields that use the old code have jcalendar in the tpl and
+   * the form uses a customised format. We are moving towards datepicker
+   * which among other things passes dates back and forth using a standardised
+   * format. Remove fields from here as they are tested and converted.
+   */
+  static public function getNonUpgradedDateFields() {
+    return array(
+      'membership_start_date' => 'activityDate',
+      'membership_end_date' => 'activityDate',
+      'join_date' => 'activityDate',
+      'receive_date' => 'activityDateTime',
+      'receipt_date' => 'activityDateTime',
+      'thankyou_date' => 'activityDateTime',
+      'cancel_date' => 'activityDateTime',
+    );
+  }
+
   /**
    * Set profile defaults.
    *
@@ -2361,10 +2390,7 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
         if (!empty($details[$name]) || isset($details[$name])) {
           //to handle custom data (checkbox) to be written
           // to handle birth/deceased date, greeting_type and few other fields
-          if (($name == 'birth_date') || ($name == 'deceased_date')) {
-            list($defaults[$fldName]) = CRM_Utils_Date::setDateDefaults($details[$name], 'birth');
-          }
-          elseif (in_array($name, CRM_Contact_BAO_Contact::$_greetingTypes)) {
+          if (in_array($name, CRM_Contact_BAO_Contact::$_greetingTypes)) {
             $defaults[$fldName] = $details[$name . '_id'];
             $defaults[$name . '_custom'] = $details[$name . '_custom'];
           }
@@ -2383,7 +2409,7 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
             $defaults[$fldName] = $details['worldregion_id'];
           }
           elseif ($customFieldId = CRM_Core_BAO_CustomField::getKeyID($name)) {
-            //fix for custom fields
+            // @todo retrieving the custom fields here seems obsolete - $field holds more data for the fields.
             $customFields = CRM_Core_BAO_CustomField::getFields(CRM_Utils_Array::value('contact_type', $details));
 
             // hack to add custom data for components
@@ -2420,24 +2446,30 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
                 break;
 
               case 'Select Date':
-                // CRM-6681, set defult values according to date and time format (if any).
-                $dateFormat = NULL;
-                if (!empty($customFields[$customFieldId]['date_format'])) {
-                  $dateFormat = $customFields[$customFieldId]['date_format'];
-                }
-
-                if (empty($customFields[$customFieldId]['time_format'])) {
-                  list($defaults[$fldName]) = CRM_Utils_Date::setDateDefaults($details[$name], NULL,
-                    $dateFormat
-                  );
+                if (!in_array($name, array_keys(self::getNonUpgradedDateFields()))) {
+                  $defaults[$fldName] = $details[$name];
                 }
                 else {
-                  $timeElement = $fldName . '_time';
-                  if (substr($fldName, -1) == ']') {
-                    $timeElement = substr($fldName, 0, -1) . '_time]';
+                  // Do legacy handling.
+                  // CRM-6681, set defult values according to date and time format (if any).
+                  $dateFormat = NULL;
+                  if (!empty($customFields[$customFieldId]['date_format'])) {
+                    $dateFormat = $customFields[$customFieldId]['date_format'];
+                  }
+
+                  if (empty($customFields[$customFieldId]['time_format'])) {
+                    list($defaults[$fldName]) = CRM_Utils_Date::setDateDefaults($details[$name], NULL,
+                      $dateFormat
+                    );
+                  }
+                  else {
+                    $timeElement = $fldName . '_time';
+                    if (substr($fldName, -1) == ']') {
+                      $timeElement = substr($fldName, 0, -1) . '_time]';
+                    }
+                    list($defaults[$fldName], $defaults[$timeElement]) = CRM_Utils_Date::setDateDefaults($details[$name],
+                      NULL, $dateFormat, $customFields[$customFieldId]['time_format']);
                   }
-                  list($defaults[$fldName], $defaults[$timeElement]) = CRM_Utils_Date::setDateDefaults($details[$name],
-                    NULL, $dateFormat, $customFields[$customFieldId]['time_format']);
                 }
                 break;
 
@@ -3254,17 +3286,9 @@ AND    ( entity_id IS NULL OR entity_id <= 0 )
     }
 
     $formattedGroupTree = array();
-    $dateTimeFields = array(
-      'participant_register_date',
-      'activity_date_time',
-      'receive_date',
-      'receipt_date',
-      'cancel_date',
-      'thankyou_date',
-      'membership_start_date',
-      'membership_end_date',
-      'join_date',
-    );
+    // @todo - as we put these on datepicker they need to be removed from here.
+    $dateTimeFields = array_keys(self::getNonUpgradedDateFields());
+
     foreach ($fields as $name => $field) {
       $fldName = $isStandalone ? $name : "field[$componentId][$name]";
       if (in_array($name, $dateTimeFields)) {
index bfd6a9b5cdfba3c1abd4e1e9068717573d5983b0..f20be6680d358810a9a5ca71e877c0d2f77f0f49 100644 (file)
@@ -356,9 +356,10 @@ AND    domain_id    = %4
    *   Id of the contact to update.
    */
   public static function updateUFName($contactId) {
-    if (!$contactId) {
+    if (!Civi::settings()->get('syncCMSEmail') || !$contactId) {
       return;
     }
+
     $config = CRM_Core_Config::singleton();
     $ufName = CRM_Contact_BAO_Contact::getPrimaryEmail($contactId);
 
@@ -420,6 +421,11 @@ AND    domain_id    = %4
       $ufmatch->uf_name = $emailAddress;
       CRM_Core_BAO_UFMatch::create((array) $ufmatch);
 
+      // If CMS integration is disabled skip Civi email update if CMS user email is changed
+      if (Civi::settings()->get('syncCMSEmail') == FALSE) {
+        return;
+      }
+
       //check if the primary email for the contact exists
       //$contactDetails[1] - email
       //$contactDetails[3] - email id
index dbebd3291ff1e3f1a0e7bd6a4f2e4c6626c6dae1..2a94606859b04cf3beefd79a7ac5506379ce0bd6 100644 (file)
@@ -365,7 +365,7 @@ class CRM_Core_CodeGen_Specification {
     if (!empty($field['html'])) {
       $validOptions = array(
         'type',
-        'format',
+        'formatType',
         /* Fixme: prior to CRM-13497 these were in a flat structure
         // CRM-13497 moved them to be nested within 'html' but there's no point
         // making that change in the DAOs right now since we are in the process of
index 2c4d8992b7a1f9f34912d31b34c8ebbf4596d417..49091efd76a9cb3d57cf0e68f1ac4d77f6307715 100644 (file)
@@ -480,7 +480,7 @@ class CRM_Core_DAO extends DB_DataObject {
 
       if ($hook) {
         $event = new \Civi\Core\DAO\Event\PostUpdate($this);
-        \Civi::service('dispatcher')->dispatch("DAO::post-update", $event);
+        \Civi::service('dispatcher')->dispatch("civi.dao.postUpdate", $event);
       }
     }
     else {
@@ -488,7 +488,7 @@ class CRM_Core_DAO extends DB_DataObject {
 
       if ($hook) {
         $event = new \Civi\Core\DAO\Event\PostUpdate($this);
-        \Civi::service('dispatcher')->dispatch("DAO::post-insert", $event);
+        \Civi::service('dispatcher')->dispatch("civi.dao.postInsert", $event);
       }
     }
     $this->free();
@@ -529,7 +529,7 @@ class CRM_Core_DAO extends DB_DataObject {
     $result = parent::delete($useWhere);
 
     $event = new \Civi\Core\DAO\Event\PostDelete($this, $result);
-    \Civi::service('dispatcher')->dispatch("DAO::post-delete", $event);
+    \Civi::service('dispatcher')->dispatch("civi.dao.postDelete", $event);
     $this->free();
 
     return $result;
@@ -2154,6 +2154,30 @@ SELECT contact_id
     }
   }
 
+
+  /**
+   * Update the fields array to also hold keys for pseudoconstant fields that relate to contained fields.
+   *
+   * This is relevant where we want to offer both the ID field and the label field
+   * as an option, e.g. search builder.
+   *
+   * It is currently limited for optionGroupName for purposes keeping the scope of the
+   * change small, but is appropriate for other sorts of pseudoconstants.
+   *
+   * @param array $fields
+   */
+  protected 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,
+        );
+      }
+    }
+  }
+
   /**
    * Get options for the called BAO object's field.
    *
index 4e8aa5d24d7e046d1957f8851430450b76e2c7c7..8282834d468c24beae5f45b668a15d7630f193a1 100644 (file)
@@ -24,7 +24,7 @@
 | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
 +--------------------------------------------------------------------+
 */
-// (GenCodeChecksum:5846411ffbd219fb1d7ead90f03e49a4)
+// (GenCodeChecksum:b66a5c6ab79bec53c7781738c148e525)
 return array(
   'CRM_Core_DAO_AddressFormat' => array(
     'name' => 'AddressFormat',
index 07dfc50b8745acea10646bec94a9791ad6397e7f..81b470bbc0260adc65d70b8ffb018efc9a0210c4 100644 (file)
@@ -310,6 +310,11 @@ class CRM_Core_Error extends PEAR_ErrorStack {
   /**
    * Display an error page with an error message describing what happened.
    *
+   * @deprecated
+   *  This is a really annoying function. We ❤ exceptions. Be exceptional!
+   *
+   * @see CRM-20181
+   *
    * @param string $message
    *   The error message.
    * @param string $code
index fadce93d65a196bd7b2ed04ebe999ddccfe49726..12c864b158b8a206d2ffd30a3b8f38329045344e 100644 (file)
@@ -337,6 +337,8 @@ class CRM_Core_Form extends HTML_QuickForm_Page {
    * @param bool $required
    * @param array $extra
    *   (attributes for select elements).
+   *   For datepicker elements this is consistent with the data
+   *   from CRM_Utils_Date::getDatePickerExtra
    *
    * @return HTML_QuickForm_Element
    *   Could be an error object
@@ -1364,11 +1366,16 @@ class CRM_Core_Form extends HTML_QuickForm_Page {
    *   - multiple - bool
    *   - context - @see CRM_Core_DAO::buildOptionsContext
    * @param bool $required
+   * @param bool $legacyDate
+   *   Temporary param to facilitate the conversion of fields to use the datepicker in
+   *   a controlled way. To convert the field the jcalendar code needs to be removed from the
+   *   tpl as well. That file is intended to be EOL.
+   *
    * @throws \CiviCRM_API3_Exception
    * @throws \Exception
    * @return HTML_QuickForm_Element
    */
-  public function addField($name, $props = array(), $required = FALSE) {
+  public function addField($name, $props = array(), $required = FALSE, $legacyDate = TRUE) {
     // Resolve context.
     if (empty($props['context'])) {
       $props['context'] = $this->getDefaultContext();
@@ -1453,10 +1460,19 @@ class CRM_Core_Form extends HTML_QuickForm_Page {
         return $this->add('textarea', $name, $label, $props, $required);
 
       case 'Select Date':
-        //TODO: add range support
-        //TODO: Add date formats
-        //TODO: Add javascript template for dates.
-        return $this->addDate($name, $label, $required, $props);
+        // This is a white list for fields that have been tested with
+        // date picker. We should be able to remove the other
+        if ($legacyDate) {
+          //TODO: add range support
+          //TODO: Add date formats
+          //TODO: Add javascript template for dates.
+          return $this->addDate($name, $label, $required, $props);
+        }
+        else {
+          $fieldSpec = CRM_Utils_Date::addDateMetadataToField($fieldSpec, $fieldSpec);
+          $attributes = array('format' => $fieldSpec['date_format']);
+          return $this->add('datepicker', $name, $label, $attributes, $required, $fieldSpec['datepicker']['extra']);
+        }
 
       case 'Radio':
         $separator = isset($props['separator']) ? $props['separator'] : NULL;
index 8fdecdfdb5f91ba4ddeeff7e2d5540b4fd064415..1227803a5fbeb173d2898a5d63ec81e80e4e0118 100644 (file)
@@ -109,6 +109,7 @@ class CRM_Core_OptionGroup {
    * @param string $keyColumnName
    *   the column to use for 'key'.
    * @param string $orderBy
+   *   the column to use for ordering.
    *
    * @return array
    *   The values as specified by the params
@@ -120,7 +121,7 @@ class CRM_Core_OptionGroup {
     $orderBy = 'weight'
   ) {
     $cache = CRM_Utils_Cache::singleton();
-    $cacheKey = self::createCacheKey($name, $flip, $grouping, $localize, $condition, $labelColumnName, $onlyActive, $keyColumnName);
+    $cacheKey = self::createCacheKey($name, $flip, $grouping, $localize, $condition, $labelColumnName, $onlyActive, $keyColumnName, $orderBy);
 
     if (!$fresh) {
       // Fetch from static var
@@ -144,6 +145,14 @@ WHERE  v.option_group_id = g.id
 
     if ($onlyActive) {
       $query .= " AND  v.is_active = 1 ";
+      // Only show options for enabled components
+      $componentClause = ' v.component_id IS NULL ';
+      $enabledComponents = CRM_Core_Config::singleton()->enableComponents;
+      if ($enabledComponents) {
+        $enabledComponents = '"' . implode('","', $enabledComponents) . '"';
+        $componentClause .= " OR v.component_id IN (SELECT id FROM civicrm_component WHERE name IN ($enabledComponents)) ";
+      }
+      $query .= " AND ($componentClause) ";
     }
     if (in_array($name, self::$_domainIDGroups)) {
       $query .= " AND v.domain_id = " . CRM_Core_Config::domainID();
@@ -253,9 +262,9 @@ WHERE  v.option_group_id = g.id
   }
 
   /**
-   * Lookup titles OR ids for a set of option_value populated fields. The retrieved value
-   * is assigned a new fieldname by id or id's by title
-   * (each within a specificied option_group)
+   * Lookup titles OR ids for a set of option_value populated fields. The
+   * retrieved value is assigned a new field name by id or id's by title
+   * (each within a specified option_group).
    *
    * @param array $params
    *   Reference array of values submitted by the form. Based on.
@@ -265,14 +274,13 @@ WHERE  v.option_group_id = g.id
    *   If $flip = true, adds actual field name => id
    *
    * @param array $names
-   *   Reference array of fieldnames we want transformed.
+   *   Array of field names we want transformed.
    *   Array key = 'postName' (field name submitted by form in $params).
    *   Array value = array('newName' => $newName, 'groupName' => $groupName).
    *
-   *
    * @param bool $flip
    */
-  public static function lookupValues(&$params, &$names, $flip = FALSE) {
+  public static function lookupValues(&$params, $names, $flip = FALSE) {
     foreach ($names as $postName => $value) {
       // See if $params field is in $names array (i.e. is a value that we need to lookup)
       if ($postalName = CRM_Utils_Array::value($postName, $params)) {
index 4167e81023662aa9cc69b70955be211cf9233706..fe0f2b0732727357f70dfae760109868e3fa81cd 100644 (file)
@@ -406,4 +406,28 @@ class CRM_Core_Page {
     $this->$name = $value;
   }
 
+  /**
+   * Assign metadata about fields to the template.
+   *
+   * In order to allow the template to format fields we assign information about them to the template.
+   *
+   * At this stage only date field metadata is assigned as that is the only use-case in play and
+   * we don't want to assign a lot of unneeded data.
+   *
+   * @param string $entity
+   *   The entity being queried.
+   *
+   * @throws \CiviCRM_API3_Exception
+   */
+  protected function assignFieldMetadataToTemplate($entity) {
+    $fields = civicrm_api3($entity, 'getfields', array('action' => 'get'));
+    $dateFields = array();
+    foreach ($fields['values'] as $fieldName => $fieldMetaData) {
+      if (isset($fieldMetaData['html']) && CRM_Utils_Array::value('type', $fieldMetaData['html']) == 'Select Date') {
+        $dateFields[$fieldName] = CRM_Utils_Date::addDateMetadataToField($fieldMetaData, $fieldMetaData);
+      }
+    }
+    $this->assign('fields', $dateFields);
+  }
+
 }
index f4d116ae39a1a61e25b29da98a7d9ac06c1972ee..9aa58748696ecd29312f9e9baa135792d548de83 100644 (file)
@@ -340,7 +340,7 @@ class CRM_Core_Payment_PayPalIPN extends CRM_Core_Payment_BaseIPN {
     $paymentProcessorID = $this->retrieve('processor_id', 'Integer', FALSE);
     if (empty($paymentProcessorID)) {
       $processorParams = array(
-        'user_name' => $this->retrieve('receiver_email', 'String', FALSE),
+        'user_name' => $this->retrieve('business', 'String', FALSE),
         'payment_processor_type_id' => CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_PaymentProcessorType', 'PayPal_Standard', 'id', 'name'),
         'is_test' => empty($input['is_test']) ? 0 : 1,
       );
index 52815a69f74cb558db1ef6812a511e2480ac2700..cb46b981bdcc2844600b6aad51ead071f0da68a1 100644 (file)
@@ -740,9 +740,7 @@ class CRM_Core_Resources {
       $items[] = "packages/jquery/plugins/jquery.tableHeader.js";
       $items[] = "packages/jquery/plugins/jquery.menu.min.js";
       $items[] = "css/civicrmNavigation.css";
-      $items[] = "packages/jquery/plugins/jquery.jeditable.min.js";
       $items[] = "packages/jquery/plugins/jquery.notify.min.js";
-      $items[] = "js/jquery/jquery.crmeditable.js";
     }
 
     // JS for multilingual installations
index ba24f9d6a8dd757ed755bae92dd0cb34aa21f887..22416b15d222d8c1105c5d97ff3d6b51f6546c40 100644 (file)
@@ -311,7 +311,8 @@ class CRM_Core_SelectValues {
    * @return array
    *   the date array
    */
-  public static function date($type = NULL, $format = NULL, $minOffset = NULL, $maxOffset = NULL) {
+  public static function date($type = NULL, $format = NULL, $minOffset = NULL, $maxOffset = NULL, $context = 'display') {
+    // These options are deprecated. Definitely not used in datepicker. Possibly not even in jcalendar+addDateTime.
     $date = array(
       'addEmptyOption' => TRUE,
       'emptyOptionText' => ts('- select -'),
@@ -328,25 +329,35 @@ class CRM_Core_SelectValues {
         if (!$dao->find(TRUE)) {
           CRM_Core_Error::fatal();
         }
-      }
+        if (!$maxOffset) {
+          $maxOffset = $dao->end;
+        }
+        if (!$minOffset) {
+          $minOffset = $dao->start;
+        }
 
-      if ($type == 'creditCard') {
-        $minOffset = $dao->start;
-        $maxOffset = $dao->end;
         $date['format'] = $dao->date_format;
-        $date['addEmptyOption'] = TRUE;
-        $date['emptyOptionText'] = ts('- select -');
-        $date['emptyOptionValue'] = '';
+        $date['time'] = (bool) $dao->time_format;
       }
 
       if (empty($date['format'])) {
-        $date['format'] = 'M d';
+        if ($context == 'Input') {
+          $date['format'] = Civi::settings()->get('dateInputFormat');
+        }
+        else {
+          $date['format'] = 'M d';
+        }
       }
     }
 
+    $date['smarty_view_format'] = CRM_Utils_Date::getDateFieldViewFormat($date['format']);
+    if (!isset($date['time'])) {
+      $date['time'] = FALSE;
+    }
+
     $year = date('Y');
-    $date['minYear'] = $year - $minOffset;
-    $date['maxYear'] = $year + $maxOffset;
+    $date['minYear'] = $year - (int) $minOffset;
+    $date['maxYear'] = $year + (int) $maxOffset;
     return $date;
   }
 
@@ -752,32 +763,6 @@ class CRM_Core_SelectValues {
     return $dateInputFormats;
   }
 
-  /**
-   * Map date plugin and actual format that is used by PHP.
-   *
-   * @return array
-   */
-  public static function datePluginToPHPFormats() {
-    $dateInputFormats = array(
-      "mm/dd/yy" => 'm/d/Y',
-      "dd/mm/yy" => 'd/m/Y',
-      "yy-mm-dd" => 'Y-m-d',
-      "dd-mm-yy" => 'd-m-Y',
-      "dd.mm.yy" => 'd.m.Y',
-      "M d, yy" => 'M j, Y',
-      "d M yy" => 'j M Y',
-      "MM d, yy" => 'F j, Y',
-      "d MM yy" => 'j F Y',
-      "DD, d MM yy" => 'l, j F Y',
-      "mm/dd" => 'm/d',
-      "dd-mm" => 'd-m',
-      "yy-mm" => 'Y-m',
-      "M yy" => 'M Y',
-      "yy" => 'Y',
-    );
-    return $dateInputFormats;
-  }
-
   /**
    * Time formats.
    *
index b38e7f3c6776650341fd63a0371407d5bed5a4c9..3f5f6b6fb8b02c778c89283119ee205c2d50b97f 100644 (file)
@@ -56,6 +56,9 @@ function smarty_function_crmStyle($params, &$smarty) {
   if (empty($params['region'])) {
     $params['region'] = CRM_Core_Resources::DEFAULT_REGION;
   }
+  if (empty($params['ext'])) {
+    $params['ext'] = 'civicrm';
+  }
 
   if (array_key_exists('file', $params)) {
     $res->addStyleFile($params['ext'], $params['file'], $params['weight'], $params['region']);
index 718e8149790c685d77e74c708f41cf3b08acd038..4293f50622e5bc30a4d19c52eb99ba02ff2a3d18 100644 (file)
      <page_callback>CRM_Admin_Page_AJAX::getNavigationMenu</page_callback>
      <access_arguments>access CiviCRM</access_arguments>
   </item>
-  <item>
-     <path>civicrm/ajax/menu</path>
-     <page_callback>CRM_Admin_Page_AJAX::getNavigationList</page_callback>
-     <access_arguments>access CiviCRM,administer CiviCRM</access_arguments>
-     <page_type>3</page_type>
-  </item>
   <item>
      <path>civicrm/ajax/menutree</path>
      <page_callback>CRM_Admin_Page_AJAX::menuTree</page_callback>
      <page_callback>CRM_Admin_Page_AJAX::getStatusMsg</page_callback>
      <access_arguments>access CiviCRM</access_arguments>
   </item>
-  <item>
-     <path>civicrm/ajax/mergeTags</path>
-     <page_callback>CRM_Admin_Page_AJAX::mergeTags</page_callback>
-     <access_arguments>access CiviCRM</access_arguments>
-  </item>
   <item>
      <path>civicrm/admin/price</path>
      <title>Price Sets</title>
      <title>Price Field Options</title>
      <page_callback>CRM_Price_Page_Option</page_callback>
   </item>
-  <item>
-       <path>civicrm/ajax/mergeTagList</path>
-       <page_callback>CRM_Admin_Page_AJAX::mergeTagList</page_callback>
-       <access_arguments>access CiviCRM</access_arguments>
-  </item>
   <item>
      <path>civicrm/admin/tplstrings/add</path>
      <page_callback>CRM_Admin_Form_Persistent</page_callback>
index 139466d2466fbb5ed79c81de1bf3d4e5f077c4b7..092a67924b4469337f454e4193f27070c6241caf 100644 (file)
      <path>civicrm/contact/merge</path>
      <title>Merge Contact</title>
      <page_callback>CRM_Contact_Form_Merge</page_callback>
+     <access_arguments>merge duplicate contacts</access_arguments>
   </item>
   <item>
      <path>civicrm/contact/email</path>
index 104f89680643d545eb1c23d121331d1668ab5434..e05e6eed8b4a21a517d62f2b51656e9b9bb2e46d 100644 (file)
     <weight>25</weight>
   </item>
   <item>
-    <path>civicrm/tag/add</path>
+    <path>civicrm/tag/edit</path>
     <title>New Tag</title>
-    <page_callback>CRM_Tag_Page_Tag</page_callback>
+    <page_callback>CRM_Tag_Form_Edit</page_callback>
     <path_arguments>action=add</path_arguments>
     <access_arguments>administer CiviCRM;manage tags</access_arguments>
   </item>
+  <item>
+    <path>civicrm/tag/merge</path>
+    <title>Merge Tags</title>
+    <page_callback>CRM_Tag_Form_Merge</page_callback>
+    <access_arguments>administer CiviCRM;manage tags</access_arguments>
+  </item>
+  <item>
+    <path>civicrm/ajax/tagTree</path>
+    <page_callback>CRM_Admin_Page_AJAX::getTagTree</page_callback>
+    <access_arguments>administer CiviCRM;manage tags</access_arguments>
+  </item>
 </menu>
index 183dd63b7dd1ab527a7a4cfce5803eaadac079be..4f88b36282a6e75ece27c3f305247225d473f371 100644 (file)
@@ -589,8 +589,6 @@ INNER JOIN  civicrm_membership membership2 ON membership1.membership_type_id = m
    *   Helps decide how to behave when there are conflicts.
    *   A 'safe' value skips the merge if there are any un-resolved conflicts, wheras 'aggressive'
    *   mode does a force merge.
-   * @param bool $autoFlip to let api decide which contact to retain and which to delete.
-   *   Whether to let api decide which contact to retain and which to delete.
    * @param int $batchLimit number of merges to carry out in one batch.
    * @param int $isSelected if records with is_selected column needs to be processed.
    *
@@ -602,7 +600,7 @@ INNER JOIN  civicrm_membership membership2 ON membership1.membership_type_id = m
    *
    * @return array|bool
    */
-  public static function batchMerge($rgid, $gid = NULL, $mode = 'safe', $autoFlip = TRUE, $batchLimit = 1, $isSelected = 2, $criteria = array(), $checkPermissions = TRUE) {
+  public static function batchMerge($rgid, $gid = NULL, $mode = 'safe', $batchLimit = 1, $isSelected = 2, $criteria = array(), $checkPermissions = TRUE) {
     $redirectForPerformance = ($batchLimit > 1) ? TRUE : FALSE;
     $reloadCacheIfEmpty = (!$redirectForPerformance && $isSelected == 2);
     $dupePairs = self::getDuplicatePairs($rgid, $gid, $reloadCacheIfEmpty, $batchLimit, $isSelected, '', ($mode == 'aggressive'), $criteria, $checkPermissions);
@@ -614,7 +612,7 @@ INNER JOIN  civicrm_membership membership2 ON membership1.membership_type_id = m
       'join' => self::getJoinOnDedupeTable(),
       'where' => self::getWhereString($batchLimit, $isSelected),
     );
-    return CRM_Dedupe_Merger::merge($dupePairs, $cacheParams, $mode, $autoFlip, $redirectForPerformance, $checkPermissions);
+    return CRM_Dedupe_Merger::merge($dupePairs, $cacheParams, $mode, $redirectForPerformance, $checkPermissions);
   }
 
   /**
@@ -748,8 +746,6 @@ INNER JOIN  civicrm_membership membership2 ON membership1.membership_type_id = m
    *   Helps decide how to behave when there are conflicts.
    *                             A 'safe' value skips the merge if there are any un-resolved conflicts.
    *                             Does a force merge otherwise (aggressive mode).
-   * @param bool $autoFlip to let api decide which contact to retain and which to delete.
-   *   Whether to let api decide which contact to retain and which to delete.
    *
    * @param bool $redirectForPerformance
    *   Redirect to a url for batch processing.
@@ -760,7 +756,7 @@ INNER JOIN  civicrm_membership membership2 ON membership1.membership_type_id = m
    * @return array|bool
    */
   public static function merge($dupePairs = array(), $cacheParams = array(), $mode = 'safe',
-                               $autoFlip = TRUE, $redirectForPerformance = FALSE, $checkPermissions = TRUE
+     $redirectForPerformance = FALSE, $checkPermissions = TRUE
   ) {
     $cacheKeyString = CRM_Utils_Array::value('cache_key_string', $cacheParams);
     $resultStats = array('merged' => array(), 'skipped' => array());
@@ -1062,8 +1058,8 @@ INNER JOIN  civicrm_membership membership2 ON membership1.membership_type_id = m
     $qfZeroBug = 'e8cddb72-a257-11dc-b9cc-0016d3330ee9';
     $fields = self::getMergeFieldsMetadata();
 
-    $main = self::getMergeContactDetails($mainId, 'main');
-    $other = self::getMergeContactDetails($otherId, 'main');
+    $main = self::getMergeContactDetails($mainId);
+    $other = self::getMergeContactDetails($otherId);
     $specialValues['main'] = self::getSpecialValues($main);
     $specialValues['other'] = self::getSpecialValues($other);
 
@@ -1169,7 +1165,7 @@ INNER JOIN  civicrm_membership membership2 ON membership1.membership_type_id = m
         $values = civicrm_api3($blockName, 'get', $searchParams);
         if ($values['count']) {
           $cnt = 0;
-          foreach ($values['values'] as $index => $value) {
+          foreach ($values['values'] as $value) {
             $locations[$moniker][$blockName][$cnt] = $value;
             // Fix address display
             if ($blockName == 'address') {
@@ -1523,10 +1519,9 @@ INNER JOIN  civicrm_membership membership2 ON membership1.membership_type_id = m
         CRM_Core_DAO::$_nullObject, NULL, -1
       );
     }
-    $cgTree = &$treeCache[$migrationInfo['main_details']['contact_type']];
 
     $cFields = array();
-    foreach ($cgTree as $key => $group) {
+    foreach ($treeCache[$migrationInfo['main_details']['contact_type']] as $key => $group) {
       if (!isset($group['fields'])) {
         continue;
       }
@@ -1997,13 +1992,12 @@ INNER JOIN  civicrm_membership membership2 ON membership1.membership_type_id = m
    * Get the details of the contact to be merged.
    *
    * @param int $contact_id
-   * @param string $moniker
    *
    * @return array
    *
    * @throws CRM_Core_Exception
    */
-  public static function getMergeContactDetails($contact_id, $moniker) {
+  public static function getMergeContactDetails($contact_id) {
     $params = array(
       'contact_id' => $contact_id,
       'version' => 3,
@@ -2013,9 +2007,8 @@ INNER JOIN  civicrm_membership membership2 ON membership1.membership_type_id = m
 
     // CRM-18480: Cancel the process if the contact is already deleted
     if (isset($result['values'][$contact_id]['contact_is_deleted']) && !empty($result['values'][$contact_id]['contact_is_deleted'])) {
-      throw new CRM_Core_Exception(ts('Cannot merge because the \'%1\' contact (ID %2) has been deleted.', array(
-        1 => $moniker,
-        2 => $contact_id,
+      throw new CRM_Core_Exception(ts('Cannot merge because one contact (ID %1) has been deleted.', array(
+        1 => $contact_id,
       )));
     }
 
index 25347945cd7f711da670e02adf03d1daaeae6bbc..2b4dbc402ad42cc21e104676beae8afec80e585b 100644 (file)
@@ -648,6 +648,7 @@ GROUP BY  participant.event_id
           'title' => ts('Participant Note'),
           'name' => 'participant_note',
           'headerPattern' => '/(participant.)?note$/i',
+          'type' => 'text',
         ),
       );
 
index b497955e61579d90243b701ea8506c9e74b68b6a..8da34792f3d23bc1eaf6d8a6b4081618f707a1d5 100644 (file)
@@ -30,7 +30,7 @@
  *
  * Generated from xml/schema/CRM/Event/Participant.xml
  * DO NOT EDIT.  Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:3c53d2d7a62cf0428fef11b9df02fcd2)
+ * (GenCodeChecksum:87c3d1afa18e39e10ba019d773eb6ce8)
  */
 require_once 'CRM/Core/DAO.php';
 require_once 'CRM/Utils/Type.php';
@@ -310,7 +310,7 @@ class CRM_Event_DAO_Participant extends CRM_Core_DAO {
           'bao' => 'CRM_Event_BAO_Participant',
           'html' => array(
             'type' => 'Select Date',
-            'format' => 'activityDateTime',
+            'formatType' => 'activityDateTime',
           ) ,
         ) ,
         'participant_source' => array(
index 876e008096805ecf507f60f9015524f4cc0e9a9b..06216727c8fb8fe582f52b59a187736e60dcc438 100644 (file)
@@ -820,6 +820,7 @@ class CRM_Event_Form_Participant extends CRM_Contribute_Form_AbstractEditPayment
       if (empty($values['payment_instrument_id'])) {
         $errorMsg['payment_instrument_id'] = ts('Payment Method is a required field.');
       }
+      CRM_Price_BAO_PriceField::priceSetValidation($values['priceSetId'], $values, $errorMsg);
     }
 
     // validate contribution status for 'Failed'.
index 5143206ee79b0900640495e3c5d7acd00bd5368b..cf567cc3da36cfeaddddd41cc0e3d94f88268c9d 100644 (file)
@@ -1467,7 +1467,7 @@ WHERE  v.option_group_id = g.id
       $startDate &&
       $startDate >= $now
     ) {
-      CRM_Core_Error::statusBounce(ts('Registration for this event begins on %1', array(1 => CRM_Utils_Date::customFormat(CRM_Utils_Array::value('registration_start_date', $this->_values['event'])))), $redirect);
+      CRM_Core_Error::statusBounce(ts('Registration for this event begins on %1', array(1 => CRM_Utils_Date::customFormat(CRM_Utils_Array::value('registration_start_date', $this->_values['event'])))), $redirect, ts('Sorry'));
     }
 
     $regEndDate = CRM_Utils_Date::processDate(CRM_Utils_Array::value('registration_end_date',
@@ -1479,7 +1479,7 @@ WHERE  v.option_group_id = g.id
       if (empty($regEndDate)) {
         $endDate = CRM_Utils_Date::customFormat(CRM_Utils_Array::value('event_end_date', $this->_values['event']));
       }
-      CRM_Core_Error::statusBounce(ts('Registration for this event ended on %1', array(1 => $endDate)), $redirect);
+      CRM_Core_Error::statusBounce(ts('Registration for this event ended on %1', array(1 => $endDate)), $redirect, ts('Sorry'));
     }
   }
 
index f0f653cced72daf4a79b62b7e5c946f427257843..155f8e6c136921e98d65a712b58dc9fa64a76568 100644 (file)
@@ -639,9 +639,9 @@ class CRM_Event_Form_Registration_Confirm extends CRM_Event_Form_Registration {
           !$this->_allowWaitlist && !$this->_requireApproval
         ) {
           // transactionID & receive date required while building email template
-          $this->assign('trxn_id', $value['trxn_id']);
-          $this->assign('receive_date', CRM_Utils_Date::mysqlToIso($value['receive_date']));
-          $this->set('receiveDate', CRM_Utils_Date::mysqlToIso($value['receive_date']));
+          $this->assign('trxn_id', CRM_Utils_Array::value('trxn_id', $value));
+          $this->assign('receive_date', CRM_Utils_Date::mysqlToIso(CRM_Utils_Array::value('receive_date', $value)));
+          $this->set('receiveDate', CRM_Utils_Date::mysqlToIso(CRM_Utils_Array::value('receive_date', $value)));
           $this->set('trxnId', CRM_Utils_Array::value('trxn_id', $value));
         }
       }
index 50999a089b561041a94a2ac76a15008eaf1e7103..6bc629a735ca145523d10211bf45d0f718f6e7e8 100644 (file)
@@ -1015,6 +1015,7 @@ class CRM_Event_Form_Registration_Register extends CRM_Event_Form_Registration {
         else {
           $submittedLineItems = array($lineItem);
         }
+        $submittedLineItems = array_filter($submittedLineItems);
         $this->set('lineItem', $submittedLineItems);
         $this->set('lineItemParticipantsCount', array($primaryParticipantCount));
       }
index bec74ceb2ba213d2e9c8687e7c3bb939d01bdcf9..515ce6d04b38e462ecd3502735bf8ce3d95ed861 100644 (file)
@@ -269,9 +269,6 @@ class CRM_Event_Form_Task_Batch extends CRM_Event_Form_Task {
 
   /**
    * Process the form after the input has been submitted and validated.
-   *
-   *
-   * @return void
    */
   public function postProcess() {
     $params = $this->exportValues();
@@ -286,12 +283,8 @@ class CRM_Event_Form_Task_Batch extends CRM_Event_Form_Task {
         );
 
         $value['id'] = $key;
-        if (!empty($value['participant_register_date'])) {
-          $value['register_date'] = CRM_Utils_Date::processDate($value['participant_register_date'], $value['participant_register_date_time']);
-        }
 
         if (!empty($value['participant_role'])) {
-          $participantRoles = CRM_Event_PseudoConstant::participantRole();
           if (is_array($value['participant_role'])) {
             $value['role_id'] = implode(CRM_Core_DAO::VALUE_SEPARATOR, array_keys($value['participant_role']));
           }
@@ -318,14 +311,9 @@ class CRM_Event_Form_Task_Batch extends CRM_Event_Form_Task {
           }
         }
 
-        if (!empty($value['participant_source'])) {
-          $value['source'] = $value['participant_source'];
-        }
-        unset($value['participant_register_date']);
         unset($value['participant_status']);
-        unset($value['participant_source']);
 
-        CRM_Event_BAO_Participant::create($value);
+        civicrm_api3('Participant', 'create', $value);
 
         //need to trigger mails when we change status
         if ($statusChange) {
index cb0c0c762c4b9a109ceb62ad4c6741be4f3d6851..22fa793331c22891f67607bafd011b3e364eb77c 100644 (file)
@@ -721,8 +721,6 @@ INSERT INTO {$componentTable} SELECT distinct gc.contact_id FROM civicrm_group_c
       }
     }
 
-    $multipleSelectFields = array('preferred_communication_method' => 1);
-
     $addPaymentHeader = FALSE;
 
     $paymentDetails = array();
@@ -790,7 +788,6 @@ INSERT INTO {$componentTable} SELECT distinct gc.contact_id FROM civicrm_group_c
         $query->convertToPseudoNames($iterationDAO);
 
         //first loop through output columns so that we return what is required, and in same order.
-        $relationshipField = 0;
         foreach ($outputColumns as $field => $value) {
 
           // add im_provider to $dao object
@@ -868,12 +865,6 @@ INSERT INTO {$componentTable} SELECT distinct gc.contact_id FROM civicrm_group_c
               }
               $field = $field . '_';
 
-              if (array_key_exists($relationField, $multipleSelectFields)) {
-                $param = array($relationField => $fieldValue);
-                $names = array($relationField => array('newName' => $relationField, 'groupName' => $relationField));
-                CRM_Core_OptionGroup::lookupValues($param, $names, FALSE);
-                $fieldValue = $param[$relationField];
-              }
               if (is_object($relDAO) && $relationField == 'id') {
                 $row[$field . $relationField] = $relDAO->contact_id;
               }
@@ -949,22 +940,6 @@ INSERT INTO {$componentTable} SELECT distinct gc.contact_id FROM civicrm_group_c
             if ($cfID = CRM_Core_BAO_CustomField::getKeyID($field)) {
               $row[$field] = CRM_Core_BAO_CustomField::displayValue($fieldValue, $cfID);
             }
-            elseif (array_key_exists($field, $multipleSelectFields)) {
-              //option group fixes
-              $paramsNew = array($field => $fieldValue);
-              if ($field == 'test_tutoring') {
-                $name = array($field => array('newName' => $field, 'groupName' => 'test'));
-                // for  readers group
-              }
-              elseif (substr($field, 0, 4) == 'cmr_') {
-                $name = array($field => array('newName' => $field, 'groupName' => substr($field, 0, -3)));
-              }
-              else {
-                $name = array($field => array('newName' => $field, 'groupName' => $field));
-              }
-              CRM_Core_OptionGroup::lookupValues($paramsNew, $name, FALSE);
-              $row[$field] = $paramsNew[$field];
-            }
 
             elseif (in_array($field, array(
               'email_greeting',
index 80125a8edc5cd3d3b7f2177d51cb7d48887fe204..0805e17cec03c3850f19bf28cbc1dd4d67cbf6e3 100644 (file)
@@ -402,6 +402,21 @@ class CRM_Financial_BAO_PaymentProcessor extends CRM_Financial_DAO_PaymentProces
 
   /**
    * Is there a processor on this site with the specified capability.
+   *
+   * The capabilities are defined on CRM_Core_Payment and can be extended by
+   * processors.
+   *
+   * examples are
+   *  - supportsBackOffice
+   *  - supportsLiveMode
+   *  - supportsFutureRecurDate
+   *  - supportsCancelRecurring
+   *  - supportsRecurContributionsForPledges
+   *
+   * They are passed as array('BackOffice');
+   *
+   * Details of specific functions are in the docblocks on the CRM_Core_Payment class.
+   *
    * @param array $capabilities
    *
    * @return bool
index d7f37ea86a80795ff9a808e9aa1b696791941386..2a13482928053b129850c7595615ed4e74fc272b 100644 (file)
@@ -30,7 +30,7 @@
  *
  * Generated from xml/schema/CRM/Financial/FinancialTrxn.xml
  * DO NOT EDIT.  Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:f8e72183039a2faadf244264d5f5da22)
+ * (GenCodeChecksum:52a627d344bca95d30eb8b22aad1e245)
  */
 require_once 'CRM/Core/DAO.php';
 require_once 'CRM/Utils/Type.php';
@@ -133,12 +133,24 @@ class CRM_Financial_DAO_FinancialTrxn extends CRM_Core_DAO {
    * @var int unsigned
    */
   public $payment_instrument_id;
+  /**
+   * FK to accept_creditcard option group values
+   *
+   * @var int unsigned
+   */
+  public $card_type;
   /**
    * Check number
    *
    * @var string
    */
   public $check_number;
+  /**
+   * Last 4 digits of credit card
+   *
+   * @var int unsigned
+   */
+  public $pan_truncation;
   /**
    * Class constructor.
    */
@@ -371,6 +383,22 @@ class CRM_Financial_DAO_FinancialTrxn extends CRM_Core_DAO {
             'optionEditPath' => 'civicrm/admin/options/payment_instrument',
           )
         ) ,
+        'financial_trxn_card_type' => array(
+          'name' => 'card_type',
+          'type' => CRM_Utils_Type::T_INT,
+          'title' => ts('Card Type') ,
+          'description' => 'FK to accept_creditcard option group values',
+          'table_name' => 'civicrm_financial_trxn',
+          'entity' => 'FinancialTrxn',
+          'bao' => 'CRM_Financial_DAO_FinancialTrxn',
+          'html' => array(
+            'type' => 'Select',
+          ) ,
+          'pseudoconstant' => array(
+            'optionGroupName' => 'accept_creditcard',
+            'optionEditPath' => 'civicrm/admin/options/accept_creditcard',
+          )
+        ) ,
         'financial_trxn_check_number' => array(
           'name' => 'check_number',
           'type' => CRM_Utils_Type::T_STRING,
@@ -385,6 +413,18 @@ class CRM_Financial_DAO_FinancialTrxn extends CRM_Core_DAO {
             'type' => 'Text',
           ) ,
         ) ,
+        'financial_trxn_pan_truncation' => array(
+          'name' => 'pan_truncation',
+          'type' => CRM_Utils_Type::T_INT,
+          'title' => ts('Pan Truncation') ,
+          'description' => 'Last 4 digits of credit card',
+          'table_name' => 'civicrm_financial_trxn',
+          'entity' => 'FinancialTrxn',
+          'bao' => 'CRM_Financial_DAO_FinancialTrxn',
+          'html' => array(
+            'type' => 'Text',
+          ) ,
+        ) ,
       );
       CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
     }
index dbb50070eb6292e665f479855cb288ec521d062b..8d4969ee4f8ac159be2e0af55dbb4e4871b23e83 100644 (file)
@@ -104,10 +104,10 @@ class CRM_Financial_Form_Payment extends CRM_Core_Form {
     $creditCards = CRM_Financial_BAO_PaymentProcessor::getCreditCards($paymentProcessorID);
     $creditCardTypes = CRM_Core_Payment_Form::getCreditCardCSSNames($creditCards);
     CRM_Core_Resources::singleton()
-      ->addScriptFile('civicrm', 'templates/CRM/Core/BillingBlock.js', 10)
+      ->addScriptFile('civicrm', 'templates/CRM/Core/BillingBlock.js', 10, 'html-header', FALSE)
       // workaround for CRM-13634
       // ->addSetting(array('config' => array('creditCardTypes' => $creditCardTypes)));
-      ->addScript('CRM.config.creditCardTypes = ' . json_encode($creditCardTypes) . ';');
+      ->addScript('CRM.config.creditCardTypes = ' . json_encode($creditCardTypes) . ';', '-9999', 'html-header');
   }
 
 }
index 6d7ec441e24f8778f5ab210a792e2e69d976d819..2715e99b9e184e0f588b1ef49a7f5422e83d7ea6 100644 (file)
@@ -296,8 +296,8 @@ class CRM_Financial_Page_AJAX {
       'contact_a.contact_type',
       'contact_a.contact_sub_type',
       'civicrm_financial_trxn.trxn_date as transaction_date',
-      'name',
-      'civicrm_contribution.currency as currency',
+      'civicrm_financial_type.name',
+      'civicrm_financial_trxn.currency as currency',
       'civicrm_financial_trxn.status_id as status',
       'civicrm_financial_trxn.check_number as check_number',
     );
index da6e8eec70d0242549cd17c753e2664d8f4c1a0c..d78bec5cfcee69fc29ec022a0fc905a078368c91 100644 (file)
@@ -99,21 +99,6 @@ class CRM_Group_Page_Group extends CRM_Core_Page_Basic {
     return 'reset=1&action=browse';
   }
 
-  /**
-   * Make sure that the user has permission to access this group.
-   *
-   * @param int $id
-   *   The id of the object.
-   * @param int $title
-   *   Name or title of the object.
-   *
-   * @return string
-   *   the permission that the user has (or null)
-   */
-  public function checkPermission($id, $title) {
-    return CRM_Contact_BAO_Group::checkPermission($id, $title);
-  }
-
   /**
    * Re-implement browse.
    *
index 7d838dc641d251bb2a30a4befbf60febac5bb987..4e9310ff03ed9452e2503b63277b0fa829aece49 100644 (file)
@@ -200,32 +200,6 @@ class CRM_Logging_Reverter {
       }
     }
 
-    // CRM-7353: if nothing altered civicrm_contact, touch it; this will
-    // make sure there’s an entry in log_civicrm_contact for this revert
-    if (empty($diffs['civicrm_contact'])) {
-      $query = "
-                SELECT id FROM `{$this->db}`.log_civicrm_contact
-                WHERE log_conn_id = %1 AND log_date BETWEEN DATE_SUB(%2, INTERVAL 10 SECOND) AND DATE_ADD(%2, INTERVAL 10 SECOND)
-                ORDER BY log_date DESC LIMIT 1
-            ";
-      $params = array(
-        1 => array($this->log_conn_id, 'String'),
-        2 => array($this->log_date, 'String'),
-      );
-      $cid = CRM_Core_DAO::singleValueQuery($query, $params);
-      if (!$cid) {
-        return;
-      }
-
-      $dao = new CRM_Contact_DAO_Contact();
-      $dao->id = $cid;
-      if ($dao->find(TRUE)) {
-        // CRM-8102: MySQL can’t parse its own dates
-        $dao->birth_date = CRM_Utils_Date::isoToMysql($dao->birth_date);
-        $dao->deceased_date = CRM_Utils_Date::isoToMysql($dao->deceased_date);
-        $dao->save();
-      }
-    }
   }
 
 }
index 130b5cd1b2d151370ee8f964055f7776c0acb051..28158cbbe63227aa4e4f0bea956b01736c1262e1 100644 (file)
@@ -61,6 +61,13 @@ class CRM_Mailing_ActionTokens extends \Civi\Token\AbstractTokenSubscriber {
     ));
   }
 
+  /**
+   * @inheritDoc
+   */
+  public function checkActive(\Civi\Token\TokenProcessor $processor) {
+    return !empty($processor->context['mailingId']) || !empty($processor->context['mailing']);
+  }
+
   /**
    * @inheritDoc
    */
index 80056cae312ba64c2f2b9273bff94ab6cf14fbd5..ba934f368f78c84a2dfc4e1ff2cec90aeb8b089e 100644 (file)
@@ -1093,6 +1093,10 @@ ORDER BY   civicrm_email.is_bulkmail DESC
 
     $localpart = CRM_Core_BAO_MailSettings::defaultLocalpart();
     $emailDomain = CRM_Core_BAO_MailSettings::defaultDomain();
+    // Make sure the user configured the site correctly, otherwise you just get "Could not identify any recipients. Perhaps the group is empty?" from the mailing UI
+    if (empty($emailDomain)) {
+      CRM_Core_Error::debug_log_message('Error setting verp parameters, defaultDomain is NULL.  Did you configure the bounce processing account for this domain?');
+    }
 
     foreach ($verpTokens as $key => $value) {
       $verp[$key] = implode($config->verpSeparator,
@@ -1448,6 +1452,7 @@ ORDER BY   civicrm_email.is_bulkmail DESC
    *
    * @param array $token_a
    * @param bool $html
+   *   Whether to encode the token result for use in HTML email
    * @param array $contact
    * @param string $verp
    * @param array $urls
@@ -1465,7 +1470,7 @@ ORDER BY   civicrm_email.is_bulkmail DESC
     if ($type == 'embedded_url') {
       $embed_data = array();
       foreach ($token as $t) {
-        $embed_data[] = $this->getTokenData($t, $html = FALSE, $contact, $verp, $urls, $event_queue_id);
+        $embed_data[] = $this->getTokenData($t, $html, $contact, $verp, $urls, $event_queue_id);
       }
       $numSlices = count($embed_data);
       $url = '';
@@ -1484,6 +1489,10 @@ ORDER BY   civicrm_email.is_bulkmail DESC
         $url .= '"';
       }
       $data = $url;
+      // CRM-20206 Fix ampersand encoding in plain text emails
+      if (empty($html)) {
+        $data = CRM_Utils_String::unstupifyUrl($data);
+      }
     }
     elseif ($type == 'url') {
       if ($this->url_tracking) {
index 612b1783afa464498437fd53f7d0e15f83146dba..ae9944f0b9eadb51aa63cf5a71063c71103d161c 100644 (file)
@@ -46,8 +46,8 @@ class CRM_Mailing_Event_BAO_Bounce extends CRM_Mailing_Event_DAO_Bounce {
    *
    * @return bool|null
    */
-  public static function &create(&$params) {
-    $q = &CRM_Mailing_Event_BAO_Queue::verify($params['job_id'],
+  public static function create(&$params) {
+    $q = CRM_Mailing_Event_BAO_Queue::verify($params['job_id'],
       $params['event_queue_id'],
       $params['hash']
     );
@@ -79,45 +79,13 @@ class CRM_Mailing_Event_BAO_Bounce extends CRM_Mailing_Event_DAO_Bounce {
 
     $bounce->copyValues($params);
     $bounce->save();
-    $success = TRUE;
 
-    $bounceTable = CRM_Mailing_Event_BAO_Bounce::getTableName();
-    $bounceType = CRM_Mailing_DAO_BounceType::getTableName();
-    $emailTable = CRM_Core_BAO_Email::getTableName();
-    $queueTable = CRM_Mailing_Event_BAO_Queue::getTableName();
-
-    $bounce->reset();
-    // might want to put distinct inside the count
-    $query = "SELECT     count($bounceTable.id) as bounces,
-                            $bounceType.hold_threshold as threshold
-                FROM        $bounceTable
-                INNER JOIN  $bounceType
-                        ON  $bounceTable.bounce_type_id = $bounceType.id
-                INNER JOIN  $queueTable
-                        ON  $bounceTable.event_queue_id = $queueTable.id
-                INNER JOIN  $emailTable
-                        ON  $queueTable.email_id = $emailTable.id
-                WHERE       $emailTable.id = {$q->email_id}
-                    AND     ($emailTable.reset_date IS NULL
-                        OR  $bounceTable.time_stamp >= $emailTable.reset_date)
-                GROUP BY    $bounceTable.bounce_type_id
-                ORDER BY    threshold, bounces desc";
-
-    $bounce->query($query);
-
-    while ($bounce->fetch()) {
-      if ($bounce->bounces >= $bounce->threshold) {
-        $email = new CRM_Core_BAO_Email();
-        $email->id = $q->email_id;
-        $email->on_hold = TRUE;
-        $email->hold_date = date('YmdHis');
-        $email->save();
-        break;
-      }
+    if ($q->email_id) {
+      self::putEmailOnHold($q->email_id);
     }
     $transaction->commit();
 
-    return $success;
+    return TRUE;
   }
 
   /**
@@ -279,4 +247,46 @@ class CRM_Mailing_Event_BAO_Bounce extends CRM_Mailing_Event_DAO_Bounce {
     return $results;
   }
 
+  /**
+   * Put the email on hold if it has met the threshold.
+   *
+   * @param int $email_id
+   */
+  protected static function putEmailOnHold($email_id) {
+
+    $bounceTable = CRM_Mailing_Event_BAO_Bounce::getTableName();
+    $bounceType = CRM_Mailing_DAO_BounceType::getTableName();
+    $emailTable = CRM_Core_BAO_Email::getTableName();
+    $queueTable = CRM_Mailing_Event_BAO_Queue::getTableName();
+
+    // might want to put distinct inside the count
+    $query = "SELECT     count($bounceTable.id) as bounces,
+                            $bounceType.hold_threshold as threshold
+                FROM        $bounceTable
+                INNER JOIN  $bounceType
+                        ON  $bounceTable.bounce_type_id = $bounceType.id
+                INNER JOIN  $queueTable
+                        ON  $bounceTable.event_queue_id = $queueTable.id
+                INNER JOIN  $emailTable
+                        ON  $queueTable.email_id = $emailTable.id
+                WHERE       $emailTable.id = $email_id
+                    AND     ($emailTable.reset_date IS NULL
+                        OR  $bounceTable.time_stamp >= $emailTable.reset_date)
+                GROUP BY    $bounceTable.bounce_type_id
+                ORDER BY    threshold, bounces desc";
+
+    $dao = CRM_Core_DAO::executeQuery($query);
+
+    while ($dao->fetch()) {
+      if ($dao->bounces >= $dao->threshold) {
+        $email = new CRM_Core_BAO_Email();
+        $email->id = $email_id;
+        $email->on_hold = TRUE;
+        $email->hold_date = date('YmdHis');
+        $email->save();
+        break;
+      }
+    }
+  }
+
 }
index 45a038c72483b4776b907767b72b0ea3a3dffbd8..a3cb6c7097ca63a00c76336e22a9e2412e51ffc1 100644 (file)
@@ -30,7 +30,7 @@
  *
  * Generated from xml/schema/CRM/Member/Membership.xml
  * DO NOT EDIT.  Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:794bd904da5edcacc20dd5784fcdcf0c)
+ * (GenCodeChecksum:d92ffd88f95da56ec5e4463369c59155)
  */
 require_once 'CRM/Core/DAO.php';
 require_once 'CRM/Utils/Type.php';
@@ -244,7 +244,7 @@ class CRM_Member_DAO_Membership extends CRM_Core_DAO {
           'bao' => 'CRM_Member_BAO_Membership',
           'html' => array(
             'type' => 'Select Date',
-            'format' => 'activityDate',
+            'formatType' => 'activityDate',
           ) ,
         ) ,
         'membership_start_date' => array(
@@ -262,7 +262,7 @@ class CRM_Member_DAO_Membership extends CRM_Core_DAO {
           'bao' => 'CRM_Member_BAO_Membership',
           'html' => array(
             'type' => 'Select Date',
-            'format' => 'activityDate',
+            'formatType' => 'activityDate',
           ) ,
         ) ,
         'membership_end_date' => array(
@@ -280,7 +280,7 @@ class CRM_Member_DAO_Membership extends CRM_Core_DAO {
           'bao' => 'CRM_Member_BAO_Membership',
           'html' => array(
             'type' => 'Select Date',
-            'format' => 'activityDate',
+            'formatType' => 'activityDate',
           ) ,
         ) ,
         'membership_source' => array(
index 4767d5e7ff80f23f855a3214cd01c3990e5ca266..56694bd71cf66b949962fe869760d1f85d14fe6d 100644 (file)
@@ -298,7 +298,15 @@ WHERE li.contribution_id = %1";
         'tax_amount' => $dao->tax_amount,
         'price_set_id' => $dao->price_set_id,
       );
-      $lineItems[$dao->id]['tax_rate'] = CRM_Price_BAO_LineItem::calculateTaxRate($lineItems[$dao->id]);
+      $taxRates = CRM_Core_PseudoConstant::getTaxRates();
+      if (isset($lineItems[$dao->id]['financial_type_id']) && array_key_exists($lineItems[$dao->id]['financial_type_id'], $taxRates)) {
+        // We are close to output/display here - so apply some rounding at output/display level - to not show Tax Rate in all 8 decimals
+        $lineItems[$dao->id]['tax_rate'] = round($taxRates[$lineItems[$dao->id]['financial_type_id']], 3);
+      }
+      else {
+        // There is no Tax Rate associated with this Financial Type
+        $lineItems[$dao->id]['tax_rate'] = FALSE;
+      }
       $lineItems[$dao->id]['subTotal'] = $lineItems[$dao->id]['qty'] * $lineItems[$dao->id]['unit_price'];
       if ($lineItems[$dao->id]['tax_amount'] != '') {
         $getTaxDetails = TRUE;
@@ -597,26 +605,4 @@ WHERE li.contribution_id = %1";
     }
   }
 
-  /**
-   * Calculate tax rate in percentage.
-   *
-   * @param array $lineItemId
-   *   An assoc array of lineItem.
-   *
-   * @return int|void
-   *   tax rate
-   */
-  public static function calculateTaxRate($lineItemId) {
-    if ($lineItemId['unit_price'] == 0 || $lineItemId['qty'] == 0) {
-      return FALSE;
-    }
-    if ($lineItemId['html_type'] == 'Text') {
-      $tax = round($lineItemId['tax_amount'] / ($lineItemId['unit_price'] * $lineItemId['qty']) * 100, 2);
-    }
-    else {
-      $tax = round(($lineItemId['tax_amount'] / $lineItemId['unit_price']) * 100, 2);
-    }
-    return $tax;
-  }
-
 }
index be5c02d6bc4173a5283e4d364dc3d9e9d6c6a2e2..af7518f3ecc19758c3f645ef7f5604b9b38129a7 100644 (file)
@@ -471,17 +471,18 @@ WHERE     cpf.price_set_id = %1";
     $select = 'SELECT ' . implode(',', $priceFields);
     $from = ' FROM civicrm_price_field';
 
-    $params = array();
-    $params[1] = array($setID, 'Integer');
-    $where = '
+    $params = array(
+      1 => array($setID, 'Integer'),
+    );
+    $currentTime = date('YmdHis');
+    $where = "
 WHERE price_set_id = %1
 AND is_active = 1
-';
+AND ( active_on IS NULL OR active_on <= {$currentTime} )
+";
     $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} )
 ";
     }
@@ -1589,11 +1590,12 @@ WHERE       ps.id = %1
    * @return array
    */
   public static function setLineItem($field, $lineItem, $optionValueId, &$totalTax) {
+    // Here we round - i.e. after multiplying by quantity
     if ($field['html_type'] == 'Text') {
-      $taxAmount = $field['options'][$optionValueId]['tax_amount'] * $lineItem[$optionValueId]['qty'];
+      $taxAmount = round($field['options'][$optionValueId]['tax_amount'] * $lineItem[$optionValueId]['qty'], 2);
     }
     else {
-      $taxAmount = $field['options'][$optionValueId]['tax_amount'];
+      $taxAmount = round($field['options'][$optionValueId]['tax_amount'], 2);
     }
     $taxRate = $field['options'][$optionValueId]['tax_rate'];
     $lineItem[$optionValueId]['tax_amount'] = $taxAmount;
index bf39aa55b78e9cc565e695a04c95ee9500461ac4..51f7d3fd053f100b0b02e63e3b01334a8595fcf8 100644 (file)
@@ -327,13 +327,6 @@ class CRM_Price_Form_Field extends CRM_Core_Form {
       CRM_Core_DAO::getAttribute('CRM_Price_DAO_PriceField', 'help_post')
     );
 
-    // active_on
-    $date_options = array(
-      'format' => 'dmY His',
-      'minYear' => date('Y') - 1,
-      'maxYear' => date('Y') + 5,
-      'addEmptyOption' => TRUE,
-    );
     $this->addDateTime('active_on', ts('Active On'), FALSE, array('formatType' => 'activityDateTime'));
 
     // expire_on
index 9bcf0b9ee759e17a3d7d50f263ec3844a297c586..d6abda6e3d595cc9ddb84d4b9ea8ac271eda396b 100644 (file)
@@ -500,7 +500,11 @@ class CRM_Profile_Form extends CRM_Core_Form {
             ) {
               $entityId = $this->_activityId;
             }
-            $url = CRM_Core_BAO_CustomField::getFileURL($entityId, $key);
+
+            $url = '';
+            if (isset($value)) {
+              $url = CRM_Core_BAO_CustomField::getFileURL($entityId, $key, $value);
+            }
 
             if ($url) {
               $customFiles[$name]['displayURL'] = ts("Attached File") . ": {$url['file_url']}";
index 3e29e7f7d83de85091dc9cc5d1d6934bc6790d8d..49d3a214bf290ea9f128bb1e0de7748efb7a658c 100644 (file)
@@ -234,7 +234,7 @@ class CRM_Profile_Page_MultipleRecordFieldsListing extends CRM_Core_Page_Basic {
         CRM_Core_DAO::commonRetrieve('CRM_Core_DAO_CustomField', $param, $returnValues, $returnProperities);
         if ($returnValues['data_type'] == 'Date') {
           $dateFields[$fieldIDs[$key]] = 1;
-          $actualPHPFormats = CRM_Core_SelectValues::datePluginToPHPFormats();
+          $actualPHPFormats = CRM_Utils_Date::datePluginToPHPFormats();
           $dateFormat = (array) CRM_Utils_Array::value($returnValues['date_format'], $actualPHPFormats);
           $timeFormat = CRM_Utils_Array::value('time_format', $returnValues);
         }
index 5e1812e5f922160a299edc78f72794c50a3e845b..8fbc9c05849bc86877fe93d067c9c2d798a74b58 100644 (file)
@@ -329,7 +329,7 @@ class CRM_Report_Form extends CRM_Core_Form {
    *
    * @var array
    */
-  protected $_selectedTables;
+  protected $_selectedTables = array();
 
   /**
    * Array of DAO tables having columns included in WHERE or HAVING clause
@@ -2658,6 +2658,7 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND
     $this->select();
     $this->from();
     $this->customDataFrom();
+    $this->buildPermissionClause();
     $this->where();
     if (array_key_exists('civicrm_contribution', $this->getVar('_columns'))) {
       $this->getPermissionedFTQuery($this);
@@ -3607,7 +3608,8 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND
   }
 
   /**
-   * Build acl clauses.
+   * Buld contact acl clause
+   * @deprecated in favor of buildPermissionClause
    *
    * @param string $tableAlias
    */
@@ -3615,6 +3617,29 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND
     list($this->_aclFrom, $this->_aclWhere) = CRM_Contact_BAO_Contact_Permission::cacheClause($tableAlias);
   }
 
+  /**
+   * Build the permision clause for all entities in this report
+   */
+  public function buildPermissionClause() {
+    $ret = array();
+    foreach ($this->selectedTables() as $tableName) {
+      $baoName = str_replace('_DAO_', '_BAO_', CRM_Core_DAO_AllCoreTables::getClassForTable($tableName));
+      if ($baoName && class_exists($baoName) && !empty($this->_columns[$tableName]['alias'])) {
+        $tableAlias = $this->_columns[$tableName]['alias'];
+        $clauses = array_filter($baoName::getSelectWhereClause($tableAlias));
+        foreach ($clauses as $field => $clause) {
+          // Skip contact_id field if redundant
+          if ($field != 'contact_id' || !in_array('civicrm_contact', $this->selectedTables())) {
+            $ret["$tableName.$field"] = $clause;
+          }
+        }
+      }
+    }
+    // Override output from buildACLClause
+    $this->_aclFrom = NULL;
+    $this->_aclWhere = implode(' AND ', $ret);
+  }
+
   /**
    * Add custom data to the columns.
    *
index 346d943b11b8d593557517797bed71b5a4160442..820b6f6d1e38a63ba701a2d5a2e2503c7671a2d5 100644 (file)
@@ -283,6 +283,12 @@ class CRM_Report_Form_Activity extends CRM_Report_Form {
             'title' => ts('Activity Details'),
             'type' => CRM_Utils_Type::T_TEXT,
           ),
+          'priority_id' => array(
+            'title' => ts('Activity Priority'),
+            'type' => CRM_Utils_Type::T_STRING,
+            'operatorType' => CRM_Report_Form::OP_MULTISELECT,
+            'options' => CRM_Core_PseudoConstant::get('CRM_Activity_DAO_Activity', 'priority_id'),
+          ),
         ),
         'order_bys' => array(
           'activity_date_time' => array(
@@ -882,6 +888,7 @@ FROM civireport_activity_temp_target tar
     $entryFound = FALSE;
     $activityType = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, FALSE, 'label', TRUE);
     $activityStatus = CRM_Core_PseudoConstant::activityStatus();
+    $priority = CRM_Core_PseudoConstant::get('CRM_Activity_DAO_Activity', 'priority_id');
     $viewLinks = FALSE;
     $context = CRM_Utils_Request::retrieve('context', 'String', $this, FALSE, 'report');
     $actUrl = '';
@@ -998,6 +1005,13 @@ FROM civireport_activity_temp_target tar
         }
       }
 
+      if (array_key_exists('civicrm_activity_priority_id', $row)) {
+        if ($value = $row['civicrm_activity_priority_id']) {
+          $rows[$rowNum]['civicrm_activity_priority_id'] = $priority[$value];
+          $entryFound = TRUE;
+        }
+      }
+
       if (array_key_exists('civicrm_activity_details', $row) && $this->_outputMode == 'html') {
         if ($value = $row['civicrm_activity_details']) {
           $fullDetails = $rows[$rowNum]['civicrm_activity_details'];
index 4ce9fb3fc8b31b5db295fe6971c3a47f92485137..c8978ec05c02adcb650c4a8c11c2627c611e78dd 100644 (file)
@@ -155,7 +155,7 @@ class CRM_Report_Form_ActivitySummary extends CRM_Report_Form {
             'options' => CRM_Core_PseudoConstant::activityStatus(),
           ),
           'priority_id' => array(
-            'title' => ts('Priority'),
+            'title' => ts('Activity Priority'),
             'type' => CRM_Utils_Type::T_INT,
             'operatorType' => CRM_Report_Form::OP_MULTISELECT,
             'options' => CRM_Core_PseudoConstant::get('CRM_Activity_DAO_Activity', 'priority_id'),
index 88cd1f45384fc4b581e96fad19c6e957da30fe02..431b2b8fb19e0fe36d48ff73f7236b3549282b66 100644 (file)
@@ -263,7 +263,7 @@ class CRM_Report_Form_Contact_Relationship extends CRM_Report_Form {
           'relationship_type_id' => array(
             'title' => ts('Relationship'),
             'operatorType' => CRM_Report_Form::OP_MULTISELECT,
-            'options' => CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, 'null', NULL, NULL, TRUE),
+            'options' => CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, NULL, NULL, NULL, TRUE),
             'type' => CRM_Utils_Type::T_INT,
           ),
           'start_date' => array(
index e80e02a3eb497dbdf18b54f78d17d62d42389a00..8b34e55c9b446fe8b5aefa18001290c405b66019 100644 (file)
@@ -42,12 +42,28 @@ class CRM_Report_Form_Contribute_DeferredRevenue extends CRM_Report_Form {
   /**
    */
   public function __construct() {
-    $this->_autoIncludeIndexedFieldsAsOrderBys = 1;
+    $this->_exposeContactID = FALSE;
     $this->_deferredFinancialAccount = CRM_Financial_BAO_FinancialAccount::getAllDeferredFinancialAccount();
     $this->_columns = array(
       'civicrm_financial_account' => array(
         'dao' => 'CRM_Financial_DAO_FinancialAccount',
-        'alias' => 'financial_account_deferred',
+        'fields' => array(
+          'name' => array(
+            'title' => ts('Deferred Account'),
+            'required' => TRUE,
+            'no_display' => TRUE,
+          ),
+          'id' => array(
+            'title' => ts('Deferred Account ID'),
+            'required' => TRUE,
+            'no_display' => TRUE,
+          ),
+          'accounting_code' => array(
+            'title' => ts('Deferred Accounting Code'),
+            'required' => TRUE,
+            'no_display' => TRUE,
+          ),
+        ),
         'filters' => array(
           'id' => array(
             'title' => ts('Deferred Financial Account'),
@@ -57,131 +73,272 @@ class CRM_Report_Form_Contribute_DeferredRevenue extends CRM_Report_Form {
           ),
         ),
       ),
+      'civicrm_financial_account_1' => array(
+        'dao' => 'CRM_Financial_DAO_FinancialAccount',
+        'fields' => array(
+          'name' => array(
+            'title' => ts('Revenue Account'),
+            'required' => TRUE,
+            'no_display' => TRUE,
+          ),
+          'id' => array(
+            'title' => ts('Revenue Account ID'),
+            'required' => TRUE,
+            'no_display' => TRUE,
+          ),
+          'accounting_code' => array(
+            'title' => ts('Revenue Accounting code'),
+            'no_display' => TRUE,
+            'required' => TRUE,
+          ),
+        ),
+      ),
+      'civicrm_financial_item' => array(
+        'dao' => 'CRM_Financial_DAO_FinancialItem',
+        'fields' => array(
+          'status_id' => array(
+            'title' => ts('Status'),
+            'required' => TRUE,
+            'no_display' => TRUE,
+          ),
+          'id' => array(
+            'title' => ts('Financial Item ID'),
+            'required' => TRUE,
+            'no_display' => TRUE,
+          ),
+          'description' => array(
+            'title' => ts('Description'),
+            'required' => TRUE,
+            'no_display' => TRUE,
+          ),
+        ),
+      ),
+      'civicrm_financial_trxn_1' => array(
+        'dao' => 'CRM_Financial_DAO_FinancialTrxn',
+        'fields' => array(
+          'total_amount' => array(
+            'title' => ts('Deferred Transaction Amount'),
+            'required' => TRUE,
+            'no_display' => TRUE,
+            'dbAlias' => 'GROUP_CONCAT(financial_trxn_1_civireport.total_amount)',
+          ),
+          'trxn_date' => array(
+            'title' => ts('Deferred Transaction Date'),
+            'required' => TRUE,
+            'no_display' => TRUE,
+            'dbAlias' => 'GROUP_CONCAT(financial_trxn_1_civireport.trxn_date)',
+          ),
+        ),
+      ),
+      'civicrm_contact' => array(
+        'dao' => 'CRM_Contact_DAO_Contact',
+        'fields' => array(
+          'display_name' => array(
+            'title' => ts('Display_name'),
+            'required' => TRUE,
+            'no_display' => TRUE,
+          ),
+        ),
+      ),
+      'civicrm_membership' => array(
+        'dao' => 'CRM_Member_DAO_Membership',
+        'fields' => array(
+          'start_date' => array(
+            'title' => ts('Start Date'),
+            'required' => TRUE,
+            'no_display' => TRUE,
+            'dbAlias' => 'IFNULL(membership_civireport.start_date, event_civireport.start_date)',
+          ),
+          'end_date' => array(
+            'title' => ts('End Date'),
+            'required' => TRUE,
+            'no_display' => TRUE,
+            'dbdbAlias' => 'IFNULL(membership_civireport.end_date, event_civireport.end_date)',
+          ),
+        ),
+      ),
+      'civicrm_event' => array(
+        'dao' => 'CRM_Event_DAO_Event',
+      ),
+      'civicrm_participant' => array(
+        'dao' => 'CRM_Event_DAO_Participant',
+      ),
+      'civicrm_batch' => array(
+        'dao' => 'CRM_Batch_DAO_EntityBatch',
+        'grouping' => 'contri-fields',
+        'filters' => array(
+          'batch_id' => array(
+            'title' => ts('Batch Title'),
+            'operatorType' => CRM_Report_Form::OP_MULTISELECT,
+            'options' => CRM_Batch_BAO_Batch::getBatches(),
+            'type' => CRM_Utils_Type::T_INT,
+          ),
+        ),
+      ),
+      'civicrm_contribution' => array(
+        'dao' => 'CRM_Contribute_DAO_Contribution',
+        'fields' => array(
+          'id' => array(
+            'title' => ts('Contribution ID'),
+            'required' => TRUE,
+            'no_display' => TRUE,
+          ),
+          'contact_id' => array(
+            'title' => ts('Contact ID'),
+            'required' => TRUE,
+            'no_display' => TRUE,
+          ),
+          'source' => array(
+            'title' => ts('Source'),
+            'required' => TRUE,
+            'no_display' => TRUE,
+          ),
+        ),
+        'filters' => array(
+          'receive_date' => array(
+            'title' => ts('Receive Date'),
+            'operatorType' => CRM_Report_Form::OP_DATE,
+            'type' => CRM_Utils_Type::T_DATE,
+          ),
+          'cancel_date' => array(
+            'title' => ts('Cancel Date'),
+            'operatorType' => CRM_Report_Form::OP_DATE,
+            'type' => CRM_Utils_Type::T_DATE,
+          ),
+          'revenue_recognition_date' => array(
+            'title' => ts('Revenue Recognition Date'),
+            'operatorType' => CRM_Report_Form::OP_DATE,
+            'type' => CRM_Utils_Type::T_DATE,
+          ),
+        ),
+      ),
+      'civicrm_financial_trxn' => array(
+        'dao' => 'CRM_Financial_DAO_FinancialTrxn',
+        'fields' => array(
+          'status_id' => array(
+            'title' => ts('Transaction Status'),
+            'required' => TRUE,
+            'no_display' => TRUE,
+          ),
+          'trxn_date' => array(
+            'title' => ts('Transaction Date'),
+            'required' => TRUE,
+            'no_display' => TRUE,
+          ),
+          'total_amount' => array(
+            'title' => ts('Transaction Amount'),
+            'required' => TRUE,
+            'no_display' => TRUE,
+          ),
+        ),
+        'filters' => array(
+          'trxn_date' => array(
+            'title' => ts('Transaction Date'),
+            'operatorType' => CRM_Report_Form::OP_DATE,
+            'type' => CRM_Utils_Type::T_DATE,
+          ),
+        ),
+      ),
     );
     parent::__construct();
   }
 
+  /**
+   * Pre process function.
+   *
+   * Called prior to build form.
+   */
   public function preProcess() {
     parent::preProcess();
   }
 
-  public function select() {
-    // TODO: add column
-    $this->_select = ' SELECT 
-financial_account_deferred_civireport.name deferred_account,
-financial_account_deferred_civireport.id deferred_account_id,
-financial_account_deferred_civireport.accounting_code deferred_account_code,
-financial_account_revenue.name revenue_account,
-financial_account_revenue.id revenue_account_id,
-financial_account_revenue.accounting_code revenue_account_code,
-financial_item.status_id,
-financial_item.id item_id,
-financial_trxn_contribution_1.status_id,
-financial_trxn_contribution_1.trxn_date transaction_date,
-financial_trxn_contribution_1.total_amount,
-contribution.id contribution_id,
-contribution.contact_id,
-contact.display_name,
-contribution.source,
-GROUP_CONCAT(financial_trxn.total_amount) trxn_amount,
-GROUP_CONCAT(financial_trxn.trxn_date) trxn_date,
-financial_item.description,
-IFNULL(membership.start_date, event.start_date) start_date,
-IFNULL(membership.end_date, event.end_date) end_date
-';
-  }
-
+  /**
+   * Build from clause.
+   */
   public function from() {
     $deferredRelationship = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Deferred Revenue Account is' "));
     $revenueRelationship = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Income Account is' "));
-    $this->_from = " FROM civicrm_financial_item financial_item
+    $this->_from = " FROM civicrm_financial_item {$this->_aliases['civicrm_financial_item']}
 INNER JOIN civicrm_entity_financial_account entity_financial_account_deferred
-  ON financial_item.financial_account_id = entity_financial_account_deferred.financial_account_id AND entity_financial_account_deferred.entity_table = 'civicrm_financial_type'
+  ON {$this->_aliases['civicrm_financial_item']}.financial_account_id = entity_financial_account_deferred.financial_account_id AND entity_financial_account_deferred.entity_table = 'civicrm_financial_type'
     AND entity_financial_account_deferred.account_relationship = {$deferredRelationship}
-INNER JOIN civicrm_financial_account financial_account_deferred_civireport
-  ON entity_financial_account_deferred.financial_account_id = financial_account_deferred_civireport.id
+INNER JOIN civicrm_financial_account {$this->_aliases['civicrm_financial_account']}
+  ON entity_financial_account_deferred.financial_account_id = {$this->_aliases['civicrm_financial_account']}.id
 INNER JOIN civicrm_entity_financial_account entity_financial_account_revenue
   ON entity_financial_account_deferred.entity_id = entity_financial_account_revenue.entity_id
     AND entity_financial_account_deferred.entity_table= entity_financial_account_revenue.entity_table
-INNER JOIN civicrm_financial_account financial_account_revenue
-  ON entity_financial_account_revenue.financial_account_id = financial_account_revenue.id
+INNER JOIN civicrm_financial_account {$this->_aliases['civicrm_financial_account_1']}
+  ON entity_financial_account_revenue.financial_account_id = {$this->_aliases['civicrm_financial_account_1']}.id
     AND {$revenueRelationship} = entity_financial_account_revenue.account_relationship
 INNER JOIN civicrm_entity_financial_trxn entity_financial_trxn_item
-  ON entity_financial_trxn_item.entity_id = financial_item.id AND entity_financial_trxn_item.entity_table = 'civicrm_financial_item'
-INNER JOIN civicrm_financial_trxn financial_trxn
-  ON financial_trxn.from_financial_account_id = financial_account_deferred_civireport.id AND financial_trxn.id =  entity_financial_trxn_item.financial_trxn_id 
+  ON entity_financial_trxn_item.entity_id = {$this->_aliases['civicrm_financial_item']}.id AND entity_financial_trxn_item.entity_table = 'civicrm_financial_item'
+INNER JOIN civicrm_financial_trxn {$this->_aliases['civicrm_financial_trxn_1']}
+  ON {$this->_aliases['civicrm_financial_trxn_1']}.from_financial_account_id = {$this->_aliases['civicrm_financial_account']}.id AND {$this->_aliases['civicrm_financial_trxn_1']}.id =  entity_financial_trxn_item.financial_trxn_id 
 INNER JOIN civicrm_entity_financial_trxn financial_trxn_contribution
-  ON financial_trxn_contribution.financial_trxn_id = financial_trxn.id AND financial_trxn_contribution.entity_table = 'civicrm_contribution'
-INNER JOIN civicrm_entity_financial_trxn entity_financial_trxn_contribution ON entity_financial_trxn_contribution.entity_id = financial_item.id and entity_financial_trxn_contribution.entity_table = 'civicrm_financial_item'  
-INNER JOIN civicrm_financial_trxn financial_trxn_contribution_1 ON financial_trxn_contribution_1.id = entity_financial_trxn_contribution.financial_trxn_id AND (financial_trxn_contribution_1.from_financial_account_id NOT IN (" . implode(',', array_keys($this->_deferredFinancialAccount)) . ") OR financial_trxn_contribution_1.from_financial_account_id IS NULL)
-INNER JOIN civicrm_contribution contribution 
-  ON contribution.id = financial_trxn_contribution.entity_id
-INNER JOIN civicrm_contact contact 
-  ON contact.id = contribution.contact_id
+  ON financial_trxn_contribution.financial_trxn_id = {$this->_aliases['civicrm_financial_trxn_1']}.id AND financial_trxn_contribution.entity_table = 'civicrm_contribution'
+INNER JOIN civicrm_entity_financial_trxn entity_financial_trxn_contribution ON entity_financial_trxn_contribution.entity_id = {$this->_aliases['civicrm_financial_item']}.id and entity_financial_trxn_contribution.entity_table = 'civicrm_financial_item'  
+INNER JOIN civicrm_financial_trxn {$this->_aliases['civicrm_financial_trxn']} ON {$this->_aliases['civicrm_financial_trxn']}.id = entity_financial_trxn_contribution.financial_trxn_id AND ({$this->_aliases['civicrm_financial_trxn']}.from_financial_account_id NOT IN (" . implode(',', array_keys($this->_deferredFinancialAccount)) . ") OR {$this->_aliases['civicrm_financial_trxn']}.from_financial_account_id IS NULL)
+INNER JOIN civicrm_contribution {$this->_aliases['civicrm_contribution']}
+  ON {$this->_aliases['civicrm_contribution']}.id = financial_trxn_contribution.entity_id
+INNER JOIN civicrm_contact {$this->_aliases['civicrm_contact']}
+  ON {$this->_aliases['civicrm_contact']}.id = {$this->_aliases['civicrm_contribution']}.contact_id
 INNER JOIN civicrm_line_item line_item 
-  ON line_item.contribution_id = contribution.id
-LEFT JOIN  civicrm_membership membership 
+  ON line_item.contribution_id = {$this->_aliases['civicrm_contribution']}.id
+LEFT JOIN  civicrm_membership {$this->_aliases['civicrm_membership']}
   ON CASE
     WHEN line_item.entity_table = 'civicrm_membership'
-    THEN line_item.entity_id = membership.id
-    ELSE membership.id = 0
+    THEN line_item.entity_id = {$this->_aliases['civicrm_membership']}.id
+    ELSE {$this->_aliases['civicrm_membership']}.id = 0
   END
-LEFT JOIN civicrm_participant participant
+LEFT JOIN civicrm_participant {$this->_aliases['civicrm_participant']}
   ON CASE
     WHEN line_item.entity_table = 'civicrm_participant'
-    THEN line_item.entity_id = participant.id
-    ELSE participant.id = 0
+    THEN line_item.entity_id = {$this->_aliases['civicrm_participant']}.id
+    ELSE {$this->_aliases['civicrm_participant']}.id = 0
   END
-LEFT JOIN civicrm_event event ON participant.event_id = event.id
+LEFT JOIN civicrm_event {$this->_aliases['civicrm_event']} ON {$this->_aliases['civicrm_participant']}.event_id = {$this->_aliases['civicrm_event']}.id
 ";
-  }
-
-  public function orderBy() {
-    parent::orderBy();
-  }
-
-  public function where() {
-    $clauses = array();
-    foreach ($this->_columns as $tableName => $table) {
-      if (array_key_exists('filters', $table)) {
-        foreach ($table['filters'] as $fieldName => $field) {
-          $clause = NULL;
-          if (CRM_Utils_Array::value('type', $field) & CRM_Utils_Type::T_DATE) {
-            $relative = CRM_Utils_Array::value("{$fieldName}_relative", $this->_params);
-            $from = CRM_Utils_Array::value("{$fieldName}_from", $this->_params);
-            $to = CRM_Utils_Array::value("{$fieldName}_to", $this->_params);
 
-            $clause = $this->dateClause($field['name'], $relative, $from, $to, $field['type']);
-          }
-          else {
-            $op = CRM_Utils_Array::value("{$fieldName}_op", $this->_params);
-            if ($op) {
-              $clause = $this->whereClause($field,
-                $op,
-                CRM_Utils_Array::value("{$fieldName}_value", $this->_params),
-                CRM_Utils_Array::value("{$fieldName}_min", $this->_params),
-                CRM_Utils_Array::value("{$fieldName}_max", $this->_params)
-              );
-            }
-          }
-          if (!empty($clause)) {
-            $clauses[] = $clause;
-          }
-        }
-      }
-    }
-    if (!empty($clauses)) {
-      $this->_where = 'WHERE ' . implode(' AND ', $clauses);
+    if (!empty($this->_params['batch_id_value'])) {
+      $this->_from .= "
+        LEFT JOIN civicrm_entity_batch {$this->_aliases['civicrm_batch']}
+          ON {$this->_aliases['civicrm_batch']}.entity_id = {$this->_aliases['civicrm_financial_trxn_1']}.id AND
+            {$this->_aliases['civicrm_batch']}.entity_table = 'civicrm_financial_trxn'\n";
     }
   }
 
+  /**
+   * Post process function.
+   */
   public function postProcess() {
     $this->_noFields = TRUE;
     parent::postProcess();
   }
 
+  /**
+   * Set limit.
+   *
+   * @param int $rowCount
+   */
+  public function limit($rowCount = self::ROW_COUNT_LIMIT) {
+    $this->_limit = NULL;
+  }
+
+  /**
+   * Build where clause.
+   */
+  public function where() {
+    parent::where();
+    $startDate = date('Y-m-01');
+    $endDate = date('Y-m-t', strtotime(date('ymd') . '+11 month'));
+    $this->_where .= " AND {$this->_aliases['civicrm_financial_trxn_1']}.trxn_date BETWEEN '{$startDate}' AND '{$endDate}'";
+  }
+
+  /**
+   * Build group by clause.
+   */
   public function groupBy() {
-    $this->_groupBy = "GROUP BY financial_account_deferred_civireport.id, financial_account_revenue.id, financial_item.id";
+    $this->_groupBy = "GROUP BY {$this->_aliases['civicrm_financial_account']}.id,  {$this->_aliases['civicrm_financial_account_1']}.id, {$this->_aliases['civicrm_financial_item']}.id";
   }
 
   /**
@@ -210,52 +367,38 @@ LEFT JOIN civicrm_event event ON participant.event_id = event.id
       'End Date' => 1,
     );
     $dateFormat = Civi::settings()->get('dateformatFinancialBatch');
+    for ($i = 0; $i < 12; $i++) {
+      //$columns[date('M, Y', strtotime("+1 month", date('Y-m-d')))] = 1;
+      $columns[date('M, Y', strtotime(date('Y-m-d') . "+{$i} month"))] = 1;
+    }
     while ($dao->fetch()) {
-      $arraykey = $dao->deferred_account_id . '_' . $dao->revenue_account_id;
+      $arraykey = $dao->civicrm_financial_account_id . '_' . $dao->civicrm_financial_account_1_id;
       if (empty($rows[$arraykey])) {
-        $rows[$arraykey]['label'] = "Deferred Revenue Account: {$dao->deferred_account} ({$dao->deferred_account_code}), Revenue Account: {$dao->revenue_account} {$dao->revenue_account_code}";
+        $rows[$arraykey]['label'] = "Deferred Revenue Account: {$dao->civicrm_financial_account_name} ({$dao->civicrm_financial_account_accounting_code}), Revenue Account: {$dao->civicrm_financial_account_1_name} {$dao->civicrm_financial_account_1_accounting_code}";
       }
-      $rows[$arraykey]['rows'][$dao->item_id] = array(
-        'Transaction' => $statuses[$dao->status_id],
-        'Date of Transaction' => CRM_Utils_Date::customFormat($dao->transaction_date, $dateFormat),
-        'Amount' => CRM_Utils_Money::format($dao->total_amount),
-        'Contribution ID' => $dao->contribution_id,
-        'Item' => $dao->description,
-        'Contact ID' => $dao->contact_id,
-        'Contact Name' => $dao->display_name,
-        'Source' => $dao->source,
-        'Start Date' => CRM_Utils_Date::customFormat($dao->start_date, $dateFormat),
-        'End Date' => CRM_Utils_Date::customFormat($dao->end_date, $dateFormat),
+      $rows[$arraykey]['rows'][$dao->civicrm_financial_item_id] = array(
+        'Transaction' => $statuses[$dao->civicrm_financial_trxn_status_id],
+        'Date of Transaction' => CRM_Utils_Date::customFormat($dao->civicrm_financial_trxn_trxn_date, $dateFormat),
+        'Amount' => CRM_Utils_Money::format($dao->civicrm_financial_trxn_total_amount),
+        'Contribution ID' => $dao->civicrm_contribution_id,
+        'Item' => $dao->civicrm_financial_item_description,
+        'Contact ID' => $dao->civicrm_contribution_contact_id,
+        'Contact Name' => $dao->civicrm_contact_display_name,
+        'Source' => $dao->civicrm_contribution_source,
+        'Start Date' => CRM_Utils_Date::customFormat($dao->civicrm_membership_start_date, $dateFormat),
+        'End Date' => CRM_Utils_Date::customFormat($dao->civicrm_membership_end_date, $dateFormat),
       );
-      $trxnDate = explode(',', $dao->trxn_date);
-      $trxnAmount = explode(',', $dao->trxn_amount);
+      $trxnDate = explode(',', $dao->civicrm_financial_trxn_1_trxn_date);
+      $trxnAmount = explode(',', $dao->civicrm_financial_trxn_1_total_amount);
       foreach ($trxnDate as $key => $date) {
         $keyDate = date('M, Y', strtotime($date));
-        $rows[$arraykey]['rows'][$dao->item_id][$keyDate] = CRM_Utils_Money::format($trxnAmount[$key]);
-        $dateColumn[date('Ymd', strtotime($date))] = 1;
+        if (!array_key_exists($keyDate, $columns)) {
+          continue;
+        }
+        $rows[$arraykey]['rows'][$dao->civicrm_financial_item_id][$keyDate] = CRM_Utils_Money::format($trxnAmount[$key]);
       }
     }
-    ksort($dateColumn);
-    foreach ($dateColumn as $key => $ignore) {
-      $columns[date('M, Y', strtotime($key))] = 1;
-    }
     $this->_columnHeaders = $columns;
   }
-  /**
-   * @param $rows
-   *
-   */
-  public function statistics(&$rows) {}
-
-  /**
-   * Alter display of rows.
-   *
-   * Iterate through the rows retrieved via SQL and make changes for display purposes,
-   * such as rendering contacts as links.
-   *
-   * @param array $rows
-   *   Rows generated by SQL, with an array for each row.
-   */
-  public function alterDisplay(&$rows) {}
 
 }
index 63faa28c22d3937d9853000eafd2902834a17940..608e408f360cac5352ddb41e29d973cffc222039 100644 (file)
@@ -581,6 +581,7 @@ class CRM_Report_Form_Contribute_Lybunt extends CRM_Report_Form {
    */
   public function buildQuery($applyLimit = TRUE) {
     $this->buildGroupTempTable();
+    $this->buildPermissionClause();
     // Calling where & select before FROM allows us to build temp tables to use in from.
     $this->where();
     $this->select();
index 684032ad1f72cd62c50be9ef47f840434e35b067..9b59afb436717bb07cc3295e7f8be4ef7b3e0ef0 100644 (file)
@@ -229,6 +229,12 @@ class CRM_Report_Form_Contribute_Summary extends CRM_Report_Form {
       'civicrm_batch' => array(
         'dao' => 'CRM_Batch_DAO_EntityBatch',
         'grouping' => 'contri-fields',
+        'fields' => array(
+          'batch_id' => array(
+            'name' => 'batch_id',
+            'title' => ts('Batch Title'),
+          ),
+        ),
         'filters' => array(
           'batch_id' => array(
             'title' => ts('Batch Title'),
@@ -237,6 +243,9 @@ class CRM_Report_Form_Contribute_Summary extends CRM_Report_Form {
             'type' => CRM_Utils_Type::T_INT,
           ),
         ),
+        'group_bys' => array(
+          'batch_id' => array('title' => ts('Batch ID')),
+        ),
       ),
       'civicrm_contribution_soft' => array(
         'dao' => 'CRM_Contribute_DAO_ContributionSoft',
@@ -495,14 +504,15 @@ class CRM_Report_Form_Contribute_Summary extends CRM_Report_Form {
                         {$this->_aliases['civicrm_phone']}.is_primary = 1)";
 
     $this->addAddressFromClause();
-    if (!empty($this->_params['batch_id_value'])) {
+    //for contribution batches
+    if ($this->isTableSelected('civicrm_batch')) {
       $this->_from .= "
-                 LEFT JOIN civicrm_entity_financial_trxn eft
-                        ON eft.entity_id = {$this->_aliases['civicrm_contribution']}.id AND
-                           eft.entity_table = 'civicrm_contribution'
-                 LEFT JOIN civicrm_entity_batch {$this->_aliases['civicrm_batch']}
-                        ON {$this->_aliases['civicrm_batch']}.entity_id = eft.financial_trxn_id AND
-                           {$this->_aliases['civicrm_batch']}.entity_table = 'civicrm_financial_trxn'\n";
+        LEFT JOIN civicrm_entity_financial_trxn eft
+          ON eft.entity_id = {$this->_aliases['civicrm_contribution']}.id AND
+            eft.entity_table = 'civicrm_contribution'
+        LEFT JOIN civicrm_entity_batch {$this->_aliases['civicrm_batch']}
+          ON ({$this->_aliases['civicrm_batch']}.entity_id = eft.financial_trxn_id
+          AND {$this->_aliases['civicrm_batch']}.entity_table = 'civicrm_financial_trxn')";
     }
   }
 
@@ -936,6 +946,12 @@ ROUND(AVG({$this->_aliases['civicrm_contribution_soft']}.amount), 2) as civicrm_
         $entryFound = TRUE;
       }
 
+      // convert batch id to batch title
+      if (!empty($row['civicrm_batch_batch_id'])) {
+        $rows[$rowNum]['civicrm_batch_batch_id'] = CRM_Core_DAO::getFieldValue('CRM_Batch_BAO_Batch', $row['civicrm_batch_batch_id'], 'title');
+        $entryFound = TRUE;
+      }
+
       $entryFound = $this->alterDisplayAddressFields($row, $rows, $rowNum, 'contribute/detail', 'List all contribution(s) for this ') ? TRUE : $entryFound;
       $entryFound = $this->alterDisplayContactFields($row, $rows, $rowNum, 'contribute/detail', 'List all contribution(s) for this ') ? TRUE : $entryFound;
 
index 9254f8bdcaab1c633d08f546680955819765600a..99a69328da3d0019e00865a80edb77035c8aae8f 100644 (file)
@@ -202,8 +202,7 @@ class CRM_Report_Form_Event_Summary extends CRM_Report_Form_Event {
                   $this->_participantWhere
 
         GROUP BY civicrm_participant.event_id,
-                 civicrm_participant.status_id,
-                 civicrm_participant.fee_currency";
+                 civicrm_participant.status_id";
 
     $info = CRM_Core_DAO::executeQuery($sql);
     $participant_data = $participant_info = $currency = array();
@@ -262,8 +261,8 @@ class CRM_Report_Form_Event_Summary extends CRM_Report_Form_Event {
       }
     }
 
-    $statusType1 = CRM_Event_PseudoConstant::participantStatus(NULL, 'is_counted = 1');
-    $statusType2 = CRM_Event_PseudoConstant::participantStatus(NULL, 'is_counted = 0');
+    $statusType1 = CRM_Event_PseudoConstant::participantStatus(NULL, 'is_counted = 1', 'label');
+    $statusType2 = CRM_Event_PseudoConstant::participantStatus(NULL, 'is_counted = 0', 'label');
 
     //make column header for participant status  Registered/Attended
     $type1_header = implode('/', $statusType1);
index 2fe10ce02680056f0ef6f1cfd89ab2a9f29f32da..f21d1d5785a4d5392b940c25bb93f57cedf45371 100644 (file)
@@ -580,6 +580,7 @@ class CRM_Report_Form_Member_ContributionDetail extends CRM_Report_Form {
     $this->tempTable();
     $this->from();
     $this->customDataFrom();
+    $this->buildPermissionClause();
     $this->where();
     $this->groupBy();
     $this->orderBy();
index 6f7cc03d22b0fb1ce8d84bbe9f39b1a53111e15d..0919c7f07005656bdd88f236200d2573b34e4a9e 100644 (file)
@@ -44,27 +44,44 @@ class CRM_Tag_Form_Edit extends CRM_Admin_Form {
     return 'Tag';
   }
 
+  public function preProcess() {
+    CRM_Utils_Request::retrieve('id', 'Integer', $this, FALSE);
+    $this->set('BAOName', 'CRM_Core_BAO_Tag');
+    parent::preProcess();
+  }
+
   /**
    * Build the form object.
    */
   public function buildQuickForm() {
     if ($this->_action == CRM_Core_Action::DELETE) {
-      if ($this->_id && $tag = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Tag', $this->_id, 'name', 'parent_id')) {
-        $url = CRM_Utils_System::url('civicrm/tag', "reset=1");
-        CRM_Core_Error::statusBounce(ts("This tag cannot be deleted. You must delete all its child tags ('%1', etc) prior to deleting this tag.", array(1 => $tag)), $url);
+      $url = CRM_Utils_System::url('civicrm/tag');
+      if (!$this->_id) {
+        $this->_id = explode(',', CRM_Utils_Request::retrieve('id', 'String'));
       }
-      if ($this->_values['is_reserved'] == 1 && !CRM_Core_Permission::check('administer reserved tags')) {
-        CRM_Core_Error::statusBounce(ts("You do not have sufficient permission to delete this reserved tag."));
+      $this->_id = (array) $this->_id;
+      if (!$this->_id) {
+        CRM_Core_Error::statusBounce(ts("Unknown tag."), $url);
+      }
+      foreach ($this->_id as $id) {
+        if (!CRM_Utils_Rule::positiveInteger($id)) {
+          CRM_Core_Error::statusBounce(ts("Unknown tag."), $url);
+        }
+        if ($tag = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Tag', $id, 'name', 'parent_id')) {
+          CRM_Core_Error::statusBounce(ts("This tag cannot be deleted. You must delete all its child tags ('%1', etc) prior to deleting this tag.", array(1 => $tag)), $url);
+        }
+        if (!CRM_Core_Permission::check('administer reserved tags') && CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Tag', $id, 'is_reserved')) {
+          CRM_Core_Error::statusBounce(ts("You do not have sufficient permission to delete this reserved tag."), $url);
+        }
+      }
+      if (count($this->_id) > 1) {
+        $this->assign('delName', ts('%1 tags', array(1 => count($this->_id))));
       }
     }
     else {
-      $parentId = NULL;
-      $isTagSetChild = FALSE;
-
       $this->_isTagSet = CRM_Utils_Request::retrieve('tagset', 'Positive', $this);
 
-      if (!$this->_isTagSet &&
-        $this->_id &&
+      if (!$this->_isTagSet && $this->_id &&
         CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Tag', $this->_id, 'is_tagset')
       ) {
         $this->_isTagSet = TRUE;
@@ -72,8 +89,11 @@ class CRM_Tag_Form_Edit extends CRM_Admin_Form {
 
       if ($this->_id) {
         $parentId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Tag', $this->_id, 'parent_id');
-        $isTagSetChild = $parentId ? CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Tag', $parentId, 'is_tagset') : FALSE;
       }
+      else {
+        $parentId = CRM_Utils_Request::retrieve('parent_id', 'Integer', $this);
+      }
+      $isTagSetChild = $parentId ? CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Tag', $parentId, 'is_tagset') : FALSE;
 
       if (!$this->_isTagSet) {
         if (!$isTagSetChild) {
@@ -109,7 +129,9 @@ class CRM_Tag_Form_Edit extends CRM_Admin_Form {
 
       $isReserved = $this->add('checkbox', 'is_reserved', ts('Reserved?'));
 
-      $this->addSelect('used_for', array('multiple' => TRUE, 'option_url' => NULL));
+      if (!$isTagSetChild) {
+        $this->addSelect('used_for', array('multiple' => TRUE, 'option_url' => NULL));
+      }
 
       $adminTagset = TRUE;
       if (!CRM_Core_Permission::check('administer Tagsets')) {
@@ -135,10 +157,17 @@ class CRM_Tag_Form_Edit extends CRM_Admin_Form {
    */
   public function setDefaultValues() {
     $defaults = parent::setDefaultValues();
-    if (empty($this->_id) || !CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Tag', $this->_id, 'color')) {
+    $cloneFrom = CRM_Utils_Request::retrieve('clone_from', 'Integer');
+    if (empty($this->_id) && $cloneFrom) {
+      $params = array('id' => $cloneFrom);
+      CRM_Core_BAO_Tag::retrieve($params, $this->_values);
+      $this->_values['name'] .= ' (' . ts('copy') . ')';
+      $defaults = $this->_values;
+    }
+    if (empty($defaults['color'])) {
       $defaults['color'] = '#ffffff';
     }
-    if (empty($this->_id)) {
+    if (empty($this->_id) && empty($defaults['used_for'])) {
       $defaults['used_for'] = 'civicrm_contact';
     }
     return $defaults;
@@ -148,46 +177,60 @@ class CRM_Tag_Form_Edit extends CRM_Admin_Form {
    * Process the form submission.
    */
   public function postProcess() {
-    // store the submitted values in an array
-    $params = $this->exportValues();
-    if ($this->_id) {
-      $params['id'] = $this->_id;
-    }
-
-    if ($this->_action == CRM_Core_Action::ADD ||
-      $this->_action == CRM_Core_Action::UPDATE
-    ) {
-      $params['used_for'] = implode(",", $params['used_for']);
+    if ($this->_action == CRM_Core_Action::DELETE) {
+      $deleted = 0;
+      $tag = civicrm_api3('tag', 'getsingle', array('id' => $this->_id[0]));
+      foreach ($this->_id as $id) {
+        if (CRM_Core_BAO_Tag::del($id)) {
+          $deleted++;
+        }
+      }
+      if (count($this->_id) == 1 && $deleted == 1) {
+        if ($tag['is_tagset']) {
+          CRM_Core_Session::setStatus(ts("The tag set '%1' has been deleted.", array(1 => $tag['name'])), ts('Deleted'), 'success');
+        }
+        else {
+          CRM_Core_Session::setStatus(ts("The tag '%1' has been deleted.", array(1 => $tag['name'])), ts('Deleted'), 'success');
+        }
+      }
+      else {
+        CRM_Core_Session::setStatus(ts("Deleted %1 tags.", array(1 => $deleted)), ts('Deleted'), 'success');
+      }
     }
+    else {
+      $params = $this->exportValues();
+      if ($this->_id) {
+        $params['id'] = $this->_id;
+      }
 
-    $params['is_tagset'] = 0;
-    if ($this->_isTagSet) {
-      $params['is_tagset'] = 1;
-    }
+      if (isset($params['used_for']) && ($this->_action == CRM_Core_Action::ADD || $this->_action == CRM_Core_Action::UPDATE)) {
+        $params['used_for'] = implode(",", $params['used_for']);
+      }
 
-    if (!isset($params['is_reserved'])) {
-      $params['is_reserved'] = 0;
-    }
+      $params['is_tagset'] = 0;
+      if ($this->_isTagSet) {
+        $params['is_tagset'] = 1;
+      }
 
-    if (!isset($params['is_selectable'])) {
-      $params['is_selectable'] = 0;
-    }
+      if (!isset($params['is_reserved'])) {
+        $params['is_reserved'] = 0;
+      }
 
-    if (strtolower($params['color']) == '#ffffff') {
-      $params['color'] = 'null';
-    }
+      if (!isset($params['parent_id']) && $this->get('parent_id')) {
+        $params['parent_id'] = $this->get('parent_id');
+      }
+      if (empty($params['parent_id'])) {
+        $params['parent_id'] = '';
+      }
 
-    if ($this->_action == CRM_Core_Action::DELETE) {
-      if ($this->_id > 0) {
-        $tag = civicrm_api3('tag', 'getsingle', array('id' => $this->_id));
-        CRM_Core_BAO_Tag::del($this->_id);
-        CRM_Core_Session::setStatus(ts("The tag '%1' has been deleted.", array(1 => $tag['name'])), ts('Deleted'), 'success');
+      if (!isset($params['is_selectable'])) {
+        $params['is_selectable'] = 0;
       }
-    }
-    else {
       $tag = CRM_Core_BAO_Tag::add($params);
       CRM_Core_Session::setStatus(ts("The tag '%1' has been saved.", array(1 => $tag->name)), ts('Saved'), 'success');
+      $this->ajaxResponse['tag'] = $tag->toArray();
     }
+    CRM_Core_Session::singleton()->pushUserContext(CRM_Utils_System::url('civicrm/tag'));
   }
 
 }
diff --git a/CRM/Tag/Form/Merge.php b/CRM/Tag/Form/Merge.php
new file mode 100644 (file)
index 0000000..f677808
--- /dev/null
@@ -0,0 +1,126 @@
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 4.7                                                |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2017                                |
+ +--------------------------------------------------------------------+
+ | 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-2017
+ */
+
+/**
+ * Form for merging tags.
+ */
+class CRM_Tag_Form_Merge extends CRM_Core_Form {
+  protected $_id;
+  protected $_tags;
+
+  public function preProcess() {
+    $this->_id = CRM_Utils_Request::retrieve('id', 'String', $this, FALSE);
+    $this->_id = explode(',', $this->_id);
+    $url = CRM_Utils_System::url('civicrm/tag');
+    if (count($this->_id) < 2) {
+      CRM_Core_Error::statusBounce(ts("You must select at least 2 tags for merging."), $url);
+    }
+    $tags = civicrm_api3('Tag', 'get', array('id' => array('IN' => $this->_id), 'options' => array('limit' => 0)));
+    $this->_tags = $tags['values'];
+    if (count($this->_id) != count($this->_tags)) {
+      CRM_Core_Error::statusBounce(ts("Unknown tag."), $url);
+    }
+    if (!CRM_Core_Permission::check('administer reserved tags')) {
+      foreach ($tags['values'] as $tag) {
+        if (!empty($tag['is_reserved'])) {
+          CRM_Core_Error::statusBounce(ts("You do not have permission to administer reserved tags."), $url);
+        }
+      }
+    }
+  }
+
+  /**
+   * Build the form object.
+   */
+  public function buildQuickForm() {
+    $this->add('text', 'name', ts('Name of combined tag'), TRUE);
+    $this->assign('tags', CRM_Utils_Array::collect('name', $this->_tags));
+
+    $this->addButtons(array(
+        array(
+          'type' => 'next',
+          'name' => ts('Merge'),
+          'spacing' => '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',
+          'isDefault' => TRUE,
+        ),
+        array(
+          'type' => 'cancel',
+          'name' => ts('Cancel'),
+        ),
+      )
+    );
+  }
+
+  /**
+   * Set default values for the form.
+   *
+   * @return array
+   */
+  public function setDefaultValues() {
+    $primary = CRM_Utils_Array::first($this->_tags);
+    return array(
+      'name' => $primary['name'],
+    );
+  }
+
+  /**
+   * Process the form submission.
+   */
+  public function postProcess() {
+    $params = $this->exportValues();
+    $deleted = CRM_Utils_Array::collect('name', $this->_tags);
+    $primary = array_shift($this->_tags);
+
+    foreach ($this->_tags as $tag) {
+      CRM_Core_BAO_EntityTag::mergeTags($primary['id'], $tag['id']);
+    }
+
+    if ($params['name'] != $primary['name']) {
+      civicrm_api3('Tag', 'create', array('id' => $primary['id'], 'name' => $params['name']));
+    }
+
+    $key = array_search($params['name'], $deleted);
+    if ($key !== FALSE) {
+      unset($deleted[$key]);
+    }
+
+    CRM_Core_Session::setStatus(
+      ts('All records previously tagged %1 are now tagged %2.', array(1 => implode(' ' . ts('or') . ' ', $deleted), 2 => $params['name'])),
+      ts('%1 Tags Merged', array(1 => count($this->_id))),
+      'success'
+    );
+
+    CRM_Core_Session::singleton()->pushUserContext(CRM_Utils_System::url('civicrm/tag'));
+  }
+
+}
index 55ccd7514f237ad7d9625e9dc4e8b5904a660b0c..231fb43db0a49d36f794a8d62f39d9bed2be8e90 100644 (file)
@@ -99,17 +99,6 @@ class CRM_Tag_Form_Tag extends CRM_Core_Form {
 
     $tags = new CRM_Core_BAO_Tag();
     $tree = $tags->getTree($this->_entityTable, TRUE);
-
-    // let's not load jstree if there are not children. This also fixes blank
-    // display at the beginning of checkboxes
-    $loadJsTree = CRM_Utils_Array::retrieveValueRecursive($tree, 'children');
-    $this->assign('loadjsTree', FALSE);
-    if (!empty($loadJsTree)) {
-      CRM_Core_Resources::singleton()
-        ->addScriptFile('civicrm', 'packages/jquery/plugins/jstree/jquery.jstree.js', 0, 'html-header', FALSE)
-        ->addStyleFile('civicrm', 'packages/jquery/plugins/jstree/themes/default/style.css', 0, 'html-header');
-      $this->assign('loadjsTree', TRUE);
-    }
     $this->assign('tree', $tree);
 
     $this->assign('allTags', $allTags);
index 5a1c18259a9d4a27f571625c7f5fdd8a4ef34e8c..1c98beca046238513360a5109ce21cad26e40bf1 100644 (file)
  */
 
 /**
- * Page for displaying list of categories.
+ * Page for managing tags.
  */
-class CRM_Tag_Page_Tag extends CRM_Core_Page_Basic {
-
-  public $useLivePageJS = TRUE;
-
-  /**
-   * The action links that we need to display for the browse screen.
-   *
-   * @var array
-   */
-  static $_links = NULL;
-
-  /**
-   * Get BAO.
-   *
-   * @return string
-   *   Classname of BAO.
-   */
-  public function getBAOName() {
-    return 'CRM_Core_BAO_Tag';
-  }
-
-  /**
-   * Get action Links.
-   *
-   * @return array
-   *   (reference) of action links
-   */
-  public function &links() {
-    if (!(self::$_links)) {
-      self::$_links = array(
-        CRM_Core_Action::UPDATE => array(
-          'name' => ts('Edit'),
-          'url' => 'civicrm/tag',
-          'qs' => 'action=update&id=%%id%%&reset=1',
-          'title' => ts('Edit Tag'),
-        ),
-        CRM_Core_Action::DELETE => array(
-          'name' => ts('Delete'),
-          'url' => 'civicrm/tag',
-          'qs' => 'action=delete&id=%%id%%',
-          'title' => ts('Delete Tag'),
-        ),
-        CRM_Core_Action::FOLLOWUP => array(
-          'name' => ts('Merge'),
-          'class' => 'merge_tag',
-          'title' => ts('Merge Tag'),
-        ),
-      );
-    }
-    return self::$_links;
-  }
-
-  /**
-   * Get name of edit form.
-   *
-   * @return string
-   *   Classname of edit form.
-   */
-  public function editForm() {
-    return 'CRM_Tag_Form_Edit';
-  }
-
-  /**
-   * Get form name for edit form.
-   *
-   * @return string
-   *   name of this page.
-   */
-  public function editName() {
-    return 'Tag';
-  }
-
-  /**
-   * Get form name for delete form.
-   *
-   * @return string
-   *   name of this page.
-   */
-  public function deleteName() {
-    return 'Tag';
-  }
-
-  /**
-   * Get user context.
-   *
-   * @param null $mode
-   *
-   * @return string
-   *   user context.
-   */
-  public function userContext($mode = NULL) {
-    return 'civicrm/tag';
-  }
-
-  /**
-   * Get name of delete form.
-   *
-   * @return string
-   *   Classname of delete form.
-   */
-  public function deleteForm() {
-    return 'CRM_Tag_Form_Edit';
-  }
+class CRM_Tag_Page_Tag extends CRM_Core_Page {
 
   /**
-   * Override function browse()
-   *
-   * @param null $action
-   * @param null $sort
+   * Run page
    */
-  public function browse($action = NULL, $sort = NULL) {
-    $adminTagSet = FALSE;
-    if (CRM_Core_Permission::check('administer Tagsets')) {
-      $adminTagSet = TRUE;
+  public function run() {
+    CRM_Core_Resources::singleton()
+      ->addScriptFile('civicrm', 'bower_components/jstree/dist/jstree.min.js', 0, 'html-header')
+      ->addStyleFile('civicrm', 'bower_components/jstree/dist/themes/default/style.min.css')
+      ->addPermissions(array('administer reserved tags', 'administer Tagsets'));
+
+    $usedFor = $tagsets = array();
+
+    $result = civicrm_api3('OptionValue', 'get', array(
+      'return' => array("value", "name"),
+      'option_group_id' => "tag_used_for",
+    ));
+    foreach ($result['values'] as $value) {
+      $usedFor[$value['value']] = $value['name'];
     }
-    $this->assign('adminTagSet', $adminTagSet);
-
-    $reservedClause = !CRM_Core_Permission::check('administer reserved tags') ? "AND t1.is_reserved != 1" : '';
-    $query = "SELECT t1.name, t1.id
-FROM civicrm_tag t1 LEFT JOIN civicrm_tag t2 ON t1.id = t2.parent_id
-WHERE t2.id IS NULL {$reservedClause}";
-    $tag = CRM_Core_DAO::executeQuery($query);
-
-    $mergeableTags = array();
-    while ($tag->fetch()) {
-      $mergeableTags[$tag->id] = 1;
-    }
-
-    $usedFor = CRM_Core_OptionGroup::values('tag_used_for');
-
-    $query = " SELECT t1.name, t1.id, t2.name as parent, t1.description, t1.used_for, t1.is_tagset as is_tagset,
-                      t1.is_reserved, t1.parent_id, t1.used_for, t1.color, t2.is_tagset as is_tagset_child, t2.parent_id as grandparent_id
-               FROM civicrm_tag t1
-               LEFT JOIN civicrm_tag t2 ON t1.parent_id = t2.id
-               LEFT JOIN civicrm_tag t3 ON t2.parent_id = t3.id
-               ORDER BY CONCAT(IFNULL(t3.name, ''), IFNULL(t2.name, ''), t1.name)";
-
-    $tag = CRM_Core_DAO::executeQuery($query);
-    $values = array();
 
-    $action = CRM_Core_Action::UPDATE + CRM_Core_Action::DELETE;
-    $permission = CRM_Core_Permission::EDIT;
-
-    while ($tag->fetch()) {
-      $values[$tag->id] = (array) $tag;
-
-      $used = array();
-      if ($values[$tag->id]['used_for']) {
-        $usedArray = explode(",", $values[$tag->id]['used_for']);
-        foreach ($usedArray as $key => $value) {
-          $used[$key] = $usedFor[$value];
-        }
-      }
-
-      $values[$tag->id]['used_for'] = implode(", ", $used);
-
-      $newAction = $action;
-      if ($values[$tag->id]['is_reserved']) {
-        $newAction = CRM_Core_Action::UPDATE;
-      }
-
-      if ($values[$tag->id]['is_tagset'] && !CRM_Core_Permission::check('administer Tagsets')) {
-        $newAction = 0;
-      }
-
-      if (array_key_exists($tag->id, $mergeableTags)) {
-        $newAction += CRM_Core_Action::FOLLOWUP;
-      }
-
-      // populate action links
-      if ($newAction) {
-        $this->action($tag, $newAction, $values[$tag->id], self::links(), $permission, TRUE);
-      }
-      else {
-        $values[$tag->id]['action'] = '';
+    $result = civicrm_api3('Tag', 'get', array(
+      'return' => array("name", "used_for", "description", "created_id.display_name", "created_date", "is_reserved"),
+      'is_tagset' => 1,
+      'options' => array('limit' => 0),
+    ));
+    foreach ($result['values'] as $id => $tagset) {
+      $used = explode(',', CRM_Utils_Array::value('used_for', $tagset, ''));
+      $tagset['used_for_label'] = array_values(array_intersect_key($usedFor, array_flip($used)));
+      if (isset($tagset['created_id.display_name'])) {
+        $tagset['display_name'] = $tagset['created_id.display_name'];
       }
+      unset($tagset['created_id.display_name']);
+      $tagsets[$id] = $tagset;
     }
 
-    $this->assign('rows', $values);
+    $this->assign('usedFor', $usedFor);
+    $this->assign('tagsets', $tagsets);
+
+    return parent::run();
   }
 
 }
index a1a3c58152a8edc27272882bd483cbd777a42d45..53083e06e076bcb5af1a445f87272e7510b6c8e9 100644 (file)
@@ -59,6 +59,9 @@ class CRM_Upgrade_Incremental_php_FourSeven extends CRM_Upgrade_Incremental_Base
         $preUpgradeMessage .= '<p>' . ts('The %1 payment processor is no longer bundled with CiviCRM. After upgrading you will need to install the extension to continue using it.', array(1 => 'Moneris')) . '</p>';
       }
     }
+    if ($rev == '4.7.13') {
+      $preUpgradeMessage .= '<p>' . ts('A new permission has been added called %1 This Permission is now used to control access to the Manage Tags screen', array(1 => 'manage tags')) . '</p>';
+    }
   }
 
   /**
@@ -119,6 +122,7 @@ class CRM_Upgrade_Incremental_php_FourSeven extends CRM_Upgrade_Incremental_Base
    * @param string $rev
    */
   public function upgrade_4_7_alpha1($rev) {
+    $this->addTask('Drop action scheudle mapping foreign key', 'dropActionScheudleMappingForeignKey');
     $this->addTask('Migrate \'on behalf of\' information to module_data', 'migrateOnBehalfOfInfo');
     $this->addTask(ts('Upgrade DB to %1: SQL', array(1 => $rev)), 'runSql', $rev);
     $this->addTask(ts('Migrate Settings to %1', array(1 => $rev)), 'migrateSettings', $rev);
@@ -303,6 +307,16 @@ class CRM_Upgrade_Incremental_php_FourSeven extends CRM_Upgrade_Incremental_Base
     $this->addTask(ts('Upgrade DB to %1: SQL', array(1 => $rev)), 'runSql', $rev);
   }
 
+  /**
+   * Upgrade function.
+   *
+   * @param string $rev
+   */
+  public function upgrade_4_7_18($rev) {
+    $this->addTask('Update Kenyan Provinces', 'updateKenyanProvinces');
+    $this->addTask(ts('Upgrade DB to %1: SQL', array(1 => $rev)), 'runSql', $rev);
+  }
+
   /*
    * Important! All upgrade functions MUST add a 'runSql' task.
    * Uncomment and use the following template for a new upgrade version
@@ -780,6 +794,18 @@ FROM `civicrm_dashboard_contact` JOIN `civicrm_contact` WHERE civicrm_dashboard_
     return TRUE;
   }
 
+  /**
+   * CRM-18464 Check if Foreign key exists and also drop any index of same name accidentially created.
+   *
+   * @param \CRM_Queue_TaskContext $ctx
+   *
+   * @return bool
+   */
+  public static function dropActionScheudleMappingForeignKey(CRM_Queue_TaskContext $ctx) {
+    CRM_Core_BAO_SchemaHandler::safeRemoveFK('civicrm_action_schedule', 'FK_civicrm_action_schedule_mapping_id');
+    return TRUE;
+  }
+
   /**
    * CRM-18345 Don't delete mailing data on email/phone deletion
    * Implemented here in CRM-18526
@@ -967,4 +993,56 @@ FROM `civicrm_dashboard_contact` JOIN `civicrm_contact` WHERE civicrm_dashboard_
     return TRUE;
   }
 
+  /**
+   * Update Kenyan Provinces to reflect changes per CRM-20062
+   *
+   * @param \CRM_Queue_TaskContext $ctx
+   */
+  public function updateKenyanProvinces(CRM_Queue_TaskContext $ctx) {
+    $kenyaCountryID = CRM_Core_DAO::singleValueQuery('SELECT max(id) from civicrm_country where iso_code = "KE"');
+    $oldProvinces = array(
+      'Nairobi Municipality',
+      'Coast',
+      'North-Eastern Kaskazini Mashariki',
+      'Rift Valley',
+      'Western Magharibi',
+    );
+    self::deprecateStateProvinces($kenyaCountryID, $oldProvinces);
+    return TRUE;
+  }
+
+  /**
+   * Deprecate provinces that no longer exist.
+   *
+   * @param int $countryID
+   * @param array $provinces
+   */
+  public static function deprecateStateProvinces($countryID, $provinces) {
+    foreach ($provinces as $province) {
+      $existingStateID = CRM_Core_DAO::singleValueQuery("
+        SELECT id FROM civicrm_state_province
+        WHERE country_id = %1
+        AND name = %2
+      ",
+      array(1 => array($countryID, 'Int'), 2 => array($province, 'String')));
+
+      if (!$existingStateID) {
+        continue;
+      }
+      if (!CRM_Core_DAO::singleValueQuery("
+       SELECT count(*) FROM civicrm_address
+       WHERE state_province_id = %1
+       ", array(1 => array($existingStateID, 'Int')))
+      ) {
+        CRM_Core_DAO::executeQuery("DELETE FROM civicrm_state_province WHERE id = %1", array(1 => array($existingStateID, 'Int')));
+      }
+      else {
+        $params = array('1' => array(ts("Former - $province"), 'String'));
+        CRM_Core_DAO::executeQuery("
+          UPDATE civicrm_state_province SET name = %1 WHERE id = $existingStateID
+        ", $params);
+      }
+    }
+  }
+
 }
index 705276ee8817a99091902807f4b3942d4d798b62..03a47793e26c73eb27ef722b6a2d98246ab9844f 100644 (file)
@@ -1,4 +1,14 @@
 {* file to handle db changes in 4.7.17 during upgrade *}
+
+-- CRM-19943
+UPDATE civicrm_navigation SET url = 'civicrm/tag' WHERE url = 'civicrm/tag?reset=1';
+UPDATE civicrm_navigation SET url = REPLACE(url, 'civicrm/tag', 'civicrm/tag/edit') WHERE url LIKE 'civicrm/tag?%';
+
 -- CRM-19815, CRM-19830 update references to check_number to reflect unique name
 UPDATE civicrm_uf_field SET field_name = 'contribution_check_number' WHERE field_name = 'check_number';
 UPDATE civicrm_mapping_field SET name = 'contribution_check_number' WHERE name = 'check_number';
+
+-- CRM-20158
+ALTER TABLE `civicrm_financial_trxn`
+  ADD card_type INT( 10 ) UNSIGNED NULL DEFAULT NULL COMMENT 'FK to accept_creditcard option group values' AFTER payment_instrument_id,
+  ADD pan_truncation INT UNSIGNED NULL COMMENT 'Last 4 digits of credit card.' AFTER check_number;
diff --git a/CRM/Upgrade/Incremental/sql/4.7.18.mysql.tpl b/CRM/Upgrade/Incremental/sql/4.7.18.mysql.tpl
new file mode 100644 (file)
index 0000000..0e9e08a
--- /dev/null
@@ -0,0 +1,70 @@
+{* file to handle db changes in 4.7.18 during upgrade *}
+
+-- CRM-20062 New counties of Kenya.
+SELECT @country_id := max(id) from civicrm_country where iso_code = "KE";
+INSERT IGNORE INTO civicrm_state_province (country_id, abbreviation, name) VALUES
+(@country_id, "01", "Baringo"),
+(@country_id, "02", "Bomet"),
+(@country_id, "03", "Bungoma"),
+(@country_id, "04", "Busia"),
+(@country_id, "05", "Elgeyo/Marakwet"),
+(@country_id, "06", "Embu"),
+(@country_id, "07", "Garissa"),
+(@country_id, "08", "Homa Bay"),
+(@country_id, "09", "Isiolo"),
+(@country_id, "10", "Kajiado"),
+(@country_id, "11", "Kakamega"),
+(@country_id, "12", "Kericho"),
+(@country_id, "13", "Kiambu"),
+(@country_id, "14", "Kilifi"),
+(@country_id, "15", "Kirinyaga"),
+(@country_id, "16", "Kisii"),
+(@country_id, "17", "Kisumu"),
+(@country_id, "18", "Kitui"),
+(@country_id, "19", "Kwale"),
+(@country_id, "20", "Laikipia"),
+(@country_id, "21", "Lamu"),
+(@country_id, "22", "Machakos"),
+(@country_id, "23", "Makueni"),
+(@country_id, "24", "Mandera"),
+(@country_id, "25", "Marsabit"),
+(@country_id, "26", "Meru"),
+(@country_id, "27", "Migori"),
+(@country_id, "28", "Mombasa"),
+(@country_id, "29", "Murang'a"),
+(@country_id, "30", "Nairobi City"),
+(@country_id, "31", "Nakuru"),
+(@country_id, "32", "Nandi"),
+(@country_id, "33", "Narok"),
+(@country_id, "34", "Nyamira"),
+(@country_id, "35", "Nyandarua"),
+(@country_id, "36", "Nyeri"),
+(@country_id, "37", "Samburu"),
+(@country_id, "38", "Siaya"),
+(@country_id, "39", "Taita/Taveta"),
+(@country_id, "40", "Tana River"),
+(@country_id, "41", "Tharaka-Nithi"),
+(@country_id, "42", "Trans Nzoia"),
+(@country_id, "43", "Turkana"),
+(@country_id, "44", "Uasin Gishu"),
+(@country_id, "45", "Vihiga"),
+(@country_id, "46", "Wajir"),
+(@country_id, "47", "West Pokot");
+
+-- CRM-19993 Fixes for ISO compliance with countries and counties
+INSERT INTO `civicrm_state_province` (`id`, `country_id`, `abbreviation`, `name`) VALUES
+(NULL, 1101, "CH", "Chandigarh"),
+(NULL, 1083, "CP", "Central"),
+(NULL, 1083, "EP", "Eastern"),
+(NULL, 1083, "NP", "Northern"),
+(NULL, 1083, "WP", "Western"),
+(NULL, 1181, "K", "Saint Kitts"),
+(NULL, 1181, "N", "Nevis"),
+(NULL, 1190, "E", "Eastern"),
+(NULL, 1190, "N", "Northern"),
+(NULL, 1190, "S", "Southern");
+
+UPDATE `civicrm_state_province` SET `name`='Uttarakhand', `abbreviation`='UT' WHERE `name` = 'Uttaranchal' AND `abbreviation`='UL';
+UPDATE `civicrm_state_province` SET `name`='Yunlin County' WHERE `name` = 'Yunlin Conuty';
+UPDATE `civicrm_country` SET `name`='Palestine, State of' WHERE `name` = 'Palestinian Territory';
+UPDATE `civicrm_country` SET `name`='Virgin Islands, British' WHERE `name` = 'Virgin Islands,British';
index 7ef1d6af18e2f8e651a06593c02629d0cc9baf57..df1ad7d5c76826743d194d361588ba90e8838457 100644 (file)
@@ -3,7 +3,6 @@
 -- Add new columns for multilingual purpose
 ALTER TABLE `civicrm_action_schedule` ADD COLUMN `filter_contact_language` varchar(128) DEFAULT NULL COMMENT 'Used for multilingual installation';
 ALTER TABLE `civicrm_action_schedule` ADD COLUMN `communication_language` varchar(8) DEFAULT NULL COMMENT 'Used for multilingual installation';
-ALTER TABLE `civicrm_action_schedule` DROP FOREIGN KEY `FK_civicrm_action_schedule_mapping_id`;
 ALTER TABLE `civicrm_action_schedule` MODIFY COLUMN mapping_id varchar(64);
 -- Q: Should we validate that local civicrm_action_mapping records have expected IDs?
 
index 2f2a17d055b0ad9af5273abdf0a17c405783676a..a533c16d93525cbe22fd7f3d9e0da2d23b4b78f1 100644 (file)
@@ -939,21 +939,21 @@ class CRM_Utils_Date {
   }
 
   /**
-   * Check given format is valid for bith date.
-   * and retrun supportable birth date format w/ qf mapping.
+   * Get the smarty view presentation mapping for the given format.
+   *
+   * Historically it was decided that where the view format is 'dd/mm/yy' or 'mm/dd/yy'
+   * they should be rendered using a longer date format. This is likely as much to
+   * do with the earlier date widget being unable to handle some formats as usablity.
+   * However, we continue to respect this.
    *
    * @param $format
    *   Given format ( eg 'M Y', 'Y M' ).
-   *   return array of qfMapping and date parts for date format.
    *
-   * @return array|null|string
+   * @return string|null
+   *   Smarty translation of the date format. Null is also valid and is translated
+   *   according to the available parts at the smarty layer.
    */
-  public static function &checkBirthDateFormat($format = NULL) {
-    $birthDateFormat = NULL;
-    if (!$format) {
-      $birthDateFormat = self::getDateFormat('birth');
-    }
-
+  public static function getDateFieldViewFormat($format) {
     $supportableFormats = array(
       'mm/dd' => '%B %E%f',
       'dd-mm' => '%E%f %B',
@@ -963,11 +963,57 @@ class CRM_Utils_Date {
       'dd/mm/yy' => '%E%f %B %Y',
     );
 
-    if (array_key_exists($birthDateFormat, $supportableFormats)) {
-      $birthDateFormat = array('qfMapping' => $supportableFormats[$birthDateFormat]);
+    return array_key_exists($format, $supportableFormats) ? $supportableFormats[$format] : self::pickBestSmartyFormat($format);
+  }
+
+  /**
+   * Pick the smarty format from settings that best matches the time string we have.
+   *
+   * For view purposes we historically use the setting that most closely matches the data
+   * in the format from our settings, as opposed to the setting configured for the field.
+   *
+   * @param $format
+   * @return mixed
+   */
+  public static function pickBestSmartyFormat($format) {
+    if (stristr($format, 'h')) {
+      return Civi::settings()->get('dateformatDatetime');
+    }
+    if (stristr($format, 'd') || stristr($format, 'j')) {
+      return Civi::settings()->get('dateformatFull');
+    }
+    if (stristr($format, 'm')) {
+      return Civi::settings()->get('dateformatPartial');
     }
+    return Civi::settings()->get('dateformatYear');
+  }
 
-    return $birthDateFormat;
+  /**
+   * Map date plugin and actual format that is used by PHP.
+   *
+   * @return array
+   */
+  public static function datePluginToPHPFormats() {
+    $dateInputFormats = array(
+      "mm/dd/yy" => 'm/d/Y',
+      "dd/mm/yy" => 'd/m/Y',
+      "yy-mm-dd" => 'Y-m-d',
+      "dd-mm-yy" => 'd-m-Y',
+      "dd.mm.yy" => 'd.m.Y',
+      "M d" => 'M j',
+      "M d, yy" => 'M j, Y',
+      "d M yy" => 'j M Y',
+      "MM d, yy" => 'F j, Y',
+      "d MM yy" => 'j F Y',
+      "DD, d MM yy" => 'l, j F Y',
+      "mm/dd" => 'm/d',
+      "dd-mm" => 'd-m',
+      "yy-mm" => 'Y-m',
+      "M yy" => 'M Y',
+      "M Y" => 'M Y',
+      "yy" => 'Y',
+    );
+    return $dateInputFormats;
   }
 
   /**
@@ -1741,6 +1787,84 @@ class CRM_Utils_Date {
     return $mysqlDate;
   }
 
+  /**
+   * Add the metadata about a date field to the field.
+   *
+   * This metadata will work with the call $form->add('datepicker', ...
+   *
+   * @param array $fieldMetaData
+   * @param array $field
+   *
+   * @return array
+   */
+  public static function addDateMetadataToField($fieldMetaData, $field) {
+    if (isset($fieldMetaData['html'])) {
+      $field['html_type'] = $fieldMetaData['html']['type'];
+      if ($field['html_type'] === 'Select Date') {
+        if (!isset($field['date_format'])) {
+          $dateAttributes = CRM_Core_SelectValues::date($fieldMetaData['html']['formatType'], NULL, NULL, NULL, 'Input');
+          $field['start_date_years'] = $dateAttributes['minYear'];
+          $field['end_date_years'] = $dateAttributes['maxYear'];
+          $field['date_format'] = $dateAttributes['format'];
+          $field['is_datetime_field'] = TRUE;
+          $field['time_format'] = $dateAttributes['time'];
+          $field['smarty_view_format'] = $dateAttributes['smarty_view_format'];
+        }
+        $field['datepicker']['extra'] = self::getDatePickerExtra($field);
+        $field['datepicker']['attributes'] = self::getDatePickerAttributes($field);
+      }
+    }
+    return $field;
+  }
+
+
+  /**
+   * Get the fields required for the 'extra' parameter when adding a datepicker.
+   *
+   * @param array $field
+   *
+   * @return array
+   */
+  public static function getDatePickerExtra($field) {
+    $extra = array();
+    if (isset($field['date_format'])) {
+      $extra['date'] = $field['date_format'];
+      $extra['time'] = $field['time_format'];
+    }
+    $thisYear = date('Y');
+    if (isset($field['start_date_years'])) {
+      $extra['minDate'] = date('Y-m-d', strtotime('-' . ($thisYear - $field['start_date_years']) . ' years'));
+    }
+    if (isset($field['end_date_years'])) {
+      $extra['maxDate'] = date('Y-m-d', strtotime('-' . ($thisYear - $field['end_date_years']) . ' years'));
+    }
+    return $extra;
+  }
+
+  /**
+   * Get the attributes parameters required for datepicker.
+   *
+   * @param array $field
+   *   Field metadata
+   *
+   * @return array
+   *   Array ready to pass to $this->addForm('datepicker' as attributes.
+   */
+  public static function getDatePickerAttributes(&$field) {
+    $attributes = array();
+    $dateAttributes = array(
+      'start_date_years' => 'minYear',
+      'end_date_years' => 'maxYear',
+      'date_format' => 'format',
+    );
+    foreach ($dateAttributes as $dateAttribute => $mapTo) {
+      if (isset($field[$dateAttribute])) {
+        $attributes[$mapTo] = $field[$dateAttribute];
+      }
+    }
+    return $attributes;
+  }
+
   /**
    * Function to convert mysql to date plugin format.
    *
index eb529aa901abc6fd73d55e1dcc22646604d6f993..fba73256c27ddcce3fd4d390ec091ac0161d58c5 100644 (file)
@@ -52,6 +52,7 @@ class CRM_Utils_Hook_UnitTests extends CRM_Utils_Hook {
    * Use a unit-testing mock object to handle hook invocations.
    *
    * e.g. hook_civicrm_foo === $mockObject->foo()
+   * Mocks with a magic `__call()` method are called for every hook invokation.
    *
    * @param object $mockObject
    */
@@ -60,7 +61,7 @@ class CRM_Utils_Hook_UnitTests extends CRM_Utils_Hook {
   }
 
   /**
-   * Register a piece of code to run when invoking a hook.
+   * Register a function to run when invoking a specific hook.
    * @param string $hook
    *   Hook name, e.g civicrm_pre.
    * @param array $callable
@@ -72,7 +73,7 @@ class CRM_Utils_Hook_UnitTests extends CRM_Utils_Hook {
   }
 
   /**
-   * Invoke hooks.
+   * Invoke standard, mock and ad hoc hooks.
    *
    * @param int $numParams
    *   Number of parameters to pass to the hook.
@@ -93,34 +94,22 @@ class CRM_Utils_Hook_UnitTests extends CRM_Utils_Hook {
    *
    * @return mixed
    */
-  /**
-   * @param int $numParams
-   * @param mixed $arg1
-   * @param mixed $arg2
-   * @param mixed $arg3
-   * @param mixed $arg4
-   * @param mixed $arg5
-   * @param mixed $arg6
-   * @param string $fnSuffix
-   *
-   * @return mixed
-   */
   public function invoke(
     $numParams,
     &$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6,
     $fnSuffix) {
-
     $params = array(&$arg1, &$arg2, &$arg3, &$arg4, &$arg5, &$arg6);
-
+    // run standard hooks
     if ($this->civiModules === NULL) {
       $this->civiModules = array();
       $this->requireCiviModules($this->civiModules);
     }
     $this->runHooks($this->civiModules, $fnSuffix, $numParams, $arg1, $arg2, $arg3, $arg4, $arg5, $arg6);
-
+    // run mock object hooks
     if ($this->mockObject && is_callable(array($this->mockObject, $fnSuffix))) {
       call_user_func(array($this->mockObject, $fnSuffix), $arg1, $arg2, $arg3, $arg4, $arg5, $arg6);
     }
+    // run adhoc hooks
     if (!empty($this->adhocHooks[$fnSuffix])) {
       call_user_func_array($this->adhocHooks[$fnSuffix], $params);
     }
index a995b7af8f2b1ac87bb09809e05da9e21bbf6078..2e8c14a9917988b2fa1571df8e093d40c707bafa 100644 (file)
@@ -136,11 +136,9 @@ class CRM_Utils_Mail_EmailProcessor {
     $usedfor = $dao->is_default;
 
     $emailActivityTypeId
-      = (defined('EMAIL_ACTIVITY_TYPE_ID') && EMAIL_ACTIVITY_TYPE_ID) ? EMAIL_ACTIVITY_TYPE_ID : CRM_Core_OptionGroup::getValue(
-        'activity_type',
-        'Inbound Email',
-        'name'
-      );
+      = (defined('EMAIL_ACTIVITY_TYPE_ID') && EMAIL_ACTIVITY_TYPE_ID)
+      ? EMAIL_ACTIVITY_TYPE_ID
+      : CRM_Core_OptionGroup::getValue('activity_type', 'Inbound Email', 'name');
 
     if (!$emailActivityTypeId) {
       CRM_Core_Error::fatal(ts('Could not find a valid Activity Type ID for Inbound Email'));
@@ -376,6 +374,14 @@ class CRM_Utils_Mail_EmailProcessor {
                 'hash' => $hash,
                 'body' => $text,
                 'version' => 3,
+                // Setting is_transactional means it will rollback if
+                // it crashes part way through creating the bounce.
+                // If the api were standard & had a create this would be the
+                // default. Adding the standard api & deprecating this one
+                // would probably be the
+                // most consistent way to address this - but this is
+                // a quick hack.
+                'is_transactional' => 1,
               );
               $result = civicrm_api('Mailing', 'event_bounce', $params);
               break;
index ff98f858b7b0c2a2a17e6beebb75f8b8c439301b..e841d67ca09461f06fb36d0b0bf671dfffbbec9c 100644 (file)
@@ -115,6 +115,7 @@ class CRM_Utils_PDF_Document {
       $phpWord = \PhpOffice\PhpWord\IOFactory::load($fileName, $formats[$ext]);
     }
 
+    \PhpOffice\PhpWord\Settings::setOutputEscapingEnabled(TRUE); //CRM-20015
     $objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, $formats[$ext]);
 
     CRM_Utils_System::setHttpHeader('Content-Type', "application/$ext");
index 2595bee080b4519b63437003aac8a709ea8cf11a..bd33490a8361b69a2eb9a5e7b650f9e27dd054a1 100644 (file)
@@ -112,11 +112,11 @@ class CRM_Utils_Pager extends Pager_Sliding {
      * page variable, but a different form element for one at the bottom.
      */
     $this->_response['titleTop'] = ts('Page %1 of %2', array(
-        1 => '<input size="2" maxlength="3" name="' . self::PAGE_ID . '" type="text" value="' . $this->_response['currentPage'] . '" />',
+        1 => '<input size="2" maxlength="4" name="' . self::PAGE_ID . '" type="text" value="' . $this->_response['currentPage'] . '" />',
         2 => $this->_response['numPages'],
       ));
     $this->_response['titleBottom'] = ts('Page %1 of %2', array(
-        1 => '<input size="2" maxlength="3" name="' . self::PAGE_ID_BOTTOM . '" type="text" value="' . $this->_response['currentPage'] . '" />',
+        1 => '<input size="2" maxlength="4" name="' . self::PAGE_ID_BOTTOM . '" type="text" value="' . $this->_response['currentPage'] . '" />',
         2 => $this->_response['numPages'],
       ));
   }
index 34f346937aef02484eb28e65e349c9964588c08e..a40286d4b5c1a414e6d9b6ac0b9a8359eb75289c 100644 (file)
@@ -100,10 +100,15 @@ class CRM_Utils_Rule {
       return FALSE;
     }
 
-    // Ensure the string contains only valid characters:
-    // For column names: alphanumeric and underscores
-    // For aliases: backticks, alphanumeric hyphens and underscores.
-    if (!preg_match('/^((`[\w-]{1,64}`|[\w-]{1,64})\.)?(`[\w-]{1,64}`|[\w-]{1,64})$/i', $str)) {
+    // Ensure $str conforms to expected format. Not a complete expression of
+    // what MySQL permits; this should permit the formats CiviCRM generates.
+    //
+    // * Table name prefix is optional.
+    // * Table & column names & aliases:
+    //   * Composed of alphanumeric chars, underscore and hyphens.
+    //   * Maximum length of 64 chars.
+    //   * Optionally surrounded by backticks, in which case spaces also OK.
+    if (!preg_match('/^((`[\w- ]{1,64}`|[\w-]{1,64})\.)?(`[\w- ]{1,64}`|[\w-]{1,64})$/i', $str)) {
       return FALSE;
     }
 
@@ -133,6 +138,21 @@ class CRM_Utils_Rule {
    * @return bool
    */
   public static function mysqlOrderBy($str) {
+    $matches = array();
+    // Using the field function in order by is valid.
+    // Look for a string like field(contribution_status_id,3,4,6).
+    // or field(civicrm_contribution.contribution_status_id,3,4,6)
+    if (preg_match('/field\([a-z_.]+,[0-9,]+\)/', $str, $matches)) {
+      // We have checked these. Remove them as they will fail the next lot.
+      // Our check currently only permits numbers & no back ticks. If we get a
+      // need for strings or backticks we can add.
+      $str = str_replace($matches, '', $str);
+    }
+    $str = trim($str);
+    if (!empty($matches) && empty($str)) {
+      // nothing left to check after the field check.
+      return TRUE;
+    }
     // Making a regex for a comma separated list is quite hard and not readable
     // at all, so we split and loop over.
     $parts = explode(',', $str);
index 8079cec6f2d61e3c40eeb88c438a2dbbeb6c3210..3ded33fe199cefa353ac9c4ac4ba72585e5e3c20 100644 (file)
@@ -1391,7 +1391,7 @@ class CRM_Utils_System {
    * @return mixed
    */
   public static function formatDocUrl($url) {
-    return preg_replace('#^user/((\w\w/)?stable/)?#', 'user/en/stable/', $url);
+    return preg_replace('#^user/((\w\w/)?(stable|current)/)?#', 'user/en/stable/', $url);
   }
 
   /**
index 475490bb3ce21ff54d166373acbb8f24cbe6e138..8d931aa045605a84c9455f96acbe2b69b7ab927c 100644 (file)
@@ -617,4 +617,20 @@ class CRM_Utils_System_Drupal8 extends CRM_Utils_System_DrupalBase {
     );
   }
 
+  /**
+   * Drupal 8 has a different function to get current path, hence
+   * overriding the postURL function
+   *
+   * @param string $action
+   *
+   * @return string
+   */
+  public function postURL($action) {
+    if (!empty($action)) {
+      return $action;
+    }
+    $current_path = \Drupal::service('path.current')->getPath();
+    return $this->url($current_path);
+  }
+
 }
index 54beb6fedfde22856f6819b934aaf6e928000b4d..c0ce0f49c19672d9aca3f9d0de60f319fecc3eb5 100644 (file)
@@ -252,7 +252,7 @@ abstract class CRM_Utils_System_DrupalBase extends CRM_Utils_System_Base {
           'cms:view user account',
         ))
     ) {
-      return url('user/' . $uid);
+      return $this->url('user/' . $uid);
     };
   }
 
index 2758d11758425545aa9c975cc6b6c52fde1ee3b1..8162ac8a615c557b1e1a5638ab70e38e94b1673e 100644 (file)
@@ -712,8 +712,20 @@ class CRM_Utils_System_Joomla extends CRM_Utils_System_Base {
       '',
       $config->userFrameworkBaseURL
     );
+    // CRM-19453 revisited. Under Windows, the pattern wasn't recognised.
+    // This is the original pattern, but it doesn't work under Windows.
+    // By setting the pattern to the one used before the change first and only
+    // changing it means that the change code only affects Windows users.
+    $pattern = '|/media/civicrm/.*$|';
+    if (DIRECTORY_SEPARATOR == '\\') {
+      // This regular expression will handle Windows as well as Linux
+      // and any combination of forward and back slashes in directory
+      // separators.  We only apply it if the directory separator is the one
+      // used by Windows.
+      $pattern = '|[\\\\/]media[\\\\/]civicrm[\\\\/].*$|';
+    }
     $siteRoot = preg_replace(
-      '|/media/civicrm/.*$|',
+      $pattern,
       '',
       $config->imageUploadDir
     );
index c782e5cec5a6c8574bba69db091b1d3bdb82271d..43b920f8be4bf595e42e4014d01f3e774074d87f 100644 (file)
@@ -143,6 +143,28 @@ class CRM_Utils_Type {
     return (isset($string)) ? $string : "";
   }
 
+  /**
+   * Get the data_type for the field.
+   *
+   * @param array $fieldMetadata
+   *   Metadata about the field.
+   *
+   * @return string
+   */
+  public static function getDataTypeFromFieldMetadata($fieldMetadata) {
+    if (isset($fieldMetadata['data_type'])) {
+      return $fieldMetadata['data_type'];
+    }
+    if (empty($fieldMetadata['type'])) {
+      // I would prefer to throw an e-notice but there is some,
+      // probably unnecessary logic, that only retrieves activity fields
+      // if they are 'in the profile' and probably they are not 'in'
+      // until they are added - which might lead to ? who knows!
+      return '';
+    }
+    return self::typeToString($fieldMetadata['type']);
+  }
+
   /**
    * Helper function to call escape on arrays.
    *
@@ -290,7 +312,33 @@ class CRM_Utils_Type {
       case 'MysqlOrderBy':
         if (CRM_Utils_Rule::mysqlOrderBy($data)) {
           $parts = explode(',', $data);
-          foreach ($parts as &$part) {
+
+          // The field() syntax is tricky here because it uses commas & when
+          // we separate by them we break it up. But we want to keep the clauses in order.
+          // so we just clumsily re-assemble it. Test cover exists.
+          $fieldClauseStart = NULL;
+          foreach ($parts as $index => &$part) {
+            if (substr($part, 0, 6) === 'field(') {
+              // Looking to escape a string like 'field(contribution_status_id,3,4,5) asc'
+              // to 'field(`contribution_status_id`,3,4,5) asc'
+              $fieldClauseStart = $index;
+              continue;
+            }
+            if ($fieldClauseStart !== NULL) {
+              // this is part of the list of field options. Concatenate it back on.
+              $parts[$fieldClauseStart] .= ',' . $part;
+              unset($parts[$index]);
+              if (!strstr($parts[$fieldClauseStart], ')')) {
+                // we have not reached the end of the list.
+                continue;
+              }
+              // We have the last piece of the field() clause, time to escape it.
+              $parts[$fieldClauseStart] = self::mysqlOrderByFieldFunctionCallback($parts[$fieldClauseStart]);
+              $fieldClauseStart = NULL;
+              continue;
+
+            }
+            // Normal clause.
             $part = preg_replace_callback('/^(?:(?:((?:`[\w-]{1,64}`|[\w-]{1,64}))(?:\.))?(`[\w-]{1,64}`|[\w-]{1,64})(?: (asc|desc))?)$/i', array('CRM_Utils_Type', 'mysqlOrderByCallback'), trim($part));
           }
           return implode(', ', $parts);
@@ -431,6 +479,19 @@ class CRM_Utils_Type {
     return NULL;
   }
 
+  /**
+   * Preg_replace_callback for mysqlOrderByFieldFunction escape.
+   *
+   * Add backticks around the field name.
+   *
+   * @param string $clause
+   *
+   * @return string
+   */
+  public static function mysqlOrderByFieldFunctionCallback($clause) {
+    return preg_replace('/field\((\w*)/', 'field(`${1}`', $clause);
+  }
+
   /**
    * preg_replace_callback for MysqlOrderBy escape.
    */
index 984b1746688ee0436c100dd2aa5117afa55fe5b0..77bdd1b4b79c51732a395277d8258e74d4022963 100644 (file)
@@ -36,6 +36,7 @@ class Api3SelectQuery extends SelectQuery {
    * @inheritDoc
    */
   protected function buildWhereClause() {
+    $filters = array();
     foreach ($this->where as $key => $value) {
       $table_name = NULL;
       $column_name = NULL;
@@ -104,23 +105,37 @@ class Api3SelectQuery extends SelectQuery {
         // Just ignore this for the $where_clause.
         continue;
       }
-      if (!is_array($value)) {
-        $this->query->where(array("`$table_name`.`$column_name` = @value"), array(
-          "@value" => $value,
-        ));
+      $operator = is_array($value) ? \CRM_Utils_Array::first(array_keys($value)) : NULL;
+      if (!in_array($operator, \CRM_Core_DAO::acceptedSQLOperators())) {
+        $value = array('=' => $value);
       }
-      else {
-        // We expect only one element in the array, of the form
-        // "operator" => "rhs".
-        $operator = \CRM_Utils_Array::first(array_keys($value));
-        if (!in_array($operator, \CRM_Core_DAO::acceptedSQLOperators())) {
-          $this->query->where(array("{$table_name}.{$column_name} = @value"), array("@value" => $value));
-        }
-        else {
-          $this->query->where(\CRM_Core_DAO::createSQLFilter("{$table_name}.{$column_name}", $value));
+      $filters[$key] = \CRM_Core_DAO::createSQLFilter("{$table_name}.{$column_name}", $value);
+    }
+    // Support OR groups
+    if (!empty($this->where['options']['or'])) {
+      $orGroups = $this->where['options']['or'];
+      if (is_string($orGroups)) {
+        $orGroups = array_map('trim', explode(',', $orGroups));
+      }
+      if (!is_array(\CRM_Utils_Array::first($orGroups))) {
+        $orGroups = array($orGroups);
+      }
+      foreach ($orGroups as $orGroup) {
+        $orClause = array();
+        foreach ($orGroup as $key) {
+          if (!isset($filters[$key])) {
+            throw new \CiviCRM_API3_Exception("'$key' specified in OR group but not added to params");
+          }
+          $orClause[] = $filters[$key];
+          unset($filters[$key]);
         }
+        $this->query->where(implode(' OR ', $orClause));
       }
     }
+    // Add the remaining params using AND
+    foreach ($filters as $filter) {
+      $this->query->where($filter);
+    }
   }
 
   /**
index c6abcb011f45b45a1545b2fc39b092959d43b829..1dd734927820f70b0d3d2f17c7e62190d882d0bf 100644 (file)
@@ -45,7 +45,7 @@ class Events {
    *
    * @see AuthorizeEvent
    */
-  const AUTHORIZE = 'api.authorize';
+  const AUTHORIZE = 'civi.api.authorize';
 
   /**
    * Determine which API provider executes the given request. For successful
@@ -54,28 +54,28 @@ class Events {
    *
    * @see ResolveEvent
    */
-  const RESOLVE = 'api.resolve';
+  const RESOLVE = 'civi.api.resolve';
 
   /**
    * Apply pre-execution logic
    *
    * @see PrepareEvent
    */
-  const PREPARE = 'api.prepare';
+  const PREPARE = 'civi.api.prepare';
 
   /**
    * Apply post-execution logic
    *
    * @see RespondEvent
    */
-  const RESPOND = 'api.respond';
+  const RESPOND = 'civi.api.respond';
 
   /**
    * Handle any exceptions.
    *
    * @see ExceptionEvent
    */
-  const EXCEPTION = 'api.exception';
+  const EXCEPTION = 'civi.api.exception';
 
   /**
    * Weight - Early
index 00274a932f3a3e12fd1b6cc0be8b07a3fa3fb9ac..9340b3b720ebb1d24b4904ed66a15f2312cd2ba2 100644 (file)
@@ -33,7 +33,7 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
 /**
  * This is a wrapper for the legacy "API Wrapper" interface which allows
  * wrappers to run through the new kernel. It translates from dispatcher events
- * ('api.prepare', 'api.respond') to wrapper calls ('fromApiInput', 'toApiOutput').
+ * ('civi.api.prepare', 'civi.api.respond') to wrapper calls ('fromApiInput', 'toApiOutput').
  */
 class WrapperAdapter implements EventSubscriberInterface {
 
index 15e49f71db8302aaa344f8f70521cf2688830779..3ff1a385e13201a81a9f02806812b573221c5d6f 100644 (file)
@@ -8,12 +8,12 @@ class Events {
    *
    * @see EntityListEvent
    */
-  const MAPPINGS = 'actionSchedule.getMappings';
+  const MAPPINGS = 'civi.actionSchedule.getMappings';
 
   /**
    * Prepare the pre-mailing query. This query loads details about
    * the contact/entity so that they're available for mail-merge.
    */
-  const MAILING_QUERY = 'actionSchedule.prepareMailingQuery';
+  const MAILING_QUERY = 'civi.actionSchedule.prepareMailingQuery';
 
 }
index 76076375a65718107499f8093b7a48016cc40972..d95b62aac13f4bb6fe5e15f464eaeea525ebd8c7 100644 (file)
@@ -245,9 +245,9 @@ class Container {
     $dispatcher->addListener('hook_civicrm_post::Case', array('\Civi\CCase\Events', 'fireCaseChange'));
     $dispatcher->addListener('hook_civicrm_caseChange', array('\Civi\CCase\Events', 'delegateToXmlListeners'));
     $dispatcher->addListener('hook_civicrm_caseChange', array('\Civi\CCase\SequenceListener', 'onCaseChange_static'));
-    $dispatcher->addListener('DAO::post-insert', array('\CRM_Core_BAO_RecurringEntity', 'triggerInsert'));
-    $dispatcher->addListener('DAO::post-update', array('\CRM_Core_BAO_RecurringEntity', 'triggerUpdate'));
-    $dispatcher->addListener('DAO::post-delete', array('\CRM_Core_BAO_RecurringEntity', 'triggerDelete'));
+    $dispatcher->addListener('civi.dao.postInsert', array('\CRM_Core_BAO_RecurringEntity', 'triggerInsert'));
+    $dispatcher->addListener('civi.dao.postUpdate', array('\CRM_Core_BAO_RecurringEntity', 'triggerUpdate'));
+    $dispatcher->addListener('civi.dao.postDelete', array('\CRM_Core_BAO_RecurringEntity', 'triggerDelete'));
     $dispatcher->addListener('hook_civicrm_unhandled_exception', array(
       'CRM_Core_LegacyErrorHandler',
       'handleException',
index 20284c2bb29825783f111def950fc3c782052191..ba87a024a02aba4bef3eefd803af691fe4b75e7b 100644 (file)
@@ -230,23 +230,35 @@ function _civicrm_api3_activity_create_spec(&$params) {
  */
 function _civicrm_api3_activity_get_spec(&$params) {
   $params['tag_id'] = array(
-    'name' => 'tag_id',
     'title' => 'Tags',
     'description' => 'Find activities with specified tags.',
     'type' => 1,
     'FKClassName' => 'CRM_Core_DAO_Tag',
     'FKApiName' => 'Tag',
+    'supports_joins' => TRUE,
+  );
+  $params['file_id'] = array(
+    'title' => 'Attached Files',
+    'description' => 'Find activities with attached files.',
+    'type' => 1,
+    'FKClassName' => 'CRM_Core_DAO_File',
+    'FKApiName' => 'File',
   );
   $params['case_id'] = array(
-    'name' => 'case_id',
     'title' => 'Cases',
     'description' => 'Find activities within specified cases.',
     'type' => 1,
     'FKClassName' => 'CRM_Case_DAO_Case',
     'FKApiName' => 'Case',
   );
+  $params['contact_id'] = array(
+    'title' => 'Activity Contact ID',
+    'description' => 'Find activities involving this contact (as target, source, OR assignee).',
+    'type' => 1,
+    'FKClassName' => 'CRM_Contact_DAO_Contact',
+    'FKApiName' => 'Contact',
+  );
   $params['target_contact_id'] = array(
-    'name' => 'target_contact_id',
     'title' => 'Target Contact ID',
     'description' => 'Find activities with specified target contact.',
     'type' => 1,
@@ -254,7 +266,6 @@ function _civicrm_api3_activity_get_spec(&$params) {
     'FKApiName' => 'Contact',
   );
   $params['source_contact_id'] = array(
-    'name' => 'source_contact_id',
     'title' => 'Source Contact ID',
     'description' => 'Find activities with specified source contact.',
     'type' => 1,
@@ -262,7 +273,6 @@ function _civicrm_api3_activity_get_spec(&$params) {
     'FKApiName' => 'Contact',
   );
   $params['assignee_contact_id'] = array(
-    'name' => 'assignee_contact_id',
     'title' => 'Assignee Contact ID',
     'description' => 'Find activities with specified assignee contact.',
     'type' => 1,
@@ -304,55 +314,62 @@ function civicrm_api3_activity_get($params) {
     }
   }
 
-  if (!empty($params['contact_id'])) {
-    $activities = CRM_Activity_BAO_Activity::getContactActivity($params['contact_id']);
-    // BAO function doesn't actually return a contact ID - hack api for now & add to test so when api re-write
-    // happens it won't get missed.
-    foreach ($activities as $key => $activityArray) {
-      $activities[$key]['id'] = $key;
+  $sql = CRM_Utils_SQL_Select::fragment();
+  // Support search by activity_contact
+  $extraFieldSpecs = array();
+  _civicrm_api3_activity_create_spec($extraFieldSpecs);
+  $options = civicrm_api3('ActivityContact', 'getoptions', array('field' => 'record_type_id'));
+  $options = $options['values'];
+  $activityContactOptions = array(
+    'contact_id' => NULL,
+    'target_contact_id' => array_search('Activity Targets', $options),
+    'source_contact_id' => array_search('Activity Source', $options),
+    'assignee_contact_id' => array_search('Activity Assignees', $options),
+  );
+  foreach ($activityContactOptions as $activityContactName => $activityContactValue) {
+    if (!empty($params[$activityContactName])) {
+      _civicrm_api3_validate_integer($params, $activityContactName, $extraFieldSpecs[$activityContactName], 'Activity');
+      if (!is_array($params[$activityContactName])) {
+        $params[$activityContactName] = array('=' => $params[$activityContactName]);
+      }
+      $clause = \CRM_Core_DAO::createSQLFilter('contact_id', $params[$activityContactName]);
+      $typeClause = $activityContactValue ? 'record_type_id = #typeId AND ' : '';
+      $sql->where("a.id IN (SELECT activity_id FROM civicrm_activity_contact WHERE $typeClause !clause)",
+        array('#typeId' => $activityContactValue, '!clause' => $clause)
+      );
     }
   }
-  else {
-    $sql = CRM_Utils_SQL_Select::fragment();
-    // Support search by activity_contact
-    $options = civicrm_api3('ActivityContact', 'getoptions', array('field' => 'record_type_id'));
-    $options = $options['values'];
-    $activityContactOptions = array(
-      'target_contact_id' => array_search('Activity Targets', $options),
-      'source_contact_id' => array_search('Activity Source', $options),
-      'assignee_contact_id' => array_search('Activity Assignees', $options),
-    );
-    foreach ($activityContactOptions as $activityContactName => $activityContactValue) {
-      if (!empty($params[$activityContactName])) {
-        if (!is_array($params[$activityContactName])) {
-          $params[$activityContactName] = array('=' => $params[$activityContactName]);
-        }
-        $clause = \CRM_Core_DAO::createSQLFilter('contact_id', $params[$activityContactName]);
-        $sql->where('a.id IN (SELECT activity_id FROM civicrm_activity_contact WHERE record_type_id = #typeId AND !clause)',
-          array('#typeId' => $activityContactValue, '!clause' => $clause)
-        );
-      }
+  if (!empty($params['tag_id'])) {
+    _civicrm_api3_validate_integer($params, 'tag_id', $extraFieldSpecs['tag_id'], 'Activity');
+    if (!is_array($params['tag_id'])) {
+      $params['tag_id'] = array('=' => $params['tag_id']);
     }
-    if (!empty($params['tag_id'])) {
-      if (!is_array($params['tag_id'])) {
-        $params['tag_id'] = array('=' => $params['tag_id']);
-      }
-      $clause = \CRM_Core_DAO::createSQLFilter('tag_id', $params['tag_id']);
-      if ($clause) {
-        $sql->where('a.id IN (SELECT entity_id FROM civicrm_entity_tag WHERE entity_table = "civicrm_activity" AND !clause)', array('!clause' => $clause));
-      }
+    $clause = \CRM_Core_DAO::createSQLFilter('tag_id', $params['tag_id']);
+    if ($clause) {
+      $sql->where('a.id IN (SELECT entity_id FROM civicrm_entity_tag WHERE entity_table = "civicrm_activity" AND !clause)', array('!clause' => $clause));
     }
-    if (!empty($params['case_id'])) {
-      if (!is_array($params['case_id'])) {
-        $params['case_id'] = array('=' => $params['case_id']);
-      }
-      $clause = \CRM_Core_DAO::createSQLFilter('case_id', $params['case_id']);
-      if ($clause) {
-        $sql->where('a.id IN (SELECT activity_id FROM civicrm_case_activity WHERE !clause)', array('!clause' => $clause));
-      }
+  }
+  if (!empty($params['file_id'])) {
+    _civicrm_api3_validate_integer($params, 'file_id', $extraFieldSpecs['file_id'], 'Activity');
+    if (!is_array($params['file_id'])) {
+      $params['file_id'] = array('=' => $params['file_id']);
+    }
+    $clause = \CRM_Core_DAO::createSQLFilter('file_id', $params['file_id']);
+    if ($clause) {
+      $sql->where('a.id IN (SELECT entity_id FROM civicrm_entity_file WHERE entity_table = "civicrm_activity" AND !clause)', array('!clause' => $clause));
     }
-    $activities = _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params, FALSE, 'Activity', $sql);
   }
+  if (!empty($params['case_id'])) {
+    _civicrm_api3_validate_integer($params, 'case_id', $extraFieldSpecs['case_id'], 'Activity');
+    if (!is_array($params['case_id'])) {
+      $params['case_id'] = array('=' => $params['case_id']);
+    }
+    $clause = \CRM_Core_DAO::createSQLFilter('case_id', $params['case_id']);
+    if ($clause) {
+      $sql->where('a.id IN (SELECT activity_id FROM civicrm_case_activity WHERE !clause)', array('!clause' => $clause));
+    }
+  }
+  $activities = _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params, FALSE, 'Activity', $sql);
   $options = _civicrm_api3_get_options_from_params($params, FALSE, 'Activity', 'get');
   if ($options['is_count']) {
     return civicrm_api3_create_success($activities, $params, 'Activity', 'get');
@@ -376,6 +393,10 @@ function civicrm_api3_activity_get($params) {
  *   new activities list
  */
 function _civicrm_api3_activity_get_formatResult($params, $activities) {
+  if (!$activities) {
+    return $activities;
+  }
+
   $returns = CRM_Utils_Array::value('return', $params, array());
   if (!is_array($returns)) {
     $returns = str_replace(' ', '', $returns);
@@ -398,6 +419,14 @@ function _civicrm_api3_activity_get_formatResult($params, $activities) {
     $returns['assignee_contact_id'] = 1;
   }
 
+  $tagGet = array('tag_id', 'entity_id');
+  foreach (array_keys($returns) as $key) {
+    if (strpos($key, 'tag_id.') === 0) {
+      $tagGet[] = $key;
+      $returns['tag_id'] = 1;
+    }
+  }
+
   foreach ($returns as $n => $v) {
     switch ($n) {
       case 'assignee_contact_id':
@@ -431,13 +460,50 @@ function _civicrm_api3_activity_get_formatResult($params, $activities) {
         }
         break;
 
+      case 'tag_id':
+        $tags = civicrm_api3('EntityTag', 'get', array(
+          'entity_table' => 'civicrm_activity',
+          'entity_id' => array('IN' => array_keys($activities)),
+          'return' => $tagGet,
+          'options' => array('limit' => 0),
+        ));
+        foreach ($tags['values'] as $tag) {
+          $key = (int) $tag['entity_id'];
+          unset($tag['entity_id'], $tag['id']);
+          $activities[$key]['tag_id'][$tag['tag_id']] = $tag;
+        }
+        break;
+
+      case 'file_id':
+        $dao = CRM_Core_DAO::executeQuery("SELECT entity_id, file_id FROM civicrm_entity_file WHERE entity_table = 'civicrm_activity' AND entity_id IN (%1)",
+          array(1 => array(implode(',', array_keys($activities)), 'String', CRM_Core_DAO::QUERY_FORMAT_NO_QUOTES)));
+        while ($dao->fetch()) {
+          $activities[$dao->entity_id]['file_id'][] = $dao->file_id;
+        }
+        break;
+
       default:
         if (substr($n, 0, 6) == 'custom') {
           $returnProperties[$n] = $v;
         }
     }
   }
-  if (!empty($activities) && (!empty($returnProperties) || !empty($params['contact_id']))) {
+
+  // Legacy extras
+  if (!empty($params['contact_id'])) {
+    $statusOptions = CRM_Activity_BAO_Activity::buildOptions('status_id', 'get');
+    $typeOptions = CRM_Activity_BAO_Activity::buildOptions('activity_type_id', 'validate');
+    foreach ($activities as $key => &$activityArray) {
+      if (!empty($activityArray['status_id'])) {
+        $activityArray['status'] = $statusOptions[$activityArray['status_id']];
+      }
+      if (!empty($activityArray['activity_type_id'])) {
+        $activityArray['activity_name'] = $typeOptions[$activityArray['activity_type_id']];
+      }
+    }
+  }
+
+  if (!empty($returnProperties) || !empty($params['contact_id'])) {
     foreach ($activities as $activityId => $values) {
       //@todo - should possibly load activity type id if not loaded (update with id)
       _civicrm_api3_custom_data_get($activities[$activityId], CRM_Utils_Array::value('check_permissions', $params), 'Activity', $activityId, NULL, CRM_Utils_Array::value('activity_type_id', $values));
index 8cfdfe1d2db9c0e34f1af597ee43c199c658e26a..efddd0904b974408d1435e43ad9eba5ca6505cb7 100644 (file)
@@ -453,6 +453,11 @@ function _civicrm_api3_case_format_params(&$params) {
 function civicrm_api3_case_getList($params) {
   require_once 'api/v3/Generic/Getlist.php';
   require_once 'api/v3/CaseContact.php';
+  //CRM:19956 - Assign case_id param if both id and case_id is passed to retrieve the case
+  if (!empty($params['id']) && !empty($params['params']) && !empty($params['params']['case_id'])) {
+    $params['params']['case_id'] = array('IN' => $params['id']);
+    unset($params['id']);
+  }
   $params['id_field'] = 'case_id';
   $params['label_field'] = $params['search_field'] = 'contact_id.sort_name';
   $params['description_field'] = array(
@@ -463,6 +468,7 @@ function civicrm_api3_case_getList($params) {
     'case_id.start_date',
   );
   $apiRequest = array(
+    'version' => 3,
     'entity' => 'CaseContact',
     'action' => 'getlist',
     'params' => $params,
index af3028d59c1e66dff29d88138dd2efe34a9373ec..773068f4bbf23e73965e62061b47433ad044e25f 100644 (file)
@@ -376,6 +376,37 @@ function _civicrm_api3_contact_get_supportanomalies(&$params, &$options) {
     unset($params['filter.group_id']);
     $options['input_params']['group'] = $groups;
   }
+  if (isset($params['group'])) {
+    $groups = $params['group'];
+    $allGroups = CRM_Core_PseudoConstant::group();
+    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);
+        }
+      }
+      // Now reset the $groups array with the ids not the titles.
+      $groups[key($groups)] = $groupsArray;
+    }
+    // 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($k) && array_search($k, $allGroups)) {
+          unset($groups[$k]);
+          $groups[array_search($k, $allGroups)] = $group;
+        }
+      }
+    }
+    elseif (!is_numeric($groups) &&  array_search($groups, $allGroups)) {
+      $groups = array_search($groups, $allGroups);
+    }
+    $params['group'] = $groups;
+  }
 }
 
 /**
@@ -1085,7 +1116,7 @@ function civicrm_api3_contact_merge($params) {
         'srcID' => $params['to_remove_id'],
         'dstID' => $params['to_keep_id'],
       ),
-    ), array(), $params['mode'], $params['auto_flip'])) != FALSE) {
+    ), array(), $params['mode'])) != FALSE) {
     return civicrm_api3_create_success($result, $params);
   }
   throw new CiviCRM_API3_Exception('Merge failed');
@@ -1111,10 +1142,6 @@ function _civicrm_api3_contact_merge_spec(&$params) {
     'type' => CRM_Utils_Type::T_INT,
     'api.aliases' => array('other_id'),
   );
-  $params['auto_flip'] = array(
-    'title' => 'Swap destination and source to retain lowest id?',
-    'api.default' => TRUE,
-  );
   $params['mode'] = array(
     // @todo need more detail on what this means.
     'title' => 'Dedupe mode',
index 897fb019993ce7eb7fc543bc84e44f96494a5c3c..c6e2b1e7abbb894e0ec35924c18cfa0dc08ca5a1 100644 (file)
@@ -605,6 +605,7 @@ function civicrm_api3_contribution_repeattransaction(&$params) {
     //  CRM-19873 call with test mode.
     $params['original_contribution_id'] = civicrm_api3('contribution', 'getvalue', array(
       'return' => 'id',
+      'contribution_status_id' => array('IN' => array('Completed')),
       'contribution_recur_id' => $params['contribution_recur_id'],
       'contribution_test' => CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionRecur', $params['contribution_recur_id'], 'is_test'),
       'options' => array('limit' => 1, 'sort' => 'id DESC'),
index 3862ac0cec739a4b5ca03a4e9fb7a4ca681f2ee8..367ad7b66d7492161ee3edd50dea318485f4f4fb 100644 (file)
@@ -244,7 +244,9 @@ function civicrm_api3_extension_download($params) {
   }
   CRM_Extension_System::singleton()->getCache()->flush();
   CRM_Extension_System::singleton(TRUE);
-  CRM_Extension_System::singleton()->getManager()->install(array($params['key']));
+  if (CRM_Utils_Array::value('install', $params, TRUE)) {
+    CRM_Extension_System::singleton()->getManager()->install(array($params['key']));
+  }
 
   return civicrm_api3_create_success();
 }
@@ -265,6 +267,12 @@ function _civicrm_api3_extension_download_spec(&$fields) {
     'type' => CRM_Utils_Type::T_STRING,
     'description' => 'Optional as the system can determine the url automatically for public extensions',
   );
+  $fields['install'] = array(
+    'title' => 'Auto-install',
+    'type' => CRM_Utils_Type::T_STRING,
+    'description' => 'Automatically install the downloaded extension',
+    'api.default' => TRUE,
+  );
 }
 
 /**
index 50378c1d96fe464d2885dccc734935d93f82a5d4..53f055e82b856ee0128c2fcc367c0c8c51a7cc14 100644 (file)
@@ -148,17 +148,17 @@ function civicrm_api3_group_contact_create($params) {
 function civicrm_api3_group_contact_delete($params) {
   $checkParams = $params;
   if (!empty($checkParams['status']) && in_array($checkParams['status'], array('Removed', 'Deleted'))) {
-    $checkParams['status'] = 'Added';
+    $checkParams['status'] = array('IN' => array('Added', 'Pending'));
   }
   elseif (!empty($checkParams['status']) && $checkParams['status'] == 'Added') {
-    $checkParams['status'] = 'Removed';
+    $checkParams['status'] = array('IN' => array('Pending', 'Removed'));
   }
   elseif (!empty($checkParams['status'])) {
     unset($checkParams['status']);
   }
   $groupContact = civicrm_api3('GroupContact', 'get', $checkParams);
   if ($groupContact['count'] == 0 && !empty($params['skip_undelete'])) {
-    $checkParams['status'] = 'removed';
+    $checkParams['status'] = array('IN' => array('Removed', 'Pending'));
   }
   $groupContact2 = civicrm_api3('GroupContact', 'get', $checkParams);
   if ($groupContact['count'] == 0 && $groupContact2['count'] == 0) {
index 381ce176653deb8b6fe26be63f15ed4ae80104ca..89f4fb0d3be1ae0fb5e2c64233ac84426bb7b292 100644 (file)
@@ -390,7 +390,7 @@ function civicrm_api3_job_fetch_activities($params) {
   }
   catch (Exception $e) {
     $lock->release();
-    return civicrm_api3_create_error('Process Activities failed');
+    return civicrm_api3_create_error($e->getMessage());
   }
 }
 
@@ -487,11 +487,9 @@ function civicrm_api3_job_process_batch_merge($params) {
     ));
   }
   $gid = CRM_Utils_Array::value('gid', $params);
-
   $mode = CRM_Utils_Array::value('mode', $params, 'safe');
-  $autoFlip = CRM_Utils_Array::value('auto_flip', $params, TRUE);
 
-  $result = CRM_Dedupe_Merger::batchMerge($rule_group_id, $gid, $mode, $autoFlip, 1, 2, CRM_Utils_Array::value('criteria', $params, array()), CRM_Utils_Array::value('check_permissions', $params));
+  $result = CRM_Dedupe_Merger::batchMerge($rule_group_id, $gid, $mode, 1, 2, CRM_Utils_Array::value('criteria', $params, array()), CRM_Utils_Array::value('check_permissions', $params));
 
   return civicrm_api3_create_success($result, $params);
 }
index c1a9010a777c08386c2da2c993cbea127b118863..3287b8794f675febda5dc29548e21dbcc7077f8f 100644 (file)
@@ -44,7 +44,8 @@
 function civicrm_api3_logging_revert($params) {
   $schema = new CRM_Logging_Schema();
   $reverter = new CRM_Logging_Reverter($params['log_conn_id'], CRM_Utils_Array::value('log_date', $params));
-  $reverter->calculateDiffsFromLogConnAndDate($schema->getLogTablesForContact());
+  $tables = !empty($params['tables']) ? (array) $params['tables'] : $schema->getLogTablesForContact();
+  $reverter->calculateDiffsFromLogConnAndDate($tables);
   $reverter->revert();
   return civicrm_api3_create_success(1);
 }
@@ -73,6 +74,12 @@ function _civicrm_api3_logging_revert_spec(&$params) {
     'api.default' => '10 SECOND',
     'description' => ts('Used when log_date is passed in'),
   );
+
+  $params['tables'] = array(
+    'title' => ts('Tables to revert'),
+    'type' => CRM_Utils_Type::T_STRING,
+    'description' => ts('Tables to revert, if not set all contact-referring entities will be reverted'),
+  );
 }
 
 /**
@@ -89,7 +96,8 @@ function civicrm_api3_logging_get($params) {
   $schema = new CRM_Logging_Schema();
   $interval = (empty($params['log_date'])) ? NULL : $params['interval'];
   $differ = new CRM_Logging_Differ($params['log_conn_id'], CRM_Utils_Array::value('log_date', $params), $interval);
-  return civicrm_api3_create_success($differ->getAllChangesForConnection($schema->getLogTablesForContact()));
+  $tables = !empty($params['tables']) ? (array) $params['tables'] : $schema->getLogTablesForContact();
+  return civicrm_api3_create_success($differ->getAllChangesForConnection($tables));
 }
 
 /**
@@ -116,4 +124,9 @@ function _civicrm_api3_logging_get_spec(&$params) {
     'api.default' => '10 SECOND',
     'description' => ts('Used when log_date is passed in'),
   );
+  $params['tables'] = array(
+    'title' => ts('Tables to query'),
+    'type' => CRM_Utils_Type::T_STRING,
+    'description' => ts('Tables to query, if not set all contact-referring entities will be queried'),
+  );
 }
index 0dbac4513f799bf49d8811d6faa7e37932d747f5..9a7a6ef67af572b629225fea722a2088d9cdd0c0 100644 (file)
  *   to indicate this entire api entity is deprecated
  */
 function _civicrm_api3_mailing_group_deprecation() {
-  return 'The MailingGroup api is deprecated. Use the mailing_event apis instead.';
+  $message = 'This action is deprecated. Use the mailing_event API instead.';
+  return array(
+    'event_unsubscribe' => $message,
+    'event_domain_unsubscribe' => $message,
+    'event_resubscribe' => $message,
+    'event_subscribe' => $message,
+  );
 }
 
 /**
index d1db1fec13d1f29f0ae0092a52e9cb3093088dd4..a8b29405c522e96e776998e287cddd31fe2768d7 100644 (file)
@@ -66,6 +66,7 @@ function _civicrm_api3_membership_type_create_spec(&$params) {
   $params['name']['api.required'] = 1;
   $params['duration_unit']['api.required'] = 1;
   $params['duration_interval']['api.required'] = 1;
+  $params['period_type']['api.required'] = 1;
   $params['is_active']['api.default'] = 1;
 }
 
index adf4230f1357246e34874a2e519e38f1b2f8259c..b830541308b82072a34e0c925ac11be684ccff42 100644 (file)
@@ -10,7 +10,7 @@
 function activity_create_example() {
   $params = array(
     'source_contact_id' => 1,
-    'activity_type_id' => '51',
+    'activity_type_id' => '55',
     'subject' => 'test activity type id',
     'activity_date_time' => '2011-06-02 14:36:13',
     'status_id' => 2,
@@ -57,7 +57,7 @@ function activity_create_expectedresult() {
       '1' => array(
         'id' => '1',
         'source_record_id' => '',
-        'activity_type_id' => '51',
+        'activity_type_id' => '55',
         'subject' => 'test activity type id',
         'activity_date_time' => '20110602143613',
         'duration' => '120',
index 6cd8188ccb393c55a17101bc108da5ca80653dd7..8603caf946b6fc24ebc48fdbaa3c5fc1702b4a6e 100644 (file)
@@ -48,7 +48,7 @@ function activity_get_expectedresult() {
     'values' => array(
       '1' => array(
         'id' => '1',
-        'activity_type_id' => '51',
+        'activity_type_id' => '55',
         'subject' => 'test activity type id',
         'activity_date_time' => '2011-06-02 14:36:13',
         'duration' => '120',
@@ -60,13 +60,14 @@ function activity_get_expectedresult() {
         'is_auto' => 0,
         'is_current_revision' => '1',
         'is_deleted' => 0,
-        'source_contact_id' => '1',
+        'is_star' => 0,
         'custom_1' => 'defaultValue',
-        'custom_1_1' => 'defaultValue',
+        'custom_2_id' => '1',
         'custom_2' => 'Anderson, Anthony',
+        'source_contact_id' => '1',
+        'custom_1_1' => 'defaultValue',
         'custom_2_1' => 'Anderson, Anthony',
         'custom_2_1_id' => '1',
-        'custom_2_id' => '1',
       ),
     ),
   );
index 6615362918b295414621933769e8d94e5811f78c..a380f128d0bea2bd72619be3540c56ad83fd22a6 100644 (file)
@@ -8,7 +8,7 @@
 function activity_create_example() {
   $params = array(
     'source_contact_id' => 1,
-    'activity_type_id' => '51',
+    'activity_type_id' => '55',
     'subject' => 'test activity type id',
     'activity_date_time' => '2011-06-02 14:36:13',
     'status_id' => 2,
@@ -55,7 +55,7 @@ function activity_create_expectedresult() {
       '1' => array(
         'id' => '1',
         'source_record_id' => '',
-        'activity_type_id' => '51',
+        'activity_type_id' => '55',
         'subject' => 'test activity type id',
         'activity_date_time' => '20110602143613',
         'duration' => '120',
@@ -87,7 +87,7 @@ function activity_create_expectedresult() {
 
 /*
 * This example has been generated from the API test suite.
-* The test that created it is called "testActivityCreateCustom"
+* The test that created it is called "testActivityCreateCustomSubType"
 * and can be found at:
 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ActivityTest.php
 *
index 4833a1885bf38bed171fe692169aa549e6696420..54d9ace23213e44e993e6745fe368c3d39c8cd89 100644 (file)
@@ -49,7 +49,7 @@ function activity_get_expectedresult() {
     'values' => array(
       '0' => array(
         'id' => '1',
-        'activity_type_id' => '51',
+        'activity_type_id' => '55',
         'subject' => 'Make-it-Happen Meeting',
         'activity_date_time' => '2011-01-01 00:00:00',
         'duration' => '120',
index f7052bc2aaf522bcfcfb72769808c733a8f59c97..e670e377e2f7884d2c6deb0ae7ec9d3e3e8e2235 100644 (file)
@@ -48,7 +48,7 @@ function activity_get_expectedresult() {
     'values' => array(
       '0' => array(
         'id' => '2',
-        'activity_type_id' => '51',
+        'activity_type_id' => '55',
         'subject' => 'Make-it-Happen Meeting',
         'activity_date_time' => '2012-02-16 00:00:00',
         'duration' => '120',
index ac52fab2604d9ab8efdcc7057f377262d7ac40d0..1d981955898e80add961209b2d70ae4ae3e40846 100644 (file)
@@ -8,7 +8,7 @@
 function activity_get_example() {
   $params = array(
     'contact_id' => 1,
-    'activity_type_id' => '51',
+    'activity_type_id' => '55',
     'sequential' => 1,
     'return.custom_1' => 1,
   );
@@ -49,7 +49,7 @@ function activity_get_expectedresult() {
       '0' => array(
         'source_contact_id' => '1',
         'id' => '1',
-        'activity_type_id' => '51',
+        'activity_type_id' => '55',
         'subject' => 'test activity type id',
         'location' => 'Pennsylvania',
         'activity_date_time' => '2011-06-02 14:36:13',
index a6269d125a82742fe69910bd8cfd96fa8015de5c..76bca1d50070e383df652783a3fbed50260e4ca3 100644 (file)
@@ -47,6 +47,9 @@ function activity_getfields_expectedresult() {
         'type' => 1,
         'title' => 'Source Record',
         'description' => 'Artificial FK to original transaction (e.g. contribution) IF it is not an Activity. Table can be figured out through activity_type_id, and further through component registry.',
+        'table_name' => 'civicrm_activity',
+        'entity' => 'Activity',
+        'bao' => 'CRM_Activity_BAO_Activity',
       ),
       'activity_type_id' => array(
         'name' => 'activity_type_id',
@@ -59,6 +62,9 @@ function activity_getfields_expectedresult() {
         'headerPattern' => '/(activity.)?type(.id$)/i',
         'export' => TRUE,
         'default' => '1',
+        'table_name' => 'civicrm_activity',
+        'entity' => 'Activity',
+        'bao' => 'CRM_Activity_BAO_Activity',
         'html' => array(
           'type' => 'Select',
           'size' => 6,
@@ -78,8 +84,12 @@ function activity_getfields_expectedresult() {
         'where' => 'civicrm_activity.activity_date_time',
         'headerPattern' => '/(activity.)?date(.time$)?/i',
         'export' => TRUE,
+        'table_name' => 'civicrm_activity',
+        'entity' => 'Activity',
+        'bao' => 'CRM_Activity_BAO_Activity',
         'html' => array(
           'type' => 'Select Date',
+          'format' => 'activityDateTime',
         ),
       ),
       'phone_id' => array(
@@ -87,6 +97,9 @@ function activity_getfields_expectedresult() {
         'type' => 1,
         'title' => 'Phone (called) ID',
         'description' => 'Phone ID of the number called (optional - used if an existing phone number is selected).',
+        'table_name' => 'civicrm_activity',
+        'entity' => 'Activity',
+        'bao' => 'CRM_Activity_BAO_Activity',
         'FKClassName' => 'CRM_Core_DAO_Phone',
         'html' => array(
           'type' => 'EntityRef',
@@ -102,6 +115,9 @@ function activity_getfields_expectedresult() {
         'description' => 'Phone number in case the number does not exist in the civicrm_phone table.',
         'maxlength' => 64,
         'size' => 30,
+        'table_name' => 'civicrm_activity',
+        'entity' => 'Activity',
+        'bao' => 'CRM_Activity_BAO_Activity',
         'html' => array(
           'type' => 'Text',
           'maxlength' => 64,
@@ -113,6 +129,9 @@ function activity_getfields_expectedresult() {
         'type' => 1,
         'title' => 'Priority',
         'description' => 'ID of the priority given to this activity. Foreign key to civicrm_option_value.',
+        'table_name' => 'civicrm_activity',
+        'entity' => 'Activity',
+        'bao' => 'CRM_Activity_BAO_Activity',
         'html' => array(
           'type' => 'Select',
           'size' => 6,
@@ -128,6 +147,9 @@ function activity_getfields_expectedresult() {
         'type' => 1,
         'title' => 'Parent Activity Id',
         'description' => 'Parent meeting ID (if this is a follow-up item). This is not currently implemented',
+        'table_name' => 'civicrm_activity',
+        'entity' => 'Activity',
+        'bao' => 'CRM_Activity_BAO_Activity',
         'FKClassName' => 'CRM_Activity_DAO_Activity',
         'FKApiName' => 'Activity',
       ),
@@ -135,6 +157,9 @@ function activity_getfields_expectedresult() {
         'name' => 'is_auto',
         'type' => 16,
         'title' => 'Auto',
+        'table_name' => 'civicrm_activity',
+        'entity' => 'Activity',
+        'bao' => 'CRM_Activity_BAO_Activity',
       ),
       'relationship_id' => array(
         'name' => 'relationship_id',
@@ -142,6 +167,9 @@ function activity_getfields_expectedresult() {
         'title' => 'Relationship Id',
         'description' => 'FK to Relationship ID',
         'default' => 'NULL',
+        'table_name' => 'civicrm_activity',
+        'entity' => 'Activity',
+        'bao' => 'CRM_Activity_BAO_Activity',
         'FKClassName' => 'CRM_Contact_DAO_Relationship',
         'FKApiName' => 'Relationship',
       ),
@@ -154,6 +182,9 @@ function activity_getfields_expectedresult() {
         'headerPattern' => '/(is.)?(current.)?(revision|version(ing)?)/i',
         'export' => TRUE,
         'default' => '1',
+        'table_name' => 'civicrm_activity',
+        'entity' => 'Activity',
+        'bao' => 'CRM_Activity_BAO_Activity',
         'html' => array(
           'type' => 'CheckBox',
         ),
@@ -163,6 +194,9 @@ function activity_getfields_expectedresult() {
         'type' => 1,
         'title' => 'Original Activity ID ',
         'description' => 'Activity ID of the first activity record in versioning chain.',
+        'table_name' => 'civicrm_activity',
+        'entity' => 'Activity',
+        'bao' => 'CRM_Activity_BAO_Activity',
         'FKClassName' => 'CRM_Activity_DAO_Activity',
         'FKApiName' => 'Activity',
       ),
@@ -170,6 +204,9 @@ function activity_getfields_expectedresult() {
         'name' => 'weight',
         'type' => 1,
         'title' => 'Order',
+        'table_name' => 'civicrm_activity',
+        'entity' => 'Activity',
+        'bao' => 'CRM_Activity_BAO_Activity',
         'html' => array(
           'type' => 'Text',
           'size' => 6,
@@ -185,6 +222,9 @@ function activity_getfields_expectedresult() {
         'where' => 'civicrm_activity.is_star',
         'headerPattern' => '/(activity.)?(star|favorite)/i',
         'export' => TRUE,
+        'table_name' => 'civicrm_activity',
+        'entity' => 'Activity',
+        'bao' => 'CRM_Activity_BAO_Activity',
       ),
       'id' => array(
         'name' => 'id',
@@ -195,6 +235,9 @@ function activity_getfields_expectedresult() {
         'import' => TRUE,
         'where' => 'civicrm_activity.id',
         'export' => TRUE,
+        'table_name' => 'civicrm_activity',
+        'entity' => 'Activity',
+        'bao' => 'CRM_Activity_BAO_Activity',
         'uniqueName' => 'activity_id',
         'api.aliases' => array(
           '0' => 'activity_id',
@@ -211,6 +254,9 @@ function activity_getfields_expectedresult() {
         'where' => 'civicrm_activity.subject',
         'headerPattern' => '/(activity.)?subject/i',
         'export' => TRUE,
+        'table_name' => 'civicrm_activity',
+        'entity' => 'Activity',
+        'bao' => 'CRM_Activity_BAO_Activity',
         'html' => array(
           'type' => 'Text',
           'maxlength' => 255,
@@ -227,6 +273,9 @@ function activity_getfields_expectedresult() {
         'where' => 'civicrm_activity.duration',
         'headerPattern' => '/(activity.)?duration(s)?$/i',
         'export' => TRUE,
+        'table_name' => 'civicrm_activity',
+        'entity' => 'Activity',
+        'bao' => 'CRM_Activity_BAO_Activity',
         'html' => array(
           'type' => 'Text',
           'size' => 6,
@@ -245,6 +294,9 @@ function activity_getfields_expectedresult() {
         'where' => 'civicrm_activity.location',
         'headerPattern' => '/(activity.)?location$/i',
         'export' => TRUE,
+        'table_name' => 'civicrm_activity',
+        'entity' => 'Activity',
+        'bao' => 'CRM_Activity_BAO_Activity',
         'html' => array(
           'type' => 'Text',
           'maxlength' => 255,
@@ -261,6 +313,9 @@ function activity_getfields_expectedresult() {
         'where' => 'civicrm_activity.details',
         'headerPattern' => '/(activity.)?detail(s)?$/i',
         'export' => TRUE,
+        'table_name' => 'civicrm_activity',
+        'entity' => 'Activity',
+        'bao' => 'CRM_Activity_BAO_Activity',
         'html' => array(
           'type' => 'RichTextEditor',
           'rows' => 2,
@@ -276,6 +331,9 @@ function activity_getfields_expectedresult() {
         'import' => TRUE,
         'where' => 'civicrm_activity.status_id',
         'headerPattern' => '/(activity.)?status(.label$)?/i',
+        'table_name' => 'civicrm_activity',
+        'entity' => 'Activity',
+        'bao' => 'CRM_Activity_BAO_Activity',
         'html' => array(
           'type' => 'Select',
           'size' => 6,
@@ -298,6 +356,9 @@ function activity_getfields_expectedresult() {
         'where' => 'civicrm_activity.is_test',
         'headerPattern' => '/(is.)?test(.activity)?/i',
         'export' => TRUE,
+        'table_name' => 'civicrm_activity',
+        'entity' => 'Activity',
+        'bao' => 'CRM_Activity_BAO_Activity',
         'html' => array(
           'type' => 'Select',
         ),
@@ -309,6 +370,9 @@ function activity_getfields_expectedresult() {
         'title' => 'Activity Medium',
         'description' => 'Activity Medium, Implicit FK to civicrm_option_value where option_group = encounter_medium.',
         'default' => 'NULL',
+        'table_name' => 'civicrm_activity',
+        'entity' => 'Activity',
+        'bao' => 'CRM_Activity_BAO_Activity',
         'html' => array(
           'type' => 'Select',
           'size' => 6,
@@ -327,6 +391,9 @@ function activity_getfields_expectedresult() {
         'description' => 'Currently being used to store result id for survey activity, FK to option value.',
         'maxlength' => 255,
         'size' => 45,
+        'table_name' => 'civicrm_activity',
+        'entity' => 'Activity',
+        'bao' => 'CRM_Activity_BAO_Activity',
         'html' => array(
           'type' => 'Text',
           'maxlength' => 255,
@@ -342,6 +409,9 @@ function activity_getfields_expectedresult() {
         'where' => 'civicrm_activity.is_deleted',
         'headerPattern' => '/(activity.)?(trash|deleted)/i',
         'export' => TRUE,
+        'table_name' => 'civicrm_activity',
+        'entity' => 'Activity',
+        'bao' => 'CRM_Activity_BAO_Activity',
         'html' => array(
           'type' => 'Text',
         ),
@@ -355,6 +425,9 @@ function activity_getfields_expectedresult() {
         'import' => TRUE,
         'where' => 'civicrm_activity.campaign_id',
         'export' => TRUE,
+        'table_name' => 'civicrm_activity',
+        'entity' => 'Activity',
+        'bao' => 'CRM_Activity_BAO_Activity',
         'FKClassName' => 'CRM_Campaign_DAO_Campaign',
         'html' => array(
           'type' => 'CheckBox',
@@ -377,6 +450,9 @@ function activity_getfields_expectedresult() {
         'import' => TRUE,
         'where' => 'civicrm_activity.engagement_level',
         'export' => TRUE,
+        'table_name' => 'civicrm_activity',
+        'entity' => 'Activity',
+        'bao' => 'CRM_Activity_BAO_Activity',
         'html' => array(
           'type' => 'Select',
           'size' => 6,
index 77b45f7bbbce1204e447491bc1bdc0a560e41c5c..003b333d37daf5152ef254d97c2174410ae6c884 100644 (file)
@@ -48,16 +48,18 @@ function activity_getsingle_expectedresult() {
   $expectedResult = array(
     'id' => '1',
     'subject' => 'Make-it-Happen Meeting',
-    'source_contact_id' => '8',
+    'source_contact_id' => '6',
     'source_contact_name' => 'D Bug',
-    'target_contact_id' => array('5', '6'),
+    'target_contact_id' => array(
+      '1' => '4',
+    ),
     'target_contact_name' => array(
-      '5' => 'A Cat',
-      '6' => 'B Good',
+      '3' => 'A Cat',
+      '4' => 'B Good',
     ),
-    'assignee_contact_id' => array('7'),
+    'assignee_contact_id' => array(),
     'assignee_contact_name' => array(
-      '7' => 'C Shore',
+      '5' => 'C Shore',
     ),
   );
 
index 574a34a7b27cbf6859706b4e56e45f831e50920c..4042c39fff4ae8946b4ced77286657829cdf52ae 100644 (file)
@@ -52,7 +52,7 @@ function activity_get_expectedresult() {
     'values' => array(
       '0' => array(
         'id' => '1',
-        'activity_type_id' => '51',
+        'activity_type_id' => '55',
         'subject' => 'test activity type id',
         'activity_date_time' => '2011-06-02 14:36:13',
         'duration' => '120',
index ac5da5ced8f491528a8f30fffd2034132ef297ef..b3a231503be5467655f41d4ebed3d3bb47631938 100644 (file)
@@ -49,13 +49,13 @@ function activity_type_create_expectedresult() {
     'is_error' => 0,
     'version' => 3,
     'count' => 1,
-    'id' => 784,
+    'id' => 849,
     'values' => array(
-      '784' => array(
-        'id' => '784',
+      '849' => array(
+        'id' => '849',
         'option_group_id' => '2',
         'label' => 'send out letters',
-        'value' => '51',
+        'value' => '55',
         'name' => 'send out letters',
         'grouping' => '',
         'filter' => 0,
@@ -68,6 +68,8 @@ function activity_type_create_expectedresult() {
         'component_id' => '',
         'domain_id' => '',
         'visibility_id' => '',
+        'icon' => '',
+        'color' => '',
       ),
     ),
     'deprecated' => 'The ActivityType api is deprecated. Please use the OptionValue api instead.',
index a2158500c1a15e8560c2107d1af44ecdc46117bd..3befa05035d7e485d1fc4e5bb1c4229caf9c3886 100644 (file)
@@ -41,7 +41,7 @@ function activity_type_get_expectedresult() {
   $expectedResult = array(
     'is_error' => 0,
     'version' => 3,
-    'count' => 50,
+    'count' => 54,
     'values' => array(
       '1' => 'Meeting',
       '2' => 'Phone Call',
index a6c11087a0d3d0422064ff1c45469894c85443d5..561e259a1eb5ccce15ed53f2f6dc3ee265716562 100644 (file)
@@ -43,7 +43,7 @@ function constant_get_expectedresult() {
   $expectedResult = array(
     'is_error' => 0,
     'version' => 3,
-    'count' => 32,
+    'count' => 36,
     'values' => array(
       '1' => 'Meeting',
       '2' => 'Phone Call',
index 839b99005e172748227e91375573100ec4d88a9b..35f3a002d46afc69d73b8cab12a0a1b141c83bf9 100644 (file)
@@ -10,7 +10,7 @@
  */
 function contact_get_example() {
   $params = array(
-    'id' => 1,
+    'id' => 3,
     'api.website.get' => array(),
     'api.Contribution.get' => array(
       'total_amount' => '120.00',
@@ -50,10 +50,10 @@ function contact_get_expectedresult() {
     'is_error' => 0,
     'version' => 3,
     'count' => 1,
-    'id' => 1,
+    'id' => 3,
     'values' => array(
-      '1' => array(
-        'contact_id' => '1',
+      '3' => array(
+        'contact_id' => '3',
         'contact_type' => 'Individual',
         'contact_sub_type' => '',
         'sort_name' => 'xyz3, abc3',
@@ -89,8 +89,8 @@ function contact_get_expectedresult() {
         'sic_code' => '',
         'contact_is_deleted' => 0,
         'current_employer' => '',
-        'address_id' => '2',
-        'street_address' => '1 my road',
+        'address_id' => '',
+        'street_address' => '',
         'supplemental_address_1' => '',
         'supplemental_address_2' => '',
         'city' => '',
@@ -118,7 +118,7 @@ function contact_get_expectedresult() {
         'state_province_name' => '',
         'state_province' => '',
         'country' => '',
-        'id' => '1',
+        'id' => '3',
         'api.website.get' => array(
           'is_error' => 0,
           'version' => 3,
@@ -127,7 +127,7 @@ function contact_get_expectedresult() {
           'values' => array(
             '0' => array(
               'id' => '1',
-              'contact_id' => '1',
+              'contact_id' => '3',
               'url' => 'http://civicrm.org',
             ),
           ),
@@ -139,7 +139,7 @@ function contact_get_expectedresult() {
           'id' => 2,
           'values' => array(
             '0' => array(
-              'contact_id' => '1',
+              'contact_id' => '3',
               'contact_type' => 'Individual',
               'contact_sub_type' => '',
               'sort_name' => 'xyz3, abc3',
@@ -159,10 +159,11 @@ function contact_get_expectedresult() {
               'thankyou_date' => '',
               'contribution_source' => 'SSF',
               'amount_level' => '',
+              'contribution_recur_id' => '',
               'is_test' => 0,
               'is_pay_later' => 0,
               'contribution_status_id' => '1',
-              'check_number' => '',
+              'contribution_check_number' => '',
               'contribution_campaign_id' => '',
               'financial_type_id' => '1',
               'financial_type' => 'Donation',
@@ -174,16 +175,17 @@ function contact_get_expectedresult() {
               'fulfilled_date' => '',
               'contribution_start_date' => '',
               'contribution_end_date' => '',
-              'contribution_recur_id' => '',
               'financial_account_id' => '1',
               'accounting_code' => '4200',
+              'campaign_id' => '',
+              'contribution_campaign_title' => '',
               'contribution_note' => '',
               'contribution_batch' => '',
               'contribution_status' => 'Completed',
               'payment_instrument' => 'Credit Card',
               'payment_instrument_id' => '1',
               'instrument_id' => '1',
-              'contribution_check_number' => '',
+              'check_number' => '',
               'id' => '2',
               'contribution_type_id' => '1',
             ),
index c79c27a426c837154073ac7659f748591ba201cd..5145682730e3646cb0cc4d939317e9cfad066e24 100644 (file)
@@ -10,7 +10,7 @@
  */
 function contact_get_example() {
   $params = array(
-    'id' => 1,
+    'id' => 3,
     'api.website.getValue' => array(
       'return' => 'url',
     ),
@@ -51,10 +51,10 @@ function contact_get_expectedresult() {
     'is_error' => 0,
     'version' => 3,
     'count' => 1,
-    'id' => 1,
+    'id' => 3,
     'values' => array(
-      '1' => array(
-        'contact_id' => '1',
+      '3' => array(
+        'contact_id' => '3',
         'contact_type' => 'Individual',
         'contact_sub_type' => '',
         'sort_name' => 'xyz3, abc3',
@@ -90,8 +90,8 @@ function contact_get_expectedresult() {
         'sic_code' => '',
         'contact_is_deleted' => 0,
         'current_employer' => '',
-        'address_id' => '2',
-        'street_address' => '1 my road',
+        'address_id' => '',
+        'street_address' => '',
         'supplemental_address_1' => '',
         'supplemental_address_2' => '',
         'city' => '',
@@ -119,7 +119,7 @@ function contact_get_expectedresult() {
         'state_province_name' => '',
         'state_province' => '',
         'country' => '',
-        'id' => '1',
+        'id' => '3',
         'api.website.getValue' => 'http://civicrm.org',
         'api.Contribution.getCount' => 2,
         'api.CustomValue.get' => array(
index c484a896c663c5a18fdc8d37e9f48211d126c4de..d9d6b8f49eed315b8a2c934b23e81ded291c857b 100644 (file)
@@ -9,7 +9,7 @@
  */
 function contact_get_example() {
   $params = array(
-    'id' => 1,
+    'id' => 3,
     'api.website.getValue' => array(
       'return' => 'url',
     ),
@@ -48,10 +48,10 @@ function contact_get_expectedresult() {
     'is_error' => 0,
     'version' => 3,
     'count' => 1,
-    'id' => 1,
+    'id' => 3,
     'values' => array(
-      '1' => array(
-        'contact_id' => '1',
+      '3' => array(
+        'contact_id' => '3',
         'contact_type' => 'Individual',
         'contact_sub_type' => '',
         'sort_name' => 'xyz3, abc3',
@@ -87,8 +87,8 @@ function contact_get_expectedresult() {
         'sic_code' => '',
         'contact_is_deleted' => 0,
         'current_employer' => '',
-        'address_id' => '2',
-        'street_address' => '1 my road',
+        'address_id' => '',
+        'street_address' => '',
         'supplemental_address_1' => '',
         'supplemental_address_2' => '',
         'city' => '',
@@ -116,59 +116,61 @@ function contact_get_expectedresult() {
         'state_province_name' => '',
         'state_province' => '',
         'country' => '',
-        'id' => '1',
+        'id' => '3',
         'api.website.getValue' => 'http://civicrm.org',
         'api.Contribution.getCount' => 2,
         'api.CustomValue.get' => array(
           'is_error' => 0,
           'version' => 3,
-          'count' => 8,
+          'count' => 7,
           'values' => array(
             '0' => array(
-              'entity_id' => '1',
+              'entity_id' => '3',
+              'entity_table' => 'Contact',
               'latest' => 'value 4',
               'id' => '1',
-              'entity_table' => 'Contact',
             ),
             '1' => array(
+              'entity_id' => '3',
               'entity_table' => 'Contact',
-            ),
-            '2' => array(
-              'entity_id' => '1',
               'latest' => 'value 3',
               'id' => '2',
               '1' => 'value 2',
-              'entity_table' => 'Contact',
               '2' => 'value 3',
             ),
-            '3' => array(
-              'entity_id' => '1',
+            '2' => array(
+              'entity_id' => '3',
+              'entity_table' => 'Contact',
               'latest' => '',
               'id' => '3',
               '1' => 'warm beer',
               '2' => '',
             ),
-            '4' => array(
-              'entity_id' => '1',
+            '3' => array(
+              'entity_id' => '3',
+              'entity_table' => 'Contact',
               'latest' => '',
               'id' => '4',
               '1' => '',
               '2' => '',
             ),
-            '5' => array(
-              'entity_id' => '1',
+            '4' => array(
+              'entity_id' => '3',
+              'entity_table' => 'Contact',
               'latest' => 'defaultValue',
               'id' => '5',
               '1' => 'defaultValue',
             ),
-            '6' => array(
-              'entity_id' => '1',
+            '5' => array(
+              'entity_id' => '3',
+              'entity_table' => 'Contact',
               'latest' => 'vegemite',
               'id' => '6',
               '1' => 'vegemite',
             ),
-            '7' => array(
-              'entity_id' => '1',
+            '6' => array(
+              'entity_id' => '3',
+              'entity_table' => 'Contact',
               'latest' => '',
               'id' => '7',
               '1' => '',
index a1b3a68db3a1721f2dca340b08e04a156e4bff21..6bca265586b6a07580e2d29c5694e23008c542fc 100644 (file)
@@ -53,10 +53,10 @@ function contact_create_expectedresult() {
     'is_error' => 0,
     'version' => 3,
     'count' => 1,
-    'id' => 1,
+    'id' => 3,
     'values' => array(
-      '1' => array(
-        'id' => '1',
+      '3' => array(
+        'id' => '3',
         'contact_type' => 'Individual',
         'contact_sub_type' => '',
         'do_not_email' => 0,
index 8d2a4d3ff54de1e53f0e156b03063f5d053680a9..0c1f887ed412d029d91fddbd3ba81362da828ce6 100644 (file)
@@ -65,10 +65,10 @@ function contact_create_expectedresult() {
     'is_error' => 0,
     'version' => 3,
     'count' => 1,
-    'id' => 1,
+    'id' => 3,
     'values' => array(
-      '1' => array(
-        'id' => '1',
+      '3' => array(
+        'id' => '3',
         'contact_type' => 'Individual',
         'contact_sub_type' => '',
         'do_not_email' => 0,
@@ -125,7 +125,7 @@ function contact_create_expectedresult() {
           'values' => array(
             '0' => array(
               'id' => '1',
-              'contact_id' => '1',
+              'contact_id' => '3',
               'financial_type_id' => '1',
               'contribution_page_id' => '',
               'payment_instrument_id' => '1',
@@ -165,7 +165,7 @@ function contact_create_expectedresult() {
           'values' => array(
             '0' => array(
               'id' => '1',
-              'contact_id' => '1',
+              'contact_id' => '3',
               'url' => 'http://civicrm.org',
               'website_type_id' => '',
             ),
@@ -179,7 +179,7 @@ function contact_create_expectedresult() {
           'values' => array(
             '0' => array(
               'id' => '2',
-              'contact_id' => '1',
+              'contact_id' => '3',
               'url' => 'http://chained.org',
               'website_type_id' => '',
             ),
index 99e6a75588898ffd55ad09393087a6c2518043a6..f6ae673091d10b66f7f37279f5e413a9a520129b 100644 (file)
@@ -68,10 +68,10 @@ function contact_create_expectedresult() {
     'is_error' => 0,
     'version' => 3,
     'count' => 1,
-    'id' => 1,
+    'id' => 3,
     'values' => array(
-      '1' => array(
-        'id' => '1',
+      '3' => array(
+        'id' => '3',
         'contact_type' => 'Individual',
         'contact_sub_type' => '',
         'do_not_email' => 0,
@@ -128,7 +128,7 @@ function contact_create_expectedresult() {
           'values' => array(
             '0' => array(
               'id' => '1',
-              'contact_id' => '1',
+              'contact_id' => '3',
               'financial_type_id' => '1',
               'contribution_page_id' => '',
               'payment_instrument_id' => '1',
@@ -169,7 +169,7 @@ function contact_create_expectedresult() {
             'values' => array(
               '0' => array(
                 'id' => '1',
-                'contact_id' => '1',
+                'contact_id' => '3',
                 'url' => 'http://civicrm.org',
                 'website_type_id' => '',
               ),
@@ -183,7 +183,7 @@ function contact_create_expectedresult() {
             'values' => array(
               '0' => array(
                 'id' => '2',
-                'contact_id' => '1',
+                'contact_id' => '3',
                 'url' => 'http://chained.org',
                 'website_type_id' => '2',
               ),
index 9e0392a4dcdb1eecd8c33bce6f21231fd5814f54..107c95ded389111e7f356d9dc8a3f726a2f90c35 100644 (file)
@@ -46,10 +46,10 @@ function contact_create_expectedresult() {
     'is_error' => 0,
     'version' => 3,
     'count' => 1,
-    'id' => 1,
+    'id' => 3,
     'values' => array(
-      '1' => array(
-        'id' => '1',
+      '3' => array(
+        'id' => '3',
         'contact_type' => 'Individual',
         'contact_sub_type' => '',
         'do_not_email' => 0,
index 80021fa595a1d82b85255114007102dfbccc3c1b..7a66c4277b84121cde4e1269030a122a60d13866 100644 (file)
@@ -13,7 +13,7 @@ function contact_create_example() {
     'contact_type' => 'Individual',
     'display_name' => 'dlobo',
     'api.participant' => array(
-      'event_id' => 40,
+      'event_id' => 42,
       'status_id' => 1,
       'role_id' => 1,
       'format.only_id' => 1,
@@ -38,7 +38,8 @@ function contact_create_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
@@ -73,7 +74,7 @@ function contact_create_expectedresult() {
         'is_opt_out' => 0,
         'legal_identifier' => '',
         'external_identifier' => '',
-        'sort_name' => '',
+        'sort_name' => 'dlobo',
         'display_name' => 'dlobo',
         'nick_name' => '',
         'legal_name' => '',
index ac3e7b3ab680e3b414474c874456e90bda1c4a96..07e8ae1e6e6ed9970a952f5481f3a16d83ebd78b 100644 (file)
@@ -10,7 +10,7 @@
 function contact_get_example() {
   $params = array(
     'return.custom_1' => 1,
-    'id' => 1,
+    'id' => 3,
   );
 
   try{
@@ -44,13 +44,13 @@ function contact_get_expectedresult() {
     'is_error' => 0,
     'version' => 3,
     'count' => 1,
-    'id' => 1,
+    'id' => 3,
     'values' => array(
-      '1' => array(
-        'contact_id' => '1',
+      '3' => array(
+        'contact_id' => '3',
         'civicrm_value_testgetwithcu_1_id' => '1',
         'custom_1' => 'custom string',
-        'id' => '1',
+        'id' => '3',
       ),
     ),
   );
index d5ac755842aa09050b34466c93581fc091e805cd..c1e47702bff5f10dd82092acd931ab33160b747d 100644 (file)
@@ -10,7 +10,7 @@
 function contact_get_example() {
   $params = array(
     'return' => 'custom_1',
-    'id' => 1,
+    'id' => 3,
   );
 
   try{
@@ -44,13 +44,13 @@ function contact_get_expectedresult() {
     'is_error' => 0,
     'version' => 3,
     'count' => 1,
-    'id' => 1,
+    'id' => 3,
     'values' => array(
-      '1' => array(
-        'contact_id' => '1',
+      '3' => array(
+        'contact_id' => '3',
         'civicrm_value_testgetwithcu_1_id' => '1',
         'custom_1' => 'custom string',
-        'id' => '1',
+        'id' => '3',
       ),
     ),
   );
index bfb4f9976e7ee61789f5316fa1b3d39138ec0f44..1bb7f83feb3e21c2eea3bbc3f45bc60e84626884 100644 (file)
@@ -7,7 +7,7 @@
  */
 function contact_delete_example() {
   $params = array(
-    'id' => 1,
+    'id' => 3,
   );
 
   try{
index fb2556c9f48cc35b58d955ab7eaa89bbfbecb95b..9f666711fc9bdd632ca0cdf02ba2282bc5f3791e 100644 (file)
@@ -41,10 +41,10 @@ function contact_get_expectedresult() {
     'is_error' => 0,
     'version' => 3,
     'count' => 1,
-    'id' => 1,
+    'id' => 3,
     'values' => array(
-      '1' => array(
-        'contact_id' => '1',
+      '3' => array(
+        'contact_id' => '3',
         'contact_type' => 'Individual',
         'contact_sub_type' => '',
         'sort_name' => 'man2@yahoo.com',
@@ -80,8 +80,8 @@ function contact_get_expectedresult() {
         'sic_code' => '',
         'contact_is_deleted' => 0,
         'current_employer' => '',
-        'address_id' => '2',
-        'street_address' => '1 my road',
+        'address_id' => '',
+        'street_address' => '',
         'supplemental_address_1' => '',
         'supplemental_address_2' => '',
         'city' => '',
@@ -109,7 +109,7 @@ function contact_get_expectedresult() {
         'state_province_name' => '',
         'state_province' => '',
         'country' => '',
-        'id' => '1',
+        'id' => '3',
       ),
     ),
   );
index d2c85713ed1ceecc4735db3475a133f495667b2a..585e5e8dca83137190c6126b0b619d2837f1ad06 100644 (file)
@@ -40,33 +40,28 @@ function contact_getactions_expectedresult() {
   $expectedResult = array(
     'is_error' => 0,
     'version' => 3,
-    'count' => 25,
+    'count' => 20,
     'values' => array(
       '0' => 'create',
       '1' => 'delete',
       '2' => 'duplicatecheck',
-      '3' => 'example_action1',
-      '4' => 'example_action2',
-      '5' => 'get',
-      '6' => 'getactions',
-      '7' => 'getcount',
-      '8' => 'getfield',
-      '9' => 'getfields',
-      '10' => 'getlist',
-      '11' => 'getoptions',
-      '12' => 'getquick',
-      '13' => 'getrefcount',
-      '14' => 'getsingle',
-      '15' => 'getvalue',
-      '16' => 'merge',
-      '17' => 'proximity',
-      '18' => 'replace',
-      '19' => 'setvalue',
-      '20' => 'type_create',
-      '21' => 'type_delete',
-      '22' => 'type_get',
-      '23' => 'update',
-      '24' => 'validate',
+      '3' => 'get',
+      '4' => 'getactions',
+      '5' => 'getcount',
+      '6' => 'getfield',
+      '7' => 'getfields',
+      '8' => 'getlist',
+      '9' => 'getoptions',
+      '10' => 'getquick',
+      '11' => 'getrefcount',
+      '12' => 'getsingle',
+      '13' => 'getvalue',
+      '14' => 'merge',
+      '15' => 'proximity',
+      '16' => 'replace',
+      '17' => 'setvalue',
+      '18' => 'update',
+      '19' => 'validate',
     ),
     'deprecated' => array(
       'getquick' => 'The "getquick" action is deprecated in favor of "getlist".',
index a366b409581927430b2af1fc223f863acd32e78b..57972c52525932146d426b8efb3f28adc51895f1 100644 (file)
@@ -57,6 +57,9 @@ function contact_getfields_expectedresult() {
         'where' => 'civicrm_contact.id',
         'headerPattern' => '/internal|contact?|id$/i',
         'export' => TRUE,
+        'table_name' => 'civicrm_contact',
+        'entity' => 'Contact',
+        'bao' => 'CRM_Contact_BAO_Contact',
         'api.aliases' => array(
           '0' => 'contact_id',
         ),
@@ -70,6 +73,9 @@ function contact_getfields_expectedresult() {
         'size' => 30,
         'export' => TRUE,
         'where' => 'civicrm_contact.contact_type',
+        'table_name' => 'civicrm_contact',
+        'entity' => 'Contact',
+        'bao' => 'CRM_Contact_BAO_Contact',
         'html' => array(
           'type' => 'Select',
           'maxlength' => 64,
@@ -94,6 +100,9 @@ function contact_getfields_expectedresult() {
         'where' => 'civicrm_contact.contact_sub_type',
         'headerPattern' => '/C(ontact )?(subtype|sub-type|sub type)/i',
         'export' => TRUE,
+        'table_name' => 'civicrm_contact',
+        'entity' => 'Contact',
+        'bao' => 'CRM_Contact_BAO_Contact',
         'html' => array(
           'type' => 'Select',
           'maxlength' => 255,
@@ -115,6 +124,9 @@ function contact_getfields_expectedresult() {
         'headerPattern' => '/d(o )?(not )?(email)/i',
         'dataPattern' => '/^\\d{1,}$/',
         'export' => TRUE,
+        'table_name' => 'civicrm_contact',
+        'entity' => 'Contact',
+        'bao' => 'CRM_Contact_BAO_Contact',
         'html' => array(
           'type' => 'CheckBox',
         ),
@@ -128,6 +140,9 @@ function contact_getfields_expectedresult() {
         'headerPattern' => '/d(o )?(not )?(call|phone)/i',
         'dataPattern' => '/^\\d{1,}$/',
         'export' => TRUE,
+        'table_name' => 'civicrm_contact',
+        'entity' => 'Contact',
+        'bao' => 'CRM_Contact_BAO_Contact',
         'html' => array(
           'type' => 'CheckBox',
         ),
@@ -141,6 +156,9 @@ function contact_getfields_expectedresult() {
         'headerPattern' => '/^(d(o\\s)?n(ot\\s)?mail)|(\\w*)?bulk\\s?(\\w*)$/i',
         'dataPattern' => '/^\\d{1,}$/',
         'export' => TRUE,
+        'table_name' => 'civicrm_contact',
+        'entity' => 'Contact',
+        'bao' => 'CRM_Contact_BAO_Contact',
         'html' => array(
           'type' => 'CheckBox',
         ),
@@ -154,6 +172,9 @@ function contact_getfields_expectedresult() {
         'headerPattern' => '/d(o )?(not )?(sms)/i',
         'dataPattern' => '/^\\d{1,}$/',
         'export' => TRUE,
+        'table_name' => 'civicrm_contact',
+        'entity' => 'Contact',
+        'bao' => 'CRM_Contact_BAO_Contact',
         'html' => array(
           'type' => 'CheckBox',
         ),
@@ -167,6 +188,9 @@ function contact_getfields_expectedresult() {
         'headerPattern' => '/d(o )?(not )?(trade)/i',
         'dataPattern' => '/^\\d{1,}$/',
         'export' => TRUE,
+        'table_name' => 'civicrm_contact',
+        'entity' => 'Contact',
+        'bao' => 'CRM_Contact_BAO_Contact',
         'html' => array(
           'type' => 'CheckBox',
         ),
@@ -180,6 +204,9 @@ function contact_getfields_expectedresult() {
         'import' => TRUE,
         'where' => 'civicrm_contact.is_opt_out',
         'export' => TRUE,
+        'table_name' => 'civicrm_contact',
+        'entity' => 'Contact',
+        'bao' => 'CRM_Contact_BAO_Contact',
         'html' => array(
           'type' => 'CheckBox',
         ),
@@ -197,6 +224,9 @@ function contact_getfields_expectedresult() {
         'headerPattern' => '/legal\\s?id/i',
         'dataPattern' => '/\\w+?\\d{5,}/',
         'export' => TRUE,
+        'table_name' => 'civicrm_contact',
+        'entity' => 'Contact',
+        'bao' => 'CRM_Contact_BAO_Contact',
         'html' => array(
           'type' => 'Text',
           'maxlength' => 32,
@@ -215,6 +245,9 @@ function contact_getfields_expectedresult() {
         'headerPattern' => '/external\\s?id/i',
         'dataPattern' => '/^\\d{11,}$/',
         'export' => TRUE,
+        'table_name' => 'civicrm_contact',
+        'entity' => 'Contact',
+        'bao' => 'CRM_Contact_BAO_Contact',
         'html' => array(
           'type' => 'Text',
           'maxlength' => 64,
@@ -230,6 +263,9 @@ function contact_getfields_expectedresult() {
         'size' => 30,
         'export' => TRUE,
         'where' => 'civicrm_contact.sort_name',
+        'table_name' => 'civicrm_contact',
+        'entity' => 'Contact',
+        'bao' => 'CRM_Contact_BAO_Contact',
         'html' => array(
           'type' => 'Text',
           'maxlength' => 128,
@@ -245,6 +281,9 @@ function contact_getfields_expectedresult() {
         'size' => 30,
         'export' => TRUE,
         'where' => 'civicrm_contact.display_name',
+        'table_name' => 'civicrm_contact',
+        'entity' => 'Contact',
+        'bao' => 'CRM_Contact_BAO_Contact',
         'html' => array(
           'type' => 'Text',
           'maxlength' => 128,
@@ -263,6 +302,9 @@ function contact_getfields_expectedresult() {
         'headerPattern' => '/n(ick\\s)name|nick$/i',
         'dataPattern' => '/^\\w+$/',
         'export' => TRUE,
+        'table_name' => 'civicrm_contact',
+        'entity' => 'Contact',
+        'bao' => 'CRM_Contact_BAO_Contact',
         'html' => array(
           'type' => 'Text',
           'maxlength' => 128,
@@ -280,6 +322,9 @@ function contact_getfields_expectedresult() {
         'where' => 'civicrm_contact.legal_name',
         'headerPattern' => '/^legal|(l(egal\\s)?name)$/i',
         'export' => TRUE,
+        'table_name' => 'civicrm_contact',
+        'entity' => 'Contact',
+        'bao' => 'CRM_Contact_BAO_Contact',
         'html' => array(
           'type' => 'Text',
           'maxlength' => 128,
@@ -294,6 +339,9 @@ function contact_getfields_expectedresult() {
         'import' => TRUE,
         'where' => 'civicrm_contact.image_URL',
         'export' => TRUE,
+        'table_name' => 'civicrm_contact',
+        'entity' => 'Contact',
+        'bao' => 'CRM_Contact_BAO_Contact',
         'html' => array(
           'type' => 'File',
           'rows' => 2,
@@ -312,6 +360,9 @@ function contact_getfields_expectedresult() {
         'headerPattern' => '/^p(ref\\w*\\s)?c(omm\\w*)|( meth\\w*)$/i',
         'dataPattern' => '/^\\w+$/',
         'export' => TRUE,
+        'table_name' => 'civicrm_contact',
+        'entity' => 'Contact',
+        'bao' => 'CRM_Contact_BAO_Contact',
         'html' => array(
           'type' => 'Select',
           'maxlength' => 255,
@@ -333,6 +384,9 @@ function contact_getfields_expectedresult() {
         'where' => 'civicrm_contact.preferred_language',
         'headerPattern' => '/^lang/i',
         'export' => TRUE,
+        'table_name' => 'civicrm_contact',
+        'entity' => 'Contact',
+        'bao' => 'CRM_Contact_BAO_Contact',
         'html' => array(
           'type' => 'Select',
           'maxlength' => 5,
@@ -356,6 +410,9 @@ function contact_getfields_expectedresult() {
         'headerPattern' => '/^p(ref\\w*\\s)?m(ail\\s)?f(orm\\w*)$/i',
         'export' => TRUE,
         'default' => 'Both',
+        'table_name' => 'civicrm_contact',
+        'entity' => 'Contact',
+        'bao' => 'CRM_Contact_BAO_Contact',
         'html' => array(
           'type' => 'Select',
           'maxlength' => 8,
@@ -374,6 +431,9 @@ function contact_getfields_expectedresult() {
         'size' => 20,
         'export' => TRUE,
         'where' => 'civicrm_contact.hash',
+        'table_name' => 'civicrm_contact',
+        'entity' => 'Contact',
+        'bao' => 'CRM_Contact_BAO_Contact',
       ),
       'api_key' => array(
         'name' => 'api_key',
@@ -382,6 +442,9 @@ function contact_getfields_expectedresult() {
         'description' => 'API Key for validating requests related to this contact.',
         'maxlength' => 32,
         'size' => 20,
+        'table_name' => 'civicrm_contact',
+        'entity' => 'Contact',
+        'bao' => 'CRM_Contact_BAO_Contact',
       ),
       'first_name' => array(
         'name' => 'first_name',
@@ -395,6 +458,9 @@ function contact_getfields_expectedresult() {
         'headerPattern' => '/^first|(f(irst\\s)?name)$/i',
         'dataPattern' => '/^\\w+$/',
         'export' => TRUE,
+        'table_name' => 'civicrm_contact',
+        'entity' => 'Contact',
+        'bao' => 'CRM_Contact_BAO_Contact',
         'html' => array(
           'type' => 'Text',
           'maxlength' => 64,
@@ -413,6 +479,9 @@ function contact_getfields_expectedresult() {
         'headerPattern' => '/^middle|(m(iddle\\s)?name)$/i',
         'dataPattern' => '/^\\w+$/',
         'export' => TRUE,
+        'table_name' => 'civicrm_contact',
+        'entity' => 'Contact',
+        'bao' => 'CRM_Contact_BAO_Contact',
         'html' => array(
           'type' => 'Text',
           'maxlength' => 64,
@@ -431,6 +500,9 @@ function contact_getfields_expectedresult() {
         'headerPattern' => '/^last|(l(ast\\s)?name)$/i',
         'dataPattern' => '/^\\w+(\\s\\w+)?+$/',
         'export' => TRUE,
+        'table_name' => 'civicrm_contact',
+        'entity' => 'Contact',
+        'bao' => 'CRM_Contact_BAO_Contact',
         'html' => array(
           'type' => 'Text',
           'maxlength' => 64,
@@ -447,6 +519,9 @@ function contact_getfields_expectedresult() {
         'headerPattern' => '/^(prefix|title)/i',
         'dataPattern' => '/^(mr|ms|mrs|sir|dr)\\.?$/i',
         'export' => TRUE,
+        'table_name' => 'civicrm_contact',
+        'entity' => 'Contact',
+        'bao' => 'CRM_Contact_BAO_Contact',
         'html' => array(
           'type' => 'Select',
           'size' => 6,
@@ -471,6 +546,9 @@ function contact_getfields_expectedresult() {
         'headerPattern' => '/^suffix$/i',
         'dataPattern' => '/^(sr|jr)\\.?|i{2,}$/',
         'export' => TRUE,
+        'table_name' => 'civicrm_contact',
+        'entity' => 'Contact',
+        'bao' => 'CRM_Contact_BAO_Contact',
         'html' => array(
           'type' => 'Select',
           'size' => 6,
@@ -496,6 +574,9 @@ function contact_getfields_expectedresult() {
         'where' => 'civicrm_contact.formal_title',
         'headerPattern' => '/^title/i',
         'export' => TRUE,
+        'table_name' => 'civicrm_contact',
+        'entity' => 'Contact',
+        'bao' => 'CRM_Contact_BAO_Contact',
         'html' => array(
           'type' => 'Text',
           'maxlength' => 64,
@@ -509,6 +590,9 @@ function contact_getfields_expectedresult() {
         'description' => 'Communication style (e.g. formal vs. familiar) to use with this contact. FK to communication styles in civicrm_option_value.',
         'export' => TRUE,
         'where' => 'civicrm_contact.communication_style_id',
+        'table_name' => 'civicrm_contact',
+        'entity' => 'Contact',
+        'bao' => 'CRM_Contact_BAO_Contact',
         'html' => array(
           'type' => 'Select',
           'size' => 6,
@@ -524,6 +608,9 @@ function contact_getfields_expectedresult() {
         'type' => 1,
         'title' => 'Email Greeting ID',
         'description' => 'FK to civicrm_option_value.id, that has to be valid registered Email Greeting.',
+        'table_name' => 'civicrm_contact',
+        'entity' => 'Contact',
+        'bao' => 'CRM_Contact_BAO_Contact',
       ),
       'email_greeting_custom' => array(
         'name' => 'email_greeting_custom',
@@ -534,6 +621,9 @@ function contact_getfields_expectedresult() {
         'size' => 45,
         'import' => TRUE,
         'where' => 'civicrm_contact.email_greeting_custom',
+        'table_name' => 'civicrm_contact',
+        'entity' => 'Contact',
+        'bao' => 'CRM_Contact_BAO_Contact',
         'html' => array(
           'type' => 'Text',
           'maxlength' => 128,
@@ -547,6 +637,9 @@ function contact_getfields_expectedresult() {
         'description' => 'Cache Email Greeting.',
         'maxlength' => 255,
         'size' => 45,
+        'table_name' => 'civicrm_contact',
+        'entity' => 'Contact',
+        'bao' => 'CRM_Contact_BAO_Contact',
         'html' => array(
           'type' => 'Text',
           'maxlength' => 255,
@@ -558,6 +651,9 @@ function contact_getfields_expectedresult() {
         'type' => 1,
         'title' => 'Postal Greeting ID',
         'description' => 'FK to civicrm_option_value.id, that has to be valid registered Postal Greeting.',
+        'table_name' => 'civicrm_contact',
+        'entity' => 'Contact',
+        'bao' => 'CRM_Contact_BAO_Contact',
         'html' => array(
           'type' => 'Text',
           'size' => 6,
@@ -573,6 +669,9 @@ function contact_getfields_expectedresult() {
         'size' => 45,
         'import' => TRUE,
         'where' => 'civicrm_contact.postal_greeting_custom',
+        'table_name' => 'civicrm_contact',
+        'entity' => 'Contact',
+        'bao' => 'CRM_Contact_BAO_Contact',
         'html' => array(
           'type' => 'Text',
           'maxlength' => 128,
@@ -586,6 +685,9 @@ function contact_getfields_expectedresult() {
         'description' => 'Cache Postal greeting.',
         'maxlength' => 255,
         'size' => 45,
+        'table_name' => 'civicrm_contact',
+        'entity' => 'Contact',
+        'bao' => 'CRM_Contact_BAO_Contact',
         'html' => array(
           'type' => 'Text',
           'maxlength' => 255,
@@ -597,6 +699,9 @@ function contact_getfields_expectedresult() {
         'type' => 1,
         'title' => 'Addressee ID',
         'description' => 'FK to civicrm_option_value.id, that has to be valid registered Addressee.',
+        'table_name' => 'civicrm_contact',
+        'entity' => 'Contact',
+        'bao' => 'CRM_Contact_BAO_Contact',
       ),
       'addressee_custom' => array(
         'name' => 'addressee_custom',
@@ -607,6 +712,9 @@ function contact_getfields_expectedresult() {
         'size' => 45,
         'import' => TRUE,
         'where' => 'civicrm_contact.addressee_custom',
+        'table_name' => 'civicrm_contact',
+        'entity' => 'Contact',
+        'bao' => 'CRM_Contact_BAO_Contact',
         'html' => array(
           'type' => 'Text',
           'maxlength' => 128,
@@ -620,6 +728,9 @@ function contact_getfields_expectedresult() {
         'description' => 'Cache Addressee.',
         'maxlength' => 255,
         'size' => 45,
+        'table_name' => 'civicrm_contact',
+        'entity' => 'Contact',
+        'bao' => 'CRM_Contact_BAO_Contact',
         'html' => array(
           'type' => 'Text',
           'maxlength' => 255,
@@ -638,6 +749,9 @@ function contact_getfields_expectedresult() {
         'headerPattern' => '/^job|(j(ob\\s)?title)$/i',
         'dataPattern' => '//',
         'export' => TRUE,
+        'table_name' => 'civicrm_contact',
+        'entity' => 'Contact',
+        'bao' => 'CRM_Contact_BAO_Contact',
         'html' => array(
           'type' => 'Text',
           'maxlength' => 255,
@@ -653,6 +767,9 @@ function contact_getfields_expectedresult() {
         'where' => 'civicrm_contact.gender_id',
         'headerPattern' => '/^gender$/i',
         'export' => TRUE,
+        'table_name' => 'civicrm_contact',
+        'entity' => 'Contact',
+        'bao' => 'CRM_Contact_BAO_Contact',
         'html' => array(
           'type' => 'Select',
           'size' => 6,
@@ -676,8 +793,12 @@ function contact_getfields_expectedresult() {
         'headerPattern' => '/^birth|(b(irth\\s)?date)|D(\\W*)O(\\W*)B(\\W*)$/i',
         'dataPattern' => '/\\d{4}-?\\d{2}-?\\d{2}/',
         'export' => TRUE,
+        'table_name' => 'civicrm_contact',
+        'entity' => 'Contact',
+        'bao' => 'CRM_Contact_BAO_Contact',
         'html' => array(
           'type' => 'Select Date',
+          'format' => 'birth',
         ),
       ),
       'is_deceased' => array(
@@ -688,6 +809,9 @@ function contact_getfields_expectedresult() {
         'where' => 'civicrm_contact.is_deceased',
         'headerPattern' => '/i(s\\s)?d(eceased)$/i',
         'export' => TRUE,
+        'table_name' => 'civicrm_contact',
+        'entity' => 'Contact',
+        'bao' => 'CRM_Contact_BAO_Contact',
         'html' => array(
           'type' => 'CheckBox',
         ),
@@ -701,8 +825,12 @@ function contact_getfields_expectedresult() {
         'where' => 'civicrm_contact.deceased_date',
         'headerPattern' => '/^deceased|(d(eceased\\s)?date)$/i',
         'export' => TRUE,
+        'table_name' => 'civicrm_contact',
+        'entity' => 'Contact',
+        'bao' => 'CRM_Contact_BAO_Contact',
         'html' => array(
           'type' => 'Select Date',
+          'format' => 'birth',
         ),
       ),
       'household_name' => array(
@@ -717,6 +845,9 @@ function contact_getfields_expectedresult() {
         'headerPattern' => '/^household|(h(ousehold\\s)?name)$/i',
         'dataPattern' => '/^\\w+$/',
         'export' => TRUE,
+        'table_name' => 'civicrm_contact',
+        'entity' => 'Contact',
+        'bao' => 'CRM_Contact_BAO_Contact',
         'html' => array(
           'type' => 'Text',
           'maxlength' => 128,
@@ -728,6 +859,9 @@ function contact_getfields_expectedresult() {
         'type' => 1,
         'title' => 'Household Primary Contact ID',
         'description' => 'Optional FK to Primary Contact for this household.',
+        'table_name' => 'civicrm_contact',
+        'entity' => 'Contact',
+        'bao' => 'CRM_Contact_BAO_Contact',
         'FKClassName' => 'CRM_Contact_DAO_Contact',
         'html' => array(
           'type' => 'Select',
@@ -748,6 +882,9 @@ function contact_getfields_expectedresult() {
         'headerPattern' => '/^organization|(o(rganization\\s)?name)$/i',
         'dataPattern' => '/^\\w+$/',
         'export' => TRUE,
+        'table_name' => 'civicrm_contact',
+        'entity' => 'Contact',
+        'bao' => 'CRM_Contact_BAO_Contact',
         'html' => array(
           'type' => 'Text',
           'maxlength' => 128,
@@ -765,6 +902,9 @@ function contact_getfields_expectedresult() {
         'where' => 'civicrm_contact.sic_code',
         'headerPattern' => '/^sic|(s(ic\\s)?code)$/i',
         'export' => TRUE,
+        'table_name' => 'civicrm_contact',
+        'entity' => 'Contact',
+        'bao' => 'CRM_Contact_BAO_Contact',
         'html' => array(
           'type' => 'Text',
           'maxlength' => 8,
@@ -784,6 +924,9 @@ function contact_getfields_expectedresult() {
         'dataPattern' => '/^[\\w\\/\\:\\.]+$/',
         'export' => TRUE,
         'rule' => 'url',
+        'table_name' => 'civicrm_contact',
+        'entity' => 'Contact',
+        'bao' => 'CRM_Contact_BAO_Contact',
         'html' => array(
           'type' => 'Text',
           'maxlength' => 255,
@@ -799,6 +942,9 @@ function contact_getfields_expectedresult() {
         'export' => TRUE,
         'where' => 'civicrm_contact.created_date',
         'default' => 'NULL',
+        'table_name' => 'civicrm_contact',
+        'entity' => 'Contact',
+        'bao' => 'CRM_Contact_BAO_Contact',
       ),
       'modified_date' => array(
         'name' => 'modified_date',
@@ -809,6 +955,9 @@ function contact_getfields_expectedresult() {
         'export' => TRUE,
         'where' => 'civicrm_contact.modified_date',
         'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
+        'table_name' => 'civicrm_contact',
+        'entity' => 'Contact',
+        'bao' => 'CRM_Contact_BAO_Contact',
       ),
       'source' => array(
         'name' => 'source',
@@ -821,6 +970,9 @@ function contact_getfields_expectedresult() {
         'where' => 'civicrm_contact.source',
         'headerPattern' => '/(C(ontact\\s)?Source)$/i',
         'export' => TRUE,
+        'table_name' => 'civicrm_contact',
+        'entity' => 'Contact',
+        'bao' => 'CRM_Contact_BAO_Contact',
         'html' => array(
           'type' => 'Text',
           'maxlength' => 255,
@@ -835,6 +987,9 @@ function contact_getfields_expectedresult() {
         'description' => 'OPTIONAL FK to civicrm_contact record.',
         'export' => TRUE,
         'where' => 'civicrm_contact.employer_id',
+        'table_name' => 'civicrm_contact',
+        'entity' => 'Contact',
+        'bao' => 'CRM_Contact_BAO_Contact',
         'FKClassName' => 'CRM_Contact_DAO_Contact',
         'html' => array(
           'type' => 'EntityRef',
@@ -851,6 +1006,9 @@ function contact_getfields_expectedresult() {
         'required' => TRUE,
         'export' => TRUE,
         'where' => 'civicrm_contact.is_deleted',
+        'table_name' => 'civicrm_contact',
+        'entity' => 'Contact',
+        'bao' => 'CRM_Contact_BAO_Contact',
         'html' => array(
           'type' => 'CheckBox',
         ),
@@ -878,8 +1036,8 @@ function contact_getfields_expectedresult() {
         'table_name' => 'civicrm_value_select_test_g_1',
         'column_name' => 'our_special_field_1',
         'pseudoconstant' => array(
-          'optionGroupName' => 'our_special_field_20170124082923',
-          'optionEditPath' => 'civicrm/admin/options/our_special_field_20170124082923',
+          'optionGroupName' => 'our_special_field_20170207021937',
+          'optionEditPath' => 'civicrm/admin/options/our_special_field_20170207021937',
         ),
         'name' => 'custom_1',
         'title' => 'Our special field',
index 67fadede7a07462b5e25dedd741c532a5745e1a2..879b059fa5537f822b5fde8031a0068647f7ce9e 100644 (file)
@@ -9,11 +9,12 @@
  */
 function contact_get_example() {
   $params = array(
-    'filter.group_id' => array(
-      '0' => 1,
-      '1' => 26,
+    'group' => array(
+      'IN' => array(
+        '0' => 'Test group C',
+        '1' => 'Test group D',
+      ),
     ),
-    'contact_type' => 'Individual',
   );
 
   try{
@@ -47,14 +48,14 @@ function contact_get_expectedresult() {
     'is_error' => 0,
     'version' => 3,
     'count' => 1,
-    'id' => 1,
+    'id' => 3,
     'values' => array(
-      '1' => array(
-        'contact_id' => '1',
+      '3' => array(
+        'contact_id' => '3',
         'contact_type' => 'Individual',
         'contact_sub_type' => '',
-        'sort_name' => 'man2@yahoo.com',
-        'display_name' => 'man2@yahoo.com',
+        'sort_name' => 'Groupmember, Test2',
+        'display_name' => 'Test2 Groupmember',
         'do_not_email' => 0,
         'do_not_phone' => 0,
         'do_not_mail' => 0,
@@ -69,9 +70,9 @@ function contact_get_expectedresult() {
         'preferred_communication_method' => '',
         'preferred_language' => 'en_US',
         'preferred_mail_format' => 'Both',
-        'first_name' => '',
+        'first_name' => 'Test2',
         'middle_name' => '',
-        'last_name' => '',
+        'last_name' => 'Groupmember',
         'prefix_id' => '',
         'suffix_id' => '',
         'formal_title' => '',
@@ -86,8 +87,8 @@ function contact_get_expectedresult() {
         'sic_code' => '',
         'contact_is_deleted' => 0,
         'current_employer' => '',
-        'address_id' => '2',
-        'street_address' => '1 my road',
+        'address_id' => '',
+        'street_address' => '',
         'supplemental_address_1' => '',
         'supplemental_address_2' => '',
         'city' => '',
@@ -101,7 +102,7 @@ function contact_get_expectedresult() {
         'phone_type_id' => '',
         'phone' => '',
         'email_id' => '1',
-        'email' => 'man2@yahoo.com',
+        'email' => 'test@example.org',
         'on_hold' => 0,
         'im_id' => '',
         'provider_id' => '',
@@ -115,7 +116,7 @@ function contact_get_expectedresult() {
         'state_province_name' => '',
         'state_province' => '',
         'country' => '',
-        'id' => '1',
+        'id' => '3',
       ),
     ),
   );
@@ -125,7 +126,7 @@ function contact_get_expectedresult() {
 
 /*
 * This example has been generated from the API test suite.
-* The test that created it is called "testGetGroupIDFromContact"
+* The test that created it is called "testContactGetWithGroupTitleMultipleGroups"
 * and can be found at:
 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php
 *
index fe6ec8ee0965bb9f6da8fbf60eb5e5111c5a4a33..0ed270153050d214d61279657712a169de9eeacd 100644 (file)
@@ -9,7 +9,7 @@
  */
 function contribution_create_example() {
   $params = array(
-    'contact_id' => 23,
+    'contact_id' => 28,
     'receive_date' => '20120511',
     'total_amount' => '100',
     'financial_type_id' => 1,
@@ -18,7 +18,7 @@ function contribution_create_example() {
     'net_amount' => '95',
     'source' => 'SSF',
     'contribution_status_id' => 1,
-    'honor_contact_id' => 24,
+    'honor_contact_id' => 29,
   );
 
   try{
@@ -30,7 +30,8 @@ function contribution_create_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
@@ -55,7 +56,7 @@ function contribution_create_expectedresult() {
     'values' => array(
       '1' => array(
         'id' => '1',
-        'contact_id' => '23',
+        'contact_id' => '28',
         'financial_type_id' => '1',
         'contribution_page_id' => '',
         'payment_instrument_id' => '4',
@@ -82,6 +83,7 @@ function contribution_create_expectedresult() {
         'campaign_id' => '',
         'creditnote_id' => '',
         'tax_amount' => '',
+        'revenue_recognition_date' => '',
         'contribution_type_id' => '1',
       ),
     ),
index 4a19762036ba1bc554ec2c46587aa2fe201b9b6c..394b0c36ada2a4d1a1700b253afc594e5da44103 100644 (file)
@@ -9,7 +9,7 @@
  */
 function contribution_create_example() {
   $params = array(
-    'contact_id' => 17,
+    'contact_id' => 22,
     'receive_date' => '2012-01-01',
     'total_amount' => '100',
     'financial_type_id' => 1,
@@ -33,7 +33,8 @@ function contribution_create_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
@@ -58,7 +59,7 @@ function contribution_create_expectedresult() {
     'values' => array(
       '1' => array(
         'id' => '1',
-        'contact_id' => '17',
+        'contact_id' => '22',
         'financial_type_id' => '1',
         'contribution_page_id' => '',
         'payment_instrument_id' => '1',
@@ -85,6 +86,7 @@ function contribution_create_expectedresult() {
         'campaign_id' => '',
         'creditnote_id' => '',
         'tax_amount' => '',
+        'revenue_recognition_date' => '',
         'contribution_type_id' => '1',
       ),
     ),
index f756efed96d3a6ae173e61c0402dda2fdc13ec3e..a798c940b10f96510fbd7cf23ae5b1229f3b717e 100644 (file)
@@ -9,7 +9,7 @@
  */
 function contribution_create_example() {
   $params = array(
-    'contact_id' => 19,
+    'contact_id' => 24,
     'receive_date' => '20120511',
     'total_amount' => '100',
     'financial_type_id' => 1,
@@ -20,7 +20,7 @@ function contribution_create_example() {
     'contribution_status_id' => 1,
     'soft_credit' => array(
       '1' => array(
-        'contact_id' => 20,
+        'contact_id' => 25,
         'amount' => 50,
         'soft_credit_type_id' => 3,
       ),
@@ -36,7 +36,8 @@ function contribution_create_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
@@ -61,7 +62,7 @@ function contribution_create_expectedresult() {
     'values' => array(
       '1' => array(
         'id' => '1',
-        'contact_id' => '19',
+        'contact_id' => '24',
         'financial_type_id' => '1',
         'contribution_page_id' => '',
         'payment_instrument_id' => '4',
@@ -88,6 +89,7 @@ function contribution_create_expectedresult() {
         'campaign_id' => '',
         'creditnote_id' => '',
         'tax_amount' => '',
+        'revenue_recognition_date' => '',
         'contribution_type_id' => '1',
       ),
     ),
index 8d7126cb897de7c0f5218e7f9f9b630623beca52..5209aa9aea94479b470d6f89333a9ba6d7eaaa22 100644 (file)
@@ -9,7 +9,7 @@
  */
 function contribution_create_example() {
   $params = array(
-    'contact_id' => 21,
+    'contact_id' => 26,
     'receive_date' => '20120511',
     'total_amount' => '100',
     'financial_type_id' => 1,
@@ -18,7 +18,7 @@ function contribution_create_example() {
     'net_amount' => '95',
     'source' => 'SSF',
     'contribution_status_id' => 1,
-    'soft_credit_to' => 22,
+    'soft_credit_to' => 27,
   );
 
   try{
@@ -30,7 +30,8 @@ function contribution_create_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
@@ -55,7 +56,7 @@ function contribution_create_expectedresult() {
     'values' => array(
       '1' => array(
         'id' => '1',
-        'contact_id' => '21',
+        'contact_id' => '26',
         'financial_type_id' => '1',
         'contribution_page_id' => '',
         'payment_instrument_id' => '4',
@@ -82,6 +83,7 @@ function contribution_create_expectedresult() {
         'campaign_id' => '',
         'creditnote_id' => '',
         'tax_amount' => '',
+        'revenue_recognition_date' => '',
         'contribution_type_id' => '1',
       ),
     ),
index 9135fe3f9201247b95e9ff1e0b4cbbfca8d92269..9b4997039319cd65ec4e8eadd6a731a094b87a64 100644 (file)
@@ -13,6 +13,7 @@ function contribution_create_example() {
     'financial_type_id' => 1,
     'contribution_page_id' => 1,
     'trxn_id' => 12345,
+    'is_pay_later' => 1,
     'invoice_id' => 67890,
     'source' => 'SSF',
     'contribution_status_id' => 2,
@@ -27,7 +28,8 @@ function contribution_create_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
@@ -59,7 +61,7 @@ function contribution_create_expectedresult() {
         'receive_date' => '20120511000000',
         'non_deductible_amount' => '',
         'total_amount' => '100',
-        'fee_amount' => '0',
+        'fee_amount' => 0,
         'net_amount' => '100',
         'trxn_id' => '12345',
         'invoice_id' => '67890',
@@ -72,15 +74,15 @@ function contribution_create_expectedresult() {
         'amount_level' => '',
         'contribution_recur_id' => '',
         'is_test' => '',
-        'is_pay_later' => '',
+        'is_pay_later' => '1',
         'contribution_status_id' => '2',
         'address_id' => '',
         'check_number' => '',
         'campaign_id' => '',
         'creditnote_id' => '',
         'tax_amount' => '',
-        'contribution_type_id' => '1',
         'revenue_recognition_date' => '',
+        'contribution_type_id' => '1',
       ),
     ),
   );
@@ -90,9 +92,9 @@ function contribution_create_expectedresult() {
 
 /*
 * This example has been generated from the API test suite.
-* The test that created it is called "testCreateContributionPendingOnline"
+* The test that created it is called "testCreateContributionPayLaterOnline"
 * and can be found at:
-* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/TaxContributionPageTest.php
+* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContributionTest.php
 *
 * You can see the outcome of the API tests at
 * https://test.civicrm.org/job/CiviCRM-master-git/
index 2c7234e41960bd60f593ba2c0930633821c4eb66..741e1763979750fe7d6a16188a4c9a372346f20d 100644 (file)
@@ -9,10 +9,14 @@
  */
 function contribution_create_example() {
   $params = array(
-    'contact_id' => 1,
+    'contact_id' => 11,
     'receive_date' => '20120511',
-    'total_amount' => '400',
-    'financial_type_id' => 7,
+    'total_amount' => '100',
+    'financial_type_id' => 1,
+    'payment_instrument_id' => 1,
+    'non_deductible_amount' => '10',
+    'fee_amount' => '50',
+    'net_amount' => '90',
     'trxn_id' => 12345,
     'invoice_id' => 67890,
     'source' => 'SSF',
@@ -20,22 +24,16 @@ function contribution_create_example() {
     'skipLineItem' => 1,
     'api.line_item.create' => array(
       '0' => array(
-        'price_field_id' => array(
-          '0' => 3,
-        ),
-        'qty' => 1,
-        'line_total' => '100',
-        'unit_price' => '100',
-        'financial_type_id' => 7,
+        'price_field_id' => 1,
+        'qty' => 2,
+        'line_total' => '20',
+        'unit_price' => '10',
       ),
       '1' => array(
-        'price_field_id' => array(
-          '0' => 3,
-        ),
+        'price_field_id' => 1,
         'qty' => 1,
-        'line_total' => '300',
-        'unit_price' => '300',
-        'financial_type_id' => 8,
+        'line_total' => '80',
+        'unit_price' => '80',
       ),
     ),
   );
@@ -49,7 +47,8 @@ function contribution_create_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
@@ -74,15 +73,15 @@ function contribution_create_expectedresult() {
     'values' => array(
       '1' => array(
         'id' => '1',
-        'contact_id' => '1',
-        'financial_type_id' => '7',
+        'contact_id' => '11',
+        'financial_type_id' => '1',
         'contribution_page_id' => '',
-        'payment_instrument_id' => '4',
+        'payment_instrument_id' => '1',
         'receive_date' => '20120511000000',
-        'non_deductible_amount' => '',
-        'total_amount' => '435',
-        'fee_amount' => 0,
-        'net_amount' => '435',
+        'non_deductible_amount' => '10',
+        'total_amount' => '100',
+        'fee_amount' => '50',
+        'net_amount' => '90',
         'trxn_id' => '12345',
         'invoice_id' => '67890',
         'currency' => 'USD',
@@ -100,8 +99,9 @@ function contribution_create_expectedresult() {
         'check_number' => '',
         'campaign_id' => '',
         'creditnote_id' => '',
-        'tax_amount' => '35',
-        'contribution_type_id' => '7',
+        'tax_amount' => 0,
+        'revenue_recognition_date' => '',
+        'contribution_type_id' => '1',
         'api.line_item.create' => array(
           '0' => array(
             'is_error' => 0,
@@ -114,18 +114,16 @@ function contribution_create_expectedresult() {
                 'entity_table' => 'civicrm_contribution',
                 'entity_id' => '1',
                 'contribution_id' => '1',
-                'price_field_id' => array(
-                  '0' => '3',
-                ),
+                'price_field_id' => '1',
                 'label' => 'line item',
-                'qty' => '1',
-                'unit_price' => '100',
-                'line_total' => '100',
+                'qty' => '2',
+                'unit_price' => '10',
+                'line_total' => '20',
                 'participant_count' => '',
                 'price_field_value_id' => '',
-                'financial_type_id' => '7',
-                'deductible_amount' => '',
-                'tax_amount' => '20',
+                'financial_type_id' => '',
+                'non_deductible_amount' => '',
+                'tax_amount' => '',
               ),
             ),
           ),
@@ -140,18 +138,16 @@ function contribution_create_expectedresult() {
                 'entity_table' => 'civicrm_contribution',
                 'entity_id' => '1',
                 'contribution_id' => '1',
-                'price_field_id' => array(
-                  '0' => '3',
-                ),
+                'price_field_id' => '1',
                 'label' => 'line item',
                 'qty' => '1',
-                'unit_price' => '300',
-                'line_total' => '300',
+                'unit_price' => '80',
+                'line_total' => '80',
                 'participant_count' => '',
                 'price_field_value_id' => '',
-                'financial_type_id' => '8',
-                'deductible_amount' => '',
-                'tax_amount' => '15',
+                'financial_type_id' => '',
+                'non_deductible_amount' => '',
+                'tax_amount' => '',
               ),
             ),
           ),
@@ -167,7 +163,7 @@ function contribution_create_expectedresult() {
 * This example has been generated from the API test suite.
 * The test that created it is called "testCreateContributionChainedLineItems"
 * and can be found at:
-* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/TaxContributionPageTest.php
+* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContributionTest.php
 *
 * You can see the outcome of the API tests at
 * https://test.civicrm.org/job/CiviCRM-master-git/
index 0242584211948b8bebf064b1001ca75c115a69f0..c22b1b102d2219623ce027337592c4b5ae5fc69f 100644 (file)
@@ -19,7 +19,8 @@ function contribution_delete_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
@@ -53,7 +54,7 @@ function contribution_delete_expectedresult() {
 * This example has been generated from the API test suite.
 * The test that created it is called "testDeleteContribution"
 * and can be found at:
-* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/TaxContributionPageTest.php
+* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContributionTest.php
 *
 * You can see the outcome of the API tests at
 * https://test.civicrm.org/job/CiviCRM-master-git/
index 3649403beaa74b45d8ac2445d60e2b0e523b7187..0c5c06f58f2f04481605f20ec4e5a02f10530337 100644 (file)
@@ -19,7 +19,8 @@ function contribution_get_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
@@ -43,7 +44,7 @@ function contribution_get_expectedresult() {
     'id' => 1,
     'values' => array(
       '1' => array(
-        'contact_id' => '4',
+        'contact_id' => '3',
         'contact_type' => 'Individual',
         'contact_sub_type' => '',
         'sort_name' => 'Anderson, Anthony',
@@ -63,10 +64,11 @@ function contribution_get_expectedresult() {
         'thankyou_date' => '',
         'contribution_source' => 'SSF',
         'amount_level' => '',
+        'contribution_recur_id' => '',
         'is_test' => 0,
         'is_pay_later' => 0,
         'contribution_status_id' => '1',
-        'check_number' => '',
+        'contribution_check_number' => '',
         'contribution_campaign_id' => '',
         'financial_type_id' => '1',
         'financial_type' => 'Donation',
@@ -78,16 +80,17 @@ function contribution_get_expectedresult() {
         'fulfilled_date' => '',
         'contribution_start_date' => '',
         'contribution_end_date' => '',
-        'contribution_recur_id' => '',
         'financial_account_id' => '1',
         'accounting_code' => '4200',
+        'campaign_id' => '',
+        'contribution_campaign_title' => '',
         'contribution_note' => '',
         'contribution_batch' => '',
         'contribution_status' => 'Completed',
         'payment_instrument' => 'Check',
         'payment_instrument_id' => '4',
         'instrument_id' => '4',
-        'contribution_check_number' => '',
+        'check_number' => '',
         'id' => '1',
         'contribution_type_id' => '1',
       ),
@@ -99,7 +102,7 @@ function contribution_get_expectedresult() {
 
 /*
 * This example has been generated from the API test suite.
-* The test that created it is called "testGetContributionLegacyBehaviour"
+* The test that created it is called "testGetContribution"
 * and can be found at:
 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContributionTest.php
 *
index bff46b83dedcecba07fae741c0264d5eefd665a7..8139aa301a4e42e16d11f01503aca666b5bed2eb 100644 (file)
@@ -13,6 +13,9 @@ function contribution_page_create_example() {
     'goal_amount' => 34567,
     'is_pay_later' => 1,
     'is_monetary' => TRUE,
+    'is_email_receipt' => TRUE,
+    'receipt_from_email' => 'yourconscience@donate.com',
+    'receipt_from_name' => 'Ego Freud',
   );
 
   try{
@@ -77,11 +80,9 @@ function contribution_page_create_expectedresult() {
         'thankyou_title' => '',
         'thankyou_text' => '',
         'thankyou_footer' => '',
-        'is_for_organization' => '',
-        'for_organization' => '',
-        'is_email_receipt' => '',
-        'receipt_from_name' => '',
-        'receipt_from_email' => '',
+        'is_email_receipt' => '1',
+        'receipt_from_name' => 'Ego Freud',
+        'receipt_from_email' => 'yourconscience@donate.com',
         'cc_receipt' => '',
         'bcc_receipt' => '',
         'receipt_text' => '',
index cc7cd888b2ee99f03f3f9c2184316e9dded66cef..0a6b234e907ec8f5066f488f1e2754c78f2525f0 100644 (file)
@@ -7,7 +7,6 @@
  */
 function contribution_page_get_example() {
   $params = array(
-    'amount' => '34567',
     'currency' => 'NZD',
     'financial_type_id' => 1,
   );
@@ -55,17 +54,20 @@ function contribution_page_get_expectedresult() {
         'is_confirm_enabled' => '1',
         'is_recur_interval' => 0,
         'is_recur_installments' => 0,
+        'adjust_recur_start_date' => 0,
         'is_pay_later' => '1',
         'is_partial_payment' => 0,
         'is_allow_other_amount' => 0,
         'goal_amount' => '34567.00',
-        'is_for_organization' => 0,
-        'is_email_receipt' => 0,
+        'is_email_receipt' => '1',
+        'receipt_from_name' => 'Ego Freud',
+        'receipt_from_email' => 'yourconscience@donate.com',
         'is_active' => '1',
         'amount_block_is_active' => '1',
         'currency' => 'NZD',
         'is_share' => '1',
         'is_billing_required' => 0,
+        'contribution_type_id' => '1',
       ),
     ),
   );
@@ -75,7 +77,7 @@ function contribution_page_get_expectedresult() {
 
 /*
 * This example has been generated from the API test suite.
-* The test that created it is called "testGetContributionPageByAmount"
+* The test that created it is called "testGetBasicContributionPage"
 * and can be found at:
 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContributionPageTest.php
 *
index db56853f5d57ec3f0709b0b2b6aaca621ed5b237..c24c4dbcb3934d62c01380acb0cb23960e4151da 100644 (file)
@@ -9,16 +9,14 @@
  */
 function contribution_page_submit_example() {
   $params = array(
-    'price_3' => '',
     'id' => 1,
-    'amount' => 10,
+    'pledge_amount' => array(
+      '2' => 1,
+    ),
     'billing_first_name' => 'Billy',
     'billing_middle_name' => 'Goat',
     'billing_last_name' => 'Gruff',
     'email' => 'billy@goat.gruff',
-    'selectMembership' => array(
-      '0' => 1,
-    ),
     'payment_processor_id' => 1,
     'credit_card_number' => '4111111111111111',
     'credit_card_type' => 'Visa',
@@ -27,9 +25,12 @@ function contribution_page_submit_example() {
       'Y' => 2040,
     ),
     'cvv2' => 123,
-    'is_recur' => 1,
-    'frequency_interval' => 1,
-    'frequency_unit' => 'month',
+    'pledge_id' => '1',
+    'cid' => '77',
+    'contact_id' => '77',
+    'amount' => '100',
+    'is_pledge' => TRUE,
+    'pledge_block_id' => 2,
   );
 
   try{
@@ -71,7 +72,7 @@ function contribution_page_submit_expectedresult() {
 
 /*
 * This example has been generated from the API test suite.
-* The test that created it is called "testSubmitMembershipPriceSetPaymentPaymentProcessorRecurDelayed"
+* The test that created it is called "testSubmitPledgePayment"
 * and can be found at:
 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContributionPageTest.php
 *
index f5b732f6f0f57ee27a320d0aac9214e46cc896a4..fba4f0585044d1bb82c40d67f66c061b1c22574d 100644 (file)
@@ -7,7 +7,7 @@
  */
 function contribution_recur_delete_example() {
   $params = array(
-    'id' => 3,
+    'id' => 4,
   );
 
   try{
index 091baaa5ef9e651c16e848bbc006597c4fc6093a..988b9bcfc9158c3b8a5ec4f29d5e9242623043d8 100644 (file)
@@ -43,10 +43,10 @@ function country_create_expectedresult() {
     'is_error' => 0,
     'version' => 3,
     'count' => 1,
-    'id' => 1252,
+    'id' => 1254,
     'values' => array(
-      '1252' => array(
-        'id' => '1252',
+      '1254' => array(
+        'id' => '1254',
         'name' => 'Made Up Land',
         'iso_code' => 'ZZ',
         'country_code' => '',
index a631c34a07baf68d8ab5dd5f2f3a172bd9890482..79fcb15348a4d63e1086bffc6bc9c23d83435b37 100644 (file)
@@ -7,7 +7,7 @@
  */
 function country_delete_example() {
   $params = array(
-    'id' => 1253,
+    'id' => 1255,
   );
 
   try{
index d1cf00f99cdb3e26c33bc496fb6e63879eadc8de..dcd4d4431e8c707f23eb0d97179c09a087196c2b 100644 (file)
@@ -41,10 +41,10 @@ function country_get_expectedresult() {
     'is_error' => 0,
     'version' => 3,
     'count' => 1,
-    'id' => 1254,
+    'id' => 1256,
     'values' => array(
-      '1254' => array(
-        'id' => '1254',
+      '1256' => array(
+        'id' => '1256',
         'name' => 'Made Up Land',
         'iso_code' => 'ZZ',
         'region_id' => '1',
index 9d117d4b9bb7b911880be192a9f27d7b3bba1ec0..83d812b1bfc975af24f6354fde4f14e169704984 100644 (file)
@@ -7,8 +7,8 @@
  */
 function entity_tag_delete_example() {
   $params = array(
-    'contact_id_h' => 37,
-    'tag_id' => '17',
+    'contact_id_h' => 31,
+    'tag_id' => '15',
   );
 
   try{
index a51e13c015f974d6953fe9861b3c6f97246e9548..d3b1392145351614c7051d5409c80683dcf74496 100644 (file)
@@ -7,7 +7,7 @@
  */
 function entity_tag_get_example() {
   $params = array(
-    'contact_id' => 3,
+    'contact_id' => 15,
   );
 
   try{
@@ -41,10 +41,13 @@ function entity_tag_get_expectedresult() {
     'is_error' => 0,
     'version' => 3,
     'count' => 1,
-    'id' => 6,
+    'id' => 5,
     'values' => array(
-      '6' => array(
-        'tag_id' => '6',
+      '5' => array(
+        'id' => '5',
+        'entity_table' => 'civicrm_contact',
+        'entity_id' => '15',
+        'tag_id' => '10',
       ),
     ),
   );
index 0eca96b971e40db0a5204481437fd7bc909e4960..556e307c48656940be379eaa24d2daeadc451534 100644 (file)
@@ -67,7 +67,7 @@ function event_getsingle_expectedresult() {
     'allow_selfcancelxfer' => 0,
     'selfcancelxfer_time' => 0,
     'is_template' => 0,
-    'created_date' => '2017-01-24 08:34:25',
+    'created_date' => '2017-02-07 02:22:22',
     'is_share' => '1',
     'is_confirm_enabled' => '1',
     'is_billing_required' => 0,
index 22dfe5250c23be010671e1fe4ea2990769caa02a..0247cb3e9e92f0ad8ba75f5f380fe7070c2f30ec 100644 (file)
@@ -50,6 +50,9 @@ function group_getfields_expectedresult() {
         'title' => 'Group ID',
         'description' => 'Group ID',
         'required' => TRUE,
+        'table_name' => 'civicrm_group',
+        'entity' => 'Group',
+        'bao' => 'CRM_Contact_BAO_Group',
         'api.aliases' => array(
           '0' => 'group_id',
         ),
@@ -61,6 +64,9 @@ function group_getfields_expectedresult() {
         'description' => 'Internal name of Group.',
         'maxlength' => 64,
         'size' => 30,
+        'table_name' => 'civicrm_group',
+        'entity' => 'Group',
+        'bao' => 'CRM_Contact_BAO_Group',
       ),
       'title' => array(
         'name' => 'title',
@@ -69,6 +75,9 @@ function group_getfields_expectedresult() {
         'description' => 'Name of Group.',
         'maxlength' => 64,
         'size' => 30,
+        'table_name' => 'civicrm_group',
+        'entity' => 'Group',
+        'bao' => 'CRM_Contact_BAO_Group',
         'api.required' => 1,
       ),
       'description' => array(
@@ -78,6 +87,9 @@ function group_getfields_expectedresult() {
         'description' => 'Optional verbose description of the group.',
         'rows' => 2,
         'cols' => 60,
+        'table_name' => 'civicrm_group',
+        'entity' => 'Group',
+        'bao' => 'CRM_Contact_BAO_Group',
         'html' => array(
           'type' => 'TextArea',
           'rows' => 2,
@@ -91,12 +103,18 @@ function group_getfields_expectedresult() {
         'description' => 'Module or process which created this group.',
         'maxlength' => 64,
         'size' => 30,
+        'table_name' => 'civicrm_group',
+        'entity' => 'Group',
+        'bao' => 'CRM_Contact_BAO_Group',
       ),
       'saved_search_id' => array(
         'name' => 'saved_search_id',
         'type' => 1,
         'title' => 'Saved Search ID',
         'description' => 'FK to saved search table.',
+        'table_name' => 'civicrm_group',
+        'entity' => 'Group',
+        'bao' => 'CRM_Contact_BAO_Group',
         'FKClassName' => 'CRM_Contact_DAO_SavedSearch',
         'FKApiName' => 'SavedSearch',
       ),
@@ -105,6 +123,9 @@ function group_getfields_expectedresult() {
         'type' => 16,
         'title' => 'Group Enabled',
         'description' => 'Is this entry active?',
+        'table_name' => 'civicrm_group',
+        'entity' => 'Group',
+        'bao' => 'CRM_Contact_BAO_Group',
         'api.default' => 1,
       ),
       'visibility' => array(
@@ -115,6 +136,9 @@ function group_getfields_expectedresult() {
         'maxlength' => 24,
         'size' => 20,
         'default' => 'User and User Admin Only',
+        'table_name' => 'civicrm_group',
+        'entity' => 'Group',
+        'bao' => 'CRM_Contact_BAO_Group',
         'html' => array(
           'type' => 'Select',
           'maxlength' => 24,
@@ -129,18 +153,27 @@ function group_getfields_expectedresult() {
         'type' => 32,
         'title' => 'Group Where Clause',
         'description' => 'the sql where clause if a saved search acl',
+        'table_name' => 'civicrm_group',
+        'entity' => 'Group',
+        'bao' => 'CRM_Contact_BAO_Group',
       ),
       'select_tables' => array(
         'name' => 'select_tables',
         'type' => 32,
         'title' => 'Tables For Select Clause',
         'description' => 'the tables to be included in a select data',
+        'table_name' => 'civicrm_group',
+        'entity' => 'Group',
+        'bao' => 'CRM_Contact_BAO_Group',
       ),
       'where_tables' => array(
         'name' => 'where_tables',
         'type' => 32,
         'title' => 'Tables For Where Clause',
         'description' => 'the tables to be included in the count statement',
+        'table_name' => 'civicrm_group',
+        'entity' => 'Group',
+        'bao' => 'CRM_Contact_BAO_Group',
       ),
       'group_type' => array(
         'name' => 'group_type',
@@ -149,6 +182,9 @@ function group_getfields_expectedresult() {
         'description' => 'FK to group type',
         'maxlength' => 128,
         'size' => 45,
+        'table_name' => 'civicrm_group',
+        'entity' => 'Group',
+        'bao' => 'CRM_Contact_BAO_Group',
         'pseudoconstant' => array(
           'optionGroupName' => 'group_type',
           'optionEditPath' => 'civicrm/admin/options/group_type',
@@ -160,6 +196,9 @@ function group_getfields_expectedresult() {
         'title' => 'Group Cache Date',
         'description' => 'Date when we created the cache for a smart group',
         'required' => '',
+        'table_name' => 'civicrm_group',
+        'entity' => 'Group',
+        'bao' => 'CRM_Contact_BAO_Group',
       ),
       'refresh_date' => array(
         'name' => 'refresh_date',
@@ -167,35 +206,53 @@ function group_getfields_expectedresult() {
         'title' => 'Next Group Refresh Time',
         'description' => 'Date and time when we need to refresh the cache next.',
         'required' => '',
+        'table_name' => 'civicrm_group',
+        'entity' => 'Group',
+        'bao' => 'CRM_Contact_BAO_Group',
       ),
       'parents' => array(
         'name' => 'parents',
         'type' => 32,
         'title' => 'Group Parents',
         'description' => 'IDs of the parent(s)',
+        'table_name' => 'civicrm_group',
+        'entity' => 'Group',
+        'bao' => 'CRM_Contact_BAO_Group',
       ),
       'children' => array(
         'name' => 'children',
         'type' => 32,
         'title' => 'Group Children',
         'description' => 'IDs of the child(ren)',
+        'table_name' => 'civicrm_group',
+        'entity' => 'Group',
+        'bao' => 'CRM_Contact_BAO_Group',
       ),
       'is_hidden' => array(
         'name' => 'is_hidden',
         'type' => 16,
         'title' => 'Group is Hidden',
         'description' => 'Is this group hidden?',
+        'table_name' => 'civicrm_group',
+        'entity' => 'Group',
+        'bao' => 'CRM_Contact_BAO_Group',
       ),
       'is_reserved' => array(
         'name' => 'is_reserved',
         'type' => 16,
         'title' => 'Group is Reserved',
+        'table_name' => 'civicrm_group',
+        'entity' => 'Group',
+        'bao' => 'CRM_Contact_BAO_Group',
       ),
       'created_id' => array(
         'name' => 'created_id',
         'type' => 1,
         'title' => 'Group Created By',
         'description' => 'FK to contact table.',
+        'table_name' => 'civicrm_group',
+        'entity' => 'Group',
+        'bao' => 'CRM_Contact_BAO_Group',
         'FKClassName' => 'CRM_Contact_DAO_Contact',
         'FKApiName' => 'Contact',
       ),
@@ -204,6 +261,9 @@ function group_getfields_expectedresult() {
         'type' => 1,
         'title' => 'Group Modified By',
         'description' => 'FK to contact table.',
+        'table_name' => 'civicrm_group',
+        'entity' => 'Group',
+        'bao' => 'CRM_Contact_BAO_Group',
         'FKClassName' => 'CRM_Contact_DAO_Contact',
         'FKApiName' => 'Contact',
       ),
index 5c8514e02f5a6128e219c1f9ecc91c859ad995a5..1060d3ccf79f6a0fc7963cb1831ecacb52434be6 100644 (file)
@@ -48,13 +48,14 @@ function job_create_expectedresult() {
     'is_error' => 0,
     'version' => 3,
     'count' => 1,
-    'id' => 29,
+    'id' => 30,
     'values' => array(
       '0' => array(
-        'id' => '29',
+        'id' => '30',
         'domain_id' => '1',
         'run_frequency' => 'Daily',
         'last_run' => '',
+        'scheduled_run_date' => '',
         'name' => 'API_Test_Job',
         'description' => 'A long description written by hand in cursive',
         'api_entity' => 'ApiTestEntity',
index fe854b3d274c35c704303403f3ba821ae0f18947..40264b4c11e1e4753a067f3b73ce4aff39cc181f 100644 (file)
@@ -7,7 +7,7 @@
  */
 function job_delete_example() {
   $params = array(
-    'id' => 30,
+    'id' => 31,
   );
 
   try{
index 2f9a4dae9b6470febb0135cbe08bba472f86a8bb..0e95cdaf508e1322e1fe312ac810423f96f84c9a 100644 (file)
@@ -44,52 +44,52 @@ function logging_get_expectedresult() {
     'values' => array(
       '0' => array(
         'action' => 'Update',
-        'id' => '9',
+        'id' => '3',
         'field' => 'sort_name',
         'from' => 'Anderson, Anthony',
         'to' => 'Dwarf, Dopey',
         'table' => 'civicrm_contact',
-        'log_date' => '2016-04-06 02:53:44',
+        'log_date' => '2017-02-07 02:36:46',
         'log_conn_id' => 'wooty wop wop',
       ),
       '1' => array(
         'action' => 'Update',
-        'id' => '9',
+        'id' => '3',
         'field' => 'display_name',
         'from' => 'Mr. Anthony Anderson II',
         'to' => 'Mr. Dopey Dwarf II',
         'table' => 'civicrm_contact',
-        'log_date' => '2016-04-06 02:53:44',
+        'log_date' => '2017-02-07 02:36:46',
         'log_conn_id' => 'wooty wop wop',
       ),
       '2' => array(
         'action' => 'Update',
-        'id' => '9',
+        'id' => '3',
         'field' => 'first_name',
         'from' => 'Anthony',
         'to' => 'Dopey',
         'table' => 'civicrm_contact',
-        'log_date' => '2016-04-06 02:53:44',
+        'log_date' => '2017-02-07 02:36:46',
         'log_conn_id' => 'wooty wop wop',
       ),
       '3' => array(
         'action' => 'Update',
-        'id' => '9',
+        'id' => '3',
         'field' => 'last_name',
         'from' => 'Anderson',
         'to' => 'Dwarf',
         'table' => 'civicrm_contact',
-        'log_date' => '2016-04-06 02:53:44',
+        'log_date' => '2017-02-07 02:36:46',
         'log_conn_id' => 'wooty wop wop',
       ),
       '4' => array(
         'action' => 'Update',
-        'id' => '9',
+        'id' => '3',
         'field' => 'modified_date',
-        'from' => '2016-04-06 02:53:27',
-        'to' => '2016-04-06 02:53:44',
+        'from' => '2017-02-07 02:36:28',
+        'to' => '2017-02-07 02:36:46',
         'table' => 'civicrm_contact',
-        'log_date' => '2016-04-06 02:53:44',
+        'log_date' => '2017-02-07 02:36:46',
         'log_conn_id' => 'wooty wop wop',
       ),
       '5' => array(
@@ -99,7 +99,7 @@ function logging_get_expectedresult() {
         'from' => '',
         'to' => '2',
         'table' => 'civicrm_email',
-        'log_date' => '2016-04-06 02:53:44',
+        'log_date' => '2017-02-07 02:36:46',
         'log_conn_id' => 'wooty wop wop',
       ),
       '6' => array(
@@ -107,9 +107,9 @@ function logging_get_expectedresult() {
         'id' => '2',
         'field' => 'contact_id',
         'from' => '',
-        'to' => '9',
+        'to' => '3',
         'table' => 'civicrm_email',
-        'log_date' => '2016-04-06 02:53:44',
+        'log_date' => '2017-02-07 02:36:46',
         'log_conn_id' => 'wooty wop wop',
       ),
       '7' => array(
@@ -119,7 +119,7 @@ function logging_get_expectedresult() {
         'from' => '',
         'to' => '',
         'table' => 'civicrm_email',
-        'log_date' => '2016-04-06 02:53:44',
+        'log_date' => '2017-02-07 02:36:46',
         'log_conn_id' => 'wooty wop wop',
       ),
       '8' => array(
@@ -129,7 +129,7 @@ function logging_get_expectedresult() {
         'from' => '',
         'to' => 'dopey@mail.com',
         'table' => 'civicrm_email',
-        'log_date' => '2016-04-06 02:53:44',
+        'log_date' => '2017-02-07 02:36:46',
         'log_conn_id' => 'wooty wop wop',
       ),
       '9' => array(
@@ -139,7 +139,7 @@ function logging_get_expectedresult() {
         'from' => '',
         'to' => 0,
         'table' => 'civicrm_email',
-        'log_date' => '2016-04-06 02:53:44',
+        'log_date' => '2017-02-07 02:36:46',
         'log_conn_id' => 'wooty wop wop',
       ),
       '10' => array(
@@ -149,7 +149,7 @@ function logging_get_expectedresult() {
         'from' => '',
         'to' => 0,
         'table' => 'civicrm_email',
-        'log_date' => '2016-04-06 02:53:44',
+        'log_date' => '2017-02-07 02:36:46',
         'log_conn_id' => 'wooty wop wop',
       ),
       '11' => array(
@@ -159,7 +159,7 @@ function logging_get_expectedresult() {
         'from' => '',
         'to' => 0,
         'table' => 'civicrm_email',
-        'log_date' => '2016-04-06 02:53:44',
+        'log_date' => '2017-02-07 02:36:46',
         'log_conn_id' => 'wooty wop wop',
       ),
       '12' => array(
@@ -169,7 +169,7 @@ function logging_get_expectedresult() {
         'from' => '',
         'to' => 0,
         'table' => 'civicrm_email',
-        'log_date' => '2016-04-06 02:53:44',
+        'log_date' => '2017-02-07 02:36:46',
         'log_conn_id' => 'wooty wop wop',
       ),
       '13' => array(
@@ -179,7 +179,7 @@ function logging_get_expectedresult() {
         'from' => '',
         'to' => '',
         'table' => 'civicrm_email',
-        'log_date' => '2016-04-06 02:53:44',
+        'log_date' => '2017-02-07 02:36:46',
         'log_conn_id' => 'wooty wop wop',
       ),
       '14' => array(
@@ -189,7 +189,7 @@ function logging_get_expectedresult() {
         'from' => '',
         'to' => '',
         'table' => 'civicrm_email',
-        'log_date' => '2016-04-06 02:53:44',
+        'log_date' => '2017-02-07 02:36:46',
         'log_conn_id' => 'wooty wop wop',
       ),
       '15' => array(
@@ -199,7 +199,7 @@ function logging_get_expectedresult() {
         'from' => '',
         'to' => '',
         'table' => 'civicrm_email',
-        'log_date' => '2016-04-06 02:53:44',
+        'log_date' => '2017-02-07 02:36:46',
         'log_conn_id' => 'wooty wop wop',
       ),
       '16' => array(
@@ -209,7 +209,7 @@ function logging_get_expectedresult() {
         'from' => '',
         'to' => '',
         'table' => 'civicrm_email',
-        'log_date' => '2016-04-06 02:53:44',
+        'log_date' => '2017-02-07 02:36:46',
         'log_conn_id' => 'wooty wop wop',
       ),
     ),
index 1dad9943445b7c93a56ad417bd1b11557af4e4ec..c085b4497c1d80e89821be1a7bb0b99affd91bb8 100644 (file)
@@ -8,7 +8,7 @@
 function logging_revert_example() {
   $params = array(
     'log_conn_id' => 'woot',
-    'log_date' => '2016-04-06 02:52:07',
+    'log_date' => '2017-02-07 02:35:06',
   );
 
   try{
index 0c5410ce6f86a532e6f12dc53112ee19765640c8..b4bcf6f7132ad90d5dc7202159e01a7b8b6638b2 100644 (file)
@@ -9,18 +9,19 @@ function mailing_create_example() {
   $params = array(
     'subject' => 'Hello {contact.display_name}',
     'body_text' => 'This is {contact.display_name}.
+https://civicrm.org
 {domain.address}{action.optOutUrl}',
-    'body_html' => '<p>This is {contact.display_name}.</p><p>{domain.address}{action.optOutUrl}</p>',
+    'body_html' => '<p>This is {contact.display_name}.</p><p><a href='https://civicrm.org/'>CiviCRM.org</a></p><p>{domain.address}{action.optOutUrl}</p>',
     'name' => 'mailing name',
-    'created_id' => 9,
+    'created_id' => 11,
     'header_id' => '',
     'footer_id' => '',
     'groups' => array(
       'include' => array(
-        '0' => 7,
+        '0' => 9,
       ),
       'exclude' => array(
-        '0' => 8,
+        '0' => 10,
       ),
     ),
     'mailings' => array(
@@ -73,10 +74,10 @@ function mailing_create_expectedresult() {
     'is_error' => 0,
     'version' => 3,
     'count' => 1,
-    'id' => 4,
+    'id' => 5,
     'values' => array(
-      '4' => array(
-        'id' => '4',
+      '5' => array(
+        'id' => '5',
         'domain_id' => '1',
         'header_id' => '',
         'footer_id' => '',
@@ -93,9 +94,9 @@ function mailing_create_expectedresult() {
         'template_options' => '',
         'subject' => 'Hello {contact.display_name}',
         'body_text' => 'This is {contact.display_name}.
-https://civińcrm.org
+https://civicrm.org
 {domain.address}{action.optOutUrl}',
-        'body_html' => '<p>This is {contact.display_name}.</p><p><a href=\'https://civińcrm.org/\'>CiviCRM.org</a></p><p>{domain.address}{action.optOutUrl}</p>',
+        'body_html' => '<p>This is {contact.display_name}.</p><p><a href=\'https://civicrm.org/\'>CiviCRM.org</a></p><p>{domain.address}{action.optOutUrl}</p>',
         'url_tracking' => '1',
         'forward_replies' => '',
         'auto_responder' => '',
@@ -103,7 +104,7 @@ https://civińcrm.org
         'is_completed' => '',
         'msg_template_id' => '',
         'override_verp' => '1',
-        'created_id' => '9',
+        'created_id' => '11',
         'created_date' => '2013-07-28 08:49:19',
         'scheduled_id' => '',
         'scheduled_date' => '',
@@ -119,6 +120,7 @@ https://civińcrm.org
         'hash' => '',
         'location_type_id' => '',
         'email_selection_method' => '',
+        'language' => '',
         'api.mailing_job.create' => array(
           'is_error' => 0,
           'version' => 3,
@@ -127,7 +129,7 @@ https://civińcrm.org
           'values' => array(
             '0' => array(
               'id' => '5',
-              'mailing_id' => '4',
+              'mailing_id' => '5',
               'scheduled_date' => '20130728085413',
               'start_date' => '',
               'end_date' => '',
@@ -148,9 +150,9 @@ https://civińcrm.org
           'values' => array(
             '0' => array(
               'id' => '4',
-              'mailing_id' => '4',
-              'contact_id' => '10',
-              'email_id' => '10',
+              'mailing_id' => '5',
+              'contact_id' => '12',
+              'email_id' => '12',
               'api.contact.getvalue' => 'Mr. Includer Person II',
               'api.email.getvalue' => 'include.me@example.org',
             ),
index d274d8c82503f39b76bdb42f071652fcd678afff..b7f02cbc766fe86f46df736d2e35094a55d3100c 100644 (file)
@@ -7,7 +7,7 @@
  */
 function mailing_delete_example() {
   $params = array(
-    'id' => 18,
+    'id' => 20,
   );
 
   try{
index 1b328b7e6cc0688af2524f5e37643c3f7c55d15f..ffaae8983dd93e0a0ea4cf2672a862a206b9fdd7 100644 (file)
@@ -9,7 +9,7 @@ function mailing_submit_example() {
   $params = array(
     'scheduled_date' => '2014-12-13 10:00:00',
     'approval_date' => '2014-12-13 00:00:00',
-    'id' => 16,
+    'id' => 18,
   );
 
   try{
@@ -43,23 +43,27 @@ function mailing_submit_expectedresult() {
     'is_error' => 0,
     'version' => 3,
     'count' => 1,
-    'id' => 16,
+    'id' => 18,
     'values' => array(
-      '16' => array(
-        'id' => '16',
+      '18' => array(
+        'id' => '18',
         'domain_id' => '1',
         'header_id' => '',
-        'footer_id' => '24',
+        'footer_id' => '27',
         'reply_id' => '8',
         'unsubscribe_id' => '5',
         'resubscribe_id' => '6',
         'optout_id' => '7',
         'name' => 'mailing name',
+        'mailing_type' => 'standalone',
         'from_name' => 'FIXME',
         'from_email' => 'info@EXAMPLE.ORG',
         'replyto_email' => 'info@EXAMPLE.ORG',
+        'template_type' => 'traditional',
+        'template_options' => '',
         'subject' => 'Hello {contact.display_name}',
         'body_text' => 'This is {contact.display_name}.
+https://civicrm.org
 {domain.address}{action.optOutUrl}',
         'body_html' => '<p>Look ma, magic tokens in the markup!</p>',
         'url_tracking' => '1',
@@ -69,11 +73,11 @@ function mailing_submit_expectedresult() {
         'is_completed' => '',
         'msg_template_id' => '',
         'override_verp' => '1',
-        'created_id' => '35',
+        'created_id' => '40',
         'created_date' => '2013-07-28 08:49:19',
-        'scheduled_id' => '36',
+        'scheduled_id' => '41',
         'scheduled_date' => '20130728085413',
-        'approver_id' => '36',
+        'approver_id' => '41',
         'approval_date' => '20130728085413',
         'approval_status_id' => '1',
         'approval_note' => '',
@@ -83,8 +87,9 @@ function mailing_submit_expectedresult() {
         'dedupe_email' => '1',
         'sms_provider_id' => '',
         'hash' => '67eac7789eaee00',
-        'location_type_id' => 0,
+        'location_type_id' => '',
         'email_selection_method' => 'automatic',
+        'language' => '',
       ),
     ),
   );
index e1189215f1a97f26cf2975f6e908676f5fd34bb5..c7ac42c59d77475b87d84c9a2ca9ce0a92536df1 100644 (file)
@@ -57,11 +57,13 @@ function mailing_a_b_create_expectedresult() {
         'mailing_id_b' => '2',
         'mailing_id_c' => '3',
         'domain_id' => '1',
-        'testing_criteria_id' => '',
-        'winner_criteria_id' => '',
+        'testing_criteria' => 'subject',
+        'winner_criteria' => 'open',
         'specific_url' => '',
-        'declare_winning_time' => '20150224231452',
+        'declare_winning_time' => '20170209023708',
         'group_percentage' => '10',
+        'created_id' => '3',
+        'created_date' => '2013-07-28 08:49:19',
       ),
     ),
   );
index 5f765f3f796f87b73edda0a14af46475ae68bc63..107c3cc7c3ce7d2ffbbac1ff990b0dd3ba5d32dd 100644 (file)
@@ -7,14 +7,14 @@
  */
 function membership_create_example() {
   $params = array(
-    'contact_id' => 76,
-    'membership_type_id' => 45,
+    'contact_id' => 79,
+    'membership_type_id' => 47,
     'join_date' => '2006-01-21',
     'start_date' => '2006-01-21',
     'end_date' => '2006-12-21',
     'source' => 'Payment',
     'is_override' => 1,
-    'status_id' => 29,
+    'status_id' => 30,
   );
 
   try{
@@ -52,13 +52,13 @@ function membership_create_expectedresult() {
     'values' => array(
       '1' => array(
         'id' => '1',
-        'contact_id' => '76',
-        'membership_type_id' => '45',
+        'contact_id' => '79',
+        'membership_type_id' => '47',
         'join_date' => '20060121000000',
         'start_date' => '2013-07-29 00:00:00',
         'end_date' => '2013-08-04 00:00:00',
         'source' => 'Payment',
-        'status_id' => '29',
+        'status_id' => '30',
         'is_override' => '1',
         'owner_membership_id' => '',
         'max_related' => '',
index fe9516e6632a3abe5cf44e2516942f2d63cfcf3a..42fa4d5b8b3fc803cde284146c969756da945a46 100644 (file)
@@ -7,14 +7,14 @@
  */
 function membership_create_example() {
   $params = array(
-    'contact_id' => 88,
-    'membership_type_id' => 53,
+    'contact_id' => 91,
+    'membership_type_id' => 55,
     'join_date' => '2009-01-21',
     'start_date' => '2009-01-21',
     'end_date' => '2009-12-21',
     'source' => 'Payment',
     'is_override' => 1,
-    'status_id' => 33,
+    'status_id' => 34,
     'custom_1' => 'custom string',
   );
 
@@ -53,13 +53,13 @@ function membership_create_expectedresult() {
     'values' => array(
       '1' => array(
         'id' => '1',
-        'contact_id' => '88',
-        'membership_type_id' => '53',
+        'contact_id' => '91',
+        'membership_type_id' => '55',
         'join_date' => '20090121000000',
         'start_date' => '2013-07-29 00:00:00',
         'end_date' => '2013-08-04 00:00:00',
         'source' => 'Payment',
-        'status_id' => '33',
+        'status_id' => '34',
         'is_override' => '1',
         'owner_membership_id' => '',
         'max_related' => '',
index 13dc628132c6f3fbb64e456896bb5338c7fe0bbe..92109b857af7d24e0f6adf31678378234ce5c8ef 100644 (file)
@@ -9,7 +9,7 @@
  */
 function membership_get_example() {
   $params = array(
-    'contact_id' => 44,
+    'contact_id' => 47,
     'filters' => array(
       'is_current' => 1,
     ),
@@ -50,13 +50,13 @@ function membership_get_expectedresult() {
     'values' => array(
       '1' => array(
         'id' => '1',
-        'contact_id' => '44',
-        'membership_type_id' => '27',
+        'contact_id' => '47',
+        'membership_type_id' => '29',
         'join_date' => '2009-01-21',
         'start_date' => '2013-07-29 00:00:00',
         'end_date' => '2013-08-04 00:00:00',
         'source' => 'Payment',
-        'status_id' => '21',
+        'status_id' => '22',
         'is_override' => '1',
         'is_test' => 0,
         'is_pay_later' => 0,
index 20f24d537d40fe27041bcc23d82640229d588547..8c4fb2aed6cee0b268c69fd7e9da06b0c138e4cf 100644 (file)
@@ -7,7 +7,7 @@
  */
 function membership_get_example() {
   $params = array(
-    'membership_type_id' => 21,
+    'membership_type_id' => 23,
   );
 
   try{
@@ -45,19 +45,19 @@ function membership_get_expectedresult() {
     'values' => array(
       '1' => array(
         'id' => '1',
-        'contact_id' => '35',
-        'membership_type_id' => '21',
+        'contact_id' => '38',
+        'membership_type_id' => '23',
         'join_date' => '2009-01-21',
         'start_date' => '2013-07-29 00:00:00',
         'end_date' => '2013-08-04 00:00:00',
         'source' => 'Payment',
-        'status_id' => '18',
+        'status_id' => '19',
         'is_override' => '1',
         'is_test' => 0,
         'is_pay_later' => 0,
+        'custom_1' => 'custom string',
         'membership_name' => 'General',
         'relationship_name' => 'Child of',
-        'custom_1' => 'custom string',
         'custom_1_1' => 'custom string',
       ),
     ),
index 1b593b34c2807d1b835b91db3a497b82cd65aca8..f93f9d1bcdd0c72875b4987ab1e92a4acf2eef32 100644 (file)
@@ -7,14 +7,14 @@
  */
 function membership_create_example() {
   $params = array(
-    'contact_id' => 106,
-    'membership_type_id' => 65,
+    'contact_id' => 112,
+    'membership_type_id' => 69,
     'join_date' => '2009-01-21',
     'start_date' => '2009-01-21',
     'end_date' => '2009-12-21',
     'source' => 'Payment',
     'is_override' => 1,
-    'status_id' => 39,
+    'status_id' => 41,
     'custom_1' => 'custom string',
   );
 
@@ -53,13 +53,13 @@ function membership_create_expectedresult() {
     'values' => array(
       '1' => array(
         'id' => '1',
-        'contact_id' => '106',
-        'membership_type_id' => '65',
+        'contact_id' => '112',
+        'membership_type_id' => '69',
         'join_date' => '20090121000000',
         'start_date' => '2013-07-29 00:00:00',
         'end_date' => '2013-08-04 00:00:00',
         'source' => 'Payment',
-        'status_id' => '39',
+        'status_id' => '41',
         'is_override' => '1',
         'owner_membership_id' => '',
         'max_related' => '',
index 81cff6e5aeb07bdb70575a1c8396a569b4fa8294..1a01818506bb79707de9e384d1e411ecb580ea93 100644 (file)
@@ -9,7 +9,7 @@ function membership_type_create_example() {
   $params = array(
     'name' => '40+ Membership',
     'description' => 'people above 40 are given health instructions',
-    'member_of_contact_id' => 13,
+    'member_of_contact_id' => 7,
     'financial_type_id' => 1,
     'domain_id' => '1',
     'minimum_fee' => '200',
@@ -57,7 +57,7 @@ function membership_type_create_expectedresult() {
         'domain_id' => '1',
         'name' => '40+ Membership',
         'description' => 'people above 40 are given health instructions',
-        'member_of_contact_id' => '13',
+        'member_of_contact_id' => '7',
         'financial_type_id' => '1',
         'minimum_fee' => '200',
         'duration_unit' => 'month',
index f111b04bd406f1dab1d610ada06e05d6965b2db8..e9904be80405085112b41b8f0fdf7a99e93f5d3e 100644 (file)
@@ -48,7 +48,7 @@ function membership_type_get_expectedresult() {
         'domain_id' => '1',
         'name' => 'General',
         'member_of_contact_id' => '4',
-        'financial_type_id' => '1',
+        'financial_type_id' => '2',
         'minimum_fee' => '0.00',
         'duration_unit' => 'year',
         'duration_interval' => '1',
@@ -56,6 +56,7 @@ function membership_type_get_expectedresult() {
         'visibility' => 'Public',
         'auto_renew' => 0,
         'is_active' => '1',
+        'contribution_type_id' => '2',
       ),
     ),
   );
index 094118233901e9664e5cc2f2249446a30327f012..7f2f51393bdd056401db885df59b36fa77e988d7 100644 (file)
@@ -7,11 +7,11 @@
  */
 function message_template_create_example() {
   $params = array(
-    'msg_title' => 'msg_title_165',
-    'msg_subject' => 'msg_subject_165',
-    'msg_text' => 'msg_text_165',
-    'msg_html' => 'msg_html_165',
-    'workflow_id' => 165,
+    'msg_title' => 'msg_title_284',
+    'msg_subject' => 'msg_subject_284',
+    'msg_text' => 'msg_text_284',
+    'msg_html' => 'msg_html_284',
+    'workflow_id' => 284,
     'is_default' => '1',
     'is_reserved' => 1,
   );
@@ -47,16 +47,16 @@ function message_template_create_expectedresult() {
     'is_error' => 0,
     'version' => 3,
     'count' => 1,
-    'id' => 67,
+    'id' => 69,
     'values' => array(
-      '67' => array(
-        'id' => '67',
-        'msg_title' => 'msg_title_165',
-        'msg_subject' => 'msg_subject_165',
-        'msg_text' => 'msg_text_165',
-        'msg_html' => 'msg_html_165',
+      '69' => array(
+        'id' => '69',
+        'msg_title' => 'msg_title_284',
+        'msg_subject' => 'msg_subject_284',
+        'msg_text' => 'msg_text_284',
+        'msg_html' => 'msg_html_284',
         'is_active' => '1',
-        'workflow_id' => '165',
+        'workflow_id' => '284',
         'is_default' => '1',
         'is_reserved' => '1',
         'is_sms' => '',
index 1d47b6f0c8e06a03f58e8cc7ed94c61431d9600a..388e12c2ae0633d642b93fd69bb6f0a97755b991 100644 (file)
@@ -7,7 +7,7 @@
  */
 function message_template_delete_example() {
   $params = array(
-    'id' => 70,
+    'id' => 72,
   );
 
   try{
index d3ab1005bcfc1e85262625fbf33ecbc99e8664f6..318d8aada33c7eccc6622c6919dbe2422fd26214 100644 (file)
@@ -7,11 +7,11 @@
  */
 function message_template_get_example() {
   $params = array(
-    'msg_title' => 'msg_title_166',
-    'msg_subject' => 'msg_subject_166',
-    'msg_text' => 'msg_text_166',
-    'msg_html' => 'msg_html_166',
-    'workflow_id' => 166,
+    'msg_title' => 'msg_title_285',
+    'msg_subject' => 'msg_subject_285',
+    'msg_text' => 'msg_text_285',
+    'msg_html' => 'msg_html_285',
+    'workflow_id' => 285,
     'is_default' => '1',
     'is_reserved' => 1,
   );
@@ -47,20 +47,20 @@ function message_template_get_expectedresult() {
     'is_error' => 0,
     'version' => 3,
     'count' => 1,
-    'id' => 68,
+    'id' => 70,
     'values' => array(
-      '68' => array(
-        'id' => '68',
-        'msg_title' => 'msg_title_166',
-        'msg_subject' => 'msg_subject_166',
-        'msg_text' => 'msg_text_166',
-        'msg_html' => 'msg_html_166',
+      '70' => array(
+        'id' => '70',
+        'msg_title' => 'msg_title_285',
+        'msg_subject' => 'msg_subject_285',
+        'msg_text' => 'msg_text_285',
+        'msg_html' => 'msg_html_285',
         'is_active' => '1',
-        'workflow_id' => '166',
+        'workflow_id' => '285',
         'is_default' => '1',
         'is_reserved' => '1',
         'is_sms' => '1',
-        'pdf_format_id' => '166',
+        'pdf_format_id' => '285',
       ),
     ),
   );
index 7220e3db6ea71a31d785426ce260f916b5feedbc..cee25ba50b24470a8f7671d72e4beca408c4e074 100644 (file)
@@ -51,17 +51,18 @@ function option_group_create_expectedresult() {
     'is_error' => 0,
     'version' => 3,
     'count' => 1,
-    'id' => 93,
+    'id' => 92,
     'values' => array(
       '0' => array(
-        'id' => '93',
+        'id' => '92',
         'name' => 'civicrm_event.amount.560',
         'title' => '',
         'description' => '',
+        'data_type' => '',
         'is_reserved' => '1',
         'is_active' => '1',
         'is_locked' => '',
-        'api.OptionValue.create' => 784,
+        'api.OptionValue.create' => 849,
       ),
     ),
   );
index cdf194ec7527ee0f8756bc13f8eb29673b4fafa7..20839505b8fad0e44a7de4703ec559312732472c 100644 (file)
@@ -7,7 +7,7 @@
  */
 function option_group_delete_example() {
   $params = array(
-    'id' => 98,
+    'id' => 97,
   );
 
   try{
index 30f5aad2c53ffe79b61dcce9a420ecee6e8d279c..2e6ea262cac1069bc363038a2875641227ceb659 100644 (file)
@@ -45,7 +45,7 @@ function order_cancel_expectedresult() {
     'values' => array(
       '1' => array(
         'id' => '1',
-        'contact_id' => '14',
+        'contact_id' => '16',
         'financial_type_id' => '1',
         'contribution_page_id' => '',
         'payment_instrument_id' => '4',
index 45ea551fcd2a78d96e0535395ff2216895e22ed7..264b1493bd41f5df1f351577c415b93e9481dc3c 100644 (file)
@@ -7,7 +7,7 @@
  */
 function order_create_example() {
   $params = array(
-    'contact_id' => 7,
+    'contact_id' => 8,
     'receive_date' => '2010-01-20',
     'total_amount' => 200,
     'financial_type_id' => 1,
@@ -29,7 +29,7 @@ function order_create_example() {
           ),
         ),
         'params' => array(
-          'contact_id' => 7,
+          'contact_id' => 8,
           'membership_type_id' => 2,
           'join_date' => '2006-01-21',
           'start_date' => '2006-01-21',
@@ -77,7 +77,7 @@ function order_create_expectedresult() {
     'values' => array(
       '1' => array(
         'id' => '1',
-        'contact_id' => '7',
+        'contact_id' => '8',
         'financial_type_id' => '1',
         'contribution_page_id' => '',
         'payment_instrument_id' => '4',
index aa65ab5fd04560d92027c7d2ad6f677facfbb21e..b1a8a1040119fe0f6099e38192e0cadade97eede 100644 (file)
@@ -9,7 +9,7 @@
  */
 function order_create_example() {
   $params = array(
-    'contact_id' => 10,
+    'contact_id' => 11,
     'receive_date' => '2010-01-20',
     'total_amount' => 300,
     'financial_type_id' => 1,
@@ -41,7 +41,7 @@ function order_create_example() {
           ),
         ),
         'params' => array(
-          'contact_id' => 10,
+          'contact_id' => 11,
           'event_id' => 1,
           'status_id' => 1,
           'role_id' => 1,
@@ -87,7 +87,7 @@ function order_create_expectedresult() {
     'values' => array(
       '1' => array(
         'id' => '1',
-        'contact_id' => '10',
+        'contact_id' => '11',
         'financial_type_id' => '1',
         'contribution_page_id' => '',
         'payment_instrument_id' => '4',
index 10a3c2c84954c4e90795eb29f5e0ef4af09d7443..720596c3d716f9d0b6b6bd3303c80961cf2660e4 100644 (file)
@@ -64,10 +64,11 @@ function order_get_expectedresult() {
         'thankyou_date' => '',
         'contribution_source' => '',
         'amount_level' => '',
+        'contribution_recur_id' => '',
         'is_test' => 0,
         'is_pay_later' => 0,
         'contribution_status_id' => '1',
-        'check_number' => '',
+        'contribution_check_number' => '',
         'contribution_campaign_id' => '',
         'financial_type_id' => '1',
         'financial_type' => 'Donation',
@@ -79,7 +80,6 @@ function order_get_expectedresult() {
         'fulfilled_date' => '',
         'contribution_start_date' => '',
         'contribution_end_date' => '',
-        'contribution_recur_id' => '',
         'financial_account_id' => '1',
         'accounting_code' => '4200',
         'campaign_id' => '',
@@ -90,7 +90,7 @@ function order_get_expectedresult() {
         'payment_instrument' => 'Check',
         'payment_instrument_id' => '4',
         'instrument_id' => '4',
-        'contribution_check_number' => '',
+        'check_number' => '',
         'id' => '1',
         'contribution_type_id' => '1',
         'line_items' => array(
@@ -106,7 +106,8 @@ function order_get_expectedresult() {
             'line_total' => '100.00',
             'price_field_value_id' => '1',
             'financial_type_id' => '1',
-            'deductible_amount' => '0.00',
+            'non_deductible_amount' => '0.00',
+            'contribution_type_id' => '1',
           ),
         ),
       ),
index 8ab8b98dda950c82bda0a3f0fae1b59e7bb4c044..15aa07367eb16d639b97a40559e9ef68f921b359 100644 (file)
@@ -7,8 +7,8 @@
  */
 function participant_create_example() {
   $params = array(
-    'contact_id' => 4,
-    'event_id' => 1,
+    'contact_id' => 2,
+    'event_id' => 2,
     'status_id' => 1,
     'role_id' => 1,
     'register_date' => '2007-07-21 00:00:00',
@@ -51,8 +51,8 @@ function participant_create_expectedresult() {
     'values' => array(
       '4' => array(
         'id' => '4',
-        'contact_id' => '4',
-        'event_id' => '1',
+        'contact_id' => '2',
+        'event_id' => '2',
         'status_id' => '1',
         'role_id' => '1',
         'register_date' => '20070721000000',
index 1e06e9540ed7b8de60e0c117102f16cf86b12c17..52ad6116ac95bca0c43be926b76694198468fd10 100644 (file)
@@ -49,7 +49,7 @@ function participant_get_expectedresult() {
         'contact_sub_type' => '',
         'sort_name' => 'Anderson, Anthony',
         'display_name' => 'Mr. Anthony Anderson II',
-        'event_id' => '5',
+        'event_id' => '6',
         'event_title' => 'Annual CiviCRM meet',
         'event_start_date' => '2013-07-29 00:00:00',
         'event_end_date' => '2013-08-04 00:00:00',
@@ -60,8 +60,8 @@ function participant_get_expectedresult() {
         'event_type' => 'Conference',
         'participant_status_id' => '2',
         'participant_status' => 'Attended',
-        'participant_role' => 'Attendee',
         'participant_role_id' => '1',
+        'participant_role' => 'Attendee',
         'participant_register_date' => '2007-02-19 00:00:00',
         'participant_source' => 'Wimbeldon',
         'participant_note' => '',
index b9429731c749fa0fe120084bb693aecef60d73b3..37555e4bebf134476d806b95266ca85b6d9bfc20 100644 (file)
@@ -51,7 +51,7 @@ function participant_get_expectedresult() {
         'contact_sub_type' => '',
         'sort_name' => 'Anderson, Anthony',
         'display_name' => 'Mr. Anthony Anderson II',
-        'event_id' => '39',
+        'event_id' => '41',
         'event_title' => 'Annual CiviCRM meet',
         'event_start_date' => '2013-07-29 00:00:00',
         'event_end_date' => '2013-08-04 00:00:00',
@@ -62,14 +62,14 @@ function participant_get_expectedresult() {
         'event_type' => 'Conference',
         'participant_status_id' => '2',
         'participant_status' => 'Attended',
-        'participant_role' => 'Attendee',
         'participant_role_id' => '1',
+        'participant_role' => 'Attendee',
         'participant_register_date' => '2007-02-19 00:00:00',
         'participant_source' => 'Wimbeldon',
         'participant_note' => '',
         'participant_is_pay_later' => 0,
         'participant_is_test' => 0,
-        'participant_registered_by_id' => '',
+        'participant_registered_by_id' => '1',
         'participant_discount_name' => '',
         'participant_campaign_id' => '',
         'id' => '2',
@@ -86,7 +86,7 @@ function participant_get_expectedresult() {
         'contact_sub_type' => '',
         'sort_name' => 'Anderson, Anthony',
         'display_name' => 'Mr. Anthony Anderson II',
-        'event_id' => '39',
+        'event_id' => '41',
         'event_title' => 'Annual CiviCRM meet',
         'event_start_date' => '2013-07-29 00:00:00',
         'event_end_date' => '2013-08-04 00:00:00',
@@ -97,8 +97,8 @@ function participant_get_expectedresult() {
         'event_type' => 'Conference',
         'participant_status_id' => '2',
         'participant_status' => 'Attended',
-        'participant_role' => 'Attendee',
         'participant_role_id' => '1',
+        'participant_role' => 'Attendee',
         'participant_register_date' => '2007-02-19 00:00:00',
         'participant_source' => 'Wimbeldon',
         'participant_note' => '',
index 78f22366da83a4cf709b7f16674315fef2214902..c6b335e63d25fc8c5d5694b46c74b97506a61373 100644 (file)
@@ -52,7 +52,7 @@ function participant_get_expectedresult() {
         'contact_sub_type' => '',
         'sort_name' => 'Anderson, Anthony',
         'display_name' => 'Mr. Anthony Anderson II',
-        'event_id' => '6',
+        'event_id' => '7',
         'event_title' => 'Annual CiviCRM meet',
         'event_start_date' => '2013-07-29 00:00:00',
         'event_end_date' => '2013-08-04 00:00:00',
@@ -63,8 +63,8 @@ function participant_get_expectedresult() {
         'event_type' => 'Conference',
         'participant_status_id' => '2',
         'participant_status' => 'Attended',
-        'participant_role' => 'Attendee',
         'participant_role_id' => '1',
+        'participant_role' => 'Attendee',
         'participant_register_date' => '2007-02-19 00:00:00',
         'participant_source' => 'Wimbeldon',
         'participant_note' => '',
@@ -78,10 +78,10 @@ function participant_get_expectedresult() {
           'is_error' => 0,
           'version' => 3,
           'count' => 1,
-          'id' => 6,
+          'id' => 7,
           'values' => array(
             '0' => array(
-              'id' => '6',
+              'id' => '7',
               'title' => 'Annual CiviCRM meet',
               'event_title' => 'Annual CiviCRM meet',
               'summary' => 'If you have any CiviCRM related issues or want to track where CiviCRM is heading, Sign up now',
index 96a4481c51cb8c3ca24a787418518aae2fb4d7eb..9059a8b3225bcc6fb9c6298beaeb74d669ec5f8b 100644 (file)
@@ -48,10 +48,10 @@ function participant_status_type_create_expectedresult() {
     'is_error' => 0,
     'version' => 3,
     'count' => 1,
-    'id' => 17,
+    'id' => 18,
     'values' => array(
-      '17' => array(
-        'id' => '17',
+      '18' => array(
+        'id' => '18',
         'name' => 'test status',
         'label' => 'I am a test',
         'class' => 'Positive',
index 258aa4af10e59e57fbae27bbf6b09d532a7481a7..ae4fa45657092458eca5bcc4c71fb03d3bca93ef 100644 (file)
@@ -7,7 +7,7 @@
  */
 function participant_status_type_delete_example() {
   $params = array(
-    'id' => 18,
+    'id' => 19,
   );
 
   try{
index 318d9b5e794231de9768bec671e9dbd1c5b5ee5f..7eb41e6d0f06ef7f713ae90e2e51abcd234b0881 100644 (file)
@@ -48,10 +48,10 @@ function participant_status_type_get_expectedresult() {
     'is_error' => 0,
     'version' => 3,
     'count' => 1,
-    'id' => 17,
+    'id' => 18,
     'values' => array(
-      '17' => array(
-        'id' => '17',
+      '18' => array(
+        'id' => '18',
         'name' => 'test status',
         'label' => 'I am a test',
         'class' => 'Positive',
index bd71ea4426aefbb9642b12ef5aa0d3afdc6bf84e..84e18f440781f0fc9b0e5cc50a610492e5d22423 100644 (file)
@@ -20,7 +20,8 @@ function payment_cancel_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
@@ -47,7 +48,7 @@ function payment_cancel_expectedresult() {
         'id' => 3,
         'from_financial_account_id' => '7',
         'to_financial_account_id' => '6',
-        'trxn_date' => '20160217204840',
+        'trxn_date' => '20170207024650',
         'total_amount' => '-150',
         'fee_amount' => '0.00',
         'net_amount' => '150.00',
index 4a8efaae330d8ddb6eee4c7492a07fc9b9091dc8..6ece14b33acd50ffc679c8cdd53aafa5d367f884 100644 (file)
@@ -20,7 +20,8 @@ function payment_create_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
@@ -47,7 +48,7 @@ function payment_create_expectedresult() {
         'id' => '3',
         'from_financial_account_id' => '7',
         'to_financial_account_id' => '6',
-        'trxn_date' => '20160217204833',
+        'trxn_date' => '20170207024646',
         'total_amount' => '50',
         'fee_amount' => '',
         'net_amount' => '50',
index b9a9b971c183322986d8e8140d681390799c7817..f2b1613a61a4feb76304c0910ade14194cadc631 100644 (file)
@@ -30,7 +30,8 @@ function payment_create_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
@@ -57,7 +58,7 @@ function payment_create_expectedresult() {
         'id' => '3',
         'from_financial_account_id' => '7',
         'to_financial_account_id' => '6',
-        'trxn_date' => '20160217204836',
+        'trxn_date' => '20170207024648',
         'total_amount' => '50',
         'fee_amount' => '',
         'net_amount' => '50',
index c5be86b58c533827dc58c785417d907ae405136d..51bc8727f919d06702a455d7e6ae2f2c2f164790 100644 (file)
@@ -20,7 +20,8 @@ function payment_delete_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
index c56d91ec57c4e903ef08e36e2adef37918e97199..ac1263d504c3b8d011b736f7f42336b5bd9fa5e2 100644 (file)
@@ -20,7 +20,8 @@ function payment_get_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
index d240cbfe2eee316120e9ee92c578710b884b454e..81e017e22305fd9be504ec1ad2c03907fa4c5c27 100644 (file)
@@ -24,7 +24,8 @@ function payment_create_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
@@ -51,7 +52,7 @@ function payment_create_expectedresult() {
         'id' => '5',
         'from_financial_account_id' => '7',
         'to_financial_account_id' => '6',
-        'trxn_date' => '20160217204847',
+        'trxn_date' => '20170207024653',
         'total_amount' => '100',
         'fee_amount' => '',
         'net_amount' => '100',
index 7d911e279af55eaaf77a4baa58610b3edc190579..aa481f9fbcd397362314549aac5ea192cb1b4835 100644 (file)
@@ -52,7 +52,7 @@ function payment_processor_create_expectedresult() {
         'domain_id' => '1',
         'name' => 'API Test PP',
         'description' => '',
-        'payment_processor_type_id' => '18',
+        'payment_processor_type_id' => '1',
         'is_active' => '',
         'is_default' => 0,
         'is_test' => 0,
@@ -68,6 +68,8 @@ function payment_processor_create_expectedresult() {
         'billing_mode' => '1',
         'is_recur' => 0,
         'payment_type' => '1',
+        'payment_instrument_id' => '1',
+        'accepted_credit_cards' => '',
       ),
     ),
   );
index d726926a9a897916e339b398bb90b59929a711b5..a633f4c4bf006f43c06e16eabb55167f6ed84304 100644 (file)
@@ -19,7 +19,8 @@ function payment_processor_delete_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
@@ -40,7 +41,7 @@ function payment_processor_delete_expectedresult() {
     'is_error' => 0,
     'version' => 3,
     'count' => 1,
-    'values' => TRUE,
+    'values' => 1,
   );
 
   return $expectedResult;
index d7803ec4045fbc39c697a18c0844d4fe24b3f890..d6fc4c1e14323a5e968d814ff5d4953df61fa799 100644 (file)
@@ -24,7 +24,8 @@ function payment_processor_type_create_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
@@ -45,10 +46,10 @@ function payment_processor_type_create_expectedresult() {
     'is_error' => 0,
     'version' => 3,
     'count' => 1,
-    'id' => 15,
+    'id' => 13,
     'values' => array(
       '0' => array(
-        'id' => '15',
+        'id' => '13',
         'name' => 'API_Test_PP',
         'title' => 'API Test Payment Processor',
         'description' => '',
@@ -70,6 +71,7 @@ function payment_processor_type_create_expectedresult() {
         'billing_mode' => '1',
         'is_recur' => 0,
         'payment_type' => '',
+        'payment_instrument_id' => '1',
       ),
     ),
   );
index 49ac762dd3005e1627744f54fd92013cf2eabc53..d5a6c6d5b088ba18b2d62b670669ad737e61a194 100644 (file)
@@ -7,7 +7,7 @@
  */
 function payment_processor_type_delete_example() {
   $params = array(
-    'id' => 17,
+    'id' => 15,
   );
 
   try{
@@ -19,7 +19,8 @@ function payment_processor_type_delete_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
diff --git a/api/v3/examples/PaymentToken/Create.php b/api/v3/examples/PaymentToken/Create.php
new file mode 100644 (file)
index 0000000..854c185
--- /dev/null
@@ -0,0 +1,93 @@
+<?php
+/**
+ * Test Generated example demonstrating the PaymentToken.create API.
+ *
+ * Create a payment token - Note use of relative dates here:
+ * @link http://www.php.net/manual/en/datetime.formats.relative.php.
+ *
+ * @return array
+ *   API result array
+ */
+function payment_token_create_example() {
+  $params = array(
+    'token' => 'fancy-token-xxxx',
+    'contact_id' => 3,
+    'created_id' => 3,
+    'payment_processor_id' => 1,
+  );
+
+  try{
+    $result = civicrm_api3('PaymentToken', 'create', $params);
+  }
+  catch (CiviCRM_API3_Exception $e) {
+    // Handle error here.
+    $errorMessage = $e->getMessage();
+    $errorCode = $e->getErrorCode();
+    $errorData = $e->getExtraParams();
+    return array(
+      'is_error' => 1,
+      'error_message' => $errorMessage,
+      'error_code' => $errorCode,
+      'error_data' => $errorData,
+    );
+  }
+
+  return $result;
+}
+
+/**
+ * Function returns array of result expected from previous function.
+ *
+ * @return array
+ *   API result array
+ */
+function payment_token_create_expectedresult() {
+
+  $expectedResult = array(
+    'is_error' => 0,
+    'version' => 3,
+    'count' => 1,
+    'id' => 1,
+    'values' => array(
+      '1' => array(
+        'id' => '1',
+        'contact_id' => '3',
+        'payment_processor_id' => '1',
+        'token' => 'fancy-token-xxxx',
+        'created_date' => '2013-07-28 08:49:19',
+        'created_id' => '3',
+        'expiry_date' => '',
+        'email' => '',
+        'billing_first_name' => '',
+        'billing_middle_name' => '',
+        'billing_last_name' => '',
+        'masked_account_number' => '',
+        'ip_address' => '',
+      ),
+    ),
+  );
+
+  return $expectedResult;
+}
+
+/*
+* This example has been generated from the API test suite.
+* The test that created it is called "testCreatePaymentToken"
+* and can be found at:
+* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/PaymentTokenTest.php
+*
+* You can see the outcome of the API tests at
+* https://test.civicrm.org/job/CiviCRM-master-git/
+*
+* To Learn about the API read
+* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
+*
+* Browse the api on your own site with the api explorer
+* http://MYSITE.ORG/path/to/civicrm/api
+*
+* Read more about testing here
+* http://wiki.civicrm.org/confluence/display/CRM/Testing
+*
+* API Standards documentation:
+* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
+*/
diff --git a/api/v3/examples/PaymentToken/Delete.php b/api/v3/examples/PaymentToken/Delete.php
new file mode 100644 (file)
index 0000000..460d6ad
--- /dev/null
@@ -0,0 +1,70 @@
+<?php
+/**
+ * Test Generated example demonstrating the PaymentToken.delete API.
+ *
+ * @return array
+ *   API result array
+ */
+function payment_token_delete_example() {
+  $params = array(
+    'id' => 3,
+  );
+
+  try{
+    $result = civicrm_api3('PaymentToken', 'delete', $params);
+  }
+  catch (CiviCRM_API3_Exception $e) {
+    // Handle error here.
+    $errorMessage = $e->getMessage();
+    $errorCode = $e->getErrorCode();
+    $errorData = $e->getExtraParams();
+    return array(
+      'is_error' => 1,
+      'error_message' => $errorMessage,
+      'error_code' => $errorCode,
+      'error_data' => $errorData,
+    );
+  }
+
+  return $result;
+}
+
+/**
+ * Function returns array of result expected from previous function.
+ *
+ * @return array
+ *   API result array
+ */
+function payment_token_delete_expectedresult() {
+
+  $expectedResult = array(
+    'is_error' => 0,
+    'version' => 3,
+    'count' => 1,
+    'values' => 1,
+  );
+
+  return $expectedResult;
+}
+
+/*
+* This example has been generated from the API test suite.
+* The test that created it is called "testDeletePaymentToken"
+* and can be found at:
+* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/PaymentTokenTest.php
+*
+* You can see the outcome of the API tests at
+* https://test.civicrm.org/job/CiviCRM-master-git/
+*
+* To Learn about the API read
+* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
+*
+* Browse the api on your own site with the api explorer
+* http://MYSITE.ORG/path/to/civicrm/api
+*
+* Read more about testing here
+* http://wiki.civicrm.org/confluence/display/CRM/Testing
+*
+* API Standards documentation:
+* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
+*/
diff --git a/api/v3/examples/PaymentToken/Get.php b/api/v3/examples/PaymentToken/Get.php
new file mode 100644 (file)
index 0000000..101c847
--- /dev/null
@@ -0,0 +1,83 @@
+<?php
+/**
+ * Test Generated example demonstrating the PaymentToken.get API.
+ *
+ * @return array
+ *   API result array
+ */
+function payment_token_get_example() {
+  $params = array(
+    'token' => 'fancy-token-xxxx',
+    'contact_id' => 4,
+    'created_id' => 4,
+    'payment_processor_id' => 2,
+  );
+
+  try{
+    $result = civicrm_api3('PaymentToken', 'get', $params);
+  }
+  catch (CiviCRM_API3_Exception $e) {
+    // Handle error here.
+    $errorMessage = $e->getMessage();
+    $errorCode = $e->getErrorCode();
+    $errorData = $e->getExtraParams();
+    return array(
+      'is_error' => 1,
+      'error_message' => $errorMessage,
+      'error_code' => $errorCode,
+      'error_data' => $errorData,
+    );
+  }
+
+  return $result;
+}
+
+/**
+ * Function returns array of result expected from previous function.
+ *
+ * @return array
+ *   API result array
+ */
+function payment_token_get_expectedresult() {
+
+  $expectedResult = array(
+    'is_error' => 0,
+    'version' => 3,
+    'count' => 1,
+    'id' => 2,
+    'values' => array(
+      '2' => array(
+        'id' => '2',
+        'contact_id' => '4',
+        'payment_processor_id' => '2',
+        'token' => 'fancy-token-xxxx',
+        'created_date' => '2013-07-28 08:49:19',
+        'created_id' => '4',
+      ),
+    ),
+  );
+
+  return $expectedResult;
+}
+
+/*
+* This example has been generated from the API test suite.
+* The test that created it is called "testGetPaymentToken"
+* and can be found at:
+* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/PaymentTokenTest.php
+*
+* You can see the outcome of the API tests at
+* https://test.civicrm.org/job/CiviCRM-master-git/
+*
+* To Learn about the API read
+* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
+*
+* Browse the api on your own site with the api explorer
+* http://MYSITE.ORG/path/to/civicrm/api
+*
+* Read more about testing here
+* http://wiki.civicrm.org/confluence/display/CRM/Testing
+*
+* API Standards documentation:
+* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
+*/
diff --git a/api/v3/examples/Pcp/Create.php b/api/v3/examples/Pcp/Create.php
new file mode 100644 (file)
index 0000000..d3481c7
--- /dev/null
@@ -0,0 +1,93 @@
+<?php
+/**
+ * Test Generated example demonstrating the Pcp.create API.
+ *
+ * @return array
+ *   API result array
+ */
+function pcp_create_example() {
+  $params = array(
+    'title' => 'Pcp title',
+    'contact_id' => 1,
+    'page_id' => 1,
+    'pcp_block_id' => 1,
+  );
+
+  try{
+    $result = civicrm_api3('Pcp', 'create', $params);
+  }
+  catch (CiviCRM_API3_Exception $e) {
+    // Handle error here.
+    $errorMessage = $e->getMessage();
+    $errorCode = $e->getErrorCode();
+    $errorData = $e->getExtraParams();
+    return array(
+      'is_error' => 1,
+      'error_message' => $errorMessage,
+      'error_code' => $errorCode,
+      'error_data' => $errorData,
+    );
+  }
+
+  return $result;
+}
+
+/**
+ * Function returns array of result expected from previous function.
+ *
+ * @return array
+ *   API result array
+ */
+function pcp_create_expectedresult() {
+
+  $expectedResult = array(
+    'is_error' => 0,
+    'version' => 3,
+    'count' => 1,
+    'id' => 1,
+    'values' => array(
+      '1' => array(
+        'id' => '1',
+        'contact_id' => '1',
+        'status_id' => 0,
+        'title' => 'Pcp title',
+        'intro_text' => '',
+        'page_text' => '',
+        'donate_link_text' => '',
+        'page_id' => '1',
+        'page_type' => '',
+        'pcp_block_id' => '1',
+        'is_thermometer' => '',
+        'is_honor_roll' => '',
+        'goal_amount' => '',
+        'currency' => 'USD',
+        'is_active' => '',
+        'is_notify' => '',
+      ),
+    ),
+  );
+
+  return $expectedResult;
+}
+
+/*
+* This example has been generated from the API test suite.
+* The test that created it is called "testCreatePcp"
+* and can be found at:
+* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/PcpTest.php
+*
+* You can see the outcome of the API tests at
+* https://test.civicrm.org/job/CiviCRM-master-git/
+*
+* To Learn about the API read
+* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
+*
+* Browse the api on your own site with the api explorer
+* http://MYSITE.ORG/path/to/civicrm/api
+*
+* Read more about testing here
+* http://wiki.civicrm.org/confluence/display/CRM/Testing
+*
+* API Standards documentation:
+* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
+*/
index ea022ea735131d53387be7997a4fab973b8edeba..384cf28e1f37defa64bd7fb4e93b3cf7754441e2 100644 (file)
@@ -23,7 +23,8 @@ function phone_create_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
index 363998ab9b7f3efc6a5e9853b880be6f4d7699f9..6f4b97e22a1d4f9a0a9074e018c0c8107cf1f7c7 100644 (file)
@@ -19,7 +19,8 @@ function phone_delete_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
@@ -40,7 +41,7 @@ function phone_delete_expectedresult() {
     'is_error' => 0,
     'version' => 3,
     'count' => 1,
-    'values' => TRUE,
+    'values' => 1,
   );
 
   return $expectedResult;
index f22274d9e26c9a0a7e01d05467b03a4d12345444..ef1a0794c99ec2cf00eab81a3431ff1b55bf0cb7 100644 (file)
@@ -20,7 +20,8 @@ function phone_get_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
index 6bd0f386de0fa040e591dd1b447249e97794ae6b..c138d72251f16e01095c8a799c782919ce9c314c 100644 (file)
@@ -8,9 +8,9 @@
 function pledge_create_example() {
   $params = array(
     'contact_id' => 11,
-    'pledge_create_date' => '20150222',
-    'start_date' => '20150222',
-    'scheduled_date' => '20150224',
+    'pledge_create_date' => '20170207',
+    'start_date' => '20170207',
+    'scheduled_date' => '20170209',
     'amount' => '100',
     'pledge_status_id' => '2',
     'pledge_financial_type_id' => '1',
@@ -31,7 +31,8 @@ function pledge_create_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
index 02b53fdf620f783aec3ed57c8d74af151c7f21ab..17e4780458af390a30fb4581df9818b3236ae4a0 100644 (file)
@@ -19,7 +19,8 @@ function pledge_delete_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
index 0ac2a326450f79833a3cb0ebca89bcc257651445..541ca67466de09e863d195f6d3e7474cb21f2e09 100644 (file)
@@ -19,7 +19,8 @@ function pledge_get_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
@@ -50,10 +51,11 @@ function pledge_get_expectedresult() {
         'display_name' => 'Mr. Anthony Anderson II',
         'pledge_id' => '1',
         'pledge_amount' => '100.00',
-        'pledge_create_date' => '2015-02-22 00:00:00',
+        'pledge_create_date' => '2017-02-07 00:00:00',
+        'pledge_start_date' => '2017-02-07 00:00:00',
         'pledge_status' => 'Pending',
         'pledge_total_paid' => '',
-        'pledge_next_pay_date' => '2015-02-24 00:00:00',
+        'pledge_next_pay_date' => '2017-02-09 00:00:00',
         'pledge_next_pay_amount' => '20.00',
         'pledge_outstanding_amount' => '',
         'pledge_financial_type' => 'Donation',
index 6e52589e8e42deded9492fd88a52f2201a8d7453..64b6b3ce57cb3622a6b47d183c8616405e4cdcf9 100644 (file)
@@ -9,7 +9,7 @@
  */
 function pledge_get_example() {
   $params = array(
-    'pledge_start_date_high' => '20150220231942',
+    'pledge_start_date_high' => '20170205024740',
   );
 
   try{
@@ -21,7 +21,8 @@ function pledge_get_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
@@ -52,10 +53,11 @@ function pledge_get_expectedresult() {
         'display_name' => 'Mr. Anthony Anderson II',
         'pledge_id' => '2',
         'pledge_amount' => '100.00',
-        'pledge_create_date' => '2015-02-22 00:00:00',
+        'pledge_create_date' => '2017-02-07 00:00:00',
+        'pledge_start_date' => '2016-03-04 00:00:00',
         'pledge_status' => 'Overdue',
         'pledge_total_paid' => '',
-        'pledge_next_pay_date' => '2014-03-07 00:00:00',
+        'pledge_next_pay_date' => '2016-03-04 00:00:00',
         'pledge_next_pay_amount' => '20.00',
         'pledge_outstanding_amount' => '20.00',
         'pledge_financial_type' => 'Donation',
index 1e8c21e3eb43c79fe0bf6d18dd8e3c96ac03b3dd..bfbe8f64fae1d27527871097958389d6516da0b8 100644 (file)
@@ -23,7 +23,8 @@ function pledge_payment_create_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
index d54893ba45d6583ff0144f8a445fabdf82a0c32d..3a0faa1372ca119e23133559131bd162cc206eca 100644 (file)
@@ -19,7 +19,8 @@ function pledge_payment_delete_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
index 17f2e27c273eb420003f010764d82a80374ca2e0..20018f0088111dc0855e63abf7832b404da7bea4 100644 (file)
@@ -17,7 +17,8 @@ function pledge_payment_get_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
index eaa3178ceec6a37964d698d00b1628b540bef958..202ba48ac89dbc8270998c51c9d9c97e9dcfdbd2 100644 (file)
@@ -20,7 +20,8 @@ function pledge_payment_update_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
index 8339479cb382acf2701b24191ebeef8971439f98..054a7a65fb87eebe78a52d768eac2ac6015da35b 100644 (file)
@@ -24,7 +24,8 @@ function price_field_create_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
index 3d23332a4471d8ee0fdbb2fafbda8848ee2c92b2..2e1f037fffde7bb85841ff27105a2a3f127d5049 100644 (file)
@@ -19,7 +19,8 @@ function price_field_delete_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
index 953f6d195752075f3eed74defce60d8c0e78a480..c3da7002da476e75372af93c4c339f012efec66c 100644 (file)
@@ -19,7 +19,8 @@ function price_field_get_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
index 567c0b9d06d6f815b5faa1bb228bab6df82c8909..a833aa785e7c5354a7e643947016fa37ced3426e 100644 (file)
@@ -26,7 +26,8 @@ function price_field_value_create_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
@@ -55,6 +56,8 @@ function price_field_value_create_expectedresult() {
         'name' => 'memType1',
         'label' => 'memType1',
         'description' => '',
+        'help_pre' => '',
+        'help_post' => '',
         'amount' => '90',
         'count' => '',
         'max_value' => '',
@@ -64,7 +67,7 @@ function price_field_value_create_expectedresult() {
         'is_default' => '',
         'is_active' => '1',
         'financial_type_id' => '2',
-        'deductible_amount' => '',
+        'non_deductible_amount' => '',
         'contribution_type_id' => '2',
       ),
     ),
index 1eb72a66d3b87470416eb2341d20a4584eb4fb23..084aac721b9d33705fba005d38b7272bb3500fe4 100644 (file)
@@ -19,7 +19,8 @@ function price_field_value_delete_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
@@ -40,7 +41,7 @@ function price_field_value_delete_expectedresult() {
     'is_error' => 0,
     'version' => 3,
     'count' => 1,
-    'values' => TRUE,
+    'values' => 1,
   );
 
   return $expectedResult;
index 1944cde832a0ca12509e728bf64dde60a628a0ad..9443533d1c075653b9fd551ad9ab05869f908723 100644 (file)
@@ -19,7 +19,8 @@ function price_field_value_get_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
@@ -52,7 +53,8 @@ function price_field_value_get_expectedresult() {
         'is_default' => 0,
         'is_active' => '1',
         'financial_type_id' => '1',
-        'deductible_amount' => '0.00',
+        'non_deductible_amount' => '0.00',
+        'contribution_type_id' => '1',
       ),
     ),
   );
index 52734d083ed64193fbad3cfbb79d878f78611ffa..bf801c3eac02522d8d03b1a16bcda4e5ebf50264 100644 (file)
@@ -23,7 +23,8 @@ function price_set_create_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
@@ -59,6 +60,7 @@ function price_set_create_expectedresult() {
         'financial_type_id' => '',
         'is_quick_config' => '',
         'is_reserved' => '',
+        'min_amount' => '',
       ),
     ),
   );
index 5360087383ff66d2ead599b7ea5573966d21d6cc..3929b96906d51f9f119b094d45ca1ccf0f658af8 100644 (file)
@@ -19,7 +19,8 @@ function price_set_delete_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
index b5468e8277c4500fe50ef7ec387a6152a6af5813..7be052caa0e62fb15a2b904cd49c82608fea3abb 100644 (file)
@@ -19,7 +19,8 @@ function price_set_get_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
@@ -50,6 +51,7 @@ function price_set_get_expectedresult() {
         'extends' => '2',
         'is_quick_config' => '1',
         'is_reserved' => '1',
+        'min_amount' => 0,
         'entity' => array(),
       ),
     ),
index 60c8da1e7e5c8d34d88a6401c3c631e8a21e359c..57b867c4d3334dd4f238178107e1de1512d08c1d 100644 (file)
@@ -26,7 +26,8 @@ function profile_apply_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
index 415ba5cde918ec9a56babfdca4099a1042f96599..9a34012a834765680ba3f7c8322eef3a1158837c 100644 (file)
@@ -24,7 +24,8 @@ function profile_get_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
index 81ec33c5c64501febca9cf5c20950085d8d796d3..48b62cee421c8b890b37e51421dec723af0bcb2c 100644 (file)
@@ -22,7 +22,8 @@ function profile_getfields_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
@@ -63,6 +64,8 @@ function profile_getfields_expectedresult() {
         'date_format' => '',
         'time_format' => '',
         'is_required' => 0,
+        'table_name' => 'civicrm_value__addcustomfie_1',
+        'column_name' => '_addcustomfieldtoprofile_1',
         'name' => 'custom_1',
         'title' => 'first_name',
         'type' => 2,
@@ -77,17 +80,25 @@ function profile_getfields_expectedresult() {
         'name' => 'postal_code',
         'type' => 2,
         'title' => 'State Province',
-        'maxlength' => 12,
-        'size' => 12,
+        'description' => 'Store both US (zip5) AND international postal codes. App is responsible for country/region appropriate validation.',
+        'maxlength' => 64,
+        'size' => 6,
         'import' => TRUE,
         'where' => 'civicrm_address.postal_code',
         'headerPattern' => '/postal|zip/i',
         'dataPattern' => '/\\d?\\d{4}(-\\d{4})?/',
         'export' => TRUE,
+        'table_name' => 'civicrm_address',
+        'entity' => 'address',
+        'bao' => 'CRM_Core_BAO_Address',
+        'html' => array(
+          'type' => 'Text',
+          'maxlength' => 64,
+          'size' => 6,
+        ),
         'api.required' => 0,
         'help_pre' => '',
         'help_post' => '',
-        'entity' => 'address',
         'weight' => '2',
         'api.aliases' => array(),
       ),
@@ -95,9 +106,15 @@ function profile_getfields_expectedresult() {
         'name' => 'state_province_id',
         'type' => 1,
         'title' => 'State Province',
+        'description' => 'Which State_Province does this address belong to.',
+        'table_name' => 'civicrm_address',
+        'entity' => 'address',
+        'bao' => 'CRM_Core_BAO_Address',
         'FKClassName' => 'CRM_Core_DAO_StateProvince',
         'html' => array(
-          'type' => 'Select',
+          'type' => 'ChainSelect',
+          'size' => 6,
+          'maxlength' => 14,
         ),
         'pseudoconstant' => array(
           'table' => 'civicrm_state_province',
@@ -108,7 +125,6 @@ function profile_getfields_expectedresult() {
         'api.required' => '1',
         'help_pre' => '',
         'help_post' => '',
-        'entity' => 'address',
         'weight' => '3',
         'api.aliases' => array(),
       ),
@@ -116,9 +132,15 @@ function profile_getfields_expectedresult() {
         'name' => 'country_id',
         'type' => 1,
         'title' => 'Country',
+        'description' => 'Which Country does this address belong to.',
+        'table_name' => 'civicrm_address',
+        'entity' => 'address',
+        'bao' => 'CRM_Core_BAO_Address',
         'FKClassName' => 'CRM_Core_DAO_Country',
         'html' => array(
           'type' => 'Select',
+          'size' => 6,
+          'maxlength' => 14,
         ),
         'pseudoconstant' => array(
           'table' => 'civicrm_country',
@@ -130,7 +152,6 @@ function profile_getfields_expectedresult() {
         'api.required' => '1',
         'help_pre' => '',
         'help_post' => '',
-        'entity' => 'address',
         'weight' => '4',
         'api.aliases' => array(),
       ),
@@ -138,6 +159,7 @@ function profile_getfields_expectedresult() {
         'name' => 'phone',
         'type' => 2,
         'title' => 'Phone',
+        'description' => 'Complete phone number.',
         'maxlength' => 32,
         'size' => 20,
         'import' => TRUE,
@@ -145,10 +167,17 @@ function profile_getfields_expectedresult() {
         'headerPattern' => '/phone/i',
         'dataPattern' => '/^[\\d\\(\\)\\-\\.\\s]+$/',
         'export' => TRUE,
+        'table_name' => 'civicrm_phone',
+        'entity' => 'phone',
+        'bao' => 'CRM_Core_BAO_Phone',
+        'html' => array(
+          'type' => 'Text',
+          'maxlength' => 32,
+          'size' => 20,
+        ),
         'api.required' => '1',
         'help_pre' => '',
         'help_post' => '',
-        'entity' => 'phone',
         'weight' => '5',
         'api.aliases' => array(),
       ),
@@ -156,21 +185,26 @@ function profile_getfields_expectedresult() {
         'name' => 'email',
         'type' => 2,
         'title' => 'Email',
+        'description' => 'Email address',
         'maxlength' => 254,
-        'size' => 20,
+        'size' => 30,
         'import' => TRUE,
         'where' => 'civicrm_email.email',
         'headerPattern' => '/e.?mail/i',
         'dataPattern' => '/^[a-zA-Z][\\w\\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\\w\\.-]*[a-zA-Z0-9]\\.[a-zA-Z][a-zA-Z\\.]*[a-zA-Z]$/',
         'export' => TRUE,
         'rule' => 'email',
+        'table_name' => 'civicrm_email',
+        'entity' => 'email',
+        'bao' => 'CRM_Core_BAO_Email',
         'html' => array(
           'type' => 'Text',
+          'maxlength' => 254,
+          'size' => 30,
         ),
         'api.required' => '1',
         'help_pre' => '',
         'help_post' => '',
-        'entity' => 'email',
         'weight' => '6',
         'api.aliases' => array(
           '0' => 'email-Primary',
@@ -180,6 +214,7 @@ function profile_getfields_expectedresult() {
         'name' => 'last_name',
         'type' => 2,
         'title' => 'Last Name',
+        'description' => 'Last Name.',
         'maxlength' => 64,
         'size' => 30,
         'import' => TRUE,
@@ -187,13 +222,17 @@ function profile_getfields_expectedresult() {
         'headerPattern' => '/^last|(l(ast\\s)?name)$/i',
         'dataPattern' => '/^\\w+(\\s\\w+)?+$/',
         'export' => TRUE,
+        'table_name' => 'civicrm_contact',
+        'entity' => 'contact',
+        'bao' => 'CRM_Contact_BAO_Contact',
         'html' => array(
           'type' => 'Text',
+          'maxlength' => 64,
+          'size' => 30,
         ),
         'api.required' => '1',
         'help_pre' => '',
         'help_post' => '',
-        'entity' => 'contact',
         'weight' => '7',
         'api.aliases' => array(),
       ),
@@ -201,6 +240,7 @@ function profile_getfields_expectedresult() {
         'name' => 'first_name',
         'type' => 2,
         'title' => 'First Name',
+        'description' => 'First Name.',
         'maxlength' => 64,
         'size' => 30,
         'import' => TRUE,
@@ -208,13 +248,17 @@ function profile_getfields_expectedresult() {
         'headerPattern' => '/^first|(f(irst\\s)?name)$/i',
         'dataPattern' => '/^\\w+$/',
         'export' => TRUE,
+        'table_name' => 'civicrm_contact',
+        'entity' => 'contact',
+        'bao' => 'CRM_Contact_BAO_Contact',
         'html' => array(
           'type' => 'Text',
+          'maxlength' => 64,
+          'size' => 30,
         ),
         'api.required' => '1',
         'help_pre' => '',
         'help_post' => '',
-        'entity' => 'contact',
         'weight' => '8',
         'api.aliases' => array(),
       ),
index 03c6ef75d730991d92f831a32ed1d26e3b0c3052..a8b26e325c92ab743a0c4e343a55c140edb2d7ad 100644 (file)
@@ -26,7 +26,8 @@ function profile_submit_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
index 2a04935a837e26e50e985805d54efe21507f6d3f..d7dfa39ddd96d86b634df63f2c4e75b87370170a 100644 (file)
@@ -11,8 +11,8 @@ function relationship_get_example() {
   $params = array(
     'relationship_type_id' => array(
       'BETWEEN' => array(
-        '0' => 33,
-        '1' => 35,
+        '0' => 36,
+        '1' => 38,
       ),
     ),
   );
@@ -26,7 +26,8 @@ function relationship_get_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
@@ -50,34 +51,31 @@ function relationship_get_expectedresult() {
     'values' => array(
       '2' => array(
         'id' => '2',
-        'contact_id_a' => '87',
-        'contact_id_b' => '89',
-        'relationship_type_id' => '33',
+        'contact_id_a' => '99',
+        'contact_id_b' => '101',
+        'relationship_type_id' => '36',
         'start_date' => '2013-07-29 00:00:00',
         'is_active' => '1',
-        'description' => '',
         'is_permission_a_b' => 0,
         'is_permission_b_a' => 0,
       ),
       '3' => array(
         'id' => '3',
-        'contact_id_a' => '87',
-        'contact_id_b' => '89',
-        'relationship_type_id' => '34',
+        'contact_id_a' => '99',
+        'contact_id_b' => '101',
+        'relationship_type_id' => '37',
         'start_date' => '2013-07-29 00:00:00',
         'is_active' => '1',
-        'description' => '',
         'is_permission_a_b' => 0,
         'is_permission_b_a' => 0,
       ),
       '4' => array(
         'id' => '4',
-        'contact_id_a' => '87',
-        'contact_id_b' => '89',
-        'relationship_type_id' => '35',
+        'contact_id_a' => '99',
+        'contact_id_b' => '101',
+        'relationship_type_id' => '38',
         'start_date' => '2013-07-29 00:00:00',
         'is_active' => '1',
-        'description' => '',
         'is_permission_a_b' => 0,
         'is_permission_b_a' => 0,
       ),
index 1c4c1586f189e044104d5a22bcce162412284620..1978de2bde515f2de131aac8e25aa3c7fb295c42 100644 (file)
@@ -25,7 +25,8 @@ function relationship_create_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
index 1e8cafd512ec553a51106e49fbd556a95f3c25e6..74e4ffc30211eb479fa5d9553adff115f2ed3ec3 100644 (file)
@@ -19,7 +19,8 @@ function relationship_delete_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
index b1a865ccb105b5e123f2811629446e64f8d66427..9d21e1f7812408479a8596e3c0eaa6183199a110 100644 (file)
@@ -19,7 +19,8 @@ function relationship_get_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
@@ -49,7 +50,6 @@ function relationship_get_expectedresult() {
         'relationship_type_id' => '22',
         'start_date' => '2013-07-29 00:00:00',
         'is_active' => '1',
-        'description' => '',
         'is_permission_a_b' => 0,
         'is_permission_b_a' => 0,
         'custom_1' => 'custom string',
index afbd42c46594946d19139819316f590e16b26a6e..3a907c0f1a27ba4575a28d3ca72e563f28cfd5de 100644 (file)
@@ -11,8 +11,8 @@ function relationship_get_example() {
   $params = array(
     'relationship_type_id' => array(
       'IN' => array(
-        '0' => 33,
-        '1' => 34,
+        '0' => 36,
+        '1' => 37,
       ),
     ),
   );
@@ -26,7 +26,8 @@ function relationship_get_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
@@ -50,23 +51,21 @@ function relationship_get_expectedresult() {
     'values' => array(
       '2' => array(
         'id' => '2',
-        'contact_id_a' => '87',
-        'contact_id_b' => '89',
-        'relationship_type_id' => '33',
+        'contact_id_a' => '99',
+        'contact_id_b' => '101',
+        'relationship_type_id' => '36',
         'start_date' => '2013-07-29 00:00:00',
         'is_active' => '1',
-        'description' => '',
         'is_permission_a_b' => 0,
         'is_permission_b_a' => 0,
       ),
       '3' => array(
         'id' => '3',
-        'contact_id_a' => '87',
-        'contact_id_b' => '89',
-        'relationship_type_id' => '34',
+        'contact_id_a' => '99',
+        'contact_id_b' => '101',
+        'relationship_type_id' => '37',
         'start_date' => '2013-07-29 00:00:00',
         'is_active' => '1',
-        'description' => '',
         'is_permission_a_b' => 0,
         'is_permission_b_a' => 0,
       ),
index 091ea47cec2bedfc8d8cd4bf47e0fcaee3df4f6d..31a8a7345443d2c6d1e77244897b1e26874b2871 100644 (file)
@@ -11,8 +11,8 @@ function relationship_get_example() {
   $params = array(
     'relationship_type_id' => array(
       'NOT BETWEEN' => array(
-        '0' => 33,
-        '1' => 35,
+        '0' => 36,
+        '1' => 38,
       ),
     ),
   );
@@ -26,7 +26,8 @@ function relationship_get_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
@@ -51,12 +52,11 @@ function relationship_get_expectedresult() {
     'values' => array(
       '1' => array(
         'id' => '1',
-        'contact_id_a' => '87',
-        'contact_id_b' => '89',
-        'relationship_type_id' => '32',
+        'contact_id_a' => '99',
+        'contact_id_b' => '101',
+        'relationship_type_id' => '35',
         'start_date' => '2013-07-29 00:00:00',
         'is_active' => '1',
-        'description' => '',
         'is_permission_a_b' => 0,
         'is_permission_b_a' => 0,
       ),
index 024c3952e869162d00e4f06690d9aac1d359dc88..5e77fe8b30c0f6d7629aa45bf261f611aaa545f1 100644 (file)
@@ -11,8 +11,8 @@ function relationship_get_example() {
   $params = array(
     'relationship_type_id' => array(
       'NOT IN' => array(
-        '0' => 33,
-        '1' => 34,
+        '0' => 36,
+        '1' => 37,
       ),
     ),
   );
@@ -26,7 +26,8 @@ function relationship_get_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
@@ -50,23 +51,21 @@ function relationship_get_expectedresult() {
     'values' => array(
       '1' => array(
         'id' => '1',
-        'contact_id_a' => '87',
-        'contact_id_b' => '89',
-        'relationship_type_id' => '32',
+        'contact_id_a' => '99',
+        'contact_id_b' => '101',
+        'relationship_type_id' => '35',
         'start_date' => '2013-07-29 00:00:00',
         'is_active' => '1',
-        'description' => '',
         'is_permission_a_b' => 0,
         'is_permission_b_a' => 0,
       ),
       '4' => array(
         'id' => '4',
-        'contact_id_a' => '87',
-        'contact_id_b' => '89',
-        'relationship_type_id' => '35',
+        'contact_id_a' => '99',
+        'contact_id_b' => '101',
+        'relationship_type_id' => '38',
         'start_date' => '2013-07-29 00:00:00',
         'is_active' => '1',
-        'description' => '',
         'is_permission_a_b' => 0,
         'is_permission_b_a' => 0,
       ),
index d12bccc3f97204dc54295f0db79234e7099510a5..c4aee7a37ae389b2a81181e3745ba9a70d6324f9 100644 (file)
@@ -23,7 +23,8 @@ function relationship_get_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
@@ -48,12 +49,11 @@ function relationship_get_expectedresult() {
     'values' => array(
       '2' => array(
         'id' => '2',
-        'contact_id_a' => '83',
-        'contact_id_b' => '85',
-        'relationship_type_id' => '31',
+        'contact_id_a' => '95',
+        'contact_id_b' => '97',
+        'relationship_type_id' => '34',
         'start_date' => '2013-07-29 00:00:00',
         'is_active' => '1',
-        'description' => '',
         'is_permission_a_b' => 0,
         'is_permission_b_a' => 0,
       ),
index 2d458c4dbf02e1cb1c41051399e614a8c704266d..42826f114c59de16ff01686fe3dfdd8fdc774470 100644 (file)
@@ -25,7 +25,8 @@ function relationship_type_create_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
index 6b1dd50373021ab1bcdcee64d14db5a7a3557ed6..d331378cdc9f95633737dad61686ff581a444e37 100644 (file)
@@ -19,7 +19,8 @@ function relationship_type_delete_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
@@ -40,7 +41,7 @@ function relationship_type_delete_expectedresult() {
     'is_error' => 0,
     'version' => 3,
     'count' => 1,
-    'values' => TRUE,
+    'values' => 1,
   );
 
   return $expectedResult;
index 8c790439fd8ade252affc0773d26f05b1687cd0d..25dc1d5fc6b40a18c9ad89e0dd0581833e09fb97 100644 (file)
@@ -27,7 +27,8 @@ function report_template_getrows_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
@@ -50,16 +51,16 @@ function report_template_getrows_expectedresult() {
     'count' => 2,
     'values' => array(
       '0' => array(
-        'civicrm_contact_sort_name' => 'Default Organization',
-        'civicrm_contact_id' => '1',
-        'civicrm_contact_sort_name_link' => '/index.php?q=civicrm/report/contact/detail&amp;reset=1&amp;force=1&amp;id_op=eq&amp;id_value=1',
-        'civicrm_contact_sort_name_hover' => 'View Constituent Detail Report for this contact.',
-      ),
-      '1' => array(
         'civicrm_contact_sort_name' => 'Second Domain',
         'civicrm_contact_id' => '2',
         'civicrm_contact_sort_name_link' => '/index.php?q=civicrm/report/contact/detail&amp;reset=1&amp;force=1&amp;id_op=eq&amp;id_value=2',
-        'civicrm_contact_sort_name_hover' => 'View Constituent Detail Report for this contact.',
+        'civicrm_contact_sort_name_hover' => 'View Contact Detail Report for this contact',
+      ),
+      '1' => array(
+        'civicrm_contact_sort_name' => 'Unit Test Organization',
+        'civicrm_contact_id' => '1',
+        'civicrm_contact_sort_name_link' => '/index.php?q=civicrm/report/contact/detail&amp;reset=1&amp;force=1&amp;id_op=eq&amp;id_value=1',
+        'civicrm_contact_sort_name_hover' => 'View Contact Detail Report for this contact',
       ),
     ),
     'metadata' => array(
index bc98a485fe3b9c526b77a2faee029a6085eeff8a..d9c9dc340c8941dfd0dc4075e7aec36069967153 100644 (file)
@@ -9,7 +9,7 @@
  */
 function report_template_getstatistics_example() {
   $params = array(
-    'report_id' => 'contribute/recursummary',
+    'report_id' => 'contribute/deferredrevenue',
   );
 
   try{
@@ -21,7 +21,8 @@ function report_template_getstatistics_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
@@ -41,16 +42,8 @@ function report_template_getstatistics_expectedresult() {
   $expectedResult = array(
     'is_error' => 0,
     'version' => 3,
-    'count' => 1,
-    'id' => 'counts',
-    'values' => array(
-      'counts' => array(
-        'rowCount' => array(
-          'title' => 'Row(s) Listed',
-          'value' => 0,
-        ),
-      ),
-    ),
+    'count' => 0,
+    'values' => '',
   );
 
   return $expectedResult;
diff --git a/api/v3/examples/SavedSearch/Create.php b/api/v3/examples/SavedSearch/Create.php
new file mode 100644 (file)
index 0000000..31d677d
--- /dev/null
@@ -0,0 +1,127 @@
+<?php
+/**
+ * Test Generated example demonstrating the SavedSearch.create API.
+ *
+ * @return array
+ *   API result array
+ */
+function saved_search_create_example() {
+  $params = array(
+    'form_values' => array(
+      'relation_type_id' => '6_a_b',
+      'relation_target_name' => 'Default Organization',
+    ),
+    'api.Group.create' => array(
+      'name' => 'my_smartgroup',
+      'title' => 'my smartgroup',
+      'description' => 'Volunteers for the default organization',
+      'saved_search_id' => '$value.id',
+      'is_active' => 1,
+      'visibility' => 'User and User Admin Only',
+      'is_hidden' => 0,
+      'is_reserved' => 0,
+    ),
+  );
+
+  try{
+    $result = civicrm_api3('SavedSearch', 'create', $params);
+  }
+  catch (CiviCRM_API3_Exception $e) {
+    // Handle error here.
+    $errorMessage = $e->getMessage();
+    $errorCode = $e->getErrorCode();
+    $errorData = $e->getExtraParams();
+    return array(
+      'is_error' => 1,
+      'error_message' => $errorMessage,
+      'error_code' => $errorCode,
+      'error_data' => $errorData,
+    );
+  }
+
+  return $result;
+}
+
+/**
+ * Function returns array of result expected from previous function.
+ *
+ * @return array
+ *   API result array
+ */
+function saved_search_create_expectedresult() {
+
+  $expectedResult = array(
+    'is_error' => 0,
+    'version' => 3,
+    'count' => 1,
+    'id' => 3,
+    'values' => array(
+      '3' => array(
+        'id' => '3',
+        'form_values' => array(
+          'relation_type_id' => '6_a_b',
+          'relation_target_name' => 'Default Organization',
+        ),
+        'mapping_id' => '',
+        'search_custom_id' => '',
+        'where_clause' => '',
+        'select_tables' => '',
+        'where_tables' => '',
+        'api.Group.create' => array(
+          'is_error' => 0,
+          'version' => 3,
+          'count' => 1,
+          'id' => 1,
+          'values' => array(
+            '0' => array(
+              'id' => '1',
+              'name' => 'my_smartgroup',
+              'title' => 'my smartgroup',
+              'description' => 'Volunteers for the default organization',
+              'source' => '',
+              'saved_search_id' => '3',
+              'is_active' => '1',
+              'visibility' => 'User and User Admin Only',
+              'where_clause' => ' (  ( `civicrm_group_contact_cache_1`.group_id IN (\"1\") )  ) ',
+              'select_tables' => 'a:8:{s:15:\"civicrm_contact\";i:1;s:15:\"civicrm_address\";i:1;s:15:\"civicrm_country\";i:1;s:13:\"civicrm_email\";i:1;s:13:\"civicrm_phone\";i:1;s:10:\"civicrm_im\";i:1;s:19:\"civicrm_worldregion\";i:1;s:31:\"`civicrm_group_contact_cache_1`\";s:132:\" LEFT JOIN civicrm_group_contact_cache `civicrm_group_contact_cache_1` ON contact_a.id = `civicrm_group_contact_cache_1`.contact_id \";}',
+              'where_tables' => 'a:2:{s:15:\"civicrm_contact\";i:1;s:31:\"`civicrm_group_contact_cache_1`\";s:132:\" LEFT JOIN civicrm_group_contact_cache `civicrm_group_contact_cache_1` ON contact_a.id = `civicrm_group_contact_cache_1`.contact_id \";}',
+              'group_type' => '',
+              'cache_date' => '',
+              'refresh_date' => '',
+              'parents' => '',
+              'children' => '',
+              'is_hidden' => 0,
+              'is_reserved' => 0,
+              'created_id' => '',
+              'modified_id' => '',
+            ),
+          ),
+        ),
+      ),
+    ),
+  );
+
+  return $expectedResult;
+}
+
+/*
+* This example has been generated from the API test suite.
+* The test that created it is called "testCreateSavedSearchWithSmartGroup"
+* and can be found at:
+* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/SavedSearchTest.php
+*
+* You can see the outcome of the API tests at
+* https://test.civicrm.org/job/CiviCRM-master-git/
+*
+* To Learn about the API read
+* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
+*
+* Browse the api on your own site with the api explorer
+* http://MYSITE.ORG/path/to/civicrm/api
+*
+* Read more about testing here
+* http://wiki.civicrm.org/confluence/display/CRM/Testing
+*
+* API Standards documentation:
+* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
+*/
diff --git a/api/v3/examples/SavedSearch/Delete.php b/api/v3/examples/SavedSearch/Delete.php
new file mode 100644 (file)
index 0000000..3d0052b
--- /dev/null
@@ -0,0 +1,70 @@
+<?php
+/**
+ * Test Generated example demonstrating the SavedSearch.delete API.
+ *
+ * @return array
+ *   API result array
+ */
+function saved_search_delete_example() {
+  $params = array(
+    'id' => 4,
+  );
+
+  try{
+    $result = civicrm_api3('SavedSearch', 'delete', $params);
+  }
+  catch (CiviCRM_API3_Exception $e) {
+    // Handle error here.
+    $errorMessage = $e->getMessage();
+    $errorCode = $e->getErrorCode();
+    $errorData = $e->getExtraParams();
+    return array(
+      'is_error' => 1,
+      'error_message' => $errorMessage,
+      'error_code' => $errorCode,
+      'error_data' => $errorData,
+    );
+  }
+
+  return $result;
+}
+
+/**
+ * Function returns array of result expected from previous function.
+ *
+ * @return array
+ *   API result array
+ */
+function saved_search_delete_expectedresult() {
+
+  $expectedResult = array(
+    'is_error' => 0,
+    'version' => 3,
+    'count' => 1,
+    'values' => 1,
+  );
+
+  return $expectedResult;
+}
+
+/*
+* This example has been generated from the API test suite.
+* The test that created it is called "testDeleteSavedSearch"
+* and can be found at:
+* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/SavedSearchTest.php
+*
+* You can see the outcome of the API tests at
+* https://test.civicrm.org/job/CiviCRM-master-git/
+*
+* To Learn about the API read
+* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
+*
+* Browse the api on your own site with the api explorer
+* http://MYSITE.ORG/path/to/civicrm/api
+*
+* Read more about testing here
+* http://wiki.civicrm.org/confluence/display/CRM/Testing
+*
+* API Standards documentation:
+* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
+*/
diff --git a/api/v3/examples/SavedSearch/Get.php b/api/v3/examples/SavedSearch/Get.php
new file mode 100644 (file)
index 0000000..14adb3a
--- /dev/null
@@ -0,0 +1,79 @@
+<?php
+/**
+ * Test Generated example demonstrating the SavedSearch.get API.
+ *
+ * @return array
+ *   API result array
+ */
+function saved_search_get_example() {
+  $params = array(
+    'id' => 2,
+  );
+
+  try{
+    $result = civicrm_api3('SavedSearch', 'get', $params);
+  }
+  catch (CiviCRM_API3_Exception $e) {
+    // Handle error here.
+    $errorMessage = $e->getMessage();
+    $errorCode = $e->getErrorCode();
+    $errorData = $e->getExtraParams();
+    return array(
+      'is_error' => 1,
+      'error_message' => $errorMessage,
+      'error_code' => $errorCode,
+      'error_data' => $errorData,
+    );
+  }
+
+  return $result;
+}
+
+/**
+ * Function returns array of result expected from previous function.
+ *
+ * @return array
+ *   API result array
+ */
+function saved_search_get_expectedresult() {
+
+  $expectedResult = array(
+    'is_error' => 0,
+    'version' => 3,
+    'count' => 1,
+    'id' => 2,
+    'values' => array(
+      '2' => array(
+        'id' => '2',
+        'form_values' => array(
+          'relation_type_id' => '6_a_b',
+          'relation_target_name' => 'Default Organization',
+        ),
+      ),
+    ),
+  );
+
+  return $expectedResult;
+}
+
+/*
+* This example has been generated from the API test suite.
+* The test that created it is called "testCreateAndGetSavedSearch"
+* and can be found at:
+* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/SavedSearchTest.php
+*
+* You can see the outcome of the API tests at
+* https://test.civicrm.org/job/CiviCRM-master-git/
+*
+* To Learn about the API read
+* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
+*
+* Browse the api on your own site with the api explorer
+* http://MYSITE.ORG/path/to/civicrm/api
+*
+* Read more about testing here
+* http://wiki.civicrm.org/confluence/display/CRM/Testing
+*
+* API Standards documentation:
+* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
+*/
index 466890049cfd068a2b8245e18d50d3fac2571339..3f92f961375dac70c2befd52751274a93682f82b 100644 (file)
@@ -20,7 +20,8 @@ function setting_create_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
index ec2115963355a78e42cc667429417a3ae23d63c0..37a4d5efc4b86e3a81666bcc3a935a3b7800d80f 100644 (file)
@@ -22,7 +22,8 @@ function setting_create_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
index a43b968efca8e906075ad68f3aae67b5198c306b..c0e189dcb2fa1c02e4459b203a22292892b72762 100644 (file)
@@ -21,7 +21,8 @@ function setting_create_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
index e889f6c3a070346c726bfbd92d044b7737ca0986..a54f24ab94976f8d2debb7adba08be2454b1328e 100644 (file)
@@ -25,7 +25,8 @@ function setting_create_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
index 270c1e5e5484132d0a8da230a5b11cf2db02d2b9..522fb14a8e2b157d8bc3a9236b32d3f9f4fed311 100644 (file)
@@ -20,7 +20,8 @@ function setting_get_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
index 4aab2582fa19878c626e700763cb1a0ecfbf0fd5..3a446f13d893419432be26df0852df762b3c234e 100644 (file)
@@ -22,7 +22,8 @@ function setting_get_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
index 3cb02ca81398b28ecf634bf5fbcb28b80989145f..1a5e7d9b2d8f4298b62550b1c9a3c6c9692605ea 100644 (file)
@@ -21,7 +21,8 @@ function setting_getdefaults_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
index df623eb6ceccbce7196ca877577623651e759c72..9e6170e70d97560be91a4567b6e038b3394b852b 100644 (file)
@@ -19,7 +19,8 @@ function setting_getfields_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
@@ -39,7 +40,7 @@ function setting_getfields_expectedresult() {
   $expectedResult = array(
     'is_error' => 0,
     'version' => 3,
-    'count' => 91,
+    'count' => 151,
     'values' => array(
       'address_standardization_provider' => array(
         'group_name' => 'Address Preferences',
@@ -84,6 +85,20 @@ function setting_getfields_expectedresult() {
         'help_text' => 'Web Service URL',
         'validate_callback' => 'CRM_Utils_Rule::url',
       ),
+      'hideCountryMailingLabels' => array(
+        'group_name' => 'Address Preferences',
+        'group' => 'address',
+        'name' => 'hideCountryMailingLabels',
+        'type' => 'Boolean',
+        'quick_form_type' => 'YesNo',
+        'default' => 0,
+        'add' => '4.7',
+        'title' => 'Hide Country in Mailing Labels when same as domain country',
+        'is_domain' => 1,
+        'is_contact' => 0,
+        'description' => 'Do not display the country field in mailing labels when the country is the same as that of the domain',
+        'help_text' => '',
+      ),
       'tag_unconfirmed' => array(
         'group_name' => 'Campaign Preferences',
         'group' => 'campaign',
@@ -126,6 +141,135 @@ function setting_getfields_expectedresult() {
         'description' => 'Is the CVV code required for back office credit card transactions',
         'help_text' => 'If set it back-office credit card transactions will required a cvv code. Leave as required unless you have a very strong reason to change',
       ),
+      'contribution_invoice_settings' => array(
+        'group_name' => 'Contribute Preferences',
+        'group' => 'contribute',
+        'name' => 'contribution_invoice_settings',
+        'type' => 'Array',
+        'default' => array(
+          'invoice_prefix' => 'INV_',
+          'credit_notes_prefix' => 'CN_',
+          'due_date' => '10',
+          'due_date_period' => 'days',
+          'notes' => '',
+          'tax_term' => 'Sales Tax',
+          'tax_display_settings' => 'Inclusive',
+        ),
+        'add' => '4.7',
+        'title' => 'Contribution Invoice Settings',
+        'is_domain' => 1,
+        'is_contact' => 0,
+        'description' => '',
+        'help_text' => '',
+      ),
+      'invoicing' => array(
+        'group_name' => 'Contribute Preferences',
+        'group' => 'contribute',
+        'name' => 'invoicing',
+        'type' => 'Integer',
+        'html_type' => 'checkbox',
+        'quick_form_type' => 'Element',
+        'default' => 0,
+        'add' => '4.7',
+        'title' => 'Enable Tax and Invoicing',
+        'is_domain' => 1,
+        'is_contact' => 0,
+        'description' => '',
+        'help_text' => '',
+      ),
+      'acl_financial_type' => array(
+        'group_name' => 'Contribute Preferences',
+        'group' => 'contribute',
+        'name' => 'acl_financial_type',
+        'type' => 'Integer',
+        'html_type' => 'checkbox',
+        'quick_form_type' => 'Element',
+        'default' => 0,
+        'add' => '4.7',
+        'title' => 'Enable Access Control by Financial Type',
+        'is_domain' => 1,
+        'is_contact' => 0,
+        'description' => '',
+        'help_text' => '',
+      ),
+      'deferred_revenue_enabled' => array(
+        'group_name' => 'Contribute Preferences',
+        'group' => 'contribute',
+        'name' => 'deferred_revenue_enabled',
+        'type' => 'Integer',
+        'html_type' => 'checkbox',
+        'quick_form_type' => 'Element',
+        'default' => 0,
+        'add' => '4.7',
+        'title' => 'Enable Deferred Revenue',
+        'is_domain' => 1,
+        'is_contact' => 0,
+        'description' => '',
+        'help_text' => '',
+      ),
+      'default_invoice_page' => array(
+        'group_name' => 'Contribute Preferences',
+        'group' => 'contribute',
+        'name' => 'default_invoice_page',
+        'type' => 'Integer',
+        'quick_form_type' => 'Element',
+        'default' => '',
+        'pseudoconstant' => array(
+          'name' => 'contributionPage',
+        ),
+        'html_type' => 'select',
+        'add' => '4.7',
+        'title' => 'Default invoice payment page',
+        'is_domain' => 1,
+        'is_contact' => 0,
+        'description' => '',
+        'help_text' => '',
+      ),
+      'financial_account_bal_enable' => array(
+        'group_name' => 'Contribute Preferences',
+        'group' => 'contribute',
+        'name' => 'financial_account_bal_enable',
+        'type' => 'Integer',
+        'html_type' => 'checkbox',
+        'quick_form_type' => 'Element',
+        'default' => 0,
+        'add' => '4.7',
+        'title' => 'Enable Financial Account Balances',
+        'is_domain' => 1,
+        'is_contact' => 0,
+        'description' => '',
+        'help_text' => '',
+      ),
+      'prior_financial_period' => array(
+        'group_name' => 'Contribute Preferences',
+        'group' => 'contribute',
+        'name' => 'prior_financial_period',
+        'type' => 'activityDate',
+        'quick_form_type' => 'Date',
+        'html_type' => 'Date',
+        'default' => '',
+        'add' => '4.7',
+        'title' => 'Prior Financial Period',
+        'is_domain' => 1,
+        'is_contact' => 0,
+        'description' => '',
+        'help_text' => '',
+      ),
+      'always_post_to_accounts_receivable' => array(
+        'group_name' => 'Contribute Preferences',
+        'group' => 'contribute',
+        'name' => 'always_post_to_accounts_receivable',
+        'type' => 'Integer',
+        'html_type' => 'checkbox',
+        'quick_form_type' => 'Element',
+        'default' => 0,
+        'add' => '4.7',
+        'title' => 'Always post to Accounts Receivable?',
+        'is_domain' => 1,
+        'is_contact' => 0,
+        'description' => '',
+        'help_text' => '',
+      ),
       'contact_view_options' => array(
         'group_name' => 'CiviCRM Preferences',
         'group' => 'core',
@@ -135,20 +279,7 @@ function setting_getfields_expectedresult() {
         'pseudoconstant' => array(
           'optionGroupName' => 'contact_view_options',
         ),
-        'default' => array(
-          '0' => '1',
-          '1' => '2',
-          '2' => '3',
-          '3' => '4',
-          '4' => '5',
-          '5' => '6',
-          '6' => '7',
-          '7' => '8',
-          '8' => '9',
-          '9' => '10',
-          '10' => '11',
-          '11' => '13',
-        ),
+        'default' => '\ 11\ 12\ 13\ 14\ 15\ 16\ 17\ 18\ 19\ 110\ 111\ 113\ 1',
         'add' => '4.1',
         'title' => 'Viewing Contacts',
         'is_domain' => '1',
@@ -165,19 +296,7 @@ function setting_getfields_expectedresult() {
         'pseudoconstant' => array(
           'optionGroupName' => 'contact_edit_options',
         ),
-        'default' => array(
-          '0' => '1',
-          '1' => '2',
-          '2' => '3',
-          '3' => '4',
-          '4' => '5',
-          '5' => '6',
-          '6' => '7',
-          '7' => '8',
-          '8' => '9',
-          '9' => '10',
-          '10' => '11',
-        ),
+        'default' => '\ 11\ 12\ 13\ 14\ 15\ 16\ 17\ 18\ 19\ 111\ 112\ 114\ 115\ 116\ 117\ 1',
         'add' => '4.1',
         'title' => 'Editing Contacts',
         'is_domain' => 1,
@@ -193,25 +312,7 @@ function setting_getfields_expectedresult() {
         'pseudoconstant' => array(
           'optionGroupName' => 'advanced_search_options',
         ),
-        'default' => array(
-          '0' => '1',
-          '1' => '2',
-          '2' => '3',
-          '3' => '4',
-          '4' => '5',
-          '5' => '6',
-          '6' => '7',
-          '7' => '8',
-          '8' => '9',
-          '9' => '10',
-          '10' => '12',
-          '11' => '13',
-          '12' => '15',
-          '13' => '16',
-          '14' => '17',
-          '15' => '18',
-          '16' => '19',
-        ),
+        'default' => '\ 11\ 12\ 13\ 14\ 15\ 16\ 17\ 18\ 19\ 110\ 111\ 112\ 113\ 115\ 116\ 117\ 118\ 119\ 1',
         'add' => '4.1',
         'title' => 'Contact Search',
         'is_domain' => 1,
@@ -228,16 +329,7 @@ function setting_getfields_expectedresult() {
         'pseudoconstant' => array(
           'optionGroupName' => 'user_dashboard_options',
         ),
-        'default' => array(
-          '0' => '1',
-          '1' => '2',
-          '2' => '3',
-          '3' => '4',
-          '4' => '5',
-          '5' => '7',
-          '6' => '8',
-          '7' => '9',
-        ),
+        'default' => '\ 11\ 12\ 13\ 14\ 15\ 17\ 18\ 1',
         'add' => '4.1',
         'title' => 'Contact Dashboard',
         'is_domain' => 1,
@@ -254,16 +346,7 @@ function setting_getfields_expectedresult() {
         'pseudoconstant' => array(
           'optionGroupName' => 'address_options',
         ),
-        'default' => array(
-          '0' => '1',
-          '1' => '2',
-          '2' => '4',
-          '3' => '5',
-          '4' => '8',
-          '5' => '9',
-          '6' => '10',
-          '7' => '11',
-        ),
+        'default' => '\ 11\ 12\ 13\ 14\ 15\ 16\ 18\ 19\ 110\ 111\ 1',
         'add' => '4.1',
         'title' => 'Addressing Options',
         'is_domain' => 1,
@@ -337,13 +420,28 @@ function setting_getfields_expectedresult() {
         'description' => '',
         'help_text' => '',
       ),
+      'remote_profile_submissions' => array(
+        'group_name' => 'CiviCRM Preferences',
+        'group' => 'core',
+        'name' => 'remote_profile_submissions',
+        'type' => 'Boolean',
+        'quick_form_type' => 'YesNo',
+        'default' => '',
+        'html_type' => 'radio',
+        'add' => '4.7',
+        'title' => 'Accept profile submissions from external sites',
+        'is_domain' => 1,
+        'is_contact' => 0,
+        'description' => 'If enabled, CiviCRM will permit submissions from external sites to profiles. This is disabled by default to limit abuse.',
+        'help_text' => '',
+      ),
       'editor_id' => array(
         'group_name' => 'CiviCRM Preferences',
         'group' => 'core',
         'name' => 'editor_id',
         'type' => 'String',
-        'html_type' => 'Text',
-        'default' => '',
+        'html_type' => 'Select',
+        'default' => 'CKEditor',
         'add' => '4.1',
         'title' => 'Wysiwig Editor',
         'is_domain' => 1,
@@ -357,7 +455,7 @@ function setting_getfields_expectedresult() {
         'name' => 'contact_ajax_check_similar',
         'type' => 'String',
         'html_type' => 'Text',
-        'default' => '',
+        'default' => '1',
         'add' => '4.1',
         'title' => 'Ajax Check Similar',
         'is_domain' => 1,
@@ -385,7 +483,7 @@ function setting_getfields_expectedresult() {
         'name' => 'activity_assignee_notification',
         'type' => 'String',
         'html_type' => 'Text',
-        'default' => '',
+        'default' => '1',
         'add' => '4.1',
         'title' => 'Notify Activity Assignees',
         'is_domain' => 1,
@@ -399,7 +497,7 @@ function setting_getfields_expectedresult() {
         'name' => 'activity_assignee_notification_ics',
         'type' => 'String',
         'html_type' => 'Text',
-        'default' => '',
+        'default' => 0,
         'add' => '4.3',
         'title' => 'Include ICal Invite to Activity Assignees',
         'is_domain' => 1,
@@ -412,24 +510,16 @@ function setting_getfields_expectedresult() {
         'group' => 'core',
         'name' => 'contact_autocomplete_options',
         'type' => 'String',
-        'html_type' => 'checkboxes',
+        'quick_form_type' => 'CheckBox',
         'pseudoconstant' => array(
-          'optionGroupName' => 'contact_autocomplete_options',
-        ),
-        'default' => array(
-          '0' => '1',
-          '1' => '2',
-          '2' => '3',
-          '3' => '4',
-          '4' => '5',
-          '5' => '6',
-          '6' => '7',
+          'callback' => 'CRM_Admin_Form_Setting_Search::getContactAutocompleteOptions',
         ),
+        'default' => '\ 11\ 12\ 1',
         'add' => '4.1',
-        'title' => 'Contact Reference Autocomplete Options',
+        'title' => 'Autocomplete Contact Search',
         'is_domain' => 1,
         'is_contact' => 0,
-        'description' => '',
+        'description' => 'Selected fields will be displayed in back-office autocomplete dropdown search results (Quick Search, etc.). Contact Name is always included.',
         'help_text' => '',
       ),
       'contact_reference_options' => array(
@@ -437,32 +527,69 @@ function setting_getfields_expectedresult() {
         'group' => 'core',
         'name' => 'contact_reference_options',
         'type' => 'String',
-        'html_type' => 'checkboxes',
+        'quick_form_type' => 'CheckBox',
         'pseudoconstant' => array(
-          'optionGroupName' => 'contact_reference_options',
-        ),
-        'default' => array(
-          '0' => '1',
-          '1' => '2',
-          '2' => '3',
-          '3' => '4',
-          '4' => '5',
-          '5' => '6',
-          '6' => '7',
+          'callback' => 'CRM_Admin_Form_Setting_Search::getContactReferenceOptions',
         ),
+        'default' => '\ 11\ 12\ 1',
         'add' => '4.1',
         'title' => 'Contact Reference Options',
         'is_domain' => 1,
         'is_contact' => 0,
+        'description' => 'Selected fields will be displayed in autocomplete dropdown search results for \'Contact Reference\' custom fields. Contact Name is always included. NOTE: You must assign \'access contact reference fields\' permission to the anonymous role if you want to use custom contact reference fields in profiles on public pages. For most situations, you should use the \'Limit List to Group\' setting when configuring a contact reference field which will be used in public forms to prevent exposing your entire contact list.',
+        'help_text' => '',
+      ),
+      'contact_smart_group_display' => array(
+        'group_name' => 'CiviCRM Preferences',
+        'group' => 'core',
+        'name' => 'contact_smart_group_display',
+        'type' => 'String',
+        'html_type' => 'radio',
+        'default' => '1',
+        'add' => '4.7',
+        'title' => 'Viewing Smart Groups',
+        'is_domain' => 1,
+        'is_contact' => 0,
         'description' => '',
         'help_text' => '',
       ),
+      'smart_group_cache_refresh_mode' => array(
+        'group_name' => 'CiviCRM Preferences',
+        'group' => 'core',
+        'name' => 'smart_group_cache_refresh_mode',
+        'type' => 'String',
+        'html_type' => 'radio',
+        'default' => 'opportunistic',
+        'add' => '4.7',
+        'title' => 'Smart Group Refresh Mode',
+        'is_domain' => 1,
+        'is_contact' => 0,
+        'pseudoconstant' => array(
+          'callback' => 'CRM_Contact_BAO_GroupContactCache::getModes',
+        ),
+        'description' => 'Should the smart groups be by cron jobs or user actions',
+        'help_text' => 'In \"Opportunistic Flush\" mode, caches are flushed in response to user actions; this mode is broadly compatible but may add latency during form-submissions. In \"Cron Flush\" mode, you should schedule a cron job to flush caches; this can improve latency on form-submissions but requires more setup.',
+      ),
+      'installed' => array(
+        'bootstrap_comment' => 'This is a boot setting which may be loaded during bootstrap. Defaults are loaded via SettingsBag::getSystemDefaults().',
+        'group_name' => 'CiviCRM Preferences',
+        'group' => 'core',
+        'name' => 'installed',
+        'type' => 'Boolean',
+        'quick_form_type' => 'YesNo',
+        'default' => '',
+        'add' => '4.7',
+        'title' => 'System Installed',
+        'is_domain' => 1,
+        'is_contact' => 0,
+        'description' => 'A flag indicating whether this system has run a post-installation routine',
+        'help_text' => '',
+      ),
       'max_attachments' => array(
         'group_name' => 'CiviCRM Preferences',
         'group' => 'core',
         'name' => 'max_attachments',
         'legacy_key' => 'maxAttachments',
-        'prefetch' => 0,
         'type' => 'Integer',
         'quick_form_type' => 'Element',
         'html_type' => 'text',
@@ -482,8 +609,6 @@ function setting_getfields_expectedresult() {
         'group_name' => 'CiviCRM Preferences',
         'group' => 'core',
         'name' => 'maxFileSize',
-        'prefetch' => 1,
-        'config_only' => 1,
         'type' => 'Integer',
         'quick_form_type' => 'Element',
         'html_type' => 'text',
@@ -535,21 +660,19 @@ function setting_getfields_expectedresult() {
         'quick_form_type' => 'YesNo',
         'default' => 1,
         'add' => '4.4',
-        'title' => 'Security Audits',
+        'title' => 'Status Alerts',
         'is_domain' => 1,
         'is_contact' => 0,
-        'description' => 'If enabled, CiviCRM will automatically run checks for significant mis-configurations such as ineffective file protections.',
+        'description' => 'If enabled, CiviCRM will display pop-up notifications (no more than once per day) for security and misconfiguration issues identified in the system check.',
         'help_text' => '',
       ),
       'doNotAttachPDFReceipt' => array(
         'group_name' => 'CiviCRM Preferences',
         'group' => 'core',
         'name' => 'doNotAttachPDFReceipt',
-        'prefetch' => 1,
-        'config_only' => 1,
         'type' => 'Boolean',
         'quick_form_type' => 'YesNo',
-        'default' => 1,
+        'default' => 0,
         'add' => '4.3',
         'title' => 'Attach PDF copy to receipts',
         'is_domain' => 1,
@@ -561,8 +684,6 @@ function setting_getfields_expectedresult() {
         'group_name' => 'CiviCRM Preferences',
         'group' => 'core',
         'name' => 'wkhtmltopdfPath',
-        'prefetch' => 1,
-        'config_only' => 1,
         'type' => 'String',
         'quick_form_type' => 'Element',
         'html_attributes' => array(
@@ -578,12 +699,29 @@ function setting_getfields_expectedresult() {
         'description' => '',
         'help_text' => '',
       ),
+      'recaptchaOptions' => array(
+        'group_name' => 'CiviCRM Preferences',
+        'group' => 'core',
+        'name' => 'recaptchaOptions',
+        'type' => 'String',
+        'quick_form_type' => 'Element',
+        'html_attributes' => array(
+          'size' => 64,
+          'maxlength' => 64,
+        ),
+        'html_type' => 'Text',
+        'default' => '',
+        'add' => '4.3',
+        'title' => 'Recaptcha Options',
+        'is_domain' => 1,
+        'is_contact' => 0,
+        'description' => 'You can specify the reCAPTCHA theme options as comma separated data.(eg: theme:\'blackglass\', lang : \'fr\' ). Check the available options at <a href=\"https://developers.google.com/recaptcha/docs/display#config\">Customizing the Look and Feel of reCAPTCHA</a>.',
+        'help_text' => '',
+      ),
       'recaptchaPublicKey' => array(
         'group_name' => 'CiviCRM Preferences',
         'group' => 'core',
         'name' => 'recaptchaPublicKey',
-        'prefetch' => 1,
-        'config_only' => 1,
         'type' => 'String',
         'quick_form_type' => 'Element',
         'html_attributes' => array(
@@ -603,8 +741,6 @@ function setting_getfields_expectedresult() {
         'group_name' => 'CiviCRM Preferences',
         'group' => 'core',
         'name' => 'recaptchaPrivateKey',
-        'prefetch' => 1,
-        'config_only' => 1,
         'type' => 'String',
         'quick_form_type' => 'Element',
         'html_attributes' => array(
@@ -620,11 +756,10 @@ function setting_getfields_expectedresult() {
         'description' => '',
         'help_text' => '',
       ),
-      'checksumTimeout' => array(
+      'checksum_timeout' => array(
         'group_name' => 'CiviCRM Preferences',
         'group' => 'core',
-        'name' => 'checksumTimeout',
-        'prefetch' => 1,
+        'name' => 'checksum_timeout',
         'type' => 'Integer',
         'quick_form_type' => 'Element',
         'html_attributes' => array(
@@ -644,7 +779,6 @@ function setting_getfields_expectedresult() {
         'group_name' => 'CiviCRM Preferences',
         'group' => 'core',
         'name' => 'blogUrl',
-        'prefetch' => 0,
         'type' => 'String',
         'quick_form_type' => 'Element',
         'html_attributes' => array(
@@ -664,7 +798,6 @@ function setting_getfields_expectedresult() {
         'group_name' => 'CiviCRM Preferences',
         'group' => 'core',
         'name' => 'communityMessagesUrl',
-        'prefetch' => 0,
         'type' => 'String',
         'quick_form_type' => 'Element',
         'html_attributes' => array(
@@ -680,22 +813,35 @@ function setting_getfields_expectedresult() {
         'description' => 'Service providing CiviCRM community messages',
         'help_text' => 'Use \"*default*\" for the system default or override with a custom URL',
       ),
-      'resCacheCode' => array(
+      'gettingStartedUrl' => array(
         'group_name' => 'CiviCRM Preferences',
         'group' => 'core',
-        'name' => 'resCacheCode',
-        'prefetch' => 1,
-        'config_only' => 1,
+        'name' => 'gettingStartedUrl',
         'type' => 'String',
         'quick_form_type' => 'Element',
         'html_attributes' => array(
-          'size' => 16,
-          'maxlength' => 16,
+          'size' => 64,
+          'maxlength' => 128,
         ),
         'html_type' => 'Text',
+        'default' => '*default*',
+        'add' => '4.3',
+        'title' => 'Getting Started URL',
+        'is_domain' => 1,
+        'is_contact' => 0,
+        'description' => 'Service providing the Getting Started data',
+        'help_text' => 'Use \"*default*\" for the system default or override with a custom URL',
+      ),
+      'resCacheCode' => array(
+        'group_name' => 'CiviCRM Preferences',
+        'group' => 'core',
+        'name' => 'resCacheCode',
+        'type' => 'String',
+        'quick_form_type' => 'Element',
+        'html_type' => 'text',
         'default' => '',
         'add' => '4.3',
-        'title' => 'Resource Cache Code',
+        'title' => 'resCacheCode',
         'is_domain' => 1,
         'is_contact' => 0,
         'description' => 'Code appended to resource URLs (JS/CSS) to coerce HTTP caching',
@@ -712,9 +858,23 @@ function setting_getfields_expectedresult() {
         'title' => 'Verify SSL?',
         'is_domain' => 1,
         'is_contact' => 0,
-        'description' => 'If disabled, backend HTTPS services will allow unverified, insecure connections',
+        'description' => 'If disabled, outbound web-service requests will allow unverified, insecure HTTPS connections',
         'help_text' => 'Unless you are absolutely unable to configure your server to check the SSL certificate of the remote server you should leave this set to Yes',
       ),
+      'enableSSL' => array(
+        'group_name' => 'CiviCRM Preferences',
+        'group' => 'core',
+        'name' => 'enableSSL',
+        'type' => 'Boolean',
+        'quick_form_type' => 'YesNo',
+        'default' => 0,
+        'add' => '4.5',
+        'title' => 'Force SSL?',
+        'is_domain' => 1,
+        'is_contact' => 0,
+        'description' => 'If enabled, inbound HTTP requests for sensitive pages will be redirected to HTTPS.',
+        'help_text' => 'If enabled, inbound HTTP requests for sensitive pages will be redirected to HTTPS.',
+      ),
       'wpBasePage' => array(
         'group_name' => 'CiviCRM Preferences',
         'group' => 'core',
@@ -722,7 +882,6 @@ function setting_getfields_expectedresult() {
         'type' => 'String',
         'html_type' => 'text',
         'quick_form_type' => 'Element',
-        'prefetch' => 1,
         'default' => '',
         'add' => '4.3',
         'title' => 'WordPress Base Page',
@@ -735,7 +894,6 @@ function setting_getfields_expectedresult() {
         'group_name' => 'CiviCRM Preferences',
         'group' => 'core',
         'name' => 'secondDegRelPermissions',
-        'prefetch' => 1,
         'type' => 'Boolean',
         'quick_form_type' => 'YesNo',
         'default' => 0,
@@ -747,6 +905,7 @@ function setting_getfields_expectedresult() {
         'help_text' => '',
       ),
       'enable_components' => array(
+        'bootstrap_comment' => 'This is a boot setting which may be loaded during bootstrap. Defaults are loaded via SettingsBag::getSystemDefaults().',
         'group_name' => 'CiviCRM Preferences',
         'group' => 'core',
         'name' => 'enable_components',
@@ -758,14 +917,7 @@ function setting_getfields_expectedresult() {
           'style' => 'width:150px',
           'class' => 'advmultiselect',
         ),
-        'default' => array(
-          '0' => 'CiviEvent',
-          '1' => 'CiviContribute',
-          '2' => 'CiviMember',
-          '3' => 'CiviMail',
-          '4' => 'CiviReport',
-          '5' => 'CiviPledge',
-        ),
+        'default' => '',
         'add' => '4.4',
         'title' => 'Enable Components',
         'is_domain' => '1',
@@ -796,7 +948,6 @@ function setting_getfields_expectedresult() {
         'group_name' => 'CiviCRM Preferences',
         'group' => 'core',
         'name' => 'empoweredBy',
-        'prefetch' => 1,
         'type' => 'Boolean',
         'quick_form_type' => 'YesNo',
         'default' => 1,
@@ -807,176 +958,446 @@ function setting_getfields_expectedresult() {
         'description' => 'When enabled, \"empowered by CiviCRM\" is displayed at the bottom of public forms.',
         'help_text' => '',
       ),
-      'userFrameworkLogging' => array(
-        'group_name' => 'Developer Preferences',
-        'group' => 'developer',
-        'name' => 'userFrameworkLogging',
+      'logging_no_trigger_permission' => array(
+        'add' => '4.7',
+        'is_domain' => 1,
+        'is_contact' => 0,
+        'group_name' => 'CiviCRM Preferences',
+        'group' => 'core',
+        'help_text' => '(EXPERIMENTAL) If the MySQL user does not have permission to administer triggers, then you must create the triggers outside CiviCRM. No support is provided for this configuration.',
+        'name' => 'logging_no_trigger_permission',
         'type' => 'Boolean',
         'quick_form_type' => 'YesNo',
+        'html_type' => '',
         'default' => 0,
-        'add' => '4.3',
-        'title' => 'Enable Drupal Watchdog Logging',
+        'title' => '(EXPERIMENTAL) MySQL user does not have trigger permissions',
+        'description' => 'Set this when you intend to manage trigger creation outside of CiviCRM',
+      ),
+      'logging' => array(
+        'add' => '4.7',
+        'help_text' => '',
         'is_domain' => 1,
         'is_contact' => 0,
-        'description' => 'Set this value to Yes if you want CiviCRM error/debugging messages to appear in the Drupal error logs',
-        'prefetch' => 1,
-        'help_text' => 'Set this value to Yes if you want CiviCRM error/debugging messages the appear in your CMS\' error log. In the case of Drupal, this will cause all CiviCRM error messages to appear in the watchdog (assuming you have Drupal\'s watchdog enabled)',
-      ),
-      'debug_enabled' => array(
-        'group_name' => 'Developer Preferences',
-        'group' => 'developer',
-        'name' => 'debug_enabled',
-        'config_key' => 'debug',
+        'group_name' => 'CiviCRM Preferences',
+        'group' => 'core',
+        'name' => 'logging',
         'type' => 'Boolean',
         'quick_form_type' => 'YesNo',
+        'html_type' => '',
         'default' => 0,
-        'add' => '4.3',
-        'title' => 'Enable Debugging',
+        'title' => 'Logging',
+        'description' => 'If enabled, all actions will be logged with a complete record of changes.',
+        'validate_callback' => 'CRM_Logging_Schema::checkLoggingSupport',
+        'on_change' => array(
+          '0' => 'CRM_Logging_Schema::onToggle',
+        ),
+      ),
+      'logging_uniqueid_date' => array(
+        'add' => '4.7',
+        'help_text' => 'This is the date when CRM-18193 was implemented',
         'is_domain' => 1,
         'is_contact' => 0,
-        'description' => 'Set this value to Yes if you want to use one of CiviCRM\'s debugging tools. This feature should NOT be enabled for production sites',
-        'prefetch' => 1,
-        'help_text' => 'Do not turn this on on production sites',
+        'group_name' => 'CiviCRM Preferences',
+        'group' => 'core',
+        'name' => 'logging_uniqueid_date',
+        'type' => 'Date',
+        'quick_form_type' => 'DateTime',
+        'html_type' => '',
+        'default' => '',
+        'title' => 'Logging Unique ID not recorded before',
+        'description' => 'This is the date when CRM-18193 was implemented',
       ),
-      'backtrace' => array(
-        'group_name' => 'Developer Preferences',
-        'group' => 'developer',
-        'name' => 'backtrace',
+      'logging_all_tables_uniquid' => array(
+        'add' => '4.7',
+        'help_text' => 'This indicates there are no tables holdng pre-uniqid log_conn_id values (CRM-18193)',
+        'is_domain' => 1,
+        'is_contact' => 0,
+        'group_name' => 'CiviCRM Preferences',
+        'group' => 'core',
+        'name' => 'logging_all_tables_uniquid',
         'type' => 'Boolean',
         'quick_form_type' => 'YesNo',
+        'html_type' => '',
         'default' => 0,
-        'add' => '4.3',
-        'title' => 'Display Backtrace',
+        'title' => 'All tables use Unique Connection ID',
+        'description' => 'Do some tables pre-date CRM-18193?',
+      ),
+      'userFrameworkUsersTableName' => array(
+        'add' => '4.7',
+        'help_text' => '',
         'is_domain' => 1,
         'is_contact' => 0,
-        'description' => 'Set this value to Yes if you want to display a backtrace listing when a fatal error is encountered. This feature should NOT be enabled for production sites',
-        'prefetch' => 1,
-      ),
-      'fatalErrorHandler' => array(
-        'group_name' => 'Developer Preferences',
-        'group' => 'developer',
-        'name' => 'fatalErrorHandler',
+        'group_name' => 'CiviCRM Preferences',
+        'group' => 'core',
+        'name' => 'userFrameworkUsersTableName',
         'type' => 'String',
         'quick_form_type' => 'Element',
         'html_type' => 'text',
+        'html_attributes' => array(
+          'size' => '32',
+          'maxlength' => '64',
+        ),
         'default' => '',
-        'add' => '4.3',
+        'title' => 'Drupal Users Table Name',
+        'description' => '',
+      ),
+      'wpLoadPhp' => array(
+        'group_name' => 'CiviCRM Preferences',
+        'group' => 'core',
+        'name' => 'wpLoadPhp',
+        'type' => 'String',
+        'html_type' => 'text',
+        'quick_form_type' => 'Element',
+        'default' => '',
+        'add' => '4.6',
+        'title' => 'WordPress Path to wp-load.php',
+        'is_domain' => 1,
+        'is_contact' => 0,
+        'description' => 'CiviCRM will use this setting as path to bootstrap WP.',
+        'help_text' => '',
+      ),
+      'secure_cache_timeout_minutes' => array(
+        'group_name' => 'CiviCRM Preferences',
+        'group' => 'core',
+        'name' => 'secure_cache_timeout_minutes',
+        'type' => 'Integer',
+        'quick_form_type' => 'Element',
+        'html_type' => 'text',
+        'html_attributes' => array(
+          'size' => 2,
+          'maxlength' => 8,
+        ),
+        'default' => 20,
+        'add' => '4.7',
+        'title' => 'Secure Cache Timeout',
+        'is_domain' => 1,
+        'is_contact' => 0,
+        'description' => 'Maximum number of minutes that secure form data should linger',
+        'help_text' => '',
+      ),
+      'site_id' => array(
+        'group_name' => 'CiviCRM Preferences',
+        'group' => 'core',
+        'name' => 'site_id',
+        'type' => 'String',
+        'quick_form_type' => 'Element',
+        'html_type' => 'text',
+        'default' => '',
+        'add' => '4.6',
+        'title' => 'Unique Site ID',
+        'is_domain' => 1,
+        'is_contact' => 0,
+        'description' => '',
+        'help_text' => '',
+      ),
+      'systemStatusCheckResult' => array(
+        'group_name' => 'CiviCRM Preferences',
+        'group' => 'core',
+        'name' => 'systemStatusCheckResult',
+        'type' => 'Integer',
+        'quick_form_type' => 'Element',
+        'html_type' => 'text',
+        'default' => 0,
+        'add' => '4.7',
+        'title' => 'systemStatusCheckResult',
+        'is_domain' => 1,
+        'is_contact' => 0,
+        'description' => '',
+        'help_text' => '',
+      ),
+      'recentItemsMaxCount' => array(
+        'group_name' => 'CiviCRM Preferences',
+        'group' => 'core',
+        'name' => 'recentItemsMaxCount',
+        'type' => 'Integer',
+        'quick_form_type' => 'Element',
+        'html_type' => 'text',
+        'html_attributes' => array(
+          'size' => 2,
+          'maxlength' => 3,
+        ),
+        'default' => 20,
+        'add' => '4.7',
+        'title' => 'Size of \"Recent Items\" stack',
+        'is_domain' => 1,
+        'is_contact' => 0,
+        'description' => 'How many items should CiviCRM store in it\'s \"Recently viewed\" list.',
+        'help_text' => '',
+      ),
+      'recentItemsProviders' => array(
+        'group_name' => 'CiviCRM Preferences',
+        'group' => 'core',
+        'name' => 'recentItemsProviders',
+        'type' => 'Array',
+        'html_type' => 'Select',
+        'quick_form_type' => 'Select',
+        'html_attributes' => array(
+          'multiple' => 1,
+          'class' => 'crm-select2',
+        ),
+        'default' => '',
+        'add' => '4.7',
+        'title' => 'Recent Items Providers',
+        'is_domain' => 1,
+        'is_contact' => 0,
+        'description' => 'What providers may save views in CiviCRM\'s \"Recently viewed\" list. If empty, all are in.',
+        'help_text' => '',
+        'pseudoconstant' => array(
+          'callback' => 'CRM_Utils_Recent::getProviders',
+        ),
+      ),
+      'dedupe_default_limit' => array(
+        'group_name' => 'CiviCRM Preferences',
+        'group' => 'core',
+        'name' => 'dedupe_default_limit',
+        'type' => 'Integer',
+        'default' => 0,
+        'quick_form_type' => 'Element',
+        'html_type' => 'text',
+        'add' => '4.7',
+        'title' => 'Default limit for dedupe screen',
+        'is_domain' => 1,
+        'is_contact' => 0,
+        'description' => 'Default to only loading matches against this number of contacts',
+        'help_text' => 'Deduping larger databases can crash the server. By configuring a limit other than 0 here the dedupe query will only search for matches against a limited number of contacts.',
+      ),
+      'syncCMSEmail' => array(
+        'group_name' => 'CiviCRM Preferences',
+        'group' => 'core',
+        'name' => 'syncCMSEmail',
+        'type' => 'Boolean',
+        'quick_form_type' => 'YesNo',
+        'default' => 1,
+        'add' => '4.7',
+        'title' => 'Sync CMS Email',
+        'is_domain' => 1,
+        'is_contact' => 0,
+        'description' => 'If enabled, then CMS email id will be syncronised with CiviCRM contacts\'s primary email.',
+        'help_text' => '',
+      ),
+      'userFrameworkLogging' => array(
+        'group_name' => 'Developer Preferences',
+        'group' => 'developer',
+        'name' => 'userFrameworkLogging',
+        'type' => 'Boolean',
+        'quick_form_type' => 'YesNo',
+        'default' => 0,
+        'add' => '4.3',
+        'title' => 'Enable Drupal Watchdog Logging',
+        'is_domain' => 1,
+        'is_contact' => 0,
+        'description' => 'Set this value to Yes if you want CiviCRM error/debugging messages to appear in the Drupal error logs',
+        'help_text' => 'Set this value to Yes if you want CiviCRM error/debugging messages the appear in your CMS\' error log. In the case of Drupal, this will cause all CiviCRM error messages to appear in the watchdog (assuming you have Drupal\'s watchdog enabled)',
+      ),
+      'debug_enabled' => array(
+        'group_name' => 'Developer Preferences',
+        'group' => 'developer',
+        'name' => 'debug_enabled',
+        'config_key' => 'debug',
+        'type' => 'Boolean',
+        'quick_form_type' => 'YesNo',
+        'default' => 0,
+        'add' => '4.3',
+        'title' => 'Enable Debugging',
+        'is_domain' => 1,
+        'is_contact' => 0,
+        'description' => 'Set this value to Yes if you want to use one of CiviCRM\'s debugging tools. This feature should NOT be enabled for production sites',
+        'help_text' => 'Do not turn this on on production sites',
+      ),
+      'backtrace' => array(
+        'group_name' => 'Developer Preferences',
+        'group' => 'developer',
+        'name' => 'backtrace',
+        'type' => 'Boolean',
+        'quick_form_type' => 'YesNo',
+        'default' => 0,
+        'add' => '4.3',
+        'title' => 'Display Backtrace',
+        'is_domain' => 1,
+        'is_contact' => 0,
+        'description' => 'Set this value to Yes if you want to display a backtrace listing when a fatal error is encountered. This feature should NOT be enabled for production sites',
+      ),
+      'fatalErrorHandler' => array(
+        'group_name' => 'Developer Preferences',
+        'group' => 'developer',
+        'name' => 'fatalErrorHandler',
+        'type' => 'String',
+        'quick_form_type' => 'Element',
+        'html_type' => 'text',
+        'default' => '',
+        'add' => '4.3',
         'title' => 'Fatal Error Handler',
         'is_domain' => 1,
         'is_contact' => 0,
         'description' => 'Enter the path and class for a custom PHP error-handling function if you want to override built-in CiviCRM error handling for your site.',
-        'prefetch' => 1,
       ),
       'uploadDir' => array(
+        'bootstrap_comment' => 'This is a boot setting which may be loaded during bootstrap. Defaults are loaded via SettingsBag::getSystemDefaults().',
         'group_name' => 'Directory Preferences',
         'group' => 'directory',
         'name' => 'uploadDir',
-        'type' => 'Url',
+        'type' => 'String',
         'html_type' => 'Text',
+        'quick_form_type' => 'Element',
         'default' => '',
         'add' => '4.1',
-        'prefetch' => 1,
-        'title' => 'Upload Directory',
+        'title' => 'Temporary Files Directory',
         'is_domain' => 1,
         'is_contact' => 0,
         'description' => '',
-        'help_text' => '',
+        'help_text' => 'File system path where temporary CiviCRM files - such as import data files - are uploaded.',
       ),
       'imageUploadDir' => array(
+        'bootstrap_comment' => 'This is a boot setting which may be loaded during bootstrap. Defaults are loaded via SettingsBag::getSystemDefaults().',
         'group_name' => 'Directory Preferences',
         'group' => 'directory',
         'name' => 'imageUploadDir',
-        'type' => 'Url',
+        'type' => 'String',
         'html_type' => 'Text',
+        'quick_form_type' => 'Element',
         'default' => '',
         'add' => '4.1',
-        'prefetch' => 1,
         'title' => 'Image Directory',
         'is_domain' => 1,
         'is_contact' => 0,
-        'description' => '',
+        'description' => 'File system path where image files are uploaded. Currently, this path is used for images associated with premiums (CiviContribute thank-you gifts).',
         'help_text' => '',
       ),
       'customFileUploadDir' => array(
+        'bootstrap_comment' => 'This is a boot setting which may be loaded during bootstrap. Defaults are loaded via SettingsBag::getSystemDefaults().',
         'group_name' => 'Directory Preferences',
         'group' => 'directory',
         'name' => 'customFileUploadDir',
-        'type' => 'Url',
+        'type' => 'String',
         'html_type' => 'Text',
+        'quick_form_type' => 'Element',
         'default' => '',
         'add' => '4.1',
-        'prefetch' => 1,
-        'title' => 'Custom Files Upload Directory',
+        'title' => 'Custom Files Directory',
         'is_domain' => 1,
         'is_contact' => 0,
-        'description' => '',
+        'description' => 'Path where documents and images which are attachments to contact records are stored (e.g. contact photos, resumes, contracts, etc.). These attachments are defined using \'file\' type custom fields.',
         'help_text' => '',
       ),
       'customTemplateDir' => array(
+        'bootstrap_comment' => 'This is a boot setting which may be loaded during bootstrap. Defaults are loaded via SettingsBag::getSystemDefaults().',
         'group_name' => 'Directory Preferences',
         'group' => 'directory',
         'name' => 'customTemplateDir',
-        'type' => 'Url',
+        'type' => 'String',
         'html_type' => 'Text',
+        'quick_form_type' => 'Element',
         'default' => '',
         'add' => '4.1',
-        'prefetch' => 1,
         'title' => 'Custom Template Directory',
         'is_domain' => 1,
         'is_contact' => 0,
-        'description' => '',
+        'description' => 'Path where site specific templates are stored if any. This directory is searched first if set. Custom JavaScript code can be added to templates by creating files named templateFile.extra.tpl. (learn more...)',
         'help_text' => '',
       ),
       'customPHPPathDir' => array(
+        'bootstrap_comment' => 'This is a boot setting which may be loaded during bootstrap. Defaults are loaded via SettingsBag::getSystemDefaults().',
         'group_name' => 'Directory Preferences',
         'group' => 'directory',
         'name' => 'customPHPPathDir',
-        'type' => 'Url',
+        'type' => 'String',
         'html_type' => 'Text',
+        'quick_form_type' => 'Element',
         'default' => '',
         'add' => '4.1',
-        'prefetch' => 1,
-        'title' => 'Custom PHP Path',
+        'title' => 'Custom PHP Directory',
         'is_domain' => 1,
         'is_contact' => 0,
-        'description' => '',
+        'description' => 'Path where site specific PHP code files are stored if any. This directory is searched first if set.',
         'help_text' => '',
       ),
       'extensionsDir' => array(
+        'bootstrap_comment' => 'This is a boot setting which may be loaded during bootstrap. Defaults are loaded via SettingsBag::getSystemDefaults().',
         'group_name' => 'Directory Preferences',
         'group' => 'directory',
         'name' => 'extensionsDir',
-        'type' => 'Url',
+        'type' => 'String',
         'html_type' => 'Text',
+        'quick_form_type' => 'Element',
         'default' => '',
         'add' => '4.1',
-        'prefetch' => 1,
         'title' => 'Extensions Directory',
         'is_domain' => 1,
         'is_contact' => 0,
-        'description' => '',
+        'description' => 'Path where CiviCRM extensions are stored.',
         'help_text' => '',
       ),
-      'event_enable_cart' => array(
+      'enable_cart' => array(
         'name' => 'enable_cart',
         'group_name' => 'Event Preferences',
         'group' => 'event',
-        'type' => 'String',
+        'type' => 'Boolean',
         'quick_form_type' => 'Element',
         'default' => 0,
         'add' => '4.1',
         'title' => 'Enable Event Cart',
         'is_domain' => 1,
-        'is_contact' => 1,
+        'is_contact' => 0,
         'description' => 'WRITE ME',
         'help_text' => 'WRITE ME',
       ),
+      'show_events' => array(
+        'name' => 'show_events',
+        'group_name' => 'Event Preferences',
+        'group' => 'event',
+        'type' => 'Integer',
+        'quick_form_type' => 'Element',
+        'default' => 10,
+        'add' => '4.5',
+        'title' => 'Dashboard entries',
+        'html_type' => 'select',
+        'is_domain' => 1,
+        'is_contact' => 0,
+        'description' => 'Configure how many events should be shown on the dashboard. This overrides the default value of 10 entries.',
+        'help_text' => '',
+      ),
+      'ext_repo_url' => array(
+        'group_name' => 'Extension Preferences',
+        'group' => 'ext',
+        'name' => 'ext_repo_url',
+        'type' => 'String',
+        'quick_form_type' => 'Element',
+        'html_attributes' => array(
+          'size' => 64,
+          'maxlength' => 128,
+        ),
+        'html_type' => 'Text',
+        'default' => 'https://civicrm.org/extdir/ver={ver}|cms={uf}',
+        'add' => '4.3',
+        'title' => 'Extension Repo URL',
+        'is_domain' => 1,
+        'is_contact' => 0,
+        'description' => '',
+        'help_text' => '',
+      ),
+      'customTranslateFunction' => array(
+        'add' => '4.7',
+        'help_text' => '',
+        'is_domain' => 1,
+        'is_contact' => 0,
+        'group_name' => 'Localization Preferences',
+        'group' => 'localization',
+        'name' => 'customTranslateFunction',
+        'type' => 'String',
+        'quick_form_type' => 'Element',
+        'html_type' => 'text',
+        'html_attributes' => array(
+          'size' => '30',
+          'maxlength' => '100',
+        ),
+        'default' => '',
+        'title' => 'Custom Translate Function',
+        'description' => '',
+      ),
       'monetaryThousandSeparator' => array(
         'group_name' => 'Localization Preferences',
         'group' => 'localization',
         'name' => 'monetaryThousandSeparator',
-        'prefetch' => 1,
-        'config_only' => 1,
         'type' => 'String',
         'quick_form_type' => 'Element',
         'html_type' => 'text',
@@ -995,8 +1416,6 @@ function setting_getfields_expectedresult() {
         'group_name' => 'Localization Preferences',
         'group' => 'localization',
         'name' => 'monetaryDecimalPoint',
-        'prefetch' => 1,
-        'config_only' => 1,
         'type' => 'String',
         'quick_form_type' => 'Element',
         'html_type' => 'text',
@@ -1015,8 +1434,6 @@ function setting_getfields_expectedresult() {
         'group_name' => 'Localization Preferences',
         'group' => 'localization',
         'name' => 'moneyformat',
-        'prefetch' => 1,
-        'config_only' => 1,
         'type' => 'String',
         'quick_form_type' => 'Element',
         'html_type' => 'text',
@@ -1032,14 +1449,12 @@ function setting_getfields_expectedresult() {
         'group_name' => 'Localization Preferences',
         'group' => 'localization',
         'name' => 'moneyvalueformat',
-        'prefetch' => 1,
-        'config_only' => 1,
         'type' => 'String',
         'quick_form_type' => 'Element',
         'html_type' => 'text',
         'default' => '%!i',
         'add' => '4.3',
-        'title' => 'Monetary Amount Display',
+        'title' => 'Monetary Value Display',
         'is_domain' => 1,
         'is_contact' => 0,
         'description' => '',
@@ -1049,13 +1464,11 @@ function setting_getfields_expectedresult() {
         'group_name' => 'Localization Preferences',
         'group' => 'localization',
         'name' => 'defaultCurrency',
-        'prefetch' => 1,
-        'config_only' => 1,
         'type' => 'String',
-        'quick_form_type' => 'Element',
-        'html_type' => 'text',
+        'quick_form_type' => 'Select',
+        'html_type' => 'Select',
         'html_attributes' => array(
-          'size' => 2,
+          'class' => 'crm-select2',
         ),
         'default' => 'USD',
         'add' => '4.3',
@@ -1064,19 +1477,18 @@ function setting_getfields_expectedresult() {
         'is_contact' => 0,
         'description' => 'Default currency assigned to contributions and other monetary transactions.',
         'help_text' => '',
+        'pseudoconstant' => array(
+          'callback' => 'CRM_Admin_Form_Setting_Localization::getCurrencySymbols',
+        ),
       ),
       'defaultContactCountry' => array(
         'group_name' => 'Localization Preferences',
         'group' => 'localization',
         'name' => 'defaultContactCountry',
-        'prefetch' => 1,
-        'config_only' => 1,
         'type' => 'String',
-        'quick_form_type' => 'Element',
-        'html_type' => 'text',
-        'html_attributes' => array(
-          'size' => 4,
-        ),
+        'quick_form_type' => 'Select',
+        'html_type' => 'Select',
+        'html_attributes' => array(),
         'default' => '1228',
         'add' => '4.4',
         'title' => 'Default Country',
@@ -1084,13 +1496,29 @@ function setting_getfields_expectedresult() {
         'is_contact' => 0,
         'description' => 'This value is selected by default when adding a new contact address.',
         'help_text' => '',
+        'pseudoconstant' => array(
+          'callback' => 'CRM_Admin_Form_Setting_Localization::getAvailableCountries',
+        ),
+      ),
+      'defaultContactStateProvince' => array(
+        'add' => '4.7',
+        'help_text' => '',
+        'is_domain' => 1,
+        'is_contact' => 0,
+        'group_name' => 'Localization Preferences',
+        'group' => 'localization',
+        'name' => 'defaultContactStateProvince',
+        'type' => 'Integer',
+        'quick_form_type' => 'ChainSelect',
+        'html_type' => 'ChainSelect',
+        'default' => '',
+        'title' => 'Default State/Province',
+        'description' => 'This value is selected by default when adding a new contact address.',
       ),
       'countryLimit' => array(
         'group_name' => 'Localization Preferences',
         'group' => 'localization',
         'name' => 'countryLimit',
-        'prefetch' => 1,
-        'config_only' => 1,
         'type' => 'Array',
         'quick_form_type' => 'Element',
         'html_type' => 'advmultiselect',
@@ -1099,20 +1527,21 @@ function setting_getfields_expectedresult() {
           'style' => 'width:150px',
           'class' => 'advmultiselect',
         ),
-        'default' => 'null',
+        'default' => array(),
         'add' => '4.3',
         'title' => 'Available Countries',
         'is_domain' => 1,
         'is_contact' => 0,
         'description' => '',
         'help_text' => '',
+        'pseudoconstant' => array(
+          'callback' => 'CRM_Admin_Form_Setting_Localization::getAvailableCountries',
+        ),
       ),
       'provinceLimit' => array(
         'group_name' => 'Localization Preferences',
         'group' => 'localization',
         'name' => 'provinceLimit',
-        'prefetch' => 1,
-        'config_only' => 1,
         'type' => 'Array',
         'quick_form_type' => 'Element',
         'html_type' => 'advmultiselect',
@@ -1121,20 +1550,21 @@ function setting_getfields_expectedresult() {
           'style' => 'width:150px',
           'class' => 'advmultiselect',
         ),
-        'default' => 'null',
+        'default' => array(),
         'add' => '4.3',
-        'title' => 'Available States and Provinces',
+        'title' => 'Available States and Provinces (by Country)',
         'is_domain' => 1,
         'is_contact' => 0,
         'description' => '',
         'help_text' => '',
+        'pseudoconstant' => array(
+          'callback' => 'CRM_Admin_Form_Setting_Localization::getAvailableCountries',
+        ),
       ),
       'inheritLocale' => array(
         'group_name' => 'Localization Preferences',
         'group' => 'localization',
         'name' => 'inheritLocale',
-        'prefetch' => 1,
-        'config_only' => 1,
         'type' => 'Boolean',
         'quick_form_type' => 'YesNo',
         'default' => 0,
@@ -1149,12 +1579,12 @@ function setting_getfields_expectedresult() {
         'group_name' => 'Localization Preferences',
         'group' => 'localization',
         'name' => 'dateformatDatetime',
-        'prefetch' => 1,
-        'config_only' => 1,
         'type' => 'String',
+        'quick_form_type' => 'Element',
+        'html_type' => 'text',
         'default' => '%B %E%f, %Y %l:%M %P',
         'add' => '4.3',
-        'title' => 'Complete Date and Time',
+        'title' => 'Date Format: Complete Date and Time',
         'is_domain' => 1,
         'is_contact' => 0,
         'description' => '',
@@ -1164,12 +1594,12 @@ function setting_getfields_expectedresult() {
         'group_name' => 'Localization Preferences',
         'group' => 'localization',
         'name' => 'dateformatFull',
-        'prefetch' => 1,
-        'config_only' => 1,
         'type' => 'String',
+        'quick_form_type' => 'Element',
+        'html_type' => 'text',
         'default' => '%B %E%f, %Y',
         'add' => '4.3',
-        'title' => 'Complete Date',
+        'title' => 'Date Format: Complete Date',
         'is_domain' => 1,
         'is_contact' => 0,
         'description' => '',
@@ -1179,31 +1609,272 @@ function setting_getfields_expectedresult() {
         'group_name' => 'Localization Preferences',
         'group' => 'localization',
         'name' => 'dateformatPartial',
-        'prefetch' => 1,
-        'config_only' => 1,
         'type' => 'String',
+        'quick_form_type' => 'Element',
+        'html_type' => 'text',
         'default' => '%B %Y',
         'add' => '4.3',
-        'title' => 'Month and Year',
+        'title' => 'Date Format: Month and Year',
+        'is_domain' => 1,
+        'is_contact' => 0,
+        'description' => '',
+        'help_text' => '',
+      ),
+      'dateformatTime' => array(
+        'add' => '4.7',
+        'help_text' => '',
+        'is_domain' => 1,
+        'is_contact' => 0,
+        'group_name' => 'Localization Preferences',
+        'group' => 'localization',
+        'name' => 'dateformatTime',
+        'type' => 'String',
+        'quick_form_type' => 'Element',
+        'html_type' => 'text',
+        'html_attributes' => array(
+          'size' => '12',
+          'maxlength' => '60',
+        ),
+        'default' => '%l:%M %P',
+        'title' => 'Date Format: Time Only',
+        'description' => '',
+      ),
+      'dateformatYear' => array(
+        'add' => '4.7',
+        'help_text' => '',
+        'is_domain' => 1,
+        'is_contact' => 0,
+        'group_name' => 'Localization Preferences',
+        'group' => 'localization',
+        'name' => 'dateformatYear',
+        'type' => 'String',
+        'quick_form_type' => 'Element',
+        'html_type' => 'text',
+        'html_attributes' => array(
+          'size' => '12',
+          'maxlength' => '60',
+        ),
+        'default' => '%Y',
+        'title' => 'Date Format: Year Only',
+        'description' => '',
+      ),
+      'dateformatFinancialBatch' => array(
+        'add' => '4.7',
+        'help_text' => '',
         'is_domain' => 1,
         'is_contact' => 0,
+        'group_name' => 'Localization Preferences',
+        'group' => 'localization',
+        'name' => 'dateformatFinancialBatch',
+        'type' => 'String',
+        'quick_form_type' => 'Element',
+        'html_type' => 'text',
+        'html_attributes' => array(
+          'size' => '12',
+          'maxlength' => '60',
+        ),
+        'default' => '%m/%d/%Y',
+        'title' => 'Date Format: Financial Batch',
         'description' => '',
+      ),
+      'dateformatshortdate' => array(
+        'add' => '4.7',
         'help_text' => '',
+        'is_domain' => 1,
+        'is_contact' => 0,
+        'group_name' => 'Localization Preferences',
+        'group' => 'localization',
+        'name' => 'dateformatshortdate',
+        'type' => 'String',
+        'quick_form_type' => 'Element',
+        'html_type' => 'text',
+        'html_attributes' => array(
+          'size' => '12',
+          'maxlength' => '60',
+        ),
+        'default' => '%m/%d/%Y',
+        'title' => 'Date Format: Short date Month Day Year',
+        'description' => '',
+      ),
+      'dateInputFormat' => array(
+        'add' => '4.7',
+        'help_text' => '',
+        'is_domain' => 1,
+        'is_contact' => 0,
+        'group_name' => 'Localization Preferences',
+        'group' => 'localization',
+        'name' => 'dateInputFormat',
+        'type' => 'String',
+        'quick_form_type' => 'Select',
+        'html_type' => 'Select',
+        'pseudoconstant' => array(
+          'callback' => 'CRM_Core_SelectValues::getDatePluginInputFormats',
+        ),
+        'default' => 'mm/dd/yy',
+        'title' => 'Date Input Format',
+        'description' => '',
+      ),
+      'fieldSeparator' => array(
+        'add' => '4.7',
+        'help_text' => '',
+        'is_domain' => 1,
+        'is_contact' => 0,
+        'group_name' => 'Localization Preferences',
+        'group' => 'localization',
+        'name' => 'fieldSeparator',
+        'type' => 'String',
+        'quick_form_type' => 'Element',
+        'html_type' => 'text',
+        'html_attributes' => array(
+          'size' => '2',
+          'maxlength' => '8',
+        ),
+        'default' => ',',
+        'title' => 'Import / Export Field Separator',
+        'description' => 'Global CSV separator character. Modify this setting to enable import and export of different kinds of CSV files (for example: \',\' \';\' \':\' \'|\' ).',
+      ),
+      'fiscalYearStart' => array(
+        'add' => '4.7',
+        'help_text' => '',
+        'is_domain' => 1,
+        'is_contact' => 0,
+        'group_name' => 'Localization Preferences',
+        'group' => 'localization',
+        'name' => 'fiscalYearStart',
+        'type' => 'Array',
+        'quick_form_type' => 'MonthDay',
+        'html_type' => 'MonthDay',
+        'default' => array(
+          'M' => 1,
+          'd' => 1,
+        ),
+        'title' => 'Fiscal Year Start',
+        'description' => '',
+      ),
+      'languageLimit' => array(
+        'group_name' => 'Localization Preferences',
+        'group' => 'localization',
+        'name' => 'languageLimit',
+        'type' => 'Array',
+        'quick_form_type' => 'Select',
+        'html_type' => 'Select',
+        'html_attributes' => array(
+          'multiple' => 1,
+          'class' => 'crm-select2',
+        ),
+        'default' => '',
+        'add' => '4.3',
+        'title' => 'Available Languages (Multi-lingual)',
+        'is_domain' => 1,
+        'is_contact' => 0,
+        'description' => '',
+        'help_text' => '',
+        'pseudoconstant' => array(
+          'callback' => 'CRM_Core_I18n::languages',
+        ),
       ),
       'lcMessages' => array(
         'group_name' => 'Localization Preferences',
         'group' => 'localization',
         'name' => 'lcMessages',
-        'prefetch' => 1,
-        'config_only' => 1,
         'type' => 'String',
+        'quick_form_type' => 'Select',
+        'html_type' => 'Select',
+        'html_attributes' => array(
+          'class' => 'crm-select2',
+        ),
         'default' => 'en_US',
         'add' => '4.3',
         'title' => 'Default Language',
         'is_domain' => 1,
         'is_contact' => 0,
-        'description' => '',
-        'help_text' => '',
+        'description' => '',
+        'help_text' => '',
+        'pseudoconstant' => array(
+          'callback' => 'CRM_Admin_Form_Setting_Localization::getDefaultLocaleOptions',
+        ),
+        'on_change' => array(
+          '0' => 'CRM_Admin_Form_Setting_Localization::onChangeLcMessages',
+        ),
+      ),
+      'legacyEncoding' => array(
+        'add' => '4.7',
+        'help_text' => '',
+        'is_domain' => 1,
+        'is_contact' => 0,
+        'group_name' => 'Localization Preferences',
+        'group' => 'localization',
+        'name' => 'legacyEncoding',
+        'type' => 'String',
+        'quick_form_type' => 'Element',
+        'html_type' => 'text',
+        'html_attributes' => array(
+          'size' => '12',
+          'maxlength' => '30',
+        ),
+        'default' => 'Windows-1252',
+        'title' => 'Legacy Encoding',
+        'description' => 'If import files are NOT encoded as UTF-8, specify an alternate character encoding for these files. The default of Windows-1252 will work for Excel-created .CSV files on many computers.',
+      ),
+      'timeInputFormat' => array(
+        'add' => '4.7',
+        'help_text' => '',
+        'is_domain' => 1,
+        'is_contact' => 0,
+        'group_name' => 'Localization Preferences',
+        'group' => 'localization',
+        'name' => 'timeInputFormat',
+        'type' => 'String',
+        'quick_form_type' => 'Select',
+        'html_type' => 'Select',
+        'pseudoconstant' => array(
+          'callback' => 'CRM_Core_SelectValues::getTimeFormats',
+        ),
+        'default' => '1',
+        'title' => 'Time Input Format',
+        'description' => '',
+        'on_change' => array(
+          '0' => 'CRM_Core_BAO_PreferencesDate::onChangeSetting',
+        ),
+      ),
+      'weekBegins' => array(
+        'group_name' => 'Localization Preferences',
+        'group' => 'localization',
+        'name' => 'weekBegins',
+        'type' => 'String',
+        'quick_form_type' => 'Select',
+        'html_type' => 'Select',
+        'pseudoconstant' => array(
+          'callback' => 'CRM_Utils_Date::getFullWeekdayNames',
+        ),
+        'default' => 0,
+        'add' => '4.7',
+        'title' => 'Week begins on',
+        'is_domain' => 1,
+        'is_contact' => 0,
+        'description' => '',
+        'help_text' => '',
+      ),
+      'contact_default_language' => array(
+        'group_name' => 'Localization Preferences',
+        'group' => 'localization',
+        'name' => 'contact_default_language',
+        'type' => 'String',
+        'quick_form_type' => 'Select',
+        'html_type' => 'Select',
+        'html_attributes' => array(
+          'class' => 'crm-select2',
+        ),
+        'pseudoconstant' => array(
+          'callback' => 'CRM_Admin_Form_Setting_Localization::getDefaultLanguageOptions',
+        ),
+        'default' => '*default*',
+        'add' => '4.7',
+        'title' => 'Default Language for contacts',
+        'is_domain' => 1,
+        'is_contact' => 0,
+        'description' => 'Default language (if any) for contact records',
+        'help_text' => 'If a contact is created with no language this setting will determine the language data (if any) to save.You may or may not wish to make an assumption here about whether it matches the site language',
       ),
       'profile_double_optin' => array(
         'group_name' => 'Mailing Preferences',
@@ -1211,7 +1882,7 @@ function setting_getfields_expectedresult() {
         'name' => 'profile_double_optin',
         'type' => 'Integer',
         'html_type' => 'checkbox',
-        'default' => 0,
+        'default' => '1',
         'add' => '4.1',
         'title' => 'Enable Double Opt-in for Profile Group(s) field',
         'is_domain' => 1,
@@ -1262,13 +1933,29 @@ function setting_getfields_expectedresult() {
         'description' => '',
         'help_text' => '',
       ),
+      'replyTo' => array(
+        'group_name' => 'Mailing Preferences',
+        'group' => 'mailing',
+        'name' => 'replyTo',
+        'type' => 'Boolean',
+        'quick_form_type' => 'YesNo',
+        'default' => 0,
+        'add' => '4.6',
+        'title' => 'Enable Custom Reply-To',
+        'is_domain' => 1,
+        'is_contact' => 0,
+        'description' => 'Allow CiviMail users to send mailings with a custom Reply-To header',
+        'help_text' => '',
+      ),
       'mailing_backend' => array(
         'group_name' => 'Mailing Preferences',
         'group' => 'mailing',
         'name' => 'mailing_backend',
         'type' => 'Array',
         'html_type' => 'checkbox',
-        'default' => 0,
+        'default' => array(
+          'outBound_option' => '3',
+        ),
         'add' => '4.1',
         'title' => 'Mailing Backend',
         'is_domain' => 1,
@@ -1332,6 +2019,223 @@ function setting_getfields_expectedresult() {
         'description' => 'If enabled, a randomized hash key will be used to reference the mailing URL in the mailing.viewUrl token, instead of the mailing ID',
         'help_text' => '',
       ),
+      'civimail_multiple_bulk_emails' => array(
+        'group_name' => 'Mailing Preferences',
+        'group' => 'mailing',
+        'name' => 'civimail_multiple_bulk_emails',
+        'type' => 'Integer',
+        'html_type' => 'checkbox',
+        'default' => 0,
+        'add' => '4.5',
+        'title' => ' Multiple Bulk Emails',
+        'is_domain' => 1,
+        'is_contact' => 0,
+        'description' => 'If enabled, CiviMail will deliver a copy of the email to each bulk email listed for the contact.',
+        'help_text' => '',
+      ),
+      'include_message_id' => array(
+        'group_name' => 'Mailing Preferences',
+        'group' => 'mailing',
+        'name' => 'include_message_id',
+        'type' => 'Integer',
+        'html_type' => 'checkbox',
+        'default' => '',
+        'add' => '4.5',
+        'title' => 'Enable CiviMail to generate Message-ID header',
+        'is_domain' => 1,
+        'is_contact' => 0,
+        'description' => '',
+        'help_text' => '',
+      ),
+      'mailerBatchLimit' => array(
+        'group_name' => 'Mailing Preferences',
+        'group' => 'mailing',
+        'name' => 'mailerBatchLimit',
+        'type' => 'Integer',
+        'quick_form_type' => 'Element',
+        'html_type' => 'text',
+        'html_attributes' => array(
+          'size' => 4,
+          'maxlength' => 8,
+        ),
+        'default' => 0,
+        'add' => '4.7',
+        'title' => 'Mailer Batch Limit',
+        'is_domain' => 1,
+        'is_contact' => 0,
+        'description' => 'Throttle email delivery by setting the maximum number of emails sent during each CiviMail run (0 = unlimited).',
+        'help_text' => '',
+      ),
+      'mailerJobSize' => array(
+        'group_name' => 'Mailing Preferences',
+        'group' => 'mailing',
+        'name' => 'mailerJobSize',
+        'type' => 'Integer',
+        'quick_form_type' => 'Element',
+        'html_type' => 'text',
+        'html_attributes' => array(
+          'size' => 4,
+          'maxlength' => 8,
+        ),
+        'default' => 0,
+        'add' => '4.7',
+        'title' => 'Mailer Job Size',
+        'is_domain' => 1,
+        'is_contact' => 0,
+        'description' => 'If you want to utilize multi-threading enter the size you want your sub jobs to be split into. Recommended values are between 1,000 and 10,000. Use a lower value if your server has multiple cron jobs running simultaneously, but do not use values smaller than 1,000. Enter \"0\" to disable multi-threading and process mail as one single job - batch limits still apply.',
+        'help_text' => '',
+      ),
+      'mailerJobsMax' => array(
+        'group_name' => 'Mailing Preferences',
+        'group' => 'mailing',
+        'name' => 'mailerJobsMax',
+        'type' => 'Integer',
+        'quick_form_type' => 'Element',
+        'html_type' => 'text',
+        'html_attributes' => array(
+          'size' => 4,
+          'maxlength' => 8,
+        ),
+        'default' => 0,
+        'add' => '4.7',
+        'title' => 'Mailer Cron Job Limit',
+        'is_domain' => 1,
+        'is_contact' => 0,
+        'description' => 'The maximum number of mailer delivery jobs executing simultaneously (0 = allow as many processes to execute as started by cron)',
+        'help_text' => '',
+      ),
+      'mailThrottleTime' => array(
+        'group_name' => 'Mailing Preferences',
+        'group' => 'mailing',
+        'name' => 'mailThrottleTime',
+        'type' => 'Integer',
+        'quick_form_type' => 'Element',
+        'html_type' => 'text',
+        'html_attributes' => array(
+          'size' => 4,
+          'maxlength' => 8,
+        ),
+        'default' => 0,
+        'add' => '4.7',
+        'title' => 'Mailer Throttle Time',
+        'is_domain' => 1,
+        'is_contact' => 0,
+        'description' => 'The time to sleep in between each e-mail in micro seconds. Setting this above 0 allows you to control the rate at which e-mail messages are sent to the mail server, avoiding filling up the mail queue very quickly. Set to 0 to disable.',
+        'help_text' => '',
+      ),
+      'verpSeparator' => array(
+        'group_name' => 'Mailing Preferences',
+        'group' => 'mailing',
+        'name' => 'verpSeparator',
+        'type' => 'String',
+        'quick_form_type' => 'Element',
+        'html_type' => 'text',
+        'html_attributes' => array(
+          'size' => 4,
+          'maxlength' => 32,
+        ),
+        'default' => '.',
+        'add' => '4.7',
+        'title' => 'VERP Separator',
+        'is_domain' => 1,
+        'is_contact' => 0,
+        'description' => 'Separator character used when CiviMail generates VERP (variable envelope return path) Mail-From addresses.',
+        'help_text' => '',
+      ),
+      'write_activity_record' => array(
+        'group_name' => 'Mailing Preferences',
+        'group' => 'mailing',
+        'name' => 'write_activity_record',
+        'type' => 'Boolean',
+        'quick_form_type' => 'YesNo',
+        'default' => '1',
+        'add' => '4.7',
+        'title' => 'Enable CiviMail to create activities on delivery',
+        'is_domain' => 1,
+        'is_contact' => 0,
+        'description' => '',
+        'help_text' => '',
+      ),
+      'geoAPIKey' => array(
+        'add' => '4.7',
+        'help_text' => '',
+        'is_domain' => 1,
+        'is_contact' => 0,
+        'group_name' => 'Map Preferences',
+        'group' => 'map',
+        'name' => 'geoAPIKey',
+        'type' => 'String',
+        'quick_form_type' => 'Element',
+        'html_type' => 'text',
+        'html_attributes' => array(
+          'size' => '32',
+          'maxlength' => '64',
+        ),
+        'default' => '',
+        'title' => 'Geo Provider Key',
+        'description' => 'Enter the API key or Application ID associated with your geocoding provider (not required for Yahoo).',
+      ),
+      'geoProvider' => array(
+        'add' => '4.7',
+        'help_text' => '',
+        'is_domain' => 1,
+        'is_contact' => 0,
+        'group_name' => 'Map Preferences',
+        'group' => 'map',
+        'name' => 'geoProvider',
+        'type' => 'String',
+        'quick_form_type' => 'Select',
+        'html_type' => 'Select',
+        'html_attributes' => array(
+          'class' => 'crm-select2',
+        ),
+        'pseudoconstant' => array(
+          'callback' => 'CRM_Core_SelectValues::geoProvider',
+        ),
+        'default' => '',
+        'title' => 'Geocoding Provider',
+        'description' => 'You may choose a different webservice for geocoding. This is required if there is no geo-coding plugin for your selected mapping provider. You can leave the Geocoding fields blank if you are using Google as your mapping provider.',
+      ),
+      'mapAPIKey' => array(
+        'add' => '4.7',
+        'help_text' => '',
+        'is_domain' => 1,
+        'is_contact' => 0,
+        'group_name' => 'Map Preferences',
+        'group' => 'map',
+        'name' => 'mapAPIKey',
+        'type' => 'String',
+        'quick_form_type' => 'Element',
+        'html_type' => 'text',
+        'html_attributes' => array(
+          'size' => '32',
+          'maxlength' => '64',
+        ),
+        'default' => '',
+        'title' => 'Map Provider Key',
+        'description' => 'Enter your API Key or Application ID. An API Key is currently optional for Google Maps API, but may be helpful diagnosing any problems and required for higher volumes of requests. Refer to developers.google.com for the latest information.',
+      ),
+      'mapProvider' => array(
+        'add' => '4.7',
+        'help_text' => '',
+        'is_domain' => 1,
+        'is_contact' => 0,
+        'group_name' => 'Map Preferences',
+        'group' => 'map',
+        'name' => 'mapProvider',
+        'type' => 'String',
+        'quick_form_type' => 'Select',
+        'html_type' => 'Select',
+        'html_attributes' => array(
+          'class' => 'crm-select2',
+        ),
+        'pseudoconstant' => array(
+          'callback' => 'CRM_Core_SelectValues::mapProvider',
+        ),
+        'default' => '',
+        'title' => 'Mapping Provider',
+        'description' => 'Choose the mapping provider that has the best coverage for the majority of your contact addresses.',
+      ),
       'default_renewal_contribution_page' => array(
         'group_name' => 'Member Preferences',
         'group' => 'member',
@@ -1355,7 +2259,7 @@ function setting_getfields_expectedresult() {
         'name' => 'is_enabled',
         'title' => 'Multisite Is enabled',
         'type' => 'Integer',
-        'default' => '',
+        'default' => 0,
         'add' => '4.1',
         'is_domain' => 1,
         'is_contact' => 0,
@@ -1368,7 +2272,7 @@ function setting_getfields_expectedresult() {
         'name' => 'domain_group_id',
         'title' => 'Multisite Domain Group',
         'type' => 'Integer',
-        'default' => '',
+        'default' => 0,
         'add' => '4.1',
         'is_domain' => 1,
         'is_contact' => 0,
@@ -1381,7 +2285,7 @@ function setting_getfields_expectedresult() {
         'name' => 'event_price_set_domain_id',
         'title' => 'Domain Event Price Set',
         'type' => 'Integer',
-        'default' => '',
+        'default' => 0,
         'add' => '4.1',
         'is_domain' => 1,
         'is_contact' => 0,
@@ -1394,7 +2298,7 @@ function setting_getfields_expectedresult() {
         'name' => 'uniq_email_per_site',
         'type' => 'Integer',
         'title' => 'Unique Email per Domain?',
-        'default' => '',
+        'default' => 0,
         'add' => '4.1',
         'is_domain' => 1,
         'is_contact' => 0,
@@ -1405,7 +2309,6 @@ function setting_getfields_expectedresult() {
         'group_name' => 'Search Preferences',
         'group' => 'Search Preferences',
         'name' => 'search_autocomplete_count',
-        'prefetch' => 0,
         'type' => 'Integer',
         'quick_form_type' => 'Element',
         'html_type' => 'text',
@@ -1425,7 +2328,6 @@ function setting_getfields_expectedresult() {
         'group_name' => 'Search Preferences',
         'group' => 'Search Preferences',
         'name' => 'enable_innodb_fts',
-        'prefetch' => 0,
         'type' => 'Boolean',
         'quick_form_type' => 'YesNo',
         'default' => 0,
@@ -1446,7 +2348,6 @@ function setting_getfields_expectedresult() {
         'group_name' => 'Search Preferences',
         'group' => 'Search Preferences',
         'name' => 'fts_query_mode',
-        'prefetch' => 0,
         'type' => 'String',
         'quick_form_type' => 'Element',
         'html_attributes' => array(
@@ -1462,50 +2363,179 @@ function setting_getfields_expectedresult() {
         'description' => '',
         'help_text' => '',
       ),
+      'includeOrderByClause' => array(
+        'group_name' => 'Search Preferences',
+        'group' => 'Search Preferences',
+        'name' => 'includeOrderByClause',
+        'type' => 'Boolean',
+        'quick_form_type' => 'YesNo',
+        'default' => 1,
+        'add' => '4.6',
+        'title' => 'Include Order By Clause',
+        'is_domain' => 1,
+        'is_contact' => 0,
+        'description' => 'If disabled, the search results will not be ordered. This may improve response time on search results on large datasets',
+        'help_text' => '',
+      ),
+      'includeWildCardInName' => array(
+        'group_name' => 'Search Preferences',
+        'group' => 'Search Preferences',
+        'name' => 'includeWildCardInName',
+        'type' => 'Boolean',
+        'quick_form_type' => 'YesNo',
+        'default' => 1,
+        'add' => '4.6',
+        'title' => 'Automatic Wildcard',
+        'is_domain' => 1,
+        'is_contact' => 0,
+        'description' => 'If enabled, wildcards are automatically added to the beginning AND end of the search term when users search for contacts by Name. EXAMPLE: Searching for \'ada\' will return any contact whose name includes those letters - e.g. \'Adams, Janet\', \'Nadal, Jorge\', etc. If disabled, a wildcard is added to the end of the search term only. EXAMPLE: Searching for \'ada\' will return any contact whose last name begins with those letters - e.g. \'Adams, Janet\' but NOT \'Nadal, Jorge\'. Disabling this feature will speed up search significantly for larger databases, but users must manually enter wildcards (\'%\' or \'_\') to the beginning of the search term if they want to find all records which contain those letters. EXAMPLE: \'%ada\' will return \'Nadal, Jorge\'.',
+        'help_text' => '',
+      ),
+      'includeEmailInName' => array(
+        'group_name' => 'Search Preferences',
+        'group' => 'Search Preferences',
+        'name' => 'includeEmailInName',
+        'type' => 'Boolean',
+        'quick_form_type' => 'YesNo',
+        'default' => 1,
+        'add' => '4.6',
+        'title' => 'Include Email',
+        'is_domain' => 1,
+        'is_contact' => 0,
+        'description' => 'If enabled, email addresses are automatically included when users search by Name. Disabling this feature will speed up search significantly for larger databases, but users will need to use the Email search fields (from Advanced Search, Search Builder, or Profiles) to find contacts by email address.',
+        'help_text' => '',
+      ),
+      'includeNickNameInName' => array(
+        'group_name' => 'Search Preferences',
+        'group' => 'Search Preferences',
+        'name' => 'includeNickNameInName',
+        'type' => 'Boolean',
+        'quick_form_type' => 'YesNo',
+        'default' => 0,
+        'add' => '4.6',
+        'title' => 'Include Nickname',
+        'is_domain' => 1,
+        'is_contact' => 0,
+        'description' => 'If enabled, nicknames are automatically included when users search by Name.',
+        'help_text' => '',
+      ),
+      'includeAlphabeticalPager' => array(
+        'group_name' => 'Search Preferences',
+        'group' => 'Search Preferences',
+        'name' => 'includeAlphabeticalPager',
+        'type' => 'Boolean',
+        'quick_form_type' => 'YesNo',
+        'default' => 1,
+        'add' => '4.6',
+        'title' => 'Include Alphabetical Pager',
+        'is_domain' => 1,
+        'is_contact' => 0,
+        'description' => 'If disabled, the alphabetical pager will not be displayed on the search screens. This will improve response time on search results on large datasets.',
+        'help_text' => '',
+      ),
+      'smartGroupCacheTimeout' => array(
+        'group_name' => 'Search Preferences',
+        'group' => 'Search Preferences',
+        'name' => 'smartGroupCacheTimeout',
+        'type' => 'Integer',
+        'quick_form_type' => 'Element',
+        'html_type' => 'text',
+        'default' => 5,
+        'add' => '4.6',
+        'title' => 'Smart group cache timeout',
+        'is_domain' => 1,
+        'is_contact' => 0,
+        'description' => 'The number of minutes to cache smart group contacts. We strongly recommend that this value be greater than zero, since a value of zero means no caching at all. If your contact data changes frequently, you should set this value to at least 5 minutes.',
+        'help_text' => '',
+      ),
+      'defaultSearchProfileID' => array(
+        'group_name' => 'Search Preferences',
+        'group' => 'Search Preferences',
+        'name' => 'defaultSearchProfileID',
+        'type' => 'Integer',
+        'quick_form_type' => 'Select',
+        'html_type' => 'Select',
+        'html_attributes' => array(
+          'class' => 'crm-select2',
+        ),
+        'pseudoconstant' => array(
+          'callback' => 'CRM_Admin_Form_Setting_Search::getAvailableProfiles',
+        ),
+        'default' => '',
+        'add' => '4.6',
+        'title' => 'Default Contact Search Profile',
+        'is_domain' => 1,
+        'is_contact' => 0,
+        'description' => 'If set, this will be the default profile used for contact search.',
+        'help_text' => '',
+      ),
       'userFrameworkResourceURL' => array(
+        'bootstrap_comment' => 'This is a boot setting which may be loaded during bootstrap. Defaults are loaded via SettingsBag::getSystemDefaults().',
         'group' => 'url',
         'group_name' => 'URL Preferences',
         'name' => 'userFrameworkResourceURL',
-        'title' => 'Script and CSS Resources URL',
+        'title' => 'CiviCRM Resource URL',
         'type' => 'String',
+        'html_type' => 'Text',
+        'quick_form_type' => 'Element',
         'default' => '',
         'add' => '4.1',
-        'prefetch' => 1,
         'is_domain' => 1,
         'is_contact' => 0,
-        'description' => 'CiviCRM Resource URL',
+        'description' => 'Absolute URL of the location where the civicrm module or component has been installed.',
         'help_text' => '',
-        'validate_callback' => 'CRM_Utils_Rule::url',
+        'validate_callback' => 'CRM_Utils_Rule::urlish',
       ),
       'imageUploadURL' => array(
+        'bootstrap_comment' => 'This is a boot setting which may be loaded during bootstrap. Defaults are loaded via SettingsBag::getSystemDefaults().',
         'group' => 'url',
         'group_name' => 'URL Preferences',
-        'title' => 'Image URL Prefix',
+        'title' => 'Image Upload URL',
         'name' => 'imageUploadURL',
         'type' => 'String',
+        'html_type' => 'Text',
+        'quick_form_type' => 'Element',
         'default' => '',
         'add' => '4.1',
-        'prefetch' => 1,
         'is_domain' => 1,
         'is_contact' => 0,
-        'description' => 'Image Upload URL',
+        'description' => 'URL of the location for uploaded image files.',
         'help_text' => '',
-        'validate_callback' => 'CRM_Utils_Rule::url',
+        'validate_callback' => 'CRM_Utils_Rule::urlish',
       ),
       'customCSSURL' => array(
+        'bootstrap_comment' => 'This is a boot setting which may be loaded during bootstrap. Defaults are loaded via SettingsBag::getSystemDefaults().',
         'group' => 'url',
         'group_name' => 'URL Preferences',
         'name' => 'customCSSURL',
-        'title' => 'Custom CSS',
+        'title' => 'Custom CSS URL',
         'type' => 'String',
+        'html_type' => 'Text',
+        'quick_form_type' => 'Element',
         'default' => '',
         'add' => '4.1',
-        'prefetch' => 1,
         'is_domain' => 1,
         'is_contact' => 0,
-        'description' => 'Custom CiviCRM CSS URL',
+        'description' => 'You can modify the look and feel of CiviCRM by adding your own stylesheet. For small to medium sized modifications, use your css file to override some of the styles in civicrm.css. Or if you need to make drastic changes, you can choose to disable civicrm.css completely.',
         'help_text' => '',
-        'validate_callback' => 'CRM_Utils_Rule::url',
+        'validate_callback' => 'CRM_Utils_Rule::urlish',
+      ),
+      'extensionsURL' => array(
+        'bootstrap_comment' => 'This is a boot setting which may be loaded during bootstrap. Defaults are loaded via SettingsBag::getSystemDefaults().',
+        'group' => 'url',
+        'group_name' => 'URL Preferences',
+        'title' => 'Extension Resource URL',
+        'name' => 'extensionsURL',
+        'type' => 'String',
+        'html_type' => 'Text',
+        'quick_form_type' => 'Element',
+        'default' => '',
+        'add' => '4.1',
+        'is_domain' => 1,
+        'is_contact' => 0,
+        'description' => 'Base URL for extension resources (images, stylesheets, etc). This should match extensionsDir.',
+        'help_text' => '',
+        'validate_callback' => 'CRM_Utils_Rule::urlish',
       ),
     ),
   );
index 5ace770b00abde215966fd6915f041a66ee04f8b..3b465448174d8bd9cc79610a92d880534e6c6443 100644 (file)
@@ -21,7 +21,8 @@ function setting_get_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
index 683e6618b3eb5eabacb0dd0c7428397f903be688..ef6db54e00254e97ee5ee87f84b604f205e5dd8f 100644 (file)
@@ -27,7 +27,8 @@ function setting_get_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
index 8ee9aa41f253cf2617b76e6af33ad1468fb3b301..10991cc435bb1d8fb872dd673e90a1251e32c90a 100644 (file)
@@ -22,7 +22,8 @@ function setting_getvalue_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
index 9eb77d993e15245e6b153ea54302e0d08eedfe76..40631b92af01345de5646a3b8ac27cea27ca7404 100644 (file)
@@ -21,7 +21,8 @@ function setting_revert_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
diff --git a/api/v3/examples/StateProvince/Create.php b/api/v3/examples/StateProvince/Create.php
new file mode 100644 (file)
index 0000000..d8e8e56
--- /dev/null
@@ -0,0 +1,80 @@
+<?php
+/**
+ * Test Generated example demonstrating the StateProvince.create API.
+ *
+ * @return array
+ *   API result array
+ */
+function state_province_create_example() {
+  $params = array(
+    'name' => 'Wessex',
+    'abbreviation' => 'WEX',
+    'country_id' => 1226,
+  );
+
+  try{
+    $result = civicrm_api3('StateProvince', 'create', $params);
+  }
+  catch (CiviCRM_API3_Exception $e) {
+    // Handle error here.
+    $errorMessage = $e->getMessage();
+    $errorCode = $e->getErrorCode();
+    $errorData = $e->getExtraParams();
+    return array(
+      'is_error' => 1,
+      'error_message' => $errorMessage,
+      'error_code' => $errorCode,
+      'error_data' => $errorData,
+    );
+  }
+
+  return $result;
+}
+
+/**
+ * Function returns array of result expected from previous function.
+ *
+ * @return array
+ *   API result array
+ */
+function state_province_create_expectedresult() {
+
+  $expectedResult = array(
+    'is_error' => 0,
+    'version' => 3,
+    'count' => 1,
+    'id' => 13947,
+    'values' => array(
+      '13947' => array(
+        'id' => '13947',
+        'name' => 'Wessex',
+        'abbreviation' => 'WEX',
+        'country_id' => '1226',
+      ),
+    ),
+  );
+
+  return $expectedResult;
+}
+
+/*
+* This example has been generated from the API test suite.
+* The test that created it is called "testCreateStateProvince"
+* and can be found at:
+* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/StateProvinceTest.php
+*
+* You can see the outcome of the API tests at
+* https://test.civicrm.org/job/CiviCRM-master-git/
+*
+* To Learn about the API read
+* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
+*
+* Browse the api on your own site with the api explorer
+* http://MYSITE.ORG/path/to/civicrm/api
+*
+* Read more about testing here
+* http://wiki.civicrm.org/confluence/display/CRM/Testing
+*
+* API Standards documentation:
+* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
+*/
diff --git a/api/v3/examples/StateProvince/Delete.php b/api/v3/examples/StateProvince/Delete.php
new file mode 100644 (file)
index 0000000..6d3d142
--- /dev/null
@@ -0,0 +1,70 @@
+<?php
+/**
+ * Test Generated example demonstrating the StateProvince.delete API.
+ *
+ * @return array
+ *   API result array
+ */
+function state_province_delete_example() {
+  $params = array(
+    'id' => 13948,
+  );
+
+  try{
+    $result = civicrm_api3('StateProvince', 'delete', $params);
+  }
+  catch (CiviCRM_API3_Exception $e) {
+    // Handle error here.
+    $errorMessage = $e->getMessage();
+    $errorCode = $e->getErrorCode();
+    $errorData = $e->getExtraParams();
+    return array(
+      'is_error' => 1,
+      'error_message' => $errorMessage,
+      'error_code' => $errorCode,
+      'error_data' => $errorData,
+    );
+  }
+
+  return $result;
+}
+
+/**
+ * Function returns array of result expected from previous function.
+ *
+ * @return array
+ *   API result array
+ */
+function state_province_delete_expectedresult() {
+
+  $expectedResult = array(
+    'is_error' => 0,
+    'version' => 3,
+    'count' => 1,
+    'values' => 1,
+  );
+
+  return $expectedResult;
+}
+
+/*
+* This example has been generated from the API test suite.
+* The test that created it is called "testDeleteStateProvince"
+* and can be found at:
+* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/StateProvinceTest.php
+*
+* You can see the outcome of the API tests at
+* https://test.civicrm.org/job/CiviCRM-master-git/
+*
+* To Learn about the API read
+* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
+*
+* Browse the api on your own site with the api explorer
+* http://MYSITE.ORG/path/to/civicrm/api
+*
+* Read more about testing here
+* http://wiki.civicrm.org/confluence/display/CRM/Testing
+*
+* API Standards documentation:
+* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
+*/
diff --git a/api/v3/examples/StateProvince/Get.php b/api/v3/examples/StateProvince/Get.php
new file mode 100644 (file)
index 0000000..c4f1ace
--- /dev/null
@@ -0,0 +1,78 @@
+<?php
+/**
+ * Test Generated example demonstrating the StateProvince.get API.
+ *
+ * @return array
+ *   API result array
+ */
+function state_province_get_example() {
+  $params = array(
+    'name' => 'Wessex',
+  );
+
+  try{
+    $result = civicrm_api3('StateProvince', 'get', $params);
+  }
+  catch (CiviCRM_API3_Exception $e) {
+    // Handle error here.
+    $errorMessage = $e->getMessage();
+    $errorCode = $e->getErrorCode();
+    $errorData = $e->getExtraParams();
+    return array(
+      'is_error' => 1,
+      'error_message' => $errorMessage,
+      'error_code' => $errorCode,
+      'error_data' => $errorData,
+    );
+  }
+
+  return $result;
+}
+
+/**
+ * Function returns array of result expected from previous function.
+ *
+ * @return array
+ *   API result array
+ */
+function state_province_get_expectedresult() {
+
+  $expectedResult = array(
+    'is_error' => 0,
+    'version' => 3,
+    'count' => 1,
+    'id' => 13949,
+    'values' => array(
+      '13949' => array(
+        'id' => '13949',
+        'name' => 'Wessex',
+        'abbreviation' => 'WEX',
+        'country_id' => '1226',
+      ),
+    ),
+  );
+
+  return $expectedResult;
+}
+
+/*
+* This example has been generated from the API test suite.
+* The test that created it is called "testGet"
+* and can be found at:
+* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/StateProvinceTest.php
+*
+* You can see the outcome of the API tests at
+* https://test.civicrm.org/job/CiviCRM-master-git/
+*
+* To Learn about the API read
+* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
+*
+* Browse the api on your own site with the api explorer
+* http://MYSITE.ORG/path/to/civicrm/api
+*
+* Read more about testing here
+* http://wiki.civicrm.org/confluence/display/CRM/Testing
+*
+* API Standards documentation:
+* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
+*/
diff --git a/api/v3/examples/StatusPreference/Create.php b/api/v3/examples/StatusPreference/Create.php
new file mode 100644 (file)
index 0000000..01ae882
--- /dev/null
@@ -0,0 +1,85 @@
+<?php
+/**
+ * Test Generated example demonstrating the StatusPreference.create API.
+ *
+ * @return array
+ *   API result array
+ */
+function status_preference_create_example() {
+  $params = array(
+    'name' => 'test_check',
+    'domain_id' => 1,
+    'hush_until' => '20151212',
+    'ignore_severity' => 'cRItical',
+    'check_info' => '',
+  );
+
+  try{
+    $result = civicrm_api3('StatusPreference', 'create', $params);
+  }
+  catch (CiviCRM_API3_Exception $e) {
+    // Handle error here.
+    $errorMessage = $e->getMessage();
+    $errorCode = $e->getErrorCode();
+    $errorData = $e->getExtraParams();
+    return array(
+      'is_error' => 1,
+      'error_message' => $errorMessage,
+      'error_code' => $errorCode,
+      'error_data' => $errorData,
+    );
+  }
+
+  return $result;
+}
+
+/**
+ * Function returns array of result expected from previous function.
+ *
+ * @return array
+ *   API result array
+ */
+function status_preference_create_expectedresult() {
+
+  $expectedResult = array(
+    'is_error' => 0,
+    'version' => 3,
+    'count' => 1,
+    'id' => 4,
+    'values' => array(
+      '4' => array(
+        'id' => '4',
+        'domain_id' => '1',
+        'name' => 'test_check',
+        'hush_until' => '20151212000000',
+        'ignore_severity' => '5',
+        'prefs' => '',
+        'check_info' => '',
+      ),
+    ),
+  );
+
+  return $expectedResult;
+}
+
+/*
+* This example has been generated from the API test suite.
+* The test that created it is called "testCreateSeverityByName"
+* and can be found at:
+* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/StatusPreferenceTest.php
+*
+* You can see the outcome of the API tests at
+* https://test.civicrm.org/job/CiviCRM-master-git/
+*
+* To Learn about the API read
+* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
+*
+* Browse the api on your own site with the api explorer
+* http://MYSITE.ORG/path/to/civicrm/api
+*
+* Read more about testing here
+* http://wiki.civicrm.org/confluence/display/CRM/Testing
+*
+* API Standards documentation:
+* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
+*/
diff --git a/api/v3/examples/StatusPreference/Delete.php b/api/v3/examples/StatusPreference/Delete.php
new file mode 100644 (file)
index 0000000..8c3d75f
--- /dev/null
@@ -0,0 +1,70 @@
+<?php
+/**
+ * Test Generated example demonstrating the StatusPreference.delete API.
+ *
+ * @return array
+ *   API result array
+ */
+function status_preference_delete_example() {
+  $params = array(
+    'id' => 2,
+  );
+
+  try{
+    $result = civicrm_api3('StatusPreference', 'delete', $params);
+  }
+  catch (CiviCRM_API3_Exception $e) {
+    // Handle error here.
+    $errorMessage = $e->getMessage();
+    $errorCode = $e->getErrorCode();
+    $errorData = $e->getExtraParams();
+    return array(
+      'is_error' => 1,
+      'error_message' => $errorMessage,
+      'error_code' => $errorCode,
+      'error_data' => $errorData,
+    );
+  }
+
+  return $result;
+}
+
+/**
+ * Function returns array of result expected from previous function.
+ *
+ * @return array
+ *   API result array
+ */
+function status_preference_delete_expectedresult() {
+
+  $expectedResult = array(
+    'is_error' => 0,
+    'version' => 3,
+    'count' => 1,
+    'values' => 1,
+  );
+
+  return $expectedResult;
+}
+
+/*
+* This example has been generated from the API test suite.
+* The test that created it is called "testDeleteStatusPreference"
+* and can be found at:
+* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/StatusPreferenceTest.php
+*
+* You can see the outcome of the API tests at
+* https://test.civicrm.org/job/CiviCRM-master-git/
+*
+* To Learn about the API read
+* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
+*
+* Browse the api on your own site with the api explorer
+* http://MYSITE.ORG/path/to/civicrm/api
+*
+* Read more about testing here
+* http://wiki.civicrm.org/confluence/display/CRM/Testing
+*
+* API Standards documentation:
+* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
+*/
diff --git a/api/v3/examples/StatusPreference/Get.php b/api/v3/examples/StatusPreference/Get.php
new file mode 100644 (file)
index 0000000..b1334a9
--- /dev/null
@@ -0,0 +1,79 @@
+<?php
+/**
+ * Test Generated example demonstrating the StatusPreference.get API.
+ *
+ * @return array
+ *   API result array
+ */
+function status_preference_get_example() {
+  $params = array(
+    'id' => 3,
+  );
+
+  try{
+    $result = civicrm_api3('StatusPreference', 'get', $params);
+  }
+  catch (CiviCRM_API3_Exception $e) {
+    // Handle error here.
+    $errorMessage = $e->getMessage();
+    $errorCode = $e->getErrorCode();
+    $errorData = $e->getExtraParams();
+    return array(
+      'is_error' => 1,
+      'error_message' => $errorMessage,
+      'error_code' => $errorCode,
+      'error_data' => $errorData,
+    );
+  }
+
+  return $result;
+}
+
+/**
+ * Function returns array of result expected from previous function.
+ *
+ * @return array
+ *   API result array
+ */
+function status_preference_get_expectedresult() {
+
+  $expectedResult = array(
+    'is_error' => 0,
+    'version' => 3,
+    'count' => 1,
+    'id' => 3,
+    'values' => array(
+      '3' => array(
+        'id' => '3',
+        'domain_id' => '1',
+        'name' => 'test_check',
+        'hush_until' => '2015-12-12',
+        'ignore_severity' => '4',
+      ),
+    ),
+  );
+
+  return $expectedResult;
+}
+
+/*
+* This example has been generated from the API test suite.
+* The test that created it is called "testStatusPreferenceGet"
+* and can be found at:
+* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/StatusPreferenceTest.php
+*
+* You can see the outcome of the API tests at
+* https://test.civicrm.org/job/CiviCRM-master-git/
+*
+* To Learn about the API read
+* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
+*
+* Browse the api on your own site with the api explorer
+* http://MYSITE.ORG/path/to/civicrm/api
+*
+* Read more about testing here
+* http://wiki.civicrm.org/confluence/display/CRM/Testing
+*
+* API Standards documentation:
+* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
+*/
index 2a218305a4f753a58f45d50139d78d6331c20c08..860366008bd5dee54826408773d33e276ccd91c4 100644 (file)
@@ -22,7 +22,8 @@ function survey_get_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
@@ -60,7 +61,7 @@ function survey_get_expectedresult() {
           'is_error' => 0,
           'version' => 3,
           'count' => 1,
-          'values' => TRUE,
+          'values' => 1,
         ),
       ),
     ),
index 11a84829142f611555f30d67fc7faabdea8d5731..09a73872516cb1334f61e4ebf5b7a021b6fa8fbb 100644 (file)
@@ -22,7 +22,8 @@ function survey_create_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
index b2b7f6d1a6d860201f7235f60f3291cbd106a9ba..2a15ecb7be4384368ac454bad23df963be3274e9 100644 (file)
@@ -19,7 +19,8 @@ function survey_delete_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
@@ -40,7 +41,7 @@ function survey_delete_expectedresult() {
     'is_error' => 0,
     'version' => 3,
     'count' => 1,
-    'values' => TRUE,
+    'values' => 1,
   );
 
   return $expectedResult;
index 43038c18303d61f0ac3012b1315dcb113a925342..f1c14e1b4416759245ddb047407e15dd3aff580e 100644 (file)
@@ -22,7 +22,8 @@ function survey_get_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
index b07f6a770f730ece8992604d74a0b2bbeacc2ccb..93614aacf45ed2bc28235edce61e65c97754fd9b 100644 (file)
@@ -23,7 +23,8 @@ function survey_respondant_get_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
index 0d124c21444f77aeb58bf1801ddbd1648108dad8..dab2f325a42a780b08ffbc2a4361d4f86cf674cc 100644 (file)
@@ -19,7 +19,8 @@ function system_flush_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
index 503eacabdb8a1eec2fd0811b052e0c06475c63f2..3add021f743f166f4ff4ad47b2f4299b781aea32 100644 (file)
@@ -20,7 +20,8 @@ function tag_create_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
@@ -53,6 +54,7 @@ function tag_create_expectedresult() {
         'is_tagset' => '',
         'used_for' => 'civicrm_contact',
         'created_id' => '',
+        'color' => '',
         'created_date' => '2013-07-28 08:49:19',
       ),
     ),
index b1112ad56bd2318e101a3ff58a4ac26776ce5a5f..75f072716aa16e9cc1dd61b9885f074a692bc459 100644 (file)
@@ -19,7 +19,8 @@ function tag_delete_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
@@ -40,7 +41,7 @@ function tag_delete_expectedresult() {
     'is_error' => 0,
     'version' => 3,
     'count' => 1,
-    'values' => TRUE,
+    'values' => 1,
   );
 
   return $expectedResult;
index 8860a11c72e9cd09380be3557a3af021e1cea8ff..a39d5c6a8e57ac4ec11c6fbb94963d4850eaad98 100644 (file)
@@ -20,7 +20,8 @@ function tag_get_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
index eb38f1819234732bf5d354d753b2205c8f760e4c..c00491e909f6e7c57d99dc3feed04b7abcb69af7 100644 (file)
@@ -21,7 +21,8 @@ function tag_getfields_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
@@ -41,13 +42,17 @@ function tag_getfields_expectedresult() {
   $expectedResult = array(
     'is_error' => 0,
     'version' => 3,
-    'count' => 10,
+    'count' => 11,
     'values' => array(
       'id' => array(
         'name' => 'id',
         'type' => 1,
         'title' => 'Tag ID',
+        'description' => 'Tag ID',
         'required' => TRUE,
+        'table_name' => 'civicrm_tag',
+        'entity' => 'Tag',
+        'bao' => 'CRM_Core_BAO_Tag',
         'api.aliases' => array(
           '0' => 'tag',
         ),
@@ -56,23 +61,35 @@ function tag_getfields_expectedresult() {
         'name' => 'name',
         'type' => 2,
         'title' => 'Tag Name',
+        'description' => 'Name of Tag.',
         'required' => TRUE,
         'maxlength' => 64,
         'size' => 30,
+        'table_name' => 'civicrm_tag',
+        'entity' => 'Tag',
+        'bao' => 'CRM_Core_BAO_Tag',
         'api.required' => 1,
       ),
       'description' => array(
         'name' => 'description',
         'type' => 2,
         'title' => 'Description',
+        'description' => 'Optional verbose description of the tag.',
         'maxlength' => 255,
         'size' => 45,
+        'table_name' => 'civicrm_tag',
+        'entity' => 'Tag',
+        'bao' => 'CRM_Core_BAO_Tag',
       ),
       'parent_id' => array(
         'name' => 'parent_id',
         'type' => 1,
         'title' => 'Parent Tag',
+        'description' => 'Optional parent id for this tag.',
         'default' => 'NULL',
+        'table_name' => 'civicrm_tag',
+        'entity' => 'Tag',
+        'bao' => 'CRM_Core_BAO_Tag',
         'FKClassName' => 'CRM_Core_DAO_Tag',
         'FKApiName' => 'Tag',
       ),
@@ -80,17 +97,27 @@ function tag_getfields_expectedresult() {
         'name' => 'is_selectable',
         'type' => 16,
         'title' => 'Display Tag?',
+        'description' => 'Is this tag selectable / displayed',
         'default' => '1',
+        'table_name' => 'civicrm_tag',
+        'entity' => 'Tag',
+        'bao' => 'CRM_Core_BAO_Tag',
       ),
       'is_reserved' => array(
         'name' => 'is_reserved',
         'type' => 16,
         'title' => 'Reserved',
+        'table_name' => 'civicrm_tag',
+        'entity' => 'Tag',
+        'bao' => 'CRM_Core_BAO_Tag',
       ),
       'is_tagset' => array(
         'name' => 'is_tagset',
         'type' => 16,
         'title' => 'Tagset',
+        'table_name' => 'civicrm_tag',
+        'entity' => 'Tag',
+        'bao' => 'CRM_Core_BAO_Tag',
       ),
       'used_for' => array(
         'name' => 'used_for',
@@ -99,11 +126,17 @@ function tag_getfields_expectedresult() {
         'maxlength' => 64,
         'size' => 30,
         'default' => 'NULL',
+        'table_name' => 'civicrm_tag',
+        'entity' => 'Tag',
+        'bao' => 'CRM_Core_BAO_Tag',
         'html' => array(
           'type' => 'Select',
+          'maxlength' => 64,
+          'size' => 30,
         ),
         'pseudoconstant' => array(
           'optionGroupName' => 'tag_used_for',
+          'optionEditPath' => 'civicrm/admin/options/tag_used_for',
         ),
         'api.default' => 'civicrm_contact',
       ),
@@ -111,13 +144,33 @@ function tag_getfields_expectedresult() {
         'name' => 'created_id',
         'type' => 1,
         'title' => 'Tag Created By',
+        'description' => 'FK to civicrm_contact, who created this tag',
+        'table_name' => 'civicrm_tag',
+        'entity' => 'Tag',
+        'bao' => 'CRM_Core_BAO_Tag',
         'FKClassName' => 'CRM_Contact_DAO_Contact',
         'FKApiName' => 'Contact',
       ),
+      'color' => array(
+        'name' => 'color',
+        'type' => 2,
+        'title' => 'Color',
+        'description' => 'Hex color value e.g. #ffffff',
+        'maxlength' => 255,
+        'size' => 45,
+        'default' => 'NULL',
+        'table_name' => 'civicrm_tag',
+        'entity' => 'Tag',
+        'bao' => 'CRM_Core_BAO_Tag',
+      ),
       'created_date' => array(
         'name' => 'created_date',
         'type' => 12,
         'title' => 'Tag Created Date',
+        'description' => 'Date and time that tag was created.',
+        'table_name' => 'civicrm_tag',
+        'entity' => 'Tag',
+        'bao' => 'CRM_Core_BAO_Tag',
       ),
     ),
   );
index 9dd6c6ebc83eff00cc36784199a53619c351e90a..08db458290490a953b1570e21c2ae0d21c37b00b 100644 (file)
@@ -24,7 +24,8 @@ function tag_getlist_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
index e3cb5b396bc572afafc8d60b5845a892133ac5fe..ae5465dce79c7a9d6ae40436f7e234702dbe25a0 100644 (file)
@@ -25,7 +25,8 @@ function tag_get_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
index ec39ee0013833f21a10c5ba5d5be1f6cec1efdd0..6710ce7375c817db8e448c22937e58ea6947b69e 100644 (file)
@@ -28,7 +28,8 @@ function uf_field_create_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
index a766ac75845927c1a58e807ab67aef88c5ad7319..996cb148ee73721bfaee4292edc3155f43fc4ec4 100644 (file)
@@ -19,7 +19,8 @@ function uf_field_delete_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
index 9c52c59d20418abb53adedf7cd4b6482b0c0aa72..c6c1a6b2df4494ca0ccf4d61d52965be106a1916 100644 (file)
@@ -17,7 +17,8 @@ function uf_field_get_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
index f94ad49347d9066536b138bbdc647b4c7b5ac5b6..992d678986a662dc0e71ea79779e3c2efb385fd6 100644 (file)
@@ -53,7 +53,8 @@ function uf_field_replace_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
index fdf7ada9352970353a5dab2f30ffa29e62dc2a8d..ade13f1fbe2cad305c994de0139787cd521303c5 100644 (file)
@@ -38,7 +38,8 @@ function uf_group_create_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
@@ -81,7 +82,7 @@ function uf_group_create_expectedresult() {
         'is_cms_user' => '1',
         'notify' => 'admin@example.org',
         'is_reserved' => '1',
-        'name' => 'Test_Group_2',
+        'name' => 'Test_Group',
         'created_id' => '1',
         'created_date' => '2013-07-28 08:49:19',
         'is_proximity_search' => '',
index c2be5ea33089e6c08deba871c5224951e41f4c0a..68855a931e51228f8d3b0c1d0c9048f52f0ad60d 100644 (file)
@@ -19,7 +19,8 @@ function uf_group_delete_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
@@ -40,7 +41,7 @@ function uf_group_delete_expectedresult() {
     'is_error' => 0,
     'version' => 3,
     'count' => 1,
-    'values' => TRUE,
+    'values' => 1,
   );
 
   return $expectedResult;
index b35be5d2ba09cf178e61b28c018b766571a188df..1ce438b38b975e5e1c152002b3dda4566cd1d83a 100644 (file)
@@ -19,7 +19,8 @@ function uf_group_get_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
@@ -61,7 +62,7 @@ function uf_group_get_expectedresult() {
         'is_cms_user' => '1',
         'notify' => 'admin@example.org',
         'is_reserved' => '1',
-        'name' => 'Test_Group_2',
+        'name' => 'Test_Group',
         'created_id' => '1',
         'created_date' => '2013-07-28 08:49:19',
         'is_proximity_search' => 0,
index fa380d97d2c23f135424851bb4cae010a6750512..45eb69fec1c9109fd3802bdbc47ad9e4e919ce64 100644 (file)
@@ -7,8 +7,8 @@
  */
 function uf_join_create_example() {
   $params = array(
-    'module' => 'CiviContribute',
-    'entity_table' => 'civicrm_contribution_page',
+    'module' => 'CiviCampaign',
+    'entity_table' => 'civicrm_survey',
     'entity_id' => 1,
     'weight' => 1,
     'uf_group_id' => 11,
@@ -25,7 +25,8 @@ function uf_join_create_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
@@ -51,8 +52,8 @@ function uf_join_create_expectedresult() {
       '0' => array(
         'id' => '1',
         'is_active' => '1',
-        'module' => 'CiviContribute',
-        'entity_table' => 'civicrm_contribution_page',
+        'module' => 'CiviCampaign',
+        'entity_table' => 'civicrm_survey',
         'entity_id' => '1',
         'weight' => '1',
         'uf_group_id' => '11',
@@ -66,7 +67,7 @@ function uf_join_create_expectedresult() {
 
 /*
 * This example has been generated from the API test suite.
-* The test that created it is called "testCreateUFJoin"
+* The test that created it is called "testCreateSurveyUFJoin"
 * and can be found at:
 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/UFJoinTest.php
 *
index 1328f59812e2d15d23ea3c298ab94bb55cdd9b4f..6f38609a02de252ffc443cf6090afb436d49a1fe 100644 (file)
@@ -21,7 +21,8 @@ function uf_join_get_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
index de24f6be46c28f60022ffa51fff79fc1a2ac452e..dddd476237eb2ca74af5badcd4bbf4ddc858d126 100644 (file)
@@ -19,7 +19,8 @@ function uf_match_get_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
index 89a347ffbde261d88a6858f0036470b08806a85b..1e1d4e10fa0ab892c3d2d191674e96be335f2e98 100644 (file)
@@ -21,7 +21,8 @@ function website_create_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
index fea28bf1645b24c59919101975abad2c7d4eddad..e40f33ac4ba072cfbd83b3482a926b7bf69c2c91 100644 (file)
@@ -19,7 +19,8 @@ function website_delete_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
index 4b26815ce96b001f01cd97293fc288fa7a1fb2d0..75474912271286714ce1d566a0d13bdfda1e5462 100644 (file)
@@ -21,7 +21,8 @@ function website_get_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
index 915c3c238aa6bd89a418c74c2b6cabf1e0a54aa1..1f163d8dc5a409c51f6306e37e72fd392773fa4d 100644 (file)
@@ -19,7 +19,8 @@ function website_getfields_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
@@ -45,7 +46,11 @@ function website_getfields_expectedresult() {
         'name' => 'id',
         'type' => 1,
         'title' => 'Website ID',
+        'description' => 'Unique Website ID',
         'required' => TRUE,
+        'table_name' => 'civicrm_website',
+        'entity' => 'Website',
+        'bao' => 'CRM_Core_BAO_Website',
         'api.aliases' => array(
           '0' => 'website_id',
         ),
@@ -54,6 +59,10 @@ function website_getfields_expectedresult() {
         'name' => 'contact_id',
         'type' => 1,
         'title' => 'Contact',
+        'description' => 'FK to Contact ID',
+        'table_name' => 'civicrm_website',
+        'entity' => 'Website',
+        'bao' => 'CRM_Core_BAO_Website',
         'FKClassName' => 'CRM_Contact_DAO_Contact',
         'FKApiName' => 'Contact',
       ),
@@ -61,6 +70,7 @@ function website_getfields_expectedresult() {
         'name' => 'url',
         'type' => 2,
         'title' => 'Website',
+        'description' => 'Website',
         'maxlength' => 128,
         'size' => 30,
         'import' => TRUE,
@@ -68,19 +78,31 @@ function website_getfields_expectedresult() {
         'headerPattern' => '/Website/i',
         'dataPattern' => '/^[A-Za-z][0-9A-Za-z]{20,}$/',
         'export' => TRUE,
+        'table_name' => 'civicrm_website',
+        'entity' => 'Website',
+        'bao' => 'CRM_Core_BAO_Website',
         'html' => array(
           'type' => 'Text',
+          'maxlength' => 128,
+          'size' => 30,
         ),
       ),
       'website_type_id' => array(
         'name' => 'website_type_id',
         'type' => 1,
         'title' => 'Website Type',
+        'description' => 'Which Website type does this website belong to.',
+        'table_name' => 'civicrm_website',
+        'entity' => 'Website',
+        'bao' => 'CRM_Core_BAO_Website',
         'html' => array(
           'type' => 'Select',
+          'size' => 6,
+          'maxlength' => 14,
         ),
         'pseudoconstant' => array(
           'optionGroupName' => 'website_type',
+          'optionEditPath' => 'civicrm/admin/options/website_type',
         ),
       ),
     ),
index db2e42874cdfcf55e3aab181c335c2111bedfa18..24c4467ddd2a3dcdf5be2222243343d775730cfa 100644 (file)
@@ -25,7 +25,8 @@ function website_get_example() {
     $errorCode = $e->getErrorCode();
     $errorData = $e->getExtraParams();
     return array(
-      'error' => $errorMessage,
+      'is_error' => 1,
+      'error_message' => $errorMessage,
       'error_code' => $errorCode,
       'error_data' => $errorData,
     );
@@ -53,7 +54,11 @@ function website_get_expectedresult() {
           'name' => 'id',
           'type' => '1',
           'title' => 'Website ID',
+          'description' => 'Unique Website ID',
           'required' => '1',
+          'table_name' => 'civicrm_website',
+          'entity' => 'Website',
+          'bao' => 'CRM_Core_BAO_Website',
           'api.aliases' => array(
             '0' => 'website_id',
           ),
@@ -62,6 +67,10 @@ function website_get_expectedresult() {
           'name' => 'contact_id',
           'type' => '1',
           'title' => 'Contact',
+          'description' => 'FK to Contact ID',
+          'table_name' => 'civicrm_website',
+          'entity' => 'Website',
+          'bao' => 'CRM_Core_BAO_Website',
           'FKClassName' => 'CRM_Contact_DAO_Contact',
           'FKApiName' => 'Contact',
         ),
@@ -69,6 +78,7 @@ function website_get_expectedresult() {
           'name' => 'url',
           'type' => '2',
           'title' => 'Website',
+          'description' => 'Website',
           'maxlength' => '128',
           'size' => '30',
           'import' => '1',
@@ -76,19 +86,31 @@ function website_get_expectedresult() {
           'headerPattern' => '/Website/i',
           'dataPattern' => '/^[A-Za-z][0-9A-Za-z]{20,}$/',
           'export' => '1',
+          'table_name' => 'civicrm_website',
+          'entity' => 'Website',
+          'bao' => 'CRM_Core_BAO_Website',
           'html' => array(
             'type' => 'Text',
+            'maxlength' => '128',
+            'size' => '30',
           ),
         ),
         'website_type_id' => array(
           'name' => 'website_type_id',
           'type' => '1',
           'title' => 'Website Type',
+          'description' => 'Which Website type does this website belong to.',
+          'table_name' => 'civicrm_website',
+          'entity' => 'Website',
+          'bao' => 'CRM_Core_BAO_Website',
           'html' => array(
             'type' => 'Select',
+            'size' => '6',
+            'maxlength' => '14',
           ),
           'pseudoconstant' => array(
             'optionGroupName' => 'website_type',
+            'optionEditPath' => 'civicrm/admin/options/website_type',
           ),
         ),
       ),
index 741ab966cdcadd51aa2af73b691e71a47ed83a30..1e5400b4197b7c0c6266c6fa765e0247afd45799 100644 (file)
@@ -1887,8 +1887,10 @@ function _civicrm_api_get_fields($entity, $unique = FALSE, &$params = array()) {
   $d = new $dao();
   $fields = $d->fields();
 
-  // Set html attributes for text fields
   foreach ($fields as $name => &$field) {
+    // Denote as core field
+    $field['is_core_field'] = TRUE;
+    // Set html attributes for text fields
     if (isset($field['html'])) {
       $field['html'] += (array) $d::makeAttribute($field);
     }
@@ -2062,7 +2064,7 @@ function _civicrm_api3_swap_out_aliases(&$apiRequest, $fields) {
  *
  * @throws API_Exception
  */
-function _civicrm_api3_validate_integer(&$params, &$fieldName, &$fieldInfo, $entity) {
+function _civicrm_api3_validate_integer(&$params, $fieldName, &$fieldInfo, $entity) {
   list($fieldValue, $op) = _civicrm_api3_field_value_check($params, $fieldName);
   if (strpos($op, 'NULL') !== FALSE || strpos($op, 'EMPTY') !== FALSE) {
     return;
index 7db9f6bb6ea907aad547b45c45f463c29fea2c02..d5cda3c0d015cc0b757e6cbbda0db5aa09e389d1 100644 (file)
@@ -22,6 +22,7 @@
     "select2": "colemanw/select2#stable/3.5",
     "jquery-validation": "~1.13",
     "datatables": "~1.10",
+    "jstree": "~3",
     "ckeditor": "~4.5",
     "font-awesome": "~4",
     "angular-sanitize": "~1.3.15"
index 4faf759475271260a8cccf343b1636bca5a8f171..bbbdaeb591713b4ea1c5802c4c506abc254c031f 100644 (file)
@@ -47,8 +47,9 @@
   organization: Nubay Services
   jira        : dtarrant
 - github      : edzelopez
-  name        : Edzel Lopez
+  name        : Edsel Lopez
   organization: JMA Consulting
+  jira        : edsel
 - github      : eileenmcnaughton
   name        : Eileen McNaughton
   organization: Fuzion
 - github      : michaelmcandrew
   name        : Michael McAndrew
   organization: Third Sector Design
+- github      : mi-kon
+  name        : Mike Kondrashin
+  organization: CompuCorp
 - github      : MiltoxBeyond
   name        : Milton Zurita
   jira        : MiltoxB
   jira        : ozyank
 - github      : PalanteJon
   name        : Jon Goldberg
+  organization: JMA Consulting
   jira        : palantejon
 - github      : petednz
   name        : Peter Davis
index 3458bc3081bdfaff5624d9b827fd058b8e4fc03f..18bc29f25c2eb0df4365c0d83e4f7f255104aee1 100644 (file)
@@ -127,7 +127,8 @@ li.menu-separator{
   line-height: 0; /* for ie */
   margin: 2px 0;
 }
-#civicrm-menu .crm-logo-sm {
+#civicrm-menu .crm-logo-sm,
+.crm-container .crm-logo-sm {
   background: url('../i/item_sprites.png') no-repeat scroll -80px -16px;
   display: inline-block;
   width: 16px;
index a0b14924a98e07512a9d748f1d3d760084176809..c29270bac9795acb7492d63749b5138bdb9e1187 100644 (file)
@@ -345,6 +345,26 @@ div#crm-contact-thumbnail {
   width: 100%;
 }
 
+#tagtree {
+  max-height: 500px;
+  overflow: auto;
+}
+
+#tagtree li {
+  margin-top: 5px;
+}
+#tagtree ins.jstree-icon {
+  cursor: pointer;
+  position: relative;
+  top: -3px;
+}
+#tagtree .jstree-disabled {
+  cursor: not-allowed;
+}
+#tagtree .jstree-disabled > .jstree-checkbox {
+  opacity: .2;
+}
+
 #tagGroup table .label {
   color: #FFF;
 }
index 0eb326d7fe5534baf41f59b6a07e14ae75e41bd6..99e8fab6fbf7173daacb3c3a31cb3ad975753105 100644 (file)
@@ -124,3 +124,8 @@ table.form-layout td, table.form-layout th {
     font-style       : italic;
     float            : right;
 }
+
+/* Fix for CRM-19869 */
+tr {
+    page-break-inside: avoid;
+}
diff --git a/docs/api.md b/docs/api.md
deleted file mode 100644 (file)
index adbe8ed..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-*The API*
-
-TODO: Assimilate http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
\ No newline at end of file
diff --git a/docs/build.md b/docs/build.md
deleted file mode 100644 (file)
index 19b91c3..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-*Build.md*
-
-TODO:
-
- * Nightlies vs gitify vs civibuild
- * gitify
- * civibuild (https://github.com/civicrm/civicrm-buildkit/blob/master/doc/civibuild.md)
diff --git a/docs/customize.md b/docs/customize.md
deleted file mode 100644 (file)
index c2377aa..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-*Customize*
-
-TODO:
-
- * *(Requirements: Don't need full git install)*
- * *(When possible, link to User/Admin Guide or other existing docs instead of giving details.)*
- * Custom fields, profiles, option groups, etc
- * webform_civicrm
- * Extensions (download+install; web and CLI).
- * (Maybe) CiviRules
- * (Maybe) CSS override
- * (Maybe) *.extra.tpl
diff --git a/docs/develop.md b/docs/develop.md
deleted file mode 100644 (file)
index f58af5f..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-*Develop*
-
-TODO: Assimilate http://wiki.civicrm.org/confluence/display/CRMDOC/GitHub+for+CiviCRM
diff --git a/docs/extend.md b/docs/extend.md
deleted file mode 100644 (file)
index 22d22a5..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-*Extend*
-
-TODO:
-
- * General overview: Use APIv3 and hooks. Package code in Civi extensions or CMS extensions (w/trade-offs).
- * Assimilate: http://wiki.civicrm.org/confluence/display/CRMDOC/Create+an+Extension
- * Assimilate: http://wiki.civicrm.org/confluence/display/CRMDOC/Publish+an+Extension
diff --git a/docs/hook.md b/docs/hook.md
deleted file mode 100644 (file)
index e071122..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-*The hooks*
-
-TODO:
-
- * http://wiki.civicrm.org/confluence/display/CRMDOC/Hooks
- * http://wiki.civicrm.org/confluence/display/CRMDOC/Hook+Reference
\ No newline at end of file
diff --git a/docs/index.md b/docs/index.md
deleted file mode 100644 (file)
index 691fecb..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-# Build
-
-CiviCRM is an open-source application which can be poked, prodded, twisted,
-and hacked.  It can be customized (with minimal code skills), extended (for
-add-ons and integrations), and collaboratively developed.
-
-<table>
-  <tbody>
-    <tr>
-      <td><a href="requirements">Requirements</a></td>
-      <td>Get the tools you need</td>
-    </tr>
-    <tr>
-      <td><a href="build">Git Install</a></td>
-      <td>Install the latest code from git</td>
-    </tr>
-    <tr>
-      <td><a href="customize">Customize</a></td>
-      <td>Change your site without coding</td>
-    </tr>
-    <tr>
-      <td><a href="extend">Extend</a></td>
-      <td>Create an add-on or integration</td>
-    </tr>
-    <tr>
-      <td><a href="develop">Develop</a></td>
-      <td>Create a feature or fix for CiviCRM</td>
-    </tr>
-    <tr>
-      <td><a href="test">Test</a></td>
-      <td>Make it good</td>
-    </tr>
-    <tr>
-      <td><a href="reference">Reference</a></td>
-      <td>Dig into the nitty-gritty</td>
-    </tr>
-  </tbody>
-</table>
-
-# Collaborate
-
-As an open-source project, CiviCRM is managed by an international community
-of developers and activists. If you have questions, issues, or want to make
-plans for new development, reach out online.
-
-<table>
-  <tbody>
-    <tr>
-      <td><a href="https://civicrm.org/blog">Blog</a></td>
-      <td>Read about the big developments</td>
-    </tr>
-    <tr>
-      <td><a href="http://forum.civicrm.org/">Forum</a></td>
-      <td>Converse in the public square</td>
-    </tr>
-    <tr>
-      <td><a href="https://github.com/civicrm/civicrm-core/">Github</a></td>
-      <td>Tap the firehose of core development</td>
-    </tr>
-    <tr>
-      <td><a href="FIXME">Guidelines</a></td>
-      <td>Check the rules of the road</td>
-    </tr>
-    <tr>
-      <td><a href="https://irc.civicrm.org/">IRC</a></td>
-      <td>Chat with other developers in real-time</td>
-    </tr>
-    <tr>
-      <td><a href="http://issues.civicrm.org/">Issues</a></td>
-      <td>Discover on-going and resolved issues</td>
-    </tr>
-    <tr>
-      <td><a href="FIXME">Publish</a></td>
-      <td>Share your extensions</td>
-    </tr>
-    <tr>
-      <td><a href="FIXME">Sprints</a></td>
-      <td>Get together IRL</td>
-    </tr>
-    <tr>
-      <td><a href="http://civicrm.stackexchange.com/">StackExchange</a></td>
-      <td>Ask questions. Find answers.</td>
-    </tr>
-    <tr>
-      <td><a href="http://wiki.civicrm.org/confluence/display/CRM/CiviCRM+Wiki">Wiki</a></td>
-      <td>Share drafts, notes, and specs</td>
-    </tr>
-  </tbody>
-</table>
diff --git a/docs/requirements.md b/docs/requirements.md
deleted file mode 100644 (file)
index 0fb7d13..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-# Languages and Services
-
- * Unix-like environment (Linux, OS X, or a virtual machine)
- * [PHP v5.3+](http://php.net/)
- * [MySQL v5.1+](http://mysql.com/)
- * [NodeJS](https://nodejs.org/)
- * [Git](https://git-scm.com/)
- * Recommended: Apache HTTPD v2.2+
- * Recommended: Ruby/Rake
-
-# Command Line
-
-There are many ways to install MySQL, PHP, and other dependencies -- for
-example, `apt-get` and `yum` can download packages automatically; `php.net`
-and `mysql.com` provide standalone installers; and MAMP/XAMPP provide
-bundled installers.
-
-Civi development should work with most packages -- but there's one proviso:
-***the command-line must support standard commands*** (`php`, `mysql`,
-`node`, `git`, `bash`, etc).
-
-Some packages are configured properly out-of-the-box. (Linux distributions
-do a pretty good job of this.) Other packages require extra configuration
-steps (e.g.  [Setup Command Line
-PHP](http://wiki.civicrm.org/confluence/display/CRMDOC/Setup+Command-Line+PHP)
-for MAMP).
-
-In subsequent steps, the download script will attempt to identify
-misconfigurations and display an appropriate message.
-
-# Buildkit
-
-The developer docs reference a large number of developer tools, such as
-`drush` (the Drupal command line), `civix` (the CiviCRM code-generator), and
-`karma` (the Javascript tester).
-
-Many of these tools are commonly used by web developers, so you may have
-already installed a few.  You could install all the tools individually --
-but that takes a lot of work.
-
-[civicrm-buildkit](https://github.com/civicrm/civicrm-buildkit) provides
-a script which downloads the full collection.
-
-### - Option #1: Full Stack Ubuntu (Opinionated)
-
-If you have a new installation of Ubuntu 12.04 or 14.04, then you can download everything -- buildkit and the system
-requirements (`git`, `php`, `apache`, `mysql`, etc) -- with one command.  This command will install buildkit to `~/buildkit`:
-
-```bash
-curl -Ls https://civicrm.org/get-buildkit.sh | bash -s -- --full --dir ~/buildkit
-```
-
-Note:
-
- * When executing the above command, you must ***NOT*** run as `root`. (Doing so will produce incorrect permissions.)
-   Instead, you must have `sudo` permissions.
- * The `--full` option is opinionated; it specifically installs `php`, `apache`, and `mysql` (rather than `hvm`, `nginx`, `lighttpd`, or `percona`).
-   If you try to mix `--full` with alternative systems, then expect conflicts.
-
-
-### - Option #2: Other Systems
-
-If you already installed the requirements (`git`, `php`, etc), then you can download buildkit to `~/buildkit` with these commands:
-
-```bash
-git clone https://github.com/civicrm/civicrm-buildkit.git buildkit
-cd buildkit/bin
-./civi-download-tools
-export PATH="$PWD:$PATH"
-```
-
-### - Option #3: Upgrade
-
-If you have previously downloaded buildkit and want to update it, run:
-
-```bash
-cd buildkit
-git pull
-./bin/civi-download-tools
-```
diff --git a/docs/test.md b/docs/test.md
deleted file mode 100644 (file)
index 8d4c4ea..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-*Test*
-
-TODO:
-
- * http://wiki.civicrm.org/confluence/display/CRMDOC/Testing
\ No newline at end of file
index 86f21fb46e73ee6b77ea9e10c84b0f7a965ae16c..499eb2eb73cd60c26d08deea0bd42ce680f4b4cd 100644 (file)
@@ -243,8 +243,16 @@ if (!CRM.vars) CRM.vars = {};
       var script = document.createElement('script');
       scriptsLoaded[url] = $.Deferred();
       script.onload = function () {
+        if (window.jQuery === CRM.$ && CRM.CMSjQuery) {
+          window.jQuery = CRM.CMSjQuery;
+        }
         scriptsLoaded[url].resolve();
       };
+      // Make jQuery global available while script is loading
+      if (window.jQuery !== CRM.$) {
+        CRM.CMSjQuery = window.jQuery;
+        window.jQuery = CRM.$;
+      }
       script.src = url;
       document.getElementsByTagName("head")[0].appendChild(script);
     }
@@ -765,58 +773,6 @@ if (!CRM.vars) CRM.vars = {};
     });
   };
 
-  $.fn.crmAjaxTable = function() {
-    // Strip the ids from ajax urls to make pageLength storage more generic
-    function simplifyUrl(ajax) {
-      // Datatables ajax prop could be a url string or an object containing the url
-      var url = typeof ajax === 'object' ? ajax.url : ajax;
-      return typeof url === 'string' ? url.replace(/[&?]\w*id=\d+/g, '') : null;
-    }
-
-    return $(this).each(function() {
-      // Recall pageLength for this table
-      var url = simplifyUrl($(this).data('ajax'));
-      if (url && window.localStorage && localStorage['dataTablePageLength:' + url]) {
-        $(this).data('pageLength', localStorage['dataTablePageLength:' + url]);
-      }
-      // Declare the defaults for DataTables
-      var defaults = {
-        "processing": true,
-        "serverSide": true,
-        "order": [],
-        "dom": '<"crm-datatable-pager-top"lfp>rt<"crm-datatable-pager-bottom"ip>',
-        "pageLength": 25,
-        "pagingType": "full_numbers",
-        "drawCallback": function(settings) {
-          //Add data attributes to cells
-          $('thead th', settings.nTable).each( function( index ) {
-            $.each(this.attributes, function() {
-              if(this.name.match("^cell-")) {
-                var cellAttr = this.name.substring(5);
-                var cellValue = this.value;
-                $('tbody tr', settings.nTable).each( function() {
-                  $('td:eq('+ index +')', this).attr( cellAttr, cellValue );
-                });
-              }
-            });
-          });
-          //Reload table after draw
-          $(settings.nTable).trigger('crmLoad');
-        }
-      };
-      //Include any table specific data
-      var settings = $.extend(true, defaults, $(this).data('table'));
-      // Remember pageLength
-      $(this).on('length.dt', function(e, settings, len) {
-        if (settings.ajax && window.localStorage) {
-          localStorage['dataTablePageLength:' + simplifyUrl(settings.ajax)] = len;
-        }
-      });
-      //Make the DataTables call
-      $(this).DataTable(settings);
-    });
-  };
-
   CRM.utils.formatSelect2Result = function (row) {
     var markup = '<div class="crm-select2-row">';
     if (row.image !== undefined) {
@@ -1037,14 +993,19 @@ if (!CRM.vars) CRM.vars = {};
       $('table.crm-ajax-table', e.target).each(function() {
         var
           $table = $(this),
+          script = CRM.config.resourceBase + 'js/jquery/jquery.crmAjaxTable.js',
           $accordion = $table.closest('.crm-accordion-wrapper.collapsed, .crm-collapsible.collapsed');
         // For tables hidden by collapsed accordions, wait.
         if ($accordion.length) {
           $accordion.one('crmAccordion:open', function() {
-            $table.crmAjaxTable();
+            CRM.loadScript(script).done(function() {
+              $table.crmAjaxTable();
+            });
           });
         } else {
-          $table.crmAjaxTable();
+          CRM.loadScript(script).done(function() {
+            $table.crmAjaxTable();
+          });
         }
       });
       if ($("input:radio[name=radio_ts]").size() == 1) {
@@ -1056,6 +1017,12 @@ if (!CRM.vars) CRM.vars = {};
       $('.crm-form-text[data-crm-datepicker]', e.target).each(function() {
         $(this).crmDatepicker($(this).data('crmDatepicker'));
       });
+      $('.crm-editable', e.target).not('thead *').each(function() {
+        var $el = $(this);
+        CRM.loadScript(CRM.config.resourceBase + 'js/jquery/jquery.crmEditable.js').done(function() {
+          $el.crmEditable();
+        });
+      });
       // Cache Form Input initial values
       $('form[data-warn-changes] :input', e.target).each(function() {
         $(this).data('crm-initial-value', $(this).is(':checkbox, :radio') ? $(this).prop('checked') : $(this).val());
@@ -1522,10 +1489,13 @@ if (!CRM.vars) CRM.vars = {};
         $(this).siblings('input:text').val('').trigger('change', ['crmClear']);
         return false;
       })
-      .on('change', 'input.crm-form-radio:checked, input[allowclear=1]', function(e, context) {
+      .on('change keyup', 'input.crm-form-radio:checked, input[allowclear=1]', function(e, context) {
         if (context !== 'crmClear' && ($(this).is(':checked') || ($(this).is('[allowclear=1]') && $(this).val()))) {
           $(this).siblings('.crm-clear-link').css({visibility: ''});
         }
+        if (context !== 'crmClear' && $(this).is('[allowclear=1]') && $(this).val() === '') {
+          $(this).siblings('.crm-clear-link').css({visibility: 'hidden'});
+        }
       })
 
       // Allow normal clicking of links within accordions
@@ -1658,8 +1628,11 @@ if (!CRM.vars) CRM.vars = {};
         return input;
 
       case 'string':
-        // convert iso format
-        return $.datepicker.parseDate('yy-mm-dd', input.substr(0, 10));
+        // convert iso format with or without dashes
+        if (input.indexOf('-') > 0) {
+          return $.datepicker.parseDate('yy-mm-dd', input.substr(0, 10));
+        }
+        return $.datepicker.parseDate('yymmdd', input.substr(0, 8));
 
       case 'number':
         // convert unix timestamp
index b01e814bf076d3c0613793ef8a43d97d5fd3e69b..262227ea895c2541ad775bde62b26a4f4217b353 100644 (file)
       url = $el.attr('href'),
       popup = $el.data('popup-type') === 'page' ? CRM.loadPage : CRM.loadForm,
       settings = $el.data('popup-settings') || {},
-      formSuccess = false;
+      formData = false;
     settings.dialog = settings.dialog || {};
     if (e.isDefaultPrevented() || !CRM.config.ajaxPopupsEnabled || !url || $el.is(exclude)) {
       return;
     // Trigger events from the dialog on the original link element
     $el.trigger('crmPopupOpen', [dialog]);
     // Listen for success events and buffer them so we only trigger once
-    dialog.on('crmFormSuccess.crmPopup crmPopupFormSuccess.crmPopup', function() {
-      formSuccess = true;
+    dialog.on('crmFormSuccess.crmPopup crmPopupFormSuccess.crmPopup', function(e, data) {
+      formData = data;
     });
     dialog.on('dialogclose.crmPopup', function(e, data) {
-      if (formSuccess) {
-        $el.trigger('crmPopupFormSuccess', [dialog, data]);
+      if (formData) {
+        $el.trigger('crmPopupFormSuccess', [dialog, formData]);
       }
       $el.trigger('crmPopupClose', [dialog, data]);
     });
index 2f14c499216e2e38bba0c202fc3a4d9b8cc9201d..7ed33666e29a834c01870d5f18cf10c59f83b13b 100644 (file)
@@ -10,5 +10,13 @@ CRM.$(function($) {
         // D7 hack, restore toolbar position (CRM-15341)
         $('#toolbar').css('z-index', '');
       }
-    });
+    })
+   // d8 Hack to hide title when it should be (CRM-19960)
+   .ready(function() {
+     var pageTitle = $('.page-title');
+     var title = $('.page-title').text();
+     if ('<span id="crm-remove-title" style="display:none">CiviCRM</span>' == title) {
+       pageTitle.hide();
+     }
+   });
 });
diff --git a/js/jquery/jquery.crmAjaxTable.js b/js/jquery/jquery.crmAjaxTable.js
new file mode 100644 (file)
index 0000000..66978e7
--- /dev/null
@@ -0,0 +1,59 @@
+// https://civicrm.org/licensing
+(function($, _) {
+  "use strict";
+  /* jshint validthis: true */
+
+  $.fn.crmAjaxTable = function() {
+
+    // Strip the ids from ajax urls to make pageLength storage more generic
+    function simplifyUrl(ajax) {
+      // Datatables ajax prop could be a url string or an object containing the url
+      var url = typeof ajax === 'object' ? ajax.url : ajax;
+      return typeof url === 'string' ? url.replace(/[&?]\w*id=\d+/g, '') : null;
+    }
+
+    return $(this).each(function() {
+      // Recall pageLength for this table
+      var url = simplifyUrl($(this).data('ajax'));
+      if (url && window.localStorage && localStorage['dataTablePageLength:' + url]) {
+        $(this).data('pageLength', localStorage['dataTablePageLength:' + url]);
+      }
+      // Declare the defaults for DataTables
+      var defaults = {
+        "processing": true,
+        "serverSide": true,
+        "order": [],
+        "dom": '<"crm-datatable-pager-top"lfp>rt<"crm-datatable-pager-bottom"ip>',
+        "pageLength": 25,
+        "pagingType": "full_numbers",
+        "drawCallback": function(settings) {
+          //Add data attributes to cells
+          $('thead th', settings.nTable).each( function( index ) {
+            $.each(this.attributes, function() {
+              if(this.name.match("^cell-")) {
+                var cellAttr = this.name.substring(5);
+                var cellValue = this.value;
+                $('tbody tr', settings.nTable).each( function() {
+                  $('td:eq('+ index +')', this).attr( cellAttr, cellValue );
+                });
+              }
+            });
+          });
+          //Reload table after draw
+          $(settings.nTable).trigger('crmLoad');
+        }
+      };
+      //Include any table specific data
+      var settings = $.extend(true, defaults, $(this).data('table'));
+      // Remember pageLength
+      $(this).on('length.dt', function(e, settings, len) {
+        if (settings.ajax && window.localStorage) {
+          localStorage['dataTablePageLength:' + simplifyUrl(settings.ajax)] = len;
+        }
+      });
+      //Make the DataTables call
+      $(this).DataTable(settings);
+    });
+  };
+
+})(CRM.$, CRM._);
similarity index 97%
rename from js/jquery/jquery.crmeditable.js
rename to js/jquery/jquery.crmEditable.js
index 453c4969320ff3e64d3c9e7acefd13ba394795c7..624f51b971b1137666570c4e994faca42b273657 100644 (file)
       }
       $i.addClass('crm-editable-enabled');
 
-      $i.editable(function(value, settings) {
+      function callback(value, settings) {
         $i.addClass('crm-editable-saving');
         var
           info = $i.crmEditableEntity(),
           .fail(function(data) {
             editableSettings.error.call($el[0], info.entity, info.field, value, data);
           });
-      }, settings);
+      }
+
+      CRM.loadScript(CRM.config.resourceBase + 'packages/jquery/plugins/jquery.jeditable.min.js').done(function() {
+        $i.editable(callback, settings);
+      });
 
       // CRM-15759 - Workaround broken textarea handling in jeditable 1.7.1
       $i.click(function() {
     });
   };
 
-  $(document).on('crmLoad', function(e) {
-    $('.crm-editable', e.target).not('thead *').crmEditable();
-  });
-
 })(jQuery, CRM._);
index 31fb325c9147476263f1fc9f28719719e1a4c889..c21ab0bee1d74e9db6a9b9bf58a7d446da633202 100644 (file)
@@ -14,6 +14,15 @@ Other resources for identifying changes are:
     * https://github.com/civicrm/civicrm-joomla
     * https://github.com/civicrm/civicrm-wordpress
 
+## CiviCRM 4.7.16
+
+Released February 8, 2017
+
+- **[Features](release-notes/4.7.16.md#features)**
+- **[Bugs resolved](release-notes/4.7.16.md#bugs)**
+- **[Miscellany](release-notes/4.7.16.md#misc)**
+- **[Credits](release-notes/4.7.16.md#credits)**
+
 ## CiviCRM 4.7.15
 
 Released January 4, 2017
diff --git a/release-notes/4.7.16.md b/release-notes/4.7.16.md
new file mode 100644 (file)
index 0000000..b8487b3
--- /dev/null
@@ -0,0 +1,550 @@
+# CiviCRM 4.7.16
+
+Released February 8, 2017
+
+- **[Features](#features)**
+- **[Bugs resolved](#bugs)**
+- **[Miscellany](#misc)**
+- **[Credits](#credits)**
+
+## <a name="features"></a>Features
+
+### Core CiviCRM
+
+- **[CRM-19925](https://issues.civicrm.org/jira/browse/CRM-19925) Add metadata
+  to fields array with entity info & date format info
+  ([9727](https://github.com/civicrm/civicrm-core/pull/9727))**
+
+  The data access objects (DAO) now include additional information for each
+  field, including the table name, entity, and business access object (BAO).
+
+- **[CRM-19829](https://issues.civicrm.org/jira/browse/CRM-19829) Activity feed
+  ([9714](https://github.com/civicrm/civicrm-core/pull/9714),
+  [9649](https://github.com/civicrm/civicrm-core/pull/9649), and
+  [9624](https://github.com/civicrm/civicrm-core/pull/9624))
+  (Preliminary work)**
+
+  The Attachment API now includes the appropriate icon class name from Font
+  Awesome, a `CRM.cache` object in Javascript is available to set and retrieve
+  information from `window.localStorage`, and a new Angular utility
+  `crmThrottle` prevents a function from running concurrently if called several
+  times in rapid succession.
+
+- **[CRM-19893](https://issues.civicrm.org/jira/browse/CRM-19893) Activity Type
+  Categories ([9696](https://github.com/civicrm/civicrm-core/pull/9696))
+  (Preliminary work)**
+
+  The option value form now displays the option's grouping if available.
+
+- **[CRM-19831](https://issues.civicrm.org/jira/browse/CRM-19831) Function
+  `CRM_Contact_BAO_Group::getGroupsHierarchy` performes bad with 3000 groups
+  ([9673](https://github.com/civicrm/civicrm-core/pull/9673) and
+  [9633](https://github.com/civicrm/civicrm-core/pull/9633))**
+
+  Group listing performance is improved on sites with many groups.
+
+- **[CRM-19256](https://issues.civicrm.org/jira/browse/CRM-19256) Add a hook to
+  dynamically escalate permissions
+  ([8916](https://github.com/civicrm/civicrm-core/pull/8916))**
+
+  A new `hook_civicrm_permission_check` is invoked whenever a user's permissions
+  are evaluated.  (See [hook
+  documentation](https://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_permission_check)
+  for details and examples.)
+
+- **[CRM-19853](https://issues.civicrm.org/jira/browse/CRM-19853) Change
+  interval select controls in Scheduled Reminders with number controls
+  ([9664](https://github.com/civicrm/civicrm-core/pull/9664))**
+
+  A few drop-down fields in the Scheduled Reminders interface that were simply
+  picking integers have been replaced with regular text fields.
+
+- **[CRM-19769](https://issues.civicrm.org/jira/browse/CRM-19769) Colors for
+  tags and [CRM-19779](https://issues.civicrm.org/jira/browse/CRM-19779) Colors
+  for activity statuses
+  ([9660](https://github.com/civicrm/civicrm-core/pull/9660),
+  [9600](https://github.com/civicrm/civicrm-core/pull/9600), and
+  [9554](https://github.com/civicrm/civicrm-core/pull/9554))**
+
+  You can choose colors for tags and activity statuses for better visibility.
+
+- **[CRM-19770](https://issues.civicrm.org/jira/browse/CRM-19770) Favorite
+  (starred) activities
+  ([9629](https://github.com/civicrm/civicrm-core/pull/9629))**
+
+  You can now mark favorite activities with stars.
+
+- **[CRM-19723](https://issues.civicrm.org/jira/browse/CRM-19723) Icons for
+  activity types ([9707](https://github.com/civicrm/civicrm-core/pull/9707),
+  [9553](https://github.com/civicrm/civicrm-core/pull/9553),
+  [9528](https://github.com/civicrm/civicrm-core/pull/9528),
+  and [9706](https://github.com/civicrm/civicrm-core/pull/9706)**
+
+  A user can now choose icons for activity types.
+
+- **[CRM-19816](https://issues.civicrm.org/jira/browse/CRM-19816) Improve
+  activity search filters
+  ([9609](https://github.com/civicrm/civicrm-core/pull/9609)) (Preliminary work)**
+
+  The `Activity.get` API is improved for filtering by related contact, case, and
+  tag.
+
+- **[CRM-19447](https://issues.civicrm.org/jira/browse/CRM-19447) Improve
+  Activity Subject/Details text search to be similiar to Notes Subject/Body
+  ([9536](https://github.com/civicrm/civicrm-core/pull/9536))**
+
+  Activity search now has a single "Activity Text" field for finding text in the
+  activity subject, details, or both.
+
+- **[CRM-19883](https://issues.civicrm.org/jira/browse/CRM-19883) Activity
+  Priority Field is Not Included in Advanced Search or Activity Reports
+  ([9687](https://github.com/civicrm/civicrm-core/pull/9687))**
+
+  The priority field is now available in search and activity reports.
+
+- **[CRM-19810](https://issues.civicrm.org/jira/browse/CRM-19810) Api3 - Add
+  joins on optionValue table
+  ([9593](https://github.com/civicrm/civicrm-core/pull/9593))**
+
+  Foreign keys to option values can now be used for joins in the API despite the
+  fact that they aren't true foreign keys.
+
+- **[CRM-19839](https://issues.civicrm.org/jira/browse/CRM-19839) Declare class
+  used on developer tab of CiviCRM reports
+  ([9646](https://github.com/civicrm/civicrm-core/pull/9646))**
+
+  When viewing the Developer tab on a report, you can now see the report class
+  in use.
+
+- **[CRM-19812](https://issues.civicrm.org/jira/browse/CRM-19812) Display
+  related contact names in activity.get api
+  ([9599](https://github.com/civicrm/civicrm-core/pull/9599))**
+
+  Activity assignees and targets are now available as return options in the
+  `Activity.get` API.
+
+### CiviCase
+
+- **[CRM-19806](https://issues.civicrm.org/jira/browse/CRM-19806) CiviCase using
+  two formlinks when it only needs one
+  ([9586](https://github.com/civicrm/civicrm-core/pull/9586))**
+
+  CiviCase now behaves like the rest of CiviCRM when creating action links in a
+  listing of cases.
+
+- **[CRM-19778](https://issues.civicrm.org/jira/browse/CRM-19778) Allowed
+  statuses per case-type
+  ([9705](https://github.com/civicrm/civicrm-core/pull/9705))**
+
+  Case types can be configured to restrict the available case statuses.
+
+### CiviContribute
+
+- **[CRM-8526](https://issues.civicrm.org/jira/browse/CRM-8526) Support
+  [contribution.custom_nn] tokens in templates
+  ([9661](https://github.com/civicrm/civicrm-core/pull/9661))**
+
+  You can now insert tokens for contribution custom fields.
+
+- **[CRM-16189](https://issues.civicrm.org/jira/browse/CRM-16189) Improve
+  support for Accrual Method bookkeeping
+  ([8870](https://github.com/civicrm/civicrm-core/pull/8870)) (Completes previous work)**
+
+  A "Record Payment" button is now available on contributions.
+
+### CiviEvent
+
+- **Add select2 class to loc_event_id
+  ([9603](https://github.com/civicrm/civicrm-core/pull/9603))**
+
+  The field for re-using the location of another event now uses a `select2`
+  widget.
+
+### CiviMail
+
+- **[CRM-19690](https://issues.civicrm.org/jira/browse/CRM-19690) Allow
+  alternative email templating systems
+  ([9689](https://github.com/civicrm/civicrm-core/pull/9689),
+  [9566](https://github.com/civicrm/civicrm-core/pull/9566),
+  [9619](https://github.com/civicrm/civicrm-core/pull/9619),
+  [9565](https://github.com/civicrm/civicrm-core/pull/9565),
+  [9564](https://github.com/civicrm/civicrm-core/pull/9564),
+  [9563](https://github.com/civicrm/civicrm-core/pull/9563), and
+  [9562](https://github.com/civicrm/civicrm-core/pull/9562))**
+
+  Extensions can now specify mailing template types with template options.
+  These types can be associated with different template editors, such as
+  [Mosaico](https://github.com/veda-consulting/uk.co.vedaconsulting.mosaico).
+  The way tokens are presented and evaluated in CiviMail is also streamlined.
+  This also passes mail delivery to the FlexMailer extension when it is enabled.
+
+### Drupal Integration Modules
+
+- **[CRM-17917](https://issues.civicrm.org/jira/browse/CRM-17917) Add support
+  for Drupal 8 ([388](https://github.com/civicrm/civicrm-drupal/pull/388)) (Continues previous work)**
+
+  Several small improvements were made, making it easier to install CiviCRM on Drupal 8 using [Buildkit](https://buildkit.civicrm.org/).
+
+## <a name="bugs"></a>Bugs resolved
+
+### Core CiviCRM
+
+- **[CRM-19874](https://issues.civicrm.org/jira/browse/CRM-19874) Allow
+  overriding sort in the getlist API without clobbering pager
+  ([9675](https://github.com/civicrm/civicrm-core/pull/9675))**
+
+  The default pager parameters are no longer ignored when other `options` are set in a `getlist` API.
+
+- **[CRM-19783](https://issues.civicrm.org/jira/browse/CRM-19783) Accessibility
+  Error - CiviCRM Subscription Page
+  ([9606](https://github.com/civicrm/civicrm-core/pull/9606))**
+
+- **Remove unused var, comments & clean up & refactor caching function
+  ([9721](https://github.com/civicrm/civicrm-core/pull/9721))**
+
+- **[CRM-19906](https://issues.civicrm.org/jira/browse/CRM-19906) Allow Drupal
+  user names with "@"
+  ([9708](https://github.com/civicrm/civicrm-core/pull/9708))**
+
+- **[CRM-19003](https://issues.civicrm.org/jira/browse/CRM-19003) Profile
+  listing doesn't produce expected results when range-searching custom date
+  field ([9699](https://github.com/civicrm/civicrm-core/pull/9699))**
+
+- **[CRM-19801](https://issues.civicrm.org/jira/browse/CRM-19801) changing the
+  same relationship type of a relationship from A to B or vice versa does not
+  work ([9579](https://github.com/civicrm/civicrm-core/pull/9579))**
+
+- **[CRM-19842](https://issues.civicrm.org/jira/browse/CRM-19842) Can't delete a
+  dedupe rule ([9698](https://github.com/civicrm/civicrm-core/pull/9698))**
+
+- **typo fix in New Tag Form.
+  ([9700](https://github.com/civicrm/civicrm-core/pull/9700))**
+
+- **CRM_Extension_Browser - Allow different cache files for different feeds
+  ([9693](https://github.com/civicrm/civicrm-core/pull/9693))**
+
+- **[CRM-17663](https://issues.civicrm.org/jira/browse/CRM-17663) Dashlet code
+  improvements ([9672](https://github.com/civicrm/civicrm-core/pull/9672))
+  (Completes previous work)**
+
+  An upgrade step now fixes dashlets named `NULL`.
+
+- **Fire hook_civicrm_emailProcessor('activity') if Activity,create successful
+  ([9651](https://github.com/civicrm/civicrm-core/pull/9651))**
+
+- **Civi\API\ExternalBatch - Verify that $_ENV is working
+  ([9595](https://github.com/civicrm/civicrm-core/pull/9595))**
+
+- **[CRM-19847](https://issues.civicrm.org/jira/browse/CRM-19847) batch merge
+  redirects users to snippet URL
+  ([9653](https://github.com/civicrm/civicrm-core/pull/9653))**
+
+- **(NFC) Civi/*, CRM_Utils_SQL_Select - Fix various warnings
+  ([9657](https://github.com/civicrm/civicrm-core/pull/9657))**
+
+- **[CRM-19824](https://issues.civicrm.org/jira/browse/CRM-19824) Event
+  listeners are missing if container cache is disabled
+  ([9617](https://github.com/civicrm/civicrm-core/pull/9617))**
+
+- **[CRM-19826](https://issues.civicrm.org/jira/browse/CRM-19826) Extensions in
+  "vendor" folder have errant slash
+  ([9618](https://github.com/civicrm/civicrm-core/pull/9618))**
+
+- **[CRM-19706](https://issues.civicrm.org/jira/browse/CRM-19706) Smart Group
+  criteria (Activity Status) are not being retained when using 'Edit Smart Group
+  criteria' ([9620](https://github.com/civicrm/civicrm-core/pull/9620))**
+
+- **[CRM-19624](https://issues.civicrm.org/jira/browse/CRM-19624) Exclude /
+  Include by privacy radio buttons gets reset on Smartgroup re-editing
+  ([9597](https://github.com/civicrm/civicrm-core/pull/9597))**
+
+- **[CRM-19805](https://issues.civicrm.org/jira/browse/CRM-19805) Comparing
+  instead of Assigning
+  ([9591](https://github.com/civicrm/civicrm-core/pull/9591))**
+
+  This fixes three typos in the codebase where `==` was used instead of `=`.
+
+- **[CRM-19244](https://issues.civicrm.org/jira/browse/CRM-19244) Custom fields
+  with option group not importing
+  ([8906](https://github.com/civicrm/civicrm-core/pull/8906))**
+
+- **OptionValue Api cleanup - remove unnecessary lookup
+  ([9569](https://github.com/civicrm/civicrm-core/pull/9569))**
+
+- **[CRM-18472](https://issues.civicrm.org/jira/browse/CRM-18472) Notice fixes
+  ([9558](https://github.com/civicrm/civicrm-core/pull/9558)) (Completes
+  previous work)**
+
+  Avoids a PHP notice on deleting soft credits.
+
+- **Upgrade cleanup - use addColumn utility instead of sql
+  ([9548](https://github.com/civicrm/civicrm-core/pull/9548))**
+
+- **API Explorer: Minor usability improvements
+  ([9539](https://github.com/civicrm/civicrm-core/pull/9539))**
+
+- **[CRM-19832](https://issues.civicrm.org/jira/browse/CRM-19832)
+  hook_civicrm_searchTasks get invoked twice for some entities
+  ([9637](https://github.com/civicrm/civicrm-core/pull/9637))**
+
+- **[CRM-19875](https://issues.civicrm.org/jira/browse/CRM-19875) Search
+  builder: Fatal error when searching custom field of type "country"
+  ([9695](https://github.com/civicrm/civicrm-core/pull/9695))**
+
+- **[CRM-19811](https://issues.civicrm.org/jira/browse/CRM-19811) Slow queries
+  due to use of LOWER() in mysql searches, fix contribution search, current
+  employer. Comment elsewhere
+  ([9596](https://github.com/civicrm/civicrm-core/pull/9596))**
+
+- **[CRM-19884](https://issues.civicrm.org/jira/browse/CRM-19884) DB Error on
+  Activity Details Report
+  ([9681](https://github.com/civicrm/civicrm-core/pull/9681))**
+
+- **[CRM-19509](https://issues.civicrm.org/jira/browse/CRM-19509) Add character
+  set and collation to create table statements in reports
+  ([9411](https://github.com/civicrm/civicrm-core/pull/9411))**
+
+- **[CRM-19807](https://issues.civicrm.org/jira/browse/CRM-19807) MySQL error
+  when adding contacts on a report to a group
+  ([9594](https://github.com/civicrm/civicrm-core/pull/9594))**
+
+- **[CRM-18591](https://issues.civicrm.org/jira/browse/CRM-18591) group_type
+  parameter ignored when using API to create group
+  ([9578](https://github.com/civicrm/civicrm-core/pull/9578)) (Completes
+  previous work)**
+
+  This improves the handling of checkboxes on the group edit form.
+
+### Accounting
+
+- **[CRM-19800](https://issues.civicrm.org/jira/browse/CRM-19800) Incorrect
+  Amount recorded in civicrm_financial_trxn table
+  ([9577](https://github.com/civicrm/civicrm-core/pull/9577))**
+
+  This fixes problems when money amounts were entered with a thousands
+  delimiter.
+
+- **[CRM-19585](https://issues.civicrm.org/jira/browse/CRM-19585) Sales tax
+  issue ([9598](https://github.com/civicrm/civicrm-core/pull/9598),
+  [9576](https://github.com/civicrm/civicrm-core/pull/9576),
+  [9590](https://github.com/civicrm/civicrm-core/pull/9590), and
+  [9574](https://github.com/civicrm/civicrm-core/pull/9574)) (Preliminary
+  work)**
+
+  A variety of problems have been partially fixed.
+
+- **[CRM-19804](https://issues.civicrm.org/jira/browse/CRM-19804) Pre() and
+  Post() hook for Financial Account
+  ([9584](https://github.com/civicrm/civicrm-core/pull/9584))**
+
+### CiviCase
+
+- **[CRM-19890](https://issues.civicrm.org/jira/browse/CRM-19890) Case Manager
+  listed in cases tab is not up to date
+  ([9691](https://github.com/civicrm/civicrm-core/pull/9691))**
+
+- **[CRM-19754](https://issues.civicrm.org/jira/browse/CRM-19754) CiviCase role
+  relationships reversed
+  ([9560](https://github.com/civicrm/civicrm-core/pull/9560))**
+
+- **[CRM-19897](https://issues.civicrm.org/jira/browse/CRM-19897) Cannot edit
+  multiple case activities via profile, because deprecated "access CiviCase"
+  permission is referenced
+  ([9703](https://github.com/civicrm/civicrm-core/pull/9703))**
+
+- **Docs fix: update for changed URL of Case Management > Setup page.
+  ([9701](https://github.com/civicrm/civicrm-core/pull/9701))**
+
+### CiviContribute
+
+- **[CRM-19172](https://issues.civicrm.org/jira/browse/CRM-19172) on behalf form +
+  user account creation attempts to create user for org
+  ([9669](https://github.com/civicrm/civicrm-core/pull/9669))**
+
+- **[CRM-19863](https://issues.civicrm.org/jira/browse/CRM-19863) 'item_name'
+  unnecessarily truncated when passed to PayPal
+  ([9677](https://github.com/civicrm/civicrm-core/pull/9677))**
+
+- **[CRM-19725](https://issues.civicrm.org/jira/browse/CRM-19725) Honoree should
+  never be same as donor
+  ([9503](https://github.com/civicrm/civicrm-core/pull/9503))**
+
+- **[CRM-19761](https://issues.civicrm.org/jira/browse/CRM-19761) contribution
+  thank you letter generator: unable to export to docx
+  ([9575](https://github.com/civicrm/civicrm-core/pull/9575) and
+  [9568](https://github.com/civicrm/civicrm-core/pull/9568))**
+
+- **[CRM-19799](https://issues.civicrm.org/jira/browse/CRM-19799) LineItems
+  incorrect at both Contribution Level and Financial Accounts Level
+  ([9580](https://github.com/civicrm/civicrm-core/pull/9580))**
+
+- **[CRM-19802](https://issues.civicrm.org/jira/browse/CRM-19802) Contribution
+  page : missing translation
+  ([9581](https://github.com/civicrm/civicrm-core/pull/9581))**
+
+- **[CRM-19777](https://issues.civicrm.org/jira/browse/CRM-19777) Edit
+  contribution : wrong decimal separator on total_amount
+  ([9556](https://github.com/civicrm/civicrm-core/pull/9556))**
+
+- **[CRM-19795](https://issues.civicrm.org/jira/browse/CRM-19795) Contribution
+  page confirmation screen undefined index pay_later_receipt
+  ([9632](https://github.com/civicrm/civicrm-core/pull/9632))**
+
+- **[CRM-19794](https://issues.civicrm.org/jira/browse/CRM-19794) Wrong fields
+  displayed when setting a price set for a contribution page
+  ([9697](https://github.com/civicrm/civicrm-core/pull/9697))**
+
+### CiviEvent
+
+- **[CRM-19860](https://issues.civicrm.org/jira/browse/CRM-19860) Event
+  participant batch update: respect "options per line" setting for radio buttons
+  ([9667](https://github.com/civicrm/civicrm-core/pull/9667))**
+
+- **[CRM-19907](https://issues.civicrm.org/jira/browse/CRM-19907) Syntax error
+  generated on CiviEvent Dashboard when show_events is null
+  ([9709](https://github.com/civicrm/civicrm-core/pull/9709))**
+
+- **[CRM-19789](https://issues.civicrm.org/jira/browse/CRM-19789) Cannot create
+  smart group from 'Find participants'
+  ([9567](https://github.com/civicrm/civicrm-core/pull/9567))**
+
+- **[CRM-19782](https://issues.civicrm.org/jira/browse/CRM-19782) "View" link on
+  printed Participant Listing Report renders display name unreadable
+  ([9546](https://github.com/civicrm/civicrm-core/pull/9546))**
+
+- **[CRM-19803](https://issues.civicrm.org/jira/browse/CRM-19803) View Payment
+  popup of a participant does not show refunds
+  ([9634](https://github.com/civicrm/civicrm-core/pull/9634) and
+  [9592](https://github.com/civicrm/civicrm-core/pull/9592))**
+
+- **[CRM-19288](https://issues.civicrm.org/jira/browse/CRM-19288) VAT not
+  included for additional participant fee when registering for events
+  ([9545](https://github.com/civicrm/civicrm-core/pull/9545))**
+
+### CiviMail
+
+- **[CRM-19413](https://issues.civicrm.org/jira/browse/CRM-19413) CiviMail: Test
+  mail notice errors: undefined index
+  ([9550](https://github.com/civicrm/civicrm-core/pull/9550))**
+
+### CiviMember
+
+- **[CRM-19895](https://issues.civicrm.org/jira/browse/CRM-19895) membership
+  renewal page style collapsed if email disabled
+  ([9713](https://github.com/civicrm/civicrm-core/pull/9713))**
+
+- **[CRM-19936](https://issues.civicrm.org/jira/browse/CRM-19936) Membership
+  line items are duplicated when a membership is created or renewed with
+  priceset containing multiple memberships
+  ([9748](https://github.com/civicrm/civicrm-core/pull/9748))
+  (Preliminary work)**
+
+- **[CRM-19817](https://issues.civicrm.org/jira/browse/CRM-19817) Notice error
+  fails membership export
+  ([9610](https://github.com/civicrm/civicrm-core/pull/9610))**
+
+  Membership export with data from related contacts was causing PHP notices or
+  complete failure, depending upon the CMS.
+
+- **Fix startdate for testMembershipJoinDateFixed
+  ([9608](https://github.com/civicrm/civicrm-core/pull/9608))**
+
+### Drupal Integration
+
+- **[CRM-19740](https://issues.civicrm.org/jira/browse/CRM-19740) Regression in
+  phone number Drupal views integration
+  ([415](https://github.com/civicrm/civicrm-drupal/pull/415))**
+
+  A problem has been fixed where the same phone number would show up for each of
+  a contact's location/phone types in Views.
+
+- **CiviCRM Menu -- Add PathProcessor to allow parameters to routes to include
+  slashes ([420](https://github.com/civicrm/civicrm-drupal/pull/420))**
+
+- **[CRM-19086](https://issues.civicrm.org/jira/browse/CRM-19086) CiviCRM Core
+  Installation fails on Drupal 8.1.x and
+  [CRM-18297](https://issues.civicrm.org/jira/browse/CRM-18297) Drupal 8 Crash
+  on Admin Config page
+  ([419](https://github.com/civicrm/civicrm-drupal/pull/419))**
+
+### Joomla Integration
+
+- **[CRM-19877](https://issues.civicrm.org/jira/browse/CRM-19877) on Joomla
+  api.Setting.create fails with "option,task not valid settings"
+  ([9678](https://github.com/civicrm/civicrm-core/pull/9678))**
+
+## <a name="misc"></a>Miscellany
+
+- **Comment fixes plus fix inconsistent unused return bool
+  ([9722](https://github.com/civicrm/civicrm-core/pull/9722))**
+
+- **[nfc] Updated test generated examples
+  ([9720](https://github.com/civicrm/civicrm-core/pull/9720))**
+
+- **[nfc] Comment fixes, remove one unused var, declare visibility
+  ([9717](https://github.com/civicrm/civicrm-core/pull/9717))**
+
+- **[NFC] add comments & extract function in contribution search
+  ([9716](https://github.com/civicrm/civicrm-core/pull/9716))**
+
+- **Comment Fixes ([9659](https://github.com/civicrm/civicrm-core/pull/9659))**
+
+- **Comments ([9658](https://github.com/civicrm/civicrm-core/pull/9658))**
+
+- **Add comment blocks
+  ([9656](https://github.com/civicrm/civicrm-core/pull/9656))**
+
+- **allow descendant classes to access the cache array
+  ([9605](https://github.com/civicrm/civicrm-core/pull/9605))**
+
+- **(NFC) CRM_*_Tokens - Reduce redundant docs
+  ([9573](https://github.com/civicrm/civicrm-core/pull/9573))**
+
+- **tools/scripts/phpunit-ls - Fix PhpStorm lookup of PHPUnit_Framework_TestCase
+  ([9535](https://github.com/civicrm/civicrm-core/pull/9535))**
+
+- **[CRM-19768](https://issues.civicrm.org/jira/browse/CRM-19768)
+  CRM_Utils_Token::replace*Tokens() usage is inconsistent
+  ([9541](https://github.com/civicrm/civicrm-core/pull/9541)) (Preliminary
+  work)**
+
+- **Convert drupal to Backdrop and change variable_get/set to state_get/set
+  ([21](https://github.com/civicrm/civicrm-backdrop/pull/21))**
+
+- **fix header ([9607](https://github.com/civicrm/civicrm-core/pull/9607))**
+
+- **fix headers ([421](https://github.com/civicrm/civicrm-drupal/pull/421))**
+
+- **fix headers ([109](https://github.com/civicrm/civicrm-wordpress/pull/109))**
+
+- **fix headers ([42](https://github.com/civicrm/civicrm-joomla/pull/42))**
+
+## <a name="credits"></a>Credits
+
+This release was developed by the following code authors:
+
+AGH Strategies - Alice Frumin, Andrew Hunt; ATD Fourth World - Véronique
+Gratioulet; Agileware - Agileware Team; Aidan Saunders; AppChecker; Australian
+reens - Seamus Lee; CiviCRM - Coleman Watts, Jitendra Purohit, Tim Otten, Monish
+Deb, Yashodha Chaku; CiviCoop - Jaap Jansma; CiviDesk - Nicolas Ganivet;
+Community Builders - Dejan Lukic; CompuCorp - Omar Abu Hussein; Coop SymbioTIC -
+Mathieu Lutfy; Erich Schulz; Freeform Solutions - Herb van den Dool; Fuzion -
+Chris Burgess, Eileen McNaughton; Ginkgo Street Labs - Frank Gómez; JMA
+Consulting - Edsel Lopez, Jon Goldberg, Pradeep Nayak; John Kingsnorth; Joinery -
+Allen Shaw; Klaas Eikelboom; Klangsoft - David Reedy Jr; Lighthouse Design and
+Consulting - Brian Shaughnessy; Marc Brazeau; Progressive Technology Project -
+Jamie McClelland; Skvare - Mark Hanna; Wikimedia Foundation - Eileen McNaughton
+
+Most authors also reviewed code for this release; in addition, the following
+reviewers contributed their comments:
+
+AGH Strategies - Tommy Bobo; Christian Wach; Circle Interactive - Dave Jenkins;
+CiviCRM - Donald Lobo, Rohan Katkar; Community IT Academy - William Mortada;
+CompuCorp - Madura Krishnamoorthy, Mike Kondrashin; Denver DataMan - Steve
+Kessler; Digitalcourage - Detlev Sieber; Fedor Khodkov; Forest CRM Consulting -
+Tamar Meir; Fuzion - Peter Davis; Ginkgo Street Labs - Frank Gómez; Glick
+Software - David Glick; iXiam - Vangelis Pantazis; JMA Consulting - Joe Murray;
+Kacper Warda; Ken West; Korlon - Stuart Gaston; Naomi Rosenberg; Noah Miller;
+Oxfam Germany - Thomas Schüttler; Richard van Oosterhout; Robert Lang; Semper IT -
+Karin Gerritsen; Tadpole Collective - Kevin Cristiano; University of Hawaii at
+Manoa - Center on Disability Studies - William Rems; Vakees K; Valéry Gouleau
index 0b35e75822059163b85573644aa6f78a5cf5e2d3..eaa0fe10fb06be172740a2d7b2d07ac458de5974 100644 (file)
@@ -918,4 +918,18 @@ return array(
     'description' => ts('Default to only loading matches against this number of contacts'),
     'help_text' => ts('Deduping larger databases can crash the server. By configuring a limit other than 0 here the dedupe query will only search for matches against a limited number of contacts.'),
   ),
+  'syncCMSEmail' => array(
+    'group_name' => 'CiviCRM Preferences',
+    'group' => 'core',
+    'name' => 'syncCMSEmail',
+    'type' => 'Boolean',
+    'quick_form_type' => 'YesNo',
+    'default' => 1,
+    'add' => '4.7',
+    'title' => 'Sync CMS Email',
+    'is_domain' => 1,
+    'is_contact' => 0,
+    'description' => 'If enabled, then CMS email id will be syncronised with CiviCRM contacts\'s primary email.',
+    'help_text' => NULL,
+  ),
 );
index 71f6e677d6dc5426945d0944f460a8eee5511ee7..6cc84b3f6123e8de090df818de58835f7a0daa35 100644 (file)
@@ -197,4 +197,18 @@ return array(
     'description' => 'If set, this will be the default profile used for contact search.',
     'help_text' => NULL,
   ),
+  'searchPrimaryDetailsOnly' => array(
+    'group_name' => 'Search Preferences',
+    'group' => 'Search Preferences',
+    'name' => 'searchPrimaryDetailsOnly',
+    'type' => 'Boolean',
+    'quick_form_type' => 'YesNo',
+    'default' => 1,
+    'add' => '4.7',
+    'title' => 'Search Primary Details Only',
+    'is_domain' => 1,
+    'is_contact' => 0,
+    'description' => 'If enabled, only primary details (eg contact\'s primary email, phone, etc) will be included in Basic and Advanced Search results. Disabling this feature will allow users to match contacts using any email, phone etc detail.',
+    'help_text' => NULL,
+  ),
 );
index 8e692636fbc7abd19428ea1013343a7c2b6e8b1c..e7c68633f2ffd808fc3f15cd956e0ce245e27b46 100644 (file)
@@ -1326,7 +1326,7 @@ UNLOCK TABLES;
 
 LOCK TABLES `civicrm_state_province` WRITE;
 /*!40000 ALTER TABLE `civicrm_state_province` DISABLE KEYS */;
-INSERT INTO `civicrm_state_province` (`id`, `name`, `abbreviation`, `country_id`) VALUES (1000,'Alabama','AL',1228),(1001,'Alaska','AK',1228),(1002,'Arizona','AZ',1228),(1003,'Arkansas','AR',1228),(1004,'California','CA',1228),(1005,'Colorado','CO',1228),(1006,'Connecticut','CT',1228),(1007,'Delaware','DE',1228),(1008,'Florida','FL',1228),(1009,'Georgia','GA',1228),(1010,'Hawaii','HI',1228),(1011,'Idaho','ID',1228),(1012,'Illinois','IL',1228),(1013,'Indiana','IN',1228),(1014,'Iowa','IA',1228),(1015,'Kansas','KS',1228),(1016,'Kentucky','KY',1228),(1017,'Louisiana','LA',1228),(1018,'Maine','ME',1228),(1019,'Maryland','MD',1228),(1020,'Massachusetts','MA',1228),(1021,'Michigan','MI',1228),(1022,'Minnesota','MN',1228),(1023,'Mississippi','MS',1228),(1024,'Missouri','MO',1228),(1025,'Montana','MT',1228),(1026,'Nebraska','NE',1228),(1027,'Nevada','NV',1228),(1028,'New Hampshire','NH',1228),(1029,'New Jersey','NJ',1228),(1030,'New Mexico','NM',1228),(1031,'New York','NY',1228),(1032,'North Carolina','NC',1228),(1033,'North Dakota','ND',1228),(1034,'Ohio','OH',1228),(1035,'Oklahoma','OK',1228),(1036,'Oregon','OR',1228),(1037,'Pennsylvania','PA',1228),(1038,'Rhode Island','RI',1228),(1039,'South Carolina','SC',1228),(1040,'South Dakota','SD',1228),(1041,'Tennessee','TN',1228),(1042,'Texas','TX',1228),(1043,'Utah','UT',1228),(1044,'Vermont','VT',1228),(1045,'Virginia','VA',1228),(1046,'Washington','WA',1228),(1047,'West Virginia','WV',1228),(1048,'Wisconsin','WI',1228),(1049,'Wyoming','WY',1228),(1050,'District of Columbia','DC',1228),(1052,'American Samoa','AS',1228),(1053,'Guam','GU',1228),(1055,'Northern Mariana Islands','MP',1228),(1056,'Puerto Rico','PR',1228),(1057,'Virgin Islands','VI',1228),(1058,'United States Minor Outlying Islands','UM',1228),(1059,'Armed Forces Europe','AE',1228),(1060,'Armed Forces Americas','AA',1228),(1061,'Armed Forces Pacific','AP',1228),(1100,'Alberta','AB',1039),(1101,'British Columbia','BC',1039),(1102,'Manitoba','MB',1039),(1103,'New Brunswick','NB',1039),(1104,'Newfoundland and Labrador','NL',1039),(1105,'Northwest Territories','NT',1039),(1106,'Nova Scotia','NS',1039),(1107,'Nunavut','NU',1039),(1108,'Ontario','ON',1039),(1109,'Prince Edward Island','PE',1039),(1110,'Quebec','QC',1039),(1111,'Saskatchewan','SK',1039),(1112,'Yukon Territory','YT',1039),(1200,'Maharashtra','MM',1101),(1201,'Karnataka','KA',1101),(1202,'Andhra Pradesh','AP',1101),(1203,'Arunachal Pradesh','AR',1101),(1204,'Assam','AS',1101),(1205,'Bihar','BR',1101),(1206,'Chhattisgarh','CH',1101),(1207,'Goa','GA',1101),(1208,'Gujarat','GJ',1101),(1209,'Haryana','HR',1101),(1210,'Himachal Pradesh','HP',1101),(1211,'Jammu and Kashmir','JK',1101),(1212,'Jharkhand','JH',1101),(1213,'Kerala','KL',1101),(1214,'Madhya Pradesh','MP',1101),(1215,'Manipur','MN',1101),(1216,'Meghalaya','ML',1101),(1217,'Mizoram','MZ',1101),(1218,'Nagaland','NL',1101),(1219,'Orissa','OR',1101),(1220,'Punjab','PB',1101),(1221,'Rajasthan','RJ',1101),(1222,'Sikkim','SK',1101),(1223,'Tamil Nadu','TN',1101),(1224,'Tripura','TR',1101),(1225,'Uttaranchal','UL',1101),(1226,'Uttar Pradesh','UP',1101),(1227,'West Bengal','WB',1101),(1228,'Andaman and Nicobar Islands','AN',1101),(1229,'Dadra and Nagar Haveli','DN',1101),(1230,'Daman and Diu','DD',1101),(1231,'Delhi','DL',1101),(1232,'Lakshadweep','LD',1101),(1233,'Pondicherry','PY',1101),(1300,'mazowieckie','MZ',1172),(1301,'pomorskie','PM',1172),(1302,'dolnośląskie','DS',1172),(1303,'kujawsko-pomorskie','KP',1172),(1304,'lubelskie','LU',1172),(1305,'lubuskie','LB',1172),(1306,'łódzkie','LD',1172),(1307,'małopolskie','MA',1172),(1308,'opolskie','OP',1172),(1309,'podkarpackie','PK',1172),(1310,'podlaskie','PD',1172),(1311,'śląskie','SL',1172),(1312,'świętokrzyskie','SK',1172),(1313,'warmińsko-mazurskie','WN',1172),(1314,'wielkopolskie','WP',1172),(1315,'zachodniopomorskie','ZP',1172),(1500,'Abu Zaby','AZ',1225),(1501,'\'Ajman','AJ',1225),(1502,'Al Fujayrah','FU',1225),(1503,'Ash Shariqah','SH',1225),(1504,'Dubayy','DU',1225),(1505,'Ra\'s al Khaymah','RK',1225),(1506,'Dac Lac','33',1233),(1507,'Umm al Qaywayn','UQ',1225),(1508,'Badakhshan','BDS',1001),(1509,'Badghis','BDG',1001),(1510,'Baghlan','BGL',1001),(1511,'Balkh','BAL',1001),(1512,'Bamian','BAM',1001),(1513,'Farah','FRA',1001),(1514,'Faryab','FYB',1001),(1515,'Ghazni','GHA',1001),(1516,'Ghowr','GHO',1001),(1517,'Helmand','HEL',1001),(1518,'Herat','HER',1001),(1519,'Jowzjan','JOW',1001),(1520,'Kabul','KAB',1001),(1521,'Kandahar','KAN',1001),(1522,'Kapisa','KAP',1001),(1523,'Khowst','KHO',1001),(1524,'Konar','KNR',1001),(1525,'Kondoz','KDZ',1001),(1526,'Laghman','LAG',1001),(1527,'Lowgar','LOW',1001),(1528,'Nangrahar','NAN',1001),(1529,'Nimruz','NIM',1001),(1530,'Nurestan','NUR',1001),(1531,'Oruzgan','ORU',1001),(1532,'Paktia','PIA',1001),(1533,'Paktika','PKA',1001),(1534,'Parwan','PAR',1001),(1535,'Samangan','SAM',1001),(1536,'Sar-e Pol','SAR',1001),(1537,'Takhar','TAK',1001),(1538,'Wardak','WAR',1001),(1539,'Zabol','ZAB',1001),(1540,'Berat','BR',1002),(1541,'Bulqizë','BU',1002),(1542,'Delvinë','DL',1002),(1543,'Devoll','DV',1002),(1544,'Dibër','DI',1002),(1545,'Durrës','DR',1002),(1546,'Elbasan','EL',1002),(1547,'Fier','FR',1002),(1548,'Gramsh','GR',1002),(1549,'Gjirokastër','GJ',1002),(1550,'Has','HA',1002),(1551,'Kavajë','KA',1002),(1552,'Kolonjë','ER',1002),(1553,'Korçë','KO',1002),(1554,'Krujë','KR',1002),(1555,'Kuçovë','KC',1002),(1556,'Kukës','KU',1002),(1557,'Kurbin','KB',1002),(1558,'Lezhë','LE',1002),(1559,'Librazhd','LB',1002),(1560,'Lushnjë','LU',1002),(1561,'Malësi e Madhe','MM',1002),(1562,'Mallakastër','MK',1002),(1563,'Mat','MT',1002),(1564,'Mirditë','MR',1002),(1565,'Peqin','PQ',1002),(1566,'Përmet','PR',1002),(1567,'Pogradec','PG',1002),(1568,'Pukë','PU',1002),(1569,'Sarandë','SR',1002),(1570,'Skrapar','SK',1002),(1571,'Shkodër','SH',1002),(1572,'Tepelenë','TE',1002),(1573,'Tiranë','TR',1002),(1574,'Tropojë','TP',1002),(1575,'Vlorë','VL',1002),(1576,'Erevan','ER',1011),(1577,'Aragacotn','AG',1011),(1578,'Ararat','AR',1011),(1579,'Armavir','AV',1011),(1580,'Gegarkunik\'','GR',1011),(1581,'Kotayk\'','KT',1011),(1582,'Lory','LO',1011),(1583,'Sirak','SH',1011),(1584,'Syunik\'','SU',1011),(1585,'Tavus','TV',1011),(1586,'Vayoc Jor','VD',1011),(1587,'Bengo','BGO',1006),(1588,'Benguela','BGU',1006),(1589,'Bie','BIE',1006),(1590,'Cabinda','CAB',1006),(1591,'Cuando-Cubango','CCU',1006),(1592,'Cuanza Norte','CNO',1006),(1593,'Cuanza Sul','CUS',1006),(1594,'Cunene','CNN',1006),(1595,'Huambo','HUA',1006),(1596,'Huila','HUI',1006),(1597,'Luanda','LUA',1006),(1598,'Lunda Norte','LNO',1006),(1599,'Lunda Sul','LSU',1006),(1600,'Malange','MAL',1006),(1601,'Moxico','MOX',1006),(1602,'Namibe','NAM',1006),(1603,'Uige','UIG',1006),(1604,'Zaire','ZAI',1006),(1605,'Capital federal','C',1010),(1606,'Buenos Aires','B',1010),(1607,'Catamarca','K',1010),(1608,'Cordoba','X',1010),(1609,'Corrientes','W',1010),(1610,'Chaco','H',1010),(1611,'Chubut','U',1010),(1612,'Entre Rios','E',1010),(1613,'Formosa','P',1010),(1614,'Jujuy','Y',1010),(1615,'La Pampa','L',1010),(1616,'Mendoza','M',1010),(1617,'Misiones','N',1010),(1618,'Neuquen','Q',1010),(1619,'Rio Negro','R',1010),(1620,'Salta','A',1010),(1621,'San Juan','J',1010),(1622,'San Luis','D',1010),(1623,'Santa Cruz','Z',1010),(1624,'Santa Fe','S',1010),(1625,'Santiago del Estero','G',1010),(1626,'Tierra del Fuego','V',1010),(1627,'Tucuman','T',1010),(1628,'Burgenland','1',1014),(1629,'Kärnten','2',1014),(1630,'Niederosterreich','3',1014),(1631,'Oberosterreich','4',1014),(1632,'Salzburg','5',1014),(1633,'Steiermark','6',1014),(1634,'Tirol','7',1014),(1635,'Vorarlberg','8',1014),(1636,'Wien','9',1014),(1637,'Australian Antarctic Territory','AAT',1008),(1638,'Australian Capital Territory','ACT',1013),(1639,'Northern Territory','NT',1013),(1640,'New South Wales','NSW',1013),(1641,'Queensland','QLD',1013),(1642,'South Australia','SA',1013),(1643,'Tasmania','TAS',1013),(1644,'Victoria','VIC',1013),(1645,'Western Australia','WA',1013),(1646,'Naxcivan','NX',1015),(1647,'Ali Bayramli','AB',1015),(1648,'Baki','BA',1015),(1649,'Ganca','GA',1015),(1650,'Lankaran','LA',1015),(1651,'Mingacevir','MI',1015),(1652,'Naftalan','NA',1015),(1653,'Saki','SA',1015),(1654,'Sumqayit','SM',1015),(1655,'Susa','SS',1015),(1656,'Xankandi','XA',1015),(1657,'Yevlax','YE',1015),(1658,'Abseron','ABS',1015),(1659,'Agcabadi','AGC',1015),(1660,'Agdam','AGM',1015),(1661,'Agdas','AGS',1015),(1662,'Agstafa','AGA',1015),(1663,'Agsu','AGU',1015),(1664,'Astara','AST',1015),(1665,'Babak','BAB',1015),(1666,'Balakan','BAL',1015),(1667,'Barda','BAR',1015),(1668,'Beylagan','BEY',1015),(1669,'Bilasuvar','BIL',1015),(1670,'Cabrayll','CAB',1015),(1671,'Calilabad','CAL',1015),(1672,'Culfa','CUL',1015),(1673,'Daskasan','DAS',1015),(1674,'Davaci','DAV',1015),(1675,'Fuzuli','FUZ',1015),(1676,'Gadabay','GAD',1015),(1677,'Goranboy','GOR',1015),(1678,'Goycay','GOY',1015),(1679,'Haciqabul','HAC',1015),(1680,'Imisli','IMI',1015),(1681,'Ismayilli','ISM',1015),(1682,'Kalbacar','KAL',1015),(1683,'Kurdamir','KUR',1015),(1684,'Lacin','LAC',1015),(1685,'Lerik','LER',1015),(1686,'Masalli','MAS',1015),(1687,'Neftcala','NEF',1015),(1688,'Oguz','OGU',1015),(1689,'Ordubad','ORD',1015),(1690,'Qabala','QAB',1015),(1691,'Qax','QAX',1015),(1692,'Qazax','QAZ',1015),(1693,'Qobustan','QOB',1015),(1694,'Quba','QBA',1015),(1695,'Qubadli','QBI',1015),(1696,'Qusar','QUS',1015),(1697,'Saatli','SAT',1015),(1698,'Sabirabad','SAB',1015),(1699,'Sadarak','SAD',1015),(1700,'Sahbuz','SAH',1015),(1701,'Salyan','SAL',1015),(1702,'Samaxi','SMI',1015),(1703,'Samkir','SKR',1015),(1704,'Samux','SMX',1015),(1705,'Sarur','SAR',1015),(1706,'Siyazan','SIY',1015),(1707,'Tartar','TAR',1015),(1708,'Tovuz','TOV',1015),(1709,'Ucar','UCA',1015),(1710,'Xacmaz','XAC',1015),(1711,'Xanlar','XAN',1015),(1712,'Xizi','XIZ',1015),(1713,'Xocali','XCI',1015),(1714,'Xocavand','XVD',1015),(1715,'Yardimli','YAR',1015),(1716,'Zangilan','ZAN',1015),(1717,'Zaqatala','ZAQ',1015),(1718,'Zardab','ZAR',1015),(1719,'Federacija Bosna i Hercegovina','BIH',1026),(1720,'Republika Srpska','SRP',1026),(1721,'Bagerhat zila','05',1017),(1722,'Bandarban zila','01',1017),(1723,'Barguna zila','02',1017),(1724,'Barisal zila','06',1017),(1725,'Bhola zila','07',1017),(1726,'Bogra zila','03',1017),(1727,'Brahmanbaria zila','04',1017),(1728,'Chandpur zila','09',1017),(1729,'Chittagong zila','10',1017),(1730,'Chuadanga zila','12',1017),(1731,'Comilla zila','08',1017),(1732,'Cox\'s Bazar zila','11',1017),(1733,'Dhaka zila','13',1017),(1734,'Dinajpur zila','14',1017),(1735,'Faridpur zila','15',1017),(1736,'Feni zila','16',1017),(1737,'Gaibandha zila','19',1017),(1738,'Gazipur zila','18',1017),(1739,'Gopalganj zila','17',1017),(1740,'Habiganj zila','20',1017),(1741,'Jaipurhat zila','24',1017),(1742,'Jamalpur zila','21',1017),(1743,'Jessore zila','22',1017),(1744,'Jhalakati zila','25',1017),(1745,'Jhenaidah zila','23',1017),(1746,'Khagrachari zila','29',1017),(1747,'Khulna zila','27',1017),(1748,'Kishorganj zila','26',1017),(1749,'Kurigram zila','28',1017),(1750,'Kushtia zila','30',1017),(1751,'Lakshmipur zila','31',1017),(1752,'Lalmonirhat zila','32',1017),(1753,'Madaripur zila','36',1017),(1754,'Magura zila','37',1017),(1755,'Manikganj zila','33',1017),(1756,'Meherpur zila','39',1017),(1757,'Moulvibazar zila','38',1017),(1758,'Munshiganj zila','35',1017),(1759,'Mymensingh zila','34',1017),(1760,'Naogaon zila','48',1017),(1761,'Narail zila','43',1017),(1762,'Narayanganj zila','40',1017),(1763,'Narsingdi zila','42',1017),(1764,'Natore zila','44',1017),(1765,'Nawabganj zila','45',1017),(1766,'Netrakona zila','41',1017),(1767,'Nilphamari zila','46',1017),(1768,'Noakhali zila','47',1017),(1769,'Pabna zila','49',1017),(1770,'Panchagarh zila','52',1017),(1771,'Patuakhali zila','51',1017),(1772,'Pirojpur zila','50',1017),(1773,'Rajbari zila','53',1017),(1774,'Rajshahi zila','54',1017),(1775,'Rangamati zila','56',1017),(1776,'Rangpur zila','55',1017),(1777,'Satkhira zila','58',1017),(1778,'Shariatpur zila','62',1017),(1779,'Sherpur zila','57',1017),(1780,'Sirajganj zila','59',1017),(1781,'Sunamganj zila','61',1017),(1782,'Sylhet zila','60',1017),(1783,'Tangail zila','63',1017),(1784,'Thakurgaon zila','64',1017),(1785,'Antwerpen','VAN',1020),(1786,'Brabant Wallon','WBR',1020),(1787,'Hainaut','WHT',1020),(1788,'Liege','WLG',1020),(1789,'Limburg','VLI',1020),(1790,'Luxembourg','WLX',1020),(1791,'Namur','WNA',1020),(1792,'Oost-Vlaanderen','VOV',1020),(1793,'Vlaams-Brabant','VBR',1020),(1794,'West-Vlaanderen','VWV',1020),(1795,'Bale','BAL',1034),(1796,'Bam','BAM',1034),(1797,'Banwa','BAN',1034),(1798,'Bazega','BAZ',1034),(1799,'Bougouriba','BGR',1034),(1800,'Boulgou','BLG',1034),(1801,'Boulkiemde','BLK',1034),(1802,'Comoe','COM',1034),(1803,'Ganzourgou','GAN',1034),(1804,'Gnagna','GNA',1034),(1805,'Gourma','GOU',1034),(1806,'Houet','HOU',1034),(1807,'Ioba','IOB',1034),(1808,'Kadiogo','KAD',1034),(1809,'Kenedougou','KEN',1034),(1810,'Komondjari','KMD',1034),(1811,'Kompienga','KMP',1034),(1812,'Kossi','KOS',1034),(1813,'Koulpulogo','KOP',1034),(1814,'Kouritenga','KOT',1034),(1815,'Kourweogo','KOW',1034),(1816,'Leraba','LER',1034),(1817,'Loroum','LOR',1034),(1818,'Mouhoun','MOU',1034),(1819,'Nahouri','NAO',1034),(1820,'Namentenga','NAM',1034),(1821,'Nayala','NAY',1034),(1822,'Noumbiel','NOU',1034),(1823,'Oubritenga','OUB',1034),(1824,'Oudalan','OUD',1034),(1825,'Passore','PAS',1034),(1826,'Poni','PON',1034),(1827,'Sanguie','SNG',1034),(1828,'Sanmatenga','SMT',1034),(1829,'Seno','SEN',1034),(1830,'Siasili','SIS',1034),(1831,'Soum','SOM',1034),(1832,'Sourou','SOR',1034),(1833,'Tapoa','TAP',1034),(1834,'Tui','TUI',1034),(1835,'Yagha','YAG',1034),(1836,'Yatenga','YAT',1034),(1837,'Ziro','ZIR',1034),(1838,'Zondoma','ZON',1034),(1839,'Zoundweogo','ZOU',1034),(1840,'Blagoevgrad','01',1033),(1841,'Burgas','02',1033),(1842,'Dobrich','08',1033),(1843,'Gabrovo','07',1033),(1844,'Haskovo','26',1033),(1845,'Yambol','28',1033),(1846,'Kardzhali','09',1033),(1847,'Kyustendil','10',1033),(1848,'Lovech','11',1033),(1849,'Montana','12',1033),(1850,'Pazardzik','13',1033),(1851,'Pernik','14',1033),(1852,'Pleven','15',1033),(1853,'Plovdiv','16',1033),(1854,'Razgrad','17',1033),(1855,'Ruse','18',1033),(1856,'Silistra','19',1033),(1857,'Sliven','20',1033),(1858,'Smolyan','21',1033),(1859,'Sofia','23',1033),(1860,'Stara Zagora','24',1033),(1861,'Shumen','27',1033),(1862,'Targovishte','25',1033),(1863,'Varna','03',1033),(1864,'Veliko Tarnovo','04',1033),(1865,'Vidin','05',1033),(1866,'Vratsa','06',1033),(1867,'Al Hadd','01',1016),(1868,'Al Manamah','03',1016),(1869,'Al Mintaqah al Gharbiyah','10',1016),(1870,'Al Mintagah al Wusta','07',1016),(1871,'Al Mintaqah ash Shamaliyah','05',1016),(1872,'Al Muharraq','02',1016),(1873,'Ar Rifa','09',1016),(1874,'Jidd Hafs','04',1016),(1875,'Madluat Jamad','12',1016),(1876,'Madluat Isa','08',1016),(1877,'Mintaqat Juzur tawar','11',1016),(1878,'Sitrah','06',1016),(1879,'Bubanza','BB',1036),(1880,'Bujumbura','BJ',1036),(1881,'Bururi','BR',1036),(1882,'Cankuzo','CA',1036),(1883,'Cibitoke','CI',1036),(1884,'Gitega','GI',1036),(1885,'Karuzi','KR',1036),(1886,'Kayanza','KY',1036),(1887,'Makamba','MA',1036),(1888,'Muramvya','MU',1036),(1889,'Mwaro','MW',1036),(1890,'Ngozi','NG',1036),(1891,'Rutana','RT',1036),(1892,'Ruyigi','RY',1036),(1893,'Alibori','AL',1022),(1894,'Atakora','AK',1022),(1895,'Atlantique','AQ',1022),(1896,'Borgou','BO',1022),(1897,'Collines','CO',1022),(1898,'Donga','DO',1022),(1899,'Kouffo','KO',1022),(1900,'Littoral','LI',1022),(1901,'Mono','MO',1022),(1902,'Oueme','OU',1022),(1903,'Plateau','PL',1022),(1904,'Zou','ZO',1022),(1905,'Belait','BE',1032),(1906,'Brunei-Muara','BM',1032),(1907,'Temburong','TE',1032),(1908,'Tutong','TU',1032),(1909,'Cochabamba','C',1025),(1910,'Chuquisaca','H',1025),(1911,'El Beni','B',1025),(1912,'La Paz','L',1025),(1913,'Oruro','O',1025),(1914,'Pando','N',1025),(1915,'Potosi','P',1025),(1916,'Tarija','T',1025),(1917,'Acre','AC',1029),(1918,'Alagoas','AL',1029),(1919,'Amazonas','AM',1029),(1920,'Amapa','AP',1029),(1921,'Bahia','BA',1029),(1922,'Ceara','CE',1029),(1923,'Distrito Federal','DF',1029),(1924,'Espirito Santo','ES',1029),(1926,'Goias','GO',1029),(1927,'Maranhao','MA',1029),(1928,'Minas Gerais','MG',1029),(1929,'Mato Grosso do Sul','MS',1029),(1930,'Mato Grosso','MT',1029),(1931,'Para','PA',1029),(1932,'Paraiba','PB',1029),(1933,'Pernambuco','PE',1029),(1934,'Piaui','PI',1029),(1935,'Parana','PR',1029),(1936,'Rio de Janeiro','RJ',1029),(1937,'Rio Grande do Norte','RN',1029),(1938,'Rondonia','RO',1029),(1939,'Roraima','RR',1029),(1940,'Rio Grande do Sul','RS',1029),(1941,'Santa Catarina','SC',1029),(1942,'Sergipe','SE',1029),(1943,'Sao Paulo','SP',1029),(1944,'Tocantins','TO',1029),(1945,'Acklins and Crooked Islands','AC',1212),(1946,'Bimini','BI',1212),(1947,'Cat Island','CI',1212),(1948,'Exuma','EX',1212),(1955,'Inagua','IN',1212),(1957,'Long Island','LI',1212),(1959,'Mayaguana','MG',1212),(1960,'New Providence','NP',1212),(1962,'Ragged Island','RI',1212),(1966,'Bumthang','33',1024),(1967,'Chhukha','12',1024),(1968,'Dagana','22',1024),(1969,'Gasa','GA',1024),(1970,'Ha','13',1024),(1971,'Lhuentse','44',1024),(1972,'Monggar','42',1024),(1973,'Paro','11',1024),(1974,'Pemagatshel','43',1024),(1975,'Punakha','23',1024),(1976,'Samdrup Jongkha','45',1024),(1977,'Samtee','14',1024),(1978,'Sarpang','31',1024),(1979,'Thimphu','15',1024),(1980,'Trashigang','41',1024),(1981,'Trashi Yangtse','TY',1024),(1982,'Trongsa','32',1024),(1983,'Tsirang','21',1024),(1984,'Wangdue Phodrang','24',1024),(1985,'Zhemgang','34',1024),(1986,'Central','CE',1027),(1987,'Ghanzi','GH',1027),(1988,'Kgalagadi','KG',1027),(1989,'Kgatleng','KL',1027),(1990,'Kweneng','KW',1027),(1991,'Ngamiland','NG',1027),(1992,'North-East','NE',1027),(1993,'North-West','NW',1027),(1994,'South-East','SE',1027),(1995,'Southern','SO',1027),(1996,'Brèsckaja voblasc\'','BR',1019),(1997,'Homel\'skaja voblasc\'','HO',1019),(1998,'Hrodzenskaja voblasc\'','HR',1019),(1999,'Mahilëuskaja voblasc\'','MA',1019),(2000,'Minskaja voblasc\'','MI',1019),(2001,'Vicebskaja voblasc\'','VI',1019),(2002,'Belize','BZ',1021),(2003,'Cayo','CY',1021),(2004,'Corozal','CZL',1021),(2005,'Orange Walk','OW',1021),(2006,'Stann Creek','SC',1021),(2007,'Toledo','TOL',1021),(2008,'Kinshasa','KN',1050),(2011,'Equateur','EQ',1050),(2014,'Kasai-Oriental','KE',1050),(2016,'Maniema','MA',1050),(2017,'Nord-Kivu','NK',1050),(2019,'Sud-Kivu','SK',1050),(2020,'Bangui','BGF',1042),(2021,'Bamingui-Bangoran','BB',1042),(2022,'Basse-Kotto','BK',1042),(2023,'Haute-Kotto','HK',1042),(2024,'Haut-Mbomou','HM',1042),(2025,'Kemo','KG',1042),(2026,'Lobaye','LB',1042),(2027,'Mambere-Kadei','HS',1042),(2028,'Mbomou','MB',1042),(2029,'Nana-Grebizi','KB',1042),(2030,'Nana-Mambere','NM',1042),(2031,'Ombella-Mpoko','MP',1042),(2032,'Ouaka','UK',1042),(2033,'Ouham','AC',1042),(2034,'Ouham-Pende','OP',1042),(2035,'Sangha-Mbaere','SE',1042),(2036,'Vakaga','VR',1042),(2037,'Brazzaville','BZV',1051),(2038,'Bouenza','11',1051),(2039,'Cuvette','8',1051),(2040,'Cuvette-Ouest','15',1051),(2041,'Kouilou','5',1051),(2042,'Lekoumou','2',1051),(2043,'Likouala','7',1051),(2044,'Niari','9',1051),(2045,'Plateaux','14',1051),(2046,'Pool','12',1051),(2047,'Sangha','13',1051),(2048,'Aargau','AG',1205),(2049,'Appenzell Innerrhoden','AI',1205),(2050,'Appenzell Ausserrhoden','AR',1205),(2051,'Bern','BE',1205),(2052,'Basel-Landschaft','BL',1205),(2053,'Basel-Stadt','BS',1205),(2054,'Fribourg','FR',1205),(2055,'Geneva','GE',1205),(2056,'Glarus','GL',1205),(2057,'Graubunden','GR',1205),(2058,'Jura','JU',1205),(2059,'Luzern','LU',1205),(2060,'Neuchatel','NE',1205),(2061,'Nidwalden','NW',1205),(2062,'Obwalden','OW',1205),(2063,'Sankt Gallen','SG',1205),(2064,'Schaffhausen','SH',1205),(2065,'Solothurn','SO',1205),(2066,'Schwyz','SZ',1205),(2067,'Thurgau','TG',1205),(2068,'Ticino','TI',1205),(2069,'Uri','UR',1205),(2070,'Vaud','VD',1205),(2071,'Valais','VS',1205),(2072,'Zug','ZG',1205),(2073,'Zurich','ZH',1205),(2074,'18 Montagnes','06',1054),(2075,'Agnebi','16',1054),(2076,'Bas-Sassandra','09',1054),(2077,'Denguele','10',1054),(2078,'Haut-Sassandra','02',1054),(2079,'Lacs','07',1054),(2080,'Lagunes','01',1054),(2081,'Marahoue','12',1054),(2082,'Moyen-Comoe','05',1054),(2083,'Nzi-Comoe','11',1054),(2084,'Savanes','03',1054),(2085,'Sud-Bandama','15',1054),(2086,'Sud-Comoe','13',1054),(2087,'Vallee du Bandama','04',1054),(2088,'Worodouqou','14',1054),(2089,'Zanzan','08',1054),(2090,'Aisen del General Carlos Ibanez del Campo','AI',1044),(2091,'Antofagasta','AN',1044),(2092,'Araucania','AR',1044),(2093,'Atacama','AT',1044),(2094,'Bio-Bio','BI',1044),(2095,'Coquimbo','CO',1044),(2096,'Libertador General Bernardo O\'Higgins','LI',1044),(2097,'Los Lagos','LL',1044),(2098,'Magallanes','MA',1044),(2099,'Maule','ML',1044),(2100,'Santiago Metropolitan','SM',1044),(2101,'Tarapaca','TA',1044),(2102,'Valparaiso','VS',1044),(2103,'Adamaoua','AD',1038),(2104,'Centre','CE',1038),(2105,'East','ES',1038),(2106,'Far North','EN',1038),(2107,'North','NO',1038),(2108,'South','SW',1038),(2109,'South-West','SW',1038),(2110,'West','OU',1038),(2111,'Beijing','11',1045),(2112,'Chongqing','50',1045),(2113,'Shanghai','31',1045),(2114,'Tianjin','12',1045),(2115,'Anhui','34',1045),(2116,'Fujian','35',1045),(2117,'Gansu','62',1045),(2118,'Guangdong','44',1045),(2119,'Guizhou','52',1045),(2120,'Hainan','46',1045),(2121,'Hebei','13',1045),(2122,'Heilongjiang','23',1045),(2123,'Henan','41',1045),(2124,'Hubei','42',1045),(2125,'Hunan','43',1045),(2126,'Jiangsu','32',1045),(2127,'Jiangxi','36',1045),(2128,'Jilin','22',1045),(2129,'Liaoning','21',1045),(2130,'Qinghai','63',1045),(2131,'Shaanxi','61',1045),(2132,'Shandong','37',1045),(2133,'Shanxi','14',1045),(2134,'Sichuan','51',1045),(2135,'Taiwan','71',1045),(2136,'Yunnan','53',1045),(2137,'Zhejiang','33',1045),(2138,'Guangxi','45',1045),(2139,'Neia Mongol (mn)','15',1045),(2140,'Xinjiang','65',1045),(2141,'Xizang','54',1045),(2142,'Hong Kong','91',1045),(2143,'Macau','92',1045),(2144,'Distrito Capital de Bogotá','DC',1048),(2145,'Amazonea','AMA',1048),(2146,'Antioquia','ANT',1048),(2147,'Arauca','ARA',1048),(2148,'Atlántico','ATL',1048),(2149,'Bolívar','BOL',1048),(2150,'Boyacá','BOY',1048),(2151,'Caldea','CAL',1048),(2152,'Caquetá','CAQ',1048),(2153,'Casanare','CAS',1048),(2154,'Cauca','CAU',1048),(2155,'Cesar','CES',1048),(2156,'Córdoba','COR',1048),(2157,'Cundinamarca','CUN',1048),(2158,'Chocó','CHO',1048),(2159,'Guainía','GUA',1048),(2160,'Guaviare','GUV',1048),(2161,'La Guajira','LAG',1048),(2162,'Magdalena','MAG',1048),(2163,'Meta','MET',1048),(2164,'Nariño','NAR',1048),(2165,'Norte de Santander','NSA',1048),(2166,'Putumayo','PUT',1048),(2167,'Quindio','QUI',1048),(2168,'Risaralda','RIS',1048),(2169,'San Andrés, Providencia y Santa Catalina','SAP',1048),(2170,'Santander','SAN',1048),(2171,'Sucre','SUC',1048),(2172,'Tolima','TOL',1048),(2173,'Valle del Cauca','VAC',1048),(2174,'Vaupés','VAU',1048),(2175,'Vichada','VID',1048),(2176,'Alajuela','A',1053),(2177,'Cartago','C',1053),(2178,'Guanacaste','G',1053),(2179,'Heredia','H',1053),(2180,'Limon','L',1053),(2181,'Puntarenas','P',1053),(2182,'San Jose','SJ',1053),(2183,'Camagey','09',1056),(2184,'Ciego de `vila','08',1056),(2185,'Cienfuegos','06',1056),(2186,'Ciudad de La Habana','03',1056),(2187,'Granma','12',1056),(2188,'Guantanamo','14',1056),(2189,'Holquin','11',1056),(2190,'La Habana','02',1056),(2191,'Las Tunas','10',1056),(2192,'Matanzas','04',1056),(2193,'Pinar del Rio','01',1056),(2194,'Sancti Spiritus','07',1056),(2195,'Santiago de Cuba','13',1056),(2196,'Villa Clara','05',1056),(2197,'Isla de la Juventud','99',1056),(2198,'Pinar del Roo','PR',1056),(2199,'Ciego de Avila','CA',1056),(2200,'Camagoey','CG',1056),(2201,'Holgun','HO',1056),(2202,'Sancti Spritus','SS',1056),(2203,'Municipio Especial Isla de la Juventud','IJ',1056),(2204,'Boa Vista','BV',1040),(2205,'Brava','BR',1040),(2206,'Calheta de Sao Miguel','CS',1040),(2207,'Fogo','FO',1040),(2208,'Maio','MA',1040),(2209,'Mosteiros','MO',1040),(2210,'Paul','PA',1040),(2211,'Porto Novo','PN',1040),(2212,'Praia','PR',1040),(2213,'Ribeira Grande','RG',1040),(2214,'Sal','SL',1040),(2215,'Sao Domingos','SD',1040),(2216,'Sao Filipe','SF',1040),(2217,'Sao Nicolau','SN',1040),(2218,'Sao Vicente','SV',1040),(2219,'Tarrafal','TA',1040),(2220,'Ammochostos Magusa','04',1057),(2221,'Keryneia','06',1057),(2222,'Larnaka','03',1057),(2223,'Lefkosia','01',1057),(2224,'Lemesos','02',1057),(2225,'Pafos','05',1057),(2226,'Jihočeský kraj','JC',1058),(2227,'Jihomoravský kraj','JM',1058),(2228,'Karlovarský kraj','KA',1058),(2229,'Královéhradecký kraj','KR',1058),(2230,'Liberecký kraj','LI',1058),(2231,'Moravskoslezský kraj','MO',1058),(2232,'Olomoucký kraj','OL',1058),(2233,'Pardubický kraj','PA',1058),(2234,'Plzeňský kraj','PL',1058),(2235,'Praha, hlavní město','PR',1058),(2236,'Středočeský kraj','ST',1058),(2237,'Ústecký kraj','US',1058),(2238,'Vysočina','VY',1058),(2239,'Zlínský kraj','ZL',1058),(2240,'Baden-Wuerttemberg','BW',1082),(2241,'Bayern','BY',1082),(2242,'Bremen','HB',1082),(2243,'Hamburg','HH',1082),(2244,'Hessen','HE',1082),(2245,'Niedersachsen','NI',1082),(2246,'Nordrhein-Westfalen','NW',1082),(2247,'Rheinland-Pfalz','RP',1082),(2248,'Saarland','SL',1082),(2249,'Schleswig-Holstein','SH',1082),(2250,'Berlin','BR',1082),(2251,'Brandenburg','BB',1082),(2252,'Mecklenburg-Vorpommern','MV',1082),(2253,'Sachsen','SN',1082),(2254,'Sachsen-Anhalt','ST',1082),(2255,'Thueringen','TH',1082),(2256,'Ali Sabiah','AS',1060),(2257,'Dikhil','DI',1060),(2258,'Djibouti','DJ',1060),(2259,'Obock','OB',1060),(2260,'Tadjoura','TA',1060),(2261,'Frederiksberg','147',1059),(2262,'Copenhagen City','101',1059),(2263,'Copenhagen','015',1059),(2264,'Frederiksborg','020',1059),(2265,'Roskilde','025',1059),(2266,'Vestsjælland','030',1059),(2267,'Storstrøm','035',1059),(2268,'Bornholm','040',1059),(2269,'Fyn','042',1059),(2270,'South Jutland','050',1059),(2271,'Ribe','055',1059),(2272,'Vejle','060',1059),(2273,'Ringkjøbing','065',1059),(2274,'Århus','070',1059),(2275,'Viborg','076',1059),(2276,'North Jutland','080',1059),(2277,'Distrito Nacional (Santo Domingo)','01',1062),(2278,'Azua','02',1062),(2279,'Bahoruco','03',1062),(2280,'Barahona','04',1062),(2281,'Dajabón','05',1062),(2282,'Duarte','06',1062),(2283,'El Seybo [El Seibo]','08',1062),(2284,'Espaillat','09',1062),(2285,'Hato Mayor','30',1062),(2286,'Independencia','10',1062),(2287,'La Altagracia','11',1062),(2288,'La Estrelleta [Elias Pina]','07',1062),(2289,'La Romana','12',1062),(2290,'La Vega','13',1062),(2291,'Maroia Trinidad Sánchez','14',1062),(2292,'Monseñor Nouel','28',1062),(2293,'Monte Cristi','15',1062),(2294,'Monte Plata','29',1062),(2295,'Pedernales','16',1062),(2296,'Peravia','17',1062),(2297,'Puerto Plata','18',1062),(2298,'Salcedo','19',1062),(2299,'Samaná','20',1062),(2300,'San Cristóbal','21',1062),(2301,'San Pedro de Macorís','23',1062),(2302,'Sánchez Ramírez','24',1062),(2303,'Santiago','25',1062),(2304,'Santiago Rodríguez','26',1062),(2305,'Valverde','27',1062),(2306,'Adrar','01',1003),(2307,'Ain Defla','44',1003),(2308,'Ain Tmouchent','46',1003),(2309,'Alger','16',1003),(2310,'Annaba','23',1003),(2311,'Batna','05',1003),(2312,'Bechar','08',1003),(2313,'Bejaia','06',1003),(2314,'Biskra','07',1003),(2315,'Blida','09',1003),(2316,'Bordj Bou Arreridj','34',1003),(2317,'Bouira','10',1003),(2318,'Boumerdes','35',1003),(2319,'Chlef','02',1003),(2320,'Constantine','25',1003),(2321,'Djelfa','17',1003),(2322,'El Bayadh','32',1003),(2323,'El Oued','39',1003),(2324,'El Tarf','36',1003),(2325,'Ghardaia','47',1003),(2326,'Guelma','24',1003),(2327,'Illizi','33',1003),(2328,'Jijel','18',1003),(2329,'Khenchela','40',1003),(2330,'Laghouat','03',1003),(2331,'Mascara','29',1003),(2332,'Medea','26',1003),(2333,'Mila','43',1003),(2334,'Mostaganem','27',1003),(2335,'Msila','28',1003),(2336,'Naama','45',1003),(2337,'Oran','31',1003),(2338,'Ouargla','30',1003),(2339,'Oum el Bouaghi','04',1003),(2340,'Relizane','48',1003),(2341,'Saida','20',1003),(2342,'Setif','19',1003),(2343,'Sidi Bel Abbes','22',1003),(2344,'Skikda','21',1003),(2345,'Souk Ahras','41',1003),(2346,'Tamanghasset','11',1003),(2347,'Tebessa','12',1003),(2348,'Tiaret','14',1003),(2349,'Tindouf','37',1003),(2350,'Tipaza','42',1003),(2351,'Tissemsilt','38',1003),(2352,'Tizi Ouzou','15',1003),(2353,'Tlemcen','13',1003),(2354,'Azuay','A',1064),(2355,'Bolivar','B',1064),(2356,'Canar','F',1064),(2357,'Carchi','C',1064),(2358,'Cotopaxi','X',1064),(2359,'Chimborazo','H',1064),(2360,'El Oro','O',1064),(2361,'Esmeraldas','E',1064),(2362,'Galapagos','W',1064),(2363,'Guayas','G',1064),(2364,'Imbabura','I',1064),(2365,'Loja','L',1064),(2366,'Los Rios','R',1064),(2367,'Manabi','M',1064),(2368,'Morona-Santiago','S',1064),(2369,'Napo','N',1064),(2370,'Orellana','D',1064),(2371,'Pastaza','Y',1064),(2372,'Pichincha','P',1064),(2373,'Sucumbios','U',1064),(2374,'Tungurahua','T',1064),(2375,'Zamora-Chinchipe','Z',1064),(2376,'Harjumaa','37',1069),(2377,'Hiiumaa','39',1069),(2378,'Ida-Virumaa','44',1069),(2379,'Jõgevamaa','49',1069),(2380,'Järvamaa','51',1069),(2381,'Läänemaa','57',1069),(2382,'Lääne-Virumaa','59',1069),(2383,'Põlvamaa','65',1069),(2384,'Pärnumaa','67',1069),(2385,'Raplamaa','70',1069),(2386,'Saaremaa','74',1069),(2387,'Tartumaa','7B',1069),(2388,'Valgamaa','82',1069),(2389,'Viljandimaa','84',1069),(2390,'Võrumaa','86',1069),(2391,'Ad Daqahllyah','DK',1065),(2392,'Al Bahr al Ahmar','BA',1065),(2393,'Al Buhayrah','BH',1065),(2394,'Al Fayym','FYM',1065),(2395,'Al Gharbiyah','GH',1065),(2396,'Al Iskandarlyah','ALX',1065),(2397,'Al Isma illyah','IS',1065),(2398,'Al Jizah','GZ',1065),(2399,'Al Minuflyah','MNF',1065),(2400,'Al Minya','MN',1065),(2401,'Al Qahirah','C',1065),(2402,'Al Qalyublyah','KB',1065),(2403,'Al Wadi al Jadid','WAD',1065),(2404,'Ash Sharqiyah','SHR',1065),(2405,'As Suways','SUZ',1065),(2406,'Aswan','ASN',1065),(2407,'Asyut','AST',1065),(2408,'Bani Suwayf','BNS',1065),(2409,'Bur Sa\'id','PTS',1065),(2410,'Dumyat','DT',1065),(2411,'Janub Sina\'','JS',1065),(2412,'Kafr ash Shaykh','KFS',1065),(2413,'Matruh','MT',1065),(2414,'Qina','KN',1065),(2415,'Shamal Sina\'','SIN',1065),(2416,'Suhaj','SHG',1065),(2417,'Anseba','AN',1068),(2418,'Debub','DU',1068),(2419,'Debubawi Keyih Bahri [Debub-Keih-Bahri]','DK',1068),(2420,'Gash-Barka','GB',1068),(2421,'Maakel [Maekel]','MA',1068),(2422,'Semenawi Keyih Bahri [Semien-Keih-Bahri]','SK',1068),(2423,'Álava','VI',1198),(2424,'Albacete','AB',1198),(2425,'Alicante','A',1198),(2426,'Almería','AL',1198),(2427,'Asturias','O',1198),(2428,'Ávila','AV',1198),(2429,'Badajoz','BA',1198),(2430,'Baleares','PM',1198),(2431,'Barcelona','B',1198),(2432,'Burgos','BU',1198),(2433,'Cáceres','CC',1198),(2434,'Cádiz','CA',1198),(2435,'Cantabria','S',1198),(2436,'Castellón','CS',1198),(2437,'Ciudad Real','CR',1198),(2438,'Cuenca','CU',1198),(2439,'Girona [Gerona]','GE',1198),(2440,'Granada','GR',1198),(2441,'Guadalajara','GU',1198),(2442,'Guipúzcoa','SS',1198),(2443,'Huelva','H',1198),(2444,'Huesca','HU',1198),(2445,'Jaén','J',1198),(2446,'La Coruña','C',1198),(2447,'La Rioja','LO',1198),(2448,'Las Palmas','GC',1198),(2449,'León','LE',1198),(2450,'Lleida [Lérida]','L',1198),(2451,'Lugo','LU',1198),(2452,'Madrid','M',1198),(2453,'Málaga','MA',1198),(2454,'Murcia','MU',1198),(2455,'Navarra','NA',1198),(2456,'Ourense','OR',1198),(2457,'Palencia','P',1198),(2458,'Pontevedra','PO',1198),(2459,'Salamanca','SA',1198),(2460,'Santa Cruz de Tenerife','TF',1198),(2461,'Segovia','SG',1198),(2462,'Sevilla','SE',1198),(2463,'Soria','SO',1198),(2464,'Tarragona','T',1198),(2465,'Teruel','TE',1198),(2466,'Valencia','V',1198),(2467,'Valladolid','VA',1198),(2468,'Vizcaya','BI',1198),(2469,'Zamora','ZA',1198),(2470,'Zaragoza','Z',1198),(2471,'Ceuta','CE',1198),(2472,'Melilla','ML',1198),(2473,'Addis Ababa','AA',1070),(2474,'Dire Dawa','DD',1070),(2475,'Afar','AF',1070),(2476,'Amara','AM',1070),(2477,'Benshangul-Gumaz','BE',1070),(2478,'Gambela Peoples','GA',1070),(2479,'Harari People','HA',1070),(2480,'Oromia','OR',1070),(2481,'Somali','SO',1070),(2482,'Southern Nations, Nationalities and Peoples','SN',1070),(2483,'Tigrai','TI',1070),(2490,'Eastern','E',1074),(2491,'Northern','N',1074),(2492,'Western','W',1074),(2493,'Rotuma','R',1074),(2494,'Chuuk','TRK',1141),(2495,'Kosrae','KSA',1141),(2496,'Pohnpei','PNI',1141),(2497,'Yap','YAP',1141),(2498,'Ain','01',1076),(2499,'Aisne','02',1076),(2500,'Allier','03',1076),(2501,'Alpes-de-Haute-Provence','04',1076),(2502,'Alpes-Maritimes','06',1076),(2503,'Ardèche','07',1076),(2504,'Ardennes','08',1076),(2505,'Ariège','09',1076),(2506,'Aube','10',1076),(2507,'Aude','11',1076),(2508,'Aveyron','12',1076),(2509,'Bas-Rhin','67',1076),(2510,'Bouches-du-Rhône','13',1076),(2511,'Calvados','14',1076),(2512,'Cantal','15',1076),(2513,'Charente','16',1076),(2514,'Charente-Maritime','17',1076),(2515,'Cher','18',1076),(2516,'Corrèze','19',1076),(2517,'Corse-du-Sud','20A',1076),(2518,'Côte-d\'Or','21',1076),(2519,'Côtes-d\'Armor','22',1076),(2520,'Creuse','23',1076),(2521,'Deux-Sèvres','79',1076),(2522,'Dordogne','24',1076),(2523,'Doubs','25',1076),(2524,'Drôme','26',1076),(2525,'Essonne','91',1076),(2526,'Eure','27',1076),(2527,'Eure-et-Loir','28',1076),(2528,'Finistère','29',1076),(2529,'Gard','30',1076),(2530,'Gers','32',1076),(2531,'Gironde','33',1076),(2532,'Haut-Rhin','68',1076),(2533,'Haute-Corse','20B',1076),(2534,'Haute-Garonne','31',1076),(2535,'Haute-Loire','43',1076),(2536,'Haute-Saône','70',1076),(2537,'Haute-Savoie','74',1076),(2538,'Haute-Vienne','87',1076),(2539,'Hautes-Alpes','05',1076),(2540,'Hautes-Pyrénées','65',1076),(2541,'Hauts-de-Seine','92',1076),(2542,'Hérault','34',1076),(2543,'Indre','36',1076),(2544,'Ille-et-Vilaine','35',1076),(2545,'Indre-et-Loire','37',1076),(2546,'Isère','38',1076),(2547,'Landes','40',1076),(2548,'Loir-et-Cher','41',1076),(2549,'Loire','42',1076),(2550,'Loire-Atlantique','44',1076),(2551,'Loiret','45',1076),(2552,'Lot','46',1076),(2553,'Lot-et-Garonne','47',1076),(2554,'Lozère','48',1076),(2555,'Maine-et-Loire','49',1076),(2556,'Manche','50',1076),(2557,'Marne','51',1076),(2558,'Mayenne','53',1076),(2559,'Meurthe-et-Moselle','54',1076),(2560,'Meuse','55',1076),(2561,'Morbihan','56',1076),(2562,'Moselle','57',1076),(2563,'Nièvre','58',1076),(2564,'Nord','59',1076),(2565,'Oise','60',1076),(2566,'Orne','61',1076),(2567,'Paris','75',1076),(2568,'Pas-de-Calais','62',1076),(2569,'Puy-de-Dôme','63',1076),(2570,'Pyrénées-Atlantiques','64',1076),(2571,'Pyrénées-Orientales','66',1076),(2572,'Rhône','69',1076),(2573,'Saône-et-Loire','71',1076),(2574,'Sarthe','72',1076),(2575,'Savoie','73',1076),(2576,'Seine-et-Marne','77',1076),(2577,'Seine-Maritime','76',1076),(2578,'Seine-Saint-Denis','93',1076),(2579,'Somme','80',1076),(2580,'Tarn','81',1076),(2581,'Tarn-et-Garonne','82',1076),(2582,'Val d\'Oise','95',1076),(2583,'Territoire de Belfort','90',1076),(2584,'Val-de-Marne','94',1076),(2585,'Var','83',1076),(2586,'Vaucluse','84',1076),(2587,'Vendée','85',1076),(2588,'Vienne','86',1076),(2589,'Vosges','88',1076),(2590,'Yonne','89',1076),(2591,'Yvelines','78',1076),(2592,'Aberdeen City','ABE',1226),(2593,'Aberdeenshire','ABD',1226),(2594,'Angus','ANS',1226),(2595,'Co Antrim','ANT',1226),(2597,'Argyll and Bute','AGB',1226),(2598,'Co Armagh','ARM',1226),(2606,'Bedfordshire','BDF',1226),(2612,'Gwent','BGW',1226),(2620,'Bristol, City of','BST',1226),(2622,'Buckinghamshire','BKM',1226),(2626,'Cambridgeshire','CAM',1226),(2634,'Cheshire','CHS',1226),(2635,'Clackmannanshire','CLK',1226),(2639,'Cornwall','CON',1226),(2643,'Cumbria','CMA',1226),(2647,'Derbyshire','DBY',1226),(2648,'Co Londonderry','DRY',1226),(2649,'Devon','DEV',1226),(2651,'Dorset','DOR',1226),(2652,'Co Down','DOW',1226),(2654,'Dumfries and Galloway','DGY',1226),(2655,'Dundee City','DND',1226),(2657,'County Durham','DUR',1226),(2659,'East Ayrshire','EAY',1226),(2660,'East Dunbartonshire','EDU',1226),(2661,'East Lothian','ELN',1226),(2662,'East Renfrewshire','ERW',1226),(2663,'East Riding of Yorkshire','ERY',1226),(2664,'East Sussex','ESX',1226),(2665,'Edinburgh, City of','EDH',1226),(2666,'Na h-Eileanan Siar','ELS',1226),(2668,'Essex','ESS',1226),(2669,'Falkirk','FAL',1226),(2670,'Co Fermanagh','FER',1226),(2671,'Fife','FIF',1226),(2674,'Glasgow City','GLG',1226),(2675,'Gloucestershire','GLS',1226),(2678,'Gwynedd','GWN',1226),(2682,'Hampshire','HAM',1226),(2687,'Herefordshire','HEF',1226),(2688,'Hertfordshire','HRT',1226),(2689,'Highland','HED',1226),(2692,'Inverclyde','IVC',1226),(2694,'Isle of Wight','IOW',1226),(2699,'Kent','KEN',1226),(2705,'Lancashire','LAN',1226),(2709,'Leicestershire','LEC',1226),(2712,'Lincolnshire','LIN',1226),(2723,'Midlothian','MLN',1226),(2726,'Moray','MRY',1226),(2734,'Norfolk','NFK',1226),(2735,'North Ayrshire','NAY',1226),(2738,'North Lanarkshire','NLK',1226),(2742,'North Yorkshire','NYK',1226),(2743,'Northamptonshire','NTH',1226),(2744,'Northumberland','NBL',1226),(2746,'Nottinghamshire','NTT',1226),(2747,'Oldham','OLD',1226),(2748,'Omagh','OMH',1226),(2749,'Orkney Islands','ORR',1226),(2750,'Oxfordshire','OXF',1226),(2752,'Perth and Kinross','PKN',1226),(2757,'Powys','POW',1226),(2761,'Renfrewshire','RFW',1226),(2766,'Rutland','RUT',1226),(2770,'Scottish Borders','SCB',1226),(2773,'Shetland Islands','ZET',1226),(2774,'Shropshire','SHR',1226),(2777,'Somerset','SOM',1226),(2778,'South Ayrshire','SAY',1226),(2779,'South Gloucestershire','SGC',1226),(2780,'South Lanarkshire','SLK',1226),(2785,'Staffordshire','STS',1226),(2786,'Stirling','STG',1226),(2791,'Suffolk','SFK',1226),(2793,'Surrey','SRY',1226),(2804,'Mid Glamorgan','VGL',1226),(2811,'Warwickshire','WAR',1226),(2813,'West Dunbartonshire','WDU',1226),(2814,'West Lothian','WLN',1226),(2815,'West Sussex','WSX',1226),(2818,'Wiltshire','WIL',1226),(2823,'Worcestershire','WOR',1226),(2826,'Ashanti','AH',1083),(2827,'Brong-Ahafo','BA',1083),(2828,'Greater Accra','AA',1083),(2829,'Upper East','UE',1083),(2830,'Upper West','UW',1083),(2831,'Volta','TV',1083),(2832,'Banjul','B',1213),(2833,'Lower River','L',1213),(2834,'MacCarthy Island','M',1213),(2835,'North Bank','N',1213),(2836,'Upper River','U',1213),(2837,'Beyla','BE',1091),(2838,'Boffa','BF',1091),(2839,'Boke','BK',1091),(2840,'Coyah','CO',1091),(2841,'Dabola','DB',1091),(2842,'Dalaba','DL',1091),(2843,'Dinguiraye','DI',1091),(2844,'Dubreka','DU',1091),(2845,'Faranah','FA',1091),(2846,'Forecariah','FO',1091),(2847,'Fria','FR',1091),(2848,'Gaoual','GA',1091),(2849,'Guekedou','GU',1091),(2850,'Kankan','KA',1091),(2851,'Kerouane','KE',1091),(2852,'Kindia','KD',1091),(2853,'Kissidougou','KS',1091),(2854,'Koubia','KB',1091),(2855,'Koundara','KN',1091),(2856,'Kouroussa','KO',1091),(2857,'Labe','LA',1091),(2858,'Lelouma','LE',1091),(2859,'Lola','LO',1091),(2860,'Macenta','MC',1091),(2861,'Mali','ML',1091),(2862,'Mamou','MM',1091),(2863,'Mandiana','MD',1091),(2864,'Nzerekore','NZ',1091),(2865,'Pita','PI',1091),(2866,'Siguiri','SI',1091),(2867,'Telimele','TE',1091),(2868,'Tougue','TO',1091),(2869,'Yomou','YO',1091),(2870,'Region Continental','C',1067),(2871,'Region Insular','I',1067),(2872,'Annobon','AN',1067),(2873,'Bioko Norte','BN',1067),(2874,'Bioko Sur','BS',1067),(2875,'Centro Sur','CS',1067),(2876,'Kie-Ntem','KN',1067),(2877,'Litoral','LI',1067),(2878,'Wele-Nzas','WN',1067),(2879,'Achaïa','13',1085),(2880,'Aitolia-Akarnania','01',1085),(2881,'Argolis','11',1085),(2882,'Arkadia','12',1085),(2883,'Arta','31',1085),(2884,'Attiki','A1',1085),(2885,'Chalkidiki','64',1085),(2886,'Chania','94',1085),(2887,'Chios','85',1085),(2888,'Dodekanisos','81',1085),(2889,'Drama','52',1085),(2890,'Evros','71',1085),(2891,'Evrytania','05',1085),(2892,'Evvoia','04',1085),(2893,'Florina','63',1085),(2894,'Fokis','07',1085),(2895,'Fthiotis','06',1085),(2896,'Grevena','51',1085),(2897,'Ileia','14',1085),(2898,'Imathia','53',1085),(2899,'Ioannina','33',1085),(2900,'Irakleion','91',1085),(2901,'Karditsa','41',1085),(2902,'Kastoria','56',1085),(2903,'Kavalla','55',1085),(2904,'Kefallinia','23',1085),(2905,'Kerkyra','22',1085),(2906,'Kilkis','57',1085),(2907,'Korinthia','15',1085),(2908,'Kozani','58',1085),(2909,'Kyklades','82',1085),(2910,'Lakonia','16',1085),(2911,'Larisa','42',1085),(2912,'Lasithion','92',1085),(2913,'Lefkas','24',1085),(2914,'Lesvos','83',1085),(2915,'Magnisia','43',1085),(2916,'Messinia','17',1085),(2917,'Pella','59',1085),(2918,'Preveza','34',1085),(2919,'Rethymnon','93',1085),(2920,'Rodopi','73',1085),(2921,'Samos','84',1085),(2922,'Serrai','62',1085),(2923,'Thesprotia','32',1085),(2924,'Thessaloniki','54',1085),(2925,'Trikala','44',1085),(2926,'Voiotia','03',1085),(2927,'Xanthi','72',1085),(2928,'Zakynthos','21',1085),(2929,'Agio Oros','69',1085),(2930,'Alta Verapaz','AV',1090),(2931,'Baja Verapaz','BV',1090),(2932,'Chimaltenango','CM',1090),(2933,'Chiquimula','CQ',1090),(2934,'El Progreso','PR',1090),(2935,'Escuintla','ES',1090),(2936,'Guatemala','GU',1090),(2937,'Huehuetenango','HU',1090),(2938,'Izabal','IZ',1090),(2939,'Jalapa','JA',1090),(2940,'Jutiapa','JU',1090),(2941,'Peten','PE',1090),(2942,'Quetzaltenango','QZ',1090),(2943,'Quiche','QC',1090),(2944,'Retalhuleu','RE',1090),(2945,'Sacatepequez','SA',1090),(2946,'San Marcos','SM',1090),(2947,'Santa Rosa','SR',1090),(2948,'Sololá','SO',1090),(2949,'Suchitepequez','SU',1090),(2950,'Totonicapan','TO',1090),(2951,'Zacapa','ZA',1090),(2952,'Bissau','BS',1092),(2953,'Bafata','BA',1092),(2954,'Biombo','BM',1092),(2955,'Bolama','BL',1092),(2956,'Cacheu','CA',1092),(2957,'Gabu','GA',1092),(2958,'Oio','OI',1092),(2959,'Quloara','QU',1092),(2960,'Tombali S','TO',1092),(2961,'Barima-Waini','BA',1093),(2962,'Cuyuni-Mazaruni','CU',1093),(2963,'Demerara-Mahaica','DE',1093),(2964,'East Berbice-Corentyne','EB',1093),(2965,'Essequibo Islands-West Demerara','ES',1093),(2966,'Mahaica-Berbice','MA',1093),(2967,'Pomeroon-Supenaam','PM',1093),(2968,'Potaro-Siparuni','PT',1093),(2969,'Upper Demerara-Berbice','UD',1093),(2970,'Upper Takutu-Upper Essequibo','UT',1093),(2971,'Atlantida','AT',1097),(2972,'Colon','CL',1097),(2973,'Comayagua','CM',1097),(2974,'Copan','CP',1097),(2975,'Cortes','CR',1097),(2976,'Choluteca','CH',1097),(2977,'El Paraiso','EP',1097),(2978,'Francisco Morazan','FM',1097),(2979,'Gracias a Dios','GD',1097),(2980,'Intibuca','IN',1097),(2981,'Islas de la Bahia','IB',1097),(2982,'Lempira','LE',1097),(2983,'Ocotepeque','OC',1097),(2984,'Olancho','OL',1097),(2985,'Santa Barbara','SB',1097),(2986,'Valle','VA',1097),(2987,'Yoro','YO',1097),(2988,'Bjelovarsko-bilogorska zupanija','07',1055),(2989,'Brodsko-posavska zupanija','12',1055),(2990,'Dubrovacko-neretvanska zupanija','19',1055),(2991,'Istarska zupanija','18',1055),(2992,'Karlovacka zupanija','04',1055),(2993,'Koprivnickco-krizevacka zupanija','06',1055),(2994,'Krapinako-zagorska zupanija','02',1055),(2995,'Licko-senjska zupanija','09',1055),(2996,'Medimurska zupanija','20',1055),(2997,'Osjecko-baranjska zupanija','14',1055),(2998,'Pozesko-slavonska zupanija','11',1055),(2999,'Primorsko-goranska zupanija','08',1055),(3000,'Sisacko-moelavacka Iupanija','03',1055),(3001,'Splitako-dalmatinska zupanija','17',1055),(3002,'Sibenako-kninska zupanija','15',1055),(3003,'Varaidinska zupanija','05',1055),(3004,'VirovitiEko-podravska zupanija','10',1055),(3005,'VuRovarako-srijemska zupanija','16',1055),(3006,'Zadaraka','13',1055),(3007,'Zagrebacka zupanija','01',1055),(3008,'Grande-Anse','GA',1094),(3009,'Nord-Est','NE',1094),(3010,'Nord-Ouest','NO',1094),(3011,'Ouest','OU',1094),(3012,'Sud','SD',1094),(3013,'Sud-Est','SE',1094),(3014,'Budapest','BU',1099),(3015,'Bács-Kiskun','BK',1099),(3016,'Baranya','BA',1099),(3017,'Békés','BE',1099),(3018,'Borsod-Abaúj-Zemplén','BZ',1099),(3019,'Csongrád','CS',1099),(3020,'Fejér','FE',1099),(3021,'Győr-Moson-Sopron','GS',1099),(3022,'Hajdu-Bihar','HB',1099),(3023,'Heves','HE',1099),(3024,'Jász-Nagykun-Szolnok','JN',1099),(3025,'Komárom-Esztergom','KE',1099),(3026,'Nográd','NO',1099),(3027,'Pest','PE',1099),(3028,'Somogy','SO',1099),(3029,'Szabolcs-Szatmár-Bereg','SZ',1099),(3030,'Tolna','TO',1099),(3031,'Vas','VA',1099),(3032,'Veszprém','VE',1099),(3033,'Zala','ZA',1099),(3034,'Békéscsaba','BC',1099),(3035,'Debrecen','DE',1099),(3036,'Dunaújváros','DU',1099),(3037,'Eger','EG',1099),(3038,'Győr','GY',1099),(3039,'Hódmezővásárhely','HV',1099),(3040,'Kaposvár','KV',1099),(3041,'Kecskemét','KM',1099),(3042,'Miskolc','MI',1099),(3043,'Nagykanizsa','NK',1099),(3044,'Nyiregyháza','NY',1099),(3045,'Pécs','PS',1099),(3046,'Salgótarján','ST',1099),(3047,'Sopron','SN',1099),(3048,'Szeged','SD',1099),(3049,'Székesfehérvár','SF',1099),(3050,'Szekszárd','SS',1099),(3051,'Szolnok','SK',1099),(3052,'Szombathely','SH',1099),(3053,'Tatabánya','TB',1099),(3054,'Zalaegerszeg','ZE',1099),(3055,'Bali','BA',1102),(3056,'Kepulauan Bangka Belitung','BB',1102),(3057,'Banten','BT',1102),(3058,'Bengkulu','BE',1102),(3059,'Gorontalo','GO',1102),(3060,'Papua Barat','PB',1102),(3061,'Jambi','JA',1102),(3062,'Jawa Barat','JB',1102),(3063,'Jawa Tengah','JT',1102),(3064,'Jawa Timur','JI',1102),(3065,'Kalimantan Barat','KB',1102),(3066,'Kalimantan Timur','KI',1102),(3067,'Kalimantan Selatan','KS',1102),(3068,'Kepulauan Riau','KR',1102),(3069,'Lampung','LA',1102),(3070,'Maluku','MA',1102),(3071,'Maluku Utara','MU',1102),(3072,'Nusa Tenggara Barat','NB',1102),(3073,'Nusa Tenggara Timur','NT',1102),(3074,'Papua','PA',1102),(3075,'Riau','RI',1102),(3076,'Sulawesi Selatan','SN',1102),(3077,'Sulawesi Tengah','ST',1102),(3078,'Sulawesi Tenggara','SG',1102),(3079,'Sulawesi Utara','SA',1102),(3080,'Sumatra Barat','SB',1102),(3081,'Sumatra Selatan','SS',1102),(3082,'Sumatera Utara','SU',1102),(3083,'DKI Jakarta','JK',1102),(3084,'Aceh','AC',1102),(3085,'DI Yogyakarta','YO',1102),(3086,'Cork','C',1105),(3087,'Clare','CE',1105),(3088,'Cavan','CN',1105),(3089,'Carlow','CW',1105),(3090,'Dublin','D',1105),(3091,'Donegal','DL',1105),(3092,'Galway','G',1105),(3093,'Kildare','KE',1105),(3094,'Kilkenny','KK',1105),(3095,'Kerry','KY',1105),(3096,'Longford','LD',1105),(3097,'Louth','LH',1105),(3098,'Limerick','LK',1105),(3099,'Leitrim','LM',1105),(3100,'Laois','LS',1105),(3101,'Meath','MH',1105),(3102,'Monaghan','MN',1105),(3103,'Mayo','MO',1105),(3104,'Offaly','OY',1105),(3105,'Roscommon','RN',1105),(3106,'Sligo','SO',1105),(3107,'Tipperary','TA',1105),(3108,'Waterford','WD',1105),(3109,'Westmeath','WH',1105),(3110,'Wicklow','WW',1105),(3111,'Wexford','WX',1105),(3112,'HaDarom','D',1106),(3113,'HaMerkaz','M',1106),(3114,'HaZafon','Z',1106),(3115,'Haifa','HA',1106),(3116,'Tel-Aviv','TA',1106),(3117,'Jerusalem','JM',1106),(3118,'Al Anbar','AN',1104),(3119,'Al Ba,rah','BA',1104),(3120,'Al Muthanna','MU',1104),(3121,'Al Qadisiyah','QA',1104),(3122,'An Najef','NA',1104),(3123,'Arbil','AR',1104),(3124,'As Sulaymaniyah','SW',1104),(3125,'At Ta\'mim','TS',1104),(3126,'Babil','BB',1104),(3127,'Baghdad','BG',1104),(3128,'Dahuk','DA',1104),(3129,'Dhi Qar','DQ',1104),(3130,'Diyala','DI',1104),(3131,'Karbala\'','KA',1104),(3132,'Maysan','MA',1104),(3133,'Ninawa','NI',1104),(3134,'Salah ad Din','SD',1104),(3135,'Wasit','WA',1104),(3136,'Ardabil','03',1103),(3137,'Azarbayjan-e Gharbi','02',1103),(3138,'Azarbayjan-e Sharqi','01',1103),(3139,'Bushehr','06',1103),(3140,'Chahar Mahall va Bakhtiari','08',1103),(3141,'Esfahan','04',1103),(3142,'Fars','14',1103),(3143,'Gilan','19',1103),(3144,'Golestan','27',1103),(3145,'Hamadan','24',1103),(3146,'Hormozgan','23',1103),(3147,'Iiam','05',1103),(3148,'Kerman','15',1103),(3149,'Kermanshah','17',1103),(3150,'Khorasan','09',1103),(3151,'Khuzestan','10',1103),(3152,'Kohjiluyeh va Buyer Ahmad','18',1103),(3153,'Kordestan','16',1103),(3154,'Lorestan','20',1103),(3155,'Markazi','22',1103),(3156,'Mazandaran','21',1103),(3157,'Qazvin','28',1103),(3158,'Qom','26',1103),(3159,'Semnan','12',1103),(3160,'Sistan va Baluchestan','13',1103),(3161,'Tehran','07',1103),(3162,'Yazd','25',1103),(3163,'Zanjan','11',1103),(3164,'Austurland','7',1100),(3165,'Hofuoborgarsvaeoi utan Reykjavikur','1',1100),(3166,'Norourland eystra','6',1100),(3167,'Norourland vestra','5',1100),(3168,'Reykjavik','0',1100),(3169,'Suourland','8',1100),(3170,'Suournes','2',1100),(3171,'Vestfirolr','4',1100),(3172,'Vesturland','3',1100),(3173,'Agrigento','AG',1107),(3174,'Alessandria','AL',1107),(3175,'Ancona','AN',1107),(3176,'Aosta','AO',1107),(3177,'Arezzo','AR',1107),(3178,'Ascoli Piceno','AP',1107),(3179,'Asti','AT',1107),(3180,'Avellino','AV',1107),(3181,'Bari','BA',1107),(3182,'Belluno','BL',1107),(3183,'Benevento','BN',1107),(3184,'Bergamo','BG',1107),(3185,'Biella','BI',1107),(3186,'Bologna','BO',1107),(3187,'Bolzano','BZ',1107),(3188,'Brescia','BS',1107),(3189,'Brindisi','BR',1107),(3190,'Cagliari','CA',1107),(3191,'Caltanissetta','CL',1107),(3192,'Campobasso','CB',1107),(3193,'Caserta','CE',1107),(3194,'Catania','CT',1107),(3195,'Catanzaro','CZ',1107),(3196,'Chieti','CH',1107),(3197,'Como','CO',1107),(3198,'Cosenza','CS',1107),(3199,'Cremona','CR',1107),(3200,'Crotone','KR',1107),(3201,'Cuneo','CN',1107),(3202,'Enna','EN',1107),(3203,'Ferrara','FE',1107),(3204,'Firenze','FI',1107),(3205,'Foggia','FG',1107),(3206,'Forlì-Cesena','FC',1107),(3207,'Frosinone','FR',1107),(3208,'Genova','GE',1107),(3209,'Gorizia','GO',1107),(3210,'Grosseto','GR',1107),(3211,'Imperia','IM',1107),(3212,'Isernia','IS',1107),(3213,'L\'Aquila','AQ',1107),(3214,'La Spezia','SP',1107),(3215,'Latina','LT',1107),(3216,'Lecce','LE',1107),(3217,'Lecco','LC',1107),(3218,'Livorno','LI',1107),(3219,'Lodi','LO',1107),(3220,'Lucca','LU',1107),(3221,'Macerata','MC',1107),(3222,'Mantova','MN',1107),(3223,'Massa-Carrara','MS',1107),(3224,'Matera','MT',1107),(3225,'Messina','ME',1107),(3226,'Milano','MI',1107),(3227,'Modena','MO',1107),(3228,'Napoli','NA',1107),(3229,'Novara','NO',1107),(3230,'Nuoro','NU',1107),(3231,'Oristano','OR',1107),(3232,'Padova','PD',1107),(3233,'Palermo','PA',1107),(3234,'Parma','PR',1107),(3235,'Pavia','PV',1107),(3236,'Perugia','PG',1107),(3237,'Pesaro e Urbino','PU',1107),(3238,'Pescara','PE',1107),(3239,'Piacenza','PC',1107),(3240,'Pisa','PI',1107),(3241,'Pistoia','PT',1107),(3242,'Pordenone','PN',1107),(3243,'Potenza','PZ',1107),(3244,'Prato','PO',1107),(3245,'Ragusa','RG',1107),(3246,'Ravenna','RA',1107),(3247,'Reggio Calabria','RC',1107),(3248,'Reggio Emilia','RE',1107),(3249,'Rieti','RI',1107),(3250,'Rimini','RN',1107),(3251,'Roma','RM',1107),(3252,'Rovigo','RO',1107),(3253,'Salerno','SA',1107),(3254,'Sassari','SS',1107),(3255,'Savona','SV',1107),(3256,'Siena','SI',1107),(3257,'Siracusa','SR',1107),(3258,'Sondrio','SO',1107),(3259,'Taranto','TA',1107),(3260,'Teramo','TE',1107),(3261,'Terni','TR',1107),(3262,'Torino','TO',1107),(3263,'Trapani','TP',1107),(3264,'Trento','TN',1107),(3265,'Treviso','TV',1107),(3266,'Trieste','TS',1107),(3267,'Udine','UD',1107),(3268,'Varese','VA',1107),(3269,'Venezia','VE',1107),(3270,'Verbano-Cusio-Ossola','VB',1107),(3271,'Vercelli','VC',1107),(3272,'Verona','VR',1107),(3273,'Vibo Valentia','VV',1107),(3274,'Vicenza','VI',1107),(3275,'Viterbo','VT',1107),(3276,'Aichi','23',1109),(3277,'Akita','05',1109),(3278,'Aomori','02',1109),(3279,'Chiba','12',1109),(3280,'Ehime','38',1109),(3281,'Fukui','18',1109),(3282,'Fukuoka','40',1109),(3283,'Fukusima','07',1109),(3284,'Gifu','21',1109),(3285,'Gunma','10',1109),(3286,'Hiroshima','34',1109),(3287,'Hokkaido','01',1109),(3288,'Hyogo','28',1109),(3289,'Ibaraki','08',1109),(3290,'Ishikawa','17',1109),(3291,'Iwate','03',1109),(3292,'Kagawa','37',1109),(3293,'Kagoshima','46',1109),(3294,'Kanagawa','14',1109),(3295,'Kochi','39',1109),(3296,'Kumamoto','43',1109),(3297,'Kyoto','26',1109),(3298,'Mie','24',1109),(3299,'Miyagi','04',1109),(3300,'Miyazaki','45',1109),(3301,'Nagano','20',1109),(3302,'Nagasaki','42',1109),(3303,'Nara','29',1109),(3304,'Niigata','15',1109),(3305,'Oita','44',1109),(3306,'Okayama','33',1109),(3307,'Okinawa','47',1109),(3308,'Osaka','27',1109),(3309,'Saga','41',1109),(3310,'Saitama','11',1109),(3311,'Shiga','25',1109),(3312,'Shimane','32',1109),(3313,'Shizuoka','22',1109),(3314,'Tochigi','09',1109),(3315,'Tokushima','36',1109),(3316,'Tokyo','13',1109),(3317,'Tottori','31',1109),(3318,'Toyama','16',1109),(3319,'Wakayama','30',1109),(3320,'Yamagata','06',1109),(3321,'Yamaguchi','35',1109),(3322,'Yamanashi','19',1109),(3323,'Clarendon','CN',1108),(3324,'Hanover','HR',1108),(3325,'Kingston','KN',1108),(3326,'Portland','PD',1108),(3327,'Saint Andrew','AW',1108),(3328,'Saint Ann','AN',1108),(3329,'Saint Catherine','CE',1108),(3330,'Saint Elizabeth','EH',1108),(3331,'Saint James','JS',1108),(3332,'Saint Mary','MY',1108),(3333,'Saint Thomas','TS',1108),(3334,'Trelawny','TY',1108),(3335,'Westmoreland','WD',1108),(3336,'Ajln','AJ',1110),(3337,'Al \'Aqaba','AQ',1110),(3338,'Al Balqa\'','BA',1110),(3339,'Al Karak','KA',1110),(3340,'Al Mafraq','MA',1110),(3341,'Amman','AM',1110),(3342,'At Tafilah','AT',1110),(3343,'Az Zarga','AZ',1110),(3344,'Irbid','JR',1110),(3345,'Jarash','JA',1110),(3346,'Ma\'an','MN',1110),(3347,'Madaba','MD',1110),(3348,'Nairobi Municipality','110',1112),(3349,'Coast','300',1112),(3350,'North-Eastern Kaskazini Mashariki','500',1112),(3351,'Rift Valley','700',1112),(3352,'Western Magharibi','900',1112),(3353,'Bishkek','GB',1117),(3354,'Batken','B',1117),(3355,'Chu','C',1117),(3356,'Jalal-Abad','J',1117),(3357,'Naryn','N',1117),(3358,'Osh','O',1117),(3359,'Talas','T',1117),(3360,'Ysyk-Kol','Y',1117),(3361,'Krong Kaeb','23',1037),(3362,'Krong Pailin','24',1037),(3363,'Xrong Preah Sihanouk','18',1037),(3364,'Phnom Penh','12',1037),(3365,'Baat Dambang','2',1037),(3366,'Banteay Mean Chey','1',1037),(3367,'Rampong Chaam','3',1037),(3368,'Kampong Chhnang','4',1037),(3369,'Kampong Spueu','5',1037),(3370,'Kampong Thum','6',1037),(3371,'Kampot','7',1037),(3372,'Kandaal','8',1037),(3373,'Kach Kong','9',1037),(3374,'Krachoh','10',1037),(3375,'Mondol Kiri','11',1037),(3376,'Otdar Mean Chey','22',1037),(3377,'Pousaat','15',1037),(3378,'Preah Vihear','13',1037),(3379,'Prey Veaeng','14',1037),(3380,'Rotanak Kiri','16',1037),(3381,'Siem Reab','17',1037),(3382,'Stueng Traeng','19',1037),(3383,'Svaay Rieng','20',1037),(3384,'Taakaev','21',1037),(3385,'Gilbert Islands','G',1113),(3386,'Line Islands','L',1113),(3387,'Phoenix Islands','P',1113),(3388,'Anjouan Ndzouani','A',1049),(3389,'Grande Comore Ngazidja','G',1049),(3390,'Moheli Moili','M',1049),(3391,'Kaesong-si','KAE',1114),(3392,'Nampo-si','NAM',1114),(3393,'Pyongyang-ai','PYO',1114),(3394,'Chagang-do','CHA',1114),(3395,'Hamgyongbuk-do','HAB',1114),(3396,'Hamgyongnam-do','HAN',1114),(3397,'Hwanghaebuk-do','HWB',1114),(3398,'Hwanghaenam-do','HWN',1114),(3399,'Kangwon-do','KAN',1114),(3400,'Pyonganbuk-do','PYB',1114),(3401,'Pyongannam-do','PYN',1114),(3402,'Yanggang-do','YAN',1114),(3403,'Najin Sonbong-si','NAJ',1114),(3404,'Seoul Teugbyeolsi','11',1115),(3405,'Busan Gwang\'yeogsi','26',1115),(3406,'Daegu Gwang\'yeogsi','27',1115),(3407,'Daejeon Gwang\'yeogsi','30',1115),(3408,'Gwangju Gwang\'yeogsi','29',1115),(3409,'Incheon Gwang\'yeogsi','28',1115),(3410,'Ulsan Gwang\'yeogsi','31',1115),(3411,'Chungcheongbugdo','43',1115),(3412,'Chungcheongnamdo','44',1115),(3413,'Gang\'weondo','42',1115),(3414,'Gyeonggido','41',1115),(3415,'Gyeongsangbugdo','47',1115),(3416,'Gyeongsangnamdo','48',1115),(3417,'Jejudo','49',1115),(3418,'Jeonrabugdo','45',1115),(3419,'Jeonranamdo','46',1115),(3420,'Al Ahmadi','AH',1116),(3421,'Al Farwanlyah','FA',1116),(3422,'Al Jahrah','JA',1116),(3423,'Al Kuwayt','KU',1116),(3424,'Hawalli','HA',1116),(3425,'Almaty','ALA',1111),(3426,'Astana','AST',1111),(3427,'Almaty oblysy','ALM',1111),(3428,'Aqmola oblysy','AKM',1111),(3429,'Aqtobe oblysy','AKT',1111),(3430,'Atyrau oblyfiy','ATY',1111),(3431,'Batys Quzaqstan oblysy','ZAP',1111),(3432,'Mangghystau oblysy','MAN',1111),(3433,'Ongtustik Quzaqstan oblysy','YUZ',1111),(3434,'Pavlodar oblysy','PAV',1111),(3435,'Qaraghandy oblysy','KAR',1111),(3436,'Qostanay oblysy','KUS',1111),(3437,'Qyzylorda oblysy','KZY',1111),(3438,'Shyghys Quzaqstan oblysy','VOS',1111),(3439,'Soltustik Quzaqstan oblysy','SEV',1111),(3440,'Zhambyl oblysy Zhambylskaya oblast\'','ZHA',1111),(3441,'Vientiane','VT',1118),(3442,'Attapu','AT',1118),(3443,'Bokeo','BK',1118),(3444,'Bolikhamxai','BL',1118),(3445,'Champasak','CH',1118),(3446,'Houaphan','HO',1118),(3447,'Khammouan','KH',1118),(3448,'Louang Namtha','LM',1118),(3449,'Louangphabang','LP',1118),(3450,'Oudomxai','OU',1118),(3451,'Phongsali','PH',1118),(3452,'Salavan','SL',1118),(3453,'Savannakhet','SV',1118),(3454,'Xaignabouli','XA',1118),(3455,'Xiasomboun','XN',1118),(3456,'Xekong','XE',1118),(3457,'Xiangkhoang','XI',1118),(3458,'Beirut','BA',1120),(3459,'Beqaa','BI',1120),(3460,'Mount Lebanon','JL',1120),(3461,'North Lebanon','AS',1120),(3462,'South Lebanon','JA',1120),(3463,'Nabatieh','NA',1120),(3464,'Ampara','52',1199),(3465,'Anuradhapura','71',1199),(3466,'Badulla','81',1199),(3467,'Batticaloa','51',1199),(3468,'Colombo','11',1199),(3469,'Galle','31',1199),(3470,'Gampaha','12',1199),(3471,'Hambantota','33',1199),(3472,'Jaffna','41',1199),(3473,'Kalutara','13',1199),(3474,'Kandy','21',1199),(3475,'Kegalla','92',1199),(3476,'Kilinochchi','42',1199),(3477,'Kurunegala','61',1199),(3478,'Mannar','43',1199),(3479,'Matale','22',1199),(3480,'Matara','32',1199),(3481,'Monaragala','82',1199),(3482,'Mullaittivu','45',1199),(3483,'Nuwara Eliya','23',1199),(3484,'Polonnaruwa','72',1199),(3485,'Puttalum','62',1199),(3486,'Ratnapura','91',1199),(3487,'Trincomalee','53',1199),(3488,'VavunLya','44',1199),(3489,'Bomi','BM',1122),(3490,'Bong','BG',1122),(3491,'Grand Basaa','GB',1122),(3492,'Grand Cape Mount','CM',1122),(3493,'Grand Gedeh','GG',1122),(3494,'Grand Kru','GK',1122),(3495,'Lofa','LO',1122),(3496,'Margibi','MG',1122),(3497,'Maryland','MY',1122),(3498,'Montserrado','MO',1122),(3499,'Nimba','NI',1122),(3500,'Rivercess','RI',1122),(3501,'Sinoe','SI',1122),(3502,'Berea','D',1121),(3503,'Butha-Buthe','B',1121),(3504,'Leribe','C',1121),(3505,'Mafeteng','E',1121),(3506,'Maseru','A',1121),(3507,'Mohale\'s Hoek','F',1121),(3508,'Mokhotlong','J',1121),(3509,'Qacha\'s Nek','H',1121),(3510,'Quthing','G',1121),(3511,'Thaba-Tseka','K',1121),(3512,'Alytaus Apskritis','AL',1125),(3513,'Kauno Apskritis','KU',1125),(3514,'Klaipėdos Apskritis','KL',1125),(3515,'Marijampolės Apskritis','MR',1125),(3516,'Panevėžio Apskritis','PN',1125),(3517,'Šiaulių Apskritis','SA',1125),(3518,'Tauragės Apskritis','TA',1125),(3519,'Telšių Apskritis','TE',1125),(3520,'Utenos Apskritis','UT',1125),(3521,'Vilniaus Apskritis','VL',1125),(3522,'Diekirch','D',1126),(3523,'GreveNmacher','G',1126),(3550,'Daugavpils','DGV',1119),(3551,'Jelgava','JEL',1119),(3552,'Jūrmala','JUR',1119),(3553,'Liepāja','LPX',1119),(3554,'Rēzekne','REZ',1119),(3555,'Rīga','RIX',1119),(3556,'Ventspils','VEN',1119),(3557,'Ajdābiyā','AJ',1123),(3558,'Al Buţnān','BU',1123),(3559,'Al Hizām al Akhdar','HZ',1123),(3560,'Al Jabal al Akhdar','JA',1123),(3561,'Al Jifārah','JI',1123),(3562,'Al Jufrah','JU',1123),(3563,'Al Kufrah','KF',1123),(3564,'Al Marj','MJ',1123),(3565,'Al Marqab','MB',1123),(3566,'Al Qaţrūn','QT',1123),(3567,'Al Qubbah','QB',1123),(3568,'Al Wāhah','WA',1123),(3569,'An Nuqaţ al Khams','NQ',1123),(3570,'Ash Shāţi\'','SH',1123),(3571,'Az Zāwiyah','ZA',1123),(3572,'Banghāzī','BA',1123),(3573,'Banī Walīd','BW',1123),(3574,'Darnah','DR',1123),(3575,'Ghadāmis','GD',1123),(3576,'Gharyān','GR',1123),(3577,'Ghāt','GT',1123),(3578,'Jaghbūb','JB',1123),(3579,'Mişrātah','MI',1123),(3580,'Mizdah','MZ',1123),(3581,'Murzuq','MQ',1123),(3582,'Nālūt','NL',1123),(3583,'Sabhā','SB',1123),(3584,'Şabrātah Şurmān','SS',1123),(3585,'Surt','SR',1123),(3586,'Tājūrā\' wa an Nawāhī al Arbāh','TN',1123),(3587,'Ţarābulus','TB',1123),(3588,'Tarhūnah-Masallātah','TM',1123),(3589,'Wādī al hayāt','WD',1123),(3590,'Yafran-Jādū','YJ',1123),(3591,'Agadir','AGD',1146),(3592,'Aït Baha','BAH',1146),(3593,'Aït Melloul','MEL',1146),(3594,'Al Haouz','HAO',1146),(3595,'Al Hoceïma','HOC',1146),(3596,'Assa-Zag','ASZ',1146),(3597,'Azilal','AZI',1146),(3598,'Beni Mellal','BEM',1146),(3599,'Ben Sllmane','BES',1146),(3600,'Berkane','BER',1146),(3601,'Boujdour','BOD',1146),(3602,'Boulemane','BOM',1146),(3603,'Casablanca  [Dar el Beïda]','CAS',1146),(3604,'Chefchaouene','CHE',1146),(3605,'Chichaoua','CHI',1146),(3606,'El Hajeb','HAJ',1146),(3607,'El Jadida','JDI',1146),(3608,'Errachidia','ERR',1146),(3609,'Essaouira','ESI',1146),(3610,'Es Smara','ESM',1146),(3611,'Fès','FES',1146),(3612,'Figuig','FIG',1146),(3613,'Guelmim','GUE',1146),(3614,'Ifrane','IFR',1146),(3615,'Jerada','JRA',1146),(3616,'Kelaat Sraghna','KES',1146),(3617,'Kénitra','KEN',1146),(3618,'Khemisaet','KHE',1146),(3619,'Khenifra','KHN',1146),(3620,'Khouribga','KHO',1146),(3621,'Laâyoune (EH)','LAA',1146),(3622,'Larache','LAP',1146),(3623,'Marrakech','MAR',1146),(3624,'Meknsès','MEK',1146),(3625,'Nador','NAD',1146),(3626,'Ouarzazate','OUA',1146),(3627,'Oued ed Dahab (EH)','OUD',1146),(3628,'Oujda','OUJ',1146),(3629,'Rabat-Salé','RBA',1146),(3630,'Safi','SAF',1146),(3631,'Sefrou','SEF',1146),(3632,'Settat','SET',1146),(3633,'Sidl Kacem','SIK',1146),(3634,'Tanger','TNG',1146),(3635,'Tan-Tan','TNT',1146),(3636,'Taounate','TAO',1146),(3637,'Taroudannt','TAR',1146),(3638,'Tata','TAT',1146),(3639,'Taza','TAZ',1146),(3640,'Tétouan','TET',1146),(3641,'Tiznit','TIZ',1146),(3642,'Gagauzia, Unitate Teritoriala Autonoma','GA',1142),(3643,'Chisinau','CU',1142),(3644,'Stinga Nistrului, unitatea teritoriala din','SN',1142),(3645,'Balti','BA',1142),(3646,'Cahul','CA',1142),(3647,'Edinet','ED',1142),(3648,'Lapusna','LA',1142),(3649,'Orhei','OR',1142),(3650,'Soroca','SO',1142),(3651,'Taraclia','TA',1142),(3652,'Tighina [Bender]','TI',1142),(3653,'Ungheni','UN',1142),(3654,'Antananarivo','T',1129),(3655,'Antsiranana','D',1129),(3656,'Fianarantsoa','F',1129),(3657,'Mahajanga','M',1129),(3658,'Toamasina','A',1129),(3659,'Toliara','U',1129),(3660,'Ailinglapalap','ALL',1135),(3661,'Ailuk','ALK',1135),(3662,'Arno','ARN',1135),(3663,'Aur','AUR',1135),(3664,'Ebon','EBO',1135),(3665,'Eniwetok','ENI',1135),(3666,'Jaluit','JAL',1135),(3667,'Kili','KIL',1135),(3668,'Kwajalein','KWA',1135),(3669,'Lae','LAE',1135),(3670,'Lib','LIB',1135),(3671,'Likiep','LIK',1135),(3672,'Majuro','MAJ',1135),(3673,'Maloelap','MAL',1135),(3674,'Mejit','MEJ',1135),(3675,'Mili','MIL',1135),(3676,'Namorik','NMK',1135),(3677,'Namu','NMU',1135),(3678,'Rongelap','RON',1135),(3679,'Ujae','UJA',1135),(3680,'Ujelang','UJL',1135),(3681,'Utirik','UTI',1135),(3682,'Wotho','WTN',1135),(3683,'Wotje','WTJ',1135),(3684,'Bamako','BK0',1133),(3685,'Gao','7',1133),(3686,'Kayes','1',1133),(3687,'Kidal','8',1133),(3688,'Xoulikoro','2',1133),(3689,'Mopti','5',1133),(3690,'S69ou','4',1133),(3691,'Sikasso','3',1133),(3692,'Tombouctou','6',1133),(3693,'Ayeyarwady','07',1035),(3694,'Bago','02',1035),(3695,'Magway','03',1035),(3696,'Mandalay','04',1035),(3697,'Sagaing','01',1035),(3698,'Tanintharyi','05',1035),(3699,'Yangon','06',1035),(3700,'Chin','14',1035),(3701,'Kachin','11',1035),(3702,'Kayah','12',1035),(3703,'Kayin','13',1035),(3704,'Mon','15',1035),(3705,'Rakhine','16',1035),(3706,'Shan','17',1035),(3707,'Ulaanbaatar','1',1144),(3708,'Arhangay','073',1144),(3709,'Bayanhongor','069',1144),(3710,'Bayan-Olgiy','071',1144),(3711,'Bulgan','067',1144),(3712,'Darhan uul','037',1144),(3713,'Dornod','061',1144),(3714,'Dornogov,','063',1144),(3715,'DundgovL','059',1144),(3716,'Dzavhan','057',1144),(3717,'Govi-Altay','065',1144),(3718,'Govi-Smber','064',1144),(3719,'Hentiy','039',1144),(3720,'Hovd','043',1144),(3721,'Hovsgol','041',1144),(3722,'Omnogovi','053',1144),(3723,'Orhon','035',1144),(3724,'Ovorhangay','055',1144),(3725,'Selenge','049',1144),(3726,'Shbaatar','051',1144),(3727,'Tov','047',1144),(3728,'Uvs','046',1144),(3729,'Nouakchott','NKC',1137),(3730,'Assaba','03',1137),(3731,'Brakna','05',1137),(3732,'Dakhlet Nouadhibou','08',1137),(3733,'Gorgol','04',1137),(3734,'Guidimaka','10',1137),(3735,'Hodh ech Chargui','01',1137),(3736,'Hodh el Charbi','02',1137),(3737,'Inchiri','12',1137),(3738,'Tagant','09',1137),(3739,'Tiris Zemmour','11',1137),(3740,'Trarza','06',1137),(3741,'Beau Bassin-Rose Hill','BR',1138),(3742,'Curepipe','CU',1138),(3743,'Port Louis','PU',1138),(3744,'Quatre Bornes','QB',1138),(3745,'Vacosa-Phoenix','VP',1138),(3746,'Black River','BL',1138),(3747,'Flacq','FL',1138),(3748,'Grand Port','GP',1138),(3749,'Moka','MO',1138),(3750,'Pamplemousses','PA',1138),(3751,'Plaines Wilhems','PW',1138),(3752,'Riviere du Rempart','RP',1138),(3753,'Savanne','SA',1138),(3754,'Agalega Islands','AG',1138),(3755,'Cargados Carajos Shoals','CC',1138),(3756,'Rodrigues Island','RO',1138),(3757,'Male','MLE',1132),(3758,'Alif','02',1132),(3759,'Baa','20',1132),(3760,'Dhaalu','17',1132),(3761,'Faafu','14',1132),(3762,'Gaaf Alif','27',1132),(3763,'Gaefu Dhaalu','28',1132),(3764,'Gnaviyani','29',1132),(3765,'Haa Alif','07',1132),(3766,'Haa Dhaalu','23',1132),(3767,'Kaafu','26',1132),(3768,'Laamu','05',1132),(3769,'Lhaviyani','03',1132),(3770,'Meemu','12',1132),(3771,'Noonu','25',1132),(3772,'Raa','13',1132),(3773,'Seenu','01',1132),(3774,'Shaviyani','24',1132),(3775,'Thaa','08',1132),(3776,'Vaavu','04',1132),(3777,'Balaka','BA',1130),(3778,'Blantyre','BL',1130),(3779,'Chikwawa','CK',1130),(3780,'Chiradzulu','CR',1130),(3781,'Chitipa','CT',1130),(3782,'Dedza','DE',1130),(3783,'Dowa','DO',1130),(3784,'Karonga','KR',1130),(3785,'Kasungu','KS',1130),(3786,'Likoma Island','LK',1130),(3787,'Lilongwe','LI',1130),(3788,'Machinga','MH',1130),(3789,'Mangochi','MG',1130),(3790,'Mchinji','MC',1130),(3791,'Mulanje','MU',1130),(3792,'Mwanza','MW',1130),(3793,'Mzimba','MZ',1130),(3794,'Nkhata Bay','NB',1130),(3795,'Nkhotakota','NK',1130),(3796,'Nsanje','NS',1130),(3797,'Ntcheu','NU',1130),(3798,'Ntchisi','NI',1130),(3799,'Phalomba','PH',1130),(3800,'Rumphi','RU',1130),(3801,'Salima','SA',1130),(3802,'Thyolo','TH',1130),(3803,'Zomba','ZO',1130),(3804,'Aguascalientes','AGU',1140),(3805,'Baja California','BCN',1140),(3806,'Baja California Sur','BCS',1140),(3807,'Campeche','CAM',1140),(3808,'Coahuila','COA',1140),(3809,'Colima','COL',1140),(3810,'Chiapas','CHP',1140),(3811,'Chihuahua','CHH',1140),(3812,'Durango','DUR',1140),(3813,'Guanajuato','GUA',1140),(3814,'Guerrero','GRO',1140),(3815,'Hidalgo','HID',1140),(3816,'Jalisco','JAL',1140),(3817,'Mexico','MEX',1140),(3818,'Michoacin','MIC',1140),(3819,'Morelos','MOR',1140),(3820,'Nayarit','NAY',1140),(3821,'Nuevo Leon','NLE',1140),(3822,'Oaxaca','OAX',1140),(3823,'Puebla','PUE',1140),(3824,'Queretaro','QUE',1140),(3825,'Quintana Roo','ROO',1140),(3826,'San Luis Potosi','SLP',1140),(3827,'Sinaloa','SIN',1140),(3828,'Sonora','SON',1140),(3829,'Tabasco','TAB',1140),(3830,'Tamaulipas','TAM',1140),(3831,'Tlaxcala','TLA',1140),(3832,'Veracruz','VER',1140),(3833,'Yucatan','YUC',1140),(3834,'Zacatecas','ZAC',1140),(3835,'Wilayah Persekutuan Kuala Lumpur','14',1131),(3836,'Wilayah Persekutuan Labuan','15',1131),(3837,'Wilayah Persekutuan Putrajaya','16',1131),(3838,'Johor','01',1131),(3839,'Kedah','02',1131),(3840,'Kelantan','03',1131),(3841,'Melaka','04',1131),(3842,'Negeri Sembilan','05',1131),(3843,'Pahang','06',1131),(3844,'Perak','08',1131),(3845,'Perlis','09',1131),(3846,'Pulau Pinang','07',1131),(3847,'Sabah','12',1131),(3848,'Sarawak','13',1131),(3849,'Selangor','10',1131),(3850,'Terengganu','11',1131),(3851,'Maputo','MPM',1147),(3852,'Cabo Delgado','P',1147),(3853,'Gaza','G',1147),(3854,'Inhambane','I',1147),(3855,'Manica','B',1147),(3856,'Numpula','N',1147),(3857,'Niaaea','A',1147),(3858,'Sofala','S',1147),(3859,'Tete','T',1147),(3860,'Zambezia','Q',1147),(3861,'Caprivi','CA',1148),(3862,'Erongo','ER',1148),(3863,'Hardap','HA',1148),(3864,'Karas','KA',1148),(3865,'Khomas','KH',1148),(3866,'Kunene','KU',1148),(3867,'Ohangwena','OW',1148),(3868,'Okavango','OK',1148),(3869,'Omaheke','OH',1148),(3870,'Omusati','OS',1148),(3871,'Oshana','ON',1148),(3872,'Oshikoto','OT',1148),(3873,'Otjozondjupa','OD',1148),(3874,'Niamey','8',1156),(3875,'Agadez','1',1156),(3876,'Diffa','2',1156),(3877,'Dosso','3',1156),(3878,'Maradi','4',1156),(3879,'Tahoua','S',1156),(3880,'Tillaberi','6',1156),(3881,'Zinder','7',1156),(3882,'Abuja Federal Capital Territory','FC',1157),(3883,'Abia','AB',1157),(3884,'Adamawa','AD',1157),(3885,'Akwa Ibom','AK',1157),(3886,'Anambra','AN',1157),(3887,'Bauchi','BA',1157),(3888,'Bayelsa','BY',1157),(3889,'Benue','BE',1157),(3890,'Borno','BO',1157),(3891,'Cross River','CR',1157),(3892,'Delta','DE',1157),(3893,'Ebonyi','EB',1157),(3894,'Edo','ED',1157),(3895,'Ekiti','EK',1157),(3896,'Enugu','EN',1157),(3897,'Gombe','GO',1157),(3898,'Imo','IM',1157),(3899,'Jigawa','JI',1157),(3900,'Kaduna','KD',1157),(3901,'Kano','KN',1157),(3902,'Katsina','KT',1157),(3903,'Kebbi','KE',1157),(3904,'Kogi','KO',1157),(3905,'Kwara','KW',1157),(3906,'Lagos','LA',1157),(3907,'Nassarawa','NA',1157),(3908,'Niger','NI',1157),(3909,'Ogun','OG',1157),(3910,'Ondo','ON',1157),(3911,'Osun','OS',1157),(3912,'Oyo','OY',1157),(3913,'Rivers','RI',1157),(3914,'Sokoto','SO',1157),(3915,'Taraba','TA',1157),(3916,'Yobe','YO',1157),(3917,'Zamfara','ZA',1157),(3918,'Boaco','BO',1155),(3919,'Carazo','CA',1155),(3920,'Chinandega','CI',1155),(3921,'Chontales','CO',1155),(3922,'Esteli','ES',1155),(3923,'Jinotega','JI',1155),(3924,'Leon','LE',1155),(3925,'Madriz','MD',1155),(3926,'Managua','MN',1155),(3927,'Masaya','MS',1155),(3928,'Matagalpa','MT',1155),(3929,'Nueva Segovia','NS',1155),(3930,'Rio San Juan','SJ',1155),(3931,'Rivas','RI',1155),(3932,'Atlantico Norte','AN',1155),(3933,'Atlantico Sur','AS',1155),(3934,'Drente','DR',1152),(3935,'Flevoland','FL',1152),(3936,'Friesland','FR',1152),(3937,'Gelderland','GL',1152),(3938,'Groningen','GR',1152),(3939,'Noord-Brabant','NB',1152),(3940,'Noord-Holland','NH',1152),(3941,'Overijssel','OV',1152),(3942,'Utrecht','UT',1152),(3943,'Zuid-Holland','ZH',1152),(3944,'Zeeland','ZL',1152),(3945,'Akershus','02',1161),(3946,'Aust-Agder','09',1161),(3947,'Buskerud','06',1161),(3948,'Finnmark','20',1161),(3949,'Hedmark','04',1161),(3950,'Hordaland','12',1161),(3951,'Møre og Romsdal','15',1161),(3952,'Nordland','18',1161),(3953,'Nord-Trøndelag','17',1161),(3954,'Oppland','05',1161),(3955,'Oslo','03',1161),(3956,'Rogaland','11',1161),(3957,'Sogn og Fjordane','14',1161),(3958,'Sør-Trøndelag','16',1161),(3959,'Telemark','06',1161),(3960,'Troms','19',1161),(3961,'Vest-Agder','10',1161),(3962,'Vestfold','07',1161),(3963,'Østfold','01',1161),(3964,'Jan Mayen','22',1161),(3965,'Svalbard','21',1161),(3966,'Auckland','AUK',1154),(3967,'Bay of Plenty','BOP',1154),(3968,'Canterbury','CAN',1154),(3969,'Gisborne','GIS',1154),(3970,'Hawkes Bay','HKB',1154),(3971,'Manawatu-Wanganui','MWT',1154),(3972,'Marlborough','MBH',1154),(3973,'Nelson','NSN',1154),(3974,'Northland','NTL',1154),(3975,'Otago','OTA',1154),(3976,'Southland','STL',1154),(3977,'Taranaki','TKI',1154),(3978,'Tasman','TAS',1154),(3979,'Waikato','WKO',1154),(3980,'Wellington','WGN',1154),(3981,'West Coast','WTC',1154),(3982,'Ad Dakhillyah','DA',1162),(3983,'Al Batinah','BA',1162),(3984,'Al Janblyah','JA',1162),(3985,'Al Wusta','WU',1162),(3986,'Ash Sharqlyah','SH',1162),(3987,'Az Zahirah','ZA',1162),(3988,'Masqat','MA',1162),(3989,'Musandam','MU',1162),(3990,'Bocas del Toro','1',1166),(3991,'Cocle','2',1166),(3992,'Chiriqui','4',1166),(3993,'Darien','5',1166),(3994,'Herrera','6',1166),(3995,'Loa Santoa','7',1166),(3996,'Panama','8',1166),(3997,'Veraguas','9',1166),(3998,'Comarca de San Blas','Q',1166),(3999,'El Callao','CAL',1169),(4000,'Ancash','ANC',1169),(4001,'Apurimac','APU',1169),(4002,'Arequipa','ARE',1169),(4003,'Ayacucho','AYA',1169),(4004,'Cajamarca','CAJ',1169),(4005,'Cuzco','CUS',1169),(4006,'Huancavelica','HUV',1169),(4007,'Huanuco','HUC',1169),(4008,'Ica','ICA',1169),(4009,'Junin','JUN',1169),(4010,'La Libertad','LAL',1169),(4011,'Lambayeque','LAM',1169),(4012,'Lima','LIM',1169),(4013,'Loreto','LOR',1169),(4014,'Madre de Dios','MDD',1169),(4015,'Moquegua','MOQ',1169),(4016,'Pasco','PAS',1169),(4017,'Piura','PIU',1169),(4018,'Puno','PUN',1169),(4019,'San Martin','SAM',1169),(4020,'Tacna','TAC',1169),(4021,'Tumbes','TUM',1169),(4022,'Ucayali','UCA',1169),(4023,'National Capital District (Port Moresby)','NCD',1167),(4024,'Chimbu','CPK',1167),(4025,'Eastern Highlands','EHG',1167),(4026,'East New Britain','EBR',1167),(4027,'East Sepik','ESW',1167),(4028,'Enga','EPW',1167),(4029,'Gulf','GPK',1167),(4030,'Madang','MPM',1167),(4031,'Manus','MRL',1167),(4032,'Milne Bay','MBA',1167),(4033,'Morobe','MPL',1167),(4034,'New Ireland','NIK',1167),(4035,'North Solomons','NSA',1167),(4036,'Santaun','SAN',1167),(4037,'Southern Highlands','SHM',1167),(4038,'Western Highlands','WHM',1167),(4039,'West New Britain','WBK',1167),(4040,'Abra','ABR',1170),(4041,'Agusan del Norte','AGN',1170),(4042,'Agusan del Sur','AGS',1170),(4043,'Aklan','AKL',1170),(4044,'Albay','ALB',1170),(4045,'Antique','ANT',1170),(4046,'Apayao','APA',1170),(4047,'Aurora','AUR',1170),(4048,'Basilan','BAS',1170),(4049,'Bataan','BAN',1170),(4050,'Batanes','BTN',1170),(4051,'Batangas','BTG',1170),(4052,'Benguet','BEN',1170),(4053,'Biliran','BIL',1170),(4054,'Bohol','BOH',1170),(4055,'Bukidnon','BUK',1170),(4056,'Bulacan','BUL',1170),(4057,'Cagayan','CAG',1170),(4058,'Camarines Norte','CAN',1170),(4059,'Camarines Sur','CAS',1170),(4060,'Camiguin','CAM',1170),(4061,'Capiz','CAP',1170),(4062,'Catanduanes','CAT',1170),(4063,'Cavite','CAV',1170),(4064,'Cebu','CEB',1170),(4065,'Compostela Valley','COM',1170),(4066,'Davao','DAV',1170),(4067,'Davao del Sur','DAS',1170),(4068,'Davao Oriental','DAO',1170),(4069,'Eastern Samar','EAS',1170),(4070,'Guimaras','GUI',1170),(4071,'Ifugao','IFU',1170),(4072,'Ilocos Norte','ILN',1170),(4073,'Ilocos Sur','ILS',1170),(4074,'Iloilo','ILI',1170),(4075,'Isabela','ISA',1170),(4076,'Kalinga-Apayso','KAL',1170),(4077,'Laguna','LAG',1170),(4078,'Lanao del Norte','LAN',1170),(4079,'Lanao del Sur','LAS',1170),(4080,'La Union','LUN',1170),(4081,'Leyte','LEY',1170),(4082,'Maguindanao','MAG',1170),(4083,'Marinduque','MAD',1170),(4084,'Masbate','MAS',1170),(4085,'Mindoro Occidental','MDC',1170),(4086,'Mindoro Oriental','MDR',1170),(4087,'Misamis Occidental','MSC',1170),(4088,'Misamis Oriental','MSR',1170),(4089,'Mountain Province','MOU',1170),(4090,'Negroe Occidental','NEC',1170),(4091,'Negros Oriental','NER',1170),(4092,'North Cotabato','NCO',1170),(4093,'Northern Samar','NSA',1170),(4094,'Nueva Ecija','NUE',1170),(4095,'Nueva Vizcaya','NUV',1170),(4096,'Palawan','PLW',1170),(4097,'Pampanga','PAM',1170),(4098,'Pangasinan','PAN',1170),(4099,'Quezon','QUE',1170),(4100,'Quirino','QUI',1170),(4101,'Rizal','RIZ',1170),(4102,'Romblon','ROM',1170),(4103,'Sarangani','SAR',1170),(4104,'Siquijor','SIG',1170),(4105,'Sorsogon','SOR',1170),(4106,'South Cotabato','SCO',1170),(4107,'Southern Leyte','SLE',1170),(4108,'Sultan Kudarat','SUK',1170),(4109,'Sulu','SLU',1170),(4110,'Surigao del Norte','SUN',1170),(4111,'Surigao del Sur','SUR',1170),(4112,'Tarlac','TAR',1170),(4113,'Tawi-Tawi','TAW',1170),(4114,'Western Samar','WSA',1170),(4115,'Zambales','ZMB',1170),(4116,'Zamboanga del Norte','ZAN',1170),(4117,'Zamboanga del Sur','ZAS',1170),(4118,'Zamboanga Sibiguey','ZSI',1170),(4119,'Islamabad Federal Capital Area','IS',1163),(4120,'Baluchistan','BA',1163),(4121,'Khyber Pakhtun Khawa','NW',1163),(4122,'Sindh','SD',1163),(4123,'Federally Administered Tribal Areas','TA',1163),(4124,'Azad Kashmir','JK',1163),(4125,'Gilgit-Baltistan','NA',1163),(4126,'Aveiro','01',1173),(4127,'Beja','02',1173),(4128,'Braga','03',1173),(4129,'Braganca','04',1173),(4130,'Castelo Branco','05',1173),(4131,'Colmbra','06',1173),(4132,'Ovora','07',1173),(4133,'Faro','08',1173),(4134,'Guarda','09',1173),(4135,'Leiria','10',1173),(4136,'Lisboa','11',1173),(4137,'Portalegre','12',1173),(4138,'Porto','13',1173),(4139,'Santarem','14',1173),(4140,'Setubal','15',1173),(4141,'Viana do Castelo','16',1173),(4142,'Vila Real','17',1173),(4143,'Viseu','18',1173),(4144,'Regiao Autonoma dos Acores','20',1173),(4145,'Regiao Autonoma da Madeira','30',1173),(4146,'Asuncion','ASU',1168),(4147,'Alto Paraguay','16',1168),(4148,'Alto Parana','10',1168),(4149,'Amambay','13',1168),(4150,'Boqueron','19',1168),(4151,'Caeguazu','5',1168),(4152,'Caazapl','6',1168),(4153,'Canindeyu','14',1168),(4154,'Concepcion','1',1168),(4155,'Cordillera','3',1168),(4156,'Guaira','4',1168),(4157,'Itapua','7',1168),(4158,'Miaiones','8',1168),(4159,'Neembucu','12',1168),(4160,'Paraguari','9',1168),(4161,'Presidente Hayes','15',1168),(4162,'San Pedro','2',1168),(4163,'Ad Dawhah','DA',1175),(4164,'Al Ghuwayriyah','GH',1175),(4165,'Al Jumayliyah','JU',1175),(4166,'Al Khawr','KH',1175),(4167,'Al Wakrah','WA',1175),(4168,'Ar Rayyan','RA',1175),(4169,'Jariyan al Batnah','JB',1175),(4170,'Madinat ash Shamal','MS',1175),(4171,'Umm Salal','US',1175),(4172,'Bucuresti','B',1176),(4173,'Alba','AB',1176),(4174,'Arad','AR',1176),(4175,'Arges','AG',1176),(4176,'Bacau','BC',1176),(4177,'Bihor','BH',1176),(4178,'Bistrita-Nasaud','BN',1176),(4179,'Boto\'ani','BT',1176),(4180,'Bra\'ov','BV',1176),(4181,'Braila','BR',1176),(4182,'Buzau','BZ',1176),(4183,'Caras-Severin','CS',1176),(4184,'Ca la ras\'i','CL',1176),(4185,'Cluj','CJ',1176),(4186,'Constant\'a','CT',1176),(4187,'Covasna','CV',1176),(4188,'Dambovit\'a','DB',1176),(4189,'Dolj','DJ',1176),(4190,'Galat\'i','GL',1176),(4191,'Giurgiu','GR',1176),(4192,'Gorj','GJ',1176),(4193,'Harghita','HR',1176),(4194,'Hunedoara','HD',1176),(4195,'Ialomit\'a','IL',1176),(4196,'Ias\'i','IS',1176),(4197,'Ilfov','IF',1176),(4198,'Maramures','MM',1176),(4199,'Mehedint\'i','MH',1176),(4200,'Mures','MS',1176),(4201,'Neamt','NT',1176),(4202,'Olt','OT',1176),(4203,'Prahova','PH',1176),(4204,'Satu Mare','SM',1176),(4205,'Sa laj','SJ',1176),(4206,'Sibiu','SB',1176),(4207,'Suceava','SV',1176),(4208,'Teleorman','TR',1176),(4209,'Timis','TM',1176),(4210,'Tulcea','TL',1176),(4211,'Vaslui','VS',1176),(4212,'Valcea','VL',1176),(4213,'Vrancea','VN',1176),(4214,'Adygeya, Respublika','AD',1177),(4215,'Altay, Respublika','AL',1177),(4216,'Bashkortostan, Respublika','BA',1177),(4217,'Buryatiya, Respublika','BU',1177),(4218,'Chechenskaya Respublika','CE',1177),(4219,'Chuvashskaya Respublika','CU',1177),(4220,'Dagestan, Respublika','DA',1177),(4221,'Ingushskaya Respublika','IN',1177),(4222,'Kabardino-Balkarskaya','KB',1177),(4223,'Kalmykiya, Respublika','KL',1177),(4224,'Karachayevo-Cherkesskaya Respublika','KC',1177),(4225,'Kareliya, Respublika','KR',1177),(4226,'Khakasiya, Respublika','KK',1177),(4227,'Komi, Respublika','KO',1177),(4228,'Mariy El, Respublika','ME',1177),(4229,'Mordoviya, Respublika','MO',1177),(4230,'Sakha, Respublika [Yakutiya]','SA',1177),(4231,'Severnaya Osetiya, Respublika','SE',1177),(4232,'Tatarstan, Respublika','TA',1177),(4233,'Tyva, Respublika [Tuva]','TY',1177),(4234,'Udmurtskaya Respublika','UD',1177),(4235,'Altayskiy kray','ALT',1177),(4236,'Khabarovskiy kray','KHA',1177),(4237,'Krasnodarskiy kray','KDA',1177),(4238,'Krasnoyarskiy kray','KYA',1177),(4239,'Primorskiy kray','PRI',1177),(4240,'Stavropol\'skiy kray','STA',1177),(4241,'Amurskaya oblast\'','AMU',1177),(4242,'Arkhangel\'skaya oblast\'','ARK',1177),(4243,'Astrakhanskaya oblast\'','AST',1177),(4244,'Belgorodskaya oblast\'','BEL',1177),(4245,'Bryanskaya oblast\'','BRY',1177),(4246,'Chelyabinskaya oblast\'','CHE',1177),(4247,'Zabaykalsky Krai\'','ZSK',1177),(4248,'Irkutskaya oblast\'','IRK',1177),(4249,'Ivanovskaya oblast\'','IVA',1177),(4250,'Kaliningradskaya oblast\'','KGD',1177),(4251,'Kaluzhskaya oblast\'','KLU',1177),(4252,'Kamchatka Krai\'','KAM',1177),(4253,'Kemerovskaya oblast\'','KEM',1177),(4254,'Kirovskaya oblast\'','KIR',1177),(4255,'Kostromskaya oblast\'','KOS',1177),(4256,'Kurganskaya oblast\'','KGN',1177),(4257,'Kurskaya oblast\'','KRS',1177),(4258,'Leningradskaya oblast\'','LEN',1177),(4259,'Lipetskaya oblast\'','LIP',1177),(4260,'Magadanskaya oblast\'','MAG',1177),(4261,'Moskovskaya oblast\'','MOS',1177),(4262,'Murmanskaya oblast\'','MUR',1177),(4263,'Nizhegorodskaya oblast\'','NIZ',1177),(4264,'Novgorodskaya oblast\'','NGR',1177),(4265,'Novosibirskaya oblast\'','NVS',1177),(4266,'Omskaya oblast\'','OMS',1177),(4267,'Orenburgskaya oblast\'','ORE',1177),(4268,'Orlovskaya oblast\'','ORL',1177),(4269,'Penzenskaya oblast\'','PNZ',1177),(4270,'Perm krai\'','PEK',1177),(4271,'Pskovskaya oblast\'','PSK',1177),(4272,'Rostovskaya oblast\'','ROS',1177),(4273,'Ryazanskaya oblast\'','RYA',1177),(4274,'Sakhalinskaya oblast\'','SAK',1177),(4275,'Samarskaya oblast\'','SAM',1177),(4276,'Saratovskaya oblast\'','SAR',1177),(4277,'Smolenskaya oblast\'','SMO',1177),(4278,'Sverdlovskaya oblast\'','SVE',1177),(4279,'Tambovskaya oblast\'','TAM',1177),(4280,'Tomskaya oblast\'','TOM',1177),(4281,'Tul\'skaya oblast\'','TUL',1177),(4282,'Tverskaya oblast\'','TVE',1177),(4283,'Tyumenskaya oblast\'','TYU',1177),(4284,'Ul\'yanovskaya oblast\'','ULY',1177),(4285,'Vladimirskaya oblast\'','VLA',1177),(4286,'Volgogradskaya oblast\'','VGG',1177),(4287,'Vologodskaya oblast\'','VLG',1177),(4288,'Voronezhskaya oblast\'','VOR',1177),(4289,'Yaroslavskaya oblast\'','YAR',1177),(4290,'Moskva','MOW',1177),(4291,'Sankt-Peterburg','SPE',1177),(4292,'Yevreyskaya avtonomnaya oblast\'','YEV',1177),(4294,'Chukotskiy avtonomnyy okrug','CHU',1177),(4296,'Khanty-Mansiyskiy avtonomnyy okrug','KHM',1177),(4299,'Nenetskiy avtonomnyy okrug','NEN',1177),(4302,'Yamalo-Nenetskiy avtonomnyy okrug','YAN',1177),(4303,'Butare','C',1178),(4304,'Byumba','I',1178),(4305,'Cyangugu','E',1178),(4306,'Gikongoro','D',1178),(4307,'Gisenyi','G',1178),(4308,'Gitarama','B',1178),(4309,'Kibungo','J',1178),(4310,'Kibuye','F',1178),(4311,'Kigali-Rural Kigali y\' Icyaro','K',1178),(4312,'Kigali-Ville Kigali Ngari','L',1178),(4313,'Mutara','M',1178),(4314,'Ruhengeri','H',1178),(4315,'Al Bahah','11',1187),(4316,'Al Hudud Ash Shamaliyah','08',1187),(4317,'Al Jawf','12',1187),(4318,'Al Madinah','03',1187),(4319,'Al Qasim','05',1187),(4320,'Ar Riyad','01',1187),(4321,'Asir','14',1187),(4322,'Ha\'il','06',1187),(4323,'Jlzan','09',1187),(4324,'Makkah','02',1187),(4325,'Najran','10',1187),(4326,'Tabuk','07',1187),(4327,'Capital Territory (Honiara)','CT',1194),(4328,'Guadalcanal','GU',1194),(4329,'Isabel','IS',1194),(4330,'Makira','MK',1194),(4331,'Malaita','ML',1194),(4332,'Temotu','TE',1194),(4333,'A\'ali an Nil','23',1200),(4334,'Al Bah al Ahmar','26',1200),(4335,'Al Buhayrat','18',1200),(4336,'Al Jazirah','07',1200),(4337,'Al Khartum','03',1200),(4338,'Al Qadarif','06',1200),(4339,'Al Wahdah','22',1200),(4340,'An Nil','04',1200),(4341,'An Nil al Abyaq','08',1200),(4342,'An Nil al Azraq','24',1200),(4343,'Ash Shamallyah','01',1200),(4344,'Bahr al Jabal','17',1200),(4345,'Gharb al Istiwa\'iyah','16',1200),(4346,'Gharb Ba~r al Ghazal','14',1200),(4347,'Gharb Darfur','12',1200),(4348,'Gharb Kurdufan','10',1200),(4349,'Janub Darfur','11',1200),(4350,'Janub Rurdufan','13',1200),(4351,'Jnqall','20',1200),(4352,'Kassala','05',1200),(4353,'Shamal Batr al Ghazal','15',1200),(4354,'Shamal Darfur','02',1200),(4355,'Shamal Kurdufan','09',1200),(4356,'Sharq al Istiwa\'iyah','19',1200),(4357,'Sinnar','25',1200),(4358,'Warab','21',1200),(4359,'Blekinge län','K',1204),(4360,'Dalarnas län','W',1204),(4361,'Gotlands län','I',1204),(4362,'Gävleborgs län','X',1204),(4363,'Hallands län','N',1204),(4364,'Jämtlands län','Z',1204),(4365,'Jönkopings län','F',1204),(4366,'Kalmar län','H',1204),(4367,'Kronobergs län','G',1204),(4368,'Norrbottens län','BD',1204),(4369,'Skåne län','M',1204),(4370,'Stockholms län','AB',1204),(4371,'Södermanlands län','D',1204),(4372,'Uppsala län','C',1204),(4373,'Värmlands län','S',1204),(4374,'Västerbottens län','AC',1204),(4375,'Västernorrlands län','Y',1204),(4376,'Västmanlands län','U',1204),(4377,'Västra Götalands län','Q',1204),(4378,'Örebro län','T',1204),(4379,'Östergötlands län','E',1204),(4380,'Saint Helena','SH',1180),(4381,'Ascension','AC',1180),(4382,'Tristan da Cunha','TA',1180),(4383,'Ajdovščina','001',1193),(4384,'Beltinci','002',1193),(4385,'Benedikt','148',1193),(4386,'Bistrica ob Sotli','149',1193),(4387,'Bled','003',1193),(4388,'Bloke','150',1193),(4389,'Bohinj','004',1193),(4390,'Borovnica','005',1193),(4391,'Bovec','006',1193),(4392,'Braslovče','151',1193),(4393,'Brda','007',1193),(4394,'Brezovica','008',1193),(4395,'Brežice','009',1193),(4396,'Cankova','152',1193),(4397,'Celje','011',1193),(4398,'Cerklje na Gorenjskem','012',1193),(4399,'Cerknica','013',1193),(4400,'Cerkno','014',1193),(4401,'Cerkvenjak','153',1193),(4402,'Črenšovci','015',1193),(4403,'Črna na Koroškem','016',1193),(4404,'Črnomelj','017',1193),(4405,'Destrnik','018',1193),(4406,'Divača','019',1193),(4407,'Dobje','154',1193),(4408,'Dobrepolje','020',1193),(4409,'Dobrna','155',1193),(4410,'Dobrova-Polhov Gradec','021',1193),(4411,'Dobrovnik','156',1193),(4412,'Dol pri Ljubljani','022',1193),(4413,'Dolenjske Toplice','157',1193),(4414,'Domžale','023',1193),(4415,'Dornava','024',1193),(4416,'Dravograd','025',1193),(4417,'Duplek','026',1193),(4418,'Gorenja vas-Poljane','027',1193),(4419,'Gorišnica','028',1193),(4420,'Gornja Radgona','029',1193),(4421,'Gornji Grad','030',1193),(4422,'Gornji Petrovci','031',1193),(4423,'Grad','158',1193),(4424,'Grosuplje','032',1193),(4425,'Hajdina','159',1193),(4426,'Hoče-Slivnica','160',1193),(4427,'Hodoš','161',1193),(4428,'Horjul','162',1193),(4429,'Hrastnik','034',1193),(4430,'Hrpelje-Kozina','035',1193),(4431,'Idrija','036',1193),(4432,'Ig','037',1193),(4433,'Ilirska Bistrica','038',1193),(4434,'Ivančna Gorica','039',1193),(4435,'Izola','040',1193),(4436,'Jesenice','041',1193),(4437,'Jezersko','163',1193),(4438,'Juršinci','042',1193),(4439,'Kamnik','043',1193),(4440,'Kanal','044',1193),(4441,'Kidričevo','045',1193),(4442,'Kobarid','046',1193),(4443,'Kobilje','047',1193),(4444,'Kočevje','048',1193),(4445,'Komen','049',1193),(4446,'Komenda','164',1193),(4447,'Koper','050',1193),(4448,'Kostel','165',1193),(4449,'Kozje','051',1193),(4450,'Kranj','052',1193),(4451,'Kranjska Gora','053',1193),(4452,'Križevci','166',1193),(4453,'Krško','054',1193),(4454,'Kungota','055',1193),(4455,'Kuzma','056',1193),(4456,'Laško','057',1193),(4457,'Lenart','058',1193),(4458,'Lendava','059',1193),(4459,'Litija','060',1193),(4460,'Ljubljana','061',1193),(4461,'Ljubno','062',1193),(4462,'Ljutomer','063',1193),(4463,'Logatec','064',1193),(4464,'Loška dolina','065',1193),(4465,'Loški Potok','066',1193),(4466,'Lovrenc na Pohorju','167',1193),(4467,'Luče','067',1193),(4468,'Lukovica','068',1193),(4469,'Majšperk','069',1193),(4470,'Maribor','070',1193),(4471,'Markovci','168',1193),(4472,'Medvode','071',1193),(4473,'Mengeš','072',1193),(4474,'Metlika','073',1193),(4475,'Mežica','074',1193),(4476,'Miklavž na Dravskem polju','169',1193),(4477,'Miren-Kostanjevica','075',1193),(4478,'Mirna Peč','170',1193),(4479,'Mislinja','076',1193),(4480,'Moravče','077',1193),(4481,'Moravske Toplice','078',1193),(4482,'Mozirje','079',1193),(4483,'Murska Sobota','080',1193),(4484,'Muta','081',1193),(4485,'Naklo','082',1193),(4486,'Nazarje','083',1193),(4487,'Nova Gorica','084',1193),(4488,'Novo mesto','085',1193),(4489,'Sveta Ana','181',1193),(4490,'Sveti Andraž v Slovenskih goricah','182',1193),(4491,'Sveti Jurij','116',1193),(4492,'Šalovci','033',1193),(4493,'Šempeter-Vrtojba','183',1193),(4494,'Šenčur','117',1193),(4495,'Šentilj','118',1193),(4496,'Šentjernej','119',1193),(4497,'Šentjur','120',1193),(4498,'Škocjan','121',1193),(4499,'Škofja Loka','122',1193),(4500,'Škofljica','123',1193),(4501,'Šmarje pri Jelšah','124',1193),(4502,'Šmartno ob Paki','125',1193),(4503,'Šmartno pri Litiji','194',1193),(4504,'Šoštanj','126',1193),(4505,'Štore','127',1193),(4506,'Tabor','184',1193),(4507,'Tišina','010',1193),(4508,'Tolmin','128',1193),(4509,'Trbovlje','129',1193),(4510,'Trebnje','130',1193),(4511,'Trnovska vas','185',1193),(4512,'Tržič','131',1193),(4513,'Trzin','186',1193),(4514,'Turnišče','132',1193),(4515,'Velenje','133',1193),(4516,'Velika Polana','187',1193),(4517,'Velike Lašče','134',1193),(4518,'Veržej','188',1193),(4519,'Videm','135',1193),(4520,'Vipava','136',1193),(4521,'Vitanje','137',1193),(4522,'Vojnik','138',1193),(4523,'Vransko','189',1193),(4524,'Vrhnika','140',1193),(4525,'Vuzenica','141',1193),(4526,'Zagorje ob Savi','142',1193),(4527,'Zavrč','143',1193),(4528,'Zreče','144',1193),(4529,'Žalec','190',1193),(4530,'Železniki','146',1193),(4531,'Žetale','191',1193),(4532,'Žiri','147',1193),(4533,'Žirovnica','192',1193),(4534,'Žužemberk','193',1193),(4535,'Banskobystrický kraj','BC',1192),(4536,'Bratislavský kraj','BL',1192),(4537,'Košický kraj','KI',1192),(4538,'Nitriansky kraj','NJ',1192),(4539,'Prešovský kraj','PV',1192),(4540,'Trenčiansky kraj','TC',1192),(4541,'Trnavský kraj','TA',1192),(4542,'Žilinský kraj','ZI',1192),(4543,'Western Area (Freetown)','W',1190),(4544,'Dakar','DK',1188),(4545,'Diourbel','DB',1188),(4546,'Fatick','FK',1188),(4547,'Kaolack','KL',1188),(4548,'Kolda','KD',1188),(4549,'Louga','LG',1188),(4550,'Matam','MT',1188),(4551,'Saint-Louis','SL',1188),(4552,'Tambacounda','TC',1188),(4553,'Thies','TH',1188),(4554,'Ziguinchor','ZG',1188),(4555,'Awdal','AW',1195),(4556,'Bakool','BK',1195),(4557,'Banaadir','BN',1195),(4558,'Bay','BY',1195),(4559,'Galguduud','GA',1195),(4560,'Gedo','GE',1195),(4561,'Hiirsan','HI',1195),(4562,'Jubbada Dhexe','JD',1195),(4563,'Jubbada Hoose','JH',1195),(4564,'Mudug','MU',1195),(4565,'Nugaal','NU',1195),(4566,'Saneag','SA',1195),(4567,'Shabeellaha Dhexe','SD',1195),(4568,'Shabeellaha Hoose','SH',1195),(4569,'Sool','SO',1195),(4570,'Togdheer','TO',1195),(4571,'Woqooyi Galbeed','WO',1195),(4572,'Brokopondo','BR',1201),(4573,'Commewijne','CM',1201),(4574,'Coronie','CR',1201),(4575,'Marowijne','MA',1201),(4576,'Nickerie','NI',1201),(4577,'Paramaribo','PM',1201),(4578,'Saramacca','SA',1201),(4579,'Sipaliwini','SI',1201),(4580,'Wanica','WA',1201),(4581,'Principe','P',1207),(4582,'Sao Tome','S',1207),(4583,'Ahuachapan','AH',1066),(4584,'Cabanas','CA',1066),(4585,'Cuscatlan','CU',1066),(4586,'Chalatenango','CH',1066),(4587,'Morazan','MO',1066),(4588,'San Miguel','SM',1066),(4589,'San Salvador','SS',1066),(4590,'Santa Ana','SA',1066),(4591,'San Vicente','SV',1066),(4592,'Sonsonate','SO',1066),(4593,'Usulutan','US',1066),(4594,'Al Hasakah','HA',1206),(4595,'Al Ladhiqiyah','LA',1206),(4596,'Al Qunaytirah','QU',1206),(4597,'Ar Raqqah','RA',1206),(4598,'As Suwayda\'','SU',1206),(4599,'Dar\'a','DR',1206),(4600,'Dayr az Zawr','DY',1206),(4601,'Dimashq','DI',1206),(4602,'Halab','HL',1206),(4603,'Hamah','HM',1206),(4604,'Jim\'','HI',1206),(4605,'Idlib','ID',1206),(4606,'Rif Dimashq','RD',1206),(4607,'Tarts','TA',1206),(4608,'Hhohho','HH',1203),(4609,'Lubombo','LU',1203),(4610,'Manzini','MA',1203),(4611,'Shiselweni','SH',1203),(4612,'Batha','BA',1043),(4613,'Biltine','BI',1043),(4614,'Borkou-Ennedi-Tibesti','BET',1043),(4615,'Chari-Baguirmi','CB',1043),(4616,'Guera','GR',1043),(4617,'Kanem','KA',1043),(4618,'Lac','LC',1043),(4619,'Logone-Occidental','LO',1043),(4620,'Logone-Oriental','LR',1043),(4621,'Mayo-Kebbi','MK',1043),(4622,'Moyen-Chari','MC',1043),(4623,'Ouaddai','OD',1043),(4624,'Salamat','SA',1043),(4625,'Tandjile','TA',1043),(4626,'Kara','K',1214),(4627,'Maritime (Region)','M',1214),(4628,'Savannes','S',1214),(4629,'Krung Thep Maha Nakhon Bangkok','10',1211),(4630,'Phatthaya','S',1211),(4631,'Amnat Charoen','37',1211),(4632,'Ang Thong','15',1211),(4633,'Buri Ram','31',1211),(4634,'Chachoengsao','24',1211),(4635,'Chai Nat','18',1211),(4636,'Chaiyaphum','36',1211),(4637,'Chanthaburi','22',1211),(4638,'Chiang Mai','50',1211),(4639,'Chiang Rai','57',1211),(4640,'Chon Buri','20',1211),(4641,'Chumphon','86',1211),(4642,'Kalasin','46',1211),(4643,'Kamphasng Phet','62',1211),(4644,'Kanchanaburi','71',1211),(4645,'Khon Kaen','40',1211),(4646,'Krabi','81',1211),(4647,'Lampang','52',1211),(4648,'Lamphun','51',1211),(4649,'Loei','42',1211),(4650,'Lop Buri','16',1211),(4651,'Mae Hong Son','58',1211),(4652,'Maha Sarakham','44',1211),(4653,'Mukdahan','49',1211),(4654,'Nakhon Nayok','26',1211),(4655,'Nakhon Pathom','73',1211),(4656,'Nakhon Phanom','48',1211),(4657,'Nakhon Ratchasima','30',1211),(4658,'Nakhon Sawan','60',1211),(4659,'Nakhon Si Thammarat','80',1211),(4660,'Nan','55',1211),(4661,'Narathiwat','96',1211),(4662,'Nong Bua Lam Phu','39',1211),(4663,'Nong Khai','43',1211),(4664,'Nonthaburi','12',1211),(4665,'Pathum Thani','13',1211),(4666,'Pattani','94',1211),(4667,'Phangnga','82',1211),(4668,'Phatthalung','93',1211),(4669,'Phayao','56',1211),(4670,'Phetchabun','67',1211),(4671,'Phetchaburi','76',1211),(4672,'Phichit','66',1211),(4673,'Phitsanulok','65',1211),(4674,'Phrae','54',1211),(4675,'Phra Nakhon Si Ayutthaya','14',1211),(4676,'Phuket','83',1211),(4677,'Prachin Buri','25',1211),(4678,'Prachuap Khiri Khan','77',1211),(4679,'Ranong','85',1211),(4680,'Ratchaburi','70',1211),(4681,'Rayong','21',1211),(4682,'Roi Et','45',1211),(4683,'Sa Kaeo','27',1211),(4684,'Sakon Nakhon','47',1211),(4685,'Samut Prakan','11',1211),(4686,'Samut Sakhon','74',1211),(4687,'Samut Songkhram','75',1211),(4688,'Saraburi','19',1211),(4689,'Satun','91',1211),(4690,'Sing Buri','17',1211),(4691,'Si Sa Ket','33',1211),(4692,'Songkhla','90',1211),(4693,'Sukhothai','64',1211),(4694,'Suphan Buri','72',1211),(4695,'Surat Thani','84',1211),(4696,'Surin','32',1211),(4697,'Tak','63',1211),(4698,'Trang','92',1211),(4699,'Trat','23',1211),(4700,'Ubon Ratchathani','34',1211),(4701,'Udon Thani','41',1211),(4702,'Uthai Thani','61',1211),(4703,'Uttaradit','53',1211),(4704,'Yala','95',1211),(4705,'Yasothon','35',1211),(4706,'Sughd','SU',1209),(4707,'Khatlon','KT',1209),(4708,'Gorno-Badakhshan','GB',1209),(4709,'Ahal','A',1220),(4710,'Balkan','B',1220),(4711,'Dasoguz','D',1220),(4712,'Lebap','L',1220),(4713,'Mary','M',1220),(4714,'Béja','31',1218),(4715,'Ben Arous','13',1218),(4716,'Bizerte','23',1218),(4717,'Gabès','81',1218),(4718,'Gafsa','71',1218),(4719,'Jendouba','32',1218),(4720,'Kairouan','41',1218),(4721,'Rasserine','42',1218),(4722,'Kebili','73',1218),(4723,'L\'Ariana','12',1218),(4724,'Le Ref','33',1218),(4725,'Mahdia','53',1218),(4726,'La Manouba','14',1218),(4727,'Medenine','82',1218),(4728,'Moneatir','52',1218),(4729,'Naboul','21',1218),(4730,'Sfax','61',1218),(4731,'Sidi Bouxid','43',1218),(4732,'Siliana','34',1218),(4733,'Sousse','51',1218),(4734,'Tataouine','83',1218),(4735,'Tozeur','72',1218),(4736,'Tunis','11',1218),(4737,'Zaghouan','22',1218),(4738,'Adana','01',1219),(4739,'Ad yaman','02',1219),(4740,'Afyon','03',1219),(4741,'Ag r','04',1219),(4742,'Aksaray','68',1219),(4743,'Amasya','05',1219),(4744,'Ankara','06',1219),(4745,'Antalya','07',1219),(4746,'Ardahan','75',1219),(4747,'Artvin','08',1219),(4748,'Aydin','09',1219),(4749,'Bal kesir','10',1219),(4750,'Bartin','74',1219),(4751,'Batman','72',1219),(4752,'Bayburt','69',1219),(4753,'Bilecik','11',1219),(4754,'Bingol','12',1219),(4755,'Bitlis','13',1219),(4756,'Bolu','14',1219),(4757,'Burdur','15',1219),(4758,'Bursa','16',1219),(4759,'Canakkale','17',1219),(4760,'Cankir','18',1219),(4761,'Corum','19',1219),(4762,'Denizli','20',1219),(4763,'Diyarbakir','21',1219),(4764,'Duzce','81',1219),(4765,'Edirne','22',1219),(4766,'Elazig','23',1219),(4767,'Erzincan','24',1219),(4768,'Erzurum','25',1219),(4769,'Eskis\'ehir','26',1219),(4770,'Gaziantep','27',1219),(4771,'Giresun','28',1219),(4772,'Gms\'hane','29',1219),(4773,'Hakkari','30',1219),(4774,'Hatay','31',1219),(4775,'Igidir','76',1219),(4776,'Isparta','32',1219),(4777,'Icel','33',1219),(4778,'Istanbul','34',1219),(4779,'Izmir','35',1219),(4780,'Kahramanmaras','46',1219),(4781,'Karabk','78',1219),(4782,'Karaman','70',1219),(4783,'Kars','36',1219),(4784,'Kastamonu','37',1219),(4785,'Kayseri','38',1219),(4786,'Kirikkale','71',1219),(4787,'Kirklareli','39',1219),(4788,'Kirs\'ehir','40',1219),(4789,'Kilis','79',1219),(4790,'Kocaeli','41',1219),(4791,'Konya','42',1219),(4792,'Ktahya','43',1219),(4793,'Malatya','44',1219),(4794,'Manisa','45',1219),(4795,'Mardin','47',1219),(4796,'Mugila','48',1219),(4797,'Mus','49',1219),(4798,'Nevs\'ehir','50',1219),(4799,'Nigide','51',1219),(4800,'Ordu','52',1219),(4801,'Osmaniye','80',1219),(4802,'Rize','53',1219),(4803,'Sakarya','54',1219),(4804,'Samsun','55',1219),(4805,'Siirt','56',1219),(4806,'Sinop','57',1219),(4807,'Sivas','58',1219),(4808,'S\'anliurfa','63',1219),(4809,'S\'rnak','73',1219),(4810,'Tekirdag','59',1219),(4811,'Tokat','60',1219),(4812,'Trabzon','61',1219),(4813,'Tunceli','62',1219),(4814,'Us\'ak','64',1219),(4815,'Van','65',1219),(4816,'Yalova','77',1219),(4817,'Yozgat','66',1219),(4818,'Zonguldak','67',1219),(4819,'Couva-Tabaquite-Talparo','CTT',1217),(4820,'Diego Martin','DMN',1217),(4821,'Eastern Tobago','ETO',1217),(4822,'Penal-Debe','PED',1217),(4823,'Princes Town','PRT',1217),(4824,'Rio Claro-Mayaro','RCM',1217),(4825,'Sangre Grande','SGE',1217),(4826,'San Juan-Laventille','SJL',1217),(4827,'Siparia','SIP',1217),(4828,'Tunapuna-Piarco','TUP',1217),(4829,'Western Tobago','WTO',1217),(4830,'Arima','ARI',1217),(4831,'Chaguanas','CHA',1217),(4832,'Point Fortin','PTF',1217),(4833,'Port of Spain','POS',1217),(4834,'San Fernando','SFO',1217),(4835,'Aileu','AL',1063),(4836,'Ainaro','AN',1063),(4837,'Bacucau','BA',1063),(4838,'Bobonaro','BO',1063),(4839,'Cova Lima','CO',1063),(4840,'Dili','DI',1063),(4841,'Ermera','ER',1063),(4842,'Laulem','LA',1063),(4843,'Liquica','LI',1063),(4844,'Manatuto','MT',1063),(4845,'Manafahi','MF',1063),(4846,'Oecussi','OE',1063),(4847,'Viqueque','VI',1063),(4848,'Changhua County','CHA',1208),(4849,'Chiayi County','CYQ',1208),(4850,'Hsinchu County','HSQ',1208),(4851,'Hualien County','HUA',1208),(4852,'Ilan County','ILA',1208),(4853,'Kaohsiung County','KHQ',1208),(4854,'Miaoli County','MIA',1208),(4855,'Nantou County','NAN',1208),(4856,'Penghu County','PEN',1208),(4857,'Pingtung County','PIF',1208),(4858,'Taichung County','TXQ',1208),(4859,'Tainan County','TNQ',1208),(4860,'Taipei County','TPQ',1208),(4861,'Taitung County','TTT',1208),(4862,'Taoyuan County','TAO',1208),(4863,'Yunlin Conuty','YUN',1208),(4864,'Keelung City','KEE',1208),(4865,'Arusha','01',1210),(4866,'Dar-es-Salaam','02',1210),(4867,'Dodoma','03',1210),(4868,'Iringa','04',1210),(4869,'Kagera','05',1210),(4870,'Kaskazini Pemba','06',1210),(4871,'Kaskazini Unguja','07',1210),(4872,'Xigoma','08',1210),(4873,'Kilimanjaro','09',1210),(4874,'Rusini Pemba','10',1210),(4875,'Kusini Unguja','11',1210),(4876,'Lindi','12',1210),(4877,'Manyara','26',1210),(4878,'Mara','13',1210),(4879,'Mbeya','14',1210),(4880,'Mjini Magharibi','15',1210),(4881,'Morogoro','16',1210),(4882,'Mtwara','17',1210),(4883,'Pwani','19',1210),(4884,'Rukwa','20',1210),(4885,'Ruvuma','21',1210),(4886,'Shinyanga','22',1210),(4887,'Singida','23',1210),(4888,'Tabora','24',1210),(4889,'Tanga','25',1210),(4890,'Cherkas\'ka Oblast\'','71',1224),(4891,'Chernihivs\'ka Oblast\'','74',1224),(4892,'Chernivets\'ka Oblast\'','77',1224),(4893,'Dnipropetrovs\'ka Oblast\'','12',1224),(4894,'Donets\'ka Oblast\'','14',1224),(4895,'Ivano-Frankivs\'ka Oblast\'','26',1224),(4896,'Kharkivs\'ka Oblast\'','63',1224),(4897,'Khersons\'ka Oblast\'','65',1224),(4898,'Khmel\'nyts\'ka Oblast\'','68',1224),(4899,'Kirovohrads\'ka Oblast\'','35',1224),(4900,'Kyivs\'ka Oblast\'','32',1224),(4901,'Luhans\'ka Oblast\'','09',1224),(4902,'L\'vivs\'ka Oblast\'','46',1224),(4903,'Mykolaivs\'ka Oblast\'','48',1224),(4904,'Odes \'ka Oblast\'','51',1224),(4905,'Poltavs\'ka Oblast\'','53',1224),(4906,'Rivnens\'ka Oblast\'','56',1224),(4907,'Sums \'ka Oblast\'','59',1224),(4908,'Ternopil\'s\'ka Oblast\'','61',1224),(4909,'Vinnyts\'ka Oblast\'','05',1224),(4910,'Volyos\'ka Oblast\'','07',1224),(4911,'Zakarpats\'ka Oblast\'','21',1224),(4912,'Zaporiz\'ka Oblast\'','23',1224),(4913,'Zhytomyrs\'ka Oblast\'','18',1224),(4914,'Respublika Krym','43',1224),(4915,'Kyiv','30',1224),(4916,'Sevastopol','40',1224),(4917,'Adjumani','301',1223),(4918,'Apac','302',1223),(4919,'Arua','303',1223),(4920,'Bugiri','201',1223),(4921,'Bundibugyo','401',1223),(4922,'Bushenyi','402',1223),(4923,'Busia','202',1223),(4924,'Gulu','304',1223),(4925,'Hoima','403',1223),(4926,'Iganga','203',1223),(4927,'Jinja','204',1223),(4928,'Kabale','404',1223),(4929,'Kabarole','405',1223),(4930,'Kaberamaido','213',1223),(4931,'Kalangala','101',1223),(4932,'Kampala','102',1223),(4933,'Kamuli','205',1223),(4934,'Kamwenge','413',1223),(4935,'Kanungu','414',1223),(4936,'Kapchorwa','206',1223),(4937,'Kasese','406',1223),(4938,'Katakwi','207',1223),(4939,'Kayunga','112',1223),(4940,'Kibaale','407',1223),(4941,'Kiboga','103',1223),(4942,'Kisoro','408',1223),(4943,'Kitgum','305',1223),(4944,'Kotido','306',1223),(4945,'Kumi','208',1223),(4946,'Kyenjojo','415',1223),(4947,'Lira','307',1223),(4948,'Luwero','104',1223),(4949,'Masaka','105',1223),(4950,'Masindi','409',1223),(4951,'Mayuge','214',1223),(4952,'Mbale','209',1223),(4953,'Mbarara','410',1223),(4954,'Moroto','308',1223),(4955,'Moyo','309',1223),(4956,'Mpigi','106',1223),(4957,'Mubende','107',1223),(4958,'Mukono','108',1223),(4959,'Nakapiripirit','311',1223),(4960,'Nakasongola','109',1223),(4961,'Nebbi','310',1223),(4962,'Ntungamo','411',1223),(4963,'Pader','312',1223),(4964,'Pallisa','210',1223),(4965,'Rakai','110',1223),(4966,'Rukungiri','412',1223),(4967,'Sembabule','111',1223),(4968,'Sironko','215',1223),(4969,'Soroti','211',1223),(4970,'Tororo','212',1223),(4971,'Wakiso','113',1223),(4972,'Yumbe','313',1223),(4973,'Baker Island','81',1227),(4974,'Howland Island','84',1227),(4975,'Jarvis Island','86',1227),(4976,'Johnston Atoll','67',1227),(4977,'Kingman Reef','89',1227),(4978,'Midway Islands','71',1227),(4979,'Navassa Island','76',1227),(4980,'Palmyra Atoll','95',1227),(4981,'Wake Island','79',1227),(4982,'Artigsa','AR',1229),(4983,'Canelones','CA',1229),(4984,'Cerro Largo','CL',1229),(4985,'Colonia','CO',1229),(4986,'Durazno','DU',1229),(4987,'Flores','FS',1229),(4988,'Lavalleja','LA',1229),(4989,'Maldonado','MA',1229),(4990,'Montevideo','MO',1229),(4991,'Paysandu','PA',1229),(4992,'Rivera','RV',1229),(4993,'Rocha','RO',1229),(4994,'Salto','SA',1229),(4995,'Soriano','SO',1229),(4996,'Tacuarembo','TA',1229),(4997,'Treinta y Tres','TT',1229),(4998,'Toshkent (city)','TK',1230),(4999,'Qoraqalpogiston Respublikasi','QR',1230),(5000,'Andijon','AN',1230),(5001,'Buxoro','BU',1230),(5002,'Farg\'ona','FA',1230),(5003,'Jizzax','JI',1230),(5004,'Khorazm','KH',1230),(5005,'Namangan','NG',1230),(5006,'Navoiy','NW',1230),(5007,'Qashqadaryo','QA',1230),(5008,'Samarqand','SA',1230),(5009,'Sirdaryo','SI',1230),(5010,'Surxondaryo','SU',1230),(5011,'Toshkent','TO',1230),(5012,'Xorazm','XO',1230),(5013,'Distrito Federal','A',1232),(5014,'Anzoategui','B',1232),(5015,'Apure','C',1232),(5016,'Aragua','D',1232),(5017,'Barinas','E',1232),(5018,'Carabobo','G',1232),(5019,'Cojedes','H',1232),(5020,'Falcon','I',1232),(5021,'Guarico','J',1232),(5022,'Lara','K',1232),(5023,'Merida','L',1232),(5024,'Miranda','M',1232),(5025,'Monagas','N',1232),(5026,'Nueva Esparta','O',1232),(5027,'Portuguesa','P',1232),(5028,'Tachira','S',1232),(5029,'Trujillo','T',1232),(5030,'Vargas','X',1232),(5031,'Yaracuy','U',1232),(5032,'Zulia','V',1232),(5033,'Delta Amacuro','Y',1232),(5034,'Dependencias Federales','W',1232),(5035,'An Giang','44',1233),(5036,'Ba Ria - Vung Tau','43',1233),(5037,'Bac Can','53',1233),(5038,'Bac Giang','54',1233),(5039,'Bac Lieu','55',1233),(5040,'Bac Ninh','56',1233),(5041,'Ben Tre','50',1233),(5042,'Binh Dinh','31',1233),(5043,'Binh Duong','57',1233),(5044,'Binh Phuoc','58',1233),(5045,'Binh Thuan','40',1233),(5046,'Ca Mau','59',1233),(5047,'Can Tho','48',1233),(5048,'Cao Bang','04',1233),(5049,'Da Nang, thanh pho','60',1233),(5050,'Dong Nai','39',1233),(5051,'Dong Thap','45',1233),(5052,'Gia Lai','30',1233),(5053,'Ha Giang','03',1233),(5054,'Ha Nam','63',1233),(5055,'Ha Noi, thu do','64',1233),(5056,'Ha Tay','15',1233),(5057,'Ha Tinh','23',1233),(5058,'Hai Duong','61',1233),(5059,'Hai Phong, thanh pho','62',1233),(5060,'Hoa Binh','14',1233),(5061,'Ho Chi Minh, thanh pho [Sai Gon]','65',1233),(5062,'Hung Yen','66',1233),(5063,'Khanh Hoa','34',1233),(5064,'Kien Giang','47',1233),(5065,'Kon Tum','28',1233),(5066,'Lai Chau','01',1233),(5067,'Lam Dong','35',1233),(5068,'Lang Son','09',1233),(5069,'Lao Cai','02',1233),(5070,'Long An','41',1233),(5071,'Nam Dinh','67',1233),(5072,'Nghe An','22',1233),(5073,'Ninh Binh','18',1233),(5074,'Ninh Thuan','36',1233),(5075,'Phu Tho','68',1233),(5076,'Phu Yen','32',1233),(5077,'Quang Binh','24',1233),(5078,'Quang Nam','27',1233),(5079,'Quang Ngai','29',1233),(5080,'Quang Ninh','13',1233),(5081,'Quang Tri','25',1233),(5082,'Soc Trang','52',1233),(5083,'Son La','05',1233),(5084,'Tay Ninh','37',1233),(5085,'Thai Binh','20',1233),(5086,'Thai Nguyen','69',1233),(5087,'Thanh Hoa','21',1233),(5088,'Thua Thien-Hue','26',1233),(5089,'Tien Giang','46',1233),(5090,'Tra Vinh','51',1233),(5091,'Tuyen Quang','07',1233),(5092,'Vinh Long','49',1233),(5093,'Vinh Phuc','70',1233),(5094,'Yen Bai','06',1233),(5095,'Malampa','MAP',1231),(5096,'Penama','PAM',1231),(5097,'Sanma','SAM',1231),(5098,'Shefa','SEE',1231),(5099,'Tafea','TAE',1231),(5100,'Torba','TOB',1231),(5101,'A\'ana','AA',1185),(5102,'Aiga-i-le-Tai','AL',1185),(5103,'Atua','AT',1185),(5104,'Fa\'aaaleleaga','FA',1185),(5105,'Gaga\'emauga','GE',1185),(5106,'Gagaifomauga','GI',1185),(5107,'Palauli','PA',1185),(5108,'Satupa\'itea','SA',1185),(5109,'Tuamasaga','TU',1185),(5110,'Va\'a-o-Fonoti','VF',1185),(5111,'Vaisigano','VS',1185),(5112,'Crna Gora','CG',1243),(5113,'Srbija','SR',1242),(5114,'Kosovo-Metohija','KM',1242),(5115,'Vojvodina','VO',1242),(5116,'Abyan','AB',1237),(5117,'Adan','AD',1237),(5118,'Ad Dali','DA',1237),(5119,'Al Bayda\'','BA',1237),(5120,'Al Hudaydah','MU',1237),(5121,'Al Mahrah','MR',1237),(5122,'Al Mahwit','MW',1237),(5123,'Amran','AM',1237),(5124,'Dhamar','DH',1237),(5125,'Hadramawt','HD',1237),(5126,'Hajjah','HJ',1237),(5127,'Ibb','IB',1237),(5128,'Lahij','LA',1237),(5129,'Ma\'rib','MA',1237),(5130,'Sa\'dah','SD',1237),(5131,'San\'a\'','SN',1237),(5132,'Shabwah','SH',1237),(5133,'Ta\'izz','TA',1237),(5134,'Eastern Cape','EC',1196),(5135,'Free State','FS',1196),(5136,'Gauteng','GT',1196),(5137,'Kwazulu-Natal','NL',1196),(5138,'Mpumalanga','MP',1196),(5139,'Northern Cape','NC',1196),(5140,'Limpopo','NP',1196),(5141,'Western Cape','WC',1196),(5142,'Copperbelt','08',1239),(5143,'Luapula','04',1239),(5144,'Lusaka','09',1239),(5145,'North-Western','06',1239),(5146,'Bulawayo','BU',1240),(5147,'Harare','HA',1240),(5148,'Manicaland','MA',1240),(5149,'Mashonaland Central','MC',1240),(5150,'Mashonaland East','ME',1240),(5151,'Mashonaland West','MW',1240),(5152,'Masvingo','MV',1240),(5153,'Matabeleland North','MN',1240),(5154,'Matabeleland South','MS',1240),(5155,'Midlands','MI',1240),(5156,'South Karelia','SK',1075),(5157,'South Ostrobothnia','SO',1075),(5158,'Etelä-Savo','ES',1075),(5159,'Häme','HH',1075),(5160,'Itä-Uusimaa','IU',1075),(5161,'Kainuu','KA',1075),(5162,'Central Ostrobothnia','CO',1075),(5163,'Central Finland','CF',1075),(5164,'Kymenlaakso','KY',1075),(5165,'Lapland','LA',1075),(5166,'Tampere Region','TR',1075),(5167,'Ostrobothnia','OB',1075),(5168,'North Karelia','NK',1075),(5169,'Northern Ostrobothnia','NO',1075),(5170,'Northern Savo','NS',1075),(5171,'Päijät-Häme','PH',1075),(5172,'Satakunta','SK',1075),(5173,'Uusimaa','UM',1075),(5174,'South-West Finland','SW',1075),(5175,'Åland','AL',1075),(5176,'Limburg','LI',1152),(5177,'Central and Western','CW',1098),(5178,'Eastern','EA',1098),(5179,'Southern','SO',1098),(5180,'Wan Chai','WC',1098),(5181,'Kowloon City','KC',1098),(5182,'Kwun Tong','KU',1098),(5183,'Sham Shui Po','SS',1098),(5184,'Wong Tai Sin','WT',1098),(5185,'Yau Tsim Mong','YT',1098),(5186,'Islands','IS',1098),(5187,'Kwai Tsing','KI',1098),(5188,'North','NO',1098),(5189,'Sai Kung','SK',1098),(5190,'Sha Tin','ST',1098),(5191,'Tai Po','TP',1098),(5192,'Tsuen Wan','TW',1098),(5193,'Tuen Mun','TM',1098),(5194,'Yuen Long','YL',1098),(5195,'Manchester','MR',1108),(5196,'Al Manāmah (Al ‘Āşimah)','13',1016),(5197,'Al Janūbīyah','14',1016),(5199,'Al Wusţá','16',1016),(5200,'Ash Shamālīyah','17',1016),(5201,'Jenin','_A',1165),(5202,'Tubas','_B',1165),(5203,'Tulkarm','_C',1165),(5204,'Nablus','_D',1165),(5205,'Qalqilya','_E',1165),(5206,'Salfit','_F',1165),(5207,'Ramallah and Al-Bireh','_G',1165),(5208,'Jericho','_H',1165),(5209,'Jerusalem','_I',1165),(5210,'Bethlehem','_J',1165),(5211,'Hebron','_K',1165),(5212,'North Gaza','_L',1165),(5213,'Gaza','_M',1165),(5214,'Deir el-Balah','_N',1165),(5215,'Khan Yunis','_O',1165),(5216,'Rafah','_P',1165),(5217,'Brussels','BRU',1020),(5218,'Distrito Federal','DIF',1140),(5219,'Taichung City','TXG',1208),(5220,'Kaohsiung City','KHH',1208),(5221,'Taipei City','TPE',1208),(5222,'Chiayi City','CYI',1208),(5223,'Hsinchu City','HSZ',1208),(5224,'Tainan City','TNN',1208),(9000,'North West','NW',1196),(9986,'Tyne and Wear','TWR',1226),(9988,'Greater Manchester','GTM',1226),(9989,'Co Tyrone','TYR',1226),(9990,'West Yorkshire','WYK',1226),(9991,'South Yorkshire','SYK',1226),(9992,'Merseyside','MSY',1226),(9993,'Berkshire','BRK',1226),(9994,'West Midlands','WMD',1226),(9998,'West Glamorgan','WGM',1226),(9999,'London','LON',1226),(10000,'Carbonia-Iglesias','CI',1107),(10001,'Olbia-Tempio','OT',1107),(10002,'Medio Campidano','VS',1107),(10003,'Ogliastra','OG',1107),(10009,'Jura','39',1076),(10010,'Barletta-Andria-Trani','Bar',1107),(10011,'Fermo','Fer',1107),(10012,'Monza e Brianza','Mon',1107),(10013,'Clwyd','CWD',1226),(10014,'Dyfed','DFD',1226),(10015,'South Glamorgan','SGM',1226),(10016,'Artibonite','AR',1094),(10017,'Centre','CE',1094),(10018,'Nippes','NI',1094),(10019,'Nord','ND',1094),(10020,'La Rioja','F',1010),(10021,'Andorra la Vella','07',1005),(10022,'Canillo','02',1005),(10023,'Encamp','03',1005),(10024,'Escaldes-Engordany','08',1005),(10025,'La Massana','04',1005),(10026,'Ordino','05',1005),(10027,'Sant Julia de Loria','06',1005),(10028,'Abaco Islands','AB',1212),(10029,'Andros Island','AN',1212),(10030,'Berry Islands','BR',1212),(10031,'Eleuthera','EL',1212),(10032,'Grand Bahama','GB',1212),(10033,'Rum Cay','RC',1212),(10034,'San Salvador Island','SS',1212),(10035,'Kongo central','01',1050),(10036,'Kwango','02',1050),(10037,'Kwilu','03',1050),(10038,'Mai-Ndombe','04',1050),(10039,'Kasai','05',1050),(10040,'Lulua','06',1050),(10041,'Lomami','07',1050),(10042,'Sankuru','08',1050),(10043,'Ituri','09',1050),(10044,'Haut-Uele','10',1050),(10045,'Tshopo','11',1050),(10046,'Bas-Uele','12',1050),(10047,'Nord-Ubangi','13',1050),(10048,'Mongala','14',1050),(10049,'Sud-Ubangi','15',1050),(10050,'Tshuapa','16',1050),(10051,'Haut-Lomami','17',1050),(10052,'Lualaba','18',1050),(10053,'Haut-Katanga','19',1050),(10054,'Tanganyika','20',1050),(10055,'Toledo','TO',1198),(10056,'Córdoba','CO',1198),(10057,'Metropolitan Manila','MNL',1170),(10058,'La Paz','LP',1097),(10059,'Yinchuan','YN',1045),(10060,'Shizuishan','SZ',1045),(10061,'Wuzhong','WZ',1045),(10062,'Guyuan','GY',1045),(10063,'Zhongwei','ZW',1045),(10064,'Luxembourg','L',1126),(10065,'Aizkraukles novads','002',1119),(10066,'Jaunjelgavas novads','038',1119),(10067,'Pļaviņu novads','072',1119),(10068,'Kokneses novads','046',1119),(10069,'Neretas novads','065',1119),(10070,'Skrīveru novads','092',1119),(10071,'Alūksnes novads','007',1119),(10072,'Apes novads','009',1119),(10073,'Balvu novads','015',1119),(10074,'Viļakas novads','108',1119),(10075,'Baltinavas novads','014',1119),(10076,'Rugāju novads','082',1119),(10077,'Bauskas novads','016',1119),(10078,'Iecavas novads','034',1119),(10079,'Rundāles novads','083',1119),(10080,'Vecumnieku novads','105',1119),(10081,'Cēsu novads','022',1119),(10082,'Līgatnes novads','055',1119),(10083,'Amatas novads','008',1119),(10084,'Jaunpiebalgas novads','039',1119),(10085,'Priekuļu novads','075',1119),(10086,'Pārgaujas novads','070',1119),(10087,'Raunas novads','076',1119),(10088,'Vecpiebalgas novads','104',1119),(10089,'Daugavpils novads','025',1119),(10090,'Ilūkstes novads','036',1119),(10091,'Dobeles novads','026',1119),(10092,'Auces novads','010',1119),(10093,'Tērvetes novads','098',1119),(10094,'Gulbenes novads','033',1119),(10095,'Jelgavas novads','041',1119),(10096,'Ozolnieku novads','069',1119),(10097,'Jēkabpils novads','042',1119),(10098,'Aknīstes novads','004',1119),(10099,'Viesītes novads','107',1119),(10100,'Krustpils novads','049',1119),(10101,'Salas novads','085',1119),(10102,'Krāslavas novads','047',1119),(10103,'Dagdas novads','024',1119),(10104,'Aglonas novads','001',1119),(10105,'Kuldīgas novads','050',1119),(10106,'Skrundas novads','093',1119),(10107,'Alsungas novads','006',1119),(10108,'Aizputes novads','003',1119),(10109,'Durbes novads','028',1119),(10110,'Grobiņas novads','032',1119),(10111,'Pāvilostas novads','071',1119),(10112,'Priekules novads','074',1119),(10113,'Nīcas novads','066',1119),(10114,'Rucavas novads','081',1119),(10115,'Vaiņodes novads','100',1119),(10116,'Limbažu novads','054',1119),(10117,'Alojas novads','005',1119),(10118,'Salacgrīvas novads','086',1119),(10119,'Ludzas novads','058',1119),(10120,'Kārsavas novads','044',1119),(10121,'Zilupes novads','110',1119),(10122,'Ciblas novads','023',1119),(10123,'Madonas novads','059',1119),(10124,'Cesvaines novads','021',1119),(10125,'Lubānas novads','057',1119),(10126,'Varakļānu novads','102',1119),(10127,'Ērgļu novads','030',1119),(10128,'Ogres novads','067',1119),(10129,'Ikšķiles novads','035',1119),(10130,'Ķeguma novads','051',1119),(10131,'Lielvārdes novads','053',1119),(10132,'Preiļu novads','073',1119),(10133,'Līvānu novads','056',1119),(10134,'Riebiņu novads','078',1119),(10135,'Vārkavas novads','103',1119),(10136,'Rēzeknes novads','077',1119),(10137,'Viļānu novads','109',1119),(10138,'Baldones novads','013',1119),(10139,'Ķekavas novads','052',1119),(10140,'Olaines novads','068',1119),(10141,'Salaspils novads','087',1119),(10142,'Saulkrastu novads','089',1119),(10143,'Siguldas novads','091',1119),(10144,'Inčukalna novads','037',1119),(10145,'Ādažu novads','011',1119),(10146,'Babītes novads','012',1119),(10147,'Carnikavas novads','020',1119),(10148,'Garkalnes novads','031',1119),(10149,'Krimuldas novads','048',1119),(10150,'Mālpils novads','061',1119),(10151,'Mārupes novads','062',1119),(10152,'Ropažu novads','080',1119),(10153,'Sējas novads','090',1119),(10154,'Stopiņu novads','095',1119),(10155,'Saldus novads','088',1119),(10156,'Brocēnu novads','018',1119),(10157,'Talsu novads','097',1119),(10158,'Dundagas novads','027',1119),(10159,'Mērsraga novads','063',1119),(10160,'Rojas novads','079',1119),(10161,'Tukuma novads','099',1119),(10162,'Kandavas novads','043',1119),(10163,'Engures novads','029',1119),(10164,'Jaunpils novads','040',1119),(10165,'Valkas novads','101',1119),(10166,'Smiltenes novads','094',1119),(10167,'Strenču novads','096',1119),(10168,'Kocēnu novads','045',1119),(10169,'Mazsalacas novads','060',1119),(10170,'Rūjienas novads','084',1119),(10171,'Beverīnas novads','017',1119),(10172,'Burtnieku novads','019',1119),(10173,'Naukšēnu novads','064',1119),(10174,'Ventspils novads','106',1119),(10175,'Jēkabpils','JKB',1119),(10176,'Valmiera','VMR',1119),(10177,'Florida','FL',1229),(10178,'Rio Negro','RN',1229),(10179,'San Jose','SJ',1229),(10180,'Plateau','PL',1157),(10181,'Pieria','61',1085),(10182,'Los Rios','LR',1044),(10183,'Arica y Parinacota','AP',1044),(10184,'Amazonas','AMA',1169),(10185,'Kalimantan Tengah','KT',1102),(10186,'Sulawesi Barat','SR',1102),(10187,'Kalimantan Utara','KU',1102),(10188,'Ankaran','86',1193),(10189,'Apače','87',1193),(10190,'Cirkulane','88',1193),(10191,'Gorje','89',1193),(10192,'Kostanjevica na Krki','90',1193),(10193,'Log-Dragomer','91',1193),(10194,'Makole','92',1193),(10195,'Mirna','93',1193),(10196,'Mokronog-Trebelno','94',1193),(10197,'Odranci','95',1193),(10198,'Oplotnica','96',1193),(10199,'Ormož','97',1193),(10200,'Osilnica','98',1193),(10201,'Pesnica','99',1193),(10202,'Piran','100',1193),(10203,'Pivka','101',1193),(10204,'Podčetrtek','102',1193),(10205,'Podlehnik','103',1193),(10206,'Podvelka','104',1193),(10207,'Poljčane','105',1193),(10208,'Polzela','106',1193),(10209,'Postojna','107',1193),(10210,'Prebold','108',1193),(10211,'Preddvor','109',1193),(10212,'Prevalje','110',1193),(10213,'Ptuj','111',1193),(10214,'Puconci','112',1193),(10215,'Rače-Fram','113',1193),(10216,'Radeče','114',1193),(10217,'Radenci','115',1193),(10218,'Radlje ob Dravi','139',1193),(10219,'Radovljica','145',1193),(10220,'Ravne na Koroškem','171',1193),(10221,'Razkrižje','172',1193),(10222,'Rečica ob Savinji','173',1193),(10223,'Renče-Vogrsko','174',1193),(10224,'Ribnica','175',1193),(10225,'Ribnica na Pohorju','176',1193),(10226,'Rogaška Slatina','177',1193),(10227,'Rogašovci','178',1193),(10228,'Rogatec','179',1193),(10229,'Ruše','180',1193),(10230,'Selnica ob Dravi','195',1193),(10231,'Semič','196',1193),(10232,'Šentrupert','197',1193),(10233,'Sevnica','198',1193),(10234,'Sežana','199',1193),(10235,'Slovenj Gradec','200',1193),(10236,'Slovenska Bistrica','201',1193),(10237,'Slovenske Konjice','202',1193),(10238,'Šmarješke Toplice','203',1193),(10239,'Sodražica','204',1193),(10240,'Solčava','205',1193),(10241,'Središče ob Dravi','206',1193),(10242,'Starše','207',1193),(10243,'Straža','208',1193),(10244,'Sveta Trojica v Slovenskih goricah','209',1193),(10245,'Sveti Jurij v Slovenskih goricah','210',1193),(10246,'Sveti Tomaž','211',1193),(10247,'Vodice','212',1193),(10248,'Abkhazia','AB',1081),(10249,'Adjara','AJ',1081),(10250,'Tbilisi','TB',1081),(10251,'Guria','GU',1081),(10252,'Imereti','IM',1081),(10253,'Kakheti','KA',1081),(10254,'Kvemo Kartli','KK',1081),(10255,'Mtskheta-Mtianeti','MM',1081),(10256,'Racha-Lechkhumi and Kvemo Svaneti','RL',1081),(10257,'Samegrelo-Zemo Svaneti','SZ',1081),(10258,'Samtskhe-Javakheti','SJ',1081),(10259,'Shida Kartli','SK',1081),(10260,'Central','C',1074),(10261,'Punjab','PB',1163),(10262,'La Libertad','LI',1066),(10263,'La Paz','PA',1066),(10264,'La Union','UN',1066),(10265,'Littoral','LT',1038),(10266,'Nord-Ouest','NW',1038),(10267,'Telangana','TG',1101),(10268,'Ash Sharqiyah','04',1187),(10269,'Guadeloupe','GP',1076),(10270,'Martinique','MQ',1076),(10271,'Guyane','GF',1076),(10272,'La Réunion','RE',1076),(10273,'Mayotte','YT',1076);
+INSERT INTO `civicrm_state_province` (`id`, `name`, `abbreviation`, `country_id`) VALUES (1000,'Alabama','AL',1228),(1001,'Alaska','AK',1228),(1002,'Arizona','AZ',1228),(1003,'Arkansas','AR',1228),(1004,'California','CA',1228),(1005,'Colorado','CO',1228),(1006,'Connecticut','CT',1228),(1007,'Delaware','DE',1228),(1008,'Florida','FL',1228),(1009,'Georgia','GA',1228),(1010,'Hawaii','HI',1228),(1011,'Idaho','ID',1228),(1012,'Illinois','IL',1228),(1013,'Indiana','IN',1228),(1014,'Iowa','IA',1228),(1015,'Kansas','KS',1228),(1016,'Kentucky','KY',1228),(1017,'Louisiana','LA',1228),(1018,'Maine','ME',1228),(1019,'Maryland','MD',1228),(1020,'Massachusetts','MA',1228),(1021,'Michigan','MI',1228),(1022,'Minnesota','MN',1228),(1023,'Mississippi','MS',1228),(1024,'Missouri','MO',1228),(1025,'Montana','MT',1228),(1026,'Nebraska','NE',1228),(1027,'Nevada','NV',1228),(1028,'New Hampshire','NH',1228),(1029,'New Jersey','NJ',1228),(1030,'New Mexico','NM',1228),(1031,'New York','NY',1228),(1032,'North Carolina','NC',1228),(1033,'North Dakota','ND',1228),(1034,'Ohio','OH',1228),(1035,'Oklahoma','OK',1228),(1036,'Oregon','OR',1228),(1037,'Pennsylvania','PA',1228),(1038,'Rhode Island','RI',1228),(1039,'South Carolina','SC',1228),(1040,'South Dakota','SD',1228),(1041,'Tennessee','TN',1228),(1042,'Texas','TX',1228),(1043,'Utah','UT',1228),(1044,'Vermont','VT',1228),(1045,'Virginia','VA',1228),(1046,'Washington','WA',1228),(1047,'West Virginia','WV',1228),(1048,'Wisconsin','WI',1228),(1049,'Wyoming','WY',1228),(1050,'District of Columbia','DC',1228),(1052,'American Samoa','AS',1228),(1053,'Guam','GU',1228),(1055,'Northern Mariana Islands','MP',1228),(1056,'Puerto Rico','PR',1228),(1057,'Virgin Islands','VI',1228),(1058,'United States Minor Outlying Islands','UM',1228),(1059,'Armed Forces Europe','AE',1228),(1060,'Armed Forces Americas','AA',1228),(1061,'Armed Forces Pacific','AP',1228),(1100,'Alberta','AB',1039),(1101,'British Columbia','BC',1039),(1102,'Manitoba','MB',1039),(1103,'New Brunswick','NB',1039),(1104,'Newfoundland and Labrador','NL',1039),(1105,'Northwest Territories','NT',1039),(1106,'Nova Scotia','NS',1039),(1107,'Nunavut','NU',1039),(1108,'Ontario','ON',1039),(1109,'Prince Edward Island','PE',1039),(1110,'Quebec','QC',1039),(1111,'Saskatchewan','SK',1039),(1112,'Yukon Territory','YT',1039),(1200,'Maharashtra','MM',1101),(1201,'Karnataka','KA',1101),(1202,'Andhra Pradesh','AP',1101),(1203,'Arunachal Pradesh','AR',1101),(1204,'Assam','AS',1101),(1205,'Bihar','BR',1101),(1206,'Chhattisgarh','CH',1101),(1207,'Goa','GA',1101),(1208,'Gujarat','GJ',1101),(1209,'Haryana','HR',1101),(1210,'Himachal Pradesh','HP',1101),(1211,'Jammu and Kashmir','JK',1101),(1212,'Jharkhand','JH',1101),(1213,'Kerala','KL',1101),(1214,'Madhya Pradesh','MP',1101),(1215,'Manipur','MN',1101),(1216,'Meghalaya','ML',1101),(1217,'Mizoram','MZ',1101),(1218,'Nagaland','NL',1101),(1219,'Orissa','OR',1101),(1220,'Punjab','PB',1101),(1221,'Rajasthan','RJ',1101),(1222,'Sikkim','SK',1101),(1223,'Tamil Nadu','TN',1101),(1224,'Tripura','TR',1101),(1225,'Uttaranchal','UL',1101),(1226,'Uttar Pradesh','UP',1101),(1227,'West Bengal','WB',1101),(1228,'Andaman and Nicobar Islands','AN',1101),(1229,'Dadra and Nagar Haveli','DN',1101),(1230,'Daman and Diu','DD',1101),(1231,'Delhi','DL',1101),(1232,'Lakshadweep','LD',1101),(1233,'Pondicherry','PY',1101),(1300,'mazowieckie','MZ',1172),(1301,'pomorskie','PM',1172),(1302,'dolnośląskie','DS',1172),(1303,'kujawsko-pomorskie','KP',1172),(1304,'lubelskie','LU',1172),(1305,'lubuskie','LB',1172),(1306,'łódzkie','LD',1172),(1307,'małopolskie','MA',1172),(1308,'opolskie','OP',1172),(1309,'podkarpackie','PK',1172),(1310,'podlaskie','PD',1172),(1311,'śląskie','SL',1172),(1312,'świętokrzyskie','SK',1172),(1313,'warmińsko-mazurskie','WN',1172),(1314,'wielkopolskie','WP',1172),(1315,'zachodniopomorskie','ZP',1172),(1500,'Abu Zaby','AZ',1225),(1501,'\'Ajman','AJ',1225),(1502,'Al Fujayrah','FU',1225),(1503,'Ash Shariqah','SH',1225),(1504,'Dubayy','DU',1225),(1505,'Ra\'s al Khaymah','RK',1225),(1506,'Dac Lac','33',1233),(1507,'Umm al Qaywayn','UQ',1225),(1508,'Badakhshan','BDS',1001),(1509,'Badghis','BDG',1001),(1510,'Baghlan','BGL',1001),(1511,'Balkh','BAL',1001),(1512,'Bamian','BAM',1001),(1513,'Farah','FRA',1001),(1514,'Faryab','FYB',1001),(1515,'Ghazni','GHA',1001),(1516,'Ghowr','GHO',1001),(1517,'Helmand','HEL',1001),(1518,'Herat','HER',1001),(1519,'Jowzjan','JOW',1001),(1520,'Kabul','KAB',1001),(1521,'Kandahar','KAN',1001),(1522,'Kapisa','KAP',1001),(1523,'Khowst','KHO',1001),(1524,'Konar','KNR',1001),(1525,'Kondoz','KDZ',1001),(1526,'Laghman','LAG',1001),(1527,'Lowgar','LOW',1001),(1528,'Nangrahar','NAN',1001),(1529,'Nimruz','NIM',1001),(1530,'Nurestan','NUR',1001),(1531,'Oruzgan','ORU',1001),(1532,'Paktia','PIA',1001),(1533,'Paktika','PKA',1001),(1534,'Parwan','PAR',1001),(1535,'Samangan','SAM',1001),(1536,'Sar-e Pol','SAR',1001),(1537,'Takhar','TAK',1001),(1538,'Wardak','WAR',1001),(1539,'Zabol','ZAB',1001),(1540,'Berat','BR',1002),(1541,'Bulqizë','BU',1002),(1542,'Delvinë','DL',1002),(1543,'Devoll','DV',1002),(1544,'Dibër','DI',1002),(1545,'Durrës','DR',1002),(1546,'Elbasan','EL',1002),(1547,'Fier','FR',1002),(1548,'Gramsh','GR',1002),(1549,'Gjirokastër','GJ',1002),(1550,'Has','HA',1002),(1551,'Kavajë','KA',1002),(1552,'Kolonjë','ER',1002),(1553,'Korçë','KO',1002),(1554,'Krujë','KR',1002),(1555,'Kuçovë','KC',1002),(1556,'Kukës','KU',1002),(1557,'Kurbin','KB',1002),(1558,'Lezhë','LE',1002),(1559,'Librazhd','LB',1002),(1560,'Lushnjë','LU',1002),(1561,'Malësi e Madhe','MM',1002),(1562,'Mallakastër','MK',1002),(1563,'Mat','MT',1002),(1564,'Mirditë','MR',1002),(1565,'Peqin','PQ',1002),(1566,'Përmet','PR',1002),(1567,'Pogradec','PG',1002),(1568,'Pukë','PU',1002),(1569,'Sarandë','SR',1002),(1570,'Skrapar','SK',1002),(1571,'Shkodër','SH',1002),(1572,'Tepelenë','TE',1002),(1573,'Tiranë','TR',1002),(1574,'Tropojë','TP',1002),(1575,'Vlorë','VL',1002),(1576,'Erevan','ER',1011),(1577,'Aragacotn','AG',1011),(1578,'Ararat','AR',1011),(1579,'Armavir','AV',1011),(1580,'Gegarkunik\'','GR',1011),(1581,'Kotayk\'','KT',1011),(1582,'Lory','LO',1011),(1583,'Sirak','SH',1011),(1584,'Syunik\'','SU',1011),(1585,'Tavus','TV',1011),(1586,'Vayoc Jor','VD',1011),(1587,'Bengo','BGO',1006),(1588,'Benguela','BGU',1006),(1589,'Bie','BIE',1006),(1590,'Cabinda','CAB',1006),(1591,'Cuando-Cubango','CCU',1006),(1592,'Cuanza Norte','CNO',1006),(1593,'Cuanza Sul','CUS',1006),(1594,'Cunene','CNN',1006),(1595,'Huambo','HUA',1006),(1596,'Huila','HUI',1006),(1597,'Luanda','LUA',1006),(1598,'Lunda Norte','LNO',1006),(1599,'Lunda Sul','LSU',1006),(1600,'Malange','MAL',1006),(1601,'Moxico','MOX',1006),(1602,'Namibe','NAM',1006),(1603,'Uige','UIG',1006),(1604,'Zaire','ZAI',1006),(1605,'Capital federal','C',1010),(1606,'Buenos Aires','B',1010),(1607,'Catamarca','K',1010),(1608,'Cordoba','X',1010),(1609,'Corrientes','W',1010),(1610,'Chaco','H',1010),(1611,'Chubut','U',1010),(1612,'Entre Rios','E',1010),(1613,'Formosa','P',1010),(1614,'Jujuy','Y',1010),(1615,'La Pampa','L',1010),(1616,'Mendoza','M',1010),(1617,'Misiones','N',1010),(1618,'Neuquen','Q',1010),(1619,'Rio Negro','R',1010),(1620,'Salta','A',1010),(1621,'San Juan','J',1010),(1622,'San Luis','D',1010),(1623,'Santa Cruz','Z',1010),(1624,'Santa Fe','S',1010),(1625,'Santiago del Estero','G',1010),(1626,'Tierra del Fuego','V',1010),(1627,'Tucuman','T',1010),(1628,'Burgenland','1',1014),(1629,'Kärnten','2',1014),(1630,'Niederosterreich','3',1014),(1631,'Oberosterreich','4',1014),(1632,'Salzburg','5',1014),(1633,'Steiermark','6',1014),(1634,'Tirol','7',1014),(1635,'Vorarlberg','8',1014),(1636,'Wien','9',1014),(1637,'Australian Antarctic Territory','AAT',1008),(1638,'Australian Capital Territory','ACT',1013),(1639,'Northern Territory','NT',1013),(1640,'New South Wales','NSW',1013),(1641,'Queensland','QLD',1013),(1642,'South Australia','SA',1013),(1643,'Tasmania','TAS',1013),(1644,'Victoria','VIC',1013),(1645,'Western Australia','WA',1013),(1646,'Naxcivan','NX',1015),(1647,'Ali Bayramli','AB',1015),(1648,'Baki','BA',1015),(1649,'Ganca','GA',1015),(1650,'Lankaran','LA',1015),(1651,'Mingacevir','MI',1015),(1652,'Naftalan','NA',1015),(1653,'Saki','SA',1015),(1654,'Sumqayit','SM',1015),(1655,'Susa','SS',1015),(1656,'Xankandi','XA',1015),(1657,'Yevlax','YE',1015),(1658,'Abseron','ABS',1015),(1659,'Agcabadi','AGC',1015),(1660,'Agdam','AGM',1015),(1661,'Agdas','AGS',1015),(1662,'Agstafa','AGA',1015),(1663,'Agsu','AGU',1015),(1664,'Astara','AST',1015),(1665,'Babak','BAB',1015),(1666,'Balakan','BAL',1015),(1667,'Barda','BAR',1015),(1668,'Beylagan','BEY',1015),(1669,'Bilasuvar','BIL',1015),(1670,'Cabrayll','CAB',1015),(1671,'Calilabad','CAL',1015),(1672,'Culfa','CUL',1015),(1673,'Daskasan','DAS',1015),(1674,'Davaci','DAV',1015),(1675,'Fuzuli','FUZ',1015),(1676,'Gadabay','GAD',1015),(1677,'Goranboy','GOR',1015),(1678,'Goycay','GOY',1015),(1679,'Haciqabul','HAC',1015),(1680,'Imisli','IMI',1015),(1681,'Ismayilli','ISM',1015),(1682,'Kalbacar','KAL',1015),(1683,'Kurdamir','KUR',1015),(1684,'Lacin','LAC',1015),(1685,'Lerik','LER',1015),(1686,'Masalli','MAS',1015),(1687,'Neftcala','NEF',1015),(1688,'Oguz','OGU',1015),(1689,'Ordubad','ORD',1015),(1690,'Qabala','QAB',1015),(1691,'Qax','QAX',1015),(1692,'Qazax','QAZ',1015),(1693,'Qobustan','QOB',1015),(1694,'Quba','QBA',1015),(1695,'Qubadli','QBI',1015),(1696,'Qusar','QUS',1015),(1697,'Saatli','SAT',1015),(1698,'Sabirabad','SAB',1015),(1699,'Sadarak','SAD',1015),(1700,'Sahbuz','SAH',1015),(1701,'Salyan','SAL',1015),(1702,'Samaxi','SMI',1015),(1703,'Samkir','SKR',1015),(1704,'Samux','SMX',1015),(1705,'Sarur','SAR',1015),(1706,'Siyazan','SIY',1015),(1707,'Tartar','TAR',1015),(1708,'Tovuz','TOV',1015),(1709,'Ucar','UCA',1015),(1710,'Xacmaz','XAC',1015),(1711,'Xanlar','XAN',1015),(1712,'Xizi','XIZ',1015),(1713,'Xocali','XCI',1015),(1714,'Xocavand','XVD',1015),(1715,'Yardimli','YAR',1015),(1716,'Zangilan','ZAN',1015),(1717,'Zaqatala','ZAQ',1015),(1718,'Zardab','ZAR',1015),(1719,'Federacija Bosna i Hercegovina','BIH',1026),(1720,'Republika Srpska','SRP',1026),(1721,'Bagerhat zila','05',1017),(1722,'Bandarban zila','01',1017),(1723,'Barguna zila','02',1017),(1724,'Barisal zila','06',1017),(1725,'Bhola zila','07',1017),(1726,'Bogra zila','03',1017),(1727,'Brahmanbaria zila','04',1017),(1728,'Chandpur zila','09',1017),(1729,'Chittagong zila','10',1017),(1730,'Chuadanga zila','12',1017),(1731,'Comilla zila','08',1017),(1732,'Cox\'s Bazar zila','11',1017),(1733,'Dhaka zila','13',1017),(1734,'Dinajpur zila','14',1017),(1735,'Faridpur zila','15',1017),(1736,'Feni zila','16',1017),(1737,'Gaibandha zila','19',1017),(1738,'Gazipur zila','18',1017),(1739,'Gopalganj zila','17',1017),(1740,'Habiganj zila','20',1017),(1741,'Jaipurhat zila','24',1017),(1742,'Jamalpur zila','21',1017),(1743,'Jessore zila','22',1017),(1744,'Jhalakati zila','25',1017),(1745,'Jhenaidah zila','23',1017),(1746,'Khagrachari zila','29',1017),(1747,'Khulna zila','27',1017),(1748,'Kishorganj zila','26',1017),(1749,'Kurigram zila','28',1017),(1750,'Kushtia zila','30',1017),(1751,'Lakshmipur zila','31',1017),(1752,'Lalmonirhat zila','32',1017),(1753,'Madaripur zila','36',1017),(1754,'Magura zila','37',1017),(1755,'Manikganj zila','33',1017),(1756,'Meherpur zila','39',1017),(1757,'Moulvibazar zila','38',1017),(1758,'Munshiganj zila','35',1017),(1759,'Mymensingh zila','34',1017),(1760,'Naogaon zila','48',1017),(1761,'Narail zila','43',1017),(1762,'Narayanganj zila','40',1017),(1763,'Narsingdi zila','42',1017),(1764,'Natore zila','44',1017),(1765,'Nawabganj zila','45',1017),(1766,'Netrakona zila','41',1017),(1767,'Nilphamari zila','46',1017),(1768,'Noakhali zila','47',1017),(1769,'Pabna zila','49',1017),(1770,'Panchagarh zila','52',1017),(1771,'Patuakhali zila','51',1017),(1772,'Pirojpur zila','50',1017),(1773,'Rajbari zila','53',1017),(1774,'Rajshahi zila','54',1017),(1775,'Rangamati zila','56',1017),(1776,'Rangpur zila','55',1017),(1777,'Satkhira zila','58',1017),(1778,'Shariatpur zila','62',1017),(1779,'Sherpur zila','57',1017),(1780,'Sirajganj zila','59',1017),(1781,'Sunamganj zila','61',1017),(1782,'Sylhet zila','60',1017),(1783,'Tangail zila','63',1017),(1784,'Thakurgaon zila','64',1017),(1785,'Antwerpen','VAN',1020),(1786,'Brabant Wallon','WBR',1020),(1787,'Hainaut','WHT',1020),(1788,'Liege','WLG',1020),(1789,'Limburg','VLI',1020),(1790,'Luxembourg','WLX',1020),(1791,'Namur','WNA',1020),(1792,'Oost-Vlaanderen','VOV',1020),(1793,'Vlaams-Brabant','VBR',1020),(1794,'West-Vlaanderen','VWV',1020),(1795,'Bale','BAL',1034),(1796,'Bam','BAM',1034),(1797,'Banwa','BAN',1034),(1798,'Bazega','BAZ',1034),(1799,'Bougouriba','BGR',1034),(1800,'Boulgou','BLG',1034),(1801,'Boulkiemde','BLK',1034),(1802,'Comoe','COM',1034),(1803,'Ganzourgou','GAN',1034),(1804,'Gnagna','GNA',1034),(1805,'Gourma','GOU',1034),(1806,'Houet','HOU',1034),(1807,'Ioba','IOB',1034),(1808,'Kadiogo','KAD',1034),(1809,'Kenedougou','KEN',1034),(1810,'Komondjari','KMD',1034),(1811,'Kompienga','KMP',1034),(1812,'Kossi','KOS',1034),(1813,'Koulpulogo','KOP',1034),(1814,'Kouritenga','KOT',1034),(1815,'Kourweogo','KOW',1034),(1816,'Leraba','LER',1034),(1817,'Loroum','LOR',1034),(1818,'Mouhoun','MOU',1034),(1819,'Nahouri','NAO',1034),(1820,'Namentenga','NAM',1034),(1821,'Nayala','NAY',1034),(1822,'Noumbiel','NOU',1034),(1823,'Oubritenga','OUB',1034),(1824,'Oudalan','OUD',1034),(1825,'Passore','PAS',1034),(1826,'Poni','PON',1034),(1827,'Sanguie','SNG',1034),(1828,'Sanmatenga','SMT',1034),(1829,'Seno','SEN',1034),(1830,'Siasili','SIS',1034),(1831,'Soum','SOM',1034),(1832,'Sourou','SOR',1034),(1833,'Tapoa','TAP',1034),(1834,'Tui','TUI',1034),(1835,'Yagha','YAG',1034),(1836,'Yatenga','YAT',1034),(1837,'Ziro','ZIR',1034),(1838,'Zondoma','ZON',1034),(1839,'Zoundweogo','ZOU',1034),(1840,'Blagoevgrad','01',1033),(1841,'Burgas','02',1033),(1842,'Dobrich','08',1033),(1843,'Gabrovo','07',1033),(1844,'Haskovo','26',1033),(1845,'Yambol','28',1033),(1846,'Kardzhali','09',1033),(1847,'Kyustendil','10',1033),(1848,'Lovech','11',1033),(1849,'Montana','12',1033),(1850,'Pazardzik','13',1033),(1851,'Pernik','14',1033),(1852,'Pleven','15',1033),(1853,'Plovdiv','16',1033),(1854,'Razgrad','17',1033),(1855,'Ruse','18',1033),(1856,'Silistra','19',1033),(1857,'Sliven','20',1033),(1858,'Smolyan','21',1033),(1859,'Sofia','23',1033),(1860,'Stara Zagora','24',1033),(1861,'Shumen','27',1033),(1862,'Targovishte','25',1033),(1863,'Varna','03',1033),(1864,'Veliko Tarnovo','04',1033),(1865,'Vidin','05',1033),(1866,'Vratsa','06',1033),(1867,'Al Hadd','01',1016),(1868,'Al Manamah','03',1016),(1869,'Al Mintaqah al Gharbiyah','10',1016),(1870,'Al Mintagah al Wusta','07',1016),(1871,'Al Mintaqah ash Shamaliyah','05',1016),(1872,'Al Muharraq','02',1016),(1873,'Ar Rifa','09',1016),(1874,'Jidd Hafs','04',1016),(1875,'Madluat Jamad','12',1016),(1876,'Madluat Isa','08',1016),(1877,'Mintaqat Juzur tawar','11',1016),(1878,'Sitrah','06',1016),(1879,'Bubanza','BB',1036),(1880,'Bujumbura','BJ',1036),(1881,'Bururi','BR',1036),(1882,'Cankuzo','CA',1036),(1883,'Cibitoke','CI',1036),(1884,'Gitega','GI',1036),(1885,'Karuzi','KR',1036),(1886,'Kayanza','KY',1036),(1887,'Makamba','MA',1036),(1888,'Muramvya','MU',1036),(1889,'Mwaro','MW',1036),(1890,'Ngozi','NG',1036),(1891,'Rutana','RT',1036),(1892,'Ruyigi','RY',1036),(1893,'Alibori','AL',1022),(1894,'Atakora','AK',1022),(1895,'Atlantique','AQ',1022),(1896,'Borgou','BO',1022),(1897,'Collines','CO',1022),(1898,'Donga','DO',1022),(1899,'Kouffo','KO',1022),(1900,'Littoral','LI',1022),(1901,'Mono','MO',1022),(1902,'Oueme','OU',1022),(1903,'Plateau','PL',1022),(1904,'Zou','ZO',1022),(1905,'Belait','BE',1032),(1906,'Brunei-Muara','BM',1032),(1907,'Temburong','TE',1032),(1908,'Tutong','TU',1032),(1909,'Cochabamba','C',1025),(1910,'Chuquisaca','H',1025),(1911,'El Beni','B',1025),(1912,'La Paz','L',1025),(1913,'Oruro','O',1025),(1914,'Pando','N',1025),(1915,'Potosi','P',1025),(1916,'Tarija','T',1025),(1917,'Acre','AC',1029),(1918,'Alagoas','AL',1029),(1919,'Amazonas','AM',1029),(1920,'Amapa','AP',1029),(1921,'Bahia','BA',1029),(1922,'Ceara','CE',1029),(1923,'Distrito Federal','DF',1029),(1924,'Espirito Santo','ES',1029),(1926,'Goias','GO',1029),(1927,'Maranhao','MA',1029),(1928,'Minas Gerais','MG',1029),(1929,'Mato Grosso do Sul','MS',1029),(1930,'Mato Grosso','MT',1029),(1931,'Para','PA',1029),(1932,'Paraiba','PB',1029),(1933,'Pernambuco','PE',1029),(1934,'Piaui','PI',1029),(1935,'Parana','PR',1029),(1936,'Rio de Janeiro','RJ',1029),(1937,'Rio Grande do Norte','RN',1029),(1938,'Rondonia','RO',1029),(1939,'Roraima','RR',1029),(1940,'Rio Grande do Sul','RS',1029),(1941,'Santa Catarina','SC',1029),(1942,'Sergipe','SE',1029),(1943,'Sao Paulo','SP',1029),(1944,'Tocantins','TO',1029),(1945,'Acklins and Crooked Islands','AC',1212),(1946,'Bimini','BI',1212),(1947,'Cat Island','CI',1212),(1948,'Exuma','EX',1212),(1955,'Inagua','IN',1212),(1957,'Long Island','LI',1212),(1959,'Mayaguana','MG',1212),(1960,'New Providence','NP',1212),(1962,'Ragged Island','RI',1212),(1966,'Bumthang','33',1024),(1967,'Chhukha','12',1024),(1968,'Dagana','22',1024),(1969,'Gasa','GA',1024),(1970,'Ha','13',1024),(1971,'Lhuentse','44',1024),(1972,'Monggar','42',1024),(1973,'Paro','11',1024),(1974,'Pemagatshel','43',1024),(1975,'Punakha','23',1024),(1976,'Samdrup Jongkha','45',1024),(1977,'Samtee','14',1024),(1978,'Sarpang','31',1024),(1979,'Thimphu','15',1024),(1980,'Trashigang','41',1024),(1981,'Trashi Yangtse','TY',1024),(1982,'Trongsa','32',1024),(1983,'Tsirang','21',1024),(1984,'Wangdue Phodrang','24',1024),(1985,'Zhemgang','34',1024),(1986,'Central','CE',1027),(1987,'Ghanzi','GH',1027),(1988,'Kgalagadi','KG',1027),(1989,'Kgatleng','KL',1027),(1990,'Kweneng','KW',1027),(1991,'Ngamiland','NG',1027),(1992,'North-East','NE',1027),(1993,'North-West','NW',1027),(1994,'South-East','SE',1027),(1995,'Southern','SO',1027),(1996,'Brèsckaja voblasc\'','BR',1019),(1997,'Homel\'skaja voblasc\'','HO',1019),(1998,'Hrodzenskaja voblasc\'','HR',1019),(1999,'Mahilëuskaja voblasc\'','MA',1019),(2000,'Minskaja voblasc\'','MI',1019),(2001,'Vicebskaja voblasc\'','VI',1019),(2002,'Belize','BZ',1021),(2003,'Cayo','CY',1021),(2004,'Corozal','CZL',1021),(2005,'Orange Walk','OW',1021),(2006,'Stann Creek','SC',1021),(2007,'Toledo','TOL',1021),(2008,'Kinshasa','KN',1050),(2011,'Equateur','EQ',1050),(2014,'Kasai-Oriental','KE',1050),(2016,'Maniema','MA',1050),(2017,'Nord-Kivu','NK',1050),(2019,'Sud-Kivu','SK',1050),(2020,'Bangui','BGF',1042),(2021,'Bamingui-Bangoran','BB',1042),(2022,'Basse-Kotto','BK',1042),(2023,'Haute-Kotto','HK',1042),(2024,'Haut-Mbomou','HM',1042),(2025,'Kemo','KG',1042),(2026,'Lobaye','LB',1042),(2027,'Mambere-Kadei','HS',1042),(2028,'Mbomou','MB',1042),(2029,'Nana-Grebizi','KB',1042),(2030,'Nana-Mambere','NM',1042),(2031,'Ombella-Mpoko','MP',1042),(2032,'Ouaka','UK',1042),(2033,'Ouham','AC',1042),(2034,'Ouham-Pende','OP',1042),(2035,'Sangha-Mbaere','SE',1042),(2036,'Vakaga','VR',1042),(2037,'Brazzaville','BZV',1051),(2038,'Bouenza','11',1051),(2039,'Cuvette','8',1051),(2040,'Cuvette-Ouest','15',1051),(2041,'Kouilou','5',1051),(2042,'Lekoumou','2',1051),(2043,'Likouala','7',1051),(2044,'Niari','9',1051),(2045,'Plateaux','14',1051),(2046,'Pool','12',1051),(2047,'Sangha','13',1051),(2048,'Aargau','AG',1205),(2049,'Appenzell Innerrhoden','AI',1205),(2050,'Appenzell Ausserrhoden','AR',1205),(2051,'Bern','BE',1205),(2052,'Basel-Landschaft','BL',1205),(2053,'Basel-Stadt','BS',1205),(2054,'Fribourg','FR',1205),(2055,'Geneva','GE',1205),(2056,'Glarus','GL',1205),(2057,'Graubunden','GR',1205),(2058,'Jura','JU',1205),(2059,'Luzern','LU',1205),(2060,'Neuchatel','NE',1205),(2061,'Nidwalden','NW',1205),(2062,'Obwalden','OW',1205),(2063,'Sankt Gallen','SG',1205),(2064,'Schaffhausen','SH',1205),(2065,'Solothurn','SO',1205),(2066,'Schwyz','SZ',1205),(2067,'Thurgau','TG',1205),(2068,'Ticino','TI',1205),(2069,'Uri','UR',1205),(2070,'Vaud','VD',1205),(2071,'Valais','VS',1205),(2072,'Zug','ZG',1205),(2073,'Zurich','ZH',1205),(2074,'18 Montagnes','06',1054),(2075,'Agnebi','16',1054),(2076,'Bas-Sassandra','09',1054),(2077,'Denguele','10',1054),(2078,'Haut-Sassandra','02',1054),(2079,'Lacs','07',1054),(2080,'Lagunes','01',1054),(2081,'Marahoue','12',1054),(2082,'Moyen-Comoe','05',1054),(2083,'Nzi-Comoe','11',1054),(2084,'Savanes','03',1054),(2085,'Sud-Bandama','15',1054),(2086,'Sud-Comoe','13',1054),(2087,'Vallee du Bandama','04',1054),(2088,'Worodouqou','14',1054),(2089,'Zanzan','08',1054),(2090,'Aisen del General Carlos Ibanez del Campo','AI',1044),(2091,'Antofagasta','AN',1044),(2092,'Araucania','AR',1044),(2093,'Atacama','AT',1044),(2094,'Bio-Bio','BI',1044),(2095,'Coquimbo','CO',1044),(2096,'Libertador General Bernardo O\'Higgins','LI',1044),(2097,'Los Lagos','LL',1044),(2098,'Magallanes','MA',1044),(2099,'Maule','ML',1044),(2100,'Santiago Metropolitan','SM',1044),(2101,'Tarapaca','TA',1044),(2102,'Valparaiso','VS',1044),(2103,'Adamaoua','AD',1038),(2104,'Centre','CE',1038),(2105,'East','ES',1038),(2106,'Far North','EN',1038),(2107,'North','NO',1038),(2108,'South','SW',1038),(2109,'South-West','SW',1038),(2110,'West','OU',1038),(2111,'Beijing','11',1045),(2112,'Chongqing','50',1045),(2113,'Shanghai','31',1045),(2114,'Tianjin','12',1045),(2115,'Anhui','34',1045),(2116,'Fujian','35',1045),(2117,'Gansu','62',1045),(2118,'Guangdong','44',1045),(2119,'Guizhou','52',1045),(2120,'Hainan','46',1045),(2121,'Hebei','13',1045),(2122,'Heilongjiang','23',1045),(2123,'Henan','41',1045),(2124,'Hubei','42',1045),(2125,'Hunan','43',1045),(2126,'Jiangsu','32',1045),(2127,'Jiangxi','36',1045),(2128,'Jilin','22',1045),(2129,'Liaoning','21',1045),(2130,'Qinghai','63',1045),(2131,'Shaanxi','61',1045),(2132,'Shandong','37',1045),(2133,'Shanxi','14',1045),(2134,'Sichuan','51',1045),(2135,'Taiwan','71',1045),(2136,'Yunnan','53',1045),(2137,'Zhejiang','33',1045),(2138,'Guangxi','45',1045),(2139,'Neia Mongol (mn)','15',1045),(2140,'Xinjiang','65',1045),(2141,'Xizang','54',1045),(2142,'Hong Kong','91',1045),(2143,'Macau','92',1045),(2144,'Distrito Capital de Bogotá','DC',1048),(2145,'Amazonea','AMA',1048),(2146,'Antioquia','ANT',1048),(2147,'Arauca','ARA',1048),(2148,'Atlántico','ATL',1048),(2149,'Bolívar','BOL',1048),(2150,'Boyacá','BOY',1048),(2151,'Caldea','CAL',1048),(2152,'Caquetá','CAQ',1048),(2153,'Casanare','CAS',1048),(2154,'Cauca','CAU',1048),(2155,'Cesar','CES',1048),(2156,'Córdoba','COR',1048),(2157,'Cundinamarca','CUN',1048),(2158,'Chocó','CHO',1048),(2159,'Guainía','GUA',1048),(2160,'Guaviare','GUV',1048),(2161,'La Guajira','LAG',1048),(2162,'Magdalena','MAG',1048),(2163,'Meta','MET',1048),(2164,'Nariño','NAR',1048),(2165,'Norte de Santander','NSA',1048),(2166,'Putumayo','PUT',1048),(2167,'Quindio','QUI',1048),(2168,'Risaralda','RIS',1048),(2169,'San Andrés, Providencia y Santa Catalina','SAP',1048),(2170,'Santander','SAN',1048),(2171,'Sucre','SUC',1048),(2172,'Tolima','TOL',1048),(2173,'Valle del Cauca','VAC',1048),(2174,'Vaupés','VAU',1048),(2175,'Vichada','VID',1048),(2176,'Alajuela','A',1053),(2177,'Cartago','C',1053),(2178,'Guanacaste','G',1053),(2179,'Heredia','H',1053),(2180,'Limon','L',1053),(2181,'Puntarenas','P',1053),(2182,'San Jose','SJ',1053),(2183,'Camagey','09',1056),(2184,'Ciego de `vila','08',1056),(2185,'Cienfuegos','06',1056),(2186,'Ciudad de La Habana','03',1056),(2187,'Granma','12',1056),(2188,'Guantanamo','14',1056),(2189,'Holquin','11',1056),(2190,'La Habana','02',1056),(2191,'Las Tunas','10',1056),(2192,'Matanzas','04',1056),(2193,'Pinar del Rio','01',1056),(2194,'Sancti Spiritus','07',1056),(2195,'Santiago de Cuba','13',1056),(2196,'Villa Clara','05',1056),(2197,'Isla de la Juventud','99',1056),(2198,'Pinar del Roo','PR',1056),(2199,'Ciego de Avila','CA',1056),(2200,'Camagoey','CG',1056),(2201,'Holgun','HO',1056),(2202,'Sancti Spritus','SS',1056),(2203,'Municipio Especial Isla de la Juventud','IJ',1056),(2204,'Boa Vista','BV',1040),(2205,'Brava','BR',1040),(2206,'Calheta de Sao Miguel','CS',1040),(2207,'Fogo','FO',1040),(2208,'Maio','MA',1040),(2209,'Mosteiros','MO',1040),(2210,'Paul','PA',1040),(2211,'Porto Novo','PN',1040),(2212,'Praia','PR',1040),(2213,'Ribeira Grande','RG',1040),(2214,'Sal','SL',1040),(2215,'Sao Domingos','SD',1040),(2216,'Sao Filipe','SF',1040),(2217,'Sao Nicolau','SN',1040),(2218,'Sao Vicente','SV',1040),(2219,'Tarrafal','TA',1040),(2220,'Ammochostos Magusa','04',1057),(2221,'Keryneia','06',1057),(2222,'Larnaka','03',1057),(2223,'Lefkosia','01',1057),(2224,'Lemesos','02',1057),(2225,'Pafos','05',1057),(2226,'Jihočeský kraj','JC',1058),(2227,'Jihomoravský kraj','JM',1058),(2228,'Karlovarský kraj','KA',1058),(2229,'Královéhradecký kraj','KR',1058),(2230,'Liberecký kraj','LI',1058),(2231,'Moravskoslezský kraj','MO',1058),(2232,'Olomoucký kraj','OL',1058),(2233,'Pardubický kraj','PA',1058),(2234,'Plzeňský kraj','PL',1058),(2235,'Praha, hlavní město','PR',1058),(2236,'Středočeský kraj','ST',1058),(2237,'Ústecký kraj','US',1058),(2238,'Vysočina','VY',1058),(2239,'Zlínský kraj','ZL',1058),(2240,'Baden-Wuerttemberg','BW',1082),(2241,'Bayern','BY',1082),(2242,'Bremen','HB',1082),(2243,'Hamburg','HH',1082),(2244,'Hessen','HE',1082),(2245,'Niedersachsen','NI',1082),(2246,'Nordrhein-Westfalen','NW',1082),(2247,'Rheinland-Pfalz','RP',1082),(2248,'Saarland','SL',1082),(2249,'Schleswig-Holstein','SH',1082),(2250,'Berlin','BR',1082),(2251,'Brandenburg','BB',1082),(2252,'Mecklenburg-Vorpommern','MV',1082),(2253,'Sachsen','SN',1082),(2254,'Sachsen-Anhalt','ST',1082),(2255,'Thueringen','TH',1082),(2256,'Ali Sabiah','AS',1060),(2257,'Dikhil','DI',1060),(2258,'Djibouti','DJ',1060),(2259,'Obock','OB',1060),(2260,'Tadjoura','TA',1060),(2261,'Frederiksberg','147',1059),(2262,'Copenhagen City','101',1059),(2263,'Copenhagen','015',1059),(2264,'Frederiksborg','020',1059),(2265,'Roskilde','025',1059),(2266,'Vestsjælland','030',1059),(2267,'Storstrøm','035',1059),(2268,'Bornholm','040',1059),(2269,'Fyn','042',1059),(2270,'South Jutland','050',1059),(2271,'Ribe','055',1059),(2272,'Vejle','060',1059),(2273,'Ringkjøbing','065',1059),(2274,'Århus','070',1059),(2275,'Viborg','076',1059),(2276,'North Jutland','080',1059),(2277,'Distrito Nacional (Santo Domingo)','01',1062),(2278,'Azua','02',1062),(2279,'Bahoruco','03',1062),(2280,'Barahona','04',1062),(2281,'Dajabón','05',1062),(2282,'Duarte','06',1062),(2283,'El Seybo [El Seibo]','08',1062),(2284,'Espaillat','09',1062),(2285,'Hato Mayor','30',1062),(2286,'Independencia','10',1062),(2287,'La Altagracia','11',1062),(2288,'La Estrelleta [Elias Pina]','07',1062),(2289,'La Romana','12',1062),(2290,'La Vega','13',1062),(2291,'Maroia Trinidad Sánchez','14',1062),(2292,'Monseñor Nouel','28',1062),(2293,'Monte Cristi','15',1062),(2294,'Monte Plata','29',1062),(2295,'Pedernales','16',1062),(2296,'Peravia','17',1062),(2297,'Puerto Plata','18',1062),(2298,'Salcedo','19',1062),(2299,'Samaná','20',1062),(2300,'San Cristóbal','21',1062),(2301,'San Pedro de Macorís','23',1062),(2302,'Sánchez Ramírez','24',1062),(2303,'Santiago','25',1062),(2304,'Santiago Rodríguez','26',1062),(2305,'Valverde','27',1062),(2306,'Adrar','01',1003),(2307,'Ain Defla','44',1003),(2308,'Ain Tmouchent','46',1003),(2309,'Alger','16',1003),(2310,'Annaba','23',1003),(2311,'Batna','05',1003),(2312,'Bechar','08',1003),(2313,'Bejaia','06',1003),(2314,'Biskra','07',1003),(2315,'Blida','09',1003),(2316,'Bordj Bou Arreridj','34',1003),(2317,'Bouira','10',1003),(2318,'Boumerdes','35',1003),(2319,'Chlef','02',1003),(2320,'Constantine','25',1003),(2321,'Djelfa','17',1003),(2322,'El Bayadh','32',1003),(2323,'El Oued','39',1003),(2324,'El Tarf','36',1003),(2325,'Ghardaia','47',1003),(2326,'Guelma','24',1003),(2327,'Illizi','33',1003),(2328,'Jijel','18',1003),(2329,'Khenchela','40',1003),(2330,'Laghouat','03',1003),(2331,'Mascara','29',1003),(2332,'Medea','26',1003),(2333,'Mila','43',1003),(2334,'Mostaganem','27',1003),(2335,'Msila','28',1003),(2336,'Naama','45',1003),(2337,'Oran','31',1003),(2338,'Ouargla','30',1003),(2339,'Oum el Bouaghi','04',1003),(2340,'Relizane','48',1003),(2341,'Saida','20',1003),(2342,'Setif','19',1003),(2343,'Sidi Bel Abbes','22',1003),(2344,'Skikda','21',1003),(2345,'Souk Ahras','41',1003),(2346,'Tamanghasset','11',1003),(2347,'Tebessa','12',1003),(2348,'Tiaret','14',1003),(2349,'Tindouf','37',1003),(2350,'Tipaza','42',1003),(2351,'Tissemsilt','38',1003),(2352,'Tizi Ouzou','15',1003),(2353,'Tlemcen','13',1003),(2354,'Azuay','A',1064),(2355,'Bolivar','B',1064),(2356,'Canar','F',1064),(2357,'Carchi','C',1064),(2358,'Cotopaxi','X',1064),(2359,'Chimborazo','H',1064),(2360,'El Oro','O',1064),(2361,'Esmeraldas','E',1064),(2362,'Galapagos','W',1064),(2363,'Guayas','G',1064),(2364,'Imbabura','I',1064),(2365,'Loja','L',1064),(2366,'Los Rios','R',1064),(2367,'Manabi','M',1064),(2368,'Morona-Santiago','S',1064),(2369,'Napo','N',1064),(2370,'Orellana','D',1064),(2371,'Pastaza','Y',1064),(2372,'Pichincha','P',1064),(2373,'Sucumbios','U',1064),(2374,'Tungurahua','T',1064),(2375,'Zamora-Chinchipe','Z',1064),(2376,'Harjumaa','37',1069),(2377,'Hiiumaa','39',1069),(2378,'Ida-Virumaa','44',1069),(2379,'Jõgevamaa','49',1069),(2380,'Järvamaa','51',1069),(2381,'Läänemaa','57',1069),(2382,'Lääne-Virumaa','59',1069),(2383,'Põlvamaa','65',1069),(2384,'Pärnumaa','67',1069),(2385,'Raplamaa','70',1069),(2386,'Saaremaa','74',1069),(2387,'Tartumaa','7B',1069),(2388,'Valgamaa','82',1069),(2389,'Viljandimaa','84',1069),(2390,'Võrumaa','86',1069),(2391,'Ad Daqahllyah','DK',1065),(2392,'Al Bahr al Ahmar','BA',1065),(2393,'Al Buhayrah','BH',1065),(2394,'Al Fayym','FYM',1065),(2395,'Al Gharbiyah','GH',1065),(2396,'Al Iskandarlyah','ALX',1065),(2397,'Al Isma illyah','IS',1065),(2398,'Al Jizah','GZ',1065),(2399,'Al Minuflyah','MNF',1065),(2400,'Al Minya','MN',1065),(2401,'Al Qahirah','C',1065),(2402,'Al Qalyublyah','KB',1065),(2403,'Al Wadi al Jadid','WAD',1065),(2404,'Ash Sharqiyah','SHR',1065),(2405,'As Suways','SUZ',1065),(2406,'Aswan','ASN',1065),(2407,'Asyut','AST',1065),(2408,'Bani Suwayf','BNS',1065),(2409,'Bur Sa\'id','PTS',1065),(2410,'Dumyat','DT',1065),(2411,'Janub Sina\'','JS',1065),(2412,'Kafr ash Shaykh','KFS',1065),(2413,'Matruh','MT',1065),(2414,'Qina','KN',1065),(2415,'Shamal Sina\'','SIN',1065),(2416,'Suhaj','SHG',1065),(2417,'Anseba','AN',1068),(2418,'Debub','DU',1068),(2419,'Debubawi Keyih Bahri [Debub-Keih-Bahri]','DK',1068),(2420,'Gash-Barka','GB',1068),(2421,'Maakel [Maekel]','MA',1068),(2422,'Semenawi Keyih Bahri [Semien-Keih-Bahri]','SK',1068),(2423,'Álava','VI',1198),(2424,'Albacete','AB',1198),(2425,'Alicante','A',1198),(2426,'Almería','AL',1198),(2427,'Asturias','O',1198),(2428,'Ávila','AV',1198),(2429,'Badajoz','BA',1198),(2430,'Baleares','PM',1198),(2431,'Barcelona','B',1198),(2432,'Burgos','BU',1198),(2433,'Cáceres','CC',1198),(2434,'Cádiz','CA',1198),(2435,'Cantabria','S',1198),(2436,'Castellón','CS',1198),(2437,'Ciudad Real','CR',1198),(2438,'Cuenca','CU',1198),(2439,'Girona [Gerona]','GE',1198),(2440,'Granada','GR',1198),(2441,'Guadalajara','GU',1198),(2442,'Guipúzcoa','SS',1198),(2443,'Huelva','H',1198),(2444,'Huesca','HU',1198),(2445,'Jaén','J',1198),(2446,'La Coruña','C',1198),(2447,'La Rioja','LO',1198),(2448,'Las Palmas','GC',1198),(2449,'León','LE',1198),(2450,'Lleida [Lérida]','L',1198),(2451,'Lugo','LU',1198),(2452,'Madrid','M',1198),(2453,'Málaga','MA',1198),(2454,'Murcia','MU',1198),(2455,'Navarra','NA',1198),(2456,'Ourense','OR',1198),(2457,'Palencia','P',1198),(2458,'Pontevedra','PO',1198),(2459,'Salamanca','SA',1198),(2460,'Santa Cruz de Tenerife','TF',1198),(2461,'Segovia','SG',1198),(2462,'Sevilla','SE',1198),(2463,'Soria','SO',1198),(2464,'Tarragona','T',1198),(2465,'Teruel','TE',1198),(2466,'Valencia','V',1198),(2467,'Valladolid','VA',1198),(2468,'Vizcaya','BI',1198),(2469,'Zamora','ZA',1198),(2470,'Zaragoza','Z',1198),(2471,'Ceuta','CE',1198),(2472,'Melilla','ML',1198),(2473,'Addis Ababa','AA',1070),(2474,'Dire Dawa','DD',1070),(2475,'Afar','AF',1070),(2476,'Amara','AM',1070),(2477,'Benshangul-Gumaz','BE',1070),(2478,'Gambela Peoples','GA',1070),(2479,'Harari People','HA',1070),(2480,'Oromia','OR',1070),(2481,'Somali','SO',1070),(2482,'Southern Nations, Nationalities and Peoples','SN',1070),(2483,'Tigrai','TI',1070),(2490,'Eastern','E',1074),(2491,'Northern','N',1074),(2492,'Western','W',1074),(2493,'Rotuma','R',1074),(2494,'Chuuk','TRK',1141),(2495,'Kosrae','KSA',1141),(2496,'Pohnpei','PNI',1141),(2497,'Yap','YAP',1141),(2498,'Ain','01',1076),(2499,'Aisne','02',1076),(2500,'Allier','03',1076),(2501,'Alpes-de-Haute-Provence','04',1076),(2502,'Alpes-Maritimes','06',1076),(2503,'Ardèche','07',1076),(2504,'Ardennes','08',1076),(2505,'Ariège','09',1076),(2506,'Aube','10',1076),(2507,'Aude','11',1076),(2508,'Aveyron','12',1076),(2509,'Bas-Rhin','67',1076),(2510,'Bouches-du-Rhône','13',1076),(2511,'Calvados','14',1076),(2512,'Cantal','15',1076),(2513,'Charente','16',1076),(2514,'Charente-Maritime','17',1076),(2515,'Cher','18',1076),(2516,'Corrèze','19',1076),(2517,'Corse-du-Sud','20A',1076),(2518,'Côte-d\'Or','21',1076),(2519,'Côtes-d\'Armor','22',1076),(2520,'Creuse','23',1076),(2521,'Deux-Sèvres','79',1076),(2522,'Dordogne','24',1076),(2523,'Doubs','25',1076),(2524,'Drôme','26',1076),(2525,'Essonne','91',1076),(2526,'Eure','27',1076),(2527,'Eure-et-Loir','28',1076),(2528,'Finistère','29',1076),(2529,'Gard','30',1076),(2530,'Gers','32',1076),(2531,'Gironde','33',1076),(2532,'Haut-Rhin','68',1076),(2533,'Haute-Corse','20B',1076),(2534,'Haute-Garonne','31',1076),(2535,'Haute-Loire','43',1076),(2536,'Haute-Saône','70',1076),(2537,'Haute-Savoie','74',1076),(2538,'Haute-Vienne','87',1076),(2539,'Hautes-Alpes','05',1076),(2540,'Hautes-Pyrénées','65',1076),(2541,'Hauts-de-Seine','92',1076),(2542,'Hérault','34',1076),(2543,'Indre','36',1076),(2544,'Ille-et-Vilaine','35',1076),(2545,'Indre-et-Loire','37',1076),(2546,'Isère','38',1076),(2547,'Landes','40',1076),(2548,'Loir-et-Cher','41',1076),(2549,'Loire','42',1076),(2550,'Loire-Atlantique','44',1076),(2551,'Loiret','45',1076),(2552,'Lot','46',1076),(2553,'Lot-et-Garonne','47',1076),(2554,'Lozère','48',1076),(2555,'Maine-et-Loire','49',1076),(2556,'Manche','50',1076),(2557,'Marne','51',1076),(2558,'Mayenne','53',1076),(2559,'Meurthe-et-Moselle','54',1076),(2560,'Meuse','55',1076),(2561,'Morbihan','56',1076),(2562,'Moselle','57',1076),(2563,'Nièvre','58',1076),(2564,'Nord','59',1076),(2565,'Oise','60',1076),(2566,'Orne','61',1076),(2567,'Paris','75',1076),(2568,'Pas-de-Calais','62',1076),(2569,'Puy-de-Dôme','63',1076),(2570,'Pyrénées-Atlantiques','64',1076),(2571,'Pyrénées-Orientales','66',1076),(2572,'Rhône','69',1076),(2573,'Saône-et-Loire','71',1076),(2574,'Sarthe','72',1076),(2575,'Savoie','73',1076),(2576,'Seine-et-Marne','77',1076),(2577,'Seine-Maritime','76',1076),(2578,'Seine-Saint-Denis','93',1076),(2579,'Somme','80',1076),(2580,'Tarn','81',1076),(2581,'Tarn-et-Garonne','82',1076),(2582,'Val d\'Oise','95',1076),(2583,'Territoire de Belfort','90',1076),(2584,'Val-de-Marne','94',1076),(2585,'Var','83',1076),(2586,'Vaucluse','84',1076),(2587,'Vendée','85',1076),(2588,'Vienne','86',1076),(2589,'Vosges','88',1076),(2590,'Yonne','89',1076),(2591,'Yvelines','78',1076),(2592,'Aberdeen City','ABE',1226),(2593,'Aberdeenshire','ABD',1226),(2594,'Angus','ANS',1226),(2595,'Co Antrim','ANT',1226),(2597,'Argyll and Bute','AGB',1226),(2598,'Co Armagh','ARM',1226),(2606,'Bedfordshire','BDF',1226),(2612,'Gwent','BGW',1226),(2620,'Bristol, City of','BST',1226),(2622,'Buckinghamshire','BKM',1226),(2626,'Cambridgeshire','CAM',1226),(2634,'Cheshire','CHS',1226),(2635,'Clackmannanshire','CLK',1226),(2639,'Cornwall','CON',1226),(2643,'Cumbria','CMA',1226),(2647,'Derbyshire','DBY',1226),(2648,'Co Londonderry','DRY',1226),(2649,'Devon','DEV',1226),(2651,'Dorset','DOR',1226),(2652,'Co Down','DOW',1226),(2654,'Dumfries and Galloway','DGY',1226),(2655,'Dundee City','DND',1226),(2657,'County Durham','DUR',1226),(2659,'East Ayrshire','EAY',1226),(2660,'East Dunbartonshire','EDU',1226),(2661,'East Lothian','ELN',1226),(2662,'East Renfrewshire','ERW',1226),(2663,'East Riding of Yorkshire','ERY',1226),(2664,'East Sussex','ESX',1226),(2665,'Edinburgh, City of','EDH',1226),(2666,'Na h-Eileanan Siar','ELS',1226),(2668,'Essex','ESS',1226),(2669,'Falkirk','FAL',1226),(2670,'Co Fermanagh','FER',1226),(2671,'Fife','FIF',1226),(2674,'Glasgow City','GLG',1226),(2675,'Gloucestershire','GLS',1226),(2678,'Gwynedd','GWN',1226),(2682,'Hampshire','HAM',1226),(2687,'Herefordshire','HEF',1226),(2688,'Hertfordshire','HRT',1226),(2689,'Highland','HED',1226),(2692,'Inverclyde','IVC',1226),(2694,'Isle of Wight','IOW',1226),(2699,'Kent','KEN',1226),(2705,'Lancashire','LAN',1226),(2709,'Leicestershire','LEC',1226),(2712,'Lincolnshire','LIN',1226),(2723,'Midlothian','MLN',1226),(2726,'Moray','MRY',1226),(2734,'Norfolk','NFK',1226),(2735,'North Ayrshire','NAY',1226),(2738,'North Lanarkshire','NLK',1226),(2742,'North Yorkshire','NYK',1226),(2743,'Northamptonshire','NTH',1226),(2744,'Northumberland','NBL',1226),(2746,'Nottinghamshire','NTT',1226),(2747,'Oldham','OLD',1226),(2748,'Omagh','OMH',1226),(2749,'Orkney Islands','ORR',1226),(2750,'Oxfordshire','OXF',1226),(2752,'Perth and Kinross','PKN',1226),(2757,'Powys','POW',1226),(2761,'Renfrewshire','RFW',1226),(2766,'Rutland','RUT',1226),(2770,'Scottish Borders','SCB',1226),(2773,'Shetland Islands','ZET',1226),(2774,'Shropshire','SHR',1226),(2777,'Somerset','SOM',1226),(2778,'South Ayrshire','SAY',1226),(2779,'South Gloucestershire','SGC',1226),(2780,'South Lanarkshire','SLK',1226),(2785,'Staffordshire','STS',1226),(2786,'Stirling','STG',1226),(2791,'Suffolk','SFK',1226),(2793,'Surrey','SRY',1226),(2804,'Mid Glamorgan','VGL',1226),(2811,'Warwickshire','WAR',1226),(2813,'West Dunbartonshire','WDU',1226),(2814,'West Lothian','WLN',1226),(2815,'West Sussex','WSX',1226),(2818,'Wiltshire','WIL',1226),(2823,'Worcestershire','WOR',1226),(2826,'Ashanti','AH',1083),(2827,'Brong-Ahafo','BA',1083),(2828,'Greater Accra','AA',1083),(2829,'Upper East','UE',1083),(2830,'Upper West','UW',1083),(2831,'Volta','TV',1083),(2832,'Banjul','B',1213),(2833,'Lower River','L',1213),(2834,'MacCarthy Island','M',1213),(2835,'North Bank','N',1213),(2836,'Upper River','U',1213),(2837,'Beyla','BE',1091),(2838,'Boffa','BF',1091),(2839,'Boke','BK',1091),(2840,'Coyah','CO',1091),(2841,'Dabola','DB',1091),(2842,'Dalaba','DL',1091),(2843,'Dinguiraye','DI',1091),(2844,'Dubreka','DU',1091),(2845,'Faranah','FA',1091),(2846,'Forecariah','FO',1091),(2847,'Fria','FR',1091),(2848,'Gaoual','GA',1091),(2849,'Guekedou','GU',1091),(2850,'Kankan','KA',1091),(2851,'Kerouane','KE',1091),(2852,'Kindia','KD',1091),(2853,'Kissidougou','KS',1091),(2854,'Koubia','KB',1091),(2855,'Koundara','KN',1091),(2856,'Kouroussa','KO',1091),(2857,'Labe','LA',1091),(2858,'Lelouma','LE',1091),(2859,'Lola','LO',1091),(2860,'Macenta','MC',1091),(2861,'Mali','ML',1091),(2862,'Mamou','MM',1091),(2863,'Mandiana','MD',1091),(2864,'Nzerekore','NZ',1091),(2865,'Pita','PI',1091),(2866,'Siguiri','SI',1091),(2867,'Telimele','TE',1091),(2868,'Tougue','TO',1091),(2869,'Yomou','YO',1091),(2870,'Region Continental','C',1067),(2871,'Region Insular','I',1067),(2872,'Annobon','AN',1067),(2873,'Bioko Norte','BN',1067),(2874,'Bioko Sur','BS',1067),(2875,'Centro Sur','CS',1067),(2876,'Kie-Ntem','KN',1067),(2877,'Litoral','LI',1067),(2878,'Wele-Nzas','WN',1067),(2879,'Achaïa','13',1085),(2880,'Aitolia-Akarnania','01',1085),(2881,'Argolis','11',1085),(2882,'Arkadia','12',1085),(2883,'Arta','31',1085),(2884,'Attiki','A1',1085),(2885,'Chalkidiki','64',1085),(2886,'Chania','94',1085),(2887,'Chios','85',1085),(2888,'Dodekanisos','81',1085),(2889,'Drama','52',1085),(2890,'Evros','71',1085),(2891,'Evrytania','05',1085),(2892,'Evvoia','04',1085),(2893,'Florina','63',1085),(2894,'Fokis','07',1085),(2895,'Fthiotis','06',1085),(2896,'Grevena','51',1085),(2897,'Ileia','14',1085),(2898,'Imathia','53',1085),(2899,'Ioannina','33',1085),(2900,'Irakleion','91',1085),(2901,'Karditsa','41',1085),(2902,'Kastoria','56',1085),(2903,'Kavalla','55',1085),(2904,'Kefallinia','23',1085),(2905,'Kerkyra','22',1085),(2906,'Kilkis','57',1085),(2907,'Korinthia','15',1085),(2908,'Kozani','58',1085),(2909,'Kyklades','82',1085),(2910,'Lakonia','16',1085),(2911,'Larisa','42',1085),(2912,'Lasithion','92',1085),(2913,'Lefkas','24',1085),(2914,'Lesvos','83',1085),(2915,'Magnisia','43',1085),(2916,'Messinia','17',1085),(2917,'Pella','59',1085),(2918,'Preveza','34',1085),(2919,'Rethymnon','93',1085),(2920,'Rodopi','73',1085),(2921,'Samos','84',1085),(2922,'Serrai','62',1085),(2923,'Thesprotia','32',1085),(2924,'Thessaloniki','54',1085),(2925,'Trikala','44',1085),(2926,'Voiotia','03',1085),(2927,'Xanthi','72',1085),(2928,'Zakynthos','21',1085),(2929,'Agio Oros','69',1085),(2930,'Alta Verapaz','AV',1090),(2931,'Baja Verapaz','BV',1090),(2932,'Chimaltenango','CM',1090),(2933,'Chiquimula','CQ',1090),(2934,'El Progreso','PR',1090),(2935,'Escuintla','ES',1090),(2936,'Guatemala','GU',1090),(2937,'Huehuetenango','HU',1090),(2938,'Izabal','IZ',1090),(2939,'Jalapa','JA',1090),(2940,'Jutiapa','JU',1090),(2941,'Peten','PE',1090),(2942,'Quetzaltenango','QZ',1090),(2943,'Quiche','QC',1090),(2944,'Retalhuleu','RE',1090),(2945,'Sacatepequez','SA',1090),(2946,'San Marcos','SM',1090),(2947,'Santa Rosa','SR',1090),(2948,'Sololá','SO',1090),(2949,'Suchitepequez','SU',1090),(2950,'Totonicapan','TO',1090),(2951,'Zacapa','ZA',1090),(2952,'Bissau','BS',1092),(2953,'Bafata','BA',1092),(2954,'Biombo','BM',1092),(2955,'Bolama','BL',1092),(2956,'Cacheu','CA',1092),(2957,'Gabu','GA',1092),(2958,'Oio','OI',1092),(2959,'Quloara','QU',1092),(2960,'Tombali S','TO',1092),(2961,'Barima-Waini','BA',1093),(2962,'Cuyuni-Mazaruni','CU',1093),(2963,'Demerara-Mahaica','DE',1093),(2964,'East Berbice-Corentyne','EB',1093),(2965,'Essequibo Islands-West Demerara','ES',1093),(2966,'Mahaica-Berbice','MA',1093),(2967,'Pomeroon-Supenaam','PM',1093),(2968,'Potaro-Siparuni','PT',1093),(2969,'Upper Demerara-Berbice','UD',1093),(2970,'Upper Takutu-Upper Essequibo','UT',1093),(2971,'Atlantida','AT',1097),(2972,'Colon','CL',1097),(2973,'Comayagua','CM',1097),(2974,'Copan','CP',1097),(2975,'Cortes','CR',1097),(2976,'Choluteca','CH',1097),(2977,'El Paraiso','EP',1097),(2978,'Francisco Morazan','FM',1097),(2979,'Gracias a Dios','GD',1097),(2980,'Intibuca','IN',1097),(2981,'Islas de la Bahia','IB',1097),(2982,'Lempira','LE',1097),(2983,'Ocotepeque','OC',1097),(2984,'Olancho','OL',1097),(2985,'Santa Barbara','SB',1097),(2986,'Valle','VA',1097),(2987,'Yoro','YO',1097),(2988,'Bjelovarsko-bilogorska zupanija','07',1055),(2989,'Brodsko-posavska zupanija','12',1055),(2990,'Dubrovacko-neretvanska zupanija','19',1055),(2991,'Istarska zupanija','18',1055),(2992,'Karlovacka zupanija','04',1055),(2993,'Koprivnickco-krizevacka zupanija','06',1055),(2994,'Krapinako-zagorska zupanija','02',1055),(2995,'Licko-senjska zupanija','09',1055),(2996,'Medimurska zupanija','20',1055),(2997,'Osjecko-baranjska zupanija','14',1055),(2998,'Pozesko-slavonska zupanija','11',1055),(2999,'Primorsko-goranska zupanija','08',1055),(3000,'Sisacko-moelavacka Iupanija','03',1055),(3001,'Splitako-dalmatinska zupanija','17',1055),(3002,'Sibenako-kninska zupanija','15',1055),(3003,'Varaidinska zupanija','05',1055),(3004,'VirovitiEko-podravska zupanija','10',1055),(3005,'VuRovarako-srijemska zupanija','16',1055),(3006,'Zadaraka','13',1055),(3007,'Zagrebacka zupanija','01',1055),(3008,'Grande-Anse','GA',1094),(3009,'Nord-Est','NE',1094),(3010,'Nord-Ouest','NO',1094),(3011,'Ouest','OU',1094),(3012,'Sud','SD',1094),(3013,'Sud-Est','SE',1094),(3014,'Budapest','BU',1099),(3015,'Bács-Kiskun','BK',1099),(3016,'Baranya','BA',1099),(3017,'Békés','BE',1099),(3018,'Borsod-Abaúj-Zemplén','BZ',1099),(3019,'Csongrád','CS',1099),(3020,'Fejér','FE',1099),(3021,'Győr-Moson-Sopron','GS',1099),(3022,'Hajdu-Bihar','HB',1099),(3023,'Heves','HE',1099),(3024,'Jász-Nagykun-Szolnok','JN',1099),(3025,'Komárom-Esztergom','KE',1099),(3026,'Nográd','NO',1099),(3027,'Pest','PE',1099),(3028,'Somogy','SO',1099),(3029,'Szabolcs-Szatmár-Bereg','SZ',1099),(3030,'Tolna','TO',1099),(3031,'Vas','VA',1099),(3032,'Veszprém','VE',1099),(3033,'Zala','ZA',1099),(3034,'Békéscsaba','BC',1099),(3035,'Debrecen','DE',1099),(3036,'Dunaújváros','DU',1099),(3037,'Eger','EG',1099),(3038,'Győr','GY',1099),(3039,'Hódmezővásárhely','HV',1099),(3040,'Kaposvár','KV',1099),(3041,'Kecskemét','KM',1099),(3042,'Miskolc','MI',1099),(3043,'Nagykanizsa','NK',1099),(3044,'Nyiregyháza','NY',1099),(3045,'Pécs','PS',1099),(3046,'Salgótarján','ST',1099),(3047,'Sopron','SN',1099),(3048,'Szeged','SD',1099),(3049,'Székesfehérvár','SF',1099),(3050,'Szekszárd','SS',1099),(3051,'Szolnok','SK',1099),(3052,'Szombathely','SH',1099),(3053,'Tatabánya','TB',1099),(3054,'Zalaegerszeg','ZE',1099),(3055,'Bali','BA',1102),(3056,'Kepulauan Bangka Belitung','BB',1102),(3057,'Banten','BT',1102),(3058,'Bengkulu','BE',1102),(3059,'Gorontalo','GO',1102),(3060,'Papua Barat','PB',1102),(3061,'Jambi','JA',1102),(3062,'Jawa Barat','JB',1102),(3063,'Jawa Tengah','JT',1102),(3064,'Jawa Timur','JI',1102),(3065,'Kalimantan Barat','KB',1102),(3066,'Kalimantan Timur','KI',1102),(3067,'Kalimantan Selatan','KS',1102),(3068,'Kepulauan Riau','KR',1102),(3069,'Lampung','LA',1102),(3070,'Maluku','MA',1102),(3071,'Maluku Utara','MU',1102),(3072,'Nusa Tenggara Barat','NB',1102),(3073,'Nusa Tenggara Timur','NT',1102),(3074,'Papua','PA',1102),(3075,'Riau','RI',1102),(3076,'Sulawesi Selatan','SN',1102),(3077,'Sulawesi Tengah','ST',1102),(3078,'Sulawesi Tenggara','SG',1102),(3079,'Sulawesi Utara','SA',1102),(3080,'Sumatra Barat','SB',1102),(3081,'Sumatra Selatan','SS',1102),(3082,'Sumatera Utara','SU',1102),(3083,'DKI Jakarta','JK',1102),(3084,'Aceh','AC',1102),(3085,'DI Yogyakarta','YO',1102),(3086,'Cork','C',1105),(3087,'Clare','CE',1105),(3088,'Cavan','CN',1105),(3089,'Carlow','CW',1105),(3090,'Dublin','D',1105),(3091,'Donegal','DL',1105),(3092,'Galway','G',1105),(3093,'Kildare','KE',1105),(3094,'Kilkenny','KK',1105),(3095,'Kerry','KY',1105),(3096,'Longford','LD',1105),(3097,'Louth','LH',1105),(3098,'Limerick','LK',1105),(3099,'Leitrim','LM',1105),(3100,'Laois','LS',1105),(3101,'Meath','MH',1105),(3102,'Monaghan','MN',1105),(3103,'Mayo','MO',1105),(3104,'Offaly','OY',1105),(3105,'Roscommon','RN',1105),(3106,'Sligo','SO',1105),(3107,'Tipperary','TA',1105),(3108,'Waterford','WD',1105),(3109,'Westmeath','WH',1105),(3110,'Wicklow','WW',1105),(3111,'Wexford','WX',1105),(3112,'HaDarom','D',1106),(3113,'HaMerkaz','M',1106),(3114,'HaZafon','Z',1106),(3115,'Haifa','HA',1106),(3116,'Tel-Aviv','TA',1106),(3117,'Jerusalem','JM',1106),(3118,'Al Anbar','AN',1104),(3119,'Al Ba,rah','BA',1104),(3120,'Al Muthanna','MU',1104),(3121,'Al Qadisiyah','QA',1104),(3122,'An Najef','NA',1104),(3123,'Arbil','AR',1104),(3124,'As Sulaymaniyah','SW',1104),(3125,'At Ta\'mim','TS',1104),(3126,'Babil','BB',1104),(3127,'Baghdad','BG',1104),(3128,'Dahuk','DA',1104),(3129,'Dhi Qar','DQ',1104),(3130,'Diyala','DI',1104),(3131,'Karbala\'','KA',1104),(3132,'Maysan','MA',1104),(3133,'Ninawa','NI',1104),(3134,'Salah ad Din','SD',1104),(3135,'Wasit','WA',1104),(3136,'Ardabil','03',1103),(3137,'Azarbayjan-e Gharbi','02',1103),(3138,'Azarbayjan-e Sharqi','01',1103),(3139,'Bushehr','06',1103),(3140,'Chahar Mahall va Bakhtiari','08',1103),(3141,'Esfahan','04',1103),(3142,'Fars','14',1103),(3143,'Gilan','19',1103),(3144,'Golestan','27',1103),(3145,'Hamadan','24',1103),(3146,'Hormozgan','23',1103),(3147,'Iiam','05',1103),(3148,'Kerman','15',1103),(3149,'Kermanshah','17',1103),(3150,'Khorasan','09',1103),(3151,'Khuzestan','10',1103),(3152,'Kohjiluyeh va Buyer Ahmad','18',1103),(3153,'Kordestan','16',1103),(3154,'Lorestan','20',1103),(3155,'Markazi','22',1103),(3156,'Mazandaran','21',1103),(3157,'Qazvin','28',1103),(3158,'Qom','26',1103),(3159,'Semnan','12',1103),(3160,'Sistan va Baluchestan','13',1103),(3161,'Tehran','07',1103),(3162,'Yazd','25',1103),(3163,'Zanjan','11',1103),(3164,'Austurland','7',1100),(3165,'Hofuoborgarsvaeoi utan Reykjavikur','1',1100),(3166,'Norourland eystra','6',1100),(3167,'Norourland vestra','5',1100),(3168,'Reykjavik','0',1100),(3169,'Suourland','8',1100),(3170,'Suournes','2',1100),(3171,'Vestfirolr','4',1100),(3172,'Vesturland','3',1100),(3173,'Agrigento','AG',1107),(3174,'Alessandria','AL',1107),(3175,'Ancona','AN',1107),(3176,'Aosta','AO',1107),(3177,'Arezzo','AR',1107),(3178,'Ascoli Piceno','AP',1107),(3179,'Asti','AT',1107),(3180,'Avellino','AV',1107),(3181,'Bari','BA',1107),(3182,'Belluno','BL',1107),(3183,'Benevento','BN',1107),(3184,'Bergamo','BG',1107),(3185,'Biella','BI',1107),(3186,'Bologna','BO',1107),(3187,'Bolzano','BZ',1107),(3188,'Brescia','BS',1107),(3189,'Brindisi','BR',1107),(3190,'Cagliari','CA',1107),(3191,'Caltanissetta','CL',1107),(3192,'Campobasso','CB',1107),(3193,'Caserta','CE',1107),(3194,'Catania','CT',1107),(3195,'Catanzaro','CZ',1107),(3196,'Chieti','CH',1107),(3197,'Como','CO',1107),(3198,'Cosenza','CS',1107),(3199,'Cremona','CR',1107),(3200,'Crotone','KR',1107),(3201,'Cuneo','CN',1107),(3202,'Enna','EN',1107),(3203,'Ferrara','FE',1107),(3204,'Firenze','FI',1107),(3205,'Foggia','FG',1107),(3206,'Forlì-Cesena','FC',1107),(3207,'Frosinone','FR',1107),(3208,'Genova','GE',1107),(3209,'Gorizia','GO',1107),(3210,'Grosseto','GR',1107),(3211,'Imperia','IM',1107),(3212,'Isernia','IS',1107),(3213,'L\'Aquila','AQ',1107),(3214,'La Spezia','SP',1107),(3215,'Latina','LT',1107),(3216,'Lecce','LE',1107),(3217,'Lecco','LC',1107),(3218,'Livorno','LI',1107),(3219,'Lodi','LO',1107),(3220,'Lucca','LU',1107),(3221,'Macerata','MC',1107),(3222,'Mantova','MN',1107),(3223,'Massa-Carrara','MS',1107),(3224,'Matera','MT',1107),(3225,'Messina','ME',1107),(3226,'Milano','MI',1107),(3227,'Modena','MO',1107),(3228,'Napoli','NA',1107),(3229,'Novara','NO',1107),(3230,'Nuoro','NU',1107),(3231,'Oristano','OR',1107),(3232,'Padova','PD',1107),(3233,'Palermo','PA',1107),(3234,'Parma','PR',1107),(3235,'Pavia','PV',1107),(3236,'Perugia','PG',1107),(3237,'Pesaro e Urbino','PU',1107),(3238,'Pescara','PE',1107),(3239,'Piacenza','PC',1107),(3240,'Pisa','PI',1107),(3241,'Pistoia','PT',1107),(3242,'Pordenone','PN',1107),(3243,'Potenza','PZ',1107),(3244,'Prato','PO',1107),(3245,'Ragusa','RG',1107),(3246,'Ravenna','RA',1107),(3247,'Reggio Calabria','RC',1107),(3248,'Reggio Emilia','RE',1107),(3249,'Rieti','RI',1107),(3250,'Rimini','RN',1107),(3251,'Roma','RM',1107),(3252,'Rovigo','RO',1107),(3253,'Salerno','SA',1107),(3254,'Sassari','SS',1107),(3255,'Savona','SV',1107),(3256,'Siena','SI',1107),(3257,'Siracusa','SR',1107),(3258,'Sondrio','SO',1107),(3259,'Taranto','TA',1107),(3260,'Teramo','TE',1107),(3261,'Terni','TR',1107),(3262,'Torino','TO',1107),(3263,'Trapani','TP',1107),(3264,'Trento','TN',1107),(3265,'Treviso','TV',1107),(3266,'Trieste','TS',1107),(3267,'Udine','UD',1107),(3268,'Varese','VA',1107),(3269,'Venezia','VE',1107),(3270,'Verbano-Cusio-Ossola','VB',1107),(3271,'Vercelli','VC',1107),(3272,'Verona','VR',1107),(3273,'Vibo Valentia','VV',1107),(3274,'Vicenza','VI',1107),(3275,'Viterbo','VT',1107),(3276,'Aichi','23',1109),(3277,'Akita','05',1109),(3278,'Aomori','02',1109),(3279,'Chiba','12',1109),(3280,'Ehime','38',1109),(3281,'Fukui','18',1109),(3282,'Fukuoka','40',1109),(3283,'Fukusima','07',1109),(3284,'Gifu','21',1109),(3285,'Gunma','10',1109),(3286,'Hiroshima','34',1109),(3287,'Hokkaido','01',1109),(3288,'Hyogo','28',1109),(3289,'Ibaraki','08',1109),(3290,'Ishikawa','17',1109),(3291,'Iwate','03',1109),(3292,'Kagawa','37',1109),(3293,'Kagoshima','46',1109),(3294,'Kanagawa','14',1109),(3295,'Kochi','39',1109),(3296,'Kumamoto','43',1109),(3297,'Kyoto','26',1109),(3298,'Mie','24',1109),(3299,'Miyagi','04',1109),(3300,'Miyazaki','45',1109),(3301,'Nagano','20',1109),(3302,'Nagasaki','42',1109),(3303,'Nara','29',1109),(3304,'Niigata','15',1109),(3305,'Oita','44',1109),(3306,'Okayama','33',1109),(3307,'Okinawa','47',1109),(3308,'Osaka','27',1109),(3309,'Saga','41',1109),(3310,'Saitama','11',1109),(3311,'Shiga','25',1109),(3312,'Shimane','32',1109),(3313,'Shizuoka','22',1109),(3314,'Tochigi','09',1109),(3315,'Tokushima','36',1109),(3316,'Tokyo','13',1109),(3317,'Tottori','31',1109),(3318,'Toyama','16',1109),(3319,'Wakayama','30',1109),(3320,'Yamagata','06',1109),(3321,'Yamaguchi','35',1109),(3322,'Yamanashi','19',1109),(3323,'Clarendon','CN',1108),(3324,'Hanover','HR',1108),(3325,'Kingston','KN',1108),(3326,'Portland','PD',1108),(3327,'Saint Andrew','AW',1108),(3328,'Saint Ann','AN',1108),(3329,'Saint Catherine','CE',1108),(3330,'Saint Elizabeth','EH',1108),(3331,'Saint James','JS',1108),(3332,'Saint Mary','MY',1108),(3333,'Saint Thomas','TS',1108),(3334,'Trelawny','TY',1108),(3335,'Westmoreland','WD',1108),(3336,'Ajln','AJ',1110),(3337,'Al \'Aqaba','AQ',1110),(3338,'Al Balqa\'','BA',1110),(3339,'Al Karak','KA',1110),(3340,'Al Mafraq','MA',1110),(3341,'Amman','AM',1110),(3342,'At Tafilah','AT',1110),(3343,'Az Zarga','AZ',1110),(3344,'Irbid','JR',1110),(3345,'Jarash','JA',1110),(3346,'Ma\'an','MN',1110),(3347,'Madaba','MD',1110),(3353,'Bishkek','GB',1117),(3354,'Batken','B',1117),(3355,'Chu','C',1117),(3356,'Jalal-Abad','J',1117),(3357,'Naryn','N',1117),(3358,'Osh','O',1117),(3359,'Talas','T',1117),(3360,'Ysyk-Kol','Y',1117),(3361,'Krong Kaeb','23',1037),(3362,'Krong Pailin','24',1037),(3363,'Xrong Preah Sihanouk','18',1037),(3364,'Phnom Penh','12',1037),(3365,'Baat Dambang','2',1037),(3366,'Banteay Mean Chey','1',1037),(3367,'Rampong Chaam','3',1037),(3368,'Kampong Chhnang','4',1037),(3369,'Kampong Spueu','5',1037),(3370,'Kampong Thum','6',1037),(3371,'Kampot','7',1037),(3372,'Kandaal','8',1037),(3373,'Kach Kong','9',1037),(3374,'Krachoh','10',1037),(3375,'Mondol Kiri','11',1037),(3376,'Otdar Mean Chey','22',1037),(3377,'Pousaat','15',1037),(3378,'Preah Vihear','13',1037),(3379,'Prey Veaeng','14',1037),(3380,'Rotanak Kiri','16',1037),(3381,'Siem Reab','17',1037),(3382,'Stueng Traeng','19',1037),(3383,'Svaay Rieng','20',1037),(3384,'Taakaev','21',1037),(3385,'Gilbert Islands','G',1113),(3386,'Line Islands','L',1113),(3387,'Phoenix Islands','P',1113),(3388,'Anjouan Ndzouani','A',1049),(3389,'Grande Comore Ngazidja','G',1049),(3390,'Moheli Moili','M',1049),(3391,'Kaesong-si','KAE',1114),(3392,'Nampo-si','NAM',1114),(3393,'Pyongyang-ai','PYO',1114),(3394,'Chagang-do','CHA',1114),(3395,'Hamgyongbuk-do','HAB',1114),(3396,'Hamgyongnam-do','HAN',1114),(3397,'Hwanghaebuk-do','HWB',1114),(3398,'Hwanghaenam-do','HWN',1114),(3399,'Kangwon-do','KAN',1114),(3400,'Pyonganbuk-do','PYB',1114),(3401,'Pyongannam-do','PYN',1114),(3402,'Yanggang-do','YAN',1114),(3403,'Najin Sonbong-si','NAJ',1114),(3404,'Seoul Teugbyeolsi','11',1115),(3405,'Busan Gwang\'yeogsi','26',1115),(3406,'Daegu Gwang\'yeogsi','27',1115),(3407,'Daejeon Gwang\'yeogsi','30',1115),(3408,'Gwangju Gwang\'yeogsi','29',1115),(3409,'Incheon Gwang\'yeogsi','28',1115),(3410,'Ulsan Gwang\'yeogsi','31',1115),(3411,'Chungcheongbugdo','43',1115),(3412,'Chungcheongnamdo','44',1115),(3413,'Gang\'weondo','42',1115),(3414,'Gyeonggido','41',1115),(3415,'Gyeongsangbugdo','47',1115),(3416,'Gyeongsangnamdo','48',1115),(3417,'Jejudo','49',1115),(3418,'Jeonrabugdo','45',1115),(3419,'Jeonranamdo','46',1115),(3420,'Al Ahmadi','AH',1116),(3421,'Al Farwanlyah','FA',1116),(3422,'Al Jahrah','JA',1116),(3423,'Al Kuwayt','KU',1116),(3424,'Hawalli','HA',1116),(3425,'Almaty','ALA',1111),(3426,'Astana','AST',1111),(3427,'Almaty oblysy','ALM',1111),(3428,'Aqmola oblysy','AKM',1111),(3429,'Aqtobe oblysy','AKT',1111),(3430,'Atyrau oblyfiy','ATY',1111),(3431,'Batys Quzaqstan oblysy','ZAP',1111),(3432,'Mangghystau oblysy','MAN',1111),(3433,'Ongtustik Quzaqstan oblysy','YUZ',1111),(3434,'Pavlodar oblysy','PAV',1111),(3435,'Qaraghandy oblysy','KAR',1111),(3436,'Qostanay oblysy','KUS',1111),(3437,'Qyzylorda oblysy','KZY',1111),(3438,'Shyghys Quzaqstan oblysy','VOS',1111),(3439,'Soltustik Quzaqstan oblysy','SEV',1111),(3440,'Zhambyl oblysy Zhambylskaya oblast\'','ZHA',1111),(3441,'Vientiane','VT',1118),(3442,'Attapu','AT',1118),(3443,'Bokeo','BK',1118),(3444,'Bolikhamxai','BL',1118),(3445,'Champasak','CH',1118),(3446,'Houaphan','HO',1118),(3447,'Khammouan','KH',1118),(3448,'Louang Namtha','LM',1118),(3449,'Louangphabang','LP',1118),(3450,'Oudomxai','OU',1118),(3451,'Phongsali','PH',1118),(3452,'Salavan','SL',1118),(3453,'Savannakhet','SV',1118),(3454,'Xaignabouli','XA',1118),(3455,'Xiasomboun','XN',1118),(3456,'Xekong','XE',1118),(3457,'Xiangkhoang','XI',1118),(3458,'Beirut','BA',1120),(3459,'Beqaa','BI',1120),(3460,'Mount Lebanon','JL',1120),(3461,'North Lebanon','AS',1120),(3462,'South Lebanon','JA',1120),(3463,'Nabatieh','NA',1120),(3464,'Ampara','52',1199),(3465,'Anuradhapura','71',1199),(3466,'Badulla','81',1199),(3467,'Batticaloa','51',1199),(3468,'Colombo','11',1199),(3469,'Galle','31',1199),(3470,'Gampaha','12',1199),(3471,'Hambantota','33',1199),(3472,'Jaffna','41',1199),(3473,'Kalutara','13',1199),(3474,'Kandy','21',1199),(3475,'Kegalla','92',1199),(3476,'Kilinochchi','42',1199),(3477,'Kurunegala','61',1199),(3478,'Mannar','43',1199),(3479,'Matale','22',1199),(3480,'Matara','32',1199),(3481,'Monaragala','82',1199),(3482,'Mullaittivu','45',1199),(3483,'Nuwara Eliya','23',1199),(3484,'Polonnaruwa','72',1199),(3485,'Puttalum','62',1199),(3486,'Ratnapura','91',1199),(3487,'Trincomalee','53',1199),(3488,'VavunLya','44',1199),(3489,'Bomi','BM',1122),(3490,'Bong','BG',1122),(3491,'Grand Basaa','GB',1122),(3492,'Grand Cape Mount','CM',1122),(3493,'Grand Gedeh','GG',1122),(3494,'Grand Kru','GK',1122),(3495,'Lofa','LO',1122),(3496,'Margibi','MG',1122),(3497,'Maryland','MY',1122),(3498,'Montserrado','MO',1122),(3499,'Nimba','NI',1122),(3500,'Rivercess','RI',1122),(3501,'Sinoe','SI',1122),(3502,'Berea','D',1121),(3503,'Butha-Buthe','B',1121),(3504,'Leribe','C',1121),(3505,'Mafeteng','E',1121),(3506,'Maseru','A',1121),(3507,'Mohale\'s Hoek','F',1121),(3508,'Mokhotlong','J',1121),(3509,'Qacha\'s Nek','H',1121),(3510,'Quthing','G',1121),(3511,'Thaba-Tseka','K',1121),(3512,'Alytaus Apskritis','AL',1125),(3513,'Kauno Apskritis','KU',1125),(3514,'Klaipėdos Apskritis','KL',1125),(3515,'Marijampolės Apskritis','MR',1125),(3516,'Panevėžio Apskritis','PN',1125),(3517,'Šiaulių Apskritis','SA',1125),(3518,'Tauragės Apskritis','TA',1125),(3519,'Telšių Apskritis','TE',1125),(3520,'Utenos Apskritis','UT',1125),(3521,'Vilniaus Apskritis','VL',1125),(3522,'Diekirch','D',1126),(3523,'GreveNmacher','G',1126),(3550,'Daugavpils','DGV',1119),(3551,'Jelgava','JEL',1119),(3552,'Jūrmala','JUR',1119),(3553,'Liepāja','LPX',1119),(3554,'Rēzekne','REZ',1119),(3555,'Rīga','RIX',1119),(3556,'Ventspils','VEN',1119),(3557,'Ajdābiyā','AJ',1123),(3558,'Al Buţnān','BU',1123),(3559,'Al Hizām al Akhdar','HZ',1123),(3560,'Al Jabal al Akhdar','JA',1123),(3561,'Al Jifārah','JI',1123),(3562,'Al Jufrah','JU',1123),(3563,'Al Kufrah','KF',1123),(3564,'Al Marj','MJ',1123),(3565,'Al Marqab','MB',1123),(3566,'Al Qaţrūn','QT',1123),(3567,'Al Qubbah','QB',1123),(3568,'Al Wāhah','WA',1123),(3569,'An Nuqaţ al Khams','NQ',1123),(3570,'Ash Shāţi\'','SH',1123),(3571,'Az Zāwiyah','ZA',1123),(3572,'Banghāzī','BA',1123),(3573,'Banī Walīd','BW',1123),(3574,'Darnah','DR',1123),(3575,'Ghadāmis','GD',1123),(3576,'Gharyān','GR',1123),(3577,'Ghāt','GT',1123),(3578,'Jaghbūb','JB',1123),(3579,'Mişrātah','MI',1123),(3580,'Mizdah','MZ',1123),(3581,'Murzuq','MQ',1123),(3582,'Nālūt','NL',1123),(3583,'Sabhā','SB',1123),(3584,'Şabrātah Şurmān','SS',1123),(3585,'Surt','SR',1123),(3586,'Tājūrā\' wa an Nawāhī al Arbāh','TN',1123),(3587,'Ţarābulus','TB',1123),(3588,'Tarhūnah-Masallātah','TM',1123),(3589,'Wādī al hayāt','WD',1123),(3590,'Yafran-Jādū','YJ',1123),(3591,'Agadir','AGD',1146),(3592,'Aït Baha','BAH',1146),(3593,'Aït Melloul','MEL',1146),(3594,'Al Haouz','HAO',1146),(3595,'Al Hoceïma','HOC',1146),(3596,'Assa-Zag','ASZ',1146),(3597,'Azilal','AZI',1146),(3598,'Beni Mellal','BEM',1146),(3599,'Ben Sllmane','BES',1146),(3600,'Berkane','BER',1146),(3601,'Boujdour','BOD',1146),(3602,'Boulemane','BOM',1146),(3603,'Casablanca  [Dar el Beïda]','CAS',1146),(3604,'Chefchaouene','CHE',1146),(3605,'Chichaoua','CHI',1146),(3606,'El Hajeb','HAJ',1146),(3607,'El Jadida','JDI',1146),(3608,'Errachidia','ERR',1146),(3609,'Essaouira','ESI',1146),(3610,'Es Smara','ESM',1146),(3611,'Fès','FES',1146),(3612,'Figuig','FIG',1146),(3613,'Guelmim','GUE',1146),(3614,'Ifrane','IFR',1146),(3615,'Jerada','JRA',1146),(3616,'Kelaat Sraghna','KES',1146),(3617,'Kénitra','KEN',1146),(3618,'Khemisaet','KHE',1146),(3619,'Khenifra','KHN',1146),(3620,'Khouribga','KHO',1146),(3621,'Laâyoune (EH)','LAA',1146),(3622,'Larache','LAP',1146),(3623,'Marrakech','MAR',1146),(3624,'Meknsès','MEK',1146),(3625,'Nador','NAD',1146),(3626,'Ouarzazate','OUA',1146),(3627,'Oued ed Dahab (EH)','OUD',1146),(3628,'Oujda','OUJ',1146),(3629,'Rabat-Salé','RBA',1146),(3630,'Safi','SAF',1146),(3631,'Sefrou','SEF',1146),(3632,'Settat','SET',1146),(3633,'Sidl Kacem','SIK',1146),(3634,'Tanger','TNG',1146),(3635,'Tan-Tan','TNT',1146),(3636,'Taounate','TAO',1146),(3637,'Taroudannt','TAR',1146),(3638,'Tata','TAT',1146),(3639,'Taza','TAZ',1146),(3640,'Tétouan','TET',1146),(3641,'Tiznit','TIZ',1146),(3642,'Gagauzia, Unitate Teritoriala Autonoma','GA',1142),(3643,'Chisinau','CU',1142),(3644,'Stinga Nistrului, unitatea teritoriala din','SN',1142),(3645,'Balti','BA',1142),(3646,'Cahul','CA',1142),(3647,'Edinet','ED',1142),(3648,'Lapusna','LA',1142),(3649,'Orhei','OR',1142),(3650,'Soroca','SO',1142),(3651,'Taraclia','TA',1142),(3652,'Tighina [Bender]','TI',1142),(3653,'Ungheni','UN',1142),(3654,'Antananarivo','T',1129),(3655,'Antsiranana','D',1129),(3656,'Fianarantsoa','F',1129),(3657,'Mahajanga','M',1129),(3658,'Toamasina','A',1129),(3659,'Toliara','U',1129),(3660,'Ailinglapalap','ALL',1135),(3661,'Ailuk','ALK',1135),(3662,'Arno','ARN',1135),(3663,'Aur','AUR',1135),(3664,'Ebon','EBO',1135),(3665,'Eniwetok','ENI',1135),(3666,'Jaluit','JAL',1135),(3667,'Kili','KIL',1135),(3668,'Kwajalein','KWA',1135),(3669,'Lae','LAE',1135),(3670,'Lib','LIB',1135),(3671,'Likiep','LIK',1135),(3672,'Majuro','MAJ',1135),(3673,'Maloelap','MAL',1135),(3674,'Mejit','MEJ',1135),(3675,'Mili','MIL',1135),(3676,'Namorik','NMK',1135),(3677,'Namu','NMU',1135),(3678,'Rongelap','RON',1135),(3679,'Ujae','UJA',1135),(3680,'Ujelang','UJL',1135),(3681,'Utirik','UTI',1135),(3682,'Wotho','WTN',1135),(3683,'Wotje','WTJ',1135),(3684,'Bamako','BK0',1133),(3685,'Gao','7',1133),(3686,'Kayes','1',1133),(3687,'Kidal','8',1133),(3688,'Xoulikoro','2',1133),(3689,'Mopti','5',1133),(3690,'S69ou','4',1133),(3691,'Sikasso','3',1133),(3692,'Tombouctou','6',1133),(3693,'Ayeyarwady','07',1035),(3694,'Bago','02',1035),(3695,'Magway','03',1035),(3696,'Mandalay','04',1035),(3697,'Sagaing','01',1035),(3698,'Tanintharyi','05',1035),(3699,'Yangon','06',1035),(3700,'Chin','14',1035),(3701,'Kachin','11',1035),(3702,'Kayah','12',1035),(3703,'Kayin','13',1035),(3704,'Mon','15',1035),(3705,'Rakhine','16',1035),(3706,'Shan','17',1035),(3707,'Ulaanbaatar','1',1144),(3708,'Arhangay','073',1144),(3709,'Bayanhongor','069',1144),(3710,'Bayan-Olgiy','071',1144),(3711,'Bulgan','067',1144),(3712,'Darhan uul','037',1144),(3713,'Dornod','061',1144),(3714,'Dornogov,','063',1144),(3715,'DundgovL','059',1144),(3716,'Dzavhan','057',1144),(3717,'Govi-Altay','065',1144),(3718,'Govi-Smber','064',1144),(3719,'Hentiy','039',1144),(3720,'Hovd','043',1144),(3721,'Hovsgol','041',1144),(3722,'Omnogovi','053',1144),(3723,'Orhon','035',1144),(3724,'Ovorhangay','055',1144),(3725,'Selenge','049',1144),(3726,'Shbaatar','051',1144),(3727,'Tov','047',1144),(3728,'Uvs','046',1144),(3729,'Nouakchott','NKC',1137),(3730,'Assaba','03',1137),(3731,'Brakna','05',1137),(3732,'Dakhlet Nouadhibou','08',1137),(3733,'Gorgol','04',1137),(3734,'Guidimaka','10',1137),(3735,'Hodh ech Chargui','01',1137),(3736,'Hodh el Charbi','02',1137),(3737,'Inchiri','12',1137),(3738,'Tagant','09',1137),(3739,'Tiris Zemmour','11',1137),(3740,'Trarza','06',1137),(3741,'Beau Bassin-Rose Hill','BR',1138),(3742,'Curepipe','CU',1138),(3743,'Port Louis','PU',1138),(3744,'Quatre Bornes','QB',1138),(3745,'Vacosa-Phoenix','VP',1138),(3746,'Black River','BL',1138),(3747,'Flacq','FL',1138),(3748,'Grand Port','GP',1138),(3749,'Moka','MO',1138),(3750,'Pamplemousses','PA',1138),(3751,'Plaines Wilhems','PW',1138),(3752,'Riviere du Rempart','RP',1138),(3753,'Savanne','SA',1138),(3754,'Agalega Islands','AG',1138),(3755,'Cargados Carajos Shoals','CC',1138),(3756,'Rodrigues Island','RO',1138),(3757,'Male','MLE',1132),(3758,'Alif','02',1132),(3759,'Baa','20',1132),(3760,'Dhaalu','17',1132),(3761,'Faafu','14',1132),(3762,'Gaaf Alif','27',1132),(3763,'Gaefu Dhaalu','28',1132),(3764,'Gnaviyani','29',1132),(3765,'Haa Alif','07',1132),(3766,'Haa Dhaalu','23',1132),(3767,'Kaafu','26',1132),(3768,'Laamu','05',1132),(3769,'Lhaviyani','03',1132),(3770,'Meemu','12',1132),(3771,'Noonu','25',1132),(3772,'Raa','13',1132),(3773,'Seenu','01',1132),(3774,'Shaviyani','24',1132),(3775,'Thaa','08',1132),(3776,'Vaavu','04',1132),(3777,'Balaka','BA',1130),(3778,'Blantyre','BL',1130),(3779,'Chikwawa','CK',1130),(3780,'Chiradzulu','CR',1130),(3781,'Chitipa','CT',1130),(3782,'Dedza','DE',1130),(3783,'Dowa','DO',1130),(3784,'Karonga','KR',1130),(3785,'Kasungu','KS',1130),(3786,'Likoma Island','LK',1130),(3787,'Lilongwe','LI',1130),(3788,'Machinga','MH',1130),(3789,'Mangochi','MG',1130),(3790,'Mchinji','MC',1130),(3791,'Mulanje','MU',1130),(3792,'Mwanza','MW',1130),(3793,'Mzimba','MZ',1130),(3794,'Nkhata Bay','NB',1130),(3795,'Nkhotakota','NK',1130),(3796,'Nsanje','NS',1130),(3797,'Ntcheu','NU',1130),(3798,'Ntchisi','NI',1130),(3799,'Phalomba','PH',1130),(3800,'Rumphi','RU',1130),(3801,'Salima','SA',1130),(3802,'Thyolo','TH',1130),(3803,'Zomba','ZO',1130),(3804,'Aguascalientes','AGU',1140),(3805,'Baja California','BCN',1140),(3806,'Baja California Sur','BCS',1140),(3807,'Campeche','CAM',1140),(3808,'Coahuila','COA',1140),(3809,'Colima','COL',1140),(3810,'Chiapas','CHP',1140),(3811,'Chihuahua','CHH',1140),(3812,'Durango','DUR',1140),(3813,'Guanajuato','GUA',1140),(3814,'Guerrero','GRO',1140),(3815,'Hidalgo','HID',1140),(3816,'Jalisco','JAL',1140),(3817,'Mexico','MEX',1140),(3818,'Michoacin','MIC',1140),(3819,'Morelos','MOR',1140),(3820,'Nayarit','NAY',1140),(3821,'Nuevo Leon','NLE',1140),(3822,'Oaxaca','OAX',1140),(3823,'Puebla','PUE',1140),(3824,'Queretaro','QUE',1140),(3825,'Quintana Roo','ROO',1140),(3826,'San Luis Potosi','SLP',1140),(3827,'Sinaloa','SIN',1140),(3828,'Sonora','SON',1140),(3829,'Tabasco','TAB',1140),(3830,'Tamaulipas','TAM',1140),(3831,'Tlaxcala','TLA',1140),(3832,'Veracruz','VER',1140),(3833,'Yucatan','YUC',1140),(3834,'Zacatecas','ZAC',1140),(3835,'Wilayah Persekutuan Kuala Lumpur','14',1131),(3836,'Wilayah Persekutuan Labuan','15',1131),(3837,'Wilayah Persekutuan Putrajaya','16',1131),(3838,'Johor','01',1131),(3839,'Kedah','02',1131),(3840,'Kelantan','03',1131),(3841,'Melaka','04',1131),(3842,'Negeri Sembilan','05',1131),(3843,'Pahang','06',1131),(3844,'Perak','08',1131),(3845,'Perlis','09',1131),(3846,'Pulau Pinang','07',1131),(3847,'Sabah','12',1131),(3848,'Sarawak','13',1131),(3849,'Selangor','10',1131),(3850,'Terengganu','11',1131),(3851,'Maputo','MPM',1147),(3852,'Cabo Delgado','P',1147),(3853,'Gaza','G',1147),(3854,'Inhambane','I',1147),(3855,'Manica','B',1147),(3856,'Numpula','N',1147),(3857,'Niaaea','A',1147),(3858,'Sofala','S',1147),(3859,'Tete','T',1147),(3860,'Zambezia','Q',1147),(3861,'Caprivi','CA',1148),(3862,'Erongo','ER',1148),(3863,'Hardap','HA',1148),(3864,'Karas','KA',1148),(3865,'Khomas','KH',1148),(3866,'Kunene','KU',1148),(3867,'Ohangwena','OW',1148),(3868,'Okavango','OK',1148),(3869,'Omaheke','OH',1148),(3870,'Omusati','OS',1148),(3871,'Oshana','ON',1148),(3872,'Oshikoto','OT',1148),(3873,'Otjozondjupa','OD',1148),(3874,'Niamey','8',1156),(3875,'Agadez','1',1156),(3876,'Diffa','2',1156),(3877,'Dosso','3',1156),(3878,'Maradi','4',1156),(3879,'Tahoua','S',1156),(3880,'Tillaberi','6',1156),(3881,'Zinder','7',1156),(3882,'Abuja Federal Capital Territory','FC',1157),(3883,'Abia','AB',1157),(3884,'Adamawa','AD',1157),(3885,'Akwa Ibom','AK',1157),(3886,'Anambra','AN',1157),(3887,'Bauchi','BA',1157),(3888,'Bayelsa','BY',1157),(3889,'Benue','BE',1157),(3890,'Borno','BO',1157),(3891,'Cross River','CR',1157),(3892,'Delta','DE',1157),(3893,'Ebonyi','EB',1157),(3894,'Edo','ED',1157),(3895,'Ekiti','EK',1157),(3896,'Enugu','EN',1157),(3897,'Gombe','GO',1157),(3898,'Imo','IM',1157),(3899,'Jigawa','JI',1157),(3900,'Kaduna','KD',1157),(3901,'Kano','KN',1157),(3902,'Katsina','KT',1157),(3903,'Kebbi','KE',1157),(3904,'Kogi','KO',1157),(3905,'Kwara','KW',1157),(3906,'Lagos','LA',1157),(3907,'Nassarawa','NA',1157),(3908,'Niger','NI',1157),(3909,'Ogun','OG',1157),(3910,'Ondo','ON',1157),(3911,'Osun','OS',1157),(3912,'Oyo','OY',1157),(3913,'Rivers','RI',1157),(3914,'Sokoto','SO',1157),(3915,'Taraba','TA',1157),(3916,'Yobe','YO',1157),(3917,'Zamfara','ZA',1157),(3918,'Boaco','BO',1155),(3919,'Carazo','CA',1155),(3920,'Chinandega','CI',1155),(3921,'Chontales','CO',1155),(3922,'Esteli','ES',1155),(3923,'Jinotega','JI',1155),(3924,'Leon','LE',1155),(3925,'Madriz','MD',1155),(3926,'Managua','MN',1155),(3927,'Masaya','MS',1155),(3928,'Matagalpa','MT',1155),(3929,'Nueva Segovia','NS',1155),(3930,'Rio San Juan','SJ',1155),(3931,'Rivas','RI',1155),(3932,'Atlantico Norte','AN',1155),(3933,'Atlantico Sur','AS',1155),(3934,'Drente','DR',1152),(3935,'Flevoland','FL',1152),(3936,'Friesland','FR',1152),(3937,'Gelderland','GL',1152),(3938,'Groningen','GR',1152),(3939,'Noord-Brabant','NB',1152),(3940,'Noord-Holland','NH',1152),(3941,'Overijssel','OV',1152),(3942,'Utrecht','UT',1152),(3943,'Zuid-Holland','ZH',1152),(3944,'Zeeland','ZL',1152),(3945,'Akershus','02',1161),(3946,'Aust-Agder','09',1161),(3947,'Buskerud','06',1161),(3948,'Finnmark','20',1161),(3949,'Hedmark','04',1161),(3950,'Hordaland','12',1161),(3951,'Møre og Romsdal','15',1161),(3952,'Nordland','18',1161),(3953,'Nord-Trøndelag','17',1161),(3954,'Oppland','05',1161),(3955,'Oslo','03',1161),(3956,'Rogaland','11',1161),(3957,'Sogn og Fjordane','14',1161),(3958,'Sør-Trøndelag','16',1161),(3959,'Telemark','06',1161),(3960,'Troms','19',1161),(3961,'Vest-Agder','10',1161),(3962,'Vestfold','07',1161),(3963,'Østfold','01',1161),(3964,'Jan Mayen','22',1161),(3965,'Svalbard','21',1161),(3966,'Auckland','AUK',1154),(3967,'Bay of Plenty','BOP',1154),(3968,'Canterbury','CAN',1154),(3969,'Gisborne','GIS',1154),(3970,'Hawkes Bay','HKB',1154),(3971,'Manawatu-Wanganui','MWT',1154),(3972,'Marlborough','MBH',1154),(3973,'Nelson','NSN',1154),(3974,'Northland','NTL',1154),(3975,'Otago','OTA',1154),(3976,'Southland','STL',1154),(3977,'Taranaki','TKI',1154),(3978,'Tasman','TAS',1154),(3979,'Waikato','WKO',1154),(3980,'Wellington','WGN',1154),(3981,'West Coast','WTC',1154),(3982,'Ad Dakhillyah','DA',1162),(3983,'Al Batinah','BA',1162),(3984,'Al Janblyah','JA',1162),(3985,'Al Wusta','WU',1162),(3986,'Ash Sharqlyah','SH',1162),(3987,'Az Zahirah','ZA',1162),(3988,'Masqat','MA',1162),(3989,'Musandam','MU',1162),(3990,'Bocas del Toro','1',1166),(3991,'Cocle','2',1166),(3992,'Chiriqui','4',1166),(3993,'Darien','5',1166),(3994,'Herrera','6',1166),(3995,'Loa Santoa','7',1166),(3996,'Panama','8',1166),(3997,'Veraguas','9',1166),(3998,'Comarca de San Blas','Q',1166),(3999,'El Callao','CAL',1169),(4000,'Ancash','ANC',1169),(4001,'Apurimac','APU',1169),(4002,'Arequipa','ARE',1169),(4003,'Ayacucho','AYA',1169),(4004,'Cajamarca','CAJ',1169),(4005,'Cuzco','CUS',1169),(4006,'Huancavelica','HUV',1169),(4007,'Huanuco','HUC',1169),(4008,'Ica','ICA',1169),(4009,'Junin','JUN',1169),(4010,'La Libertad','LAL',1169),(4011,'Lambayeque','LAM',1169),(4012,'Lima','LIM',1169),(4013,'Loreto','LOR',1169),(4014,'Madre de Dios','MDD',1169),(4015,'Moquegua','MOQ',1169),(4016,'Pasco','PAS',1169),(4017,'Piura','PIU',1169),(4018,'Puno','PUN',1169),(4019,'San Martin','SAM',1169),(4020,'Tacna','TAC',1169),(4021,'Tumbes','TUM',1169),(4022,'Ucayali','UCA',1169),(4023,'National Capital District (Port Moresby)','NCD',1167),(4024,'Chimbu','CPK',1167),(4025,'Eastern Highlands','EHG',1167),(4026,'East New Britain','EBR',1167),(4027,'East Sepik','ESW',1167),(4028,'Enga','EPW',1167),(4029,'Gulf','GPK',1167),(4030,'Madang','MPM',1167),(4031,'Manus','MRL',1167),(4032,'Milne Bay','MBA',1167),(4033,'Morobe','MPL',1167),(4034,'New Ireland','NIK',1167),(4035,'North Solomons','NSA',1167),(4036,'Santaun','SAN',1167),(4037,'Southern Highlands','SHM',1167),(4038,'Western Highlands','WHM',1167),(4039,'West New Britain','WBK',1167),(4040,'Abra','ABR',1170),(4041,'Agusan del Norte','AGN',1170),(4042,'Agusan del Sur','AGS',1170),(4043,'Aklan','AKL',1170),(4044,'Albay','ALB',1170),(4045,'Antique','ANT',1170),(4046,'Apayao','APA',1170),(4047,'Aurora','AUR',1170),(4048,'Basilan','BAS',1170),(4049,'Bataan','BAN',1170),(4050,'Batanes','BTN',1170),(4051,'Batangas','BTG',1170),(4052,'Benguet','BEN',1170),(4053,'Biliran','BIL',1170),(4054,'Bohol','BOH',1170),(4055,'Bukidnon','BUK',1170),(4056,'Bulacan','BUL',1170),(4057,'Cagayan','CAG',1170),(4058,'Camarines Norte','CAN',1170),(4059,'Camarines Sur','CAS',1170),(4060,'Camiguin','CAM',1170),(4061,'Capiz','CAP',1170),(4062,'Catanduanes','CAT',1170),(4063,'Cavite','CAV',1170),(4064,'Cebu','CEB',1170),(4065,'Compostela Valley','COM',1170),(4066,'Davao','DAV',1170),(4067,'Davao del Sur','DAS',1170),(4068,'Davao Oriental','DAO',1170),(4069,'Eastern Samar','EAS',1170),(4070,'Guimaras','GUI',1170),(4071,'Ifugao','IFU',1170),(4072,'Ilocos Norte','ILN',1170),(4073,'Ilocos Sur','ILS',1170),(4074,'Iloilo','ILI',1170),(4075,'Isabela','ISA',1170),(4076,'Kalinga-Apayso','KAL',1170),(4077,'Laguna','LAG',1170),(4078,'Lanao del Norte','LAN',1170),(4079,'Lanao del Sur','LAS',1170),(4080,'La Union','LUN',1170),(4081,'Leyte','LEY',1170),(4082,'Maguindanao','MAG',1170),(4083,'Marinduque','MAD',1170),(4084,'Masbate','MAS',1170),(4085,'Mindoro Occidental','MDC',1170),(4086,'Mindoro Oriental','MDR',1170),(4087,'Misamis Occidental','MSC',1170),(4088,'Misamis Oriental','MSR',1170),(4089,'Mountain Province','MOU',1170),(4090,'Negroe Occidental','NEC',1170),(4091,'Negros Oriental','NER',1170),(4092,'North Cotabato','NCO',1170),(4093,'Northern Samar','NSA',1170),(4094,'Nueva Ecija','NUE',1170),(4095,'Nueva Vizcaya','NUV',1170),(4096,'Palawan','PLW',1170),(4097,'Pampanga','PAM',1170),(4098,'Pangasinan','PAN',1170),(4099,'Quezon','QUE',1170),(4100,'Quirino','QUI',1170),(4101,'Rizal','RIZ',1170),(4102,'Romblon','ROM',1170),(4103,'Sarangani','SAR',1170),(4104,'Siquijor','SIG',1170),(4105,'Sorsogon','SOR',1170),(4106,'South Cotabato','SCO',1170),(4107,'Southern Leyte','SLE',1170),(4108,'Sultan Kudarat','SUK',1170),(4109,'Sulu','SLU',1170),(4110,'Surigao del Norte','SUN',1170),(4111,'Surigao del Sur','SUR',1170),(4112,'Tarlac','TAR',1170),(4113,'Tawi-Tawi','TAW',1170),(4114,'Western Samar','WSA',1170),(4115,'Zambales','ZMB',1170),(4116,'Zamboanga del Norte','ZAN',1170),(4117,'Zamboanga del Sur','ZAS',1170),(4118,'Zamboanga Sibiguey','ZSI',1170),(4119,'Islamabad Federal Capital Area','IS',1163),(4120,'Baluchistan','BA',1163),(4121,'Khyber Pakhtun Khawa','NW',1163),(4122,'Sindh','SD',1163),(4123,'Federally Administered Tribal Areas','TA',1163),(4124,'Azad Kashmir','JK',1163),(4125,'Gilgit-Baltistan','NA',1163),(4126,'Aveiro','01',1173),(4127,'Beja','02',1173),(4128,'Braga','03',1173),(4129,'Braganca','04',1173),(4130,'Castelo Branco','05',1173),(4131,'Colmbra','06',1173),(4132,'Ovora','07',1173),(4133,'Faro','08',1173),(4134,'Guarda','09',1173),(4135,'Leiria','10',1173),(4136,'Lisboa','11',1173),(4137,'Portalegre','12',1173),(4138,'Porto','13',1173),(4139,'Santarem','14',1173),(4140,'Setubal','15',1173),(4141,'Viana do Castelo','16',1173),(4142,'Vila Real','17',1173),(4143,'Viseu','18',1173),(4144,'Regiao Autonoma dos Acores','20',1173),(4145,'Regiao Autonoma da Madeira','30',1173),(4146,'Asuncion','ASU',1168),(4147,'Alto Paraguay','16',1168),(4148,'Alto Parana','10',1168),(4149,'Amambay','13',1168),(4150,'Boqueron','19',1168),(4151,'Caeguazu','5',1168),(4152,'Caazapl','6',1168),(4153,'Canindeyu','14',1168),(4154,'Concepcion','1',1168),(4155,'Cordillera','3',1168),(4156,'Guaira','4',1168),(4157,'Itapua','7',1168),(4158,'Miaiones','8',1168),(4159,'Neembucu','12',1168),(4160,'Paraguari','9',1168),(4161,'Presidente Hayes','15',1168),(4162,'San Pedro','2',1168),(4163,'Ad Dawhah','DA',1175),(4164,'Al Ghuwayriyah','GH',1175),(4165,'Al Jumayliyah','JU',1175),(4166,'Al Khawr','KH',1175),(4167,'Al Wakrah','WA',1175),(4168,'Ar Rayyan','RA',1175),(4169,'Jariyan al Batnah','JB',1175),(4170,'Madinat ash Shamal','MS',1175),(4171,'Umm Salal','US',1175),(4172,'Bucuresti','B',1176),(4173,'Alba','AB',1176),(4174,'Arad','AR',1176),(4175,'Arges','AG',1176),(4176,'Bacau','BC',1176),(4177,'Bihor','BH',1176),(4178,'Bistrita-Nasaud','BN',1176),(4179,'Boto\'ani','BT',1176),(4180,'Bra\'ov','BV',1176),(4181,'Braila','BR',1176),(4182,'Buzau','BZ',1176),(4183,'Caras-Severin','CS',1176),(4184,'Ca la ras\'i','CL',1176),(4185,'Cluj','CJ',1176),(4186,'Constant\'a','CT',1176),(4187,'Covasna','CV',1176),(4188,'Dambovit\'a','DB',1176),(4189,'Dolj','DJ',1176),(4190,'Galat\'i','GL',1176),(4191,'Giurgiu','GR',1176),(4192,'Gorj','GJ',1176),(4193,'Harghita','HR',1176),(4194,'Hunedoara','HD',1176),(4195,'Ialomit\'a','IL',1176),(4196,'Ias\'i','IS',1176),(4197,'Ilfov','IF',1176),(4198,'Maramures','MM',1176),(4199,'Mehedint\'i','MH',1176),(4200,'Mures','MS',1176),(4201,'Neamt','NT',1176),(4202,'Olt','OT',1176),(4203,'Prahova','PH',1176),(4204,'Satu Mare','SM',1176),(4205,'Sa laj','SJ',1176),(4206,'Sibiu','SB',1176),(4207,'Suceava','SV',1176),(4208,'Teleorman','TR',1176),(4209,'Timis','TM',1176),(4210,'Tulcea','TL',1176),(4211,'Vaslui','VS',1176),(4212,'Valcea','VL',1176),(4213,'Vrancea','VN',1176),(4214,'Adygeya, Respublika','AD',1177),(4215,'Altay, Respublika','AL',1177),(4216,'Bashkortostan, Respublika','BA',1177),(4217,'Buryatiya, Respublika','BU',1177),(4218,'Chechenskaya Respublika','CE',1177),(4219,'Chuvashskaya Respublika','CU',1177),(4220,'Dagestan, Respublika','DA',1177),(4221,'Ingushskaya Respublika','IN',1177),(4222,'Kabardino-Balkarskaya','KB',1177),(4223,'Kalmykiya, Respublika','KL',1177),(4224,'Karachayevo-Cherkesskaya Respublika','KC',1177),(4225,'Kareliya, Respublika','KR',1177),(4226,'Khakasiya, Respublika','KK',1177),(4227,'Komi, Respublika','KO',1177),(4228,'Mariy El, Respublika','ME',1177),(4229,'Mordoviya, Respublika','MO',1177),(4230,'Sakha, Respublika [Yakutiya]','SA',1177),(4231,'Severnaya Osetiya, Respublika','SE',1177),(4232,'Tatarstan, Respublika','TA',1177),(4233,'Tyva, Respublika [Tuva]','TY',1177),(4234,'Udmurtskaya Respublika','UD',1177),(4235,'Altayskiy kray','ALT',1177),(4236,'Khabarovskiy kray','KHA',1177),(4237,'Krasnodarskiy kray','KDA',1177),(4238,'Krasnoyarskiy kray','KYA',1177),(4239,'Primorskiy kray','PRI',1177),(4240,'Stavropol\'skiy kray','STA',1177),(4241,'Amurskaya oblast\'','AMU',1177),(4242,'Arkhangel\'skaya oblast\'','ARK',1177),(4243,'Astrakhanskaya oblast\'','AST',1177),(4244,'Belgorodskaya oblast\'','BEL',1177),(4245,'Bryanskaya oblast\'','BRY',1177),(4246,'Chelyabinskaya oblast\'','CHE',1177),(4247,'Zabaykalsky Krai\'','ZSK',1177),(4248,'Irkutskaya oblast\'','IRK',1177),(4249,'Ivanovskaya oblast\'','IVA',1177),(4250,'Kaliningradskaya oblast\'','KGD',1177),(4251,'Kaluzhskaya oblast\'','KLU',1177),(4252,'Kamchatka Krai\'','KAM',1177),(4253,'Kemerovskaya oblast\'','KEM',1177),(4254,'Kirovskaya oblast\'','KIR',1177),(4255,'Kostromskaya oblast\'','KOS',1177),(4256,'Kurganskaya oblast\'','KGN',1177),(4257,'Kurskaya oblast\'','KRS',1177),(4258,'Leningradskaya oblast\'','LEN',1177),(4259,'Lipetskaya oblast\'','LIP',1177),(4260,'Magadanskaya oblast\'','MAG',1177),(4261,'Moskovskaya oblast\'','MOS',1177),(4262,'Murmanskaya oblast\'','MUR',1177),(4263,'Nizhegorodskaya oblast\'','NIZ',1177),(4264,'Novgorodskaya oblast\'','NGR',1177),(4265,'Novosibirskaya oblast\'','NVS',1177),(4266,'Omskaya oblast\'','OMS',1177),(4267,'Orenburgskaya oblast\'','ORE',1177),(4268,'Orlovskaya oblast\'','ORL',1177),(4269,'Penzenskaya oblast\'','PNZ',1177),(4270,'Perm krai\'','PEK',1177),(4271,'Pskovskaya oblast\'','PSK',1177),(4272,'Rostovskaya oblast\'','ROS',1177),(4273,'Ryazanskaya oblast\'','RYA',1177),(4274,'Sakhalinskaya oblast\'','SAK',1177),(4275,'Samarskaya oblast\'','SAM',1177),(4276,'Saratovskaya oblast\'','SAR',1177),(4277,'Smolenskaya oblast\'','SMO',1177),(4278,'Sverdlovskaya oblast\'','SVE',1177),(4279,'Tambovskaya oblast\'','TAM',1177),(4280,'Tomskaya oblast\'','TOM',1177),(4281,'Tul\'skaya oblast\'','TUL',1177),(4282,'Tverskaya oblast\'','TVE',1177),(4283,'Tyumenskaya oblast\'','TYU',1177),(4284,'Ul\'yanovskaya oblast\'','ULY',1177),(4285,'Vladimirskaya oblast\'','VLA',1177),(4286,'Volgogradskaya oblast\'','VGG',1177),(4287,'Vologodskaya oblast\'','VLG',1177),(4288,'Voronezhskaya oblast\'','VOR',1177),(4289,'Yaroslavskaya oblast\'','YAR',1177),(4290,'Moskva','MOW',1177),(4291,'Sankt-Peterburg','SPE',1177),(4292,'Yevreyskaya avtonomnaya oblast\'','YEV',1177),(4294,'Chukotskiy avtonomnyy okrug','CHU',1177),(4296,'Khanty-Mansiyskiy avtonomnyy okrug','KHM',1177),(4299,'Nenetskiy avtonomnyy okrug','NEN',1177),(4302,'Yamalo-Nenetskiy avtonomnyy okrug','YAN',1177),(4303,'Butare','C',1178),(4304,'Byumba','I',1178),(4305,'Cyangugu','E',1178),(4306,'Gikongoro','D',1178),(4307,'Gisenyi','G',1178),(4308,'Gitarama','B',1178),(4309,'Kibungo','J',1178),(4310,'Kibuye','F',1178),(4311,'Kigali-Rural Kigali y\' Icyaro','K',1178),(4312,'Kigali-Ville Kigali Ngari','L',1178),(4313,'Mutara','M',1178),(4314,'Ruhengeri','H',1178),(4315,'Al Bahah','11',1187),(4316,'Al Hudud Ash Shamaliyah','08',1187),(4317,'Al Jawf','12',1187),(4318,'Al Madinah','03',1187),(4319,'Al Qasim','05',1187),(4320,'Ar Riyad','01',1187),(4321,'Asir','14',1187),(4322,'Ha\'il','06',1187),(4323,'Jlzan','09',1187),(4324,'Makkah','02',1187),(4325,'Najran','10',1187),(4326,'Tabuk','07',1187),(4327,'Capital Territory (Honiara)','CT',1194),(4328,'Guadalcanal','GU',1194),(4329,'Isabel','IS',1194),(4330,'Makira','MK',1194),(4331,'Malaita','ML',1194),(4332,'Temotu','TE',1194),(4333,'A\'ali an Nil','23',1200),(4334,'Al Bah al Ahmar','26',1200),(4335,'Al Buhayrat','18',1200),(4336,'Al Jazirah','07',1200),(4337,'Al Khartum','03',1200),(4338,'Al Qadarif','06',1200),(4339,'Al Wahdah','22',1200),(4340,'An Nil','04',1200),(4341,'An Nil al Abyaq','08',1200),(4342,'An Nil al Azraq','24',1200),(4343,'Ash Shamallyah','01',1200),(4344,'Bahr al Jabal','17',1200),(4345,'Gharb al Istiwa\'iyah','16',1200),(4346,'Gharb Ba~r al Ghazal','14',1200),(4347,'Gharb Darfur','12',1200),(4348,'Gharb Kurdufan','10',1200),(4349,'Janub Darfur','11',1200),(4350,'Janub Rurdufan','13',1200),(4351,'Jnqall','20',1200),(4352,'Kassala','05',1200),(4353,'Shamal Batr al Ghazal','15',1200),(4354,'Shamal Darfur','02',1200),(4355,'Shamal Kurdufan','09',1200),(4356,'Sharq al Istiwa\'iyah','19',1200),(4357,'Sinnar','25',1200),(4358,'Warab','21',1200),(4359,'Blekinge län','K',1204),(4360,'Dalarnas län','W',1204),(4361,'Gotlands län','I',1204),(4362,'Gävleborgs län','X',1204),(4363,'Hallands län','N',1204),(4364,'Jämtlands län','Z',1204),(4365,'Jönkopings län','F',1204),(4366,'Kalmar län','H',1204),(4367,'Kronobergs län','G',1204),(4368,'Norrbottens län','BD',1204),(4369,'Skåne län','M',1204),(4370,'Stockholms län','AB',1204),(4371,'Södermanlands län','D',1204),(4372,'Uppsala län','C',1204),(4373,'Värmlands län','S',1204),(4374,'Västerbottens län','AC',1204),(4375,'Västernorrlands län','Y',1204),(4376,'Västmanlands län','U',1204),(4377,'Västra Götalands län','Q',1204),(4378,'Örebro län','T',1204),(4379,'Östergötlands län','E',1204),(4380,'Saint Helena','SH',1180),(4381,'Ascension','AC',1180),(4382,'Tristan da Cunha','TA',1180),(4383,'Ajdovščina','001',1193),(4384,'Beltinci','002',1193),(4385,'Benedikt','148',1193),(4386,'Bistrica ob Sotli','149',1193),(4387,'Bled','003',1193),(4388,'Bloke','150',1193),(4389,'Bohinj','004',1193),(4390,'Borovnica','005',1193),(4391,'Bovec','006',1193),(4392,'Braslovče','151',1193),(4393,'Brda','007',1193),(4394,'Brezovica','008',1193),(4395,'Brežice','009',1193),(4396,'Cankova','152',1193),(4397,'Celje','011',1193),(4398,'Cerklje na Gorenjskem','012',1193),(4399,'Cerknica','013',1193),(4400,'Cerkno','014',1193),(4401,'Cerkvenjak','153',1193),(4402,'Črenšovci','015',1193),(4403,'Črna na Koroškem','016',1193),(4404,'Črnomelj','017',1193),(4405,'Destrnik','018',1193),(4406,'Divača','019',1193),(4407,'Dobje','154',1193),(4408,'Dobrepolje','020',1193),(4409,'Dobrna','155',1193),(4410,'Dobrova-Polhov Gradec','021',1193),(4411,'Dobrovnik','156',1193),(4412,'Dol pri Ljubljani','022',1193),(4413,'Dolenjske Toplice','157',1193),(4414,'Domžale','023',1193),(4415,'Dornava','024',1193),(4416,'Dravograd','025',1193),(4417,'Duplek','026',1193),(4418,'Gorenja vas-Poljane','027',1193),(4419,'Gorišnica','028',1193),(4420,'Gornja Radgona','029',1193),(4421,'Gornji Grad','030',1193),(4422,'Gornji Petrovci','031',1193),(4423,'Grad','158',1193),(4424,'Grosuplje','032',1193),(4425,'Hajdina','159',1193),(4426,'Hoče-Slivnica','160',1193),(4427,'Hodoš','161',1193),(4428,'Horjul','162',1193),(4429,'Hrastnik','034',1193),(4430,'Hrpelje-Kozina','035',1193),(4431,'Idrija','036',1193),(4432,'Ig','037',1193),(4433,'Ilirska Bistrica','038',1193),(4434,'Ivančna Gorica','039',1193),(4435,'Izola','040',1193),(4436,'Jesenice','041',1193),(4437,'Jezersko','163',1193),(4438,'Juršinci','042',1193),(4439,'Kamnik','043',1193),(4440,'Kanal','044',1193),(4441,'Kidričevo','045',1193),(4442,'Kobarid','046',1193),(4443,'Kobilje','047',1193),(4444,'Kočevje','048',1193),(4445,'Komen','049',1193),(4446,'Komenda','164',1193),(4447,'Koper','050',1193),(4448,'Kostel','165',1193),(4449,'Kozje','051',1193),(4450,'Kranj','052',1193),(4451,'Kranjska Gora','053',1193),(4452,'Križevci','166',1193),(4453,'Krško','054',1193),(4454,'Kungota','055',1193),(4455,'Kuzma','056',1193),(4456,'Laško','057',1193),(4457,'Lenart','058',1193),(4458,'Lendava','059',1193),(4459,'Litija','060',1193),(4460,'Ljubljana','061',1193),(4461,'Ljubno','062',1193),(4462,'Ljutomer','063',1193),(4463,'Logatec','064',1193),(4464,'Loška dolina','065',1193),(4465,'Loški Potok','066',1193),(4466,'Lovrenc na Pohorju','167',1193),(4467,'Luče','067',1193),(4468,'Lukovica','068',1193),(4469,'Majšperk','069',1193),(4470,'Maribor','070',1193),(4471,'Markovci','168',1193),(4472,'Medvode','071',1193),(4473,'Mengeš','072',1193),(4474,'Metlika','073',1193),(4475,'Mežica','074',1193),(4476,'Miklavž na Dravskem polju','169',1193),(4477,'Miren-Kostanjevica','075',1193),(4478,'Mirna Peč','170',1193),(4479,'Mislinja','076',1193),(4480,'Moravče','077',1193),(4481,'Moravske Toplice','078',1193),(4482,'Mozirje','079',1193),(4483,'Murska Sobota','080',1193),(4484,'Muta','081',1193),(4485,'Naklo','082',1193),(4486,'Nazarje','083',1193),(4487,'Nova Gorica','084',1193),(4488,'Novo mesto','085',1193),(4489,'Sveta Ana','181',1193),(4490,'Sveti Andraž v Slovenskih goricah','182',1193),(4491,'Sveti Jurij','116',1193),(4492,'Šalovci','033',1193),(4493,'Šempeter-Vrtojba','183',1193),(4494,'Šenčur','117',1193),(4495,'Šentilj','118',1193),(4496,'Šentjernej','119',1193),(4497,'Šentjur','120',1193),(4498,'Škocjan','121',1193),(4499,'Škofja Loka','122',1193),(4500,'Škofljica','123',1193),(4501,'Šmarje pri Jelšah','124',1193),(4502,'Šmartno ob Paki','125',1193),(4503,'Šmartno pri Litiji','194',1193),(4504,'Šoštanj','126',1193),(4505,'Štore','127',1193),(4506,'Tabor','184',1193),(4507,'Tišina','010',1193),(4508,'Tolmin','128',1193),(4509,'Trbovlje','129',1193),(4510,'Trebnje','130',1193),(4511,'Trnovska vas','185',1193),(4512,'Tržič','131',1193),(4513,'Trzin','186',1193),(4514,'Turnišče','132',1193),(4515,'Velenje','133',1193),(4516,'Velika Polana','187',1193),(4517,'Velike Lašče','134',1193),(4518,'Veržej','188',1193),(4519,'Videm','135',1193),(4520,'Vipava','136',1193),(4521,'Vitanje','137',1193),(4522,'Vojnik','138',1193),(4523,'Vransko','189',1193),(4524,'Vrhnika','140',1193),(4525,'Vuzenica','141',1193),(4526,'Zagorje ob Savi','142',1193),(4527,'Zavrč','143',1193),(4528,'Zreče','144',1193),(4529,'Žalec','190',1193),(4530,'Železniki','146',1193),(4531,'Žetale','191',1193),(4532,'Žiri','147',1193),(4533,'Žirovnica','192',1193),(4534,'Žužemberk','193',1193),(4535,'Banskobystrický kraj','BC',1192),(4536,'Bratislavský kraj','BL',1192),(4537,'Košický kraj','KI',1192),(4538,'Nitriansky kraj','NJ',1192),(4539,'Prešovský kraj','PV',1192),(4540,'Trenčiansky kraj','TC',1192),(4541,'Trnavský kraj','TA',1192),(4542,'Žilinský kraj','ZI',1192),(4543,'Western Area (Freetown)','W',1190),(4544,'Dakar','DK',1188),(4545,'Diourbel','DB',1188),(4546,'Fatick','FK',1188),(4547,'Kaolack','KL',1188),(4548,'Kolda','KD',1188),(4549,'Louga','LG',1188),(4550,'Matam','MT',1188),(4551,'Saint-Louis','SL',1188),(4552,'Tambacounda','TC',1188),(4553,'Thies','TH',1188),(4554,'Ziguinchor','ZG',1188),(4555,'Awdal','AW',1195),(4556,'Bakool','BK',1195),(4557,'Banaadir','BN',1195),(4558,'Bay','BY',1195),(4559,'Galguduud','GA',1195),(4560,'Gedo','GE',1195),(4561,'Hiirsan','HI',1195),(4562,'Jubbada Dhexe','JD',1195),(4563,'Jubbada Hoose','JH',1195),(4564,'Mudug','MU',1195),(4565,'Nugaal','NU',1195),(4566,'Saneag','SA',1195),(4567,'Shabeellaha Dhexe','SD',1195),(4568,'Shabeellaha Hoose','SH',1195),(4569,'Sool','SO',1195),(4570,'Togdheer','TO',1195),(4571,'Woqooyi Galbeed','WO',1195),(4572,'Brokopondo','BR',1201),(4573,'Commewijne','CM',1201),(4574,'Coronie','CR',1201),(4575,'Marowijne','MA',1201),(4576,'Nickerie','NI',1201),(4577,'Paramaribo','PM',1201),(4578,'Saramacca','SA',1201),(4579,'Sipaliwini','SI',1201),(4580,'Wanica','WA',1201),(4581,'Principe','P',1207),(4582,'Sao Tome','S',1207),(4583,'Ahuachapan','AH',1066),(4584,'Cabanas','CA',1066),(4585,'Cuscatlan','CU',1066),(4586,'Chalatenango','CH',1066),(4587,'Morazan','MO',1066),(4588,'San Miguel','SM',1066),(4589,'San Salvador','SS',1066),(4590,'Santa Ana','SA',1066),(4591,'San Vicente','SV',1066),(4592,'Sonsonate','SO',1066),(4593,'Usulutan','US',1066),(4594,'Al Hasakah','HA',1206),(4595,'Al Ladhiqiyah','LA',1206),(4596,'Al Qunaytirah','QU',1206),(4597,'Ar Raqqah','RA',1206),(4598,'As Suwayda\'','SU',1206),(4599,'Dar\'a','DR',1206),(4600,'Dayr az Zawr','DY',1206),(4601,'Dimashq','DI',1206),(4602,'Halab','HL',1206),(4603,'Hamah','HM',1206),(4604,'Jim\'','HI',1206),(4605,'Idlib','ID',1206),(4606,'Rif Dimashq','RD',1206),(4607,'Tarts','TA',1206),(4608,'Hhohho','HH',1203),(4609,'Lubombo','LU',1203),(4610,'Manzini','MA',1203),(4611,'Shiselweni','SH',1203),(4612,'Batha','BA',1043),(4613,'Biltine','BI',1043),(4614,'Borkou-Ennedi-Tibesti','BET',1043),(4615,'Chari-Baguirmi','CB',1043),(4616,'Guera','GR',1043),(4617,'Kanem','KA',1043),(4618,'Lac','LC',1043),(4619,'Logone-Occidental','LO',1043),(4620,'Logone-Oriental','LR',1043),(4621,'Mayo-Kebbi','MK',1043),(4622,'Moyen-Chari','MC',1043),(4623,'Ouaddai','OD',1043),(4624,'Salamat','SA',1043),(4625,'Tandjile','TA',1043),(4626,'Kara','K',1214),(4627,'Maritime (Region)','M',1214),(4628,'Savannes','S',1214),(4629,'Krung Thep Maha Nakhon Bangkok','10',1211),(4630,'Phatthaya','S',1211),(4631,'Amnat Charoen','37',1211),(4632,'Ang Thong','15',1211),(4633,'Buri Ram','31',1211),(4634,'Chachoengsao','24',1211),(4635,'Chai Nat','18',1211),(4636,'Chaiyaphum','36',1211),(4637,'Chanthaburi','22',1211),(4638,'Chiang Mai','50',1211),(4639,'Chiang Rai','57',1211),(4640,'Chon Buri','20',1211),(4641,'Chumphon','86',1211),(4642,'Kalasin','46',1211),(4643,'Kamphasng Phet','62',1211),(4644,'Kanchanaburi','71',1211),(4645,'Khon Kaen','40',1211),(4646,'Krabi','81',1211),(4647,'Lampang','52',1211),(4648,'Lamphun','51',1211),(4649,'Loei','42',1211),(4650,'Lop Buri','16',1211),(4651,'Mae Hong Son','58',1211),(4652,'Maha Sarakham','44',1211),(4653,'Mukdahan','49',1211),(4654,'Nakhon Nayok','26',1211),(4655,'Nakhon Pathom','73',1211),(4656,'Nakhon Phanom','48',1211),(4657,'Nakhon Ratchasima','30',1211),(4658,'Nakhon Sawan','60',1211),(4659,'Nakhon Si Thammarat','80',1211),(4660,'Nan','55',1211),(4661,'Narathiwat','96',1211),(4662,'Nong Bua Lam Phu','39',1211),(4663,'Nong Khai','43',1211),(4664,'Nonthaburi','12',1211),(4665,'Pathum Thani','13',1211),(4666,'Pattani','94',1211),(4667,'Phangnga','82',1211),(4668,'Phatthalung','93',1211),(4669,'Phayao','56',1211),(4670,'Phetchabun','67',1211),(4671,'Phetchaburi','76',1211),(4672,'Phichit','66',1211),(4673,'Phitsanulok','65',1211),(4674,'Phrae','54',1211),(4675,'Phra Nakhon Si Ayutthaya','14',1211),(4676,'Phuket','83',1211),(4677,'Prachin Buri','25',1211),(4678,'Prachuap Khiri Khan','77',1211),(4679,'Ranong','85',1211),(4680,'Ratchaburi','70',1211),(4681,'Rayong','21',1211),(4682,'Roi Et','45',1211),(4683,'Sa Kaeo','27',1211),(4684,'Sakon Nakhon','47',1211),(4685,'Samut Prakan','11',1211),(4686,'Samut Sakhon','74',1211),(4687,'Samut Songkhram','75',1211),(4688,'Saraburi','19',1211),(4689,'Satun','91',1211),(4690,'Sing Buri','17',1211),(4691,'Si Sa Ket','33',1211),(4692,'Songkhla','90',1211),(4693,'Sukhothai','64',1211),(4694,'Suphan Buri','72',1211),(4695,'Surat Thani','84',1211),(4696,'Surin','32',1211),(4697,'Tak','63',1211),(4698,'Trang','92',1211),(4699,'Trat','23',1211),(4700,'Ubon Ratchathani','34',1211),(4701,'Udon Thani','41',1211),(4702,'Uthai Thani','61',1211),(4703,'Uttaradit','53',1211),(4704,'Yala','95',1211),(4705,'Yasothon','35',1211),(4706,'Sughd','SU',1209),(4707,'Khatlon','KT',1209),(4708,'Gorno-Badakhshan','GB',1209),(4709,'Ahal','A',1220),(4710,'Balkan','B',1220),(4711,'Dasoguz','D',1220),(4712,'Lebap','L',1220),(4713,'Mary','M',1220),(4714,'Béja','31',1218),(4715,'Ben Arous','13',1218),(4716,'Bizerte','23',1218),(4717,'Gabès','81',1218),(4718,'Gafsa','71',1218),(4719,'Jendouba','32',1218),(4720,'Kairouan','41',1218),(4721,'Rasserine','42',1218),(4722,'Kebili','73',1218),(4723,'L\'Ariana','12',1218),(4724,'Le Ref','33',1218),(4725,'Mahdia','53',1218),(4726,'La Manouba','14',1218),(4727,'Medenine','82',1218),(4728,'Moneatir','52',1218),(4729,'Naboul','21',1218),(4730,'Sfax','61',1218),(4731,'Sidi Bouxid','43',1218),(4732,'Siliana','34',1218),(4733,'Sousse','51',1218),(4734,'Tataouine','83',1218),(4735,'Tozeur','72',1218),(4736,'Tunis','11',1218),(4737,'Zaghouan','22',1218),(4738,'Adana','01',1219),(4739,'Ad yaman','02',1219),(4740,'Afyon','03',1219),(4741,'Ag r','04',1219),(4742,'Aksaray','68',1219),(4743,'Amasya','05',1219),(4744,'Ankara','06',1219),(4745,'Antalya','07',1219),(4746,'Ardahan','75',1219),(4747,'Artvin','08',1219),(4748,'Aydin','09',1219),(4749,'Bal kesir','10',1219),(4750,'Bartin','74',1219),(4751,'Batman','72',1219),(4752,'Bayburt','69',1219),(4753,'Bilecik','11',1219),(4754,'Bingol','12',1219),(4755,'Bitlis','13',1219),(4756,'Bolu','14',1219),(4757,'Burdur','15',1219),(4758,'Bursa','16',1219),(4759,'Canakkale','17',1219),(4760,'Cankir','18',1219),(4761,'Corum','19',1219),(4762,'Denizli','20',1219),(4763,'Diyarbakir','21',1219),(4764,'Duzce','81',1219),(4765,'Edirne','22',1219),(4766,'Elazig','23',1219),(4767,'Erzincan','24',1219),(4768,'Erzurum','25',1219),(4769,'Eskis\'ehir','26',1219),(4770,'Gaziantep','27',1219),(4771,'Giresun','28',1219),(4772,'Gms\'hane','29',1219),(4773,'Hakkari','30',1219),(4774,'Hatay','31',1219),(4775,'Igidir','76',1219),(4776,'Isparta','32',1219),(4777,'Icel','33',1219),(4778,'Istanbul','34',1219),(4779,'Izmir','35',1219),(4780,'Kahramanmaras','46',1219),(4781,'Karabk','78',1219),(4782,'Karaman','70',1219),(4783,'Kars','36',1219),(4784,'Kastamonu','37',1219),(4785,'Kayseri','38',1219),(4786,'Kirikkale','71',1219),(4787,'Kirklareli','39',1219),(4788,'Kirs\'ehir','40',1219),(4789,'Kilis','79',1219),(4790,'Kocaeli','41',1219),(4791,'Konya','42',1219),(4792,'Ktahya','43',1219),(4793,'Malatya','44',1219),(4794,'Manisa','45',1219),(4795,'Mardin','47',1219),(4796,'Mugila','48',1219),(4797,'Mus','49',1219),(4798,'Nevs\'ehir','50',1219),(4799,'Nigide','51',1219),(4800,'Ordu','52',1219),(4801,'Osmaniye','80',1219),(4802,'Rize','53',1219),(4803,'Sakarya','54',1219),(4804,'Samsun','55',1219),(4805,'Siirt','56',1219),(4806,'Sinop','57',1219),(4807,'Sivas','58',1219),(4808,'S\'anliurfa','63',1219),(4809,'S\'rnak','73',1219),(4810,'Tekirdag','59',1219),(4811,'Tokat','60',1219),(4812,'Trabzon','61',1219),(4813,'Tunceli','62',1219),(4814,'Us\'ak','64',1219),(4815,'Van','65',1219),(4816,'Yalova','77',1219),(4817,'Yozgat','66',1219),(4818,'Zonguldak','67',1219),(4819,'Couva-Tabaquite-Talparo','CTT',1217),(4820,'Diego Martin','DMN',1217),(4821,'Eastern Tobago','ETO',1217),(4822,'Penal-Debe','PED',1217),(4823,'Princes Town','PRT',1217),(4824,'Rio Claro-Mayaro','RCM',1217),(4825,'Sangre Grande','SGE',1217),(4826,'San Juan-Laventille','SJL',1217),(4827,'Siparia','SIP',1217),(4828,'Tunapuna-Piarco','TUP',1217),(4829,'Western Tobago','WTO',1217),(4830,'Arima','ARI',1217),(4831,'Chaguanas','CHA',1217),(4832,'Point Fortin','PTF',1217),(4833,'Port of Spain','POS',1217),(4834,'San Fernando','SFO',1217),(4835,'Aileu','AL',1063),(4836,'Ainaro','AN',1063),(4837,'Bacucau','BA',1063),(4838,'Bobonaro','BO',1063),(4839,'Cova Lima','CO',1063),(4840,'Dili','DI',1063),(4841,'Ermera','ER',1063),(4842,'Laulem','LA',1063),(4843,'Liquica','LI',1063),(4844,'Manatuto','MT',1063),(4845,'Manafahi','MF',1063),(4846,'Oecussi','OE',1063),(4847,'Viqueque','VI',1063),(4848,'Changhua County','CHA',1208),(4849,'Chiayi County','CYQ',1208),(4850,'Hsinchu County','HSQ',1208),(4851,'Hualien County','HUA',1208),(4852,'Ilan County','ILA',1208),(4853,'Kaohsiung County','KHQ',1208),(4854,'Miaoli County','MIA',1208),(4855,'Nantou County','NAN',1208),(4856,'Penghu County','PEN',1208),(4857,'Pingtung County','PIF',1208),(4858,'Taichung County','TXQ',1208),(4859,'Tainan County','TNQ',1208),(4860,'Taipei County','TPQ',1208),(4861,'Taitung County','TTT',1208),(4862,'Taoyuan County','TAO',1208),(4863,'Yunlin Conuty','YUN',1208),(4864,'Keelung City','KEE',1208),(4865,'Arusha','01',1210),(4866,'Dar-es-Salaam','02',1210),(4867,'Dodoma','03',1210),(4868,'Iringa','04',1210),(4869,'Kagera','05',1210),(4870,'Kaskazini Pemba','06',1210),(4871,'Kaskazini Unguja','07',1210),(4872,'Xigoma','08',1210),(4873,'Kilimanjaro','09',1210),(4874,'Rusini Pemba','10',1210),(4875,'Kusini Unguja','11',1210),(4876,'Lindi','12',1210),(4877,'Manyara','26',1210),(4878,'Mara','13',1210),(4879,'Mbeya','14',1210),(4880,'Mjini Magharibi','15',1210),(4881,'Morogoro','16',1210),(4882,'Mtwara','17',1210),(4883,'Pwani','19',1210),(4884,'Rukwa','20',1210),(4885,'Ruvuma','21',1210),(4886,'Shinyanga','22',1210),(4887,'Singida','23',1210),(4888,'Tabora','24',1210),(4889,'Tanga','25',1210),(4890,'Cherkas\'ka Oblast\'','71',1224),(4891,'Chernihivs\'ka Oblast\'','74',1224),(4892,'Chernivets\'ka Oblast\'','77',1224),(4893,'Dnipropetrovs\'ka Oblast\'','12',1224),(4894,'Donets\'ka Oblast\'','14',1224),(4895,'Ivano-Frankivs\'ka Oblast\'','26',1224),(4896,'Kharkivs\'ka Oblast\'','63',1224),(4897,'Khersons\'ka Oblast\'','65',1224),(4898,'Khmel\'nyts\'ka Oblast\'','68',1224),(4899,'Kirovohrads\'ka Oblast\'','35',1224),(4900,'Kyivs\'ka Oblast\'','32',1224),(4901,'Luhans\'ka Oblast\'','09',1224),(4902,'L\'vivs\'ka Oblast\'','46',1224),(4903,'Mykolaivs\'ka Oblast\'','48',1224),(4904,'Odes \'ka Oblast\'','51',1224),(4905,'Poltavs\'ka Oblast\'','53',1224),(4906,'Rivnens\'ka Oblast\'','56',1224),(4907,'Sums \'ka Oblast\'','59',1224),(4908,'Ternopil\'s\'ka Oblast\'','61',1224),(4909,'Vinnyts\'ka Oblast\'','05',1224),(4910,'Volyos\'ka Oblast\'','07',1224),(4911,'Zakarpats\'ka Oblast\'','21',1224),(4912,'Zaporiz\'ka Oblast\'','23',1224),(4913,'Zhytomyrs\'ka Oblast\'','18',1224),(4914,'Respublika Krym','43',1224),(4915,'Kyiv','30',1224),(4916,'Sevastopol','40',1224),(4917,'Adjumani','301',1223),(4918,'Apac','302',1223),(4919,'Arua','303',1223),(4920,'Bugiri','201',1223),(4921,'Bundibugyo','401',1223),(4922,'Bushenyi','402',1223),(4923,'Busia','202',1223),(4924,'Gulu','304',1223),(4925,'Hoima','403',1223),(4926,'Iganga','203',1223),(4927,'Jinja','204',1223),(4928,'Kabale','404',1223),(4929,'Kabarole','405',1223),(4930,'Kaberamaido','213',1223),(4931,'Kalangala','101',1223),(4932,'Kampala','102',1223),(4933,'Kamuli','205',1223),(4934,'Kamwenge','413',1223),(4935,'Kanungu','414',1223),(4936,'Kapchorwa','206',1223),(4937,'Kasese','406',1223),(4938,'Katakwi','207',1223),(4939,'Kayunga','112',1223),(4940,'Kibaale','407',1223),(4941,'Kiboga','103',1223),(4942,'Kisoro','408',1223),(4943,'Kitgum','305',1223),(4944,'Kotido','306',1223),(4945,'Kumi','208',1223),(4946,'Kyenjojo','415',1223),(4947,'Lira','307',1223),(4948,'Luwero','104',1223),(4949,'Masaka','105',1223),(4950,'Masindi','409',1223),(4951,'Mayuge','214',1223),(4952,'Mbale','209',1223),(4953,'Mbarara','410',1223),(4954,'Moroto','308',1223),(4955,'Moyo','309',1223),(4956,'Mpigi','106',1223),(4957,'Mubende','107',1223),(4958,'Mukono','108',1223),(4959,'Nakapiripirit','311',1223),(4960,'Nakasongola','109',1223),(4961,'Nebbi','310',1223),(4962,'Ntungamo','411',1223),(4963,'Pader','312',1223),(4964,'Pallisa','210',1223),(4965,'Rakai','110',1223),(4966,'Rukungiri','412',1223),(4967,'Sembabule','111',1223),(4968,'Sironko','215',1223),(4969,'Soroti','211',1223),(4970,'Tororo','212',1223),(4971,'Wakiso','113',1223),(4972,'Yumbe','313',1223),(4973,'Baker Island','81',1227),(4974,'Howland Island','84',1227),(4975,'Jarvis Island','86',1227),(4976,'Johnston Atoll','67',1227),(4977,'Kingman Reef','89',1227),(4978,'Midway Islands','71',1227),(4979,'Navassa Island','76',1227),(4980,'Palmyra Atoll','95',1227),(4981,'Wake Island','79',1227),(4982,'Artigsa','AR',1229),(4983,'Canelones','CA',1229),(4984,'Cerro Largo','CL',1229),(4985,'Colonia','CO',1229),(4986,'Durazno','DU',1229),(4987,'Flores','FS',1229),(4988,'Lavalleja','LA',1229),(4989,'Maldonado','MA',1229),(4990,'Montevideo','MO',1229),(4991,'Paysandu','PA',1229),(4992,'Rivera','RV',1229),(4993,'Rocha','RO',1229),(4994,'Salto','SA',1229),(4995,'Soriano','SO',1229),(4996,'Tacuarembo','TA',1229),(4997,'Treinta y Tres','TT',1229),(4998,'Toshkent (city)','TK',1230),(4999,'Qoraqalpogiston Respublikasi','QR',1230),(5000,'Andijon','AN',1230),(5001,'Buxoro','BU',1230),(5002,'Farg\'ona','FA',1230),(5003,'Jizzax','JI',1230),(5004,'Khorazm','KH',1230),(5005,'Namangan','NG',1230),(5006,'Navoiy','NW',1230),(5007,'Qashqadaryo','QA',1230),(5008,'Samarqand','SA',1230),(5009,'Sirdaryo','SI',1230),(5010,'Surxondaryo','SU',1230),(5011,'Toshkent','TO',1230),(5012,'Xorazm','XO',1230),(5013,'Distrito Federal','A',1232),(5014,'Anzoategui','B',1232),(5015,'Apure','C',1232),(5016,'Aragua','D',1232),(5017,'Barinas','E',1232),(5018,'Carabobo','G',1232),(5019,'Cojedes','H',1232),(5020,'Falcon','I',1232),(5021,'Guarico','J',1232),(5022,'Lara','K',1232),(5023,'Merida','L',1232),(5024,'Miranda','M',1232),(5025,'Monagas','N',1232),(5026,'Nueva Esparta','O',1232),(5027,'Portuguesa','P',1232),(5028,'Tachira','S',1232),(5029,'Trujillo','T',1232),(5030,'Vargas','X',1232),(5031,'Yaracuy','U',1232),(5032,'Zulia','V',1232),(5033,'Delta Amacuro','Y',1232),(5034,'Dependencias Federales','W',1232),(5035,'An Giang','44',1233),(5036,'Ba Ria - Vung Tau','43',1233),(5037,'Bac Can','53',1233),(5038,'Bac Giang','54',1233),(5039,'Bac Lieu','55',1233),(5040,'Bac Ninh','56',1233),(5041,'Ben Tre','50',1233),(5042,'Binh Dinh','31',1233),(5043,'Binh Duong','57',1233),(5044,'Binh Phuoc','58',1233),(5045,'Binh Thuan','40',1233),(5046,'Ca Mau','59',1233),(5047,'Can Tho','48',1233),(5048,'Cao Bang','04',1233),(5049,'Da Nang, thanh pho','60',1233),(5050,'Dong Nai','39',1233),(5051,'Dong Thap','45',1233),(5052,'Gia Lai','30',1233),(5053,'Ha Giang','03',1233),(5054,'Ha Nam','63',1233),(5055,'Ha Noi, thu do','64',1233),(5056,'Ha Tay','15',1233),(5057,'Ha Tinh','23',1233),(5058,'Hai Duong','61',1233),(5059,'Hai Phong, thanh pho','62',1233),(5060,'Hoa Binh','14',1233),(5061,'Ho Chi Minh, thanh pho [Sai Gon]','65',1233),(5062,'Hung Yen','66',1233),(5063,'Khanh Hoa','34',1233),(5064,'Kien Giang','47',1233),(5065,'Kon Tum','28',1233),(5066,'Lai Chau','01',1233),(5067,'Lam Dong','35',1233),(5068,'Lang Son','09',1233),(5069,'Lao Cai','02',1233),(5070,'Long An','41',1233),(5071,'Nam Dinh','67',1233),(5072,'Nghe An','22',1233),(5073,'Ninh Binh','18',1233),(5074,'Ninh Thuan','36',1233),(5075,'Phu Tho','68',1233),(5076,'Phu Yen','32',1233),(5077,'Quang Binh','24',1233),(5078,'Quang Nam','27',1233),(5079,'Quang Ngai','29',1233),(5080,'Quang Ninh','13',1233),(5081,'Quang Tri','25',1233),(5082,'Soc Trang','52',1233),(5083,'Son La','05',1233),(5084,'Tay Ninh','37',1233),(5085,'Thai Binh','20',1233),(5086,'Thai Nguyen','69',1233),(5087,'Thanh Hoa','21',1233),(5088,'Thua Thien-Hue','26',1233),(5089,'Tien Giang','46',1233),(5090,'Tra Vinh','51',1233),(5091,'Tuyen Quang','07',1233),(5092,'Vinh Long','49',1233),(5093,'Vinh Phuc','70',1233),(5094,'Yen Bai','06',1233),(5095,'Malampa','MAP',1231),(5096,'Penama','PAM',1231),(5097,'Sanma','SAM',1231),(5098,'Shefa','SEE',1231),(5099,'Tafea','TAE',1231),(5100,'Torba','TOB',1231),(5101,'A\'ana','AA',1185),(5102,'Aiga-i-le-Tai','AL',1185),(5103,'Atua','AT',1185),(5104,'Fa\'aaaleleaga','FA',1185),(5105,'Gaga\'emauga','GE',1185),(5106,'Gagaifomauga','GI',1185),(5107,'Palauli','PA',1185),(5108,'Satupa\'itea','SA',1185),(5109,'Tuamasaga','TU',1185),(5110,'Va\'a-o-Fonoti','VF',1185),(5111,'Vaisigano','VS',1185),(5112,'Crna Gora','CG',1243),(5113,'Srbija','SR',1242),(5114,'Kosovo-Metohija','KM',1242),(5115,'Vojvodina','VO',1242),(5116,'Abyan','AB',1237),(5117,'Adan','AD',1237),(5118,'Ad Dali','DA',1237),(5119,'Al Bayda\'','BA',1237),(5120,'Al Hudaydah','MU',1237),(5121,'Al Mahrah','MR',1237),(5122,'Al Mahwit','MW',1237),(5123,'Amran','AM',1237),(5124,'Dhamar','DH',1237),(5125,'Hadramawt','HD',1237),(5126,'Hajjah','HJ',1237),(5127,'Ibb','IB',1237),(5128,'Lahij','LA',1237),(5129,'Ma\'rib','MA',1237),(5130,'Sa\'dah','SD',1237),(5131,'San\'a\'','SN',1237),(5132,'Shabwah','SH',1237),(5133,'Ta\'izz','TA',1237),(5134,'Eastern Cape','EC',1196),(5135,'Free State','FS',1196),(5136,'Gauteng','GT',1196),(5137,'Kwazulu-Natal','NL',1196),(5138,'Mpumalanga','MP',1196),(5139,'Northern Cape','NC',1196),(5140,'Limpopo','NP',1196),(5141,'Western Cape','WC',1196),(5142,'Copperbelt','08',1239),(5143,'Luapula','04',1239),(5144,'Lusaka','09',1239),(5145,'North-Western','06',1239),(5146,'Bulawayo','BU',1240),(5147,'Harare','HA',1240),(5148,'Manicaland','MA',1240),(5149,'Mashonaland Central','MC',1240),(5150,'Mashonaland East','ME',1240),(5151,'Mashonaland West','MW',1240),(5152,'Masvingo','MV',1240),(5153,'Matabeleland North','MN',1240),(5154,'Matabeleland South','MS',1240),(5155,'Midlands','MI',1240),(5156,'South Karelia','SK',1075),(5157,'South Ostrobothnia','SO',1075),(5158,'Etelä-Savo','ES',1075),(5159,'Häme','HH',1075),(5160,'Itä-Uusimaa','IU',1075),(5161,'Kainuu','KA',1075),(5162,'Central Ostrobothnia','CO',1075),(5163,'Central Finland','CF',1075),(5164,'Kymenlaakso','KY',1075),(5165,'Lapland','LA',1075),(5166,'Tampere Region','TR',1075),(5167,'Ostrobothnia','OB',1075),(5168,'North Karelia','NK',1075),(5169,'Northern Ostrobothnia','NO',1075),(5170,'Northern Savo','NS',1075),(5171,'Päijät-Häme','PH',1075),(5172,'Satakunta','SK',1075),(5173,'Uusimaa','UM',1075),(5174,'South-West Finland','SW',1075),(5175,'Åland','AL',1075),(5176,'Limburg','LI',1152),(5177,'Central and Western','CW',1098),(5178,'Eastern','EA',1098),(5179,'Southern','SO',1098),(5180,'Wan Chai','WC',1098),(5181,'Kowloon City','KC',1098),(5182,'Kwun Tong','KU',1098),(5183,'Sham Shui Po','SS',1098),(5184,'Wong Tai Sin','WT',1098),(5185,'Yau Tsim Mong','YT',1098),(5186,'Islands','IS',1098),(5187,'Kwai Tsing','KI',1098),(5188,'North','NO',1098),(5189,'Sai Kung','SK',1098),(5190,'Sha Tin','ST',1098),(5191,'Tai Po','TP',1098),(5192,'Tsuen Wan','TW',1098),(5193,'Tuen Mun','TM',1098),(5194,'Yuen Long','YL',1098),(5195,'Manchester','MR',1108),(5196,'Al Manāmah (Al ‘Āşimah)','13',1016),(5197,'Al Janūbīyah','14',1016),(5199,'Al Wusţá','16',1016),(5200,'Ash Shamālīyah','17',1016),(5201,'Jenin','_A',1165),(5202,'Tubas','_B',1165),(5203,'Tulkarm','_C',1165),(5204,'Nablus','_D',1165),(5205,'Qalqilya','_E',1165),(5206,'Salfit','_F',1165),(5207,'Ramallah and Al-Bireh','_G',1165),(5208,'Jericho','_H',1165),(5209,'Jerusalem','_I',1165),(5210,'Bethlehem','_J',1165),(5211,'Hebron','_K',1165),(5212,'North Gaza','_L',1165),(5213,'Gaza','_M',1165),(5214,'Deir el-Balah','_N',1165),(5215,'Khan Yunis','_O',1165),(5216,'Rafah','_P',1165),(5217,'Brussels','BRU',1020),(5218,'Distrito Federal','DIF',1140),(5219,'Taichung City','TXG',1208),(5220,'Kaohsiung City','KHH',1208),(5221,'Taipei City','TPE',1208),(5222,'Chiayi City','CYI',1208),(5223,'Hsinchu City','HSZ',1208),(5224,'Tainan City','TNN',1208),(9000,'North West','NW',1196),(9986,'Tyne and Wear','TWR',1226),(9988,'Greater Manchester','GTM',1226),(9989,'Co Tyrone','TYR',1226),(9990,'West Yorkshire','WYK',1226),(9991,'South Yorkshire','SYK',1226),(9992,'Merseyside','MSY',1226),(9993,'Berkshire','BRK',1226),(9994,'West Midlands','WMD',1226),(9998,'West Glamorgan','WGM',1226),(9999,'London','LON',1226),(10000,'Carbonia-Iglesias','CI',1107),(10001,'Olbia-Tempio','OT',1107),(10002,'Medio Campidano','VS',1107),(10003,'Ogliastra','OG',1107),(10009,'Jura','39',1076),(10010,'Barletta-Andria-Trani','Bar',1107),(10011,'Fermo','Fer',1107),(10012,'Monza e Brianza','Mon',1107),(10013,'Clwyd','CWD',1226),(10014,'Dyfed','DFD',1226),(10015,'South Glamorgan','SGM',1226),(10016,'Artibonite','AR',1094),(10017,'Centre','CE',1094),(10018,'Nippes','NI',1094),(10019,'Nord','ND',1094),(10020,'La Rioja','F',1010),(10021,'Andorra la Vella','07',1005),(10022,'Canillo','02',1005),(10023,'Encamp','03',1005),(10024,'Escaldes-Engordany','08',1005),(10025,'La Massana','04',1005),(10026,'Ordino','05',1005),(10027,'Sant Julia de Loria','06',1005),(10028,'Abaco Islands','AB',1212),(10029,'Andros Island','AN',1212),(10030,'Berry Islands','BR',1212),(10031,'Eleuthera','EL',1212),(10032,'Grand Bahama','GB',1212),(10033,'Rum Cay','RC',1212),(10034,'San Salvador Island','SS',1212),(10035,'Kongo central','01',1050),(10036,'Kwango','02',1050),(10037,'Kwilu','03',1050),(10038,'Mai-Ndombe','04',1050),(10039,'Kasai','05',1050),(10040,'Lulua','06',1050),(10041,'Lomami','07',1050),(10042,'Sankuru','08',1050),(10043,'Ituri','09',1050),(10044,'Haut-Uele','10',1050),(10045,'Tshopo','11',1050),(10046,'Bas-Uele','12',1050),(10047,'Nord-Ubangi','13',1050),(10048,'Mongala','14',1050),(10049,'Sud-Ubangi','15',1050),(10050,'Tshuapa','16',1050),(10051,'Haut-Lomami','17',1050),(10052,'Lualaba','18',1050),(10053,'Haut-Katanga','19',1050),(10054,'Tanganyika','20',1050),(10055,'Toledo','TO',1198),(10056,'Córdoba','CO',1198),(10057,'Metropolitan Manila','MNL',1170),(10058,'La Paz','LP',1097),(10059,'Yinchuan','YN',1045),(10060,'Shizuishan','SZ',1045),(10061,'Wuzhong','WZ',1045),(10062,'Guyuan','GY',1045),(10063,'Zhongwei','ZW',1045),(10064,'Luxembourg','L',1126),(10065,'Aizkraukles novads','002',1119),(10066,'Jaunjelgavas novads','038',1119),(10067,'Pļaviņu novads','072',1119),(10068,'Kokneses novads','046',1119),(10069,'Neretas novads','065',1119),(10070,'Skrīveru novads','092',1119),(10071,'Alūksnes novads','007',1119),(10072,'Apes novads','009',1119),(10073,'Balvu novads','015',1119),(10074,'Viļakas novads','108',1119),(10075,'Baltinavas novads','014',1119),(10076,'Rugāju novads','082',1119),(10077,'Bauskas novads','016',1119),(10078,'Iecavas novads','034',1119),(10079,'Rundāles novads','083',1119),(10080,'Vecumnieku novads','105',1119),(10081,'Cēsu novads','022',1119),(10082,'Līgatnes novads','055',1119),(10083,'Amatas novads','008',1119),(10084,'Jaunpiebalgas novads','039',1119),(10085,'Priekuļu novads','075',1119),(10086,'Pārgaujas novads','070',1119),(10087,'Raunas novads','076',1119),(10088,'Vecpiebalgas novads','104',1119),(10089,'Daugavpils novads','025',1119),(10090,'Ilūkstes novads','036',1119),(10091,'Dobeles novads','026',1119),(10092,'Auces novads','010',1119),(10093,'Tērvetes novads','098',1119),(10094,'Gulbenes novads','033',1119),(10095,'Jelgavas novads','041',1119),(10096,'Ozolnieku novads','069',1119),(10097,'Jēkabpils novads','042',1119),(10098,'Aknīstes novads','004',1119),(10099,'Viesītes novads','107',1119),(10100,'Krustpils novads','049',1119),(10101,'Salas novads','085',1119),(10102,'Krāslavas novads','047',1119),(10103,'Dagdas novads','024',1119),(10104,'Aglonas novads','001',1119),(10105,'Kuldīgas novads','050',1119),(10106,'Skrundas novads','093',1119),(10107,'Alsungas novads','006',1119),(10108,'Aizputes novads','003',1119),(10109,'Durbes novads','028',1119),(10110,'Grobiņas novads','032',1119),(10111,'Pāvilostas novads','071',1119),(10112,'Priekules novads','074',1119),(10113,'Nīcas novads','066',1119),(10114,'Rucavas novads','081',1119),(10115,'Vaiņodes novads','100',1119),(10116,'Limbažu novads','054',1119),(10117,'Alojas novads','005',1119),(10118,'Salacgrīvas novads','086',1119),(10119,'Ludzas novads','058',1119),(10120,'Kārsavas novads','044',1119),(10121,'Zilupes novads','110',1119),(10122,'Ciblas novads','023',1119),(10123,'Madonas novads','059',1119),(10124,'Cesvaines novads','021',1119),(10125,'Lubānas novads','057',1119),(10126,'Varakļānu novads','102',1119),(10127,'Ērgļu novads','030',1119),(10128,'Ogres novads','067',1119),(10129,'Ikšķiles novads','035',1119),(10130,'Ķeguma novads','051',1119),(10131,'Lielvārdes novads','053',1119),(10132,'Preiļu novads','073',1119),(10133,'Līvānu novads','056',1119),(10134,'Riebiņu novads','078',1119),(10135,'Vārkavas novads','103',1119),(10136,'Rēzeknes novads','077',1119),(10137,'Viļānu novads','109',1119),(10138,'Baldones novads','013',1119),(10139,'Ķekavas novads','052',1119),(10140,'Olaines novads','068',1119),(10141,'Salaspils novads','087',1119),(10142,'Saulkrastu novads','089',1119),(10143,'Siguldas novads','091',1119),(10144,'Inčukalna novads','037',1119),(10145,'Ādažu novads','011',1119),(10146,'Babītes novads','012',1119),(10147,'Carnikavas novads','020',1119),(10148,'Garkalnes novads','031',1119),(10149,'Krimuldas novads','048',1119),(10150,'Mālpils novads','061',1119),(10151,'Mārupes novads','062',1119),(10152,'Ropažu novads','080',1119),(10153,'Sējas novads','090',1119),(10154,'Stopiņu novads','095',1119),(10155,'Saldus novads','088',1119),(10156,'Brocēnu novads','018',1119),(10157,'Talsu novads','097',1119),(10158,'Dundagas novads','027',1119),(10159,'Mērsraga novads','063',1119),(10160,'Rojas novads','079',1119),(10161,'Tukuma novads','099',1119),(10162,'Kandavas novads','043',1119),(10163,'Engures novads','029',1119),(10164,'Jaunpils novads','040',1119),(10165,'Valkas novads','101',1119),(10166,'Smiltenes novads','094',1119),(10167,'Strenču novads','096',1119),(10168,'Kocēnu novads','045',1119),(10169,'Mazsalacas novads','060',1119),(10170,'Rūjienas novads','084',1119),(10171,'Beverīnas novads','017',1119),(10172,'Burtnieku novads','019',1119),(10173,'Naukšēnu novads','064',1119),(10174,'Ventspils novads','106',1119),(10175,'Jēkabpils','JKB',1119),(10176,'Valmiera','VMR',1119),(10177,'Florida','FL',1229),(10178,'Rio Negro','RN',1229),(10179,'San Jose','SJ',1229),(10180,'Plateau','PL',1157),(10181,'Pieria','61',1085),(10182,'Los Rios','LR',1044),(10183,'Arica y Parinacota','AP',1044),(10184,'Amazonas','AMA',1169),(10185,'Kalimantan Tengah','KT',1102),(10186,'Sulawesi Barat','SR',1102),(10187,'Kalimantan Utara','KU',1102),(10188,'Ankaran','86',1193),(10189,'Apače','87',1193),(10190,'Cirkulane','88',1193),(10191,'Gorje','89',1193),(10192,'Kostanjevica na Krki','90',1193),(10193,'Log-Dragomer','91',1193),(10194,'Makole','92',1193),(10195,'Mirna','93',1193),(10196,'Mokronog-Trebelno','94',1193),(10197,'Odranci','95',1193),(10198,'Oplotnica','96',1193),(10199,'Ormož','97',1193),(10200,'Osilnica','98',1193),(10201,'Pesnica','99',1193),(10202,'Piran','100',1193),(10203,'Pivka','101',1193),(10204,'Podčetrtek','102',1193),(10205,'Podlehnik','103',1193),(10206,'Podvelka','104',1193),(10207,'Poljčane','105',1193),(10208,'Polzela','106',1193),(10209,'Postojna','107',1193),(10210,'Prebold','108',1193),(10211,'Preddvor','109',1193),(10212,'Prevalje','110',1193),(10213,'Ptuj','111',1193),(10214,'Puconci','112',1193),(10215,'Rače-Fram','113',1193),(10216,'Radeče','114',1193),(10217,'Radenci','115',1193),(10218,'Radlje ob Dravi','139',1193),(10219,'Radovljica','145',1193),(10220,'Ravne na Koroškem','171',1193),(10221,'Razkrižje','172',1193),(10222,'Rečica ob Savinji','173',1193),(10223,'Renče-Vogrsko','174',1193),(10224,'Ribnica','175',1193),(10225,'Ribnica na Pohorju','176',1193),(10226,'Rogaška Slatina','177',1193),(10227,'Rogašovci','178',1193),(10228,'Rogatec','179',1193),(10229,'Ruše','180',1193),(10230,'Selnica ob Dravi','195',1193),(10231,'Semič','196',1193),(10232,'Šentrupert','197',1193),(10233,'Sevnica','198',1193),(10234,'Sežana','199',1193),(10235,'Slovenj Gradec','200',1193),(10236,'Slovenska Bistrica','201',1193),(10237,'Slovenske Konjice','202',1193),(10238,'Šmarješke Toplice','203',1193),(10239,'Sodražica','204',1193),(10240,'Solčava','205',1193),(10241,'Središče ob Dravi','206',1193),(10242,'Starše','207',1193),(10243,'Straža','208',1193),(10244,'Sveta Trojica v Slovenskih goricah','209',1193),(10245,'Sveti Jurij v Slovenskih goricah','210',1193),(10246,'Sveti Tomaž','211',1193),(10247,'Vodice','212',1193),(10248,'Abkhazia','AB',1081),(10249,'Adjara','AJ',1081),(10250,'Tbilisi','TB',1081),(10251,'Guria','GU',1081),(10252,'Imereti','IM',1081),(10253,'Kakheti','KA',1081),(10254,'Kvemo Kartli','KK',1081),(10255,'Mtskheta-Mtianeti','MM',1081),(10256,'Racha-Lechkhumi and Kvemo Svaneti','RL',1081),(10257,'Samegrelo-Zemo Svaneti','SZ',1081),(10258,'Samtskhe-Javakheti','SJ',1081),(10259,'Shida Kartli','SK',1081),(10260,'Central','C',1074),(10261,'Punjab','PB',1163),(10262,'La Libertad','LI',1066),(10263,'La Paz','PA',1066),(10264,'La Union','UN',1066),(10265,'Littoral','LT',1038),(10266,'Nord-Ouest','NW',1038),(10267,'Telangana','TG',1101),(10268,'Ash Sharqiyah','04',1187),(10269,'Guadeloupe','GP',1076),(10270,'Martinique','MQ',1076),(10271,'Guyane','GF',1076),(10272,'La Réunion','RE',1076),(10273,'Mayotte','YT',1076),(10274,'Baringo','01',1112),(10275,'Bomet','02',1112),(10276,'Bungoma','03',1112),(10277,'Busia','04',1112),(10278,'Elgeyo/Marakwet','05',1112),(10279,'Embu','06',1112),(10280,'Garissa','07',1112),(10281,'Homa Bay','08',1112),(10282,'Isiolo','09',1112),(10283,'Kajiado','10',1112),(10284,'Kakamega','11',1112),(10285,'Kericho','12',1112),(10286,'Kiambu','13',1112),(10287,'Kilifi','14',1112),(10288,'Kirinyaga','15',1112),(10289,'Kisii','16',1112),(10290,'Kisumu','17',1112),(10291,'Kitui','18',1112),(10292,'Kwale','19',1112),(10293,'Laikipia','20',1112),(10294,'Lamu','21',1112),(10295,'Machakos','22',1112),(10296,'Makueni','23',1112),(10297,'Mandera','24',1112),(10298,'Marsabit','25',1112),(10299,'Meru','26',1112),(10300,'Migori','27',1112),(10301,'Mombasa','28',1112),(10302,'Murang\'a','29',1112),(10303,'Nairobi City','30',1112),(10304,'Nakuru','31',1112),(10305,'Nandi','32',1112),(10306,'Narok','33',1112),(10307,'Nyamira','34',1112),(10308,'Nyandarua','35',1112),(10309,'Nyeri','36',1112),(10310,'Samburu','37',1112),(10311,'Siaya','38',1112),(10312,'Taita/Taveta','39',1112),(10313,'Tana River','40',1112),(10314,'Tharaka-Nithi','41',1112),(10315,'Trans Nzoia','42',1112),(10316,'Turkana','43',1112),(10317,'Uasin Gishu','44',1112),(10318,'Vihiga','45',1112),(10319,'Wajir','46',1112),(10320,'West Pokot','47',1112);
 /*!40000 ALTER TABLE `civicrm_state_province` ENABLE KEYS */;
 UNLOCK TABLES;
 
index 1835f4c330376dfc291321def98432d5e287ba0f..d1f23594d294a2cea076f61352d752a61bbe48e1 100644 (file)
@@ -68,7 +68,8 @@
 {if $hookLinks}
    {foreach from=$hookLinks item=link}
     <li>
-        <a href="{$link.url}" data-tab="activity"{if !empty($link.title)} title="{$link.title}"{/if}>
+        <a href="{$link.url}" data-tab="activity"{if !empty($link.title)} title="{$link.title}"{/if}
+        {if !empty($link.class)} class="{$link.class}"{/if}>
           {if $link.img}
                 <img src="{$link.img}" alt="{$link.title}" />&nbsp;
           {/if}
index 5af6d8c6ea911af0b37ed3e209bd29e64adfa902..e57a71bcc3ccbfdf846e8bb2724e8af0d414737f 100644 (file)
            <td>{$contactDetails.$activityId.$fName}</td>
         {/foreach}
                 {foreach from=$fields item=field key=fieldName}
-                {assign var=n value=$field.name}
-                {if $fields.$n.name eq 'activity_date_time' }
-                <td class="compressed">{include file="CRM/common/jcalendar.tpl" elementName=$fieldName elementIndex=$activityId batchUpdate=1}</td>
-                {else}
+                  {assign var=n value=$field.name}
                    <td class="compressed">{$form.field.$activityId.$n.html}</td>
-                {/if}
               {/foreach}
              </tr>
               {/foreach}
index e0f68826e537917fb98ca620d229b213072ea566..aa5a8766f3809b3e35d6152ae0bf43d3080a64c1 100644 (file)
             <td>{$form.includeEmailInName.html}<br />
                 <span class="description">{ts}If enabled, email addresses are automatically included when users search by Name. Disabling this feature will speed up search significantly for larger databases, but users will need to use the Email search fields (from Advanced Search, Search Builder, or Profiles) to find contacts by email address.{/ts}</span></td>
         </tr>
+        <tr class="crm-search-setting-form-block-searchPrimaryDetailsOnly">
+            <td class="label">{$form.searchPrimaryDetailsOnly.label}</td>
+            <td>{$form.searchPrimaryDetailsOnly.html}<br />
+                <span class="description">{ts}If enabled, only primary details (eg contact's primary email, phone, etc) will be included in Basic and Advanced Search results. Disabling this feature will allow users to match contacts using any email, phone etc detail.{/ts}</span>
+            </td>
+        </tr>
         <tr  class="crm-search-setting-form-block-includeNickNameInName">
             <td class="label">{$form.includeNickNameInName.label}</td>
             <td>{$form.includeNickNameInName.html}<br />
index 77f245749be9dcadfe5480ecee5c650dc8e02d87..a38feec15b701043829a8d89355457b2608e0b87 100644 (file)
             </td>
         </tr>
         {/if}
+        <tr class="crm-uf-form-block-syncCMSEmail">
+           <td class="label">{$form.syncCMSEmail.label}</td>
+           <td>{$form.syncCMSEmail.html}</td>
+       </tr>
         </table>
             <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
 <div class="spacer"></div>
index bbcc7260954dd8483fe76dd8de9c054ae9090dd1..aa871e76839a403cf86b05696b8a6ca5dc43a09f 100644 (file)
@@ -20,8 +20,7 @@
     docCodeTpl = _.template($('#doc-code-tpl').html()),
     joinTpl = _.template($('#join-tpl').html()),
 
-    // The following apis do not support the syntax for joins
-    // FIXME: the solution is to convert these apis to use _civicrm_api3_basic_get
+    // The following apis do not use Api3SelectQuery so do not support advanced features like joins or OR
     NO_JOINS = ['Contact', 'Contribution', 'Pledge', 'Participant'],
 
     // These types of entityRef don't require any input to open
 
   function addJoinInfo(field, name) {
     if (field.name === 'entity_id') {
-      var entityTableParam = name.slice(0, -2) + 'table';
-      if (params[entityTableParam]) {
-        field.FKApiName = getField(entityTableParam).options[params[entityTableParam]];
+      var entityTableParam = name.slice(0, -2) + 'table',
+        entityField = params[entityTableParam] ? getField(entityTableParam) : {};
+      if (entityField.options) {
+        field.FKApiName = entityField.options[params[entityTableParam]];
       }
     }
     if (field.pseudoconstant && field.pseudoconstant.optionGroupName) {
       }
     });
     if (entity && action) {
+      handleAndOr();
       formatQuery();
     }
   }
    */
   function renderJoinSelector() {
     $('#api-join').hide();
-    if (!_.includes(NO_JOINS, entity) && _.includes(['get', 'getsingle'], action)) {
+    if (!_.includes(NO_JOINS, entity) && _.includes(['get', 'getsingle', 'getcount'], action)) {
       var joinable = {};
       (function recurse(fields, joinable, prefix, depth, entities) {
         _.each(fields, function(field) {
           var name = prefix + field.name;
           addJoinInfo(field, name);
           var entity = field.FKApiName;
-          if (entity) {
+          if (entity && (field.is_core_field || field.supports_joins)) {
             joinable[name] = {
               title: field.title + ' (' + field.FKApiName + ')',
               entity: entity,
     }
   }
 
+  function handleAndOr() {
+    if (!_.includes(NO_JOINS, entity) && _.includes(['get', 'getsingle', 'getcount'], action)) {
+      var or = [];
+      $('tr.api-param-row').each(function() {
+        if ($(this).next().is('tr.api-param-row') && $('input.api-param-name', this).val()) {
+          $('.api-and-or', this).show();
+        } else {
+          $(this).removeClass('or').find('.api-and-or').hide();
+        }
+      });
+      $('tr.api-param-row.or').each(function() {
+        var val = $(this).next().find('input.api-param-name').val();
+        if (val) {
+          if ($(this).prev().is('.or')) {
+            or[or.length - 1].push(val);
+          } else {
+            or.push([$('input.api-param-name', this).val(), val]);
+          }
+        }
+      });
+      if (or.length) {
+        params.options = params.options || {};
+        params.options.or = or;
+      }
+    } else {
+      $('.api-and-or').hide();
+    }
+  }
+
+  function toggleAndOr() {
+    $(this).closest('tr').toggleClass('or');
+    buildParams();
+  }
+
   $(document).ready(function() {
     // Set up tabs - bind active tab to document hash because... it's cool?
     document.location.hash = document.location.hash || 'explorer';
         $(this).closest('tr').remove();
         buildParams();
       })
-      .on('change', 'select.api-chain-entity', getChainedAction);
+      .on('click', '.api-and-or > span', toggleAndOr)
+      .on('change', 'select.api-chain-entity', getChainedAction)
+      .on('sortupdate', buildParams)
+      .sortable({
+        handle: '.api-sort-handle',
+        items: '.api-chain-row, .api-param-row'
+      });
     $('#api-join').on('change', 'input', onSelectJoin);
     $('#example-entity').on('change', getExamples);
     $('#example-action').on('change', getExample);
index fea4a10bcd9224eec877e9a6711bf5535f27f2cc..b2b22bbc87de9f7ae8740721e31f8da081e65c89 100644 (file)
@@ -50,6 +50,9 @@
     margin-top: 1em;
     overflow: auto;
   }
+  #api-params tr td {
+    padding-top: 13px;
+  }
   #api-params-table th:first-child,
   #api-params-table td:first-child {
     width: 35%;
   #api-params-table th:first-child + th + th {
     width: 65%
   }
+  #api-params .api-sort-handle {
+    margin-right: 10px;
+    cursor: move;
+  }
+  #api-params tr td > .crm-i,
+  #api-params tr td > a .crm-i {
+    color: lightgrey;
+  }
+  #api-params tr:hover td > .crm-i,
+  #api-params tr:hover td > a .crm-i {
+    color: grey;
+  }
+  #api-params .api-and-or {
+    margin-left: 1.2em;
+    font-size: .8em;
+    position: relative;
+    top: 5px;
+    width: 10em;
+    margin-bottom: -9px;
+  }
+  #api-params .api-and-or > span {
+    padding: 0 1em;
+    background: white;
+    cursor: pointer;
+  }
+  #api-params .api-or,
+  #api-params tr.or .api-and {
+    color: lightgrey;
+  }
+  #api-params tr.or .api-or {
+    color: inherit;
+  }
+  #api-params .api-and-or .crm-i {
+    transform: rotate(180deg);
+  }
+  #api-params tr.or .api-and-or .crm-i {
+    transform: initial;
+  }
+  #api-params .api-and-or:hover .crm-i {
+    color: #2786c2;
+  }
+  #api-params tr.or {
+    border-top: 3px solid lightgrey;
+    border-left: 3px solid lightgrey;
+    border-right: 3px solid lightgrey;
+  }
+  #api-params tr.or + tr {
+    border-left: 3px solid lightgrey;
+    border-right: 3px solid lightgrey;
+    border-bottom: 3px solid lightgrey;
+  }
+  #api-params tr.or + tr.or {
+    border-top: none;
+    border-bottom: none;
+  }
   #api-generated td:first-child {
     width: 60px;
   }
 <div id="mainTabContainer">
   <ul>
     <li class="ui-corner-all" title="GUI to build and execute API calls">
-      <a href="#explorer-tab">{ts}Explorer{/ts}</a>
+      <a href="#explorer-tab"><i class="crm-i fa-search"></i> {ts}Explorer{/ts}</a>
     </li>
     <li class="ui-corner-all" title="Auto-generated examples from the test suite">
-      <a href="#examples-tab">{ts}Examples{/ts}</a>
+      <a href="#examples-tab"><i class="crm-i fa-book"></i> {ts}Examples{/ts}</a>
     </li>
     <li class="ui-corner-all" title="API source-code and code-level documentation">
-      <a href="#docs-tab">{ts}Code Docs{/ts}</a>
+      <a href="#docs-tab"><i class="crm-i fa-code"></i> {ts}Code Docs{/ts}</a>
     </li>
   </ul>
 
 {strip}
 <script type="text/template" id="api-param-tpl">
   <tr class="api-param-row">
-    <td><input style="width: 100%;" class="crm-form-text api-param-name api-input" value="<%= name %>" placeholder="{ts}Parameter{/ts}" /></td>
+    <td>
+      <i class="crm-i api-sort-handle fa-arrows"></i>
+      <input style="width: 90%;" class="crm-form-text api-param-name api-input" value="<%= name %>" placeholder="{ts}Parameter{/ts}" />
+      <div class="api-and-or"><span><span class="api-and">{ts}AND{/ts}</span> <i class="crm-i fa-toggle-on"></i> <span class="api-or">{ts}OR{/ts}</span></span></div>
+    </td>
     <td>
       {literal}
       <% if (noOps) { %>
 <script type="text/template" id="api-chain-tpl">
   <tr class="api-chain-row">
     <td>
-      <select style="width: 100%;" class="crm-form-select api-chain-entity">
+      <i class="crm-i api-sort-handle fa-arrows"></i>
+      <select style="width: 90%;" class="crm-form-select api-chain-entity">
         <option value=""></option>
         {foreach from=$entities.values item=entity}
           <option value="{$entity}" {if !empty($entities.deprecated) && in_array($entity, $entities.deprecated)}class="strikethrough"{/if}>
index 094507f80b143d78eebeddd01e1ca3f34cb599ff..e37969e8834e64ecfa9491cf86661f753359425c 100644 (file)
@@ -39,6 +39,7 @@
         </span><br/><br/>
     </div>
     <div class="spacer"></div>
+    <div style="padding-left: 25px;"><div class="crm-logo-sm"></div></div>
     <div id="navigation-tree" class="navigation-tree" style="height:auto; border-collapse:separate; background-color:#FFFFFF;"></div>
     <div class="spacer"></div>
     <div>
     <div class="spacer"></div>
   </div>
   {literal}
-  <style type="text/css">
-    #navigation-tree li {
-      font-weight: normal;
-    }
-    #navigation-tree > ul > li {
-      font-weight: bold;
-    }
-  </style>
   <script type="text/javascript">
     CRM.$(function($) {
       $("#navigation-tree").jstree({
-        plugins: [ "themes", "json_data", "dnd","ui", "crrm","contextmenu" ],
-        json_data: {
-          ajax:{
-            dataType: "json",
-            url: {/literal}"{crmURL p='civicrm/ajax/menu' h=0 q='key='}{crmKey name='civicrm/ajax/menu'}"{literal}
+        plugins: ["dnd", "contextmenu"],
+        core: {
+          data: function(tree, callBack) {
+            CRM.api3('Navigation', 'get', {
+              domain_id: {/literal}{$config->domainID()}{literal},
+              options: {limit: 0, sort: 'weight'},
+              return: ['label', 'parent_id'],
+              name: {'!=': 'Home'},
+              sequential: 1
+            }).done(function(data) {
+              var items = [];
+              $.each(data.values, function(key, value) {
+                items.push({
+                  id: value.id,
+                  text: value.label,
+                  icon: false,
+                  parent: value.parent_id || '#'
+                });
+              });
+              callBack(items);
+            });
           },
-          progressive_render: true
-        },
-        themes: {
-          "theme": 'classic',
-          "dots": true,
-          "icons": false,
-          "url": CRM.config.resourceBase + 'packages/jquery/plugins/jstree/themes/classic/style.css'
+          progressive_render: true,
+          check_callback: true
         },
-        rules: {
-          droppable: [ "tree-drop" ],
-          multiple: true,
-          deletable: "all",
-          draggable: "all"
-        },
-        crrm: {
-          move: {
-            check_move: function(m) {
-              var homeMenuId = {/literal}"{$homeMenuId}"{literal};
-              if ( $( m.r[0] ).attr('id').replace("node_","") == homeMenuId ||
-                $( m.o[0] ).attr('id').replace("node_","") == homeMenuId ) {
-                return false;
-              } else {
-                return true;
-              }
-            }
-          }
+        dnd: {
+          copy: false
         },
         contextmenu: {
-          items: {
-            create: false,
-            ccp: {
-              label : "{/literal}{ts escape='js'}Edit{/ts}{literal}",
-              visible: function (node, obj) { if(node.length != 1) return false;
-                return obj.check("renameable", node); },
-              action: function (node, obj) {
-                var nid = $(node).prop('id');
-                var nodeID = nid.substr( 5 );
-                var editURL = {/literal}"{crmURL p='civicrm/admin/menu' h=0 q='action=update&reset=1&id='}"{literal} + nodeID;
-                CRM.loadForm(editURL).on('crmFormSuccess', function() {
-                  $("#navigation-tree").jstree('refresh');
-                  $("#reset-menu").show( );
-                });
+          items: function (node, callBack) {
+            var items = {
+              add: {
+                label: "{/literal}{ts escape='js'}Add{/ts}{literal}",
+                icon: 'crm-i fa-plus',
+                action: editForm
+              },
+              edit: {
+                label: "{/literal}{ts escape='js'}Edit{/ts}{literal}",
+                icon: 'crm-i fa-pencil',
+                action: editForm
               },
-              submenu: false
-            }
+              delete: {
+                label: "{/literal}{ts escape='js'}Delete{/ts}{literal}",
+                icon: 'crm-i fa-trash',
+                action: function (menu) {
+                  var nodeID = menu.reference.attr('id').replace('_anchor', ''),
+                    node = $("#navigation-tree").jstree(true).get_node(nodeID),
+                    menuName = node.text;
+                  var deleteMsg = {/literal}"{ts escape='js'}Are you sure you want to delete this menu item:{/ts} " + '"'{literal} + menuName + {/literal}'"? {ts escape='js'}This action cannot be undone.{/ts}'{literal};
+                  if (node.children.length) {
+                    deleteMsg += {/literal}"<br /><br />" + ts('{ts escape='js' 1='<strong>%1</strong>'}%1 sub-menu items will also be deleted.{/ts}'{literal}, {1: node.children.length});
+                  }
+                  CRM.confirm({message: deleteMsg})
+                    .on('crmConfirm:yes', function() {
+                      CRM.api3('Navigation', 'delete', {id: nodeID}, true);
+                      $("#navigation-tree").jstree(true).delete_node(menu.reference.closest('li'));
+                      $("#reset-menu").show();
+                    });
+                }
+              }
+            };
+            callBack(items);
           }
         }
-
-      }).bind("rename.jstree", function ( e,node ) {
-        var nodeID  = node.rslt.obj.attr('id').replace("node_","");
-        var newName = node.rslt.new_name;
+      }).on("move_node.jstree", function (e, data) {
+        var nodeID = data.node.id;
+        var refID = data.parent === '#' ? '' : data.parent;
+        var ps = data.position;
         var postURL = {/literal}"{crmURL p='civicrm/ajax/menutree' h=0 q='key='}{crmKey name='civicrm/ajax/menutree'}"{literal};
-        $.get( postURL + '&type=rename&id=' + nodeID + '&data=' + newName,
-          function (data) {
-            $("#reset-menu").show( );
-          }
-        );
-
-      }).bind("remove.jstree", function( e,node ) {
-        var menuName  = node.rslt.obj.find('a').first( ).text( );
-        var nodeID  = node.rslt.obj.attr('id').replace("node_","");
+        CRM.status({}, $.get( postURL + '&type=move&id=' +  nodeID + '&ref_id=' + refID + '&ps='+ps));
+        $("#reset-menu").show();
+      });
 
-        // don't allow deleting of home
-        var homeMenuId = {/literal}"{$homeMenuId}"{literal};
-        if ( nodeID == homeMenuId ) {
-          var cannotDeleteMsg = {/literal}"{ts escape='js'}You cannot delete this menu item:{/ts}" + " "{literal} + menuName;
-          CRM.alert( cannotDeleteMsg, {/literal}"{ts escape='js'}Cannot Delete{/ts}"{literal} );
-          $("#navigation-tree").jstree('refresh');
-          return false;
-        }
-        var deleteMsg = {/literal}"{ts escape='js'}Are you sure you want to delete this menu item:{/ts}" + " "{literal} + menuName + {/literal}" ? {ts}This action cannot be undone.{/ts}"{literal};
-        var isDelete  = confirm( deleteMsg );
-        if ( isDelete ) {
-          var postURL = {/literal}"{crmURL p='civicrm/ajax/menutree' h=0 q='key='}{crmKey name='civicrm/ajax/menutree'}"{literal};
-          $.get( postURL + '&type=delete&id=' + nodeID,
-            function (data) {
-              $("#reset-menu").show( );
-            }
-          );
+      function editForm(menu) {
+        var nodeID = menu.reference.attr('id').replace('_anchor', ''),
+          action = menu.item.icon === 'crm-i fa-pencil' ? 'update' : 'add',
+          args = {reset: 1, action: action};
+        if (action === 'add') {
+          args.parent_id = nodeID;
         } else {
-          $("#navigation-tree").jstree('refresh');
+          args.id = nodeID;
         }
-
-      }).bind("move_node.jstree", function ( e,node ) {
-        node.rslt.o.each(function (i) {
-          var nodeID = node.rslt.o.attr('id').replace("node_","");
-          var refID  = node.rslt.np.attr('id').replace("node_","");
-          if (isNaN( refID ) ){ refID =''; }
-          var ps = node.rslt.cp+i;
-          var postURL = {/literal}"{crmURL p='civicrm/ajax/menutree' h=0 q='key='}{crmKey name='civicrm/ajax/menutree'}"{literal};
-          $.get( postURL + '&type=move&id=' +  nodeID + '&ref_id=' + refID + '&ps='+ps,
-            function (data) {
-              $("#reset-menu").show( );
-            });
+        CRM.loadForm(CRM.url('civicrm/admin/menu', args)).on('crmFormSuccess', function() {
+          $("#navigation-tree").jstree(true).refresh();
+          $("#reset-menu").show();
         });
-      });
+      }
+
       $('#new-menu-item a.button')
         .on('click', CRM.popup)
         .on('crmPopupFormSuccess', function() {
-          $("#navigation-tree").jstree('refresh');
+          $("#navigation-tree").jstree(true).refresh();
           $("#reset-menu").show();
         });
 
             CRM.api3('Navigation', 'reset', {'for': 'report'}, true)
               .done(function() {
                 $('#crm-container').unblock();
-                $("#navigation-tree").jstree('refresh');
+                $("#navigation-tree").jstree(true).refresh();
                 $("#reset-menu").show();
               })
           });
index 23bf05aef91fc5a6d28fd5afd781384bade9d809..89fcda8db49bf648e2fd1ad93b2f964b6b460a26 100644 (file)
@@ -171,6 +171,7 @@ function checkColumns(parentRow) {
 
   parentRow.find('div .required').each(function () {
     //special case to handle contact autocomplete select
+    // @todo WHY OH WHY is this duplicated on the tpl file?
     var fieldId = cj(this).attr('id');
     if (fieldId.substring(0, 16) == 'primary_contact_') {
       // if display value is set then make sure we also check if contact id is set
index ad7d9a77ce70a7bb4e1ffa6b57e66546b105d3a5..067c6b2e9eb28bd223a4641b03ed120d18e626af 100644 (file)
       "oLanguage": {"sEmptyTable": noRecordFoundMsg,
         "sZeroRecords": noRecordFoundMsg },
       "fnDrawCallback": function () {
-        // FIXME: trigger crmLoad and crmEditable would happen automatically
-        $('.crm-editable').crmEditable();
+        $(this).trigger('crmLoad');
       },
       "fnRowCallback": function (nRow, aData, iDisplayIndex) {
         //insert the id for each row for enable/disable.
index 6f54ea14ac31f133a63c8f820ccde1b142231dad..08da9d8157ed4e7c8a1638c2d71645c4e011d9f9 100644 (file)
@@ -198,8 +198,7 @@ function loadPetitionList( )
              "oLanguage":{"sEmptyTable"  : noRecordFoundMsg,
                  "sZeroRecords" : noRecordFoundMsg },
              "fnDrawCallback": function() {
-               // FIXME: trigger crmLoad and crmEditable would happen automatically
-               CRM.$('.crm-editable').crmEditable();
+               $(this).trigger('crmLoad');
              },
              "fnRowCallback": function( nRow, aData, iDisplayIndex ) {
 
index ceb44095f42879e54aae00070fb9b92d5f182f3a..2b72618d5853fdfe4f05e30927436343cd38c9ed 100644 (file)
@@ -212,8 +212,7 @@ function loadSurveyList( )
              "oLanguage":{"sEmptyTable"  : noRecordFoundMsg,
                  "sZeroRecords" : noRecordFoundMsg },
              "fnDrawCallback": function() {
-               // FIXME: trigger crmLoad and crmEditable would happen automatically
-               CRM.$('.crm-editable').crmEditable();
+               $(this).trigger('crmLoad');
              },
              "fnRowCallback": function( nRow, aData, iDisplayIndex ) {
                // Crm-editable
index 4a563b2fec48883b7cb8af27d36634883d59cffa..1b6113be306913c8353466b832105a7ef19ca164 100644 (file)
@@ -37,7 +37,7 @@
   </div>
   <div class="form-item">
         <span class="label">{$form.birth_date.label}</span>
-        <span class="value">{include file="CRM/common/jcalendar.tpl" elementName=birth_date}</span>
+        <span class="fields">{$form.birth_date.html}</span>
   </div>
   <div class="form-item">
        {$form.is_deceased.html}
@@ -45,7 +45,7 @@
   </div>
   <div id="showDeceasedDate" class="form-item">
        <span class="label">{$form.deceased_date.label}</span>
-       <span class="value">{include file="CRM/common/jcalendar.tpl" elementName=deceased_date}</span>
+       <span class="fields">{$form.deceased_date.html}</span>
   </div>
  </div><!-- /.crm-accordion-body -->
 </div><!-- /.crm-accordion-wrapper -->
index ba423175a29cc8ae9250fdfb6e076aa1469154e2..df271f19d194c1ce6f2eaa1359021676af04e905 100644 (file)
           <td>
             {if $groupElementType eq 'select'}
               <span class="label">{if $title}{$form.group.label}{/if}</span>
+              {$form.group.html}
+            {else}
+              {foreach key=key item=item from=$tagGroup.group}
+                <div class="group-wrapper">
+                  {$form.group.$key.html}
+                  {if $item.description}
+                    <div class="description">{$item.description}</div>
+                  {/if}
+                </div>
+              {/foreach}
             {/if}
-            {$form.group.html}
           </td>
         {/if}
         {if (!$type || $type eq 'tag') && $tree}
index 315884de9739d8bc25ef12ca255fe9b6f4ce830a..dbc3b9dbc14c1f648512c47bb2ed04681d3ebd73 100644 (file)
@@ -37,7 +37,7 @@
     <div class="crm-summary-row">
       <div class="crm-label">{$form.birth_date.label}</div>
       <div class="crm-content">
-        {include file="CRM/common/jcalendar.tpl" elementName=birth_date}
+        {$form.birth_date.html}
       </div>
     </div>
     <div class="crm-summary-row">
@@ -50,7 +50,7 @@
     <div class="crm-summary-row">
       <div class="crm-label crm-deceased-date">{$form.deceased_date.label}</div>
       <div class="crm-content crm-deceased-date">
-        {include file="CRM/common/jcalendar.tpl" elementName=deceased_date}
+        {$form.deceased_date.html}
       </div>
     </div>
   </div>
index 4541877abfcd0e0b5976a9a8bcf14de24ff2310d..ca2de4c87ad5302fc901725ae452550a289a5d93 100644 (file)
               $row.title|substr:0:5 == "Phone"}
 
             <td>
-              {* @TODO check if this is ever an array or a fileName? *}
-              {* This is on one long line for address formatting *}
-              {if $row.title|substr:0:7 == "Address"}<span style="white-space: pre" id="main_{$blockName}_{$blockId}">{else}<span id="main_{$blockName}_{$blockId}">{/if}{if !is_array($row.main)}{$row.main}{elseif $row.main.fileName}{$row.main.fileName}{else}{', '|implode:$row.main}{/if}</span>
+              {strip}
+                {if $row.title|substr:0:7 == "Address"}
+                  <span style="white-space: pre" id="main_{$blockName}_{$blockId}">
+                {else}
+                  <span id="main_{$blockName}_{$blockId}">
+                {/if}
+                {* @TODO check if this is ever an array or a fileName? *}
+                {if !is_array($row.main)}
+                  {$row.main}
+                {elseif $row.main.fileName}
+                  {$row.main.fileName}
+                {else}
+                  {', '|implode:$row.main}
+                {/if}
+                </span>
+              {/strip}
             </td>
 
             <td>
       {/if}
     {/foreach}
   </table>
-  <div class='form-item'>
-    <!--<p>{$form.moveBelongings.html} {$form.moveBelongings.label}</p>-->
-    <!--<p>{$form.deleteOther.html} {$form.deleteOther.label}</p>-->
-  </div>
 
   <div class="crm-submit-buttons">
     {include file="CRM/common/formButtons.tpl" location="bottom"}
   /**
    * Triggered when a 'location' or 'type' destination is changed, and when
    * the operation or 'set primary' checkboxes are changed.
-   * 
+   *
    * Check to see if the 'main' contact record has a corresponding location
    * block when the destination of a field is changed. Allow existing location
    * fields to be overwritten with data from the 'other' contact.
     }
   }
 
-  CRM.$(function($) {
-
-    $('table td input.form-checkbox').each(function() {
-      var ele = null;
-      var element = $(this).attr('id').split('_',3);
+  /**
+   * Toggle the location type and the is_primary on & off depending on whether the merge box is ticked.
+   *
+   * @param element
+   */
+  function toggleRelatedLocationFields(element) {
+    relatedElements = CRM.$(element).parent().siblings('td').find('input,select,label,hidden');
+    if (CRM.$(element).is(':checked')) {
+      relatedElements.removeClass('disabled').attr('disabled', false);
 
-      switch ( element['1'] ) {
-        case 'addressee':
-          ele = '#' + element['0'] + '_' + element['1'];
-          break;
+    }
+    else {
+      relatedElements.addClass('disabled').attr('disabled', true);
+    }
 
-         case 'email':
-         case 'postal':
-           ele = '#' + element['0'] + '_' + element['1'] + '_' + element['2'];
-           break;
-      }
+  }
 
-      if( ele ) {
-        $(this).on('click', function() {
-          var val = $(this).prop('checked');
-          $('input' + ele + ', input' + ele + '_custom').prop('checked', val);
-        });
-      }
+  CRM.$(function($) {
+    $('input.crm-form-checkbox[data-is_location]').on('click', function(){
+      toggleRelatedLocationFields(this)
     });
 
     // Show/hide matching data rows
     });
 
     // Call mergeBlock whenever a location type is changed
+    // (This is applied to the body because the inputs can be added dynamically
+    // to the form, and we need to catch when they change.)
     $('body').on('change', 'select[id$="locTypeId"],select[id$="typeTypeId"],input[id$="[operation]"],input[id$="[set_other_primary]"]', function(event){
 
       // All the information we need is held in the id, separated by underscores
index 0f138c7dc2a4ef4dbc4639ce8caca661be61edd2..2309aaa448bda80dce5f8f75b184d07a7b023dd0 100644 (file)
           </table>
         </div>
         {/if}
+        <div class="crm-field-wrapper">
+          {$form.supplemental_address_1.label}<br />
+          {$form.supplemental_address_1.html}
+        </div>
+        <div class="crm-field-wrapper">
+          {$form.supplemental_address_2.label}<br />
+          {$form.supplemental_address_2.html}
+        </div>
         <div class="crm-field-wrapper">
           {$form.city.label}<br />
           {$form.city.html}
     </script>
   {/literal}
 {/if}
-
-
index 74485a1cae795eb9937d733426db93c188442fce..1653ecb8839792343789a036bc63aae79405099b 100644 (file)
@@ -73,8 +73,6 @@
             </table>
           {/strip}
         </td>
-      {elseif ( $n eq 'birth_date' or $n eq 'deceased_date' ) }
-        <td class="compressed">{include file="CRM/common/jcalendar.tpl" elementName=$n elementIndex=$cid batchUpdate=1}</td>
       {elseif $n|substr:0:5 eq 'phone'}
         <td class="compressed">
           {assign var="phone_ext_field" value=$n|replace:'phone':'phone_ext'}
index fc9b0f0ae128988a381b034dc8d61ae1bbf2b0cf..a2dabf1fba5cb1f4ec5609f747af3bee8e85144a 100644 (file)
       <div class="crm-label">{ts}Gender{/ts}</div>
       <div class="crm-content crm-contact-gender_display">{$gender_display}</div>
     </div>
+
     <div class="crm-summary-row">
       <div class="crm-label">{ts}Date of Birth{/ts}</div>
       <div class="crm-content crm-contact-birth_date_display">
-          {if $birthDateViewFormat}
-            {$birth_date_display|crmDate:$birthDateViewFormat}
-          {else}
-            {$birth_date_display|crmDate}
-          {/if}
+         {assign var="date_format" value = $fields.birth_date.smarty_view_format}
+         {$birth_date|crmDate:$date_format}
           &nbsp;
       </div>
     </div>
           <div class="crm-summary-row">
             <div class="crm-label">{ts}Date Deceased{/ts}</div>
             <div class="crm-content crm-contact-deceased_date_display">
-            {if $birthDateViewFormat}
-              {$deceased_date_display|crmDate:$birthDateViewFormat}
-            {else}
-              {$deceased_date_display|crmDate}
-             {/if}
+              {$deceased_date}
             </div>
           </div>
         {else}
index 79e7ff60b62e21f592fb5a81cfa444a994d195b3..db34df3c08f0f7e33edffc02aa44e1a765ae7433 100644 (file)
       });
     </script>
       {if !$contributionMode}
+        {crmAPI var="checkVal" entity="OptionValue" action="getvalue" version="3" option_group_id="payment_instrument" name="Check" return="value"}
         {include file="CRM/common/showHideByFieldValue.tpl"
         trigger_field_id    ="payment_instrument_id"
-        trigger_value       = '4'
+        trigger_value       = $checkVal
         target_element_id   ="checkNumber"
         target_element_type ="table-row"
         field_type          ="select"
index 4d75202f6eace2bd4af6bcfa75c20a0aabd789b8..e170975ac82c86d25d52bbf94e11811cd089191d 100644 (file)
@@ -8,34 +8,36 @@
    * Removes spaces and dashes from credit card numbers.
    */
   function civicrm_billingblock_creditcard_helper() {
-    $.each(CRM.config.creditCardTypes, function(key, val) {
-      var html = '<a href="#" title="' + val + '" class="crm-credit_card_type-icon-' + key + '"><span>' + val + '</span></a>';
-      $('.crm-credit_card_type-icons').append(html);
+    $(function() {
+      $.each(CRM.config.creditCardTypes, function(key, val) {
+        var html = '<a href="#" title="' + val + '" class="crm-credit_card_type-icon-' + key + '"><span>' + val + '</span></a>';
+        $('.crm-credit_card_type-icons').append(html);
 
-      $('.crm-credit_card_type-icon-' + key).click(function() {
-        $('#credit_card_type').val(val);
-        $('.crm-container .credit_card_type-section a').css('opacity', 0.25);
-        $('.crm-container .credit_card_type-section .crm-credit_card_type-icon-' + key).css('opacity', 1);
-        return false;
+        $('.crm-credit_card_type-icon-' + key).click(function() {
+          $('#credit_card_type').val(val);
+          $('.crm-container .credit_card_type-section a').css('opacity', 0.25);
+          $('.crm-container .credit_card_type-section .crm-credit_card_type-icon-' + key).css('opacity', 1);
+          return false;
+        });
       });
-    });
 
-    // Hide the CC type field (redundant)
-    $('#credit_card_type, .label', '.crm-container .credit_card_type-section').hide();
+      // Hide the CC type field (redundant)
+      $('#credit_card_type, .label', '.crm-container .credit_card_type-section').hide();
 
-    // Select according to the number entered
-    $('.crm-container input#credit_card_number').change(function() {
-      var ccnumber = cj(this).val();
+      // Select according to the number entered
+      $('.crm-container input#credit_card_number').change(function() {
+        var ccnumber = cj(this).val();
 
-      // Remove spaces and dashes
-      ccnumber = ccnumber.replace(/[- ]/g, '');
-      cj(this).val(ccnumber);
+        // Remove spaces and dashes
+        ccnumber = ccnumber.replace(/[- ]/g, '');
+        cj(this).val(ccnumber);
 
-      // Semi-hide all images, we will un-hide the right one afterwards
-      $('.crm-container .credit_card_type-section a').css('opacity', 0.25);
-      $('#credit_card_type').val('');
+        // Semi-hide all images, we will un-hide the right one afterwards
+        $('.crm-container .credit_card_type-section a').css('opacity', 0.25);
+        $('#credit_card_type').val('');
 
-      civicrm_billingblock_set_card_type(ccnumber);
+        civicrm_billingblock_set_card_type(ccnumber);
+      });
     });
   }
 
index cf9aa881c71a95db0f0a2dff610b48d691eabfff..7cd373f67dc09d3196c944eff3258746ee4055bd 100644 (file)
                 return nRow;
               },
               "fnDrawCallback": function() {
-                // FIXME: trigger crmLoad and crmEditable would happen automatically
-                $('.crm-editable').crmEditable();
+                $(this).trigger('crmLoad');
               },
 
               "fnServerData": function ( sSource, aoData, fnCallback ) {
index 883c7af87b9271bfe9bdef6eceb9bb5833dc0d34..d5f5f04255c5771ee1ecb93cd7089c5e1f1d9989 100644 (file)
                       </table>
                     {/strip}
                   </td>
-                {elseif ( $n eq 'participant_register_date' ) }
-                  <td class="compressed">{include file="CRM/common/jcalendar.tpl" elementName=$n elementIndex=$pid batchUpdate=1}</td>
                 {else}
                   <td class="compressed">{$form.field.$pid.$n.html}</td>
                 {/if}
index ec4695a14c17890e5e33787adf9ba77561286866..9e0c7543e493a2d38b70e3e6be2d30a4b1d314ab 100644 (file)
@@ -149,8 +149,7 @@ CRM.$(function($) {
         return nRow;
       },
       "fnDrawCallback": function(oSettings) {
-        // FIXME: trigger crmLoad and crmEditable would happen automatically
-        $('.crm-editable', '#crm-batch-selector-{/literal}{$batchStatus}{literal}').crmEditable();
+        $(this).trigger('crmLoad');
         $("#toggleSelect").prop('checked', false);
         if (checkedRows.length) {
           $(checkedRows.join(',')).prop('checked', true).change();
index 85c46bccb408390164cb4d49f03e5174df68d739..5408df48c6525571a2d3da2fe679fd245ffd6177 100644 (file)
@@ -150,7 +150,8 @@ function calculateSelectLineItemValue(priceElement) {
  */
 function calculateText(priceElement) {
   //CRM-16034 - comma acts as decimal in price set text pricing
-  var textval = parseFloat(cj(priceElement).val().replace(thousandMarker, ''));
+  //CRM-19937 - dollar sign easy mistake to make by users.
+  var textval = parseFloat(cj(priceElement).val().replace(thousandMarker, '').replace(symbol, ''));
 
   if (isNaN(textval)) {
     textval = parseFloat(0);
index 9c0c0f365cbf06265ebc7def7638e3b90ea8d4e8..d0ab3de21c18ec8cbd3ceb322087796ac0961449 100644 (file)
@@ -78,7 +78,7 @@
     {if $getTaxDetails}
       <td class="right">{$line.line_total|crmMoney}</td>
       {if $line.tax_rate != "" || $line.tax_amount != ""}
-        <td class="right">{$taxTerm} ({$line.tax_rate|string_format:"%.2f"}%)</td>
+        <td class="right">{$taxTerm} ({$line.tax_rate|string_format:"%.3f"}%)</td>
         <td class="right">{$line.tax_amount|crmMoney}</td>
       {else}
         <td></td>
index 477c0c5750b538002f76fc5fecbf039dd93044cf..7b7725af99f677912f14511af81265042cd8cef6 100644 (file)
                 &nbsp;{$form.$phone_ext_field.html}
                 {/if}
               {else}
-                {if
-                ( ( $n eq 'birth_date' ) or ( $n eq 'deceased_date' ) or ( $n eq 'activity_date_time' ) ) and $field.is_view neq 1 }
-                {include file="CRM/common/jcalendar.tpl" elementName=$n}
-                {else}
-                  {$form.$n.html}
-                {/if}
+                {$form.$n.html}
                 {if $field.html_type eq 'Autocomplete-Select'}
                   {if $field.data_type eq 'ContactReference'}
                     {include file="CRM/Custom/Form/ContactReference.tpl" element_name = $n}
index 719327e6ef39d88f136bf2150dc72dde41284c29..02ad086f04c38a3a3f2500eabf383d0713098123 100644 (file)
@@ -65,9 +65,7 @@
             </td>
           {else}
             <td class="description">
-              {if ( $n eq 'birth_date' ) or ( $n eq 'deceased_date' ) }
-                {include file="CRM/common/jcalendar.tpl" elementName=$n}
-              {elseif $n|substr:0:5 eq 'phone'}
+              {if $n|substr:0:5 eq 'phone'}
                 {assign var="phone_ext_field" value=$n|replace:'phone':'phone_ext'}
                 {$form.$n.html}
                 {if $form.$phone_ext_field.html}
index 646dd7c519eb06770131d62721b8de4e0dfd8f8b..0f78e0f83936a206f5d9abed54bbd664ec8ff788 100644 (file)
@@ -42,6 +42,7 @@
          <td>{$form.parent_id.html}</td>
        </tr>
    {/if}
+      {if $form.used_for}
        <tr class="crm-tag-form-block-used_for">
           <td class="label">{$form.used_for.label}</td>
           <td>{$form.used_for.html} <br />
@@ -52,6 +53,7 @@
             </span>
           </td>
         </tr>
+      {/if}
       {if $form.color.html}
         <tr class="crm-tag-form-block-color">
           <td class="label">{$form.color.label}</td>
@@ -81,7 +83,7 @@
         </table><br />
         {/if}
     {else}
-        <div class="status">{ts 1=$delName}Are you sure you want to delete <b>%1</b> Tag?{/ts}<br />{ts}This tag will be removed from any currently tagged contacts, and users will no longer be able to assign contacts to this tag.{/ts}</div>
+        <div class="status">{ts 1=$delName}Are you sure you want to delete <b>%1</b>?{/ts}<br />{ts}This tag will be removed from any currently tagged contacts, and users will no longer be able to assign contacts to this tag.{/ts}</div>
     {/if}
     <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
 </div>
@@ -90,8 +92,9 @@
   CRM.$(function($) {
     var $form = $('form.{/literal}{$form.formClass}{literal}');
     function toggleUsedFor() {
-      $('.crm-tag-form-block-used_for', $form).toggle(!$(this).val());
-      if ($(this).val()) {
+      var value = $(this).val() && $(this).val() !== '0';
+      $('.crm-tag-form-block-used_for', $form).toggle(!value);
+      if (value) {
         $('select#used_for', $form).val('').change();
       }
     }
diff --git a/templates/CRM/Tag/Form/Merge.tpl b/templates/CRM/Tag/Form/Merge.tpl
new file mode 100644 (file)
index 0000000..a62e200
--- /dev/null
@@ -0,0 +1,39 @@
+{*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 4.7                                                |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2017                                |
+ +--------------------------------------------------------------------+
+ | 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        |
+ +--------------------------------------------------------------------+
+*}
+{* this template is used for merging tags (admin)  *}
+<div class="crm-block crm-form-block crm-tag-form-block">
+  <div class="status">
+    {ts 1=$tags|@count}You are about to combine the following %1 tags into a single tag:{/ts}<br />
+    {', '|implode:$tags}
+  </div>
+  <table class="form-layout-compressed">
+    <tr class="crm-tag-form-block-label">
+      <td class="label">{$form.name.label}</td>
+      <td>{$form.name.html}</td>
+    </tr>
+  </table>
+  <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
+</div>
\ No newline at end of file
index 817fdddba812f83811d0778860ac36ca7c5e740e..64ccc9707eda5fc098f578e6b3e019997b4bfe8f 100644 (file)
  +--------------------------------------------------------------------+
 *}
 {* this template is used for adding/editing tags  *}
+{crmStyle file='bower_components/jstree/dist/themes/default/style.min.css'}
 {literal}
-<style>
-  #tagtree,
-  #tagtree li.highlighted ul {
-    background-color: white;
-  }
-  #tagtree li.highlighted,
-  #tagtree li.highlighted-child.jstree-closed {
-    background-color: #fefcb0;
-  }
-  #tagtree ins.jstree-icon {
-    cursor: pointer;
-  }
-</style>
 <script type="text/javascript">
   (function($, _){{/literal}
     var entityID={$entityID},
       entityTable='{$entityTable}',
       $form = $('form.{$form.formClass}');
     {literal}
-    CRM.updateContactSummaryTags = function() {
-      var tags = [];
-      $('#tagtree input:checkbox:checked+span label').each(function() {
-        tags.push('<span class="crm-tag-item" style="' + $(this).attr('style') + '" title="' + ($(this).attr('title') || '') + '">' + $(this).text() + '</span>');
-      });
-      $('input.crm-contact-tagset').each(function() {
-        $.each($(this).select2('data'), function (i, tag) {
-          tags.push('<span class="crm-tag-item" title="' + (tag.description || '') + '"' + (tag.color ? 'style="color: ' + CRM.utils.colorContrast(tag.color) + '; background-color: ' + tag.color + ';"' : '') + '>' + tag.label + '</span>');
-        });
-      });
-      // contact summary tabs and search forms both listen for this event
-      $($form).closest('.crm-ajax-container').trigger('crmFormSuccess', {tabCount: tags.length});
-      // update summary tab
-      $("#contact-summary #tags").html(tags.join(' '));
-    };
 
     $(function() {
-      function highlightSelected() {
-        $("ul input:not(:checked)", '#tagtree').each(function () {
-          $(this).closest("li").removeClass('highlighted highlighted-child');
+
+      // Display tags on the contact summary
+      function updateContactSummaryTags() {
+        var tags = [],
+          selected = $("#tagtree").jstree(true).get_selected(true);
+        $.each(selected, function(k, item) {
+          var $tag = $(item.text);
+          tags.push('<span class="crm-tag-item" style="' + $tag.attr('style') + '" title="' + ($tag.attr('title') || '') + '">' + $tag.text() + '</span>');
         });
-        $("ul input:checked", '#tagtree').each(function () {
-          $(this).closest("li").addClass('highlighted');
-          $(this).parents("li[id^=tag]").addClass('highlighted-child');
+        $('input.crm-contact-tagset').each(function() {
+          $.each($(this).select2('data'), function (i, tag) {
+            tags.push('<span class="crm-tag-item" title="' + (tag.description || '') + '"' + (tag.color ? 'style="color: ' + CRM.utils.colorContrast(tag.color) + '; background-color: ' + tag.color + ';"' : '') + '>' + tag.label + '</span>');
+          });
         });
+        // contact summary tabs and search forms both listen for this event
+        $($form).closest('.crm-ajax-container').trigger('crmFormSuccess', {tabCount: tags.length});
+        // update summary tab
+        $("#contact-summary #tags").html(tags.join(' '));
       }
-      highlightSelected();
 
-      $("#tagtree input").change(function(){
-        var tagid = this.id.replace("check_", "");
-        var op = (this.checked) ? 'create' : 'delete';
-        var api = CRM.api3('entity_tag', op, {entity_table: entityTable, entity_id: entityID, tag_id: tagid}, true);
-        highlightSelected();
-        CRM.updateContactSummaryTags();
-      });
-      var childTag = "{/literal}{$loadjsTree}{literal}";
-      if (childTag) {
-        //load js tree.
+      // Load js tree.
+      CRM.loadScript(CRM.config.resourceBase + 'bower_components/jstree/dist/jstree.min.js').done(function() {
         $("#tagtree").jstree({
-          plugins : ["themes", "html_data"],
-          core: {animation: 100},
-          themes: {
-            "theme": 'classic',
-            "dots": false,
-            "icons": false,
-            "url": CRM.config.resourceBase + 'packages/jquery/plugins/jstree/themes/classic/style.css'
+          plugins : ['search', 'wholerow', 'checkbox'],
+          core: {
+            animation: 100,
+            themes: {
+              "theme": 'classic',
+              "dots": false,
+              "icons": false
+            }
+          },
+          'search': {
+            'case_insensitive' : true,
+            'show_only_matches': true
+          },
+          checkbox: {
+            three_state: false
           }
-        });
-      }
-      {/literal}
-      {if $permission neq 'edit'}
-        {literal}
-          $("#tagtree input").prop('disabled', true);
-        {/literal}
-      {/if}
-      {literal}
+        })
+          .on('select_node.jstree deselect_node.jstree', function(e, selected) {
+            var id = selected.node.a_attr.id.replace('tag_', ''),
+              op = e.type === 'select_node' ? 'create' : 'delete';
+            CRM.api3('entity_tag', op, {entity_table: entityTable, entity_id: entityID, tag_id: id}, true);
+            updateContactSummaryTags();
+          });
+      });
 
-      $(document).on('change', 'input.crm-contact-tagset', CRM.updateContactSummaryTags);
+      $(document).on('change', 'input.crm-contact-tagset', updateContactSummaryTags);
+
+      $('input[name=filter_tag_tree]', '#Tag').on('keyup change', function() {
+        $("#tagtree").jstree(true).search($(this).val());
+      });
     });
   })(CRM.$, CRM._);
   {/literal}
 </script>
 <div id="Tag" class="view-content">
-  <h3>{if !$hideContext}{ts}Tags{/ts}{/if}</h3>
-  <div id="tagtree">
-    {include file="CRM/Tag/Form/Tagtree.tpl" level=1}
-  </div>
-  <br />
-{include file="CRM/common/Tagset.tpl"}
+  <table class="">
+    <thead>
+      <tr>
+        <th>{ts}Tag Tree{/ts}</th>
+        {if $tagsetInfo.contact}<th>{ts}Tag Sets{/ts}</th>{/if}
+      </tr>
+    </thead>
+    <tbody>
+      <tr>
+        <td>
+          <input class="crm-form-text big" name="filter_tag_tree" placeholder="{ts}Filter List{/ts}" allowclear="1"/>
+          <a class="crm-hover-button crm-clear-link" style="visibility:hidden;" title="{ts}Clear{/ts}"><i class="crm-i fa-times"></i></a>
+          <div id="tagtree">
+            {include file="CRM/Tag/Form/Tagtree.tpl" level=1}
+          </div>
+        </td>
+        {if $tagsetInfo.contact}
+        <td>
+          {include file="CRM/common/Tagset.tpl"}
+        </td>
+        {/if}
+      </tr>
+    </tbody>
+  </table>
 </div>
index 8102dabb924046e61ee91f96388ce645137e202b..8f3a1df17e9a583d6c14e98cb7bf67aff525dd1d 100644 (file)
 {* This tpl runs recursively to build each level of the tag tree *}
 <ul class="tree-level-{$level}">
   {foreach from=$tree item="node" key="id"}
-    <li id="tag_{$id}">
-      <input name="tagList[{$id}]" id="check_{$id}" type="checkbox" {if $node.is_selectable EQ 0}disabled=""{/if} {if $tagged[$id]}checked="checked"{/if}/>
-      <span>
-        <label for="check_{$id}" id="tagLabel_{$id}" class="crm-tag-item" {if !empty($allTags.$id.color)}style="background-color: {$allTags.$id.color}; color: {$allTags.$id.color|colorContrast};"{/if} title="{$node.description}">
+    <li>
+      <a id="tag_{$id}" class="{if !$node.is_selectable || $permission neq 'edit'}jstree-disabled{/if} {if $tagged[$id]}jstree-clicked{/if}">
+        <span class="crm-tag-item" {if !empty($allTags.$id.color)}style="background-color: {$allTags.$id.color}; color: {$allTags.$id.color|colorContrast};"{/if} title="{$node.description}">
           {$node.name}
-        </label>
-      </span>
+        </span>
+      </a>
       {if $node.children}
         {* Recurse... *}
         {include file="CRM/Tag/Form/Tagtree.tpl" tree=$node.children level=$level+1}
index dd292d70b94bd6b980d5a9392d46c545f1c80a1b..c30187d1b6018dd14c27c07b63947070c1d3e049 100644 (file)
  | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
  +--------------------------------------------------------------------+
 *}
+<div class="crm-content-block">
+  <div class="help">
+    {ts 1=', '|implode:$usedFor}Tags are a convenient way to categorize data (%1).{/ts}
+    {if call_user_func(array('CRM_Core_Permission','check'), 'administer Tagsets')}
+      <br />
+      {ts}Create predefined tags in the main tree, or click the <strong>+</strong> to add a set for free tagging.{/ts}
+    {/if}
+    {docURL page="user/organising-your-data/groups-and-tags"}
+  </div>
 
-{capture assign=docLink}{docURL page="user/organising-your-data/groups-and-tags"}{/capture}
-
-{if $action eq 1 or $action eq 2 or $action eq 8}
-  {include file="CRM/Tag/Form/Edit.tpl"}
-{else}
-  <div class="crm-content-block">
-    <div class="help">
-      {ts 1=$docLink}Tags can be assigned to any contact record, and are a convenient way to find contacts. You can create as many tags as needed to organize and segment your records.{/ts} {$docLink}
-    </div>
-
-    {if $rows}
-      <div id="mainTabContainer">
-        <ul>
-          <li class="ui-corner-all crm-tab-button">
-            <a href="#tags">{ts}Tags{/ts}</a>
-          </li>
-          <li class="ui-corner-all crm-tab-button">
-            <a href="#tagsets">{ts}Tag Sets{/ts}</a>
-          </li>
-        </ul>
-        <div id="tags">
-          {if !($action eq 1 and $action eq 2)}
-            <div class="crm-submit-buttons">
-              <div class="action-link">
-                {crmButton q="action=add&reset=1" id="newTag"  icon="plus-circle"}{ts}Add Tag{/ts}{/crmButton}
-              </div>
-            </div>
-          {/if}
-          {strip}
-            <table id="tags_table" class="display">
-              <thead>
-              <tr>
-                <th>{ts}Tag{/ts}</th>
-                <th>{ts}ID{/ts}</th>
-                <th id="nosort">{ts}Description{/ts}</th>
-                <th>{ts}Parent (ID){/ts}</th>
-                <th>{ts}Used For{/ts}</th>
-                <th>{ts}Reserved?{/ts}</th>
-                <th></th>
-              </tr>
-              </thead>
-              {foreach from=$rows item=row key=id }
-                {if !$row.is_tagset && !$row.is_tagset_child}
-                  <tr class="{if $row.parent_id}child-row{/if} {if $row.grandparent_id}grandchild-row{/if} crm-tag crm-entity" id="tag-{$row.id}">
-                    <td class="crm-tag-name crm-editable crmf-name" {if $row.color}style="background-color: {$row.color}; color: {$row.color|colorContrast};"{/if}>
-                      {$row.name}
-                    </td>
-                    <td class="crm-tag-id">{$row.id}</td>
-                    <td class="crm-tag-description crm-editable crmf-description">{$row.description} </td>
-                    <td class="crm-tag-parent">{$row.parent}{if $row.parent_id} ({$row.parent_id}){/if}</td>
-                    <td class="crm-tag-used_for">{$row.used_for}</td>
-                    <td class="crm-tag-is_reserved">{if $row.is_reserved}<img src="{$config->resourceBase}i/check.gif" alt="{ts}Reserved{/ts}" />{/if}</td>
-                    <td>{$row.action|replace:'xx':$row.id}</td>
-                  </tr>
-                {/if}
-              {/foreach}
-            </table>
-          {/strip}
-        </div>
-        <div id="tagsets">
-          {if !($action eq 1 and $action eq 2) && $adminTagSet}
-            <div class="crm-submit-buttons">
-              <div class="action-link">
-                {crmButton q="action=add&reset=1&tagset=1" id="newTagSet"  icon="plus-circle"}{ts}Add Tag Set{/ts}{/crmButton}
-              </div>
-            </div>
-          {/if}
-          {strip}
-            <table id="tagsets_table" class="display">
-              <thead>
-              <tr>
-                <th>{ts}Tag{/ts}</th>
-                <th>{ts}ID{/ts}</th>
-                <th id="nosort">{ts}Description{/ts}</th>
-                <th>{ts}Parent (ID){/ts}</th>
-                <th>{ts}Used For{/ts}</th>
-                <th>{ts}Reserved?{/ts}</th>
-                <th></th>
-              </tr>
-              </thead>
-              {foreach from=$rows item=row key=id}
-                {if $row.is_tagset || $row.is_tagset_child}
-                  <tr class="{if $row.parent_id}child-row{/if} crm-tag crm-entity" id="tag-{$row.id}">
-                    <td class="crm-tag-name crm-editable crmf-name" {if $row.color}style="background-color: {$row.color}; color: {$row.color|colorContrast};"{/if}>
-                      {$row.name}
-                    </td>
-                    <td class="crm-tag-id">{$row.id}</td>
-                    <td class="crm-tag-description crm-editable crmf-description">{$row.description} </td>
-                    <td class="crm-tag-parent">{$row.parent}{if $row.parent_id} ({$row.parent_id}){/if}</td>
-                    <td class="crm-tag-used_for">{$row.used_for}</td>
-                    <td class="crm-tag-is_reserved">{if $row.is_reserved}<img src="{$config->resourceBase}i/check.gif" alt="{ts}Reserved{/ts}" />{/if}</td>
-                    <td>{$row.action|replace:'xx':$row.id}</td>
-                  </tr>
-                {/if}
-              {/foreach}
-            </table>
-          {/strip}
-        </div>
-      </div>
-      {if !($action eq 1 and $action eq 2)}
-        <div class="crm-submit-buttons">
-          <div class="action-link">
-            {crmButton q="action=add&reset=1" id="newTag"  icon="plus-circle"}{ts}Add Tag{/ts}{/crmButton}
-            {if $adminTagSet}
-              {crmButton q="action=add&reset=1&tagset=1" id="newTagSet"  icon="plus-circle"}{ts}Add Tag Set{/ts}{/crmButton}
-            {/if}
-          </div>
-        </div>
+  <div id="mainTabContainer">
+    <ul>
+      <li class="ui-corner-all crm-tab-button" title="{ts}Main Tag List{/ts}">
+        <a href="#tree"><i class="crm-i fa-tags"></i> {ts}Tag Tree{/ts}</a>
+      </li>
+      {foreach from=$tagsets item=set}
+        <li class="ui-corner-all crm-tab-button {if ($set.is_reserved)}is-reserved{/if}" title="{ts 1=', '|implode:$set.used_for_label}Tag Set for %1{/ts}">
+          <a href="#tagset-{$set.id}">{$set.name}</a>
+        </li>
+      {/foreach}
+      {if call_user_func(array('CRM_Core_Permission','check'), 'administer Tagsets')}
+        <li class="ui-corner-all crm-tab-button" title="{ts}Add Tag Set{/ts}">
+          <a href="#new-tagset"><i class="crm-i fa-plus"></i></a>
+        </li>
       {/if}
-      <div id="merge_tag_status"></div>
-      {include file="CRM/common/jsortable.tpl"}
-    {else}
-      <div class="messages status no-popup">
-        <div class="icon inform-icon"></div>&nbsp;
-        {capture assign=crmURL}{crmURL p='civicrm/tag' q="action=add&reset=1"}{/capture}
-        {ts 1=$crmURL}There are no Tags present. You can <a href='%1'>add one</a>.{/ts}
+    </ul>
+    <div id="tree">
+      <div class="help">
+        {ts}Organize the tag hierarchy by clicking and dragging. Shift-click to select multiple tags to merge/move/delete.{/ts}
       </div>
-    {/if}
-
+    </div>
+    {foreach from=$tagsets item=set}
+      <div id="tagset-{$set.id}">
+      </div>
+    {/foreach}
+    <div id="new-tagset">
+    </div>
   </div>
-
+</div>
+{crmAPI entity="Contact" action="getsingle" var="user" return='display_name' id="user_contact_id"}
 {literal}
-  <script type="text/javascript">
-    CRM.$(function($) {
-      var tag;
-      $('#mainTabContainer').tabs();
-      $('.merge_tag').click(function(e) {
-        tag = $(this).crmEditableEntity();
-        mergeTagDialog();
-        e.preventDefault();
-      });
+<script type="text/javascript">
+  (function($, _) {
+    $(function($) {
+      var $window = $(window),
+        renderedTabs = ['tree'],
+        tagSets = {/literal}{$tagsets|@json_encode}{literal},
+        user = {/literal}{$user|@json_encode}{literal},
+        usedFor = {/literal}{$usedFor|@json_encode}{literal},
+        menuHeight = $('#civicrm-menu').height() + 15,
+        noneSelectedTpl = _.template($('#noneSelectedTpl').html()),
+        oneSelectedTpl = _.template($('#oneSelectedTpl').html()),
+        moreSelectedTpl = _.template($('#moreSelectedTpl').html()),
+        tagsetHelpTpl = _.template($('#tagsetHelpTpl').html());
 
-      function mergeTagDialog() {
-        var tagUrl = {/literal}"{crmURL p='civicrm/ajax/mergeTagList' h=0}"{literal};
-        var title = {/literal}'{ts escape="js" 1="%1"}Merge tag %1 into:{/ts}'{literal};
-        CRM.confirm({
-            title: ts(title, {1: tag.name}),
-            message: '<input name="select_merge_tag" class="big" />',
-            open: function() {
-              var dialog = this;
-              $('input[name=select_merge_tag]', dialog)
-                .crmSelect2({
-                  placeholder: {/literal}'{ts escape="js"}- select tag -{/ts}'{literal},
-                  minimumInputLength: 1,
-                  ajax: {
-                    url: tagUrl,
-                    data: function(term) {
-                      return {term: term, fromId: tag.id};
-                    },
-                    results: function(response) {
-                      return {results: response};
-                    }
-                  }
-                })
-                .change(function() {
-                  $('.messages', dialog).remove();
-                  if ($(this).val() && $(this).select2('data').warning) {
-                    $(dialog).append('<div class="messages status">{/literal}{ts escape='js'}Note: the selected tag is used by additional entities.{/ts}{literal}</div>');
-                  }
-                });
-            }
+      function formatTagSet(info) {
+        info.date = CRM.utils.formatDate(info.created_date);
+        info.used_for_label = [];
+        if (undefined !== info.used_for) {
+          _.each(info.used_for.split(','), function(item) {
+            info.used_for_label.push(usedFor[item]);
+          });
+        }
+      }
+
+      _.each(tagSets, formatTagSet);
+
+      function renderTree($panel) {
+        var plugins,
+          selected = [],
+          tagset = $panel.attr('id').split('-')[1] || 0;
+
+        function hasChildren(id) {
+          var $node = $('.tag-tree', $panel).jstree(true).get_node(id, true);
+          return !$node.hasClass('jstree-leaf');
+        }
+
+        function changeColor() {
+          var color = $(this).val().toLowerCase(),
+            id = $(this).closest('.crm-entity').data('id'),
+            node = $('.tag-tree', $panel).jstree(true).get_node(id);
+          if (color === '#ffffff') {
+            node.a_attr.style = '';
+          } else {
+            node.a_attr.style = 'background-color: ' + color + '; color: ' + CRM.utils.colorContrast(color) + ';';
+          }
+          node.data.color = color;
+          $('.tag-tree', $panel).jstree(true).redraw(true);
+          CRM.api3('Tag', 'create', {id: id, color: color}, true);
+        }
+
+        function changeSelection(e, data) {
+          var tplParams = {
+            tagset: tagset,
+            tagsetCount: _.keys(tagSets).length,
+            adminReserved: CRM.checkPerm('administer reserved tags')
+          },
+            tree = $('.tag-tree', $panel).jstree(true),
+            $infoBox = $('.tag-info', $panel);
+          selected = data.selected;
+          if (!data.selected || !data.selected.length) {
+            tplParams.is_reserved = tagset ? tagSets[tagset].is_reserved == 1 : false;
+            tplParams.length = $('.tag-tree li', $panel).length;
+            tplParams.adminTagsets = CRM.checkPerm('administer Tagsets');
+            $infoBox.html(noneSelectedTpl(tplParams));
+          } else if (data.selected.length === 1) {
+            tplParams.usedFor = usedFor;
+            tplParams.hasChildren = hasChildren(data.node.id);
+            $infoBox.html(oneSelectedTpl($.extend({}, data.node, tplParams)));
+          } else {
+            tplParams.items = data.selected;
+            tplParams.hasChildren = tplParams.reserved = tplParams.usages = 0;
+            _.each(data.selected, function(id) {
+              var node = tree.get_node(id);
+              tplParams.usages += node.data.usages;
+              tplParams.reserved += node.data.is_reserved;
+              tplParams.hasChildren += hasChildren(id) ? 1 : 0;
+            });
+            $infoBox.html(moreSelectedTpl(tplParams));
+          }
+          $infoBox.trigger('crmLoad');
+        }
+
+        function clearSelection(e) {
+          e.preventDefault();
+          $('.tag-tree', $panel).jstree(true).deselect_all();
+        }
+
+        function changeUsedFor() {
+          var vals = $('input[name=used_for]:checked', $panel).map(function(i, el) {
+            return $(el).val();
+          }).get(),
+            id = $(this).closest('.crm-entity').data('id');
+          if (vals.length) {
+            CRM.api3('Tag', 'create', {id: id, used_for: vals}, true);
+            var node = $('.tag-tree', $panel).jstree(true).get_node(id);
+            node.data.used_for = vals;
+          }
+        }
+
+        function moveTag(e, data) {
+          if (data.parent != data.old_parent) {
+            CRM.api3('Tag', 'create', {id: data.node.id, parent_id: data.parent.replace('#', '')}, true);
+          }
+        }
+
+        function deleteTagset() {
+          $('#mainTabContainer').tabs('option', 'active', 0);
+          $panel.off().remove();
+          $("a[href='#tagset-" + tagset + "']").parent().remove();
+          $('#mainTabContainer').tabs('refresh');
+        }
+
+        function updateTagset(info) {
+          tagSets[tagset].description = info.description;
+          tagSets[tagset].name = info.name;
+          tagSets[tagset].used_for = info.used_for;
+          tagSets[tagset].is_reserved = info.is_reserved;
+          formatTagSet(tagSets[tagset]);
+          $('.help', $panel).remove();
+          addHelp();
+        }
+
+        function addHelp() {
+          $panel.prepend(tagsetHelpTpl(tagSets[tagset]));
+          $("a[href='#tagset-" + tagset + "']").text(tagSets[tagset].name)
+            .parent().toggleClass('is-reserved', tagSets[tagset].is_reserved == 1)
+            .attr('title', ts('{/literal}{ts escape='js' 1='%1'}Tag Set for %1{/ts}{literal}', {'1': tagSets[tagset].used_for_label.join(', ')}));
+        }
+
+        if (tagset) {
+          addHelp();
+        }
+
+        function moveTagDialog(e) {
+          e.preventDefault();
+          var sets = [{key: '0', value: '{/literal}{ts escape='js'}Main Tag Tree{/ts}{literal}'}];
+          _.each(tagSets, function(tagSet) {
+            sets.push({key: tagSet.id, value: tagSet.name});
+          });
+          CRM.confirm({
+            title: '{/literal}{ts escape='js'}Move to Tagset{/ts}{literal}',
+            message: '<label for="select-tagset">{/literal}{ts escape='js'}Select Tagset{/ts}{literal}: '
+              + '<select id="select-tagset" class="crm-select2 big">'
+              + CRM.utils.renderOptions(sets, tagset)
+              + '</select>'
           })
-          .on('dialogclose', function() {
-            $('input[name=select_merge_tag]', this).select2('destroy');
+            .on('crmConfirm:yes', function() {
+              var chosen = parseInt($('#select-tagset').val());
+              if (parseInt(tagset) !== chosen) {
+                var apiCalls = [];
+                _.each(selected, function(id) {
+                  apiCalls.push(['Tag', 'create', {id: id, parent_id: chosen || ''}]);
+                });
+                $('#mainTabContainer').block();
+                CRM.api3(apiCalls, true)
+                  .done(function() {
+                    $('.tag-tree', $panel).jstree(true).refresh();
+                    $('#mainTabContainer').unblock();
+                    var $otherPanel = $(chosen ? '#tagset-' + chosen : '#tree');
+                    if ($('.tag-tree', $otherPanel).length) {
+                      $('.tag-tree', $otherPanel).jstree(true).refresh();
+                    }
+                  });
+              }
+            });
+        }
+
+        $panel
+          .append('<div class="tag-tree-wrapper"><div class="tag-tree"></div><div class="tag-info"></div></div>')
+          .on('change', 'input[type=color]', changeColor)
+          .on('change', 'input[name=used_for]', changeUsedFor)
+          .on('click', '.clear-tag-selection', clearSelection)
+          .on('click', '.move-tag-button', moveTagDialog)
+          .on('click', '.used-for-toggle', function() {
+            $(this).attr('style', 'display: none !important;').next().show();
           })
-          .on('crmConfirm:yes', function() {
-            var toId = $("input[name=select_merge_tag]", this).val();
-            if (!toId) {
-              $("input[name=select_merge_tag]", this).crmError('{/literal}{ts escape='js'}Select a tag{/ts}{literal}');
-              return false;
+          .on('crmPopupFormSuccess crmFormSuccess', function(e, cts, data) {
+            if ($(e.target).hasClass('tagset-action-delete')) {
+              deleteTagset();
+            } else if ($(e.target).hasClass('tagset-action-update')) {
+              updateTagset(data.tag);
+            } else {
+              $('.tag-tree', $panel).jstree(true).refresh();
             }
-            var postUrl = {/literal}"{crmURL p='civicrm/ajax/mergeTags' h=0 }"{literal};
-            var data = {fromId: tag.id, toId: toId, key:{/literal}"{crmKey name='civicrm/ajax/mergeTags'}"{literal}};
-            $.ajax({
-              type: "POST",
-              url: postUrl,
-              data: data,
-              dataType: "json",
-              success: function(values) {
-                if ( values.status == true ) {
-                  $('#tag-' + toId).children('td.crm-tag-used_for').text(values.tagB_used_for);
-                  $('#tag-' + tag.id).html('<td colspan="8"><div class="status message"><div class="icon inform-icon"></div>' + values.message + '</div></td>');
+          });
+
+        plugins = ['wholerow', 'changed'];
+        if (!tagset) {
+          // Allow drag-n-drop nesting of the tag tree
+          plugins.push('dnd');
+        }
+
+        $('.tag-tree', $panel)
+          .on('changed.jstree loaded.jstree', changeSelection)
+          .on('move_node.jstree', moveTag)
+          .jstree({
+            core: {
+              data: {
+                url: CRM.url('civicrm/ajax/tagTree'),
+                data: function(node) {
+                  return {parent_id: node.id === '#' ? tagset : node.id};
                 }
-              }
-            });
+              },
+              check_callback: true
+            },
+            plugins: plugins,
+            dnd: {
+              copy: false
+            }
+          });
+      }
+
+      function newTagset() {
+        CRM.loadForm(CRM.url('civicrm/tag/edit', {action: 'add', tagset: 1}))
+          .on('crmFormSuccess', function(e, data) {
+            tagSets[data.tag.id] = data.tag;
+            tagSets[data.tag.id].display_name = user.display_name;
+            formatTagSet(tagSets[data.tag.id]);
+            $("#new-tagset").before('<div id="tagset-' + data.tag.id + '">');
+            $("a[href='#new-tagset']").parent().before('<li class="ui-corner-all crm-tab-button"><a href="#tagset-' + data.tag.id + '">' + data.tag.name + '</a></li>');
+            $('#mainTabContainer').tabs('refresh');
+            $('#mainTabContainer').tabs('option', 'active', -2);
           });
       }
+
+      $('#mainTabContainer')
+        .tabs()
+        .on("tabsbeforeactivate", function (event, ui) {
+          var id = $(ui.newPanel).attr('id');
+          if (id === 'new-tagset') {
+            event.preventDefault();
+            newTagset();
+            return false;
+          }
+          if ($.inArray(id, renderedTabs) < 0) {
+            renderedTabs.push(id);
+            renderTree(ui.newPanel);
+          }
+        });
+
+      renderTree($('#tree'));
+
+      // Prevent the info box from scrolling offscreen
+      $window.on('scroll resize', function () {
+        var $wrapper = $('.tag-tree-wrapper:visible'),
+          pos = $wrapper.offset(),
+          $box = $('.tag-info:visible');
+        if ($window.scrollTop() + menuHeight > pos.top) {
+          $box.css({
+            position: 'fixed',
+            top: menuHeight,
+            right: parseInt($window.width() - (pos.left + $wrapper.width())),
+            width: parseInt($wrapper.width() * .40)
+          });
+        } else {
+          $box.removeAttr('style');
+        }
+      });
+
     });
-  </script>
-  <style type="text/css">
-    .crm-container tr.child-row td:first-child {
-      padding-left: 2em;
-    }
-    .crm-container tr.grandchild-row td:first-child {
-      padding-left: 3em;
-    }
-  </style>
+  })(CRM.$, CRM._);
+</script>
+<style type="text/css">
+  div.tag-tree-wrapper {
+    position: relative;
+    min-height: 250px;
+  }
+  div.tag-tree {
+    width: 59%;
+  }
+  div.tag-info {
+    width: 40%;
+    position: absolute;
+    top: 5px;
+    right: 0;
+    min-height: 100px;
+    border: 1px solid #aaa;
+    border-radius: 4px;
+    box-shadow: 0 0 4px #e3e3e3;
+    padding: 1em;
+    box-sizing: border-box;
+    background: white;
+  }
+  div.tag-info .clear-tag-selection {
+    position: absolute;
+    top: 10px;
+    right: 12px;
+    color: inherit;
+    opacity: .5;
+  }
+  div.tag-info .clear-tag-selection:hover,
+  div.tag-info .clear-tag-selection:active {
+    opacity: 1;
+  }
+  .tag-tree-wrapper .tag-tree a.crm-tag-item {
+    border-radius: 3px;
+    margin: 2px 0;
+    height: 20px;
+    line-height: 20px;
+    font-size: 12px;
+    padding: 0 3px;
+  }
+  #tree a.crm-tag-item {
+    cursor: move;
+  }
+  li.is-reserved > a:after {
+    content: ' *';
+  }
+  .tag-tree-wrapper ul {
+    margin: 0;
+    padding: 0;
+  }
+  div.tag-info h4 .crm-editable {
+    min-width: 60%;
+    padding: .2em;
+  }
+  div.tag-info .crm-editable-enabled {
+    min-width: 5em;
+  }
+  div.tag-info .crm-editable-enabled[data-field=description] {
+    min-width: 60%;
+  }
+  div.tag-info input[type=color] {
+    cursor: pointer;
+  }
+  div.tag-info .tdl {
+    font-weight: bold;
+    color: #999;
+  }
+  div.tag-info hr {
+    margin: .2em 0;
+  }
+  div.tag-info .crm-submit-buttons {
+    margin: 10px 0 0;
+  }
+</style>
 {/literal}
 
-{/if}
+<script type="text/template" id="noneSelectedTpl">
+  <% if (length) {ldelim} %>
+    <h4>{ts}None Selected{/ts}</h4>
+    <hr />
+    <p>{ts}Select one or more tags for details.{/ts}</p>
+  <% {rdelim} else {ldelim} %>
+    <h4>{ts}Empty Tag Set{/ts}</h4>
+    <hr />
+    <p>{ts}No tags have been created in this set.{/ts}</p>
+  <% {rdelim} %>
+  <div class="crm-submit-buttons">
+    <a href="{crmURL p="civicrm/tag/edit" q="action=add&parent_id="}<%= tagset || '' %>" class="button crm-popup">
+      <span><i class="crm-i fa-plus"></i>&nbsp; {ts}Add Tag{/ts}</span>
+    </a>
+    <% if(tagset && adminTagsets) {ldelim} %>
+      <a href="{crmURL p="civicrm/tag/edit" q="action=update&id="}<%= tagset %>" class="button crm-popup tagset-action-update">
+        <span><i class="crm-i fa-pencil"></i>&nbsp; {ts}Edit Set{/ts}</span>
+      </a>
+    <% {rdelim} %>
+    <% if(tagset && !length && adminTagsets && (!is_reserved || adminReserved)) {ldelim} %>
+      <a href="{crmURL p="civicrm/tag/edit" q="action=delete&id="}<%= tagset %>" class="button crm-popup small-popup tagset-action-delete">
+        <span><i class="crm-i fa-trash"></i>&nbsp; {ts}Delete Set{/ts}</span>
+      </a>
+    <% {rdelim} %>
+  </div>
+</script>
+
+<script type="text/template" id="oneSelectedTpl">
+  <div class="crm-entity" data-entity="Tag" data-id="<%= id %>">
+    <h4>
+      <input type="color" value="<%= data.color %>" title="{ts}Select color{/ts}"/>
+      <span class="crm-editable" data-field="name"><%- text %></span>
+    </h4>
+    <hr />
+    <div><span class="tdl">{ts}Description:{/ts}</span>
+      <span class="crm-editable" data-field="description"><%- data.description %></span>
+    </div>
+    <div><span class="tdl">{ts}Selectable:{/ts}</span>
+      <span class="crm-editable" data-field="is_selectable" data-type="select"><% if (data.is_selectable) {ldelim} %> {ts}Yes{/ts} <% {rdelim} else {ldelim} %> {ts}No{/ts} <% {rdelim} %></span>
+    </div>
+    <div><span class="tdl">{ts}Reserved:{/ts}</span>
+      <span class="<% if (adminReserved) {ldelim} %>crm-editable<% {rdelim} %>" data-field="is_reserved" data-type="select"><% if (data.is_reserved) {ldelim} %> {ts}Yes{/ts} <% {rdelim} else {ldelim} %> {ts}No{/ts} <% {rdelim} %></span>
+    </div>
+    <% if (parent === '#' && !tagset) {ldelim} %>
+      <div>
+        <span class="tdl">{ts}Used For:{/ts}</span>
+        {literal}
+          <span class="crm-editable-enabled used-for-toggle">
+            <% if (!data.used_for.length) { %><i class="crm-i fa-pencil crm-editable-placeholder"></i><% } %>
+            <% _.forEach(data.used_for, function(key, i) { %><%- (i ? ', ' : '') + usedFor[key] %><% }) %>
+          </span>
+          <span style="display: none">
+          <% _.forEach(usedFor, function(label, key) { %>
+            <span style="white-space: nowrap">
+              <input type="checkbox" name="used_for" value="<%= key %>" id="<%= id + '_used_for_' + key %>" <% if (data.used_for.indexOf(key) > -1) { %>checked<% } %> />
+              <label for="<%= id + '_used_for_' + key %>"><%- label %></label>
+            </span>
+          <% }) %>
+          </span>
+        {/literal}
+      </div>
+    <% {rdelim} %>
+    <div><span class="tdl">{ts}Usage Count:{/ts}</span> <%= data.usages %></div>
+    <a class="clear-tag-selection" href="#" title="{ts}Clear selection{/ts}"><i class="crm-i fa-ban"></i></a>
+  </div>
+  <div class="crm-submit-buttons">
+    <% if(!tagset) {ldelim} %>
+      <a href="{crmURL p="civicrm/tag/edit" q="action=add&parent_id="}<%= id %>" class="button crm-popup" title="{ts}Create new tag under this one{/ts}">
+        <span><i class="crm-i fa-plus"></i>&nbsp; {ts}Add Child{/ts}</span>
+      </a>
+    <% {rdelim} %>
+    <a href="{crmURL p="civicrm/tag/edit" q="action=add&clone_from="}<%= id %>" class="button crm-popup" title="{ts}Duplicate ths tag{/ts}">
+      <span><i class="crm-i fa-copy"></i>&nbsp; {ts}Clone Tag{/ts}</span>
+    </a>
+    <% if(!data.is_reserved || adminReserved) {ldelim} %>
+      <% if(tagsetCount) {ldelim} %>
+        <a href="#move" class="button move-tag-button" title="{ts}Move to a different tagset{/ts}">
+          <span><i class="crm-i fa-share-square-o"></i>&nbsp; {ts}Move Tag{/ts}</span>
+        </a>
+      <% {rdelim} %>
+      <% if(!hasChildren) {ldelim} %>
+        <a href="{crmURL p="civicrm/tag/edit" q="action=delete&id="}<%= id %>" class="button crm-popup small-popup">
+          <span><i class="crm-i fa-trash"></i>&nbsp; {ts}Delete{/ts}</span>
+        </a>
+      <% {rdelim} %>
+    <% {rdelim} %>
+  </div>
+</script>
+
+<script type="text/template" id="moreSelectedTpl">
+  <h4>{ts 1="<%= items.length %>"}%1 Tags Selected{/ts}</h4>
+  <hr />
+    <% if (reserved) {ldelim} %>
+      <p>* {ts 1="<%= reserved %>"}%1 reserved.{/ts}</p>
+    <% {rdelim} %>
+  <p><span class="tdl">{ts}Total Usage:{/ts}</span> <%= usages %></p>
+  <a class="clear-tag-selection" href="#" title="{ts}Clear selection{/ts}"><i class="crm-i fa-ban"></i></a>
+  <div class="crm-submit-buttons">
+    <% if(!reserved || adminReserved) {ldelim} %>
+      <a href="{crmURL p="civicrm/tag/merge" q="id="}<%= items.join() %>" class="button crm-popup small-popup" title="{ts}Combine tags into one{/ts}">
+        <span><i class="crm-i fa-compress"></i>&nbsp; {ts}Merge Tags{/ts}</span>
+      </a>
+      <% if(tagsetCount) {ldelim} %>
+        <a href="#move" class="button move-tag-button" title="{ts}Move to a different tagset{/ts}">
+          <span><i class="crm-i fa-share-square-o"></i>&nbsp; {ts}Move Tags{/ts}</span>
+        </a>
+      <% {rdelim} %>
+      <% if(!hasChildren) {ldelim} %>
+        <a href="{crmURL p="civicrm/tag/edit" q="action=delete&id="}<%= items.join() %>" class="button crm-popup small-popup">
+          <span><i class="crm-i fa-trash"></i>&nbsp; {ts}Delete All{/ts}</span>
+        </a>
+      <% {rdelim} %>
+    <% {rdelim} %>
+  </div>
+</script>
+
+<script type="text/template" id="tagsetHelpTpl">
+  <div class="help">
+    <% if(is_reserved == 1) {ldelim} %><strong>{ts}Reserved{/ts}</strong><% {rdelim} %>
+    <% if(undefined === display_name) {ldelim} var display_name = null; {rdelim} %>
+    {ts 1="<%= used_for_label.join(', ') %>" 2="<%= date %>" 3="<%= display_name %>"}Tag Set for %1 (created %2 by %3).{/ts}
+    <% if(typeof description === 'string' && description.length) {ldelim} %><p><em><%- description %></em></p><% {rdelim} %>
+  </div>
+</script>
index ffdd708d35057253f4382659b239ee2f455f138a..da77dda5d11cfcbe248b8eea381c080d1aa83ced 100644 (file)
     {if $help_pre && $action neq 4}<div class="messages help">{$help_pre}</div>{/if}
     {assign var=zeroField value="Initial Non Existent Fieldset"}
     {assign var=fieldset  value=$zeroField}
-    {foreach from=$fields item=field key=fieldName}
-      {if $field.skipDisplay}
-        {continue}
-      {/if}
-      {if $field.groupTitle != $fieldset}
-        {if $fieldset != $zeroField}
-          {if $groupHelpPost && $action neq 4}
-          <div class="messages help">{$groupHelpPost}</div>
-          {/if}
-          {if $mode ne 8}
-          </fieldset>
-          {/if}
-        {/if}
-
-        {if $mode ne 8 && $action ne 1028 && $action ne 4 && !$hideFieldset}
-        <fieldset class="crm-profile crm-profile-id-{$field.group_id} crm-profile-name-{$field.groupName}"><legend>{$field.groupTitle}</legend>
-        {/if}
-
-        {if ($form.formName eq 'Confirm' OR $form.formName eq 'ThankYou') AND $prefix neq 'honor'}
-          <div class="header-dark">{$field.groupTitle} </div>
-        {/if}
-        {assign var=fieldset  value=`$field.groupTitle`}
-        {assign var=groupHelpPost  value=`$field.groupHelpPost`}
-        {if $field.groupHelpPre && $action neq 4 && $action neq 1028}
-          <div class="messages help">{$field.groupHelpPre}</div>
-        {/if}
-      {/if}
-
-      {assign var=n value=$field.name}
-
-      {if $field.field_type eq "Formatting"}
-        {if $action neq 4 && $action neq 1028}
-          {$field.help_pre}
-        {/if}
-      {elseif $n}
-        {* Show explanatory text for field if not in 'view' or 'preview' modes *}
-        {if $field.help_pre && $action neq 4 && $action neq 1028}
-          <div class="crm-section helprow-{$n}-section helprow-pre" id="helprow-{$n}">
-            <div class="content description">{$field.help_pre}</div>
-          </div>
-        {/if}
-        {if $field.options_per_line != 0}
-          <div class="crm-section editrow_{$n}-section form-item" id="editrow-{$n}">
-            <div class="label option-label">{if $prefix}{$form.$prefix.$n.label}{else}{$form.$n.label}{/if}</div>
-            <div class="content 3">
-              {assign var="count" value="1"}
-              {strip}
-                <table class="form-layout-compressed">
-                <tr>
-                {* sort by fails for option per line. Added a variable to iterate through the element array*}
-                  {assign var="index" value="1"}
-                  {if $prefix}
-                    {assign var="formElement" value=$form.$prefix.$n}
-                  {else}
-                    {assign var="formElement" value=$form.$n}
-                  {/if}
-                  {foreach name=outer key=key item=item from=$formElement}
-                    {if $index < 10}
-                      {assign var="index" value=`$index+1`}
-                    {else}
-                      <td class="labels font-light">{$formElement.$key.html}</td>
-                      {if $count == $field.options_per_line}
-                      </tr>
-                      <tr>
-                        {assign var="count" value="1"}
-                      {else}
-                        {assign var="count" value=`$count+1`}
-                      {/if}
-                    {/if}
-                  {/foreach}
-                </tr>
-                </table>
-              {/strip}
-            </div>
-            <div class="clear"></div>
-          </div>
-        {else}
-          <div class="crm-section editrow_{$n}-section form-item" id="editrow-{$n}">
-            <div class="label">
-              {if $prefix}{$form.$prefix.$n.label}{else}{$form.$n.label}{/if}
-            </div>
-            <div class="content">
-              {if $n|substr:0:3 eq 'im-'}
-                {assign var="provider" value=$n|cat:"-provider_id"}
-                {$form.$provider.html}&nbsp;
-              {/if}
-
-              {if $n eq 'email_greeting' or  $n eq 'postal_greeting' or $n eq 'addressee'}
-                {include file="CRM/Profile/Form/GreetingType.tpl"}
-              {elseif ($n eq 'group' && $form.group) || ($n eq 'tag' && $form.tag)}
-                {include file="CRM/Contact/Form/Edit/TagsAndGroups.tpl" type=$n title=null context="profile"}
-              {elseif ( $n|substr:-5:5 eq '_date' ) AND
-              ( $form.formName neq 'Confirm' )  AND
-              ( $form.formName neq 'ThankYou' ) }
-                {include file="CRM/common/jcalendar.tpl" elementName=$n}
-              {elseif ( $n|substr:-5:5 eq '_date' ) }
-                {assign var="date_value" value=$form.$n.value}
-                <span class="crm-frozen-field">
-                  {$date_value|date_format:"%Y-%m-%d"|crmDate:$config->dateformatshortdate}
-                  <input type="hidden" name="{$form.$n.name}" value="{$form.$n.value}" id="{$form.$n.name}">
-                </span>
-              {elseif $n|substr:0:5 eq 'phone'}
-                {assign var="phone_ext_field" value=$n|replace:'phone':'phone_ext'}
-                {if $prefix}{$form.$prefix.$n.html}{else}{$form.$n.html}{/if}
-                {if $form.$phone_ext_field.html}
-                  &nbsp;{$form.$phone_ext_field.html}
-                {/if}
-              {else}
-                {if $prefix}
-                  {if $n eq 'organization_name' && !empty($form.onbehalfof_id)}
-                    {$form.onbehalfof_id.html}
-                  {/if}
-                  {if $field.html_type eq 'File' && $viewOnlyPrefixFileValues}
-                    {$viewOnlyPrefixFileValues.$prefix.$n}
-                  {else}
-                    {$form.$prefix.$n.html}
-                  {/if}
-    {elseif $field.html_type eq 'File' && $viewOnlyFileValues}
-      {$viewOnlyFileValues.$n}
-               {else}
-                 {$form.$n.html}
-               {/if}
-              {/if}
-
-            {*CRM-4564*}
-              {if $field.html_type eq 'Autocomplete-Select'}
-                {if $field.data_type eq 'ContactReference'}
-                {include file="CRM/Custom/Form/ContactReference.tpl" element_name = $n}
-                {/if}
-              {/if}
-          </div>
-          <div class="clear"></div>
-        </div>
-        {/if}
-        {* Show explanatory text for field if not in 'view' or 'preview' modes *}
-        {if $field.help_post && $action neq 4 && $action neq 1028}
-          <div class="crm-section helprow-{$n}-section helprow-post" id="helprow-{$n}">
-            <div class="content description">{$field.help_post}</div>
-          </div>
-        {/if}
-      {/if}
-    {/foreach}
+    {include file="CRM/UF/Form/Fields.tpl"}
 
     {if $field.groupHelpPost && $action neq 4  && $action neq 1028}
       <div class="messages help">{$field.groupHelpPost}</div>
diff --git a/templates/CRM/UF/Form/Fields.tpl b/templates/CRM/UF/Form/Fields.tpl
new file mode 100644 (file)
index 0000000..e16d730
--- /dev/null
@@ -0,0 +1,142 @@
+{foreach from=$fields item=field key=fieldName}
+  {if $field.skipDisplay}
+    {continue}
+  {/if}
+  {if $field.groupTitle != $fieldset}
+    {if $fieldset != $zeroField}
+      {if $groupHelpPost && $action neq 4}
+        <div class="messages help">{$groupHelpPost}</div>
+      {/if}
+      {if $mode ne 8}
+        </fieldset>
+      {/if}
+    {/if}
+
+    {if $mode ne 8 && $action ne 1028 && $action ne 4 && !$hideFieldset}
+      <fieldset class="crm-profile crm-profile-id-{$field.group_id} crm-profile-name-{$field.groupName}"><legend>{$field.groupTitle}</legend>
+    {/if}
+
+    {if ($form.formName eq 'Confirm' OR $form.formName eq 'ThankYou') AND $prefix neq 'honor'}
+      <div class="header-dark">{$field.groupTitle} </div>
+    {/if}
+    {assign var=fieldset  value=`$field.groupTitle`}
+    {assign var=groupHelpPost  value=`$field.groupHelpPost`}
+    {if $field.groupHelpPre && $action neq 4 && $action neq 1028}
+      <div class="messages help">{$field.groupHelpPre}</div>
+    {/if}
+  {/if}
+
+  {assign var=profileFieldName value=$field.name}
+
+  {if $field.field_type eq "Formatting"}
+    {if $action neq 4 && $action neq 1028}
+      {$field.help_pre}
+    {/if}
+  {elseif $profileFieldName}
+    {* Show explanatory text for field if not in 'view' or 'preview' modes *}
+    {if $field.help_pre && $action neq 4 && $action neq 1028}
+      <div class="crm-section helprow-{$profileFieldName}-section helprow-pre" id="helprow-{$profileFieldName}">
+        <div class="content description">{$field.help_pre}</div>
+      </div>
+    {/if}
+    {if $field.options_per_line != 0}
+      <div class="crm-section editrow_{$profileFieldName}-section form-item" id="editrow-{$profileFieldName}">
+        <div class="label option-label">{if $prefix}{$form.$prefix.$profileFieldName.label}{else}{$form.$profileFieldName.label}{/if}</div>
+        <div class="content 3">
+          {assign var="count" value="1"}
+          {strip}
+            <table class="form-layout-compressed">
+              <tr>
+                {* sort by fails for option per line. Added a variable to iterate through the element array*}
+                {assign var="index" value="1"}
+                {if $prefix}
+                  {assign var="formElement" value=$form.$prefix.$profileFieldName}
+                {else}
+                  {assign var="formElement" value=$form.$profileFieldName}
+                {/if}
+                {foreach name=outer key=key item=item from=$formElement}
+                {if $index < 10}
+                {assign var="index" value=`$index+1`}
+                {else}
+                <td class="labels font-light">{$formElement.$key.html}</td>
+                {if $count == $field.options_per_line}
+              </tr>
+              <tr>
+                {assign var="count" value="1"}
+                {else}
+                {assign var="count" value=`$count+1`}
+                {/if}
+                {/if}
+                {/foreach}
+              </tr>
+            </table>
+          {/strip}
+        </div>
+        <div class="clear"></div>
+      </div>
+    {else}
+      <div class="crm-section editrow_{$profileFieldName}-section form-item" id="editrow-{$profileFieldName}">
+        <div class="label">
+          {if $prefix}{$form.$prefix.$profileFieldName.label}{else}{$form.$profileFieldName.label}{/if}
+        </div>
+        <div class="content">
+          {if $profileFieldName|substr:0:3 eq 'im-'}
+            {assign var="provider" value=profileFieldNamen|cat:"-provider_id"}
+            {$form.$provider.html}&nbsp;
+          {/if}
+
+          {if $profileFieldName eq 'email_greeting' or  $profileFieldName eq 'postal_greeting' or $profileFieldName eq 'addressee'}
+            {include file="CRM/Profile/Form/GreetingType.tpl"}
+          {elseif ($profileFieldName eq 'group' && $form.group) || ($profileFieldName eq 'tag' && $form.tag)}
+            {include file="CRM/Contact/Form/Edit/TagsAndGroups.tpl" type=$profileFieldName title=null context="profile"}
+          {elseif $field.is_datetime_field && $action & 4}
+            <span class="crm-frozen-field">
+              {$form.$profileFieldName.value|crmDate:$field.smarty_view_format}
+              <input type="hidden"
+               name="{$form.$profileFieldName.name}"
+               value="{$form.$profileFieldName.value}" id="{$form.$profileFieldName.name}"
+              >
+            </span>
+          {elseif $field.is_legacy_date}
+            {include file="CRM/common/jcalendar.tpl" elementName=$profileFieldName}
+          {elseif $profileFieldName|substr:0:5 eq 'phone'}
+            {assign var="phone_ext_field" value=$profileFieldName|replace:'phone':'phone_ext'}
+            {if $prefix}{$form.$prefix.$profileFieldName.html}{else}{$form.$profileFieldName.html}{/if}
+            {if $form.$phone_ext_field.html}
+              &nbsp;{$form.$phone_ext_field.html}
+            {/if}
+          {else}
+            {if $prefix}
+              {if $profileFieldName eq 'organization_name' && !empty($form.onbehalfof_id)}
+                {$form.onbehalfof_id.html}
+              {/if}
+              {if $field.html_type eq 'File' && $viewOnlyPrefixFileValues}
+                {$viewOnlyPrefixFileValues.$prefix.$profileFieldName}
+              {else}
+                {$form.$prefix.$profileFieldName.html}
+              {/if}
+            {elseif $field.html_type eq 'File' && $viewOnlyFileValues}
+              {$viewOnlyFileValues.$profileFieldName}
+            {else}
+              {$form.$profileFieldName.html}
+            {/if}
+          {/if}
+
+          {*CRM-4564*}
+          {if $field.html_type eq 'Autocomplete-Select'}
+            {if $field.data_type eq 'ContactReference'}
+              {include file="CRM/Custom/Form/ContactReference.tpl" element_name = $profileFieldName}
+            {/if}
+          {/if}
+        </div>
+        <div class="clear"></div>
+      </div>
+    {/if}
+    {* Show explanatory text for field if not in 'view' or 'preview' modes *}
+    {if $field.help_post && $action neq 4 && $action neq 1028}
+      <div class="crm-section helprow-{$profileFieldName}-section helprow-post" id="helprow-{$profileFieldName}">
+        <div class="content description">{$field.help_post}</div>
+      </div>
+    {/if}
+  {/if}
+{/foreach}
index 6bede7d17b04d0c78bdef167e633d2e218323c8f..cc4b5cf7d9403bba3ed11d59fd846beb292a81ba 100644 (file)
         {if $help_pre && $action neq 4}<div class="messages help">{$help_pre}</div>{/if}
         {assign var=zeroField value="Initial Non Existent Fieldset"}
         {assign var=fieldset  value=$zeroField}
-        {foreach from=$fields item=field key=fieldName}
-          {if $field.skipDisplay}
-            {continue}
-          {/if}
-          {if $field.groupTitle != $fieldset}
-            {if $fieldset != $zeroField}
-              </table>
-              {if $groupHelpPost}
-                <div class="messages help">{$groupHelpPost}</div>
-              {/if}
-              {if $mode ne 8}
-                </fieldset>
-              {/if}
-            {/if}
-            {if $mode ne 8}
-              <h3>{$field.groupTitle}</h3>
-            {/if}
-            {assign var=fieldset  value=`$field.groupTitle`}
-            {assign var=groupHelpPost  value=`$field.groupHelpPost`}
-            {if $field.groupHelpPre}
-              <div class="messages help">{$field.groupHelpPre}</div>
-            {/if}
-          <table class="form-layout-compressed" id="table-1">
-          {/if}
-          {* Show explanatory text for field if not in 'view' mode *}
-          {if $field.help_pre && $action neq 4 && $field.field_type neq "Formatting"}
-            <tr><td>&nbsp;</td><td class="description">{$field.help_pre}</td></tr>
-          {/if}
-          {assign var=n value=$field.name}
-          {if $field.field_type eq "Formatting"}
-            <tr><td colspan="2">{$field.help_pre}</td></tr>
-          {elseif $field.options_per_line }
-            <tr>
-              <td class="option-label">{$form.$n.label}</td>
-              <td>
-                {assign var="count" value="1"}
-                {strip}
-                  <table class="form-layout-compressed">
-                  <tr>
-                  {* sort by fails for option per line. Added a variable to iterate through the element array*}
-                    {assign var="index" value="1"}
-                    {foreach name=outer key=key item=item from=$form.$n}
-                      {if $index < 10}
-                        {assign var="index" value=`$index+1`}
-                      {else}
-                        <td class="labels font-light">{$form.$n.$key.html}</td>
-                        {if $count == $field.options_per_line}
-                        </tr>
-                          {assign var="count" value="1"}
-                        {else}
-                          {assign var="count" value=`$count+1`}
-                        {/if}
-                      {/if}
-                    {/foreach}
-                  </table>
-                {/strip}
-              </td>
-            </tr>
-          {else}
-          <tr>
-            <td class="label">
-              {$form.$n.label}
-            </td>
-            <td>
-              {if $n eq 'group' && $form.group || ( $n eq 'tag' && $form.tag )}
-                {include file="CRM/Contact/Form/Edit/TagsAndGroups.tpl" type=$n}
-              {elseif $n eq 'email_greeting' or  $n eq 'postal_greeting' or $n eq 'addressee'}
-                {include file="CRM/Profile/Form/GreetingType.tpl"}
-              {elseif ( $n|substr:-5:5 eq '_date' ) or ( $field.name eq 'activity_date_time' )  }
-                {include file="CRM/common/jcalendar.tpl" elementName=$form.$n.name}
-              {elseif $n|substr:0:5 eq 'phone'}
-                {assign var="phone_ext_field" value=$n|replace:'phone':'phone_ext'}
-                {$form.$n.html}
-                {if $form.$phone_ext_field.html}
-                  &nbsp;{$form.$phone_ext_field.html}
-                {/if}
-              {else}
-                {if $n|substr:0:3 eq 'im-'}
-                  {assign var="provider" value=$n|cat:"-provider_id"}
-                  {$form.$provider.html}&nbsp;
-                {/if}
-                {$form.$n.html}
-                {if $field.is_view eq 0}
-                  {if $field.html_type eq 'Autocomplete-Select'}
-                    {if $field.data_type eq 'ContactReference'}
-                    {include file="CRM/Custom/Form/ContactReference.tpl" element_name = $n}
-                    {/if}
-                  {/if}
-                {/if}
-              {/if}
-            </td>
-            </tr>
-          {/if}
-        {* Show explanatory text for field if not in 'view' mode *}
-          {if $field.help_post && $action neq 4}
-            <tr><td>&nbsp;</td><td class="description">{$field.help_post}</td></tr>
-          {/if}
-        {/foreach}
-
+        {include file="CRM/UF/Form/Fields.tpl"}
         {if $addCAPTCHA }
           {include file='CRM/common/ReCAPTCHA.tpl'}
         {/if}
-      </table>
         {if $field.groupHelpPost}
           <div class="messages help">{$field.groupHelpPost}</div>
         {/if}
index 049471c3020c9bcc5532b7de17c2f4cf2552cb75..cb359af23c72feb949f1c9cf46d2c1fe5da374df 100644 (file)
@@ -61,7 +61,6 @@
     }
 
     function enableDisable() {
-      $a = $(this);
       $row = $a.closest('.crm-entity');
       info = $a.crmEditableEntity();
       fieldLabel = info.label || info.title || info.display_name || info.name || {/literal}'{ts escape="js"}Record{/ts}'{literal};
       } else {
         save();
       }
-      return false;
     }
 
     // Because this is an inline script it may get added to the document more than once, so remove handler before adding
     $('body')
       .off('.crmEnableDisable')
-      .on('click.crmEnableDisable', '.action-item.crm-enable-disable', enableDisable);
+      .on('click.crmEnableDisable', '.action-item.crm-enable-disable', function(e) {
+        e.preventDefault();
+        $a = $(this);
+        CRM.loadScript(CRM.config.resourceBase + 'js/jquery/jquery.crmEditable.js').done(enableDisable);
+      });
   });
 </script>
 {/literal}
diff --git a/tests/phpunit/CRM/Contact/BAO/QueryStateNameTest.php b/tests/phpunit/CRM/Contact/BAO/QueryStateNameTest.php
new file mode 100644 (file)
index 0000000..ba16c35
--- /dev/null
@@ -0,0 +1,39 @@
+<?php
+
+/**
+ * Class CRM_Contact_BAO_QueryStateNameTest
+ * @group headless
+ */
+class CRM_Contact_BAO_QueryStateNameTest extends CiviUnitTestCase {
+
+  /**
+   * Test case for state_province_name pseudofield
+   *
+   * See CRM-15505: Mailing labels show the state/province name as the abbreviation rather than the full state/province name
+   * Change to CRM_Contact_BAO_query::convertToPseudoNames()
+   */
+  public function testStateName() {
+    $state_name = 'Norfolk';
+    $state_abbreviation = 'NFK';
+    $create_params = array(
+      'contact_type' => 'Individual',
+      'first_name' => 'John',
+      'last_name' => 'Doe',
+      'api.Address.create' => array(
+        'location_type_id' => 'Home',
+        'state_province_id' => $state_name,
+      ),
+    );
+    $create_res = civicrm_api3('Contact', 'Create', $create_params);
+
+    $get_params = array(
+      'id' => $create_res['id'],
+      'sequential' => 1,
+    );
+    $get_res = civicrm_api3('Contact', 'get', $get_params);
+    $this->assertEquals($state_name, $get_res['values'][0]['state_province_name']);
+    // Lock in that state_provice should equal that of the abbreviation.
+    $this->assertEquals($state_abbreviation, $get_res['values'][0]['state_province']);
+  }
+
+}
index 5c014f30b8e676405b6ca9318c064beaacc726e4..25b4f2fd2bdb0d215109308a7591bf721c7c7296 100644 (file)
@@ -151,6 +151,62 @@ class CRM_Contact_BAO_QueryTest extends CiviUnitTestCase {
     }
   }
 
+  /**
+   * Test searchPrimaryDetailsOnly setting.
+   */
+  public function testSearchPrimaryLocTypes() {
+    $contactID = $this->individualCreate();
+    $params = array(
+      'contact_id' => $contactID,
+      'email' => 'primary@example.com',
+      'is_primary' => 1,
+    );
+    $this->callAPISuccess('email', 'create', $params);
+
+    unset($params['is_primary']);
+    $params['email'] = 'secondary@team.com';
+    $this->callAPISuccess('email', 'create', $params);
+
+    foreach (array(0, 1) as $searchPrimary) {
+      Civi::settings()->set('searchPrimaryDetailsOnly', $searchPrimary);
+
+      $params = array(
+        0 => array(
+          0 => 'email',
+          1 => 'LIKE',
+          2 => 'secondary@example.com',
+          3 => 0,
+          4 => 1,
+        ),
+      );
+      $returnProperties = array(
+        'contact_type' => 1,
+        'contact_sub_type' => 1,
+        'sort_name' => 1,
+      );
+
+      $queryObj = new CRM_Contact_BAO_Query($params, $returnProperties);
+      $resultDAO = $queryObj->searchQuery(0, 0, NULL,
+        FALSE, FALSE,
+        FALSE, FALSE,
+        FALSE);
+
+      if ($searchPrimary) {
+        $this->assertEquals($resultDAO->N, 0);
+      }
+      else {
+        //Assert secondary email gets included in search results.
+        while ($resultDAO->fetch()) {
+          $this->assertEquals('secondary@example.com', $resultDAO->email);
+        }
+      }
+
+      // API should always return primary email.
+      $result = $this->callAPISuccess('Contact', 'get', array('contact_id' => $contactID));
+      $this->assertEquals('primary@example.com', $result['values'][$contactID]['email']);
+    }
+  }
+
   /**
    * CRM-14263 search builder failure with search profile & address in criteria
    * We are retrieving primary here - checking the actual sql seems super prescriptive - but since the massive query object has
@@ -178,7 +234,7 @@ class CRM_Contact_BAO_QueryTest extends CiviUnitTestCase {
       'contact_sub_type' => 1,
       'sort_name' => 1,
     );
-    $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, civicrm_address.city as `city`  FROM civicrm_contact contact_a LEFT JOIN civicrm_address ON ( contact_a.id = civicrm_address.contact_id AND civicrm_address.is_primary = 1 ) WHERE  (  ( LOWER(civicrm_address.city) = 'cool city' )  )  AND (contact_a.is_deleted = 0)    ORDER BY `contact_a`.`sort_name` asc, `contact_a`.`id` ";
+    $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, civicrm_address.city as `city`  FROM civicrm_contact contact_a LEFT JOIN civicrm_address ON ( contact_a.id = civicrm_address.contact_id AND civicrm_address.is_primary = 1 ) WHERE  (  ( LOWER(civicrm_address.city) = 'cool city' )  )  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,
@@ -349,17 +405,20 @@ class CRM_Contact_BAO_QueryTest extends CiviUnitTestCase {
       "display_name" => 1,
       "preferred_mail_format" => 1,
     );
-    $numberofContacts = 2;
+    $numberOfContacts = 2;
     $query = new CRM_Contact_BAO_Query($params, $returnProperties);
     try {
-      $query->apiQuery($params, $returnProperties, NULL, NULL, 0, $numberofContacts);
+      $query->apiQuery($params, $returnProperties, NULL, NULL, 0, $numberOfContacts);
     }
     catch (Exception $e) {
-      $this->assertEquals("A fatal error was triggered: One of parameters  (value: foo@example.com) is not of the type Positive",
-        $e->getMessage());
-      return $this->assertTrue(TRUE);
+      $this->assertEquals(
+        "A fatal error was triggered: One of parameters  (value: foo@example.com) is not of the type Positive",
+        $e->getMessage()
+      );
+      $this->assertTrue(TRUE);
+      return;
     }
-    return $this->fail('Test failed for some reason which is not good');
+    $this->fail('Test failed for some reason which is not good');
   }
 
 }
index ede681e112c04554ee6c5a21bf6fc86ba68476af..c745657fb6d225063c41a353175ee783264c2407 100644 (file)
@@ -194,7 +194,6 @@ class CRM_Core_BAO_UFFieldTest extends CiviUnitTestCase {
 
     foreach ($fields as $field) {
       $defaults = array(
-        'version' => 3,
         'uf_group_id' => $ufGroup->id,
         'visibility' => 'Public Pages and Listings',
         'weight' => 1,
@@ -204,7 +203,7 @@ class CRM_Core_BAO_UFFieldTest extends CiviUnitTestCase {
         'location_type_id' => NULL,
       );
       $params = array_merge($field, $defaults);
-      $ufField = civicrm_api('UFField', 'create', $params);
+      $ufField = $this->callAPISuccess('UFField', 'create', $params);
       $this->assertAPISuccess($ufField);
     }
 
index 5bcc22be20fbf70dee28ed12daf1adcfca54fa69..afd48f7eb733775f1673c1149f1681874efae48d 100644 (file)
@@ -43,8 +43,8 @@ class CRM_Core_OptionGroupTest extends CiviUnitTestCase {
    */
   public function testWeightOptionGroup() {
     $values = array();
-    $options1 = CRM_Core_OptionGroup::values('activity_type');
-    $options2 = CRM_Core_OptionGroup::values('activity_type', FALSE, FALSE, FALSE, NULL, 'label', TRUE, TRUE, 'value', 'name');
+    $options1 = CRM_Core_OptionGroup::values('activity_type', FALSE, FALSE, FALSE, NULL, 'label', FALSE);
+    $options2 = CRM_Core_OptionGroup::values('activity_type', FALSE, FALSE, FALSE, NULL, 'label', FALSE, FALSE, 'value', 'name');
     // Verify that arrays are equal.
     $this->assertTrue(($options1 == $options2), "The arrays retrieved should be the same");
     // Verify sequence is different.
@@ -54,7 +54,6 @@ class CRM_Core_OptionGroupTest extends CiviUnitTestCase {
       FROM civicrm_option_value v
       INNER JOIN civicrm_option_group g ON g.id = v.option_group_id
       AND g.name = 'activity_type'
-      WHERE g.is_active = 1 AND v.is_active = 1
       ORDER BY v.name";
     $dao = CRM_Core_DAO::executeQuery($sql);
     while ($dao->fetch()) {
index 89a6fdfb96449791a4f8a66b27bd018a51b11bf3..6f36779fa8c938d11a471a67820bd5e91d1216fd 100644 (file)
@@ -116,6 +116,7 @@ class CRM_Core_PseudoConstantTest extends CiviUnitTestCase {
       'member_of_contact_id' => 1,
       'duration_unit' => 'day',
       'duration_interval' => 1,
+      'period_type' => 'rolling',
     );
     $result = civicrm_api3('membership_type', 'create', $api_params);
 
index f3b52c9e1ec895b29a76424cbdc19f17db9331cd..c986059222e015eb860877f4ef545e24d0178c74 100644 (file)
@@ -176,7 +176,7 @@ class CRM_Dedupe_MergerTest extends CiviUnitTestCase {
     $this->assertEquals($pnDupePairs[0]['is_selected'], 1, 'Check if second record in dupe pairs is marked as selected.');
 
     // batch merge selected dupes
-    $result = CRM_Dedupe_Merger::batchMerge($dao->id, $this->_groupId, 'safe', TRUE, 5, 1);
+    $result = CRM_Dedupe_Merger::batchMerge($dao->id, $this->_groupId, 'safe', 5, 1);
     $this->assertEquals(count($result['merged']), 2, 'Check number of merged pairs.');
 
     // retrieve pairs from prev next cache table
@@ -232,7 +232,7 @@ class CRM_Dedupe_MergerTest extends CiviUnitTestCase {
     $this->assertEquals(count($foundDupes), count($pnDupePairs), 'Check number of dupe pairs in prev next cache.');
 
     // batch merge all dupes
-    $result = CRM_Dedupe_Merger::batchMerge($dao->id, $this->_groupId, 'safe', TRUE, 5, 2);
+    $result = CRM_Dedupe_Merger::batchMerge($dao->id, $this->_groupId, 'safe', 5, 2);
     $this->assertEquals(count($result['merged']), 3, 'Check number of merged pairs.');
 
     // retrieve pairs from prev next cache table
index 1132dde1f6dca988f65896992e222bf85a0a445c..d57e1eb6bd3cd2897ae9ee22b76aefb850b0ac69 100644 (file)
@@ -164,4 +164,69 @@ class CRM_Event_Form_Registration_ConfirmTest extends CiviUnitTestCase {
     $this->assertEquals($contribution['total_amount'], 440, 'Invalid Tax amount.');
   }
 
+  /**
+   * Test online registration for event with no price options selected as per CRM-19964.
+   */
+  public function testOnlineRegNoPrice() {
+    $paymentProcessorID = $this->processorCreate(array('is_default' => TRUE, 'user_name' => 'Test', 'is_test' => FALSE));
+    $paymentProcessorID = $this->processorCreate(array('is_default' => TRUE, 'user_name' => 'Test', 'is_test' => TRUE));
+    $params = array(
+      'start_date' => date('YmdHis', strtotime('+ 1 week')),
+      'end_date' => date('YmdHis', strtotime('+ 1 year')),
+      'registration_start_date' => date('YmdHis', strtotime('- 1 day')),
+      'registration_end_date' => date('YmdHis', strtotime('+ 1 year')),
+      'payment_processor_id' => $paymentProcessorID,
+      'is_monetary' => TRUE,
+      'financial_type_id' => 'Event Fee',
+    );
+    $event = $this->eventCreate($params);
+    $priceFieldOptions = array(
+      'option_label' => 'Price Field',
+      'option_value' => 100,
+      'is_required' => FALSE,
+      'html_type' => 'Text',
+    );
+    $this->createPriceSet('event', $event['id'], $priceFieldOptions);
+
+    $priceField = $this->callAPISuccess('PriceField', 'get',
+      array(
+        'label' => 'Price Field',
+      )
+    );
+    // Create online event registration.
+    CRM_Event_Form_Registration_Confirm::testSubmit(array(
+      'id' => $event['id'],
+      'contributeMode' => 'direct',
+      'registerByID' => $this->createLoggedInUser(),
+      'params' => array(
+        array(
+          'qfKey' => 'e6eb2903eae63d4c5c6cc70bfdda8741_2801',
+          'entryURL' => "http://dmaster.local/civicrm/event/register?reset=1&amp;id={$event['id']}",
+          'first_name' => 'Bruce',
+          'last_name' => 'Wayne',
+          'email-Primary' => 'bruce@gotham.com',
+          'price_' . $priceField['id'] => '',
+          'priceSetId' => $priceField['values'][$priceField['id']]['price_set_id'],
+          'payment_processor_id' => $paymentProcessorID,
+          'amount' => 0,
+          'bypass_payment' => '',
+          'MAX_FILE_SIZE' => '33554432',
+          'is_primary' => 1,
+          'is_pay_later' => 0,
+          'campaign_id' => NULL,
+          'defaultRole' => 1,
+          'participant_role_id' => '1',
+          'tax_amount' => NULL,
+          'ip_address' => '127.0.0.1',
+          'invoiceID' => '57adc34957a29171948e8643ce906332',
+          'button' => '_qf_Register_upload',
+          'scriptFee' => '',
+          'scriptArray' => '',
+        ),
+      ),
+    ));
+    $contribution = $this->callAPISuccess('Contribution', 'get', array('invoice_id' => '57adc34957a29171948e8643ce906332'));
+    $this->assertEquals($contribution['count'], '0', "Contribution should not be created for zero fee event registration when no price field selected.");
+  }
+
 }
diff --git a/tests/phpunit/CRM/Utils/Mail/EmailProcessorTest.php b/tests/phpunit/CRM/Utils/Mail/EmailProcessorTest.php
new file mode 100644 (file)
index 0000000..0c9289c
--- /dev/null
@@ -0,0 +1,108 @@
+<?php
+
+/**
+ * Class CRM_Utils_EmailProcessorTest
+ * @group headless
+ */
+
+class CRM_Utils_EmailProcessorTest extends CiviUnitTestCase {
+
+  /**
+   * Event queue record.
+   *
+   * @var array
+   */
+  protected $eventQueue = array();
+
+  /**
+   * ID of our sample contact.
+   *
+   * @var int
+   */
+  protected $contactID;
+
+  public function setUp() {
+    parent::setUp();
+    $this->callAPISuccess('MailSettings', 'get', array(
+      'api.MailSettings.create' => array(
+        'name' => 'local',
+        'protocol' => 'Localdir',
+        'source' => __DIR__ . '/data/mail',
+        'domain' => 'example.com',
+      ),
+    ));
+  }
+
+  /**
+   * Test the job processing function works and processes a bounce.
+   */
+  public function testBounceProcessing() {
+    $this->setUpMailing();
+
+    copy(__DIR__ . '/data/bounces/bounce_no_verp.txt', __DIR__ . '/data/mail/bounce_no_verp.txt');
+    $this->assertTrue(file_exists(__DIR__ . '/data/mail/bounce_no_verp.txt'));
+    $this->callAPISuccess('job', 'fetch_bounces', array());
+    $this->assertFalse(file_exists(__DIR__ . '/data/mail/bounce_no_verp.txt'));
+    $this->checkMailingBounces(1);
+  }
+
+  /**
+   * Test that a deleted email does not cause a hard fail.
+   *
+   * The civicrm_mailing_event_queue table tracks email ids to represent an
+   * email address. The id may not represent the same email by the time the bounce may
+   * come in - a weakness of storing the id not the email. Relevant here
+   * is that it might have been deleted altogether, in which case the bounce should be
+   * silently ignored. This ignoring is also at the expense of the contact
+   * having the same email address with a different id.
+   *
+   * Longer term it would make sense to track the email address & track bounces back to that
+   * rather than an id that may not reflect the email used. Issue logged CRM-20021.
+   *
+   * For not however, we are testing absence of mysql error in conjunction with CRM-20016.
+   */
+  public function testBounceProcessingDeletedEmail() {
+    $this->setUpMailing();
+    $this->callAPISuccess('Email', 'get', array(
+      'contact_id' => $this->contactID,
+      'api.email.delete' => 1,
+    ));
+
+    copy(__DIR__ . '/data/bounces/bounce_no_verp.txt', __DIR__ . '/data/mail/bounce_no_verp.txt');
+    $this->assertTrue(file_exists(__DIR__ . '/data/mail/bounce_no_verp.txt'));
+    $this->callAPISuccess('job', 'fetch_bounces', array());
+    $this->assertFalse(file_exists(__DIR__ . '/data/mail/bounce_no_verp.txt'));
+    $this->checkMailingBounces(1);
+  }
+
+  /**
+   * Wrapper to check for mailing bounces.
+   *
+   * Normally we would call $this->callAPISuccessGetCount but there is not one & there is resistance to
+   * adding apis for 'convenience' so just adding a hacky function to get past the impasse.
+   *
+   * @param int $expectedCount
+   */
+  public function checkMailingBounces($expectedCount) {
+    $this->assertEquals($expectedCount, CRM_Core_DAO::singleValueQuery(
+      "SELECT count(*) FROM civicrm_mailing_event_bounce WHERE event_queue_id = " . $this->eventQueue['id']
+    ));
+  }
+
+  /**
+   * Set up a mailing.
+   */
+  public function setUpMailing() {
+    $this->contactID = $this->individualCreate(array('email' => 'undeliverable@example.com'));
+    $groupID = $this->callAPISuccess('Group', 'create', array(
+      'title' => 'Mailing group',
+      'api.GroupContact.create' => array(
+        'contact_id' => $this->contactID,
+      ),
+    ));
+    $this->createMailing(array('scheduled_date' => 'now', 'groups' => array('include' => array($groupID))));
+    $this->callAPISuccess('job', 'process_mailing', array());
+    $this->eventQueue = $this->callAPISuccess('MailingEventQueue', 'get', array('api.MailingEventQueue.create' => array('hash' => 'aaaaaaaaaaaaaaaa')));
+  }
+
+}
diff --git a/tests/phpunit/CRM/Utils/Mail/data/bounces/bounce_no_verp.txt b/tests/phpunit/CRM/Utils/Mail/data/bounces/bounce_no_verp.txt
new file mode 100644 (file)
index 0000000..26e07f2
--- /dev/null
@@ -0,0 +1,72 @@
+Delivered-To: my@example.com
+Received: by 10.112.67.71 with SMTP id l7csp45921lbt;
+        Thu, 23 Jan 2014 12:45:42 -0800 (PST)
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
+        d=googlemail.com; s=20120113;
+        h=mime-version:from:to:subject:message-id:date:content-type;
+        bh=UGTp5DX2SZvxoM2GPLjZwRcpcz4/3zeLJyMyYuTvOI0=;
+        b=lbtNQ3EnmzubKV0sbek27d5E0+yCG4FXwcKrk3+mfgJ2nDUHeBvQNz/fyL+ppmJs6h
+         XHZzakNN0JAeQh9AxELPYlRM5iTYcRe2zFiBGvU0YMcoIoDZOV3r8RvpfcRm5IYQCNS5
+         LJmRJsvPN+mwgKhdYmBqWezjasQSVVlaHMVt59CdH106pp1FixWFrSxl0r465/IhlbWR
+         p1geZmq89piISVsNemXT8n5src0OuqMQCFW4m4LZbk6JKdCuS3ErnJ6t6ODSmzRW+0Lv
+         WkiXuxKefj/d5OHdgUb9YHDQMb8EU3Gh4q0udoqkTV1l87Lfq2c/2NpH9tk/2dbN9MaA
+         65hA==
+X-Received: by 10.67.22.67 with SMTP id hq3mr9981350pad.132.1390509942011;
+        Thu, 23 Jan 2014 12:45:42 -0800 (PST)
+MIME-Version: 1.0
+Return-Path: <>
+Received: by 10.67.22.67 with SMTP id hq3mr12327267pad.132; Thu, 23 Jan 2014
+ 12:45:42 -0800 (PST)
+From: Mail Delivery Subsystem <mailer-daemon@googlemail.com>
+To: b.2.1.aaaaaaaaaaaaaaaa@example.com
+X-Failed-Recipients: undeliverable@example.com
+Subject: Delivery Status Notification (Failure)
+Message-ID: <047d7b5dbbd42675d704f0a953a8@google.com>
+Date: Thu, 23 Jan 2014 20:45:42 +0000
+Content-Type: text/plain; charset=ISO-8859-1
+
+Delivery to the following recipient failed permanently:
+
+     undeliverable@example.com
+
+Technical details of permanent failure:
+Google tried to deliver your message, but it was rejected by the server for the recipient domain example.com by aspmx.l.google.com. [74.125.129.26].
+
+The error that the other server returned was:
+550-5.1.1 The email account that you tried to reach does not exist. Please try
+550-5.1.1 double-checking the recipient's email address for typos or
+550-5.1.1 unnecessary spaces. Learn more at
+550 5.1.1 http://support.google.com/mail/bin/answer.py?answer=6596 yy4si15401666pbc.69 - gsmtp
+
+----- Original message -----
+
+X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
+        d=1e100.net; s=20130820;
+        h=x-gm-message-state:from:content-type:subject:message-id:date:to
+         :mime-version;
+        bh=pmXAuF/5WEKUL4czT4KPvdj7HdW4O6/bnJxxnzhDxS4=;
+        b=OLUdt6zYl0SwEk+7rmWCcpxDxpELnUMFnU8LGHDZxefjkFcugCUCGb4SEFo0uW+FEv
+         JYxv9xteYtVZ4pfy40ggFUtN5mXnn/B8WSI0Y+/BF5Ow2FpKXKk932+Jhi+DPRDc7fB0
+         YdpwO9CqEDx0FHi6r1G7uKmse8Y6ekfO8zCq48t4SQ9A39P1pNESj3KSIhaaBP/PdMVu
+         VezOOwae71dMviH6WSiDksIJgw+cRXcxpWNU/mjn+Yf7lk2PHYn2vrhCni2Q3Trr2PpK
+         oNQBiGHbxSGDeHX8r+DsoWeSIvaXxH8y0AICSnTMAXqFuzEEhFHFFkqrXwn0ZWgLyK3F
+         Vjaw==
+X-Gm-Message-State: ALoCoQkkZ5zeZN9IR1iF+yKdq/RaFqQbP/XzNV3rJ2PRHd9eagL83ZI9HrH5oEWtcQWqI11+gALC
+X-Received: by 10.67.22.67 with SMTP id hq3mr9981324pad.132.1390509941690;
+        Thu, 23 Jan 2014 12:45:41 -0800 (PST)
+Return-Path: <my@example.com>
+Received: from [10.1.1.2] ([121.99.62.224])
+        by mx.google.com with ESMTPSA id vx10sm65825229pac.17.2014.01.23.12.45.38
+        for <undeliverable@example.com>
+        (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
+        Thu, 23 Jan 2014 12:45:40 -0800 (PST)
+From: My Mail <my@example.com>
+Content-Type: multipart/signed; boundary="Apple-Mail=_2E4B9F97-76BD-4F9D-94C0-5DEC92528786"; protocol="application/pgp-signature"; micalg=pgp-sha1
+Subject: test
+Message-Id: <20E88533-8A36-4405-8125-FDC61CD6AB56@example.co>
+Date: Fri, 24 Jan 2014 09:45:37 +1300
+To: undeliverable@example.com
+Mime-Version: 1.0 (Mac OS X Mail 7.1 \(1827\))
+X-Mailer: Apple Mail (2.1827)
+
+test
index 832f535ef8f18dcd4f48caff64775f919ed41fd5..ad9ff03738fe4102b31e1e8b47ac39f3195ed10a 100644 (file)
@@ -2,6 +2,8 @@
 
 /**
  * Class CRM_Utils_TypeTest
+ * @package CiviCRM
+ * @subpackage CRM_Utils_Type
  * @group headless
  */
 class CRM_Utils_TypeTest extends CiviUnitTestCase {
@@ -46,16 +48,29 @@ class CRM_Utils_TypeTest extends CiviUnitTestCase {
       array('table.`Home-street_address`', 'MysqlColumnNameOrAlias', 'table.`Home-street_address`'),
       array('`table-alias`.`Home-street_address`', 'MysqlColumnNameOrAlias', '`table-alias`.`Home-street_address`'),
       array('`table-alias`.column', 'MysqlColumnNameOrAlias', '`table-alias`.column'),
+      // Spaces also permitted, only when enclosed in backticks.
+      array('`column alias`', 'MysqlColumnNameOrAlias', '`column alias`'),
+      array('`table alias`.column', 'MysqlColumnNameOrAlias', '`table alias`.column'),
+      array('`table alias`.`column alias`', 'MysqlColumnNameOrAlias', '`table alias`.`column alias`'),
+      array('table alias.column alias', 'MysqlColumnNameOrAlias', NULL),
+      array('table alias.column_alias', 'MysqlColumnNameOrAlias', NULL),
+      array('table_alias.column alias', 'MysqlColumnNameOrAlias', NULL),
+      // Functions are not permitted.
       array('column_name, sleep(5)', 'MysqlColumnNameOrAlias', NULL),
+      // Length checking permits only 64 chars.
       array(str_repeat('a', 64), 'MysqlColumnNameOrAlias', str_repeat('a', 64)),
       array(str_repeat('a', 65), 'MysqlColumnNameOrAlias', NULL),
       array(str_repeat('a', 64) . '.' . str_repeat('a', 64), 'MysqlColumnNameOrAlias', str_repeat('a', 64) . '.' . str_repeat('a', 64)),
+      array('`' . str_repeat('a', 64) . '`.`' . str_repeat('b', 64) . '`', 'MysqlColumnNameOrAlias', '`' . str_repeat('a', 64) . '`.`' . str_repeat('b', 64) . '`'),
       array(str_repeat('a', 64) . '.' . str_repeat('a', 65), 'MysqlColumnNameOrAlias', NULL),
       array(str_repeat('a', 65) . '.' . str_repeat('a', 64), 'MysqlColumnNameOrAlias', NULL),
+      // ORDER BY can be ASC or DESC, case not significant.
       array('asc', 'MysqlOrderByDirection', 'asc'),
       array('DESC', 'MysqlOrderByDirection', 'desc'),
       array('DESCc', 'MysqlOrderByDirection', NULL),
       array('table.civicrm_column_name desc', 'MysqlOrderBy', 'table.civicrm_column_name desc'),
+      array('field(civicrm_column_name,4,5,6)', 'MysqlOrderBy', 'field(civicrm_column_name,4,5,6)'),
+      array('field(table.civicrm_column_name,4,5,6)', 'MysqlOrderBy', 'field(table.civicrm_column_name,4,5,6)'),
       array('table.civicrm_column_name desc,other_column, another_column desc', 'MysqlOrderBy', 'table.civicrm_column_name desc,other_column, another_column desc'),
       array('table.`Home-street_address` asc, `table-alias`.`Home-street_address` desc,`table-alias`.column', 'MysqlOrderBy', 'table.`Home-street_address` asc, `table-alias`.`Home-street_address` desc,`table-alias`.column'),
       array('a string', 'String', 'a string'),
@@ -108,6 +123,8 @@ class CRM_Utils_TypeTest extends CiviUnitTestCase {
       array('DESC', 'MysqlOrderByDirection', 'desc'),
       array('DESCc', 'MysqlOrderByDirection', NULL),
       array('table.civicrm_column_name desc', 'MysqlOrderBy', '`table`.`civicrm_column_name` desc'),
+      array('field(contribution_status_id,4,5,6) asc', 'MysqlOrderBy', 'field(`contribution_status_id`,4,5,6) asc'),
+      array('field(contribution_status_id,4,5,6) asc, contact_id asc', 'MysqlOrderBy', 'field(`contribution_status_id`,4,5,6) asc, `contact_id` asc'),
       array('table.civicrm_column_name desc,other_column,another_column desc', 'MysqlOrderBy', '`table`.`civicrm_column_name` desc, `other_column`, `another_column` desc'),
       array('table.`Home-street_address` asc, `table-alias`.`Home-street_address` desc,`table-alias`.column', 'MysqlOrderBy', '`table`.`Home-street_address` asc, `table-alias`.`Home-street_address` desc, `table-alias`.`column`'),
     );
index c4aba681eea50a8fdd74c6f600fbca6d8714aac8..c95c39b0f3552437f2005a806dac741755599e45 100644 (file)
@@ -1531,7 +1531,6 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
       'receive_date' => date('Ymd'),
       'total_amount' => 100.00,
       'fee_amount' => 5.00,
-      'net_ammount' => 95.00,
       'financial_type_id' => 1,
       'payment_instrument_id' => 1,
       'non_deductible_amount' => 10.00,
@@ -3199,15 +3198,18 @@ AND    ( TABLE_NAME LIKE 'civicrm_value_%' )
 
   /**
    * Helper function to create new mailing.
-   * @return mixed
+   *
+   * @param array $params
+   *
+   * @return int
    */
-  public function createMailing() {
-    $params = array(
+  public function createMailing($params = array()) {
+    $params = array_merge(array(
       'subject' => 'maild' . rand(),
       'body_text' => 'bdkfhdskfhduew{domain.address}{action.optOutUrl}',
       'name' => 'mailing name' . rand(),
       'created_id' => 1,
-    );
+    ), $params);
 
     $result = $this->callAPISuccess('Mailing', 'create', $params);
     return $result['id'];
@@ -3396,7 +3398,7 @@ AND    ( TABLE_NAME LIKE 'civicrm_value_%' )
    *
    * @return array
    */
-  protected function createPriceSet($component = 'contribution_page', $componentId = NULL) {
+  protected function createPriceSet($component = 'contribution_page', $componentId = NULL, $priceFieldOptions = array()) {
     $paramsSet['title'] = 'Price Set' . substr(sha1(rand()), 0, 7);
     $paramsSet['name'] = CRM_Utils_String::titleToVar($paramsSet['title']);
     $paramsSet['is_active'] = TRUE;
@@ -3408,7 +3410,7 @@ AND    ( TABLE_NAME LIKE 'civicrm_value_%' )
     $this->assertDBCompareValue('CRM_Price_BAO_PriceSet', $priceSetId, 'title',
       'id', $paramsSet['title'], 'Check DB for created priceset'
     );
-    $paramsField = array(
+    $paramsField = array_merge(array(
       'label' => 'Price Field',
       'name' => CRM_Utils_String::titleToVar('Price Field'),
       'html_type' => 'CheckBox',
@@ -3424,7 +3426,8 @@ AND    ( TABLE_NAME LIKE 'civicrm_value_%' )
       'price_set_id' => $priceSet['id'],
       'is_enter_qty' => 1,
       'financial_type_id' => $this->getFinancialTypeId('Event Fee'),
-    );
+    ), $priceFieldOptions);
+
     $priceField = CRM_Price_BAO_PriceField::create($paramsField);
     if ($componentId) {
       CRM_Price_BAO_PriceSet::addTo('civicrm_' . $component, $componentId, $priceSetId);
@@ -3767,4 +3770,18 @@ AND    ( TABLE_NAME LIKE 'civicrm_value_%' )
     $this->_ids['membership_type'] = $membershipTypeID;
   }
 
+  /**
+   * No results returned.
+   *
+   * @implements CRM_Utils_Hook::aclWhereClause
+   *
+   * @param string $type
+   * @param array $tables
+   * @param array $whereTables
+   * @param int $contactID
+   * @param string $where
+   */
+  public function aclWhereHookNoResults($type, &$tables, &$whereTables, &$contactID, &$where) {
+  }
+
 }
index 7e17d7aec04a9cd054dfd4f3ca4af1b37163f278..2bc56747a41cb56a3a240b43539505d5812ffd74 100644 (file)
@@ -427,20 +427,6 @@ class api_v3_ACLPermissionTest extends CiviUnitTestCase {
     );
   }
 
-  /**
-   * No results returned.
-   *
-   * @implements CRM_Utils_Hook::aclWhereClause
-   *
-   * @param string $type
-   * @param array $tables
-   * @param array $whereTables
-   * @param int $contactID
-   * @param string $where
-   */
-  public function aclWhereHookNoResults($type, &$tables, &$whereTables, &$contactID, &$where) {
-  }
-
   /**
    * All results returned.
    *
index afe7e74b88f12a15a318d02177420db389b01f47..5ce55f7c0f4bb9e4e55e8d900f0f535eb8bcf36b 100644 (file)
@@ -717,6 +717,48 @@ class api_v3_ActivityTest extends CiviUnitTestCase {
     $this->assertEquals($activityget['id'], $activity['id']);
   }
 
+  /**
+   * Return tag info
+   */
+  public function testJoinOnTags() {
+    $tagName = 'act_tag_nm_' . mt_rand();
+    $tagDescription = 'act_tag_ds_' . mt_rand();
+    $tagColor = '#' . substr(md5(mt_rand()), 0, 6);
+    $tag = $this->callAPISuccess('Tag', 'create', array('name' => $tagName, 'color' => $tagColor, 'description' => $tagDescription, 'used_for' => 'Activities'));
+    $activity = $this->callAPISuccess('Activity', 'Create', $this->_params);
+    $this->callAPISuccess('EntityTag', 'create', array('entity_table' => 'civicrm_activity', 'tag_id' => $tag['id'], 'entity_id' => $activity['id']));
+    $activityget = $this->callAPISuccess('activity', 'getsingle', array(
+      'id' => $activity['id'],
+      'return' => array('tag_id.name', 'tag_id.description', 'tag_id.color'),
+    ));
+    $this->assertEquals($tagName, $activityget['tag_id'][$tag['id']]['tag_id.name']);
+    $this->assertEquals($tagColor, $activityget['tag_id'][$tag['id']]['tag_id.color']);
+    $this->assertEquals($tagDescription, $activityget['tag_id'][$tag['id']]['tag_id.description']);
+  }
+
+
+  /**
+   * Test that activity.get api works to filter on and return files.
+   */
+  public function testActivityGetFile() {
+    $activity = $this->callAPISuccess('Activity', 'create', $this->_params);
+    $activity2 = $this->callAPISuccess('Activity', 'create', $this->_params2);
+    $file = $this->callAPISuccess('Attachment', 'create', array(
+      'name' => 'actAttachment.txt',
+      'mime_type' => 'text/plain',
+      'description' => 'My test description',
+      'content' => 'My test content',
+      'entity_table' => 'civicrm_activity',
+      'entity_id' => $activity2['id'],
+    ));
+    $activityget = $this->callAPISuccess('activity', 'getsingle', array(
+      'file_id' => $file['id'],
+      'return' => 'file_id',
+    ));
+    $this->assertEquals($activityget['id'], $activity2['id']);
+    $this->assertEquals($file['id'], $activityget['file_id'][0]);
+  }
+
   /**
    * test that get functioning does filtering.
    */
@@ -1289,4 +1331,33 @@ class api_v3_ActivityTest extends CiviUnitTestCase {
     }
   }
 
+  public function testGetWithOr() {
+    $acts = array(
+      'test or 1' => 'orOperator',
+      'test or 2' => 'orOperator',
+      'test or 3' => 'nothing',
+    );
+    foreach ($acts as $subject => $details) {
+      $params = $this->_params;
+      $params['subject'] = $subject;
+      $params['details'] = $details;
+      $this->callAPISuccess('Activity', 'create', $params);
+    }
+    $result = $this->callAPISuccess('Activity', 'get', array(
+      'details' => 'orOperator',
+    ));
+    $this->assertEquals(2, $result['count']);
+    $result = $this->callAPISuccess('Activity', 'get', array(
+      'details' => 'orOperator',
+      'subject' => 'test or 3',
+    ));
+    $this->assertEquals(0, $result['count']);
+    $result = $this->callAPISuccess('Activity', 'get', array(
+      'details' => 'orOperator',
+      'subject' => 'test or 3',
+      'options' => array('or' => array(array('details', 'subject'))),
+    ));
+    $this->assertEquals(3, $result['count']);
+  }
+
 }
index 5a28165a2faefc82bf96a3d2a93bdf5df6e25437..4388b9545d5e4667c26387883ed41fcec498e8ef 100644 (file)
@@ -48,7 +48,6 @@ class api_v3_ActivityTypeTest extends CiviUnitTestCase {
     $params = array();
     $result = $this->callAPIAndDocument('activity_type', 'get', $params, __FUNCTION__, __FILE__);
     $this->assertEquals($result['values']['1'], 'Meeting');
-    $this->assertEquals($result['values']['13'], 'Open Case');
   }
 
   /**
index 8357d62c5c2b9f53b66e4315d8ff131ac90bab32..61558e5f06d45ecaab9886062896b2d6a7c9ebc9 100644 (file)
@@ -96,6 +96,38 @@ class api_v3_CaseTest extends CiviCaseTestCase {
     $this->callAPIFailure('case', 'create', $params);
   }
 
+  /**
+   * Test Getlist with id and case_id
+   */
+  public function testCaseGetListById() {
+    $params = $this->_params;
+    $params['contact_id'] = $this->individualCreate();
+
+    //Create 3 sample Cases.
+    $case1 = $this->callAPISuccess('case', 'create', $params);
+    $params['subject'] = 'Test Case 2';
+    $case2 = $this->callAPISuccess('case', 'create', $params);
+    $params['subject'] = 'Test Case 3';
+    $case3 = $this->callAPISuccess('case', 'create', $params);
+
+    $getParams = array(
+      'id' => array($case1['id']),
+      'extra' => array('contact_id'),
+      'params' => array(
+        'version' => 3,
+        'case_id' => array('!=' => $case2['id']),
+        'case_id.is_deleted' => 0,
+        'case_id.status_id' => array('!=' => "Closed"),
+        'case_id.end_date' => array('IS NULL' => 1),
+      ),
+    );
+    $result = $this->callAPISuccess('case', 'getlist', $getParams);
+
+    //Only 1 case should be returned.
+    $this->assertEquals(count($result['values']), 1);
+    $this->assertEquals($result['values'][0]['id'], $case1['id']);
+  }
+
   /**
    * Test create function with valid parameters.
    */
index cfe690a31cd4aa826f84b73be809a935550bed71..8e9c020395fe7d39d9969b252eada642c172131a 100644 (file)
@@ -572,7 +572,7 @@ class api_v3_ContactTest extends CiviUnitTestCase {
       ),
     );
 
-    $result = $this->callAPIAndDocument('Contact', 'create', $params, __FUNCTION__, __FILE__);
+    $result = $this->callAPISuccess('Contact', 'create', $params);
     $customFldId = $result['values'][$result['id']]['api.CustomField.create']['id'];
     $this->assertNotNull($result['id']);
     $this->assertNotNull($customFldId);
@@ -583,7 +583,7 @@ class api_v3_ContactTest extends CiviUnitTestCase {
       'api.CustomValue.get' => 1,
     );
 
-    $result = $this->callAPIAndDocument('Contact', 'create', $params, __FUNCTION__, __FILE__);
+    $result = $this->callAPISuccess('Contact', 'create', $params);
     $this->assertNotNull($result['id']);
     $customFldDate = date("YmdHis", strtotime($result['values'][$result['id']]['api.CustomValue.get']['values'][0]['latest']));
     $this->assertNotNull($customFldDate);
@@ -606,14 +606,14 @@ class api_v3_ContactTest extends CiviUnitTestCase {
       ),
       'api.CustomValue.get' => 1,
     );
-    $result = $this->callAPIAndDocument('Contact', 'create', $params, __FUNCTION__, __FILE__);
+    $result = $this->callAPISuccess('Contact', 'create', $params);
     $this->assertNotNull($result['id']);
     $customFldDate = date("Ymd", strtotime($result['values'][$result['id']]['api.CustomValue.get']['values'][0]['latest']));
     $customFldTime = date("His", strtotime($result['values'][$result['id']]['api.CustomValue.get']['values'][0]['latest']));
     $this->assertNotNull($customFldDate);
     $this->assertEquals($dateTime, $customFldDate);
     $this->assertEquals(000000, $customFldTime);
-    $this->callAPIAndDocument('Contact', 'create', $params, __FUNCTION__, __FILE__);
+    $this->callAPISuccess('Contact', 'create', $params);
   }
 
 
@@ -984,8 +984,6 @@ class api_v3_ContactTest extends CiviUnitTestCase {
    */
   public function testGetGroupIDFromContact() {
     $groupId = $this->groupCreate();
-    $description = "Get all from group and display contacts.";
-    $subFile = "GroupFilterUsingContactAPI";
     $params = array(
       'email' => 'man2@yahoo.com',
       'contact_type' => 'Individual',
@@ -999,7 +997,7 @@ class api_v3_ContactTest extends CiviUnitTestCase {
       'filter.group_id' => $groupId,
       'contact_type' => 'Individual',
     );
-    $result = $this->callAPIAndDocument('contact', 'get', $params, __FUNCTION__, __FILE__, $description, $subFile);
+    $result = $this->callAPISuccess('contact', 'get', $params);
     $this->assertEquals(1, $result['count']);
     // group 26 doesn't exist, but we can still search contacts in it.
     $params = array(
@@ -1012,7 +1010,7 @@ class api_v3_ContactTest extends CiviUnitTestCase {
       'filter.group_id' => "$groupId, 26",
       'contact_type' => 'Individual',
     );
-    $result = $this->callAPIAndDocument('contact', 'get', $params, __FUNCTION__, __FILE__, $description, $subFile);
+    $result = $this->callAPISuccess('contact', 'get', $params);
     $this->assertEquals(1, $result['count']);
     $params = array(
       'filter.group_id' => "26,27",
@@ -1025,7 +1023,7 @@ class api_v3_ContactTest extends CiviUnitTestCase {
       'filter.group_id' => array($groupId, 26),
       'contact_type' => 'Individual',
     );
-    $result = $this->callAPIAndDocument('contact', 'get', $params, __FUNCTION__, __FILE__, $description, $subFile);
+    $result = $this->callAPISuccess('contact', 'get', $params);
     $this->assertEquals(1, $result['count']);
 
     //test in conjunction with other criteria
@@ -1648,6 +1646,40 @@ class api_v3_ContactTest extends CiviUnitTestCase {
     $this->callAPISuccess('contact', 'delete', $contact);
   }
 
+  /**
+   * Ensure consistent return format for option group fields.
+   */
+  public function testPseudoFields() {
+    $params = array(
+      'preferred_communication_method' => array('Phone', 'SMS'),
+      'preferred_language' => 'en_US',
+      'gender_id' => 'Female',
+      'prefix_id' => 'Mrs.',
+      'suffix_id' => 'II',
+      'communication_style_id' => 'Formal',
+    );
+
+    $contact = $this->callAPISuccess('contact', 'create', array_merge($this->_params, $params));
+
+    $result = $this->callAPISuccess('contact', 'getsingle', array('id' => $contact['id']));
+    $this->assertEquals('Both', $result['preferred_mail_format']);
+
+    $this->assertEquals('en_US', $result['preferred_language']);
+    $this->assertEquals(1, $result['communication_style_id']);
+    $this->assertEquals(1, $result['gender_id']);
+    $this->assertEquals('Female', $result['gender']);
+    $this->assertEquals('Mrs.', $result['individual_prefix']);
+    $this->assertEquals(1, $result['prefix_id']);
+    $this->assertEquals('II', $result['individual_suffix']);
+    $this->assertEquals(CRM_Core_PseudoConstant::getKey("CRM_Contact_BAO_Contact", 'suffix_id', 'II'), $result['suffix_id']);
+    $this->callAPISuccess('contact', 'delete', $contact);
+    $this->assertEquals(array(
+      CRM_Core_PseudoConstant::getKey("CRM_Contact_BAO_Contact", 'preferred_communication_method', 'Phone'),
+      CRM_Core_PseudoConstant::getKey("CRM_Contact_BAO_Contact", 'preferred_communication_method', 'SMS'),
+    ), $result['preferred_communication_method']);
+  }
+
+
   /**
    * Test birth date parameters.
    *
@@ -3166,4 +3198,176 @@ class api_v3_ContactTest extends CiviUnitTestCase {
     }
   }
 
+  /**
+   * CRM-20144 Verify that passing title of group works as well as id
+   * Tests the following formats
+   * contact.get group='title1'
+   * contact.get group=id1
+   */
+  public function testContactGetWithGroupTitle() {
+    // Set up a contact, asser that they were created.
+    $contact_params = array(
+      'contact_type' => 'Individual',
+      'first_name' => 'Test2',
+      'last_name' => 'Groupmember',
+      'email' => 'test@example.org',
+    );
+    $create_contact = $this->callApiSuccess('Contact', 'create', $contact_params);
+    $created_contact_id = $create_contact['id'];
+    // Set up multiple groups, add the contact to the groups.
+    $test_groups = array('Test group C', 'Test group D');
+    foreach ($test_groups as $title) {
+      $group_params = array(
+        'title' => $title,
+        'created_id' => $created_contact_id,
+      );
+      $create_group = $this->callApiSuccess('Group', 'create', $group_params);
+      $created_group_id = $create_group['id'];
+
+      // Add contact to the new group.
+      $group_contact_params = array(
+        'contact_id' => $created_contact_id,
+        'group_id' => $create_group['id'],
+      );
+      $create_group_contact = $this->callApiSuccess('GroupContact', 'create', $group_contact_params);
+      $contact_get = $this->callAPISuccess('contact', 'get', array('group' => $title, 'return' => 'group'));
+      $this->assertEquals(1, $contact_get['count']);
+      $this->assertEquals($created_contact_id, $contact_get['id']);
+      $contact_groups = explode(',', $contact_get['values'][$created_contact_id]['groups']);
+      $this->assertContains((string) $create_group['id'], $contact_groups);
+      $contact_get2 = $this->callAPISuccess('contact', 'get', array('group' => $created_group_id, 'return' => 'group'));
+      $this->assertEquals($created_contact_id, $contact_get2['id']);
+      $contact_groups2 = explode(',', $contact_get2['values'][$created_contact_id]['groups']);
+      $this->assertContains((string) $create_group['id'], $contact_groups2);
+      $this->callAPISuccess('group', 'delete', array('id' => $created_group_id));
+    }
+    $this->callAPISuccess('contact', 'delete', array('id' => $created_contact_id, 'skip_undelete' => TRUE));
+  }
+
+  /**
+   * CRM-20144 Verify that passing title of group works as well as id
+   * Tests the following formats
+   * contact.get group=array('title1', title1)
+   * contact.get group=array('IN' => array('title1', 'title2)
+   */
+  public function testContactGetWithGroupTitleMultipleGroups() {
+    $description = "Get all from group and display contacts.";
+    $subFile = "GroupFilterUsingContactAPI";
+    // Set up a contact, asser that they were created.
+    $contact_params = array(
+      'contact_type' => 'Individual',
+      'first_name' => 'Test2',
+      'last_name' => 'Groupmember',
+      'email' => 'test@example.org',
+    );
+    $create_contact = $this->callApiSuccess('Contact', 'create', $contact_params);
+    $created_contact_id = $create_contact['id'];
+    $createdGroupsTitles = $createdGroupsIds = array();
+    // Set up multiple groups, add the contact to the groups.
+    $test_groups = array('Test group C', 'Test group D');
+    foreach ($test_groups as $title) {
+      $group_params = array(
+        'title' => $title,
+        'created_id' => $created_contact_id,
+      );
+      $create_group = $this->callApiSuccess('Group', 'create', $group_params);
+      $created_group_id = $create_group['id'];
+      $createdGroupsIds[] = $create_group['id'];
+      $createdGroupTitles[] = $title;
+      // Add contact to the new group.
+      $group_contact_params = array(
+        'contact_id' => $created_contact_id,
+        'group_id' => $create_group['id'],
+      );
+      $create_group_contact = $this->callApiSuccess('GroupContact', 'create', $group_contact_params);
+    }
+    $contact_get = $this->callAPISuccess('contact', 'get', array('group' => $createdGroupTitles, 'return' => 'group'));
+    $this->assertEquals(1, $contact_get['count']);
+    $this->assertEquals($created_contact_id, $contact_get['id']);
+    $contact_groups = explode(',', $contact_get['values'][$created_contact_id]['groups']);
+    foreach ($createdGroupsIds as $id) {
+      $this->assertContains((string) $id, $contact_groups);
+    }
+    $contact_get2 = $this->callAPIAndDocument('contact', 'get', array('group' => array('IN' => $createdGroupTitles)), __FUNCTION__, __FILE__, $description, $subFile);
+    $contact_get2 = $this->callAPISuccess('contact', 'get', array('group' => array('IN' => $createdGroupTitles), 'return' => 'group'));
+    $this->assertEquals($created_contact_id, $contact_get2['id']);
+    $contact_groups2 = explode(',', $contact_get2['values'][$created_contact_id]['groups']);
+    foreach ($createdGroupsIds as $id) {
+      $this->assertContains((string) $id, $contact_groups2);
+    }
+    foreach ($createdGroupsIds as $id) {
+      $this->callAPISuccess('group', 'delete', array('id' => $id));
+    }
+    $this->callAPISuccess('contact', 'delete', array('id' => $created_contact_id, 'skip_undelete' => TRUE));
+  }
+
+  /**
+   * CRM-20144 Verify that passing title of group works as well as id
+   * Tests the following formats
+   * contact.get group=array('title1' => 1)
+   * contact.get group=array('titke1' => 1, 'title2' => 1)
+   * contact.get group=array('id1' => 1)
+   * contact.get group=array('id1' => 1, id2 => 1)
+   */
+  public function testContactGetWithGroupTitleMultipleGroupsLegacyFormat() {
+    // Set up a contact, asser that they were created.
+    $contact_params = array(
+      'contact_type' => 'Individual',
+      'first_name' => 'Test2',
+      'last_name' => 'Groupmember',
+      'email' => 'test@example.org',
+    );
+    $create_contact = $this->callApiSuccess('Contact', 'create', $contact_params);
+    $created_contact_id = $create_contact['id'];
+    $createdGroupsTitles = $createdGroupsIds = array();
+    // Set up multiple groups, add the contact to the groups.
+    $test_groups = array('Test group C', 'Test group D');
+    foreach ($test_groups as $title) {
+      $group_params = array(
+        'title' => $title,
+        'created_id' => $created_contact_id,
+      );
+      $create_group = $this->callApiSuccess('Group', 'create', $group_params);
+      $created_group_id = $create_group['id'];
+      $createdGroupsIds[] = $create_group['id'];
+      $createdGroupTitles[] = $title;
+      // Add contact to the new group.
+      $group_contact_params = array(
+        'contact_id' => $created_contact_id,
+        'group_id' => $create_group['id'],
+      );
+      $create_group_contact = $this->callApiSuccess('GroupContact', 'create', $group_contact_params);
+    }
+    $contact_get = $this->callAPISuccess('contact', 'get', array('group' => array($createdGroupTitles[0] => 1), 'return' => 'group'));
+    $this->assertEquals(1, $contact_get['count']);
+    $this->assertEquals($created_contact_id, $contact_get['id']);
+    $contact_groups = explode(',', $contact_get['values'][$created_contact_id]['groups']);
+    foreach ($createdGroupsIds as $id) {
+      $this->assertContains((string) $id, $contact_groups);
+    }
+    $contact_get2 = $this->callAPISuccess('contact', 'get', array('group' => array($createdGroupTitles[0] => 1, $createdGroupTitles[1] => 1), 'return' => 'group'));
+    $this->assertEquals(1, $contact_get2['count']);
+    $this->assertEquals($created_contact_id, $contact_get2['id']);
+    $contact_groups2 = explode(',', $contact_get2['values'][$created_contact_id]['groups']);
+    foreach ($createdGroupsIds as $id) {
+      $this->assertContains((string) $id, $contact_groups2);
+    }
+    $contact_get3 = $this->callAPISuccess('contact', 'get', array('group' => array($createdGroupsIds[0] => 1), 'return' => 'group'));
+    $this->assertEquals($created_contact_id, $contact_get3['id']);
+    $contact_groups3 = explode(',', $contact_get3['values'][$created_contact_id]['groups']);
+    foreach ($createdGroupsIds as $id) {
+      $this->assertContains((string) $id, $contact_groups3);
+    }
+    $contact_get4 = $this->callAPISuccess('contact', 'get', array('group' => array($createdGroupsIds[0] => 1, $createdGroupsIds[1] => 1), 'return' => 'group'));
+    $this->assertEquals($created_contact_id, $contact_get4['id']);
+    $contact_groups4 = explode(',', $contact_get4['values'][$created_contact_id]['groups']);
+    foreach ($createdGroupsIds as $id) {
+      $this->assertContains((string) $id, $contact_groups4);
+    }
+    foreach ($createdGroupsIds as $id) {
+      $this->callAPISuccess('group', 'delete', array('id' => $id));
+    }
+    $this->callAPISuccess('contact', 'delete', array('id' => $created_contact_id, 'skip_undelete' => TRUE));
+  }
+
 }
index 2b76a3add9491daa1baba2d577cee0cf1f6e85ba..e9a6c3d7b862079d97155a4d2540318609dbf096 100644 (file)
@@ -313,6 +313,52 @@ class api_v3_ContributionPageTest extends CiviUnitTestCase {
     $this->callAPISuccessGetSingle('LineItem', array('contribution_id' => $contribution['id'], 'entity_id' => $membershipPayment['id']));
   }
 
+  /**
+   * Test submit with a membership block in place works with renewal.
+   */
+  public function testSubmitMembershipBlockNotSeparatePaymentProcessorInstantRenew() {
+    $this->setUpMembershipContributionPage();
+    $dummyPP = Civi\Payment\System::singleton()->getByProcessor($this->_paymentProcessor);
+    $dummyPP->setDoDirectPaymentResult(array('payment_status_id' => 1));
+    $submitParams = array(
+      'price_' . $this->_ids['price_field'][0] => reset($this->_ids['price_field_value']),
+      'id' => (int) $this->_ids['contribution_page'],
+      'amount' => 10,
+      'billing_first_name' => 'Billy',
+      'billing_middle_name' => 'Goat',
+      'billing_last_name' => 'Gruff',
+      'selectMembership' => $this->_ids['membership_type'],
+      'payment_processor_id' => 1,
+      'credit_card_number' => '4111111111111111',
+      'credit_card_type' => 'Visa',
+      'credit_card_exp_date' => array('M' => 9, 'Y' => 2040),
+      'cvv2' => 123,
+    );
+
+    $this->callAPISuccess('contribution_page', 'submit', $submitParams);
+    $contribution = $this->callAPISuccess('contribution', 'getsingle', array('contribution_page_id' => $this->_ids['contribution_page']));
+    $membershipPayment = $this->callAPISuccess('membership_payment', 'getsingle', array('contribution_id' => $contribution['id']));
+    $this->callAPISuccessGetCount('LineItem', array(
+      'entity_table' => 'civicrm_membership',
+      'entity_id' => $membershipPayment['id'],
+    ), 1);
+
+    $submitParams['contact_id'] = $contribution['contact_id'];
+
+    $this->callAPISuccess('contribution_page', 'submit', $submitParams);
+    $this->callAPISuccessGetCount('LineItem', array(
+      'entity_table' => 'civicrm_membership',
+      'entity_id' => $membershipPayment['id'],
+    ), 2);
+    $membership = $this->callAPISuccessGetSingle('Membership', array(
+      'id' => $membershipPayment['membership_id'],
+      'return' => array('end_date', 'join_date', 'start_date'),
+    ));
+    $this->assertEquals(date('Y-m-d'), $membership['start_date']);
+    $this->assertEquals(date('Y-m-d'), $membership['join_date']);
+    $this->assertEquals(date('Y-m-d', strtotime('+ 2 year - 1 day')), $membership['end_date']);
+  }
+
   /**
    * Test submit with a membership block in place.
    */
@@ -1416,4 +1462,66 @@ class api_v3_ContributionPageTest extends CiviUnitTestCase {
     );
   }
 
+  /**
+   * Test Tax Amount is calculated properly when using PriceSet with Field Type = Text/Numeric Quantity
+   */
+  public function testSubmitContributionPageWithPriceSetQuantity() {
+    $this->_priceSetParams['is_quick_config'] = 0;
+    $this->enableTaxAndInvoicing();
+    $financialType = $this->createFinancialType();
+    $financialTypeId = $financialType['id'];
+    // This function sets the Tax Rate at 10% - it currently has no way to pass Tax Rate into it - so let's work with 10%
+    $financialAccount = $this->relationForFinancialTypeWithFinancialAccount($financialType['id'], 5);
+
+    $this->setUpContributionPage();
+    $submitParams = array(
+      'price_' . $this->_ids['price_field'][0] => reset($this->_ids['price_field_value']),
+      'id' => (int) $this->_ids['contribution_page'],
+      'first_name' => 'J',
+      'last_name' => 'T',
+      'email' => 'JT@ohcanada.ca',
+      'is_pay_later' => TRUE,
+    );
+
+    // Create PriceSet/PriceField
+    $priceSetID = reset($this->_ids['price_set']);
+    $priceField = $this->callAPISuccess('price_field', 'create', array(
+      'price_set_id' => $priceSetID,
+      'label' => 'Printing Rights',
+      'html_type' => 'Text',
+    ));
+    $priceFieldValue = $this->callAPISuccess('price_field_value', 'create', array(
+      'price_set_id' => $priceSetID,
+      'price_field_id' => $priceField['id'],
+      'label' => 'Printing Rights',
+      'financial_type_id' => $financialTypeId,
+      'amount' => '16.95',
+    ));
+    $priceFieldId = $priceField['id'];
+
+    // Set quantity for our test
+    $submitParams['price_' . $priceFieldId] = 180;
+
+    // contribution_page submit requires amount and tax_amount - and that's ok we're not testing that - we're testing at the LineItem level
+    $submitParams['amount'] = 180 * 16.95;
+    // This is the correct Tax Amount - use it later to compare to what the CiviCRM Core came up with at the LineItem level
+    $submitParams['tax_amount'] = 180 * 16.95 * 0.10;
+
+    $this->callAPISuccess('contribution_page', 'submit', $submitParams);
+    $contribution = $this->callAPISuccessGetSingle('contribution', array(
+      'contribution_page_id' => $this->_ids['contribution_page'],
+    ));
+
+    // Retrieve the lineItem that belongs to the Printing Rights and check the tax_amount CiviCRM Core calculated for it
+    $lineItem = $this->callAPISuccess('LineItem', 'get', array(
+      'contribution_id' => $contribution['id'],
+      'label' => 'Printing Rights',
+    ));
+    $lineItemId = $lineItem['id'];
+    $lineItem_TaxAmount = round($lineItem['values'][$lineItemId]['tax_amount'], 2);
+
+    // Compare this to what it should be!
+    $this->assertEquals($lineItem_TaxAmount, round($submitParams['tax_amount'], 2), 'Wrong Sales Tax Amount is calculated and stored.');
+  }
+
 }
index 2320f688c9fb1931a2df84c1a008b9171ad941cb..18040298efcbbc94d1b652dba67b52718cc776cf 100644 (file)
@@ -2094,6 +2094,42 @@ class api_v3_ContributionTest extends CiviUnitTestCase {
     $this->assertEquals($contributionRecur['values'][1]['is_test'], $repeatedContribution['values'][2]['is_test']);
     $this->quickCleanUpFinancialEntities();
   }
+  /**
+   * CRM-19945 Tests repeattransaction is using a completed contribution for the template.
+   *  ( Tests membership is renewed after repeattransaction. )
+   */
+  public function testRepeatTransactionUsesCompleted() {
+    list($originalContribution, $membership) = $this->setUpAutoRenewMembership();
+
+    $this->callAPISuccess('contribution', 'create', array(
+          'contact_id' => $originalContribution['values'][1]['contact_id'],
+          'financial_type_id' => $originalContribution['values'][1]['financial_type_id'],
+          'total_amount' => $originalContribution['values'][1]['total_amount'],
+          'contribution_recur_id' => $originalContribution['values'][1]['contribution_recur_id'],
+          'contribution_status_id' => "Failed",
+    ));
+
+    $this->callAPISuccess('membership', 'create', array(
+       'id' => $membership['id'],
+       'end_date' => 'yesterday',
+       'status_id' => 4,
+    ));
+
+    $this->callAPISuccess('contribution', 'repeattransaction', array(
+       'contribution_recur_id' => $originalContribution['values'][1]['contribution_recur_id'],
+       'contribution_status_id' => 'Completed',
+       'trxn_id' => uniqid(),
+    ));
+
+    $membershipStatus = $this->callAPISuccess('membership', 'getvalue', array(
+      'id' => $membership['id'],
+      'return' => 'status_id',
+    ));
+
+    $this->assertEquals('1', $membershipStatus);
+    $this->quickCleanUpFinancialEntities();
+    $this->contactDelete($originalContribution['values'][1]['contact_id']);
+  }
 
   /**
    * CRM-16397 test appropriate action if total amount has changed for single line items.
@@ -3146,6 +3182,76 @@ class api_v3_ContributionTest extends CiviUnitTestCase {
     return $originalContribution;
   }
 
+  /**
+   * Set up a basic auto-renew membership for tests.
+   *
+   * @param array $generalParams
+   *   Parameters that can be merged into the recurring AND the contribution.
+   *
+   * @param array $recurParams
+   *   Parameters to merge into the recur only.
+   *
+   * @return array|int
+   */
+  protected function setUpAutoRenewMembership($generalParams = array(), $recurParams = array()) {
+    $newContact = $this->callAPISuccess('Contact', 'create', array(
+       'contact_type' => 'Individual',
+       'sort_name' => 'McTesterson, Testy',
+       'display_name' => 'Testy McTesterson',
+       'preferred_language' => 'en_US',
+       'preferred_mail_format' => 'Both',
+       'first_name' => 'Testy',
+       'last_name' => 'McTesterson',
+       'contact_is_deleted' => '0',
+       'email_id' => '4',
+       'email' => 'tmctesterson@example.com',
+       'on_hold' => '0',
+    ));
+    $membershipType = $this->callAPISuccess('MembershipType', 'create', array(
+      'domain_id' => "Default Domain Name",
+      'member_of_contact_id' => 1,
+      'financial_type_id' => "Member Dues",
+      'duration_unit' => "month",
+      'duration_interval' => 1,
+      'period_type' => 'rolling',
+      'name' => "Standard Member",
+      'minimum_fee' => 100,
+    ));
+    $contributionRecur = $this->callAPISuccess('contribution_recur', 'create', array_merge(array(
+      'contact_id' => $newContact['id'],
+      'installments' => '12',
+      'frequency_interval' => '1',
+      'amount' => '100',
+      'contribution_status_id' => 1,
+      'start_date' => '2012-01-01 00:00:00',
+      'currency' => 'USD',
+      'frequency_unit' => 'month',
+      'payment_processor_id' => $this->paymentProcessorID,
+    ), $generalParams, $recurParams));
+    $originalContribution = $this->callAPISuccess('contribution', 'create', array_merge(
+      $this->_params,
+      array(
+        'contact_id' => $newContact['id'],
+        'contribution_recur_id' => $contributionRecur['id'],
+        'financial_type_id' => "Member Dues",
+        'contribution_status_id' => 1,
+        'invoice_id' => uniqid(),
+      ), $generalParams)
+    );
+    $membership = $this->callAPISuccess('membership', 'create', array(
+      'contact_id' => $newContact['id'],
+      'contribution_recur_id' => $contributionRecur['id'],
+      'financial_type_id' => "Member Dues",
+      'membership_type_id' => $membershipType['id'],
+      'num_terms' => 1,
+    ));
+
+    $this->callAPISuccess('MembershipPayment', 'create', array(
+        'contribution_id' => $originalContribution['id'],
+        'membership_id' => $membership['id'],
+    ));
+    return array($originalContribution, $membership);
+  }
   /**
    * Set up a repeat transaction.
    *
@@ -3218,4 +3324,170 @@ class api_v3_ContributionTest extends CiviUnitTestCase {
     return $contribution;
   }
 
+  /**
+   * Test repeat contribution uses the Payment Processor' payment_instrument setting.
+   */
+  public function testRepeatTransactionWithNonCreditCardDefault() {
+    $contributionRecur = $this->callAPISuccess('contribution_recur', 'create', array(
+      'contact_id' => $this->_individualId,
+      'installments' => '12',
+      'frequency_interval' => '1',
+      'amount' => '100',
+      'contribution_status_id' => 1,
+      'start_date' => '2012-01-01 00:00:00',
+      'currency' => 'USD',
+      'frequency_unit' => 'month',
+      'payment_processor_id' => $this->paymentProcessorID,
+    ));
+    $contribution1 = $this->callAPISuccess('contribution', 'create', array_merge(
+        $this->_params,
+        array('contribution_recur_id' => $contributionRecur['id'], 'payment_instrument_id' => 2))
+    );
+    $paymentInstruments = CRM_Contribute_PseudoConstant::paymentInstrument('name');
+    $contribution2 = $this->callAPISuccess('contribution', 'repeattransaction', array(
+      'contribution_status_id' => 'Completed',
+      'trxn_id' => uniqid(),
+      'original_contribution_id' => $contribution1,
+    ));
+    $this->assertEquals(array_search('Debit Card', $paymentInstruments), $contribution2['values'][$contribution2['id']]['payment_instrument_id']);
+    $this->quickCleanUpFinancialEntities();
+  }
+
+  /**
+   * Test sending a mail via the API.
+   */
+  public function testSendMailWithAPISetFromDetails() {
+    $mut = new CiviMailUtils($this, TRUE);
+    $contribution = $this->callAPISuccess('contribution', 'create', $this->_params);
+    $this->callAPISuccess('contribution', 'sendconfirmation', array(
+      'id' => $contribution['id'],
+      'receipt_from_email' => 'api@civicrm.org',
+      'receipt_from_name' => 'CiviCRM LLC',
+    ));
+    $mut->checkMailLog(array(
+        'From: CiviCRM LLC <api@civicrm.org>',
+        'Contribution Information',
+        'Please print this confirmation for your records',
+      ), array(
+        'Event',
+      )
+    );
+    $mut->stop();
+  }
+
+  /**
+   * Test sending a mail via the API.
+   */
+  public function testSendMailWithNoFromSetFallToDomain() {
+    $this->createLoggedInUser();
+    $mut = new CiviMailUtils($this, TRUE);
+    $contribution = $this->callAPISuccess('contribution', 'create', $this->_params);
+    $this->callAPISuccess('contribution', 'sendconfirmation', array(
+      'id' => $contribution['id'],
+    ));
+    $domain = $this->callAPISuccess('domain', 'getsingle', array('id' => 1));
+    $mut->checkMailLog(array(
+        'From: ' . $domain['from_name'] . ' <' . $domain['from_email'] . '>',
+        'Contribution Information',
+        'Please print this confirmation for your records',
+      ), array(
+        'Event',
+      )
+    );
+    $mut->stop();
+  }
+
+  /**
+   * Test sending a mail via the API.
+   */
+  public function testSendMailWithRepeatTransactionAPIFalltoDomain() {
+    $this->createLoggedInUser();
+    $mut = new CiviMailUtils($this, TRUE);
+    $contribution = $this->setUpRepeatTransaction(array(), 'single');
+    $this->callAPISuccess('contribution', 'repeattransaction', array(
+      'contribution_status_id' => 'Completed',
+      'trxn_id' => uniqid(),
+      'original_contribution_id' => $contribution,
+    ));
+    $domain = $this->callAPISuccess('domain', 'getsingle', array('id' => 1));
+    $mut->checkMailLog(array(
+        'From: ' . $domain['from_name'] . ' <' . $domain['from_email'] . '>',
+        'Contribution Information',
+        'Please print this confirmation for your records',
+      ), array(
+        'Event',
+      )
+    );
+    $mut->stop();
+  }
+
+  /**
+   * Test sending a mail via the API.
+   */
+  public function testSendMailWithRepeatTransactionAPIFalltoContributionPage() {
+    $mut = new CiviMailUtils($this, TRUE);
+    $contributionPage = $this->contributionPageCreate(array('receipt_from_name' => 'CiviCRM LLC', 'receipt_from_email' => 'contributionpage@civicrm.org', 'is_email_receipt' => 1));
+    $paymentProcessorID = $this->paymentProcessorCreate();
+    $contributionRecur = $this->callAPISuccess('contribution_recur', 'create', array(
+      'contact_id' => $this->_individualId,
+      'installments' => '12',
+      'frequency_interval' => '1',
+      'amount' => '500',
+      'contribution_status_id' => 1,
+      'start_date' => '2012-01-01 00:00:00',
+      'currency' => 'USD',
+      'frequency_unit' => 'month',
+      'payment_processor_id' => $paymentProcessorID,
+    ));
+    $originalContribution = $this->callAPISuccess('contribution', 'create', array_merge(
+      $this->_params,
+      array(
+        'contribution_recur_id' => $contributionRecur['id'],
+        'contribution_page_id' => $contributionPage['id']))
+    );
+    $this->callAPISuccess('contribution', 'repeattransaction', array(
+      'contribution_status_id' => 'Completed',
+      'trxn_id' => uniqid(),
+      'original_contribution_id' => $originalContribution,
+      )
+    );
+    $mut->checkMailLog(array(
+        'From: CiviCRM LLC <contributionpage@civicrm.org>',
+        'Contribution Information',
+        'Please print this confirmation for your records',
+      ), array(
+        'Event',
+      )
+    );
+    $mut->stop();
+  }
+
+  /**
+   * Test sending a mail via the API.
+   */
+  public function testSendMailWithRepeatTransactionAPIFalltoSystemFromNoDefaultFrom() {
+    $mut = new CiviMailUtils($this, TRUE);
+    $originalContribution = $contribution = $this->setUpRepeatTransaction(array(), 'single');
+    $fromEmail = $this->CallAPISuccess('optionValue', 'get', array('is_default' => 1, 'option_group_id' => 'from_email_address', 'sequential' => 1));
+    foreach ($fromEmail['values'] as $from) {
+      $this->callAPISuccess('optionValue', 'create', array('is_default' => 0, 'id' => $from['id']));
+    }
+    $domain = $this->callAPISuccess('domain', 'getsingle', array('id' => CRM_Core_Config::domainID()));
+    $this->callAPISuccess('contribution', 'repeattransaction', array(
+      'contribution_status_id' => 'Completed',
+      'trxn_id' => uniqid(),
+      'original_contribution_id' => $originalContribution,
+      )
+    );
+    $mut->checkMailLog(array(
+        'From: ' . $domain['name'] . ' <' . $domain['domain_email'] . '>',
+        'Contribution Information',
+        'Please print this confirmation for your records',
+      ), array(
+        'Event',
+      )
+    );
+    $mut->stop();
+  }
+
 }
index 63b79a3179c3b8d760eedd1e3467a3167a1b4991..ac5f7f2bbd6b9bd86cadb57df25af9ed7d9cb14e 100644 (file)
@@ -296,9 +296,8 @@ class api_v3_EventTest extends CiviUnitTestCase {
       'api.Event.create' => $eventParams,
       'sequential' => 1,
     );
-    $createResult = $this->callAPIAndDocument('LocBlock', 'create', $locBlockParams, __FUNCTION__, __FILE__);
+    $createResult = $this->callAPISuccess('LocBlock', 'create', $locBlockParams);
     $locBlockId = $createResult['id'];
-    $addressId = $createResult['values'][0]['address_id'];
     $eventId = $createResult['values'][0]['api.Event.create']['id'];
 
     // request the event with its loc block:
@@ -426,7 +425,7 @@ class api_v3_EventTest extends CiviUnitTestCase {
     $params['event_type_id'] = 1;
     $params['custom_' . $customField['id']] = "$contact_id";
 
-    $result = $this->callAPIAndDocument($this->_entity, 'create', $params, __FUNCTION__, __FILE__, $description, $subfile);
+    $this->callAPIAndDocument($this->_entity, 'create', $params, __FUNCTION__, __FILE__, $description, $subfile);
 
     // Retrieve the activity, search for the contact.
     $result = $this->callAPIAndDocument($this->_entity, 'get', array(
@@ -562,10 +561,10 @@ class api_v3_EventTest extends CiviUnitTestCase {
     $this->assertArrayHasKey('id', $result['values'][$result['id']]);
     $result = $this->callAPISuccess($this->_entity, 'Get', array('id' => $result['id']));
     $this->callAPISuccess($this->_entity, 'Delete', array('id' => $result['id']));
-    $this->assertEquals('2008-10-21 00:00:00', $result['values'][$result['id']]['start_date'], 'start date is not set in line ' . __LINE__);
-    $this->assertEquals('2008-10-23 00:00:00', $result['values'][$result['id']]['end_date'], 'end date is not set in line ' . __LINE__);
-    $this->assertEquals('2008-06-01 00:00:00', $result['values'][$result['id']]['registration_start_date'], 'start date is not set in line ' . __LINE__);
-    $this->assertEquals('2008-10-15 00:00:00', $result['values'][$result['id']]['registration_end_date'], 'end date is not set in line ' . __LINE__);
+    $this->assertEquals('2008-10-21 00:00:00', $result['values'][$result['id']]['start_date'], 'start date is not set');
+    $this->assertEquals('2008-10-23 00:00:00', $result['values'][$result['id']]['end_date'], 'end date is not set');
+    $this->assertEquals('2008-06-01 00:00:00', $result['values'][$result['id']]['registration_start_date'], 'start date is not set');
+    $this->assertEquals('2008-10-15 00:00:00', $result['values'][$result['id']]['registration_end_date'], 'end date is not set');
   }
 
   /**
@@ -612,7 +611,7 @@ class api_v3_EventTest extends CiviUnitTestCase {
     $params = array(
       'id' => $this->_eventIds[0],
     );
-    $result = $this->callAPIAndDocument('Event', 'Delete', $params, __FUNCTION__, __FILE__);
+    $this->callAPIAndDocument('Event', 'Delete', $params, __FUNCTION__, __FILE__);
   }
 
   /**
@@ -631,13 +630,13 @@ class api_v3_EventTest extends CiviUnitTestCase {
    */
   public function testDeleteWithExistingParticipant() {
     $contactID = $this->individualCreate();
-    $participantID = $this->participantCreate(
+    $this->participantCreate(
       array(
         'contactID' => $contactID,
         'eventID' => $this->_eventIds[0],
       )
     );
-    $result = $this->callAPISuccess('Event', 'Delete', array('id' => $this->_eventIds[0]));
+    $this->callAPISuccess('Event', 'Delete', array('id' => $this->_eventIds[0]));
   }
 
   public function testDeleteWithWrongEventId() {
@@ -648,8 +647,6 @@ class api_v3_EventTest extends CiviUnitTestCase {
     $result = $this->callAPIFailure('Event', 'Delete', $params);
   }
 
-  ///////////////// civicrm_event_search methods
-
   /**
    * Test civicrm_event_search with wrong params type.
    */
index 3283d88b357f7fbdd6728c38fc03b261def3f5a8..39509f095ae89c0498da13887f8a1bd65432fbe6 100644 (file)
@@ -238,6 +238,53 @@ class api_v3_GroupContactTest extends CiviUnitTestCase {
     $this->assertEquals($result2['total_count'], 1);
   }
 
+  /**
+   * CRM-19979 test that group cotnact delete action works when contact is in status of pendin.
+   */
+  public function testDeleteWithPending() {
+    $groupId3 = $this->groupCreate(array(
+      'name' => 'Test Group 3',
+      'domain_id' => 1,
+      'title' => 'New Test Group3 Created',
+      'description' => 'New Test Group3 Created',
+      'is_active' => 1,
+      'visibility' => 'User and User Admin Only',
+    ));
+    $groupContactCreateParams = array(
+      'contact_id' => $this->_contactId,
+      'group_id' => $groupId3,
+      'status' => 'Pending',
+    );
+    $groupContact = $this->callAPISuccess('groupContact', 'create', $groupContactCreateParams);
+    $groupGetContact = $this->CallAPISuccess('groupContact', 'get', $groupContactCreateParams);
+    $this->callAPISuccess('groupContact', 'delete', array('id' => $groupGetContact['id'], 'status' => 'Removed'));
+    $this->callAPISuccess('groupContact', 'delete', array('id' => $groupGetContact['id'], 'skip_undelete' => TRUE));
+    $this->callAPISuccess('group', 'delete', array('id' => $groupId3));
+  }
+
+  /**
+   * CRM-19979 test that group cotnact delete action works when contact is in status of pendin and is a permanent delete.
+   */
+  public function testPermanentDeleteWithPending() {
+    $groupId3 = $this->groupCreate(array(
+      'name' => 'Test Group 3',
+      'domain_id' => 1,
+      'title' => 'New Test Group3 Created',
+      'description' => 'New Test Group3 Created',
+      'is_active' => 1,
+      'visibility' => 'User and User Admin Only',
+    ));
+    $groupContactCreateParams = array(
+      'contact_id' => $this->_contactId,
+      'group_id' => $groupId3,
+      'status' => 'Pending',
+    );
+    $groupContact = $this->callAPISuccess('groupContact', 'create', $groupContactCreateParams);
+    $groupGetContact = $this->CallAPISuccess('groupContact', 'get', $groupContactCreateParams);
+    $this->callAPISuccess('groupContact', 'delete', array('id' => $groupGetContact['id'], 'skip_undelete' => TRUE));
+    $this->callAPISuccess('group', 'delete', array('id' => $groupId3));
+  }
+
   /**
    * CRM-16945 duplicate groups are showing up when contacts are hard-added to child groups or smart groups.
    *
index 96f3095b6498b257f28b2ca5d0ffe43bed2c3025..27ff65e00b3f5214c68c72a7792ea44ebddb6d76 100644 (file)
@@ -47,7 +47,7 @@ class api_v3_LoggingTest extends CiviUnitTestCase {
    * Clean up log tables.
    */
   protected function tearDown() {
-    $this->quickCleanup(array('civicrm_email'));
+    $this->quickCleanup(array('civicrm_email', 'civicrm_address'));
     parent::tearDown();
     $this->callAPISuccess('Setting', 'create', array('logging' => FALSE));
     $schema = new CRM_Logging_Schema();
@@ -213,6 +213,9 @@ class api_v3_LoggingTest extends CiviUnitTestCase {
 
   /**
    * Check the triggers were created and look OK.
+   *
+   * @param bool $unique
+   *   Is the site configured for unique logging connection IDs per CRM-18193?
    */
   protected function checkTriggersCreated($unique) {
     $dao = CRM_Core_DAO::executeQuery("SHOW TRIGGERS LIKE 'civicrm_contact'");
@@ -289,6 +292,58 @@ class api_v3_LoggingTest extends CiviUnitTestCase {
     $this->callAPISuccessGetCount('Email', array('id' => $email['id']), 0);
   }
 
+  /**
+   * Ensure that a limited list of tables can be reverted.
+   *
+   * In this case ONLY civicrm_address is reverted and we check that email, contact and contribution
+   * entities have not been.
+   *
+   * @throws \Exception
+   */
+  public function testRevertRestrictedTables() {
+
+    CRM_Core_DAO::executeQuery("SET @uniqueID = 'temp name'");
+    $this->callAPISuccessGetValue('Setting', array('name' => 'logging_all_tables_uniquid'), TRUE);
+    $this->callAPISuccess('Setting', 'create', array('logging' => TRUE));
+
+    $contactId = $this->individualCreate(array('address' => array(array('street_address' => '27 Cool way', 'location_type_id' => 1))));
+    $contact = $this->callAPISuccessGetSingle('contact', array('id' => $contactId));
+    $this->assertEquals('Anthony', $contact['first_name']);
+    $this->assertEquals('anthony_anderson@civicrm.org', $contact['email']);
+    $this->assertEquals('27 Cool way', $contact['street_address']);
+
+    sleep(1);
+    CRM_Core_DAO::executeQuery("SET @uniqueID = 'bitty bot bot'");
+    $this->callAPISuccess('Contact', 'create', array(
+        'id' => $contactId,
+        'first_name' => 'Dopey',
+        'address' => array(array('street_address' => '25 Dorky way', 'location_type_id' => 1)),
+        'email' => array('email' => array('email' => 'dopey@mail.com', 'location_type_id' => 1)),
+        'api.contribution.create' => array('financial_type_id' => 'Donation', 'receive_date' => 'now', 'total_amount' => 10),
+      )
+    );
+    $contact = $this->callAPISuccessGetSingle('contact', array('id' => $contactId, 'return' => array('first_name', 'email', 'modified_date', 'street_address')));
+    $this->assertEquals('Dopey', $contact['first_name']);
+    $this->assertEquals('dopey@mail.com', $contact['email']);
+    $this->assertEquals('25 Dorky way', $contact['street_address']);
+    $modifiedDate = $contact['modified_date'];
+    // To protect against the modified date not changing due to the updates being too close together.
+    sleep(1);
+    $loggings = $this->callAPISuccess('Logging', 'get', array('log_conn_id' => 'bitty bot bot', 'tables' => array('civicrm_address')));
+    $this->assertEquals('civicrm_address', $loggings['values'][0]['table'], CRM_Core_DAO::executeQuery('SELECT * FROM log_civicrm_address')->toArray());
+    $this->assertEquals(1, $loggings['count'], CRM_Core_DAO::executeQuery('SELECT * FROM log_civicrm_address')->toArray());
+    $this->assertEquals('27 Cool way', $loggings['values'][0]['from']);
+    $this->assertEquals('25 Dorky way', $loggings['values'][0]['to']);
+    $this->callAPISuccess('Logging', 'revert', array('log_conn_id' => 'bitty bot bot', 'tables' => array('civicrm_address')));
+
+    $contact = $this->callAPISuccessGetSingle('contact', array('id' => $contactId, 'return' => array('first_name', 'email', 'modified_date', 'street_address')));
+    $this->assertEquals('Dopey', $contact['first_name']);
+    $this->assertEquals('dopey@mail.com', $contact['email']);
+    $this->assertEquals('27 Cool way', $contact['street_address']);
+    $this->callAPISuccessGetCount('Contribution', array('contact_id' => $contactId), 1);
+    $this->assertTrue(strtotime($modifiedDate) < strtotime($contact['modified_date']));
+  }
+
   /**
    * Test changes can be reverted.
    */
@@ -379,7 +434,7 @@ class api_v3_LoggingTest extends CiviUnitTestCase {
    * @param string $table
    * @param string $column
    *
-   * @return \CRM_Core_DAO|object
+   * @return bool
    */
   protected function checkColumnExistsInTable($table, $column) {
     $dao = CRM_Core_DAO::executeQuery("SHOW columns FROM {$table} WHERE Field = '{$column}'");
index eb60ca10855c35b7acfb1949b661016dddd6afae..04a1b73c6c73898b34d6e586497adbac7e24a206 100644 (file)
@@ -335,7 +335,7 @@ class api_v3_MailingTest extends CiviUnitTestCase {
     );
     // END SAMPLE DATA
 
-    $create = $this->callAPIAndDocument('Mailing', 'create', $params, __FUNCTION__, __FILE__);
+    $create = $this->callAPISuccess('Mailing', 'create', $params);
 
     $preview = $create['values'][$create['id']]['api.MailingRecipients.get'];
     $this->assertEquals(1, $preview['count']);
@@ -758,7 +758,7 @@ SELECT event_queue_id, time_stamp FROM mail_{$type}_temp";
    * we can still have working click-trough URLs working (CRM-17959).
    */
   public function testUrlWithMissingTrackingHash() {
-    $mail = $this->callAPIAndDocument('mailing', 'create', $this->_params + array('scheduled_date' => 'now'), __FUNCTION__, __FILE__);
+    $mail = $this->callAPISuccess('mailing', 'create', $this->_params + array('scheduled_date' => 'now'), __FUNCTION__, __FILE__);
     $jobs = $this->callAPISuccess('mailing_job', 'get', array('mailing_id' => $mail['id']));
     $this->assertEquals(1, $jobs['count']);
 
@@ -792,10 +792,10 @@ SELECT event_queue_id, time_stamp FROM mail_{$type}_temp";
     $this->_params['body_text'] = str_replace("https://civicrm.org", $unicodeURL, $this->_params['body_text']);
     $this->_params['body_html'] = str_replace("https://civicrm.org", $unicodeURL, $this->_params['body_html']);
 
-    $mail = $this->callAPIAndDocument('mailing', 'create', $this->_params + array('scheduled_date' => 'now'), __FUNCTION__, __FILE__);
+    $mail = $this->callAPISuccess('mailing', 'create', $this->_params + array('scheduled_date' => 'now'));
 
     $params = array('mailing_id' => $mail['id'], 'test_email' => 'alice@example.org', 'test_group' => NULL);
-    $deliveredInfo = $this->callAPISuccess($this->_entity, 'send_test', $params);
+    $this->callAPISuccess($this->_entity, 'send_test', $params);
 
     $sql = "SELECT turl.id as url_id, turl.url, q.id as queue_id
       FROM civicrm_mailing_trackable_url as turl
index 5e45401900428c0a97d5760d0eb8cb8b789f81b5..81c2bf95b27b5b49d6a8f9d92b648fb2d87e483c 100644 (file)
@@ -145,6 +145,21 @@ class api_v3_MembershipTypeTest extends CiviUnitTestCase {
     $this->assertEquals($membershipType['error_message'], 'Mandatory key(s) missing from params array: domain_id');
   }
 
+  /**
+   *  CRM-20010 Tests period_type is required for MemberType create
+   */
+  public function testMemberTypePeriodiTypeRequired() {
+    $this->callAPIFailure('MembershipType', 'create', array(
+      'domain_id' => "Default Domain Name",
+      'member_of_contact_id' => 1,
+      'financial_type_id' => "Member Dues",
+      'duration_unit' => "month",
+      'duration_interval' => 1,
+      'name' => "Standard Member",
+      'minimum_fee' => 100,
+    ));
+  }
+
   /**
    * Test update.
    */
index 319c00bfee03ecadc7af97353f60475439fc26bc..d38a8355bfd8d9ef93c244267e29b3759a43a921 100644 (file)
@@ -189,9 +189,9 @@ class api_v3_OptionValueTest extends CiviUnitTestCase {
   }
 
   /**
-   * Check that component  continues to be honoured.
+   * Check that component string is honoured.
    */
-  public function testCreateOptionSpecifyComponent() {
+  public function testCreateOptionSpecifyComponentString() {
     $result = $this->callAPISuccess('option_group', 'get', array(
       'name' => 'from_email_address',
       'sequential' => 1,
@@ -199,7 +199,6 @@ class api_v3_OptionValueTest extends CiviUnitTestCase {
         'component_id' => 'CiviContribute',
         'name' => 'my@y.com',
       ),
-
     ));
     $this->assertAPISuccess($result);
     $optionValueId = $result['values'][0]['api.option_value.create']['id'];
@@ -211,25 +210,53 @@ class api_v3_OptionValueTest extends CiviUnitTestCase {
   }
 
   /**
-   * Check that component string is honoured.
+   * Check that component is honoured when fetching options.
    */
-  public function testCreateOptionSpecifyComponentString() {
-    $result = $this->callAPISuccess('option_group', 'get', array(
-      'name' => 'from_email_address',
-      'sequential' => 1,
+  public function testGetOptionWithComponent() {
+    $components = Civi::settings()->get('enable_components');
+    CRM_Core_BAO_ConfigSetting::enableComponent('CiviContribute');
+    $this->callAPISuccess('option_group', 'get', array(
+      'name' => 'gender',
       'api.option_value.create' => array(
         'component_id' => 'CiviContribute',
-        'name' => 'my@y.com',
+        'name' => 'Contrib',
       ),
-
     ));
-    $this->assertAPISuccess($result);
-    $optionValueId = $result['values'][0]['api.option_value.create']['id'];
-    $component_id = $this->callAPISuccess('option_value', 'getvalue', array(
-      'id' => $optionValueId,
-      'return' => 'component_id',
+    // Verify new option is present
+    $genders = $this->callAPISuccess('contact', 'getoptions', array(
+      'field' => 'gender_id',
+      'context' => 'create',
     ));
-    $this->assertEquals(2, $component_id);
+    $this->assertContains('Contrib', $genders['values']);
+
+    // Disable relevant component
+    CRM_Core_BAO_ConfigSetting::disableComponent('CiviContribute');
+    CRM_Core_PseudoConstant::flush();
+    // New option should now be hidden for "create" context
+    $genders = $this->callAPISuccess('contact', 'getoptions', array(
+      'field' => 'gender_id',
+      'context' => 'create',
+    ));
+    $this->assertNotContains('Contrib', $genders['values']);
+    // New option should be visible for "get" context even with component disabled
+    $genders = $this->callAPISuccess('contact', 'getoptions', array(
+      'field' => 'gender_id',
+      'context' => 'get',
+    ));
+    $this->assertContains('Contrib', $genders['values']);
+
+    // Now disable all components and ensure we can still fetch options with no errors
+    CRM_Core_BAO_ConfigSetting::setEnabledComponents(array());
+    CRM_Core_PseudoConstant::flush();
+    // New option should still be hidden for "create" context
+    $genders = $this->callAPISuccess('contact', 'getoptions', array(
+      'field' => 'gender_id',
+      'context' => 'create',
+    ));
+    $this->assertNotContains('Contrib', $genders['values']);
+
+    // Restore original state
+    CRM_Core_BAO_ConfigSetting::setEnabledComponents($components);
   }
 
   /**
index cafbfffd88cf568f09391e8ae1769ce251c3d1c3..b920675e38bf11cae24d8bfca8c07406de58de0f 100644 (file)
@@ -57,8 +57,6 @@ class api_v3_PaymentProcessorTest extends CiviUnitTestCase {
     );
   }
 
-  ///////////////// civicrm_payment_processor_add methods
-
   /**
    * Check with no name.
    */
@@ -66,7 +64,7 @@ class api_v3_PaymentProcessorTest extends CiviUnitTestCase {
     $payProcParams = array(
       'is_active' => 1,
     );
-    $result = $this->callAPIFailure('payment_processor', 'create', $payProcParams);
+    $this->callAPIFailure('payment_processor', 'create', $payProcParams);
   }
 
   /**
@@ -76,8 +74,6 @@ class api_v3_PaymentProcessorTest extends CiviUnitTestCase {
     $params = $this->_params;
     $result = $this->callAPIAndDocument('payment_processor', 'create', $params, __FUNCTION__, __FILE__);
     $this->assertNotNull($result['id']);
-
-    //assertDBState compares expected values in $result to actual values in the DB
     $this->assertDBState('CRM_Financial_DAO_PaymentProcessor', $result['id'], $params);
     return $result['id'];
   }
@@ -92,8 +88,6 @@ class api_v3_PaymentProcessorTest extends CiviUnitTestCase {
     $this->assertAPISuccess($result);
   }
 
-  ///////////////// civicrm_payment_processor_delete methods
-
   /**
    * Check payment processor delete.
    */
@@ -103,11 +97,9 @@ class api_v3_PaymentProcessorTest extends CiviUnitTestCase {
       'id' => $id,
     );
 
-    $result = $this->callAPIAndDocument('payment_processor', 'delete', $params, __FUNCTION__, __FILE__);
+    $this->callAPIAndDocument('payment_processor', 'delete', $params, __FUNCTION__, __FILE__);
   }
 
-  ///////////////// civicrm_payment_processors_get methods
-
   /**
    * Check with valid params array.
    */
@@ -121,8 +113,8 @@ class api_v3_PaymentProcessorTest extends CiviUnitTestCase {
     );
     $results = $this->callAPISuccess('payment_processor', 'get', $params);
 
-    $this->assertEquals(1, $results['count'], ' in line ' . __LINE__);
-    $this->assertEquals('test@test.com', $results['values'][$results['id']]['user_name'], ' in line ' . __LINE__);
+    $this->assertEquals(1, $results['count']);
+    $this->assertEquals('test@test.com', $results['values'][$results['id']]['user_name']);
   }
 
 }
index e366f1d4b0166666920fbe7ae126d3363715961b..73d0da3d51ef037394198a89f225abf26d47abe5 100644 (file)
@@ -91,7 +91,7 @@ class api_v3_PcpTest extends CiviUnitTestCase {
     $checkCreated = $this->callAPISuccess($this->entity, 'get',
       array('id' => $entity['id']));
     $this->assertEquals(1, $checkCreated['count']);
-    $result = $this->callAPIAndDocument('Pcp', 'delete',
+    $this->callAPIAndDocument('Pcp', 'delete',
         array('id' => $entity['id']), __FUNCTION__, __FILE__);
     $checkDeleted = $this->callAPISuccess($this->entity, 'get',
         array('id' => $entity['id']));
@@ -109,8 +109,8 @@ class api_v3_PcpTest extends CiviUnitTestCase {
     $description = "Demonstrates get + delete in the same call.";
     $subfile = 'ChainedGetDelete';
     $params = array('title' => "Pcp title", 'api.Pcp.delete' => 1);
-    $result = $this->callAPISuccess('Pcp', 'create', $this->params);
-    $result = $this->callAPIAndDocument('Pcp', 'get', $params, __FUNCTION__,
+    $this->callAPISuccess('Pcp', 'create', $this->params);
+    $this->callAPIAndDocument('Pcp', 'get', $params, __FUNCTION__,
         __FILE__, $description, $subfile);
     $this->assertEquals(0, $this->callAPISuccess('Pcp', 'getcount', array()));
   }
index 4a56f5355ebde273bc4fa2a07af6119d401a3d91..4e8ede8883dc10e8682b76335af4cdc8bb8ce5e6 100644 (file)
@@ -64,16 +64,11 @@ class api_v3_ProfileTest extends CiviUnitTestCase {
     CRM_Core_DAO::executeQuery(" DELETE FROM civicrm_uf_group WHERE id IN ($this->_profileID, 26)");
   }
 
-  ////////////// test $this->callAPISuccess3_profile_get //////////////////
-
   /**
    * Check Without ProfileId.
    */
   public function testProfileGetWithoutProfileId() {
-    $params = array(
-      'contact_id' => 1,
-    );
-    $result = $this->callAPIFailure('profile', 'get', $params,
+    $this->callAPIFailure('profile', 'get', array('contact_id' => 1),
       'Mandatory key(s) missing from params array: profile_id'
     );
   }
@@ -82,20 +77,16 @@ class api_v3_ProfileTest extends CiviUnitTestCase {
    * Check with no invalid profile Id.
    */
   public function testProfileGetInvalidProfileId() {
-    $params = array(
-      'contact_id' => 1,
-      'profile_id' => 1000,
-    );
-    $result = $this->callAPIFailure('profile', 'get', $params);
+    $this->callAPIFailure('profile', 'get', array('contact_id' => 1, 'profile_id' => 1000));
   }
 
   /**
    * Check with success.
    */
   public function testProfileGet() {
-    $pofileFieldValues = $this->_createIndividualContact();
-    $expected = current($pofileFieldValues);
-    $contactId = key($pofileFieldValues);
+    $profileFieldValues = $this->_createIndividualContact();
+    $expected = current($profileFieldValues);
+    $contactId = key($profileFieldValues);
     $params = array(
       'profile_id' => $this->_profileID,
       'contact_id' => $contactId,
@@ -107,9 +98,9 @@ class api_v3_ProfileTest extends CiviUnitTestCase {
   }
 
   public function testProfileGetMultiple() {
-    $pofileFieldValues = $this->_createIndividualContact();
-    $expected = current($pofileFieldValues);
-    $contactId = key($pofileFieldValues);
+    $profileFieldValues = $this->_createIndividualContact();
+    $expected = current($profileFieldValues);
+    $contactId = key($profileFieldValues);
     $params = array(
       'profile_id' => array($this->_profileID, 1, 'Billing'),
       'contact_id' => $contactId,
@@ -145,8 +136,6 @@ class api_v3_ProfileTest extends CiviUnitTestCase {
       'contact_id' => $contactId,
     ));
 
-    $expected = current($individual);
-
     $params = array(
       'profile_id' => array($this->_profileID, 1, 'Billing'),
       'contact_id' => $contactId,
@@ -184,14 +173,12 @@ class api_v3_ProfileTest extends CiviUnitTestCase {
         'is_billing' => 1,
       ));
 
-    $expected = current($individual);
-
     $params = array(
       'profile_id' => array($this->_profileID, 1, 'Billing'),
       'contact_id' => $contactId,
     );
 
-    $result = $this->callAPISuccess('profile', 'get', $params, __FUNCTION__, __FILE__);
+    $result = $this->callAPISuccess('profile', 'get', $params);
     $this->assertEquals('abc1', $result['values'][1]['first_name']);
     $this->assertEquals($result['values']['Billing'], array(
       'billing_first_name' => 'abc1',
@@ -235,22 +222,19 @@ class api_v3_ProfileTest extends CiviUnitTestCase {
    * Check contact activity profile without activity id.
    */
   public function testContactActivityGetWithoutActivityId() {
-    list($params, $expected) = $this->_createContactWithActivity();
+    list($params) = $this->_createContactWithActivity();
 
     unset($params['activity_id']);
-    $result = $this->callAPIFailure('profile', 'get', $params,
-      'Mandatory key(s) missing from params array: activity_id');
+    $this->callAPIFailure('profile', 'get', $params, 'Mandatory key(s) missing from params array: activity_id');
   }
 
   /**
    * Check contact activity profile wrong activity id.
    */
   public function testContactActivityGetWrongActivityId() {
-    list($params, $expected) = $this->_createContactWithActivity();
-
+    list($params) = $this->_createContactWithActivity();
     $params['activity_id'] = 100001;
-    $result = $this->callAPIFailure('profile', 'get', $params,
-      'Invalid Activity Id (aid).');
+    $this->callAPIFailure('profile', 'get', $params, 'Invalid Activity Id (aid).');
   }
 
   /**
@@ -278,12 +262,10 @@ class api_v3_ProfileTest extends CiviUnitTestCase {
 
     $activityValues = array_pop($activity['values']);
 
-    list($params, $expected) = $this->_createContactWithActivity();
+    list($params) = $this->_createContactWithActivity();
 
     $params['activity_id'] = $activityValues['id'];
-    $result = $this->callAPIFailure('profile', 'get', $params,
-      'This activity cannot be edited or viewed via this profile.'
-    );
+    $this->callAPIFailure('profile', 'get', $params, 'This activity cannot be edited or viewed via this profile.');
   }
 
   /**
@@ -295,7 +277,7 @@ class api_v3_ProfileTest extends CiviUnitTestCase {
     $result = $this->callAPISuccess('profile', 'get', $params);
 
     foreach ($expected as $profileField => $value) {
-      $this->assertEquals($value, CRM_Utils_Array::value($profileField, $result['values']), "In line " . __LINE__ . " error message: " . "missing/mismatching value for {$profileField}"
+      $this->assertEquals($value, CRM_Utils_Array::value($profileField, $result['values']), " error message: " . "missing/mismatching value for {$profileField}"
       );
     }
   }
@@ -364,7 +346,7 @@ class api_v3_ProfileTest extends CiviUnitTestCase {
     $result = $this->callAPISuccess('uf_group', 'get', array('return' => 'id'));
     $profileIDs = array_keys($result['values']);
     foreach ($profileIDs as $profileID) {
-      $result = $this->callAPISuccess('profile', 'getfields', array(
+      $this->callAPISuccess('profile', 'getfields', array(
           'action' => 'submit',
           'profile_id' => $profileID,
           'get_options' => 'all',
@@ -372,7 +354,6 @@ class api_v3_ProfileTest extends CiviUnitTestCase {
       );
     }
   }
-  /////////////// test $this->callAPISuccess3_profile_set //////////////////
 
   /**
    * Check Without ProfileId.
@@ -381,7 +362,7 @@ class api_v3_ProfileTest extends CiviUnitTestCase {
     $params = array(
       'contact_id' => 1,
     );
-    $result = $this->callAPIFailure('profile', 'submit', $params,
+    $this->callAPIFailure('profile', 'submit', $params,
       'Mandatory key(s) missing from params array: profile_id'
     );
   }
@@ -443,7 +424,7 @@ class api_v3_ProfileTest extends CiviUnitTestCase {
       'contact_id' => $contactId,
     ), $updateParams);
 
-    $result = $this->callAPIAndDocument('profile', 'submit', $params, __FUNCTION__, __FILE__);
+    $this->callAPIAndDocument('profile', 'submit', $params, __FUNCTION__, __FILE__);
 
     $getParams = array(
       'profile_id' => $this->_profileID,
@@ -584,7 +565,7 @@ class api_v3_ProfileTest extends CiviUnitTestCase {
    */
   public function testContactActivitySubmitWrongActivityType() {
     //flush cache by calling with reset
-    $activityTypes = CRM_Core_PseudoConstant::activityType(TRUE, TRUE, TRUE, 'name', TRUE);
+    CRM_Core_PseudoConstant::activityType(TRUE, TRUE, TRUE, 'name', TRUE);
 
     $sourceContactId = $this->householdCreate();
 
@@ -608,7 +589,7 @@ class api_v3_ProfileTest extends CiviUnitTestCase {
 
     $params = array_merge($params, $expected);
     $params['activity_id'] = $activityValues['id'];
-    $result = $this->callAPIFailure('profile', 'submit', $params,
+    $this->callAPIFailure('profile', 'submit', $params,
       'This activity cannot be edited or viewed via this profile.');
   }
 
@@ -616,7 +597,7 @@ class api_v3_ProfileTest extends CiviUnitTestCase {
    * Check contact activity profile with success.
    */
   public function testContactActivitySubmitSuccess() {
-    list($params, $expected) = $this->_createContactWithActivity();
+    list($params) = $this->_createContactWithActivity();
 
     $updateParams = array(
       'first_name' => 'abc2',
@@ -625,7 +606,7 @@ class api_v3_ProfileTest extends CiviUnitTestCase {
       'activity_subject' => 'Test Meeting',
       'activity_details' => 'a test activity details',
       'activity_duration' => '100',
-      'activity_date_time' => '03/08/2010',
+      'activity_date_time' => '2010-03-08 00:00:00',
       'activity_status_id' => '2',
     );
     $profileParams = array_merge($params, $updateParams);
@@ -633,7 +614,7 @@ class api_v3_ProfileTest extends CiviUnitTestCase {
     $result = $this->callAPISuccess('profile', 'get', $params);
 
     foreach ($updateParams as $profileField => $value) {
-      $this->assertEquals($value, CRM_Utils_Array::value($profileField, $result['values']), "In line " . __LINE__ . " error message: " . "missing/mismatching value for {$profileField}"
+      $this->assertEquals($value, CRM_Utils_Array::value($profileField, $result['values']), " error message: " . "missing/mismatching value for {$profileField}"
       );
     }
   }
@@ -645,7 +626,7 @@ class api_v3_ProfileTest extends CiviUnitTestCase {
     $params = array(
       'contact_id' => 1,
     );
-    $result = $this->callAPIFailure('profile', 'apply', $params,
+    $this->callAPIFailure('profile', 'apply', $params,
       'Mandatory key(s) missing from params array: profile_id');
   }
 
@@ -657,16 +638,16 @@ class api_v3_ProfileTest extends CiviUnitTestCase {
       'contact_id' => 1,
       'profile_id' => 1000,
     );
-    $result = $this->callAPIFailure('profile', 'apply', $params);
+    $this->callAPIFailure('profile', 'apply', $params);
   }
 
   /**
    * Check with success.
    */
   public function testProfileApply() {
-    $pofileFieldValues = $this->_createIndividualContact();
-    current($pofileFieldValues);
-    $contactId = key($pofileFieldValues);
+    $profileFieldValues = $this->_createIndividualContact();
+    current($profileFieldValues);
+    $contactId = key($profileFieldValues);
 
     $params = array(
       'profile_id' => $this->_profileID,
@@ -810,7 +791,7 @@ class api_v3_ProfileTest extends CiviUnitTestCase {
     $keys = array_keys($contact['values']);
     $contactId = array_pop($keys);
 
-    $this->assertEquals(0, $contact['values'][$contactId]['api.address.create']['is_error'], "In line " . __LINE__ . " error message: " . CRM_Utils_Array::value('error_message', $contact['values'][$contactId]['api.address.create'])
+    $this->assertEquals(0, $contact['values'][$contactId]['api.address.create']['is_error'], " error message: " . CRM_Utils_Array::value('error_message', $contact['values'][$contactId]['api.address.create'])
     );
 
     $activityParams = array(
@@ -818,7 +799,7 @@ class api_v3_ProfileTest extends CiviUnitTestCase {
       'assignee_contact_id' => $contactId,
       'activity_type_id' => '1',
       'subject' => 'Make-it-Happen Meeting',
-      'activity_date_time' => '20110316',
+      'activity_date_time' => '2011-03-16 00:00:00',
       'duration' => '120',
       'location' => 'Pensulvania',
       'details' => 'a test activity',
@@ -844,8 +825,7 @@ class api_v3_ProfileTest extends CiviUnitTestCase {
       'activity_subject' => 'Make-it-Happen Meeting',
       'activity_details' => 'a test activity',
       'activity_duration' => '120',
-      'activity_date_time_time' => '12:00AM',
-      'activity_date_time' => '03/16/2011',
+      'activity_date_time' => '2011-03-16 00:00:00',
       'activity_status_id' => '1',
     );
 
@@ -856,12 +836,9 @@ class api_v3_ProfileTest extends CiviUnitTestCase {
    * Create a profile.
    */
   public function _createIndividualProfile() {
-
-    // creating these via the api as we want to utilise & test the flushing of caches when fields created
-    // via the api
-
     $ufGroupParams = array(
-      'group_type' => 'Individual,Contact', // really we should remove this & test the ufField create sets it
+      'group_type' => 'Individual,Contact',
+      // really we should remove this & test the ufField create sets it
       'name' => 'test_individual_contact_profile',
       'title' => 'Flat Coffee',
       'api.uf_field.create' => array(
index 34904b5ab6cbfa29fd1a9fffd2559b8c618f2a74..3b636b1523a51a33af81d43aa031ce48fff834c0 100644 (file)
@@ -235,6 +235,30 @@ class api_v3_ReportTemplateTest extends CiviUnitTestCase {
     $this->assertEquals(1, $rows['count'], "Report failed - the sql used to generate the results was " . print_r($rows['metadata']['sql'], TRUE));
   }
 
+  /**
+   * Test Lybunt report applies ACLs.
+   */
+  public function testLybuntReportWithDataAndACLFilter() {
+    CRM_Core_Config::singleton()->userPermissionClass->permissions = array('administer CiviCRM');
+    $inInd = $this->individualCreate();
+    $outInd = $this->individualCreate();
+    $this->contributionCreate(array('contact_id' => $inInd, 'receive_date' => '2014-03-01'));
+    $this->contributionCreate(array('contact_id' => $outInd, 'receive_date' => '2015-03-01', 'trxn_id' => NULL, 'invoice_id' => NULL));
+    $this->hookClass->setHook('civicrm_aclWhereClause', array($this, 'aclWhereHookNoResults'));
+    $params = array(
+      'report_id' => 'contribute/lybunt',
+      'yid_value' => 2015,
+      'yid_op' => 'calendar',
+      'options' => array('metadata' => array('sql')),
+      'check_permissions' => 1,
+    );
+
+    $rows = $this->callAPISuccess('report_template', 'getrows', $params);
+    $this->assertEquals(0, $rows['count'], "Report failed - the sql used to generate the results was " . print_r($rows['metadata']['sql'], TRUE));
+
+    CRM_Utils_Hook::singleton()->reset();
+  }
+
   /**
    * Test Lybunt report to check basic inclusion of a contact who gave in the year before the chosen year.
    */
@@ -532,4 +556,62 @@ class api_v3_ReportTemplateTest extends CiviUnitTestCase {
     return array($groupID, $groupID2);
   }
 
+  /**
+   * Test Deferred Revenue Report.
+   */
+  public function testDeferredRevenueReport() {
+    $indv1 = $this->individualCreate();
+    $indv2 = $this->individualCreate();
+    $params = array(
+      'contribution_invoice_settings' => array(
+        'deferred_revenue_enabled' => '1',
+      ),
+    );
+    $this->callAPISuccess('Setting', 'create', $params);
+    $this->contributionCreate(
+      array(
+        'contact_id' => $indv1,
+        'receive_date' => '2016-10-01',
+        'revenue_recognition_date' => date('Y-m-t', strtotime(date('ymd') . '+3 month')),
+        'financial_type_id' => 2,
+      )
+    );
+    $this->contributionCreate(
+      array(
+        'contact_id' => $indv1,
+        'revenue_recognition_date' => date('Y-m-t', strtotime(date('ymd') . '+22 month')),
+        'financial_type_id' => 4,
+        'trxn_id' => NULL,
+        'invoice_id' => NULL,
+      )
+    );
+    $this->contributionCreate(
+      array(
+        'contact_id' => $indv2,
+        'revenue_recognition_date' => date('Y-m-t', strtotime(date('ymd') . '+1 month')),
+        'financial_type_id' => 4,
+        'trxn_id' => NULL,
+        'invoice_id' => NULL,
+      )
+    );
+    $this->contributionCreate(
+      array(
+        'contact_id' => $indv2,
+        'receive_date' => '2016-03-01',
+        'revenue_recognition_date' => date('Y-m-t', strtotime(date('ymd') . '+4 month')),
+        'financial_type_id' => 2,
+        'trxn_id' => NULL,
+        'invoice_id' => NULL,
+      )
+    );
+    $rows = $this->callAPISuccess('report_template', 'getrows', array(
+      'report_id' => 'contribute/deferredrevenue',
+    ));
+    $this->assertEquals(2, $rows['count'], "Report failed to get row count");
+    $count = array(2, 1);
+    foreach ($rows['values'] as $row) {
+      $this->assertEquals(array_pop($count), count($row['rows']), "Report failed to get row count");
+    }
+  }
+
 }
index 96aee8d35f0de8877eb67b41a42018f9e308ccef..91b784f5277e011b96b883f335161cf4ec30d56a 100644 (file)
@@ -241,7 +241,7 @@ class api_v3_TaxContributionPageTest extends CiviUnitTestCase {
       'contribution_status_id' => 1,
     );
 
-    $contribution = $this->callAPIAndDocument('contribution', 'create', $params, __FUNCTION__, __FILE__);
+    $contribution = $this->callAPISuccess('contribution', 'create', $params);
     $this->_ids['contributionId'] = $contribution['id'];
     $this->assertEquals($contribution['values'][$contribution['id']]['contact_id'], $this->_individualId);
     $this->assertEquals($contribution['values'][$contribution['id']]['total_amount'], 120.00);
@@ -284,9 +284,7 @@ class api_v3_TaxContributionPageTest extends CiviUnitTestCase {
       ),
     );
 
-    $description = "Create Contribution with Nested Line Items.";
-    $subfile = "CreateWithNestedLineItems";
-    $contribution = $this->callAPIAndDocument('contribution', 'create', $params, __FUNCTION__, __FILE__, $description, $subfile);
+    $contribution = $this->callAPISuccess('contribution', 'create', $params);
 
     $lineItems = $this->callAPISuccess('line_item', 'get', array(
       'entity_id' => $contribution['id'],
@@ -311,7 +309,7 @@ class api_v3_TaxContributionPageTest extends CiviUnitTestCase {
       'source' => 'SSF',
       'contribution_status_id' => 2,
     );
-    $contribution = $this->callAPIAndDocument('contribution', 'create', $params, __FUNCTION__, __FILE__);
+    $contribution = $this->callAPISuccess('contribution', 'create', $params, __FUNCTION__, __FILE__);
     $this->assertEquals($contribution['values'][$contribution['id']]['contact_id'], $this->_individualId);
     $this->assertEquals($contribution['values'][$contribution['id']]['total_amount'], 120.00);
     $this->assertEquals($contribution['values'][$contribution['id']]['financial_type_id'], $this->financialtypeID);
@@ -337,7 +335,7 @@ class api_v3_TaxContributionPageTest extends CiviUnitTestCase {
       'contribution_status_id' => 2,
     );
 
-    $contribution = $this->callAPIAndDocument('contribution', 'create', $params, __FUNCTION__, __FILE__);
+    $contribution = $this->callAPISuccess('contribution', 'create', $params, __FUNCTION__, __FILE__);
     $this->assertEquals($contribution['values'][$contribution['id']]['contact_id'], $this->_individualId);
     $this->assertEquals($contribution['values'][$contribution['id']]['total_amount'], 120.00);
     $this->assertEquals($contribution['values'][$contribution['id']]['financial_type_id'], $this->financialtypeID);
index b48e426ac192603e242b39b1ff391ce5929cf42a..e68e43f5265f7e158aedd4773e9a68c447ac78b0 100644 (file)
@@ -128,6 +128,42 @@ class api_v3_UFMatchTest extends CiviUnitTestCase {
     $this->getAndCheck($this->_params, $result['id'], 'uf_match');
   }
 
+  /**
+   * Test Civi to CMS email sync optional
+   */
+  public function testUFNameMatchSync() {
+    $this->callAPISuccess('uf_match', 'create', $this->_params);
+    $email1 = substr(sha1(rand()), 0, 7) . '@test.com';
+    $email2 = substr(sha1(rand()), 0, 7) . '@test.com';
+
+    // Case A: Enable CMS integration
+    Civi::settings()->set('syncCMSEmail', TRUE);
+    $this->callAPISuccess('email', 'create', array(
+      'contact_id' => $this->_contactId,
+      'email' => $email1,
+      'is_primary' => 1,
+    ));
+    $ufName = $this->callAPISuccess('uf_match', 'getvalue', array(
+      'contact_id' => $this->_contactId,
+      'return' => 'uf_name',
+    ));
+    $this->assertEquals($email1, $ufName);
+
+    // Case B: Disable CMS integration
+    Civi::settings()->set('syncCMSEmail', FALSE);
+    $this->callAPISuccess('email', 'create', array(
+      'contact_id' => $this->_contactId,
+      'email' => $email2,
+      'is_primary' => 1,
+    ));
+    $ufName = $this->callAPISuccess('uf_match', 'getvalue', array(
+      'contact_id' => $this->_contactId,
+      'return' => 'uf_name',
+    ));
+    $this->assertNotEquals($email2, $ufName, 'primary email will not match if changed on disabled CMS integration setting');
+    $this->assertEquals($email1, $ufName);
+  }
+
   public function testDelete() {
     $result = $this->callAPISuccess('uf_match', 'create', $this->_params);
     $this->assertEquals(1, $this->callAPISuccess('uf_match', 'getcount', array(
index 4635a49b718b104994f8f573f8c53bb4feafe5a2..307dbd72ff5b83d44178200bac9fd929c5756f58 100644 (file)
@@ -69,12 +69,14 @@ function civicrm_webtest_enable() {
    'edit all events',
    'edit contributions',
    'edit event participants',
+   'edit message templates',
    // 'edit grants',
    'edit groups',
    'edit memberships',
    'edit pledges',
    'import contacts',
    'make online contributions',
+   'manage tags',
    'merge duplicate contacts',
    'profile create',
    'profile edit',
index 70650731002d18ee5a43354af362235b1db4d5c0..b47eb8900b427005f635748bf25d110493496f41 100644 (file)
     <comment>Date and time this activity is scheduled to occur. Formerly named scheduled_date_time.</comment>
     <html>
       <type>Select Date</type>
-      <format>activityDateTime</format>
+      <formatType>activityDateTime</formatType>
     </html>
     <add>2.0</add>
   </field>
index 716c82edf360297a3aff8a3f531cc6bb55c31d51..6343cccc7e806e1f9afd7855e855af306933091b 100644 (file)
     <add>1.1</add>
     <html>
       <type>Select Date</type>
-      <format>birth</format>
+      <formatType>birth</formatType>
     </html>
   </field>
   <field>
     <add>1.5</add>
     <html>
       <type>Select Date</type>
-      <format>birth</format>
+      <formatType>birth</formatType>
     </html>
   </field>
   <field>
index 8c312e6bc2a7bb09fb36a2d486c98dda410d63c1..ad9260293beb107ad0103c49201bbe4485a1ef0e 100644 (file)
   <field>
     <name>payment_instrument_id</name>
     <uniqueName>payment_instrument_id</uniqueName>
-    <title>Payment Method</title>
+    <title>Payment Method ID</title>
     <type>int unsigned</type>
     <comment>FK to Payment Instrument</comment>
+    <export>true</export>
+    <headerPattern>/^payment|(p(ayment\s)?instrument)$/i</headerPattern>
     <pseudoconstant>
       <optionGroupName>payment_instrument</optionGroupName>
     </pseudoconstant>
     <add>1.3</add>
     <html>
      <type>Select Date</type>
-     <format>activityDateTime</format>
+     <formatType>activityDateTime</formatType>
    </html>
   </field>
   <field>
     <add>1.3</add>
     <html>
       <type>Select Date</type>
-      <format>activityDateTime</format>
+      <formatType>activityDateTime</formatType>
     </html>
   </field>
   <field>
     <comment>when (if) receipt was sent. populated automatically for online donations w/ automatic receipting</comment>
     <html>
       <type>Select Date</type>
-      <format>activityDateTime</format>
+      <formatType>activityDateTime</formatType>
     </html>
     <add>1.3</add>
   </field>
     <add>1.3</add>
     <html>
       <type>Select Date</type>
-      <format>activityDateTime</format>
+      <formatType>activityDateTime</formatType>
     </html>
   </field>
   <field>
     <comment>Stores the date when revenue should be recognized.</comment>
     <html>
       <type>Select Date</type>
-        <format>activityDateTime</format>
+        <formatType>activityDateTime</formatType>
     </html>
     <add>4.7</add>
   </field>
index ca92ae4542612cb7e5cf78394be5e940ebdce5f9..b35eb253b89d419bd77fccb0f856c864b6897759 100644 (file)
     <add>1.7</add>
     <html>
       <type>Select Date</type>
-      <format>activityDateTime</format>
+      <formatType>activityDateTime</formatType>
     </html>
   </field>
   <field>
index eb4dba07df5c4e34a0ed2d9db6ec3539f93561d9..e6f31fd132284a830081073691441d62c6e1535d 100644 (file)
     <fieldName>payment_instrument_id</fieldName>
     <add>4.3</add>
   </index>
+  <field>
+    <name>card_type</name>
+    <uniqueName>financial_trxn_card_type</uniqueName>
+    <title>Card Type</title>
+    <type>int unsigned</type>
+    <comment>FK to accept_creditcard option group values</comment>
+    <pseudoconstant>
+      <optionGroupName>accept_creditcard</optionGroupName>
+    </pseudoconstant>
+    <html>
+      <type>Select</type>
+    </html>
+    <add>4.7</add>
+  </field>
   <field>
     <name>check_number</name>
     <uniqueName>financial_trxn_check_number</uniqueName>
     <fieldName>check_number</fieldName>
     <add>4.3</add>
   </index>
+  <field>
+    <name>pan_truncation</name>
+    <uniqueName>financial_trxn_pan_truncation</uniqueName>
+    <title>Pan Truncation</title>
+    <type>int unsigned</type>
+    <html>
+      <type>Text</type>
+      <size>4</size>
+    </html>
+    <comment>Last 4 digits of credit card</comment>
+    <add>4.7</add>
+  </field>
 </table>
index ad00f4dc14ded962d1c31a67559b28cc61fc239a..7a51751bd71035dc87c76b16558d932cf72a8e7b 100644 (file)
@@ -82,7 +82,7 @@
     <add>1.5</add>
     <html>
       <type>Select Date</type>
-      <format>activityDate</format>
+      <formatType>activityDate</formatType>
     </html>
   </field>
   <field>
@@ -97,7 +97,7 @@
     <add>1.5</add>
     <html>
       <type>Select Date</type>
-      <format>activityDate</format>
+      <formatType>activityDate</formatType>
     </html>
   </field>
   <field>
     <add>1.5</add>
     <html>
       <type>Select Date</type>
-      <format>activityDate</format>
+      <formatType>activityDate</formatType>
     </html>
   </field>
   <field>
index 706442608cbfbf2847bf38b3962bd3e011b0afca..5f5ed762c2973a3d5d4c3a9fc8479161bc28c48e 100644 (file)
@@ -72,7 +72,7 @@ INSERT INTO civicrm_country (id, name,iso_code,region_id,is_province_abbreviated
 INSERT INTO civicrm_country (id, name,iso_code,region_id,is_province_abbreviated) VALUES("1028", "Bouvet Island", "BV", "1", "0");
 INSERT INTO civicrm_country (id, name,iso_code,region_id,is_province_abbreviated) VALUES("1029", "Brazil", "BR", "2", "0");
 INSERT INTO civicrm_country (id, name,iso_code,region_id,is_province_abbreviated) VALUES("1030", "British Indian Ocean Territory", "IO", "4", "0");
-INSERT INTO civicrm_country (id, name,iso_code,region_id,is_province_abbreviated) VALUES("1031", "Virgin Islands,British", "VG", "2", "0");
+INSERT INTO civicrm_country (id, name,iso_code,region_id,is_province_abbreviated) VALUES("1031", "Virgin Islands, British", "VG", "2", "0");
 INSERT INTO civicrm_country (id, name,iso_code,region_id,is_province_abbreviated) VALUES("1032", "Brunei Darussalam", "BN", "4", "0");
 INSERT INTO civicrm_country (id, name,iso_code,region_id,is_province_abbreviated) VALUES("1033", "Bulgaria", "BG", "1", "0");
 INSERT INTO civicrm_country (id, name,iso_code,region_id,is_province_abbreviated) VALUES("1034", "Burkina Faso", "BF", "5", "0");
@@ -205,7 +205,7 @@ INSERT INTO civicrm_country (id, name,iso_code,region_id,is_province_abbreviated
 INSERT INTO civicrm_country (id, name,iso_code,region_id,is_province_abbreviated) VALUES("1162", "Oman", "OM", "3", "0");
 INSERT INTO civicrm_country (id, name,iso_code,region_id,is_province_abbreviated) VALUES("1163", "Pakistan", "PK", "4", "0");
 INSERT INTO civicrm_country (id, name,iso_code,region_id,is_province_abbreviated) VALUES("1164", "Palau", "PW", "4", "0");
-INSERT INTO civicrm_country (id, name,iso_code,region_id,is_province_abbreviated) VALUES("1165", "Palestinian Territory", "PS", "3", "0");
+INSERT INTO civicrm_country (id, name,iso_code,region_id,is_province_abbreviated) VALUES("1165", "Palestine, State of", "PS", "3", "0");
 INSERT INTO civicrm_country (id, name,iso_code,region_id,is_province_abbreviated) VALUES("1166", "Panama", "PA", "2", "0");
 INSERT INTO civicrm_country (id, name,iso_code,region_id,is_province_abbreviated) VALUES("1167", "Papua New Guinea", "PG", "4", "0");
 INSERT INTO civicrm_country (id, name,iso_code,region_id,is_province_abbreviated) VALUES("1168", "Paraguay", "PY", "2", "0");
index bb59d618bbcea4ca31709abf5dc6b86331026677..fa453dc46933b37cfefac8bff34f971513c2c3b7 100644 (file)
@@ -126,7 +126,7 @@ INSERT INTO civicrm_state_province (id, country_id, abbreviation, name) VALUES
 (1222, 1101, "SK", "Sikkim"),
 (1223, 1101, "TN", "Tamil Nadu"),
 (1224, 1101, "TR", "Tripura"),
-(1225, 1101, "UL", "Uttaranchal"),
+(1225, 1101, "UT", "Uttarakhand"),
 (1226, 1101, "UP", "Uttar Pradesh"),
 (1227, 1101, "WB", "West Bengal"),
 (1228, 1101, "AN", "Andaman and Nicobar Islands"),
@@ -1829,11 +1829,9 @@ INSERT INTO civicrm_state_province (id, country_id, abbreviation, name) VALUES
 (3345, 1110, "JA", "Jarash"),
 (3346, 1110, "MN", "Ma\'an"),
 (3347, 1110, "MD", "Madaba"),
-(3348, 1112, "110", "Nairobi Municipality"),
-(3349, 1112, "300", "Coast"),
-(3350, 1112, "500", "North-Eastern Kaskazini Mashariki"),
-(3351, 1112, "700", "Rift Valley"),
-(3352, 1112, "900", "Western Magharibi"),
+
+-- CRM-20062 Outdated provinces for Kenya removed .
+
 (3353, 1117, "GB", "Bishkek"),
 (3354, 1117, "B", "Batken"),
 (3355, 1117, "C", "Chu"),
@@ -3312,7 +3310,7 @@ INSERT INTO civicrm_state_province (id, country_id, abbreviation, name) VALUES
 (4860, 1208, "TPQ", "Taipei County"),
 (4861, 1208, "TTT", "Taitung County"),
 (4862, 1208, "TAO", "Taoyuan County"),
-(4863, 1208, "YUN", "Yunlin Conuty"),
+(4863, 1208, "YUN", "Yunlin County"),
 (4864, 1208, "KEE", "Keelung City"),
 (4865, 1210, "01", "Arusha"),
 (4866, 1210, "02", "Dar-es-Salaam"),
@@ -4001,7 +3999,7 @@ INSERT INTO civicrm_state_province (id, country_id, abbreviation, name) VALUES
 (NULL, 1066, "LI", "La Libertad"),
 (NULL, 1066, "PA", "La Paz"),
 (NULL, 1066, "UN", "La Union"),
+
 -- CRM-17660 Add missing Cameroon Provinces
 (NULL, 1038, "LT", "Littoral"),
 (NULL, 1038, "NW", "Nord-Ouest"),
@@ -4017,4 +4015,66 @@ INSERT INTO civicrm_state_province (id, country_id, abbreviation, name) VALUES
 (NULL, 1076, "MQ", "Martinique"),
 (NULL, 1076, "GF", "Guyane"),
 (NULL, 1076, "RE", "La Réunion"),
-(NULL, 1076, "YT", "Mayotte");
+(NULL, 1076, "YT", "Mayotte"),
+
+-- CRM-20062 New counties of Kenya.
+(NULL, 1112, "01", "Baringo"),
+(NULL, 1112, "02", "Bomet"),
+(NULL, 1112, "03", "Bungoma"),
+(NULL, 1112, "04", "Busia"),
+(NULL, 1112, "05", "Elgeyo/Marakwet"),
+(NULL, 1112, "06", "Embu"),
+(NULL, 1112, "07", "Garissa"),
+(NULL, 1112, "08", "Homa Bay"),
+(NULL, 1112, "09", "Isiolo"),
+(NULL, 1112, "10", "Kajiado"),
+(NULL, 1112, "11", "Kakamega"),
+(NULL, 1112, "12", "Kericho"),
+(NULL, 1112, "13", "Kiambu"),
+(NULL, 1112, "14", "Kilifi"),
+(NULL, 1112, "15", "Kirinyaga"),
+(NULL, 1112, "16", "Kisii"),
+(NULL, 1112, "17", "Kisumu"),
+(NULL, 1112, "18", "Kitui"),
+(NULL, 1112, "19", "Kwale"),
+(NULL, 1112, "20", "Laikipia"),
+(NULL, 1112, "21", "Lamu"),
+(NULL, 1112, "22", "Machakos"),
+(NULL, 1112, "23", "Makueni"),
+(NULL, 1112, "24", "Mandera"),
+(NULL, 1112, "25", "Marsabit"),
+(NULL, 1112, "26", "Meru"),
+(NULL, 1112, "27", "Migori"),
+(NULL, 1112, "28", "Mombasa"),
+(NULL, 1112, "29", "Murang'a"),
+(NULL, 1112, "30", "Nairobi City"),
+(NULL, 1112, "31", "Nakuru"),
+(NULL, 1112, "32", "Nandi"),
+(NULL, 1112, "33", "Narok"),
+(NULL, 1112, "34", "Nyamira"),
+(NULL, 1112, "35", "Nyandarua"),
+(NULL, 1112, "36", "Nyeri"),
+(NULL, 1112, "37", "Samburu"),
+(NULL, 1112, "38", "Siaya"),
+(NULL, 1112, "39", "Taita/Taveta"),
+(NULL, 1112, "40", "Tana River"),
+(NULL, 1112, "41", "Tharaka-Nithi"),
+(NULL, 1112, "42", "Trans Nzoia"),
+(NULL, 1112, "43", "Turkana"),
+(NULL, 1112, "44", "Uasin Gishu"),
+(NULL, 1112, "45", "Vihiga"),
+(NULL, 1112, "46", "Wajir"),
+(NULL, 1112, "47", "West Pokot"),
+
+-- CRM-19993 Fixes for ISO compliance with countries and counties
+-- Add states for: India, Ghana, Sierra Leone, Saint Kitts & Nevis
+(NULL, 1101, "CH", "Chandigarh"),
+(NULL, 1083, "CP", "Central"),
+(NULL, 1083, "EP", "Eastern"),
+(NULL, 1083, "NP", "Northern"),
+(NULL, 1083, "WP", "Western"),
+(NULL, 1181, "K", "Saint Kitts"),
+(NULL, 1181, "N", "Nevis"),
+(NULL, 1190, "E", "Eastern"),
+(NULL, 1190, "N", "Northern"),
+(NULL, 1190, "S", "Southern");