diff --git a/civicrm.php b/civicrm.php
index 93942cb70709788c403508e7b83e9e6e5b664787..8bc4567a4f9cdaba7242c2bf9d18d4928af5e7ea 100644
--- a/civicrm.php
+++ b/civicrm.php
@@ -2,7 +2,7 @@
 /*
 Plugin Name: CiviCRM
 Description: CiviCRM - Growing and Sustaining Relationships
-Version: 5.13.5
+Version: 5.14.0
 Author: CiviCRM LLC
 Author URI: https://civicrm.org/
 Plugin URI: https://wiki.civicrm.org/confluence/display/CRMDOC/Installing+CiviCRM+for+WordPress
diff --git a/civicrm/CRM/ACL/DAO/ACL.php b/civicrm/CRM/ACL/DAO/ACL.php
index 51791fb5f5afe8c263158d4495adc233a46c9a11..2cba8eaaf3cd7fa2320c0f2df4527a28c2da073f 100644
--- a/civicrm/CRM/ACL/DAO/ACL.php
+++ b/civicrm/CRM/ACL/DAO/ACL.php
@@ -142,6 +142,7 @@ class CRM_ACL_DAO_ACL extends CRM_Core_DAO {
           'title' => ts('ACL ID'),
           'description' => ts('Unique table ID'),
           'required' => TRUE,
+          'where' => 'civicrm_acl.id',
           'table_name' => 'civicrm_acl',
           'entity' => 'ACL',
           'bao' => 'CRM_ACL_BAO_ACL',
@@ -154,6 +155,7 @@ class CRM_ACL_DAO_ACL extends CRM_Core_DAO {
           'description' => ts('ACL Name.'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_acl.name',
           'table_name' => 'civicrm_acl',
           'entity' => 'ACL',
           'bao' => 'CRM_ACL_BAO_ACL',
@@ -168,6 +170,7 @@ class CRM_ACL_DAO_ACL extends CRM_Core_DAO {
           'title' => ts('Deny ACL?'),
           'description' => ts('Is this ACL entry Allow  (0) or Deny (1) ?'),
           'required' => TRUE,
+          'where' => 'civicrm_acl.deny',
           'default' => '0',
           'table_name' => 'civicrm_acl',
           'entity' => 'ACL',
@@ -185,6 +188,7 @@ class CRM_ACL_DAO_ACL extends CRM_Core_DAO {
           'required' => TRUE,
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_acl.entity_table',
           'table_name' => 'civicrm_acl',
           'entity' => 'ACL',
           'bao' => 'CRM_ACL_BAO_ACL',
@@ -195,6 +199,7 @@ class CRM_ACL_DAO_ACL extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Entity ID'),
           'description' => ts('ID of the object possessing this ACL'),
+          'where' => 'civicrm_acl.entity_id',
           'table_name' => 'civicrm_acl',
           'entity' => 'ACL',
           'bao' => 'CRM_ACL_BAO_ACL',
@@ -208,6 +213,7 @@ class CRM_ACL_DAO_ACL extends CRM_Core_DAO {
           'required' => TRUE,
           'maxlength' => 8,
           'size' => CRM_Utils_Type::EIGHT,
+          'where' => 'civicrm_acl.operation',
           'table_name' => 'civicrm_acl',
           'entity' => 'ACL',
           'bao' => 'CRM_ACL_BAO_ACL',
@@ -226,6 +232,7 @@ class CRM_ACL_DAO_ACL extends CRM_Core_DAO {
           'description' => ts('The table of the object controlled by this ACL entry'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_acl.object_table',
           'table_name' => 'civicrm_acl',
           'entity' => 'ACL',
           'bao' => 'CRM_ACL_BAO_ACL',
@@ -236,6 +243,7 @@ class CRM_ACL_DAO_ACL extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('ACL Object ID'),
           'description' => ts('The ID of the object controlled by this ACL entry'),
+          'where' => 'civicrm_acl.object_id',
           'table_name' => 'civicrm_acl',
           'entity' => 'ACL',
           'bao' => 'CRM_ACL_BAO_ACL',
@@ -248,6 +256,7 @@ class CRM_ACL_DAO_ACL extends CRM_Core_DAO {
           'description' => ts('If this is a grant/revoke entry, what table are we granting?'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_acl.acl_table',
           'table_name' => 'civicrm_acl',
           'entity' => 'ACL',
           'bao' => 'CRM_ACL_BAO_ACL',
@@ -258,6 +267,7 @@ class CRM_ACL_DAO_ACL extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('ACL Group ID'),
           'description' => ts('ID of the ACL or ACL group being granted/revoked'),
+          'where' => 'civicrm_acl.acl_id',
           'table_name' => 'civicrm_acl',
           'entity' => 'ACL',
           'bao' => 'CRM_ACL_BAO_ACL',
@@ -268,6 +278,7 @@ class CRM_ACL_DAO_ACL extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('ACL Is Active?'),
           'description' => ts('Is this property active?'),
+          'where' => 'civicrm_acl.is_active',
           'table_name' => 'civicrm_acl',
           'entity' => 'ACL',
           'bao' => 'CRM_ACL_BAO_ACL',
diff --git a/civicrm/CRM/ACL/DAO/Cache.php b/civicrm/CRM/ACL/DAO/Cache.php
index cd74fd01bba42093cb14aaa8250d7a714fc2b013..c59ff67e57094ce65dbbd500684e5ef28a4bfe62 100644
--- a/civicrm/CRM/ACL/DAO/Cache.php
+++ b/civicrm/CRM/ACL/DAO/Cache.php
@@ -94,6 +94,7 @@ class CRM_ACL_DAO_Cache extends CRM_Core_DAO {
           'title' => ts('Cache ID'),
           'description' => ts('Unique table ID'),
           'required' => TRUE,
+          'where' => 'civicrm_acl_cache.id',
           'table_name' => 'civicrm_acl_cache',
           'entity' => 'Cache',
           'bao' => 'CRM_ACL_BAO_Cache',
@@ -104,6 +105,7 @@ class CRM_ACL_DAO_Cache extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Cache Contact'),
           'description' => ts('Foreign Key to Contact'),
+          'where' => 'civicrm_acl_cache.contact_id',
           'table_name' => 'civicrm_acl_cache',
           'entity' => 'Cache',
           'bao' => 'CRM_ACL_BAO_Cache',
@@ -116,6 +118,7 @@ class CRM_ACL_DAO_Cache extends CRM_Core_DAO {
           'title' => ts('Cache ACL'),
           'description' => ts('Foreign Key to ACL'),
           'required' => TRUE,
+          'where' => 'civicrm_acl_cache.acl_id',
           'table_name' => 'civicrm_acl_cache',
           'entity' => 'Cache',
           'bao' => 'CRM_ACL_BAO_Cache',
@@ -128,6 +131,7 @@ class CRM_ACL_DAO_Cache extends CRM_Core_DAO {
           'title' => ts('Cache Modified Date'),
           'description' => ts('When was this cache entry last modified'),
           'required' => FALSE,
+          'where' => 'civicrm_acl_cache.modified_date',
           'table_name' => 'civicrm_acl_cache',
           'entity' => 'Cache',
           'bao' => 'CRM_ACL_BAO_Cache',
diff --git a/civicrm/CRM/ACL/DAO/EntityRole.php b/civicrm/CRM/ACL/DAO/EntityRole.php
index bb0fda29f27a74420c4566109052cac9abdf7c62..93956fc8b9d876b2d3c6e16f0d03e4fb852f100c 100644
--- a/civicrm/CRM/ACL/DAO/EntityRole.php
+++ b/civicrm/CRM/ACL/DAO/EntityRole.php
@@ -100,6 +100,7 @@ class CRM_ACL_DAO_EntityRole extends CRM_Core_DAO {
           'title' => ts('Entity Role'),
           'description' => ts('Unique table ID'),
           'required' => TRUE,
+          'where' => 'civicrm_acl_entity_role.id',
           'table_name' => 'civicrm_acl_entity_role',
           'entity' => 'EntityRole',
           'bao' => 'CRM_ACL_BAO_EntityRole',
@@ -111,6 +112,7 @@ class CRM_ACL_DAO_EntityRole extends CRM_Core_DAO {
           'title' => ts('ACL Role ID'),
           'description' => ts('Foreign Key to ACL Role (which is an option value pair and hence an implicit FK)'),
           'required' => TRUE,
+          'where' => 'civicrm_acl_entity_role.acl_role_id',
           'table_name' => 'civicrm_acl_entity_role',
           'entity' => 'EntityRole',
           'bao' => 'CRM_ACL_BAO_EntityRole',
@@ -124,6 +126,7 @@ class CRM_ACL_DAO_EntityRole extends CRM_Core_DAO {
           'required' => TRUE,
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_acl_entity_role.entity_table',
           'table_name' => 'civicrm_acl_entity_role',
           'entity' => 'EntityRole',
           'bao' => 'CRM_ACL_BAO_EntityRole',
@@ -135,6 +138,7 @@ class CRM_ACL_DAO_EntityRole extends CRM_Core_DAO {
           'title' => ts('ACL Entity ID'),
           'description' => ts('ID of the group/contact object being joined'),
           'required' => TRUE,
+          'where' => 'civicrm_acl_entity_role.entity_id',
           'table_name' => 'civicrm_acl_entity_role',
           'entity' => 'EntityRole',
           'bao' => 'CRM_ACL_BAO_EntityRole',
@@ -145,6 +149,7 @@ class CRM_ACL_DAO_EntityRole extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('ACL Entity Role is Active'),
           'description' => ts('Is this property active?'),
+          'where' => 'civicrm_acl_entity_role.is_active',
           'table_name' => 'civicrm_acl_entity_role',
           'entity' => 'EntityRole',
           'bao' => 'CRM_ACL_BAO_EntityRole',
diff --git a/civicrm/CRM/ACL/Form/WordPress/Permissions.php b/civicrm/CRM/ACL/Form/WordPress/Permissions.php
index bad293c934c17f1d0567697ce7abc3b935b3501e..65191fb9793aed95be6ef1190364b5fd59b5a109 100644
--- a/civicrm/CRM/ACL/Form/WordPress/Permissions.php
+++ b/civicrm/CRM/ACL/Form/WordPress/Permissions.php
@@ -54,7 +54,7 @@ class CRM_ACL_Form_WordPress_Permissions extends CRM_Core_Form {
     }
     foreach ($wp_roles->role_names as $role => $name) {
       // Don't show the permissions options for administrator, as they have all permissions
-      if ( is_multisite() OR $role !== 'administrator') {
+      if ($role !== 'administrator') {
         $roleObj = $wp_roles->get_role($role);
         if (!empty($roleObj->capabilities)) {
           foreach ($roleObj->capabilities as $ckey => $cname) {
diff --git a/civicrm/CRM/Activity/BAO/Activity.php b/civicrm/CRM/Activity/BAO/Activity.php
index 3f1f37b6e318f0d30ff790c7fc8fcc85f4b09d62..56f12e5288fedc56aff4b034db6d47029e44dd54 100644
--- a/civicrm/CRM/Activity/BAO/Activity.php
+++ b/civicrm/CRM/Activity/BAO/Activity.php
@@ -2450,7 +2450,7 @@ INNER JOIN  civicrm_option_group grp ON (grp.id = option_group_id AND grp.name =
   }
 
   /**
-   * Checks if user has permissions to edit inbound e-mails, either bsic info
+   * Checks if user has permissions to edit inbound e-mails, either basic info
    * or both basic information and content.
    *
    * @return bool
diff --git a/civicrm/CRM/Activity/DAO/Activity.php b/civicrm/CRM/Activity/DAO/Activity.php
index b6434b2bf68b99e13c7d6d39cc55a3707e71416f..d81c1a82a875b6471d79fb0b774863b1c701f4a7 100644
--- a/civicrm/CRM/Activity/DAO/Activity.php
+++ b/civicrm/CRM/Activity/DAO/Activity.php
@@ -250,8 +250,6 @@ class CRM_Activity_DAO_Activity extends CRM_Core_DAO {
           'required' => TRUE,
           'import' => TRUE,
           'where' => 'civicrm_activity.id',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_activity',
           'entity' => 'Activity',
@@ -263,6 +261,7 @@ class CRM_Activity_DAO_Activity extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Source Record'),
           'description' => ts('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.'),
+          'where' => 'civicrm_activity.source_record_id',
           'table_name' => 'civicrm_activity',
           'entity' => 'Activity',
           'bao' => 'CRM_Activity_BAO_Activity',
@@ -277,7 +276,6 @@ class CRM_Activity_DAO_Activity extends CRM_Core_DAO {
           'import' => TRUE,
           'where' => 'civicrm_activity.activity_type_id',
           'headerPattern' => '/(activity.)?type(.id$)/i',
-          'dataPattern' => '',
           'export' => TRUE,
           'default' => '1',
           'table_name' => 'civicrm_activity',
@@ -302,7 +300,6 @@ class CRM_Activity_DAO_Activity extends CRM_Core_DAO {
           'import' => TRUE,
           'where' => 'civicrm_activity.subject',
           'headerPattern' => '/(activity.)?subject/i',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_activity',
           'entity' => 'Activity',
@@ -320,7 +317,6 @@ class CRM_Activity_DAO_Activity extends CRM_Core_DAO {
           'import' => TRUE,
           'where' => 'civicrm_activity.activity_date_time',
           'headerPattern' => '/(activity.)?date(.time$)?/i',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_activity',
           'entity' => 'Activity',
@@ -339,7 +335,6 @@ class CRM_Activity_DAO_Activity extends CRM_Core_DAO {
           'import' => TRUE,
           'where' => 'civicrm_activity.duration',
           'headerPattern' => '/(activity.)?duration(s)?$/i',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_activity',
           'entity' => 'Activity',
@@ -359,7 +354,6 @@ class CRM_Activity_DAO_Activity extends CRM_Core_DAO {
           'import' => TRUE,
           'where' => 'civicrm_activity.location',
           'headerPattern' => '/(activity.)?location$/i',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_activity',
           'entity' => 'Activity',
@@ -374,6 +368,7 @@ class CRM_Activity_DAO_Activity extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Phone (called) ID'),
           'description' => ts('Phone ID of the number called (optional - used if an existing phone number is selected).'),
+          'where' => 'civicrm_activity.phone_id',
           'table_name' => 'civicrm_activity',
           'entity' => 'Activity',
           'bao' => 'CRM_Activity_BAO_Activity',
@@ -390,6 +385,7 @@ class CRM_Activity_DAO_Activity extends CRM_Core_DAO {
           'description' => ts('Phone number in case the number does not exist in the civicrm_phone table.'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_activity.phone_number',
           'table_name' => 'civicrm_activity',
           'entity' => 'Activity',
           'bao' => 'CRM_Activity_BAO_Activity',
@@ -406,7 +402,6 @@ class CRM_Activity_DAO_Activity extends CRM_Core_DAO {
           'import' => TRUE,
           'where' => 'civicrm_activity.details',
           'headerPattern' => '/(activity.)?detail(s)?$/i',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_activity',
           'entity' => 'Activity',
@@ -424,7 +419,6 @@ class CRM_Activity_DAO_Activity extends CRM_Core_DAO {
           'import' => TRUE,
           'where' => 'civicrm_activity.status_id',
           'headerPattern' => '/(activity.)?status(.label$)?/i',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_activity',
           'entity' => 'Activity',
@@ -443,6 +437,7 @@ class CRM_Activity_DAO_Activity extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Priority'),
           'description' => ts('ID of the priority given to this activity. Foreign key to civicrm_option_value.'),
+          'where' => 'civicrm_activity.priority_id',
           'table_name' => 'civicrm_activity',
           'entity' => 'Activity',
           'bao' => 'CRM_Activity_BAO_Activity',
@@ -460,6 +455,7 @@ class CRM_Activity_DAO_Activity extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Parent Activity Id'),
           'description' => ts('Parent meeting ID (if this is a follow-up item). This is not currently implemented'),
+          'where' => 'civicrm_activity.parent_id',
           'table_name' => 'civicrm_activity',
           'entity' => 'Activity',
           'bao' => 'CRM_Activity_BAO_Activity',
@@ -473,7 +469,6 @@ class CRM_Activity_DAO_Activity extends CRM_Core_DAO {
           'import' => TRUE,
           'where' => 'civicrm_activity.is_test',
           'headerPattern' => '/(is.)?test(.activity)?/i',
-          'dataPattern' => '',
           'export' => TRUE,
           'default' => '0',
           'table_name' => 'civicrm_activity',
@@ -489,6 +484,7 @@ class CRM_Activity_DAO_Activity extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Activity Medium'),
           'description' => ts('Activity Medium, Implicit FK to civicrm_option_value where option_group = encounter_medium.'),
+          'where' => 'civicrm_activity.medium_id',
           'default' => 'NULL',
           'table_name' => 'civicrm_activity',
           'entity' => 'Activity',
@@ -506,6 +502,7 @@ class CRM_Activity_DAO_Activity extends CRM_Core_DAO {
           'name' => 'is_auto',
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Auto'),
+          'where' => 'civicrm_activity.is_auto',
           'default' => '0',
           'table_name' => 'civicrm_activity',
           'entity' => 'Activity',
@@ -517,6 +514,7 @@ class CRM_Activity_DAO_Activity extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Relationship Id'),
           'description' => ts('FK to Relationship ID'),
+          'where' => 'civicrm_activity.relationship_id',
           'default' => 'NULL',
           'table_name' => 'civicrm_activity',
           'entity' => 'Activity',
@@ -531,7 +529,6 @@ class CRM_Activity_DAO_Activity extends CRM_Core_DAO {
           'import' => TRUE,
           'where' => 'civicrm_activity.is_current_revision',
           'headerPattern' => '/(is.)?(current.)?(revision|version(ing)?)/i',
-          'dataPattern' => '',
           'export' => TRUE,
           'default' => '1',
           'table_name' => 'civicrm_activity',
@@ -547,6 +544,7 @@ class CRM_Activity_DAO_Activity extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Original Activity ID '),
           'description' => ts('Activity ID of the first activity record in versioning chain.'),
+          'where' => 'civicrm_activity.original_id',
           'table_name' => 'civicrm_activity',
           'entity' => 'Activity',
           'bao' => 'CRM_Activity_BAO_Activity',
@@ -560,6 +558,7 @@ class CRM_Activity_DAO_Activity extends CRM_Core_DAO {
           'description' => ts('Currently being used to store result id for survey activity, FK to option value.'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_activity.result',
           'table_name' => 'civicrm_activity',
           'entity' => 'Activity',
           'bao' => 'CRM_Activity_BAO_Activity',
@@ -575,7 +574,6 @@ class CRM_Activity_DAO_Activity extends CRM_Core_DAO {
           'import' => TRUE,
           'where' => 'civicrm_activity.is_deleted',
           'headerPattern' => '/(activity.)?(trash|deleted)/i',
-          'dataPattern' => '',
           'export' => TRUE,
           'default' => '0',
           'table_name' => 'civicrm_activity',
@@ -593,8 +591,6 @@ class CRM_Activity_DAO_Activity extends CRM_Core_DAO {
           'description' => ts('The campaign for which this activity has been triggered.'),
           'import' => TRUE,
           'where' => 'civicrm_activity.campaign_id',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_activity',
           'entity' => 'Activity',
@@ -617,8 +613,6 @@ class CRM_Activity_DAO_Activity extends CRM_Core_DAO {
           'description' => ts('Assign a specific level of engagement to this activity. Used for tracking constituents in ladder of engagement.'),
           'import' => TRUE,
           'where' => 'civicrm_activity.engagement_level',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_activity',
           'entity' => 'Activity',
@@ -636,6 +630,7 @@ class CRM_Activity_DAO_Activity extends CRM_Core_DAO {
           'name' => 'weight',
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Order'),
+          'where' => 'civicrm_activity.weight',
           'table_name' => 'civicrm_activity',
           'entity' => 'Activity',
           'bao' => 'CRM_Activity_BAO_Activity',
@@ -652,7 +647,6 @@ class CRM_Activity_DAO_Activity extends CRM_Core_DAO {
           'import' => TRUE,
           'where' => 'civicrm_activity.is_star',
           'headerPattern' => '/(activity.)?(star|favorite)/i',
-          'dataPattern' => '',
           'export' => TRUE,
           'default' => '0',
           'table_name' => 'civicrm_activity',
@@ -666,10 +660,8 @@ class CRM_Activity_DAO_Activity extends CRM_Core_DAO {
           'title' => ts('Created Date'),
           'description' => ts('When was the activity was created.'),
           'required' => FALSE,
-          'export' => TRUE,
           'where' => 'civicrm_activity.created_date',
-          'headerPattern' => '',
-          'dataPattern' => '',
+          'export' => TRUE,
           'default' => 'NULL',
           'table_name' => 'civicrm_activity',
           'entity' => 'Activity',
@@ -682,10 +674,8 @@ class CRM_Activity_DAO_Activity extends CRM_Core_DAO {
           'title' => ts('Modified Date'),
           'description' => ts('When was the activity (or closely related entity) was created or modified or deleted.'),
           'required' => FALSE,
-          'export' => TRUE,
           'where' => 'civicrm_activity.modified_date',
-          'headerPattern' => '',
-          'dataPattern' => '',
+          'export' => TRUE,
           'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
           'table_name' => 'civicrm_activity',
           'entity' => 'Activity',
diff --git a/civicrm/CRM/Activity/DAO/ActivityContact.php b/civicrm/CRM/Activity/DAO/ActivityContact.php
index eab2e15f2aa43282d0bad7b6aaba7ec1de201019..1eaa7ca8256d902b98b70ff12e91b97e221e967f 100644
--- a/civicrm/CRM/Activity/DAO/ActivityContact.php
+++ b/civicrm/CRM/Activity/DAO/ActivityContact.php
@@ -94,6 +94,7 @@ class CRM_Activity_DAO_ActivityContact extends CRM_Core_DAO {
           'title' => ts('Activity Contact ID'),
           'description' => ts('Activity contact id'),
           'required' => TRUE,
+          'where' => 'civicrm_activity_contact.id',
           'table_name' => 'civicrm_activity_contact',
           'entity' => 'ActivityContact',
           'bao' => 'CRM_Activity_BAO_ActivityContact',
@@ -105,6 +106,7 @@ class CRM_Activity_DAO_ActivityContact extends CRM_Core_DAO {
           'title' => ts('Activity ID'),
           'description' => ts('Foreign key to the activity for this record.'),
           'required' => TRUE,
+          'where' => 'civicrm_activity_contact.activity_id',
           'table_name' => 'civicrm_activity_contact',
           'entity' => 'ActivityContact',
           'bao' => 'CRM_Activity_BAO_ActivityContact',
@@ -119,8 +121,6 @@ class CRM_Activity_DAO_ActivityContact extends CRM_Core_DAO {
           'required' => TRUE,
           'import' => TRUE,
           'where' => 'civicrm_activity_contact.contact_id',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_activity_contact',
           'entity' => 'ActivityContact',
@@ -133,6 +133,7 @@ class CRM_Activity_DAO_ActivityContact extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Record Type ID'),
           'description' => ts('Nature of this contact\'s role in the activity: 1 assignee, 2 creator, 3 focus or target.'),
+          'where' => 'civicrm_activity_contact.record_type_id',
           'table_name' => 'civicrm_activity_contact',
           'entity' => 'ActivityContact',
           'bao' => 'CRM_Activity_BAO_ActivityContact',
diff --git a/civicrm/CRM/Activity/Form/Activity.php b/civicrm/CRM/Activity/Form/Activity.php
index 680188871e0cc79c8fb6d4df686b587a1e0552a3..a3fef8d7d8f07bfd20c1d1f1898b8b93edf5c86f 100644
--- a/civicrm/CRM/Activity/Form/Activity.php
+++ b/civicrm/CRM/Activity/Form/Activity.php
@@ -602,7 +602,7 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task {
     }
 
     // CRM-15472 - 50 is around the practical limit of how many items a select2 entityRef can handle
-    if ($this->_action == 2 && !empty($defaults['target_contact_id'])) {
+    if ($this->_action == CRM_Core_Action::UPDATE && !empty($defaults['target_contact_id'])) {
       $count = count(is_array($defaults['target_contact_id']) ? $defaults['target_contact_id'] : explode(',', $defaults['target_contact_id']));
       if ($count > 50) {
         $this->freeze(['target_contact_id']);
@@ -860,14 +860,12 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task {
       $errors['activity_type_id'] = ts('Activity Type is a required field');
     }
 
-    if (CRM_Utils_Array::value('activity_type_id', $fields) == 3 &&
-      CRM_Utils_Array::value('status_id', $fields) == 1
-    ) {
+    if (CRM_Utils_Array::value('activity_type_id', $fields) == CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'Email')
+      && CRM_Utils_Array::value('status_id', $fields) == CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'status_id', 'Scheduled')) {
       $errors['status_id'] = ts('You cannot record scheduled email activity.');
     }
-    elseif (CRM_Utils_Array::value('activity_type_id', $fields) == 4 &&
-      CRM_Utils_Array::value('status_id', $fields) == 1
-    ) {
+    elseif (CRM_Utils_Array::value('activity_type_id', $fields) == CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'SMS')
+      && CRM_Utils_Array::value('status_id', $fields) == CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'status_id', 'Scheduled')) {
       $errors['status_id'] = ts('You cannot record scheduled SMS activity.');
     }
 
@@ -896,7 +894,9 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task {
    *
    *
    * @param array $params
+
    * @return array|null
+   * @throws \CiviCRM_API3_Exception
    */
   public function postProcess($params = NULL) {
     if ($this->_action & CRM_Core_Action::DELETE) {
diff --git a/civicrm/CRM/Activity/Selector/Activity.php b/civicrm/CRM/Activity/Selector/Activity.php
index e03072dbdd175adf0321ad4882139e375a46d92e..6fef52aaff359b1ef55f3e9c4df1444164b8d7d8 100644
--- a/civicrm/CRM/Activity/Selector/Activity.php
+++ b/civicrm/CRM/Activity/Selector/Activity.php
@@ -181,9 +181,7 @@ class CRM_Activity_Selector_Activity extends CRM_Core_Selector_Base implements C
         $url = 'civicrm/contact/view/activity';
         $qsView = "atype={$activityTypeId}&action=view&reset=1&id=%%id%%&cid=%%cid%%&context=%%cxt%%{$extraParams}";
 
-        if (CRM_Core_Permission::check('edit inbound email basic information')
-          || CRM_Core_Permission::check('edit inbound email basic information and content')
-        ) {
+        if (CRM_Activity_BAO_Activity::checkEditInboundEmailsPermissions()) {
           $showDelete = $showUpdate = TRUE;
           $qsUpdate = "atype={$activityTypeId}&action=update&reset=1&id=%%id%%&cid=%%cid%%&context=%%cxt%%{$extraParams}";
         }
diff --git a/civicrm/CRM/Admin/Form/ScheduleReminders.php b/civicrm/CRM/Admin/Form/ScheduleReminders.php
index 38e425bfd5f0b926a6061e3b88e254577baf8007..e2365cb9d01e38fe9688c7c6e477de3d387c7ad1 100644
--- a/civicrm/CRM/Admin/Form/ScheduleReminders.php
+++ b/civicrm/CRM/Admin/Form/ScheduleReminders.php
@@ -463,7 +463,6 @@ class CRM_Admin_Form_ScheduleReminders extends CRM_Admin_Form {
 
     // we need to set this on the form so that hooks can identify the created entity
     $this->set('id', $bao->id);
-    $bao->free();
 
     $status = ts("Your new Reminder titled %1 has been saved.",
       [1 => "<strong>{$values['title']}</strong>"]
diff --git a/civicrm/CRM/Batch/DAO/Batch.php b/civicrm/CRM/Batch/DAO/Batch.php
index a066888d143f02afcef7010494c743c90d7c4f99..cac1d10f15b44d05108cb98a90c8c86db59cbec6 100644
--- a/civicrm/CRM/Batch/DAO/Batch.php
+++ b/civicrm/CRM/Batch/DAO/Batch.php
@@ -184,6 +184,7 @@ class CRM_Batch_DAO_Batch extends CRM_Core_DAO {
           'title' => ts('Batch ID'),
           'description' => ts('Unique Address ID'),
           'required' => TRUE,
+          'where' => 'civicrm_batch.id',
           'table_name' => 'civicrm_batch',
           'entity' => 'Batch',
           'bao' => 'CRM_Batch_BAO_Batch',
@@ -196,6 +197,7 @@ class CRM_Batch_DAO_Batch extends CRM_Core_DAO {
           'description' => ts('Variable name/programmatic handle for this batch.'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_batch.name',
           'table_name' => 'civicrm_batch',
           'entity' => 'Batch',
           'bao' => 'CRM_Batch_BAO_Batch',
@@ -211,6 +213,7 @@ class CRM_Batch_DAO_Batch extends CRM_Core_DAO {
           'description' => ts('Friendly Name.'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_batch.title',
           'table_name' => 'civicrm_batch',
           'entity' => 'Batch',
           'bao' => 'CRM_Batch_BAO_Batch',
@@ -226,6 +229,7 @@ class CRM_Batch_DAO_Batch extends CRM_Core_DAO {
           'description' => ts('Description of this batch set.'),
           'rows' => 4,
           'cols' => 80,
+          'where' => 'civicrm_batch.description',
           'table_name' => 'civicrm_batch',
           'entity' => 'Batch',
           'bao' => 'CRM_Batch_BAO_Batch',
@@ -239,6 +243,7 @@ class CRM_Batch_DAO_Batch extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Batch Created By'),
           'description' => ts('FK to Contact ID'),
+          'where' => 'civicrm_batch.created_id',
           'table_name' => 'civicrm_batch',
           'entity' => 'Batch',
           'bao' => 'CRM_Batch_BAO_Batch',
@@ -250,6 +255,7 @@ class CRM_Batch_DAO_Batch extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
           'title' => ts('Batch Created Date'),
           'description' => ts('When was this item created'),
+          'where' => 'civicrm_batch.created_date',
           'table_name' => 'civicrm_batch',
           'entity' => 'Batch',
           'bao' => 'CRM_Batch_BAO_Batch',
@@ -263,6 +269,7 @@ class CRM_Batch_DAO_Batch extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Batch Modified By'),
           'description' => ts('FK to Contact ID'),
+          'where' => 'civicrm_batch.modified_id',
           'table_name' => 'civicrm_batch',
           'entity' => 'Batch',
           'bao' => 'CRM_Batch_BAO_Batch',
@@ -274,6 +281,7 @@ class CRM_Batch_DAO_Batch extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
           'title' => ts('Batch Modified Date'),
           'description' => ts('When was this item created'),
+          'where' => 'civicrm_batch.modified_date',
           'table_name' => 'civicrm_batch',
           'entity' => 'Batch',
           'bao' => 'CRM_Batch_BAO_Batch',
@@ -284,6 +292,7 @@ class CRM_Batch_DAO_Batch extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Batch Smart Group'),
           'description' => ts('FK to Saved Search ID'),
+          'where' => 'civicrm_batch.saved_search_id',
           'table_name' => 'civicrm_batch',
           'entity' => 'Batch',
           'bao' => 'CRM_Batch_BAO_Batch',
@@ -299,6 +308,7 @@ class CRM_Batch_DAO_Batch extends CRM_Core_DAO {
           'title' => ts('Batch Status'),
           'description' => ts('fk to Batch Status options in civicrm_option_values'),
           'required' => TRUE,
+          'where' => 'civicrm_batch.status_id',
           'table_name' => 'civicrm_batch',
           'entity' => 'Batch',
           'bao' => 'CRM_Batch_BAO_Batch',
@@ -316,6 +326,7 @@ class CRM_Batch_DAO_Batch extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Batch Type'),
           'description' => ts('fk to Batch Type options in civicrm_option_values'),
+          'where' => 'civicrm_batch.type_id',
           'table_name' => 'civicrm_batch',
           'entity' => 'Batch',
           'bao' => 'CRM_Batch_BAO_Batch',
@@ -333,6 +344,7 @@ class CRM_Batch_DAO_Batch extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Batch Mode'),
           'description' => ts('fk to Batch mode options in civicrm_option_values'),
+          'where' => 'civicrm_batch.mode_id',
           'table_name' => 'civicrm_batch',
           'entity' => 'Batch',
           'bao' => 'CRM_Batch_BAO_Batch',
@@ -354,6 +366,7 @@ class CRM_Batch_DAO_Batch extends CRM_Core_DAO {
             20,
             2
           ],
+          'where' => 'civicrm_batch.total',
           'table_name' => 'civicrm_batch',
           'entity' => 'Batch',
           'bao' => 'CRM_Batch_BAO_Batch',
@@ -367,6 +380,7 @@ class CRM_Batch_DAO_Batch extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Batch Number of Items'),
           'description' => ts('Number of items in a batch.'),
+          'where' => 'civicrm_batch.item_count',
           'table_name' => 'civicrm_batch',
           'entity' => 'Batch',
           'bao' => 'CRM_Batch_BAO_Batch',
@@ -380,6 +394,7 @@ class CRM_Batch_DAO_Batch extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Batch Payment Method'),
           'description' => ts('fk to Payment Instrument options in civicrm_option_values'),
+          'where' => 'civicrm_batch.payment_instrument_id',
           'table_name' => 'civicrm_batch',
           'entity' => 'Batch',
           'bao' => 'CRM_Batch_BAO_Batch',
@@ -396,6 +411,7 @@ class CRM_Batch_DAO_Batch extends CRM_Core_DAO {
           'name' => 'exported_date',
           'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
           'title' => ts('Batch Exported Date'),
+          'where' => 'civicrm_batch.exported_date',
           'table_name' => 'civicrm_batch',
           'entity' => 'Batch',
           'bao' => 'CRM_Batch_BAO_Batch',
@@ -406,6 +422,7 @@ class CRM_Batch_DAO_Batch extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_LONGTEXT,
           'title' => ts('Batch Data'),
           'description' => ts('cache entered data'),
+          'where' => 'civicrm_batch.data',
           'table_name' => 'civicrm_batch',
           'entity' => 'Batch',
           'bao' => 'CRM_Batch_BAO_Batch',
diff --git a/civicrm/CRM/Batch/DAO/EntityBatch.php b/civicrm/CRM/Batch/DAO/EntityBatch.php
index 7526bf3d913007ec3da8e0d80111c0f9aa03495c..a9ec632af09366b4b0b998a375f0578e91034540 100644
--- a/civicrm/CRM/Batch/DAO/EntityBatch.php
+++ b/civicrm/CRM/Batch/DAO/EntityBatch.php
@@ -94,6 +94,7 @@ class CRM_Batch_DAO_EntityBatch extends CRM_Core_DAO {
           'title' => ts('EntityBatch ID'),
           'description' => ts('primary key'),
           'required' => TRUE,
+          'where' => 'civicrm_entity_batch.id',
           'table_name' => 'civicrm_entity_batch',
           'entity' => 'EntityBatch',
           'bao' => 'CRM_Batch_BAO_EntityBatch',
@@ -106,6 +107,7 @@ class CRM_Batch_DAO_EntityBatch extends CRM_Core_DAO {
           'description' => ts('physical tablename for entity being joined to file, e.g. civicrm_contact'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_entity_batch.entity_table',
           'table_name' => 'civicrm_entity_batch',
           'entity' => 'EntityBatch',
           'bao' => 'CRM_Batch_BAO_EntityBatch',
@@ -117,6 +119,7 @@ class CRM_Batch_DAO_EntityBatch extends CRM_Core_DAO {
           'title' => ts('Entity ID'),
           'description' => ts('FK to entity table specified in entity_table column.'),
           'required' => TRUE,
+          'where' => 'civicrm_entity_batch.entity_id',
           'table_name' => 'civicrm_entity_batch',
           'entity' => 'EntityBatch',
           'bao' => 'CRM_Batch_BAO_EntityBatch',
@@ -128,6 +131,7 @@ class CRM_Batch_DAO_EntityBatch extends CRM_Core_DAO {
           'title' => ts('Batch ID'),
           'description' => ts('FK to civicrm_batch'),
           'required' => TRUE,
+          'where' => 'civicrm_entity_batch.batch_id',
           'table_name' => 'civicrm_entity_batch',
           'entity' => 'EntityBatch',
           'bao' => 'CRM_Batch_BAO_EntityBatch',
diff --git a/civicrm/CRM/Campaign/DAO/Campaign.php b/civicrm/CRM/Campaign/DAO/Campaign.php
index 361539410738e7f1d80c35a9f1cb8f1931681701..dad2b00defec43ddd5e0c0253449ffdba01fb1b5 100644
--- a/civicrm/CRM/Campaign/DAO/Campaign.php
+++ b/civicrm/CRM/Campaign/DAO/Campaign.php
@@ -188,8 +188,6 @@ class CRM_Campaign_DAO_Campaign extends CRM_Core_DAO {
           'required' => TRUE,
           'import' => TRUE,
           'where' => 'civicrm_campaign.id',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_campaign',
           'entity' => 'Campaign',
@@ -206,8 +204,6 @@ class CRM_Campaign_DAO_Campaign extends CRM_Core_DAO {
           'size' => CRM_Utils_Type::HUGE,
           'import' => TRUE,
           'where' => 'civicrm_campaign.name',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_campaign',
           'entity' => 'Campaign',
@@ -226,8 +222,6 @@ class CRM_Campaign_DAO_Campaign extends CRM_Core_DAO {
           'size' => CRM_Utils_Type::HUGE,
           'import' => TRUE,
           'where' => 'civicrm_campaign.title',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_campaign',
           'entity' => 'Campaign',
@@ -244,6 +238,7 @@ class CRM_Campaign_DAO_Campaign extends CRM_Core_DAO {
           'description' => ts('Full description of Campaign.'),
           'rows' => 8,
           'cols' => 60,
+          'where' => 'civicrm_campaign.description',
           'table_name' => 'civicrm_campaign',
           'entity' => 'Campaign',
           'bao' => 'CRM_Campaign_BAO_Campaign',
@@ -260,7 +255,6 @@ class CRM_Campaign_DAO_Campaign extends CRM_Core_DAO {
           'import' => TRUE,
           'where' => 'civicrm_campaign.start_date',
           'headerPattern' => '/^start|(s(tart\s)?date)$/i',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_campaign',
           'entity' => 'Campaign',
@@ -278,7 +272,6 @@ class CRM_Campaign_DAO_Campaign extends CRM_Core_DAO {
           'import' => TRUE,
           'where' => 'civicrm_campaign.end_date',
           'headerPattern' => '/^end|(e(nd\s)?date)$/i',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_campaign',
           'entity' => 'Campaign',
@@ -295,8 +288,6 @@ class CRM_Campaign_DAO_Campaign extends CRM_Core_DAO {
           'description' => ts('Campaign Type ID.Implicit FK to civicrm_option_value where option_group = campaign_type'),
           'import' => TRUE,
           'where' => 'civicrm_campaign.campaign_type_id',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'default' => 'NULL',
           'table_name' => 'civicrm_campaign',
@@ -318,8 +309,6 @@ class CRM_Campaign_DAO_Campaign extends CRM_Core_DAO {
           'description' => ts('Campaign status ID.Implicit FK to civicrm_option_value where option_group = campaign_status'),
           'import' => TRUE,
           'where' => 'civicrm_campaign.status_id',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'default' => 'NULL',
           'table_name' => 'civicrm_campaign',
@@ -361,8 +350,6 @@ class CRM_Campaign_DAO_Campaign extends CRM_Core_DAO {
           'description' => ts('Optional parent id for this Campaign.'),
           'import' => TRUE,
           'where' => 'civicrm_campaign.parent_id',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'default' => 'NULL',
           'table_name' => 'civicrm_campaign',
@@ -379,6 +366,7 @@ class CRM_Campaign_DAO_Campaign extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Is Campaign Active?'),
           'description' => ts('Is this Campaign enabled or disabled/cancelled?'),
+          'where' => 'civicrm_campaign.is_active',
           'default' => '1',
           'table_name' => 'civicrm_campaign',
           'entity' => 'Campaign',
@@ -393,6 +381,7 @@ class CRM_Campaign_DAO_Campaign extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Campaign Created By'),
           'description' => ts('FK to civicrm_contact, who created this Campaign.'),
+          'where' => 'civicrm_campaign.created_id',
           'table_name' => 'civicrm_campaign',
           'entity' => 'Campaign',
           'bao' => 'CRM_Campaign_BAO_Campaign',
@@ -404,6 +393,7 @@ class CRM_Campaign_DAO_Campaign extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
           'title' => ts('Campaign Created Date'),
           'description' => ts('Date and time that Campaign was created.'),
+          'where' => 'civicrm_campaign.created_date',
           'table_name' => 'civicrm_campaign',
           'entity' => 'Campaign',
           'bao' => 'CRM_Campaign_BAO_Campaign',
@@ -417,6 +407,7 @@ class CRM_Campaign_DAO_Campaign extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Campaign Modified By'),
           'description' => ts('FK to civicrm_contact, who recently edited this Campaign.'),
+          'where' => 'civicrm_campaign.last_modified_id',
           'table_name' => 'civicrm_campaign',
           'entity' => 'Campaign',
           'bao' => 'CRM_Campaign_BAO_Campaign',
@@ -428,6 +419,7 @@ class CRM_Campaign_DAO_Campaign extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
           'title' => ts('Campaign Modified Date'),
           'description' => ts('Date and time that Campaign was edited last time.'),
+          'where' => 'civicrm_campaign.last_modified_date',
           'table_name' => 'civicrm_campaign',
           'entity' => 'Campaign',
           'bao' => 'CRM_Campaign_BAO_Campaign',
@@ -438,6 +430,7 @@ class CRM_Campaign_DAO_Campaign extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_TEXT,
           'title' => ts('Campaign Goals'),
           'description' => ts('General goals for Campaign.'),
+          'where' => 'civicrm_campaign.goal_general',
           'table_name' => 'civicrm_campaign',
           'entity' => 'Campaign',
           'bao' => 'CRM_Campaign_BAO_Campaign',
@@ -455,6 +448,7 @@ class CRM_Campaign_DAO_Campaign extends CRM_Core_DAO {
             20,
             2
           ],
+          'where' => 'civicrm_campaign.goal_revenue',
           'table_name' => 'civicrm_campaign',
           'entity' => 'Campaign',
           'bao' => 'CRM_Campaign_BAO_Campaign',
diff --git a/civicrm/CRM/Campaign/DAO/CampaignGroup.php b/civicrm/CRM/Campaign/DAO/CampaignGroup.php
index 39807c1ac6ea1b08ad8d1927dcdd9c2415ca53ce..5c8ec894d4be4df252da6163493f52d08563298e 100644
--- a/civicrm/CRM/Campaign/DAO/CampaignGroup.php
+++ b/civicrm/CRM/Campaign/DAO/CampaignGroup.php
@@ -101,6 +101,7 @@ class CRM_Campaign_DAO_CampaignGroup extends CRM_Core_DAO {
           'title' => ts('Campaign Group ID'),
           'description' => ts('Campaign Group id.'),
           'required' => TRUE,
+          'where' => 'civicrm_campaign_group.id',
           'table_name' => 'civicrm_campaign_group',
           'entity' => 'CampaignGroup',
           'bao' => 'CRM_Campaign_DAO_CampaignGroup',
@@ -112,6 +113,7 @@ class CRM_Campaign_DAO_CampaignGroup extends CRM_Core_DAO {
           'title' => ts('Campaign'),
           'description' => ts('Foreign key to the activity Campaign.'),
           'required' => TRUE,
+          'where' => 'civicrm_campaign_group.campaign_id',
           'table_name' => 'civicrm_campaign_group',
           'entity' => 'CampaignGroup',
           'bao' => 'CRM_Campaign_DAO_CampaignGroup',
@@ -130,6 +132,7 @@ class CRM_Campaign_DAO_CampaignGroup extends CRM_Core_DAO {
           'description' => ts('Type of Group.'),
           'maxlength' => 8,
           'size' => CRM_Utils_Type::EIGHT,
+          'where' => 'civicrm_campaign_group.group_type',
           'default' => 'NULL',
           'table_name' => 'civicrm_campaign_group',
           'entity' => 'CampaignGroup',
@@ -149,6 +152,7 @@ class CRM_Campaign_DAO_CampaignGroup extends CRM_Core_DAO {
           'description' => ts('Name of table where item being referenced is stored.'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_campaign_group.entity_table',
           'default' => 'NULL',
           'table_name' => 'civicrm_campaign_group',
           'entity' => 'CampaignGroup',
@@ -160,6 +164,7 @@ class CRM_Campaign_DAO_CampaignGroup extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Entity ID'),
           'description' => ts('Entity id of referenced table.'),
+          'where' => 'civicrm_campaign_group.entity_id',
           'default' => 'NULL',
           'table_name' => 'civicrm_campaign_group',
           'entity' => 'CampaignGroup',
diff --git a/civicrm/CRM/Campaign/DAO/Survey.php b/civicrm/CRM/Campaign/DAO/Survey.php
index 17cc7fcc90b92fde97e62f2528d62c582bff6a35..763fd2f71033d248de3b179c661fc01e4c73369f 100644
--- a/civicrm/CRM/Campaign/DAO/Survey.php
+++ b/civicrm/CRM/Campaign/DAO/Survey.php
@@ -207,6 +207,7 @@ class CRM_Campaign_DAO_Survey extends CRM_Core_DAO {
           'title' => ts('Survey ID'),
           'description' => ts('Survey id.'),
           'required' => TRUE,
+          'where' => 'civicrm_survey.id',
           'table_name' => 'civicrm_survey',
           'entity' => 'Survey',
           'bao' => 'CRM_Campaign_BAO_Survey',
@@ -222,8 +223,6 @@ class CRM_Campaign_DAO_Survey extends CRM_Core_DAO {
           'size' => CRM_Utils_Type::HUGE,
           'import' => TRUE,
           'where' => 'civicrm_survey.title',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_survey',
           'entity' => 'Survey',
@@ -235,6 +234,7 @@ class CRM_Campaign_DAO_Survey extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Survey Campaign ID'),
           'description' => ts('Foreign key to the Campaign.'),
+          'where' => 'civicrm_survey.campaign_id',
           'default' => 'NULL',
           'table_name' => 'civicrm_survey',
           'entity' => 'Survey',
@@ -254,8 +254,6 @@ class CRM_Campaign_DAO_Survey extends CRM_Core_DAO {
           'description' => ts('Implicit FK to civicrm_option_value where option_group = activity_type'),
           'import' => TRUE,
           'where' => 'civicrm_survey.activity_type_id',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'default' => 'NULL',
           'table_name' => 'civicrm_survey',
@@ -277,6 +275,7 @@ class CRM_Campaign_DAO_Survey extends CRM_Core_DAO {
           'description' => ts('Recontact intervals for each status.'),
           'rows' => 20,
           'cols' => 80,
+          'where' => 'civicrm_survey.recontact_interval',
           'table_name' => 'civicrm_survey',
           'entity' => 'Survey',
           'bao' => 'CRM_Campaign_BAO_Survey',
@@ -292,6 +291,7 @@ class CRM_Campaign_DAO_Survey extends CRM_Core_DAO {
           'description' => ts('Script instructions for volunteers to use for the survey.'),
           'rows' => 20,
           'cols' => 80,
+          'where' => 'civicrm_survey.instructions',
           'table_name' => 'civicrm_survey',
           'entity' => 'Survey',
           'bao' => 'CRM_Campaign_BAO_Survey',
@@ -305,6 +305,7 @@ class CRM_Campaign_DAO_Survey extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Survey Hold Duration'),
           'description' => ts('Number of days for recurrence of release.'),
+          'where' => 'civicrm_survey.release_frequency',
           'default' => 'NULL',
           'table_name' => 'civicrm_survey',
           'entity' => 'Survey',
@@ -316,6 +317,7 @@ class CRM_Campaign_DAO_Survey extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Maximum number of contacts'),
           'description' => ts('Maximum number of contacts to allow for survey.'),
+          'where' => 'civicrm_survey.max_number_of_contacts',
           'default' => 'NULL',
           'table_name' => 'civicrm_survey',
           'entity' => 'Survey',
@@ -327,6 +329,7 @@ class CRM_Campaign_DAO_Survey extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Default number of contacts'),
           'description' => ts('Default number of contacts to allow for survey.'),
+          'where' => 'civicrm_survey.default_number_of_contacts',
           'default' => 'NULL',
           'table_name' => 'civicrm_survey',
           'entity' => 'Survey',
@@ -338,6 +341,7 @@ class CRM_Campaign_DAO_Survey extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Survey Is Active'),
           'description' => ts('Is this survey enabled or disabled/cancelled?'),
+          'where' => 'civicrm_survey.is_active',
           'default' => '1',
           'table_name' => 'civicrm_survey',
           'entity' => 'Survey',
@@ -349,6 +353,7 @@ class CRM_Campaign_DAO_Survey extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Is Default Survey'),
           'description' => ts('Is this default survey?'),
+          'where' => 'civicrm_survey.is_default',
           'default' => '0',
           'table_name' => 'civicrm_survey',
           'entity' => 'Survey',
@@ -360,6 +365,7 @@ class CRM_Campaign_DAO_Survey extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Survey Created By'),
           'description' => ts('FK to civicrm_contact, who created this Survey.'),
+          'where' => 'civicrm_survey.created_id',
           'table_name' => 'civicrm_survey',
           'entity' => 'Survey',
           'bao' => 'CRM_Campaign_BAO_Survey',
@@ -371,6 +377,7 @@ class CRM_Campaign_DAO_Survey extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
           'title' => ts('Campaign Created Date'),
           'description' => ts('Date and time that Survey was created.'),
+          'where' => 'civicrm_survey.created_date',
           'table_name' => 'civicrm_survey',
           'entity' => 'Survey',
           'bao' => 'CRM_Campaign_BAO_Survey',
@@ -381,6 +388,7 @@ class CRM_Campaign_DAO_Survey extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Survey Modified'),
           'description' => ts('FK to civicrm_contact, who recently edited this Survey.'),
+          'where' => 'civicrm_survey.last_modified_id',
           'table_name' => 'civicrm_survey',
           'entity' => 'Survey',
           'bao' => 'CRM_Campaign_BAO_Survey',
@@ -392,6 +400,7 @@ class CRM_Campaign_DAO_Survey extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
           'title' => ts('Survey Modified On'),
           'description' => ts('Date and time that Survey was edited last time.'),
+          'where' => 'civicrm_survey.last_modified_date',
           'table_name' => 'civicrm_survey',
           'entity' => 'Survey',
           'bao' => 'CRM_Campaign_BAO_Survey',
@@ -402,6 +411,7 @@ class CRM_Campaign_DAO_Survey extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Survey Result'),
           'description' => ts('Used to store option group id.'),
+          'where' => 'civicrm_survey.result_id',
           'default' => 'NULL',
           'table_name' => 'civicrm_survey',
           'entity' => 'Survey',
@@ -413,6 +423,7 @@ class CRM_Campaign_DAO_Survey extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('No Email Verification'),
           'description' => ts('Bypass the email verification.'),
+          'where' => 'civicrm_survey.bypass_confirm',
           'default' => '0',
           'table_name' => 'civicrm_survey',
           'entity' => 'Survey',
@@ -426,6 +437,7 @@ class CRM_Campaign_DAO_Survey extends CRM_Core_DAO {
           'description' => ts('Title for Thank-you page (header title tag, and display at the top of the page).'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_survey.thankyou_title',
           'table_name' => 'civicrm_survey',
           'entity' => 'Survey',
           'bao' => 'CRM_Campaign_BAO_Survey',
@@ -438,6 +450,7 @@ class CRM_Campaign_DAO_Survey extends CRM_Core_DAO {
           'description' => ts('text and html allowed. displayed above result on success page'),
           'rows' => 8,
           'cols' => 60,
+          'where' => 'civicrm_survey.thankyou_text',
           'table_name' => 'civicrm_survey',
           'entity' => 'Survey',
           'bao' => 'CRM_Campaign_BAO_Survey',
@@ -451,6 +464,7 @@ class CRM_Campaign_DAO_Survey extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Is shared through social media'),
           'description' => ts('Can people share the petition through social media?'),
+          'where' => 'civicrm_survey.is_share',
           'default' => '1',
           'table_name' => 'civicrm_survey',
           'entity' => 'Survey',
diff --git a/civicrm/CRM/Campaign/Form/Search/Campaign.php b/civicrm/CRM/Campaign/Form/Search/Campaign.php
index 6fc5d63ab848583b26da230833933e9be33c3ebd..f292272399c593a112c880420adaa3681fe2cc90 100644
--- a/civicrm/CRM/Campaign/Form/Search/Campaign.php
+++ b/civicrm/CRM/Campaign/Form/Search/Campaign.php
@@ -36,6 +36,15 @@
  */
 class CRM_Campaign_Form_Search_Campaign extends CRM_Core_Form {
 
+  /**
+   * Explicitly declare the entity api name.
+   *
+   * @return string
+   */
+  public function getDefaultEntity() {
+    return 'Campaign';
+  }
+
   /**
    * Are we forced to run a search.
    *
@@ -78,11 +87,8 @@ class CRM_Campaign_Form_Search_Campaign extends CRM_Core_Form {
     //campaign description.
     $this->add('text', 'description', ts('Description'), $attributes['description']);
 
-    //campaign start date.
-    $this->addDate('start_date', ts('From'), FALSE, ['formatType' => 'searchDate']);
-
-    //campaign end date.
-    $this->addDate('end_date', ts('To'), FALSE, ['formatType' => 'searchDate']);
+    $this->add('datepicker', 'start_date', ts('Campaign Start Date'), [], FALSE, ['time' => FALSE]);
+    $this->add('datepicker', 'end_date', ts('Campaign End Date'), [], FALSE, ['time' => FALSE]);
 
     //campaign type.
     $campaignTypes = CRM_Campaign_PseudoConstant::campaignType();
diff --git a/civicrm/CRM/Case/BAO/Case.php b/civicrm/CRM/Case/BAO/Case.php
index 091b4e9f046f74b26202acd3c39bd5fac2f95fc2..222860016a0125dbbdd91beeb93e281a0613b555 100644
--- a/civicrm/CRM/Case/BAO/Case.php
+++ b/civicrm/CRM/Case/BAO/Case.php
@@ -429,121 +429,60 @@ WHERE cc.contact_id = %1 AND civicrm_case_type.name = '{$caseType}'";
       'civicrm_phone.phone as phone',
       'civicrm_contact.contact_type as contact_type',
       'civicrm_contact.contact_sub_type as contact_sub_type',
-      't_act.activity_type_id',
-      'c_type.title as case_type',
+      't_act.activity_type_id as activity_type_id',
       'civicrm_case.case_type_id as case_type_id',
-      'cov_status.label as case_status',
-      'cov_status.label as case_status_name',
-      't_act.status_id',
+      'civicrm_case.status_id as case_status_id',
+      't_act.status_id as status_id',
       'civicrm_case.start_date as case_start_date',
       'case_relation_type.label_b_a as case_role',
+      't_act.activity_date_time as activity_date_time',
+      't_act.id as activity_id',
     );
 
-    if ($type == 'upcoming') {
-      $selectClauses = array_merge($selectClauses, array(
-        't_act.desired_date as case_scheduled_activity_date',
-        't_act.id as case_scheduled_activity_id',
-        't_act.act_type_name as case_scheduled_activity_type_name',
-        't_act.act_type AS case_scheduled_activity_type',
-      ));
-    }
-    elseif ($type == 'recent') {
-      $selectClauses = array_merge($selectClauses, array(
-        't_act.desired_date as case_recent_activity_date',
-        't_act.id as case_recent_activity_id',
-        't_act.act_type_name as case_recent_activity_type_name',
-        't_act.act_type AS case_recent_activity_type',
-      ));
-    }
-    elseif ($type == 'any') {
-      $selectClauses = array_merge($selectClauses, array(
-        't_act.desired_date as case_activity_date',
-        't_act.id as case_activity_id',
-        't_act.act_type_name as case_activity_type_name',
-        't_act.act_type AS case_activity_type',
-      ));
-    }
-
     $query = CRM_Contact_BAO_Query::appendAnyValueToSelect($selectClauses, 'case_id');
 
-    $query .= " FROM civicrm_case
-                  INNER JOIN civicrm_case_contact ON civicrm_case.id = civicrm_case_contact.case_id
-                  INNER JOIN civicrm_contact ON civicrm_case_contact.contact_id = civicrm_contact.id ";
-
-    if ($type == 'upcoming') {
-      // This gets the earliest activity per case that's scheduled within 14 days from now.
-      // Note we have an inner select to get the min activity id in order to remove duplicates in case there are two with the same datetime.
-      // In this case we don't really care which one, so min(id) works.
-      // optimized in CRM-11837
-      $query .= " INNER JOIN
-(
-  SELECT case_id, act.id, activity_date_time AS desired_date, activity_type_id, status_id, aov.name AS act_type_name, aov.label AS act_type
-  FROM (
-    SELECT *
-    FROM (
-      SELECT *
-      FROM civicrm_view_case_activity_upcoming
-      ORDER BY activity_date_time ASC, id ASC
-      ) AS upcomingOrdered
-    ) AS act
-  LEFT JOIN civicrm_option_group aog ON aog.name='activity_type'
-  LEFT JOIN civicrm_option_value aov ON ( aov.option_group_id = aog.id AND aov.value = act.activity_type_id )
-) AS t_act
-";
-    }
-    elseif ($type == 'recent') {
-      // Similarly, the most recent activity in the past 14 days, and exclude scheduled.
-      //improve query performance - CRM-10598
-      $query .= " INNER JOIN
-(
-  SELECT case_id, act.id, activity_date_time AS desired_date, activity_type_id, status_id, aov.name AS act_type_name, aov.label AS act_type
-  FROM (
-    SELECT *
-    FROM (
-      SELECT *
-      FROM civicrm_view_case_activity_recent
-      ORDER BY activity_date_time DESC, id ASC
-      ) AS recentOrdered
-    ) AS act
-LEFT JOIN civicrm_option_group aog ON aog.name='activity_type'
-  LEFT JOIN civicrm_option_value aov ON ( aov.option_group_id = aog.id AND aov.value = act.activity_type_id )
-) AS t_act ";
-    }
-    elseif ($type == 'any') {
-      $query .= " LEFT JOIN
-(
-  SELECT ca4.case_id, act4.id AS id, act4.activity_date_time AS desired_date, act4.activity_type_id, act4.status_id, aov.name AS act_type_name, aov.label AS act_type
-  FROM civicrm_activity act4
-  LEFT JOIN civicrm_case_activity ca4
-    ON ca4.activity_id = act4.id
-    AND act4.is_current_revision = 1
-  LEFT JOIN civicrm_option_group aog
-    ON aog.name='activity_type'
-  LEFT JOIN civicrm_option_value aov
-    ON aov.option_group_id = aog.id
-    AND aov.value = act4.activity_type_id
-) AS t_act";
-    }
-
-    $query .= "
-        ON t_act.case_id = civicrm_case.id
- LEFT JOIN civicrm_phone ON (civicrm_phone.contact_id = civicrm_contact.id AND civicrm_phone.is_primary=1)
- LEFT JOIN civicrm_relationship case_relationship
- ON ( case_relationship.contact_id_a = civicrm_case_contact.contact_id AND case_relationship.contact_id_b = {$userID} AND case_relationship.is_active AND case_relationship.case_id = civicrm_case.id )
- LEFT JOIN civicrm_relationship_type case_relation_type
- ON ( case_relation_type.id = case_relationship.relationship_type_id
-      AND case_relation_type.id = case_relationship.relationship_type_id )
-
- LEFT JOIN civicrm_case_type c_type
- ON civicrm_case.case_type_id = c_type.id
-
- LEFT JOIN civicrm_option_group cog_status
- ON cog_status.name = 'case_status'
-
- LEFT JOIN civicrm_option_value cov_status
- ON ( civicrm_case.status_id = cov_status.value
-      AND cog_status.id = cov_status.option_group_id )
-";
+    $query .= <<<HERESQL
+      FROM civicrm_case
+        INNER JOIN civicrm_case_contact ON civicrm_case.id = civicrm_case_contact.case_id
+        INNER JOIN civicrm_contact ON civicrm_case_contact.contact_id = civicrm_contact.id
+HERESQL;
+
+    switch ($type) {
+      case 'upcoming':
+      case 'recent':
+        // civicrm_view_case_activity_upcoming and
+        // civicrm_view_case_activity_recent are views that show the next
+        // scheduled and most recent not-scheduled activity on each case,
+        // respectively.
+        $query .= <<<HERESQL
+        INNER JOIN civicrm_view_case_activity_$type t_act
+          ON t_act.case_id = civicrm_case.id
+HERESQL;
+        break;
+
+      case 'any':
+        $query .= <<<HERESQL
+        LEFT JOIN civicrm_case_activity ca4
+          ON civicrm_case.id = ca4.case_id
+        LEFT JOIN civicrm_activity t_act
+          ON t_act.id = ca4.activity_id
+          AND t_act.is_current_revision = 1
+HERESQL;
+    }
+
+    $query .= <<<HERESQL
+        LEFT JOIN civicrm_phone
+          ON civicrm_phone.contact_id = civicrm_contact.id
+            AND civicrm_phone.is_primary = 1
+        LEFT JOIN civicrm_relationship case_relationship
+          ON case_relationship.contact_id_a = civicrm_case_contact.contact_id
+            AND case_relationship.contact_id_b = {$userID}
+            AND case_relationship.is_active
+            AND case_relationship.case_id = civicrm_case.id
+        LEFT JOIN civicrm_relationship_type case_relation_type
+          ON case_relation_type.id = case_relationship.relationship_type_id
+            AND case_relation_type.id = case_relationship.relationship_type_id
+HERESQL;
 
     if ($condition) {
       // CRM-8749 backwards compatibility - callers of this function expect to start $condition with "AND"
@@ -551,20 +490,7 @@ LEFT JOIN civicrm_option_group aog ON aog.name='activity_type'
     }
     $query .= " GROUP BY case_id ";
 
-    if ($order) {
-      $query .= $order;
-    }
-    else {
-      if ($type == 'upcoming') {
-        $query .= " ORDER BY case_scheduled_activity_date ASC ";
-      }
-      elseif ($type == 'recent') {
-        $query .= " ORDER BY case_recent_activity_date ASC ";
-      }
-      elseif ($type == 'any') {
-        $query .= " ORDER BY case_activity_date ASC ";
-      }
-    }
+    $query .= ($order) ?: ' ORDER BY activity_date_time ASC';
 
     if ($limit) {
       $query .= $limit;
@@ -601,20 +527,6 @@ LEFT JOIN civicrm_option_group aog ON aog.name='activity_type'
     $type = CRM_Utils_Array::value('type', $params, 'upcoming');
     $userID = CRM_Core_Session::singleton()->get('userID');
 
-    $caseActivityTypeColumn = 'case_activity_type_name';
-    $caseActivityDateColumn = 'case_activity_date';
-    $caseActivityIDColumn = 'case_activity_id';
-    if ($type == 'upcoming') {
-      $caseActivityDateColumn = 'case_scheduled_activity_date';
-      $caseActivityTypeColumn = 'case_scheduled_activity_type';
-      $caseActivityIDColumn = 'case_scheduled_activity_id';
-    }
-    elseif ($type == 'recent') {
-      $caseActivityDateColumn = 'case_recent_activity_date';
-      $caseActivityTypeColumn = 'case_recent_activity_type';
-      $caseActivityIDColumn = 'case_recent_activity_id';
-    }
-
     // validate access for all cases.
     if ($allCases && !CRM_Core_Permission::check('access all cases and activities')) {
       $allCases = FALSE;
@@ -654,7 +566,7 @@ LEFT JOIN civicrm_option_group aog ON aog.name='activity_type'
     $order = NULL;
     if (!empty($params['sortBy'])) {
       if (strstr($params['sortBy'], 'date ')) {
-        $params['sortBy'] = str_replace('date', $caseActivityDateColumn, $params['sortBy']);
+        $params['sortBy'] = str_replace('date', 'activity_date_time', $params['sortBy']);
       }
       $order = "ORDER BY " . $params['sortBy'];
     }
@@ -662,8 +574,6 @@ LEFT JOIN civicrm_option_group aog ON aog.name='activity_type'
     $query = self::getCaseActivityQuery($type, $userID, $condition, $limit, $order);
     $result = CRM_Core_DAO::executeQuery($query);
 
-    $caseStatus = CRM_Core_OptionGroup::values('case_status', FALSE, FALSE, FALSE, " AND v.name = 'Urgent' ");
-
     // we're going to use the usual actions, so doesn't make sense to duplicate definitions
     $actions = CRM_Case_Selector_Search::links();
 
@@ -679,7 +589,12 @@ LEFT JOIN civicrm_option_group aog ON aog.name='activity_type'
     }
     $mask = CRM_Core_Action::mask($permissions);
 
+    // Pseudoconstants to populate labels
+    $caseStatuses = CRM_Case_PseudoConstant::caseStatus('label', FALSE);
     $caseTypes = CRM_Case_PseudoConstant::caseType('name');
+    $caseTypeTitles = CRM_Case_PseudoConstant::caseType('title', FALSE);
+    $activityTypeLabels = CRM_Activity_BAO_Activity::buildOptions('activity_type_id');
+
     foreach ($result->fetchAll() as $case) {
       $key = $case['case_id'];
       $casesList[$key] = array();
@@ -701,30 +616,31 @@ LEFT JOIN civicrm_option_group aog ON aog.name='activity_type'
         $case['case_id']
       );
       $casesList[$key]['subject'] = $case['case_subject'];
-      $casesList[$key]['case_status'] = in_array($case['case_status'], $caseStatus) ? sprintf('<strong>%s</strong>', strtoupper($case['case_status'])) : $case['case_status'];
-      $casesList[$key]['case_type'] = $case['case_type'];
+      $casesList[$key]['case_status'] = CRM_Utils_Array::value($case['case_status_id'], $caseStatuses);
+      if ($case['case_status_id'] == CRM_Case_PseudoConstant::getKey('CRM_Case_BAO_Case', 'case_status_id', 'Urgent')) {
+        $casesList[$key]['case_status'] = sprintf('<strong>%s</strong>', strtoupper($casesList[$key]['case_status']));
+      }
+      $casesList[$key]['case_type'] = CRM_Utils_Array::value($case['case_type_id'], $caseTypeTitles);
       $casesList[$key]['case_role'] = CRM_Utils_Array::value('case_role', $case, '---');
       $casesList[$key]['manager'] = self::getCaseManagerContact($caseTypes[$case['case_type_id']], $case['case_id']);
 
-      $casesList[$key]['date'] = $case[$caseActivityTypeColumn];
-      if (($actId = CRM_Utils_Array::value('case_scheduled_activity_id', $case)) ||
-        ($actId = CRM_Utils_Array::value('case_recent_activity_id', $case))
-      ) {
+      $casesList[$key]['date'] = CRM_Utils_Array::value($case['activity_type_id'], $activityTypeLabels);
+      if ($actId = CRM_Utils_Array::value('activity_id', $case)) {
         if (self::checkPermission($actId, 'view', $case['activity_type_id'], $userID)) {
           if ($type == 'recent') {
             $casesList[$key]['date'] = sprintf('<a class="action-item crm-hover-button" href="%s" title="%s">%s</a>',
-              CRM_Utils_System::url('civicrm/case/activity/view', array('reset' => 1, 'cid' => $case['contact_id'], 'aid' => $case[$caseActivityIDColumn])),
+              CRM_Utils_System::url('civicrm/case/activity/view', array('reset' => 1, 'cid' => $case['contact_id'], 'aid' => $case['activity_id'])),
               ts('View activity'),
-              $case[$caseActivityTypeColumn]
+              CRM_Utils_Array::value($case['activity_type_id'], $activityTypeLabels)
             );
           }
           else {
-            $status = CRM_Utils_Date::overdue($case[$caseActivityDateColumn]) ? 'status-overdue' : 'status-scheduled';
+            $status = CRM_Utils_Date::overdue($case['activity_date_time']) ? 'status-overdue' : 'status-scheduled';
             $casesList[$key]['date'] = sprintf('<a class="crm-popup %s" href="%s" title="%s">%s</a> &nbsp;&nbsp;',
              $status,
-              CRM_Utils_System::url('civicrm/case/activity/view', array('reset' => 1, 'cid' => $case['contact_id'], 'aid' => $case[$caseActivityIDColumn])),
+              CRM_Utils_System::url('civicrm/case/activity/view', array('reset' => 1, 'cid' => $case['contact_id'], 'aid' => $case['activity_id'])),
               ts('View activity'),
-              $case[$caseActivityTypeColumn]
+              CRM_Utils_Array::value($case['activity_type_id'], $activityTypeLabels)
             );
           }
         }
@@ -735,7 +651,7 @@ LEFT JOIN civicrm_option_group aog ON aog.name='activity_type'
           );
         }
       }
-      $casesList[$key]['date'] .= "<br/>" . CRM_Utils_Date::customFormat($case[$caseActivityDateColumn]);
+      $casesList[$key]['date'] .= "<br/>" . CRM_Utils_Date::customFormat($case['activity_date_time']);
       $casesList[$key]['links'] = CRM_Core_Action::formLink($actions['primaryActions'], $mask,
         array(
           'id' => $case['case_id'],
@@ -1151,9 +1067,18 @@ SELECT case_status.label AS case_status, status_id, civicrm_case_type.title AS c
 
       // Activity Status Label for Case activities list
       $caseActivities[$caseActivityId]['status_id'] = CRM_Core_PseudoConstant::getLabel('CRM_Activity_BAO_Activity', 'activity_status_id', $dao->status);
+      $deleted = '';
+      if ($dao->deleted) {
+        $deleted = '<br /> ' . ts('(deleted)');
+      }
+      $caseActivities[$caseActivityId]['status_id'] = CRM_Core_PseudoConstant::getLabel('CRM_Activity_BAO_Activity', 'activity_status_id', $dao->status) . $deleted;
+      // if there are file attachments we will return how many
+      if (!empty($dao->attachment_ids)) {
+        $attachmentIDs = array_unique(explode(',', $dao->attachment_ids));
+        $caseActivity['no_attachments'] = count($attachmentIDs);
+      }
 
-      $caseActivities[$caseActivityId]
-        = self::addCaseActivityLinks($caseID, $contactID, $userID, $context, $dao, $caseActivities[$caseActivityId]);
+      $caseActivities[$caseActivityId]['links'] = self::addCaseActivityLinks($caseID, $contactID, $userID, $context, $dao);
     }
 
     $caseActivitiesDT = array();
@@ -1173,11 +1098,11 @@ SELECT case_status.label AS case_status, status_id, civicrm_case_type.title AS c
    * @param int $userID
    * @param string $context
    * @param \CRM_Core_DAO $dao
-   * @param array $caseActivity
    *
-   * @return array caseActivity
+   * @return string
+   *   HTML formatted Link
    */
-  public static function addCaseActivityLinks($caseID, $contactID, $userID, $context, $dao, $caseActivity) {
+  private static function addCaseActivityLinks($caseID, $contactID, $userID, $context, $dao) {
     // FIXME: Why are we not using CRM_Core_Action for these links? This is too much manual work and likely to get out-of-sync with core markup.
     $caseActivityId = $dao->id;
     $allowView = self::checkPermission($caseActivityId, 'view', $dao->activity_type_id, $userID);
@@ -1221,7 +1146,6 @@ SELECT case_status.label AS case_status, status_id, civicrm_case_type.title AS c
     }
     elseif (!$caseDeleted) {
       $url = ' <a ' . $css . ' href="' . $restoreUrl . $additionalUrl . '">' . ts('Restore') . '</a>';
-      $caseActivity['status_id'] = $caseActivity['status_id'] . '<br /> (deleted)';
     }
 
     //check for operations.
@@ -1233,12 +1157,10 @@ SELECT case_status.label AS case_status, status_id, civicrm_case_type.title AS c
     }
     // if there are file attachments we will return how many and, if only one, add a link to it
     if (!empty($dao->attachment_ids)) {
-      $attachmentIDs = array_unique(explode(',', $dao->attachment_ids));
-      $caseActivity['no_attachments'] = count($attachmentIDs);
       $url .= implode(' ', CRM_Core_BAO_File::paperIconAttachment('civicrm_activity', $caseActivityId));
     }
-    $caseActivity['links'] = $url;
-    return $caseActivity;
+
+    return $url;
   }
 
   /**
@@ -1621,18 +1543,19 @@ SELECT case_status.label AS case_status, status_id, civicrm_case_type.title AS c
  AND civicrm_case.is_deleted     = {$cases['case_deleted']}";
 
     $query = self::getCaseActivityQuery($type, $userID, $condition);
+    $activityTypes = CRM_Activity_BAO_Activity::buildOptions('activity_type_id');
 
     $res = CRM_Core_DAO::executeQuery($query);
 
     $activityInfo = array();
     while ($res->fetch()) {
       if ($type == 'upcoming') {
-        $activityInfo[$res->case_id]['date'] = $res->case_scheduled_activity_date;
-        $activityInfo[$res->case_id]['type'] = $res->case_scheduled_activity_type;
+        $activityInfo[$res->case_id]['date'] = $res->activity_date_time;
+        $activityInfo[$res->case_id]['type'] = CRM_Utils_Array::value($res->activity_type_id, $activityTypes);
       }
       else {
-        $activityInfo[$res->case_id]['date'] = $res->case_recent_activity_date;
-        $activityInfo[$res->case_id]['type'] = $res->case_recent_activity_type;
+        $activityInfo[$res->case_id]['date'] = $res->activity_date_time;
+        $activityInfo[$res->case_id]['type'] = CRM_Utils_Array::value($res->activity_type_id, $activityTypes);
       }
     }
 
@@ -2750,9 +2673,7 @@ WHERE id IN (' . implode(',', $copiedActivityIds) . ')';
       //allow edit operation.
       $allowEditNames = array('Open Case');
 
-      if (CRM_Core_Permission::check('edit inbound email basic information') ||
-        CRM_Core_Permission::check('edit inbound email basic information and content')
-      ) {
+      if (CRM_Activity_BAO_Activity::checkEditInboundEmailsPermissions()) {
         $allowEditNames[] = 'Inbound Email';
       }
 
@@ -3051,8 +2972,8 @@ WHERE id IN (' . implode(',', $copiedActivityIds) . ')';
  AS SELECT ca.case_id, a.id, a.activity_date_time, a.status_id, a.activity_type_id
  FROM civicrm_case_activity ca
  INNER JOIN civicrm_activity a ON ca.activity_id=a.id
- WHERE a.activity_date_time =
-(SELECT b.activity_date_time FROM civicrm_case_activity bca
+ WHERE a.id =
+(SELECT b.id FROM civicrm_case_activity bca
  INNER JOIN civicrm_activity b ON bca.activity_id=b.id
  WHERE b.activity_date_time <= DATE_ADD( NOW(), INTERVAL 14 DAY )
  AND b.is_current_revision = 1 AND b.is_deleted=0 AND b.status_id = $scheduled_id
@@ -3064,8 +2985,8 @@ WHERE id IN (' . implode(',', $copiedActivityIds) . ')';
  AS SELECT ca.case_id, a.id, a.activity_date_time, a.status_id, a.activity_type_id
  FROM civicrm_case_activity ca
  INNER JOIN civicrm_activity a ON ca.activity_id=a.id
- WHERE a.activity_date_time =
-(SELECT b.activity_date_time FROM civicrm_case_activity bca
+ WHERE a.id =
+(SELECT b.id FROM civicrm_case_activity bca
  INNER JOIN civicrm_activity b ON bca.activity_id=b.id
  WHERE b.activity_date_time >= DATE_SUB( NOW(), INTERVAL 14 DAY )
  AND b.is_current_revision = 1 AND b.is_deleted=0 AND b.status_id <> $scheduled_id
diff --git a/civicrm/CRM/Case/BAO/CaseContact.php b/civicrm/CRM/Case/BAO/CaseContact.php
index a8cfcdbb028038bd79bbb6a98b6f3881a7800a16..9d8a3955203d2090081e0d220693daca686d120a 100644
--- a/civicrm/CRM/Case/BAO/CaseContact.php
+++ b/civicrm/CRM/Case/BAO/CaseContact.php
@@ -45,10 +45,15 @@ class CRM_Case_BAO_CaseContact extends CRM_Case_DAO_CaseContact {
    * @return CRM_Case_BAO_CaseContact
    */
   public static function create($params) {
+    $hook = empty($params['id']) ? 'create' : 'edit';
+    CRM_Utils_Hook::pre($hook, 'CaseContact', CRM_Utils_Array::value('id', $params), $params);
+
     $caseContact = new self();
     $caseContact->copyValues($params);
     $caseContact->save();
 
+    CRM_Utils_Hook::post($hook, 'CaseContact', $caseContact->id, $caseContact);
+
     // add to recently viewed
     $caseType = CRM_Case_BAO_Case::getCaseType($caseContact->case_id);
     $url = CRM_Utils_System::url('civicrm/contact/view/case',
diff --git a/civicrm/CRM/Case/DAO/Case.php b/civicrm/CRM/Case/DAO/Case.php
index 2405fa06e4b307ea94ddc09f1d9d4f03db1d23c1..2323c780c439bdc4c44478250e2aa4499dbe8f82 100644
--- a/civicrm/CRM/Case/DAO/Case.php
+++ b/civicrm/CRM/Case/DAO/Case.php
@@ -135,8 +135,6 @@ class CRM_Case_DAO_Case extends CRM_Core_DAO {
           'required' => TRUE,
           'import' => TRUE,
           'where' => 'civicrm_case.id',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_case',
           'entity' => 'Case',
@@ -151,8 +149,6 @@ class CRM_Case_DAO_Case extends CRM_Core_DAO {
           'required' => TRUE,
           'import' => TRUE,
           'where' => 'civicrm_case.case_type_id',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => FALSE,
           'table_name' => 'civicrm_case',
           'entity' => 'Case',
@@ -177,8 +173,6 @@ class CRM_Case_DAO_Case extends CRM_Core_DAO {
           'size' => CRM_Utils_Type::HUGE,
           'import' => TRUE,
           'where' => 'civicrm_case.subject',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_case',
           'entity' => 'Case',
@@ -195,8 +189,6 @@ class CRM_Case_DAO_Case extends CRM_Core_DAO {
           'description' => ts('Date on which given case starts.'),
           'import' => TRUE,
           'where' => 'civicrm_case.start_date',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_case',
           'entity' => 'Case',
@@ -214,8 +206,6 @@ class CRM_Case_DAO_Case extends CRM_Core_DAO {
           'description' => ts('Date on which given case ends.'),
           'import' => TRUE,
           'where' => 'civicrm_case.end_date',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_case',
           'entity' => 'Case',
@@ -233,6 +223,7 @@ class CRM_Case_DAO_Case extends CRM_Core_DAO {
           'description' => ts('Details about the meeting (agenda, notes, etc).'),
           'rows' => 8,
           'cols' => 60,
+          'where' => 'civicrm_case.details',
           'table_name' => 'civicrm_case',
           'entity' => 'Case',
           'bao' => 'CRM_Case_BAO_Case',
@@ -249,8 +240,6 @@ class CRM_Case_DAO_Case extends CRM_Core_DAO {
           'required' => TRUE,
           'import' => TRUE,
           'where' => 'civicrm_case.status_id',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => FALSE,
           'table_name' => 'civicrm_case',
           'entity' => 'Case',
@@ -270,8 +259,6 @@ class CRM_Case_DAO_Case extends CRM_Core_DAO {
           'title' => ts('Case is in the Trash'),
           'import' => TRUE,
           'where' => 'civicrm_case.is_deleted',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'default' => '0',
           'table_name' => 'civicrm_case',
@@ -285,10 +272,8 @@ class CRM_Case_DAO_Case extends CRM_Core_DAO {
           'title' => ts('Created Date'),
           'description' => ts('When was the case was created.'),
           'required' => FALSE,
-          'export' => TRUE,
           'where' => 'civicrm_case.created_date',
-          'headerPattern' => '',
-          'dataPattern' => '',
+          'export' => TRUE,
           'default' => 'NULL',
           'table_name' => 'civicrm_case',
           'entity' => 'Case',
@@ -301,10 +286,8 @@ class CRM_Case_DAO_Case extends CRM_Core_DAO {
           'title' => ts('Modified Date'),
           'description' => ts('When was the case (or closely related entity) was created or modified or deleted.'),
           'required' => FALSE,
-          'export' => TRUE,
           'where' => 'civicrm_case.modified_date',
-          'headerPattern' => '',
-          'dataPattern' => '',
+          'export' => TRUE,
           'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
           'table_name' => 'civicrm_case',
           'entity' => 'Case',
diff --git a/civicrm/CRM/Case/DAO/CaseActivity.php b/civicrm/CRM/Case/DAO/CaseActivity.php
index f941d5cdd2667bfe62e2052322771e7b681186b0..e6a9999b40b1feef9161d7d30dfd9fd68ce098e4 100644
--- a/civicrm/CRM/Case/DAO/CaseActivity.php
+++ b/civicrm/CRM/Case/DAO/CaseActivity.php
@@ -87,6 +87,7 @@ class CRM_Case_DAO_CaseActivity extends CRM_Core_DAO {
           'title' => ts('Case Activity ID'),
           'description' => ts('Unique case-activity association id'),
           'required' => TRUE,
+          'where' => 'civicrm_case_activity.id',
           'table_name' => 'civicrm_case_activity',
           'entity' => 'CaseActivity',
           'bao' => 'CRM_Case_DAO_CaseActivity',
@@ -98,6 +99,7 @@ class CRM_Case_DAO_CaseActivity extends CRM_Core_DAO {
           'title' => ts('Case'),
           'description' => ts('Case ID of case-activity association.'),
           'required' => TRUE,
+          'where' => 'civicrm_case_activity.case_id',
           'table_name' => 'civicrm_case_activity',
           'entity' => 'CaseActivity',
           'bao' => 'CRM_Case_DAO_CaseActivity',
@@ -110,6 +112,7 @@ class CRM_Case_DAO_CaseActivity extends CRM_Core_DAO {
           'title' => ts('Activity ID'),
           'description' => ts('Activity ID of case-activity association.'),
           'required' => TRUE,
+          'where' => 'civicrm_case_activity.activity_id',
           'table_name' => 'civicrm_case_activity',
           'entity' => 'CaseActivity',
           'bao' => 'CRM_Case_DAO_CaseActivity',
diff --git a/civicrm/CRM/Case/DAO/CaseContact.php b/civicrm/CRM/Case/DAO/CaseContact.php
index 641b5e5ae5067950cca938a939215d66a33c477f..40b3e158cfcdc66799e85495a0678d6080d3fb6f 100644
--- a/civicrm/CRM/Case/DAO/CaseContact.php
+++ b/civicrm/CRM/Case/DAO/CaseContact.php
@@ -87,6 +87,7 @@ class CRM_Case_DAO_CaseContact extends CRM_Core_DAO {
           'title' => ts('Case Contact ID'),
           'description' => ts('Unique case-contact association id'),
           'required' => TRUE,
+          'where' => 'civicrm_case_contact.id',
           'table_name' => 'civicrm_case_contact',
           'entity' => 'CaseContact',
           'bao' => 'CRM_Case_BAO_CaseContact',
@@ -98,6 +99,7 @@ class CRM_Case_DAO_CaseContact extends CRM_Core_DAO {
           'title' => ts('Case'),
           'description' => ts('Case ID of case-contact association.'),
           'required' => TRUE,
+          'where' => 'civicrm_case_contact.case_id',
           'table_name' => 'civicrm_case_contact',
           'entity' => 'CaseContact',
           'bao' => 'CRM_Case_BAO_CaseContact',
@@ -110,6 +112,7 @@ class CRM_Case_DAO_CaseContact extends CRM_Core_DAO {
           'title' => ts('Contact ID'),
           'description' => ts('Contact ID of contact record given case belongs to.'),
           'required' => TRUE,
+          'where' => 'civicrm_case_contact.contact_id',
           'table_name' => 'civicrm_case_contact',
           'entity' => 'CaseContact',
           'bao' => 'CRM_Case_BAO_CaseContact',
diff --git a/civicrm/CRM/Case/DAO/CaseType.php b/civicrm/CRM/Case/DAO/CaseType.php
index f187f9d650a00092e1c8d3ce145ff6c1f1ab5e4a..3a0b59404e20b7f17b5c2be27388404c76776a42 100644
--- a/civicrm/CRM/Case/DAO/CaseType.php
+++ b/civicrm/CRM/Case/DAO/CaseType.php
@@ -106,6 +106,7 @@ class CRM_Case_DAO_CaseType extends CRM_Core_DAO {
           'title' => ts('Case Type ID'),
           'description' => ts('Autoincremented type id'),
           'required' => TRUE,
+          'where' => 'civicrm_case_type.id',
           'table_name' => 'civicrm_case_type',
           'entity' => 'CaseType',
           'bao' => 'CRM_Case_BAO_CaseType',
@@ -119,6 +120,7 @@ class CRM_Case_DAO_CaseType extends CRM_Core_DAO {
           'required' => TRUE,
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_case_type.name',
           'table_name' => 'civicrm_case_type',
           'entity' => 'CaseType',
           'bao' => 'CRM_Case_BAO_CaseType',
@@ -132,6 +134,7 @@ class CRM_Case_DAO_CaseType extends CRM_Core_DAO {
           'required' => TRUE,
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_case_type.title',
           'table_name' => 'civicrm_case_type',
           'entity' => 'CaseType',
           'bao' => 'CRM_Case_BAO_CaseType',
@@ -144,6 +147,7 @@ class CRM_Case_DAO_CaseType extends CRM_Core_DAO {
           'description' => ts('Description of the Case Type'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_case_type.description',
           'table_name' => 'civicrm_case_type',
           'entity' => 'CaseType',
           'bao' => 'CRM_Case_BAO_CaseType',
@@ -154,6 +158,7 @@ class CRM_Case_DAO_CaseType extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Case Type Is Active'),
           'description' => ts('Is this entry active?'),
+          'where' => 'civicrm_case_type.is_active',
           'table_name' => 'civicrm_case_type',
           'entity' => 'CaseType',
           'bao' => 'CRM_Case_BAO_CaseType',
@@ -164,6 +169,7 @@ class CRM_Case_DAO_CaseType extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Case Type Is Reserved'),
           'description' => ts('Is this case type a predefined system type?'),
+          'where' => 'civicrm_case_type.is_reserved',
           'table_name' => 'civicrm_case_type',
           'entity' => 'CaseType',
           'bao' => 'CRM_Case_BAO_CaseType',
@@ -175,6 +181,7 @@ class CRM_Case_DAO_CaseType extends CRM_Core_DAO {
           'title' => ts('Order'),
           'description' => ts('Ordering of the case types'),
           'required' => TRUE,
+          'where' => 'civicrm_case_type.weight',
           'default' => '1',
           'table_name' => 'civicrm_case_type',
           'entity' => 'CaseType',
@@ -186,6 +193,7 @@ class CRM_Case_DAO_CaseType extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BLOB,
           'title' => ts('Case Type Definition'),
           'description' => ts('xml definition of case type'),
+          'where' => 'civicrm_case_type.definition',
           'table_name' => 'civicrm_case_type',
           'entity' => 'CaseType',
           'bao' => 'CRM_Case_BAO_CaseType',
diff --git a/civicrm/CRM/Case/Selector/Search.php b/civicrm/CRM/Case/Selector/Search.php
index 55c396e60ee1260aded7a33a1f24b1c853e79f57..8d63a8ea2923221bb55f0d399c4bdb65c2e1f959 100644
--- a/civicrm/CRM/Case/Selector/Search.php
+++ b/civicrm/CRM/Case/Selector/Search.php
@@ -322,7 +322,7 @@ class CRM_Case_Selector_Search extends CRM_Core_Selector_Base {
       $isDeleted = FALSE;
       if ($result->case_deleted) {
         $isDeleted = TRUE;
-        $row['case_status_id'] = empty($row['case_status_id']) ? "" : $row['case_status_id'] . '<br />(deleted)';
+        $row['case_status_id'] = empty($row['case_status_id']) ? "" : $row['case_status_id'] . '<br />' . ts('(deleted)');
       }
 
       $scheduledInfo['case_id'][] = $result->case_id;
diff --git a/civicrm/CRM/Contact/BAO/Contact.php b/civicrm/CRM/Contact/BAO/Contact.php
index f1fb6929d82ea39bbe3ff8818f790d080fecfe17..7280f6d5c75bd9aace4f860d8189a9743130c690 100644
--- a/civicrm/CRM/Contact/BAO/Contact.php
+++ b/civicrm/CRM/Contact/BAO/Contact.php
@@ -272,6 +272,10 @@ class CRM_Contact_BAO_Contact extends CRM_Contact_DAO_Contact {
       return $contact;
     }
 
+    if (!empty($params['contact_id']) && empty($params['contact_type'])) {
+      $params['contact_type'] = self::getContactType($params['contact_id']);
+    }
+
     $isEdit = TRUE;
     if ($invokeHooks) {
       if (!empty($params['contact_id'])) {
@@ -2945,7 +2949,6 @@ AND       civicrm_openid.is_primary = 1";
       while ($blockDAO->fetch()) {
         $locBlockIds[$name][] = $blockDAO->id;
       }
-      $blockDAO->free();
     }
 
     return $locBlockIds;
@@ -3556,7 +3559,6 @@ LEFT JOIN civicrm_address ON ( civicrm_address.contact_id = civicrm_contact.id )
       }
     }
     CRM_Utils_Hook::post('delete', $type, $id, $obj);
-    $obj->free();
     return TRUE;
   }
 
diff --git a/civicrm/CRM/Contact/BAO/Contact/Location.php b/civicrm/CRM/Contact/BAO/Contact/Location.php
index 8e7a12f373c6887e4269a3cd0c7aca4fc8a56195..4d7c24eaa2330718a47e11253a81a9d96d7c659d 100644
--- a/civicrm/CRM/Contact/BAO/Contact/Location.php
+++ b/civicrm/CRM/Contact/BAO/Contact/Location.php
@@ -45,21 +45,34 @@ class CRM_Contact_BAO_Contact_Location {
    *   Array of display_name, email, location type and location id if found, or (null,null,null, null)
    */
   public static function getEmailDetails($id, $isPrimary = TRUE, $locationTypeID = NULL) {
-    $params = [
-      'location_type_id' => $locationTypeID,
+    $params = array(
       'contact_id' => $id,
-      'return' => ['contact_id.display_name', 'email', 'location_type_id', 'id'],
-    ];
+      'return' => array('display_name', 'email.email'),
+      'api.Email.get' => array(
+        'location_type_id' => $locationTypeID,
+        'sequential' => 0,
+        'return' => array('email', 'location_type_id', 'id'),
+      ),
+    );
     if ($isPrimary) {
-      $params['is_primary'] = 1;
+      $params['api.Email.get']['is_primary'] = 1;
     }
-    $emails = civicrm_api3('Email', 'get', $params);
 
-    if ($emails['count'] > 0) {
-      $email = reset($emails['values']);
-      return [$email['contact_id.display_name'], $email['email'], $email['location_type_id'], $email['id']];
+    $contacts = civicrm_api3('Contact', 'get', $params);
+    if ($contacts['count'] > 0) {
+      $contact = reset($contacts['values']);
+      if ($contact['api.Email.get']['count'] > 0) {
+        $email = reset($contact['api.Email.get']['values']);
+      }
     }
-    return [NULL, NULL, NULL, NULL];
+    $returnParams = array(
+      (isset($contact['display_name'])) ? $contact['display_name'] : NULL,
+      (isset($email['email'])) ? $email['email'] : NULL,
+      (isset($email['location_type_id'])) ? $email['location_type_id'] : NULL,
+      (isset($email['id'])) ? $email['id'] : NULL,
+    );
+
+    return $returnParams;
   }
 
   /**
diff --git a/civicrm/CRM/Contact/BAO/Contact/Utils.php b/civicrm/CRM/Contact/BAO/Contact/Utils.php
index 2b3f0879133a708bb6380fb22cc9f9d70deb0031..81a93b376c9fd753645f0214df1d99d8f774b351 100644
--- a/civicrm/CRM/Contact/BAO/Contact/Utils.php
+++ b/civicrm/CRM/Contact/BAO/Contact/Utils.php
@@ -374,7 +374,6 @@ UNION
         $ids['relationship'] = $relationship->id;
         CRM_Contact_BAO_Relationship::setIsActive($relationship->id, TRUE);
       }
-      $relationship->free();
     }
 
     //need to handle related meberships. CRM-3792
@@ -457,7 +456,6 @@ WHERE id={$contactId}; ";
             CRM_Core_Action::DELETE
           );
         }
-        $relationship->free();
       }
     }
   }
@@ -799,7 +797,6 @@ INNER JOIN civicrm_contact contact_target ON ( contact_target.id = act.contact_i
           $contactDetails[$contact->componentId][$property] = $contact->$property;
         }
       }
-      $contact->free();
     }
 
     return $contactDetails;
diff --git a/civicrm/CRM/Contact/BAO/ContactType.php b/civicrm/CRM/Contact/BAO/ContactType.php
index 897fcbc6f886bd53afd154d294fde35f2abeba4e..b0d25258ef6d60ea2280d4a4781cff46659651c7 100644
--- a/civicrm/CRM/Contact/BAO/ContactType.php
+++ b/civicrm/CRM/Contact/BAO/ContactType.php
@@ -785,7 +785,6 @@ WHERE name = %1";
 
       $customDataCount = CRM_Core_DAO::singleValueQuery($sql);
       if (!empty($customDataCount)) {
-        $dao->free();
         return TRUE;
       }
     }
diff --git a/civicrm/CRM/Contact/BAO/Group.php b/civicrm/CRM/Contact/BAO/Group.php
index 94d8852e9ab847aa9f1329b955304e7c803410aa..e7ec4a8de8226d1b8056c786ec29babdd1824da4 100644
--- a/civicrm/CRM/Contact/BAO/Group.php
+++ b/civicrm/CRM/Contact/BAO/Group.php
@@ -1112,7 +1112,6 @@ WHERE  id IN $groupIdString
         ];
       }
     }
-    $dao->free();
 
     $hierarchy = [];
     for ($i = 0; $i < count($roots); $i++) {
diff --git a/civicrm/CRM/Contact/BAO/Query.php b/civicrm/CRM/Contact/BAO/Query.php
index e5f9b4c6048bb034e2715314bcacf8551eb933f9..7136a7cc32347b63dd33a443cf9511a166808cd4 100644
--- a/civicrm/CRM/Contact/BAO/Query.php
+++ b/civicrm/CRM/Contact/BAO/Query.php
@@ -2709,7 +2709,7 @@ class CRM_Contact_BAO_Query {
       case 'civicrm_worldregion':
         // We can be sure from the calling function that country will already be joined in.
         // we really don't need world_region - we could use a pseudoconstant for it.
-        return "$side JOIN civicrm_worldregion ON civicrm_country.region_id = civicrm_worldregion.id ";
+        return " $side JOIN civicrm_worldregion ON civicrm_country.region_id = civicrm_worldregion.id ";
 
       case 'civicrm_location_type':
         return " $side JOIN civicrm_location_type ON civicrm_address.location_type_id = civicrm_location_type.id ";
@@ -4952,7 +4952,7 @@ civicrm_relationship.start_date > {$today}
   public function alphabetQuery() {
     $sqlParts = $this->getSearchSQLParts(NULL, NULL, NULL, FALSE, FALSE, TRUE);
     $query = "SELECT DISTINCT LEFT(contact_a.sort_name, 1) as sort_name
-      {$this->_simpleFromClause}
+      {$sqlParts['from']}
       {$sqlParts['where']}
       {$sqlParts['having']}
       GROUP BY sort_name
@@ -5681,10 +5681,8 @@ civicrm_relationship.start_date > {$today}
     }
     else {
       // create temp table with contact ids
-      $tableName = CRM_Core_DAO::createTempTableName('civicrm_transform', TRUE);
 
-      $sql = "CREATE TEMPORARY TABLE $tableName ( contact_id int primary key) ENGINE=HEAP";
-      CRM_Core_DAO::executeQuery($sql);
+      $tableName = CRM_Utils_SQL_TempTable::build()->createWithColumns('contact_id int primary key')->setMemory(TRUE)->getName();
 
       $sql = "
 REPLACE INTO $tableName ( contact_id )
diff --git a/civicrm/CRM/Contact/BAO/Relationship.php b/civicrm/CRM/Contact/BAO/Relationship.php
index d5c76f345e840558fabe62e1d2b7fdfcba1891af..e271d16cb1332e6dc4d7b7d60e7c2ba4cdba2f64 100644
--- a/civicrm/CRM/Contact/BAO/Relationship.php
+++ b/civicrm/CRM/Contact/BAO/Relationship.php
@@ -344,8 +344,6 @@ class CRM_Contact_BAO_Relationship extends CRM_Contact_DAO_Relationship {
       CRM_Core_BAO_CustomValueTable::store($params['custom'], 'civicrm_relationship', $relationship->id);
     }
 
-    $relationship->free();
-
     CRM_Utils_Hook::post($hook, 'Relationship', $relationship->id, $relationship);
 
     return $relationship;
@@ -959,11 +957,9 @@ WHERE  relationship_type_id = " . CRM_Utils_Type::escape($type, 'Integer');
       // Check whether the custom field values are identical.
       $result = self::checkDuplicateCustomFields($params, $relationship->id);
       if ($result) {
-        $relationship->free();
         return TRUE;
       }
     }
-    $relationship->free();
     return FALSE;
   }
 
@@ -1450,7 +1446,6 @@ LEFT JOIN  civicrm_country ON (civicrm_address.country_id = civicrm_country.id)
         }
       }
 
-      $relationship->free();
       return $values;
     }
   }
diff --git a/civicrm/CRM/Contact/BAO/RelationshipType.php b/civicrm/CRM/Contact/BAO/RelationshipType.php
index e229a03ea5718ee40692998d53cc479b0a43f18c..bc11bf2f0248ec9b041eae625072a1c6c0fc8266 100644
--- a/civicrm/CRM/Contact/BAO/RelationshipType.php
+++ b/civicrm/CRM/Contact/BAO/RelationshipType.php
@@ -54,7 +54,6 @@ class CRM_Contact_BAO_RelationshipType extends CRM_Contact_DAO_RelationshipType
     $relationshipType->copyValues($params);
     if ($relationshipType->find(TRUE)) {
       CRM_Core_DAO::storeValues($relationshipType, $defaults);
-      $relationshipType->free();
       return $relationshipType;
     }
     return NULL;
diff --git a/civicrm/CRM/Contact/DAO/ACLContactCache.php b/civicrm/CRM/Contact/DAO/ACLContactCache.php
index b1c08f0f3fd085053c809e379fc3ac4fd59966a8..456ca86348653032423cf105c10a301523e67c5f 100644
--- a/civicrm/CRM/Contact/DAO/ACLContactCache.php
+++ b/civicrm/CRM/Contact/DAO/ACLContactCache.php
@@ -93,6 +93,7 @@ class CRM_Contact_DAO_ACLContactCache extends CRM_Core_DAO {
           'title' => ts('ACL Contact Cache ID'),
           'description' => ts('primary key'),
           'required' => TRUE,
+          'where' => 'civicrm_acl_contact_cache.id',
           'table_name' => 'civicrm_acl_contact_cache',
           'entity' => 'ACLContactCache',
           'bao' => 'CRM_Contact_DAO_ACLContactCache',
@@ -103,6 +104,7 @@ class CRM_Contact_DAO_ACLContactCache extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Contact ID'),
           'description' => ts('FK to civicrm_contact (could be null for anon user)'),
+          'where' => 'civicrm_acl_contact_cache.user_id',
           'table_name' => 'civicrm_acl_contact_cache',
           'entity' => 'ACLContactCache',
           'bao' => 'CRM_Contact_DAO_ACLContactCache',
@@ -114,6 +116,7 @@ class CRM_Contact_DAO_ACLContactCache extends CRM_Core_DAO {
           'title' => ts('Contact ID'),
           'description' => ts('FK to civicrm_contact'),
           'required' => TRUE,
+          'where' => 'civicrm_acl_contact_cache.contact_id',
           'table_name' => 'civicrm_acl_contact_cache',
           'entity' => 'ACLContactCache',
           'bao' => 'CRM_Contact_DAO_ACLContactCache',
@@ -128,6 +131,7 @@ class CRM_Contact_DAO_ACLContactCache extends CRM_Core_DAO {
           'required' => TRUE,
           'maxlength' => 8,
           'size' => CRM_Utils_Type::EIGHT,
+          'where' => 'civicrm_acl_contact_cache.operation',
           'table_name' => 'civicrm_acl_contact_cache',
           'entity' => 'ACLContactCache',
           'bao' => 'CRM_Contact_DAO_ACLContactCache',
diff --git a/civicrm/CRM/Contact/DAO/Contact.php b/civicrm/CRM/Contact/DAO/Contact.php
index c5833d27b8653471a364563468b00e24e5e77327..736dffa2f7e561b904c286330d6b54026e1b4723 100644
--- a/civicrm/CRM/Contact/DAO/Contact.php
+++ b/civicrm/CRM/Contact/DAO/Contact.php
@@ -419,7 +419,6 @@ class CRM_Contact_DAO_Contact extends CRM_Core_DAO {
           'import' => TRUE,
           'where' => 'civicrm_contact.id',
           'headerPattern' => '/internal|contact?|id$/i',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_contact',
           'entity' => 'Contact',
@@ -433,10 +432,8 @@ class CRM_Contact_DAO_Contact extends CRM_Core_DAO {
           'description' => ts('Type of Contact.'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
-          'export' => TRUE,
           'where' => 'civicrm_contact.contact_type',
-          'headerPattern' => '',
-          'dataPattern' => '',
+          'export' => TRUE,
           'table_name' => 'civicrm_contact',
           'entity' => 'Contact',
           'bao' => 'CRM_Contact_BAO_Contact',
@@ -461,7 +458,6 @@ class CRM_Contact_DAO_Contact extends CRM_Core_DAO {
           'import' => TRUE,
           'where' => 'civicrm_contact.contact_sub_type',
           'headerPattern' => '/C(ontact )?(subtype|sub-type|sub type)/i',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_contact',
           'entity' => 'Contact',
@@ -576,8 +572,6 @@ class CRM_Contact_DAO_Contact extends CRM_Core_DAO {
           'required' => TRUE,
           'import' => TRUE,
           'where' => 'civicrm_contact.is_opt_out',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'default' => '0',
           'table_name' => 'civicrm_contact',
@@ -636,10 +630,8 @@ class CRM_Contact_DAO_Contact extends CRM_Core_DAO {
           'description' => ts('Name used for sorting different contact types'),
           'maxlength' => 128,
           'size' => 30,
-          'export' => TRUE,
           'where' => 'civicrm_contact.sort_name',
-          'headerPattern' => '',
-          'dataPattern' => '',
+          'export' => TRUE,
           'table_name' => 'civicrm_contact',
           'entity' => 'Contact',
           'bao' => 'CRM_Contact_BAO_Contact',
@@ -655,10 +647,8 @@ class CRM_Contact_DAO_Contact extends CRM_Core_DAO {
           'description' => ts('Formatted name representing preferred format for display/print/other output.'),
           'maxlength' => 128,
           'size' => 30,
-          'export' => TRUE,
           'where' => 'civicrm_contact.display_name',
-          'headerPattern' => '',
-          'dataPattern' => '',
+          'export' => TRUE,
           'table_name' => 'civicrm_contact',
           'entity' => 'Contact',
           'bao' => 'CRM_Contact_BAO_Contact',
@@ -697,7 +687,6 @@ class CRM_Contact_DAO_Contact extends CRM_Core_DAO {
           'import' => TRUE,
           'where' => 'civicrm_contact.legal_name',
           'headerPattern' => '/^legal|(l(egal\s)?name)$/i',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_contact',
           'entity' => 'Contact',
@@ -714,8 +703,6 @@ class CRM_Contact_DAO_Contact extends CRM_Core_DAO {
           'description' => ts('optional URL for preferred image (photo, logo, etc.) to display for this contact.'),
           'import' => TRUE,
           'where' => 'civicrm_contact.image_URL',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_contact',
           'entity' => 'Contact',
@@ -760,7 +747,6 @@ class CRM_Contact_DAO_Contact extends CRM_Core_DAO {
           'import' => TRUE,
           'where' => 'civicrm_contact.preferred_language',
           'headerPattern' => '/^lang/i',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_contact',
           'entity' => 'Contact',
@@ -785,7 +771,6 @@ class CRM_Contact_DAO_Contact extends CRM_Core_DAO {
           'import' => TRUE,
           'where' => 'civicrm_contact.preferred_mail_format',
           'headerPattern' => '/^p(ref\w*\s)?m(ail\s)?f(orm\w*)$/i',
-          'dataPattern' => '',
           'export' => TRUE,
           'default' => 'Both',
           'table_name' => 'civicrm_contact',
@@ -806,10 +791,8 @@ class CRM_Contact_DAO_Contact extends CRM_Core_DAO {
           'description' => ts('Key for validating requests related to this contact.'),
           'maxlength' => 32,
           'size' => CRM_Utils_Type::MEDIUM,
-          'export' => TRUE,
           'where' => 'civicrm_contact.hash',
-          'headerPattern' => '',
-          'dataPattern' => '',
+          'export' => TRUE,
           'table_name' => 'civicrm_contact',
           'entity' => 'Contact',
           'bao' => 'CRM_Contact_BAO_Contact',
@@ -822,6 +805,7 @@ class CRM_Contact_DAO_Contact extends CRM_Core_DAO {
           'description' => ts('API Key for validating requests related to this contact.'),
           'maxlength' => 32,
           'size' => CRM_Utils_Type::MEDIUM,
+          'where' => 'civicrm_contact.api_key',
           'table_name' => 'civicrm_contact',
           'entity' => 'Contact',
           'bao' => 'CRM_Contact_BAO_Contact',
@@ -837,7 +821,6 @@ class CRM_Contact_DAO_Contact extends CRM_Core_DAO {
           'import' => TRUE,
           'where' => 'civicrm_contact.source',
           'headerPattern' => '/(C(ontact\s)?Source)$/i',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_contact',
           'entity' => 'Contact',
@@ -961,7 +944,6 @@ class CRM_Contact_DAO_Contact extends CRM_Core_DAO {
           'import' => TRUE,
           'where' => 'civicrm_contact.formal_title',
           'headerPattern' => '/^title/i',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_contact',
           'entity' => 'Contact',
@@ -976,10 +958,8 @@ class CRM_Contact_DAO_Contact extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Communication Style'),
           'description' => ts('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',
-          'headerPattern' => '',
-          'dataPattern' => '',
+          'export' => TRUE,
           'table_name' => 'civicrm_contact',
           'entity' => 'Contact',
           'bao' => 'CRM_Contact_BAO_Contact',
@@ -997,10 +977,8 @@ class CRM_Contact_DAO_Contact extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Email Greeting ID'),
           'description' => ts('FK to civicrm_option_value.id, that has to be valid registered Email Greeting.'),
-          'export' => TRUE,
           'where' => 'civicrm_contact.email_greeting_id',
-          'headerPattern' => '',
-          'dataPattern' => '',
+          'export' => TRUE,
           'table_name' => 'civicrm_contact',
           'entity' => 'Contact',
           'bao' => 'CRM_Contact_BAO_Contact',
@@ -1019,8 +997,6 @@ class CRM_Contact_DAO_Contact extends CRM_Core_DAO {
           'size' => CRM_Utils_Type::HUGE,
           'import' => TRUE,
           'where' => 'civicrm_contact.email_greeting_custom',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => FALSE,
           'table_name' => 'civicrm_contact',
           'entity' => 'Contact',
@@ -1037,6 +1013,7 @@ class CRM_Contact_DAO_Contact extends CRM_Core_DAO {
           'description' => ts('Cache Email Greeting.'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_contact.email_greeting_display',
           'table_name' => 'civicrm_contact',
           'entity' => 'Contact',
           'bao' => 'CRM_Contact_BAO_Contact',
@@ -1050,10 +1027,8 @@ class CRM_Contact_DAO_Contact extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Postal Greeting ID'),
           'description' => ts('FK to civicrm_option_value.id, that has to be valid registered Postal Greeting.'),
-          'export' => TRUE,
           'where' => 'civicrm_contact.postal_greeting_id',
-          'headerPattern' => '',
-          'dataPattern' => '',
+          'export' => TRUE,
           'table_name' => 'civicrm_contact',
           'entity' => 'Contact',
           'bao' => 'CRM_Contact_BAO_Contact',
@@ -1075,8 +1050,6 @@ class CRM_Contact_DAO_Contact extends CRM_Core_DAO {
           'size' => CRM_Utils_Type::HUGE,
           'import' => TRUE,
           'where' => 'civicrm_contact.postal_greeting_custom',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => FALSE,
           'table_name' => 'civicrm_contact',
           'entity' => 'Contact',
@@ -1093,6 +1066,7 @@ class CRM_Contact_DAO_Contact extends CRM_Core_DAO {
           'description' => ts('Cache Postal greeting.'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_contact.postal_greeting_display',
           'table_name' => 'civicrm_contact',
           'entity' => 'Contact',
           'bao' => 'CRM_Contact_BAO_Contact',
@@ -1106,10 +1080,8 @@ class CRM_Contact_DAO_Contact extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Addressee ID'),
           'description' => ts('FK to civicrm_option_value.id, that has to be valid registered Addressee.'),
-          'export' => TRUE,
           'where' => 'civicrm_contact.addressee_id',
-          'headerPattern' => '',
-          'dataPattern' => '',
+          'export' => TRUE,
           'table_name' => 'civicrm_contact',
           'entity' => 'Contact',
           'bao' => 'CRM_Contact_BAO_Contact',
@@ -1128,8 +1100,6 @@ class CRM_Contact_DAO_Contact extends CRM_Core_DAO {
           'size' => CRM_Utils_Type::HUGE,
           'import' => TRUE,
           'where' => 'civicrm_contact.addressee_custom',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => FALSE,
           'table_name' => 'civicrm_contact',
           'entity' => 'Contact',
@@ -1146,6 +1116,7 @@ class CRM_Contact_DAO_Contact extends CRM_Core_DAO {
           'description' => ts('Cache Addressee.'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_contact.addressee_display',
           'table_name' => 'civicrm_contact',
           'entity' => 'Contact',
           'bao' => 'CRM_Contact_BAO_Contact',
@@ -1182,7 +1153,6 @@ class CRM_Contact_DAO_Contact extends CRM_Core_DAO {
           'import' => TRUE,
           'where' => 'civicrm_contact.gender_id',
           'headerPattern' => '/^gender$/i',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_contact',
           'entity' => 'Contact',
@@ -1222,7 +1192,6 @@ class CRM_Contact_DAO_Contact extends CRM_Core_DAO {
           'import' => TRUE,
           'where' => 'civicrm_contact.is_deceased',
           'headerPattern' => '/i(s\s)?d(eceased)$/i',
-          'dataPattern' => '',
           'export' => TRUE,
           'default' => '0',
           'table_name' => 'civicrm_contact',
@@ -1241,7 +1210,6 @@ class CRM_Contact_DAO_Contact extends CRM_Core_DAO {
           'import' => TRUE,
           'where' => 'civicrm_contact.deceased_date',
           'headerPattern' => '/^deceased|(d(eceased\s)?date)$/i',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_contact',
           'entity' => 'Contact',
@@ -1277,6 +1245,7 @@ class CRM_Contact_DAO_Contact extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Household Primary Contact ID'),
           'description' => ts('Optional FK to Primary Contact for this household.'),
+          'where' => 'civicrm_contact.primary_contact_id',
           'table_name' => 'civicrm_contact',
           'entity' => 'Contact',
           'bao' => 'CRM_Contact_BAO_Contact',
@@ -1316,7 +1285,6 @@ class CRM_Contact_DAO_Contact extends CRM_Core_DAO {
           'import' => TRUE,
           'where' => 'civicrm_contact.sic_code',
           'headerPattern' => '/^sic|(s(ic\s)?code)$/i',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_contact',
           'entity' => 'Contact',
@@ -1352,10 +1320,8 @@ class CRM_Contact_DAO_Contact extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Current Employer'),
           'description' => ts('OPTIONAL FK to civicrm_contact record.'),
-          'export' => TRUE,
           'where' => 'civicrm_contact.employer_id',
-          'headerPattern' => '',
-          'dataPattern' => '',
+          'export' => TRUE,
           'table_name' => 'civicrm_contact',
           'entity' => 'Contact',
           'bao' => 'CRM_Contact_BAO_Contact',
@@ -1370,10 +1336,8 @@ class CRM_Contact_DAO_Contact extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Contact is in Trash'),
           'required' => TRUE,
-          'export' => TRUE,
           'where' => 'civicrm_contact.is_deleted',
-          'headerPattern' => '',
-          'dataPattern' => '',
+          'export' => TRUE,
           'default' => '0',
           'table_name' => 'civicrm_contact',
           'entity' => 'Contact',
@@ -1389,10 +1353,8 @@ class CRM_Contact_DAO_Contact extends CRM_Core_DAO {
           'title' => ts('Created Date'),
           'description' => ts('When was the contact was created.'),
           'required' => FALSE,
-          'export' => TRUE,
           'where' => 'civicrm_contact.created_date',
-          'headerPattern' => '',
-          'dataPattern' => '',
+          'export' => TRUE,
           'default' => 'NULL',
           'table_name' => 'civicrm_contact',
           'entity' => 'Contact',
@@ -1405,10 +1367,8 @@ class CRM_Contact_DAO_Contact extends CRM_Core_DAO {
           'title' => ts('Modified Date'),
           'description' => ts('When was the contact (or closely related entity) was created or modified or deleted.'),
           'required' => FALSE,
-          'export' => TRUE,
           'where' => 'civicrm_contact.modified_date',
-          'headerPattern' => '',
-          'dataPattern' => '',
+          'export' => TRUE,
           'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
           'table_name' => 'civicrm_contact',
           'entity' => 'Contact',
diff --git a/civicrm/CRM/Contact/DAO/ContactType.php b/civicrm/CRM/Contact/DAO/ContactType.php
index db032d503fe6d0629eb42caf200e96d017497a74..f76bbaab4cf3acbc955f34b0b4c634c8acf92843 100644
--- a/civicrm/CRM/Contact/DAO/ContactType.php
+++ b/civicrm/CRM/Contact/DAO/ContactType.php
@@ -121,6 +121,7 @@ class CRM_Contact_DAO_ContactType extends CRM_Core_DAO {
           'title' => ts('Contact Type ID'),
           'description' => ts('Contact Type ID'),
           'required' => TRUE,
+          'where' => 'civicrm_contact_type.id',
           'table_name' => 'civicrm_contact_type',
           'entity' => 'ContactType',
           'bao' => 'CRM_Contact_BAO_ContactType',
@@ -133,6 +134,7 @@ class CRM_Contact_DAO_ContactType extends CRM_Core_DAO {
           'description' => ts('Internal name of Contact Type (or Subtype).'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_contact_type.name',
           'table_name' => 'civicrm_contact_type',
           'entity' => 'ContactType',
           'bao' => 'CRM_Contact_BAO_ContactType',
@@ -145,6 +147,7 @@ class CRM_Contact_DAO_ContactType extends CRM_Core_DAO {
           'description' => ts('localized Name of Contact Type.'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_contact_type.label',
           'table_name' => 'civicrm_contact_type',
           'entity' => 'ContactType',
           'bao' => 'CRM_Contact_BAO_ContactType',
@@ -157,6 +160,7 @@ class CRM_Contact_DAO_ContactType extends CRM_Core_DAO {
           'description' => ts('localized Optional verbose description of the type.'),
           'rows' => 2,
           'cols' => 60,
+          'where' => 'civicrm_contact_type.description',
           'table_name' => 'civicrm_contact_type',
           'entity' => 'ContactType',
           'bao' => 'CRM_Contact_BAO_ContactType',
@@ -172,6 +176,7 @@ class CRM_Contact_DAO_ContactType extends CRM_Core_DAO {
           'description' => ts('URL of image if any.'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_contact_type.image_URL',
           'table_name' => 'civicrm_contact_type',
           'entity' => 'ContactType',
           'bao' => 'CRM_Contact_BAO_ContactType',
@@ -182,6 +187,7 @@ class CRM_Contact_DAO_ContactType extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Contact Type Parent'),
           'description' => ts('Optional FK to parent contact type.'),
+          'where' => 'civicrm_contact_type.parent_id',
           'table_name' => 'civicrm_contact_type',
           'entity' => 'ContactType',
           'bao' => 'CRM_Contact_BAO_ContactType',
@@ -199,6 +205,7 @@ class CRM_Contact_DAO_ContactType extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Contact Type Is Active?'),
           'description' => ts('Is this entry active?'),
+          'where' => 'civicrm_contact_type.is_active',
           'table_name' => 'civicrm_contact_type',
           'entity' => 'ContactType',
           'bao' => 'CRM_Contact_BAO_ContactType',
@@ -209,6 +216,7 @@ class CRM_Contact_DAO_ContactType extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Contact Type is Reserved?'),
           'description' => ts('Is this contact type a predefined system type'),
+          'where' => 'civicrm_contact_type.is_reserved',
           'table_name' => 'civicrm_contact_type',
           'entity' => 'ContactType',
           'bao' => 'CRM_Contact_BAO_ContactType',
diff --git a/civicrm/CRM/Contact/DAO/DashboardContact.php b/civicrm/CRM/Contact/DAO/DashboardContact.php
index 8b354a2bb3d8dd0401c5750bb629b433af1fd4d3..4585ec169af047e4bcf0a2ed649140315aa33aab 100644
--- a/civicrm/CRM/Contact/DAO/DashboardContact.php
+++ b/civicrm/CRM/Contact/DAO/DashboardContact.php
@@ -105,6 +105,7 @@ class CRM_Contact_DAO_DashboardContact extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Dashboard Contact ID'),
           'required' => TRUE,
+          'where' => 'civicrm_dashboard_contact.id',
           'table_name' => 'civicrm_dashboard_contact',
           'entity' => 'DashboardContact',
           'bao' => 'CRM_Contact_BAO_DashboardContact',
@@ -116,6 +117,7 @@ class CRM_Contact_DAO_DashboardContact extends CRM_Core_DAO {
           'title' => ts('Dashboard'),
           'description' => ts('Dashboard ID'),
           'required' => TRUE,
+          'where' => 'civicrm_dashboard_contact.dashboard_id',
           'table_name' => 'civicrm_dashboard_contact',
           'entity' => 'DashboardContact',
           'bao' => 'CRM_Contact_BAO_DashboardContact',
@@ -128,6 +130,7 @@ class CRM_Contact_DAO_DashboardContact extends CRM_Core_DAO {
           'title' => ts('Dashboard Contact'),
           'description' => ts('Contact ID'),
           'required' => TRUE,
+          'where' => 'civicrm_dashboard_contact.contact_id',
           'table_name' => 'civicrm_dashboard_contact',
           'entity' => 'DashboardContact',
           'bao' => 'CRM_Contact_BAO_DashboardContact',
@@ -139,6 +142,7 @@ class CRM_Contact_DAO_DashboardContact extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Column No'),
           'description' => ts('column no for this widget'),
+          'where' => 'civicrm_dashboard_contact.column_no',
           'default' => '0',
           'table_name' => 'civicrm_dashboard_contact',
           'entity' => 'DashboardContact',
@@ -150,6 +154,7 @@ class CRM_Contact_DAO_DashboardContact extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Dashlet is Active?'),
           'description' => ts('Is this widget active?'),
+          'where' => 'civicrm_dashboard_contact.is_active',
           'default' => '0',
           'table_name' => 'civicrm_dashboard_contact',
           'entity' => 'DashboardContact',
@@ -161,6 +166,7 @@ class CRM_Contact_DAO_DashboardContact extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Order'),
           'description' => ts('Ordering of the widgets.'),
+          'where' => 'civicrm_dashboard_contact.weight',
           'default' => '0',
           'table_name' => 'civicrm_dashboard_contact',
           'entity' => 'DashboardContact',
diff --git a/civicrm/CRM/Contact/DAO/Group.php b/civicrm/CRM/Contact/DAO/Group.php
index 1213b90fc6e9bbb88da0668e78cca41c39afcd6e..71b28d33673296d1aed5d0aaa48678217e1f78dc 100644
--- a/civicrm/CRM/Contact/DAO/Group.php
+++ b/civicrm/CRM/Contact/DAO/Group.php
@@ -6,7 +6,7 @@
  *
  * Generated from xml/schema/CRM/Contact/Group.xml
  * DO NOT EDIT.  Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:48373e283a62b36aa59ac812f8cb4134)
+ * (GenCodeChecksum:21b3e21494b0831994f860083cd82e24)
  */
 
 /**
@@ -205,6 +205,7 @@ class CRM_Contact_DAO_Group extends CRM_Core_DAO {
           'title' => ts('Group ID'),
           'description' => ts('Group ID'),
           'required' => TRUE,
+          'where' => 'civicrm_group.id',
           'table_name' => 'civicrm_group',
           'entity' => 'Group',
           'bao' => 'CRM_Contact_BAO_Group',
@@ -217,6 +218,7 @@ class CRM_Contact_DAO_Group extends CRM_Core_DAO {
           'description' => ts('Internal name of Group.'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_group.name',
           'table_name' => 'civicrm_group',
           'entity' => 'Group',
           'bao' => 'CRM_Contact_BAO_Group',
@@ -229,10 +231,14 @@ class CRM_Contact_DAO_Group extends CRM_Core_DAO {
           'description' => ts('Name of Group.'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_group.title',
           'table_name' => 'civicrm_group',
           'entity' => 'Group',
           'bao' => 'CRM_Contact_BAO_Group',
           'localizable' => 1,
+          'html' => [
+            'type' => 'Text',
+          ],
         ],
         'description' => [
           'name' => 'description',
@@ -241,6 +247,7 @@ class CRM_Contact_DAO_Group extends CRM_Core_DAO {
           'description' => ts('Optional verbose description of the group.'),
           'rows' => 2,
           'cols' => 60,
+          'where' => 'civicrm_group.description',
           'table_name' => 'civicrm_group',
           'entity' => 'Group',
           'bao' => 'CRM_Contact_BAO_Group',
@@ -256,6 +263,7 @@ class CRM_Contact_DAO_Group extends CRM_Core_DAO {
           'description' => ts('Module or process which created this group.'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_group.source',
           'table_name' => 'civicrm_group',
           'entity' => 'Group',
           'bao' => 'CRM_Contact_BAO_Group',
@@ -266,6 +274,7 @@ class CRM_Contact_DAO_Group extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Saved Search ID'),
           'description' => ts('FK to saved search table.'),
+          'where' => 'civicrm_group.saved_search_id',
           'table_name' => 'civicrm_group',
           'entity' => 'Group',
           'bao' => 'CRM_Contact_BAO_Group',
@@ -277,6 +286,7 @@ class CRM_Contact_DAO_Group extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Group Enabled'),
           'description' => ts('Is this entry active?'),
+          'where' => 'civicrm_group.is_active',
           'table_name' => 'civicrm_group',
           'entity' => 'Group',
           'bao' => 'CRM_Contact_BAO_Group',
@@ -289,6 +299,7 @@ class CRM_Contact_DAO_Group extends CRM_Core_DAO {
           'description' => ts('In what context(s) is this field visible.'),
           'maxlength' => 24,
           'size' => CRM_Utils_Type::MEDIUM,
+          'where' => 'civicrm_group.visibility',
           'default' => 'User and User Admin Only',
           'table_name' => 'civicrm_group',
           'entity' => 'Group',
@@ -306,6 +317,7 @@ class CRM_Contact_DAO_Group extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_TEXT,
           'title' => ts('Group Where Clause'),
           'description' => ts('the sql where clause if a saved search acl'),
+          'where' => 'civicrm_group.where_clause',
           'table_name' => 'civicrm_group',
           'entity' => 'Group',
           'bao' => 'CRM_Contact_BAO_Group',
@@ -316,6 +328,7 @@ class CRM_Contact_DAO_Group extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_TEXT,
           'title' => ts('Tables For Select Clause'),
           'description' => ts('the tables to be included in a select data'),
+          'where' => 'civicrm_group.select_tables',
           'table_name' => 'civicrm_group',
           'entity' => 'Group',
           'bao' => 'CRM_Contact_BAO_Group',
@@ -327,6 +340,7 @@ class CRM_Contact_DAO_Group extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_TEXT,
           'title' => ts('Tables For Where Clause'),
           'description' => ts('the tables to be included in the count statement'),
+          'where' => 'civicrm_group.where_tables',
           'table_name' => 'civicrm_group',
           'entity' => 'Group',
           'bao' => 'CRM_Contact_BAO_Group',
@@ -340,6 +354,7 @@ class CRM_Contact_DAO_Group extends CRM_Core_DAO {
           'description' => ts('FK to group type'),
           'maxlength' => 128,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_group.group_type',
           'table_name' => 'civicrm_group',
           'entity' => 'Group',
           'bao' => 'CRM_Contact_BAO_Group',
@@ -356,6 +371,7 @@ class CRM_Contact_DAO_Group extends CRM_Core_DAO {
           'title' => ts('Group Cache Date'),
           'description' => ts('Date when we created the cache for a smart group'),
           'required' => FALSE,
+          'where' => 'civicrm_group.cache_date',
           'table_name' => 'civicrm_group',
           'entity' => 'Group',
           'bao' => 'CRM_Contact_BAO_Group',
@@ -367,6 +383,7 @@ class CRM_Contact_DAO_Group extends CRM_Core_DAO {
           'title' => ts('Next Group Refresh Time'),
           'description' => ts('Date and time when we need to refresh the cache next.'),
           'required' => FALSE,
+          'where' => 'civicrm_group.refresh_date',
           'table_name' => 'civicrm_group',
           'entity' => 'Group',
           'bao' => 'CRM_Contact_BAO_Group',
@@ -377,6 +394,7 @@ class CRM_Contact_DAO_Group extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_TEXT,
           'title' => ts('Group Parents'),
           'description' => ts('IDs of the parent(s)'),
+          'where' => 'civicrm_group.parents',
           'table_name' => 'civicrm_group',
           'entity' => 'Group',
           'bao' => 'CRM_Contact_BAO_Group',
@@ -391,6 +409,7 @@ class CRM_Contact_DAO_Group extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_TEXT,
           'title' => ts('Group Children'),
           'description' => ts('IDs of the child(ren)'),
+          'where' => 'civicrm_group.children',
           'table_name' => 'civicrm_group',
           'entity' => 'Group',
           'bao' => 'CRM_Contact_BAO_Group',
@@ -401,6 +420,7 @@ class CRM_Contact_DAO_Group extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Group is Hidden'),
           'description' => ts('Is this group hidden?'),
+          'where' => 'civicrm_group.is_hidden',
           'default' => '0',
           'table_name' => 'civicrm_group',
           'entity' => 'Group',
@@ -411,6 +431,7 @@ class CRM_Contact_DAO_Group extends CRM_Core_DAO {
           'name' => 'is_reserved',
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Group is Reserved'),
+          'where' => 'civicrm_group.is_reserved',
           'default' => '0',
           'table_name' => 'civicrm_group',
           'entity' => 'Group',
@@ -422,6 +443,7 @@ class CRM_Contact_DAO_Group extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Group Created By'),
           'description' => ts('FK to contact table.'),
+          'where' => 'civicrm_group.created_id',
           'table_name' => 'civicrm_group',
           'entity' => 'Group',
           'bao' => 'CRM_Contact_BAO_Group',
@@ -433,6 +455,7 @@ class CRM_Contact_DAO_Group extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Group Modified By'),
           'description' => ts('FK to contact table.'),
+          'where' => 'civicrm_group.modified_id',
           'table_name' => 'civicrm_group',
           'entity' => 'Group',
           'bao' => 'CRM_Contact_BAO_Group',
diff --git a/civicrm/CRM/Contact/DAO/GroupContact.php b/civicrm/CRM/Contact/DAO/GroupContact.php
index 8a259670c63a4b1914981d39cf8d04863bd8c2b1..8980f8c8bf9df2f89e33465d52af6ba5e0c8e14b 100644
--- a/civicrm/CRM/Contact/DAO/GroupContact.php
+++ b/civicrm/CRM/Contact/DAO/GroupContact.php
@@ -110,6 +110,7 @@ class CRM_Contact_DAO_GroupContact extends CRM_Core_DAO {
           'title' => ts('Group Contact ID'),
           'description' => ts('primary key'),
           'required' => TRUE,
+          'where' => 'civicrm_group_contact.id',
           'table_name' => 'civicrm_group_contact',
           'entity' => 'GroupContact',
           'bao' => 'CRM_Contact_BAO_GroupContact',
@@ -121,6 +122,7 @@ class CRM_Contact_DAO_GroupContact extends CRM_Core_DAO {
           'title' => ts('Group ID'),
           'description' => ts('FK to civicrm_group'),
           'required' => TRUE,
+          'where' => 'civicrm_group_contact.group_id',
           'table_name' => 'civicrm_group_contact',
           'entity' => 'GroupContact',
           'bao' => 'CRM_Contact_BAO_GroupContact',
@@ -141,6 +143,7 @@ class CRM_Contact_DAO_GroupContact extends CRM_Core_DAO {
           'title' => ts('Contact ID'),
           'description' => ts('FK to civicrm_contact'),
           'required' => TRUE,
+          'where' => 'civicrm_group_contact.contact_id',
           'table_name' => 'civicrm_group_contact',
           'entity' => 'GroupContact',
           'bao' => 'CRM_Contact_BAO_GroupContact',
@@ -154,6 +157,7 @@ class CRM_Contact_DAO_GroupContact extends CRM_Core_DAO {
           'description' => ts('status of contact relative to membership in group'),
           'maxlength' => 8,
           'size' => CRM_Utils_Type::EIGHT,
+          'where' => 'civicrm_group_contact.status',
           'table_name' => 'civicrm_group_contact',
           'entity' => 'GroupContact',
           'bao' => 'CRM_Contact_BAO_GroupContact',
@@ -170,6 +174,7 @@ class CRM_Contact_DAO_GroupContact extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Group Contact Location'),
           'description' => ts('Optional location to associate with this membership'),
+          'where' => 'civicrm_group_contact.location_id',
           'table_name' => 'civicrm_group_contact',
           'entity' => 'GroupContact',
           'bao' => 'CRM_Contact_BAO_GroupContact',
@@ -181,6 +186,7 @@ class CRM_Contact_DAO_GroupContact extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Group Contact Email'),
           'description' => ts('Optional email to associate with this membership'),
+          'where' => 'civicrm_group_contact.email_id',
           'table_name' => 'civicrm_group_contact',
           'entity' => 'GroupContact',
           'bao' => 'CRM_Contact_BAO_GroupContact',
diff --git a/civicrm/CRM/Contact/DAO/GroupContactCache.php b/civicrm/CRM/Contact/DAO/GroupContactCache.php
index 7e97bd7b867df0849d5a7da3746cdb017153e2af..0370dcc98c1931cf936373bd075a372430d81641 100644
--- a/civicrm/CRM/Contact/DAO/GroupContactCache.php
+++ b/civicrm/CRM/Contact/DAO/GroupContactCache.php
@@ -87,6 +87,7 @@ class CRM_Contact_DAO_GroupContactCache extends CRM_Core_DAO {
           'title' => ts('Group Contact Cache ID'),
           'description' => ts('primary key'),
           'required' => TRUE,
+          'where' => 'civicrm_group_contact_cache.id',
           'table_name' => 'civicrm_group_contact_cache',
           'entity' => 'GroupContactCache',
           'bao' => 'CRM_Contact_BAO_GroupContactCache',
@@ -98,6 +99,7 @@ class CRM_Contact_DAO_GroupContactCache extends CRM_Core_DAO {
           'title' => ts('Group'),
           'description' => ts('FK to civicrm_group'),
           'required' => TRUE,
+          'where' => 'civicrm_group_contact_cache.group_id',
           'table_name' => 'civicrm_group_contact_cache',
           'entity' => 'GroupContactCache',
           'bao' => 'CRM_Contact_BAO_GroupContactCache',
@@ -118,6 +120,7 @@ class CRM_Contact_DAO_GroupContactCache extends CRM_Core_DAO {
           'title' => ts('Contact ID'),
           'description' => ts('FK to civicrm_contact'),
           'required' => TRUE,
+          'where' => 'civicrm_group_contact_cache.contact_id',
           'table_name' => 'civicrm_group_contact_cache',
           'entity' => 'GroupContactCache',
           'bao' => 'CRM_Contact_BAO_GroupContactCache',
diff --git a/civicrm/CRM/Contact/DAO/GroupNesting.php b/civicrm/CRM/Contact/DAO/GroupNesting.php
index d7a59df69366842e80041914f265820099ddef7d..e2d83582c81d69ec4f92290b37187524f5b65135 100644
--- a/civicrm/CRM/Contact/DAO/GroupNesting.php
+++ b/civicrm/CRM/Contact/DAO/GroupNesting.php
@@ -87,6 +87,7 @@ class CRM_Contact_DAO_GroupNesting extends CRM_Core_DAO {
           'title' => ts('Group Nesting ID'),
           'description' => ts('Relationship ID'),
           'required' => TRUE,
+          'where' => 'civicrm_group_nesting.id',
           'table_name' => 'civicrm_group_nesting',
           'entity' => 'GroupNesting',
           'bao' => 'CRM_Contact_BAO_GroupNesting',
@@ -98,6 +99,7 @@ class CRM_Contact_DAO_GroupNesting extends CRM_Core_DAO {
           'title' => ts('Child Group'),
           'description' => ts('ID of the child group'),
           'required' => TRUE,
+          'where' => 'civicrm_group_nesting.child_group_id',
           'table_name' => 'civicrm_group_nesting',
           'entity' => 'GroupNesting',
           'bao' => 'CRM_Contact_BAO_GroupNesting',
@@ -110,6 +112,7 @@ class CRM_Contact_DAO_GroupNesting extends CRM_Core_DAO {
           'title' => ts('Parent Group'),
           'description' => ts('ID of the parent group'),
           'required' => TRUE,
+          'where' => 'civicrm_group_nesting.parent_group_id',
           'table_name' => 'civicrm_group_nesting',
           'entity' => 'GroupNesting',
           'bao' => 'CRM_Contact_BAO_GroupNesting',
diff --git a/civicrm/CRM/Contact/DAO/GroupOrganization.php b/civicrm/CRM/Contact/DAO/GroupOrganization.php
index fd90ae2bfba36f00a943d1c4295fc0f7627b6dbd..b16db55d397c34a4146cba2309f9a936596a0e12 100644
--- a/civicrm/CRM/Contact/DAO/GroupOrganization.php
+++ b/civicrm/CRM/Contact/DAO/GroupOrganization.php
@@ -87,6 +87,7 @@ class CRM_Contact_DAO_GroupOrganization extends CRM_Core_DAO {
           'title' => ts('Group Organization ID'),
           'description' => ts('Relationship ID'),
           'required' => TRUE,
+          'where' => 'civicrm_group_organization.id',
           'table_name' => 'civicrm_group_organization',
           'entity' => 'GroupOrganization',
           'bao' => 'CRM_Contact_BAO_GroupOrganization',
@@ -98,6 +99,7 @@ class CRM_Contact_DAO_GroupOrganization extends CRM_Core_DAO {
           'title' => ts('Group'),
           'description' => ts('ID of the group'),
           'required' => TRUE,
+          'where' => 'civicrm_group_organization.group_id',
           'table_name' => 'civicrm_group_organization',
           'entity' => 'GroupOrganization',
           'bao' => 'CRM_Contact_BAO_GroupOrganization',
@@ -118,6 +120,7 @@ class CRM_Contact_DAO_GroupOrganization extends CRM_Core_DAO {
           'title' => ts('Organization'),
           'description' => ts('ID of the Organization Contact'),
           'required' => TRUE,
+          'where' => 'civicrm_group_organization.organization_id',
           'table_name' => 'civicrm_group_organization',
           'entity' => 'GroupOrganization',
           'bao' => 'CRM_Contact_BAO_GroupOrganization',
diff --git a/civicrm/CRM/Contact/DAO/Relationship.php b/civicrm/CRM/Contact/DAO/Relationship.php
index c40f4218315435cb50e4ec0295ff9f7d89ffe85a..f6dcce482c6edac33aa234a87cbca19d305ffcb6 100644
--- a/civicrm/CRM/Contact/DAO/Relationship.php
+++ b/civicrm/CRM/Contact/DAO/Relationship.php
@@ -145,6 +145,7 @@ class CRM_Contact_DAO_Relationship extends CRM_Core_DAO {
           'title' => ts('Relationship ID'),
           'description' => ts('Relationship ID'),
           'required' => TRUE,
+          'where' => 'civicrm_relationship.id',
           'table_name' => 'civicrm_relationship',
           'entity' => 'Relationship',
           'bao' => 'CRM_Contact_BAO_Relationship',
@@ -156,6 +157,7 @@ class CRM_Contact_DAO_Relationship extends CRM_Core_DAO {
           'title' => ts('Contact A'),
           'description' => ts('id of the first contact'),
           'required' => TRUE,
+          'where' => 'civicrm_relationship.contact_id_a',
           'table_name' => 'civicrm_relationship',
           'entity' => 'Relationship',
           'bao' => 'CRM_Contact_BAO_Relationship',
@@ -168,6 +170,7 @@ class CRM_Contact_DAO_Relationship extends CRM_Core_DAO {
           'title' => ts('Contact B'),
           'description' => ts('id of the second contact'),
           'required' => TRUE,
+          'where' => 'civicrm_relationship.contact_id_b',
           'table_name' => 'civicrm_relationship',
           'entity' => 'Relationship',
           'bao' => 'CRM_Contact_BAO_Relationship',
@@ -183,6 +186,7 @@ class CRM_Contact_DAO_Relationship extends CRM_Core_DAO {
           'title' => ts('Relationship Type'),
           'description' => ts('id of the relationship'),
           'required' => TRUE,
+          'where' => 'civicrm_relationship.relationship_type_id',
           'table_name' => 'civicrm_relationship',
           'entity' => 'Relationship',
           'bao' => 'CRM_Contact_BAO_Relationship',
@@ -197,6 +201,7 @@ class CRM_Contact_DAO_Relationship extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_DATE,
           'title' => ts('Relationship Start Date'),
           'description' => ts('date when the relationship started'),
+          'where' => 'civicrm_relationship.start_date',
           'table_name' => 'civicrm_relationship',
           'entity' => 'Relationship',
           'bao' => 'CRM_Contact_BAO_Relationship',
@@ -211,6 +216,7 @@ class CRM_Contact_DAO_Relationship extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_DATE,
           'title' => ts('Relationship End Date'),
           'description' => ts('date when the relationship ended'),
+          'where' => 'civicrm_relationship.end_date',
           'table_name' => 'civicrm_relationship',
           'entity' => 'Relationship',
           'bao' => 'CRM_Contact_BAO_Relationship',
@@ -225,6 +231,7 @@ class CRM_Contact_DAO_Relationship extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Relationship Is Active'),
           'description' => ts('is the relationship active ?'),
+          'where' => 'civicrm_relationship.is_active',
           'default' => '1',
           'table_name' => 'civicrm_relationship',
           'entity' => 'Relationship',
@@ -241,6 +248,7 @@ class CRM_Contact_DAO_Relationship extends CRM_Core_DAO {
           'description' => ts('Optional verbose description for the relationship.'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_relationship.description',
           'table_name' => 'civicrm_relationship',
           'entity' => 'Relationship',
           'bao' => 'CRM_Contact_BAO_Relationship',
@@ -255,6 +263,7 @@ class CRM_Contact_DAO_Relationship extends CRM_Core_DAO {
           'title' => ts('Contact A has Permission Over Contact B'),
           'description' => ts('Permission that Contact A has to view/update Contact B'),
           'required' => TRUE,
+          'where' => 'civicrm_relationship.is_permission_a_b',
           'default' => '0',
           'table_name' => 'civicrm_relationship',
           'entity' => 'Relationship',
@@ -273,6 +282,7 @@ class CRM_Contact_DAO_Relationship extends CRM_Core_DAO {
           'title' => ts('Contact B has Permission Over Contact A'),
           'description' => ts('Permission that Contact B has to view/update Contact A'),
           'required' => TRUE,
+          'where' => 'civicrm_relationship.is_permission_b_a',
           'default' => '0',
           'table_name' => 'civicrm_relationship',
           'entity' => 'Relationship',
@@ -290,6 +300,7 @@ class CRM_Contact_DAO_Relationship extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Relationship Case'),
           'description' => ts('FK to civicrm_case'),
+          'where' => 'civicrm_relationship.case_id',
           'default' => 'NULL',
           'table_name' => 'civicrm_relationship',
           'entity' => 'Relationship',
diff --git a/civicrm/CRM/Contact/DAO/RelationshipType.php b/civicrm/CRM/Contact/DAO/RelationshipType.php
index 11bb3d1ba0eb8d50c71923207082c9c1487e9a57..7a3a77e310bfe231a4fdec86ba4343dcb3e662e4 100644
--- a/civicrm/CRM/Contact/DAO/RelationshipType.php
+++ b/civicrm/CRM/Contact/DAO/RelationshipType.php
@@ -134,6 +134,7 @@ class CRM_Contact_DAO_RelationshipType extends CRM_Core_DAO {
           'title' => ts('Relationship Type ID'),
           'description' => ts('Primary key'),
           'required' => TRUE,
+          'where' => 'civicrm_relationship_type.id',
           'table_name' => 'civicrm_relationship_type',
           'entity' => 'RelationshipType',
           'bao' => 'CRM_Contact_BAO_RelationshipType',
@@ -146,6 +147,7 @@ class CRM_Contact_DAO_RelationshipType extends CRM_Core_DAO {
           'description' => ts('name for relationship of contact_a to contact_b.'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_relationship_type.name_a_b',
           'table_name' => 'civicrm_relationship_type',
           'entity' => 'RelationshipType',
           'bao' => 'CRM_Contact_BAO_RelationshipType',
@@ -158,6 +160,7 @@ class CRM_Contact_DAO_RelationshipType extends CRM_Core_DAO {
           'description' => ts('label for relationship of contact_a to contact_b.'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_relationship_type.label_a_b',
           'table_name' => 'civicrm_relationship_type',
           'entity' => 'RelationshipType',
           'bao' => 'CRM_Contact_BAO_RelationshipType',
@@ -173,6 +176,7 @@ class CRM_Contact_DAO_RelationshipType extends CRM_Core_DAO {
           'description' => ts('Optional name for relationship of contact_b to contact_a.'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_relationship_type.name_b_a',
           'table_name' => 'civicrm_relationship_type',
           'entity' => 'RelationshipType',
           'bao' => 'CRM_Contact_BAO_RelationshipType',
@@ -185,6 +189,7 @@ class CRM_Contact_DAO_RelationshipType extends CRM_Core_DAO {
           'description' => ts('Optional label for relationship of contact_b to contact_a.'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_relationship_type.label_b_a',
           'table_name' => 'civicrm_relationship_type',
           'entity' => 'RelationshipType',
           'bao' => 'CRM_Contact_BAO_RelationshipType',
@@ -200,6 +205,7 @@ class CRM_Contact_DAO_RelationshipType extends CRM_Core_DAO {
           'description' => ts('Optional verbose description of the relationship type.'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_relationship_type.description',
           'table_name' => 'civicrm_relationship_type',
           'entity' => 'RelationshipType',
           'bao' => 'CRM_Contact_BAO_RelationshipType',
@@ -215,6 +221,7 @@ class CRM_Contact_DAO_RelationshipType extends CRM_Core_DAO {
           'description' => ts('If defined, contact_a in a relationship of this type must be a specific contact_type.'),
           'maxlength' => 12,
           'size' => CRM_Utils_Type::TWELVE,
+          'where' => 'civicrm_relationship_type.contact_type_a',
           'table_name' => 'civicrm_relationship_type',
           'entity' => 'RelationshipType',
           'bao' => 'CRM_Contact_BAO_RelationshipType',
@@ -236,6 +243,7 @@ class CRM_Contact_DAO_RelationshipType extends CRM_Core_DAO {
           'description' => ts('If defined, contact_b in a relationship of this type must be a specific contact_type.'),
           'maxlength' => 12,
           'size' => CRM_Utils_Type::TWELVE,
+          'where' => 'civicrm_relationship_type.contact_type_b',
           'table_name' => 'civicrm_relationship_type',
           'entity' => 'RelationshipType',
           'bao' => 'CRM_Contact_BAO_RelationshipType',
@@ -258,6 +266,7 @@ class CRM_Contact_DAO_RelationshipType extends CRM_Core_DAO {
     '),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_relationship_type.contact_sub_type_a',
           'table_name' => 'civicrm_relationship_type',
           'entity' => 'RelationshipType',
           'bao' => 'CRM_Contact_BAO_RelationshipType',
@@ -280,6 +289,7 @@ class CRM_Contact_DAO_RelationshipType extends CRM_Core_DAO {
     '),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_relationship_type.contact_sub_type_b',
           'table_name' => 'civicrm_relationship_type',
           'entity' => 'RelationshipType',
           'bao' => 'CRM_Contact_BAO_RelationshipType',
@@ -299,6 +309,7 @@ class CRM_Contact_DAO_RelationshipType extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Relationship Type is Reserved'),
           'description' => ts('Is this relationship type a predefined system type (can not be changed or de-activated)?'),
+          'where' => 'civicrm_relationship_type.is_reserved',
           'table_name' => 'civicrm_relationship_type',
           'entity' => 'RelationshipType',
           'bao' => 'CRM_Contact_BAO_RelationshipType',
@@ -313,6 +324,7 @@ class CRM_Contact_DAO_RelationshipType extends CRM_Core_DAO {
           'title' => ts('Relationship Type is Active'),
           'description' => ts('Is this relationship type currently active (i.e. can be used when creating or editing relationships)?
     '),
+          'where' => 'civicrm_relationship_type.is_active',
           'default' => '1',
           'table_name' => 'civicrm_relationship_type',
           'entity' => 'RelationshipType',
diff --git a/civicrm/CRM/Contact/DAO/SavedSearch.php b/civicrm/CRM/Contact/DAO/SavedSearch.php
index e1c75e9bac0eb17d8c2957632f943c030a8fd046..b7fd62c31a36e7f6037962c6e20b202179d9bb13 100644
--- a/civicrm/CRM/Contact/DAO/SavedSearch.php
+++ b/civicrm/CRM/Contact/DAO/SavedSearch.php
@@ -114,6 +114,7 @@ class CRM_Contact_DAO_SavedSearch extends CRM_Core_DAO {
           'title' => ts('Saved Search ID'),
           'description' => ts('Saved Search ID'),
           'required' => TRUE,
+          'where' => 'civicrm_saved_search.id',
           'table_name' => 'civicrm_saved_search',
           'entity' => 'SavedSearch',
           'bao' => 'CRM_Contact_BAO_SavedSearch',
@@ -126,8 +127,6 @@ class CRM_Contact_DAO_SavedSearch extends CRM_Core_DAO {
           'description' => ts('Submitted form values for this search'),
           'import' => TRUE,
           'where' => 'civicrm_saved_search.form_values',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_saved_search',
           'entity' => 'SavedSearch',
@@ -140,6 +139,7 @@ class CRM_Contact_DAO_SavedSearch extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Mapping ID'),
           'description' => ts('Foreign key to civicrm_mapping used for saved search-builder searches.'),
+          'where' => 'civicrm_saved_search.mapping_id',
           'table_name' => 'civicrm_saved_search',
           'entity' => 'SavedSearch',
           'bao' => 'CRM_Contact_BAO_SavedSearch',
@@ -151,6 +151,7 @@ class CRM_Contact_DAO_SavedSearch extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Option Value ID'),
           'description' => ts('Foreign key to civicrm_option value table used for saved custom searches.'),
+          'where' => 'civicrm_saved_search.search_custom_id',
           'table_name' => 'civicrm_saved_search',
           'entity' => 'SavedSearch',
           'bao' => 'CRM_Contact_BAO_SavedSearch',
@@ -161,6 +162,7 @@ class CRM_Contact_DAO_SavedSearch extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_TEXT,
           'title' => ts('Where Clause'),
           'description' => ts('the sql where clause if a saved search acl'),
+          'where' => 'civicrm_saved_search.where_clause',
           'table_name' => 'civicrm_saved_search',
           'entity' => 'SavedSearch',
           'bao' => 'CRM_Contact_BAO_SavedSearch',
@@ -171,6 +173,7 @@ class CRM_Contact_DAO_SavedSearch extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_TEXT,
           'title' => ts('Select Tables'),
           'description' => ts('the tables to be included in a select data'),
+          'where' => 'civicrm_saved_search.select_tables',
           'table_name' => 'civicrm_saved_search',
           'entity' => 'SavedSearch',
           'bao' => 'CRM_Contact_BAO_SavedSearch',
@@ -182,6 +185,7 @@ class CRM_Contact_DAO_SavedSearch extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_TEXT,
           'title' => ts('Where Tables'),
           'description' => ts('the tables to be included in the count statement'),
+          'where' => 'civicrm_saved_search.where_tables',
           'table_name' => 'civicrm_saved_search',
           'entity' => 'SavedSearch',
           'bao' => 'CRM_Contact_BAO_SavedSearch',
diff --git a/civicrm/CRM/Contact/DAO/SubscriptionHistory.php b/civicrm/CRM/Contact/DAO/SubscriptionHistory.php
index 90f7ea3d8f81523f49645e6962341cec91d070bd..1df68f7f335699ac5f4d743c37bf8c27a75b58c8 100644
--- a/civicrm/CRM/Contact/DAO/SubscriptionHistory.php
+++ b/civicrm/CRM/Contact/DAO/SubscriptionHistory.php
@@ -115,6 +115,7 @@ class CRM_Contact_DAO_SubscriptionHistory extends CRM_Core_DAO {
           'title' => ts('Group Membership History ID'),
           'description' => ts('Internal Id'),
           'required' => TRUE,
+          'where' => 'civicrm_subscription_history.id',
           'table_name' => 'civicrm_subscription_history',
           'entity' => 'SubscriptionHistory',
           'bao' => 'CRM_Contact_BAO_SubscriptionHistory',
@@ -126,6 +127,7 @@ class CRM_Contact_DAO_SubscriptionHistory extends CRM_Core_DAO {
           'title' => ts('Contact ID'),
           'description' => ts('Contact Id'),
           'required' => TRUE,
+          'where' => 'civicrm_subscription_history.contact_id',
           'table_name' => 'civicrm_subscription_history',
           'entity' => 'SubscriptionHistory',
           'bao' => 'CRM_Contact_BAO_SubscriptionHistory',
@@ -137,6 +139,7 @@ class CRM_Contact_DAO_SubscriptionHistory extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Group'),
           'description' => ts('Group Id'),
+          'where' => 'civicrm_subscription_history.group_id',
           'table_name' => 'civicrm_subscription_history',
           'entity' => 'SubscriptionHistory',
           'bao' => 'CRM_Contact_BAO_SubscriptionHistory',
@@ -157,6 +160,7 @@ class CRM_Contact_DAO_SubscriptionHistory extends CRM_Core_DAO {
           'title' => ts('Group Membership Action Date'),
           'description' => ts('Date of the (un)subscription'),
           'required' => TRUE,
+          'where' => 'civicrm_subscription_history.date',
           'default' => 'CURRENT_TIMESTAMP',
           'table_name' => 'civicrm_subscription_history',
           'entity' => 'SubscriptionHistory',
@@ -170,6 +174,7 @@ class CRM_Contact_DAO_SubscriptionHistory extends CRM_Core_DAO {
           'description' => ts('How the (un)subscription was triggered'),
           'maxlength' => 8,
           'size' => CRM_Utils_Type::EIGHT,
+          'where' => 'civicrm_subscription_history.method',
           'table_name' => 'civicrm_subscription_history',
           'entity' => 'SubscriptionHistory',
           'bao' => 'CRM_Contact_BAO_SubscriptionHistory',
@@ -188,6 +193,7 @@ class CRM_Contact_DAO_SubscriptionHistory extends CRM_Core_DAO {
           'description' => ts('The state of the contact within the group'),
           'maxlength' => 8,
           'size' => CRM_Utils_Type::EIGHT,
+          'where' => 'civicrm_subscription_history.status',
           'table_name' => 'civicrm_subscription_history',
           'entity' => 'SubscriptionHistory',
           'bao' => 'CRM_Contact_BAO_SubscriptionHistory',
@@ -203,6 +209,7 @@ class CRM_Contact_DAO_SubscriptionHistory extends CRM_Core_DAO {
           'description' => ts('IP address or other tracking info'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_subscription_history.tracking',
           'table_name' => 'civicrm_subscription_history',
           'entity' => 'SubscriptionHistory',
           'bao' => 'CRM_Contact_BAO_SubscriptionHistory',
diff --git a/civicrm/CRM/Contact/Form/DedupeRules.php b/civicrm/CRM/Contact/Form/DedupeRules.php
index 82bd6ef93f6ab7337a231696d37e918f2a56ef19..318138ff760792c1a1ebf924fbb73e4f6d8c1806 100644
--- a/civicrm/CRM/Contact/Form/DedupeRules.php
+++ b/civicrm/CRM/Contact/Form/DedupeRules.php
@@ -113,22 +113,16 @@ class CRM_Contact_Form_DedupeRules extends CRM_Admin_Form {
     );
 
     $this->addField('used', ['label' => ts('Usage')], TRUE);
-    $disabled = [];
     $reserved = $this->addField('is_reserved', ['label' => ts('Reserved?')]);
     if (!empty($this->_defaults['is_reserved'])) {
       $reserved->freeze();
     }
 
     $attributes = ['class' => 'two'];
-    if (!empty($disabled)) {
-      $attributes = array_merge($attributes, $disabled);
-    }
 
     for ($count = 0; $count < self::RULES_COUNT; $count++) {
       $this->add('select', "where_$count", ts('Field'),
-        [
-          NULL => ts('- none -'),
-        ] + $this->_fields, FALSE, $disabled
+        $this->_fields, FALSE, ['class' => 'crm-select2', 'placeholder' => ts('Select Field')]
       );
       $this->addField("length_$count", ['entity' => 'Rule', 'name' => 'rule_length'] + $attributes);
       $this->addField("weight_$count", ['entity' => 'Rule', 'name' => 'rule_weight'] + $attributes);
@@ -245,8 +239,6 @@ UPDATE civicrm_dedupe_rule_group
     $ruleDao = new CRM_Dedupe_DAO_Rule();
     $ruleDao->dedupe_rule_group_id = $rgDao->id;
     $ruleDao->delete();
-    $ruleDao->free();
-
     $substrLenghts = [];
 
     $tables = [];
@@ -267,7 +259,6 @@ UPDATE civicrm_dedupe_rule_group
         $ruleDao->rule_length = $length;
         $ruleDao->rule_weight = $weight;
         $ruleDao->save();
-        $ruleDao->free();
 
         if (!array_key_exists($table, $tables)) {
           $tables[$table] = [];
diff --git a/civicrm/CRM/Contact/Form/Task.php b/civicrm/CRM/Contact/Form/Task.php
index 9448c3b59c55b6e2e72d3bf30374656a15a85c4a..8e1c3a3aa14543abacc470e6728522606ad855a2 100644
--- a/civicrm/CRM/Contact/Form/Task.php
+++ b/civicrm/CRM/Contact/Form/Task.php
@@ -453,7 +453,6 @@ class CRM_Contact_Form_Task extends CRM_Core_Form_Task {
           $this->_contactIds[] = $householdsDAO->household_id;
         }
       }
-      $householdsDAO->free();
     }
 
     // If contact list has changed, households will probably be at the end of
diff --git a/civicrm/CRM/Contact/Import/Parser.php b/civicrm/CRM/Contact/Import/Parser.php
index 8979fb64f6a22dad386c9db19e61262dd60c2f95..c9d41c2cb1b101abacf3b7e412d3b8030329c089 100644
--- a/civicrm/CRM/Contact/Import/Parser.php
+++ b/civicrm/CRM/Contact/Import/Parser.php
@@ -69,6 +69,7 @@ abstract class CRM_Contact_Import_Parser extends CRM_Import_Parser {
   protected $_primaryKeyName;
   protected $_statusFieldName;
 
+  protected $fieldMetadata = [];
   /**
    * On duplicate
    *
@@ -846,7 +847,13 @@ abstract class CRM_Contact_Import_Parser extends CRM_Import_Parser {
           }
 
           if (!$break) {
-            $this->formatContactParameters($value, $formatted);
+            if (!empty($value['location_type_id'])) {
+              $this->formatLocationBlock($value, $formatted);
+            }
+            else {
+              CRM_Core_Error::deprecatedFunctionWarning('this is not expected to be reachable now');
+              $this->formatContactParameters($value, $formatted);
+            }
           }
         }
         if (!$isAddressCustomField) {
@@ -1129,143 +1136,8 @@ abstract class CRM_Contact_Import_Parser extends CRM_Import_Parser {
 
     // get the formatted location blocks into params - w/ 3.0 format, CRM-4605
     if (!empty($values['location_type_id'])) {
-      $blockTypes = [
-        'phone' => 'Phone',
-        'email' => 'Email',
-        'im' => 'IM',
-        'openid' => 'OpenID',
-        'phone_ext' => 'Phone',
-      ];
-      foreach ($blockTypes as $blockFieldName => $block) {
-        if (!array_key_exists($blockFieldName, $values)) {
-          continue;
-        }
-
-        // block present in value array.
-        if (!array_key_exists($blockFieldName, $params) || !is_array($params[$blockFieldName])) {
-          $params[$blockFieldName] = [];
-        }
-
-        if (!array_key_exists($block, $fields)) {
-          $className = "CRM_Core_DAO_$block";
-          $fields[$block] = $className::fields();
-        }
-
-        $blockCnt = count($params[$blockFieldName]);
-
-        // copy value to dao field name.
-        if ($blockFieldName == 'im') {
-          $values['name'] = $values[$blockFieldName];
-        }
-
-        _civicrm_api3_store_values($fields[$block], $values,
-          $params[$blockFieldName][++$blockCnt]
-        );
-
-        if ($values['location_type_id'] === 'Primary') {
-          if (!empty($params['id'])) {
-            $primary = civicrm_api3($block, 'get', ['return' => 'location_type_id', 'contact_id' => $params['id'], 'is_primary' => 1, 'sequential' => 1]);
-          }
-          $defaultLocationType = CRM_Core_BAO_LocationType::getDefault();
-          $values['location_type_id'] = (isset($primary) && $primary['count']) ? $primary['values'][0]['location_type_id'] : $defaultLocationType->id;
-          $values['is_primary'] = 1;
-        }
-
-        if (empty($params['id']) && ($blockCnt == 1)) {
-          $params[$blockFieldName][$blockCnt]['is_primary'] = TRUE;
-        }
-
-        // we only process single block at a time.
-        return TRUE;
-      }
-
-      // handle address fields.
-      if (!array_key_exists('address', $params) || !is_array($params['address'])) {
-        $params['address'] = [];
-      }
-
-      if (!array_key_exists('Address', $fields)) {
-        $fields['Address'] = CRM_Core_DAO_Address::fields();
-      }
-
-      // Note: we doing multiple value formatting here for address custom fields, plus putting into right format.
-      // The actual formatting (like date, country ..etc) for address custom fields is taken care of while saving
-      // the address in CRM_Core_BAO_Address::create method
-      if (!empty($values['location_type_id'])) {
-        static $customFields = [];
-        if (empty($customFields)) {
-          $customFields = CRM_Core_BAO_CustomField::getFields('Address');
-        }
-        // make a copy of values, as we going to make changes
-        $newValues = $values;
-        foreach ($values as $key => $val) {
-          $customFieldID = CRM_Core_BAO_CustomField::getKeyID($key);
-          if ($customFieldID && array_key_exists($customFieldID, $customFields)) {
-            // mark an entry in fields array since we want the value of custom field to be copied
-            $fields['Address'][$key] = NULL;
-
-            $htmlType = CRM_Utils_Array::value('html_type', $customFields[$customFieldID]);
-            switch ($htmlType) {
-              case 'CheckBox':
-              case 'Multi-Select':
-                if ($val) {
-                  $mulValues = explode(',', $val);
-                  $customOption = CRM_Core_BAO_CustomOption::getCustomOption($customFieldID, TRUE);
-                  $newValues[$key] = [];
-                  foreach ($mulValues as $v1) {
-                    foreach ($customOption as $v2) {
-                      if ((strtolower($v2['label']) == strtolower(trim($v1))) ||
-                        (strtolower($v2['value']) == strtolower(trim($v1)))
-                      ) {
-                        if ($htmlType == 'CheckBox') {
-                          $newValues[$key][$v2['value']] = 1;
-                        }
-                        else {
-                          $newValues[$key][] = $v2['value'];
-                        }
-                      }
-                    }
-                  }
-                }
-                break;
-            }
-          }
-        }
-        // consider new values
-        $values = $newValues;
-      }
-
-      _civicrm_api3_store_values($fields['Address'], $values, $params['address'][$values['location_type_id']]);
-
-      $addressFields = [
-        'county',
-        'country',
-        'state_province',
-        'supplemental_address_1',
-        'supplemental_address_2',
-        'supplemental_address_3',
-        'StateProvince.name',
-      ];
-
-      foreach ($addressFields as $field) {
-        if (array_key_exists($field, $values)) {
-          if (!array_key_exists('address', $params)) {
-            $params['address'] = [];
-          }
-          $params['address'][$values['location_type_id']][$field] = $values[$field];
-        }
-      }
-
-      if ($values['location_type_id'] === 'Primary') {
-        if (!empty($params['id'])) {
-          $primary = civicrm_api3('Address', 'get', ['return' => 'location_type_id', 'contact_id' => $params['id'], 'is_primary' => 1, 'sequential' => 1]);
-        }
-        $defaultLocationType = CRM_Core_BAO_LocationType::getDefault();
-        $params['address'][$values['location_type_id']]['location_type_id'] = (isset($primary) && $primary['count']) ? $primary['values'][0]['location_type_id'] : $defaultLocationType->id;
-        $params['address'][$values['location_type_id']]['is_primary'] = 1;
-
-      }
-      return TRUE;
+      CRM_Core_Error::deprecatedFunctionWarning('this is not expected to be reachable now');
+      return $this->formatLocationBlock($values, $params);
     }
 
     if (isset($values['note'])) {
@@ -1316,4 +1188,179 @@ abstract class CRM_Contact_Import_Parser extends CRM_Import_Parser {
     return TRUE;
   }
 
+  /**
+   * Format location block ready for importing.
+   *
+   * There is some test coverage for this in CRM_Contact_Import_Parser_ContactTest
+   * e.g. testImportPrimaryAddress.
+   *
+   * @param array $values
+   * @param array $params
+   *
+   * @return bool
+   */
+  protected function formatLocationBlock(&$values, &$params) {
+    $blockTypes = [
+      'phone' => 'Phone',
+      'email' => 'Email',
+      'im' => 'IM',
+      'openid' => 'OpenID',
+      'phone_ext' => 'Phone',
+    ];
+    foreach ($blockTypes as $blockFieldName => $block) {
+      if (!array_key_exists($blockFieldName, $values)) {
+        continue;
+      }
+
+      // block present in value array.
+      if (!array_key_exists($blockFieldName, $params) || !is_array($params[$blockFieldName])) {
+        $params[$blockFieldName] = [];
+      }
+
+      $fields[$block] = $this->getMetadataForEntity($block);
+
+      // copy value to dao field name.
+      if ($blockFieldName == 'im') {
+        $values['name'] = $values[$blockFieldName];
+      }
+
+      _civicrm_api3_store_values($fields[$block], $values,
+        $params[$blockFieldName][$values['location_type_id']]
+      );
+
+      $this->fillPrimary($params[$blockFieldName][$values['location_type_id']], $values, $block, CRM_Utils_Array::value('id', $params));
+
+      if (empty($params['id']) && (count($params[$blockFieldName]) == 1)) {
+        $params[$blockFieldName][$values['location_type_id']]['is_primary'] = TRUE;
+      }
+
+      // we only process single block at a time.
+      return TRUE;
+    }
+
+    // handle address fields.
+    if (!array_key_exists('address', $params) || !is_array($params['address'])) {
+      $params['address'] = [];
+    }
+
+    // Note: we doing multiple value formatting here for address custom fields, plus putting into right format.
+    // The actual formatting (like date, country ..etc) for address custom fields is taken care of while saving
+    // the address in CRM_Core_BAO_Address::create method
+    if (!empty($values['location_type_id'])) {
+      static $customFields = [];
+      if (empty($customFields)) {
+        $customFields = CRM_Core_BAO_CustomField::getFields('Address');
+      }
+      // make a copy of values, as we going to make changes
+      $newValues = $values;
+      foreach ($values as $key => $val) {
+        $customFieldID = CRM_Core_BAO_CustomField::getKeyID($key);
+        if ($customFieldID && array_key_exists($customFieldID, $customFields)) {
+
+          $htmlType = CRM_Utils_Array::value('html_type', $customFields[$customFieldID]);
+          switch ($htmlType) {
+            case 'CheckBox':
+            case 'Multi-Select':
+              if ($val) {
+                $mulValues = explode(',', $val);
+                $customOption = CRM_Core_BAO_CustomOption::getCustomOption($customFieldID, TRUE);
+                $newValues[$key] = [];
+                foreach ($mulValues as $v1) {
+                  foreach ($customOption as $v2) {
+                    if ((strtolower($v2['label']) == strtolower(trim($v1))) ||
+                      (strtolower($v2['value']) == strtolower(trim($v1)))
+                    ) {
+                      if ($htmlType == 'CheckBox') {
+                        $newValues[$key][$v2['value']] = 1;
+                      }
+                      else {
+                        $newValues[$key][] = $v2['value'];
+                      }
+                    }
+                  }
+                }
+              }
+              break;
+          }
+        }
+      }
+      // consider new values
+      $values = $newValues;
+    }
+
+    $fields['Address'] = $this->getMetadataForEntity('Address');
+    // @todo this is kinda replicated below....
+    _civicrm_api3_store_values($fields['Address'], $values, $params['address'][$values['location_type_id']]);
+
+    $addressFields = [
+      'county',
+      'country',
+      'state_province',
+      'supplemental_address_1',
+      'supplemental_address_2',
+      'supplemental_address_3',
+      'StateProvince.name',
+    ];
+    foreach (array_keys($customFields) as $customFieldID) {
+      $addressFields[] = 'custom_' . $customFieldID;
+    }
+
+    foreach ($addressFields as $field) {
+      if (array_key_exists($field, $values)) {
+        if (!array_key_exists('address', $params)) {
+          $params['address'] = [];
+        }
+        $params['address'][$values['location_type_id']][$field] = $values[$field];
+      }
+    }
+
+    $this->fillPrimary($params['address'][$values['location_type_id']], $values, 'address', CRM_Utils_Array::value('id', $params));
+    return TRUE;
+  }
+
+  /**
+   * Get the field metadata for the relevant entity.
+   *
+   * @param string $entity
+   *
+   * @return array
+   */
+  protected function getMetadataForEntity($entity) {
+    if (!isset($this->fieldMetadata[$entity])) {
+      $className = "CRM_Core_DAO_$entity";
+      $this->fieldMetadata[$entity] = $className::fields();
+    }
+    return $this->fieldMetadata[$entity];
+  }
+
+  /**
+   * Fill in the primary location.
+   *
+   * If the contact has a primary address we update it. Otherwise
+   * we add an address of the default location type.
+   *
+   * @param array $params
+   *   Address block parameters
+   * @param array $values
+   *   Input values
+   * @param string $entity
+   *  - address, email, phone
+   * @param int|NULL $contactID
+   */
+  protected function fillPrimary(&$params, $values, $entity, $contactID) {
+    if ($values['location_type_id'] === 'Primary') {
+      if ($contactID) {
+        $primary = civicrm_api3($entity, 'get', [
+          'return' => 'location_type_id',
+          'contact_id' => $contactID,
+          'is_primary' => 1,
+          'sequential' => 1
+        ]);
+      }
+      $defaultLocationType = CRM_Core_BAO_LocationType::getDefault();
+      $params['location_type_id'] = (int) (isset($primary) && $primary['count']) ? $primary['values'][0]['location_type_id'] : $defaultLocationType->id;
+      $params['is_primary'] = 1;
+    }
+  }
+
 }
diff --git a/civicrm/CRM/Contact/Import/Parser/Contact.php b/civicrm/CRM/Contact/Import/Parser/Contact.php
index 663aa55101cf5ddac3d3a6ce1a8787b2c84c7166..542a65ba556588e5d0e67241774298bae0ec9201 100644
--- a/civicrm/CRM/Contact/Import/Parser/Contact.php
+++ b/civicrm/CRM/Contact/Import/Parser/Contact.php
@@ -820,7 +820,6 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser {
               $formatting['contact_sub_type'] = $relationType->$direction;
             }
           }
-          $relationType->free();
 
           $contactFields = NULL;
           $contactFields = CRM_Contact_DAO_Contact::import();
@@ -1353,7 +1352,6 @@ class CRM_Contact_Import_Parser_Contact extends CRM_Contact_Import_Parser {
               $params[$key]['contact_sub_type'] = $relationshipType->$direction;
             }
           }
-          $relationshipType->free();
         }
 
         self::isErrorInCustomData($params[$key], $errorMessage, $csType, $relationships);
diff --git a/civicrm/CRM/Contact/Page/DedupeException.php b/civicrm/CRM/Contact/Page/DedupeException.php
index cb73cb3c20395166824722f496ea65ff2e3ca30d..48452d215d6f1df9faff121a704fb21494950e84 100644
--- a/civicrm/CRM/Contact/Page/DedupeException.php
+++ b/civicrm/CRM/Contact/Page/DedupeException.php
@@ -81,10 +81,9 @@ class CRM_Contact_Page_DedupeException extends CRM_Core_Page {
   /**
    * Function to get the exceptions
    *
-   * @return array $exceptions
-   * @access protected
+   * @return array $exceptionsd
    */
-  protected function getExceptions() {
+  public function getExceptions() {
     list($offset, $limit) = $this->_pager->getOffsetAndRowCount();
     $contactOneQ = CRM_Utils_Request::retrieve('crmContact1Q', 'String');
 
diff --git a/civicrm/CRM/Contact/Page/View/Note.php b/civicrm/CRM/Contact/Page/View/Note.php
index 2930341be709a478f7985f6821fdda58494fd9bc..9fe30dc03bdf99ba4144791c2fda63deaba0e5cf 100644
--- a/civicrm/CRM/Contact/Page/View/Note.php
+++ b/civicrm/CRM/Contact/Page/View/Note.php
@@ -50,6 +50,12 @@ class CRM_Contact_Page_View_Note extends CRM_Core_Page {
    */
   public static $_commentLinks = NULL;
 
+  /**
+   * Notes found running the browse function
+   * @var array
+   */
+  public $values = [];
+
   /**
    * View details of a note.
    */
@@ -57,14 +63,13 @@ class CRM_Contact_Page_View_Note extends CRM_Core_Page {
     $note = new CRM_Core_DAO_Note();
     $note->id = $this->_id;
     if ($note->find(TRUE)) {
-      $values = [];
 
-      CRM_Core_DAO::storeValues($note, $values);
-      $values['privacy'] = CRM_Core_PseudoConstant::getLabel('CRM_Core_BAO_Note', 'privacy', $values['privacy']);
-      $this->assign('note', $values);
+      CRM_Core_DAO::storeValues($note, $this->values);
+      $this->values['privacy'] = CRM_Core_PseudoConstant::getLabel('CRM_Core_BAO_Note', 'privacy', $this->values['privacy']);
+      $this->assign('note', $this->values);
     }
 
-    $comments = CRM_Core_BAO_Note::getNoteTree($values['id'], 1);
+    $comments = CRM_Core_BAO_Note::getNoteTree($this->values['id'], 1);
     if (!empty($comments)) {
       $this->assign('comments', $comments);
     }
@@ -96,16 +101,15 @@ class CRM_Contact_Page_View_Note extends CRM_Core_Page {
 
     $this->assign('canAddNotes', CRM_Core_Permission::check('add contact notes'));
 
-    $values = [];
     $links = self::links();
     $action = array_sum(array_keys($links)) & $mask;
 
     $note->find();
     while ($note->fetch()) {
       if (!CRM_Core_BAO_Note::getNotePrivacyHidden($note)) {
-        CRM_Core_DAO::storeValues($note, $values[$note->id]);
+        CRM_Core_DAO::storeValues($note, $this->values[$note->id]);
 
-        $values[$note->id]['action'] = CRM_Core_Action::formLink($links,
+        $this->values[$note->id]['action'] = CRM_Core_Action::formLink($links,
           $action,
           [
             'id' => $note->id,
@@ -122,17 +126,16 @@ class CRM_Contact_Page_View_Note extends CRM_Core_Page {
           $contact->id = $note->contact_id;
           $contact->find();
           $contact->fetch();
-          $values[$note->id]['createdBy'] = $contact->display_name;
+          $this->values[$note->id]['createdBy'] = $contact->display_name;
         }
-        $values[$note->id]['comment_count'] = CRM_Core_BAO_Note::getChildCount($note->id);
+        $this->values[$note->id]['comment_count'] = CRM_Core_BAO_Note::getChildCount($note->id);
 
         // paper icon view for attachments part
         $paperIconAttachmentInfo = CRM_Core_BAO_File::paperIconAttachment('civicrm_note', $note->id);
-        $values[$note->id]['attachment'] = $paperIconAttachmentInfo;
+        $this->values[$note->id]['attachment'] = $paperIconAttachmentInfo;
       }
     }
-
-    $this->assign('notes', $values);
+    $this->assign('notes', $this->values);
 
     $commentLinks = self::commentLinks();
 
diff --git a/civicrm/CRM/Contribute/BAO/Contribution.php b/civicrm/CRM/Contribute/BAO/Contribution.php
index 48e16a4dbf27fcec5c0434e1df457e5f5a2f5dff..02cee6dd710321c7db574f4ba255eec9ea7c7e44 100644
--- a/civicrm/CRM/Contribute/BAO/Contribution.php
+++ b/civicrm/CRM/Contribute/BAO/Contribution.php
@@ -3337,6 +3337,9 @@ INNER JOIN civicrm_activity ON civicrm_activity_contact.activity_id = civicrm_ac
         'net_amount' => CRM_Utils_Array::value('net_amount', $params, $totalAmount),
         'currency' => $params['contribution']->currency,
         'trxn_id' => $params['contribution']->trxn_id,
+        // @todo - this is getting the status id from the contribution - that is BAD - ie the contribution could be partially
+        // paid but each payment is completed. The work around is to pass in the status_id in the trxn_params but
+        // this should really default to completed (after discussion).
         'status_id' => $statusId,
         'payment_instrument_id' => CRM_Utils_Array::value('payment_instrument_id', $params, $params['contribution']->payment_instrument_id),
         'check_number' => CRM_Utils_Array::value('check_number', $params),
@@ -3890,6 +3893,7 @@ INNER JOIN civicrm_activity ON civicrm_activity_contact.activity_id = civicrm_ac
       $financialTrxn = CRM_Financial_BAO_Payment::recordPayment($contributionId, $trxnsData, $participantId);
     }
     elseif ($paymentType == 'refund') {
+      $trxnsData['total_amount'] = -$trxnsData['total_amount'];
       $financialTrxn = CRM_Financial_BAO_Payment::recordRefundPayment($contributionId, $trxnsData, $updateStatus);
       if ($participantId) {
         // update participant status
diff --git a/civicrm/CRM/Contribute/BAO/ContributionRecur.php b/civicrm/CRM/Contribute/BAO/ContributionRecur.php
index c72b03236836a6d85e3324bde008f1883985b4ff..a416a9573f2031f630ffaa4deec4b5f363d66a68 100644
--- a/civicrm/CRM/Contribute/BAO/ContributionRecur.php
+++ b/civicrm/CRM/Contribute/BAO/ContributionRecur.php
@@ -342,44 +342,6 @@ class CRM_Contribute_BAO_ContributionRecur extends CRM_Contribute_DAO_Contributi
     return FALSE;
   }
 
-  /**
-   * @deprecated Get list of recurring contribution of contact Ids.
-   *
-   * @param int $contactId
-   *   Contact ID.
-   *
-   * @return array
-   *   list of recurring contribution fields
-   *
-   */
-  public static function getRecurContributions($contactId) {
-    CRM_Core_Error::deprecatedFunctionWarning('ContributionRecur.get API instead');
-    $params = [];
-    $recurDAO = new CRM_Contribute_DAO_ContributionRecur();
-    $recurDAO->contact_id = $contactId;
-    $recurDAO->find();
-    $contributionStatus = CRM_Contribute_PseudoConstant::contributionStatus();
-
-    while ($recurDAO->fetch()) {
-      $params[$recurDAO->id]['id'] = $recurDAO->id;
-      $params[$recurDAO->id]['contactId'] = $recurDAO->contact_id;
-      $params[$recurDAO->id]['start_date'] = $recurDAO->start_date;
-      $params[$recurDAO->id]['end_date'] = $recurDAO->end_date;
-      $params[$recurDAO->id]['next_sched_contribution_date'] = $recurDAO->next_sched_contribution_date;
-      $params[$recurDAO->id]['amount'] = $recurDAO->amount;
-      $params[$recurDAO->id]['currency'] = $recurDAO->currency;
-      $params[$recurDAO->id]['frequency_unit'] = $recurDAO->frequency_unit;
-      $params[$recurDAO->id]['frequency_interval'] = $recurDAO->frequency_interval;
-      $params[$recurDAO->id]['installments'] = $recurDAO->installments;
-      $params[$recurDAO->id]['contribution_status_id'] = $recurDAO->contribution_status_id;
-      $params[$recurDAO->id]['contribution_status'] = CRM_Utils_Array::value($recurDAO->contribution_status_id, $contributionStatus);
-      $params[$recurDAO->id]['is_test'] = $recurDAO->is_test;
-      $params[$recurDAO->id]['payment_processor_id'] = $recurDAO->payment_processor_id;
-    }
-
-    return $params;
-  }
-
   /**
    * @param int $entityID
    * @param string $entity
diff --git a/civicrm/CRM/Contribute/BAO/Query.php b/civicrm/CRM/Contribute/BAO/Query.php
index 3c51f78c2357ca658d922e1ddc88fcfc8d30c176..b70e3392b0da2aea2891ab1be6d2675a2de0df4c 100644
--- a/civicrm/CRM/Contribute/BAO/Query.php
+++ b/civicrm/CRM/Contribute/BAO/Query.php
@@ -47,8 +47,12 @@ class CRM_Contribute_BAO_Query extends CRM_Core_BAO_Query {
    *   Associative array of contribution fields
    */
   public static function getFields($checkPermission = TRUE) {
-    if (!isset(\Civi::$statics[__CLASS__]) || !isset(\Civi::$statics[__CLASS__]['fields']) || !isset(\Civi::$statics[__CLASS__]['contribution'])) {
-      $fields = CRM_Contribute_BAO_Contribution::exportableFields($checkPermission);
+    if (!isset(\Civi::$statics[__CLASS__]) || !isset(\Civi::$statics[__CLASS__]['fields']) || !isset(\Civi::$statics[__CLASS__]['fields']['contribution'])) {
+      // Adding fields with some care as those without unique names could clobber others.
+      // Refer to CRM_Contribute_Form_SearchTest for existing tests ... and to add more!
+      $testedRecurFields = array_fill_keys(['contribution_recur_trxn_id', 'contribution_recur_processor_id', 'contribution_recur_payment_processor_id'], 1);
+      $recurFields = array_intersect_key(CRM_Contribute_DAO_ContributionRecur::fields(), $testedRecurFields);
+      $fields = array_merge($recurFields, CRM_Contribute_BAO_Contribution::exportableFields($checkPermission));
       CRM_Contribute_BAO_Contribution::appendPseudoConstantsToFields($fields);
       unset($fields['contribution_contact_id']);
       \Civi::$statics[__CLASS__]['fields']['contribution'] = $fields;
@@ -382,13 +386,12 @@ class CRM_Contribute_BAO_Query extends CRM_Core_BAO_Query {
 
       case 'contribution_recur_processor_id':
       case 'contribution_recur_trxn_id':
-        $fieldName = str_replace('contribution_recur_', '', $name);
-        $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause("civicrm_contribution_recur.{$fieldName}",
+        $spec = $fields[$name];
+        $query->_where[$grouping][] = CRM_Contact_BAO_Query::buildClause($spec['where'],
           $op, $value, "String"
         );
-        $recurFields = CRM_Contribute_DAO_ContributionRecur::fields();
-        $query->_qill[$grouping][] = ts("Recurring Contribution %1 %2 '%3'", [1 => $recurFields[$fieldName]['title'], 2 => $op, 3 => $value]);
-        $query->_tables['civicrm_contribution_recur'] = $query->_whereTables['civicrm_contribution_recur'] = 1;
+        $query->_qill[$grouping][] = ts("Recurring Contribution %1 %2 '%3'", [1 => $fields[$name]['title'], 2 => $op, 3 => $value]);
+        $query->_tables[$spec['table_name']] = $query->_whereTables[$spec['table_name']] = 1;
         return;
 
       case 'contribution_recur_payment_made':
diff --git a/civicrm/CRM/Contribute/DAO/Contribution.php b/civicrm/CRM/Contribute/DAO/Contribution.php
index a3640ef1a4d960ddfa0cc4cbd3cee9ed63721955..c95672ed773ef34f5cdb4dcb6142f912cce7138d 100644
--- a/civicrm/CRM/Contribute/DAO/Contribution.php
+++ b/civicrm/CRM/Contribute/DAO/Contribution.php
@@ -270,8 +270,6 @@ class CRM_Contribute_DAO_Contribution extends CRM_Core_DAO {
           'required' => TRUE,
           'import' => TRUE,
           'where' => 'civicrm_contribution.id',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_contribution',
           'entity' => 'Contribution',
@@ -303,10 +301,8 @@ class CRM_Contribute_DAO_Contribution extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Financial Type'),
           'description' => ts('FK to Financial Type for (total_amount - non_deductible_amount).'),
-          'export' => TRUE,
           'where' => 'civicrm_contribution.financial_type_id',
-          'headerPattern' => '',
-          'dataPattern' => '',
+          'export' => TRUE,
           'table_name' => 'civicrm_contribution',
           'entity' => 'Contribution',
           'bao' => 'CRM_Contribute_BAO_Contribution',
@@ -328,8 +324,6 @@ class CRM_Contribute_DAO_Contribution extends CRM_Core_DAO {
           'description' => ts('The Contribution Page which triggered this contribution'),
           'import' => TRUE,
           'where' => 'civicrm_contribution.contribution_page_id',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_contribution',
           'entity' => 'Contribution',
@@ -350,10 +344,9 @@ class CRM_Contribute_DAO_Contribution extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Payment Method ID'),
           'description' => ts('FK to Payment Instrument'),
-          'export' => TRUE,
           'where' => 'civicrm_contribution.payment_instrument_id',
           'headerPattern' => '/^payment|(p(ayment\s)?instrument)$/i',
-          'dataPattern' => '',
+          'export' => TRUE,
           'table_name' => 'civicrm_contribution',
           'entity' => 'Contribution',
           'bao' => 'CRM_Contribute_BAO_Contribution',
@@ -485,7 +478,6 @@ class CRM_Contribute_DAO_Contribution extends CRM_Core_DAO {
           'import' => TRUE,
           'where' => 'civicrm_contribution.trxn_id',
           'headerPattern' => '/tr(ansactio|x)n(.?id)?/i',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_contribution',
           'entity' => 'Contribution',
@@ -505,7 +497,6 @@ class CRM_Contribute_DAO_Contribution extends CRM_Core_DAO {
           'import' => TRUE,
           'where' => 'civicrm_contribution.invoice_id',
           'headerPattern' => '/invoice(.?id)?/i',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_contribution',
           'entity' => 'Contribution',
@@ -525,7 +516,6 @@ class CRM_Contribute_DAO_Contribution extends CRM_Core_DAO {
           'import' => TRUE,
           'where' => 'civicrm_contribution.invoice_number',
           'headerPattern' => '/invoice(.?number)?/i',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_contribution',
           'entity' => 'Contribution',
@@ -588,7 +578,6 @@ class CRM_Contribute_DAO_Contribution extends CRM_Core_DAO {
           'import' => TRUE,
           'where' => 'civicrm_contribution.cancel_reason',
           'headerPattern' => '/(cancel.?)?reason/i',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_contribution',
           'entity' => 'Contribution',
@@ -646,7 +635,6 @@ class CRM_Contribute_DAO_Contribution extends CRM_Core_DAO {
           'import' => TRUE,
           'where' => 'civicrm_contribution.source',
           'headerPattern' => '/source/i',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_contribution',
           'entity' => 'Contribution',
@@ -662,8 +650,6 @@ class CRM_Contribute_DAO_Contribution extends CRM_Core_DAO {
           'title' => ts('Amount Label'),
           'import' => TRUE,
           'where' => 'civicrm_contribution.amount_level',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_contribution',
           'entity' => 'Contribution',
@@ -678,10 +664,8 @@ class CRM_Contribute_DAO_Contribution extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Recurring Contribution ID'),
           'description' => ts('Conditional foreign key to civicrm_contribution_recur id. Each contribution made in connection with a recurring contribution carries a foreign key to the recurring contribution record. This assumes we can track these processor initiated events.'),
-          'export' => TRUE,
           'where' => 'civicrm_contribution.contribution_recur_id',
-          'headerPattern' => '',
-          'dataPattern' => '',
+          'export' => TRUE,
           'table_name' => 'civicrm_contribution',
           'entity' => 'Contribution',
           'bao' => 'CRM_Contribute_BAO_Contribution',
@@ -694,8 +678,6 @@ class CRM_Contribute_DAO_Contribution extends CRM_Core_DAO {
           'title' => ts('Test'),
           'import' => TRUE,
           'where' => 'civicrm_contribution.is_test',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'default' => '0',
           'table_name' => 'civicrm_contribution',
@@ -712,8 +694,6 @@ class CRM_Contribute_DAO_Contribution extends CRM_Core_DAO {
           'title' => ts('Is Pay Later'),
           'import' => TRUE,
           'where' => 'civicrm_contribution.is_pay_later',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'default' => '0',
           'table_name' => 'civicrm_contribution',
@@ -731,7 +711,6 @@ class CRM_Contribute_DAO_Contribution extends CRM_Core_DAO {
           'import' => TRUE,
           'where' => 'civicrm_contribution.contribution_status_id',
           'headerPattern' => '/status/i',
-          'dataPattern' => '',
           'export' => TRUE,
           'default' => '1',
           'table_name' => 'civicrm_contribution',
@@ -751,10 +730,8 @@ class CRM_Contribute_DAO_Contribution extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Contribution Address'),
           'description' => ts('Conditional foreign key to civicrm_address.id. We insert an address record for each contribution when we have associated billing name and address data.'),
-          'export' => TRUE,
           'where' => 'civicrm_contribution.address_id',
-          'headerPattern' => '',
-          'dataPattern' => '',
+          'export' => TRUE,
           'table_name' => 'civicrm_contribution',
           'entity' => 'Contribution',
           'bao' => 'CRM_Contribute_BAO_Contribution',
@@ -770,7 +747,6 @@ class CRM_Contribute_DAO_Contribution extends CRM_Core_DAO {
           'import' => TRUE,
           'where' => 'civicrm_contribution.check_number',
           'headerPattern' => '/check(.?number)?/i',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_contribution',
           'entity' => 'Contribution',
@@ -787,8 +763,6 @@ class CRM_Contribute_DAO_Contribution extends CRM_Core_DAO {
           'description' => ts('The campaign for which this contribution has been triggered.'),
           'import' => TRUE,
           'where' => 'civicrm_contribution.campaign_id',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_contribution',
           'entity' => 'Contribution',
@@ -814,7 +788,6 @@ class CRM_Contribute_DAO_Contribution extends CRM_Core_DAO {
           'import' => TRUE,
           'where' => 'civicrm_contribution.creditnote_id',
           'headerPattern' => '/creditnote(.?id)?/i',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_contribution',
           'entity' => 'Contribution',
diff --git a/civicrm/CRM/Contribute/DAO/ContributionPage.php b/civicrm/CRM/Contribute/DAO/ContributionPage.php
index 116c52df9da67ad3411db38f4fb4daad193fb6e2..e75fa97d995eff5fbf557ff3a6beb221e4a367b4 100644
--- a/civicrm/CRM/Contribute/DAO/ContributionPage.php
+++ b/civicrm/CRM/Contribute/DAO/ContributionPage.php
@@ -382,6 +382,7 @@ class CRM_Contribute_DAO_ContributionPage extends CRM_Core_DAO {
           'title' => ts('Contribution Page ID'),
           'description' => ts('Contribution Id'),
           'required' => TRUE,
+          'where' => 'civicrm_contribution_page.id',
           'table_name' => 'civicrm_contribution_page',
           'entity' => 'ContributionPage',
           'bao' => 'CRM_Contribute_BAO_ContributionPage',
@@ -394,6 +395,7 @@ class CRM_Contribute_DAO_ContributionPage extends CRM_Core_DAO {
           'description' => ts('Contribution Page title. For top of page display'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_contribution_page.title',
           'table_name' => 'civicrm_contribution_page',
           'entity' => 'ContributionPage',
           'bao' => 'CRM_Contribute_BAO_ContributionPage',
@@ -406,6 +408,7 @@ class CRM_Contribute_DAO_ContributionPage extends CRM_Core_DAO {
           'description' => ts('Text and html allowed. Displayed below title.'),
           'rows' => 6,
           'cols' => 50,
+          'where' => 'civicrm_contribution_page.intro_text',
           'table_name' => 'civicrm_contribution_page',
           'entity' => 'ContributionPage',
           'bao' => 'CRM_Contribute_BAO_ContributionPage',
@@ -419,6 +422,7 @@ class CRM_Contribute_DAO_ContributionPage extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Financial Type'),
           'description' => ts('default financial type assigned to contributions submitted via this page, e.g. Contribution, Campaign Contribution'),
+          'where' => 'civicrm_contribution_page.financial_type_id',
           'table_name' => 'civicrm_contribution_page',
           'entity' => 'ContributionPage',
           'bao' => 'CRM_Contribute_BAO_ContributionPage',
@@ -440,6 +444,7 @@ class CRM_Contribute_DAO_ContributionPage extends CRM_Core_DAO {
           'description' => ts('Payment Processors configured for this contribution Page'),
           'maxlength' => 128,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_contribution_page.payment_processor',
           'table_name' => 'civicrm_contribution_page',
           'entity' => 'ContributionPage',
           'bao' => 'CRM_Contribute_BAO_ContributionPage',
@@ -458,6 +463,7 @@ class CRM_Contribute_DAO_ContributionPage extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Is Credit Card Only?'),
           'description' => ts('if true - processing logic must reject transaction at confirmation stage if pay method != credit card'),
+          'where' => 'civicrm_contribution_page.is_credit_card_only',
           'default' => '0',
           'table_name' => 'civicrm_contribution_page',
           'entity' => 'ContributionPage',
@@ -469,6 +475,7 @@ class CRM_Contribute_DAO_ContributionPage extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Is Monetary'),
           'description' => ts('if true - allows real-time monetary transactions otherwise non-monetary transactions'),
+          'where' => 'civicrm_contribution_page.is_monetary',
           'default' => '1',
           'table_name' => 'civicrm_contribution_page',
           'entity' => 'ContributionPage',
@@ -480,6 +487,7 @@ class CRM_Contribute_DAO_ContributionPage extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Is Recurring'),
           'description' => ts('if true - allows recurring contributions, valid only for PayPal_Standard'),
+          'where' => 'civicrm_contribution_page.is_recur',
           'default' => '0',
           'table_name' => 'civicrm_contribution_page',
           'entity' => 'ContributionPage',
@@ -491,6 +499,7 @@ class CRM_Contribute_DAO_ContributionPage extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Confirmation Page?'),
           'description' => ts('if false, the confirm page in contribution pages gets skipped'),
+          'where' => 'civicrm_contribution_page.is_confirm_enabled',
           'default' => '1',
           'table_name' => 'civicrm_contribution_page',
           'entity' => 'ContributionPage',
@@ -504,6 +513,7 @@ class CRM_Contribute_DAO_ContributionPage extends CRM_Core_DAO {
           'description' => ts('Supported recurring frequency units.'),
           'maxlength' => 128,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_contribution_page.recur_frequency_unit',
           'table_name' => 'civicrm_contribution_page',
           'entity' => 'ContributionPage',
           'bao' => 'CRM_Contribute_BAO_ContributionPage',
@@ -523,6 +533,7 @@ class CRM_Contribute_DAO_ContributionPage extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Support Recurring Intervals'),
           'description' => ts('if true - supports recurring intervals'),
+          'where' => 'civicrm_contribution_page.is_recur_interval',
           'default' => '0',
           'table_name' => 'civicrm_contribution_page',
           'entity' => 'ContributionPage',
@@ -534,6 +545,7 @@ class CRM_Contribute_DAO_ContributionPage extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Recurring Installments?'),
           'description' => ts('if true - asks user for recurring installments'),
+          'where' => 'civicrm_contribution_page.is_recur_installments',
           'default' => '0',
           'table_name' => 'civicrm_contribution_page',
           'entity' => 'ContributionPage',
@@ -545,6 +557,7 @@ class CRM_Contribute_DAO_ContributionPage extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Adjust Recurring Start Date'),
           'description' => ts('if true - user is able to adjust payment start date'),
+          'where' => 'civicrm_contribution_page.adjust_recur_start_date',
           'default' => '0',
           'table_name' => 'civicrm_contribution_page',
           'entity' => 'ContributionPage',
@@ -556,6 +569,7 @@ class CRM_Contribute_DAO_ContributionPage extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Pay Later'),
           'description' => ts('if true - allows the user to send payment directly to the org later'),
+          'where' => 'civicrm_contribution_page.is_pay_later',
           'default' => '0',
           'table_name' => 'civicrm_contribution_page',
           'entity' => 'ContributionPage',
@@ -567,6 +581,7 @@ class CRM_Contribute_DAO_ContributionPage extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_TEXT,
           'title' => ts('Pay Later Text'),
           'description' => ts('The text displayed to the user in the main form'),
+          'where' => 'civicrm_contribution_page.pay_later_text',
           'table_name' => 'civicrm_contribution_page',
           'entity' => 'ContributionPage',
           'bao' => 'CRM_Contribute_BAO_ContributionPage',
@@ -577,6 +592,7 @@ class CRM_Contribute_DAO_ContributionPage extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_TEXT,
           'title' => ts('Pay Later Receipt'),
           'description' => ts('The receipt sent to the user instead of the normal receipt text'),
+          'where' => 'civicrm_contribution_page.pay_later_receipt',
           'table_name' => 'civicrm_contribution_page',
           'entity' => 'ContributionPage',
           'bao' => 'CRM_Contribute_BAO_ContributionPage',
@@ -587,6 +603,7 @@ class CRM_Contribute_DAO_ContributionPage extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Allow Partial Payment'),
           'description' => ts('is partial payment enabled for this online contribution page'),
+          'where' => 'civicrm_contribution_page.is_partial_payment',
           'default' => '0',
           'table_name' => 'civicrm_contribution_page',
           'entity' => 'ContributionPage',
@@ -600,6 +617,7 @@ class CRM_Contribute_DAO_ContributionPage extends CRM_Core_DAO {
           'description' => ts('Initial amount label for partial payment'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_contribution_page.initial_amount_label',
           'table_name' => 'civicrm_contribution_page',
           'entity' => 'ContributionPage',
           'bao' => 'CRM_Contribute_BAO_ContributionPage',
@@ -610,6 +628,7 @@ class CRM_Contribute_DAO_ContributionPage extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_TEXT,
           'title' => ts('Initial Amount Help Text'),
           'description' => ts('Initial amount help text for partial payment'),
+          'where' => 'civicrm_contribution_page.initial_amount_help_text',
           'table_name' => 'civicrm_contribution_page',
           'entity' => 'ContributionPage',
           'bao' => 'CRM_Contribute_BAO_ContributionPage',
@@ -624,6 +643,7 @@ class CRM_Contribute_DAO_ContributionPage extends CRM_Core_DAO {
             20,
             2
           ],
+          'where' => 'civicrm_contribution_page.min_initial_amount',
           'table_name' => 'civicrm_contribution_page',
           'entity' => 'ContributionPage',
           'bao' => 'CRM_Contribute_BAO_ContributionPage',
@@ -634,6 +654,7 @@ class CRM_Contribute_DAO_ContributionPage extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Allow Other Amounts'),
           'description' => ts('if true, page will include an input text field where user can enter their own amount'),
+          'where' => 'civicrm_contribution_page.is_allow_other_amount',
           'default' => '0',
           'table_name' => 'civicrm_contribution_page',
           'entity' => 'ContributionPage',
@@ -645,6 +666,7 @@ class CRM_Contribute_DAO_ContributionPage extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Default Amount'),
           'description' => ts('FK to civicrm_option_value.'),
+          'where' => 'civicrm_contribution_page.default_amount_id',
           'table_name' => 'civicrm_contribution_page',
           'entity' => 'ContributionPage',
           'bao' => 'CRM_Contribute_BAO_ContributionPage',
@@ -659,6 +681,7 @@ class CRM_Contribute_DAO_ContributionPage extends CRM_Core_DAO {
             20,
             2
           ],
+          'where' => 'civicrm_contribution_page.min_amount',
           'table_name' => 'civicrm_contribution_page',
           'entity' => 'ContributionPage',
           'bao' => 'CRM_Contribute_BAO_ContributionPage',
@@ -673,6 +696,7 @@ class CRM_Contribute_DAO_ContributionPage extends CRM_Core_DAO {
             20,
             2
           ],
+          'where' => 'civicrm_contribution_page.max_amount',
           'table_name' => 'civicrm_contribution_page',
           'entity' => 'ContributionPage',
           'bao' => 'CRM_Contribute_BAO_ContributionPage',
@@ -687,6 +711,7 @@ class CRM_Contribute_DAO_ContributionPage extends CRM_Core_DAO {
             20,
             2
           ],
+          'where' => 'civicrm_contribution_page.goal_amount',
           'table_name' => 'civicrm_contribution_page',
           'entity' => 'ContributionPage',
           'bao' => 'CRM_Contribute_BAO_ContributionPage',
@@ -699,6 +724,7 @@ class CRM_Contribute_DAO_ContributionPage extends CRM_Core_DAO {
           'description' => ts('Title for Thank-you page (header title tag, and display at the top of the page).'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_contribution_page.thankyou_title',
           'table_name' => 'civicrm_contribution_page',
           'entity' => 'ContributionPage',
           'bao' => 'CRM_Contribute_BAO_ContributionPage',
@@ -711,6 +737,7 @@ class CRM_Contribute_DAO_ContributionPage extends CRM_Core_DAO {
           'description' => ts('text and html allowed. displayed above result on success page'),
           'rows' => 8,
           'cols' => 60,
+          'where' => 'civicrm_contribution_page.thankyou_text',
           'table_name' => 'civicrm_contribution_page',
           'entity' => 'ContributionPage',
           'bao' => 'CRM_Contribute_BAO_ContributionPage',
@@ -726,6 +753,7 @@ class CRM_Contribute_DAO_ContributionPage extends CRM_Core_DAO {
           'description' => ts('Text and html allowed. displayed at the bottom of the success page. Common usage is to include link(s) to other pages such as tell-a-friend, etc.'),
           'rows' => 8,
           'cols' => 60,
+          'where' => 'civicrm_contribution_page.thankyou_footer',
           'table_name' => 'civicrm_contribution_page',
           'entity' => 'ContributionPage',
           'bao' => 'CRM_Contribute_BAO_ContributionPage',
@@ -739,6 +767,7 @@ class CRM_Contribute_DAO_ContributionPage extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Send email Receipt'),
           'description' => ts('if true, receipt is automatically emailed to contact on success'),
+          'where' => 'civicrm_contribution_page.is_email_receipt',
           'default' => '0',
           'table_name' => 'civicrm_contribution_page',
           'entity' => 'ContributionPage',
@@ -752,6 +781,7 @@ class CRM_Contribute_DAO_ContributionPage extends CRM_Core_DAO {
           'description' => ts('FROM email name used for receipts generated by contributions to this contribution page.'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_contribution_page.receipt_from_name',
           'table_name' => 'civicrm_contribution_page',
           'entity' => 'ContributionPage',
           'bao' => 'CRM_Contribute_BAO_ContributionPage',
@@ -764,6 +794,7 @@ class CRM_Contribute_DAO_ContributionPage extends CRM_Core_DAO {
           'description' => ts('FROM email address used for receipts generated by contributions to this contribution page.'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_contribution_page.receipt_from_email',
           'table_name' => 'civicrm_contribution_page',
           'entity' => 'ContributionPage',
           'bao' => 'CRM_Contribute_BAO_ContributionPage',
@@ -776,6 +807,7 @@ class CRM_Contribute_DAO_ContributionPage extends CRM_Core_DAO {
           'description' => ts('comma-separated list of email addresses to cc each time a receipt is sent'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_contribution_page.cc_receipt',
           'table_name' => 'civicrm_contribution_page',
           'entity' => 'ContributionPage',
           'bao' => 'CRM_Contribute_BAO_ContributionPage',
@@ -788,6 +820,7 @@ class CRM_Contribute_DAO_ContributionPage extends CRM_Core_DAO {
           'description' => ts('comma-separated list of email addresses to bcc each time a receipt is sent'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_contribution_page.bcc_receipt',
           'table_name' => 'civicrm_contribution_page',
           'entity' => 'ContributionPage',
           'bao' => 'CRM_Contribute_BAO_ContributionPage',
@@ -800,6 +833,7 @@ class CRM_Contribute_DAO_ContributionPage extends CRM_Core_DAO {
           'description' => ts('text to include above standard receipt info on receipt email. emails are text-only, so do not allow html for now'),
           'rows' => 6,
           'cols' => 50,
+          'where' => 'civicrm_contribution_page.receipt_text',
           'table_name' => 'civicrm_contribution_page',
           'entity' => 'ContributionPage',
           'bao' => 'CRM_Contribute_BAO_ContributionPage',
@@ -813,6 +847,7 @@ class CRM_Contribute_DAO_ContributionPage extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Is Page Active?'),
           'description' => ts('Is this property active?'),
+          'where' => 'civicrm_contribution_page.is_active',
           'table_name' => 'civicrm_contribution_page',
           'entity' => 'ContributionPage',
           'bao' => 'CRM_Contribute_BAO_ContributionPage',
@@ -825,6 +860,7 @@ class CRM_Contribute_DAO_ContributionPage extends CRM_Core_DAO {
           'description' => ts('Text and html allowed. Displayed at the bottom of the first page of the contribution wizard.'),
           'rows' => 6,
           'cols' => 50,
+          'where' => 'civicrm_contribution_page.footer_text',
           'table_name' => 'civicrm_contribution_page',
           'entity' => 'ContributionPage',
           'bao' => 'CRM_Contribute_BAO_ContributionPage',
@@ -838,6 +874,7 @@ class CRM_Contribute_DAO_ContributionPage extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Is Amount Block Active?'),
           'description' => ts('Is this property active?'),
+          'where' => 'civicrm_contribution_page.amount_block_is_active',
           'default' => '1',
           'table_name' => 'civicrm_contribution_page',
           'entity' => 'ContributionPage',
@@ -849,6 +886,7 @@ class CRM_Contribute_DAO_ContributionPage extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
           'title' => ts('Contribution Page Start Date'),
           'description' => ts('Date and time that this page starts.'),
+          'where' => 'civicrm_contribution_page.start_date',
           'table_name' => 'civicrm_contribution_page',
           'entity' => 'ContributionPage',
           'bao' => 'CRM_Contribute_BAO_ContributionPage',
@@ -859,6 +897,7 @@ class CRM_Contribute_DAO_ContributionPage extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
           'title' => ts('Contribution Page End Date'),
           'description' => ts('Date and time that this page ends. May be NULL if no defined end date/time'),
+          'where' => 'civicrm_contribution_page.end_date',
           'table_name' => 'civicrm_contribution_page',
           'entity' => 'ContributionPage',
           'bao' => 'CRM_Contribute_BAO_ContributionPage',
@@ -869,6 +908,7 @@ class CRM_Contribute_DAO_ContributionPage extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Contribution Page Created By'),
           'description' => ts('FK to civicrm_contact, who created this contribution page'),
+          'where' => 'civicrm_contribution_page.created_id',
           'table_name' => 'civicrm_contribution_page',
           'entity' => 'ContributionPage',
           'bao' => 'CRM_Contribute_BAO_ContributionPage',
@@ -880,6 +920,7 @@ class CRM_Contribute_DAO_ContributionPage extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
           'title' => ts('Contribution Page Created Date'),
           'description' => ts('Date and time that contribution page was created.'),
+          'where' => 'civicrm_contribution_page.created_date',
           'table_name' => 'civicrm_contribution_page',
           'entity' => 'ContributionPage',
           'bao' => 'CRM_Contribute_BAO_ContributionPage',
@@ -892,6 +933,9 @@ class CRM_Contribute_DAO_ContributionPage extends CRM_Core_DAO {
           'description' => ts('3 character string, value from config setting or input via user.'),
           'maxlength' => 3,
           'size' => CRM_Utils_Type::FOUR,
+          'where' => 'civicrm_contribution_page.currency',
+          'headerPattern' => '/cur(rency)?/i',
+          'dataPattern' => '/^[A-Z]{3}$/i',
           'default' => 'NULL',
           'table_name' => 'civicrm_contribution_page',
           'entity' => 'ContributionPage',
@@ -912,6 +956,7 @@ class CRM_Contribute_DAO_ContributionPage extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Contribution Page Campaign ID'),
           'description' => ts('The campaign for which we are collecting contributions with this page.'),
+          'where' => 'civicrm_contribution_page.campaign_id',
           'table_name' => 'civicrm_contribution_page',
           'entity' => 'ContributionPage',
           'bao' => 'CRM_Contribute_BAO_ContributionPage',
@@ -928,6 +973,7 @@ class CRM_Contribute_DAO_ContributionPage extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Is Contribution Page Shared?'),
           'description' => ts('Can people share the contribution page through social media?'),
+          'where' => 'civicrm_contribution_page.is_share',
           'default' => '1',
           'table_name' => 'civicrm_contribution_page',
           'entity' => 'ContributionPage',
@@ -939,6 +985,7 @@ class CRM_Contribute_DAO_ContributionPage extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Is billing block required'),
           'description' => ts('if true - billing block is required for online contribution page'),
+          'where' => 'civicrm_contribution_page.is_billing_required',
           'default' => '0',
           'table_name' => 'civicrm_contribution_page',
           'entity' => 'ContributionPage',
diff --git a/civicrm/CRM/Contribute/DAO/ContributionProduct.php b/civicrm/CRM/Contribute/DAO/ContributionProduct.php
index 58dd6257ce82d868b455baf34110886b21586294..8fa970114ce33951e5c86b4301894c01a60a2b3b 100644
--- a/civicrm/CRM/Contribute/DAO/ContributionProduct.php
+++ b/civicrm/CRM/Contribute/DAO/ContributionProduct.php
@@ -125,6 +125,7 @@ class CRM_Contribute_DAO_ContributionProduct extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Contribution Product ID'),
           'required' => TRUE,
+          'where' => 'civicrm_contribution_product.id',
           'table_name' => 'civicrm_contribution_product',
           'entity' => 'ContributionProduct',
           'bao' => 'CRM_Contribute_DAO_ContributionProduct',
@@ -135,6 +136,7 @@ class CRM_Contribute_DAO_ContributionProduct extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Product ID'),
           'required' => TRUE,
+          'where' => 'civicrm_contribution_product.product_id',
           'table_name' => 'civicrm_contribution_product',
           'entity' => 'ContributionProduct',
           'bao' => 'CRM_Contribute_DAO_ContributionProduct',
@@ -145,6 +147,7 @@ class CRM_Contribute_DAO_ContributionProduct extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Contribution ID'),
           'required' => TRUE,
+          'where' => 'civicrm_contribution_product.contribution_id',
           'table_name' => 'civicrm_contribution_product',
           'entity' => 'ContributionProduct',
           'bao' => 'CRM_Contribute_DAO_ContributionProduct',
@@ -158,10 +161,8 @@ class CRM_Contribute_DAO_ContributionProduct extends CRM_Core_DAO {
           'description' => ts('Option value selected if applicable - e.g. color, size etc.'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
-          'export' => TRUE,
           'where' => 'civicrm_contribution_product.product_option',
-          'headerPattern' => '',
-          'dataPattern' => '',
+          'export' => TRUE,
           'table_name' => 'civicrm_contribution_product',
           'entity' => 'ContributionProduct',
           'bao' => 'CRM_Contribute_DAO_ContributionProduct',
@@ -171,10 +172,8 @@ class CRM_Contribute_DAO_ContributionProduct extends CRM_Core_DAO {
           'name' => 'quantity',
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Quantity'),
-          'export' => TRUE,
           'where' => 'civicrm_contribution_product.quantity',
-          'headerPattern' => '',
-          'dataPattern' => '',
+          'export' => TRUE,
           'table_name' => 'civicrm_contribution_product',
           'entity' => 'ContributionProduct',
           'bao' => 'CRM_Contribute_DAO_ContributionProduct',
@@ -185,10 +184,8 @@ class CRM_Contribute_DAO_ContributionProduct extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_DATE,
           'title' => ts('Fulfilled Date'),
           'description' => ts('Optional. Can be used to record the date this product was fulfilled or shipped.'),
-          'export' => TRUE,
           'where' => 'civicrm_contribution_product.fulfilled_date',
-          'headerPattern' => '',
-          'dataPattern' => '',
+          'export' => TRUE,
           'table_name' => 'civicrm_contribution_product',
           'entity' => 'ContributionProduct',
           'bao' => 'CRM_Contribute_DAO_ContributionProduct',
@@ -203,10 +200,8 @@ class CRM_Contribute_DAO_ContributionProduct extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_DATE,
           'title' => ts('Start date for premium'),
           'description' => ts('Actual start date for a time-delimited premium (subscription, service or membership)'),
-          'export' => TRUE,
           'where' => 'civicrm_contribution_product.start_date',
-          'headerPattern' => '',
-          'dataPattern' => '',
+          'export' => TRUE,
           'table_name' => 'civicrm_contribution_product',
           'entity' => 'ContributionProduct',
           'bao' => 'CRM_Contribute_DAO_ContributionProduct',
@@ -217,10 +212,8 @@ class CRM_Contribute_DAO_ContributionProduct extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_DATE,
           'title' => ts('End date for premium'),
           'description' => ts('Actual end date for a time-delimited premium (subscription, service or membership)'),
-          'export' => TRUE,
           'where' => 'civicrm_contribution_product.end_date',
-          'headerPattern' => '',
-          'dataPattern' => '',
+          'export' => TRUE,
           'table_name' => 'civicrm_contribution_product',
           'entity' => 'ContributionProduct',
           'bao' => 'CRM_Contribute_DAO_ContributionProduct',
@@ -230,6 +223,7 @@ class CRM_Contribute_DAO_ContributionProduct extends CRM_Core_DAO {
           'name' => 'comment',
           'type' => CRM_Utils_Type::T_TEXT,
           'title' => ts('Premium comment'),
+          'where' => 'civicrm_contribution_product.comment',
           'table_name' => 'civicrm_contribution_product',
           'entity' => 'ContributionProduct',
           'bao' => 'CRM_Contribute_DAO_ContributionProduct',
@@ -240,6 +234,7 @@ class CRM_Contribute_DAO_ContributionProduct extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Financial Type'),
           'description' => ts('FK to Financial Type(for membership price sets only).'),
+          'where' => 'civicrm_contribution_product.financial_type_id',
           'default' => 'NULL',
           'table_name' => 'civicrm_contribution_product',
           'entity' => 'ContributionProduct',
diff --git a/civicrm/CRM/Contribute/DAO/ContributionRecur.php b/civicrm/CRM/Contribute/DAO/ContributionRecur.php
index ba78c33c9c6e71b9642f5514dcd6f73804a72ca9..525f08b968f5e2a4d53ef7f7424b84d78ca8f19e 100644
--- a/civicrm/CRM/Contribute/DAO/ContributionRecur.php
+++ b/civicrm/CRM/Contribute/DAO/ContributionRecur.php
@@ -6,7 +6,7 @@
  *
  * Generated from xml/schema/CRM/Contribute/ContributionRecur.xml
  * DO NOT EDIT.  Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:2ccc42487b9e4e5774fcfcde7db9c5ae)
+ * (GenCodeChecksum:9859d3b98d51f0f1df207253199186ab)
  */
 
 /**
@@ -262,12 +262,13 @@ class CRM_Contribute_DAO_ContributionRecur extends CRM_Core_DAO {
   public static function &fields() {
     if (!isset(Civi::$statics[__CLASS__]['fields'])) {
       Civi::$statics[__CLASS__]['fields'] = [
-        'id' => [
+        'contribution_recur_id' => [
           'name' => 'id',
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Recurring Contribution ID'),
           'description' => ts('Contribution Recur ID'),
           'required' => TRUE,
+          'where' => 'civicrm_contribution_recur.id',
           'table_name' => 'civicrm_contribution_recur',
           'entity' => 'ContributionRecur',
           'bao' => 'CRM_Contribute_BAO_ContributionRecur',
@@ -279,6 +280,7 @@ class CRM_Contribute_DAO_ContributionRecur extends CRM_Core_DAO {
           'title' => ts('Contact'),
           'description' => ts('Foreign key to civicrm_contact.id.'),
           'required' => TRUE,
+          'where' => 'civicrm_contribution_recur.contact_id',
           'table_name' => 'civicrm_contribution_recur',
           'entity' => 'ContributionRecur',
           'bao' => 'CRM_Contribute_BAO_ContributionRecur',
@@ -298,6 +300,7 @@ class CRM_Contribute_DAO_ContributionRecur extends CRM_Core_DAO {
             20,
             2
           ],
+          'where' => 'civicrm_contribution_recur.amount',
           'table_name' => 'civicrm_contribution_recur',
           'entity' => 'ContributionRecur',
           'bao' => 'CRM_Contribute_BAO_ContributionRecur',
@@ -313,6 +316,7 @@ class CRM_Contribute_DAO_ContributionRecur extends CRM_Core_DAO {
           'description' => ts('3 character string, value from config setting or input via user.'),
           'maxlength' => 3,
           'size' => CRM_Utils_Type::FOUR,
+          'where' => 'civicrm_contribution_recur.currency',
           'default' => 'NULL',
           'table_name' => 'civicrm_contribution_recur',
           'entity' => 'ContributionRecur',
@@ -335,6 +339,7 @@ class CRM_Contribute_DAO_ContributionRecur extends CRM_Core_DAO {
           'description' => ts('Time units for recurrence of payment.'),
           'maxlength' => 8,
           'size' => CRM_Utils_Type::EIGHT,
+          'where' => 'civicrm_contribution_recur.frequency_unit',
           'default' => 'month',
           'table_name' => 'civicrm_contribution_recur',
           'entity' => 'ContributionRecur',
@@ -355,6 +360,7 @@ class CRM_Contribute_DAO_ContributionRecur extends CRM_Core_DAO {
           'title' => ts('Interval (number of units)'),
           'description' => ts('Number of time units for recurrence of payment.'),
           'required' => TRUE,
+          'where' => 'civicrm_contribution_recur.frequency_interval',
           'table_name' => 'civicrm_contribution_recur',
           'entity' => 'ContributionRecur',
           'bao' => 'CRM_Contribute_BAO_ContributionRecur',
@@ -368,6 +374,7 @@ class CRM_Contribute_DAO_ContributionRecur extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Number of Installments'),
           'description' => ts('Total number of payments to be made. Set this to 0 if this is an open-ended commitment i.e. no set end date.'),
+          'where' => 'civicrm_contribution_recur.installments',
           'table_name' => 'civicrm_contribution_recur',
           'entity' => 'ContributionRecur',
           'bao' => 'CRM_Contribute_BAO_ContributionRecur',
@@ -382,6 +389,7 @@ class CRM_Contribute_DAO_ContributionRecur extends CRM_Core_DAO {
           'title' => ts('Start Date'),
           'description' => ts('The date the first scheduled recurring contribution occurs.'),
           'required' => TRUE,
+          'where' => 'civicrm_contribution_recur.start_date',
           'table_name' => 'civicrm_contribution_recur',
           'entity' => 'ContributionRecur',
           'bao' => 'CRM_Contribute_BAO_ContributionRecur',
@@ -397,6 +405,7 @@ class CRM_Contribute_DAO_ContributionRecur extends CRM_Core_DAO {
           'title' => ts('Created Date'),
           'description' => ts('When this recurring contribution record was created.'),
           'required' => TRUE,
+          'where' => 'civicrm_contribution_recur.create_date',
           'table_name' => 'civicrm_contribution_recur',
           'entity' => 'ContributionRecur',
           'bao' => 'CRM_Contribute_BAO_ContributionRecur',
@@ -411,6 +420,7 @@ class CRM_Contribute_DAO_ContributionRecur extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
           'title' => ts('Modified Date'),
           'description' => ts('Last updated date for this record. mostly the last time a payment was received'),
+          'where' => 'civicrm_contribution_recur.modified_date',
           'table_name' => 'civicrm_contribution_recur',
           'entity' => 'ContributionRecur',
           'bao' => 'CRM_Contribute_BAO_ContributionRecur',
@@ -425,6 +435,7 @@ class CRM_Contribute_DAO_ContributionRecur extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
           'title' => ts('Cancel Date'),
           'description' => ts('Date this recurring contribution was cancelled by contributor- if we can get access to it'),
+          'where' => 'civicrm_contribution_recur.cancel_date',
           'table_name' => 'civicrm_contribution_recur',
           'entity' => 'ContributionRecur',
           'bao' => 'CRM_Contribute_BAO_ContributionRecur',
@@ -439,6 +450,7 @@ class CRM_Contribute_DAO_ContributionRecur extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_TEXT,
           'title' => ts('Cancellation Reason'),
           'description' => ts('Free text field for a reason for cancelling'),
+          'where' => 'civicrm_contribution_recur.cancel_reason',
           'table_name' => 'civicrm_contribution_recur',
           'entity' => 'ContributionRecur',
           'bao' => 'CRM_Contribute_BAO_ContributionRecur',
@@ -452,6 +464,7 @@ class CRM_Contribute_DAO_ContributionRecur extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
           'title' => ts('Recurring Contribution End Date'),
           'description' => ts('Date this recurring contribution finished successfully'),
+          'where' => 'civicrm_contribution_recur.end_date',
           'table_name' => 'civicrm_contribution_recur',
           'entity' => 'ContributionRecur',
           'bao' => 'CRM_Contribute_BAO_ContributionRecur',
@@ -461,13 +474,14 @@ class CRM_Contribute_DAO_ContributionRecur extends CRM_Core_DAO {
             'formatType' => 'activityDate',
           ],
         ],
-        'processor_id' => [
+        'contribution_recur_processor_id' => [
           'name' => 'processor_id',
           'type' => CRM_Utils_Type::T_STRING,
           'title' => ts('Processor ID'),
           'description' => ts('Possibly needed to store a unique identifier for this recurring payment order - if this is available from the processor??'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_contribution_recur.processor_id',
           'table_name' => 'civicrm_contribution_recur',
           'entity' => 'ContributionRecur',
           'bao' => 'CRM_Contribute_BAO_ContributionRecur',
@@ -481,19 +495,21 @@ class CRM_Contribute_DAO_ContributionRecur extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Payment Token ID'),
           'description' => ts('Optionally used to store a link to a payment token used for this recurring contribution.'),
+          'where' => 'civicrm_contribution_recur.payment_token_id',
           'table_name' => 'civicrm_contribution_recur',
           'entity' => 'ContributionRecur',
           'bao' => 'CRM_Contribute_BAO_ContributionRecur',
           'localizable' => 0,
           'FKClassName' => 'CRM_Financial_DAO_PaymentToken',
         ],
-        'trxn_id' => [
+        'contribution_recur_trxn_id' => [
           'name' => 'trxn_id',
           'type' => CRM_Utils_Type::T_STRING,
           'title' => ts('Transaction ID'),
           'description' => ts('unique transaction id. may be processor id, bank id + trans id, or account number + check number... depending on payment_method'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_contribution_recur.trxn_id',
           'table_name' => 'civicrm_contribution_recur',
           'entity' => 'ContributionRecur',
           'bao' => 'CRM_Contribute_BAO_ContributionRecur',
@@ -509,6 +525,7 @@ class CRM_Contribute_DAO_ContributionRecur extends CRM_Core_DAO {
           'description' => ts('unique invoice id, system generated or passed in'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_contribution_recur.invoice_id',
           'table_name' => 'civicrm_contribution_recur',
           'entity' => 'ContributionRecur',
           'bao' => 'CRM_Contribute_BAO_ContributionRecur',
@@ -517,14 +534,12 @@ class CRM_Contribute_DAO_ContributionRecur extends CRM_Core_DAO {
             'type' => 'Text',
           ],
         ],
-        'contribution_status_id' => [
+        'contribution_recur_contribution_status_id' => [
           'name' => 'contribution_status_id',
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Status'),
           'import' => TRUE,
           'where' => 'civicrm_contribution_recur.contribution_status_id',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'default' => '1',
           'table_name' => 'civicrm_contribution_recur',
@@ -545,8 +560,6 @@ class CRM_Contribute_DAO_ContributionRecur extends CRM_Core_DAO {
           'title' => ts('Test'),
           'import' => TRUE,
           'where' => 'civicrm_contribution_recur.is_test',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'default' => '0',
           'table_name' => 'civicrm_contribution_recur',
@@ -563,6 +576,7 @@ class CRM_Contribute_DAO_ContributionRecur extends CRM_Core_DAO {
           'title' => ts('Cycle Day'),
           'description' => ts('Day in the period when the payment should be charged e.g. 1st of month, 15th etc.'),
           'required' => TRUE,
+          'where' => 'civicrm_contribution_recur.cycle_day',
           'default' => '1',
           'table_name' => 'civicrm_contribution_recur',
           'entity' => 'ContributionRecur',
@@ -577,6 +591,7 @@ class CRM_Contribute_DAO_ContributionRecur extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
           'title' => ts('Next Scheduled Contribution Date'),
           'description' => ts('Next scheduled date'),
+          'where' => 'civicrm_contribution_recur.next_sched_contribution_date',
           'table_name' => 'civicrm_contribution_recur',
           'entity' => 'ContributionRecur',
           'bao' => 'CRM_Contribute_BAO_ContributionRecur',
@@ -591,6 +606,7 @@ class CRM_Contribute_DAO_ContributionRecur extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Number of Failures'),
           'description' => ts('Number of failed charge attempts since last success. Business rule could be set to deactivate on more than x failures.'),
+          'where' => 'civicrm_contribution_recur.failure_count',
           'default' => '0',
           'table_name' => 'civicrm_contribution_recur',
           'entity' => 'ContributionRecur',
@@ -605,6 +621,7 @@ class CRM_Contribute_DAO_ContributionRecur extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
           'title' => ts('Retry Failed Attempt Date'),
           'description' => ts('Date to retry failed attempt'),
+          'where' => 'civicrm_contribution_recur.failure_retry_date',
           'table_name' => 'civicrm_contribution_recur',
           'entity' => 'ContributionRecur',
           'bao' => 'CRM_Contribute_BAO_ContributionRecur',
@@ -620,6 +637,7 @@ class CRM_Contribute_DAO_ContributionRecur extends CRM_Core_DAO {
           'title' => ts('Auto Renew'),
           'description' => ts('Some systems allow contributor to set a number of installments - but then auto-renew the subscription or commitment if they do not cancel.'),
           'required' => TRUE,
+          'where' => 'civicrm_contribution_recur.auto_renew',
           'default' => '0',
           'table_name' => 'civicrm_contribution_recur',
           'entity' => 'ContributionRecur',
@@ -629,11 +647,12 @@ class CRM_Contribute_DAO_ContributionRecur extends CRM_Core_DAO {
             'type' => 'CheckBox',
           ],
         ],
-        'payment_processor_id' => [
+        'contribution_recur_payment_processor_id' => [
           'name' => 'payment_processor_id',
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Payment Processor'),
           'description' => ts('Foreign key to civicrm_payment_processor.id'),
+          'where' => 'civicrm_contribution_recur.payment_processor_id',
           'table_name' => 'civicrm_contribution_recur',
           'entity' => 'ContributionRecur',
           'bao' => 'CRM_Contribute_BAO_ContributionRecur',
@@ -653,10 +672,8 @@ class CRM_Contribute_DAO_ContributionRecur extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Financial Type'),
           'description' => ts('FK to Financial Type'),
-          'export' => FALSE,
           'where' => 'civicrm_contribution_recur.financial_type_id',
-          'headerPattern' => '',
-          'dataPattern' => '',
+          'export' => FALSE,
           'table_name' => 'civicrm_contribution_recur',
           'entity' => 'ContributionRecur',
           'bao' => 'CRM_Contribute_BAO_ContributionRecur',
@@ -676,6 +693,7 @@ class CRM_Contribute_DAO_ContributionRecur extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Payment Method'),
           'description' => ts('FK to Payment Instrument'),
+          'where' => 'civicrm_contribution_recur.payment_instrument_id',
           'table_name' => 'civicrm_contribution_recur',
           'entity' => 'ContributionRecur',
           'bao' => 'CRM_Contribute_BAO_ContributionRecur',
@@ -695,8 +713,6 @@ class CRM_Contribute_DAO_ContributionRecur extends CRM_Core_DAO {
           'description' => ts('The campaign for which this contribution has been triggered.'),
           'import' => TRUE,
           'where' => 'civicrm_contribution_recur.campaign_id',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_contribution_recur',
           'entity' => 'ContributionRecur',
@@ -717,6 +733,7 @@ class CRM_Contribute_DAO_ContributionRecur extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Send email Receipt?'),
           'description' => ts('if true, receipt is automatically emailed to contact on each successful payment'),
+          'where' => 'civicrm_contribution_recur.is_email_receipt',
           'default' => '1',
           'table_name' => 'civicrm_contribution_recur',
           'entity' => 'ContributionRecur',
diff --git a/civicrm/CRM/Contribute/DAO/ContributionSoft.php b/civicrm/CRM/Contribute/DAO/ContributionSoft.php
index ae009420f0b68313977d0e7492f92940807ea993..75f2dcd4a76043c65afae47781a8a547a3d3812c 100644
--- a/civicrm/CRM/Contribute/DAO/ContributionSoft.php
+++ b/civicrm/CRM/Contribute/DAO/ContributionSoft.php
@@ -133,8 +133,6 @@ class CRM_Contribute_DAO_ContributionSoft extends CRM_Core_DAO {
           'required' => TRUE,
           'import' => TRUE,
           'where' => 'civicrm_contribution_soft.id',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_contribution_soft',
           'entity' => 'ContributionSoft',
@@ -147,6 +145,7 @@ class CRM_Contribute_DAO_ContributionSoft extends CRM_Core_DAO {
           'title' => ts('Soft Contribution - Contribution'),
           'description' => ts('FK to contribution table.'),
           'required' => TRUE,
+          'where' => 'civicrm_contribution_soft.contribution_id',
           'table_name' => 'civicrm_contribution_soft',
           'entity' => 'ContributionSoft',
           'bao' => 'CRM_Contribute_BAO_ContributionSoft',
@@ -197,6 +196,7 @@ class CRM_Contribute_DAO_ContributionSoft extends CRM_Core_DAO {
           'description' => ts('3 character string, value from config setting or input via user.'),
           'maxlength' => 3,
           'size' => CRM_Utils_Type::FOUR,
+          'where' => 'civicrm_contribution_soft.currency',
           'default' => 'NULL',
           'table_name' => 'civicrm_contribution_soft',
           'entity' => 'ContributionSoft',
@@ -217,6 +217,7 @@ class CRM_Contribute_DAO_ContributionSoft extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Soft Contribution PCP'),
           'description' => ts('FK to civicrm_pcp.id'),
+          'where' => 'civicrm_contribution_soft.pcp_id',
           'default' => 'NULL',
           'table_name' => 'civicrm_contribution_soft',
           'entity' => 'ContributionSoft',
@@ -233,6 +234,7 @@ class CRM_Contribute_DAO_ContributionSoft extends CRM_Core_DAO {
           'name' => 'pcp_display_in_roll',
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Soft Contribution Display on PCP'),
+          'where' => 'civicrm_contribution_soft.pcp_display_in_roll',
           'default' => '0',
           'table_name' => 'civicrm_contribution_soft',
           'entity' => 'ContributionSoft',
@@ -245,6 +247,7 @@ class CRM_Contribute_DAO_ContributionSoft extends CRM_Core_DAO {
           'title' => ts('Soft Contribution PCP Nickname'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_contribution_soft.pcp_roll_nickname',
           'default' => 'NULL',
           'table_name' => 'civicrm_contribution_soft',
           'entity' => 'ContributionSoft',
@@ -257,6 +260,7 @@ class CRM_Contribute_DAO_ContributionSoft extends CRM_Core_DAO {
           'title' => ts('Soft Contribution PCP Note'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_contribution_soft.pcp_personal_note',
           'default' => 'NULL',
           'table_name' => 'civicrm_contribution_soft',
           'entity' => 'ContributionSoft',
@@ -271,6 +275,7 @@ class CRM_Contribute_DAO_ContributionSoft extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Soft Credit Type'),
           'description' => ts('Soft Credit Type ID.Implicit FK to civicrm_option_value where option_group = soft_credit_type.'),
+          'where' => 'civicrm_contribution_soft.soft_credit_type_id',
           'default' => 'NULL',
           'table_name' => 'civicrm_contribution_soft',
           'entity' => 'ContributionSoft',
diff --git a/civicrm/CRM/Contribute/DAO/Premium.php b/civicrm/CRM/Contribute/DAO/Premium.php
index 643bf1dbafdb0ee0aebc2c466ac778bf50ff1e63..8302aef5e581cd4822eecdd108b5d1e3a0021c0f 100644
--- a/civicrm/CRM/Contribute/DAO/Premium.php
+++ b/civicrm/CRM/Contribute/DAO/Premium.php
@@ -135,6 +135,7 @@ class CRM_Contribute_DAO_Premium extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Premium ID'),
           'required' => TRUE,
+          'where' => 'civicrm_premiums.id',
           'table_name' => 'civicrm_premiums',
           'entity' => 'Premium',
           'bao' => 'CRM_Contribute_BAO_Premium',
@@ -148,6 +149,7 @@ class CRM_Contribute_DAO_Premium extends CRM_Core_DAO {
           'required' => TRUE,
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_premiums.entity_table',
           'table_name' => 'civicrm_premiums',
           'entity' => 'Premium',
           'bao' => 'CRM_Contribute_BAO_Premium',
@@ -158,6 +160,7 @@ class CRM_Contribute_DAO_Premium extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Premium entity ID'),
           'required' => TRUE,
+          'where' => 'civicrm_premiums.entity_id',
           'table_name' => 'civicrm_premiums',
           'entity' => 'Premium',
           'bao' => 'CRM_Contribute_BAO_Premium',
@@ -169,6 +172,7 @@ class CRM_Contribute_DAO_Premium extends CRM_Core_DAO {
           'title' => ts('Is Premium Active?'),
           'description' => ts('Is the Premiums feature enabled for this page?'),
           'required' => TRUE,
+          'where' => 'civicrm_premiums.premiums_active',
           'default' => '0',
           'table_name' => 'civicrm_premiums',
           'entity' => 'Premium',
@@ -182,6 +186,7 @@ class CRM_Contribute_DAO_Premium extends CRM_Core_DAO {
           'description' => ts('Title for Premiums section.'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_premiums.premiums_intro_title',
           'table_name' => 'civicrm_premiums',
           'entity' => 'Premium',
           'bao' => 'CRM_Contribute_BAO_Premium',
@@ -192,6 +197,7 @@ class CRM_Contribute_DAO_Premium extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_TEXT,
           'title' => ts('Premium Introductory Text'),
           'description' => ts('Displayed in <div> at top of Premiums section of page. Text and HTML allowed.'),
+          'where' => 'civicrm_premiums.premiums_intro_text',
           'table_name' => 'civicrm_premiums',
           'entity' => 'Premium',
           'bao' => 'CRM_Contribute_BAO_Premium',
@@ -204,6 +210,7 @@ class CRM_Contribute_DAO_Premium extends CRM_Core_DAO {
           'description' => ts('This email address is included in receipts if it is populated and a premium has been selected.'),
           'maxlength' => 100,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_premiums.premiums_contact_email',
           'table_name' => 'civicrm_premiums',
           'entity' => 'Premium',
           'bao' => 'CRM_Contribute_BAO_Premium',
@@ -216,6 +223,7 @@ class CRM_Contribute_DAO_Premium extends CRM_Core_DAO {
           'description' => ts('This phone number is included in receipts if it is populated and a premium has been selected.'),
           'maxlength' => 50,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_premiums.premiums_contact_phone',
           'table_name' => 'civicrm_premiums',
           'entity' => 'Premium',
           'bao' => 'CRM_Contribute_BAO_Premium',
@@ -227,6 +235,7 @@ class CRM_Contribute_DAO_Premium extends CRM_Core_DAO {
           'title' => ts('Display Minimum Contribution?'),
           'description' => ts('Boolean. Should we automatically display minimum contribution amount text after the premium descriptions.'),
           'required' => TRUE,
+          'where' => 'civicrm_premiums.premiums_display_min_contribution',
           'table_name' => 'civicrm_premiums',
           'entity' => 'Premium',
           'bao' => 'CRM_Contribute_BAO_Premium',
@@ -239,6 +248,7 @@ class CRM_Contribute_DAO_Premium extends CRM_Core_DAO {
           'description' => ts('Label displayed for No Thank-you option in premiums block (e.g. No thank you)'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_premiums.premiums_nothankyou_label',
           'table_name' => 'civicrm_premiums',
           'entity' => 'Premium',
           'bao' => 'CRM_Contribute_BAO_Premium',
@@ -248,6 +258,7 @@ class CRM_Contribute_DAO_Premium extends CRM_Core_DAO {
           'name' => 'premiums_nothankyou_position',
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('No Thank-you Position'),
+          'where' => 'civicrm_premiums.premiums_nothankyou_position',
           'default' => '1',
           'table_name' => 'civicrm_premiums',
           'entity' => 'Premium',
diff --git a/civicrm/CRM/Contribute/DAO/PremiumsProduct.php b/civicrm/CRM/Contribute/DAO/PremiumsProduct.php
index 7f319b0669d1114ba4cf9751e57684937ee1f4a2..ff19638fb7570909eba725c7def3f6fa7981b99c 100644
--- a/civicrm/CRM/Contribute/DAO/PremiumsProduct.php
+++ b/civicrm/CRM/Contribute/DAO/PremiumsProduct.php
@@ -100,6 +100,7 @@ class CRM_Contribute_DAO_PremiumsProduct extends CRM_Core_DAO {
           'title' => ts('Premium Product ID'),
           'description' => ts('Contribution ID'),
           'required' => TRUE,
+          'where' => 'civicrm_premiums_product.id',
           'table_name' => 'civicrm_premiums_product',
           'entity' => 'PremiumsProduct',
           'bao' => 'CRM_Contribute_DAO_PremiumsProduct',
@@ -111,6 +112,7 @@ class CRM_Contribute_DAO_PremiumsProduct extends CRM_Core_DAO {
           'title' => ts('Premium'),
           'description' => ts('Foreign key to premiums settings record.'),
           'required' => TRUE,
+          'where' => 'civicrm_premiums_product.premiums_id',
           'table_name' => 'civicrm_premiums_product',
           'entity' => 'PremiumsProduct',
           'bao' => 'CRM_Contribute_DAO_PremiumsProduct',
@@ -123,6 +125,7 @@ class CRM_Contribute_DAO_PremiumsProduct extends CRM_Core_DAO {
           'title' => ts('Product'),
           'description' => ts('Foreign key to each product object.'),
           'required' => TRUE,
+          'where' => 'civicrm_premiums_product.product_id',
           'table_name' => 'civicrm_premiums_product',
           'entity' => 'PremiumsProduct',
           'bao' => 'CRM_Contribute_DAO_PremiumsProduct',
@@ -134,6 +137,7 @@ class CRM_Contribute_DAO_PremiumsProduct extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Order'),
           'required' => TRUE,
+          'where' => 'civicrm_premiums_product.weight',
           'table_name' => 'civicrm_premiums_product',
           'entity' => 'PremiumsProduct',
           'bao' => 'CRM_Contribute_DAO_PremiumsProduct',
@@ -144,6 +148,7 @@ class CRM_Contribute_DAO_PremiumsProduct extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Financial Type'),
           'description' => ts('FK to Financial Type.'),
+          'where' => 'civicrm_premiums_product.financial_type_id',
           'default' => 'NULL',
           'table_name' => 'civicrm_premiums_product',
           'entity' => 'PremiumsProduct',
diff --git a/civicrm/CRM/Contribute/DAO/Product.php b/civicrm/CRM/Contribute/DAO/Product.php
index d4e1e75ef531c7b1b096a22aa7c1eb50ca257e00..e897a5476606035aae3a2d18a258e0000a85e9a6 100644
--- a/civicrm/CRM/Contribute/DAO/Product.php
+++ b/civicrm/CRM/Contribute/DAO/Product.php
@@ -194,6 +194,7 @@ class CRM_Contribute_DAO_Product extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Product ID'),
           'required' => TRUE,
+          'where' => 'civicrm_product.id',
           'table_name' => 'civicrm_product',
           'entity' => 'Product',
           'bao' => 'CRM_Contribute_BAO_Product',
@@ -207,10 +208,8 @@ class CRM_Contribute_DAO_Product extends CRM_Core_DAO {
           'required' => TRUE,
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
-          'export' => TRUE,
           'where' => 'civicrm_product.name',
-          'headerPattern' => '',
-          'dataPattern' => '',
+          'export' => TRUE,
           'table_name' => 'civicrm_product',
           'entity' => 'Product',
           'bao' => 'CRM_Contribute_BAO_Product',
@@ -221,6 +220,7 @@ class CRM_Contribute_DAO_Product extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_TEXT,
           'title' => ts('Description'),
           'description' => ts('Optional description of the product/premium.'),
+          'where' => 'civicrm_product.description',
           'table_name' => 'civicrm_product',
           'entity' => 'Product',
           'bao' => 'CRM_Contribute_BAO_Product',
@@ -233,10 +233,8 @@ class CRM_Contribute_DAO_Product extends CRM_Core_DAO {
           'description' => ts('Optional product sku or code.'),
           'maxlength' => 50,
           'size' => CRM_Utils_Type::BIG,
-          'export' => TRUE,
           'where' => 'civicrm_product.sku',
-          'headerPattern' => '',
-          'dataPattern' => '',
+          'export' => TRUE,
           'table_name' => 'civicrm_product',
           'entity' => 'Product',
           'bao' => 'CRM_Contribute_BAO_Product',
@@ -247,6 +245,7 @@ class CRM_Contribute_DAO_Product extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_TEXT,
           'title' => ts('Options'),
           'description' => ts('Store comma-delimited list of color, size, etc. options for the product.'),
+          'where' => 'civicrm_product.options',
           'table_name' => 'civicrm_product',
           'entity' => 'Product',
           'bao' => 'CRM_Contribute_BAO_Product',
@@ -259,6 +258,7 @@ class CRM_Contribute_DAO_Product extends CRM_Core_DAO {
           'description' => ts('Full or relative URL to uploaded image - fullsize.'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_product.image',
           'table_name' => 'civicrm_product',
           'entity' => 'Product',
           'bao' => 'CRM_Contribute_BAO_Product',
@@ -271,6 +271,7 @@ class CRM_Contribute_DAO_Product extends CRM_Core_DAO {
           'description' => ts('Full or relative URL to image thumbnail.'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_product.thumbnail',
           'table_name' => 'civicrm_product',
           'entity' => 'Product',
           'bao' => 'CRM_Contribute_BAO_Product',
@@ -285,6 +286,7 @@ class CRM_Contribute_DAO_Product extends CRM_Core_DAO {
             20,
             2
           ],
+          'where' => 'civicrm_product.price',
           'table_name' => 'civicrm_product',
           'entity' => 'Product',
           'bao' => 'CRM_Contribute_BAO_Product',
@@ -297,6 +299,7 @@ class CRM_Contribute_DAO_Product extends CRM_Core_DAO {
           'description' => ts('3 character string, value from config setting or input via user.'),
           'maxlength' => 3,
           'size' => CRM_Utils_Type::FOUR,
+          'where' => 'civicrm_product.currency',
           'default' => 'NULL',
           'table_name' => 'civicrm_product',
           'entity' => 'Product',
@@ -317,6 +320,7 @@ class CRM_Contribute_DAO_Product extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Financial Type'),
           'description' => ts('FK to Financial Type.'),
+          'where' => 'civicrm_product.financial_type_id',
           'default' => 'NULL',
           'table_name' => 'civicrm_product',
           'entity' => 'Product',
@@ -338,6 +342,7 @@ class CRM_Contribute_DAO_Product extends CRM_Core_DAO {
             20,
             2
           ],
+          'where' => 'civicrm_product.min_contribution',
           'table_name' => 'civicrm_product',
           'entity' => 'Product',
           'bao' => 'CRM_Contribute_BAO_Product',
@@ -352,6 +357,7 @@ class CRM_Contribute_DAO_Product extends CRM_Core_DAO {
             20,
             2
           ],
+          'where' => 'civicrm_product.cost',
           'table_name' => 'civicrm_product',
           'entity' => 'Product',
           'bao' => 'CRM_Contribute_BAO_Product',
@@ -363,6 +369,7 @@ class CRM_Contribute_DAO_Product extends CRM_Core_DAO {
           'title' => ts('Is Active'),
           'description' => ts('Disabling premium removes it from the premiums_premium join table below.'),
           'required' => TRUE,
+          'where' => 'civicrm_product.is_active',
           'table_name' => 'civicrm_product',
           'entity' => 'Product',
           'bao' => 'CRM_Contribute_BAO_Product',
@@ -376,6 +383,7 @@ class CRM_Contribute_DAO_Product extends CRM_Core_DAO {
       (e.g. 1 year + fixed -> we would set start/end for 1/1/06 thru 12/31/06 for any premium chosen in 2006) '),
           'maxlength' => 8,
           'size' => CRM_Utils_Type::EIGHT,
+          'where' => 'civicrm_product.period_type',
           'default' => 'rolling',
           'table_name' => 'civicrm_product',
           'entity' => 'Product',
@@ -393,6 +401,7 @@ class CRM_Contribute_DAO_Product extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Fixed Period Start Day'),
           'description' => ts('Month and day (MMDD) that fixed period type subscription or membership starts.'),
+          'where' => 'civicrm_product.fixed_period_start_day',
           'default' => '0101',
           'table_name' => 'civicrm_product',
           'entity' => 'Product',
@@ -405,6 +414,7 @@ class CRM_Contribute_DAO_Product extends CRM_Core_DAO {
           'title' => ts('Duration Unit'),
           'maxlength' => 8,
           'size' => CRM_Utils_Type::EIGHT,
+          'where' => 'civicrm_product.duration_unit',
           'default' => 'year',
           'table_name' => 'civicrm_product',
           'entity' => 'Product',
@@ -422,6 +432,7 @@ class CRM_Contribute_DAO_Product extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Duration Interval'),
           'description' => ts('Number of units for total duration of subscription, service, membership (e.g. 12 Months).'),
+          'where' => 'civicrm_product.duration_interval',
           'table_name' => 'civicrm_product',
           'entity' => 'Product',
           'bao' => 'CRM_Contribute_BAO_Product',
@@ -434,6 +445,7 @@ class CRM_Contribute_DAO_Product extends CRM_Core_DAO {
           'description' => ts('Frequency unit and interval allow option to store actual delivery frequency for a subscription or service.'),
           'maxlength' => 8,
           'size' => CRM_Utils_Type::EIGHT,
+          'where' => 'civicrm_product.frequency_unit',
           'default' => 'month',
           'table_name' => 'civicrm_product',
           'entity' => 'Product',
@@ -451,6 +463,7 @@ class CRM_Contribute_DAO_Product extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Frequency Interval'),
           'description' => ts('Number of units for delivery frequency of subscription, service, membership (e.g. every 3 Months).'),
+          'where' => 'civicrm_product.frequency_interval',
           'table_name' => 'civicrm_product',
           'entity' => 'Product',
           'bao' => 'CRM_Contribute_BAO_Product',
diff --git a/civicrm/CRM/Contribute/DAO/Widget.php b/civicrm/CRM/Contribute/DAO/Widget.php
index fb7eb5e58edaf995ae26c463129ed9361721fbc6..9d77dfb9bfb3522ca7448a0b1140a0d584506e3a 100644
--- a/civicrm/CRM/Contribute/DAO/Widget.php
+++ b/civicrm/CRM/Contribute/DAO/Widget.php
@@ -166,6 +166,7 @@ class CRM_Contribute_DAO_Widget extends CRM_Core_DAO {
           'title' => ts('Widget ID'),
           'description' => ts('Contribution Id'),
           'required' => TRUE,
+          'where' => 'civicrm_contribution_widget.id',
           'table_name' => 'civicrm_contribution_widget',
           'entity' => 'Widget',
           'bao' => 'CRM_Contribute_BAO_Widget',
@@ -176,6 +177,7 @@ class CRM_Contribute_DAO_Widget extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Contribution Page'),
           'description' => ts('The Contribution Page which triggered this contribution'),
+          'where' => 'civicrm_contribution_widget.contribution_page_id',
           'table_name' => 'civicrm_contribution_widget',
           'entity' => 'Widget',
           'bao' => 'CRM_Contribute_BAO_Widget',
@@ -187,6 +189,7 @@ class CRM_Contribute_DAO_Widget extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Enabled?'),
           'description' => ts('Is this property active?'),
+          'where' => 'civicrm_contribution_widget.is_active',
           'table_name' => 'civicrm_contribution_widget',
           'entity' => 'Widget',
           'bao' => 'CRM_Contribute_BAO_Widget',
@@ -199,6 +202,7 @@ class CRM_Contribute_DAO_Widget extends CRM_Core_DAO {
           'description' => ts('Widget title.'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_contribution_widget.title',
           'table_name' => 'civicrm_contribution_widget',
           'entity' => 'Widget',
           'bao' => 'CRM_Contribute_BAO_Widget',
@@ -211,6 +215,7 @@ class CRM_Contribute_DAO_Widget extends CRM_Core_DAO {
           'description' => ts('URL to Widget logo'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_contribution_widget.url_logo',
           'table_name' => 'civicrm_contribution_widget',
           'entity' => 'Widget',
           'bao' => 'CRM_Contribute_BAO_Widget',
@@ -223,6 +228,7 @@ class CRM_Contribute_DAO_Widget extends CRM_Core_DAO {
           'description' => ts('Button title.'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_contribution_widget.button_title',
           'table_name' => 'civicrm_contribution_widget',
           'entity' => 'Widget',
           'bao' => 'CRM_Contribute_BAO_Widget',
@@ -233,6 +239,7 @@ class CRM_Contribute_DAO_Widget extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_TEXT,
           'title' => ts('Description'),
           'description' => ts('About description.'),
+          'where' => 'civicrm_contribution_widget.about',
           'table_name' => 'civicrm_contribution_widget',
           'entity' => 'Widget',
           'bao' => 'CRM_Contribute_BAO_Widget',
@@ -245,6 +252,7 @@ class CRM_Contribute_DAO_Widget extends CRM_Core_DAO {
           'description' => ts('URL to Homepage.'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_contribution_widget.url_homepage',
           'table_name' => 'civicrm_contribution_widget',
           'entity' => 'Widget',
           'bao' => 'CRM_Contribute_BAO_Widget',
@@ -256,6 +264,7 @@ class CRM_Contribute_DAO_Widget extends CRM_Core_DAO {
           'title' => ts('Title Color'),
           'maxlength' => 10,
           'size' => CRM_Utils_Type::TWELVE,
+          'where' => 'civicrm_contribution_widget.color_title',
           'table_name' => 'civicrm_contribution_widget',
           'entity' => 'Widget',
           'bao' => 'CRM_Contribute_BAO_Widget',
@@ -267,6 +276,7 @@ class CRM_Contribute_DAO_Widget extends CRM_Core_DAO {
           'title' => ts('Button Colour'),
           'maxlength' => 10,
           'size' => CRM_Utils_Type::TWELVE,
+          'where' => 'civicrm_contribution_widget.color_button',
           'table_name' => 'civicrm_contribution_widget',
           'entity' => 'Widget',
           'bao' => 'CRM_Contribute_BAO_Widget',
@@ -278,6 +288,7 @@ class CRM_Contribute_DAO_Widget extends CRM_Core_DAO {
           'title' => ts('Bar Color'),
           'maxlength' => 10,
           'size' => CRM_Utils_Type::TWELVE,
+          'where' => 'civicrm_contribution_widget.color_bar',
           'table_name' => 'civicrm_contribution_widget',
           'entity' => 'Widget',
           'bao' => 'CRM_Contribute_BAO_Widget',
@@ -289,6 +300,7 @@ class CRM_Contribute_DAO_Widget extends CRM_Core_DAO {
           'title' => ts('Main Text Color'),
           'maxlength' => 10,
           'size' => CRM_Utils_Type::TWELVE,
+          'where' => 'civicrm_contribution_widget.color_main_text',
           'table_name' => 'civicrm_contribution_widget',
           'entity' => 'Widget',
           'bao' => 'CRM_Contribute_BAO_Widget',
@@ -300,6 +312,7 @@ class CRM_Contribute_DAO_Widget extends CRM_Core_DAO {
           'title' => ts('Main Colour'),
           'maxlength' => 10,
           'size' => CRM_Utils_Type::TWELVE,
+          'where' => 'civicrm_contribution_widget.color_main',
           'table_name' => 'civicrm_contribution_widget',
           'entity' => 'Widget',
           'bao' => 'CRM_Contribute_BAO_Widget',
@@ -311,6 +324,7 @@ class CRM_Contribute_DAO_Widget extends CRM_Core_DAO {
           'title' => ts('Backgroup Color'),
           'maxlength' => 10,
           'size' => CRM_Utils_Type::TWELVE,
+          'where' => 'civicrm_contribution_widget.color_main_bg',
           'table_name' => 'civicrm_contribution_widget',
           'entity' => 'Widget',
           'bao' => 'CRM_Contribute_BAO_Widget',
@@ -322,6 +336,7 @@ class CRM_Contribute_DAO_Widget extends CRM_Core_DAO {
           'title' => ts('Other Backgroun Colour'),
           'maxlength' => 10,
           'size' => CRM_Utils_Type::TWELVE,
+          'where' => 'civicrm_contribution_widget.color_bg',
           'table_name' => 'civicrm_contribution_widget',
           'entity' => 'Widget',
           'bao' => 'CRM_Contribute_BAO_Widget',
@@ -333,6 +348,7 @@ class CRM_Contribute_DAO_Widget extends CRM_Core_DAO {
           'title' => ts('About Link Colour'),
           'maxlength' => 10,
           'size' => CRM_Utils_Type::TWELVE,
+          'where' => 'civicrm_contribution_widget.color_about_link',
           'table_name' => 'civicrm_contribution_widget',
           'entity' => 'Widget',
           'bao' => 'CRM_Contribute_BAO_Widget',
@@ -344,6 +360,7 @@ class CRM_Contribute_DAO_Widget extends CRM_Core_DAO {
           'title' => ts('Homepage Link Colour'),
           'maxlength' => 10,
           'size' => CRM_Utils_Type::TWELVE,
+          'where' => 'civicrm_contribution_widget.color_homepage_link',
           'table_name' => 'civicrm_contribution_widget',
           'entity' => 'Widget',
           'bao' => 'CRM_Contribute_BAO_Widget',
diff --git a/civicrm/CRM/Contribute/Form/AbstractEditPayment.php b/civicrm/CRM/Contribute/Form/AbstractEditPayment.php
index 1eacda32bb1f0a020852b899f52a7f0e8854c2c4..f410a2bf7130f6d5fb9023ae01d05c22c5c78d1f 100644
--- a/civicrm/CRM/Contribute/Form/AbstractEditPayment.php
+++ b/civicrm/CRM/Contribute/Form/AbstractEditPayment.php
@@ -343,7 +343,6 @@ WHERE  contribution_id = {$id}
       $this->_premiumID = $dao->id;
       $this->_productDAO = $dao;
     }
-    $dao->free();
   }
 
   /**
diff --git a/civicrm/CRM/Contribute/Form/CancelSubscription.php b/civicrm/CRM/Contribute/Form/CancelSubscription.php
index 91bbe384604b074ac5a877d044e447e84b12e407..69c682756a1943a420b0adc3d8d11635810fbc79 100644
--- a/civicrm/CRM/Contribute/Form/CancelSubscription.php
+++ b/civicrm/CRM/Contribute/Form/CancelSubscription.php
@@ -35,7 +35,6 @@
  * This class provides support for canceling recurring subscriptions.
  */
 class CRM_Contribute_Form_CancelSubscription extends CRM_Contribute_Form_ContributionRecur {
-  protected $_paymentProcessorObj = NULL;
 
   protected $_userContext = NULL;
 
@@ -45,12 +44,12 @@ class CRM_Contribute_Form_CancelSubscription extends CRM_Contribute_Form_Contrib
 
   /**
    * Set variables up before form is built.
+   *
+   * @throws \CRM_Core_Exception
    */
   public function preProcess() {
     parent::preProcess();
     if ($this->_crid) {
-      $this->_paymentProcessorObj = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_crid, 'recur', 'obj');
-      $this->_subscriptionDetails = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($this->_crid);
       $this->assign('frequency_unit', $this->_subscriptionDetails->frequency_unit);
       $this->assign('frequency_interval', $this->_subscriptionDetails->frequency_interval);
       $this->assign('amount', $this->_subscriptionDetails->amount);
@@ -81,7 +80,6 @@ class CRM_Contribute_Form_CancelSubscription extends CRM_Contribute_Form_Contrib
         CRM_Core_Error::fatal(ts('The recurring contribution looks to have been cancelled already.'));
       }
       $this->_paymentProcessorObj = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_coid, 'contribute', 'obj');
-      $this->_subscriptionDetails = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($this->_coid, 'contribution');
 
       $this->assign('frequency_unit', $this->_subscriptionDetails->frequency_unit);
       $this->assign('frequency_interval', $this->_subscriptionDetails->frequency_interval);
@@ -206,10 +204,13 @@ class CRM_Contribute_Form_CancelSubscription extends CRM_Contribute_Form_Contrib
       CRM_Core_Error::displaySessionError($cancelSubscription);
     }
     elseif ($cancelSubscription) {
-      $cancelStatus = CRM_Contribute_BAO_ContributionRecur::cancelRecurContribution(
-        ['id' => $this->_subscriptionDetails->recur_id, 'membership_id' => $this->_mid, 'processor_message' => $message]);
+      try {
+        civicrm_api3('ContributionRecur', 'cancel', [
+          'id' => $this->_subscriptionDetails->recur_id,
+          'membership_id' => $this->_mid,
+          'processor_message' => $message,
+        ]);
 
-      if ($cancelStatus) {
         $tplParams = [];
         if ($this->_mid) {
           $inputParams = ['id' => $this->_mid];
@@ -275,7 +276,7 @@ class CRM_Contribute_Form_CancelSubscription extends CRM_Contribute_Form_Contrib
           list($sent) = CRM_Core_BAO_MessageTemplate::sendTemplate($sendTemplateParams);
         }
       }
-      else {
+      catch (CiviCRM_API3_Exception $e) {
         $msgType = 'error';
         $msgTitle = ts('Error');
         if ($params['send_cancel_request'] == 1) {
diff --git a/civicrm/CRM/Contribute/Form/ContributionPage.php b/civicrm/CRM/Contribute/Form/ContributionPage.php
index a7e95aedfe8d551dfa80d96e785f34e67ee0f84d..d47d7a522407752e558c784e719f3aa7eefc2c82 100644
--- a/civicrm/CRM/Contribute/Form/ContributionPage.php
+++ b/civicrm/CRM/Contribute/Form/ContributionPage.php
@@ -339,7 +339,7 @@ class CRM_Contribute_Form_ContributionPage extends CRM_Core_Form {
       // @todo look to change to $defaults['start_date'] = date('Ymd His');
       // main settings form overrides this to implement above but this is left here
       // 'in case' another extending form uses start_date - for now
-      list($defaults['start_date'], $defaults['start_date_time']) = CRM_Utils_Date::setDateDefaults();
+      $defaults['start_date'] = date('Y-m-d H:i:s');
     }
 
     if (!empty($defaults['recur_frequency_unit'])) {
diff --git a/civicrm/CRM/Contribute/Form/ContributionPage/Amount.php b/civicrm/CRM/Contribute/Form/ContributionPage/Amount.php
index ed7efb2d82e9738cb5652499fe9e05752d3f2dce..29fdd78efeca3171dfc74b677d2301262b16089d 100644
--- a/civicrm/CRM/Contribute/Form/ContributionPage/Amount.php
+++ b/civicrm/CRM/Contribute/Form/ContributionPage/Amount.php
@@ -179,7 +179,7 @@ class CRM_Contribute_Form_ContributionPage_Amount extends CRM_Contribute_Form_Co
         $this->addElement('checkbox', 'adjust_recur_start_date', ts('Adjust Recurring Start Date'), NULL,
           ['onclick' => "showHideByValue('adjust_recur_start_date',true,'recurDefaults','table-row','radio',false);"]
         );
-        $this->addDate('pledge_calendar_date', ts('Specific Calendar Date'));
+        $this->add('datepicker', 'pledge_calendar_date', ts('Specific Calendar Date'), [], FALSE, ['time' => FALSE]);
         $month = CRM_Utils_Date::getCalendarDayOfMonth();
         $this->add('select', 'pledge_calendar_month', ts('Specific day of Month'), $month);
         $pledgeDefaults = [
@@ -512,7 +512,7 @@ class CRM_Contribute_Form_ContributionPage_Amount extends CRM_Contribute_Form_Co
         'calendar_month' => 'pledge_calendar_month',
       ];
       if ($params['pledge_default_toggle'] == 'contribution_date') {
-        $fieldValue = json_encode(['contribution_date' => date('m/d/Y')]);
+        $fieldValue = json_encode(['contribution_date' => date('Y-m-d')]);
       }
       else {
         foreach ($pledgeDateFields as $key => $pledgeDateField) {
diff --git a/civicrm/CRM/Contribute/Form/ContributionRecur.php b/civicrm/CRM/Contribute/Form/ContributionRecur.php
index d0b1ee2873ad50d109940914d4f94071455d3dcd..d37db2c0a35065a28703bfa1b15952f937e327c5 100644
--- a/civicrm/CRM/Contribute/Form/ContributionRecur.php
+++ b/civicrm/CRM/Contribute/Form/ContributionRecur.php
@@ -36,6 +36,8 @@
  */
 class CRM_Contribute_Form_ContributionRecur extends CRM_Core_Form {
 
+  use CRM_Core_Form_EntityFormTrait;
+
   /**
    * @var int Contribution ID
    */
@@ -61,6 +63,43 @@ class CRM_Contribute_Form_ContributionRecur extends CRM_Core_Form {
    */
   protected $_mid = NULL;
 
+  /**
+   * Payment processor object.
+   *
+   * @var \CRM_Core_Payment
+   */
+  protected $_paymentProcessorObj = NULL;
+
+  /**
+   * @var array
+   *
+   * Current payment processor including a copy of the object in 'object' key for
+   * legacy reasons.
+   */
+  public $_paymentProcessor = [];
+
+  /**
+   * Fields for the entity to be assigned to the template.
+   *
+   * Fields may have keys
+   *  - name (required to show in tpl from the array)
+   *  - description (optional, will appear below the field)
+   *  - not-auto-addable - this class will not attempt to add the field using addField.
+   *    (this will be automatically set if the field does not have html in it's metadata
+   *    or is not a core field on the form's entity).
+   *  - help (option) add help to the field - e.g ['id' => 'id-source', 'file' => 'CRM/Contact/Form/Contact']]
+   *  - template - use a field specific template to render this field
+   * @var array
+   */
+  protected $entityFields = [];
+
+  /**
+   * Details of the subscription (recurring contribution) to be altered.
+   *
+   * @var array
+   */
+  protected $subscriptionDetails = [];
+
   /**
    * Explicitly declare the entity api name.
    */
@@ -77,12 +116,67 @@ class CRM_Contribute_Form_ContributionRecur extends CRM_Core_Form {
 
   /**
    * Set variables up before form is built.
+   *
+   * @throws \CRM_Core_Exception
    */
   public function preProcess() {
+    $this->setAction(CRM_Core_Action::UPDATE);
     $this->_mid = CRM_Utils_Request::retrieve('mid', 'Integer', $this, FALSE);
     $this->_crid = CRM_Utils_Request::retrieve('crid', 'Integer', $this, FALSE);
     $this->contributionRecurID = $this->_crid;
     $this->_coid = CRM_Utils_Request::retrieve('coid', 'Integer', $this, FALSE);
+    $this->setSubscriptionDetails();
+    $this->setPaymentProcessor();
+    if ($this->getSubscriptionContactID()) {
+      $this->set('cid', $this->getSubscriptionContactID());
+    }
+  }
+
+  /**
+   * Set the payment processor object up.
+   *
+   * This is a function that needs to be better consolidated between the inheriting forms
+   * but this is good choice of function to call.
+   */
+  protected function setPaymentProcessor() {
+    if ($this->_crid) {
+      $this->_paymentProcessor = CRM_Contribute_BAO_ContributionRecur::getPaymentProcessor($this->contributionRecurID);
+      if (!$this->_paymentProcessor) {
+        CRM_Core_Error::statusBounce(ts('There is no valid processor for this subscription so it cannot be updated'));
+      }
+      $this->_paymentProcessorObj = $this->_paymentProcessor['object'];
+    }
+  }
+
+  /**
+   * Set the subscription details on the form.
+   */
+  protected function setSubscriptionDetails() {
+    if ($this->contributionRecurID) {
+      $this->subscriptionDetails = $this->_subscriptionDetails = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($this->_crid);
+    }
+    elseif ($this->_coid) {
+      $this->subscriptionDetails = $this->_subscriptionDetails = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($this->_coid, 'contribution');
+    }
+  }
+
+  /**
+   * Get details for the recurring contribution being altered.
+   *
+   * @return array
+   */
+  public function getSubscriptionDetails() {
+    return $this->subscriptionDetails;
+  }
+
+  /**
+   * Get the contact ID for the subscription.
+   *
+   * @return int|false
+   */
+  protected function getSubscriptionContactID() {
+    $sub = $this->getSubscriptionDetails();
+    return isset($sub->contact_id) ? $sub->contact_id : FALSE;
   }
 
 }
diff --git a/civicrm/CRM/Contribute/Form/Task.php b/civicrm/CRM/Contribute/Form/Task.php
index 8e6eb1d3ad3c9a249d8dd877fb17b8b426d637ff..fac10e2ac666ff28d362c845163ec9437f7c9d51 100644
--- a/civicrm/CRM/Contribute/Form/Task.php
+++ b/civicrm/CRM/Contribute/Form/Task.php
@@ -137,7 +137,6 @@ class CRM_Contribute_Form_Task extends CRM_Core_Form_Task {
           $contributionContactIds["{$result->contact_id}-{$result->contribution_id}"] = $result->contribution_id;
         }
       }
-      $result->free();
       $form->assign('totalSelectedContributions', $form->get('rowCount'));
     }
 
diff --git a/civicrm/CRM/Contribute/Form/Task/Invoice.php b/civicrm/CRM/Contribute/Form/Task/Invoice.php
index 4d02644bd4bb5d7990c429cda9cbcd246b9210dc..f2742ee109e2dfb00e38dfad622818ce66593646 100644
--- a/civicrm/CRM/Contribute/Form/Task/Invoice.php
+++ b/civicrm/CRM/Contribute/Form/Task/Invoice.php
@@ -301,7 +301,13 @@ class CRM_Contribute_Form_Task_Invoice extends CRM_Contribute_Form_Task {
       $invoiceDate = date("F j, Y");
       $dueDate = date('F j, Y', strtotime($contributionReceiveDate . "+" . $prefixValue['due_date'] . "" . $prefixValue['due_date_period']));
 
-      $lineItem = CRM_Price_BAO_LineItem::getLineItemsByContributionID($contribID);
+      if ($input['component'] == 'contribute') {
+        $lineItem = CRM_Price_BAO_LineItem::getLineItemsByContributionID($contribID);
+      }
+      else {
+        $eid = $contribution->_relatedObjects['participant']->id;
+        $lineItem = CRM_Price_BAO_LineItem::getLineItems($eid, 'participant', NULL, TRUE, FALSE, TRUE);
+      }
 
       $resultPayments = civicrm_api3('Payment', 'get', [
         'sequential' => 1,
diff --git a/civicrm/CRM/Contribute/Form/UpdateBilling.php b/civicrm/CRM/Contribute/Form/UpdateBilling.php
index 8d58d978e0cee6c01942d34a1056dbb124503291..2854e77424cd800c226079a3d590dc12319ce075 100644
--- a/civicrm/CRM/Contribute/Form/UpdateBilling.php
+++ b/civicrm/CRM/Contribute/Form/UpdateBilling.php
@@ -43,21 +43,14 @@ class CRM_Contribute_Form_UpdateBilling extends CRM_Contribute_Form_Contribution
 
   public $_bltID = NULL;
 
-  /**
-   * @var array current payment processor including a copy of the object in 'object' key
-   */
-  public $_paymentProcessor = array();
-
   /**
    * Set variables up before form is built.
+   *
+   * @throws \CRM_Core_Exception
    */
   public function preProcess() {
     parent::preProcess();
     if ($this->_crid) {
-      $this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_crid, 'recur', 'info');
-      $this->_paymentProcessor['object'] = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_crid, 'recur', 'obj');
-      $this->_subscriptionDetails = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($this->_crid);
-
       // Are we cancelling a recurring contribution that is linked to an auto-renew membership?
       if ($this->_subscriptionDetails->membership_id) {
         $this->_mid = $this->_subscriptionDetails->membership_id;
@@ -67,7 +60,6 @@ class CRM_Contribute_Form_UpdateBilling extends CRM_Contribute_Form_Contribution
     if ($this->_coid) {
       $this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_coid, 'contribute', 'info');
       $this->_paymentProcessor['object'] = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_coid, 'contribute', 'obj');
-      $this->_subscriptionDetails = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($this->_coid, 'contribution');
     }
 
     if ($this->_mid) {
diff --git a/civicrm/CRM/Contribute/Form/UpdateSubscription.php b/civicrm/CRM/Contribute/Form/UpdateSubscription.php
index 7b4be7a22c462df42cb3aea3917f59e6e6c61f14..0e50b0383cb9b7474a1568df9ec36fd64faff5bb 100644
--- a/civicrm/CRM/Contribute/Form/UpdateSubscription.php
+++ b/civicrm/CRM/Contribute/Form/UpdateSubscription.php
@@ -71,24 +71,10 @@ class CRM_Contribute_Form_UpdateSubscription extends CRM_Contribute_Form_Contrib
     parent::preProcess();
     $this->setAction(CRM_Core_Action::UPDATE);
 
-    if ($this->contributionRecurID) {
-      try {
-        $this->_paymentProcessorObj = CRM_Financial_BAO_PaymentProcessor::getPaymentProcessorForRecurringContribution($this->contributionRecurID);
-      }
-      catch (CRM_Core_Exception $e) {
-        CRM_Core_Error::statusBounce(ts('There is no valid processor for this subscription so it cannot be edited.'));
-      }
-      catch (CiviCRM_API3_Exception $e) {
-        CRM_Core_Error::statusBounce(ts('There is no valid processor for this subscription so it cannot be edited.'));
-      }
-      $this->_subscriptionDetails = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($this->contributionRecurID);
-    }
-
     if ($this->_coid) {
       $this->_paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_coid, 'contribute', 'info');
       // @todo test & replace with $this->_paymentProcessorObj =  Civi\Payment\System::singleton()->getById($this->_paymentProcessor['id']);
       $this->_paymentProcessorObj = CRM_Financial_BAO_PaymentProcessor::getProcessorForEntity($this->_coid, 'contribute', 'obj');
-      $this->_subscriptionDetails = CRM_Contribute_BAO_ContributionRecur::getSubscriptionDetails($this->_coid, 'contribution');
       $this->contributionRecurID = $this->_subscriptionDetails->recur_id;
     }
     elseif ($this->contributionRecurID) {
diff --git a/civicrm/CRM/Core/Action.php b/civicrm/CRM/Core/Action.php
index 638976ea32831afba220f0b4e638c8bead94f141..f93583590f0fc5511fc88b3823b306afd2b44105 100644
--- a/civicrm/CRM/Core/Action.php
+++ b/civicrm/CRM/Core/Action.php
@@ -298,6 +298,65 @@ class CRM_Core_Action {
     return $result;
   }
 
+  /**
+   * Given a set of links and a mask, return a filtered (by mask) array containing the final links with parsed values
+   *   and calling hooks as appropriate.
+   * Use this when passing a set of action links to the API or to the form without adding html formatting.
+   *
+   * @param array $links
+   *   The set of link items.
+   * @param int $mask
+   *   The mask to be used. a null mask means all items.
+   * @param array $values
+   *   The array of values for parameter substitution in the link items.
+   * @param null $op
+   * @param null $objectName
+   * @param int $objectId
+   *
+   * @return array|null
+   *   The array describing each link
+   */
+  public static function filterLinks(
+    $links,
+    $mask,
+    $values,
+    $op = NULL,
+    $objectName = NULL,
+    $objectId = NULL
+  ) {
+    if (empty($links)) {
+      return NULL;
+    }
+
+    // make links indexed sequentially instead of by bitmask
+    // otherwise it's next to impossible to reliably add new ones
+    $seqLinks = array();
+    foreach ($links as $bit => $link) {
+      $link['bit'] = $bit;
+      $seqLinks[] = $link;
+    }
+
+    if ($op && $objectName && $objectId) {
+      CRM_Utils_Hook::links($op, $objectName, $objectId, $seqLinks, $mask, $values);
+    }
+
+    foreach ($seqLinks as $i => $link) {
+      if (!$mask || !array_key_exists('bit', $link) || ($mask & $link['bit'])) {
+        $seqLinks[$i]['extra'] = isset($link['extra']) ? self::replace($link['extra'], $values) : NULL;
+
+        if (isset($link['qs']) && !CRM_Utils_System::isNull($link['qs'])) {
+          $seqLinks[$i]['url'] = self::replace($link['url'], $values);
+          $seqLinks[$i]['qs'] = self::replace($link['qs'], $values);
+        }
+      }
+      else {
+        unset($seqLinks[$i]);
+      }
+    }
+
+    return $seqLinks;
+  }
+
   /**
    * Given a string and an array of values, substitute the real values
    * in the placeholder in the str in the CiviCRM format
diff --git a/civicrm/CRM/Core/BAO/CustomField.php b/civicrm/CRM/Core/BAO/CustomField.php
index 02b9519e671a0d17b8e1679e8b96a69b1ec602ac..f8483021a3de5f6b81637cac58aa24239ffaec08 100644
--- a/civicrm/CRM/Core/BAO/CustomField.php
+++ b/civicrm/CRM/Core/BAO/CustomField.php
@@ -1421,18 +1421,6 @@ class CRM_Core_BAO_CustomField extends CRM_Core_DAO_CustomField {
         }
         break;
 
-      case 'Autocomplete-Select':
-        if ($customField->data_type == 'ContactReference') {
-          if (is_numeric($value)) {
-            $defaults[$elementName . '_id'] = $value;
-            $defaults[$elementName] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $value, 'sort_name');
-          }
-        }
-        else {
-          $defaults[$elementName] = $value;
-        }
-        break;
-
       default:
         $defaults[$elementName] = $value;
     }
diff --git a/civicrm/CRM/Core/BAO/CustomValueTable.php b/civicrm/CRM/Core/BAO/CustomValueTable.php
index dac03b0075093b46732b629d001131085cede8d6..9740318b97f10cdc1066bc6feaef27289c505817 100644
--- a/civicrm/CRM/Core/BAO/CustomValueTable.php
+++ b/civicrm/CRM/Core/BAO/CustomValueTable.php
@@ -536,16 +536,17 @@ AND    $cond
    * @return array
    */
   public static function setValues(&$params) {
+    // For legacy reasons, accept this param in either format
+    if (empty($params['entityID']) && !empty($params['entity_id'])) {
+      $params['entityID'] = $params['entity_id'];
+    }
 
-    if (!isset($params['entityID']) ||
-      CRM_Utils_Type::escape($params['entityID'], 'Integer', FALSE) === NULL
-    ) {
-      return CRM_Core_Error::createAPIError(ts('entityID needs to be set and of type Integer'));
+    if (!isset($params['entityID']) || !CRM_Utils_Type::validate($params['entityID'], 'Integer', FALSE)) {
+      return CRM_Core_Error::createAPIError(ts('entity_id needs to be set and of type Integer'));
     }
 
     // first collect all the id/value pairs. The format is:
     // custom_X => value or custom_X_VALUEID => value (for multiple values), VALUEID == -1, -2 etc for new insertions
-    $values = [];
     $fieldValues = [];
     foreach ($params as $n => $v) {
       if ($customFieldInfo = CRM_Core_BAO_CustomField::getKeyID($n, TRUE)) {
diff --git a/civicrm/CRM/Core/BAO/File.php b/civicrm/CRM/Core/BAO/File.php
index c9a1265d671ed7dec42d0752e4e6e171cd2a8549..c2c06bd279fbc166fe15af0537e3f7c2afe6d840 100644
--- a/civicrm/CRM/Core/BAO/File.php
+++ b/civicrm/CRM/Core/BAO/File.php
@@ -210,7 +210,7 @@ class CRM_Core_BAO_File extends CRM_Core_DAO_File {
     $fileDAO = new CRM_Core_DAO_File();
     $fileDAO->id = $fileID;
     if (!$fileDAO->find(TRUE)) {
-      CRM_Core_Error::fatal();
+      throw new CRM_Core_Exception(ts('File not found'));
     }
 
     // lets call a pre hook before the delete, so attachments hooks can get the info before things
@@ -226,7 +226,7 @@ class CRM_Core_BAO_File extends CRM_Core_DAO_File {
     $entityFileDAO->entity_table = $tableName;
 
     if (!$entityFileDAO->find(TRUE)) {
-      CRM_Core_Error::fatal(sprintf('No record found for given file ID - %d and entity ID - %d', $fileID, $entityID));
+      throw new CRM_Core_Exception(sprintf('No record found for given file ID - %d and entity ID - %d', $fileID, $entityID));
     }
 
     $entityFileDAO->delete();
diff --git a/civicrm/CRM/Core/BAO/UFField.php b/civicrm/CRM/Core/BAO/UFField.php
index dba79c97c89a5dbcf0bed31964c3115ff12ee481..4549d78d3b0a1f5963dc5dcffaa611c75ed47f0e 100644
--- a/civicrm/CRM/Core/BAO/UFField.php
+++ b/civicrm/CRM/Core/BAO/UFField.php
@@ -52,85 +52,74 @@ class CRM_Core_BAO_UFField extends CRM_Core_DAO_UFField {
    * @return \CRM_Core_BAO_UFField
    * @throws \API_Exception
    */
-  public static function create(&$params) {
-    // CRM-14756: kind of a hack-ish fix. If the user gives the id, uf_group_id is retrieved and then set.
-    if (isset($params['id'])) {
-      $groupId = civicrm_api3('UFField', 'getvalue', [
-        'return' => 'uf_group_id',
-        'id' => $params['id'],
-      ]);
-    }
-    else {
-      $groupId = CRM_Utils_Array::value('uf_group_id', $params);
-    }
+  public static function create($params) {
+    $id = CRM_Utils_Array::value('id', $params);
 
-    $field_name = CRM_Utils_Array::value('field_name', $params);
+    // Merge in data from existing field
+    if (!empty($id)) {
+      $UFField = new CRM_Core_BAO_UFField();
+      $UFField->id = $params['id'];
+      if ($UFField->find(TRUE)) {
+        $defaults = $UFField->toArray();
+        // This will be calculated based on field name
+        unset($defaults['field_type']);
+        $params += $defaults;
+      }
+      else {
+        throw new API_Exception("UFFIeld id {$params['id']} not found.");
+      }
+    }
 
-    if (strpos($field_name, 'formatting') !== 0 && !CRM_Core_BAO_UFField::isValidFieldName($field_name)) {
+    // Validate field_name
+    if (strpos($params['field_name'], 'formatting') !== 0 && !CRM_Core_BAO_UFField::isValidFieldName($params['field_name'])) {
       throw new API_Exception('The field_name is not valid');
     }
 
-    if (!(CRM_Utils_Array::value('group_id', $params))) {
-      $params['group_id'] = $groupId;
+    // Supply default label if not set
+    if (empty($id) && !isset($params['label'])) {
+      $params['label'] = self::getAvailableFieldTitles()[$params['field_name']];
     }
 
-    $fieldId = CRM_Utils_Array::value('id', $params);
-    if (!empty($fieldId)) {
-      $UFField = new CRM_Core_BAO_UFField();
-      $UFField->id = $fieldId;
-      if ($UFField->find(TRUE)) {
-        if (!(CRM_Utils_Array::value('group_id', $params))) {
-          // this copied here from previous api function - not sure if required
-          $params['group_id'] = $UFField->uf_group_id;
-        }
-      }
-      else {
-        throw new API_Exception("there is no field for this fieldId");
-      }
+    // Supply field_type if not set
+    if (empty($params['field_type']) && strpos($params['field_name'], 'formatting') !== 0) {
+      $params['field_type'] = CRM_Utils_Array::pathGet(self::getAvailableFieldsFlat(), [$params['field_name'], 'field_type']);
+    }
+    elseif (empty($params['field_type'])) {
+      $params['field_type'] = 'Formatting';
+    }
+
+    // Generate unique name for formatting fields
+    if ($params['field_name'] === 'formatting') {
+      $params['field_name'] = 'formatting_' . substr(uniqid(), -4);
     }
-    $params['uf_group_id'] = $params['group_id'];
 
-    if (CRM_Core_BAO_UFField::duplicateField($params)) {
+    if (self::duplicateField($params)) {
       throw new API_Exception("The field was not added. It already exists in this profile.");
     }
 
-    // @todo fix BAO to be less weird.
-    $field_type       = CRM_Utils_Array::value('field_type', $params);
-    $location_type_id = CRM_Utils_Array::value('location_type_id', $params, CRM_Utils_Array::value('website_type_id', $params));
-    $phone_type       = CRM_Utils_Array::value('phone_type_id', $params, CRM_Utils_Array::value('phone_type', $params));
-    $params['field_name'] = [$field_type, $field_name, $location_type_id, $phone_type];
     //@todo why is this even optional? Surely weight should just be 'managed' ??
     if (CRM_Utils_Array::value('option.autoweight', $params, TRUE)) {
       $params['weight'] = CRM_Core_BAO_UFField::autoWeight($params);
     }
-    // set values for uf field properties and save
+
+    // Set values for uf field properties and save
     $ufField = new CRM_Core_DAO_UFField();
     $ufField->copyValues($params);
-    $ufField->field_type = $params['field_name'][0];
-    $ufField->field_name = $params['field_name'][1];
 
-    //should not set location type id for Primary
-    $locationTypeId = NULL;
-    if ($params['field_name'][1] == 'url') {
-      $ufField->website_type_id = CRM_Utils_Array::value(2, $params['field_name']);
+    if ($params['field_name'] == 'url') {
+      $ufField->location_type_id = 'null';
     }
     else {
-      $locationTypeId = CRM_Utils_Array::value(2, $params['field_name']);
-      $ufField->website_type_id = NULL;
-    }
-    if ($locationTypeId) {
-      $ufField->location_type_id = $locationTypeId;
+      $ufField->website_type_id = 'null';
     }
-    else {
-      $ufField->location_type_id = 'null';
+    if (!strstr($params['field_name'], 'phone')) {
+      $ufField->phone_type_id = 'null';
     }
 
-    $ufField->phone_type_id = CRM_Utils_Array::value(3, $params['field_name'], 'NULL');
-
     $ufField->save();
 
-    $fieldsType = CRM_Core_BAO_UFGroup::calculateGroupType($groupId, TRUE);
-    CRM_Core_BAO_UFGroup::updateGroupTypes($groupId, $fieldsType);
+    $fieldsType = CRM_Core_BAO_UFGroup::calculateGroupType($ufField->uf_group_id, TRUE);
+    CRM_Core_BAO_UFGroup::updateGroupTypes($ufField->uf_group_id, $fieldsType);
 
     civicrm_api3('profile', 'getfields', ['cache_clear' => TRUE]);
     return $ufField;
@@ -204,8 +193,8 @@ class CRM_Core_BAO_UFField extends CRM_Core_DAO_UFField {
   public static function duplicateField($params) {
     $ufField = new CRM_Core_DAO_UFField();
     $ufField->uf_group_id = CRM_Utils_Array::value('uf_group_id', $params);
-    $ufField->field_type = $params['field_type'];
-    $ufField->field_name = $params['field_name'];
+    $ufField->field_type = CRM_Utils_Array::value('field_type', $params);
+    $ufField->field_name = CRM_Utils_Array::value('field_name', $params);
     $ufField->website_type_id = CRM_Utils_Array::value('website_type_id', $params);
     if (is_null(CRM_Utils_Array::value('location_type_id', $params, ''))) {
       // primary location type have NULL value in DB
@@ -220,7 +209,7 @@ class CRM_Core_BAO_UFField extends CRM_Core_DAO_UFField {
       $ufField->whereAdd("id <> " . $params['id']);
     }
 
-    return ($ufField->find(TRUE) ? 1 : 0);
+    return (bool) $ufField->find(TRUE);
   }
 
   /**
@@ -280,10 +269,10 @@ WHERE cf.id IN (" . $customFieldIds . ") AND is_multiple = 1 LIMIT 0,1";
     // fix for CRM-316
     $oldWeight = NULL;
 
-    if (!empty($params['field_id'])) {
-      $oldWeight = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFField', $params['field_id'], 'weight', 'id');
+    if (!empty($params['field_id']) || !empty($params['id'])) {
+      $oldWeight = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFField', !empty($params['id']) ? $params['id'] : $params['field_id'], 'weight', 'id');
     }
-    $fieldValues = ['uf_group_id' => $params['group_id']];
+    $fieldValues = ['uf_group_id' => !empty($params['uf_group_id']) ? $params['uf_group_id'] : $params['group_id']];
     return CRM_Utils_Weight::updateOtherWeights('CRM_Core_DAO_UFField', $oldWeight, CRM_Utils_Array::value('weight', $params, 0), $fieldValues);
   }
 
@@ -1061,24 +1050,33 @@ SELECT  id
    *
    * @param bool $force
    *
-   * @return array, multidimensional; e.g. $result['field_name']['label']
+   * @return array
+   *   e.g. $result['field_name']['label']
    */
   public static function getAvailableFieldsFlat($force = FALSE) {
-    // FIXME reset when data model changes
-    static $result = NULL;
-    if ($result === NULL || $force) {
-      $fieldTree = self::getAvailableFields();
-      $result = [];
-      foreach ($fieldTree as $field_type => $fields) {
-        foreach ($fields as $field_name => $field) {
-          if (!isset($result[$field_name])) {
-            $field['field_type'] = $field_type;
-            $result[$field_name] = $field;
+    if (!isset(Civi::$statics['UFFieldsFlat']) || $force) {
+      Civi::$statics['UFFieldsFlat'] = [];
+      foreach (self::getAvailableFields() as $fieldType => $fields) {
+        foreach ($fields as $fieldName => $field) {
+          if (!isset(Civi::$statics['UFFieldsFlat'][$fieldName])) {
+            $field['field_type'] = $fieldType;
+            Civi::$statics['UFFieldsFlat'][$fieldName] = $field;
           }
         }
       }
     }
-    return $result;
+    return Civi::$statics['UFFieldsFlat'];
+  }
+
+  /**
+   * Get a list of fields which can be added to profiles in the format [name => title]
+   *
+   * @return array
+   */
+  public static function getAvailableFieldTitles() {
+    $fields = self::getAvailableFieldsFlat();
+    $fields['formatting'] = ['title' => ts('Formatting')];
+    return CRM_Utils_Array::collect('title', $fields);
   }
 
   /**
diff --git a/civicrm/CRM/Core/CodeGen/Util/Template.php b/civicrm/CRM/Core/CodeGen/Util/Template.php
index 66efbc3867872c1d67d3f7609db30fad2ab413f8..ed2eac1cae61d5f975a5875dae798a935f1ec4b5 100644
--- a/civicrm/CRM/Core/CodeGen/Util/Template.php
+++ b/civicrm/CRM/Core/CodeGen/Util/Template.php
@@ -77,6 +77,7 @@ class CRM_Core_CodeGen_Util_Template {
         "\n  }\n}\n" => "\n  }\n\n}\n",
         '=> true,' => '=> TRUE,',
         '=> false,' => '=> FALSE,',
+        'static ::' => 'static::'
       ];
       $contents = str_replace(array_keys($replacements), array_values($replacements), $contents);
       $contents = preg_replace('#(\s*)\\/\\*\\*#', "\n\$1/**", $contents);
diff --git a/civicrm/CRM/Core/DAO/ActionLog.php b/civicrm/CRM/Core/DAO/ActionLog.php
index cdccd9babb9e38a4c722ce99700e6d648bff4513..3ebd410feccb48078c95cebfb5a256c2c4159491 100644
--- a/civicrm/CRM/Core/DAO/ActionLog.php
+++ b/civicrm/CRM/Core/DAO/ActionLog.php
@@ -134,6 +134,7 @@ class CRM_Core_DAO_ActionLog extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Action Schedule ID'),
           'required' => TRUE,
+          'where' => 'civicrm_action_log.id',
           'table_name' => 'civicrm_action_log',
           'entity' => 'ActionLog',
           'bao' => 'CRM_Core_BAO_ActionLog',
@@ -144,6 +145,7 @@ class CRM_Core_DAO_ActionLog extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Action Schedule Contact ID'),
           'description' => ts('FK to Contact ID'),
+          'where' => 'civicrm_action_log.contact_id',
           'table_name' => 'civicrm_action_log',
           'entity' => 'ActionLog',
           'bao' => 'CRM_Core_BAO_ActionLog',
@@ -156,6 +158,7 @@ class CRM_Core_DAO_ActionLog extends CRM_Core_DAO {
           'title' => ts('Entity ID'),
           'description' => ts('FK to id of the entity that the action was performed on. Pseudo - FK.'),
           'required' => TRUE,
+          'where' => 'civicrm_action_log.entity_id',
           'table_name' => 'civicrm_action_log',
           'entity' => 'ActionLog',
           'bao' => 'CRM_Core_BAO_ActionLog',
@@ -168,6 +171,7 @@ class CRM_Core_DAO_ActionLog extends CRM_Core_DAO {
           'description' => ts('name of the entity table for the above id, e.g. civicrm_activity, civicrm_participant'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_action_log.entity_table',
           'table_name' => 'civicrm_action_log',
           'entity' => 'ActionLog',
           'bao' => 'CRM_Core_BAO_ActionLog',
@@ -179,6 +183,7 @@ class CRM_Core_DAO_ActionLog extends CRM_Core_DAO {
           'title' => ts('Schedule'),
           'description' => ts('FK to the action schedule that this action originated from.'),
           'required' => TRUE,
+          'where' => 'civicrm_action_log.action_schedule_id',
           'table_name' => 'civicrm_action_log',
           'entity' => 'ActionLog',
           'bao' => 'CRM_Core_BAO_ActionLog',
@@ -190,6 +195,7 @@ class CRM_Core_DAO_ActionLog extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
           'title' => ts('Action Date And Time'),
           'description' => ts('date time that the action was performed on.'),
+          'where' => 'civicrm_action_log.action_date_time',
           'table_name' => 'civicrm_action_log',
           'entity' => 'ActionLog',
           'bao' => 'CRM_Core_BAO_ActionLog',
@@ -200,6 +206,7 @@ class CRM_Core_DAO_ActionLog extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Error?'),
           'description' => ts('Was there any error sending the reminder?'),
+          'where' => 'civicrm_action_log.is_error',
           'default' => '0',
           'table_name' => 'civicrm_action_log',
           'entity' => 'ActionLog',
@@ -211,6 +218,7 @@ class CRM_Core_DAO_ActionLog extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_TEXT,
           'title' => ts('Message'),
           'description' => ts('Description / text in case there was an error encountered.'),
+          'where' => 'civicrm_action_log.message',
           'table_name' => 'civicrm_action_log',
           'entity' => 'ActionLog',
           'bao' => 'CRM_Core_BAO_ActionLog',
@@ -221,6 +229,7 @@ class CRM_Core_DAO_ActionLog extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Repetition Number'),
           'description' => ts('Keeps track of the sequence number of this repetition.'),
+          'where' => 'civicrm_action_log.repetition_number',
           'table_name' => 'civicrm_action_log',
           'entity' => 'ActionLog',
           'bao' => 'CRM_Core_BAO_ActionLog',
@@ -231,6 +240,7 @@ class CRM_Core_DAO_ActionLog extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_DATE,
           'title' => ts('Reference Date'),
           'description' => ts('Stores the date from the entity which triggered this reminder action (e.g. membership.end_date for most membership renewal reminders)'),
+          'where' => 'civicrm_action_log.reference_date',
           'default' => 'NULL',
           'table_name' => 'civicrm_action_log',
           'entity' => 'ActionLog',
diff --git a/civicrm/CRM/Core/DAO/ActionMapping.php b/civicrm/CRM/Core/DAO/ActionMapping.php
index cafb30f2aa904834e4451c5458636dd85e705b67..fce373b430dd513dfc23e12f452d1db960291649 100644
--- a/civicrm/CRM/Core/DAO/ActionMapping.php
+++ b/civicrm/CRM/Core/DAO/ActionMapping.php
@@ -110,6 +110,7 @@ class CRM_Core_DAO_ActionMapping extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Action Mapping ID'),
           'required' => TRUE,
+          'where' => 'civicrm_action_mapping.id',
           'table_name' => 'civicrm_action_mapping',
           'entity' => 'ActionMapping',
           'bao' => 'CRM_Core_DAO_ActionMapping',
@@ -122,6 +123,7 @@ class CRM_Core_DAO_ActionMapping extends CRM_Core_DAO {
           'description' => ts('Entity for which the reminder is created'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_action_mapping.entity',
           'table_name' => 'civicrm_action_mapping',
           'entity' => 'ActionMapping',
           'bao' => 'CRM_Core_DAO_ActionMapping',
@@ -134,6 +136,7 @@ class CRM_Core_DAO_ActionMapping extends CRM_Core_DAO {
           'description' => ts('Entity value'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_action_mapping.entity_value',
           'table_name' => 'civicrm_action_mapping',
           'entity' => 'ActionMapping',
           'bao' => 'CRM_Core_DAO_ActionMapping',
@@ -146,6 +149,7 @@ class CRM_Core_DAO_ActionMapping extends CRM_Core_DAO {
           'description' => ts('Entity value label'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_action_mapping.entity_value_label',
           'table_name' => 'civicrm_action_mapping',
           'entity' => 'ActionMapping',
           'bao' => 'CRM_Core_DAO_ActionMapping',
@@ -158,6 +162,7 @@ class CRM_Core_DAO_ActionMapping extends CRM_Core_DAO {
           'description' => ts('Entity status'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_action_mapping.entity_status',
           'table_name' => 'civicrm_action_mapping',
           'entity' => 'ActionMapping',
           'bao' => 'CRM_Core_DAO_ActionMapping',
@@ -170,6 +175,7 @@ class CRM_Core_DAO_ActionMapping extends CRM_Core_DAO {
           'description' => ts('Entity status label'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_action_mapping.entity_status_label',
           'table_name' => 'civicrm_action_mapping',
           'entity' => 'ActionMapping',
           'bao' => 'CRM_Core_DAO_ActionMapping',
@@ -182,6 +188,7 @@ class CRM_Core_DAO_ActionMapping extends CRM_Core_DAO {
           'description' => ts('Entity date'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_action_mapping.entity_date_start',
           'table_name' => 'civicrm_action_mapping',
           'entity' => 'ActionMapping',
           'bao' => 'CRM_Core_DAO_ActionMapping',
@@ -194,6 +201,7 @@ class CRM_Core_DAO_ActionMapping extends CRM_Core_DAO {
           'description' => ts('Entity date'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_action_mapping.entity_date_end',
           'table_name' => 'civicrm_action_mapping',
           'entity' => 'ActionMapping',
           'bao' => 'CRM_Core_DAO_ActionMapping',
@@ -206,6 +214,7 @@ class CRM_Core_DAO_ActionMapping extends CRM_Core_DAO {
           'description' => ts('Entity recipient'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_action_mapping.entity_recipient',
           'table_name' => 'civicrm_action_mapping',
           'entity' => 'ActionMapping',
           'bao' => 'CRM_Core_DAO_ActionMapping',
diff --git a/civicrm/CRM/Core/DAO/ActionSchedule.php b/civicrm/CRM/Core/DAO/ActionSchedule.php
index 7e5afe04e93088b894703e27445bce96f78fc5b8..25b0376dda16b32d81f32053fd7f561fb3ae374d 100644
--- a/civicrm/CRM/Core/DAO/ActionSchedule.php
+++ b/civicrm/CRM/Core/DAO/ActionSchedule.php
@@ -327,6 +327,7 @@ class CRM_Core_DAO_ActionSchedule extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Action Schedule ID'),
           'required' => TRUE,
+          'where' => 'civicrm_action_schedule.id',
           'table_name' => 'civicrm_action_schedule',
           'entity' => 'ActionSchedule',
           'bao' => 'CRM_Core_BAO_ActionSchedule',
@@ -339,6 +340,7 @@ class CRM_Core_DAO_ActionSchedule extends CRM_Core_DAO {
           'description' => ts('Name of the action(reminder)'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_action_schedule.name',
           'table_name' => 'civicrm_action_schedule',
           'entity' => 'ActionSchedule',
           'bao' => 'CRM_Core_BAO_ActionSchedule',
@@ -351,6 +353,7 @@ class CRM_Core_DAO_ActionSchedule extends CRM_Core_DAO {
           'description' => ts('Title of the action(reminder)'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_action_schedule.title',
           'table_name' => 'civicrm_action_schedule',
           'entity' => 'ActionSchedule',
           'bao' => 'CRM_Core_BAO_ActionSchedule',
@@ -363,6 +366,7 @@ class CRM_Core_DAO_ActionSchedule extends CRM_Core_DAO {
           'description' => ts('Recipient'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_action_schedule.recipient',
           'table_name' => 'civicrm_action_schedule',
           'entity' => 'ActionSchedule',
           'bao' => 'CRM_Core_BAO_ActionSchedule',
@@ -373,6 +377,7 @@ class CRM_Core_DAO_ActionSchedule extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Limit To'),
           'description' => ts('Is this the recipient criteria limited to OR in addition to?'),
+          'where' => 'civicrm_action_schedule.limit_to',
           'table_name' => 'civicrm_action_schedule',
           'entity' => 'ActionSchedule',
           'bao' => 'CRM_Core_BAO_ActionSchedule',
@@ -385,6 +390,7 @@ class CRM_Core_DAO_ActionSchedule extends CRM_Core_DAO {
           'description' => ts('Entity value'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_action_schedule.entity_value',
           'table_name' => 'civicrm_action_schedule',
           'entity' => 'ActionSchedule',
           'bao' => 'CRM_Core_BAO_ActionSchedule',
@@ -397,6 +403,7 @@ class CRM_Core_DAO_ActionSchedule extends CRM_Core_DAO {
           'description' => ts('Entity status'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_action_schedule.entity_status',
           'table_name' => 'civicrm_action_schedule',
           'entity' => 'ActionSchedule',
           'bao' => 'CRM_Core_BAO_ActionSchedule',
@@ -407,6 +414,7 @@ class CRM_Core_DAO_ActionSchedule extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Start Action Offset'),
           'description' => ts('Reminder Interval.'),
+          'where' => 'civicrm_action_schedule.start_action_offset',
           'default' => '0',
           'table_name' => 'civicrm_action_schedule',
           'entity' => 'ActionSchedule',
@@ -420,6 +428,7 @@ class CRM_Core_DAO_ActionSchedule extends CRM_Core_DAO {
           'description' => ts('Time units for reminder.'),
           'maxlength' => 8,
           'size' => CRM_Utils_Type::EIGHT,
+          'where' => 'civicrm_action_schedule.start_action_unit',
           'table_name' => 'civicrm_action_schedule',
           'entity' => 'ActionSchedule',
           'bao' => 'CRM_Core_BAO_ActionSchedule',
@@ -438,6 +447,7 @@ class CRM_Core_DAO_ActionSchedule extends CRM_Core_DAO {
           'description' => ts('Reminder Action'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_action_schedule.start_action_condition',
           'table_name' => 'civicrm_action_schedule',
           'entity' => 'ActionSchedule',
           'bao' => 'CRM_Core_BAO_ActionSchedule',
@@ -450,6 +460,7 @@ class CRM_Core_DAO_ActionSchedule extends CRM_Core_DAO {
           'description' => ts('Entity date'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_action_schedule.start_action_date',
           'table_name' => 'civicrm_action_schedule',
           'entity' => 'ActionSchedule',
           'bao' => 'CRM_Core_BAO_ActionSchedule',
@@ -459,6 +470,7 @@ class CRM_Core_DAO_ActionSchedule extends CRM_Core_DAO {
           'name' => 'is_repeat',
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Repeat?'),
+          'where' => 'civicrm_action_schedule.is_repeat',
           'default' => '0',
           'table_name' => 'civicrm_action_schedule',
           'entity' => 'ActionSchedule',
@@ -472,6 +484,7 @@ class CRM_Core_DAO_ActionSchedule extends CRM_Core_DAO {
           'description' => ts('Time units for repetition of reminder.'),
           'maxlength' => 8,
           'size' => CRM_Utils_Type::EIGHT,
+          'where' => 'civicrm_action_schedule.repetition_frequency_unit',
           'table_name' => 'civicrm_action_schedule',
           'entity' => 'ActionSchedule',
           'bao' => 'CRM_Core_BAO_ActionSchedule',
@@ -488,6 +501,7 @@ class CRM_Core_DAO_ActionSchedule extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Repetition Frequency Interval'),
           'description' => ts('Time interval for repeating the reminder.'),
+          'where' => 'civicrm_action_schedule.repetition_frequency_interval',
           'default' => '0',
           'table_name' => 'civicrm_action_schedule',
           'entity' => 'ActionSchedule',
@@ -501,6 +515,7 @@ class CRM_Core_DAO_ActionSchedule extends CRM_Core_DAO {
           'description' => ts('Time units till repetition of reminder.'),
           'maxlength' => 8,
           'size' => CRM_Utils_Type::EIGHT,
+          'where' => 'civicrm_action_schedule.end_frequency_unit',
           'table_name' => 'civicrm_action_schedule',
           'entity' => 'ActionSchedule',
           'bao' => 'CRM_Core_BAO_ActionSchedule',
@@ -517,6 +532,7 @@ class CRM_Core_DAO_ActionSchedule extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('End Frequency Interval'),
           'description' => ts('Time interval till repeating the reminder.'),
+          'where' => 'civicrm_action_schedule.end_frequency_interval',
           'default' => '0',
           'table_name' => 'civicrm_action_schedule',
           'entity' => 'ActionSchedule',
@@ -530,6 +546,7 @@ class CRM_Core_DAO_ActionSchedule extends CRM_Core_DAO {
           'description' => ts('Reminder Action till repeating the reminder.'),
           'maxlength' => 32,
           'size' => CRM_Utils_Type::MEDIUM,
+          'where' => 'civicrm_action_schedule.end_action',
           'table_name' => 'civicrm_action_schedule',
           'entity' => 'ActionSchedule',
           'bao' => 'CRM_Core_BAO_ActionSchedule',
@@ -542,6 +559,7 @@ class CRM_Core_DAO_ActionSchedule extends CRM_Core_DAO {
           'description' => ts('Entity end date'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_action_schedule.end_date',
           'table_name' => 'civicrm_action_schedule',
           'entity' => 'ActionSchedule',
           'bao' => 'CRM_Core_BAO_ActionSchedule',
@@ -552,6 +570,7 @@ class CRM_Core_DAO_ActionSchedule extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Schedule is Active?'),
           'description' => ts('Is this option active?'),
+          'where' => 'civicrm_action_schedule.is_active',
           'default' => '1',
           'table_name' => 'civicrm_action_schedule',
           'entity' => 'ActionSchedule',
@@ -565,6 +584,7 @@ class CRM_Core_DAO_ActionSchedule extends CRM_Core_DAO {
           'description' => ts('Contact IDs to which reminder should be sent.'),
           'maxlength' => 128,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_action_schedule.recipient_manual',
           'table_name' => 'civicrm_action_schedule',
           'entity' => 'ActionSchedule',
           'bao' => 'CRM_Core_BAO_ActionSchedule',
@@ -577,6 +597,7 @@ class CRM_Core_DAO_ActionSchedule extends CRM_Core_DAO {
           'description' => ts('listing based on recipient field.'),
           'maxlength' => 128,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_action_schedule.recipient_listing',
           'table_name' => 'civicrm_action_schedule',
           'entity' => 'ActionSchedule',
           'bao' => 'CRM_Core_BAO_ActionSchedule',
@@ -587,6 +608,7 @@ class CRM_Core_DAO_ActionSchedule extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_LONGTEXT,
           'title' => ts('Reminder Text'),
           'description' => ts('Body of the mailing in text format.'),
+          'where' => 'civicrm_action_schedule.body_text',
           'table_name' => 'civicrm_action_schedule',
           'entity' => 'ActionSchedule',
           'bao' => 'CRM_Core_BAO_ActionSchedule',
@@ -597,6 +619,7 @@ class CRM_Core_DAO_ActionSchedule extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_LONGTEXT,
           'title' => ts('Reminder HTML'),
           'description' => ts('Body of the mailing in html format.'),
+          'where' => 'civicrm_action_schedule.body_html',
           'table_name' => 'civicrm_action_schedule',
           'entity' => 'ActionSchedule',
           'bao' => 'CRM_Core_BAO_ActionSchedule',
@@ -607,6 +630,7 @@ class CRM_Core_DAO_ActionSchedule extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_LONGTEXT,
           'title' => ts('SMS Reminder Text'),
           'description' => ts('Content of the SMS text.'),
+          'where' => 'civicrm_action_schedule.sms_body_text',
           'table_name' => 'civicrm_action_schedule',
           'entity' => 'ActionSchedule',
           'bao' => 'CRM_Core_BAO_ActionSchedule',
@@ -619,6 +643,7 @@ class CRM_Core_DAO_ActionSchedule extends CRM_Core_DAO {
           'description' => ts('Subject of mailing'),
           'maxlength' => 128,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_action_schedule.subject',
           'table_name' => 'civicrm_action_schedule',
           'entity' => 'ActionSchedule',
           'bao' => 'CRM_Core_BAO_ActionSchedule',
@@ -629,6 +654,7 @@ class CRM_Core_DAO_ActionSchedule extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Record Activity for Reminder?'),
           'description' => ts('Record Activity for this reminder?'),
+          'where' => 'civicrm_action_schedule.record_activity',
           'default' => 'NULL',
           'table_name' => 'civicrm_action_schedule',
           'entity' => 'ActionSchedule',
@@ -642,6 +668,7 @@ class CRM_Core_DAO_ActionSchedule extends CRM_Core_DAO {
           'description' => ts('Name/ID of the mapping to use on this table'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_action_schedule.mapping_id',
           'table_name' => 'civicrm_action_schedule',
           'entity' => 'ActionSchedule',
           'bao' => 'CRM_Core_BAO_ActionSchedule',
@@ -652,6 +679,7 @@ class CRM_Core_DAO_ActionSchedule extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Reminder Group'),
           'description' => ts('FK to Group'),
+          'where' => 'civicrm_action_schedule.group_id',
           'table_name' => 'civicrm_action_schedule',
           'entity' => 'ActionSchedule',
           'bao' => 'CRM_Core_BAO_ActionSchedule',
@@ -671,6 +699,7 @@ class CRM_Core_DAO_ActionSchedule extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Reminder Template'),
           'description' => ts('FK to the message template.'),
+          'where' => 'civicrm_action_schedule.msg_template_id',
           'table_name' => 'civicrm_action_schedule',
           'entity' => 'ActionSchedule',
           'bao' => 'CRM_Core_BAO_ActionSchedule',
@@ -682,6 +711,7 @@ class CRM_Core_DAO_ActionSchedule extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('SMS Reminder Template'),
           'description' => ts('FK to the message template.'),
+          'where' => 'civicrm_action_schedule.sms_template_id',
           'table_name' => 'civicrm_action_schedule',
           'entity' => 'ActionSchedule',
           'bao' => 'CRM_Core_BAO_ActionSchedule',
@@ -693,6 +723,7 @@ class CRM_Core_DAO_ActionSchedule extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_DATE,
           'title' => ts('Fixed Date for Reminder'),
           'description' => ts('Date on which the reminder be sent.'),
+          'where' => 'civicrm_action_schedule.absolute_date',
           'table_name' => 'civicrm_action_schedule',
           'entity' => 'ActionSchedule',
           'bao' => 'CRM_Core_BAO_ActionSchedule',
@@ -705,6 +736,7 @@ class CRM_Core_DAO_ActionSchedule extends CRM_Core_DAO {
           'description' => ts('Name in "from" field'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_action_schedule.from_name',
           'table_name' => 'civicrm_action_schedule',
           'entity' => 'ActionSchedule',
           'bao' => 'CRM_Core_BAO_ActionSchedule',
@@ -717,6 +749,7 @@ class CRM_Core_DAO_ActionSchedule extends CRM_Core_DAO {
           'description' => ts('Email address in "from" field'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_action_schedule.from_email',
           'table_name' => 'civicrm_action_schedule',
           'entity' => 'ActionSchedule',
           'bao' => 'CRM_Core_BAO_ActionSchedule',
@@ -729,6 +762,7 @@ class CRM_Core_DAO_ActionSchedule extends CRM_Core_DAO {
           'description' => ts('Send the message as email or sms or both.'),
           'maxlength' => 128,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_action_schedule.mode',
           'default' => 'Email',
           'table_name' => 'civicrm_action_schedule',
           'entity' => 'ActionSchedule',
@@ -746,6 +780,7 @@ class CRM_Core_DAO_ActionSchedule extends CRM_Core_DAO {
           'name' => 'sms_provider_id',
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('SMS Provider'),
+          'where' => 'civicrm_action_schedule.sms_provider_id',
           'table_name' => 'civicrm_action_schedule',
           'entity' => 'ActionSchedule',
           'bao' => 'CRM_Core_BAO_ActionSchedule',
@@ -762,6 +797,7 @@ class CRM_Core_DAO_ActionSchedule extends CRM_Core_DAO {
           'description' => ts('Used for repeating entity'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_action_schedule.used_for',
           'table_name' => 'civicrm_action_schedule',
           'entity' => 'ActionSchedule',
           'bao' => 'CRM_Core_BAO_ActionSchedule',
@@ -774,6 +810,7 @@ class CRM_Core_DAO_ActionSchedule extends CRM_Core_DAO {
           'description' => ts('Used for multilingual installation'),
           'maxlength' => 128,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_action_schedule.filter_contact_language',
           'table_name' => 'civicrm_action_schedule',
           'entity' => 'ActionSchedule',
           'bao' => 'CRM_Core_BAO_ActionSchedule',
@@ -786,6 +823,7 @@ class CRM_Core_DAO_ActionSchedule extends CRM_Core_DAO {
           'description' => ts('Used for multilingual installation'),
           'maxlength' => 8,
           'size' => CRM_Utils_Type::EIGHT,
+          'where' => 'civicrm_action_schedule.communication_language',
           'table_name' => 'civicrm_action_schedule',
           'entity' => 'ActionSchedule',
           'bao' => 'CRM_Core_BAO_ActionSchedule',
diff --git a/civicrm/CRM/Core/DAO/Address.php b/civicrm/CRM/Core/DAO/Address.php
index 05402a732e315ca8186bf03422a8b2ffc5723b9f..f020412740ff0ee7349db790888fe4cf95e54656 100644
--- a/civicrm/CRM/Core/DAO/Address.php
+++ b/civicrm/CRM/Core/DAO/Address.php
@@ -272,6 +272,7 @@ class CRM_Core_DAO_Address extends CRM_Core_DAO {
           'title' => ts('Address ID'),
           'description' => ts('Unique Address ID'),
           'required' => TRUE,
+          'where' => 'civicrm_address.id',
           'table_name' => 'civicrm_address',
           'entity' => 'Address',
           'bao' => 'CRM_Core_BAO_Address',
@@ -282,6 +283,7 @@ class CRM_Core_DAO_Address extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Contact ID'),
           'description' => ts('FK to Contact ID'),
+          'where' => 'civicrm_address.contact_id',
           'table_name' => 'civicrm_address',
           'entity' => 'Address',
           'bao' => 'CRM_Core_BAO_Address',
@@ -293,6 +295,7 @@ class CRM_Core_DAO_Address extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Address Location Type'),
           'description' => ts('Which Location does this address belong to.'),
+          'where' => 'civicrm_address.location_type_id',
           'table_name' => 'civicrm_address',
           'entity' => 'Address',
           'bao' => 'CRM_Core_BAO_Address',
@@ -311,6 +314,7 @@ class CRM_Core_DAO_Address extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Is Address Primary?'),
           'description' => ts('Is this the primary address.'),
+          'where' => 'civicrm_address.is_primary',
           'default' => '0',
           'table_name' => 'civicrm_address',
           'entity' => 'Address',
@@ -325,6 +329,7 @@ class CRM_Core_DAO_Address extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Is Billing Address'),
           'description' => ts('Is this the billing address.'),
+          'where' => 'civicrm_address.is_billing',
           'default' => '0',
           'table_name' => 'civicrm_address',
           'entity' => 'Address',
@@ -362,10 +367,8 @@ class CRM_Core_DAO_Address extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Street Number'),
           'description' => ts('Numeric portion of address number on the street, e.g. For 112A Main St, the street_number = 112.'),
-          'export' => TRUE,
           'where' => 'civicrm_address.street_number',
-          'headerPattern' => '',
-          'dataPattern' => '',
+          'export' => TRUE,
           'table_name' => 'civicrm_address',
           'entity' => 'Address',
           'bao' => 'CRM_Core_BAO_Address',
@@ -382,10 +385,8 @@ class CRM_Core_DAO_Address extends CRM_Core_DAO {
     '),
           'maxlength' => 8,
           'size' => CRM_Utils_Type::EIGHT,
-          'export' => TRUE,
           'where' => 'civicrm_address.street_number_suffix',
-          'headerPattern' => '',
-          'dataPattern' => '',
+          'export' => TRUE,
           'table_name' => 'civicrm_address',
           'entity' => 'Address',
           'bao' => 'CRM_Core_BAO_Address',
@@ -401,6 +402,7 @@ class CRM_Core_DAO_Address extends CRM_Core_DAO {
           'description' => ts('Directional prefix, e.g. SE Main St, SE is the prefix.'),
           'maxlength' => 8,
           'size' => CRM_Utils_Type::EIGHT,
+          'where' => 'civicrm_address.street_number_predirectional',
           'table_name' => 'civicrm_address',
           'entity' => 'Address',
           'bao' => 'CRM_Core_BAO_Address',
@@ -416,10 +418,8 @@ class CRM_Core_DAO_Address extends CRM_Core_DAO {
           'description' => ts('Actual street name, excluding St, Dr, Rd, Ave, e.g. For 112 Main St, the street_name = Main.'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
-          'export' => TRUE,
           'where' => 'civicrm_address.street_name',
-          'headerPattern' => '',
-          'dataPattern' => '',
+          'export' => TRUE,
           'table_name' => 'civicrm_address',
           'entity' => 'Address',
           'bao' => 'CRM_Core_BAO_Address',
@@ -435,6 +435,7 @@ class CRM_Core_DAO_Address extends CRM_Core_DAO {
           'description' => ts('St, Rd, Dr, etc.'),
           'maxlength' => 8,
           'size' => CRM_Utils_Type::EIGHT,
+          'where' => 'civicrm_address.street_type',
           'table_name' => 'civicrm_address',
           'entity' => 'Address',
           'bao' => 'CRM_Core_BAO_Address',
@@ -450,6 +451,7 @@ class CRM_Core_DAO_Address extends CRM_Core_DAO {
           'description' => ts('Directional prefix, e.g. Main St S, S is the suffix.'),
           'maxlength' => 8,
           'size' => CRM_Utils_Type::EIGHT,
+          'where' => 'civicrm_address.street_number_postdirectional',
           'table_name' => 'civicrm_address',
           'entity' => 'Address',
           'bao' => 'CRM_Core_BAO_Address',
@@ -465,10 +467,8 @@ class CRM_Core_DAO_Address extends CRM_Core_DAO {
           'description' => ts('Secondary unit designator, e.g. Apt 3 or Unit # 14, or Bldg 1200'),
           'maxlength' => 16,
           'size' => CRM_Utils_Type::TWELVE,
-          'export' => TRUE,
           'where' => 'civicrm_address.street_unit',
-          'headerPattern' => '',
-          'dataPattern' => '',
+          'export' => TRUE,
           'table_name' => 'civicrm_address',
           'entity' => 'Address',
           'bao' => 'CRM_Core_BAO_Address',
@@ -562,6 +562,7 @@ class CRM_Core_DAO_Address extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('County'),
           'description' => ts('Which County does this address belong to.'),
+          'where' => 'civicrm_address.county_id',
           'table_name' => 'civicrm_address',
           'entity' => 'Address',
           'bao' => 'CRM_Core_BAO_Address',
@@ -581,6 +582,7 @@ class CRM_Core_DAO_Address extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('State/Province'),
           'description' => ts('Which State_Province does this address belong to.'),
+          'where' => 'civicrm_address.state_province_id',
           'table_name' => 'civicrm_address',
           'entity' => 'Address',
           'bao' => 'CRM_Core_BAO_Address',
@@ -643,6 +645,7 @@ class CRM_Core_DAO_Address extends CRM_Core_DAO {
           'description' => ts('USPS Bulk mailing code.'),
           'maxlength' => 32,
           'size' => CRM_Utils_Type::MEDIUM,
+          'where' => 'civicrm_address.usps_adc',
           'table_name' => 'civicrm_address',
           'entity' => 'Address',
           'bao' => 'CRM_Core_BAO_Address',
@@ -653,6 +656,7 @@ class CRM_Core_DAO_Address extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Country'),
           'description' => ts('Which Country does this address belong to.'),
+          'where' => 'civicrm_address.country_id',
           'table_name' => 'civicrm_address',
           'entity' => 'Address',
           'bao' => 'CRM_Core_BAO_Address',
@@ -677,7 +681,6 @@ class CRM_Core_DAO_Address extends CRM_Core_DAO {
           'import' => TRUE,
           'where' => 'civicrm_address.geo_code_1',
           'headerPattern' => '/geo/i',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_address',
           'entity' => 'Address',
@@ -695,7 +698,6 @@ class CRM_Core_DAO_Address extends CRM_Core_DAO {
           'import' => TRUE,
           'where' => 'civicrm_address.geo_code_2',
           'headerPattern' => '/geo/i',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_address',
           'entity' => 'Address',
@@ -710,6 +712,7 @@ class CRM_Core_DAO_Address extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Is manually geocoded'),
           'description' => ts('Is this a manually entered geo code'),
+          'where' => 'civicrm_address.manual_geo_code',
           'default' => '0',
           'table_name' => 'civicrm_address',
           'entity' => 'Address',
@@ -726,6 +729,7 @@ class CRM_Core_DAO_Address extends CRM_Core_DAO {
           'description' => ts('Timezone expressed as a UTC offset - e.g. United States CST would be written as "UTC-6".'),
           'maxlength' => 8,
           'size' => CRM_Utils_Type::EIGHT,
+          'where' => 'civicrm_address.timezone',
           'table_name' => 'civicrm_address',
           'entity' => 'Address',
           'bao' => 'CRM_Core_BAO_Address',
@@ -760,8 +764,6 @@ class CRM_Core_DAO_Address extends CRM_Core_DAO {
           'description' => ts('FK to Address ID'),
           'import' => TRUE,
           'where' => 'civicrm_address.master_id',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_address',
           'entity' => 'Address',
diff --git a/civicrm/CRM/Core/DAO/AddressFormat.php b/civicrm/CRM/Core/DAO/AddressFormat.php
index d9286653a4931fb438b5e5891fe2a688ac8bce25..6db05ca4ad455ea9e153cdef318f834324254509 100644
--- a/civicrm/CRM/Core/DAO/AddressFormat.php
+++ b/civicrm/CRM/Core/DAO/AddressFormat.php
@@ -64,6 +64,7 @@ class CRM_Core_DAO_AddressFormat extends CRM_Core_DAO {
           'title' => ts('Address Format ID'),
           'description' => ts('Address Format Id'),
           'required' => TRUE,
+          'where' => 'civicrm_address_format.id',
           'table_name' => 'civicrm_address_format',
           'entity' => 'AddressFormat',
           'bao' => 'CRM_Core_DAO_AddressFormat',
@@ -74,6 +75,7 @@ class CRM_Core_DAO_AddressFormat extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_TEXT,
           'title' => ts('Address Format'),
           'description' => ts('The format of an address'),
+          'where' => 'civicrm_address_format.format',
           'table_name' => 'civicrm_address_format',
           'entity' => 'AddressFormat',
           'bao' => 'CRM_Core_DAO_AddressFormat',
diff --git a/civicrm/CRM/Core/DAO/Cache.php b/civicrm/CRM/Core/DAO/Cache.php
index d378cc8dd93f1a916e3adf3b8bf447060490a55e..a92e8ad9777ab5462b020e8e47425e0cb40e4918 100644
--- a/civicrm/CRM/Core/DAO/Cache.php
+++ b/civicrm/CRM/Core/DAO/Cache.php
@@ -110,6 +110,7 @@ class CRM_Core_DAO_Cache extends CRM_Core_DAO {
           'name' => 'id',
           'type' => CRM_Utils_Type::T_INT,
           'required' => TRUE,
+          'where' => 'civicrm_cache.id',
           'table_name' => 'civicrm_cache',
           'entity' => 'Cache',
           'bao' => 'CRM_Core_BAO_Cache',
@@ -123,6 +124,7 @@ class CRM_Core_DAO_Cache extends CRM_Core_DAO {
           'required' => TRUE,
           'maxlength' => 32,
           'size' => CRM_Utils_Type::MEDIUM,
+          'where' => 'civicrm_cache.group_name',
           'table_name' => 'civicrm_cache',
           'entity' => 'Cache',
           'bao' => 'CRM_Core_BAO_Cache',
@@ -135,6 +137,7 @@ class CRM_Core_DAO_Cache extends CRM_Core_DAO {
           'description' => ts('Unique path name for cache element'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_cache.path',
           'table_name' => 'civicrm_cache',
           'entity' => 'Cache',
           'bao' => 'CRM_Core_BAO_Cache',
@@ -145,6 +148,7 @@ class CRM_Core_DAO_Cache extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_LONGTEXT,
           'title' => ts('Data'),
           'description' => ts('data associated with this path'),
+          'where' => 'civicrm_cache.data',
           'table_name' => 'civicrm_cache',
           'entity' => 'Cache',
           'bao' => 'CRM_Core_BAO_Cache',
@@ -154,6 +158,7 @@ class CRM_Core_DAO_Cache extends CRM_Core_DAO {
           'name' => 'component_id',
           'type' => CRM_Utils_Type::T_INT,
           'description' => ts('Component that this menu item belongs to'),
+          'where' => 'civicrm_cache.component_id',
           'table_name' => 'civicrm_cache',
           'entity' => 'Cache',
           'bao' => 'CRM_Core_BAO_Cache',
@@ -173,6 +178,7 @@ class CRM_Core_DAO_Cache extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_TIMESTAMP,
           'title' => ts('Created Date'),
           'description' => ts('When was the cache item created'),
+          'where' => 'civicrm_cache.created_date',
           'default' => 'CURRENT_TIMESTAMP',
           'table_name' => 'civicrm_cache',
           'entity' => 'Cache',
@@ -185,6 +191,7 @@ class CRM_Core_DAO_Cache extends CRM_Core_DAO {
           'title' => ts('Expired Date'),
           'description' => ts('When should the cache item expire'),
           'required' => FALSE,
+          'where' => 'civicrm_cache.expired_date',
           'default' => 'NULL',
           'table_name' => 'civicrm_cache',
           'entity' => 'Cache',
diff --git a/civicrm/CRM/Core/DAO/Component.php b/civicrm/CRM/Core/DAO/Component.php
index 6303b7b1002a15f397b110cfa25d54f36e52e042..710c3b15936115cfb40428b6420060cabd843a91 100644
--- a/civicrm/CRM/Core/DAO/Component.php
+++ b/civicrm/CRM/Core/DAO/Component.php
@@ -72,6 +72,7 @@ class CRM_Core_DAO_Component extends CRM_Core_DAO {
           'title' => ts('Component ID'),
           'description' => ts('Component ID'),
           'required' => TRUE,
+          'where' => 'civicrm_component.id',
           'table_name' => 'civicrm_component',
           'entity' => 'Component',
           'bao' => 'CRM_Core_DAO_Component',
@@ -85,6 +86,7 @@ class CRM_Core_DAO_Component extends CRM_Core_DAO {
           'required' => TRUE,
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_component.name',
           'table_name' => 'civicrm_component',
           'entity' => 'Component',
           'bao' => 'CRM_Core_DAO_Component',
@@ -99,6 +101,7 @@ class CRM_Core_DAO_Component extends CRM_Core_DAO {
     '),
           'maxlength' => 128,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_component.namespace',
           'table_name' => 'civicrm_component',
           'entity' => 'Component',
           'bao' => 'CRM_Core_DAO_Component',
diff --git a/civicrm/CRM/Core/DAO/Country.php b/civicrm/CRM/Core/DAO/Country.php
index 376f3738f82cd17ec3a4967719496e3f937d4f89..fa5108bc655c2db6a4ed33a5e125c86e3351aba5 100644
--- a/civicrm/CRM/Core/DAO/Country.php
+++ b/civicrm/CRM/Core/DAO/Country.php
@@ -129,6 +129,7 @@ class CRM_Core_DAO_Country extends CRM_Core_DAO {
           'title' => ts('Country ID'),
           'description' => ts('Country Id'),
           'required' => TRUE,
+          'where' => 'civicrm_country.id',
           'table_name' => 'civicrm_country',
           'entity' => 'Country',
           'bao' => 'CRM_Core_BAO_Country',
@@ -158,6 +159,7 @@ class CRM_Core_DAO_Country extends CRM_Core_DAO {
           'description' => ts('ISO Code'),
           'maxlength' => 2,
           'size' => CRM_Utils_Type::TWO,
+          'where' => 'civicrm_country.iso_code',
           'table_name' => 'civicrm_country',
           'entity' => 'Country',
           'bao' => 'CRM_Core_BAO_Country',
@@ -170,6 +172,7 @@ class CRM_Core_DAO_Country extends CRM_Core_DAO {
           'description' => ts('National prefix to be used when dialing TO this country.'),
           'maxlength' => 4,
           'size' => CRM_Utils_Type::FOUR,
+          'where' => 'civicrm_country.country_code',
           'table_name' => 'civicrm_country',
           'entity' => 'Country',
           'bao' => 'CRM_Core_BAO_Country',
@@ -180,6 +183,7 @@ class CRM_Core_DAO_Country extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Address Format'),
           'description' => ts('Foreign key to civicrm_address_format.id.'),
+          'where' => 'civicrm_country.address_format_id',
           'table_name' => 'civicrm_country',
           'entity' => 'Country',
           'bao' => 'CRM_Core_BAO_Country',
@@ -193,6 +197,7 @@ class CRM_Core_DAO_Country extends CRM_Core_DAO {
           'description' => ts('International direct dialing prefix from within the country TO another country'),
           'maxlength' => 4,
           'size' => CRM_Utils_Type::FOUR,
+          'where' => 'civicrm_country.idd_prefix',
           'table_name' => 'civicrm_country',
           'entity' => 'Country',
           'bao' => 'CRM_Core_BAO_Country',
@@ -205,6 +210,7 @@ class CRM_Core_DAO_Country extends CRM_Core_DAO {
           'description' => ts('Access prefix to call within a country to a different area'),
           'maxlength' => 4,
           'size' => CRM_Utils_Type::FOUR,
+          'where' => 'civicrm_country.ndd_prefix',
           'table_name' => 'civicrm_country',
           'entity' => 'Country',
           'bao' => 'CRM_Core_BAO_Country',
@@ -216,6 +222,7 @@ class CRM_Core_DAO_Country extends CRM_Core_DAO {
           'title' => ts('World Region ID'),
           'description' => ts('Foreign key to civicrm_worldregion.id.'),
           'required' => TRUE,
+          'where' => 'civicrm_country.region_id',
           'table_name' => 'civicrm_country',
           'entity' => 'Country',
           'bao' => 'CRM_Core_BAO_Country',
@@ -233,6 +240,7 @@ class CRM_Core_DAO_Country extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Abbreviate Province?'),
           'description' => ts('Should state/province be displayed as abbreviation for contacts from this country?'),
+          'where' => 'civicrm_country.is_province_abbreviated',
           'default' => '0',
           'table_name' => 'civicrm_country',
           'entity' => 'Country',
diff --git a/civicrm/CRM/Core/DAO/County.php b/civicrm/CRM/Core/DAO/County.php
index 6858becf82dbe81efbb8ea272b00334b06235072..f3dedbed8e424374dfceec9cc28614ea556f62a3 100644
--- a/civicrm/CRM/Core/DAO/County.php
+++ b/civicrm/CRM/Core/DAO/County.php
@@ -93,6 +93,7 @@ class CRM_Core_DAO_County extends CRM_Core_DAO {
           'title' => ts('County ID'),
           'description' => ts('County ID'),
           'required' => TRUE,
+          'where' => 'civicrm_county.id',
           'table_name' => 'civicrm_county',
           'entity' => 'County',
           'bao' => 'CRM_Core_DAO_County',
@@ -122,6 +123,7 @@ class CRM_Core_DAO_County extends CRM_Core_DAO {
           'description' => ts('2-4 Character Abbreviation of County'),
           'maxlength' => 4,
           'size' => CRM_Utils_Type::FOUR,
+          'where' => 'civicrm_county.abbreviation',
           'table_name' => 'civicrm_county',
           'entity' => 'County',
           'bao' => 'CRM_Core_DAO_County',
@@ -133,6 +135,7 @@ class CRM_Core_DAO_County extends CRM_Core_DAO {
           'title' => ts('State'),
           'description' => ts('ID of State/Province that County belongs'),
           'required' => TRUE,
+          'where' => 'civicrm_county.state_province_id',
           'table_name' => 'civicrm_county',
           'entity' => 'County',
           'bao' => 'CRM_Core_DAO_County',
diff --git a/civicrm/CRM/Core/DAO/CustomField.php b/civicrm/CRM/Core/DAO/CustomField.php
index 8d06e9a74c9142598d3dcc532b3258bdc918ca46..ee0fb15f20be2545ac1c7085e5d163c635851270 100644
--- a/civicrm/CRM/Core/DAO/CustomField.php
+++ b/civicrm/CRM/Core/DAO/CustomField.php
@@ -276,6 +276,7 @@ class CRM_Core_DAO_CustomField extends CRM_Core_DAO {
           'title' => ts('Custom Field ID'),
           'description' => ts('Unique Custom Field ID'),
           'required' => TRUE,
+          'where' => 'civicrm_custom_field.id',
           'table_name' => 'civicrm_custom_field',
           'entity' => 'CustomField',
           'bao' => 'CRM_Core_BAO_CustomField',
@@ -287,6 +288,7 @@ class CRM_Core_DAO_CustomField extends CRM_Core_DAO {
           'title' => ts('Custom Group'),
           'description' => ts('FK to civicrm_custom_group.'),
           'required' => TRUE,
+          'where' => 'civicrm_custom_field.custom_group_id',
           'table_name' => 'civicrm_custom_field',
           'entity' => 'CustomField',
           'bao' => 'CRM_Core_BAO_CustomField',
@@ -308,6 +310,7 @@ class CRM_Core_DAO_CustomField extends CRM_Core_DAO {
           'description' => ts('Variable name/programmatic handle for this group.'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_custom_field.name',
           'table_name' => 'civicrm_custom_field',
           'entity' => 'CustomField',
           'bao' => 'CRM_Core_BAO_CustomField',
@@ -321,6 +324,7 @@ class CRM_Core_DAO_CustomField extends CRM_Core_DAO {
           'required' => TRUE,
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_custom_field.label',
           'table_name' => 'civicrm_custom_field',
           'entity' => 'CustomField',
           'bao' => 'CRM_Core_BAO_CustomField',
@@ -334,6 +338,7 @@ class CRM_Core_DAO_CustomField extends CRM_Core_DAO {
           'required' => TRUE,
           'maxlength' => 16,
           'size' => CRM_Utils_Type::TWELVE,
+          'where' => 'civicrm_custom_field.data_type',
           'table_name' => 'civicrm_custom_field',
           'entity' => 'CustomField',
           'bao' => 'CRM_Core_BAO_CustomField',
@@ -353,6 +358,7 @@ class CRM_Core_DAO_CustomField extends CRM_Core_DAO {
           'required' => TRUE,
           'maxlength' => 32,
           'size' => CRM_Utils_Type::MEDIUM,
+          'where' => 'civicrm_custom_field.html_type',
           'table_name' => 'civicrm_custom_field',
           'entity' => 'CustomField',
           'bao' => 'CRM_Core_BAO_CustomField',
@@ -368,6 +374,7 @@ class CRM_Core_DAO_CustomField extends CRM_Core_DAO {
           'description' => ts('Use form_options.is_default for field_types which use options.'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_custom_field.default_value',
           'table_name' => 'civicrm_custom_field',
           'entity' => 'CustomField',
           'bao' => 'CRM_Core_BAO_CustomField',
@@ -378,6 +385,7 @@ class CRM_Core_DAO_CustomField extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Custom Field Is Required?'),
           'description' => ts('Is a value required for this property.'),
+          'where' => 'civicrm_custom_field.is_required',
           'default' => '0',
           'table_name' => 'civicrm_custom_field',
           'entity' => 'CustomField',
@@ -389,6 +397,7 @@ class CRM_Core_DAO_CustomField extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Allow Searching on Field?'),
           'description' => ts('Is this property searchable.'),
+          'where' => 'civicrm_custom_field.is_searchable',
           'default' => '0',
           'table_name' => 'civicrm_custom_field',
           'entity' => 'CustomField',
@@ -400,6 +409,7 @@ class CRM_Core_DAO_CustomField extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Search as a Range'),
           'description' => ts('Is this property range searchable.'),
+          'where' => 'civicrm_custom_field.is_search_range',
           'default' => '0',
           'table_name' => 'civicrm_custom_field',
           'entity' => 'CustomField',
@@ -412,6 +422,7 @@ class CRM_Core_DAO_CustomField extends CRM_Core_DAO {
           'title' => ts('Order'),
           'description' => ts('Controls field display order within an extended property group.'),
           'required' => TRUE,
+          'where' => 'civicrm_custom_field.weight',
           'default' => '1',
           'table_name' => 'civicrm_custom_field',
           'entity' => 'CustomField',
@@ -423,6 +434,7 @@ class CRM_Core_DAO_CustomField extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_TEXT,
           'title' => ts('Custom Field Pre Text'),
           'description' => ts('Description and/or help text to display before this field.'),
+          'where' => 'civicrm_custom_field.help_pre',
           'table_name' => 'civicrm_custom_field',
           'entity' => 'CustomField',
           'bao' => 'CRM_Core_BAO_CustomField',
@@ -433,6 +445,7 @@ class CRM_Core_DAO_CustomField extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_TEXT,
           'title' => ts('Custom Field Post Text'),
           'description' => ts('Description and/or help text to display after this field.'),
+          'where' => 'civicrm_custom_field.help_post',
           'table_name' => 'civicrm_custom_field',
           'entity' => 'CustomField',
           'bao' => 'CRM_Core_BAO_CustomField',
@@ -445,6 +458,7 @@ class CRM_Core_DAO_CustomField extends CRM_Core_DAO {
           'description' => ts('Optional format instructions for specific field types, like date types.'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_custom_field.mask',
           'table_name' => 'civicrm_custom_field',
           'entity' => 'CustomField',
           'bao' => 'CRM_Core_BAO_CustomField',
@@ -457,6 +471,7 @@ class CRM_Core_DAO_CustomField extends CRM_Core_DAO {
           'description' => ts('Store collection of type-appropriate attributes, e.g. textarea  needs rows/cols attributes'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_custom_field.attributes',
           'table_name' => 'civicrm_custom_field',
           'entity' => 'CustomField',
           'bao' => 'CRM_Core_BAO_CustomField',
@@ -469,6 +484,7 @@ class CRM_Core_DAO_CustomField extends CRM_Core_DAO {
           'description' => ts('Optional scripting attributes for field.'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_custom_field.javascript',
           'table_name' => 'civicrm_custom_field',
           'entity' => 'CustomField',
           'bao' => 'CRM_Core_BAO_CustomField',
@@ -479,6 +495,7 @@ class CRM_Core_DAO_CustomField extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Custom Field Is Active?'),
           'description' => ts('Is this property active?'),
+          'where' => 'civicrm_custom_field.is_active',
           'default' => '1',
           'table_name' => 'civicrm_custom_field',
           'entity' => 'CustomField',
@@ -490,6 +507,7 @@ class CRM_Core_DAO_CustomField extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Field is Viewable'),
           'description' => ts('Is this property set by PHP Code? A code field is viewable but not editable'),
+          'where' => 'civicrm_custom_field.is_view',
           'default' => '0',
           'table_name' => 'civicrm_custom_field',
           'entity' => 'CustomField',
@@ -501,6 +519,7 @@ class CRM_Core_DAO_CustomField extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Field Options Per Line'),
           'description' => ts('number of options per line for checkbox and radio'),
+          'where' => 'civicrm_custom_field.options_per_line',
           'table_name' => 'civicrm_custom_field',
           'entity' => 'CustomField',
           'bao' => 'CRM_Core_BAO_CustomField',
@@ -511,6 +530,7 @@ class CRM_Core_DAO_CustomField extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Field Length'),
           'description' => ts('field length if alphanumeric'),
+          'where' => 'civicrm_custom_field.text_length',
           'table_name' => 'civicrm_custom_field',
           'entity' => 'CustomField',
           'bao' => 'CRM_Core_BAO_CustomField',
@@ -521,6 +541,7 @@ class CRM_Core_DAO_CustomField extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Field Start Date'),
           'description' => ts('Date may be up to start_date_years years prior to the current date.'),
+          'where' => 'civicrm_custom_field.start_date_years',
           'table_name' => 'civicrm_custom_field',
           'entity' => 'CustomField',
           'bao' => 'CRM_Core_BAO_CustomField',
@@ -531,6 +552,7 @@ class CRM_Core_DAO_CustomField extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Field End Date'),
           'description' => ts('Date may be up to end_date_years years after the current date.'),
+          'where' => 'civicrm_custom_field.end_date_years',
           'table_name' => 'civicrm_custom_field',
           'entity' => 'CustomField',
           'bao' => 'CRM_Core_BAO_CustomField',
@@ -543,6 +565,7 @@ class CRM_Core_DAO_CustomField extends CRM_Core_DAO {
           'description' => ts('date format for custom date'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_custom_field.date_format',
           'table_name' => 'civicrm_custom_field',
           'entity' => 'CustomField',
           'bao' => 'CRM_Core_BAO_CustomField',
@@ -553,6 +576,7 @@ class CRM_Core_DAO_CustomField extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Field Time Format'),
           'description' => ts('time format for custom date'),
+          'where' => 'civicrm_custom_field.time_format',
           'table_name' => 'civicrm_custom_field',
           'entity' => 'CustomField',
           'bao' => 'CRM_Core_BAO_CustomField',
@@ -563,6 +587,7 @@ class CRM_Core_DAO_CustomField extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Field Note Columns'),
           'description' => ts(' Number of columns in Note Field '),
+          'where' => 'civicrm_custom_field.note_columns',
           'table_name' => 'civicrm_custom_field',
           'entity' => 'CustomField',
           'bao' => 'CRM_Core_BAO_CustomField',
@@ -573,6 +598,7 @@ class CRM_Core_DAO_CustomField extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Field Note Rows'),
           'description' => ts(' Number of rows in Note Field '),
+          'where' => 'civicrm_custom_field.note_rows',
           'table_name' => 'civicrm_custom_field',
           'entity' => 'CustomField',
           'bao' => 'CRM_Core_BAO_CustomField',
@@ -585,6 +611,7 @@ class CRM_Core_DAO_CustomField extends CRM_Core_DAO {
           'description' => ts('Name of the column that holds the values for this field.'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_custom_field.column_name',
           'table_name' => 'civicrm_custom_field',
           'entity' => 'CustomField',
           'bao' => 'CRM_Core_BAO_CustomField',
@@ -595,6 +622,7 @@ class CRM_Core_DAO_CustomField extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Field Option Group'),
           'description' => ts('For elements with options, the option group id that is used'),
+          'where' => 'civicrm_custom_field.option_group_id',
           'table_name' => 'civicrm_custom_field',
           'entity' => 'CustomField',
           'bao' => 'CRM_Core_BAO_CustomField',
@@ -613,6 +641,7 @@ class CRM_Core_DAO_CustomField extends CRM_Core_DAO {
           'description' => ts('Stores Contact Get API params contact reference custom fields. May be used for other filters in the future.'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_custom_field.filter',
           'table_name' => 'civicrm_custom_field',
           'entity' => 'CustomField',
           'bao' => 'CRM_Core_BAO_CustomField',
@@ -623,6 +652,7 @@ class CRM_Core_DAO_CustomField extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Field Display'),
           'description' => ts('Should the multi-record custom field values be displayed in tab table listing'),
+          'where' => 'civicrm_custom_field.in_selector',
           'default' => '0',
           'table_name' => 'civicrm_custom_field',
           'entity' => 'CustomField',
diff --git a/civicrm/CRM/Core/DAO/CustomGroup.php b/civicrm/CRM/Core/DAO/CustomGroup.php
index dbb98871caa6b7ea1504c921d51b21ddee53f5e2..aa7f05551f2c7410288bc3af9e4b67e9c21a9e26 100644
--- a/civicrm/CRM/Core/DAO/CustomGroup.php
+++ b/civicrm/CRM/Core/DAO/CustomGroup.php
@@ -212,6 +212,7 @@ class CRM_Core_DAO_CustomGroup extends CRM_Core_DAO {
           'title' => ts('Custom Group ID'),
           'description' => ts('Unique Custom Group ID'),
           'required' => TRUE,
+          'where' => 'civicrm_custom_group.id',
           'table_name' => 'civicrm_custom_group',
           'entity' => 'CustomGroup',
           'bao' => 'CRM_Core_BAO_CustomGroup',
@@ -224,6 +225,7 @@ class CRM_Core_DAO_CustomGroup extends CRM_Core_DAO {
           'description' => ts('Variable name/programmatic handle for this group.'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_custom_group.name',
           'table_name' => 'civicrm_custom_group',
           'entity' => 'CustomGroup',
           'bao' => 'CRM_Core_BAO_CustomGroup',
@@ -237,6 +239,7 @@ class CRM_Core_DAO_CustomGroup extends CRM_Core_DAO {
           'required' => TRUE,
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_custom_group.title',
           'table_name' => 'civicrm_custom_group',
           'entity' => 'CustomGroup',
           'bao' => 'CRM_Core_BAO_CustomGroup',
@@ -249,6 +252,7 @@ class CRM_Core_DAO_CustomGroup extends CRM_Core_DAO {
           'description' => ts('Type of object this group extends (can add other options later e.g. contact_address, etc.).'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_custom_group.extends',
           'default' => 'Contact',
           'table_name' => 'civicrm_custom_group',
           'entity' => 'CustomGroup',
@@ -260,6 +264,7 @@ class CRM_Core_DAO_CustomGroup extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Custom Group Subtype List'),
           'description' => ts('FK to civicrm_option_value.id (for option group custom_data_type.)'),
+          'where' => 'civicrm_custom_group.extends_entity_column_id',
           'default' => 'NULL',
           'table_name' => 'civicrm_custom_group',
           'entity' => 'CustomGroup',
@@ -280,6 +285,7 @@ class CRM_Core_DAO_CustomGroup extends CRM_Core_DAO {
           'description' => ts('linking custom group for dynamic object'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_custom_group.extends_entity_column_value',
           'table_name' => 'civicrm_custom_group',
           'entity' => 'CustomGroup',
           'bao' => 'CRM_Core_BAO_CustomGroup',
@@ -293,6 +299,7 @@ class CRM_Core_DAO_CustomGroup extends CRM_Core_DAO {
           'description' => ts('Visual relationship between this form and its parent.'),
           'maxlength' => 15,
           'size' => CRM_Utils_Type::TWELVE,
+          'where' => 'civicrm_custom_group.style',
           'table_name' => 'civicrm_custom_group',
           'entity' => 'CustomGroup',
           'bao' => 'CRM_Core_BAO_CustomGroup',
@@ -309,6 +316,7 @@ class CRM_Core_DAO_CustomGroup extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Collapse Custom Group?'),
           'description' => ts('Will this group be in collapsed or expanded mode on initial display ?'),
+          'where' => 'civicrm_custom_group.collapse_display',
           'default' => '0',
           'table_name' => 'civicrm_custom_group',
           'entity' => 'CustomGroup',
@@ -322,6 +330,7 @@ class CRM_Core_DAO_CustomGroup extends CRM_Core_DAO {
           'description' => ts('Description and/or help text to display before fields in form.'),
           'rows' => 4,
           'cols' => 80,
+          'where' => 'civicrm_custom_group.help_pre',
           'table_name' => 'civicrm_custom_group',
           'entity' => 'CustomGroup',
           'bao' => 'CRM_Core_BAO_CustomGroup',
@@ -337,6 +346,7 @@ class CRM_Core_DAO_CustomGroup extends CRM_Core_DAO {
           'description' => ts('Description and/or help text to display after fields in form.'),
           'rows' => 4,
           'cols' => 80,
+          'where' => 'civicrm_custom_group.help_post',
           'table_name' => 'civicrm_custom_group',
           'entity' => 'CustomGroup',
           'bao' => 'CRM_Core_BAO_CustomGroup',
@@ -351,6 +361,7 @@ class CRM_Core_DAO_CustomGroup extends CRM_Core_DAO {
           'title' => ts('Order'),
           'description' => ts('Controls display order when multiple extended property groups are setup for the same class.'),
           'required' => TRUE,
+          'where' => 'civicrm_custom_group.weight',
           'default' => '1',
           'table_name' => 'civicrm_custom_group',
           'entity' => 'CustomGroup',
@@ -362,6 +373,7 @@ class CRM_Core_DAO_CustomGroup extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Custom Group Is Active?'),
           'description' => ts('Is this property active?'),
+          'where' => 'civicrm_custom_group.is_active',
           'default' => '1',
           'table_name' => 'civicrm_custom_group',
           'entity' => 'CustomGroup',
@@ -375,6 +387,7 @@ class CRM_Core_DAO_CustomGroup extends CRM_Core_DAO {
           'description' => ts('Name of the table that holds the values for this group.'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_custom_group.table_name',
           'table_name' => 'civicrm_custom_group',
           'entity' => 'CustomGroup',
           'bao' => 'CRM_Core_BAO_CustomGroup',
@@ -385,6 +398,7 @@ class CRM_Core_DAO_CustomGroup extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Supports Multiple Records'),
           'description' => ts('Does this group hold multiple values?'),
+          'where' => 'civicrm_custom_group.is_multiple',
           'default' => '0',
           'table_name' => 'civicrm_custom_group',
           'entity' => 'CustomGroup',
@@ -396,6 +410,7 @@ class CRM_Core_DAO_CustomGroup extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Minimum Multiple Records'),
           'description' => ts('minimum number of multiple records (typically 0?)'),
+          'where' => 'civicrm_custom_group.min_multiple',
           'table_name' => 'civicrm_custom_group',
           'entity' => 'CustomGroup',
           'bao' => 'CRM_Core_BAO_CustomGroup',
@@ -406,6 +421,7 @@ class CRM_Core_DAO_CustomGroup extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Maximum Multiple Records'),
           'description' => ts('maximum number of multiple records, if 0 - no max'),
+          'where' => 'civicrm_custom_group.max_multiple',
           'table_name' => 'civicrm_custom_group',
           'entity' => 'CustomGroup',
           'bao' => 'CRM_Core_BAO_CustomGroup',
@@ -416,6 +432,7 @@ class CRM_Core_DAO_CustomGroup extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Collapse Group Display'),
           'description' => ts('Will this group be in collapsed or expanded mode on advanced search display ?'),
+          'where' => 'civicrm_custom_group.collapse_adv_display',
           'default' => '0',
           'table_name' => 'civicrm_custom_group',
           'entity' => 'CustomGroup',
@@ -427,6 +444,7 @@ class CRM_Core_DAO_CustomGroup extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Custom Group Created By'),
           'description' => ts('FK to civicrm_contact, who created this custom group'),
+          'where' => 'civicrm_custom_group.created_id',
           'table_name' => 'civicrm_custom_group',
           'entity' => 'CustomGroup',
           'bao' => 'CRM_Core_BAO_CustomGroup',
@@ -438,6 +456,7 @@ class CRM_Core_DAO_CustomGroup extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
           'title' => ts('Custom Group Created Date'),
           'description' => ts('Date and time this custom group was created.'),
+          'where' => 'civicrm_custom_group.created_date',
           'table_name' => 'civicrm_custom_group',
           'entity' => 'CustomGroup',
           'bao' => 'CRM_Core_BAO_CustomGroup',
@@ -448,6 +467,7 @@ class CRM_Core_DAO_CustomGroup extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Reserved Group?'),
           'description' => ts('Is this a reserved Custom Group?'),
+          'where' => 'civicrm_custom_group.is_reserved',
           'default' => '0',
           'table_name' => 'civicrm_custom_group',
           'entity' => 'CustomGroup',
@@ -459,6 +479,7 @@ class CRM_Core_DAO_CustomGroup extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Custom Group Is Public?'),
           'description' => ts('Is this property public?'),
+          'where' => 'civicrm_custom_group.is_public',
           'default' => '1',
           'table_name' => 'civicrm_custom_group',
           'entity' => 'CustomGroup',
diff --git a/civicrm/CRM/Core/DAO/Dashboard.php b/civicrm/CRM/Core/DAO/Dashboard.php
index b9fe1d241c77d99197cfc2a65fa8a4ec06872f19..42aa0ab23a920264a7fcd7ce1defa4ce37d12696 100644
--- a/civicrm/CRM/Core/DAO/Dashboard.php
+++ b/civicrm/CRM/Core/DAO/Dashboard.php
@@ -139,6 +139,7 @@ class CRM_Core_DAO_Dashboard extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('DashletID'),
           'required' => TRUE,
+          'where' => 'civicrm_dashboard.id',
           'table_name' => 'civicrm_dashboard',
           'entity' => 'Dashboard',
           'bao' => 'CRM_Core_BAO_Dashboard',
@@ -150,6 +151,7 @@ class CRM_Core_DAO_Dashboard extends CRM_Core_DAO {
           'title' => ts('Dashlet Domain'),
           'description' => ts('Domain for dashboard'),
           'required' => TRUE,
+          'where' => 'civicrm_dashboard.domain_id',
           'table_name' => 'civicrm_dashboard',
           'entity' => 'Dashboard',
           'bao' => 'CRM_Core_BAO_Dashboard',
@@ -168,6 +170,7 @@ class CRM_Core_DAO_Dashboard extends CRM_Core_DAO {
           'description' => ts('Internal name of dashlet.'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_dashboard.name',
           'table_name' => 'civicrm_dashboard',
           'entity' => 'Dashboard',
           'bao' => 'CRM_Core_BAO_Dashboard',
@@ -180,6 +183,7 @@ class CRM_Core_DAO_Dashboard extends CRM_Core_DAO {
           'description' => ts('dashlet title'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_dashboard.label',
           'table_name' => 'civicrm_dashboard',
           'entity' => 'Dashboard',
           'bao' => 'CRM_Core_BAO_Dashboard',
@@ -192,6 +196,7 @@ class CRM_Core_DAO_Dashboard extends CRM_Core_DAO {
           'description' => ts('url in case of external dashlet'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_dashboard.url',
           'table_name' => 'civicrm_dashboard',
           'entity' => 'Dashboard',
           'bao' => 'CRM_Core_BAO_Dashboard',
@@ -204,6 +209,7 @@ class CRM_Core_DAO_Dashboard extends CRM_Core_DAO {
           'description' => ts('Permission for the dashlet'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_dashboard.permission',
           'table_name' => 'civicrm_dashboard',
           'entity' => 'Dashboard',
           'bao' => 'CRM_Core_BAO_Dashboard',
@@ -216,6 +222,7 @@ class CRM_Core_DAO_Dashboard extends CRM_Core_DAO {
           'description' => ts('Permission Operator'),
           'maxlength' => 3,
           'size' => CRM_Utils_Type::FOUR,
+          'where' => 'civicrm_dashboard.permission_operator',
           'table_name' => 'civicrm_dashboard',
           'entity' => 'Dashboard',
           'bao' => 'CRM_Core_BAO_Dashboard',
@@ -228,6 +235,7 @@ class CRM_Core_DAO_Dashboard extends CRM_Core_DAO {
           'description' => ts('fullscreen url for dashlet'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_dashboard.fullscreen_url',
           'table_name' => 'civicrm_dashboard',
           'entity' => 'Dashboard',
           'bao' => 'CRM_Core_BAO_Dashboard',
@@ -238,6 +246,7 @@ class CRM_Core_DAO_Dashboard extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Is Dashlet Active?'),
           'description' => ts('Is this dashlet active?'),
+          'where' => 'civicrm_dashboard.is_active',
           'default' => '0',
           'table_name' => 'civicrm_dashboard',
           'entity' => 'Dashboard',
@@ -249,6 +258,7 @@ class CRM_Core_DAO_Dashboard extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Is Dashlet Reserved?'),
           'description' => ts('Is this dashlet reserved?'),
+          'where' => 'civicrm_dashboard.is_reserved',
           'default' => '0',
           'table_name' => 'civicrm_dashboard',
           'entity' => 'Dashboard',
@@ -261,6 +271,7 @@ class CRM_Core_DAO_Dashboard extends CRM_Core_DAO {
           'title' => ts('Cache Minutes'),
           'description' => ts('Number of minutes to cache dashlet content in browser localStorage.'),
           'required' => TRUE,
+          'where' => 'civicrm_dashboard.cache_minutes',
           'default' => '60',
           'table_name' => 'civicrm_dashboard',
           'entity' => 'Dashboard',
diff --git a/civicrm/CRM/Core/DAO/Discount.php b/civicrm/CRM/Core/DAO/Discount.php
index eff4329fbbbd6de510172afa5bb6ac1d27c27551..32dbbb454e4a2dac4e67f5339e860a3a82f5c40e 100644
--- a/civicrm/CRM/Core/DAO/Discount.php
+++ b/civicrm/CRM/Core/DAO/Discount.php
@@ -108,6 +108,7 @@ class CRM_Core_DAO_Discount extends CRM_Core_DAO {
           'title' => ts('Discount ID'),
           'description' => ts('primary key'),
           'required' => TRUE,
+          'where' => 'civicrm_discount.id',
           'table_name' => 'civicrm_discount',
           'entity' => 'Discount',
           'bao' => 'CRM_Core_BAO_Discount',
@@ -120,6 +121,7 @@ class CRM_Core_DAO_Discount extends CRM_Core_DAO {
           'description' => ts('physical tablename for entity being joined to discount, e.g. civicrm_event'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_discount.entity_table',
           'table_name' => 'civicrm_discount',
           'entity' => 'Discount',
           'bao' => 'CRM_Core_BAO_Discount',
@@ -131,6 +133,7 @@ class CRM_Core_DAO_Discount extends CRM_Core_DAO {
           'title' => ts('Entity ID'),
           'description' => ts('FK to entity table specified in entity_table column.'),
           'required' => TRUE,
+          'where' => 'civicrm_discount.entity_id',
           'table_name' => 'civicrm_discount',
           'entity' => 'Discount',
           'bao' => 'CRM_Core_BAO_Discount',
@@ -142,10 +145,8 @@ class CRM_Core_DAO_Discount extends CRM_Core_DAO {
           'title' => ts('Discount Name'),
           'description' => ts('FK to civicrm_price_set'),
           'required' => TRUE,
-          'export' => TRUE,
           'where' => 'civicrm_discount.price_set_id',
-          'headerPattern' => '',
-          'dataPattern' => '',
+          'export' => TRUE,
           'table_name' => 'civicrm_discount',
           'entity' => 'Discount',
           'bao' => 'CRM_Core_BAO_Discount',
@@ -157,6 +158,7 @@ class CRM_Core_DAO_Discount extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_DATE,
           'title' => ts('Discount Start Date'),
           'description' => ts('Date when discount starts.'),
+          'where' => 'civicrm_discount.start_date',
           'table_name' => 'civicrm_discount',
           'entity' => 'Discount',
           'bao' => 'CRM_Core_BAO_Discount',
@@ -167,6 +169,7 @@ class CRM_Core_DAO_Discount extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_DATE,
           'title' => ts('Discount End Date'),
           'description' => ts('Date when discount ends.'),
+          'where' => 'civicrm_discount.end_date',
           'table_name' => 'civicrm_discount',
           'entity' => 'Discount',
           'bao' => 'CRM_Core_BAO_Discount',
diff --git a/civicrm/CRM/Core/DAO/Domain.php b/civicrm/CRM/Core/DAO/Domain.php
index b3abdbb2d5056747bc16dd7220e0363e9b0de307..2f84735d72468027921cb126cbc83ba21c3484d1 100644
--- a/civicrm/CRM/Core/DAO/Domain.php
+++ b/civicrm/CRM/Core/DAO/Domain.php
@@ -121,6 +121,7 @@ class CRM_Core_DAO_Domain extends CRM_Core_DAO {
           'title' => ts('Domain ID'),
           'description' => ts('Domain ID'),
           'required' => TRUE,
+          'where' => 'civicrm_domain.id',
           'table_name' => 'civicrm_domain',
           'entity' => 'Domain',
           'bao' => 'CRM_Core_BAO_Domain',
@@ -133,6 +134,7 @@ class CRM_Core_DAO_Domain extends CRM_Core_DAO {
           'description' => ts('Name of Domain / Organization'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_domain.name',
           'table_name' => 'civicrm_domain',
           'entity' => 'Domain',
           'bao' => 'CRM_Core_BAO_Domain',
@@ -148,6 +150,7 @@ class CRM_Core_DAO_Domain extends CRM_Core_DAO {
           'description' => ts('Description of Domain.'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_domain.description',
           'table_name' => 'civicrm_domain',
           'entity' => 'Domain',
           'bao' => 'CRM_Core_BAO_Domain',
@@ -161,6 +164,7 @@ class CRM_Core_DAO_Domain extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_TEXT,
           'title' => ts('Domain Configuration'),
           'description' => ts('Backend configuration.'),
+          'where' => 'civicrm_domain.config_backend',
           'table_name' => 'civicrm_domain',
           'entity' => 'Domain',
           'bao' => 'CRM_Core_BAO_Domain',
@@ -174,6 +178,7 @@ class CRM_Core_DAO_Domain extends CRM_Core_DAO {
           'description' => ts('The civicrm version this instance is running'),
           'maxlength' => 32,
           'size' => CRM_Utils_Type::MEDIUM,
+          'where' => 'civicrm_domain.version',
           'table_name' => 'civicrm_domain',
           'entity' => 'Domain',
           'bao' => 'CRM_Core_BAO_Domain',
@@ -184,6 +189,7 @@ class CRM_Core_DAO_Domain extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Domain Contact'),
           'description' => ts('FK to Contact ID. This is specifically not an FK to avoid circular constraints'),
+          'where' => 'civicrm_domain.contact_id',
           'table_name' => 'civicrm_domain',
           'entity' => 'Domain',
           'bao' => 'CRM_Core_BAO_Domain',
@@ -195,6 +201,7 @@ class CRM_Core_DAO_Domain extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_TEXT,
           'title' => ts('Supported Languages'),
           'description' => ts('list of locales supported by the current db state (NULL for single-lang install)'),
+          'where' => 'civicrm_domain.locales',
           'table_name' => 'civicrm_domain',
           'entity' => 'Domain',
           'bao' => 'CRM_Core_BAO_Domain',
@@ -205,6 +212,7 @@ class CRM_Core_DAO_Domain extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_TEXT,
           'title' => ts('Language Customizations'),
           'description' => ts('Locale specific string overrides'),
+          'where' => 'civicrm_domain.locale_custom_strings',
           'table_name' => 'civicrm_domain',
           'entity' => 'Domain',
           'bao' => 'CRM_Core_BAO_Domain',
diff --git a/civicrm/CRM/Core/DAO/Email.php b/civicrm/CRM/Core/DAO/Email.php
index cd169bef4ac7778f611696e6e199ea3745e7dc61..ac48170decacc9b8abde27cd0b4c43e3ea031b9d 100644
--- a/civicrm/CRM/Core/DAO/Email.php
+++ b/civicrm/CRM/Core/DAO/Email.php
@@ -149,6 +149,7 @@ class CRM_Core_DAO_Email extends CRM_Core_DAO {
           'title' => ts('Email ID'),
           'description' => ts('Unique Email ID'),
           'required' => TRUE,
+          'where' => 'civicrm_email.id',
           'table_name' => 'civicrm_email',
           'entity' => 'Email',
           'bao' => 'CRM_Core_BAO_Email',
@@ -159,6 +160,7 @@ class CRM_Core_DAO_Email extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Email Contact'),
           'description' => ts('FK to Contact ID'),
+          'where' => 'civicrm_email.contact_id',
           'table_name' => 'civicrm_email',
           'entity' => 'Email',
           'bao' => 'CRM_Core_BAO_Email',
@@ -170,6 +172,7 @@ class CRM_Core_DAO_Email extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Email Location Type'),
           'description' => ts('Which Location does this email belong to.'),
+          'where' => 'civicrm_email.location_type_id',
           'table_name' => 'civicrm_email',
           'entity' => 'Email',
           'bao' => 'CRM_Core_BAO_Email',
@@ -209,6 +212,7 @@ class CRM_Core_DAO_Email extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Is Primary email'),
           'description' => ts('Is this the primary?'),
+          'where' => 'civicrm_email.is_primary',
           'default' => '0',
           'table_name' => 'civicrm_email',
           'entity' => 'Email',
@@ -220,6 +224,7 @@ class CRM_Core_DAO_Email extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Is Billing Email?'),
           'description' => ts('Is this the billing?'),
+          'where' => 'civicrm_email.is_billing',
           'default' => '0',
           'table_name' => 'civicrm_email',
           'entity' => 'Email',
@@ -232,10 +237,8 @@ class CRM_Core_DAO_Email extends CRM_Core_DAO {
           'title' => ts('On Hold'),
           'description' => ts('Implicit FK to civicrm_option_value where option_group = email_on_hold.'),
           'required' => TRUE,
-          'export' => TRUE,
           'where' => 'civicrm_email.on_hold',
-          'headerPattern' => '',
-          'dataPattern' => '',
+          'export' => TRUE,
           'default' => '0',
           'table_name' => 'civicrm_email',
           'entity' => 'Email',
@@ -254,10 +257,8 @@ class CRM_Core_DAO_Email extends CRM_Core_DAO {
           'title' => ts('Use for Bulk Mail'),
           'description' => ts('Is this address for bulk mail ?'),
           'required' => TRUE,
-          'export' => TRUE,
           'where' => 'civicrm_email.is_bulkmail',
-          'headerPattern' => '',
-          'dataPattern' => '',
+          'export' => TRUE,
           'default' => '0',
           'table_name' => 'civicrm_email',
           'entity' => 'Email',
@@ -269,6 +270,7 @@ class CRM_Core_DAO_Email extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
           'title' => ts('Hold Date'),
           'description' => ts('When the address went on bounce hold'),
+          'where' => 'civicrm_email.hold_date',
           'table_name' => 'civicrm_email',
           'entity' => 'Email',
           'bao' => 'CRM_Core_BAO_Email',
@@ -279,6 +281,7 @@ class CRM_Core_DAO_Email extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
           'title' => ts('Reset Date'),
           'description' => ts('When the address bounce status was last reset'),
+          'where' => 'civicrm_email.reset_date',
           'table_name' => 'civicrm_email',
           'entity' => 'Email',
           'bao' => 'CRM_Core_BAO_Email',
@@ -291,8 +294,6 @@ class CRM_Core_DAO_Email extends CRM_Core_DAO {
           'description' => ts('Text formatted signature for the email.'),
           'import' => TRUE,
           'where' => 'civicrm_email.signature_text',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'default' => 'NULL',
           'table_name' => 'civicrm_email',
@@ -307,8 +308,6 @@ class CRM_Core_DAO_Email extends CRM_Core_DAO {
           'description' => ts('HTML formatted signature for the email.'),
           'import' => TRUE,
           'where' => 'civicrm_email.signature_html',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'default' => 'NULL',
           'table_name' => 'civicrm_email',
diff --git a/civicrm/CRM/Core/DAO/EntityFile.php b/civicrm/CRM/Core/DAO/EntityFile.php
index 388f6b02dc967a3fa4b588dc7ca220f1c088162d..26069113cbefad1604991e12fdf447bcfd8963eb 100644
--- a/civicrm/CRM/Core/DAO/EntityFile.php
+++ b/civicrm/CRM/Core/DAO/EntityFile.php
@@ -94,6 +94,7 @@ class CRM_Core_DAO_EntityFile extends CRM_Core_DAO {
           'title' => ts('Entity File ID'),
           'description' => ts('primary key'),
           'required' => TRUE,
+          'where' => 'civicrm_entity_file.id',
           'table_name' => 'civicrm_entity_file',
           'entity' => 'EntityFile',
           'bao' => 'CRM_Core_DAO_EntityFile',
@@ -106,6 +107,7 @@ class CRM_Core_DAO_EntityFile extends CRM_Core_DAO {
           'description' => ts('physical tablename for entity being joined to file, e.g. civicrm_contact'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_entity_file.entity_table',
           'table_name' => 'civicrm_entity_file',
           'entity' => 'EntityFile',
           'bao' => 'CRM_Core_DAO_EntityFile',
@@ -117,6 +119,7 @@ class CRM_Core_DAO_EntityFile extends CRM_Core_DAO {
           'title' => ts('Entity ID'),
           'description' => ts('FK to entity table specified in entity_table column.'),
           'required' => TRUE,
+          'where' => 'civicrm_entity_file.entity_id',
           'table_name' => 'civicrm_entity_file',
           'entity' => 'EntityFile',
           'bao' => 'CRM_Core_DAO_EntityFile',
@@ -128,6 +131,7 @@ class CRM_Core_DAO_EntityFile extends CRM_Core_DAO {
           'title' => ts('File'),
           'description' => ts('FK to civicrm_file'),
           'required' => TRUE,
+          'where' => 'civicrm_entity_file.file_id',
           'table_name' => 'civicrm_entity_file',
           'entity' => 'EntityFile',
           'bao' => 'CRM_Core_DAO_EntityFile',
diff --git a/civicrm/CRM/Core/DAO/EntityTag.php b/civicrm/CRM/Core/DAO/EntityTag.php
index 47bd481d6a0443e9a728ba0cff2ae05ce26a4719..11bcdfcb5b78f8f92aa473e220c93605a47ccd7b 100644
--- a/civicrm/CRM/Core/DAO/EntityTag.php
+++ b/civicrm/CRM/Core/DAO/EntityTag.php
@@ -94,6 +94,7 @@ class CRM_Core_DAO_EntityTag extends CRM_Core_DAO {
           'title' => ts('Entity Tag ID'),
           'description' => ts('primary key'),
           'required' => TRUE,
+          'where' => 'civicrm_entity_tag.id',
           'table_name' => 'civicrm_entity_tag',
           'entity' => 'EntityTag',
           'bao' => 'CRM_Core_BAO_EntityTag',
@@ -106,6 +107,7 @@ class CRM_Core_DAO_EntityTag extends CRM_Core_DAO {
           'description' => ts('physical tablename for entity being joined to file, e.g. civicrm_contact'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_entity_tag.entity_table',
           'table_name' => 'civicrm_entity_tag',
           'entity' => 'EntityTag',
           'bao' => 'CRM_Core_BAO_EntityTag',
@@ -121,6 +123,7 @@ class CRM_Core_DAO_EntityTag extends CRM_Core_DAO {
           'title' => ts('Entity ID'),
           'description' => ts('FK to entity table specified in entity_table column.'),
           'required' => TRUE,
+          'where' => 'civicrm_entity_tag.entity_id',
           'table_name' => 'civicrm_entity_tag',
           'entity' => 'EntityTag',
           'bao' => 'CRM_Core_BAO_EntityTag',
@@ -132,6 +135,7 @@ class CRM_Core_DAO_EntityTag extends CRM_Core_DAO {
           'title' => ts('Tag'),
           'description' => ts('FK to civicrm_tag'),
           'required' => TRUE,
+          'where' => 'civicrm_entity_tag.tag_id',
           'table_name' => 'civicrm_entity_tag',
           'entity' => 'EntityTag',
           'bao' => 'CRM_Core_BAO_EntityTag',
diff --git a/civicrm/CRM/Core/DAO/Extension.php b/civicrm/CRM/Core/DAO/Extension.php
index be80ddb69711c4306e79be620aee8c264fafce85..9bb233277e46da7b9608386466340a1a86372e0a 100644
--- a/civicrm/CRM/Core/DAO/Extension.php
+++ b/civicrm/CRM/Core/DAO/Extension.php
@@ -104,6 +104,7 @@ class CRM_Core_DAO_Extension extends CRM_Core_DAO {
           'title' => ts('Extension ID'),
           'description' => ts('Local Extension ID'),
           'required' => TRUE,
+          'where' => 'civicrm_extension.id',
           'table_name' => 'civicrm_extension',
           'entity' => 'Extension',
           'bao' => 'CRM_Core_BAO_Extension',
@@ -116,6 +117,7 @@ class CRM_Core_DAO_Extension extends CRM_Core_DAO {
           'required' => TRUE,
           'maxlength' => 8,
           'size' => CRM_Utils_Type::EIGHT,
+          'where' => 'civicrm_extension.type',
           'table_name' => 'civicrm_extension',
           'entity' => 'Extension',
           'bao' => 'CRM_Core_BAO_Extension',
@@ -135,6 +137,7 @@ class CRM_Core_DAO_Extension extends CRM_Core_DAO {
           'required' => TRUE,
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_extension.full_name',
           'table_name' => 'civicrm_extension',
           'entity' => 'Extension',
           'bao' => 'CRM_Core_BAO_Extension',
@@ -149,8 +152,6 @@ class CRM_Core_DAO_Extension extends CRM_Core_DAO {
           'size' => CRM_Utils_Type::HUGE,
           'import' => TRUE,
           'where' => 'civicrm_extension.name',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_extension',
           'entity' => 'Extension',
@@ -166,8 +167,6 @@ class CRM_Core_DAO_Extension extends CRM_Core_DAO {
           'size' => CRM_Utils_Type::HUGE,
           'import' => TRUE,
           'where' => 'civicrm_extension.label',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_extension',
           'entity' => 'Extension',
@@ -183,8 +182,6 @@ class CRM_Core_DAO_Extension extends CRM_Core_DAO {
           'size' => CRM_Utils_Type::HUGE,
           'import' => TRUE,
           'where' => 'civicrm_extension.file',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_extension',
           'entity' => 'Extension',
@@ -200,8 +197,6 @@ class CRM_Core_DAO_Extension extends CRM_Core_DAO {
           'size' => CRM_Utils_Type::BIG,
           'import' => TRUE,
           'where' => 'civicrm_extension.schema_version',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_extension',
           'entity' => 'Extension',
@@ -213,6 +208,7 @@ class CRM_Core_DAO_Extension extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Extension is Active?'),
           'description' => ts('Is this extension active?'),
+          'where' => 'civicrm_extension.is_active',
           'default' => '1',
           'table_name' => 'civicrm_extension',
           'entity' => 'Extension',
diff --git a/civicrm/CRM/Core/DAO/File.php b/civicrm/CRM/Core/DAO/File.php
index 41911d9b89ed7a4011ae67d319a11bf0babc8d04..fe4ae741f492e26e768325ddb91c210fc54b7f79 100644
--- a/civicrm/CRM/Core/DAO/File.php
+++ b/civicrm/CRM/Core/DAO/File.php
@@ -121,6 +121,7 @@ class CRM_Core_DAO_File extends CRM_Core_DAO {
           'title' => ts('File ID'),
           'description' => ts('Unique ID'),
           'required' => TRUE,
+          'where' => 'civicrm_file.id',
           'table_name' => 'civicrm_file',
           'entity' => 'File',
           'bao' => 'CRM_Core_BAO_File',
@@ -131,6 +132,7 @@ class CRM_Core_DAO_File extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('File Type'),
           'description' => ts('Type of file (e.g. Transcript, Income Tax Return, etc). FK to civicrm_option_value.'),
+          'where' => 'civicrm_file.file_type_id',
           'table_name' => 'civicrm_file',
           'entity' => 'File',
           'bao' => 'CRM_Core_BAO_File',
@@ -143,6 +145,7 @@ class CRM_Core_DAO_File extends CRM_Core_DAO {
           'description' => ts('mime type of the document'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_file.mime_type',
           'table_name' => 'civicrm_file',
           'entity' => 'File',
           'bao' => 'CRM_Core_BAO_File',
@@ -155,6 +158,7 @@ class CRM_Core_DAO_File extends CRM_Core_DAO {
           'description' => ts('uri of the file on disk'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_file.uri',
           'table_name' => 'civicrm_file',
           'entity' => 'File',
           'bao' => 'CRM_Core_BAO_File',
@@ -165,6 +169,7 @@ class CRM_Core_DAO_File extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_MEDIUMBLOB,
           'title' => ts('File Contents'),
           'description' => ts('contents of the document'),
+          'where' => 'civicrm_file.document',
           'table_name' => 'civicrm_file',
           'entity' => 'File',
           'bao' => 'CRM_Core_BAO_File',
@@ -177,6 +182,7 @@ class CRM_Core_DAO_File extends CRM_Core_DAO {
           'description' => ts('Additional descriptive text regarding this attachment (optional).'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_file.description',
           'table_name' => 'civicrm_file',
           'entity' => 'File',
           'bao' => 'CRM_Core_BAO_File',
@@ -187,6 +193,7 @@ class CRM_Core_DAO_File extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
           'title' => ts('File Upload Date'),
           'description' => ts('Date and time that this attachment was uploaded or written to server.'),
+          'where' => 'civicrm_file.upload_date',
           'table_name' => 'civicrm_file',
           'entity' => 'File',
           'bao' => 'CRM_Core_BAO_File',
@@ -197,6 +204,7 @@ class CRM_Core_DAO_File extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Created By Contact ID'),
           'description' => ts('FK to civicrm_contact, who uploaded this file'),
+          'where' => 'civicrm_file.created_id',
           'table_name' => 'civicrm_file',
           'entity' => 'File',
           'bao' => 'CRM_Core_BAO_File',
diff --git a/civicrm/CRM/Core/DAO/IM.php b/civicrm/CRM/Core/DAO/IM.php
index eed59c3908653a1393073d608244ebea9e60da20..e53ce78aff364fe9c253b088787e41c1a45c31d0 100644
--- a/civicrm/CRM/Core/DAO/IM.php
+++ b/civicrm/CRM/Core/DAO/IM.php
@@ -114,6 +114,7 @@ class CRM_Core_DAO_IM extends CRM_Core_DAO {
           'title' => ts('Instant Messenger ID'),
           'description' => ts('Unique IM ID'),
           'required' => TRUE,
+          'where' => 'civicrm_im.id',
           'table_name' => 'civicrm_im',
           'entity' => 'IM',
           'bao' => 'CRM_Core_BAO_IM',
@@ -124,6 +125,7 @@ class CRM_Core_DAO_IM extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('IM Contact'),
           'description' => ts('FK to Contact ID'),
+          'where' => 'civicrm_im.contact_id',
           'table_name' => 'civicrm_im',
           'entity' => 'IM',
           'bao' => 'CRM_Core_BAO_IM',
@@ -135,6 +137,7 @@ class CRM_Core_DAO_IM extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('IM Location Type'),
           'description' => ts('Which Location does this email belong to.'),
+          'where' => 'civicrm_im.location_type_id',
           'table_name' => 'civicrm_im',
           'entity' => 'IM',
           'bao' => 'CRM_Core_BAO_IM',
@@ -173,6 +176,7 @@ class CRM_Core_DAO_IM extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('IM Provider'),
           'description' => ts('Which IM Provider does this screen name belong to.'),
+          'where' => 'civicrm_im.provider_id',
           'table_name' => 'civicrm_im',
           'entity' => 'IM',
           'bao' => 'CRM_Core_BAO_IM',
@@ -190,6 +194,7 @@ class CRM_Core_DAO_IM extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Is IM Primary?'),
           'description' => ts('Is this the primary IM for this contact and location.'),
+          'where' => 'civicrm_im.is_primary',
           'default' => '0',
           'table_name' => 'civicrm_im',
           'entity' => 'IM',
@@ -201,6 +206,7 @@ class CRM_Core_DAO_IM extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Is IM Billing?'),
           'description' => ts('Is this the billing?'),
+          'where' => 'civicrm_im.is_billing',
           'default' => '0',
           'table_name' => 'civicrm_im',
           'entity' => 'IM',
diff --git a/civicrm/CRM/Core/DAO/Job.php b/civicrm/CRM/Core/DAO/Job.php
index 7c6ff616efe13ff0058a7fe8ffce7451f0520b33..3c0961ef24b0c2ae0033b074678c83f84f879805 100644
--- a/civicrm/CRM/Core/DAO/Job.php
+++ b/civicrm/CRM/Core/DAO/Job.php
@@ -142,6 +142,7 @@ class CRM_Core_DAO_Job extends CRM_Core_DAO {
           'title' => ts('Job ID'),
           'description' => ts('Job Id'),
           'required' => TRUE,
+          'where' => 'civicrm_job.id',
           'table_name' => 'civicrm_job',
           'entity' => 'Job',
           'bao' => 'CRM_Core_BAO_Job',
@@ -153,6 +154,7 @@ class CRM_Core_DAO_Job extends CRM_Core_DAO {
           'title' => ts('Job Domain'),
           'description' => ts('Which Domain is this scheduled job for'),
           'required' => TRUE,
+          'where' => 'civicrm_job.domain_id',
           'table_name' => 'civicrm_job',
           'entity' => 'Job',
           'bao' => 'CRM_Core_BAO_Job',
@@ -171,6 +173,7 @@ class CRM_Core_DAO_Job extends CRM_Core_DAO {
           'description' => ts('Scheduled job run frequency.'),
           'maxlength' => 8,
           'size' => CRM_Utils_Type::EIGHT,
+          'where' => 'civicrm_job.run_frequency',
           'default' => 'Daily',
           'table_name' => 'civicrm_job',
           'entity' => 'Job',
@@ -189,6 +192,7 @@ class CRM_Core_DAO_Job extends CRM_Core_DAO {
           'title' => ts('Last Run'),
           'description' => ts('When was this cron entry last run'),
           'required' => FALSE,
+          'where' => 'civicrm_job.last_run',
           'default' => 'NULL',
           'table_name' => 'civicrm_job',
           'entity' => 'Job',
@@ -201,6 +205,7 @@ class CRM_Core_DAO_Job extends CRM_Core_DAO {
           'title' => ts('Scheduled Run Date'),
           'description' => ts('When is this cron entry scheduled to run'),
           'required' => FALSE,
+          'where' => 'civicrm_job.scheduled_run_date',
           'default' => 'NULL',
           'table_name' => 'civicrm_job',
           'entity' => 'Job',
@@ -214,6 +219,7 @@ class CRM_Core_DAO_Job extends CRM_Core_DAO {
           'description' => ts('Title of the job'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_job.name',
           'table_name' => 'civicrm_job',
           'entity' => 'Job',
           'bao' => 'CRM_Core_BAO_Job',
@@ -226,6 +232,7 @@ class CRM_Core_DAO_Job extends CRM_Core_DAO {
           'description' => ts('Description of the job'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_job.description',
           'table_name' => 'civicrm_job',
           'entity' => 'Job',
           'bao' => 'CRM_Core_BAO_Job',
@@ -238,6 +245,7 @@ class CRM_Core_DAO_Job extends CRM_Core_DAO {
           'description' => ts('Entity of the job api call'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_job.api_entity',
           'table_name' => 'civicrm_job',
           'entity' => 'Job',
           'bao' => 'CRM_Core_BAO_Job',
@@ -250,6 +258,7 @@ class CRM_Core_DAO_Job extends CRM_Core_DAO {
           'description' => ts('Action of the job api call'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_job.api_action',
           'table_name' => 'civicrm_job',
           'entity' => 'Job',
           'bao' => 'CRM_Core_BAO_Job',
@@ -262,6 +271,7 @@ class CRM_Core_DAO_Job extends CRM_Core_DAO {
           'description' => ts('List of parameters to the command.'),
           'rows' => 4,
           'cols' => 60,
+          'where' => 'civicrm_job.parameters',
           'table_name' => 'civicrm_job',
           'entity' => 'Job',
           'bao' => 'CRM_Core_BAO_Job',
@@ -275,6 +285,7 @@ class CRM_Core_DAO_Job extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Job Is Active?'),
           'description' => ts('Is this job active?'),
+          'where' => 'civicrm_job.is_active',
           'table_name' => 'civicrm_job',
           'entity' => 'Job',
           'bao' => 'CRM_Core_BAO_Job',
diff --git a/civicrm/CRM/Core/DAO/JobLog.php b/civicrm/CRM/Core/DAO/JobLog.php
index aaa71773e7ea5415205a9d4f791c28800db73c12..65737e4fffbd3e7a2f0a986f3abbcaa7006ff374 100644
--- a/civicrm/CRM/Core/DAO/JobLog.php
+++ b/civicrm/CRM/Core/DAO/JobLog.php
@@ -121,6 +121,7 @@ class CRM_Core_DAO_JobLog extends CRM_Core_DAO {
           'title' => ts('Job Log ID'),
           'description' => ts('Job log entry Id'),
           'required' => TRUE,
+          'where' => 'civicrm_job_log.id',
           'table_name' => 'civicrm_job_log',
           'entity' => 'JobLog',
           'bao' => 'CRM_Core_DAO_JobLog',
@@ -132,6 +133,7 @@ class CRM_Core_DAO_JobLog extends CRM_Core_DAO {
           'title' => ts('Domain ID'),
           'description' => ts('Which Domain is this scheduled job for'),
           'required' => TRUE,
+          'where' => 'civicrm_job_log.domain_id',
           'table_name' => 'civicrm_job_log',
           'entity' => 'JobLog',
           'bao' => 'CRM_Core_DAO_JobLog',
@@ -148,6 +150,7 @@ class CRM_Core_DAO_JobLog extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_TIMESTAMP,
           'title' => ts('Timestamp'),
           'description' => ts('Log entry date'),
+          'where' => 'civicrm_job_log.run_time',
           'table_name' => 'civicrm_job_log',
           'entity' => 'JobLog',
           'bao' => 'CRM_Core_DAO_JobLog',
@@ -158,6 +161,7 @@ class CRM_Core_DAO_JobLog extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Job ID'),
           'description' => ts('Pointer to job id - not a FK though, just for logging purposes'),
+          'where' => 'civicrm_job_log.job_id',
           'table_name' => 'civicrm_job_log',
           'entity' => 'JobLog',
           'bao' => 'CRM_Core_DAO_JobLog',
@@ -170,6 +174,7 @@ class CRM_Core_DAO_JobLog extends CRM_Core_DAO {
           'description' => ts('Title of the job'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_job_log.name',
           'table_name' => 'civicrm_job_log',
           'entity' => 'JobLog',
           'bao' => 'CRM_Core_DAO_JobLog',
@@ -182,6 +187,7 @@ class CRM_Core_DAO_JobLog extends CRM_Core_DAO {
           'description' => ts('Full path to file containing job script'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_job_log.command',
           'table_name' => 'civicrm_job_log',
           'entity' => 'JobLog',
           'bao' => 'CRM_Core_DAO_JobLog',
@@ -194,6 +200,7 @@ class CRM_Core_DAO_JobLog extends CRM_Core_DAO {
           'description' => ts('Title line of log entry'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_job_log.description',
           'table_name' => 'civicrm_job_log',
           'entity' => 'JobLog',
           'bao' => 'CRM_Core_DAO_JobLog',
@@ -204,6 +211,7 @@ class CRM_Core_DAO_JobLog extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_TEXT,
           'title' => ts('Extended Data'),
           'description' => ts('Potential extended data for specific job run (e.g. tracebacks).'),
+          'where' => 'civicrm_job_log.data',
           'table_name' => 'civicrm_job_log',
           'entity' => 'JobLog',
           'bao' => 'CRM_Core_DAO_JobLog',
diff --git a/civicrm/CRM/Core/DAO/LocBlock.php b/civicrm/CRM/Core/DAO/LocBlock.php
index 8862e752b54a91f2ae23b801abcfe67536ca4e7f..c48de8d06d6f37007c6d39933b253264e63075ba 100644
--- a/civicrm/CRM/Core/DAO/LocBlock.php
+++ b/civicrm/CRM/Core/DAO/LocBlock.php
@@ -119,6 +119,7 @@ class CRM_Core_DAO_LocBlock extends CRM_Core_DAO {
           'title' => ts('Location Block ID'),
           'description' => ts('Unique ID'),
           'required' => TRUE,
+          'where' => 'civicrm_loc_block.id',
           'table_name' => 'civicrm_loc_block',
           'entity' => 'LocBlock',
           'bao' => 'CRM_Core_DAO_LocBlock',
@@ -128,6 +129,7 @@ class CRM_Core_DAO_LocBlock extends CRM_Core_DAO {
           'name' => 'address_id',
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Location Block Address'),
+          'where' => 'civicrm_loc_block.address_id',
           'table_name' => 'civicrm_loc_block',
           'entity' => 'LocBlock',
           'bao' => 'CRM_Core_DAO_LocBlock',
@@ -138,6 +140,7 @@ class CRM_Core_DAO_LocBlock extends CRM_Core_DAO {
           'name' => 'email_id',
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Location Block Email'),
+          'where' => 'civicrm_loc_block.email_id',
           'table_name' => 'civicrm_loc_block',
           'entity' => 'LocBlock',
           'bao' => 'CRM_Core_DAO_LocBlock',
@@ -148,6 +151,7 @@ class CRM_Core_DAO_LocBlock extends CRM_Core_DAO {
           'name' => 'phone_id',
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Location Block Phone'),
+          'where' => 'civicrm_loc_block.phone_id',
           'table_name' => 'civicrm_loc_block',
           'entity' => 'LocBlock',
           'bao' => 'CRM_Core_DAO_LocBlock',
@@ -158,6 +162,7 @@ class CRM_Core_DAO_LocBlock extends CRM_Core_DAO {
           'name' => 'im_id',
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Location Block IM'),
+          'where' => 'civicrm_loc_block.im_id',
           'table_name' => 'civicrm_loc_block',
           'entity' => 'LocBlock',
           'bao' => 'CRM_Core_DAO_LocBlock',
@@ -168,6 +173,7 @@ class CRM_Core_DAO_LocBlock extends CRM_Core_DAO {
           'name' => 'address_2_id',
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Location Block IM 2'),
+          'where' => 'civicrm_loc_block.address_2_id',
           'table_name' => 'civicrm_loc_block',
           'entity' => 'LocBlock',
           'bao' => 'CRM_Core_DAO_LocBlock',
@@ -178,6 +184,7 @@ class CRM_Core_DAO_LocBlock extends CRM_Core_DAO {
           'name' => 'email_2_id',
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Email 2'),
+          'where' => 'civicrm_loc_block.email_2_id',
           'table_name' => 'civicrm_loc_block',
           'entity' => 'LocBlock',
           'bao' => 'CRM_Core_DAO_LocBlock',
@@ -188,6 +195,7 @@ class CRM_Core_DAO_LocBlock extends CRM_Core_DAO {
           'name' => 'phone_2_id',
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Phone 2'),
+          'where' => 'civicrm_loc_block.phone_2_id',
           'table_name' => 'civicrm_loc_block',
           'entity' => 'LocBlock',
           'bao' => 'CRM_Core_DAO_LocBlock',
@@ -198,6 +206,7 @@ class CRM_Core_DAO_LocBlock extends CRM_Core_DAO {
           'name' => 'im_2_id',
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Instant Messenger 2'),
+          'where' => 'civicrm_loc_block.im_2_id',
           'table_name' => 'civicrm_loc_block',
           'entity' => 'LocBlock',
           'bao' => 'CRM_Core_DAO_LocBlock',
diff --git a/civicrm/CRM/Core/DAO/LocationType.php b/civicrm/CRM/Core/DAO/LocationType.php
index ebbe98c330f2fc7187c7b1a6e67b5a17f241c0e1..fbab7fe2dabeaa0dfce1484407dfda40766e66b1 100644
--- a/civicrm/CRM/Core/DAO/LocationType.php
+++ b/civicrm/CRM/Core/DAO/LocationType.php
@@ -106,6 +106,7 @@ class CRM_Core_DAO_LocationType extends CRM_Core_DAO {
           'title' => ts('Location Type ID'),
           'description' => ts('Location Type ID'),
           'required' => TRUE,
+          'where' => 'civicrm_location_type.id',
           'table_name' => 'civicrm_location_type',
           'entity' => 'LocationType',
           'bao' => 'CRM_Core_BAO_LocationType',
@@ -118,6 +119,7 @@ class CRM_Core_DAO_LocationType extends CRM_Core_DAO {
           'description' => ts('Location Type Name.'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_location_type.name',
           'table_name' => 'civicrm_location_type',
           'entity' => 'LocationType',
           'bao' => 'CRM_Core_BAO_LocationType',
@@ -130,6 +132,7 @@ class CRM_Core_DAO_LocationType extends CRM_Core_DAO {
           'description' => ts('Location Type Display Name.'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_location_type.display_name',
           'table_name' => 'civicrm_location_type',
           'entity' => 'LocationType',
           'bao' => 'CRM_Core_BAO_LocationType',
@@ -142,6 +145,7 @@ class CRM_Core_DAO_LocationType extends CRM_Core_DAO {
           'description' => ts('vCard Location Type Name.'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_location_type.vcard_name',
           'table_name' => 'civicrm_location_type',
           'entity' => 'LocationType',
           'bao' => 'CRM_Core_BAO_LocationType',
@@ -154,6 +158,7 @@ class CRM_Core_DAO_LocationType extends CRM_Core_DAO {
           'description' => ts('Location Type Description.'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_location_type.description',
           'table_name' => 'civicrm_location_type',
           'entity' => 'LocationType',
           'bao' => 'CRM_Core_BAO_LocationType',
@@ -164,6 +169,7 @@ class CRM_Core_DAO_LocationType extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Location Type is Reserved?'),
           'description' => ts('Is this location type a predefined system location?'),
+          'where' => 'civicrm_location_type.is_reserved',
           'table_name' => 'civicrm_location_type',
           'entity' => 'LocationType',
           'bao' => 'CRM_Core_BAO_LocationType',
@@ -174,6 +180,7 @@ class CRM_Core_DAO_LocationType extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Location Type is Active?'),
           'description' => ts('Is this property active?'),
+          'where' => 'civicrm_location_type.is_active',
           'table_name' => 'civicrm_location_type',
           'entity' => 'LocationType',
           'bao' => 'CRM_Core_BAO_LocationType',
@@ -184,6 +191,7 @@ class CRM_Core_DAO_LocationType extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Default Location Type?'),
           'description' => ts('Is this location type the default?'),
+          'where' => 'civicrm_location_type.is_default',
           'table_name' => 'civicrm_location_type',
           'entity' => 'LocationType',
           'bao' => 'CRM_Core_BAO_LocationType',
diff --git a/civicrm/CRM/Core/DAO/Log.php b/civicrm/CRM/Core/DAO/Log.php
index 61b9ab668c58b7f861fcde8158c853d06327b101..61a74d8a3f2cca253624f0aace7f2eb87d190294 100644
--- a/civicrm/CRM/Core/DAO/Log.php
+++ b/civicrm/CRM/Core/DAO/Log.php
@@ -108,6 +108,7 @@ class CRM_Core_DAO_Log extends CRM_Core_DAO {
           'title' => ts('Log ID'),
           'description' => ts('Log ID'),
           'required' => TRUE,
+          'where' => 'civicrm_log.id',
           'table_name' => 'civicrm_log',
           'entity' => 'Log',
           'bao' => 'CRM_Core_BAO_Log',
@@ -121,6 +122,7 @@ class CRM_Core_DAO_Log extends CRM_Core_DAO {
           'required' => TRUE,
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_log.entity_table',
           'table_name' => 'civicrm_log',
           'entity' => 'Log',
           'bao' => 'CRM_Core_BAO_Log',
@@ -132,6 +134,7 @@ class CRM_Core_DAO_Log extends CRM_Core_DAO {
           'title' => ts('Entity ID '),
           'description' => ts('Foreign key to the referenced item.'),
           'required' => TRUE,
+          'where' => 'civicrm_log.entity_id',
           'table_name' => 'civicrm_log',
           'entity' => 'Log',
           'bao' => 'CRM_Core_BAO_Log',
@@ -142,6 +145,7 @@ class CRM_Core_DAO_Log extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_TEXT,
           'title' => ts('Data'),
           'description' => ts('Updates does to this object if any.'),
+          'where' => 'civicrm_log.data',
           'table_name' => 'civicrm_log',
           'entity' => 'Log',
           'bao' => 'CRM_Core_BAO_Log',
@@ -152,6 +156,7 @@ class CRM_Core_DAO_Log extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Modified By'),
           'description' => ts('FK to Contact ID of person under whose credentials this data modification was made.'),
+          'where' => 'civicrm_log.modified_id',
           'table_name' => 'civicrm_log',
           'entity' => 'Log',
           'bao' => 'CRM_Core_BAO_Log',
@@ -163,6 +168,7 @@ class CRM_Core_DAO_Log extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
           'title' => ts('Modified Date'),
           'description' => ts('When was the referenced entity created or modified or deleted.'),
+          'where' => 'civicrm_log.modified_date',
           'table_name' => 'civicrm_log',
           'entity' => 'Log',
           'bao' => 'CRM_Core_BAO_Log',
diff --git a/civicrm/CRM/Core/DAO/MailSettings.php b/civicrm/CRM/Core/DAO/MailSettings.php
index 5ffd0c27fefae76ff4d89a76383a06840da4a25b..7657ad3a7262c4bb57ad2018df640930dd334b17 100644
--- a/civicrm/CRM/Core/DAO/MailSettings.php
+++ b/civicrm/CRM/Core/DAO/MailSettings.php
@@ -170,6 +170,7 @@ class CRM_Core_DAO_MailSettings extends CRM_Core_DAO {
           'title' => ts('Mail Settings ID'),
           'description' => ts('primary key'),
           'required' => TRUE,
+          'where' => 'civicrm_mail_settings.id',
           'table_name' => 'civicrm_mail_settings',
           'entity' => 'MailSettings',
           'bao' => 'CRM_Core_BAO_MailSettings',
@@ -181,6 +182,7 @@ class CRM_Core_DAO_MailSettings extends CRM_Core_DAO {
           'title' => ts('Mail Settings Domain'),
           'description' => ts('Which Domain is this match entry for'),
           'required' => TRUE,
+          'where' => 'civicrm_mail_settings.domain_id',
           'table_name' => 'civicrm_mail_settings',
           'entity' => 'MailSettings',
           'bao' => 'CRM_Core_BAO_MailSettings',
@@ -199,6 +201,7 @@ class CRM_Core_DAO_MailSettings extends CRM_Core_DAO {
           'description' => ts('name of this group of settings'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_mail_settings.name',
           'table_name' => 'civicrm_mail_settings',
           'entity' => 'MailSettings',
           'bao' => 'CRM_Core_BAO_MailSettings',
@@ -209,6 +212,7 @@ class CRM_Core_DAO_MailSettings extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Is Default Mail Settings?'),
           'description' => ts('whether this is the default set of settings for this domain'),
+          'where' => 'civicrm_mail_settings.is_default',
           'table_name' => 'civicrm_mail_settings',
           'entity' => 'MailSettings',
           'bao' => 'CRM_Core_BAO_MailSettings',
@@ -221,6 +225,7 @@ class CRM_Core_DAO_MailSettings extends CRM_Core_DAO {
           'description' => ts('email address domain (the part after @)'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_mail_settings.domain',
           'table_name' => 'civicrm_mail_settings',
           'entity' => 'MailSettings',
           'bao' => 'CRM_Core_BAO_MailSettings',
@@ -233,6 +238,7 @@ class CRM_Core_DAO_MailSettings extends CRM_Core_DAO {
           'description' => ts('optional local part (like civimail+ for addresses like civimail+s.1.2@example.com)'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_mail_settings.localpart',
           'table_name' => 'civicrm_mail_settings',
           'entity' => 'MailSettings',
           'bao' => 'CRM_Core_BAO_MailSettings',
@@ -245,6 +251,7 @@ class CRM_Core_DAO_MailSettings extends CRM_Core_DAO {
           'description' => ts('contents of the Return-Path header'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_mail_settings.return_path',
           'table_name' => 'civicrm_mail_settings',
           'entity' => 'MailSettings',
           'bao' => 'CRM_Core_BAO_MailSettings',
@@ -257,6 +264,7 @@ class CRM_Core_DAO_MailSettings extends CRM_Core_DAO {
           'description' => ts('name of the protocol to use for polling (like IMAP, POP3 or Maildir)'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_mail_settings.protocol',
           'table_name' => 'civicrm_mail_settings',
           'entity' => 'MailSettings',
           'bao' => 'CRM_Core_BAO_MailSettings',
@@ -276,6 +284,7 @@ class CRM_Core_DAO_MailSettings extends CRM_Core_DAO {
           'description' => ts('server to use when polling'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_mail_settings.server',
           'table_name' => 'civicrm_mail_settings',
           'entity' => 'MailSettings',
           'bao' => 'CRM_Core_BAO_MailSettings',
@@ -286,6 +295,7 @@ class CRM_Core_DAO_MailSettings extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Mail Port'),
           'description' => ts('port to use when polling'),
+          'where' => 'civicrm_mail_settings.port',
           'table_name' => 'civicrm_mail_settings',
           'entity' => 'MailSettings',
           'bao' => 'CRM_Core_BAO_MailSettings',
@@ -298,6 +308,7 @@ class CRM_Core_DAO_MailSettings extends CRM_Core_DAO {
           'description' => ts('username to use when polling'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_mail_settings.username',
           'table_name' => 'civicrm_mail_settings',
           'entity' => 'MailSettings',
           'bao' => 'CRM_Core_BAO_MailSettings',
@@ -310,6 +321,7 @@ class CRM_Core_DAO_MailSettings extends CRM_Core_DAO {
           'description' => ts('password to use when polling'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_mail_settings.password',
           'table_name' => 'civicrm_mail_settings',
           'entity' => 'MailSettings',
           'bao' => 'CRM_Core_BAO_MailSettings',
@@ -320,6 +332,7 @@ class CRM_Core_DAO_MailSettings extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Mail Account Uses SSL'),
           'description' => ts('whether to use SSL or not'),
+          'where' => 'civicrm_mail_settings.is_ssl',
           'table_name' => 'civicrm_mail_settings',
           'entity' => 'MailSettings',
           'bao' => 'CRM_Core_BAO_MailSettings',
@@ -332,6 +345,7 @@ class CRM_Core_DAO_MailSettings extends CRM_Core_DAO {
           'description' => ts('folder to poll from when using IMAP, path to poll from when using Maildir, etc.'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_mail_settings.source',
           'table_name' => 'civicrm_mail_settings',
           'entity' => 'MailSettings',
           'bao' => 'CRM_Core_BAO_MailSettings',
@@ -344,6 +358,7 @@ class CRM_Core_DAO_MailSettings extends CRM_Core_DAO {
           'description' => ts('Name of status to use when creating email to activity.'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_mail_settings.activity_status',
           'table_name' => 'civicrm_mail_settings',
           'entity' => 'MailSettings',
           'bao' => 'CRM_Core_BAO_MailSettings',
diff --git a/civicrm/CRM/Core/DAO/Managed.php b/civicrm/CRM/Core/DAO/Managed.php
index 4ba363ef562bc792de1d688cb2feef57be061f88..940c62e686388859ba10df3074d69a859f9e125d 100644
--- a/civicrm/CRM/Core/DAO/Managed.php
+++ b/civicrm/CRM/Core/DAO/Managed.php
@@ -92,6 +92,7 @@ class CRM_Core_DAO_Managed extends CRM_Core_DAO {
           'title' => ts('Managed ID'),
           'description' => ts('Surrogate Key'),
           'required' => TRUE,
+          'where' => 'civicrm_managed.id',
           'table_name' => 'civicrm_managed',
           'entity' => 'Managed',
           'bao' => 'CRM_Core_DAO_Managed',
@@ -105,6 +106,7 @@ class CRM_Core_DAO_Managed extends CRM_Core_DAO {
           'required' => TRUE,
           'maxlength' => 127,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_managed.module',
           'table_name' => 'civicrm_managed',
           'entity' => 'Managed',
           'bao' => 'CRM_Core_DAO_Managed',
@@ -117,6 +119,7 @@ class CRM_Core_DAO_Managed extends CRM_Core_DAO {
           'description' => ts('Symbolic name used by the module to identify the object'),
           'maxlength' => 127,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_managed.name',
           'table_name' => 'civicrm_managed',
           'entity' => 'Managed',
           'bao' => 'CRM_Core_DAO_Managed',
@@ -130,6 +133,7 @@ class CRM_Core_DAO_Managed extends CRM_Core_DAO {
           'required' => TRUE,
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_managed.entity_type',
           'table_name' => 'civicrm_managed',
           'entity' => 'Managed',
           'bao' => 'CRM_Core_DAO_Managed',
@@ -141,6 +145,7 @@ class CRM_Core_DAO_Managed extends CRM_Core_DAO {
           'title' => ts('Entity ID'),
           'description' => ts('Foreign key to the referenced item.'),
           'required' => TRUE,
+          'where' => 'civicrm_managed.entity_id',
           'table_name' => 'civicrm_managed',
           'entity' => 'Managed',
           'bao' => 'CRM_Core_DAO_Managed',
@@ -153,6 +158,7 @@ class CRM_Core_DAO_Managed extends CRM_Core_DAO {
           'description' => ts('Policy on when to cleanup entity (always, never, unused)'),
           'maxlength' => 32,
           'size' => CRM_Utils_Type::MEDIUM,
+          'where' => 'civicrm_managed.cleanup',
           'table_name' => 'civicrm_managed',
           'entity' => 'Managed',
           'bao' => 'CRM_Core_DAO_Managed',
diff --git a/civicrm/CRM/Core/DAO/Mapping.php b/civicrm/CRM/Core/DAO/Mapping.php
index e2e3a90a0cd3bcdd6e83173ae216ae66b4941ea1..a4c2e3556a442c2b93db9e5c55b59ed2256106ba 100644
--- a/civicrm/CRM/Core/DAO/Mapping.php
+++ b/civicrm/CRM/Core/DAO/Mapping.php
@@ -78,6 +78,7 @@ class CRM_Core_DAO_Mapping extends CRM_Core_DAO {
           'title' => ts('Mapping ID'),
           'description' => ts('Mapping ID'),
           'required' => TRUE,
+          'where' => 'civicrm_mapping.id',
           'table_name' => 'civicrm_mapping',
           'entity' => 'Mapping',
           'bao' => 'CRM_Core_BAO_Mapping',
@@ -90,6 +91,7 @@ class CRM_Core_DAO_Mapping extends CRM_Core_DAO {
           'description' => ts('Name of Mapping'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_mapping.name',
           'table_name' => 'civicrm_mapping',
           'entity' => 'Mapping',
           'bao' => 'CRM_Core_BAO_Mapping',
@@ -102,6 +104,7 @@ class CRM_Core_DAO_Mapping extends CRM_Core_DAO {
           'description' => ts('Description of Mapping.'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_mapping.description',
           'table_name' => 'civicrm_mapping',
           'entity' => 'Mapping',
           'bao' => 'CRM_Core_BAO_Mapping',
@@ -112,6 +115,7 @@ class CRM_Core_DAO_Mapping extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Mapping Type'),
           'description' => ts('Mapping Type'),
+          'where' => 'civicrm_mapping.mapping_type_id',
           'table_name' => 'civicrm_mapping',
           'entity' => 'Mapping',
           'bao' => 'CRM_Core_BAO_Mapping',
diff --git a/civicrm/CRM/Core/DAO/MappingField.php b/civicrm/CRM/Core/DAO/MappingField.php
index c7b228c75a1e77ce6fee282f4c9efea1b6dadb59..eecc8d44bf875320a5bb11c9bd27f4312a0d41e6 100644
--- a/civicrm/CRM/Core/DAO/MappingField.php
+++ b/civicrm/CRM/Core/DAO/MappingField.php
@@ -164,6 +164,7 @@ class CRM_Core_DAO_MappingField extends CRM_Core_DAO {
           'title' => ts('Mapping Field ID'),
           'description' => ts('Mapping Field ID'),
           'required' => TRUE,
+          'where' => 'civicrm_mapping_field.id',
           'table_name' => 'civicrm_mapping_field',
           'entity' => 'MappingField',
           'bao' => 'CRM_Core_DAO_MappingField',
@@ -175,6 +176,7 @@ class CRM_Core_DAO_MappingField extends CRM_Core_DAO {
           'title' => ts('Mapping ID'),
           'description' => ts('Mapping to which this field belongs'),
           'required' => TRUE,
+          'where' => 'civicrm_mapping_field.mapping_id',
           'table_name' => 'civicrm_mapping_field',
           'entity' => 'MappingField',
           'bao' => 'CRM_Core_DAO_MappingField',
@@ -188,6 +190,7 @@ class CRM_Core_DAO_MappingField extends CRM_Core_DAO {
           'description' => ts('Mapping field key'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_mapping_field.name',
           'table_name' => 'civicrm_mapping_field',
           'entity' => 'MappingField',
           'bao' => 'CRM_Core_DAO_MappingField',
@@ -200,6 +203,7 @@ class CRM_Core_DAO_MappingField extends CRM_Core_DAO {
           'description' => ts('Contact Type in mapping'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_mapping_field.contact_type',
           'table_name' => 'civicrm_mapping_field',
           'entity' => 'MappingField',
           'bao' => 'CRM_Core_DAO_MappingField',
@@ -214,6 +218,7 @@ class CRM_Core_DAO_MappingField extends CRM_Core_DAO {
           'title' => ts('Column Number'),
           'description' => ts('Column number for mapping set'),
           'required' => TRUE,
+          'where' => 'civicrm_mapping_field.column_number',
           'table_name' => 'civicrm_mapping_field',
           'entity' => 'MappingField',
           'bao' => 'CRM_Core_DAO_MappingField',
@@ -224,6 +229,7 @@ class CRM_Core_DAO_MappingField extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Location type ID'),
           'description' => ts('Location type of this mapping, if required'),
+          'where' => 'civicrm_mapping_field.location_type_id',
           'table_name' => 'civicrm_mapping_field',
           'entity' => 'MappingField',
           'bao' => 'CRM_Core_DAO_MappingField',
@@ -235,6 +241,7 @@ class CRM_Core_DAO_MappingField extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Phone type ID'),
           'description' => ts('Which type of phone does this number belongs.'),
+          'where' => 'civicrm_mapping_field.phone_type_id',
           'table_name' => 'civicrm_mapping_field',
           'entity' => 'MappingField',
           'bao' => 'CRM_Core_DAO_MappingField',
@@ -245,6 +252,7 @@ class CRM_Core_DAO_MappingField extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('IM provider ID'),
           'description' => ts('Which type of IM Provider does this name belong.'),
+          'where' => 'civicrm_mapping_field.im_provider_id',
           'table_name' => 'civicrm_mapping_field',
           'entity' => 'MappingField',
           'bao' => 'CRM_Core_DAO_MappingField',
@@ -262,6 +270,7 @@ class CRM_Core_DAO_MappingField extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Website type ID'),
           'description' => ts('Which type of website does this site belong'),
+          'where' => 'civicrm_mapping_field.website_type_id',
           'table_name' => 'civicrm_mapping_field',
           'entity' => 'MappingField',
           'bao' => 'CRM_Core_DAO_MappingField',
@@ -279,6 +288,7 @@ class CRM_Core_DAO_MappingField extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Relationship type ID'),
           'description' => ts('Relationship type, if required'),
+          'where' => 'civicrm_mapping_field.relationship_type_id',
           'table_name' => 'civicrm_mapping_field',
           'entity' => 'MappingField',
           'bao' => 'CRM_Core_DAO_MappingField',
@@ -291,6 +301,7 @@ class CRM_Core_DAO_MappingField extends CRM_Core_DAO {
           'title' => ts('Relationship Direction'),
           'maxlength' => 6,
           'size' => CRM_Utils_Type::SIX,
+          'where' => 'civicrm_mapping_field.relationship_direction',
           'table_name' => 'civicrm_mapping_field',
           'entity' => 'MappingField',
           'bao' => 'CRM_Core_DAO_MappingField',
@@ -303,6 +314,7 @@ class CRM_Core_DAO_MappingField extends CRM_Core_DAO {
           'description' => ts('Used to group mapping_field records into related sets (e.g. for criteria sets in search builder
       mappings).
     '),
+          'where' => 'civicrm_mapping_field.grouping',
           'default' => '1',
           'table_name' => 'civicrm_mapping_field',
           'entity' => 'MappingField',
@@ -316,6 +328,7 @@ class CRM_Core_DAO_MappingField extends CRM_Core_DAO {
           'description' => ts('SQL WHERE operator for search-builder mapping fields (search criteria).'),
           'maxlength' => 16,
           'size' => CRM_Utils_Type::TWELVE,
+          'where' => 'civicrm_mapping_field.operator',
           'table_name' => 'civicrm_mapping_field',
           'entity' => 'MappingField',
           'bao' => 'CRM_Core_DAO_MappingField',
@@ -334,6 +347,7 @@ class CRM_Core_DAO_MappingField extends CRM_Core_DAO {
           'description' => ts('SQL WHERE value for search-builder mapping fields.'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_mapping_field.value',
           'table_name' => 'civicrm_mapping_field',
           'entity' => 'MappingField',
           'bao' => 'CRM_Core_DAO_MappingField',
diff --git a/civicrm/CRM/Core/DAO/Menu.php b/civicrm/CRM/Core/DAO/Menu.php
index 10b3f14316cbc6aee3b0c151fc008151ba0a3a34..3815647ba270afb98e78438d314c381500300765 100644
--- a/civicrm/CRM/Core/DAO/Menu.php
+++ b/civicrm/CRM/Core/DAO/Menu.php
@@ -215,6 +215,7 @@ class CRM_Core_DAO_Menu extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Menu ID'),
           'required' => TRUE,
+          'where' => 'civicrm_menu.id',
           'table_name' => 'civicrm_menu',
           'entity' => 'Menu',
           'bao' => 'CRM_Core_DAO_Menu',
@@ -226,6 +227,7 @@ class CRM_Core_DAO_Menu extends CRM_Core_DAO {
           'title' => ts('Domain'),
           'description' => ts('Which Domain is this menu item for'),
           'required' => TRUE,
+          'where' => 'civicrm_menu.domain_id',
           'table_name' => 'civicrm_menu',
           'entity' => 'Menu',
           'bao' => 'CRM_Core_DAO_Menu',
@@ -244,6 +246,7 @@ class CRM_Core_DAO_Menu extends CRM_Core_DAO {
           'description' => ts('Path Name'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_menu.path',
           'table_name' => 'civicrm_menu',
           'entity' => 'Menu',
           'bao' => 'CRM_Core_DAO_Menu',
@@ -254,6 +257,7 @@ class CRM_Core_DAO_Menu extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_TEXT,
           'title' => ts('Arguments'),
           'description' => ts('Arguments to pass to the url'),
+          'where' => 'civicrm_menu.path_arguments',
           'table_name' => 'civicrm_menu',
           'entity' => 'Menu',
           'bao' => 'CRM_Core_DAO_Menu',
@@ -265,6 +269,7 @@ class CRM_Core_DAO_Menu extends CRM_Core_DAO {
           'title' => ts('Menu Title'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_menu.title',
           'table_name' => 'civicrm_menu',
           'entity' => 'Menu',
           'bao' => 'CRM_Core_DAO_Menu',
@@ -277,6 +282,7 @@ class CRM_Core_DAO_Menu extends CRM_Core_DAO {
           'description' => ts('Function to call to check access permissions'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_menu.access_callback',
           'table_name' => 'civicrm_menu',
           'entity' => 'Menu',
           'bao' => 'CRM_Core_DAO_Menu',
@@ -287,6 +293,7 @@ class CRM_Core_DAO_Menu extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_TEXT,
           'title' => ts('Access Arguments'),
           'description' => ts('Arguments to pass to access callback'),
+          'where' => 'civicrm_menu.access_arguments',
           'table_name' => 'civicrm_menu',
           'entity' => 'Menu',
           'bao' => 'CRM_Core_DAO_Menu',
@@ -299,6 +306,7 @@ class CRM_Core_DAO_Menu extends CRM_Core_DAO {
           'description' => ts('function to call for this url'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_menu.page_callback',
           'table_name' => 'civicrm_menu',
           'entity' => 'Menu',
           'bao' => 'CRM_Core_DAO_Menu',
@@ -309,6 +317,7 @@ class CRM_Core_DAO_Menu extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_TEXT,
           'title' => ts('Page Arguments'),
           'description' => ts('Arguments to pass to page callback'),
+          'where' => 'civicrm_menu.page_arguments',
           'table_name' => 'civicrm_menu',
           'entity' => 'Menu',
           'bao' => 'CRM_Core_DAO_Menu',
@@ -319,6 +328,7 @@ class CRM_Core_DAO_Menu extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_TEXT,
           'title' => ts('Breadcrumb'),
           'description' => ts('Breadcrumb for the path.'),
+          'where' => 'civicrm_menu.breadcrumb',
           'table_name' => 'civicrm_menu',
           'entity' => 'Menu',
           'bao' => 'CRM_Core_DAO_Menu',
@@ -331,6 +341,7 @@ class CRM_Core_DAO_Menu extends CRM_Core_DAO {
           'description' => ts('Url where a page should redirected to, if next url not known.'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_menu.return_url',
           'table_name' => 'civicrm_menu',
           'entity' => 'Menu',
           'bao' => 'CRM_Core_DAO_Menu',
@@ -343,6 +354,7 @@ class CRM_Core_DAO_Menu extends CRM_Core_DAO {
           'description' => ts('Arguments to pass to return_url'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_menu.return_url_args',
           'table_name' => 'civicrm_menu',
           'entity' => 'Menu',
           'bao' => 'CRM_Core_DAO_Menu',
@@ -353,6 +365,7 @@ class CRM_Core_DAO_Menu extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Component'),
           'description' => ts('Component that this menu item belongs to'),
+          'where' => 'civicrm_menu.component_id',
           'table_name' => 'civicrm_menu',
           'entity' => 'Menu',
           'bao' => 'CRM_Core_DAO_Menu',
@@ -372,6 +385,7 @@ class CRM_Core_DAO_Menu extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Enabled?'),
           'description' => ts('Is this menu item active?'),
+          'where' => 'civicrm_menu.is_active',
           'table_name' => 'civicrm_menu',
           'entity' => 'Menu',
           'bao' => 'CRM_Core_DAO_Menu',
@@ -382,6 +396,7 @@ class CRM_Core_DAO_Menu extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Public?'),
           'description' => ts('Is this menu accessible to the public?'),
+          'where' => 'civicrm_menu.is_public',
           'table_name' => 'civicrm_menu',
           'entity' => 'Menu',
           'bao' => 'CRM_Core_DAO_Menu',
@@ -392,6 +407,7 @@ class CRM_Core_DAO_Menu extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Exposed?'),
           'description' => ts('Is this menu exposed to the navigation system?'),
+          'where' => 'civicrm_menu.is_exposed',
           'table_name' => 'civicrm_menu',
           'entity' => 'Menu',
           'bao' => 'CRM_Core_DAO_Menu',
@@ -402,6 +418,7 @@ class CRM_Core_DAO_Menu extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Use SSL?'),
           'description' => ts('Should this menu be exposed via SSL if enabled?'),
+          'where' => 'civicrm_menu.is_ssl',
           'table_name' => 'civicrm_menu',
           'entity' => 'Menu',
           'bao' => 'CRM_Core_DAO_Menu',
@@ -413,6 +430,7 @@ class CRM_Core_DAO_Menu extends CRM_Core_DAO {
           'title' => ts('Order'),
           'description' => ts('Ordering of the menu items in various blocks.'),
           'required' => TRUE,
+          'where' => 'civicrm_menu.weight',
           'default' => '1',
           'table_name' => 'civicrm_menu',
           'entity' => 'Menu',
@@ -425,6 +443,7 @@ class CRM_Core_DAO_Menu extends CRM_Core_DAO {
           'title' => ts('Type'),
           'description' => ts('Drupal menu type.'),
           'required' => TRUE,
+          'where' => 'civicrm_menu.type',
           'default' => '1',
           'table_name' => 'civicrm_menu',
           'entity' => 'Menu',
@@ -437,6 +456,7 @@ class CRM_Core_DAO_Menu extends CRM_Core_DAO {
           'title' => ts('Page Type'),
           'description' => ts('CiviCRM menu type.'),
           'required' => TRUE,
+          'where' => 'civicrm_menu.page_type',
           'default' => '1',
           'table_name' => 'civicrm_menu',
           'entity' => 'Menu',
@@ -448,6 +468,7 @@ class CRM_Core_DAO_Menu extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Hide Breadcrumb?'),
           'description' => ts('skip this url being exposed to breadcrumb'),
+          'where' => 'civicrm_menu.skipBreadcrumb',
           'table_name' => 'civicrm_menu',
           'entity' => 'Menu',
           'bao' => 'CRM_Core_DAO_Menu',
@@ -458,6 +479,7 @@ class CRM_Core_DAO_Menu extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_TEXT,
           'title' => ts('Other menu data'),
           'description' => ts('All other menu metadata not stored in other fields'),
+          'where' => 'civicrm_menu.module_data',
           'table_name' => 'civicrm_menu',
           'entity' => 'Menu',
           'bao' => 'CRM_Core_DAO_Menu',
diff --git a/civicrm/CRM/Core/DAO/MessageTemplate.php b/civicrm/CRM/Core/DAO/MessageTemplate.php
index 3fee5bb1f1f25daa77008355abd001ac95d98968..7ba12439092b90a1fcd27c6f73414f3e0a783cc4 100644
--- a/civicrm/CRM/Core/DAO/MessageTemplate.php
+++ b/civicrm/CRM/Core/DAO/MessageTemplate.php
@@ -125,6 +125,7 @@ class CRM_Core_DAO_MessageTemplate extends CRM_Core_DAO {
           'title' => ts('Message Template ID'),
           'description' => ts('Message Template ID'),
           'required' => TRUE,
+          'where' => 'civicrm_msg_template.id',
           'table_name' => 'civicrm_msg_template',
           'entity' => 'MessageTemplate',
           'bao' => 'CRM_Core_BAO_MessageTemplate',
@@ -137,6 +138,7 @@ class CRM_Core_DAO_MessageTemplate extends CRM_Core_DAO {
           'description' => ts('Descriptive title of message'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_msg_template.msg_title',
           'table_name' => 'civicrm_msg_template',
           'entity' => 'MessageTemplate',
           'bao' => 'CRM_Core_BAO_MessageTemplate',
@@ -147,6 +149,7 @@ class CRM_Core_DAO_MessageTemplate extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_TEXT,
           'title' => ts('Message Template Subject'),
           'description' => ts('Subject for email message.'),
+          'where' => 'civicrm_msg_template.msg_subject',
           'table_name' => 'civicrm_msg_template',
           'entity' => 'MessageTemplate',
           'bao' => 'CRM_Core_BAO_MessageTemplate',
@@ -157,6 +160,7 @@ class CRM_Core_DAO_MessageTemplate extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_LONGTEXT,
           'title' => ts('Message Template Text'),
           'description' => ts('Text formatted message'),
+          'where' => 'civicrm_msg_template.msg_text',
           'table_name' => 'civicrm_msg_template',
           'entity' => 'MessageTemplate',
           'bao' => 'CRM_Core_BAO_MessageTemplate',
@@ -170,6 +174,7 @@ class CRM_Core_DAO_MessageTemplate extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_LONGTEXT,
           'title' => ts('Message Template HTML'),
           'description' => ts('HTML formatted message'),
+          'where' => 'civicrm_msg_template.msg_html',
           'table_name' => 'civicrm_msg_template',
           'entity' => 'MessageTemplate',
           'bao' => 'CRM_Core_BAO_MessageTemplate',
@@ -182,6 +187,7 @@ class CRM_Core_DAO_MessageTemplate extends CRM_Core_DAO {
           'name' => 'is_active',
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Is Active'),
+          'where' => 'civicrm_msg_template.is_active',
           'default' => '1',
           'table_name' => 'civicrm_msg_template',
           'entity' => 'MessageTemplate',
@@ -193,6 +199,7 @@ class CRM_Core_DAO_MessageTemplate extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Message Template Workflow'),
           'description' => ts('a pseudo-FK to civicrm_option_value'),
+          'where' => 'civicrm_msg_template.workflow_id',
           'table_name' => 'civicrm_msg_template',
           'entity' => 'MessageTemplate',
           'bao' => 'CRM_Core_BAO_MessageTemplate',
@@ -203,6 +210,7 @@ class CRM_Core_DAO_MessageTemplate extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Message Template Is Default?'),
           'description' => ts('is this the default message template for the workflow referenced by workflow_id?'),
+          'where' => 'civicrm_msg_template.is_default',
           'default' => '1',
           'table_name' => 'civicrm_msg_template',
           'entity' => 'MessageTemplate',
@@ -214,6 +222,7 @@ class CRM_Core_DAO_MessageTemplate extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Message Template Is Reserved?'),
           'description' => ts('is this the reserved message template which we ship for the workflow referenced by workflow_id?'),
+          'where' => 'civicrm_msg_template.is_reserved',
           'table_name' => 'civicrm_msg_template',
           'entity' => 'MessageTemplate',
           'bao' => 'CRM_Core_BAO_MessageTemplate',
@@ -224,6 +233,7 @@ class CRM_Core_DAO_MessageTemplate extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Message Template is used for SMS?'),
           'description' => ts('Is this message template used for sms?'),
+          'where' => 'civicrm_msg_template.is_sms',
           'default' => '0',
           'table_name' => 'civicrm_msg_template',
           'entity' => 'MessageTemplate',
@@ -235,6 +245,7 @@ class CRM_Core_DAO_MessageTemplate extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Message Template Format'),
           'description' => ts('a pseudo-FK to civicrm_option_value containing PDF Page Format.'),
+          'where' => 'civicrm_msg_template.pdf_format_id',
           'table_name' => 'civicrm_msg_template',
           'entity' => 'MessageTemplate',
           'bao' => 'CRM_Core_BAO_MessageTemplate',
diff --git a/civicrm/CRM/Core/DAO/Navigation.php b/civicrm/CRM/Core/DAO/Navigation.php
index 60f0c807ddb0984982b2fbdbb31652e06c506225..3e025a452bf61913bad58240597056394556b29a 100644
--- a/civicrm/CRM/Core/DAO/Navigation.php
+++ b/civicrm/CRM/Core/DAO/Navigation.php
@@ -147,6 +147,7 @@ class CRM_Core_DAO_Navigation extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Navigation ID'),
           'required' => TRUE,
+          'where' => 'civicrm_navigation.id',
           'table_name' => 'civicrm_navigation',
           'entity' => 'Navigation',
           'bao' => 'CRM_Core_BAO_Navigation',
@@ -158,6 +159,7 @@ class CRM_Core_DAO_Navigation extends CRM_Core_DAO {
           'title' => ts('Navigation Domain'),
           'description' => ts('Which Domain is this navigation item for'),
           'required' => TRUE,
+          'where' => 'civicrm_navigation.domain_id',
           'table_name' => 'civicrm_navigation',
           'entity' => 'Navigation',
           'bao' => 'CRM_Core_BAO_Navigation',
@@ -176,6 +178,7 @@ class CRM_Core_DAO_Navigation extends CRM_Core_DAO {
           'description' => ts('Navigation Title'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_navigation.label',
           'table_name' => 'civicrm_navigation',
           'entity' => 'Navigation',
           'bao' => 'CRM_Core_BAO_Navigation',
@@ -188,6 +191,7 @@ class CRM_Core_DAO_Navigation extends CRM_Core_DAO {
           'description' => ts('Internal Name'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_navigation.name',
           'table_name' => 'civicrm_navigation',
           'entity' => 'Navigation',
           'bao' => 'CRM_Core_BAO_Navigation',
@@ -200,6 +204,7 @@ class CRM_Core_DAO_Navigation extends CRM_Core_DAO {
           'description' => ts('url in case of custom navigation link'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_navigation.url',
           'table_name' => 'civicrm_navigation',
           'entity' => 'Navigation',
           'bao' => 'CRM_Core_BAO_Navigation',
@@ -213,6 +218,7 @@ class CRM_Core_DAO_Navigation extends CRM_Core_DAO {
           'required' => FALSE,
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_navigation.icon',
           'default' => 'NULL',
           'table_name' => 'civicrm_navigation',
           'entity' => 'Navigation',
@@ -226,6 +232,7 @@ class CRM_Core_DAO_Navigation extends CRM_Core_DAO {
           'description' => ts('Permission for menu item'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_navigation.permission',
           'table_name' => 'civicrm_navigation',
           'entity' => 'Navigation',
           'bao' => 'CRM_Core_BAO_Navigation',
@@ -238,6 +245,7 @@ class CRM_Core_DAO_Navigation extends CRM_Core_DAO {
           'description' => ts('Permission Operator'),
           'maxlength' => 3,
           'size' => CRM_Utils_Type::FOUR,
+          'where' => 'civicrm_navigation.permission_operator',
           'table_name' => 'civicrm_navigation',
           'entity' => 'Navigation',
           'bao' => 'CRM_Core_BAO_Navigation',
@@ -248,6 +256,7 @@ class CRM_Core_DAO_Navigation extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Navigation parent ID'),
           'description' => ts('Parent navigation item, used for grouping'),
+          'where' => 'civicrm_navigation.parent_id',
           'table_name' => 'civicrm_navigation',
           'entity' => 'Navigation',
           'bao' => 'CRM_Core_BAO_Navigation',
@@ -265,6 +274,7 @@ class CRM_Core_DAO_Navigation extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Is Active'),
           'description' => ts('Is this navigation item active?'),
+          'where' => 'civicrm_navigation.is_active',
           'table_name' => 'civicrm_navigation',
           'entity' => 'Navigation',
           'bao' => 'CRM_Core_BAO_Navigation',
@@ -275,6 +285,7 @@ class CRM_Core_DAO_Navigation extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Use separator'),
           'description' => ts('If separator needs to be added after this menu item'),
+          'where' => 'civicrm_navigation.has_separator',
           'table_name' => 'civicrm_navigation',
           'entity' => 'Navigation',
           'bao' => 'CRM_Core_BAO_Navigation',
@@ -285,6 +296,7 @@ class CRM_Core_DAO_Navigation extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Order'),
           'description' => ts('Ordering of the navigation items in various blocks.'),
+          'where' => 'civicrm_navigation.weight',
           'table_name' => 'civicrm_navigation',
           'entity' => 'Navigation',
           'bao' => 'CRM_Core_BAO_Navigation',
diff --git a/civicrm/CRM/Core/DAO/Note.php b/civicrm/CRM/Core/DAO/Note.php
index 95b17c3bf8f09aff746577d85a5c68b25b2da9d9..84ecb5ba800690ed07e9dd4003d620eecfdc5c22 100644
--- a/civicrm/CRM/Core/DAO/Note.php
+++ b/civicrm/CRM/Core/DAO/Note.php
@@ -122,6 +122,7 @@ class CRM_Core_DAO_Note extends CRM_Core_DAO {
           'title' => ts('Note ID'),
           'description' => ts('Note ID'),
           'required' => TRUE,
+          'where' => 'civicrm_note.id',
           'table_name' => 'civicrm_note',
           'entity' => 'Note',
           'bao' => 'CRM_Core_BAO_Note',
@@ -135,6 +136,7 @@ class CRM_Core_DAO_Note extends CRM_Core_DAO {
           'required' => TRUE,
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_note.entity_table',
           'table_name' => 'civicrm_note',
           'entity' => 'Note',
           'bao' => 'CRM_Core_BAO_Note',
@@ -149,6 +151,7 @@ class CRM_Core_DAO_Note extends CRM_Core_DAO {
           'title' => ts('Note Entity ID'),
           'description' => ts('Foreign key to the referenced item.'),
           'required' => TRUE,
+          'where' => 'civicrm_note.entity_id',
           'table_name' => 'civicrm_note',
           'entity' => 'Note',
           'bao' => 'CRM_Core_BAO_Note',
@@ -179,6 +182,7 @@ class CRM_Core_DAO_Note extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Note Created By'),
           'description' => ts('FK to Contact ID creator'),
+          'where' => 'civicrm_note.contact_id',
           'table_name' => 'civicrm_note',
           'entity' => 'Note',
           'bao' => 'CRM_Core_BAO_Note',
@@ -190,6 +194,7 @@ class CRM_Core_DAO_Note extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_DATE,
           'title' => ts('Note Modified By'),
           'description' => ts('When was this note last modified/edited'),
+          'where' => 'civicrm_note.modified_date',
           'table_name' => 'civicrm_note',
           'entity' => 'Note',
           'bao' => 'CRM_Core_BAO_Note',
@@ -202,6 +207,7 @@ class CRM_Core_DAO_Note extends CRM_Core_DAO {
           'description' => ts('subject of note description'),
           'maxlength' => 255,
           'size' => 60,
+          'where' => 'civicrm_note.subject',
           'table_name' => 'civicrm_note',
           'entity' => 'Note',
           'bao' => 'CRM_Core_BAO_Note',
@@ -217,6 +223,7 @@ class CRM_Core_DAO_Note extends CRM_Core_DAO {
           'description' => ts('Foreign Key to Note Privacy Level (which is an option value pair and hence an implicit FK)'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_note.privacy',
           'table_name' => 'civicrm_note',
           'entity' => 'Note',
           'bao' => 'CRM_Core_BAO_Note',
diff --git a/civicrm/CRM/Core/DAO/OpenID.php b/civicrm/CRM/Core/DAO/OpenID.php
index f70c0eca3df3d8d63497bd1507efa814af3edb9d..206cb5ba8846b486dc70bde62301f5e0cad57764 100644
--- a/civicrm/CRM/Core/DAO/OpenID.php
+++ b/civicrm/CRM/Core/DAO/OpenID.php
@@ -107,6 +107,7 @@ class CRM_Core_DAO_OpenID extends CRM_Core_DAO {
           'title' => ts('Open ID identifier'),
           'description' => ts('Unique OpenID ID'),
           'required' => TRUE,
+          'where' => 'civicrm_openid.id',
           'table_name' => 'civicrm_openid',
           'entity' => 'OpenID',
           'bao' => 'CRM_Core_BAO_OpenID',
@@ -117,6 +118,7 @@ class CRM_Core_DAO_OpenID extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('OpenID Contact'),
           'description' => ts('FK to Contact ID'),
+          'where' => 'civicrm_openid.contact_id',
           'table_name' => 'civicrm_openid',
           'entity' => 'OpenID',
           'bao' => 'CRM_Core_BAO_OpenID',
@@ -128,6 +130,7 @@ class CRM_Core_DAO_OpenID extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('OpenID Location Type'),
           'description' => ts('Which Location does this email belong to.'),
+          'where' => 'civicrm_openid.location_type_id',
           'table_name' => 'civicrm_openid',
           'entity' => 'OpenID',
           'bao' => 'CRM_Core_BAO_OpenID',
@@ -157,6 +160,7 @@ class CRM_Core_DAO_OpenID extends CRM_Core_DAO {
           'title' => ts('Allowed to login?'),
           'description' => ts('Whether or not this user is allowed to login'),
           'required' => TRUE,
+          'where' => 'civicrm_openid.allowed_to_login',
           'default' => '0',
           'table_name' => 'civicrm_openid',
           'entity' => 'OpenID',
@@ -168,6 +172,7 @@ class CRM_Core_DAO_OpenID extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Is OpenID Primary?'),
           'description' => ts('Is this the primary email for this contact and location.'),
+          'where' => 'civicrm_openid.is_primary',
           'default' => '0',
           'table_name' => 'civicrm_openid',
           'entity' => 'OpenID',
diff --git a/civicrm/CRM/Core/DAO/OptionGroup.php b/civicrm/CRM/Core/DAO/OptionGroup.php
index c65b63b9aade22131fb6b46a173f2833d2fb13f1..fa42e8ebfc46a8f8e38f6d5df05496597764da9c 100644
--- a/civicrm/CRM/Core/DAO/OptionGroup.php
+++ b/civicrm/CRM/Core/DAO/OptionGroup.php
@@ -106,6 +106,7 @@ class CRM_Core_DAO_OptionGroup extends CRM_Core_DAO {
           'title' => ts('Option Group ID'),
           'description' => ts('Option Group ID'),
           'required' => TRUE,
+          'where' => 'civicrm_option_group.id',
           'table_name' => 'civicrm_option_group',
           'entity' => 'OptionGroup',
           'bao' => 'CRM_Core_BAO_OptionGroup',
@@ -119,6 +120,7 @@ class CRM_Core_DAO_OptionGroup extends CRM_Core_DAO {
           'required' => TRUE,
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_option_group.name',
           'table_name' => 'civicrm_option_group',
           'entity' => 'OptionGroup',
           'bao' => 'CRM_Core_BAO_OptionGroup',
@@ -131,6 +133,7 @@ class CRM_Core_DAO_OptionGroup extends CRM_Core_DAO {
           'description' => ts('Option Group title.'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_option_group.title',
           'table_name' => 'civicrm_option_group',
           'entity' => 'OptionGroup',
           'bao' => 'CRM_Core_BAO_OptionGroup',
@@ -143,6 +146,7 @@ class CRM_Core_DAO_OptionGroup extends CRM_Core_DAO {
           'description' => ts('Option group description.'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_option_group.description',
           'table_name' => 'civicrm_option_group',
           'entity' => 'OptionGroup',
           'bao' => 'CRM_Core_BAO_OptionGroup',
@@ -155,6 +159,7 @@ class CRM_Core_DAO_OptionGroup extends CRM_Core_DAO {
           'description' => ts('Option group description.'),
           'maxlength' => 128,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_option_group.data_type',
           'table_name' => 'civicrm_option_group',
           'entity' => 'OptionGroup',
           'bao' => 'CRM_Core_BAO_OptionGroup',
@@ -169,6 +174,7 @@ class CRM_Core_DAO_OptionGroup extends CRM_Core_DAO {
           'title' => ts('Option Group Is Reserved?'),
           'description' => ts('Is this a predefined system option group (i.e. it can not be deleted)?'),
           'required' => TRUE,
+          'where' => 'civicrm_option_group.is_reserved',
           'default' => '1',
           'table_name' => 'civicrm_option_group',
           'entity' => 'OptionGroup',
@@ -181,6 +187,7 @@ class CRM_Core_DAO_OptionGroup extends CRM_Core_DAO {
           'title' => ts('Option Group Is Active?'),
           'description' => ts('Is this option group active?'),
           'required' => TRUE,
+          'where' => 'civicrm_option_group.is_active',
           'default' => '1',
           'table_name' => 'civicrm_option_group',
           'entity' => 'OptionGroup',
@@ -193,6 +200,7 @@ class CRM_Core_DAO_OptionGroup extends CRM_Core_DAO {
           'title' => ts('Option Group Is Locked'),
           'description' => ts('A lock to remove the ability to add new options via the UI.'),
           'required' => TRUE,
+          'where' => 'civicrm_option_group.is_locked',
           'default' => '0',
           'table_name' => 'civicrm_option_group',
           'entity' => 'OptionGroup',
diff --git a/civicrm/CRM/Core/DAO/OptionValue.php b/civicrm/CRM/Core/DAO/OptionValue.php
index e896d993552e9725478bb8262e3cfacc868fd4d8..2fb21aa4ea2728a3c608994f873d12663b1271d2 100644
--- a/civicrm/CRM/Core/DAO/OptionValue.php
+++ b/civicrm/CRM/Core/DAO/OptionValue.php
@@ -191,6 +191,7 @@ class CRM_Core_DAO_OptionValue extends CRM_Core_DAO {
           'title' => ts('Option Value ID'),
           'description' => ts('Option ID'),
           'required' => TRUE,
+          'where' => 'civicrm_option_value.id',
           'table_name' => 'civicrm_option_value',
           'entity' => 'OptionValue',
           'bao' => 'CRM_Core_BAO_OptionValue',
@@ -202,6 +203,7 @@ class CRM_Core_DAO_OptionValue extends CRM_Core_DAO {
           'title' => ts('Option Group ID'),
           'description' => ts('Group which this option belongs to.'),
           'required' => TRUE,
+          'where' => 'civicrm_option_value.option_group_id',
           'table_name' => 'civicrm_option_value',
           'entity' => 'OptionValue',
           'bao' => 'CRM_Core_BAO_OptionValue',
@@ -224,6 +226,7 @@ class CRM_Core_DAO_OptionValue extends CRM_Core_DAO {
           'required' => TRUE,
           'maxlength' => 512,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_option_value.label',
           'table_name' => 'civicrm_option_value',
           'entity' => 'OptionValue',
           'bao' => 'CRM_Core_BAO_OptionValue',
@@ -237,6 +240,7 @@ class CRM_Core_DAO_OptionValue extends CRM_Core_DAO {
           'required' => TRUE,
           'maxlength' => 512,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_option_value.value',
           'table_name' => 'civicrm_option_value',
           'entity' => 'OptionValue',
           'bao' => 'CRM_Core_BAO_OptionValue',
@@ -251,8 +255,6 @@ class CRM_Core_DAO_OptionValue extends CRM_Core_DAO {
           'size' => CRM_Utils_Type::HUGE,
           'import' => TRUE,
           'where' => 'civicrm_option_value.name',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_option_value',
           'entity' => 'OptionValue',
@@ -266,6 +268,7 @@ class CRM_Core_DAO_OptionValue extends CRM_Core_DAO {
           'description' => ts('Use to sort and/or set display properties for sub-set(s) of options within an option group. EXAMPLE: Use for college_interest field, to differentiate partners from non-partners.'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_option_value.grouping',
           'table_name' => 'civicrm_option_value',
           'entity' => 'OptionValue',
           'bao' => 'CRM_Core_BAO_OptionValue',
@@ -276,6 +279,7 @@ class CRM_Core_DAO_OptionValue extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Filter'),
           'description' => ts('Bitwise logic can be used to create subsets of options within an option_group for different uses.'),
+          'where' => 'civicrm_option_value.filter',
           'table_name' => 'civicrm_option_value',
           'entity' => 'OptionValue',
           'bao' => 'CRM_Core_BAO_OptionValue',
@@ -286,6 +290,7 @@ class CRM_Core_DAO_OptionValue extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Option is Default?'),
           'description' => ts('Is this the default option for the group?'),
+          'where' => 'civicrm_option_value.is_default',
           'default' => '0',
           'table_name' => 'civicrm_option_value',
           'entity' => 'OptionValue',
@@ -298,6 +303,7 @@ class CRM_Core_DAO_OptionValue extends CRM_Core_DAO {
           'title' => ts('Order'),
           'description' => ts('Controls display sort order.'),
           'required' => TRUE,
+          'where' => 'civicrm_option_value.weight',
           'table_name' => 'civicrm_option_value',
           'entity' => 'OptionValue',
           'bao' => 'CRM_Core_BAO_OptionValue',
@@ -310,6 +316,7 @@ class CRM_Core_DAO_OptionValue extends CRM_Core_DAO {
           'description' => ts('Optional description.'),
           'rows' => 8,
           'cols' => 60,
+          'where' => 'civicrm_option_value.description',
           'table_name' => 'civicrm_option_value',
           'entity' => 'OptionValue',
           'bao' => 'CRM_Core_BAO_OptionValue',
@@ -323,6 +330,7 @@ class CRM_Core_DAO_OptionValue extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Option is Header?'),
           'description' => ts('Is this row simply a display header? Expected usage is to render these as OPTGROUP tags within a SELECT field list of options?'),
+          'where' => 'civicrm_option_value.is_optgroup',
           'default' => '0',
           'table_name' => 'civicrm_option_value',
           'entity' => 'OptionValue',
@@ -334,6 +342,7 @@ class CRM_Core_DAO_OptionValue extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Option Is Reserved?'),
           'description' => ts('Is this a predefined system object?'),
+          'where' => 'civicrm_option_value.is_reserved',
           'default' => '0',
           'table_name' => 'civicrm_option_value',
           'entity' => 'OptionValue',
@@ -345,6 +354,7 @@ class CRM_Core_DAO_OptionValue extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Option Is Active'),
           'description' => ts('Is this option active?'),
+          'where' => 'civicrm_option_value.is_active',
           'default' => '1',
           'table_name' => 'civicrm_option_value',
           'entity' => 'OptionValue',
@@ -356,6 +366,7 @@ class CRM_Core_DAO_OptionValue extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Option Component'),
           'description' => ts('Component that this option value belongs/caters to.'),
+          'where' => 'civicrm_option_value.component_id',
           'table_name' => 'civicrm_option_value',
           'entity' => 'OptionValue',
           'bao' => 'CRM_Core_BAO_OptionValue',
@@ -375,6 +386,7 @@ class CRM_Core_DAO_OptionValue extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Option Domain'),
           'description' => ts('Which Domain is this option value for'),
+          'where' => 'civicrm_option_value.domain_id',
           'table_name' => 'civicrm_option_value',
           'entity' => 'OptionValue',
           'bao' => 'CRM_Core_BAO_OptionValue',
@@ -390,6 +402,7 @@ class CRM_Core_DAO_OptionValue extends CRM_Core_DAO {
           'name' => 'visibility_id',
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Option Visibility'),
+          'where' => 'civicrm_option_value.visibility_id',
           'default' => 'NULL',
           'table_name' => 'civicrm_option_value',
           'entity' => 'OptionValue',
@@ -407,6 +420,7 @@ class CRM_Core_DAO_OptionValue extends CRM_Core_DAO {
           'description' => ts('crm-i icon class'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_option_value.icon',
           'default' => 'NULL',
           'table_name' => 'civicrm_option_value',
           'entity' => 'OptionValue',
@@ -420,6 +434,7 @@ class CRM_Core_DAO_OptionValue extends CRM_Core_DAO {
           'description' => ts('Hex color value e.g. #ffffff'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_option_value.color',
           'default' => 'NULL',
           'table_name' => 'civicrm_option_value',
           'entity' => 'OptionValue',
diff --git a/civicrm/CRM/Core/DAO/Persistent.php b/civicrm/CRM/Core/DAO/Persistent.php
index c83bdf6505a949bd934ba5a977f0f64d0bff0e53..3f56e7c6933ad36f18b17a3b733da54f03742c8b 100644
--- a/civicrm/CRM/Core/DAO/Persistent.php
+++ b/civicrm/CRM/Core/DAO/Persistent.php
@@ -85,6 +85,7 @@ class CRM_Core_DAO_Persistent extends CRM_Core_DAO {
           'title' => ts('Persistent ID'),
           'description' => ts('Persistent Record Id'),
           'required' => TRUE,
+          'where' => 'civicrm_persistent.id',
           'table_name' => 'civicrm_persistent',
           'entity' => 'Persistent',
           'bao' => 'CRM_Core_BAO_Persistent',
@@ -98,6 +99,7 @@ class CRM_Core_DAO_Persistent extends CRM_Core_DAO {
           'required' => TRUE,
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_persistent.context',
           'table_name' => 'civicrm_persistent',
           'entity' => 'Persistent',
           'bao' => 'CRM_Core_BAO_Persistent',
@@ -111,6 +113,7 @@ class CRM_Core_DAO_Persistent extends CRM_Core_DAO {
           'required' => TRUE,
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_persistent.name',
           'table_name' => 'civicrm_persistent',
           'entity' => 'Persistent',
           'bao' => 'CRM_Core_BAO_Persistent',
@@ -121,6 +124,7 @@ class CRM_Core_DAO_Persistent extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_LONGTEXT,
           'title' => ts('Data'),
           'description' => ts('data associated with name'),
+          'where' => 'civicrm_persistent.data',
           'table_name' => 'civicrm_persistent',
           'entity' => 'Persistent',
           'bao' => 'CRM_Core_BAO_Persistent',
@@ -132,6 +136,7 @@ class CRM_Core_DAO_Persistent extends CRM_Core_DAO {
           'title' => ts('Is Configuration?'),
           'description' => ts('Config Settings'),
           'required' => TRUE,
+          'where' => 'civicrm_persistent.is_config',
           'default' => '0',
           'table_name' => 'civicrm_persistent',
           'entity' => 'Persistent',
diff --git a/civicrm/CRM/Core/DAO/Phone.php b/civicrm/CRM/Core/DAO/Phone.php
index 002ea1b93c6534adb278a99d5900a58353afc6ca..fce47cfc31ec1f0969174fd0f476f274131b9f0a 100644
--- a/civicrm/CRM/Core/DAO/Phone.php
+++ b/civicrm/CRM/Core/DAO/Phone.php
@@ -135,6 +135,7 @@ class CRM_Core_DAO_Phone extends CRM_Core_DAO {
           'title' => ts('Phone ID'),
           'description' => ts('Unique Phone ID'),
           'required' => TRUE,
+          'where' => 'civicrm_phone.id',
           'table_name' => 'civicrm_phone',
           'entity' => 'Phone',
           'bao' => 'CRM_Core_BAO_Phone',
@@ -145,6 +146,7 @@ class CRM_Core_DAO_Phone extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Phone Contact'),
           'description' => ts('FK to Contact ID'),
+          'where' => 'civicrm_phone.contact_id',
           'table_name' => 'civicrm_phone',
           'entity' => 'Phone',
           'bao' => 'CRM_Core_BAO_Phone',
@@ -156,6 +158,7 @@ class CRM_Core_DAO_Phone extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Phone Location Type'),
           'description' => ts('Which Location does this phone belong to.'),
+          'where' => 'civicrm_phone.location_type_id',
           'table_name' => 'civicrm_phone',
           'entity' => 'Phone',
           'bao' => 'CRM_Core_BAO_Phone',
@@ -174,6 +177,7 @@ class CRM_Core_DAO_Phone extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Is Phone Primary?'),
           'description' => ts('Is this the primary phone for this contact and location.'),
+          'where' => 'civicrm_phone.is_primary',
           'default' => '0',
           'table_name' => 'civicrm_phone',
           'entity' => 'Phone',
@@ -185,6 +189,7 @@ class CRM_Core_DAO_Phone extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Is Billing Phone'),
           'description' => ts('Is this the billing?'),
+          'where' => 'civicrm_phone.is_billing',
           'default' => '0',
           'table_name' => 'civicrm_phone',
           'entity' => 'Phone',
@@ -196,6 +201,7 @@ class CRM_Core_DAO_Phone extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Mobile Provider'),
           'description' => ts('Which Mobile Provider does this phone belong to.'),
+          'where' => 'civicrm_phone.mobile_provider_id',
           'table_name' => 'civicrm_phone',
           'entity' => 'Phone',
           'bao' => 'CRM_Core_BAO_Phone',
@@ -248,6 +254,7 @@ class CRM_Core_DAO_Phone extends CRM_Core_DAO {
           'description' => ts('Phone number stripped of all whitespace, letters, and punctuation.'),
           'maxlength' => 32,
           'size' => CRM_Utils_Type::MEDIUM,
+          'where' => 'civicrm_phone.phone_numeric',
           'table_name' => 'civicrm_phone',
           'entity' => 'Phone',
           'bao' => 'CRM_Core_BAO_Phone',
@@ -258,10 +265,8 @@ class CRM_Core_DAO_Phone extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Phone Type'),
           'description' => ts('Which type of phone does this number belongs.'),
-          'export' => TRUE,
           'where' => 'civicrm_phone.phone_type_id',
-          'headerPattern' => '',
-          'dataPattern' => '',
+          'export' => TRUE,
           'table_name' => 'civicrm_phone',
           'entity' => 'Phone',
           'bao' => 'CRM_Core_BAO_Phone',
diff --git a/civicrm/CRM/Core/DAO/PreferencesDate.php b/civicrm/CRM/Core/DAO/PreferencesDate.php
index 02d3dd355402970ee1e7cb8a0ea193a1f1a5ab3f..45f75c9cc21a7b0738d8de8f506e21f065bca679 100644
--- a/civicrm/CRM/Core/DAO/PreferencesDate.php
+++ b/civicrm/CRM/Core/DAO/PreferencesDate.php
@@ -96,6 +96,7 @@ class CRM_Core_DAO_PreferencesDate extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Date Preference ID'),
           'required' => TRUE,
+          'where' => 'civicrm_preferences_date.id',
           'table_name' => 'civicrm_preferences_date',
           'entity' => 'PreferencesDate',
           'bao' => 'CRM_Core_BAO_PreferencesDate',
@@ -109,6 +110,7 @@ class CRM_Core_DAO_PreferencesDate extends CRM_Core_DAO {
           'required' => TRUE,
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_preferences_date.name',
           'table_name' => 'civicrm_preferences_date',
           'entity' => 'PreferencesDate',
           'bao' => 'CRM_Core_BAO_PreferencesDate',
@@ -121,6 +123,7 @@ class CRM_Core_DAO_PreferencesDate extends CRM_Core_DAO {
           'description' => ts('Description of this date type.'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_preferences_date.description',
           'table_name' => 'civicrm_preferences_date',
           'entity' => 'PreferencesDate',
           'bao' => 'CRM_Core_BAO_PreferencesDate',
@@ -132,6 +135,7 @@ class CRM_Core_DAO_PreferencesDate extends CRM_Core_DAO {
           'title' => ts('Start'),
           'description' => ts('The start offset relative to current year'),
           'required' => TRUE,
+          'where' => 'civicrm_preferences_date.start',
           'table_name' => 'civicrm_preferences_date',
           'entity' => 'PreferencesDate',
           'bao' => 'CRM_Core_BAO_PreferencesDate',
@@ -143,6 +147,7 @@ class CRM_Core_DAO_PreferencesDate extends CRM_Core_DAO {
           'title' => ts('End Offset'),
           'description' => ts('The end offset relative to current year, can be negative'),
           'required' => TRUE,
+          'where' => 'civicrm_preferences_date.end',
           'table_name' => 'civicrm_preferences_date',
           'entity' => 'PreferencesDate',
           'bao' => 'CRM_Core_BAO_PreferencesDate',
@@ -155,6 +160,7 @@ class CRM_Core_DAO_PreferencesDate extends CRM_Core_DAO {
           'description' => ts('The date type'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_preferences_date.date_format',
           'table_name' => 'civicrm_preferences_date',
           'entity' => 'PreferencesDate',
           'bao' => 'CRM_Core_BAO_PreferencesDate',
@@ -167,6 +173,7 @@ class CRM_Core_DAO_PreferencesDate extends CRM_Core_DAO {
           'description' => ts('time format'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_preferences_date.time_format',
           'table_name' => 'civicrm_preferences_date',
           'entity' => 'PreferencesDate',
           'bao' => 'CRM_Core_BAO_PreferencesDate',
diff --git a/civicrm/CRM/Core/DAO/PrevNextCache.php b/civicrm/CRM/Core/DAO/PrevNextCache.php
index 3d878125a88f3e1716cde5f6706cfe8135b75823..9af6dafa8c1d04b96888123800d305a2e455a864 100644
--- a/civicrm/CRM/Core/DAO/PrevNextCache.php
+++ b/civicrm/CRM/Core/DAO/PrevNextCache.php
@@ -94,6 +94,7 @@ class CRM_Core_DAO_PrevNextCache extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Prev Next Cache ID'),
           'required' => TRUE,
+          'where' => 'civicrm_prevnext_cache.id',
           'table_name' => 'civicrm_prevnext_cache',
           'entity' => 'PrevNextCache',
           'bao' => 'CRM_Core_BAO_PrevNextCache',
@@ -106,6 +107,7 @@ class CRM_Core_DAO_PrevNextCache extends CRM_Core_DAO {
           'description' => ts('physical tablename for entity being joined to discount, e.g. civicrm_event'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_prevnext_cache.entity_table',
           'table_name' => 'civicrm_prevnext_cache',
           'entity' => 'PrevNextCache',
           'bao' => 'CRM_Core_BAO_PrevNextCache',
@@ -117,6 +119,7 @@ class CRM_Core_DAO_PrevNextCache extends CRM_Core_DAO {
           'title' => ts('Prev Next Entity ID 1'),
           'description' => ts('FK to entity table specified in entity_table column.'),
           'required' => TRUE,
+          'where' => 'civicrm_prevnext_cache.entity_id1',
           'table_name' => 'civicrm_prevnext_cache',
           'entity' => 'PrevNextCache',
           'bao' => 'CRM_Core_BAO_PrevNextCache',
@@ -128,6 +131,7 @@ class CRM_Core_DAO_PrevNextCache extends CRM_Core_DAO {
           'title' => ts('Prev Next Entity ID 2'),
           'description' => ts('FK to entity table specified in entity_table column.'),
           'required' => FALSE,
+          'where' => 'civicrm_prevnext_cache.entity_id2',
           'table_name' => 'civicrm_prevnext_cache',
           'entity' => 'PrevNextCache',
           'bao' => 'CRM_Core_BAO_PrevNextCache',
@@ -140,6 +144,7 @@ class CRM_Core_DAO_PrevNextCache extends CRM_Core_DAO {
           'description' => ts('Unique path name for cache element of the searched item'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_prevnext_cache.cacheKey',
           'table_name' => 'civicrm_prevnext_cache',
           'entity' => 'PrevNextCache',
           'bao' => 'CRM_Core_BAO_PrevNextCache',
@@ -150,6 +155,7 @@ class CRM_Core_DAO_PrevNextCache extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_LONGTEXT,
           'title' => ts('Prev Next Data'),
           'description' => ts('cached snapshot of the serialized data'),
+          'where' => 'civicrm_prevnext_cache.data',
           'table_name' => 'civicrm_prevnext_cache',
           'entity' => 'PrevNextCache',
           'bao' => 'CRM_Core_BAO_PrevNextCache',
@@ -160,6 +166,7 @@ class CRM_Core_DAO_PrevNextCache extends CRM_Core_DAO {
           'name' => 'is_selected',
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Is Selected'),
+          'where' => 'civicrm_prevnext_cache.is_selected',
           'default' => '0',
           'table_name' => 'civicrm_prevnext_cache',
           'entity' => 'PrevNextCache',
diff --git a/civicrm/CRM/Core/DAO/PrintLabel.php b/civicrm/CRM/Core/DAO/PrintLabel.php
index 5d9e84f6c9966cdcc2a757754d8295e2714b2fae..1f20a3825e1f1ac3cef2df1c9d54bae6c178f254 100644
--- a/civicrm/CRM/Core/DAO/PrintLabel.php
+++ b/civicrm/CRM/Core/DAO/PrintLabel.php
@@ -139,6 +139,7 @@ class CRM_Core_DAO_PrintLabel extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Print Label ID'),
           'required' => TRUE,
+          'where' => 'civicrm_print_label.id',
           'table_name' => 'civicrm_print_label',
           'entity' => 'PrintLabel',
           'bao' => 'CRM_Core_DAO_PrintLabel',
@@ -151,6 +152,7 @@ class CRM_Core_DAO_PrintLabel extends CRM_Core_DAO {
           'description' => ts('User title for for this label layout'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_print_label.title',
           'table_name' => 'civicrm_print_label',
           'entity' => 'PrintLabel',
           'bao' => 'CRM_Core_DAO_PrintLabel',
@@ -163,6 +165,7 @@ class CRM_Core_DAO_PrintLabel extends CRM_Core_DAO {
           'description' => ts('variable name/programmatic handle for this field.'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_print_label.name',
           'table_name' => 'civicrm_print_label',
           'entity' => 'PrintLabel',
           'bao' => 'CRM_Core_DAO_PrintLabel',
@@ -173,6 +176,7 @@ class CRM_Core_DAO_PrintLabel extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_TEXT,
           'title' => ts('Description'),
           'description' => ts('Description of this label layout'),
+          'where' => 'civicrm_print_label.description',
           'table_name' => 'civicrm_print_label',
           'entity' => 'PrintLabel',
           'bao' => 'CRM_Core_DAO_PrintLabel',
@@ -185,6 +189,7 @@ class CRM_Core_DAO_PrintLabel extends CRM_Core_DAO {
           'description' => ts('This refers to name column of civicrm_option_value row in name_badge option group'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_print_label.label_format_name',
           'table_name' => 'civicrm_print_label',
           'entity' => 'PrintLabel',
           'bao' => 'CRM_Core_DAO_PrintLabel',
@@ -202,6 +207,7 @@ class CRM_Core_DAO_PrintLabel extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Label Type'),
           'description' => ts('Implicit FK to civicrm_option_value row in NEW label_type option group'),
+          'where' => 'civicrm_print_label.label_type_id',
           'table_name' => 'civicrm_print_label',
           'entity' => 'PrintLabel',
           'bao' => 'CRM_Core_DAO_PrintLabel',
@@ -219,6 +225,7 @@ class CRM_Core_DAO_PrintLabel extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_LONGTEXT,
           'title' => ts('Data'),
           'description' => ts('contains json encode configurations options'),
+          'where' => 'civicrm_print_label.data',
           'table_name' => 'civicrm_print_label',
           'entity' => 'PrintLabel',
           'bao' => 'CRM_Core_DAO_PrintLabel',
@@ -230,6 +237,7 @@ class CRM_Core_DAO_PrintLabel extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Label is Default?'),
           'description' => ts('Is this default?'),
+          'where' => 'civicrm_print_label.is_default',
           'default' => '1',
           'table_name' => 'civicrm_print_label',
           'entity' => 'PrintLabel',
@@ -241,6 +249,7 @@ class CRM_Core_DAO_PrintLabel extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Label Is Active?'),
           'description' => ts('Is this option active?'),
+          'where' => 'civicrm_print_label.is_active',
           'default' => '1',
           'table_name' => 'civicrm_print_label',
           'entity' => 'PrintLabel',
@@ -252,6 +261,7 @@ class CRM_Core_DAO_PrintLabel extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Is Label Reserved?'),
           'description' => ts('Is this reserved label?'),
+          'where' => 'civicrm_print_label.is_reserved',
           'default' => '1',
           'table_name' => 'civicrm_print_label',
           'entity' => 'PrintLabel',
@@ -263,6 +273,7 @@ class CRM_Core_DAO_PrintLabel extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Label Created By'),
           'description' => ts('FK to civicrm_contact, who created this label layout'),
+          'where' => 'civicrm_print_label.created_id',
           'table_name' => 'civicrm_print_label',
           'entity' => 'PrintLabel',
           'bao' => 'CRM_Core_DAO_PrintLabel',
diff --git a/civicrm/CRM/Core/DAO/RecurringEntity.php b/civicrm/CRM/Core/DAO/RecurringEntity.php
index 0c08cbe3659a3e08fedeebbaf0067d38f08d68d2..9aed7cc925093f763573525b95d5e0ebf312db45 100644
--- a/civicrm/CRM/Core/DAO/RecurringEntity.php
+++ b/civicrm/CRM/Core/DAO/RecurringEntity.php
@@ -82,6 +82,7 @@ class CRM_Core_DAO_RecurringEntity extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('ID'),
           'required' => TRUE,
+          'where' => 'civicrm_recurring_entity.id',
           'table_name' => 'civicrm_recurring_entity',
           'entity' => 'RecurringEntity',
           'bao' => 'CRM_Core_BAO_RecurringEntity',
@@ -93,6 +94,7 @@ class CRM_Core_DAO_RecurringEntity extends CRM_Core_DAO {
           'title' => ts('Parent ID'),
           'description' => ts('Recurring Entity Parent ID'),
           'required' => TRUE,
+          'where' => 'civicrm_recurring_entity.parent_id',
           'table_name' => 'civicrm_recurring_entity',
           'entity' => 'RecurringEntity',
           'bao' => 'CRM_Core_BAO_RecurringEntity',
@@ -103,6 +105,7 @@ class CRM_Core_DAO_RecurringEntity extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Entity ID'),
           'description' => ts('Recurring Entity Child ID'),
+          'where' => 'civicrm_recurring_entity.entity_id',
           'table_name' => 'civicrm_recurring_entity',
           'entity' => 'RecurringEntity',
           'bao' => 'CRM_Core_BAO_RecurringEntity',
@@ -116,6 +119,7 @@ class CRM_Core_DAO_RecurringEntity extends CRM_Core_DAO {
           'required' => TRUE,
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_recurring_entity.entity_table',
           'table_name' => 'civicrm_recurring_entity',
           'entity' => 'RecurringEntity',
           'bao' => 'CRM_Core_BAO_RecurringEntity',
@@ -127,6 +131,7 @@ class CRM_Core_DAO_RecurringEntity extends CRM_Core_DAO {
           'title' => ts('Cascade Type'),
           'description' => ts('1-this entity, 2-this and the following entities, 3-all the entities'),
           'required' => TRUE,
+          'where' => 'civicrm_recurring_entity.mode',
           'default' => '1',
           'table_name' => 'civicrm_recurring_entity',
           'entity' => 'RecurringEntity',
diff --git a/civicrm/CRM/Core/DAO/Setting.php b/civicrm/CRM/Core/DAO/Setting.php
index 7ce962cc08d2b8172e88594c07f4331592fc13d2..5a16f8c65696c5424aa64888a047b55ce9c89076 100644
--- a/civicrm/CRM/Core/DAO/Setting.php
+++ b/civicrm/CRM/Core/DAO/Setting.php
@@ -128,6 +128,7 @@ class CRM_Core_DAO_Setting extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Setting ID'),
           'required' => TRUE,
+          'where' => 'civicrm_setting.id',
           'table_name' => 'civicrm_setting',
           'entity' => 'Setting',
           'bao' => 'CRM_Core_BAO_Setting',
@@ -140,6 +141,7 @@ class CRM_Core_DAO_Setting extends CRM_Core_DAO {
           'description' => ts('Unique name for setting'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_setting.name',
           'table_name' => 'civicrm_setting',
           'entity' => 'Setting',
           'bao' => 'CRM_Core_BAO_Setting',
@@ -150,6 +152,7 @@ class CRM_Core_DAO_Setting extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_TEXT,
           'title' => ts('Value'),
           'description' => ts('data associated with this group / name combo'),
+          'where' => 'civicrm_setting.value',
           'table_name' => 'civicrm_setting',
           'entity' => 'Setting',
           'bao' => 'CRM_Core_BAO_Setting',
@@ -162,6 +165,7 @@ class CRM_Core_DAO_Setting extends CRM_Core_DAO {
           'title' => ts('Setting Domain'),
           'description' => ts('Which Domain is this menu item for'),
           'required' => TRUE,
+          'where' => 'civicrm_setting.domain_id',
           'table_name' => 'civicrm_setting',
           'entity' => 'Setting',
           'bao' => 'CRM_Core_BAO_Setting',
@@ -178,6 +182,7 @@ class CRM_Core_DAO_Setting extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Setting Contact'),
           'description' => ts('FK to Contact ID if the setting is localized to a contact'),
+          'where' => 'civicrm_setting.contact_id',
           'table_name' => 'civicrm_setting',
           'entity' => 'Setting',
           'bao' => 'CRM_Core_BAO_Setting',
@@ -189,6 +194,7 @@ class CRM_Core_DAO_Setting extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Is Domain Setting?'),
           'description' => ts('Is this setting a contact specific or site wide setting?'),
+          'where' => 'civicrm_setting.is_domain',
           'table_name' => 'civicrm_setting',
           'entity' => 'Setting',
           'bao' => 'CRM_Core_BAO_Setting',
@@ -199,6 +205,7 @@ class CRM_Core_DAO_Setting extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Setting Component'),
           'description' => ts('Component that this menu item belongs to'),
+          'where' => 'civicrm_setting.component_id',
           'table_name' => 'civicrm_setting',
           'entity' => 'Setting',
           'bao' => 'CRM_Core_BAO_Setting',
@@ -218,6 +225,7 @@ class CRM_Core_DAO_Setting extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
           'title' => ts('Setting Created Date'),
           'description' => ts('When was the setting created'),
+          'where' => 'civicrm_setting.created_date',
           'table_name' => 'civicrm_setting',
           'entity' => 'Setting',
           'bao' => 'CRM_Core_BAO_Setting',
@@ -228,6 +236,7 @@ class CRM_Core_DAO_Setting extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Setting Created By'),
           'description' => ts('FK to civicrm_contact, who created this setting'),
+          'where' => 'civicrm_setting.created_id',
           'table_name' => 'civicrm_setting',
           'entity' => 'Setting',
           'bao' => 'CRM_Core_BAO_Setting',
diff --git a/civicrm/CRM/Core/DAO/StateProvince.php b/civicrm/CRM/Core/DAO/StateProvince.php
index 345f8eb4c0cae05769e2079fa0e930c3e6036ca2..cb0e4b98ed1e185617880f2c3f71271bb895b9aa 100644
--- a/civicrm/CRM/Core/DAO/StateProvince.php
+++ b/civicrm/CRM/Core/DAO/StateProvince.php
@@ -93,6 +93,7 @@ class CRM_Core_DAO_StateProvince extends CRM_Core_DAO {
           'title' => ts('State ID'),
           'description' => ts('State/Province ID'),
           'required' => TRUE,
+          'where' => 'civicrm_state_province.id',
           'table_name' => 'civicrm_state_province',
           'entity' => 'StateProvince',
           'bao' => 'CRM_Core_DAO_StateProvince',
@@ -122,6 +123,7 @@ class CRM_Core_DAO_StateProvince extends CRM_Core_DAO {
           'description' => ts('2-4 Character Abbreviation of State/Province'),
           'maxlength' => 4,
           'size' => CRM_Utils_Type::FOUR,
+          'where' => 'civicrm_state_province.abbreviation',
           'table_name' => 'civicrm_state_province',
           'entity' => 'StateProvince',
           'bao' => 'CRM_Core_DAO_StateProvince',
@@ -133,6 +135,7 @@ class CRM_Core_DAO_StateProvince extends CRM_Core_DAO {
           'title' => ts('Country'),
           'description' => ts('ID of Country that State/Province belong'),
           'required' => TRUE,
+          'where' => 'civicrm_state_province.country_id',
           'table_name' => 'civicrm_state_province',
           'entity' => 'StateProvince',
           'bao' => 'CRM_Core_DAO_StateProvince',
diff --git a/civicrm/CRM/Core/DAO/StatusPreference.php b/civicrm/CRM/Core/DAO/StatusPreference.php
index 69bdf13503baeef44608deb719d56a0d4a4e2376..c2cd8d97d982ac4bc45b3dfea8afff8240c48127 100644
--- a/civicrm/CRM/Core/DAO/StatusPreference.php
+++ b/civicrm/CRM/Core/DAO/StatusPreference.php
@@ -114,6 +114,7 @@ class CRM_Core_DAO_StatusPreference extends CRM_Core_DAO {
           'title' => ts('Status Preference ID'),
           'description' => ts('Unique Status Preference ID'),
           'required' => TRUE,
+          'where' => 'civicrm_status_pref.id',
           'table_name' => 'civicrm_status_pref',
           'entity' => 'StatusPreference',
           'bao' => 'CRM_Core_BAO_StatusPreference',
@@ -125,6 +126,7 @@ class CRM_Core_DAO_StatusPreference extends CRM_Core_DAO {
           'title' => ts('Setting Domain'),
           'description' => ts('Which Domain is this Status Preference for'),
           'required' => TRUE,
+          'where' => 'civicrm_status_pref.domain_id',
           'table_name' => 'civicrm_status_pref',
           'entity' => 'StatusPreference',
           'bao' => 'CRM_Core_BAO_StatusPreference',
@@ -146,8 +148,6 @@ class CRM_Core_DAO_StatusPreference extends CRM_Core_DAO {
           'size' => CRM_Utils_Type::HUGE,
           'import' => TRUE,
           'where' => 'civicrm_status_pref.name',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_status_pref',
           'entity' => 'StatusPreference',
@@ -161,8 +161,6 @@ class CRM_Core_DAO_StatusPreference extends CRM_Core_DAO {
           'description' => ts('expires ignore_severity.  NULL never hushes.'),
           'import' => TRUE,
           'where' => 'civicrm_status_pref.hush_until',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'default' => 'NULL',
           'table_name' => 'civicrm_status_pref',
@@ -177,8 +175,6 @@ class CRM_Core_DAO_StatusPreference extends CRM_Core_DAO {
           'description' => ts('Hush messages up to and including this severity.'),
           'import' => TRUE,
           'where' => 'civicrm_status_pref.ignore_severity',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'default' => '1',
           'table_name' => 'civicrm_status_pref',
@@ -196,6 +192,7 @@ class CRM_Core_DAO_StatusPreference extends CRM_Core_DAO {
           'description' => ts('These settings are per-check, and can\'t be compared across checks.'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_status_pref.prefs',
           'table_name' => 'civicrm_status_pref',
           'entity' => 'StatusPreference',
           'bao' => 'CRM_Core_BAO_StatusPreference',
@@ -208,6 +205,7 @@ class CRM_Core_DAO_StatusPreference extends CRM_Core_DAO {
           'description' => ts('These values are per-check, and can\'t be compared across checks.'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_status_pref.check_info',
           'table_name' => 'civicrm_status_pref',
           'entity' => 'StatusPreference',
           'bao' => 'CRM_Core_BAO_StatusPreference',
diff --git a/civicrm/CRM/Core/DAO/SystemLog.php b/civicrm/CRM/Core/DAO/SystemLog.php
index 2090dd18dda7e4c9c77ceb22e71a3ea35bde266a..f3c7e8817f93ea73a4ae54072a5268f0b2796e15 100644
--- a/civicrm/CRM/Core/DAO/SystemLog.php
+++ b/civicrm/CRM/Core/DAO/SystemLog.php
@@ -99,6 +99,7 @@ class CRM_Core_DAO_SystemLog extends CRM_Core_DAO {
           'title' => ts('System Log ID'),
           'description' => ts('Primary key ID'),
           'required' => TRUE,
+          'where' => 'civicrm_system_log.id',
           'table_name' => 'civicrm_system_log',
           'entity' => 'SystemLog',
           'bao' => 'CRM_Core_DAO_SystemLog',
@@ -112,6 +113,7 @@ class CRM_Core_DAO_SystemLog extends CRM_Core_DAO {
           'required' => TRUE,
           'maxlength' => 128,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_system_log.message',
           'table_name' => 'civicrm_system_log',
           'entity' => 'SystemLog',
           'bao' => 'CRM_Core_DAO_SystemLog',
@@ -122,6 +124,7 @@ class CRM_Core_DAO_SystemLog extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_LONGTEXT,
           'title' => ts('Detailed Log Data'),
           'description' => ts('JSON encoded data'),
+          'where' => 'civicrm_system_log.context',
           'table_name' => 'civicrm_system_log',
           'entity' => 'SystemLog',
           'bao' => 'CRM_Core_DAO_SystemLog',
@@ -134,6 +137,7 @@ class CRM_Core_DAO_SystemLog extends CRM_Core_DAO {
           'description' => ts('error level per PSR3'),
           'maxlength' => 9,
           'size' => CRM_Utils_Type::TWELVE,
+          'where' => 'civicrm_system_log.level',
           'default' => 'info',
           'table_name' => 'civicrm_system_log',
           'entity' => 'SystemLog',
@@ -145,6 +149,7 @@ class CRM_Core_DAO_SystemLog extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_TIMESTAMP,
           'title' => ts('Log Timestamp'),
           'description' => ts('Timestamp of when event occurred.'),
+          'where' => 'civicrm_system_log.timestamp',
           'default' => 'CURRENT_TIMESTAMP',
           'table_name' => 'civicrm_system_log',
           'entity' => 'SystemLog',
@@ -156,6 +161,7 @@ class CRM_Core_DAO_SystemLog extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Log Contact ID'),
           'description' => ts('Optional Contact ID that created the log. Not an FK as we keep this regardless'),
+          'where' => 'civicrm_system_log.contact_id',
           'table_name' => 'civicrm_system_log',
           'entity' => 'SystemLog',
           'bao' => 'CRM_Core_DAO_SystemLog',
@@ -168,6 +174,7 @@ class CRM_Core_DAO_SystemLog extends CRM_Core_DAO {
           'description' => ts('Optional Name of logging host'),
           'maxlength' => 128,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_system_log.hostname',
           'table_name' => 'civicrm_system_log',
           'entity' => 'SystemLog',
           'bao' => 'CRM_Core_DAO_SystemLog',
diff --git a/civicrm/CRM/Core/DAO/Tag.php b/civicrm/CRM/Core/DAO/Tag.php
index bb716b17461d873195ab5b88d33a95f51ddf740e..24fc209c681bd70898a7d69f436955c2c9387d68 100644
--- a/civicrm/CRM/Core/DAO/Tag.php
+++ b/civicrm/CRM/Core/DAO/Tag.php
@@ -6,7 +6,7 @@
  *
  * Generated from xml/schema/CRM/Core/Tag.xml
  * DO NOT EDIT.  Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:e66cd3973c4f223dd201904b3c59b233)
+ * (GenCodeChecksum:8c816585b0863674074b4aaf5c644cab)
  */
 
 /**
@@ -137,6 +137,7 @@ class CRM_Core_DAO_Tag extends CRM_Core_DAO {
           'title' => ts('Tag ID'),
           'description' => ts('Tag ID'),
           'required' => TRUE,
+          'where' => 'civicrm_tag.id',
           'table_name' => 'civicrm_tag',
           'entity' => 'Tag',
           'bao' => 'CRM_Core_BAO_Tag',
@@ -150,6 +151,7 @@ class CRM_Core_DAO_Tag extends CRM_Core_DAO {
           'required' => TRUE,
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_tag.name',
           'table_name' => 'civicrm_tag',
           'entity' => 'Tag',
           'bao' => 'CRM_Core_BAO_Tag',
@@ -162,6 +164,7 @@ class CRM_Core_DAO_Tag extends CRM_Core_DAO {
           'description' => ts('Optional verbose description of the tag.'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_tag.description',
           'table_name' => 'civicrm_tag',
           'entity' => 'Tag',
           'bao' => 'CRM_Core_BAO_Tag',
@@ -172,6 +175,7 @@ class CRM_Core_DAO_Tag extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Parent Tag'),
           'description' => ts('Optional parent id for this tag.'),
+          'where' => 'civicrm_tag.parent_id',
           'default' => 'NULL',
           'table_name' => 'civicrm_tag',
           'entity' => 'Tag',
@@ -184,6 +188,7 @@ class CRM_Core_DAO_Tag extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Display Tag?'),
           'description' => ts('Is this tag selectable / displayed'),
+          'where' => 'civicrm_tag.is_selectable',
           'default' => '1',
           'table_name' => 'civicrm_tag',
           'entity' => 'Tag',
@@ -194,6 +199,7 @@ class CRM_Core_DAO_Tag extends CRM_Core_DAO {
           'name' => 'is_reserved',
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Reserved'),
+          'where' => 'civicrm_tag.is_reserved',
           'default' => '0',
           'table_name' => 'civicrm_tag',
           'entity' => 'Tag',
@@ -204,6 +210,7 @@ class CRM_Core_DAO_Tag extends CRM_Core_DAO {
           'name' => 'is_tagset',
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Tagset'),
+          'where' => 'civicrm_tag.is_tagset',
           'default' => '0',
           'table_name' => 'civicrm_tag',
           'entity' => 'Tag',
@@ -216,11 +223,13 @@ class CRM_Core_DAO_Tag extends CRM_Core_DAO {
           'title' => ts('Used For'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_tag.used_for',
           'default' => 'NULL',
           'table_name' => 'civicrm_tag',
           'entity' => 'Tag',
           'bao' => 'CRM_Core_BAO_Tag',
           'localizable' => 0,
+          'serialize' => self::SERIALIZE_COMMA,
           'html' => [
             'type' => 'Select',
           ],
@@ -234,6 +243,7 @@ class CRM_Core_DAO_Tag extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Tag Created By'),
           'description' => ts('FK to civicrm_contact, who created this tag'),
+          'where' => 'civicrm_tag.created_id',
           'table_name' => 'civicrm_tag',
           'entity' => 'Tag',
           'bao' => 'CRM_Core_BAO_Tag',
@@ -247,6 +257,7 @@ class CRM_Core_DAO_Tag extends CRM_Core_DAO {
           'description' => ts('Hex color value e.g. #ffffff'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_tag.color',
           'default' => 'NULL',
           'table_name' => 'civicrm_tag',
           'entity' => 'Tag',
@@ -258,6 +269,7 @@ class CRM_Core_DAO_Tag extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
           'title' => ts('Tag Created Date'),
           'description' => ts('Date and time that tag was created.'),
+          'where' => 'civicrm_tag.created_date',
           'table_name' => 'civicrm_tag',
           'entity' => 'Tag',
           'bao' => 'CRM_Core_BAO_Tag',
diff --git a/civicrm/CRM/Core/DAO/Timezone.php b/civicrm/CRM/Core/DAO/Timezone.php
index 3b75fab08927f403d9a357447adce432d15847f4..91418a1c74dcea0fa71d23b1e194936d78375f95 100644
--- a/civicrm/CRM/Core/DAO/Timezone.php
+++ b/civicrm/CRM/Core/DAO/Timezone.php
@@ -105,6 +105,7 @@ class CRM_Core_DAO_Timezone extends CRM_Core_DAO {
           'title' => ts('Timezone ID'),
           'description' => ts('Timezone Id'),
           'required' => TRUE,
+          'where' => 'civicrm_timezone.id',
           'table_name' => 'civicrm_timezone',
           'entity' => 'Timezone',
           'bao' => 'CRM_Core_DAO_Timezone',
@@ -117,6 +118,7 @@ class CRM_Core_DAO_Timezone extends CRM_Core_DAO {
           'description' => ts('Timezone full name'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_timezone.name',
           'table_name' => 'civicrm_timezone',
           'entity' => 'Timezone',
           'bao' => 'CRM_Core_DAO_Timezone',
@@ -129,6 +131,7 @@ class CRM_Core_DAO_Timezone extends CRM_Core_DAO {
           'description' => ts('ISO Code for timezone abbreviation'),
           'maxlength' => 3,
           'size' => CRM_Utils_Type::FOUR,
+          'where' => 'civicrm_timezone.abbreviation',
           'table_name' => 'civicrm_timezone',
           'entity' => 'Timezone',
           'bao' => 'CRM_Core_DAO_Timezone',
@@ -141,6 +144,7 @@ class CRM_Core_DAO_Timezone extends CRM_Core_DAO {
           'description' => ts('GMT name of the timezone'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_timezone.gmt',
           'table_name' => 'civicrm_timezone',
           'entity' => 'Timezone',
           'bao' => 'CRM_Core_DAO_Timezone',
@@ -150,6 +154,7 @@ class CRM_Core_DAO_Timezone extends CRM_Core_DAO {
           'name' => 'offset',
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('GMT Offset'),
+          'where' => 'civicrm_timezone.offset',
           'table_name' => 'civicrm_timezone',
           'entity' => 'Timezone',
           'bao' => 'CRM_Core_DAO_Timezone',
@@ -161,6 +166,7 @@ class CRM_Core_DAO_Timezone extends CRM_Core_DAO {
           'title' => ts('Country'),
           'description' => ts('Country Id'),
           'required' => TRUE,
+          'where' => 'civicrm_timezone.country_id',
           'table_name' => 'civicrm_timezone',
           'entity' => 'Timezone',
           'bao' => 'CRM_Core_DAO_Timezone',
diff --git a/civicrm/CRM/Core/DAO/UFField.php b/civicrm/CRM/Core/DAO/UFField.php
index 9befc7fab51ba23d2a1203c47eb3a16c3b795cd0..5d6c9183e4e0f078de3c45a5812a11d196ac8083 100644
--- a/civicrm/CRM/Core/DAO/UFField.php
+++ b/civicrm/CRM/Core/DAO/UFField.php
@@ -6,7 +6,7 @@
  *
  * Generated from xml/schema/CRM/Core/UFField.xml
  * DO NOT EDIT.  Generated by CRM_Core_CodeGen
- * (GenCodeChecksum:efbfbe95aac7abe98b31ab715965b57f)
+ * (GenCodeChecksum:3acfd1d2bd5f1e54f8aee7f96328cb58)
  */
 
 /**
@@ -199,6 +199,7 @@ class CRM_Core_DAO_UFField extends CRM_Core_DAO {
           'title' => ts('Profile Field ID'),
           'description' => ts('Unique table ID'),
           'required' => TRUE,
+          'where' => 'civicrm_uf_field.id',
           'table_name' => 'civicrm_uf_field',
           'entity' => 'UFField',
           'bao' => 'CRM_Core_BAO_UFField',
@@ -210,6 +211,7 @@ class CRM_Core_DAO_UFField extends CRM_Core_DAO {
           'title' => ts('Profile ID'),
           'description' => ts('Which form does this field belong to.'),
           'required' => TRUE,
+          'where' => 'civicrm_uf_field.uf_group_id',
           'table_name' => 'civicrm_uf_field',
           'entity' => 'UFField',
           'bao' => 'CRM_Core_BAO_UFField',
@@ -232,16 +234,21 @@ class CRM_Core_DAO_UFField extends CRM_Core_DAO {
           'required' => TRUE,
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_uf_field.field_name',
           'table_name' => 'civicrm_uf_field',
           'entity' => 'UFField',
           'bao' => 'CRM_Core_BAO_UFField',
           'localizable' => 0,
+          'pseudoconstant' => [
+            'callback' => 'CRM_Core_BAO_UFField::getAvailableFieldTitles',
+          ]
         ],
         'is_active' => [
           'name' => 'is_active',
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Profile Field Is Active'),
           'description' => ts('Is this field currently shareable? If false, hide the field for all sharing contexts.'),
+          'where' => 'civicrm_uf_field.is_active',
           'default' => '1',
           'table_name' => 'civicrm_uf_field',
           'entity' => 'UFField',
@@ -253,6 +260,7 @@ class CRM_Core_DAO_UFField extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Profile Is View Only'),
           'description' => ts('the field is view only and not editable in user forms.'),
+          'where' => 'civicrm_uf_field.is_view',
           'default' => '0',
           'table_name' => 'civicrm_uf_field',
           'entity' => 'UFField',
@@ -264,6 +272,7 @@ class CRM_Core_DAO_UFField extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Profile Field Is Required'),
           'description' => ts('Is this field required when included in a user or registration form?'),
+          'where' => 'civicrm_uf_field.is_required',
           'default' => '0',
           'table_name' => 'civicrm_uf_field',
           'entity' => 'UFField',
@@ -276,6 +285,7 @@ class CRM_Core_DAO_UFField extends CRM_Core_DAO {
           'title' => ts('Order'),
           'description' => ts('Controls field display order when user framework fields are displayed in registration and account editing forms.'),
           'required' => TRUE,
+          'where' => 'civicrm_uf_field.weight',
           'default' => '1',
           'table_name' => 'civicrm_uf_field',
           'entity' => 'UFField',
@@ -287,6 +297,7 @@ class CRM_Core_DAO_UFField extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_TEXT,
           'title' => ts('Profile Field Post Help'),
           'description' => ts('Description and/or help text to display after this field.'),
+          'where' => 'civicrm_uf_field.help_post',
           'table_name' => 'civicrm_uf_field',
           'entity' => 'UFField',
           'bao' => 'CRM_Core_BAO_UFField',
@@ -297,6 +308,7 @@ class CRM_Core_DAO_UFField extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_TEXT,
           'title' => ts('Profile Field Pre Help'),
           'description' => ts('Description and/or help text to display before this field.'),
+          'where' => 'civicrm_uf_field.help_pre',
           'table_name' => 'civicrm_uf_field',
           'entity' => 'UFField',
           'bao' => 'CRM_Core_BAO_UFField',
@@ -309,6 +321,7 @@ class CRM_Core_DAO_UFField extends CRM_Core_DAO {
           'description' => ts('In what context(s) is this field visible.'),
           'maxlength' => 32,
           'size' => CRM_Utils_Type::MEDIUM,
+          'where' => 'civicrm_uf_field.visibility',
           'default' => 'User and User Admin Only',
           'table_name' => 'civicrm_uf_field',
           'entity' => 'UFField',
@@ -326,6 +339,7 @@ class CRM_Core_DAO_UFField extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Profile Field Is a Filter'),
           'description' => ts('Is this field included as a column in the selector table?'),
+          'where' => 'civicrm_uf_field.in_selector',
           'default' => '0',
           'table_name' => 'civicrm_uf_field',
           'entity' => 'UFField',
@@ -337,6 +351,7 @@ class CRM_Core_DAO_UFField extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Profile Field Is Searchable'),
           'description' => ts('Is this field included search form of profile?'),
+          'where' => 'civicrm_uf_field.is_searchable',
           'default' => '0',
           'table_name' => 'civicrm_uf_field',
           'entity' => 'UFField',
@@ -348,6 +363,7 @@ class CRM_Core_DAO_UFField extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Profile Field Location Type'),
           'description' => ts('Location type of this mapping, if required'),
+          'where' => 'civicrm_uf_field.location_type_id',
           'table_name' => 'civicrm_uf_field',
           'entity' => 'UFField',
           'bao' => 'CRM_Core_BAO_UFField',
@@ -359,6 +375,7 @@ class CRM_Core_DAO_UFField extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Profile Field Phone Type'),
           'description' => ts('Phone Type Id, if required'),
+          'where' => 'civicrm_uf_field.phone_type_id',
           'table_name' => 'civicrm_uf_field',
           'entity' => 'UFField',
           'bao' => 'CRM_Core_BAO_UFField',
@@ -373,6 +390,7 @@ class CRM_Core_DAO_UFField extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Profile Field Website Type'),
           'description' => ts('Website Type Id, if required'),
+          'where' => 'civicrm_uf_field.website_type_id',
           'table_name' => 'civicrm_uf_field',
           'entity' => 'UFField',
           'bao' => 'CRM_Core_BAO_UFField',
@@ -390,6 +408,7 @@ class CRM_Core_DAO_UFField extends CRM_Core_DAO {
           'required' => TRUE,
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_uf_field.label',
           'table_name' => 'civicrm_uf_field',
           'entity' => 'UFField',
           'bao' => 'CRM_Core_BAO_UFField',
@@ -402,6 +421,7 @@ class CRM_Core_DAO_UFField extends CRM_Core_DAO {
           'description' => ts('This field saves field type (ie individual,household.. field etc).'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_uf_field.field_type',
           'table_name' => 'civicrm_uf_field',
           'entity' => 'UFField',
           'bao' => 'CRM_Core_BAO_UFField',
@@ -412,6 +432,7 @@ class CRM_Core_DAO_UFField extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Profile Field Is Reserved'),
           'description' => ts('Is this field reserved for use by some other CiviCRM functionality?'),
+          'where' => 'civicrm_uf_field.is_reserved',
           'table_name' => 'civicrm_uf_field',
           'entity' => 'UFField',
           'bao' => 'CRM_Core_BAO_UFField',
@@ -422,6 +443,7 @@ class CRM_Core_DAO_UFField extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Profile Field Supports Multiple'),
           'description' => ts('Include in multi-record listing?'),
+          'where' => 'civicrm_uf_field.is_multi_summary',
           'default' => '0',
           'table_name' => 'civicrm_uf_field',
           'entity' => 'UFField',
diff --git a/civicrm/CRM/Core/DAO/UFGroup.php b/civicrm/CRM/Core/DAO/UFGroup.php
index c3d7c543358bc9835d57ab0470b10e47e654479d..290ed5b3b17e654f35e485d7c69f088035e0e58e 100644
--- a/civicrm/CRM/Core/DAO/UFGroup.php
+++ b/civicrm/CRM/Core/DAO/UFGroup.php
@@ -254,6 +254,7 @@ class CRM_Core_DAO_UFGroup extends CRM_Core_DAO {
           'title' => ts('Profile ID'),
           'description' => ts('Unique table ID'),
           'required' => TRUE,
+          'where' => 'civicrm_uf_group.id',
           'table_name' => 'civicrm_uf_group',
           'entity' => 'UFGroup',
           'bao' => 'CRM_Core_BAO_UFGroup',
@@ -264,6 +265,7 @@ class CRM_Core_DAO_UFGroup extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Profile Is Active'),
           'description' => ts('Is this form currently active? If false, hide all related fields for all sharing contexts.'),
+          'where' => 'civicrm_uf_group.is_active',
           'default' => '1',
           'table_name' => 'civicrm_uf_group',
           'entity' => 'UFGroup',
@@ -279,8 +281,6 @@ class CRM_Core_DAO_UFGroup extends CRM_Core_DAO {
           'size' => CRM_Utils_Type::HUGE,
           'import' => TRUE,
           'where' => 'civicrm_uf_group.group_type',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_uf_group',
           'entity' => 'UFGroup',
@@ -296,6 +296,7 @@ class CRM_Core_DAO_UFGroup extends CRM_Core_DAO {
           'required' => TRUE,
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_uf_group.title',
           'table_name' => 'civicrm_uf_group',
           'entity' => 'UFGroup',
           'bao' => 'CRM_Core_BAO_UFGroup',
@@ -311,6 +312,7 @@ class CRM_Core_DAO_UFGroup extends CRM_Core_DAO {
           'description' => ts('Profile Form Public title'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_uf_group.frontend_title',
           'table_name' => 'civicrm_uf_group',
           'entity' => 'UFGroup',
           'bao' => 'CRM_Core_BAO_UFGroup',
@@ -326,6 +328,7 @@ class CRM_Core_DAO_UFGroup extends CRM_Core_DAO {
           'description' => ts('Optional verbose description of the profile.'),
           'rows' => 2,
           'cols' => 60,
+          'where' => 'civicrm_uf_group.description',
           'table_name' => 'civicrm_uf_group',
           'entity' => 'UFGroup',
           'bao' => 'CRM_Core_BAO_UFGroup',
@@ -341,6 +344,7 @@ class CRM_Core_DAO_UFGroup extends CRM_Core_DAO {
           'description' => ts('Description and/or help text to display before fields in form.'),
           'rows' => 4,
           'cols' => 80,
+          'where' => 'civicrm_uf_group.help_pre',
           'table_name' => 'civicrm_uf_group',
           'entity' => 'UFGroup',
           'bao' => 'CRM_Core_BAO_UFGroup',
@@ -356,6 +360,7 @@ class CRM_Core_DAO_UFGroup extends CRM_Core_DAO {
           'description' => ts('Description and/or help text to display after fields in form.'),
           'rows' => 4,
           'cols' => 80,
+          'where' => 'civicrm_uf_group.help_post',
           'table_name' => 'civicrm_uf_group',
           'entity' => 'UFGroup',
           'bao' => 'CRM_Core_BAO_UFGroup',
@@ -369,6 +374,7 @@ class CRM_Core_DAO_UFGroup extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Profile Search Limit Group'),
           'description' => ts('Group id, foreign key from civicrm_group'),
+          'where' => 'civicrm_uf_group.limit_listings_group_id',
           'table_name' => 'civicrm_uf_group',
           'entity' => 'UFGroup',
           'bao' => 'CRM_Core_BAO_UFGroup',
@@ -382,6 +388,7 @@ class CRM_Core_DAO_UFGroup extends CRM_Core_DAO {
           'description' => ts('Redirect to URL.'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_uf_group.post_URL',
           'table_name' => 'civicrm_uf_group',
           'entity' => 'UFGroup',
           'bao' => 'CRM_Core_BAO_UFGroup',
@@ -392,6 +399,7 @@ class CRM_Core_DAO_UFGroup extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Add Contact To Group'),
           'description' => ts('foreign key to civicrm_group_id'),
+          'where' => 'civicrm_uf_group.add_to_group_id',
           'table_name' => 'civicrm_uf_group',
           'entity' => 'UFGroup',
           'bao' => 'CRM_Core_BAO_UFGroup',
@@ -403,6 +411,7 @@ class CRM_Core_DAO_UFGroup extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Show Captcha On Profile'),
           'description' => ts('Should a CAPTCHA widget be included this Profile form.'),
+          'where' => 'civicrm_uf_group.add_captcha',
           'default' => '0',
           'table_name' => 'civicrm_uf_group',
           'entity' => 'UFGroup',
@@ -414,6 +423,7 @@ class CRM_Core_DAO_UFGroup extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Map Profile'),
           'description' => ts('Do we want to map results from this profile.'),
+          'where' => 'civicrm_uf_group.is_map',
           'default' => '0',
           'table_name' => 'civicrm_uf_group',
           'entity' => 'UFGroup',
@@ -425,6 +435,7 @@ class CRM_Core_DAO_UFGroup extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Show Edit Link?'),
           'description' => ts('Should edit link display in profile selector'),
+          'where' => 'civicrm_uf_group.is_edit_link',
           'default' => '0',
           'table_name' => 'civicrm_uf_group',
           'entity' => 'UFGroup',
@@ -436,6 +447,7 @@ class CRM_Core_DAO_UFGroup extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Show Link to CMS User'),
           'description' => ts('Should we display a link to the website profile in profile selector'),
+          'where' => 'civicrm_uf_group.is_uf_link',
           'default' => '0',
           'table_name' => 'civicrm_uf_group',
           'entity' => 'UFGroup',
@@ -447,6 +459,7 @@ class CRM_Core_DAO_UFGroup extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Update on Duplicate'),
           'description' => ts('Should we update the contact record if we find a duplicate'),
+          'where' => 'civicrm_uf_group.is_update_dupe',
           'default' => '0',
           'table_name' => 'civicrm_uf_group',
           'entity' => 'UFGroup',
@@ -460,6 +473,7 @@ class CRM_Core_DAO_UFGroup extends CRM_Core_DAO {
           'description' => ts('Redirect to URL when Cancle button clik .'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_uf_group.cancel_URL',
           'table_name' => 'civicrm_uf_group',
           'entity' => 'UFGroup',
           'bao' => 'CRM_Core_BAO_UFGroup',
@@ -470,6 +484,7 @@ class CRM_Core_DAO_UFGroup extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Create CMS User?'),
           'description' => ts('Should we create a cms user for this profile '),
+          'where' => 'civicrm_uf_group.is_cms_user',
           'default' => '0',
           'table_name' => 'civicrm_uf_group',
           'entity' => 'UFGroup',
@@ -480,6 +495,7 @@ class CRM_Core_DAO_UFGroup extends CRM_Core_DAO {
           'name' => 'notify',
           'type' => CRM_Utils_Type::T_TEXT,
           'title' => ts('Notify on Profile Submit'),
+          'where' => 'civicrm_uf_group.notify',
           'table_name' => 'civicrm_uf_group',
           'entity' => 'UFGroup',
           'bao' => 'CRM_Core_BAO_UFGroup',
@@ -490,6 +506,7 @@ class CRM_Core_DAO_UFGroup extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Profile Is Reserved'),
           'description' => ts('Is this group reserved for use by some other CiviCRM functionality?'),
+          'where' => 'civicrm_uf_group.is_reserved',
           'table_name' => 'civicrm_uf_group',
           'entity' => 'UFGroup',
           'bao' => 'CRM_Core_BAO_UFGroup',
@@ -502,6 +519,7 @@ class CRM_Core_DAO_UFGroup extends CRM_Core_DAO {
           'description' => ts('Name of the UF group for directly addressing it in the codebase'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_uf_group.name',
           'table_name' => 'civicrm_uf_group',
           'entity' => 'UFGroup',
           'bao' => 'CRM_Core_BAO_UFGroup',
@@ -512,6 +530,7 @@ class CRM_Core_DAO_UFGroup extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Profile Created By'),
           'description' => ts('FK to civicrm_contact, who created this UF group'),
+          'where' => 'civicrm_uf_group.created_id',
           'table_name' => 'civicrm_uf_group',
           'entity' => 'UFGroup',
           'bao' => 'CRM_Core_BAO_UFGroup',
@@ -523,6 +542,7 @@ class CRM_Core_DAO_UFGroup extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
           'title' => ts('UF Group Created Date'),
           'description' => ts('Date and time this UF group was created.'),
+          'where' => 'civicrm_uf_group.created_date',
           'table_name' => 'civicrm_uf_group',
           'entity' => 'UFGroup',
           'bao' => 'CRM_Core_BAO_UFGroup',
@@ -533,6 +553,7 @@ class CRM_Core_DAO_UFGroup extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Include Proximity Search?'),
           'description' => ts('Should we include proximity search feature in this profile search form?'),
+          'where' => 'civicrm_uf_group.is_proximity_search',
           'default' => '0',
           'table_name' => 'civicrm_uf_group',
           'entity' => 'UFGroup',
@@ -546,6 +567,7 @@ class CRM_Core_DAO_UFGroup extends CRM_Core_DAO {
           'description' => ts('Custom Text to display on the Cancel button when used in create or edit mode'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_uf_group.cancel_button_text',
           'default' => 'NULL',
           'table_name' => 'civicrm_uf_group',
           'entity' => 'UFGroup',
@@ -562,6 +584,7 @@ class CRM_Core_DAO_UFGroup extends CRM_Core_DAO {
           'description' => ts('Custom Text to display on the submit button on profile edit/create screens'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_uf_group.submit_button_text',
           'default' => 'NULL',
           'table_name' => 'civicrm_uf_group',
           'entity' => 'UFGroup',
@@ -576,6 +599,7 @@ class CRM_Core_DAO_UFGroup extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Include Cancel Button'),
           'description' => ts('Should a Cancel button be included in this Profile form.'),
+          'where' => 'civicrm_uf_group.add_cancel_button',
           'default' => '1',
           'table_name' => 'civicrm_uf_group',
           'entity' => 'UFGroup',
diff --git a/civicrm/CRM/Core/DAO/UFJoin.php b/civicrm/CRM/Core/DAO/UFJoin.php
index eaa94f4a9a07febaec157728698dd1671a6c47f1..2f940a4d74a38c5afe2aff3638789ecb8188276b 100644
--- a/civicrm/CRM/Core/DAO/UFJoin.php
+++ b/civicrm/CRM/Core/DAO/UFJoin.php
@@ -122,6 +122,7 @@ class CRM_Core_DAO_UFJoin extends CRM_Core_DAO {
           'title' => ts('UF Join ID'),
           'description' => ts('Unique table ID'),
           'required' => TRUE,
+          'where' => 'civicrm_uf_join.id',
           'table_name' => 'civicrm_uf_join',
           'entity' => 'UFJoin',
           'bao' => 'CRM_Core_BAO_UFJoin',
@@ -132,6 +133,7 @@ class CRM_Core_DAO_UFJoin extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Profile Use is active'),
           'description' => ts('Is this join currently active?'),
+          'where' => 'civicrm_uf_join.is_active',
           'default' => '1',
           'table_name' => 'civicrm_uf_join',
           'entity' => 'UFJoin',
@@ -146,6 +148,7 @@ class CRM_Core_DAO_UFJoin extends CRM_Core_DAO {
           'required' => TRUE,
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_uf_join.module',
           'table_name' => 'civicrm_uf_join',
           'entity' => 'UFJoin',
           'bao' => 'CRM_Core_BAO_UFJoin',
@@ -158,6 +161,7 @@ class CRM_Core_DAO_UFJoin extends CRM_Core_DAO {
           'description' => ts('Name of table where item being referenced is stored. Modules which only need a single collection of uf_join instances may choose not to populate entity_table and entity_id.'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_uf_join.entity_table',
           'table_name' => 'civicrm_uf_join',
           'entity' => 'UFJoin',
           'bao' => 'CRM_Core_BAO_UFJoin',
@@ -171,6 +175,7 @@ class CRM_Core_DAO_UFJoin extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Profile Entity ID'),
           'description' => ts('Foreign key to the referenced item.'),
+          'where' => 'civicrm_uf_join.entity_id',
           'table_name' => 'civicrm_uf_join',
           'entity' => 'UFJoin',
           'bao' => 'CRM_Core_BAO_UFJoin',
@@ -182,6 +187,7 @@ class CRM_Core_DAO_UFJoin extends CRM_Core_DAO {
           'title' => ts('Order'),
           'description' => ts('Controls display order when multiple user framework groups are setup for concurrent display.'),
           'required' => TRUE,
+          'where' => 'civicrm_uf_join.weight',
           'default' => '1',
           'table_name' => 'civicrm_uf_join',
           'entity' => 'UFJoin',
@@ -194,6 +200,7 @@ class CRM_Core_DAO_UFJoin extends CRM_Core_DAO {
           'title' => ts('Profile ID'),
           'description' => ts('Which form does this field belong to.'),
           'required' => TRUE,
+          'where' => 'civicrm_uf_join.uf_group_id',
           'table_name' => 'civicrm_uf_join',
           'entity' => 'UFJoin',
           'bao' => 'CRM_Core_BAO_UFJoin',
@@ -213,6 +220,7 @@ class CRM_Core_DAO_UFJoin extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_LONGTEXT,
           'title' => ts('Profile Use Data'),
           'description' => ts('Json serialized array of data used by the ufjoin.module'),
+          'where' => 'civicrm_uf_join.module_data',
           'table_name' => 'civicrm_uf_join',
           'entity' => 'UFJoin',
           'bao' => 'CRM_Core_BAO_UFJoin',
diff --git a/civicrm/CRM/Core/DAO/UFMatch.php b/civicrm/CRM/Core/DAO/UFMatch.php
index 6b54207610e9d1767eb03c7ec9e53c4ce050b711..0e072cef5d2e80c06c1307231cc65419bf44a4f9 100644
--- a/civicrm/CRM/Core/DAO/UFMatch.php
+++ b/civicrm/CRM/Core/DAO/UFMatch.php
@@ -108,6 +108,7 @@ class CRM_Core_DAO_UFMatch extends CRM_Core_DAO {
           'title' => ts('UF Match ID'),
           'description' => ts('System generated ID.'),
           'required' => TRUE,
+          'where' => 'civicrm_uf_match.id',
           'table_name' => 'civicrm_uf_match',
           'entity' => 'UFMatch',
           'bao' => 'CRM_Core_BAO_UFMatch',
@@ -119,6 +120,7 @@ class CRM_Core_DAO_UFMatch extends CRM_Core_DAO {
           'title' => ts('UF Match Domain ID'),
           'description' => ts('Which Domain is this match entry for'),
           'required' => TRUE,
+          'where' => 'civicrm_uf_match.domain_id',
           'table_name' => 'civicrm_uf_match',
           'entity' => 'UFMatch',
           'bao' => 'CRM_Core_BAO_UFMatch',
@@ -136,6 +138,7 @@ class CRM_Core_DAO_UFMatch extends CRM_Core_DAO {
           'title' => ts('CMS ID'),
           'description' => ts('UF ID'),
           'required' => TRUE,
+          'where' => 'civicrm_uf_match.uf_id',
           'table_name' => 'civicrm_uf_match',
           'entity' => 'UFMatch',
           'bao' => 'CRM_Core_BAO_UFMatch',
@@ -148,6 +151,7 @@ class CRM_Core_DAO_UFMatch extends CRM_Core_DAO {
           'description' => ts('UF Name'),
           'maxlength' => 128,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_uf_match.uf_name',
           'table_name' => 'civicrm_uf_match',
           'entity' => 'UFMatch',
           'bao' => 'CRM_Core_BAO_UFMatch',
@@ -158,6 +162,7 @@ class CRM_Core_DAO_UFMatch extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('CiviCRM Contact ID'),
           'description' => ts('FK to Contact ID'),
+          'where' => 'civicrm_uf_match.contact_id',
           'table_name' => 'civicrm_uf_match',
           'entity' => 'UFMatch',
           'bao' => 'CRM_Core_BAO_UFMatch',
@@ -171,6 +176,7 @@ class CRM_Core_DAO_UFMatch extends CRM_Core_DAO {
           'description' => ts('UI language preferred by the given user/contact'),
           'maxlength' => 5,
           'size' => CRM_Utils_Type::SIX,
+          'where' => 'civicrm_uf_match.language',
           'table_name' => 'civicrm_uf_match',
           'entity' => 'UFMatch',
           'bao' => 'CRM_Core_BAO_UFMatch',
diff --git a/civicrm/CRM/Core/DAO/Website.php b/civicrm/CRM/Core/DAO/Website.php
index 350f6d26ed84e88499e872b5567fdf563b50c399..6976248baa07b19d66c3e2359f14b01b63e421f2 100644
--- a/civicrm/CRM/Core/DAO/Website.php
+++ b/civicrm/CRM/Core/DAO/Website.php
@@ -93,6 +93,7 @@ class CRM_Core_DAO_Website extends CRM_Core_DAO {
           'title' => ts('Website ID'),
           'description' => ts('Unique Website ID'),
           'required' => TRUE,
+          'where' => 'civicrm_website.id',
           'table_name' => 'civicrm_website',
           'entity' => 'Website',
           'bao' => 'CRM_Core_BAO_Website',
@@ -103,6 +104,7 @@ class CRM_Core_DAO_Website extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Contact'),
           'description' => ts('FK to Contact ID'),
+          'where' => 'civicrm_website.contact_id',
           'table_name' => 'civicrm_website',
           'entity' => 'Website',
           'bao' => 'CRM_Core_BAO_Website',
@@ -134,6 +136,7 @@ class CRM_Core_DAO_Website extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Website Type'),
           'description' => ts('Which Website type does this website belong to.'),
+          'where' => 'civicrm_website.website_type_id',
           'table_name' => 'civicrm_website',
           'entity' => 'Website',
           'bao' => 'CRM_Core_BAO_Website',
diff --git a/civicrm/CRM/Core/DAO/WordReplacement.php b/civicrm/CRM/Core/DAO/WordReplacement.php
index 3084dae9bf42a86669b9606522729cf5d2acec36..dfde25755f6969db42a6df96cb8e3c227c3eab69 100644
--- a/civicrm/CRM/Core/DAO/WordReplacement.php
+++ b/civicrm/CRM/Core/DAO/WordReplacement.php
@@ -105,6 +105,7 @@ class CRM_Core_DAO_WordReplacement extends CRM_Core_DAO {
           'title' => ts('Word Replacement ID'),
           'description' => ts('Word replacement ID'),
           'required' => TRUE,
+          'where' => 'civicrm_word_replacement.id',
           'table_name' => 'civicrm_word_replacement',
           'entity' => 'WordReplacement',
           'bao' => 'CRM_Core_BAO_WordReplacement',
@@ -117,6 +118,7 @@ class CRM_Core_DAO_WordReplacement extends CRM_Core_DAO {
           'description' => ts('Word which need to be replaced'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_word_replacement.find_word',
           'table_name' => 'civicrm_word_replacement',
           'entity' => 'WordReplacement',
           'bao' => 'CRM_Core_BAO_WordReplacement',
@@ -129,6 +131,7 @@ class CRM_Core_DAO_WordReplacement extends CRM_Core_DAO {
           'description' => ts('Word which will replace the word in find'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_word_replacement.replace_word',
           'table_name' => 'civicrm_word_replacement',
           'entity' => 'WordReplacement',
           'bao' => 'CRM_Core_BAO_WordReplacement',
@@ -139,6 +142,7 @@ class CRM_Core_DAO_WordReplacement extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Word Replacement is Active'),
           'description' => ts('Is this entry active?'),
+          'where' => 'civicrm_word_replacement.is_active',
           'default' => '1',
           'table_name' => 'civicrm_word_replacement',
           'entity' => 'WordReplacement',
@@ -151,6 +155,7 @@ class CRM_Core_DAO_WordReplacement extends CRM_Core_DAO {
           'title' => ts('Word Replacement Match Type'),
           'maxlength' => 16,
           'size' => CRM_Utils_Type::TWELVE,
+          'where' => 'civicrm_word_replacement.match_type',
           'default' => 'wildcardMatch',
           'table_name' => 'civicrm_word_replacement',
           'entity' => 'WordReplacement',
@@ -168,6 +173,7 @@ class CRM_Core_DAO_WordReplacement extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Word Replacement Domain ID'),
           'description' => ts('FK to Domain ID. This is for Domain specific word replacement'),
+          'where' => 'civicrm_word_replacement.domain_id',
           'table_name' => 'civicrm_word_replacement',
           'entity' => 'WordReplacement',
           'bao' => 'CRM_Core_BAO_WordReplacement',
diff --git a/civicrm/CRM/Core/DAO/Worldregion.php b/civicrm/CRM/Core/DAO/Worldregion.php
index 8e297e7e2a2290f009bc46ee0cca9e0d1ce6c43d..fc5b2eb2691a382a444150af8686616ebac07221 100644
--- a/civicrm/CRM/Core/DAO/Worldregion.php
+++ b/civicrm/CRM/Core/DAO/Worldregion.php
@@ -64,6 +64,7 @@ class CRM_Core_DAO_Worldregion extends CRM_Core_DAO {
           'title' => ts('World Region ID'),
           'description' => ts('Country Id'),
           'required' => TRUE,
+          'where' => 'civicrm_worldregion.id',
           'table_name' => 'civicrm_worldregion',
           'entity' => 'Worldregion',
           'bao' => 'CRM_Core_DAO_Worldregion',
@@ -76,10 +77,8 @@ class CRM_Core_DAO_Worldregion extends CRM_Core_DAO {
           'description' => ts('Region name to be associated with countries'),
           'maxlength' => 128,
           'size' => CRM_Utils_Type::HUGE,
-          'export' => TRUE,
           'where' => 'civicrm_worldregion.name',
-          'headerPattern' => '',
-          'dataPattern' => '',
+          'export' => TRUE,
           'table_name' => 'civicrm_worldregion',
           'entity' => 'Worldregion',
           'bao' => 'CRM_Core_DAO_Worldregion',
diff --git a/civicrm/CRM/Core/Form/EntityFormTrait.php b/civicrm/CRM/Core/Form/EntityFormTrait.php
index 38f2548208f0268ee380624dd24b9e13b9f3d5c1..00a5c5b6e0922e7143081f1163669e29914d59aa 100644
--- a/civicrm/CRM/Core/Form/EntityFormTrait.php
+++ b/civicrm/CRM/Core/Form/EntityFormTrait.php
@@ -64,6 +64,20 @@ trait CRM_Core_Form_EntityFormTrait {
     return $this->deleteMessage;
   }
 
+  /**
+   * Set the delete message.
+   *
+   * We do this from the constructor in order to do a translation.
+   */
+  public function setDeleteMessage() {
+  }
+
+  /**
+   * Set entity fields to be assigned to the form.
+   */
+  protected function setEntityFields() {
+  }
+
   /**
    * Get the entity id being edited.
    *
diff --git a/civicrm/CRM/Core/Payment.php b/civicrm/CRM/Core/Payment.php
index 9399504e1600a10dc3fc71341c68727c4547ba7c..1e5f6462231da332699ab5891c477643bbcf96e8 100644
--- a/civicrm/CRM/Core/Payment.php
+++ b/civicrm/CRM/Core/Payment.php
@@ -635,6 +635,7 @@ abstract class CRM_Core_Payment {
     if ($this->supports('changeSubscriptionAmount')) {
       return ['amount'];
     }
+    return [];
   }
 
   /**
@@ -1189,7 +1190,7 @@ abstract class CRM_Core_Payment {
 
   /**
    * Calling this from outside the payment subsystem is deprecated - use doPayment.
-   *
+   * @deprecated
    * Does a server to server payment transaction.
    *
    * @param array $params
@@ -1204,33 +1205,25 @@ abstract class CRM_Core_Payment {
 
   /**
    * Process payment - this function wraps around both doTransferCheckout and doDirectPayment.
+   * Any processor that still implements the deprecated doTransferCheckout() or doDirectPayment() should be updated to use doPayment().
    *
-   * The function ensures an exception is thrown & moves some of this logic out of the form layer and makes the forms
-   * more agnostic.
-   *
-   * Payment processors should set payment_status_id. This function adds some historical defaults ie. the
-   * assumption that if a 'doDirectPayment' processors comes back it completed the transaction & in fact
-   * doTransferCheckout would not traditionally come back.
-   *
-   * doDirectPayment does not do an immediate payment for Authorize.net or Paypal so the default is assumed
-   * to be Pending.
+   * This function adds some historical defaults ie. the assumption that if a 'doDirectPayment' processors comes back it completed
+   *   the transaction & in fact doTransferCheckout would not traditionally come back.
+   * Payment processors should throw exceptions and not return Error objects as they may have done with the old functions.
    *
-   * Once this function is fully rolled out then it will be preferred for processors to throw exceptions than to
-   * return Error objects
+   * Payment processors should set payment_status_id (which is really contribution_status_id) in the returned array. The default is assumed to be Pending.
+   *   In some cases the IPN will set the payment to "Completed" some time later.
    *
-   * Usage:
-   * Payment processors should override this function directly instead of using doDirectPayment/doTransferCheckout which are deprecated.
-   * Payment processors should set and return payment_status_id (Pending if the IPN will complete it, Completed if successful).
-   * @fixme For the contribution workflow we have a contributionID, but for the event and membership workflow the contribution has not yet been created
-   *  so we can't update params directly on the contribution.  However if you return trxn_id, fee_amount, net_amount they will be set on the contribution
-   *  by those workflows.  Ideally all workflows would create a pending contribution BEFORE calling doPayment (eg. https://github.com/civicrm/civicrm-core/pull/13763 for events)
+   * @fixme Creating a contribution record is inconsistent! We should always create a contribution BEFORE calling doPayment...
+   *  For the current status see: https://lab.civicrm.org/dev/financial/issues/53
+   * If we DO have a contribution ID, then the payment processor can (and should) update parameters on the contribution record as necessary.
    *
    * @param array $params
    *
    * @param string $component
    *
    * @return array
-   *   Result array
+   *   Result array (containing at least the key payment_status_id)
    *
    * @throws \Civi\Payment\Exception\PaymentProcessorException
    */
diff --git a/civicrm/CRM/Core/Payment/Dummy.php b/civicrm/CRM/Core/Payment/Dummy.php
index 1fdbd9cda3406526d99bd128824a61becf20faed..d2f8c5c00d444fd97f6bbd447fd2989d85e23698 100644
--- a/civicrm/CRM/Core/Payment/Dummy.php
+++ b/civicrm/CRM/Core/Payment/Dummy.php
@@ -146,6 +146,14 @@ class CRM_Core_Payment_Dummy extends CRM_Core_Payment {
     return TRUE;
   }
 
+  /**
+   * Supports altering future start dates
+   * @return bool
+   */
+  public function supportsFutureRecurStartDate() {
+    return TRUE;
+  }
+
   /**
    * Submit a refund payment
    *
diff --git a/civicrm/CRM/Core/Resources.php b/civicrm/CRM/Core/Resources.php
index 014750ece774cbbc59b5a51a1127dcd0d1dc310d..69f9e46150897be1f34182783e58665513c253d9 100644
--- a/civicrm/CRM/Core/Resources.php
+++ b/civicrm/CRM/Core/Resources.php
@@ -767,6 +767,9 @@ class CRM_Core_Resources {
       $items[] = 'js/crm.menubar.js';
       $items[] = Civi::service('asset_builder')->getUrl('crm-menubar.css', [
         'color' => Civi::settings()->get('menubar_color'),
+        'height' => 40,
+        'breakpoint' => 768,
+        'opacity' => .88,
       ]);
       $items[] = [
         'menubar' => [
@@ -821,8 +824,8 @@ class CRM_Core_Resources {
     ) {
       return TRUE;
     }
-    $url = CRM_Utils_System::getUrlPath();
-    return (strpos($url, 'civicrm/ajax') === 0) || (strpos($url, 'civicrm/angular') === 0);
+    list($arg0, $arg1) = array_pad(explode('/', CRM_Utils_System::getUrlPath()), 2, '');
+    return ($arg0 === 'civicrm' && in_array($arg1, ['ajax', 'angularprofiles', 'asset']));
   }
 
   /**
@@ -852,8 +855,11 @@ class CRM_Core_Resources {
     }
     $vars = [
       'resourceBase' => rtrim($config->resourceBase, '/'),
+      'menubarHeight' => $e->params['height'] . 'px',
+      'breakMin' => $e->params['breakpoint'] . 'px',
+      'breakMax' => ($e->params['breakpoint'] - 1) . 'px',
       'menubarColor' => $color,
-      'semiTransparentMenuColor' => 'rgba(' . implode(', ', CRM_Utils_Color::getRgb($color)) . ', .85)',
+      'menuItemColor' => 'rgba(' . implode(', ', CRM_Utils_Color::getRgb($color)) . ", {$e->params['opacity']})",
       'highlightColor' => CRM_Utils_Color::getHighlight($color),
       'textColor' => CRM_Utils_Color::getContrast($color, '#333', '#ddd'),
     ];
diff --git a/civicrm/CRM/Cxn/DAO/Cxn.php b/civicrm/CRM/Cxn/DAO/Cxn.php
index 96b240eead22e636bb04d2edb33b79855fc8f8ce..7713ee953ff597274f31df68897f5a667a84c900 100644
--- a/civicrm/CRM/Cxn/DAO/Cxn.php
+++ b/civicrm/CRM/Cxn/DAO/Cxn.php
@@ -127,6 +127,7 @@ class CRM_Cxn_DAO_Cxn extends CRM_Core_DAO {
           'title' => ts('Connection ID'),
           'description' => ts('Connection ID'),
           'required' => TRUE,
+          'where' => 'civicrm_cxn.id',
           'table_name' => 'civicrm_cxn',
           'entity' => 'Cxn',
           'bao' => 'CRM_Cxn_BAO_Cxn',
@@ -139,6 +140,7 @@ class CRM_Cxn_DAO_Cxn extends CRM_Core_DAO {
           'description' => ts('Application GUID'),
           'maxlength' => 128,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_cxn.app_guid',
           'table_name' => 'civicrm_cxn',
           'entity' => 'Cxn',
           'bao' => 'CRM_Cxn_BAO_Cxn',
@@ -149,6 +151,7 @@ class CRM_Cxn_DAO_Cxn extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_TEXT,
           'title' => ts('Application Metadata (JSON)'),
           'description' => ts('Application Metadata (JSON)'),
+          'where' => 'civicrm_cxn.app_meta',
           'table_name' => 'civicrm_cxn',
           'entity' => 'Cxn',
           'bao' => 'CRM_Cxn_BAO_Cxn',
@@ -161,6 +164,7 @@ class CRM_Cxn_DAO_Cxn extends CRM_Core_DAO {
           'description' => ts('Connection GUID'),
           'maxlength' => 128,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_cxn.cxn_guid',
           'table_name' => 'civicrm_cxn',
           'entity' => 'Cxn',
           'bao' => 'CRM_Cxn_BAO_Cxn',
@@ -171,6 +175,7 @@ class CRM_Cxn_DAO_Cxn extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_TEXT,
           'title' => ts('Secret'),
           'description' => ts('Shared secret'),
+          'where' => 'civicrm_cxn.secret',
           'table_name' => 'civicrm_cxn',
           'entity' => 'Cxn',
           'bao' => 'CRM_Cxn_BAO_Cxn',
@@ -181,6 +186,7 @@ class CRM_Cxn_DAO_Cxn extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_TEXT,
           'title' => ts('Perm'),
           'description' => ts('Permissions approved for the service (JSON)'),
+          'where' => 'civicrm_cxn.perm',
           'table_name' => 'civicrm_cxn',
           'entity' => 'Cxn',
           'bao' => 'CRM_Cxn_BAO_Cxn',
@@ -191,6 +197,7 @@ class CRM_Cxn_DAO_Cxn extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_TEXT,
           'title' => ts('Options'),
           'description' => ts('Options for the service (JSON)'),
+          'where' => 'civicrm_cxn.options',
           'table_name' => 'civicrm_cxn',
           'entity' => 'Cxn',
           'bao' => 'CRM_Cxn_BAO_Cxn',
@@ -202,6 +209,7 @@ class CRM_Cxn_DAO_Cxn extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Is Active'),
           'description' => ts('Is connection currently enabled?'),
+          'where' => 'civicrm_cxn.is_active',
           'default' => '1',
           'table_name' => 'civicrm_cxn',
           'entity' => 'Cxn',
@@ -214,6 +222,7 @@ class CRM_Cxn_DAO_Cxn extends CRM_Core_DAO {
           'title' => ts('Created Date'),
           'description' => ts('When was the connection was created.'),
           'required' => FALSE,
+          'where' => 'civicrm_cxn.created_date',
           'default' => 'NULL',
           'table_name' => 'civicrm_cxn',
           'entity' => 'Cxn',
@@ -226,6 +235,7 @@ class CRM_Cxn_DAO_Cxn extends CRM_Core_DAO {
           'title' => ts('Modified Date'),
           'description' => ts('When the connection was created or modified.'),
           'required' => FALSE,
+          'where' => 'civicrm_cxn.modified_date',
           'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
           'table_name' => 'civicrm_cxn',
           'entity' => 'Cxn',
@@ -238,6 +248,7 @@ class CRM_Cxn_DAO_Cxn extends CRM_Core_DAO {
           'title' => ts('Fetched Date'),
           'description' => ts('The last time the application metadata was fetched.'),
           'required' => FALSE,
+          'where' => 'civicrm_cxn.fetched_date',
           'default' => 'NULL',
           'table_name' => 'civicrm_cxn',
           'entity' => 'Cxn',
diff --git a/civicrm/CRM/Dedupe/BAO/RuleGroup.php b/civicrm/CRM/Dedupe/BAO/RuleGroup.php
index b6dab2843a97fc3ae7be1ebee9bd369f9263d920..61f70b2d279e9c8b69746edae9c8847b3ee2721e 100644
--- a/civicrm/CRM/Dedupe/BAO/RuleGroup.php
+++ b/civicrm/CRM/Dedupe/BAO/RuleGroup.php
@@ -247,7 +247,6 @@ class CRM_Dedupe_BAO_RuleGroup extends CRM_Dedupe_DAO_RuleGroup {
             // get prepared to search within already found dupes if $searchWithinDupes flag is set
             $dao->query("DROP TEMPORARY TABLE IF EXISTS dedupe_copy");
             $dao->query("CREATE TEMPORARY TABLE dedupe_copy SELECT * FROM {$this->temporaryTables['dedupe']} WHERE weight >= {$weightSum}");
-            $dao->free();
 
             preg_match($patternColumn, $query, $matches);
             $query = str_replace(' WHERE ', str_replace('column', $matches[1], $dupeCopyJoin), $query);
@@ -258,7 +257,6 @@ class CRM_Dedupe_BAO_RuleGroup extends CRM_Dedupe_DAO_RuleGroup {
               // Make a second temp table:
               $dao->query("DROP TEMPORARY TABLE IF EXISTS dedupe_copy_2");
               $dao->query("CREATE TEMPORARY TABLE dedupe_copy_2 SELECT * FROM {$this->temporaryTables['dedupe']} WHERE weight >= {$weightSum}");
-              $dao->free();
               // After the union, use that new temp table:
               $part1 = substr($query, 0, $matches[1][1]);
               $query = $part1 . str_replace('dedupe_copy', 'dedupe_copy_2', substr($query, $matches[1][1]));
@@ -273,7 +271,6 @@ class CRM_Dedupe_BAO_RuleGroup extends CRM_Dedupe_DAO_RuleGroup {
           // FIXME: we need to be more acurate with affected rows, especially for insert vs duplicate insert.
           // And that will help optimize further.
           $affectedRows = $dao->affectedRows();
-          $dao->free();
 
           // In an inclusive situation, failure of any query means no further processing -
           if ($affectedRows == 0) {
diff --git a/civicrm/CRM/Dedupe/DAO/Exception.php b/civicrm/CRM/Dedupe/DAO/Exception.php
index 3692a9d0acae5cd1d19cd1b94f9500bfe2947e9b..cfc6bc3b9a0a569eaaf64e29075684e959f943ba 100644
--- a/civicrm/CRM/Dedupe/DAO/Exception.php
+++ b/civicrm/CRM/Dedupe/DAO/Exception.php
@@ -87,6 +87,7 @@ class CRM_Dedupe_DAO_Exception extends CRM_Core_DAO {
           'title' => ts('Dedupe Exception ID'),
           'description' => ts('Unique dedupe exception id'),
           'required' => TRUE,
+          'where' => 'civicrm_dedupe_exception.id',
           'table_name' => 'civicrm_dedupe_exception',
           'entity' => 'Exception',
           'bao' => 'CRM_Dedupe_DAO_Exception',
@@ -98,6 +99,7 @@ class CRM_Dedupe_DAO_Exception extends CRM_Core_DAO {
           'title' => ts('First Dupe Contact ID'),
           'description' => ts('FK to Contact ID'),
           'required' => TRUE,
+          'where' => 'civicrm_dedupe_exception.contact_id1',
           'table_name' => 'civicrm_dedupe_exception',
           'entity' => 'Exception',
           'bao' => 'CRM_Dedupe_DAO_Exception',
@@ -110,6 +112,7 @@ class CRM_Dedupe_DAO_Exception extends CRM_Core_DAO {
           'title' => ts('Second Dupe Contact ID'),
           'description' => ts('FK to Contact ID'),
           'required' => TRUE,
+          'where' => 'civicrm_dedupe_exception.contact_id2',
           'table_name' => 'civicrm_dedupe_exception',
           'entity' => 'Exception',
           'bao' => 'CRM_Dedupe_DAO_Exception',
diff --git a/civicrm/CRM/Dedupe/DAO/Rule.php b/civicrm/CRM/Dedupe/DAO/Rule.php
index b9e916d952ac18d35f23799aaf8d0ac2d5733a9c..806185c260a9dfbc84e230a065a4dadebe4a06a7 100644
--- a/civicrm/CRM/Dedupe/DAO/Rule.php
+++ b/civicrm/CRM/Dedupe/DAO/Rule.php
@@ -107,6 +107,7 @@ class CRM_Dedupe_DAO_Rule extends CRM_Core_DAO {
           'title' => ts('Dedupe Rule ID'),
           'description' => ts('Unique dedupe rule id'),
           'required' => TRUE,
+          'where' => 'civicrm_dedupe_rule.id',
           'table_name' => 'civicrm_dedupe_rule',
           'entity' => 'Rule',
           'bao' => 'CRM_Dedupe_BAO_Rule',
@@ -118,6 +119,7 @@ class CRM_Dedupe_DAO_Rule extends CRM_Core_DAO {
           'title' => ts('Dedupe Rule Group'),
           'description' => ts('The id of the rule group this rule belongs to'),
           'required' => TRUE,
+          'where' => 'civicrm_dedupe_rule.dedupe_rule_group_id',
           'table_name' => 'civicrm_dedupe_rule',
           'entity' => 'Rule',
           'bao' => 'CRM_Dedupe_BAO_Rule',
@@ -132,6 +134,7 @@ class CRM_Dedupe_DAO_Rule extends CRM_Core_DAO {
           'required' => TRUE,
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_dedupe_rule.rule_table',
           'table_name' => 'civicrm_dedupe_rule',
           'entity' => 'Rule',
           'bao' => 'CRM_Dedupe_BAO_Rule',
@@ -145,6 +148,7 @@ class CRM_Dedupe_DAO_Rule extends CRM_Core_DAO {
           'required' => TRUE,
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_dedupe_rule.rule_field',
           'table_name' => 'civicrm_dedupe_rule',
           'entity' => 'Rule',
           'bao' => 'CRM_Dedupe_BAO_Rule',
@@ -155,6 +159,7 @@ class CRM_Dedupe_DAO_Rule extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Rule Length'),
           'description' => ts('The length of the matching substring'),
+          'where' => 'civicrm_dedupe_rule.rule_length',
           'table_name' => 'civicrm_dedupe_rule',
           'entity' => 'Rule',
           'bao' => 'CRM_Dedupe_BAO_Rule',
@@ -169,6 +174,7 @@ class CRM_Dedupe_DAO_Rule extends CRM_Core_DAO {
           'title' => ts('Order'),
           'description' => ts('The weight of the rule'),
           'required' => TRUE,
+          'where' => 'civicrm_dedupe_rule.rule_weight',
           'table_name' => 'civicrm_dedupe_rule',
           'entity' => 'Rule',
           'bao' => 'CRM_Dedupe_BAO_Rule',
diff --git a/civicrm/CRM/Dedupe/DAO/RuleGroup.php b/civicrm/CRM/Dedupe/DAO/RuleGroup.php
index d4b0fe9ba5055c3b0454abd46b4e79e4f1b6bff4..505c8044dcdcf3e68be60fc5935961fcb30e50ca 100644
--- a/civicrm/CRM/Dedupe/DAO/RuleGroup.php
+++ b/civicrm/CRM/Dedupe/DAO/RuleGroup.php
@@ -99,6 +99,7 @@ class CRM_Dedupe_DAO_RuleGroup extends CRM_Core_DAO {
           'title' => ts('Rule Group ID'),
           'description' => ts('Unique dedupe rule group id'),
           'required' => TRUE,
+          'where' => 'civicrm_dedupe_rule_group.id',
           'table_name' => 'civicrm_dedupe_rule_group',
           'entity' => 'RuleGroup',
           'bao' => 'CRM_Dedupe_BAO_RuleGroup',
@@ -111,6 +112,7 @@ class CRM_Dedupe_DAO_RuleGroup extends CRM_Core_DAO {
           'description' => ts('The type of contacts this group applies to'),
           'maxlength' => 12,
           'size' => CRM_Utils_Type::TWELVE,
+          'where' => 'civicrm_dedupe_rule_group.contact_type',
           'table_name' => 'civicrm_dedupe_rule_group',
           'entity' => 'RuleGroup',
           'bao' => 'CRM_Dedupe_BAO_RuleGroup',
@@ -131,6 +133,7 @@ class CRM_Dedupe_DAO_RuleGroup extends CRM_Core_DAO {
           'title' => ts('Threshold'),
           'description' => ts('The weight threshold the sum of the rule weights has to cross to consider two contacts the same'),
           'required' => TRUE,
+          'where' => 'civicrm_dedupe_rule_group.threshold',
           'table_name' => 'civicrm_dedupe_rule_group',
           'entity' => 'RuleGroup',
           'bao' => 'CRM_Dedupe_BAO_RuleGroup',
@@ -147,6 +150,7 @@ class CRM_Dedupe_DAO_RuleGroup extends CRM_Core_DAO {
           'required' => TRUE,
           'maxlength' => 12,
           'size' => CRM_Utils_Type::TWELVE,
+          'where' => 'civicrm_dedupe_rule_group.used',
           'table_name' => 'civicrm_dedupe_rule_group',
           'entity' => 'RuleGroup',
           'bao' => 'CRM_Dedupe_BAO_RuleGroup',
@@ -165,6 +169,7 @@ class CRM_Dedupe_DAO_RuleGroup extends CRM_Core_DAO {
           'description' => ts('Name of the rule group'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_dedupe_rule_group.name',
           'table_name' => 'civicrm_dedupe_rule_group',
           'entity' => 'RuleGroup',
           'bao' => 'CRM_Dedupe_BAO_RuleGroup',
@@ -177,6 +182,7 @@ class CRM_Dedupe_DAO_RuleGroup extends CRM_Core_DAO {
           'description' => ts('Label of the rule group'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_dedupe_rule_group.title',
           'table_name' => 'civicrm_dedupe_rule_group',
           'entity' => 'RuleGroup',
           'bao' => 'CRM_Dedupe_BAO_RuleGroup',
@@ -190,6 +196,7 @@ class CRM_Dedupe_DAO_RuleGroup extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Reserved?'),
           'description' => ts('Is this a reserved rule - a rule group that has been optimized and cannot be changed by the admin'),
+          'where' => 'civicrm_dedupe_rule_group.is_reserved',
           'table_name' => 'civicrm_dedupe_rule_group',
           'entity' => 'RuleGroup',
           'bao' => 'CRM_Dedupe_BAO_RuleGroup',
diff --git a/civicrm/CRM/Dedupe/Merger.php b/civicrm/CRM/Dedupe/Merger.php
index ceea27b4e854b69d56d5bbf864521acb167093f5..6703e57a7cda0e1c7a73a94f5cce7343c2a497ac 100644
--- a/civicrm/CRM/Dedupe/Merger.php
+++ b/civicrm/CRM/Dedupe/Merger.php
@@ -924,92 +924,13 @@ INNER JOIN  civicrm_membership membership2 ON membership1.membership_type_id = m
    *   -  Does a force merge otherwise (aggressive mode).
    *
    * @param array $conflicts
+   *  An empty array to be filed with conflict information.
    *
    * @return bool
    */
   public static function skipMerge($mainId, $otherId, &$migrationInfo, $mode = 'safe', &$conflicts = []) {
 
-    $originalMigrationInfo = $migrationInfo;
-    foreach ($migrationInfo as $key => $val) {
-      if ($val === "null") {
-        // Rule: Never overwrite with an empty value (in any mode)
-        unset($migrationInfo[$key]);
-        continue;
-      }
-      elseif ((in_array(substr($key, 5), CRM_Dedupe_Merger::getContactFields()) or
-          substr($key, 0, 12) == 'move_custom_'
-        ) and $val != NULL
-      ) {
-        // Rule: If both main-contact, and other-contact have a field with a
-        // different value, then let $mode decide if to merge it or not
-        if (
-          (!empty($migrationInfo['rows'][$key]['main'])
-            // For custom fields a 0 (e.g in an int field) could be a true conflict. This
-            // is probably true for other fields too - e.g. 'do_not_email' but
-            // leaving that investigation as a @todo - until tests can be written.
-            // Note the handling of this has test coverage - although the data-typing
-            // of '0' feels flakey we have insurance.
-            || ($migrationInfo['rows'][$key]['main'] === '0' && substr($key, 0, 12) == 'move_custom_')
-          )
-          && $migrationInfo['rows'][$key]['main'] != $migrationInfo['rows'][$key]['other']
-        ) {
-
-          // note it down & lets wait for response from the hook.
-          // For no response $mode will decide if to skip this merge
-          $conflicts[$key] = NULL;
-        }
-      }
-      elseif (substr($key, 0, 14) == 'move_location_' and $val != NULL) {
-        $locField = explode('_', $key);
-        $fieldName = $locField[2];
-        $fieldCount = $locField[3];
-
-        // Rule: Catch address conflicts (same address type on both contacts)
-        if (
-          isset($migrationInfo['main_details']['location_blocks'][$fieldName]) &&
-          !empty($migrationInfo['main_details']['location_blocks'][$fieldName])
-        ) {
-
-          // Load the address we're inspecting from the 'other' contact
-          $addressRecord = $migrationInfo['other_details']['location_blocks'][$fieldName][$fieldCount];
-          $addressRecordLocTypeId = CRM_Utils_Array::value('location_type_id', $addressRecord);
-
-          // If it exists on the 'main' contact already, skip it. Otherwise
-          // if the location type exists already, log a conflict.
-          foreach ($migrationInfo['main_details']['location_blocks'][$fieldName] as $mainAddressKey => $mainAddressRecord) {
-            if (self::locationIsSame($addressRecord, $mainAddressRecord)) {
-              unset($migrationInfo[$key]);
-              break;
-            }
-            elseif ($addressRecordLocTypeId == $mainAddressRecord['location_type_id']) {
-              $conflicts[$key] = NULL;
-              break;
-            }
-          }
-        }
-
-        // For other locations, don't merge/add if the values are the same
-        elseif (CRM_Utils_Array::value('main', $migrationInfo['rows'][$key]) == $migrationInfo['rows'][$key]['other']) {
-          unset($migrationInfo[$key]);
-        }
-      }
-    }
-
-    // A hook to implement other algorithms for choosing which contact to bias to when
-    // there's a conflict (to handle "gotchas"). fields_in_conflict could be modified here
-    // merge happens with new values filled in here. For a particular field / row not to be merged
-    // field should be unset from fields_in_conflict.
-    $migrationData = [
-      'old_migration_info' => $originalMigrationInfo,
-      'mode' => $mode,
-      'fields_in_conflict' => $conflicts,
-      'merge_mode' => $mode,
-      'migration_info' => $migrationInfo,
-    ];
-    CRM_Utils_Hook::merge('batch', $migrationData, $mainId, $otherId);
-    $conflicts = $migrationData['fields_in_conflict'];
-    // allow hook to override / manipulate migrationInfo as well
-    $migrationInfo = $migrationData['migration_info'];
+    $conflicts = self::getConflicts($migrationInfo, $mainId, $otherId, $mode);
 
     if (!empty($conflicts)) {
       foreach ($conflicts as $key => $val) {
@@ -1023,9 +944,7 @@ INNER JOIN  civicrm_membership membership2 ON membership1.membership_type_id = m
         }
       }
       // if there are conflicts and mode is aggressive, allow hooks to decide if to skip merges
-      if (array_key_exists('skip_merge', $migrationData)) {
-        return (bool) $migrationData['skip_merge'];
-      }
+      return (bool) $migrationInfo['skip_merge'];
     }
     return FALSE;
   }
@@ -1609,14 +1528,12 @@ INNER JOIN  civicrm_membership membership2 ON membership1.membership_type_id = m
       return FALSE;
     }
 
-    $qfZeroBug = 'e8cddb72-a257-11dc-b9cc-0016d3330ee9';
+    $contactType = $migrationInfo['main_details']['contact_type'];
     $relTables = CRM_Dedupe_Merger::relTables();
-    $submittedCustomFields = $moveTables = $locationMigrationInfo = $tableOperations = $removeTables = [];
+    $submittedCustomFields = $moveTables = $tableOperations = $removeTables = [];
 
+    self::swapOutFieldsAffectedByQFZeroBug($migrationInfo);
     foreach ($migrationInfo as $key => $value) {
-      if ($value == $qfZeroBug) {
-        $value = '0';
-      }
 
       if (substr($key, 0, 12) == 'move_custom_' && $value != NULL) {
         $submitted[substr($key, 5)] = $value;
@@ -1625,10 +1542,6 @@ INNER JOIN  civicrm_membership membership2 ON membership1.membership_type_id = m
       elseif (in_array(substr($key, 5), CRM_Dedupe_Merger::getContactFields()) && $value != NULL) {
         $submitted[substr($key, 5)] = $value;
       }
-      // Set up initial information for handling migration of location blocks
-      elseif (substr($key, 0, 14) == 'move_location_' and $value != NULL) {
-        $locationMigrationInfo[$key] = $value;
-      }
       elseif (substr($key, 0, 15) == 'move_rel_table_' and $value == '1') {
         $moveTables = array_merge($moveTables, $relTables[substr($key, 5)]['tables']);
         if (array_key_exists('operation', $migrationInfo)) {
@@ -1643,7 +1556,7 @@ INNER JOIN  civicrm_membership membership2 ON membership1.membership_type_id = m
         $removeTables = array_merge($moveTables, $relTables[substr($key, 5)]['tables']);
       }
     }
-    self::mergeLocations($mainId, $otherId, $locationMigrationInfo, $migrationInfo);
+    self::mergeLocations($mainId, $otherId, $migrationInfo);
 
     // **** Do contact related migrations
     $customTablesToCopyValues = self::getAffectedCustomTables($submittedCustomFields);
@@ -1684,181 +1597,18 @@ INNER JOIN  civicrm_membership membership2 ON membership1.membership_type_id = m
       'groupName' => 'postal_greeting',
     ];
     CRM_Core_OptionGroup::lookupValues($submitted, $names, TRUE);
-
     // fix custom fields so they're edible by createProfileContact()
-    $treeCache = [];
-    if (!array_key_exists($migrationInfo['main_details']['contact_type'], $treeCache)) {
-      $treeCache[$migrationInfo['main_details']['contact_type']] = CRM_Core_BAO_CustomGroup::getTree(
-        $migrationInfo['main_details']['contact_type'],
-        NULL,
-        NULL,
-        -1,
-        [],
-        NULL,
-        TRUE,
-        NULL,
-        FALSE,
-        FALSE
-      );
-    }
-
-    $cFields = [];
-    foreach ($treeCache[$migrationInfo['main_details']['contact_type']] as $key => $group) {
-      if (!isset($group['fields'])) {
-        continue;
-      }
-      foreach ($group['fields'] as $fid => $field) {
-        $cFields[$fid]['attributes'] = $field;
-      }
-    }
+    $cFields = self::getCustomFieldMetadata($contactType);
 
     if (!isset($submitted)) {
       $submitted = [];
     }
+    $customFiles = [];
     foreach ($submitted as $key => $value) {
-      if (substr($key, 0, 7) == 'custom_') {
-        $fid = (int) substr($key, 7);
-        if (empty($cFields[$fid])) {
-          continue;
-        }
-        $htmlType = $cFields[$fid]['attributes']['html_type'];
-        switch ($htmlType) {
-          case 'File':
-            $customFiles[] = $fid;
-            unset($submitted["custom_$fid"]);
-            break;
-
-          case 'Select Country':
-          case 'Select State/Province':
-            $submitted[$key] = CRM_Core_BAO_CustomField::displayValue($value, $fid);
-            break;
-
-          case 'Select Date':
-            if ($cFields[$fid]['attributes']['is_view']) {
-              $submitted[$key] = date('YmdHis', strtotime($submitted[$key]));
-            }
-            break;
-
-          case 'CheckBox':
-          case 'Multi-Select':
-          case 'Multi-Select Country':
-          case 'Multi-Select State/Province':
-            // Merge values from both contacts for multivalue fields, CRM-4385
-            // get the existing custom values from db.
-            $customParams = ['entityID' => $mainId, $key => TRUE];
-            $customfieldValues = CRM_Core_BAO_CustomValueTable::getValues($customParams);
-            if (!empty($customfieldValues[$key])) {
-              $existingValue = explode(CRM_Core_DAO::VALUE_SEPARATOR, $customfieldValues[$key]);
-              if (is_array($existingValue) && !empty($existingValue)) {
-                $mergeValue = $submittedCustomFields = [];
-                if ($value == 'null') {
-                  // CRM-19074 if someone has deliberately chosen to overwrite with 'null', respect it.
-                  $submitted[$key] = $value;
-                }
-                else {
-                  if ($value) {
-                    $submittedCustomFields = explode(CRM_Core_DAO::VALUE_SEPARATOR, $value);
-                  }
-
-                  // CRM-19653: overwrite or add the existing custom field value with dupicate contact's
-                  // custom field value stored at $submittedCustomValue.
-                  foreach ($submittedCustomFields as $k => $v) {
-                    if ($v != '' && !in_array($v, $mergeValue)) {
-                      $mergeValue[] = $v;
-                    }
-                  }
-
-                  //keep state and country as array format.
-                  //for checkbox and m-select format w/ VALUE_SEPARATOR
-                  if (in_array($htmlType, [
-                    'CheckBox',
-                    'Multi-Select',
-                  ])) {
-                    $submitted[$key] = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR,
-                        $mergeValue
-                      ) . CRM_Core_DAO::VALUE_SEPARATOR;
-                  }
-                  else {
-                    $submitted[$key] = $mergeValue;
-                  }
-                }
-              }
-            }
-            elseif (in_array($htmlType, [
-              'Multi-Select Country',
-              'Multi-Select State/Province',
-            ])) {
-              //we require submitted values should be in array format
-              if ($value) {
-                $mergeValueArray = explode(CRM_Core_DAO::VALUE_SEPARATOR, $value);
-                //hack to remove null values from array.
-                $mergeValue = [];
-                foreach ($mergeValueArray as $k => $v) {
-                  if ($v != '') {
-                    $mergeValue[] = $v;
-                  }
-                }
-                $submitted[$key] = $mergeValue;
-              }
-            }
-            break;
-
-          default:
-            break;
-        }
-      }
+      list($cFields, $customFiles, $submitted) = self::processCustomFields($mainId, $key, $cFields, $customFiles, $submitted, $value);
     }
 
-    // **** Do file custom fields related migrations
-    // FIXME: move this someplace else (one of the BAOs) after discussing
-    // where to, and whether CRM_Core_BAO_File::deleteFileReferences() shouldn't actually,
-    // like, delete a file...
-
-    if (!isset($customFiles)) {
-      $customFiles = [];
-    }
-    foreach ($customFiles as $customId) {
-      list($tableName, $columnName, $groupID) = CRM_Core_BAO_CustomField::getTableColumnGroup($customId);
-
-      // get the contact_id -> file_id mapping
-      $fileIds = [];
-      $sql = "SELECT entity_id, {$columnName} AS file_id FROM {$tableName} WHERE entity_id IN ({$mainId}, {$otherId})";
-      $dao = CRM_Core_DAO::executeQuery($sql);
-      while ($dao->fetch()) {
-        $fileIds[$dao->entity_id] = $dao->file_id;
-        if ($dao->entity_id == $mainId) {
-          CRM_Core_BAO_File::deleteFileReferences($fileIds[$mainId], $mainId, $customId);
-        }
-      }
-      $dao->free();
-
-      // move the other contact's file to main contact
-      //NYSS need to INSERT or UPDATE depending on whether main contact has an existing record
-      if (CRM_Core_DAO::singleValueQuery("SELECT id FROM {$tableName} WHERE entity_id = {$mainId}")) {
-        $sql = "UPDATE {$tableName} SET {$columnName} = {$fileIds[$otherId]} WHERE entity_id = {$mainId}";
-      }
-      else {
-        $sql = "INSERT INTO {$tableName} ( entity_id, {$columnName} ) VALUES ( {$mainId}, {$fileIds[$otherId]} )";
-      }
-      CRM_Core_DAO::executeQuery($sql);
-
-      if (CRM_Core_DAO::singleValueQuery("
-        SELECT id
-        FROM civicrm_entity_file
-        WHERE entity_table = '{$tableName}' AND file_id = {$fileIds[$otherId]}")
-      ) {
-        $sql = "
-          UPDATE civicrm_entity_file
-          SET entity_id = {$mainId}
-          WHERE entity_table = '{$tableName}' AND file_id = {$fileIds[$otherId]}";
-      }
-      else {
-        $sql = "
-          INSERT INTO civicrm_entity_file ( entity_table, entity_id, file_id )
-          VALUES ( '{$tableName}', {$mainId}, {$fileIds[$otherId]} )";
-      }
-      CRM_Core_DAO::executeQuery($sql);
-    }
+    self::processCustomFieldFiles($mainId, $otherId, $customFiles);
 
     // move view only custom fields CRM-5362
     $viewOnlyCustomFields = [];
@@ -2235,14 +1985,16 @@ INNER JOIN  civicrm_membership membership2 ON membership1.membership_type_id = m
    *
    * @param int $mainId
    * @param int $otherId
-   * @param array $locationMigrationInfo
-   *   Portion of the migration_info that holds location migration information.
    *
    * @param array $migrationInfo
    *   Migration info for the merge. This is passed to the hook as informational only.
    */
-  public static function mergeLocations($mainId, $otherId, $locationMigrationInfo, $migrationInfo) {
-    foreach ($locationMigrationInfo as $key => $value) {
+  public static function mergeLocations($mainId, $otherId, $migrationInfo) {
+    foreach ($migrationInfo as $key => $value) {
+      $isLocationField = (substr($key, 0, 14) == 'move_location_' and $value != NULL);
+      if (!$isLocationField) {
+        continue;
+      }
       $locField = explode('_', $key);
       $fieldName = $locField[2];
       $fieldCount = $locField[3];
@@ -2409,4 +2161,327 @@ INNER JOIN  civicrm_membership membership2 ON membership1.membership_type_id = m
     }
   }
 
+  /**
+   * Replace the pseudo QFKey with zero if it is present.
+   *
+   * @todo - on the slim chance this is still relevant it should be moved to the form layer.
+   *
+   * Details about this bug are somewhat obscured by the move from svn but perhaps JIRA
+   * can still help.
+   *
+   * @param array $migrationInfo
+   */
+  protected static function swapOutFieldsAffectedByQFZeroBug(&$migrationInfo) {
+    $qfZeroBug = 'e8cddb72-a257-11dc-b9cc-0016d3330ee9';
+    foreach ($migrationInfo as $key => &$value) {
+      if ($value == $qfZeroBug) {
+        $value = '0';
+      }
+    }
+  }
+
+  /**
+   * Honestly - what DOES this do - hopefully some refactoring will reveal it's purpose.
+   *
+   * @param $mainId
+   * @param $key
+   * @param $cFields
+   * @param $customFiles
+   * @param $submitted
+   * @param $value
+   *
+   * @return array
+   */
+  protected static function processCustomFields($mainId, $key, $cFields, $customFiles, $submitted, $value) {
+    if (substr($key, 0, 7) == 'custom_') {
+      $fid = (int) substr($key, 7);
+      if (empty($cFields[$fid])) {
+        return [$cFields, $customFiles, $submitted];
+      }
+      $htmlType = $cFields[$fid]['attributes']['html_type'];
+      switch ($htmlType) {
+        case 'File':
+          $customFiles[] = $fid;
+          unset($submitted["custom_$fid"]);
+          break;
+
+        case 'Select Country':
+        case 'Select State/Province':
+          $submitted[$key] = CRM_Core_BAO_CustomField::displayValue($value, $fid);
+          break;
+
+        case 'Select Date':
+          if ($cFields[$fid]['attributes']['is_view']) {
+            $submitted[$key] = date('YmdHis', strtotime($submitted[$key]));
+          }
+          break;
+
+        case 'CheckBox':
+        case 'Multi-Select':
+        case 'Multi-Select Country':
+        case 'Multi-Select State/Province':
+          // Merge values from both contacts for multivalue fields, CRM-4385
+          // get the existing custom values from db.
+          $customParams = ['entityID' => $mainId, $key => TRUE];
+          $customfieldValues = CRM_Core_BAO_CustomValueTable::getValues($customParams);
+          if (!empty($customfieldValues[$key])) {
+            $existingValue = explode(CRM_Core_DAO::VALUE_SEPARATOR, $customfieldValues[$key]);
+            if (is_array($existingValue) && !empty($existingValue)) {
+              $mergeValue = $submittedCustomFields = [];
+              if ($value == 'null') {
+                // CRM-19074 if someone has deliberately chosen to overwrite with 'null', respect it.
+                $submitted[$key] = $value;
+              }
+              else {
+                if ($value) {
+                  $submittedCustomFields = explode(CRM_Core_DAO::VALUE_SEPARATOR, $value);
+                }
+
+                // CRM-19653: overwrite or add the existing custom field value with dupicate contact's
+                // custom field value stored at $submittedCustomValue.
+                foreach ($submittedCustomFields as $k => $v) {
+                  if ($v != '' && !in_array($v, $mergeValue)) {
+                    $mergeValue[] = $v;
+                  }
+                }
+
+                //keep state and country as array format.
+                //for checkbox and m-select format w/ VALUE_SEPARATOR
+                if (in_array($htmlType, [
+                  'CheckBox',
+                  'Multi-Select',
+                ])) {
+                  $submitted[$key] = CRM_Core_DAO::VALUE_SEPARATOR . implode(CRM_Core_DAO::VALUE_SEPARATOR,
+                      $mergeValue
+                    ) . CRM_Core_DAO::VALUE_SEPARATOR;
+                }
+                else {
+                  $submitted[$key] = $mergeValue;
+                }
+              }
+            }
+          }
+          elseif (in_array($htmlType, [
+            'Multi-Select Country',
+            'Multi-Select State/Province',
+          ])) {
+            //we require submitted values should be in array format
+            if ($value) {
+              $mergeValueArray = explode(CRM_Core_DAO::VALUE_SEPARATOR, $value);
+              //hack to remove null values from array.
+              $mergeValue = [];
+              foreach ($mergeValueArray as $k => $v) {
+                if ($v != '') {
+                  $mergeValue[] = $v;
+                }
+              }
+              $submitted[$key] = $mergeValue;
+            }
+          }
+          break;
+
+        default:
+          break;
+      }
+    }
+    return [$cFields, $customFiles, $submitted];
+  }
+
+  /**
+   * Get metadata for the custom fields for the merge.
+   *
+   * @param string $contactType
+   *
+   * @return array
+   */
+  protected static function getCustomFieldMetadata($contactType) {
+    $treeCache = [];
+    if (!array_key_exists($contactType, $treeCache)) {
+      $treeCache[$contactType] = CRM_Core_BAO_CustomGroup::getTree(
+        $contactType,
+        NULL,
+        NULL,
+        -1,
+        [],
+        NULL,
+        TRUE,
+        NULL,
+        FALSE,
+        FALSE
+      );
+    }
+
+    $cFields = [];
+    foreach ($treeCache[$contactType] as $key => $group) {
+      if (!isset($group['fields'])) {
+        continue;
+      }
+      foreach ($group['fields'] as $fid => $field) {
+        $cFields[$fid]['attributes'] = $field;
+      }
+    }
+    return $cFields;
+  }
+
+  /**
+   * Get conflicts for proposed merge pair.
+   *
+   * @param array $migrationInfo
+   *   This is primarily to inform hooks. The can also modify it which feels
+   *   pretty fragile to do it here - but it is historical.
+   * @param int $mainId
+   *   Main contact with whom merge has to happen.
+   * @param int $otherId
+   *   Duplicate contact which would be deleted after merge operation.
+   * @param string $mode
+   *   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).
+   *
+   * @return array
+   */
+  public static function getConflicts(&$migrationInfo, $mainId, $otherId, $mode) {
+    $conflicts = [];
+    $originalMigrationInfo = $migrationInfo;
+    foreach ($migrationInfo as $key => $val) {
+      if ($val === "null") {
+        // Rule: Never overwrite with an empty value (in any mode)
+        unset($migrationInfo[$key]);
+        continue;
+      }
+      elseif ((in_array(substr($key, 5), CRM_Dedupe_Merger::getContactFields()) or
+          substr($key, 0, 12) == 'move_custom_'
+        ) and $val != NULL
+      ) {
+        // Rule: If both main-contact, and other-contact have a field with a
+        // different value, then let $mode decide if to merge it or not
+        if (
+          (!empty($migrationInfo['rows'][$key]['main'])
+            // For custom fields a 0 (e.g in an int field) could be a true conflict. This
+            // is probably true for other fields too - e.g. 'do_not_email' but
+            // leaving that investigation as a @todo - until tests can be written.
+            // Note the handling of this has test coverage - although the data-typing
+            // of '0' feels flakey we have insurance.
+            || ($migrationInfo['rows'][$key]['main'] === '0' && substr($key, 0, 12) == 'move_custom_')
+          )
+          && $migrationInfo['rows'][$key]['main'] != $migrationInfo['rows'][$key]['other']
+        ) {
+
+          // note it down & lets wait for response from the hook.
+          // For no response $mode will decide if to skip this merge
+          $conflicts[$key] = NULL;
+        }
+      }
+      elseif (substr($key, 0, 14) == 'move_location_' and $val != NULL) {
+        $locField = explode('_', $key);
+        $fieldName = $locField[2];
+        $fieldCount = $locField[3];
+
+        // Rule: Catch address conflicts (same address type on both contacts)
+        if (
+          isset($migrationInfo['main_details']['location_blocks'][$fieldName]) &&
+          !empty($migrationInfo['main_details']['location_blocks'][$fieldName])
+        ) {
+
+          // Load the address we're inspecting from the 'other' contact
+          $addressRecord = $migrationInfo['other_details']['location_blocks'][$fieldName][$fieldCount];
+          $addressRecordLocTypeId = CRM_Utils_Array::value('location_type_id', $addressRecord);
+
+          // If it exists on the 'main' contact already, skip it. Otherwise
+          // if the location type exists already, log a conflict.
+          foreach ($migrationInfo['main_details']['location_blocks'][$fieldName] as $mainAddressKey => $mainAddressRecord) {
+            if (self::locationIsSame($addressRecord, $mainAddressRecord)) {
+              unset($migrationInfo[$key]);
+              break;
+            }
+            elseif ($addressRecordLocTypeId == $mainAddressRecord['location_type_id']) {
+              $conflicts[$key] = NULL;
+              break;
+            }
+          }
+        }
+
+        // For other locations, don't merge/add if the values are the same
+        elseif (CRM_Utils_Array::value('main', $migrationInfo['rows'][$key]) == $migrationInfo['rows'][$key]['other']) {
+          unset($migrationInfo[$key]);
+        }
+      }
+    }
+
+    // A hook to implement other algorithms for choosing which contact to bias to when
+    // there's a conflict (to handle "gotchas"). fields_in_conflict could be modified here
+    // merge happens with new values filled in here. For a particular field / row not to be merged
+    // field should be unset from fields_in_conflict.
+    $migrationData = [
+      'old_migration_info' => $originalMigrationInfo,
+      'mode' => $mode,
+      'fields_in_conflict' => $conflicts,
+      'merge_mode' => $mode,
+      'migration_info' => $migrationInfo,
+    ];
+    CRM_Utils_Hook::merge('batch', $migrationData, $mainId, $otherId);
+    $conflicts = $migrationData['fields_in_conflict'];
+    // allow hook to override / manipulate migrationInfo as well
+    $migrationInfo = $migrationData['migration_info'];
+    $migrationInfo['skip_merge'] = CRM_Utils_Array::value('skip_merge', $migrationData);
+    return $conflicts;
+  }
+
+  /**
+   * Do file custom fields related migrations.
+   * FIXME: move this someplace else (one of the BAOs) after discussing
+   * where to, and whether CRM_Core_BAO_File::deleteFileReferences() shouldn't actually,
+   * like, delete a file...
+   *
+   * Note outstanding bug https://lab.civicrm.org/dev/core/issues/723
+   * relates to this code....
+   *
+   * @param $mainId
+   * @param $otherId
+   * @param $customFiles
+   */
+  protected static function processCustomFieldFiles($mainId, $otherId, $customFiles) {
+    foreach ($customFiles as $customId) {
+      list($tableName, $columnName, $groupID) = CRM_Core_BAO_CustomField::getTableColumnGroup($customId);
+
+      // get the contact_id -> file_id mapping
+      $fileIds = [];
+      $sql = "SELECT entity_id, {$columnName} AS file_id FROM {$tableName} WHERE entity_id IN ({$mainId}, {$otherId})";
+      $dao = CRM_Core_DAO::executeQuery($sql);
+      while ($dao->fetch()) {
+        $fileIds[$dao->entity_id] = $dao->file_id;
+        if ($dao->entity_id == $mainId) {
+          CRM_Core_BAO_File::deleteFileReferences($fileIds[$mainId], $mainId, $customId);
+        }
+      }
+
+      // move the other contact's file to main contact
+      //NYSS need to INSERT or UPDATE depending on whether main contact has an existing record
+      if (CRM_Core_DAO::singleValueQuery("SELECT id FROM {$tableName} WHERE entity_id = {$mainId}")) {
+        $sql = "UPDATE {$tableName} SET {$columnName} = {$fileIds[$otherId]} WHERE entity_id = {$mainId}";
+      }
+      else {
+        $sql = "INSERT INTO {$tableName} ( entity_id, {$columnName} ) VALUES ( {$mainId}, {$fileIds[$otherId]} )";
+      }
+      CRM_Core_DAO::executeQuery($sql);
+
+      if (CRM_Core_DAO::singleValueQuery("
+        SELECT id
+        FROM civicrm_entity_file
+        WHERE entity_table = '{$tableName}' AND file_id = {$fileIds[$otherId]}")
+      ) {
+        $sql = "
+          UPDATE civicrm_entity_file
+          SET entity_id = {$mainId}
+          WHERE entity_table = '{$tableName}' AND file_id = {$fileIds[$otherId]}";
+      }
+      else {
+        $sql = "
+          INSERT INTO civicrm_entity_file ( entity_table, entity_id, file_id )
+          VALUES ( '{$tableName}', {$mainId}, {$fileIds[$otherId]} )";
+      }
+      CRM_Core_DAO::executeQuery($sql);
+    }
+  }
+
 }
diff --git a/civicrm/CRM/Event/Cart/DAO/Cart.php b/civicrm/CRM/Event/Cart/DAO/Cart.php
index e953400f05e8794ec74e39de7f141189ea16231f..893b1ba406dd3ccf4378b1508911d20d5174ff79 100644
--- a/civicrm/CRM/Event/Cart/DAO/Cart.php
+++ b/civicrm/CRM/Event/Cart/DAO/Cart.php
@@ -63,7 +63,7 @@ class CRM_Event_Cart_DAO_Cart extends CRM_Core_DAO {
    */
   public static function getReferenceColumns() {
     if (!isset(Civi::$statics[__CLASS__]['links'])) {
-      Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
+      Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
       Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'user_id', 'civicrm_contact', 'id');
       CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
     }
@@ -84,6 +84,7 @@ class CRM_Event_Cart_DAO_Cart extends CRM_Core_DAO {
           'title' => ts('Cart ID'),
           'description' => ts('Cart Id'),
           'required' => TRUE,
+          'where' => 'civicrm_event_carts.id',
           'table_name' => 'civicrm_event_carts',
           'entity' => 'Cart',
           'bao' => 'CRM_Event_Cart_BAO_Cart',
@@ -94,6 +95,7 @@ class CRM_Event_Cart_DAO_Cart extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Created By'),
           'description' => ts('FK to civicrm_contact who created this cart'),
+          'where' => 'civicrm_event_carts.user_id',
           'table_name' => 'civicrm_event_carts',
           'entity' => 'Cart',
           'bao' => 'CRM_Event_Cart_BAO_Cart',
@@ -104,6 +106,7 @@ class CRM_Event_Cart_DAO_Cart extends CRM_Core_DAO {
           'name' => 'completed',
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Complete?'),
+          'where' => 'civicrm_event_carts.completed',
           'default' => '0',
           'table_name' => 'civicrm_event_carts',
           'entity' => 'Cart',
diff --git a/civicrm/CRM/Event/Cart/DAO/EventInCart.php b/civicrm/CRM/Event/Cart/DAO/EventInCart.php
index f0c31b4d318934ebf2f40e5c32db2dbf1c4b00c2..41654c3d24f5b6b2e0bc165f5f9507a79a124843 100644
--- a/civicrm/CRM/Event/Cart/DAO/EventInCart.php
+++ b/civicrm/CRM/Event/Cart/DAO/EventInCart.php
@@ -65,7 +65,7 @@ class CRM_Event_Cart_DAO_EventInCart extends CRM_Core_DAO {
    */
   public static function getReferenceColumns() {
     if (!isset(Civi::$statics[__CLASS__]['links'])) {
-      Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
+      Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
       Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'event_id', 'civicrm_event', 'id');
       Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'event_cart_id', 'civicrm_event_carts', 'id');
       CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
@@ -87,6 +87,7 @@ class CRM_Event_Cart_DAO_EventInCart extends CRM_Core_DAO {
           'title' => ts('Event In Cart'),
           'description' => ts('Event In Cart Id'),
           'required' => TRUE,
+          'where' => 'civicrm_events_in_carts.id',
           'table_name' => 'civicrm_events_in_carts',
           'entity' => 'EventInCart',
           'bao' => 'CRM_Event_Cart_BAO_EventInCart',
@@ -97,6 +98,7 @@ class CRM_Event_Cart_DAO_EventInCart extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Event'),
           'description' => ts('FK to Event ID'),
+          'where' => 'civicrm_events_in_carts.event_id',
           'table_name' => 'civicrm_events_in_carts',
           'entity' => 'EventInCart',
           'bao' => 'CRM_Event_Cart_BAO_EventInCart',
@@ -108,6 +110,7 @@ class CRM_Event_Cart_DAO_EventInCart extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Event In Cart'),
           'description' => ts('FK to Event Cart ID'),
+          'where' => 'civicrm_events_in_carts.event_cart_id',
           'table_name' => 'civicrm_events_in_carts',
           'entity' => 'EventInCart',
           'bao' => 'CRM_Event_Cart_BAO_EventInCart',
diff --git a/civicrm/CRM/Event/Cart/Form/Checkout/ParticipantsAndPrices.php b/civicrm/CRM/Event/Cart/Form/Checkout/ParticipantsAndPrices.php
index a78d34f0263c3f8f0d8258fb0b8c7840b637793b..45767901189b3f8324c87fd0748b1311160f6861 100644
--- a/civicrm/CRM/Event/Cart/Form/Checkout/ParticipantsAndPrices.php
+++ b/civicrm/CRM/Event/Cart/Form/Checkout/ParticipantsAndPrices.php
@@ -151,6 +151,11 @@ class CRM_Event_Cart_Form_Checkout_ParticipantsAndPrices extends CRM_Event_Cart_
         }
       }
 
+      // Validate if participant is already registered
+      if ($event_in_cart->event->allow_same_participant_emails) {
+        continue;
+      }
+
       foreach ($event_in_cart->participants as $mer_participant) {
         $participant_fields = $fields['event'][$event_in_cart->event_id]['participant'][$mer_participant->id];
         //TODO what to do when profile responses differ for the same contact?
diff --git a/civicrm/CRM/Event/Cart/Form/Checkout/Payment.php b/civicrm/CRM/Event/Cart/Form/Checkout/Payment.php
index d6906fd94ce61da937f21bf09938857bb08b26d8..143096e3525826f0ec24af0a33f7bcf5b880c73a 100644
--- a/civicrm/CRM/Event/Cart/Form/Checkout/Payment.php
+++ b/civicrm/CRM/Event/Cart/Form/Checkout/Payment.php
@@ -175,6 +175,10 @@ class CRM_Event_Cart_Form_Checkout_Payment extends CRM_Event_Cart_Form_Cart {
       );
       $this->assign('pay_later_instructions', $this->pay_later_receipt);
     }
+
+    // Event Cart does not support multiple payment processors
+    // so we cannot call $this->preProcessPaymentOptions();
+    CRM_Financial_Form_Payment::addCreditCardJs($this->_paymentProcessor['id']);
   }
 
   /**
@@ -351,7 +355,7 @@ class CRM_Event_Cart_Form_Checkout_Payment extends CRM_Event_Cart_Form_Cart {
     $send_template_params = [
       'table' => 'civicrm_msg_template',
       'contactId' => $this->payer_contact_id,
-      'from' => CRM_Core_BAO_Domain::getNameAndEmail(TRUE, TRUE),
+      'from' => current(CRM_Core_BAO_Domain::getNameAndEmail(TRUE, TRUE)),
       'groupName' => 'msg_tpl_workflow_event',
       'isTest' => FALSE,
       'toEmail' => $contact_details[1],
@@ -502,6 +506,8 @@ class CRM_Event_Cart_Form_Checkout_Payment extends CRM_Event_Cart_Form_Cart {
         $ctype,
         TRUE
       );
+
+      $params['contact_id'] = $this->payer_contact_id;
     }
 
     $params['now'] = date('YmdHis');
diff --git a/civicrm/CRM/Event/DAO/Event.php b/civicrm/CRM/Event/DAO/Event.php
index 3febfd099d382bee5b6850856c6dd44ab07e8a23..f5f563ec182619b6871b54c65ffafc4df3c5c732 100644
--- a/civicrm/CRM/Event/DAO/Event.php
+++ b/civicrm/CRM/Event/DAO/Event.php
@@ -549,6 +549,7 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
           'title' => ts('Event ID'),
           'description' => ts('Event'),
           'required' => TRUE,
+          'where' => 'civicrm_event.id',
           'table_name' => 'civicrm_event',
           'entity' => 'Event',
           'bao' => 'CRM_Event_BAO_Event',
@@ -564,7 +565,6 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
           'import' => TRUE,
           'where' => 'civicrm_event.title',
           'headerPattern' => '/(event.)?title$/i',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_event',
           'entity' => 'Event',
@@ -581,6 +581,7 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
           'description' => ts('Brief summary of event. Text and html allowed. Displayed on Event Registration form and can be used on other CMS pages which need an event summary.'),
           'rows' => 4,
           'cols' => 60,
+          'where' => 'civicrm_event.summary',
           'table_name' => 'civicrm_event',
           'entity' => 'Event',
           'bao' => 'CRM_Event_BAO_Event',
@@ -596,6 +597,7 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
           'description' => ts('Full description of event. Text and html allowed. Displayed on built-in Event Information screens.'),
           'rows' => 8,
           'cols' => 60,
+          'where' => 'civicrm_event.description',
           'table_name' => 'civicrm_event',
           'entity' => 'Event',
           'bao' => 'CRM_Event_BAO_Event',
@@ -609,6 +611,7 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Event Type'),
           'description' => ts('Event Type ID.Implicit FK to civicrm_option_value where option_group = event_type.'),
+          'where' => 'civicrm_event.event_type_id',
           'default' => '0',
           'table_name' => 'civicrm_event',
           'entity' => 'Event',
@@ -627,6 +630,7 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Participant Listing'),
           'description' => ts('Should we expose the participant list? Implicit FK to civicrm_option_value where option_group = participant_listing.'),
+          'where' => 'civicrm_event.participant_listing_id',
           'default' => '0',
           'table_name' => 'civicrm_event',
           'entity' => 'Event',
@@ -645,6 +649,7 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Is Event Public'),
           'description' => ts('Public events will be included in the iCal feeds. Access to private event information may be limited using ACLs.'),
+          'where' => 'civicrm_event.is_public',
           'default' => '1',
           'table_name' => 'civicrm_event',
           'entity' => 'Event',
@@ -662,7 +667,6 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
           'import' => TRUE,
           'where' => 'civicrm_event.start_date',
           'headerPattern' => '/^start|(s(tart\s)?date)$/i',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_event',
           'entity' => 'Event',
@@ -681,7 +685,6 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
           'import' => TRUE,
           'where' => 'civicrm_event.end_date',
           'headerPattern' => '/^end|(e(nd\s)?date)$/i',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_event',
           'entity' => 'Event',
@@ -697,6 +700,7 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Is Online Registration'),
           'description' => ts('If true, include registration link on Event Info page.'),
+          'where' => 'civicrm_event.is_online_registration',
           'default' => '0',
           'table_name' => 'civicrm_event',
           'entity' => 'Event',
@@ -713,6 +717,7 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
           'description' => ts('Text for link to Event Registration form which is displayed on Event Information screen when is_online_registration is true.'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_event.registration_link_text',
           'table_name' => 'civicrm_event',
           'entity' => 'Event',
           'bao' => 'CRM_Event_BAO_Event',
@@ -726,6 +731,7 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
           'title' => ts('Registration Start Date'),
           'description' => ts('Date and time that online registration starts.'),
+          'where' => 'civicrm_event.registration_start_date',
           'table_name' => 'civicrm_event',
           'entity' => 'Event',
           'bao' => 'CRM_Event_BAO_Event',
@@ -740,6 +746,7 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
           'title' => ts('Registration End Date'),
           'description' => ts('Date and time that online registration ends.'),
+          'where' => 'civicrm_event.registration_end_date',
           'table_name' => 'civicrm_event',
           'entity' => 'Event',
           'bao' => 'CRM_Event_BAO_Event',
@@ -754,6 +761,7 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Max Participants'),
           'description' => ts('Maximum number of registered participants to allow. After max is reached, a custom Event Full message is displayed. If NULL, allow unlimited number of participants.'),
+          'where' => 'civicrm_event.max_participants',
           'default' => 'NULL',
           'table_name' => 'civicrm_event',
           'entity' => 'Event',
@@ -770,6 +778,7 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
           'description' => ts('Message to display on Event Information page and INSTEAD OF Event Registration form if maximum participants are signed up. Can include email address/info about getting on a waiting list, etc. Text and html allowed.'),
           'rows' => 4,
           'cols' => 60,
+          'where' => 'civicrm_event.event_full_text',
           'table_name' => 'civicrm_event',
           'entity' => 'Event',
           'bao' => 'CRM_Event_BAO_Event',
@@ -783,6 +792,7 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Is this a PAID event?'),
           'description' => ts('If true, one or more fee amounts must be set and a Payment Processor must be configured for Online Event Registration.'),
+          'where' => 'civicrm_event.is_monetary',
           'default' => '0',
           'table_name' => 'civicrm_event',
           'entity' => 'Event',
@@ -797,6 +807,7 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Financial Type'),
           'description' => ts('Financial type assigned to paid event registrations for this event. Required if is_monetary is true.'),
+          'where' => 'civicrm_event.financial_type_id',
           'default' => 'NULL',
           'table_name' => 'civicrm_event',
           'entity' => 'Event',
@@ -818,6 +829,7 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
           'description' => ts('Payment Processors configured for this Event (if is_monetary is true)'),
           'maxlength' => 128,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_event.payment_processor',
           'table_name' => 'civicrm_event',
           'entity' => 'Event',
           'bao' => 'CRM_Event_BAO_Event',
@@ -836,6 +848,7 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Map Enabled'),
           'description' => ts('Include a map block on the Event Information page when geocode info is available and a mapping provider has been specified?'),
+          'where' => 'civicrm_event.is_map',
           'default' => '0',
           'table_name' => 'civicrm_event',
           'entity' => 'Event',
@@ -850,6 +863,7 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Is Active'),
           'description' => ts('Is this Event enabled or disabled/cancelled?'),
+          'where' => 'civicrm_event.is_active',
           'default' => '0',
           'table_name' => 'civicrm_event',
           'entity' => 'Event',
@@ -868,7 +882,6 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
           'import' => TRUE,
           'where' => 'civicrm_event.fee_label',
           'headerPattern' => '/^fee|(f(ee\s)?label)$/i',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_event',
           'entity' => 'Event',
@@ -883,6 +896,7 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('show location'),
           'description' => ts('If true, show event location.'),
+          'where' => 'civicrm_event.is_show_location',
           'default' => '1',
           'table_name' => 'civicrm_event',
           'entity' => 'Event',
@@ -897,6 +911,7 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Location Block ID'),
           'description' => ts('FK to Location Block ID'),
+          'where' => 'civicrm_event.loc_block_id',
           'table_name' => 'civicrm_event',
           'entity' => 'Event',
           'bao' => 'CRM_Event_BAO_Event',
@@ -910,8 +925,6 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
           'description' => ts('Participant role ID. Implicit FK to civicrm_option_value where option_group = participant_role.'),
           'import' => TRUE,
           'where' => 'civicrm_event.default_role_id',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'default' => '1',
           'table_name' => 'civicrm_event',
@@ -933,6 +946,7 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
           'description' => ts('Introductory message for Event Registration page. Text and html allowed. Displayed at the top of Event Registration form.'),
           'rows' => 6,
           'cols' => 50,
+          'where' => 'civicrm_event.intro_text',
           'table_name' => 'civicrm_event',
           'entity' => 'Event',
           'bao' => 'CRM_Event_BAO_Event',
@@ -948,6 +962,7 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
           'description' => ts('Footer message for Event Registration page. Text and html allowed. Displayed at the bottom of Event Registration form.'),
           'rows' => 6,
           'cols' => 50,
+          'where' => 'civicrm_event.footer_text',
           'table_name' => 'civicrm_event',
           'entity' => 'Event',
           'bao' => 'CRM_Event_BAO_Event',
@@ -963,6 +978,7 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
           'description' => ts('Title for Confirmation page.'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_event.confirm_title',
           'default' => 'NULL',
           'table_name' => 'civicrm_event',
           'entity' => 'Event',
@@ -979,6 +995,7 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
           'description' => ts('Introductory message for Event Registration page. Text and html allowed. Displayed at the top of Event Registration form.'),
           'rows' => 6,
           'cols' => 50,
+          'where' => 'civicrm_event.confirm_text',
           'table_name' => 'civicrm_event',
           'entity' => 'Event',
           'bao' => 'CRM_Event_BAO_Event',
@@ -994,6 +1011,7 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
           'description' => ts('Footer message for Event Registration page. Text and html allowed. Displayed at the bottom of Event Registration form.'),
           'rows' => 6,
           'cols' => 50,
+          'where' => 'civicrm_event.confirm_footer_text',
           'table_name' => 'civicrm_event',
           'entity' => 'Event',
           'bao' => 'CRM_Event_BAO_Event',
@@ -1007,6 +1025,7 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Is confirm email'),
           'description' => ts('If true, confirmation is automatically emailed to contact on successful registration.'),
+          'where' => 'civicrm_event.is_email_confirm',
           'default' => '0',
           'table_name' => 'civicrm_event',
           'entity' => 'Event',
@@ -1023,6 +1042,7 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
           'description' => ts('text to include above standard event info on confirmation email. emails are text-only, so do not allow html for now'),
           'rows' => 4,
           'cols' => 50,
+          'where' => 'civicrm_event.confirm_email_text',
           'table_name' => 'civicrm_event',
           'entity' => 'Event',
           'bao' => 'CRM_Event_BAO_Event',
@@ -1038,6 +1058,7 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
           'description' => ts('FROM email name used for confirmation emails.'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_event.confirm_from_name',
           'table_name' => 'civicrm_event',
           'entity' => 'Event',
           'bao' => 'CRM_Event_BAO_Event',
@@ -1053,6 +1074,7 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
           'description' => ts('FROM email address used for confirmation emails.'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_event.confirm_from_email',
           'table_name' => 'civicrm_event',
           'entity' => 'Event',
           'bao' => 'CRM_Event_BAO_Event',
@@ -1068,6 +1090,7 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
           'description' => ts('comma-separated list of email addresses to cc each time a confirmation is sent'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_event.cc_confirm',
           'table_name' => 'civicrm_event',
           'entity' => 'Event',
           'bao' => 'CRM_Event_BAO_Event',
@@ -1083,6 +1106,7 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
           'description' => ts('comma-separated list of email addresses to bcc each time a confirmation is sent'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_event.bcc_confirm',
           'table_name' => 'civicrm_event',
           'entity' => 'Event',
           'bao' => 'CRM_Event_BAO_Event',
@@ -1096,6 +1120,7 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Default Fee ID'),
           'description' => ts('FK to civicrm_option_value.'),
+          'where' => 'civicrm_event.default_fee_id',
           'table_name' => 'civicrm_event',
           'entity' => 'Event',
           'bao' => 'CRM_Event_BAO_Event',
@@ -1106,6 +1131,7 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Default Discount Fee ID'),
           'description' => ts('FK to civicrm_option_value.'),
+          'where' => 'civicrm_event.default_discount_fee_id',
           'table_name' => 'civicrm_event',
           'entity' => 'Event',
           'bao' => 'CRM_Event_BAO_Event',
@@ -1118,6 +1144,7 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
           'description' => ts('Title for ThankYou page.'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_event.thankyou_title',
           'default' => 'NULL',
           'table_name' => 'civicrm_event',
           'entity' => 'Event',
@@ -1134,6 +1161,7 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
           'description' => ts('ThankYou Text.'),
           'rows' => 6,
           'cols' => 50,
+          'where' => 'civicrm_event.thankyou_text',
           'table_name' => 'civicrm_event',
           'entity' => 'Event',
           'bao' => 'CRM_Event_BAO_Event',
@@ -1149,6 +1177,7 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
           'description' => ts('Footer message.'),
           'rows' => 6,
           'cols' => 50,
+          'where' => 'civicrm_event.thankyou_footer_text',
           'table_name' => 'civicrm_event',
           'entity' => 'Event',
           'bao' => 'CRM_Event_BAO_Event',
@@ -1162,6 +1191,7 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Pay Later Allowed'),
           'description' => ts('if true - allows the user to send payment directly to the org later'),
+          'where' => 'civicrm_event.is_pay_later',
           'default' => '0',
           'table_name' => 'civicrm_event',
           'entity' => 'Event',
@@ -1176,6 +1206,7 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_TEXT,
           'title' => ts('Pay Later Text'),
           'description' => ts('The text displayed to the user in the main form'),
+          'where' => 'civicrm_event.pay_later_text',
           'table_name' => 'civicrm_event',
           'entity' => 'Event',
           'bao' => 'CRM_Event_BAO_Event',
@@ -1189,6 +1220,7 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_TEXT,
           'title' => ts('Pay Later Receipt Text'),
           'description' => ts('The receipt sent to the user instead of the normal receipt text'),
+          'where' => 'civicrm_event.pay_later_receipt',
           'table_name' => 'civicrm_event',
           'entity' => 'Event',
           'bao' => 'CRM_Event_BAO_Event',
@@ -1202,6 +1234,7 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Partial Payments Enabled'),
           'description' => ts('is partial payment enabled for this event'),
+          'where' => 'civicrm_event.is_partial_payment',
           'default' => '0',
           'table_name' => 'civicrm_event',
           'entity' => 'Event',
@@ -1218,6 +1251,7 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
           'description' => ts('Initial amount label for partial payment'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_event.initial_amount_label',
           'table_name' => 'civicrm_event',
           'entity' => 'Event',
           'bao' => 'CRM_Event_BAO_Event',
@@ -1231,6 +1265,7 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_TEXT,
           'title' => ts('Initial Amount Help Text'),
           'description' => ts('Initial amount help text for partial payment'),
+          'where' => 'civicrm_event.initial_amount_help_text',
           'table_name' => 'civicrm_event',
           'entity' => 'Event',
           'bao' => 'CRM_Event_BAO_Event',
@@ -1248,6 +1283,7 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
             20,
             2
           ],
+          'where' => 'civicrm_event.min_initial_amount',
           'table_name' => 'civicrm_event',
           'entity' => 'Event',
           'bao' => 'CRM_Event_BAO_Event',
@@ -1261,6 +1297,7 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Allow Multiple Registrations'),
           'description' => ts('if true - allows the user to register multiple participants for event'),
+          'where' => 'civicrm_event.is_multiple_registrations',
           'default' => '0',
           'table_name' => 'civicrm_event',
           'entity' => 'Event',
@@ -1275,6 +1312,7 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Maximum number of additional participants per registration'),
           'description' => ts('Maximum number of additional participants that can be registered on a single booking'),
+          'where' => 'civicrm_event.max_additional_participants',
           'default' => '0',
           'table_name' => 'civicrm_event',
           'entity' => 'Event',
@@ -1286,6 +1324,7 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Does Event allow multiple registrations from same email address?'),
           'description' => ts('if true - allows the user to register multiple registrations from same email address.'),
+          'where' => 'civicrm_event.allow_same_participant_emails',
           'default' => '0',
           'table_name' => 'civicrm_event',
           'entity' => 'Event',
@@ -1300,6 +1339,7 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Waitlist Enabled'),
           'description' => ts('Whether the event has waitlist support.'),
+          'where' => 'civicrm_event.has_waitlist',
           'table_name' => 'civicrm_event',
           'entity' => 'Event',
           'bao' => 'CRM_Event_BAO_Event',
@@ -1313,6 +1353,7 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Requires Approval'),
           'description' => ts('Whether participants require approval before they can finish registering.'),
+          'where' => 'civicrm_event.requires_approval',
           'table_name' => 'civicrm_event',
           'entity' => 'Event',
           'bao' => 'CRM_Event_BAO_Event',
@@ -1326,6 +1367,7 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Expiration Time'),
           'description' => ts('Expire pending but unconfirmed registrations after this many hours.'),
+          'where' => 'civicrm_event.expiration_time',
           'table_name' => 'civicrm_event',
           'entity' => 'Event',
           'bao' => 'CRM_Event_BAO_Event',
@@ -1339,6 +1381,7 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Allow Self-service Cancellation or Transfer'),
           'description' => ts('Allow self service cancellation or transfer for event?'),
+          'where' => 'civicrm_event.allow_selfcancelxfer',
           'default' => '0',
           'table_name' => 'civicrm_event',
           'entity' => 'Event',
@@ -1353,6 +1396,7 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Self-service Cancellation or Transfer Time'),
           'description' => ts('Number of hours prior to event start date to allow self-service cancellation or transfer.'),
+          'where' => 'civicrm_event.selfcancelxfer_time',
           'default' => '0',
           'table_name' => 'civicrm_event',
           'entity' => 'Event',
@@ -1369,6 +1413,7 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
           'description' => ts('Text to display when the event is full, but participants can signup for a waitlist.'),
           'rows' => 4,
           'cols' => 60,
+          'where' => 'civicrm_event.waitlist_text',
           'table_name' => 'civicrm_event',
           'entity' => 'Event',
           'bao' => 'CRM_Event_BAO_Event',
@@ -1384,6 +1429,7 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
           'description' => ts('Text to display when the approval is required to complete registration for an event.'),
           'rows' => 4,
           'cols' => 60,
+          'where' => 'civicrm_event.approval_req_text',
           'table_name' => 'civicrm_event',
           'entity' => 'Event',
           'bao' => 'CRM_Event_BAO_Event',
@@ -1398,6 +1444,7 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
           'title' => ts('Is an Event Template'),
           'description' => ts('whether the event has template'),
           'required' => TRUE,
+          'where' => 'civicrm_event.is_template',
           'default' => '0',
           'table_name' => 'civicrm_event',
           'entity' => 'Event',
@@ -1417,7 +1464,6 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
           'import' => TRUE,
           'where' => 'civicrm_event.template_title',
           'headerPattern' => '/(template.)?title$/i',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_event',
           'entity' => 'Event',
@@ -1432,6 +1478,7 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Created By Contact ID'),
           'description' => ts('FK to civicrm_contact, who created this event'),
+          'where' => 'civicrm_event.created_id',
           'table_name' => 'civicrm_event',
           'entity' => 'Event',
           'bao' => 'CRM_Event_BAO_Event',
@@ -1443,6 +1490,7 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
           'title' => ts('Event Created Date'),
           'description' => ts('Date and time that event was created.'),
+          'where' => 'civicrm_event.created_date',
           'table_name' => 'civicrm_event',
           'entity' => 'Event',
           'bao' => 'CRM_Event_BAO_Event',
@@ -1479,6 +1527,7 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Campaign'),
           'description' => ts('The campaign for which this event has been created.'),
+          'where' => 'civicrm_event.campaign_id',
           'table_name' => 'civicrm_event',
           'entity' => 'Event',
           'bao' => 'CRM_Event_BAO_Event',
@@ -1498,6 +1547,7 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Is shared through social media'),
           'description' => ts('Can people share the event through social media?'),
+          'where' => 'civicrm_event.is_share',
           'default' => '1',
           'table_name' => 'civicrm_event',
           'entity' => 'Event',
@@ -1512,6 +1562,7 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Is the booking confirmation screen enabled?'),
           'description' => ts('If false, the event booking confirmation screen gets skipped'),
+          'where' => 'civicrm_event.is_confirm_enabled',
           'default' => '1',
           'table_name' => 'civicrm_event',
           'entity' => 'Event',
@@ -1526,6 +1577,7 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Parent Event ID'),
           'description' => ts('Implicit FK to civicrm_event: parent event'),
+          'where' => 'civicrm_event.parent_event_id',
           'default' => 'NULL',
           'table_name' => 'civicrm_event',
           'entity' => 'Event',
@@ -1540,6 +1592,7 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Subevent Slot Label ID'),
           'description' => ts('Subevent slot label. Implicit FK to civicrm_option_value where option_group = conference_slot.'),
+          'where' => 'civicrm_event.slot_label_id',
           'default' => 'NULL',
           'table_name' => 'civicrm_event',
           'entity' => 'Event',
@@ -1554,6 +1607,7 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Dedupe Rule'),
           'description' => ts('Rule to use when matching registrations for this event'),
+          'where' => 'civicrm_event.dedupe_rule_group_id',
           'default' => 'NULL',
           'table_name' => 'civicrm_event',
           'entity' => 'Event',
@@ -1575,6 +1629,7 @@ class CRM_Event_DAO_Event extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Is billing block required'),
           'description' => ts('if true than billing block is required this event'),
+          'where' => 'civicrm_event.is_billing_required',
           'default' => '0',
           'table_name' => 'civicrm_event',
           'entity' => 'Event',
diff --git a/civicrm/CRM/Event/DAO/Participant.php b/civicrm/CRM/Event/DAO/Participant.php
index 93be1828dbd886ffbd920affcda21923e17291ee..fc7aaccb3840f4590232b2e6c0c5efe5d43a9b2b 100644
--- a/civicrm/CRM/Event/DAO/Participant.php
+++ b/civicrm/CRM/Event/DAO/Participant.php
@@ -205,7 +205,6 @@ class CRM_Event_DAO_Participant extends CRM_Core_DAO {
           'import' => TRUE,
           'where' => 'civicrm_participant.id',
           'headerPattern' => '/(^(participant(.)?)?id$)/i',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_participant',
           'entity' => 'Participant',
@@ -221,7 +220,6 @@ class CRM_Event_DAO_Participant extends CRM_Core_DAO {
           'import' => TRUE,
           'where' => 'civicrm_participant.contact_id',
           'headerPattern' => '/contact(.?id)?/i',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_participant',
           'entity' => 'Participant',
@@ -238,7 +236,6 @@ class CRM_Event_DAO_Participant extends CRM_Core_DAO {
           'import' => TRUE,
           'where' => 'civicrm_participant.event_id',
           'headerPattern' => '/event id$/i',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_participant',
           'entity' => 'Participant',
@@ -255,7 +252,6 @@ class CRM_Event_DAO_Participant extends CRM_Core_DAO {
           'import' => TRUE,
           'where' => 'civicrm_participant.status_id',
           'headerPattern' => '/(participant.)?(status)$/i',
-          'dataPattern' => '',
           'export' => TRUE,
           'default' => '1',
           'table_name' => 'civicrm_participant',
@@ -282,7 +278,6 @@ class CRM_Event_DAO_Participant extends CRM_Core_DAO {
           'import' => TRUE,
           'where' => 'civicrm_participant.role_id',
           'headerPattern' => '/(participant.)?(role)$/i',
-          'dataPattern' => '',
           'export' => TRUE,
           'default' => 'NULL',
           'table_name' => 'civicrm_participant',
@@ -306,7 +301,6 @@ class CRM_Event_DAO_Participant extends CRM_Core_DAO {
           'import' => TRUE,
           'where' => 'civicrm_participant.register_date',
           'headerPattern' => '/^(r(egister\s)?date)$/i',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_participant',
           'entity' => 'Participant',
@@ -327,7 +321,6 @@ class CRM_Event_DAO_Participant extends CRM_Core_DAO {
           'import' => TRUE,
           'where' => 'civicrm_participant.source',
           'headerPattern' => '/(participant.)?(source)$/i',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_participant',
           'entity' => 'Participant',
@@ -347,7 +340,6 @@ class CRM_Event_DAO_Participant extends CRM_Core_DAO {
           'import' => TRUE,
           'where' => 'civicrm_participant.fee_level',
           'headerPattern' => '/^(f(ee\s)?level)$/i',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_participant',
           'entity' => 'Participant',
@@ -361,8 +353,6 @@ class CRM_Event_DAO_Participant extends CRM_Core_DAO {
           'title' => ts('Test'),
           'import' => TRUE,
           'where' => 'civicrm_participant.is_test',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'default' => '0',
           'table_name' => 'civicrm_participant',
@@ -377,7 +367,6 @@ class CRM_Event_DAO_Participant extends CRM_Core_DAO {
           'import' => TRUE,
           'where' => 'civicrm_participant.is_pay_later',
           'headerPattern' => '/(is.)?(pay(.)?later)$/i',
-          'dataPattern' => '',
           'export' => TRUE,
           'default' => '0',
           'table_name' => 'civicrm_participant',
@@ -411,8 +400,6 @@ class CRM_Event_DAO_Participant extends CRM_Core_DAO {
           'description' => ts('FK to Participant ID'),
           'import' => TRUE,
           'where' => 'civicrm_participant.registered_by_id',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'default' => 'NULL',
           'table_name' => 'civicrm_participant',
@@ -426,6 +413,7 @@ class CRM_Event_DAO_Participant extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Discount ID'),
           'description' => ts('FK to Discount ID'),
+          'where' => 'civicrm_participant.discount_id',
           'default' => 'NULL',
           'table_name' => 'civicrm_participant',
           'entity' => 'Participant',
@@ -467,8 +455,6 @@ class CRM_Event_DAO_Participant extends CRM_Core_DAO {
           'description' => ts('The campaign for which this participant has been registered.'),
           'import' => TRUE,
           'where' => 'civicrm_participant.campaign_id',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_participant',
           'entity' => 'Participant',
@@ -486,6 +472,7 @@ class CRM_Event_DAO_Participant extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Discount Amount'),
           'description' => ts('Discount Amount'),
+          'where' => 'civicrm_participant.discount_amount',
           'table_name' => 'civicrm_participant',
           'entity' => 'Participant',
           'bao' => 'CRM_Event_BAO_Participant',
@@ -496,6 +483,7 @@ class CRM_Event_DAO_Participant extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Event Cart ID'),
           'description' => ts('FK to civicrm_event_carts'),
+          'where' => 'civicrm_participant.cart_id',
           'table_name' => 'civicrm_participant',
           'entity' => 'Participant',
           'bao' => 'CRM_Event_BAO_Participant',
@@ -507,6 +495,7 @@ class CRM_Event_DAO_Participant extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Must Wait on List'),
           'description' => ts('On Waiting List'),
+          'where' => 'civicrm_participant.must_wait',
           'table_name' => 'civicrm_participant',
           'entity' => 'Participant',
           'bao' => 'CRM_Event_BAO_Participant',
@@ -520,7 +509,6 @@ class CRM_Event_DAO_Participant extends CRM_Core_DAO {
           'import' => TRUE,
           'where' => 'civicrm_participant.transferred_to_contact_id',
           'headerPattern' => '/transfer(.?id)?/i',
-          'dataPattern' => '',
           'export' => TRUE,
           'default' => 'NULL',
           'table_name' => 'civicrm_participant',
diff --git a/civicrm/CRM/Event/DAO/ParticipantPayment.php b/civicrm/CRM/Event/DAO/ParticipantPayment.php
index 91838cbf532e89832cdab1c87f646e27af1f53c0..39843364b0cba9fc3cf371aa96847c99cc57bfbb 100644
--- a/civicrm/CRM/Event/DAO/ParticipantPayment.php
+++ b/civicrm/CRM/Event/DAO/ParticipantPayment.php
@@ -87,6 +87,7 @@ class CRM_Event_DAO_ParticipantPayment extends CRM_Core_DAO {
           'title' => ts('Payment ID'),
           'description' => ts('Participant Payment Id'),
           'required' => TRUE,
+          'where' => 'civicrm_participant_payment.id',
           'table_name' => 'civicrm_participant_payment',
           'entity' => 'ParticipantPayment',
           'bao' => 'CRM_Event_BAO_ParticipantPayment',
@@ -98,6 +99,7 @@ class CRM_Event_DAO_ParticipantPayment extends CRM_Core_DAO {
           'title' => ts('Participant ID'),
           'description' => ts('Participant Id (FK)'),
           'required' => TRUE,
+          'where' => 'civicrm_participant_payment.participant_id',
           'table_name' => 'civicrm_participant_payment',
           'entity' => 'ParticipantPayment',
           'bao' => 'CRM_Event_BAO_ParticipantPayment',
@@ -110,6 +112,7 @@ class CRM_Event_DAO_ParticipantPayment extends CRM_Core_DAO {
           'title' => ts('Contribution'),
           'description' => ts('FK to contribution table.'),
           'required' => TRUE,
+          'where' => 'civicrm_participant_payment.contribution_id',
           'table_name' => 'civicrm_participant_payment',
           'entity' => 'ParticipantPayment',
           'bao' => 'CRM_Event_BAO_ParticipantPayment',
diff --git a/civicrm/CRM/Event/DAO/ParticipantStatusType.php b/civicrm/CRM/Event/DAO/ParticipantStatusType.php
index 00c8d1def9bd0cd2fe17290e0ff5f3acc0014954..e04f88ced3fb06d1f1b2ecdfa85c8bf04cd79d01 100644
--- a/civicrm/CRM/Event/DAO/ParticipantStatusType.php
+++ b/civicrm/CRM/Event/DAO/ParticipantStatusType.php
@@ -113,6 +113,7 @@ class CRM_Event_DAO_ParticipantStatusType extends CRM_Core_DAO {
           'title' => ts('Participant Status Type ID'),
           'description' => ts('unique participant status type id'),
           'required' => TRUE,
+          'where' => 'civicrm_participant_status_type.id',
           'table_name' => 'civicrm_participant_status_type',
           'entity' => 'ParticipantStatusType',
           'bao' => 'CRM_Event_BAO_ParticipantStatusType',
@@ -127,8 +128,6 @@ class CRM_Event_DAO_ParticipantStatusType extends CRM_Core_DAO {
           'size' => CRM_Utils_Type::BIG,
           'import' => TRUE,
           'where' => 'civicrm_participant_status_type.name',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_participant_status_type',
           'entity' => 'ParticipantStatusType',
@@ -142,6 +141,7 @@ class CRM_Event_DAO_ParticipantStatusType extends CRM_Core_DAO {
           'description' => ts('localized label for display of this status type'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_participant_status_type.label',
           'table_name' => 'civicrm_participant_status_type',
           'entity' => 'ParticipantStatusType',
           'bao' => 'CRM_Event_BAO_ParticipantStatusType',
@@ -154,6 +154,7 @@ class CRM_Event_DAO_ParticipantStatusType extends CRM_Core_DAO {
           'description' => ts('the general group of status type this one belongs to'),
           'maxlength' => 8,
           'size' => CRM_Utils_Type::EIGHT,
+          'where' => 'civicrm_participant_status_type.class',
           'table_name' => 'civicrm_participant_status_type',
           'entity' => 'ParticipantStatusType',
           'bao' => 'CRM_Event_BAO_ParticipantStatusType',
@@ -170,6 +171,7 @@ class CRM_Event_DAO_ParticipantStatusType extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Participant Status Is Reserved?>'),
           'description' => ts('whether this is a status type required by the system'),
+          'where' => 'civicrm_participant_status_type.is_reserved',
           'table_name' => 'civicrm_participant_status_type',
           'entity' => 'ParticipantStatusType',
           'bao' => 'CRM_Event_BAO_ParticipantStatusType',
@@ -180,6 +182,7 @@ class CRM_Event_DAO_ParticipantStatusType extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Participant Status is Active'),
           'description' => ts('whether this status type is active'),
+          'where' => 'civicrm_participant_status_type.is_active',
           'default' => '1',
           'table_name' => 'civicrm_participant_status_type',
           'entity' => 'ParticipantStatusType',
@@ -191,6 +194,7 @@ class CRM_Event_DAO_ParticipantStatusType extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Participant Status Counts?'),
           'description' => ts('whether this status type is counted against event size limit'),
+          'where' => 'civicrm_participant_status_type.is_counted',
           'table_name' => 'civicrm_participant_status_type',
           'entity' => 'ParticipantStatusType',
           'bao' => 'CRM_Event_BAO_ParticipantStatusType',
@@ -202,6 +206,7 @@ class CRM_Event_DAO_ParticipantStatusType extends CRM_Core_DAO {
           'title' => ts('Order'),
           'description' => ts('controls sort order'),
           'required' => TRUE,
+          'where' => 'civicrm_participant_status_type.weight',
           'table_name' => 'civicrm_participant_status_type',
           'entity' => 'ParticipantStatusType',
           'bao' => 'CRM_Event_BAO_ParticipantStatusType',
@@ -212,6 +217,7 @@ class CRM_Event_DAO_ParticipantStatusType extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Participant Status Visibility'),
           'description' => ts('whether the status type is visible to the public, an implicit foreign key to option_value.value related to the `visibility` option_group'),
+          'where' => 'civicrm_participant_status_type.visibility_id',
           'table_name' => 'civicrm_participant_status_type',
           'entity' => 'ParticipantStatusType',
           'bao' => 'CRM_Event_BAO_ParticipantStatusType',
diff --git a/civicrm/CRM/Financial/BAO/Payment.php b/civicrm/CRM/Financial/BAO/Payment.php
index fbb3e58de800cf03a6b1db3909c4f987f54b722f..e743d2d796851b6e7983565a65cb1345fdc4b371 100644
--- a/civicrm/CRM/Financial/BAO/Payment.php
+++ b/civicrm/CRM/Financial/BAO/Payment.php
@@ -63,7 +63,7 @@ class CRM_Financial_BAO_Payment {
     // should be handled through Payment.create.
     $isSkipRecordingPaymentHereForLegacyHandlingReasons = ($contributionStatus == 'Pending' && $isPaymentCompletesContribution);
 
-    if (!$isSkipRecordingPaymentHereForLegacyHandlingReasons) {
+    if (!$isSkipRecordingPaymentHereForLegacyHandlingReasons && $params['total_amount'] > 0) {
       $trxn = CRM_Contribute_BAO_Contribution::recordPartialPayment($contribution, $params);
 
       if (CRM_Utils_Array::value('line_item', $params) && !empty($trxn)) {
@@ -99,6 +99,9 @@ class CRM_Financial_BAO_Payment {
         CRM_Contribute_BAO_Contribution::assignProportionalLineItems($params, $trxn->id, $contribution['total_amount']);
       }
     }
+    elseif ($params['total_amount'] < 0) {
+      $trxn = self::recordRefundPayment($params['contribution_id'], $params, FALSE);
+    }
 
     if ($isPaymentCompletesContribution) {
       civicrm_api3('Contribution', 'completetransaction', ['id' => $contribution['id']]);
@@ -311,7 +314,7 @@ class CRM_Financial_BAO_Payment {
     $arAccountId = CRM_Contribute_PseudoConstant::getRelationalFinancialAccount($contributionDAO->financial_type_id, 'Accounts Receivable Account is');
     $completedStatusId = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Completed');
 
-    $trxnData['total_amount'] = $trxnData['net_amount'] = -$trxnData['total_amount'];
+    $trxnData['total_amount'] = $trxnData['net_amount'] = $trxnData['total_amount'];
     $trxnData['from_financial_account_id'] = $arAccountId;
     $trxnData['status_id'] = CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Refunded');
     // record the entry
diff --git a/civicrm/CRM/Financial/DAO/Currency.php b/civicrm/CRM/Financial/DAO/Currency.php
index 672e3ed366e5fd4e9ed9a8a93d7c3e87e280c358..f20e3c2037423860a14fdb6706665c09c1974a26 100644
--- a/civicrm/CRM/Financial/DAO/Currency.php
+++ b/civicrm/CRM/Financial/DAO/Currency.php
@@ -85,6 +85,7 @@ class CRM_Financial_DAO_Currency extends CRM_Core_DAO {
           'title' => ts('Currency ID'),
           'description' => ts('Currency Id'),
           'required' => TRUE,
+          'where' => 'civicrm_currency.id',
           'table_name' => 'civicrm_currency',
           'entity' => 'Currency',
           'bao' => 'CRM_Financial_DAO_Currency',
@@ -99,8 +100,6 @@ class CRM_Financial_DAO_Currency extends CRM_Core_DAO {
           'size' => CRM_Utils_Type::BIG,
           'import' => TRUE,
           'where' => 'civicrm_currency.name',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_currency',
           'entity' => 'Currency',
@@ -117,6 +116,7 @@ class CRM_Financial_DAO_Currency extends CRM_Core_DAO {
           'description' => ts('Currency Symbol'),
           'maxlength' => 8,
           'size' => CRM_Utils_Type::EIGHT,
+          'where' => 'civicrm_currency.symbol',
           'table_name' => 'civicrm_currency',
           'entity' => 'Currency',
           'bao' => 'CRM_Financial_DAO_Currency',
@@ -134,8 +134,6 @@ class CRM_Financial_DAO_Currency extends CRM_Core_DAO {
           'size' => CRM_Utils_Type::FOUR,
           'import' => TRUE,
           'where' => 'civicrm_currency.numeric_code',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_currency',
           'entity' => 'Currency',
@@ -149,6 +147,7 @@ class CRM_Financial_DAO_Currency extends CRM_Core_DAO {
           'description' => ts('Full currency name'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_currency.full_name',
           'table_name' => 'civicrm_currency',
           'entity' => 'Currency',
           'bao' => 'CRM_Financial_DAO_Currency',
diff --git a/civicrm/CRM/Financial/DAO/EntityFinancialAccount.php b/civicrm/CRM/Financial/DAO/EntityFinancialAccount.php
index 687db0a729a695c6f29f88736005a02cde9297cb..529a8d68a48d712281fa64df1a75442e9e141a45 100644
--- a/civicrm/CRM/Financial/DAO/EntityFinancialAccount.php
+++ b/civicrm/CRM/Financial/DAO/EntityFinancialAccount.php
@@ -101,6 +101,7 @@ class CRM_Financial_DAO_EntityFinancialAccount extends CRM_Core_DAO {
           'title' => ts('Entity Financial Account ID'),
           'description' => ts('ID'),
           'required' => TRUE,
+          'where' => 'civicrm_entity_financial_account.id',
           'table_name' => 'civicrm_entity_financial_account',
           'entity' => 'EntityFinancialAccount',
           'bao' => 'CRM_Financial_DAO_EntityFinancialAccount',
@@ -116,8 +117,6 @@ class CRM_Financial_DAO_EntityFinancialAccount extends CRM_Core_DAO {
           'size' => CRM_Utils_Type::BIG,
           'import' => TRUE,
           'where' => 'civicrm_entity_financial_account.entity_table',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_entity_financial_account',
           'entity' => 'EntityFinancialAccount',
@@ -130,6 +129,7 @@ class CRM_Financial_DAO_EntityFinancialAccount extends CRM_Core_DAO {
           'title' => ts('Entity ID'),
           'description' => ts('Links to an id in the entity_table, such as vid in civicrm_financial_type'),
           'required' => TRUE,
+          'where' => 'civicrm_entity_financial_account.entity_id',
           'table_name' => 'civicrm_entity_financial_account',
           'entity' => 'EntityFinancialAccount',
           'bao' => 'CRM_Financial_DAO_EntityFinancialAccount',
@@ -141,6 +141,7 @@ class CRM_Financial_DAO_EntityFinancialAccount extends CRM_Core_DAO {
           'title' => ts('Account Relationship'),
           'description' => ts('FK to a new civicrm_option_value (account_relationship)'),
           'required' => TRUE,
+          'where' => 'civicrm_entity_financial_account.account_relationship',
           'table_name' => 'civicrm_entity_financial_account',
           'entity' => 'EntityFinancialAccount',
           'bao' => 'CRM_Financial_DAO_EntityFinancialAccount',
@@ -159,6 +160,7 @@ class CRM_Financial_DAO_EntityFinancialAccount extends CRM_Core_DAO {
           'title' => ts('Financial Account'),
           'description' => ts('FK to the financial_account_id'),
           'required' => TRUE,
+          'where' => 'civicrm_entity_financial_account.financial_account_id',
           'table_name' => 'civicrm_entity_financial_account',
           'entity' => 'EntityFinancialAccount',
           'bao' => 'CRM_Financial_DAO_EntityFinancialAccount',
diff --git a/civicrm/CRM/Financial/DAO/EntityFinancialTrxn.php b/civicrm/CRM/Financial/DAO/EntityFinancialTrxn.php
index dd5940494d7cdb8e27023271c51cad1ad3d9791b..ba7d38c4711653ba9624ef93fd83ef9351395f12 100644
--- a/civicrm/CRM/Financial/DAO/EntityFinancialTrxn.php
+++ b/civicrm/CRM/Financial/DAO/EntityFinancialTrxn.php
@@ -97,6 +97,7 @@ class CRM_Financial_DAO_EntityFinancialTrxn extends CRM_Core_DAO {
           'title' => ts('Entity Financial Transaction ID'),
           'description' => ts('ID'),
           'required' => TRUE,
+          'where' => 'civicrm_entity_financial_trxn.id',
           'table_name' => 'civicrm_entity_financial_trxn',
           'entity' => 'EntityFinancialTrxn',
           'bao' => 'CRM_Financial_DAO_EntityFinancialTrxn',
@@ -112,8 +113,6 @@ class CRM_Financial_DAO_EntityFinancialTrxn extends CRM_Core_DAO {
           'size' => CRM_Utils_Type::BIG,
           'import' => TRUE,
           'where' => 'civicrm_entity_financial_trxn.entity_table',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_entity_financial_trxn',
           'entity' => 'EntityFinancialTrxn',
@@ -125,6 +124,7 @@ class CRM_Financial_DAO_EntityFinancialTrxn extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Entity ID'),
           'required' => TRUE,
+          'where' => 'civicrm_entity_financial_trxn.entity_id',
           'table_name' => 'civicrm_entity_financial_trxn',
           'entity' => 'EntityFinancialTrxn',
           'bao' => 'CRM_Financial_DAO_EntityFinancialTrxn',
@@ -134,6 +134,7 @@ class CRM_Financial_DAO_EntityFinancialTrxn extends CRM_Core_DAO {
           'name' => 'financial_trxn_id',
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Financial Transaction Id'),
+          'where' => 'civicrm_entity_financial_trxn.financial_trxn_id',
           'table_name' => 'civicrm_entity_financial_trxn',
           'entity' => 'EntityFinancialTrxn',
           'bao' => 'CRM_Financial_DAO_EntityFinancialTrxn',
diff --git a/civicrm/CRM/Financial/DAO/FinancialAccount.php b/civicrm/CRM/Financial/DAO/FinancialAccount.php
index c6aaa009719671c2ee33ce9148eaa44c72c3f395..99c784aa70e6adbdaf9a870755415e168f48448b 100644
--- a/civicrm/CRM/Financial/DAO/FinancialAccount.php
+++ b/civicrm/CRM/Financial/DAO/FinancialAccount.php
@@ -171,6 +171,7 @@ class CRM_Financial_DAO_FinancialAccount extends CRM_Core_DAO {
           'title' => ts('Financial Account ID'),
           'description' => ts('ID'),
           'required' => TRUE,
+          'where' => 'civicrm_financial_account.id',
           'table_name' => 'civicrm_financial_account',
           'entity' => 'FinancialAccount',
           'bao' => 'CRM_Financial_BAO_FinancialAccount',
@@ -184,6 +185,7 @@ class CRM_Financial_DAO_FinancialAccount extends CRM_Core_DAO {
           'required' => TRUE,
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_financial_account.name',
           'table_name' => 'civicrm_financial_account',
           'entity' => 'FinancialAccount',
           'bao' => 'CRM_Financial_BAO_FinancialAccount',
@@ -194,6 +196,7 @@ class CRM_Financial_DAO_FinancialAccount extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Contact ID'),
           'description' => ts('FK to Contact ID that is responsible for the funds in this account'),
+          'where' => 'civicrm_financial_account.contact_id',
           'table_name' => 'civicrm_financial_account',
           'entity' => 'FinancialAccount',
           'bao' => 'CRM_Financial_BAO_FinancialAccount',
@@ -206,6 +209,7 @@ class CRM_Financial_DAO_FinancialAccount extends CRM_Core_DAO {
           'title' => ts('Financial Account Type'),
           'description' => ts('pseudo FK into civicrm_option_value.'),
           'required' => TRUE,
+          'where' => 'civicrm_financial_account.financial_account_type_id',
           'default' => '3',
           'table_name' => 'civicrm_financial_account',
           'entity' => 'FinancialAccount',
@@ -226,10 +230,8 @@ class CRM_Financial_DAO_FinancialAccount extends CRM_Core_DAO {
           'description' => ts('Optional value for mapping monies owed and received to accounting system codes.'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
-          'export' => TRUE,
           'where' => 'civicrm_financial_account.accounting_code',
-          'headerPattern' => '',
-          'dataPattern' => '',
+          'export' => TRUE,
           'table_name' => 'civicrm_financial_account',
           'entity' => 'FinancialAccount',
           'bao' => 'CRM_Financial_BAO_FinancialAccount',
@@ -242,10 +244,8 @@ class CRM_Financial_DAO_FinancialAccount extends CRM_Core_DAO {
           'description' => ts('Optional value for mapping account types to accounting system account categories (QuickBooks Account Type Codes for example).'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
-          'export' => TRUE,
           'where' => 'civicrm_financial_account.account_type_code',
-          'headerPattern' => '',
-          'dataPattern' => '',
+          'export' => TRUE,
           'table_name' => 'civicrm_financial_account',
           'entity' => 'FinancialAccount',
           'bao' => 'CRM_Financial_BAO_FinancialAccount',
@@ -258,6 +258,7 @@ class CRM_Financial_DAO_FinancialAccount extends CRM_Core_DAO {
           'description' => ts('Financial Type Description.'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_financial_account.description',
           'table_name' => 'civicrm_financial_account',
           'entity' => 'FinancialAccount',
           'bao' => 'CRM_Financial_BAO_FinancialAccount',
@@ -268,6 +269,7 @@ class CRM_Financial_DAO_FinancialAccount extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Financial Account Parent'),
           'description' => ts('Parent ID in account hierarchy'),
+          'where' => 'civicrm_financial_account.parent_id',
           'table_name' => 'civicrm_financial_account',
           'entity' => 'FinancialAccount',
           'bao' => 'CRM_Financial_BAO_FinancialAccount',
@@ -279,6 +281,7 @@ class CRM_Financial_DAO_FinancialAccount extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Header Financial Account?'),
           'description' => ts('Is this a header account which does not allow transactions to be posted against it directly, but only to its sub-accounts?'),
+          'where' => 'civicrm_financial_account.is_header_account',
           'default' => '0',
           'table_name' => 'civicrm_financial_account',
           'entity' => 'FinancialAccount',
@@ -290,6 +293,7 @@ class CRM_Financial_DAO_FinancialAccount extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Deductible Financial Account?'),
           'description' => ts('Is this account tax-deductible?'),
+          'where' => 'civicrm_financial_account.is_deductible',
           'default' => '1',
           'table_name' => 'civicrm_financial_account',
           'entity' => 'FinancialAccount',
@@ -301,6 +305,7 @@ class CRM_Financial_DAO_FinancialAccount extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Tax Financial Account?'),
           'description' => ts('Is this account for taxes?'),
+          'where' => 'civicrm_financial_account.is_tax',
           'default' => '0',
           'table_name' => 'civicrm_financial_account',
           'entity' => 'FinancialAccount',
@@ -316,6 +321,7 @@ class CRM_Financial_DAO_FinancialAccount extends CRM_Core_DAO {
             10,
             8
           ],
+          'where' => 'civicrm_financial_account.tax_rate',
           'table_name' => 'civicrm_financial_account',
           'entity' => 'FinancialAccount',
           'bao' => 'CRM_Financial_BAO_FinancialAccount',
@@ -326,6 +332,7 @@ class CRM_Financial_DAO_FinancialAccount extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Reserved Financial Account?'),
           'description' => ts('Is this a predefined system object?'),
+          'where' => 'civicrm_financial_account.is_reserved',
           'table_name' => 'civicrm_financial_account',
           'entity' => 'FinancialAccount',
           'bao' => 'CRM_Financial_BAO_FinancialAccount',
@@ -336,6 +343,7 @@ class CRM_Financial_DAO_FinancialAccount extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Financial Account is Active'),
           'description' => ts('Is this property active?'),
+          'where' => 'civicrm_financial_account.is_active',
           'table_name' => 'civicrm_financial_account',
           'entity' => 'FinancialAccount',
           'bao' => 'CRM_Financial_BAO_FinancialAccount',
@@ -346,6 +354,7 @@ class CRM_Financial_DAO_FinancialAccount extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Default Financial Account'),
           'description' => ts('Is this account the default one (or default tax one) for its financial_account_type?'),
+          'where' => 'civicrm_financial_account.is_default',
           'table_name' => 'civicrm_financial_account',
           'entity' => 'FinancialAccount',
           'bao' => 'CRM_Financial_BAO_FinancialAccount',
diff --git a/civicrm/CRM/Financial/DAO/FinancialItem.php b/civicrm/CRM/Financial/DAO/FinancialItem.php
index d25859144de4a3f319c6b49eb887eeda501c6a84..dcbc5b4d4f3146e77d788dd8c83c2099dee1079d 100644
--- a/civicrm/CRM/Financial/DAO/FinancialItem.php
+++ b/civicrm/CRM/Financial/DAO/FinancialItem.php
@@ -141,6 +141,7 @@ class CRM_Financial_DAO_FinancialItem extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Financial Item ID'),
           'required' => TRUE,
+          'where' => 'civicrm_financial_item.id',
           'table_name' => 'civicrm_financial_item',
           'entity' => 'FinancialItem',
           'bao' => 'CRM_Financial_BAO_FinancialItem',
@@ -152,6 +153,7 @@ class CRM_Financial_DAO_FinancialItem extends CRM_Core_DAO {
           'title' => ts('Financial Item Created Date'),
           'description' => ts('Date and time the item was created'),
           'required' => TRUE,
+          'where' => 'civicrm_financial_item.created_date',
           'default' => 'CURRENT_TIMESTAMP',
           'table_name' => 'civicrm_financial_item',
           'entity' => 'FinancialItem',
@@ -164,6 +166,7 @@ class CRM_Financial_DAO_FinancialItem extends CRM_Core_DAO {
           'title' => ts('Financial Item Transaction Date'),
           'description' => ts('Date and time of the source transaction'),
           'required' => TRUE,
+          'where' => 'civicrm_financial_item.transaction_date',
           'table_name' => 'civicrm_financial_item',
           'entity' => 'FinancialItem',
           'bao' => 'CRM_Financial_BAO_FinancialItem',
@@ -175,10 +178,8 @@ class CRM_Financial_DAO_FinancialItem extends CRM_Core_DAO {
           'title' => ts('Financial Item Contact ID'),
           'description' => ts('FK to Contact ID of contact the item is from'),
           'required' => TRUE,
-          'export' => TRUE,
           'where' => 'civicrm_financial_item.contact_id',
-          'headerPattern' => '',
-          'dataPattern' => '',
+          'export' => TRUE,
           'table_name' => 'civicrm_financial_item',
           'entity' => 'FinancialItem',
           'bao' => 'CRM_Financial_BAO_FinancialItem',
@@ -192,6 +193,7 @@ class CRM_Financial_DAO_FinancialItem extends CRM_Core_DAO {
           'description' => ts('Human readable description of this item, to ease display without lookup of source item.'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_financial_item.description',
           'table_name' => 'civicrm_financial_item',
           'entity' => 'FinancialItem',
           'bao' => 'CRM_Financial_BAO_FinancialItem',
@@ -207,6 +209,9 @@ class CRM_Financial_DAO_FinancialItem extends CRM_Core_DAO {
             20,
             2
           ],
+          'where' => 'civicrm_financial_item.amount',
+          'headerPattern' => '/unit?.?amoun/i',
+          'dataPattern' => '/^\d+(\.\d{2})?$/',
           'default' => '0',
           'table_name' => 'civicrm_financial_item',
           'entity' => 'FinancialItem',
@@ -220,10 +225,8 @@ class CRM_Financial_DAO_FinancialItem extends CRM_Core_DAO {
           'description' => ts('Currency for the amount'),
           'maxlength' => 3,
           'size' => CRM_Utils_Type::FOUR,
-          'export' => TRUE,
           'where' => 'civicrm_financial_item.currency',
-          'headerPattern' => '',
-          'dataPattern' => '',
+          'export' => TRUE,
           'table_name' => 'civicrm_financial_item',
           'entity' => 'FinancialItem',
           'bao' => 'CRM_Financial_BAO_FinancialItem',
@@ -243,6 +246,7 @@ class CRM_Financial_DAO_FinancialItem extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Financial Account ID'),
           'description' => ts('FK to civicrm_financial_account'),
+          'where' => 'civicrm_financial_item.financial_account_id',
           'table_name' => 'civicrm_financial_item',
           'entity' => 'FinancialItem',
           'bao' => 'CRM_Financial_BAO_FinancialItem',
@@ -262,10 +266,8 @@ class CRM_Financial_DAO_FinancialItem extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Financial Item Status ID'),
           'description' => ts('Payment status: test, paid, part_paid, unpaid (if empty assume unpaid)'),
-          'export' => TRUE,
           'where' => 'civicrm_financial_item.status_id',
-          'headerPattern' => '',
-          'dataPattern' => '',
+          'export' => TRUE,
           'table_name' => 'civicrm_financial_item',
           'entity' => 'FinancialItem',
           'bao' => 'CRM_Financial_BAO_FinancialItem',
@@ -285,6 +287,7 @@ class CRM_Financial_DAO_FinancialItem extends CRM_Core_DAO {
           'description' => ts('The table providing the source of this item such as civicrm_line_item'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_financial_item.entity_table',
           'table_name' => 'civicrm_financial_item',
           'entity' => 'FinancialItem',
           'bao' => 'CRM_Financial_BAO_FinancialItem',
@@ -295,6 +298,7 @@ class CRM_Financial_DAO_FinancialItem extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Entity ID'),
           'description' => ts('The specific source item that is responsible for the creation of this financial_item'),
+          'where' => 'civicrm_financial_item.entity_id',
           'table_name' => 'civicrm_financial_item',
           'entity' => 'FinancialItem',
           'bao' => 'CRM_Financial_BAO_FinancialItem',
diff --git a/civicrm/CRM/Financial/DAO/FinancialTrxn.php b/civicrm/CRM/Financial/DAO/FinancialTrxn.php
index f89106a691d20f108aa85484e0723c44cb2f7864..1d262b411dcb0f3f7cd2601115a53b6de7a177aa 100644
--- a/civicrm/CRM/Financial/DAO/FinancialTrxn.php
+++ b/civicrm/CRM/Financial/DAO/FinancialTrxn.php
@@ -183,6 +183,7 @@ class CRM_Financial_DAO_FinancialTrxn extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Financial Transaction ID'),
           'required' => TRUE,
+          'where' => 'civicrm_financial_trxn.id',
           'table_name' => 'civicrm_financial_trxn',
           'entity' => 'FinancialTrxn',
           'bao' => 'CRM_Financial_DAO_FinancialTrxn',
@@ -193,6 +194,7 @@ class CRM_Financial_DAO_FinancialTrxn extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Financial Transaction From Account'),
           'description' => ts('FK to financial_account table.'),
+          'where' => 'civicrm_financial_trxn.from_financial_account_id',
           'table_name' => 'civicrm_financial_trxn',
           'entity' => 'FinancialTrxn',
           'bao' => 'CRM_Financial_DAO_FinancialTrxn',
@@ -212,6 +214,7 @@ class CRM_Financial_DAO_FinancialTrxn extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Financial Transaction To Account'),
           'description' => ts('FK to financial_financial_account table.'),
+          'where' => 'civicrm_financial_trxn.to_financial_account_id',
           'table_name' => 'civicrm_financial_trxn',
           'entity' => 'FinancialTrxn',
           'bao' => 'CRM_Financial_DAO_FinancialTrxn',
@@ -231,6 +234,7 @@ class CRM_Financial_DAO_FinancialTrxn extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
           'title' => ts('Financial Transaction Date'),
           'description' => ts('date transaction occurred'),
+          'where' => 'civicrm_financial_trxn.trxn_date',
           'default' => 'NULL',
           'table_name' => 'civicrm_financial_trxn',
           'entity' => 'FinancialTrxn',
@@ -251,6 +255,7 @@ class CRM_Financial_DAO_FinancialTrxn extends CRM_Core_DAO {
             20,
             2
           ],
+          'where' => 'civicrm_financial_trxn.total_amount',
           'table_name' => 'civicrm_financial_trxn',
           'entity' => 'FinancialTrxn',
           'bao' => 'CRM_Financial_DAO_FinancialTrxn',
@@ -265,6 +270,7 @@ class CRM_Financial_DAO_FinancialTrxn extends CRM_Core_DAO {
             20,
             2
           ],
+          'where' => 'civicrm_financial_trxn.fee_amount',
           'table_name' => 'civicrm_financial_trxn',
           'entity' => 'FinancialTrxn',
           'bao' => 'CRM_Financial_DAO_FinancialTrxn',
@@ -279,6 +285,7 @@ class CRM_Financial_DAO_FinancialTrxn extends CRM_Core_DAO {
             20,
             2
           ],
+          'where' => 'civicrm_financial_trxn.net_amount',
           'table_name' => 'civicrm_financial_trxn',
           'entity' => 'FinancialTrxn',
           'bao' => 'CRM_Financial_DAO_FinancialTrxn',
@@ -318,8 +325,6 @@ class CRM_Financial_DAO_FinancialTrxn extends CRM_Core_DAO {
           'description' => ts('Is this entry either a payment or a reversal of a payment?'),
           'import' => TRUE,
           'where' => 'civicrm_financial_trxn.is_payment',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'default' => '0',
           'table_name' => 'civicrm_financial_trxn',
@@ -334,6 +339,7 @@ class CRM_Financial_DAO_FinancialTrxn extends CRM_Core_DAO {
           'description' => ts('Transaction id supplied by external processor. This may not be unique.'),
           'maxlength' => 255,
           'size' => 10,
+          'where' => 'civicrm_financial_trxn.trxn_id',
           'table_name' => 'civicrm_financial_trxn',
           'entity' => 'FinancialTrxn',
           'bao' => 'CRM_Financial_DAO_FinancialTrxn',
@@ -349,6 +355,7 @@ class CRM_Financial_DAO_FinancialTrxn extends CRM_Core_DAO {
           'description' => ts('processor result code'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_financial_trxn.trxn_result_code',
           'table_name' => 'civicrm_financial_trxn',
           'entity' => 'FinancialTrxn',
           'bao' => 'CRM_Financial_DAO_FinancialTrxn',
@@ -362,7 +369,6 @@ class CRM_Financial_DAO_FinancialTrxn extends CRM_Core_DAO {
           'import' => TRUE,
           'where' => 'civicrm_financial_trxn.status_id',
           'headerPattern' => '/status/i',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_financial_trxn',
           'entity' => 'FinancialTrxn',
@@ -378,6 +384,7 @@ class CRM_Financial_DAO_FinancialTrxn extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Payment Processor'),
           'description' => ts('Payment Processor for this financial transaction'),
+          'where' => 'civicrm_financial_trxn.payment_processor_id',
           'table_name' => 'civicrm_financial_trxn',
           'entity' => 'FinancialTrxn',
           'bao' => 'CRM_Financial_DAO_FinancialTrxn',
@@ -389,6 +396,7 @@ class CRM_Financial_DAO_FinancialTrxn extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Payment Method'),
           'description' => ts('FK to payment_instrument option group values'),
+          'where' => 'civicrm_financial_trxn.payment_instrument_id',
           'table_name' => 'civicrm_financial_trxn',
           'entity' => 'FinancialTrxn',
           'bao' => 'CRM_Financial_DAO_FinancialTrxn',
@@ -406,6 +414,7 @@ class CRM_Financial_DAO_FinancialTrxn extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Card Type ID'),
           'description' => ts('FK to accept_creditcard option group values'),
+          'where' => 'civicrm_financial_trxn.card_type_id',
           'table_name' => 'civicrm_financial_trxn',
           'entity' => 'FinancialTrxn',
           'bao' => 'CRM_Financial_DAO_FinancialTrxn',
@@ -425,6 +434,7 @@ class CRM_Financial_DAO_FinancialTrxn extends CRM_Core_DAO {
           'description' => ts('Check number'),
           'maxlength' => 255,
           'size' => 6,
+          'where' => 'civicrm_financial_trxn.check_number',
           'table_name' => 'civicrm_financial_trxn',
           'entity' => 'FinancialTrxn',
           'bao' => 'CRM_Financial_DAO_FinancialTrxn',
@@ -440,6 +450,7 @@ class CRM_Financial_DAO_FinancialTrxn extends CRM_Core_DAO {
           'description' => ts('Last 4 digits of credit card'),
           'maxlength' => 4,
           'size' => 4,
+          'where' => 'civicrm_financial_trxn.pan_truncation',
           'table_name' => 'civicrm_financial_trxn',
           'entity' => 'FinancialTrxn',
           'bao' => 'CRM_Financial_DAO_FinancialTrxn',
diff --git a/civicrm/CRM/Financial/DAO/FinancialType.php b/civicrm/CRM/Financial/DAO/FinancialType.php
index 611c7b6506bde657f1bab0d05a7cedf4abb6b79c..90a916f0750d552eb299bf921e8e067e4c15e081 100644
--- a/civicrm/CRM/Financial/DAO/FinancialType.php
+++ b/civicrm/CRM/Financial/DAO/FinancialType.php
@@ -92,6 +92,7 @@ class CRM_Financial_DAO_FinancialType extends CRM_Core_DAO {
           'title' => ts('Financial Type ID'),
           'description' => ts('ID of original financial_type so you can search this table by the financial_type.id and then select the relevant version based on the timestamp'),
           'required' => TRUE,
+          'where' => 'civicrm_financial_type.id',
           'table_name' => 'civicrm_financial_type',
           'entity' => 'FinancialType',
           'bao' => 'CRM_Financial_BAO_FinancialType',
@@ -126,6 +127,7 @@ class CRM_Financial_DAO_FinancialType extends CRM_Core_DAO {
           'description' => ts('Financial Type Description.'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_financial_type.description',
           'table_name' => 'civicrm_financial_type',
           'entity' => 'FinancialType',
           'bao' => 'CRM_Financial_BAO_FinancialType',
@@ -140,6 +142,7 @@ class CRM_Financial_DAO_FinancialType extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Is Tax Deductible?'),
           'description' => ts('Is this financial type tax-deductible? If true, contributions of this type may be fully OR partially deductible - non-deductible amount is stored in the Contribution record.'),
+          'where' => 'civicrm_financial_type.is_deductible',
           'default' => '1',
           'table_name' => 'civicrm_financial_type',
           'entity' => 'FinancialType',
@@ -155,6 +158,7 @@ class CRM_Financial_DAO_FinancialType extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Financial Type is Reserved?'),
           'description' => ts('Is this a predefined system object?'),
+          'where' => 'civicrm_financial_type.is_reserved',
           'table_name' => 'civicrm_financial_type',
           'entity' => 'FinancialType',
           'bao' => 'CRM_Financial_BAO_FinancialType',
@@ -169,6 +173,7 @@ class CRM_Financial_DAO_FinancialType extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Financial Type Is Active?'),
           'description' => ts('Is this property active?'),
+          'where' => 'civicrm_financial_type.is_active',
           'table_name' => 'civicrm_financial_type',
           'entity' => 'FinancialType',
           'bao' => 'CRM_Financial_BAO_FinancialType',
diff --git a/civicrm/CRM/Financial/DAO/PaymentProcessor.php b/civicrm/CRM/Financial/DAO/PaymentProcessor.php
index eccbc23fc1ccdd00e9cfe928eed83f1fb05855c0..f3aed47352471e49512c3ac1851242c0f1757fad 100644
--- a/civicrm/CRM/Financial/DAO/PaymentProcessor.php
+++ b/civicrm/CRM/Financial/DAO/PaymentProcessor.php
@@ -207,6 +207,7 @@ class CRM_Financial_DAO_PaymentProcessor extends CRM_Core_DAO {
           'title' => ts('Payment Processor ID'),
           'description' => ts('Payment Processor ID'),
           'required' => TRUE,
+          'where' => 'civicrm_payment_processor.id',
           'table_name' => 'civicrm_payment_processor',
           'entity' => 'PaymentProcessor',
           'bao' => 'CRM_Financial_BAO_PaymentProcessor',
@@ -218,6 +219,7 @@ class CRM_Financial_DAO_PaymentProcessor extends CRM_Core_DAO {
           'title' => ts('Payment Processor Domain'),
           'description' => ts('Which Domain is this match entry for'),
           'required' => TRUE,
+          'where' => 'civicrm_payment_processor.domain_id',
           'table_name' => 'civicrm_payment_processor',
           'entity' => 'PaymentProcessor',
           'bao' => 'CRM_Financial_BAO_PaymentProcessor',
@@ -236,6 +238,7 @@ class CRM_Financial_DAO_PaymentProcessor extends CRM_Core_DAO {
           'description' => ts('Payment Processor Name.'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_payment_processor.name',
           'table_name' => 'civicrm_payment_processor',
           'entity' => 'PaymentProcessor',
           'bao' => 'CRM_Financial_BAO_PaymentProcessor',
@@ -251,6 +254,7 @@ class CRM_Financial_DAO_PaymentProcessor extends CRM_Core_DAO {
           'description' => ts('Payment Processor Descriptive Name.'),
           'maxlength' => 127,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_payment_processor.title',
           'table_name' => 'civicrm_payment_processor',
           'entity' => 'PaymentProcessor',
           'bao' => 'CRM_Financial_BAO_PaymentProcessor',
@@ -266,6 +270,7 @@ class CRM_Financial_DAO_PaymentProcessor extends CRM_Core_DAO {
           'description' => ts('Payment Processor Description.'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_payment_processor.description',
           'table_name' => 'civicrm_payment_processor',
           'entity' => 'PaymentProcessor',
           'bao' => 'CRM_Financial_BAO_PaymentProcessor',
@@ -275,6 +280,7 @@ class CRM_Financial_DAO_PaymentProcessor extends CRM_Core_DAO {
           'name' => 'payment_processor_type_id',
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Payment Processor Type ID'),
+          'where' => 'civicrm_payment_processor.payment_processor_type_id',
           'table_name' => 'civicrm_payment_processor',
           'entity' => 'PaymentProcessor',
           'bao' => 'CRM_Financial_BAO_PaymentProcessor',
@@ -291,6 +297,7 @@ class CRM_Financial_DAO_PaymentProcessor extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Processor is Active?'),
           'description' => ts('Is this processor active?'),
+          'where' => 'civicrm_payment_processor.is_active',
           'table_name' => 'civicrm_payment_processor',
           'entity' => 'PaymentProcessor',
           'bao' => 'CRM_Financial_BAO_PaymentProcessor',
@@ -301,6 +308,7 @@ class CRM_Financial_DAO_PaymentProcessor extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Processor Is Default?'),
           'description' => ts('Is this processor the default?'),
+          'where' => 'civicrm_payment_processor.is_default',
           'table_name' => 'civicrm_payment_processor',
           'entity' => 'PaymentProcessor',
           'bao' => 'CRM_Financial_BAO_PaymentProcessor',
@@ -311,6 +319,7 @@ class CRM_Financial_DAO_PaymentProcessor extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Is Test Processor?'),
           'description' => ts('Is this processor for a test site?'),
+          'where' => 'civicrm_payment_processor.is_test',
           'table_name' => 'civicrm_payment_processor',
           'entity' => 'PaymentProcessor',
           'bao' => 'CRM_Financial_BAO_PaymentProcessor',
@@ -322,6 +331,7 @@ class CRM_Financial_DAO_PaymentProcessor extends CRM_Core_DAO {
           'title' => ts('User Name'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_payment_processor.user_name',
           'table_name' => 'civicrm_payment_processor',
           'entity' => 'PaymentProcessor',
           'bao' => 'CRM_Financial_BAO_PaymentProcessor',
@@ -336,6 +346,7 @@ class CRM_Financial_DAO_PaymentProcessor extends CRM_Core_DAO {
           'title' => ts('Password'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_payment_processor.password',
           'table_name' => 'civicrm_payment_processor',
           'entity' => 'PaymentProcessor',
           'bao' => 'CRM_Financial_BAO_PaymentProcessor',
@@ -350,6 +361,7 @@ class CRM_Financial_DAO_PaymentProcessor extends CRM_Core_DAO {
           'title' => ts('Signature'),
           'rows' => 4,
           'cols' => 40,
+          'where' => 'civicrm_payment_processor.signature',
           'table_name' => 'civicrm_payment_processor',
           'entity' => 'PaymentProcessor',
           'bao' => 'CRM_Financial_BAO_PaymentProcessor',
@@ -364,6 +376,7 @@ class CRM_Financial_DAO_PaymentProcessor extends CRM_Core_DAO {
           'title' => ts('Site URL'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_payment_processor.url_site',
           'table_name' => 'civicrm_payment_processor',
           'entity' => 'PaymentProcessor',
           'bao' => 'CRM_Financial_BAO_PaymentProcessor',
@@ -378,6 +391,7 @@ class CRM_Financial_DAO_PaymentProcessor extends CRM_Core_DAO {
           'title' => ts('API URL'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_payment_processor.url_api',
           'table_name' => 'civicrm_payment_processor',
           'entity' => 'PaymentProcessor',
           'bao' => 'CRM_Financial_BAO_PaymentProcessor',
@@ -392,6 +406,7 @@ class CRM_Financial_DAO_PaymentProcessor extends CRM_Core_DAO {
           'title' => ts('Recurring Payments URL'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_payment_processor.url_recur',
           'table_name' => 'civicrm_payment_processor',
           'entity' => 'PaymentProcessor',
           'bao' => 'CRM_Financial_BAO_PaymentProcessor',
@@ -406,6 +421,7 @@ class CRM_Financial_DAO_PaymentProcessor extends CRM_Core_DAO {
           'title' => ts('Button URL'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_payment_processor.url_button',
           'table_name' => 'civicrm_payment_processor',
           'entity' => 'PaymentProcessor',
           'bao' => 'CRM_Financial_BAO_PaymentProcessor',
@@ -420,6 +436,7 @@ class CRM_Financial_DAO_PaymentProcessor extends CRM_Core_DAO {
           'title' => ts('Subject'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_payment_processor.subject',
           'table_name' => 'civicrm_payment_processor',
           'entity' => 'PaymentProcessor',
           'bao' => 'CRM_Financial_BAO_PaymentProcessor',
@@ -434,6 +451,7 @@ class CRM_Financial_DAO_PaymentProcessor extends CRM_Core_DAO {
           'title' => ts('Suffix for PHP class name implementation'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_payment_processor.class_name',
           'table_name' => 'civicrm_payment_processor',
           'entity' => 'PaymentProcessor',
           'bao' => 'CRM_Financial_BAO_PaymentProcessor',
@@ -445,6 +463,7 @@ class CRM_Financial_DAO_PaymentProcessor extends CRM_Core_DAO {
           'title' => ts('Processor Billing Mode'),
           'description' => ts('Billing Mode (deprecated)'),
           'required' => TRUE,
+          'where' => 'civicrm_payment_processor.billing_mode',
           'table_name' => 'civicrm_payment_processor',
           'entity' => 'PaymentProcessor',
           'bao' => 'CRM_Financial_BAO_PaymentProcessor',
@@ -455,6 +474,7 @@ class CRM_Financial_DAO_PaymentProcessor extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Processor Supports Recurring?'),
           'description' => ts('Can process recurring contributions'),
+          'where' => 'civicrm_payment_processor.is_recur',
           'table_name' => 'civicrm_payment_processor',
           'entity' => 'PaymentProcessor',
           'bao' => 'CRM_Financial_BAO_PaymentProcessor',
@@ -465,6 +485,7 @@ class CRM_Financial_DAO_PaymentProcessor extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Payment Type'),
           'description' => ts('Payment Type: Credit or Debit (deprecated)'),
+          'where' => 'civicrm_payment_processor.payment_type',
           'default' => '1',
           'table_name' => 'civicrm_payment_processor',
           'entity' => 'PaymentProcessor',
@@ -476,6 +497,7 @@ class CRM_Financial_DAO_PaymentProcessor extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Payment Method'),
           'description' => ts('Payment Instrument ID'),
+          'where' => 'civicrm_payment_processor.payment_instrument_id',
           'default' => '1',
           'table_name' => 'civicrm_payment_processor',
           'entity' => 'PaymentProcessor',
@@ -491,6 +513,7 @@ class CRM_Financial_DAO_PaymentProcessor extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_TEXT,
           'title' => ts('Accepted Credit Cards'),
           'description' => ts('array of accepted credit card types'),
+          'where' => 'civicrm_payment_processor.accepted_credit_cards',
           'default' => 'NULL',
           'table_name' => 'civicrm_payment_processor',
           'entity' => 'PaymentProcessor',
diff --git a/civicrm/CRM/Financial/DAO/PaymentProcessorType.php b/civicrm/CRM/Financial/DAO/PaymentProcessorType.php
index e5de98746e41782e58e521b307a4b89b0d239acb..5bad18359df931a966bf2e0a2a70d34640b3173f 100644
--- a/civicrm/CRM/Financial/DAO/PaymentProcessorType.php
+++ b/civicrm/CRM/Financial/DAO/PaymentProcessorType.php
@@ -185,6 +185,7 @@ class CRM_Financial_DAO_PaymentProcessorType extends CRM_Core_DAO {
           'title' => ts('Payment Processor Type ID'),
           'description' => ts('Payment Processor Type ID'),
           'required' => TRUE,
+          'where' => 'civicrm_payment_processor_type.id',
           'table_name' => 'civicrm_payment_processor_type',
           'entity' => 'PaymentProcessorType',
           'bao' => 'CRM_Financial_BAO_PaymentProcessorType',
@@ -197,6 +198,7 @@ class CRM_Financial_DAO_PaymentProcessorType extends CRM_Core_DAO {
           'description' => ts('Payment Processor Name.'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_payment_processor_type.name',
           'table_name' => 'civicrm_payment_processor_type',
           'entity' => 'PaymentProcessorType',
           'bao' => 'CRM_Financial_BAO_PaymentProcessorType',
@@ -209,6 +211,7 @@ class CRM_Financial_DAO_PaymentProcessorType extends CRM_Core_DAO {
           'description' => ts('Payment Processor Name.'),
           'maxlength' => 127,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_payment_processor_type.title',
           'table_name' => 'civicrm_payment_processor_type',
           'entity' => 'PaymentProcessorType',
           'bao' => 'CRM_Financial_BAO_PaymentProcessorType',
@@ -221,6 +224,7 @@ class CRM_Financial_DAO_PaymentProcessorType extends CRM_Core_DAO {
           'description' => ts('Payment Processor Description.'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_payment_processor_type.description',
           'table_name' => 'civicrm_payment_processor_type',
           'entity' => 'PaymentProcessorType',
           'bao' => 'CRM_Financial_BAO_PaymentProcessorType',
@@ -231,6 +235,7 @@ class CRM_Financial_DAO_PaymentProcessorType extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Processor Type Is Active?'),
           'description' => ts('Is this processor active?'),
+          'where' => 'civicrm_payment_processor_type.is_active',
           'table_name' => 'civicrm_payment_processor_type',
           'entity' => 'PaymentProcessorType',
           'bao' => 'CRM_Financial_BAO_PaymentProcessorType',
@@ -241,6 +246,7 @@ class CRM_Financial_DAO_PaymentProcessorType extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Processor Type is Default?'),
           'description' => ts('Is this processor the default?'),
+          'where' => 'civicrm_payment_processor_type.is_default',
           'table_name' => 'civicrm_payment_processor_type',
           'entity' => 'PaymentProcessorType',
           'bao' => 'CRM_Financial_BAO_PaymentProcessorType',
@@ -252,6 +258,7 @@ class CRM_Financial_DAO_PaymentProcessorType extends CRM_Core_DAO {
           'title' => ts('Label for User Name if used'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_payment_processor_type.user_name_label',
           'table_name' => 'civicrm_payment_processor_type',
           'entity' => 'PaymentProcessorType',
           'bao' => 'CRM_Financial_BAO_PaymentProcessorType',
@@ -263,6 +270,7 @@ class CRM_Financial_DAO_PaymentProcessorType extends CRM_Core_DAO {
           'title' => ts('Label for password'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_payment_processor_type.password_label',
           'table_name' => 'civicrm_payment_processor_type',
           'entity' => 'PaymentProcessorType',
           'bao' => 'CRM_Financial_BAO_PaymentProcessorType',
@@ -274,6 +282,7 @@ class CRM_Financial_DAO_PaymentProcessorType extends CRM_Core_DAO {
           'title' => ts('Label for Signature'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_payment_processor_type.signature_label',
           'table_name' => 'civicrm_payment_processor_type',
           'entity' => 'PaymentProcessorType',
           'bao' => 'CRM_Financial_BAO_PaymentProcessorType',
@@ -285,6 +294,7 @@ class CRM_Financial_DAO_PaymentProcessorType extends CRM_Core_DAO {
           'title' => ts('Label for Subject'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_payment_processor_type.subject_label',
           'table_name' => 'civicrm_payment_processor_type',
           'entity' => 'PaymentProcessorType',
           'bao' => 'CRM_Financial_BAO_PaymentProcessorType',
@@ -296,6 +306,7 @@ class CRM_Financial_DAO_PaymentProcessorType extends CRM_Core_DAO {
           'title' => ts('Suffix for PHP class name implementation'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_payment_processor_type.class_name',
           'table_name' => 'civicrm_payment_processor_type',
           'entity' => 'PaymentProcessorType',
           'bao' => 'CRM_Financial_BAO_PaymentProcessorType',
@@ -307,6 +318,7 @@ class CRM_Financial_DAO_PaymentProcessorType extends CRM_Core_DAO {
           'title' => ts('Default Live Site URL'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_payment_processor_type.url_site_default',
           'table_name' => 'civicrm_payment_processor_type',
           'entity' => 'PaymentProcessorType',
           'bao' => 'CRM_Financial_BAO_PaymentProcessorType',
@@ -318,6 +330,7 @@ class CRM_Financial_DAO_PaymentProcessorType extends CRM_Core_DAO {
           'title' => ts('Default API Site URL'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_payment_processor_type.url_api_default',
           'table_name' => 'civicrm_payment_processor_type',
           'entity' => 'PaymentProcessorType',
           'bao' => 'CRM_Financial_BAO_PaymentProcessorType',
@@ -329,6 +342,7 @@ class CRM_Financial_DAO_PaymentProcessorType extends CRM_Core_DAO {
           'title' => ts('Default Live Recurring Payments URL'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_payment_processor_type.url_recur_default',
           'table_name' => 'civicrm_payment_processor_type',
           'entity' => 'PaymentProcessorType',
           'bao' => 'CRM_Financial_BAO_PaymentProcessorType',
@@ -340,6 +354,7 @@ class CRM_Financial_DAO_PaymentProcessorType extends CRM_Core_DAO {
           'title' => ts('Default Live Button URL'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_payment_processor_type.url_button_default',
           'table_name' => 'civicrm_payment_processor_type',
           'entity' => 'PaymentProcessorType',
           'bao' => 'CRM_Financial_BAO_PaymentProcessorType',
@@ -351,6 +366,7 @@ class CRM_Financial_DAO_PaymentProcessorType extends CRM_Core_DAO {
           'title' => ts('Default Test Site URL'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_payment_processor_type.url_site_test_default',
           'table_name' => 'civicrm_payment_processor_type',
           'entity' => 'PaymentProcessorType',
           'bao' => 'CRM_Financial_BAO_PaymentProcessorType',
@@ -362,6 +378,7 @@ class CRM_Financial_DAO_PaymentProcessorType extends CRM_Core_DAO {
           'title' => ts('Default Test API URL'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_payment_processor_type.url_api_test_default',
           'table_name' => 'civicrm_payment_processor_type',
           'entity' => 'PaymentProcessorType',
           'bao' => 'CRM_Financial_BAO_PaymentProcessorType',
@@ -373,6 +390,7 @@ class CRM_Financial_DAO_PaymentProcessorType extends CRM_Core_DAO {
           'title' => ts('Default Test Recurring Payment URL'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_payment_processor_type.url_recur_test_default',
           'table_name' => 'civicrm_payment_processor_type',
           'entity' => 'PaymentProcessorType',
           'bao' => 'CRM_Financial_BAO_PaymentProcessorType',
@@ -384,6 +402,7 @@ class CRM_Financial_DAO_PaymentProcessorType extends CRM_Core_DAO {
           'title' => ts('Default Test Button URL'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_payment_processor_type.url_button_test_default',
           'table_name' => 'civicrm_payment_processor_type',
           'entity' => 'PaymentProcessorType',
           'bao' => 'CRM_Financial_BAO_PaymentProcessorType',
@@ -395,6 +414,7 @@ class CRM_Financial_DAO_PaymentProcessorType extends CRM_Core_DAO {
           'title' => ts('Billing Mode'),
           'description' => ts('Billing Mode (deprecated)'),
           'required' => TRUE,
+          'where' => 'civicrm_payment_processor_type.billing_mode',
           'table_name' => 'civicrm_payment_processor_type',
           'entity' => 'PaymentProcessorType',
           'bao' => 'CRM_Financial_BAO_PaymentProcessorType',
@@ -411,6 +431,7 @@ class CRM_Financial_DAO_PaymentProcessorType extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Processor Type Supports Recurring?'),
           'description' => ts('Can process recurring contributions'),
+          'where' => 'civicrm_payment_processor_type.is_recur',
           'table_name' => 'civicrm_payment_processor_type',
           'entity' => 'PaymentProcessorType',
           'bao' => 'CRM_Financial_BAO_PaymentProcessorType',
@@ -421,6 +442,7 @@ class CRM_Financial_DAO_PaymentProcessorType extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Processor Type Payment Type'),
           'description' => ts('Payment Type: Credit or Debit (deprecated)'),
+          'where' => 'civicrm_payment_processor_type.payment_type',
           'default' => '1',
           'table_name' => 'civicrm_payment_processor_type',
           'entity' => 'PaymentProcessorType',
@@ -432,6 +454,7 @@ class CRM_Financial_DAO_PaymentProcessorType extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Payment Method'),
           'description' => ts('Payment Instrument ID'),
+          'where' => 'civicrm_payment_processor_type.payment_instrument_id',
           'default' => '1',
           'table_name' => 'civicrm_payment_processor_type',
           'entity' => 'PaymentProcessorType',
diff --git a/civicrm/CRM/Financial/DAO/PaymentToken.php b/civicrm/CRM/Financial/DAO/PaymentToken.php
index 923f2fb4fb2ef47afa9cf52349511f0822ce78c8..88206dd264f769e4330994e6e2665262cabe2fec 100644
--- a/civicrm/CRM/Financial/DAO/PaymentToken.php
+++ b/civicrm/CRM/Financial/DAO/PaymentToken.php
@@ -156,6 +156,7 @@ class CRM_Financial_DAO_PaymentToken extends CRM_Core_DAO {
           'title' => ts('Payment Token ID'),
           'description' => ts('Payment Token ID'),
           'required' => TRUE,
+          'where' => 'civicrm_payment_token.id',
           'table_name' => 'civicrm_payment_token',
           'entity' => 'PaymentToken',
           'bao' => 'CRM_Financial_DAO_PaymentToken',
@@ -167,6 +168,7 @@ class CRM_Financial_DAO_PaymentToken extends CRM_Core_DAO {
           'title' => ts('Contact ID'),
           'description' => ts('FK to Contact ID for the owner of the token'),
           'required' => TRUE,
+          'where' => 'civicrm_payment_token.contact_id',
           'table_name' => 'civicrm_payment_token',
           'entity' => 'PaymentToken',
           'bao' => 'CRM_Financial_DAO_PaymentToken',
@@ -178,6 +180,7 @@ class CRM_Financial_DAO_PaymentToken extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Payment Processor ID'),
           'required' => TRUE,
+          'where' => 'civicrm_payment_token.payment_processor_id',
           'table_name' => 'civicrm_payment_token',
           'entity' => 'PaymentToken',
           'bao' => 'CRM_Financial_DAO_PaymentToken',
@@ -192,6 +195,7 @@ class CRM_Financial_DAO_PaymentToken extends CRM_Core_DAO {
           'required' => TRUE,
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_payment_token.token',
           'table_name' => 'civicrm_payment_token',
           'entity' => 'PaymentToken',
           'bao' => 'CRM_Financial_DAO_PaymentToken',
@@ -202,6 +206,7 @@ class CRM_Financial_DAO_PaymentToken extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_TIMESTAMP,
           'title' => ts('Created Date'),
           'description' => ts('Date created'),
+          'where' => 'civicrm_payment_token.created_date',
           'default' => 'CURRENT_TIMESTAMP',
           'table_name' => 'civicrm_payment_token',
           'entity' => 'PaymentToken',
@@ -213,6 +218,7 @@ class CRM_Financial_DAO_PaymentToken extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Created ID'),
           'description' => ts('Contact ID of token creator'),
+          'where' => 'civicrm_payment_token.created_id',
           'table_name' => 'civicrm_payment_token',
           'entity' => 'PaymentToken',
           'bao' => 'CRM_Financial_DAO_PaymentToken',
@@ -224,6 +230,7 @@ class CRM_Financial_DAO_PaymentToken extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
           'title' => ts('Expiry Date'),
           'description' => ts('Date this token expires'),
+          'where' => 'civicrm_payment_token.expiry_date',
           'table_name' => 'civicrm_payment_token',
           'entity' => 'PaymentToken',
           'bao' => 'CRM_Financial_DAO_PaymentToken',
@@ -236,6 +243,7 @@ class CRM_Financial_DAO_PaymentToken extends CRM_Core_DAO {
           'description' => ts('Email at the time of token creation. Useful for fraud forensics'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_payment_token.email',
           'table_name' => 'civicrm_payment_token',
           'entity' => 'PaymentToken',
           'bao' => 'CRM_Financial_DAO_PaymentToken',
@@ -248,6 +256,7 @@ class CRM_Financial_DAO_PaymentToken extends CRM_Core_DAO {
           'description' => ts('Billing first name at the time of token creation. Useful for fraud forensics'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_payment_token.billing_first_name',
           'table_name' => 'civicrm_payment_token',
           'entity' => 'PaymentToken',
           'bao' => 'CRM_Financial_DAO_PaymentToken',
@@ -260,6 +269,7 @@ class CRM_Financial_DAO_PaymentToken extends CRM_Core_DAO {
           'description' => ts('Billing middle name at the time of token creation. Useful for fraud forensics'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_payment_token.billing_middle_name',
           'table_name' => 'civicrm_payment_token',
           'entity' => 'PaymentToken',
           'bao' => 'CRM_Financial_DAO_PaymentToken',
@@ -272,6 +282,7 @@ class CRM_Financial_DAO_PaymentToken extends CRM_Core_DAO {
           'description' => ts('Billing last name at the time of token creation. Useful for fraud forensics'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_payment_token.billing_last_name',
           'table_name' => 'civicrm_payment_token',
           'entity' => 'PaymentToken',
           'bao' => 'CRM_Financial_DAO_PaymentToken',
@@ -284,6 +295,7 @@ class CRM_Financial_DAO_PaymentToken extends CRM_Core_DAO {
           'description' => ts('Holds the part of the card number or account details that may be retained or displayed'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_payment_token.masked_account_number',
           'table_name' => 'civicrm_payment_token',
           'entity' => 'PaymentToken',
           'bao' => 'CRM_Financial_DAO_PaymentToken',
@@ -296,6 +308,7 @@ class CRM_Financial_DAO_PaymentToken extends CRM_Core_DAO {
           'description' => ts('IP used when creating the token. Useful for fraud forensics'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_payment_token.ip_address',
           'table_name' => 'civicrm_payment_token',
           'entity' => 'PaymentToken',
           'bao' => 'CRM_Financial_DAO_PaymentToken',
diff --git a/civicrm/CRM/Friend/DAO/Friend.php b/civicrm/CRM/Friend/DAO/Friend.php
index 568c648d3344bf9edd8c9e5ebc6e6a9815a14a2c..2d568215f02d59410022a276cf85c2d3cf0af0ac 100644
--- a/civicrm/CRM/Friend/DAO/Friend.php
+++ b/civicrm/CRM/Friend/DAO/Friend.php
@@ -131,6 +131,7 @@ class CRM_Friend_DAO_Friend extends CRM_Core_DAO {
           'title' => ts('Friend ID'),
           'description' => ts('Friend ID'),
           'required' => TRUE,
+          'where' => 'civicrm_tell_friend.id',
           'table_name' => 'civicrm_tell_friend',
           'entity' => 'Friend',
           'bao' => 'CRM_Friend_BAO_Friend',
@@ -144,6 +145,7 @@ class CRM_Friend_DAO_Friend extends CRM_Core_DAO {
           'required' => TRUE,
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_tell_friend.entity_table',
           'table_name' => 'civicrm_tell_friend',
           'entity' => 'Friend',
           'bao' => 'CRM_Friend_BAO_Friend',
@@ -155,6 +157,7 @@ class CRM_Friend_DAO_Friend extends CRM_Core_DAO {
           'title' => ts('Entity ID'),
           'description' => ts('Foreign key to the referenced item.'),
           'required' => TRUE,
+          'where' => 'civicrm_tell_friend.entity_id',
           'table_name' => 'civicrm_tell_friend',
           'entity' => 'Friend',
           'bao' => 'CRM_Friend_BAO_Friend',
@@ -166,6 +169,7 @@ class CRM_Friend_DAO_Friend extends CRM_Core_DAO {
           'title' => ts('Title'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_tell_friend.title',
           'table_name' => 'civicrm_tell_friend',
           'entity' => 'Friend',
           'bao' => 'CRM_Friend_BAO_Friend',
@@ -179,6 +183,7 @@ class CRM_Friend_DAO_Friend extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_TEXT,
           'title' => ts('Intro'),
           'description' => ts('Introductory message to contributor or participant displayed on the Tell a Friend form.'),
+          'where' => 'civicrm_tell_friend.intro',
           'table_name' => 'civicrm_tell_friend',
           'entity' => 'Friend',
           'bao' => 'CRM_Friend_BAO_Friend',
@@ -192,6 +197,7 @@ class CRM_Friend_DAO_Friend extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_TEXT,
           'title' => ts('Suggested Message'),
           'description' => ts('Suggested message to friends, provided as default on the Tell A Friend form.'),
+          'where' => 'civicrm_tell_friend.suggested_message',
           'table_name' => 'civicrm_tell_friend',
           'entity' => 'Friend',
           'bao' => 'CRM_Friend_BAO_Friend',
@@ -209,8 +215,6 @@ class CRM_Friend_DAO_Friend extends CRM_Core_DAO {
           'size' => CRM_Utils_Type::HUGE,
           'import' => TRUE,
           'where' => 'civicrm_tell_friend.general_link',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_tell_friend',
           'entity' => 'Friend',
@@ -227,6 +231,7 @@ class CRM_Friend_DAO_Friend extends CRM_Core_DAO {
           'description' => ts('Text for Tell a Friend thank you page header and HTML title.'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_tell_friend.thankyou_title',
           'table_name' => 'civicrm_tell_friend',
           'entity' => 'Friend',
           'bao' => 'CRM_Friend_BAO_Friend',
@@ -240,6 +245,7 @@ class CRM_Friend_DAO_Friend extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_TEXT,
           'title' => ts('Thank You Text'),
           'description' => ts('Thank you message displayed on success page.'),
+          'where' => 'civicrm_tell_friend.thankyou_text',
           'table_name' => 'civicrm_tell_friend',
           'entity' => 'Friend',
           'bao' => 'CRM_Friend_BAO_Friend',
@@ -252,6 +258,7 @@ class CRM_Friend_DAO_Friend extends CRM_Core_DAO {
           'name' => 'is_active',
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Enabled?'),
+          'where' => 'civicrm_tell_friend.is_active',
           'table_name' => 'civicrm_tell_friend',
           'entity' => 'Friend',
           'bao' => 'CRM_Friend_BAO_Friend',
diff --git a/civicrm/CRM/Grant/DAO/Grant.php b/civicrm/CRM/Grant/DAO/Grant.php
index f3b0a3f4149048fa70698585d2a39f3e11b1b101..ce4dfe0d4c8e6bf743877f2db5d94ea8a9fff74f 100644
--- a/civicrm/CRM/Grant/DAO/Grant.php
+++ b/civicrm/CRM/Grant/DAO/Grant.php
@@ -173,8 +173,6 @@ class CRM_Grant_DAO_Grant extends CRM_Core_DAO {
           'required' => TRUE,
           'import' => TRUE,
           'where' => 'civicrm_grant.id',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_grant',
           'entity' => 'Grant',
@@ -187,10 +185,8 @@ class CRM_Grant_DAO_Grant extends CRM_Core_DAO {
           'title' => ts('Contact ID'),
           'description' => ts('Contact ID of contact record given grant belongs to.'),
           'required' => TRUE,
-          'export' => TRUE,
           'where' => 'civicrm_grant.contact_id',
-          'headerPattern' => '',
-          'dataPattern' => '',
+          'export' => TRUE,
           'table_name' => 'civicrm_grant',
           'entity' => 'Grant',
           'bao' => 'CRM_Grant_BAO_Grant',
@@ -207,8 +203,6 @@ class CRM_Grant_DAO_Grant extends CRM_Core_DAO {
           'description' => ts('Date on which grant application was received by donor.'),
           'import' => TRUE,
           'where' => 'civicrm_grant.application_received_date',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_grant',
           'entity' => 'Grant',
@@ -226,8 +220,6 @@ class CRM_Grant_DAO_Grant extends CRM_Core_DAO {
           'description' => ts('Date on which grant decision was made.'),
           'import' => TRUE,
           'where' => 'civicrm_grant.decision_date',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_grant',
           'entity' => 'Grant',
@@ -245,8 +237,6 @@ class CRM_Grant_DAO_Grant extends CRM_Core_DAO {
           'description' => ts('Date on which grant money transfer was made.'),
           'import' => TRUE,
           'where' => 'civicrm_grant.money_transfer_date',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_grant',
           'entity' => 'Grant',
@@ -264,8 +254,6 @@ class CRM_Grant_DAO_Grant extends CRM_Core_DAO {
           'description' => ts('Date on which grant report is due.'),
           'import' => TRUE,
           'where' => 'civicrm_grant.grant_due_date',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_grant',
           'entity' => 'Grant',
@@ -283,8 +271,6 @@ class CRM_Grant_DAO_Grant extends CRM_Core_DAO {
           'description' => ts('Yes/No field stating whether grant report was received by donor.'),
           'import' => TRUE,
           'where' => 'civicrm_grant.grant_report_received',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_grant',
           'entity' => 'Grant',
@@ -300,10 +286,8 @@ class CRM_Grant_DAO_Grant extends CRM_Core_DAO {
           'title' => ts('Grant Type'),
           'description' => ts('Type of grant. Implicit FK to civicrm_option_value in grant_type option_group.'),
           'required' => TRUE,
-          'export' => TRUE,
           'where' => 'civicrm_grant.grant_type_id',
-          'headerPattern' => '',
-          'dataPattern' => '',
+          'export' => TRUE,
           'table_name' => 'civicrm_grant',
           'entity' => 'Grant',
           'bao' => 'CRM_Grant_BAO_Grant',
@@ -328,7 +312,6 @@ class CRM_Grant_DAO_Grant extends CRM_Core_DAO {
           ],
           'import' => TRUE,
           'where' => 'civicrm_grant.amount_total',
-          'headerPattern' => '',
           'dataPattern' => '/^\d+(\.\d{2})?$/',
           'export' => TRUE,
           'table_name' => 'civicrm_grant',
@@ -348,6 +331,8 @@ class CRM_Grant_DAO_Grant extends CRM_Core_DAO {
             20,
             2
           ],
+          'where' => 'civicrm_grant.amount_requested',
+          'dataPattern' => '/^\d+(\.\d{2})?$/',
           'table_name' => 'civicrm_grant',
           'entity' => 'Grant',
           'bao' => 'CRM_Grant_BAO_Grant',
@@ -367,7 +352,6 @@ class CRM_Grant_DAO_Grant extends CRM_Core_DAO {
           ],
           'import' => TRUE,
           'where' => 'civicrm_grant.amount_granted',
-          'headerPattern' => '',
           'dataPattern' => '/^\d+(\.\d{2})?$/',
           'export' => TRUE,
           'table_name' => 'civicrm_grant',
@@ -386,6 +370,7 @@ class CRM_Grant_DAO_Grant extends CRM_Core_DAO {
           'required' => TRUE,
           'maxlength' => 3,
           'size' => CRM_Utils_Type::FOUR,
+          'where' => 'civicrm_grant.currency',
           'table_name' => 'civicrm_grant',
           'entity' => 'Grant',
           'bao' => 'CRM_Grant_BAO_Grant',
@@ -409,8 +394,6 @@ class CRM_Grant_DAO_Grant extends CRM_Core_DAO {
           'cols' => 60,
           'import' => TRUE,
           'where' => 'civicrm_grant.rationale',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_grant',
           'entity' => 'Grant',
@@ -428,8 +411,6 @@ class CRM_Grant_DAO_Grant extends CRM_Core_DAO {
           'required' => TRUE,
           'import' => TRUE,
           'where' => 'civicrm_grant.status_id',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => FALSE,
           'table_name' => 'civicrm_grant',
           'entity' => 'Grant',
@@ -448,6 +429,7 @@ class CRM_Grant_DAO_Grant extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Financial Type'),
           'description' => ts('FK to Financial Type.'),
+          'where' => 'civicrm_grant.financial_type_id',
           'default' => 'NULL',
           'table_name' => 'civicrm_grant',
           'entity' => 'Grant',
diff --git a/civicrm/CRM/Group/Form/Edit.php b/civicrm/CRM/Group/Form/Edit.php
index 789689886fd8d2543d080254f98fede1429f88a0..3c3e9722fbde2ab91c1b9e614fe0ac7248c946d1 100644
--- a/civicrm/CRM/Group/Form/Edit.php
+++ b/civicrm/CRM/Group/Form/Edit.php
@@ -36,6 +36,8 @@
  */
 class CRM_Group_Form_Edit extends CRM_Core_Form {
 
+  use CRM_Core_Form_EntityFormTrait;
+
   /**
    * The group id, used when editing a group
    *
@@ -78,6 +80,35 @@ class CRM_Group_Form_Edit extends CRM_Core_Form {
    */
   protected $_groupOrganizationID;
 
+  /**
+   * Set entity fields to be assigned to the form.
+   */
+  protected function setEntityFields() {
+    $this->entityFields = [
+      'title' => [
+        'name' => 'title',
+        'required' => TRUE,
+      ],
+      'description' => ['name' => 'description'],
+    ];
+  }
+
+  /**
+   * Set the delete message.
+   *
+   * We do this from the constructor in order to do a translation.
+   */
+  public function setDeleteMessage() {
+    $this->deleteMessage = '';
+  }
+
+  /**
+   * Explicitly declare the entity api name.
+   */
+  public function getDefaultEntity() {
+    return 'Group';
+  }
+
   /**
    * Set up variables to build the form.
    */
@@ -213,18 +244,8 @@ class CRM_Group_Form_Edit extends CRM_Core_Form {
    * Build the form object.
    */
   public function buildQuickForm() {
-    if ($this->_action == CRM_Core_Action::DELETE) {
-      $this->addButtons(array(
-        array(
-          'type' => 'next',
-          'name' => ts('Delete Group'),
-          'isDefault' => TRUE,
-        ),
-        array(
-          'type' => 'cancel',
-          'name' => ts('Cancel'),
-        ),
-      ));
+    self::buildQuickEntityForm();
+    if ($this->_action & CRM_Core_Action::DELETE) {
       return;
     }
 
@@ -233,15 +254,6 @@ class CRM_Group_Form_Edit extends CRM_Core_Form {
       $this->preventAjaxSubmit();
     }
 
-    $this->applyFilter('__ALL__', 'trim');
-    $this->add('text', 'title', ts('Name') . ' ',
-      CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Group', 'title'), TRUE
-    );
-
-    $this->add('textarea', 'description', ts('Description') . ' ',
-      CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Group', 'description')
-    );
-
     $groupTypes = CRM_Core_OptionGroup::values('group_type', TRUE);
 
     if (isset($this->_id) && !empty($this->_groupValues['saved_search_id'])) {
@@ -272,18 +284,6 @@ class CRM_Group_Form_Edit extends CRM_Core_Form {
     //build custom data
     CRM_Custom_Form_CustomData::buildQuickForm($this);
 
-    $this->addButtons(array(
-      array(
-        'type' => 'upload',
-        'name' => ($this->_action == CRM_Core_Action::ADD) ? ts('Continue') : ts('Save'),
-        'isDefault' => TRUE,
-      ),
-      array(
-        'type' => 'cancel',
-        'name' => ts('Cancel'),
-      ),
-    ));
-
     $doParentCheck = FALSE;
     if (CRM_Core_Permission::isMultisiteEnabled()) {
       $doParentCheck = ($this->_id && CRM_Core_BAO_Domain::isDomainGroup($this->_id)) ? FALSE : TRUE;
diff --git a/civicrm/CRM/Mailing/BAO/Mailing.php b/civicrm/CRM/Mailing/BAO/Mailing.php
index f0ced3b8d881c77010710a14236a9736045661f5..21d10f7c5f77d2aab9ed34ad29bb15daed6f7446 100644
--- a/civicrm/CRM/Mailing/BAO/Mailing.php
+++ b/civicrm/CRM/Mailing/BAO/Mailing.php
@@ -1363,6 +1363,10 @@ ORDER BY   civicrm_email.is_bulkmail DESC
       $numSlices = count($embed_data);
       $url = '';
       for ($i = 0; $i < $numSlices; $i++) {
+        $embed_url_data = parse_url($embed_data[$i]);
+        if (!empty($embed_url_data['scheme'])) {
+          $token_a['embed_parts'][$i] = preg_replace("/href=\"(https*:\/\/)/", "href=\"", $token_a['embed_parts'][$i]);
+        }
         $url .= "{$token_a['embed_parts'][$i]}{$embed_data[$i]}";
       }
       if (isset($token_a['embed_parts'][$numSlices])) {
diff --git a/civicrm/CRM/Mailing/BAO/TrackableURL.php b/civicrm/CRM/Mailing/BAO/TrackableURL.php
index 6c5b6590f2d9823ff8b6be45a7cc214e97b466ed..da57a134c3eb8674234aa1318cc8dc01a9c8cd4d 100644
--- a/civicrm/CRM/Mailing/BAO/TrackableURL.php
+++ b/civicrm/CRM/Mailing/BAO/TrackableURL.php
@@ -88,7 +88,6 @@ class CRM_Mailing_BAO_TrackableURL extends CRM_Mailing_DAO_TrackableURL {
         $tracker->save();
       }
       $id = $tracker->id;
-      $tracker->free();
 
       $redirect = $config->userFrameworkResourceURL . "extern/url.php?u=$id";
       $urlCache[$mailing_id . $url] = $redirect;
diff --git a/civicrm/CRM/Mailing/DAO/BouncePattern.php b/civicrm/CRM/Mailing/DAO/BouncePattern.php
index 447451c0dc9034d0d6ee4eda1978f8f2dd5d2d2f..efdaf7d04e58e16661ac8805a71285ab609eb77a 100644
--- a/civicrm/CRM/Mailing/DAO/BouncePattern.php
+++ b/civicrm/CRM/Mailing/DAO/BouncePattern.php
@@ -83,6 +83,7 @@ class CRM_Mailing_DAO_BouncePattern extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Bounce Pattern ID'),
           'required' => TRUE,
+          'where' => 'civicrm_mailing_bounce_pattern.id',
           'table_name' => 'civicrm_mailing_bounce_pattern',
           'entity' => 'BouncePattern',
           'bao' => 'CRM_Mailing_BAO_BouncePattern',
@@ -94,6 +95,7 @@ class CRM_Mailing_DAO_BouncePattern extends CRM_Core_DAO {
           'title' => ts('Bounce Type'),
           'description' => ts('Type of bounce'),
           'required' => TRUE,
+          'where' => 'civicrm_mailing_bounce_pattern.bounce_type_id',
           'table_name' => 'civicrm_mailing_bounce_pattern',
           'entity' => 'BouncePattern',
           'bao' => 'CRM_Mailing_BAO_BouncePattern',
@@ -107,6 +109,7 @@ class CRM_Mailing_DAO_BouncePattern extends CRM_Core_DAO {
           'description' => ts('A regexp to match a message to a bounce type'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_mailing_bounce_pattern.pattern',
           'table_name' => 'civicrm_mailing_bounce_pattern',
           'entity' => 'BouncePattern',
           'bao' => 'CRM_Mailing_BAO_BouncePattern',
diff --git a/civicrm/CRM/Mailing/DAO/BounceType.php b/civicrm/CRM/Mailing/DAO/BounceType.php
index 134ed3302e2b7106273491ad8a6bb47903d282ef..6819e18c518a6df63b89e1a6d23577c8ddccef35 100644
--- a/civicrm/CRM/Mailing/DAO/BounceType.php
+++ b/civicrm/CRM/Mailing/DAO/BounceType.php
@@ -75,6 +75,7 @@ class CRM_Mailing_DAO_BounceType extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Bounce Type ID'),
           'required' => TRUE,
+          'where' => 'civicrm_mailing_bounce_type.id',
           'table_name' => 'civicrm_mailing_bounce_type',
           'entity' => 'BounceType',
           'bao' => 'CRM_Mailing_DAO_BounceType',
@@ -88,6 +89,7 @@ class CRM_Mailing_DAO_BounceType extends CRM_Core_DAO {
           'required' => TRUE,
           'maxlength' => 24,
           'size' => CRM_Utils_Type::MEDIUM,
+          'where' => 'civicrm_mailing_bounce_type.name',
           'table_name' => 'civicrm_mailing_bounce_type',
           'entity' => 'BounceType',
           'bao' => 'CRM_Mailing_DAO_BounceType',
@@ -100,6 +102,7 @@ class CRM_Mailing_DAO_BounceType extends CRM_Core_DAO {
           'description' => ts('A description of this bounce type'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_mailing_bounce_type.description',
           'table_name' => 'civicrm_mailing_bounce_type',
           'entity' => 'BounceType',
           'bao' => 'CRM_Mailing_DAO_BounceType',
@@ -111,6 +114,7 @@ class CRM_Mailing_DAO_BounceType extends CRM_Core_DAO {
           'title' => ts('Hold Threshold'),
           'description' => ts('Number of bounces of this type required before the email address is put on bounce hold'),
           'required' => TRUE,
+          'where' => 'civicrm_mailing_bounce_type.hold_threshold',
           'table_name' => 'civicrm_mailing_bounce_type',
           'entity' => 'BounceType',
           'bao' => 'CRM_Mailing_DAO_BounceType',
diff --git a/civicrm/CRM/Mailing/DAO/Mailing.php b/civicrm/CRM/Mailing/DAO/Mailing.php
index e57dc5ced88d8afb730caaca1f1ad87abfc2e0fc..4296e1ea7d774dcbdf2217d8e12d7527111635da 100644
--- a/civicrm/CRM/Mailing/DAO/Mailing.php
+++ b/civicrm/CRM/Mailing/DAO/Mailing.php
@@ -371,6 +371,7 @@ class CRM_Mailing_DAO_Mailing extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Mailing ID'),
           'required' => TRUE,
+          'where' => 'civicrm_mailing.id',
           'table_name' => 'civicrm_mailing',
           'entity' => 'Mailing',
           'bao' => 'CRM_Mailing_BAO_Mailing',
@@ -381,6 +382,7 @@ class CRM_Mailing_DAO_Mailing extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Mailing Domain'),
           'description' => ts('Which site is this mailing for'),
+          'where' => 'civicrm_mailing.domain_id',
           'table_name' => 'civicrm_mailing',
           'entity' => 'Mailing',
           'bao' => 'CRM_Mailing_BAO_Mailing',
@@ -397,6 +399,7 @@ class CRM_Mailing_DAO_Mailing extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Mailing Header'),
           'description' => ts('FK to the header component.'),
+          'where' => 'civicrm_mailing.header_id',
           'table_name' => 'civicrm_mailing',
           'entity' => 'Mailing',
           'bao' => 'CRM_Mailing_BAO_Mailing',
@@ -408,6 +411,7 @@ class CRM_Mailing_DAO_Mailing extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Mailing Footer'),
           'description' => ts('FK to the footer component.'),
+          'where' => 'civicrm_mailing.footer_id',
           'table_name' => 'civicrm_mailing',
           'entity' => 'Mailing',
           'bao' => 'CRM_Mailing_BAO_Mailing',
@@ -419,6 +423,7 @@ class CRM_Mailing_DAO_Mailing extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Mailing Reply'),
           'description' => ts('FK to the auto-responder component.'),
+          'where' => 'civicrm_mailing.reply_id',
           'table_name' => 'civicrm_mailing',
           'entity' => 'Mailing',
           'bao' => 'CRM_Mailing_BAO_Mailing',
@@ -430,6 +435,7 @@ class CRM_Mailing_DAO_Mailing extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Mailing Unsubscribe'),
           'description' => ts('FK to the unsubscribe component.'),
+          'where' => 'civicrm_mailing.unsubscribe_id',
           'table_name' => 'civicrm_mailing',
           'entity' => 'Mailing',
           'bao' => 'CRM_Mailing_BAO_Mailing',
@@ -440,6 +446,7 @@ class CRM_Mailing_DAO_Mailing extends CRM_Core_DAO {
           'name' => 'resubscribe_id',
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Mailing Resubscribe'),
+          'where' => 'civicrm_mailing.resubscribe_id',
           'table_name' => 'civicrm_mailing',
           'entity' => 'Mailing',
           'bao' => 'CRM_Mailing_BAO_Mailing',
@@ -450,6 +457,7 @@ class CRM_Mailing_DAO_Mailing extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Mailing Opt Out'),
           'description' => ts('FK to the opt-out component.'),
+          'where' => 'civicrm_mailing.optout_id',
           'table_name' => 'civicrm_mailing',
           'entity' => 'Mailing',
           'bao' => 'CRM_Mailing_BAO_Mailing',
@@ -463,6 +471,7 @@ class CRM_Mailing_DAO_Mailing extends CRM_Core_DAO {
           'description' => ts('Mailing Name.'),
           'maxlength' => 128,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_mailing.name',
           'table_name' => 'civicrm_mailing',
           'entity' => 'Mailing',
           'bao' => 'CRM_Mailing_BAO_Mailing',
@@ -478,6 +487,7 @@ class CRM_Mailing_DAO_Mailing extends CRM_Core_DAO {
           'description' => ts('differentiate between standalone mailings, A/B tests, and A/B final-winner'),
           'maxlength' => 32,
           'size' => CRM_Utils_Type::MEDIUM,
+          'where' => 'civicrm_mailing.mailing_type',
           'table_name' => 'civicrm_mailing',
           'entity' => 'Mailing',
           'bao' => 'CRM_Mailing_BAO_Mailing',
@@ -496,6 +506,7 @@ class CRM_Mailing_DAO_Mailing extends CRM_Core_DAO {
           'description' => ts('From Header of mailing'),
           'maxlength' => 128,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_mailing.from_name',
           'table_name' => 'civicrm_mailing',
           'entity' => 'Mailing',
           'bao' => 'CRM_Mailing_BAO_Mailing',
@@ -511,6 +522,7 @@ class CRM_Mailing_DAO_Mailing extends CRM_Core_DAO {
           'description' => ts('From Email of mailing'),
           'maxlength' => 128,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_mailing.from_email',
           'table_name' => 'civicrm_mailing',
           'entity' => 'Mailing',
           'bao' => 'CRM_Mailing_BAO_Mailing',
@@ -526,6 +538,7 @@ class CRM_Mailing_DAO_Mailing extends CRM_Core_DAO {
           'description' => ts('Reply-To Email of mailing'),
           'maxlength' => 128,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_mailing.replyto_email',
           'table_name' => 'civicrm_mailing',
           'entity' => 'Mailing',
           'bao' => 'CRM_Mailing_BAO_Mailing',
@@ -542,6 +555,7 @@ class CRM_Mailing_DAO_Mailing extends CRM_Core_DAO {
           'required' => TRUE,
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_mailing.template_type',
           'default' => 'traditional',
           'table_name' => 'civicrm_mailing',
           'entity' => 'Mailing',
@@ -556,6 +570,7 @@ class CRM_Mailing_DAO_Mailing extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_LONGTEXT,
           'title' => ts('Template Options (JSON)'),
           'description' => ts('Advanced options used by the email templating system. (JSON encoded)'),
+          'where' => 'civicrm_mailing.template_options',
           'table_name' => 'civicrm_mailing',
           'entity' => 'Mailing',
           'bao' => 'CRM_Mailing_BAO_Mailing',
@@ -568,6 +583,7 @@ class CRM_Mailing_DAO_Mailing extends CRM_Core_DAO {
           'description' => ts('Subject of mailing'),
           'maxlength' => 128,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_mailing.subject',
           'table_name' => 'civicrm_mailing',
           'entity' => 'Mailing',
           'bao' => 'CRM_Mailing_BAO_Mailing',
@@ -581,6 +597,7 @@ class CRM_Mailing_DAO_Mailing extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_LONGTEXT,
           'title' => ts('Body Text'),
           'description' => ts('Body of the mailing in text format.'),
+          'where' => 'civicrm_mailing.body_text',
           'table_name' => 'civicrm_mailing',
           'entity' => 'Mailing',
           'bao' => 'CRM_Mailing_BAO_Mailing',
@@ -591,6 +608,7 @@ class CRM_Mailing_DAO_Mailing extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_LONGTEXT,
           'title' => ts('Body Html'),
           'description' => ts('Body of the mailing in html format.'),
+          'where' => 'civicrm_mailing.body_html',
           'table_name' => 'civicrm_mailing',
           'entity' => 'Mailing',
           'bao' => 'CRM_Mailing_BAO_Mailing',
@@ -601,6 +619,7 @@ class CRM_Mailing_DAO_Mailing extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Url Tracking'),
           'description' => ts('Should we track URL click-throughs for this mailing?'),
+          'where' => 'civicrm_mailing.url_tracking',
           'table_name' => 'civicrm_mailing',
           'entity' => 'Mailing',
           'bao' => 'CRM_Mailing_BAO_Mailing',
@@ -614,6 +633,7 @@ class CRM_Mailing_DAO_Mailing extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Forward Replies'),
           'description' => ts('Should we forward replies back to the author?'),
+          'where' => 'civicrm_mailing.forward_replies',
           'table_name' => 'civicrm_mailing',
           'entity' => 'Mailing',
           'bao' => 'CRM_Mailing_BAO_Mailing',
@@ -627,6 +647,7 @@ class CRM_Mailing_DAO_Mailing extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Auto Responder'),
           'description' => ts('Should we enable the auto-responder?'),
+          'where' => 'civicrm_mailing.auto_responder',
           'table_name' => 'civicrm_mailing',
           'entity' => 'Mailing',
           'bao' => 'CRM_Mailing_BAO_Mailing',
@@ -640,6 +661,7 @@ class CRM_Mailing_DAO_Mailing extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Track Mailing?'),
           'description' => ts('Should we track when recipients open/read this mailing?'),
+          'where' => 'civicrm_mailing.open_tracking',
           'table_name' => 'civicrm_mailing',
           'entity' => 'Mailing',
           'bao' => 'CRM_Mailing_BAO_Mailing',
@@ -650,6 +672,7 @@ class CRM_Mailing_DAO_Mailing extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Mailing Completed'),
           'description' => ts('Has at least one job associated with this mailing finished?'),
+          'where' => 'civicrm_mailing.is_completed',
           'table_name' => 'civicrm_mailing',
           'entity' => 'Mailing',
           'bao' => 'CRM_Mailing_BAO_Mailing',
@@ -663,6 +686,7 @@ class CRM_Mailing_DAO_Mailing extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Mailing Message Template'),
           'description' => ts('FK to the message template.'),
+          'where' => 'civicrm_mailing.msg_template_id',
           'table_name' => 'civicrm_mailing',
           'entity' => 'Mailing',
           'bao' => 'CRM_Mailing_BAO_Mailing',
@@ -674,6 +698,7 @@ class CRM_Mailing_DAO_Mailing extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Override Verp'),
           'description' => ts('Should we overrite VERP address in Reply-To'),
+          'where' => 'civicrm_mailing.override_verp',
           'default' => '0',
           'table_name' => 'civicrm_mailing',
           'entity' => 'Mailing',
@@ -688,6 +713,7 @@ class CRM_Mailing_DAO_Mailing extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Mailing Creator'),
           'description' => ts('FK to Contact ID who first created this mailing'),
+          'where' => 'civicrm_mailing.created_id',
           'table_name' => 'civicrm_mailing',
           'entity' => 'Mailing',
           'bao' => 'CRM_Mailing_BAO_Mailing',
@@ -700,6 +726,7 @@ class CRM_Mailing_DAO_Mailing extends CRM_Core_DAO {
           'title' => ts('Mailing Created Date'),
           'description' => ts('Date and time this mailing was created.'),
           'required' => FALSE,
+          'where' => 'civicrm_mailing.created_date',
           'default' => 'NULL',
           'table_name' => 'civicrm_mailing',
           'entity' => 'Mailing',
@@ -716,10 +743,8 @@ class CRM_Mailing_DAO_Mailing extends CRM_Core_DAO {
           'title' => ts('Modified Date'),
           'description' => ts('When the mailing (or closely related entity) was created or modified or deleted.'),
           'required' => FALSE,
-          'export' => TRUE,
           'where' => 'civicrm_mailing.modified_date',
-          'headerPattern' => '',
-          'dataPattern' => '',
+          'export' => TRUE,
           'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
           'table_name' => 'civicrm_mailing',
           'entity' => 'Mailing',
@@ -731,6 +756,7 @@ class CRM_Mailing_DAO_Mailing extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Scheduled By'),
           'description' => ts('FK to Contact ID who scheduled this mailing'),
+          'where' => 'civicrm_mailing.scheduled_id',
           'table_name' => 'civicrm_mailing',
           'entity' => 'Mailing',
           'bao' => 'CRM_Mailing_BAO_Mailing',
@@ -743,6 +769,7 @@ class CRM_Mailing_DAO_Mailing extends CRM_Core_DAO {
           'title' => ts('Mailing Scheduled Date'),
           'description' => ts('Date and time this mailing was scheduled.'),
           'required' => FALSE,
+          'where' => 'civicrm_mailing.scheduled_date',
           'default' => 'NULL',
           'table_name' => 'civicrm_mailing',
           'entity' => 'Mailing',
@@ -758,6 +785,7 @@ class CRM_Mailing_DAO_Mailing extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Approved By'),
           'description' => ts('FK to Contact ID who approved this mailing'),
+          'where' => 'civicrm_mailing.approver_id',
           'table_name' => 'civicrm_mailing',
           'entity' => 'Mailing',
           'bao' => 'CRM_Mailing_BAO_Mailing',
@@ -770,6 +798,7 @@ class CRM_Mailing_DAO_Mailing extends CRM_Core_DAO {
           'title' => ts('Mailing Approved Date'),
           'description' => ts('Date and time this mailing was approved.'),
           'required' => FALSE,
+          'where' => 'civicrm_mailing.approval_date',
           'default' => 'NULL',
           'table_name' => 'civicrm_mailing',
           'entity' => 'Mailing',
@@ -785,6 +814,7 @@ class CRM_Mailing_DAO_Mailing extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Approval Status'),
           'description' => ts('The status of this mailing. Values: none, approved, rejected'),
+          'where' => 'civicrm_mailing.approval_status_id',
           'table_name' => 'civicrm_mailing',
           'entity' => 'Mailing',
           'bao' => 'CRM_Mailing_BAO_Mailing',
@@ -802,6 +832,7 @@ class CRM_Mailing_DAO_Mailing extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_LONGTEXT,
           'title' => ts('Approval Note'),
           'description' => ts('Note behind the decision.'),
+          'where' => 'civicrm_mailing.approval_note',
           'table_name' => 'civicrm_mailing',
           'entity' => 'Mailing',
           'bao' => 'CRM_Mailing_BAO_Mailing',
@@ -815,6 +846,7 @@ class CRM_Mailing_DAO_Mailing extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Is Mailing Archived?'),
           'description' => ts('Is this mailing archived?'),
+          'where' => 'civicrm_mailing.is_archived',
           'default' => '0',
           'table_name' => 'civicrm_mailing',
           'entity' => 'Mailing',
@@ -831,6 +863,7 @@ class CRM_Mailing_DAO_Mailing extends CRM_Core_DAO {
           'description' => ts('In what context(s) is the mailing contents visible (online viewing)'),
           'maxlength' => 40,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_mailing.visibility',
           'default' => 'Public Pages',
           'table_name' => 'civicrm_mailing',
           'entity' => 'Mailing',
@@ -848,6 +881,7 @@ class CRM_Mailing_DAO_Mailing extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Mailing Campaign'),
           'description' => ts('The campaign for which this mailing has been initiated.'),
+          'where' => 'civicrm_mailing.campaign_id',
           'table_name' => 'civicrm_mailing',
           'entity' => 'Mailing',
           'bao' => 'CRM_Mailing_BAO_Mailing',
@@ -867,6 +901,7 @@ class CRM_Mailing_DAO_Mailing extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('No Duplicate emails?'),
           'description' => ts('Remove duplicate emails?'),
+          'where' => 'civicrm_mailing.dedupe_email',
           'default' => '0',
           'table_name' => 'civicrm_mailing',
           'entity' => 'Mailing',
@@ -880,6 +915,7 @@ class CRM_Mailing_DAO_Mailing extends CRM_Core_DAO {
           'name' => 'sms_provider_id',
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Mailing SMS Provider'),
+          'where' => 'civicrm_mailing.sms_provider_id',
           'table_name' => 'civicrm_mailing',
           'entity' => 'Mailing',
           'bao' => 'CRM_Mailing_BAO_Mailing',
@@ -896,6 +932,7 @@ class CRM_Mailing_DAO_Mailing extends CRM_Core_DAO {
           'description' => ts('Key for validating requests related to this mailing.'),
           'maxlength' => 16,
           'size' => CRM_Utils_Type::TWELVE,
+          'where' => 'civicrm_mailing.hash',
           'table_name' => 'civicrm_mailing',
           'entity' => 'Mailing',
           'bao' => 'CRM_Mailing_BAO_Mailing',
@@ -906,6 +943,7 @@ class CRM_Mailing_DAO_Mailing extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Location Type'),
           'description' => ts('With email_selection_method, determines which email address to use'),
+          'where' => 'civicrm_mailing.location_type_id',
           'table_name' => 'civicrm_mailing',
           'entity' => 'Mailing',
           'bao' => 'CRM_Mailing_BAO_Mailing',
@@ -924,6 +962,7 @@ class CRM_Mailing_DAO_Mailing extends CRM_Core_DAO {
           'description' => ts('With location_type_id, determine how to choose the email address to use.'),
           'maxlength' => 20,
           'size' => CRM_Utils_Type::MEDIUM,
+          'where' => 'civicrm_mailing.email_selection_method',
           'default' => 'automatic',
           'table_name' => 'civicrm_mailing',
           'entity' => 'Mailing',
@@ -940,6 +979,7 @@ class CRM_Mailing_DAO_Mailing extends CRM_Core_DAO {
           'description' => ts('Language of the content of the mailing. Useful for tokens.'),
           'maxlength' => 5,
           'size' => CRM_Utils_Type::SIX,
+          'where' => 'civicrm_mailing.language',
           'table_name' => 'civicrm_mailing',
           'entity' => 'Mailing',
           'bao' => 'CRM_Mailing_BAO_Mailing',
diff --git a/civicrm/CRM/Mailing/DAO/MailingAB.php b/civicrm/CRM/Mailing/DAO/MailingAB.php
index 9d4ac8bff0e0965e01bfc07e436a90bb31572f37..3e42d261d0e98e35089ad9e7eb0fb3019e6c5fb3 100644
--- a/civicrm/CRM/Mailing/DAO/MailingAB.php
+++ b/civicrm/CRM/Mailing/DAO/MailingAB.php
@@ -154,6 +154,7 @@ class CRM_Mailing_DAO_MailingAB extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('MailingAB ID'),
           'required' => TRUE,
+          'where' => 'civicrm_mailing_abtest.id',
           'table_name' => 'civicrm_mailing_abtest',
           'entity' => 'MailingAB',
           'bao' => 'CRM_Mailing_BAO_MailingAB',
@@ -166,6 +167,7 @@ class CRM_Mailing_DAO_MailingAB extends CRM_Core_DAO {
           'description' => ts('Name of the A/B test'),
           'maxlength' => 128,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_mailing_abtest.name',
           'table_name' => 'civicrm_mailing_abtest',
           'entity' => 'MailingAB',
           'bao' => 'CRM_Mailing_BAO_MailingAB',
@@ -178,6 +180,7 @@ class CRM_Mailing_DAO_MailingAB extends CRM_Core_DAO {
           'description' => ts('Status'),
           'maxlength' => 32,
           'size' => CRM_Utils_Type::MEDIUM,
+          'where' => 'civicrm_mailing_abtest.status',
           'table_name' => 'civicrm_mailing_abtest',
           'entity' => 'MailingAB',
           'bao' => 'CRM_Mailing_BAO_MailingAB',
@@ -191,6 +194,7 @@ class CRM_Mailing_DAO_MailingAB extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Mailing ID (A)'),
           'description' => ts('The first experimental mailing ("A" condition)'),
+          'where' => 'civicrm_mailing_abtest.mailing_id_a',
           'table_name' => 'civicrm_mailing_abtest',
           'entity' => 'MailingAB',
           'bao' => 'CRM_Mailing_BAO_MailingAB',
@@ -201,6 +205,7 @@ class CRM_Mailing_DAO_MailingAB extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Mailing ID (B)'),
           'description' => ts('The second experimental mailing ("B" condition)'),
+          'where' => 'civicrm_mailing_abtest.mailing_id_b',
           'table_name' => 'civicrm_mailing_abtest',
           'entity' => 'MailingAB',
           'bao' => 'CRM_Mailing_BAO_MailingAB',
@@ -211,6 +216,7 @@ class CRM_Mailing_DAO_MailingAB extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Mailing ID (C)'),
           'description' => ts('The final, general mailing (derived from A or B)'),
+          'where' => 'civicrm_mailing_abtest.mailing_id_c',
           'table_name' => 'civicrm_mailing_abtest',
           'entity' => 'MailingAB',
           'bao' => 'CRM_Mailing_BAO_MailingAB',
@@ -221,6 +227,7 @@ class CRM_Mailing_DAO_MailingAB extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Domain ID'),
           'description' => ts('Which site is this mailing for'),
+          'where' => 'civicrm_mailing_abtest.domain_id',
           'table_name' => 'civicrm_mailing_abtest',
           'entity' => 'MailingAB',
           'bao' => 'CRM_Mailing_BAO_MailingAB',
@@ -232,6 +239,7 @@ class CRM_Mailing_DAO_MailingAB extends CRM_Core_DAO {
           'title' => ts('Testing Criteria'),
           'maxlength' => 32,
           'size' => CRM_Utils_Type::MEDIUM,
+          'where' => 'civicrm_mailing_abtest.testing_criteria',
           'table_name' => 'civicrm_mailing_abtest',
           'entity' => 'MailingAB',
           'bao' => 'CRM_Mailing_BAO_MailingAB',
@@ -246,6 +254,7 @@ class CRM_Mailing_DAO_MailingAB extends CRM_Core_DAO {
           'title' => ts('Winner Criteria'),
           'maxlength' => 32,
           'size' => CRM_Utils_Type::MEDIUM,
+          'where' => 'civicrm_mailing_abtest.winner_criteria',
           'table_name' => 'civicrm_mailing_abtest',
           'entity' => 'MailingAB',
           'bao' => 'CRM_Mailing_BAO_MailingAB',
@@ -261,6 +270,7 @@ class CRM_Mailing_DAO_MailingAB extends CRM_Core_DAO {
           'description' => ts('What specific url to track'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_mailing_abtest.specific_url',
           'table_name' => 'civicrm_mailing_abtest',
           'entity' => 'MailingAB',
           'bao' => 'CRM_Mailing_BAO_MailingAB',
@@ -271,6 +281,7 @@ class CRM_Mailing_DAO_MailingAB extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
           'title' => ts('Declaration Time'),
           'description' => ts('In how much time to declare winner'),
+          'where' => 'civicrm_mailing_abtest.declare_winning_time',
           'table_name' => 'civicrm_mailing_abtest',
           'entity' => 'MailingAB',
           'bao' => 'CRM_Mailing_BAO_MailingAB',
@@ -280,6 +291,7 @@ class CRM_Mailing_DAO_MailingAB extends CRM_Core_DAO {
           'name' => 'group_percentage',
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Group Percentage'),
+          'where' => 'civicrm_mailing_abtest.group_percentage',
           'table_name' => 'civicrm_mailing_abtest',
           'entity' => 'MailingAB',
           'bao' => 'CRM_Mailing_BAO_MailingAB',
@@ -290,6 +302,7 @@ class CRM_Mailing_DAO_MailingAB extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('AB Test Created By'),
           'description' => ts('FK to Contact ID'),
+          'where' => 'civicrm_mailing_abtest.created_id',
           'table_name' => 'civicrm_mailing_abtest',
           'entity' => 'MailingAB',
           'bao' => 'CRM_Mailing_BAO_MailingAB',
@@ -302,6 +315,7 @@ class CRM_Mailing_DAO_MailingAB extends CRM_Core_DAO {
           'title' => ts('AB Test Created Date'),
           'description' => ts('When was this item created'),
           'required' => FALSE,
+          'where' => 'civicrm_mailing_abtest.created_date',
           'default' => 'CURRENT_TIMESTAMP',
           'table_name' => 'civicrm_mailing_abtest',
           'entity' => 'MailingAB',
diff --git a/civicrm/CRM/Mailing/DAO/MailingComponent.php b/civicrm/CRM/Mailing/DAO/MailingComponent.php
index 6f2ba81e3139fcf1311ecf92bd81295a37515a5f..f4e6b01ac4f79d259ddf8b2127cef64e31b1701c 100644
--- a/civicrm/CRM/Mailing/DAO/MailingComponent.php
+++ b/civicrm/CRM/Mailing/DAO/MailingComponent.php
@@ -101,6 +101,7 @@ class CRM_Mailing_DAO_MailingComponent extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Mailing Component ID'),
           'required' => TRUE,
+          'where' => 'civicrm_mailing_component.id',
           'table_name' => 'civicrm_mailing_component',
           'entity' => 'MailingComponent',
           'bao' => 'CRM_Mailing_BAO_MailingComponent',
@@ -113,6 +114,7 @@ class CRM_Mailing_DAO_MailingComponent extends CRM_Core_DAO {
           'description' => ts('The name of this component'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_mailing_component.name',
           'table_name' => 'civicrm_mailing_component',
           'entity' => 'MailingComponent',
           'bao' => 'CRM_Mailing_BAO_MailingComponent',
@@ -125,6 +127,7 @@ class CRM_Mailing_DAO_MailingComponent extends CRM_Core_DAO {
           'description' => ts('Type of Component.'),
           'maxlength' => 12,
           'size' => CRM_Utils_Type::TWELVE,
+          'where' => 'civicrm_mailing_component.component_type',
           'table_name' => 'civicrm_mailing_component',
           'entity' => 'MailingComponent',
           'bao' => 'CRM_Mailing_BAO_MailingComponent',
@@ -142,6 +145,7 @@ class CRM_Mailing_DAO_MailingComponent extends CRM_Core_DAO {
           'title' => ts('Subject'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_mailing_component.subject',
           'table_name' => 'civicrm_mailing_component',
           'entity' => 'MailingComponent',
           'bao' => 'CRM_Mailing_BAO_MailingComponent',
@@ -154,6 +158,7 @@ class CRM_Mailing_DAO_MailingComponent extends CRM_Core_DAO {
           'description' => ts('Body of the component in html format.'),
           'rows' => 8,
           'cols' => 80,
+          'where' => 'civicrm_mailing_component.body_html',
           'table_name' => 'civicrm_mailing_component',
           'entity' => 'MailingComponent',
           'bao' => 'CRM_Mailing_BAO_MailingComponent',
@@ -169,6 +174,7 @@ class CRM_Mailing_DAO_MailingComponent extends CRM_Core_DAO {
           'description' => ts('Body of the component in text format.'),
           'rows' => 8,
           'cols' => 80,
+          'where' => 'civicrm_mailing_component.body_text',
           'table_name' => 'civicrm_mailing_component',
           'entity' => 'MailingComponent',
           'bao' => 'CRM_Mailing_BAO_MailingComponent',
@@ -182,6 +188,7 @@ class CRM_Mailing_DAO_MailingComponent extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Mailing Component is Default?'),
           'description' => ts('Is this the default component for this component_type?'),
+          'where' => 'civicrm_mailing_component.is_default',
           'default' => '0',
           'table_name' => 'civicrm_mailing_component',
           'entity' => 'MailingComponent',
@@ -193,6 +200,7 @@ class CRM_Mailing_DAO_MailingComponent extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Mailing Component Is Active?'),
           'description' => ts('Is this property active?'),
+          'where' => 'civicrm_mailing_component.is_active',
           'table_name' => 'civicrm_mailing_component',
           'entity' => 'MailingComponent',
           'bao' => 'CRM_Mailing_BAO_MailingComponent',
diff --git a/civicrm/CRM/Mailing/DAO/MailingGroup.php b/civicrm/CRM/Mailing/DAO/MailingGroup.php
index 46f6a4033371a36561bf4aca33fff2709ea007e6..dc3dec5d07aab4db9349399934de74000fe3ba92 100644
--- a/civicrm/CRM/Mailing/DAO/MailingGroup.php
+++ b/civicrm/CRM/Mailing/DAO/MailingGroup.php
@@ -112,6 +112,7 @@ class CRM_Mailing_DAO_MailingGroup extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Mailing Group ID'),
           'required' => TRUE,
+          'where' => 'civicrm_mailing_group.id',
           'table_name' => 'civicrm_mailing_group',
           'entity' => 'MailingGroup',
           'bao' => 'CRM_Mailing_DAO_MailingGroup',
@@ -123,6 +124,7 @@ class CRM_Mailing_DAO_MailingGroup extends CRM_Core_DAO {
           'title' => ts('Mailing'),
           'description' => ts('The ID of a previous mailing to include/exclude recipients.'),
           'required' => TRUE,
+          'where' => 'civicrm_mailing_group.mailing_id',
           'table_name' => 'civicrm_mailing_group',
           'entity' => 'MailingGroup',
           'bao' => 'CRM_Mailing_DAO_MailingGroup',
@@ -136,6 +138,7 @@ class CRM_Mailing_DAO_MailingGroup extends CRM_Core_DAO {
           'description' => ts('Are the members of the group included or excluded?.'),
           'maxlength' => 8,
           'size' => CRM_Utils_Type::EIGHT,
+          'where' => 'civicrm_mailing_group.group_type',
           'table_name' => 'civicrm_mailing_group',
           'entity' => 'MailingGroup',
           'bao' => 'CRM_Mailing_DAO_MailingGroup',
@@ -155,6 +158,7 @@ class CRM_Mailing_DAO_MailingGroup extends CRM_Core_DAO {
           'required' => TRUE,
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_mailing_group.entity_table',
           'table_name' => 'civicrm_mailing_group',
           'entity' => 'MailingGroup',
           'bao' => 'CRM_Mailing_DAO_MailingGroup',
@@ -169,6 +173,7 @@ class CRM_Mailing_DAO_MailingGroup extends CRM_Core_DAO {
           'title' => ts('Mailing Group Entity'),
           'description' => ts('Foreign key to the referenced item.'),
           'required' => TRUE,
+          'where' => 'civicrm_mailing_group.entity_id',
           'table_name' => 'civicrm_mailing_group',
           'entity' => 'MailingGroup',
           'bao' => 'CRM_Mailing_DAO_MailingGroup',
@@ -179,6 +184,7 @@ class CRM_Mailing_DAO_MailingGroup extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Mailing Group Search'),
           'description' => ts('The filtering search. custom search id or -1 for civicrm api search'),
+          'where' => 'civicrm_mailing_group.search_id',
           'table_name' => 'civicrm_mailing_group',
           'entity' => 'MailingGroup',
           'bao' => 'CRM_Mailing_DAO_MailingGroup',
@@ -189,6 +195,7 @@ class CRM_Mailing_DAO_MailingGroup extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_TEXT,
           'title' => ts('Mailing Group Search Arguments'),
           'description' => ts('The arguments to be sent to the search function'),
+          'where' => 'civicrm_mailing_group.search_args',
           'table_name' => 'civicrm_mailing_group',
           'entity' => 'MailingGroup',
           'bao' => 'CRM_Mailing_DAO_MailingGroup',
diff --git a/civicrm/CRM/Mailing/DAO/MailingJob.php b/civicrm/CRM/Mailing/DAO/MailingJob.php
index a88d4abcf64eeea4204797f489e2c04a4a5a9a43..cbbce73c406fc3c424dc31b6cae0cb717d281125 100644
--- a/civicrm/CRM/Mailing/DAO/MailingJob.php
+++ b/civicrm/CRM/Mailing/DAO/MailingJob.php
@@ -140,6 +140,7 @@ class CRM_Mailing_DAO_MailingJob extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Mailing Job ID'),
           'required' => TRUE,
+          'where' => 'civicrm_mailing_job.id',
           'table_name' => 'civicrm_mailing_job',
           'entity' => 'MailingJob',
           'bao' => 'CRM_Mailing_BAO_MailingJob',
@@ -151,6 +152,7 @@ class CRM_Mailing_DAO_MailingJob extends CRM_Core_DAO {
           'title' => ts('Mailing'),
           'description' => ts('The ID of the mailing this Job will send.'),
           'required' => TRUE,
+          'where' => 'civicrm_mailing_job.mailing_id',
           'table_name' => 'civicrm_mailing_job',
           'entity' => 'MailingJob',
           'bao' => 'CRM_Mailing_BAO_MailingJob',
@@ -163,6 +165,7 @@ class CRM_Mailing_DAO_MailingJob extends CRM_Core_DAO {
           'title' => ts('Mailing Scheduled Date'),
           'description' => ts('date on which this job was scheduled.'),
           'required' => FALSE,
+          'where' => 'civicrm_mailing_job.scheduled_date',
           'default' => 'NULL',
           'table_name' => 'civicrm_mailing_job',
           'entity' => 'MailingJob',
@@ -175,6 +178,7 @@ class CRM_Mailing_DAO_MailingJob extends CRM_Core_DAO {
           'title' => ts('Mailing Job Start Date'),
           'description' => ts('date on which this job was started.'),
           'required' => FALSE,
+          'where' => 'civicrm_mailing_job.start_date',
           'default' => 'NULL',
           'table_name' => 'civicrm_mailing_job',
           'entity' => 'MailingJob',
@@ -187,6 +191,7 @@ class CRM_Mailing_DAO_MailingJob extends CRM_Core_DAO {
           'title' => ts('Mailing Job End Date'),
           'description' => ts('date on which this job ended.'),
           'required' => FALSE,
+          'where' => 'civicrm_mailing_job.end_date',
           'default' => 'NULL',
           'table_name' => 'civicrm_mailing_job',
           'entity' => 'MailingJob',
@@ -200,6 +205,7 @@ class CRM_Mailing_DAO_MailingJob extends CRM_Core_DAO {
           'description' => ts('The state of this job'),
           'maxlength' => 12,
           'size' => CRM_Utils_Type::TWELVE,
+          'where' => 'civicrm_mailing_job.status',
           'table_name' => 'civicrm_mailing_job',
           'entity' => 'MailingJob',
           'bao' => 'CRM_Mailing_BAO_MailingJob',
@@ -216,6 +222,7 @@ class CRM_Mailing_DAO_MailingJob extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Mailing Job Is Test?'),
           'description' => ts('Is this job for a test mail?'),
+          'where' => 'civicrm_mailing_job.is_test',
           'default' => '0',
           'table_name' => 'civicrm_mailing_job',
           'entity' => 'MailingJob',
@@ -229,6 +236,7 @@ class CRM_Mailing_DAO_MailingJob extends CRM_Core_DAO {
           'description' => ts('Type of mailling job: null | child '),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_mailing_job.job_type',
           'table_name' => 'civicrm_mailing_job',
           'entity' => 'MailingJob',
           'bao' => 'CRM_Mailing_BAO_MailingJob',
@@ -239,6 +247,7 @@ class CRM_Mailing_DAO_MailingJob extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Mailing Job Parent'),
           'description' => ts('Parent job id'),
+          'where' => 'civicrm_mailing_job.parent_id',
           'default' => 'NULL',
           'table_name' => 'civicrm_mailing_job',
           'entity' => 'MailingJob',
@@ -251,6 +260,7 @@ class CRM_Mailing_DAO_MailingJob extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Mailing Job Offset'),
           'description' => ts('Offset of the child job'),
+          'where' => 'civicrm_mailing_job.job_offset',
           'default' => '0',
           'table_name' => 'civicrm_mailing_job',
           'entity' => 'MailingJob',
@@ -262,6 +272,7 @@ class CRM_Mailing_DAO_MailingJob extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Mailing Job Limit'),
           'description' => ts('Queue size limit for each child job'),
+          'where' => 'civicrm_mailing_job.job_limit',
           'default' => '0',
           'table_name' => 'civicrm_mailing_job',
           'entity' => 'MailingJob',
diff --git a/civicrm/CRM/Mailing/DAO/Recipients.php b/civicrm/CRM/Mailing/DAO/Recipients.php
index 3b10af904ae9e7e854e3f760c1e6e99d775cc92f..4f1375686157f23ea563005760fd24510b7d3495 100644
--- a/civicrm/CRM/Mailing/DAO/Recipients.php
+++ b/civicrm/CRM/Mailing/DAO/Recipients.php
@@ -100,6 +100,7 @@ class CRM_Mailing_DAO_Recipients extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Mailing Recipients ID'),
           'required' => TRUE,
+          'where' => 'civicrm_mailing_recipients.id',
           'table_name' => 'civicrm_mailing_recipients',
           'entity' => 'Recipients',
           'bao' => 'CRM_Mailing_BAO_Recipients',
@@ -111,6 +112,7 @@ class CRM_Mailing_DAO_Recipients extends CRM_Core_DAO {
           'title' => ts('Mailing'),
           'description' => ts('The ID of the mailing this Job will send.'),
           'required' => TRUE,
+          'where' => 'civicrm_mailing_recipients.mailing_id',
           'table_name' => 'civicrm_mailing_recipients',
           'entity' => 'Recipients',
           'bao' => 'CRM_Mailing_BAO_Recipients',
@@ -123,6 +125,7 @@ class CRM_Mailing_DAO_Recipients extends CRM_Core_DAO {
           'title' => ts('Mailing Recipient'),
           'description' => ts('FK to Contact'),
           'required' => TRUE,
+          'where' => 'civicrm_mailing_recipients.contact_id',
           'table_name' => 'civicrm_mailing_recipients',
           'entity' => 'Recipients',
           'bao' => 'CRM_Mailing_BAO_Recipients',
@@ -134,6 +137,7 @@ class CRM_Mailing_DAO_Recipients extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Recipient Email'),
           'description' => ts('FK to Email'),
+          'where' => 'civicrm_mailing_recipients.email_id',
           'default' => 'NULL',
           'table_name' => 'civicrm_mailing_recipients',
           'entity' => 'Recipients',
@@ -146,6 +150,7 @@ class CRM_Mailing_DAO_Recipients extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Recipient Phone'),
           'description' => ts('FK to Phone'),
+          'where' => 'civicrm_mailing_recipients.phone_id',
           'default' => 'NULL',
           'table_name' => 'civicrm_mailing_recipients',
           'entity' => 'Recipients',
diff --git a/civicrm/CRM/Mailing/DAO/Spool.php b/civicrm/CRM/Mailing/DAO/Spool.php
index bdc28b428d042dbf524775eaff71fd731dabc8ba..ffde488e26969b704ba7a22530f880153cd927dc 100644
--- a/civicrm/CRM/Mailing/DAO/Spool.php
+++ b/civicrm/CRM/Mailing/DAO/Spool.php
@@ -111,6 +111,7 @@ class CRM_Mailing_DAO_Spool extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Spool ID'),
           'required' => TRUE,
+          'where' => 'civicrm_mailing_spool.id',
           'table_name' => 'civicrm_mailing_spool',
           'entity' => 'Spool',
           'bao' => 'CRM_Mailing_BAO_Spool',
@@ -122,6 +123,7 @@ class CRM_Mailing_DAO_Spool extends CRM_Core_DAO {
           'title' => ts('Mailing Job'),
           'description' => ts('The ID of the Job .'),
           'required' => TRUE,
+          'where' => 'civicrm_mailing_spool.job_id',
           'table_name' => 'civicrm_mailing_spool',
           'entity' => 'Spool',
           'bao' => 'CRM_Mailing_BAO_Spool',
@@ -133,6 +135,7 @@ class CRM_Mailing_DAO_Spool extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_TEXT,
           'title' => ts('Recipient Email'),
           'description' => ts('The email of the receipients this mail is to be sent.'),
+          'where' => 'civicrm_mailing_spool.recipient_email',
           'table_name' => 'civicrm_mailing_spool',
           'entity' => 'Spool',
           'bao' => 'CRM_Mailing_BAO_Spool',
@@ -143,6 +146,7 @@ class CRM_Mailing_DAO_Spool extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_TEXT,
           'title' => ts('Headers'),
           'description' => ts('The header information of this mailing .'),
+          'where' => 'civicrm_mailing_spool.headers',
           'table_name' => 'civicrm_mailing_spool',
           'entity' => 'Spool',
           'bao' => 'CRM_Mailing_BAO_Spool',
@@ -153,6 +157,7 @@ class CRM_Mailing_DAO_Spool extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_TEXT,
           'title' => ts('Body'),
           'description' => ts('The body of this mailing.'),
+          'where' => 'civicrm_mailing_spool.body',
           'table_name' => 'civicrm_mailing_spool',
           'entity' => 'Spool',
           'bao' => 'CRM_Mailing_BAO_Spool',
@@ -164,6 +169,7 @@ class CRM_Mailing_DAO_Spool extends CRM_Core_DAO {
           'title' => ts('Added'),
           'description' => ts('date on which this job was added.'),
           'required' => FALSE,
+          'where' => 'civicrm_mailing_spool.added_at',
           'default' => 'NULL',
           'table_name' => 'civicrm_mailing_spool',
           'entity' => 'Spool',
@@ -176,6 +182,7 @@ class CRM_Mailing_DAO_Spool extends CRM_Core_DAO {
           'title' => ts('Removed'),
           'description' => ts('date on which this job was removed.'),
           'required' => FALSE,
+          'where' => 'civicrm_mailing_spool.removed_at',
           'default' => 'NULL',
           'table_name' => 'civicrm_mailing_spool',
           'entity' => 'Spool',
diff --git a/civicrm/CRM/Mailing/DAO/TrackableURL.php b/civicrm/CRM/Mailing/DAO/TrackableURL.php
index 840f42c6b3d3a0ec34fa3d31fb408461711387e8..f87f00a386e77470d0566c78b7d996efb70a9ef5 100644
--- a/civicrm/CRM/Mailing/DAO/TrackableURL.php
+++ b/civicrm/CRM/Mailing/DAO/TrackableURL.php
@@ -83,6 +83,7 @@ class CRM_Mailing_DAO_TrackableURL extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Trackable URL ID'),
           'required' => TRUE,
+          'where' => 'civicrm_mailing_trackable_url.id',
           'table_name' => 'civicrm_mailing_trackable_url',
           'entity' => 'TrackableURL',
           'bao' => 'CRM_Mailing_BAO_TrackableURL',
@@ -94,6 +95,7 @@ class CRM_Mailing_DAO_TrackableURL extends CRM_Core_DAO {
           'title' => ts('Url'),
           'description' => ts('The URL to be tracked.'),
           'required' => TRUE,
+          'where' => 'civicrm_mailing_trackable_url.url',
           'table_name' => 'civicrm_mailing_trackable_url',
           'entity' => 'TrackableURL',
           'bao' => 'CRM_Mailing_BAO_TrackableURL',
@@ -105,6 +107,7 @@ class CRM_Mailing_DAO_TrackableURL extends CRM_Core_DAO {
           'title' => ts('Mailing'),
           'description' => ts('FK to the mailing'),
           'required' => TRUE,
+          'where' => 'civicrm_mailing_trackable_url.mailing_id',
           'table_name' => 'civicrm_mailing_trackable_url',
           'entity' => 'TrackableURL',
           'bao' => 'CRM_Mailing_BAO_TrackableURL',
diff --git a/civicrm/CRM/Mailing/Event/BAO/Delivered.php b/civicrm/CRM/Mailing/Event/BAO/Delivered.php
index 706a65d2151ef9d9d0403740a4ef237f9179f2c8..e8c9a4cc19b6a1e285f250661d43f073b40d17fe 100644
--- a/civicrm/CRM/Mailing/Event/BAO/Delivered.php
+++ b/civicrm/CRM/Mailing/Event/BAO/Delivered.php
@@ -56,7 +56,6 @@ class CRM_Mailing_Event_BAO_Delivered extends CRM_Mailing_Event_DAO_Delivered {
     if (!$q) {
       return NULL;
     }
-    $q->free();
 
     $delivered = new CRM_Mailing_Event_BAO_Delivered();
     $delivered->time_stamp = date('YmdHis');
diff --git a/civicrm/CRM/Mailing/Event/BAO/Subscribe.php b/civicrm/CRM/Mailing/Event/BAO/Subscribe.php
index b020f76ad7c44192ba4fadd89dacb54f60bbe994..393216364ee45ea999df3e71ddd9c7282ba246c0 100644
--- a/civicrm/CRM/Mailing/Event/BAO/Subscribe.php
+++ b/civicrm/CRM/Mailing/Event/BAO/Subscribe.php
@@ -97,7 +97,6 @@ LEFT JOIN civicrm_email      ON contact_a.id = civicrm_email.contact_id
       if ($dao->fetch()) {
         $contact_id = $dao->contact_id;
       }
-      $dao->free();
     }
 
     $transaction = new CRM_Core_Transaction();
@@ -343,7 +342,6 @@ SELECT     civicrm_email.id as email_id
       ];
     }
 
-    $dao->free();
     return $groups;
   }
 
diff --git a/civicrm/CRM/Mailing/Event/DAO/Bounce.php b/civicrm/CRM/Mailing/Event/DAO/Bounce.php
index ba53bf7c06c25fec23c23663306ee358f125f5a0..d60eb55715dfff9d856d22ab61cbe30f064e35c2 100644
--- a/civicrm/CRM/Mailing/Event/DAO/Bounce.php
+++ b/civicrm/CRM/Mailing/Event/DAO/Bounce.php
@@ -77,7 +77,7 @@ class CRM_Mailing_Event_DAO_Bounce extends CRM_Core_DAO {
    */
   public static function getReferenceColumns() {
     if (!isset(Civi::$statics[__CLASS__]['links'])) {
-      Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
+      Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
       Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'event_queue_id', 'civicrm_mailing_event_queue', 'id');
       CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
     }
@@ -97,6 +97,7 @@ class CRM_Mailing_Event_DAO_Bounce extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Bounce ID'),
           'required' => TRUE,
+          'where' => 'civicrm_mailing_event_bounce.id',
           'table_name' => 'civicrm_mailing_event_bounce',
           'entity' => 'Bounce',
           'bao' => 'CRM_Mailing_Event_BAO_Bounce',
@@ -108,6 +109,7 @@ class CRM_Mailing_Event_DAO_Bounce extends CRM_Core_DAO {
           'title' => ts('Event Queue'),
           'description' => ts('FK to EventQueue'),
           'required' => TRUE,
+          'where' => 'civicrm_mailing_event_bounce.event_queue_id',
           'table_name' => 'civicrm_mailing_event_bounce',
           'entity' => 'Bounce',
           'bao' => 'CRM_Mailing_Event_BAO_Bounce',
@@ -119,6 +121,7 @@ class CRM_Mailing_Event_DAO_Bounce extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Bounce Type'),
           'description' => ts('What type of bounce was it?'),
+          'where' => 'civicrm_mailing_event_bounce.bounce_type_id',
           'table_name' => 'civicrm_mailing_event_bounce',
           'entity' => 'Bounce',
           'bao' => 'CRM_Mailing_Event_BAO_Bounce',
@@ -139,6 +142,7 @@ class CRM_Mailing_Event_DAO_Bounce extends CRM_Core_DAO {
           'description' => ts('The reason the email bounced.'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_mailing_event_bounce.bounce_reason',
           'table_name' => 'civicrm_mailing_event_bounce',
           'entity' => 'Bounce',
           'bao' => 'CRM_Mailing_Event_BAO_Bounce',
@@ -150,6 +154,7 @@ class CRM_Mailing_Event_DAO_Bounce extends CRM_Core_DAO {
           'title' => ts('Timestamp'),
           'description' => ts('When this bounce event occurred.'),
           'required' => TRUE,
+          'where' => 'civicrm_mailing_event_bounce.time_stamp',
           'default' => 'CURRENT_TIMESTAMP',
           'table_name' => 'civicrm_mailing_event_bounce',
           'entity' => 'Bounce',
diff --git a/civicrm/CRM/Mailing/Event/DAO/Confirm.php b/civicrm/CRM/Mailing/Event/DAO/Confirm.php
index b66ca4a6fb76c312419dd21d1493a6548c11e893..61373315e4e695287c7b56899469f68863d47f54 100644
--- a/civicrm/CRM/Mailing/Event/DAO/Confirm.php
+++ b/civicrm/CRM/Mailing/Event/DAO/Confirm.php
@@ -63,7 +63,7 @@ class CRM_Mailing_Event_DAO_Confirm extends CRM_Core_DAO {
    */
   public static function getReferenceColumns() {
     if (!isset(Civi::$statics[__CLASS__]['links'])) {
-      Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
+      Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
       Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'event_subscribe_id', 'civicrm_mailing_event_subscribe', 'id');
       CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
     }
@@ -83,6 +83,7 @@ class CRM_Mailing_Event_DAO_Confirm extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Mailing Confirmation ID'),
           'required' => TRUE,
+          'where' => 'civicrm_mailing_event_confirm.id',
           'table_name' => 'civicrm_mailing_event_confirm',
           'entity' => 'Confirm',
           'bao' => 'CRM_Mailing_Event_BAO_Confirm',
@@ -94,6 +95,7 @@ class CRM_Mailing_Event_DAO_Confirm extends CRM_Core_DAO {
           'title' => ts('Mailing Subscribe ID'),
           'description' => ts('FK to civicrm_mailing_event_subscribe'),
           'required' => TRUE,
+          'where' => 'civicrm_mailing_event_confirm.event_subscribe_id',
           'table_name' => 'civicrm_mailing_event_confirm',
           'entity' => 'Confirm',
           'bao' => 'CRM_Mailing_Event_BAO_Confirm',
@@ -106,6 +108,7 @@ class CRM_Mailing_Event_DAO_Confirm extends CRM_Core_DAO {
           'title' => ts('Confirm Timestamp'),
           'description' => ts('When this confirmation event occurred.'),
           'required' => TRUE,
+          'where' => 'civicrm_mailing_event_confirm.time_stamp',
           'default' => 'CURRENT_TIMESTAMP',
           'table_name' => 'civicrm_mailing_event_confirm',
           'entity' => 'Confirm',
diff --git a/civicrm/CRM/Mailing/Event/DAO/Delivered.php b/civicrm/CRM/Mailing/Event/DAO/Delivered.php
index ddde617bab6c00f1ca168abd8612dfd01b25b30d..fed90da898dd971625dd4c925e679b7378b2dea6 100644
--- a/civicrm/CRM/Mailing/Event/DAO/Delivered.php
+++ b/civicrm/CRM/Mailing/Event/DAO/Delivered.php
@@ -63,7 +63,7 @@ class CRM_Mailing_Event_DAO_Delivered extends CRM_Core_DAO {
    */
   public static function getReferenceColumns() {
     if (!isset(Civi::$statics[__CLASS__]['links'])) {
-      Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
+      Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
       Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'event_queue_id', 'civicrm_mailing_event_queue', 'id');
       CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
     }
@@ -83,6 +83,7 @@ class CRM_Mailing_Event_DAO_Delivered extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Delivered ID'),
           'required' => TRUE,
+          'where' => 'civicrm_mailing_event_delivered.id',
           'table_name' => 'civicrm_mailing_event_delivered',
           'entity' => 'Delivered',
           'bao' => 'CRM_Mailing_Event_BAO_Delivered',
@@ -94,6 +95,7 @@ class CRM_Mailing_Event_DAO_Delivered extends CRM_Core_DAO {
           'title' => ts('Event Queue'),
           'description' => ts('FK to EventQueue'),
           'required' => TRUE,
+          'where' => 'civicrm_mailing_event_delivered.event_queue_id',
           'table_name' => 'civicrm_mailing_event_delivered',
           'entity' => 'Delivered',
           'bao' => 'CRM_Mailing_Event_BAO_Delivered',
@@ -106,6 +108,7 @@ class CRM_Mailing_Event_DAO_Delivered extends CRM_Core_DAO {
           'title' => ts('Timestamp'),
           'description' => ts('When this delivery event occurred.'),
           'required' => TRUE,
+          'where' => 'civicrm_mailing_event_delivered.time_stamp',
           'default' => 'CURRENT_TIMESTAMP',
           'table_name' => 'civicrm_mailing_event_delivered',
           'entity' => 'Delivered',
diff --git a/civicrm/CRM/Mailing/Event/DAO/Forward.php b/civicrm/CRM/Mailing/Event/DAO/Forward.php
index c9d1588dd4fed5cef7dec9a4446bed7509ad3ec9..7f9e189d4861bb46eea7a469a559b8c060c84a62 100644
--- a/civicrm/CRM/Mailing/Event/DAO/Forward.php
+++ b/civicrm/CRM/Mailing/Event/DAO/Forward.php
@@ -70,7 +70,7 @@ class CRM_Mailing_Event_DAO_Forward extends CRM_Core_DAO {
    */
   public static function getReferenceColumns() {
     if (!isset(Civi::$statics[__CLASS__]['links'])) {
-      Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
+      Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
       Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'event_queue_id', 'civicrm_mailing_event_queue', 'id');
       Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'dest_queue_id', 'civicrm_mailing_event_queue', 'id');
       CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
@@ -91,6 +91,7 @@ class CRM_Mailing_Event_DAO_Forward extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Forward ID'),
           'required' => TRUE,
+          'where' => 'civicrm_mailing_event_forward.id',
           'table_name' => 'civicrm_mailing_event_forward',
           'entity' => 'Forward',
           'bao' => 'CRM_Mailing_Event_BAO_Forward',
@@ -102,6 +103,7 @@ class CRM_Mailing_Event_DAO_Forward extends CRM_Core_DAO {
           'title' => ts('Mailing Event Queue'),
           'description' => ts('FK to EventQueue'),
           'required' => TRUE,
+          'where' => 'civicrm_mailing_event_forward.event_queue_id',
           'table_name' => 'civicrm_mailing_event_forward',
           'entity' => 'Forward',
           'bao' => 'CRM_Mailing_Event_BAO_Forward',
@@ -113,6 +115,7 @@ class CRM_Mailing_Event_DAO_Forward extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Destination Queue'),
           'description' => ts('FK to EventQueue for destination'),
+          'where' => 'civicrm_mailing_event_forward.dest_queue_id',
           'table_name' => 'civicrm_mailing_event_forward',
           'entity' => 'Forward',
           'bao' => 'CRM_Mailing_Event_BAO_Forward',
@@ -125,6 +128,7 @@ class CRM_Mailing_Event_DAO_Forward extends CRM_Core_DAO {
           'title' => ts('Timestamp'),
           'description' => ts('When this forward event occurred.'),
           'required' => TRUE,
+          'where' => 'civicrm_mailing_event_forward.time_stamp',
           'default' => 'CURRENT_TIMESTAMP',
           'table_name' => 'civicrm_mailing_event_forward',
           'entity' => 'Forward',
diff --git a/civicrm/CRM/Mailing/Event/DAO/Opened.php b/civicrm/CRM/Mailing/Event/DAO/Opened.php
index e3337cba2836dc90f12772496e120ba728b22fcd..6147a770ab39071e4a50a2611ea8657ebecaa346 100644
--- a/civicrm/CRM/Mailing/Event/DAO/Opened.php
+++ b/civicrm/CRM/Mailing/Event/DAO/Opened.php
@@ -63,7 +63,7 @@ class CRM_Mailing_Event_DAO_Opened extends CRM_Core_DAO {
    */
   public static function getReferenceColumns() {
     if (!isset(Civi::$statics[__CLASS__]['links'])) {
-      Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
+      Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
       Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'event_queue_id', 'civicrm_mailing_event_queue', 'id');
       CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
     }
@@ -83,6 +83,7 @@ class CRM_Mailing_Event_DAO_Opened extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Mailing Opened ID'),
           'required' => TRUE,
+          'where' => 'civicrm_mailing_event_opened.id',
           'table_name' => 'civicrm_mailing_event_opened',
           'entity' => 'Opened',
           'bao' => 'CRM_Mailing_Event_BAO_Opened',
@@ -94,6 +95,7 @@ class CRM_Mailing_Event_DAO_Opened extends CRM_Core_DAO {
           'title' => ts('Event Queue'),
           'description' => ts('FK to EventQueue'),
           'required' => TRUE,
+          'where' => 'civicrm_mailing_event_opened.event_queue_id',
           'table_name' => 'civicrm_mailing_event_opened',
           'entity' => 'Opened',
           'bao' => 'CRM_Mailing_Event_BAO_Opened',
@@ -106,6 +108,7 @@ class CRM_Mailing_Event_DAO_Opened extends CRM_Core_DAO {
           'title' => ts('Timestamp'),
           'description' => ts('When this open event occurred.'),
           'required' => TRUE,
+          'where' => 'civicrm_mailing_event_opened.time_stamp',
           'default' => 'CURRENT_TIMESTAMP',
           'table_name' => 'civicrm_mailing_event_opened',
           'entity' => 'Opened',
diff --git a/civicrm/CRM/Mailing/Event/DAO/Queue.php b/civicrm/CRM/Mailing/Event/DAO/Queue.php
index b1e3447500026dfeb7e9bf57b66b94451d20bf5c..c229b074ec5fd445bc013b582c5553188eed0b68 100644
--- a/civicrm/CRM/Mailing/Event/DAO/Queue.php
+++ b/civicrm/CRM/Mailing/Event/DAO/Queue.php
@@ -84,7 +84,7 @@ class CRM_Mailing_Event_DAO_Queue extends CRM_Core_DAO {
    */
   public static function getReferenceColumns() {
     if (!isset(Civi::$statics[__CLASS__]['links'])) {
-      Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
+      Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
       Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'job_id', 'civicrm_mailing_job', 'id');
       Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'email_id', 'civicrm_email', 'id');
       Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id');
@@ -107,6 +107,7 @@ class CRM_Mailing_Event_DAO_Queue extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Mailing Event Queue ID'),
           'required' => TRUE,
+          'where' => 'civicrm_mailing_event_queue.id',
           'table_name' => 'civicrm_mailing_event_queue',
           'entity' => 'Queue',
           'bao' => 'CRM_Mailing_Event_BAO_Queue',
@@ -118,6 +119,7 @@ class CRM_Mailing_Event_DAO_Queue extends CRM_Core_DAO {
           'title' => ts('Job ID'),
           'description' => ts('FK to Job'),
           'required' => TRUE,
+          'where' => 'civicrm_mailing_event_queue.job_id',
           'table_name' => 'civicrm_mailing_event_queue',
           'entity' => 'Queue',
           'bao' => 'CRM_Mailing_Event_BAO_Queue',
@@ -129,6 +131,7 @@ class CRM_Mailing_Event_DAO_Queue extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Email ID'),
           'description' => ts('FK to Email'),
+          'where' => 'civicrm_mailing_event_queue.email_id',
           'default' => 'NULL',
           'table_name' => 'civicrm_mailing_event_queue',
           'entity' => 'Queue',
@@ -142,6 +145,7 @@ class CRM_Mailing_Event_DAO_Queue extends CRM_Core_DAO {
           'title' => ts('Contact ID'),
           'description' => ts('FK to Contact'),
           'required' => TRUE,
+          'where' => 'civicrm_mailing_event_queue.contact_id',
           'table_name' => 'civicrm_mailing_event_queue',
           'entity' => 'Queue',
           'bao' => 'CRM_Mailing_Event_BAO_Queue',
@@ -156,6 +160,7 @@ class CRM_Mailing_Event_DAO_Queue extends CRM_Core_DAO {
           'required' => TRUE,
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_mailing_event_queue.hash',
           'table_name' => 'civicrm_mailing_event_queue',
           'entity' => 'Queue',
           'bao' => 'CRM_Mailing_Event_BAO_Queue',
@@ -166,6 +171,7 @@ class CRM_Mailing_Event_DAO_Queue extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Phone ID'),
           'description' => ts('FK to Phone'),
+          'where' => 'civicrm_mailing_event_queue.phone_id',
           'default' => 'NULL',
           'table_name' => 'civicrm_mailing_event_queue',
           'entity' => 'Queue',
diff --git a/civicrm/CRM/Mailing/Event/DAO/Reply.php b/civicrm/CRM/Mailing/Event/DAO/Reply.php
index d7f71831b59d2768979497bf3d5ef7b49212722f..8ca919a823fe637b269b5fb1ce8c250e4edb8ff3 100644
--- a/civicrm/CRM/Mailing/Event/DAO/Reply.php
+++ b/civicrm/CRM/Mailing/Event/DAO/Reply.php
@@ -63,7 +63,7 @@ class CRM_Mailing_Event_DAO_Reply extends CRM_Core_DAO {
    */
   public static function getReferenceColumns() {
     if (!isset(Civi::$statics[__CLASS__]['links'])) {
-      Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
+      Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
       Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'event_queue_id', 'civicrm_mailing_event_queue', 'id');
       CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
     }
@@ -83,6 +83,7 @@ class CRM_Mailing_Event_DAO_Reply extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Reply ID'),
           'required' => TRUE,
+          'where' => 'civicrm_mailing_event_reply.id',
           'table_name' => 'civicrm_mailing_event_reply',
           'entity' => 'Reply',
           'bao' => 'CRM_Mailing_Event_BAO_Reply',
@@ -94,6 +95,7 @@ class CRM_Mailing_Event_DAO_Reply extends CRM_Core_DAO {
           'title' => ts('Event Queue'),
           'description' => ts('FK to EventQueue'),
           'required' => TRUE,
+          'where' => 'civicrm_mailing_event_reply.event_queue_id',
           'table_name' => 'civicrm_mailing_event_reply',
           'entity' => 'Reply',
           'bao' => 'CRM_Mailing_Event_BAO_Reply',
@@ -106,6 +108,7 @@ class CRM_Mailing_Event_DAO_Reply extends CRM_Core_DAO {
           'title' => ts('Reply Timestamp'),
           'description' => ts('When this reply event occurred.'),
           'required' => TRUE,
+          'where' => 'civicrm_mailing_event_reply.time_stamp',
           'default' => 'CURRENT_TIMESTAMP',
           'table_name' => 'civicrm_mailing_event_reply',
           'entity' => 'Reply',
diff --git a/civicrm/CRM/Mailing/Event/DAO/Subscribe.php b/civicrm/CRM/Mailing/Event/DAO/Subscribe.php
index 888c2ecc199a6e7a0760c3dacc0be2b1faa424d9..ad711c9d26d5ef6ee69204ec5d1934388fee4266 100644
--- a/civicrm/CRM/Mailing/Event/DAO/Subscribe.php
+++ b/civicrm/CRM/Mailing/Event/DAO/Subscribe.php
@@ -77,7 +77,7 @@ class CRM_Mailing_Event_DAO_Subscribe extends CRM_Core_DAO {
    */
   public static function getReferenceColumns() {
     if (!isset(Civi::$statics[__CLASS__]['links'])) {
-      Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
+      Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
       Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'group_id', 'civicrm_group', 'id');
       Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id');
       CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
@@ -98,6 +98,7 @@ class CRM_Mailing_Event_DAO_Subscribe extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Mailing Subscribe ID'),
           'required' => TRUE,
+          'where' => 'civicrm_mailing_event_subscribe.id',
           'table_name' => 'civicrm_mailing_event_subscribe',
           'entity' => 'Subscribe',
           'bao' => 'CRM_Mailing_Event_BAO_Subscribe',
@@ -109,6 +110,7 @@ class CRM_Mailing_Event_DAO_Subscribe extends CRM_Core_DAO {
           'title' => ts('Mailing Subscribe Group'),
           'description' => ts('FK to Group'),
           'required' => TRUE,
+          'where' => 'civicrm_mailing_event_subscribe.group_id',
           'table_name' => 'civicrm_mailing_event_subscribe',
           'entity' => 'Subscribe',
           'bao' => 'CRM_Mailing_Event_BAO_Subscribe',
@@ -129,6 +131,7 @@ class CRM_Mailing_Event_DAO_Subscribe extends CRM_Core_DAO {
           'title' => ts('Mailing Subscribe Contact'),
           'description' => ts('FK to Contact'),
           'required' => TRUE,
+          'where' => 'civicrm_mailing_event_subscribe.contact_id',
           'table_name' => 'civicrm_mailing_event_subscribe',
           'entity' => 'Subscribe',
           'bao' => 'CRM_Mailing_Event_BAO_Subscribe',
@@ -143,6 +146,7 @@ class CRM_Mailing_Event_DAO_Subscribe extends CRM_Core_DAO {
           'required' => TRUE,
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_mailing_event_subscribe.hash',
           'table_name' => 'civicrm_mailing_event_subscribe',
           'entity' => 'Subscribe',
           'bao' => 'CRM_Mailing_Event_BAO_Subscribe',
@@ -154,6 +158,7 @@ class CRM_Mailing_Event_DAO_Subscribe extends CRM_Core_DAO {
           'title' => ts('Mailing Subscribe Timestamp'),
           'description' => ts('When this subscription event occurred.'),
           'required' => TRUE,
+          'where' => 'civicrm_mailing_event_subscribe.time_stamp',
           'default' => 'CURRENT_TIMESTAMP',
           'table_name' => 'civicrm_mailing_event_subscribe',
           'entity' => 'Subscribe',
diff --git a/civicrm/CRM/Mailing/Event/DAO/TrackableURLOpen.php b/civicrm/CRM/Mailing/Event/DAO/TrackableURLOpen.php
index 60e2eafef2c1f4605ea79a146a6db8766c96edc4..39c7646d10e88197b98c153ceeeebae23d1f81b4 100644
--- a/civicrm/CRM/Mailing/Event/DAO/TrackableURLOpen.php
+++ b/civicrm/CRM/Mailing/Event/DAO/TrackableURLOpen.php
@@ -70,7 +70,7 @@ class CRM_Mailing_Event_DAO_TrackableURLOpen extends CRM_Core_DAO {
    */
   public static function getReferenceColumns() {
     if (!isset(Civi::$statics[__CLASS__]['links'])) {
-      Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
+      Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
       Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'event_queue_id', 'civicrm_mailing_event_queue', 'id');
       Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'trackable_url_id', 'civicrm_mailing_trackable_url', 'id');
       CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
@@ -91,6 +91,7 @@ class CRM_Mailing_Event_DAO_TrackableURLOpen extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Trackable URL Open ID'),
           'required' => TRUE,
+          'where' => 'civicrm_mailing_event_trackable_url_open.id',
           'table_name' => 'civicrm_mailing_event_trackable_url_open',
           'entity' => 'TrackableURLOpen',
           'bao' => 'CRM_Mailing_Event_BAO_TrackableURLOpen',
@@ -102,6 +103,7 @@ class CRM_Mailing_Event_DAO_TrackableURLOpen extends CRM_Core_DAO {
           'title' => ts('Event Queue'),
           'description' => ts('FK to EventQueue'),
           'required' => TRUE,
+          'where' => 'civicrm_mailing_event_trackable_url_open.event_queue_id',
           'table_name' => 'civicrm_mailing_event_trackable_url_open',
           'entity' => 'TrackableURLOpen',
           'bao' => 'CRM_Mailing_Event_BAO_TrackableURLOpen',
@@ -114,6 +116,7 @@ class CRM_Mailing_Event_DAO_TrackableURLOpen extends CRM_Core_DAO {
           'title' => ts('Trackable Url'),
           'description' => ts('FK to TrackableURL'),
           'required' => TRUE,
+          'where' => 'civicrm_mailing_event_trackable_url_open.trackable_url_id',
           'table_name' => 'civicrm_mailing_event_trackable_url_open',
           'entity' => 'TrackableURLOpen',
           'bao' => 'CRM_Mailing_Event_BAO_TrackableURLOpen',
@@ -126,6 +129,7 @@ class CRM_Mailing_Event_DAO_TrackableURLOpen extends CRM_Core_DAO {
           'title' => ts('Timestamp'),
           'description' => ts('When this trackable URL open occurred.'),
           'required' => TRUE,
+          'where' => 'civicrm_mailing_event_trackable_url_open.time_stamp',
           'default' => 'CURRENT_TIMESTAMP',
           'table_name' => 'civicrm_mailing_event_trackable_url_open',
           'entity' => 'TrackableURLOpen',
diff --git a/civicrm/CRM/Mailing/Event/DAO/Unsubscribe.php b/civicrm/CRM/Mailing/Event/DAO/Unsubscribe.php
index 8459b8a50bd28814e8027a463bb6a26f8c04ad7f..7cd86585117cce5fae70658b6de23172bfb5ccd2 100644
--- a/civicrm/CRM/Mailing/Event/DAO/Unsubscribe.php
+++ b/civicrm/CRM/Mailing/Event/DAO/Unsubscribe.php
@@ -70,7 +70,7 @@ class CRM_Mailing_Event_DAO_Unsubscribe extends CRM_Core_DAO {
    */
   public static function getReferenceColumns() {
     if (!isset(Civi::$statics[__CLASS__]['links'])) {
-      Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
+      Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
       Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'event_queue_id', 'civicrm_mailing_event_queue', 'id');
       CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
     }
@@ -90,6 +90,7 @@ class CRM_Mailing_Event_DAO_Unsubscribe extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Unsubscribe ID'),
           'required' => TRUE,
+          'where' => 'civicrm_mailing_event_unsubscribe.id',
           'table_name' => 'civicrm_mailing_event_unsubscribe',
           'entity' => 'Unsubscribe',
           'bao' => 'CRM_Mailing_Event_BAO_Unsubscribe',
@@ -101,6 +102,7 @@ class CRM_Mailing_Event_DAO_Unsubscribe extends CRM_Core_DAO {
           'title' => ts('Mailing Event Queue'),
           'description' => ts('FK to EventQueue'),
           'required' => TRUE,
+          'where' => 'civicrm_mailing_event_unsubscribe.event_queue_id',
           'table_name' => 'civicrm_mailing_event_unsubscribe',
           'entity' => 'Unsubscribe',
           'bao' => 'CRM_Mailing_Event_BAO_Unsubscribe',
@@ -113,6 +115,7 @@ class CRM_Mailing_Event_DAO_Unsubscribe extends CRM_Core_DAO {
           'title' => ts('Unsubscribe is for Organization?'),
           'description' => ts('Unsubscribe at org- or group-level'),
           'required' => TRUE,
+          'where' => 'civicrm_mailing_event_unsubscribe.org_unsubscribe',
           'table_name' => 'civicrm_mailing_event_unsubscribe',
           'entity' => 'Unsubscribe',
           'bao' => 'CRM_Mailing_Event_BAO_Unsubscribe',
@@ -124,6 +127,7 @@ class CRM_Mailing_Event_DAO_Unsubscribe extends CRM_Core_DAO {
           'title' => ts('Unsubscribe Timestamp'),
           'description' => ts('When this delivery event occurred.'),
           'required' => TRUE,
+          'where' => 'civicrm_mailing_event_unsubscribe.time_stamp',
           'default' => 'CURRENT_TIMESTAMP',
           'table_name' => 'civicrm_mailing_event_unsubscribe',
           'entity' => 'Unsubscribe',
diff --git a/civicrm/CRM/Mailing/Selector/Search.php b/civicrm/CRM/Mailing/Selector/Search.php
index e50406bd8359b9560cfefa4d5dbf3d78aaedcede..65ad8038ce66c12b7dd251994827fb60c990eb88 100644
--- a/civicrm/CRM/Mailing/Selector/Search.php
+++ b/civicrm/CRM/Mailing/Selector/Search.php
@@ -341,8 +341,10 @@ class CRM_Mailing_Selector_Search extends CRM_Core_Selector_Base implements CRM_
    *   the column headers that need to be displayed
    */
   public function &getColumnHeaders($action = NULL, $output = NULL) {
+
     if (!isset(self::$_columnHeaders)) {
-      self::$_columnHeaders = [
+      $isMultiLingual = CRM_Core_I18n::isMultiLingual();
+      $headers = [
         ['desc' => ts('Contact Type')],
         [
           'name' => ts('Name'),
@@ -359,11 +361,17 @@ class CRM_Mailing_Selector_Search extends CRM_Core_Selector_Base implements CRM_
           'sort' => 'mailing_name',
           'direction' => CRM_Utils_Sort::DONTCARE,
         ],
-        [
+      ];
+
+      // Check to see if languages column should be displayed.
+      if ($isMultiLingual) {
+        $headers[] = [
           'name' => ts('Language'),
           'sort' => 'language',
           'direction' => CRM_Utils_Sort::DONTCARE,
-        ],
+        ];
+      }
+      self::$_columnHeaders = array_merge($headers, [
         [
           'name' => ts('Mailing Subject'),
           'sort' => 'mailing_subject',
@@ -380,7 +388,7 @@ class CRM_Mailing_Selector_Search extends CRM_Core_Selector_Base implements CRM_
           'direction' => CRM_Utils_Sort::DONTCARE,
         ],
         ['desc' => ts('Actions')],
-      ];
+      ]);
     }
     return self::$_columnHeaders;
   }
diff --git a/civicrm/CRM/Member/DAO/Membership.php b/civicrm/CRM/Member/DAO/Membership.php
index 5dbba6f274d74d8a62293b6e5b467d781a0719db..43b1b5aa60a41b4c146c889ca7bb243f77034b61 100644
--- a/civicrm/CRM/Member/DAO/Membership.php
+++ b/civicrm/CRM/Member/DAO/Membership.php
@@ -179,7 +179,6 @@ class CRM_Member_DAO_Membership extends CRM_Core_DAO {
           'import' => TRUE,
           'where' => 'civicrm_membership.id',
           'headerPattern' => '/^(m(embership\s)?id)$/i',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_membership',
           'entity' => 'Membership',
@@ -215,7 +214,6 @@ class CRM_Member_DAO_Membership extends CRM_Core_DAO {
           'import' => TRUE,
           'where' => 'civicrm_membership.membership_type_id',
           'headerPattern' => '/^(m(embership\s)?type)$/i',
-          'dataPattern' => '',
           'export' => FALSE,
           'table_name' => 'civicrm_membership',
           'entity' => 'Membership',
@@ -297,7 +295,6 @@ class CRM_Member_DAO_Membership extends CRM_Core_DAO {
           'import' => TRUE,
           'where' => 'civicrm_membership.source',
           'headerPattern' => '/^(member(ship?))?source$/i',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_membership',
           'entity' => 'Membership',
@@ -316,7 +313,6 @@ class CRM_Member_DAO_Membership extends CRM_Core_DAO {
           'import' => TRUE,
           'where' => 'civicrm_membership.status_id',
           'headerPattern' => '/(member(ship|).)?(status)$/i',
-          'dataPattern' => '',
           'export' => FALSE,
           'table_name' => 'civicrm_membership',
           'entity' => 'Membership',
@@ -340,7 +336,6 @@ class CRM_Member_DAO_Membership extends CRM_Core_DAO {
           'import' => TRUE,
           'where' => 'civicrm_membership.is_override',
           'headerPattern' => '/override$/i',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_membership',
           'entity' => 'Membership',
@@ -357,8 +352,6 @@ class CRM_Member_DAO_Membership extends CRM_Core_DAO {
           'description' => ts('Then end date of membership status override if \'Override until selected date\' override type is selected.'),
           'import' => TRUE,
           'where' => 'civicrm_membership.status_override_end_date',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'default' => 'NULL',
           'table_name' => 'civicrm_membership',
@@ -374,10 +367,8 @@ class CRM_Member_DAO_Membership extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Primary Member ID'),
           'description' => ts('Optional FK to Parent Membership.'),
-          'export' => TRUE,
           'where' => 'civicrm_membership.owner_membership_id',
-          'headerPattern' => '',
-          'dataPattern' => '',
+          'export' => TRUE,
           'table_name' => 'civicrm_membership',
           'entity' => 'Membership',
           'bao' => 'CRM_Member_BAO_Membership',
@@ -389,6 +380,7 @@ class CRM_Member_DAO_Membership extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Max Related'),
           'description' => ts('Maximum number of related memberships (membership_type override).'),
+          'where' => 'civicrm_membership.max_related',
           'table_name' => 'civicrm_membership',
           'entity' => 'Membership',
           'bao' => 'CRM_Member_BAO_Membership',
@@ -404,7 +396,6 @@ class CRM_Member_DAO_Membership extends CRM_Core_DAO {
           'import' => TRUE,
           'where' => 'civicrm_membership.is_test',
           'headerPattern' => '/(is.)?test(.member(ship)?)?/i',
-          'dataPattern' => '',
           'export' => TRUE,
           'default' => '0',
           'table_name' => 'civicrm_membership',
@@ -422,7 +413,6 @@ class CRM_Member_DAO_Membership extends CRM_Core_DAO {
           'import' => TRUE,
           'where' => 'civicrm_membership.is_pay_later',
           'headerPattern' => '/(is.)?(pay(.)?later)$/i',
-          'dataPattern' => '',
           'export' => TRUE,
           'default' => '0',
           'table_name' => 'civicrm_membership',
@@ -438,6 +428,7 @@ class CRM_Member_DAO_Membership extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Membership Recurring Contribution'),
           'description' => ts('Conditional foreign key to civicrm_contribution_recur id. Each membership in connection with a recurring contribution carries a foreign key to the recurring contribution record. This assumes we can track these processor initiated events.'),
+          'where' => 'civicrm_membership.contribution_recur_id',
           'table_name' => 'civicrm_membership',
           'entity' => 'Membership',
           'bao' => 'CRM_Member_BAO_Membership',
@@ -451,8 +442,6 @@ class CRM_Member_DAO_Membership extends CRM_Core_DAO {
           'description' => ts('The campaign for which this membership is attached.'),
           'import' => TRUE,
           'where' => 'civicrm_membership.campaign_id',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_membership',
           'entity' => 'Membership',
diff --git a/civicrm/CRM/Member/DAO/MembershipBlock.php b/civicrm/CRM/Member/DAO/MembershipBlock.php
index 0b533176c33ddf18523ac451213584a9ed81703c..275fce3e7a3805c23f4459a8c6d9c1e41c85fdbd 100644
--- a/civicrm/CRM/Member/DAO/MembershipBlock.php
+++ b/civicrm/CRM/Member/DAO/MembershipBlock.php
@@ -157,6 +157,7 @@ class CRM_Member_DAO_MembershipBlock extends CRM_Core_DAO {
           'title' => ts('Membership Block ID'),
           'description' => ts('Membership Id'),
           'required' => TRUE,
+          'where' => 'civicrm_membership_block.id',
           'table_name' => 'civicrm_membership_block',
           'entity' => 'MembershipBlock',
           'bao' => 'CRM_Member_BAO_MembershipBlock',
@@ -169,6 +170,7 @@ class CRM_Member_DAO_MembershipBlock extends CRM_Core_DAO {
           'description' => ts('Name for Membership Status'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_membership_block.entity_table',
           'table_name' => 'civicrm_membership_block',
           'entity' => 'MembershipBlock',
           'bao' => 'CRM_Member_BAO_MembershipBlock',
@@ -180,6 +182,7 @@ class CRM_Member_DAO_MembershipBlock extends CRM_Core_DAO {
           'title' => ts('Membership Block Entity ID'),
           'description' => ts('FK to civicrm_contribution_page.id'),
           'required' => TRUE,
+          'where' => 'civicrm_membership_block.entity_id',
           'table_name' => 'civicrm_membership_block',
           'entity' => 'MembershipBlock',
           'bao' => 'CRM_Member_BAO_MembershipBlock',
@@ -193,6 +196,7 @@ class CRM_Member_DAO_MembershipBlock extends CRM_Core_DAO {
           'description' => ts('Membership types to be exposed by this block'),
           'maxlength' => 1024,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_membership_block.membership_types',
           'table_name' => 'civicrm_membership_block',
           'entity' => 'MembershipBlock',
           'bao' => 'CRM_Member_BAO_MembershipBlock',
@@ -204,6 +208,7 @@ class CRM_Member_DAO_MembershipBlock extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Membership Block Default Type'),
           'description' => ts('Optional foreign key to membership_type'),
+          'where' => 'civicrm_membership_block.membership_type_default',
           'table_name' => 'civicrm_membership_block',
           'entity' => 'MembershipBlock',
           'bao' => 'CRM_Member_BAO_MembershipBlock',
@@ -215,6 +220,7 @@ class CRM_Member_DAO_MembershipBlock extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Membership Block Display Minimum Fee'),
           'description' => ts('Display minimum membership fee'),
+          'where' => 'civicrm_membership_block.display_min_fee',
           'default' => '1',
           'table_name' => 'civicrm_membership_block',
           'entity' => 'MembershipBlock',
@@ -226,6 +232,7 @@ class CRM_Member_DAO_MembershipBlock extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Membership Block Is Separate Payment'),
           'description' => ts('Should membership transactions be processed separately'),
+          'where' => 'civicrm_membership_block.is_separate_payment',
           'default' => '1',
           'table_name' => 'civicrm_membership_block',
           'entity' => 'MembershipBlock',
@@ -239,6 +246,7 @@ class CRM_Member_DAO_MembershipBlock extends CRM_Core_DAO {
           'description' => ts('Title to display at top of block'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_membership_block.new_title',
           'table_name' => 'civicrm_membership_block',
           'entity' => 'MembershipBlock',
           'bao' => 'CRM_Member_BAO_MembershipBlock',
@@ -249,6 +257,7 @@ class CRM_Member_DAO_MembershipBlock extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_TEXT,
           'title' => ts('Membership Block New Text'),
           'description' => ts('Text to display below title'),
+          'where' => 'civicrm_membership_block.new_text',
           'table_name' => 'civicrm_membership_block',
           'entity' => 'MembershipBlock',
           'bao' => 'CRM_Member_BAO_MembershipBlock',
@@ -261,6 +270,7 @@ class CRM_Member_DAO_MembershipBlock extends CRM_Core_DAO {
           'description' => ts('Title for renewal'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_membership_block.renewal_title',
           'table_name' => 'civicrm_membership_block',
           'entity' => 'MembershipBlock',
           'bao' => 'CRM_Member_BAO_MembershipBlock',
@@ -271,6 +281,7 @@ class CRM_Member_DAO_MembershipBlock extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_TEXT,
           'title' => ts('Membership Block Renewal Text'),
           'description' => ts('Text to display for member renewal'),
+          'where' => 'civicrm_membership_block.renewal_text',
           'table_name' => 'civicrm_membership_block',
           'entity' => 'MembershipBlock',
           'bao' => 'CRM_Member_BAO_MembershipBlock',
@@ -281,6 +292,7 @@ class CRM_Member_DAO_MembershipBlock extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Is Required'),
           'description' => ts('Is membership sign up optional'),
+          'where' => 'civicrm_membership_block.is_required',
           'default' => '0',
           'table_name' => 'civicrm_membership_block',
           'entity' => 'MembershipBlock',
@@ -292,6 +304,7 @@ class CRM_Member_DAO_MembershipBlock extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Is Active'),
           'description' => ts('Is this membership_block enabled'),
+          'where' => 'civicrm_membership_block.is_active',
           'default' => '1',
           'table_name' => 'civicrm_membership_block',
           'entity' => 'MembershipBlock',
diff --git a/civicrm/CRM/Member/DAO/MembershipLog.php b/civicrm/CRM/Member/DAO/MembershipLog.php
index 306cd2064772948852a516321aa00d512bc6f9ef..30b1e0bf476817784a48cbcb0a0b62a088e75da7 100644
--- a/civicrm/CRM/Member/DAO/MembershipLog.php
+++ b/civicrm/CRM/Member/DAO/MembershipLog.php
@@ -128,6 +128,7 @@ class CRM_Member_DAO_MembershipLog extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Membership Log ID'),
           'required' => TRUE,
+          'where' => 'civicrm_membership_log.id',
           'table_name' => 'civicrm_membership_log',
           'entity' => 'MembershipLog',
           'bao' => 'CRM_Member_BAO_MembershipLog',
@@ -139,6 +140,7 @@ class CRM_Member_DAO_MembershipLog extends CRM_Core_DAO {
           'title' => ts('Membership ID'),
           'description' => ts('FK to Membership table'),
           'required' => TRUE,
+          'where' => 'civicrm_membership_log.membership_id',
           'table_name' => 'civicrm_membership_log',
           'entity' => 'MembershipLog',
           'bao' => 'CRM_Member_BAO_MembershipLog',
@@ -151,6 +153,7 @@ class CRM_Member_DAO_MembershipLog extends CRM_Core_DAO {
           'title' => ts('Membership Status'),
           'description' => ts('New status assigned to membership by this action. FK to Membership Status'),
           'required' => TRUE,
+          'where' => 'civicrm_membership_log.status_id',
           'table_name' => 'civicrm_membership_log',
           'entity' => 'MembershipLog',
           'bao' => 'CRM_Member_BAO_MembershipLog',
@@ -162,6 +165,8 @@ class CRM_Member_DAO_MembershipLog extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_DATE,
           'title' => ts('Membership Log Start Date'),
           'description' => ts('New membership period start date'),
+          'where' => 'civicrm_membership_log.start_date',
+          'dataPattern' => '/\d{4}-?\d{2}-?\d{2}/',
           'table_name' => 'civicrm_membership_log',
           'entity' => 'MembershipLog',
           'bao' => 'CRM_Member_BAO_MembershipLog',
@@ -172,6 +177,8 @@ class CRM_Member_DAO_MembershipLog extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_DATE,
           'title' => ts('Membership Log End Date'),
           'description' => ts('New membership period expiration date.'),
+          'where' => 'civicrm_membership_log.end_date',
+          'dataPattern' => '/\d{4}-?\d{2}-?\d{2}/',
           'table_name' => 'civicrm_membership_log',
           'entity' => 'MembershipLog',
           'bao' => 'CRM_Member_BAO_MembershipLog',
@@ -182,6 +189,7 @@ class CRM_Member_DAO_MembershipLog extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Membership Log modified By'),
           'description' => ts('FK to Contact ID of person under whose credentials this data modification was made.'),
+          'where' => 'civicrm_membership_log.modified_id',
           'table_name' => 'civicrm_membership_log',
           'entity' => 'MembershipLog',
           'bao' => 'CRM_Member_BAO_MembershipLog',
@@ -193,6 +201,8 @@ class CRM_Member_DAO_MembershipLog extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_DATE,
           'title' => ts('Membership Change Date'),
           'description' => ts('Date this membership modification action was logged.'),
+          'where' => 'civicrm_membership_log.modified_date',
+          'dataPattern' => '/\d{4}-?\d{2}-?\d{2}/',
           'table_name' => 'civicrm_membership_log',
           'entity' => 'MembershipLog',
           'bao' => 'CRM_Member_BAO_MembershipLog',
@@ -203,6 +213,7 @@ class CRM_Member_DAO_MembershipLog extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Membership Type ID'),
           'description' => ts('FK to Membership Type.'),
+          'where' => 'civicrm_membership_log.membership_type_id',
           'table_name' => 'civicrm_membership_log',
           'entity' => 'MembershipLog',
           'bao' => 'CRM_Member_BAO_MembershipLog',
@@ -214,6 +225,7 @@ class CRM_Member_DAO_MembershipLog extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Maximum Related Memberships'),
           'description' => ts('Maximum number of related memberships.'),
+          'where' => 'civicrm_membership_log.max_related',
           'table_name' => 'civicrm_membership_log',
           'entity' => 'MembershipLog',
           'bao' => 'CRM_Member_BAO_MembershipLog',
diff --git a/civicrm/CRM/Member/DAO/MembershipPayment.php b/civicrm/CRM/Member/DAO/MembershipPayment.php
index e1b4c7abe95a6e28dc8f158ad63bb34457942ecc..82a01b13e695871f4541afcd6a4ac60d37530301 100644
--- a/civicrm/CRM/Member/DAO/MembershipPayment.php
+++ b/civicrm/CRM/Member/DAO/MembershipPayment.php
@@ -84,6 +84,7 @@ class CRM_Member_DAO_MembershipPayment extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Membership Payment ID'),
           'required' => TRUE,
+          'where' => 'civicrm_membership_payment.id',
           'table_name' => 'civicrm_membership_payment',
           'entity' => 'MembershipPayment',
           'bao' => 'CRM_Member_BAO_MembershipPayment',
@@ -95,6 +96,7 @@ class CRM_Member_DAO_MembershipPayment extends CRM_Core_DAO {
           'title' => ts('Membership'),
           'description' => ts('FK to Membership table'),
           'required' => TRUE,
+          'where' => 'civicrm_membership_payment.membership_id',
           'table_name' => 'civicrm_membership_payment',
           'entity' => 'MembershipPayment',
           'bao' => 'CRM_Member_BAO_MembershipPayment',
@@ -106,6 +108,7 @@ class CRM_Member_DAO_MembershipPayment extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Contribution'),
           'description' => ts('FK to contribution table.'),
+          'where' => 'civicrm_membership_payment.contribution_id',
           'table_name' => 'civicrm_membership_payment',
           'entity' => 'MembershipPayment',
           'bao' => 'CRM_Member_BAO_MembershipPayment',
diff --git a/civicrm/CRM/Member/DAO/MembershipStatus.php b/civicrm/CRM/Member/DAO/MembershipStatus.php
index 03d9b33b3081eea3d9d6be11b766d6273a6946d9..701759ffc0363a4109664703abd3bfd9726eae95 100644
--- a/civicrm/CRM/Member/DAO/MembershipStatus.php
+++ b/civicrm/CRM/Member/DAO/MembershipStatus.php
@@ -153,6 +153,7 @@ class CRM_Member_DAO_MembershipStatus extends CRM_Core_DAO {
           'title' => ts('Membership Status ID'),
           'description' => ts('Membership Id'),
           'required' => TRUE,
+          'where' => 'civicrm_membership_status.id',
           'table_name' => 'civicrm_membership_status',
           'entity' => 'MembershipStatus',
           'bao' => 'CRM_Member_BAO_MembershipStatus',
@@ -167,8 +168,6 @@ class CRM_Member_DAO_MembershipStatus extends CRM_Core_DAO {
           'size' => CRM_Utils_Type::HUGE,
           'import' => TRUE,
           'where' => 'civicrm_membership_status.name',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_membership_status',
           'entity' => 'MembershipStatus',
@@ -182,6 +181,7 @@ class CRM_Member_DAO_MembershipStatus extends CRM_Core_DAO {
           'description' => ts('Label for Membership Status'),
           'maxlength' => 128,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_membership_status.label',
           'table_name' => 'civicrm_membership_status',
           'entity' => 'MembershipStatus',
           'bao' => 'CRM_Member_BAO_MembershipStatus',
@@ -197,6 +197,7 @@ class CRM_Member_DAO_MembershipStatus extends CRM_Core_DAO {
           'description' => ts('Event when this status starts.'),
           'maxlength' => 12,
           'size' => CRM_Utils_Type::TWELVE,
+          'where' => 'civicrm_membership_status.start_event',
           'table_name' => 'civicrm_membership_status',
           'entity' => 'MembershipStatus',
           'bao' => 'CRM_Member_BAO_MembershipStatus',
@@ -215,6 +216,7 @@ class CRM_Member_DAO_MembershipStatus extends CRM_Core_DAO {
           'description' => ts('Unit used for adjusting from start_event.'),
           'maxlength' => 8,
           'size' => CRM_Utils_Type::EIGHT,
+          'where' => 'civicrm_membership_status.start_event_adjust_unit',
           'table_name' => 'civicrm_membership_status',
           'entity' => 'MembershipStatus',
           'bao' => 'CRM_Member_BAO_MembershipStatus',
@@ -231,6 +233,7 @@ class CRM_Member_DAO_MembershipStatus extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Start Event Adjust Interval'),
           'description' => ts('Status range begins this many units from start_event.'),
+          'where' => 'civicrm_membership_status.start_event_adjust_interval',
           'table_name' => 'civicrm_membership_status',
           'entity' => 'MembershipStatus',
           'bao' => 'CRM_Member_BAO_MembershipStatus',
@@ -243,6 +246,7 @@ class CRM_Member_DAO_MembershipStatus extends CRM_Core_DAO {
           'description' => ts('Event after which this status ends.'),
           'maxlength' => 12,
           'size' => CRM_Utils_Type::TWELVE,
+          'where' => 'civicrm_membership_status.end_event',
           'table_name' => 'civicrm_membership_status',
           'entity' => 'MembershipStatus',
           'bao' => 'CRM_Member_BAO_MembershipStatus',
@@ -261,6 +265,7 @@ class CRM_Member_DAO_MembershipStatus extends CRM_Core_DAO {
           'description' => ts('Unit used for adjusting from the ending event.'),
           'maxlength' => 8,
           'size' => CRM_Utils_Type::EIGHT,
+          'where' => 'civicrm_membership_status.end_event_adjust_unit',
           'table_name' => 'civicrm_membership_status',
           'entity' => 'MembershipStatus',
           'bao' => 'CRM_Member_BAO_MembershipStatus',
@@ -277,6 +282,7 @@ class CRM_Member_DAO_MembershipStatus extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('End Event Adjust Interval'),
           'description' => ts('Status range ends this many units from end_event.'),
+          'where' => 'civicrm_membership_status.end_event_adjust_interval',
           'table_name' => 'civicrm_membership_status',
           'entity' => 'MembershipStatus',
           'bao' => 'CRM_Member_BAO_MembershipStatus',
@@ -287,6 +293,7 @@ class CRM_Member_DAO_MembershipStatus extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Current Membership?'),
           'description' => ts('Does this status aggregate to current members (e.g. New, Renewed, Grace might all be TRUE... while Unrenewed, Lapsed, Inactive would be FALSE).'),
+          'where' => 'civicrm_membership_status.is_current_member',
           'table_name' => 'civicrm_membership_status',
           'entity' => 'MembershipStatus',
           'bao' => 'CRM_Member_BAO_MembershipStatus',
@@ -297,6 +304,7 @@ class CRM_Member_DAO_MembershipStatus extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Administrator Only?'),
           'description' => ts('Is this status for admin/manual assignment only.'),
+          'where' => 'civicrm_membership_status.is_admin',
           'table_name' => 'civicrm_membership_status',
           'entity' => 'MembershipStatus',
           'bao' => 'CRM_Member_BAO_MembershipStatus',
@@ -309,6 +317,7 @@ class CRM_Member_DAO_MembershipStatus extends CRM_Core_DAO {
           'name' => 'weight',
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Order'),
+          'where' => 'civicrm_membership_status.weight',
           'table_name' => 'civicrm_membership_status',
           'entity' => 'MembershipStatus',
           'bao' => 'CRM_Member_BAO_MembershipStatus',
@@ -319,6 +328,7 @@ class CRM_Member_DAO_MembershipStatus extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Default Status?'),
           'description' => ts('Assign this status to a membership record if no other status match is found.'),
+          'where' => 'civicrm_membership_status.is_default',
           'table_name' => 'civicrm_membership_status',
           'entity' => 'MembershipStatus',
           'bao' => 'CRM_Member_BAO_MembershipStatus',
@@ -332,6 +342,7 @@ class CRM_Member_DAO_MembershipStatus extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Is Active'),
           'description' => ts('Is this membership_status enabled.'),
+          'where' => 'civicrm_membership_status.is_active',
           'default' => '1',
           'table_name' => 'civicrm_membership_status',
           'entity' => 'MembershipStatus',
@@ -346,6 +357,7 @@ class CRM_Member_DAO_MembershipStatus extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Is Reserved'),
           'description' => ts('Is this membership_status reserved.'),
+          'where' => 'civicrm_membership_status.is_reserved',
           'default' => '0',
           'table_name' => 'civicrm_membership_status',
           'entity' => 'MembershipStatus',
diff --git a/civicrm/CRM/Member/DAO/MembershipType.php b/civicrm/CRM/Member/DAO/MembershipType.php
index e2f99222f0df41c799897447acbd47b2e28d8c75..c777c9a2e37e3351603e877045171906e7247c6d 100644
--- a/civicrm/CRM/Member/DAO/MembershipType.php
+++ b/civicrm/CRM/Member/DAO/MembershipType.php
@@ -208,6 +208,7 @@ class CRM_Member_DAO_MembershipType extends CRM_Core_DAO {
           'title' => ts('Membership Type ID'),
           'description' => ts('Membership Id'),
           'required' => TRUE,
+          'where' => 'civicrm_membership_type.id',
           'table_name' => 'civicrm_membership_type',
           'entity' => 'MembershipType',
           'bao' => 'CRM_Member_BAO_MembershipType',
@@ -219,6 +220,7 @@ class CRM_Member_DAO_MembershipType extends CRM_Core_DAO {
           'title' => ts('Membership Type Domain'),
           'description' => ts('Which Domain is this match entry for'),
           'required' => TRUE,
+          'where' => 'civicrm_membership_type.domain_id',
           'table_name' => 'civicrm_membership_type',
           'entity' => 'MembershipType',
           'bao' => 'CRM_Member_BAO_MembershipType',
@@ -239,8 +241,6 @@ class CRM_Member_DAO_MembershipType extends CRM_Core_DAO {
           'size' => CRM_Utils_Type::HUGE,
           'import' => TRUE,
           'where' => 'civicrm_membership_type.name',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_membership_type',
           'entity' => 'MembershipType',
@@ -258,6 +258,7 @@ class CRM_Member_DAO_MembershipType extends CRM_Core_DAO {
           'description' => ts('Description of Membership Type'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_membership_type.description',
           'table_name' => 'civicrm_membership_type',
           'entity' => 'MembershipType',
           'bao' => 'CRM_Member_BAO_MembershipType',
@@ -273,6 +274,7 @@ class CRM_Member_DAO_MembershipType extends CRM_Core_DAO {
           'title' => ts('Membership Type Organization'),
           'description' => ts('Owner organization for this membership type. FK to Contact ID'),
           'required' => TRUE,
+          'where' => 'civicrm_membership_type.member_of_contact_id',
           'table_name' => 'civicrm_membership_type',
           'entity' => 'MembershipType',
           'bao' => 'CRM_Member_BAO_MembershipType',
@@ -285,6 +287,7 @@ class CRM_Member_DAO_MembershipType extends CRM_Core_DAO {
           'title' => ts('Membership Financial Type'),
           'description' => ts('If membership is paid by a contribution - what financial type should be used. FK to civicrm_financial_type.id'),
           'required' => TRUE,
+          'where' => 'civicrm_membership_type.financial_type_id',
           'table_name' => 'civicrm_membership_type',
           'entity' => 'MembershipType',
           'bao' => 'CRM_Member_BAO_MembershipType',
@@ -305,6 +308,7 @@ class CRM_Member_DAO_MembershipType extends CRM_Core_DAO {
             18,
             9
           ],
+          'where' => 'civicrm_membership_type.minimum_fee',
           'default' => '0',
           'table_name' => 'civicrm_membership_type',
           'entity' => 'MembershipType',
@@ -322,6 +326,7 @@ class CRM_Member_DAO_MembershipType extends CRM_Core_DAO {
           'description' => ts('Unit in which membership period is expressed.'),
           'maxlength' => 8,
           'size' => CRM_Utils_Type::EIGHT,
+          'where' => 'civicrm_membership_type.duration_unit',
           'table_name' => 'civicrm_membership_type',
           'entity' => 'MembershipType',
           'bao' => 'CRM_Member_BAO_MembershipType',
@@ -338,6 +343,7 @@ class CRM_Member_DAO_MembershipType extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Membership Type Duration Interval'),
           'description' => ts('Number of duration units in membership period (e.g. 1 year, 12 months).'),
+          'where' => 'civicrm_membership_type.duration_interval',
           'table_name' => 'civicrm_membership_type',
           'entity' => 'MembershipType',
           'bao' => 'CRM_Member_BAO_MembershipType',
@@ -353,6 +359,7 @@ class CRM_Member_DAO_MembershipType extends CRM_Core_DAO {
           'description' => ts('Rolling membership period starts on signup date. Fixed membership periods start on fixed_period_start_day.'),
           'maxlength' => 8,
           'size' => CRM_Utils_Type::EIGHT,
+          'where' => 'civicrm_membership_type.period_type',
           'table_name' => 'civicrm_membership_type',
           'entity' => 'MembershipType',
           'bao' => 'CRM_Member_BAO_MembershipType',
@@ -369,6 +376,7 @@ class CRM_Member_DAO_MembershipType extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Fixed Period Start Day'),
           'description' => ts('For fixed period memberships, month and day (mmdd) on which subscription/membership will start. Period start is back-dated unless after rollover day.'),
+          'where' => 'civicrm_membership_type.fixed_period_start_day',
           'table_name' => 'civicrm_membership_type',
           'entity' => 'MembershipType',
           'bao' => 'CRM_Member_BAO_MembershipType',
@@ -379,6 +387,7 @@ class CRM_Member_DAO_MembershipType extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Fixed Period Rollover Day'),
           'description' => ts('For fixed period memberships, signups after this day (mmdd) rollover to next period.'),
+          'where' => 'civicrm_membership_type.fixed_period_rollover_day',
           'table_name' => 'civicrm_membership_type',
           'entity' => 'MembershipType',
           'bao' => 'CRM_Member_BAO_MembershipType',
@@ -391,6 +400,7 @@ class CRM_Member_DAO_MembershipType extends CRM_Core_DAO {
           'description' => ts('FK to Relationship Type ID'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_membership_type.relationship_type_id',
           'table_name' => 'civicrm_membership_type',
           'entity' => 'MembershipType',
           'bao' => 'CRM_Member_BAO_MembershipType',
@@ -402,6 +412,7 @@ class CRM_Member_DAO_MembershipType extends CRM_Core_DAO {
           'title' => ts('Relationship Direction'),
           'maxlength' => 128,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_membership_type.relationship_direction',
           'table_name' => 'civicrm_membership_type',
           'entity' => 'MembershipType',
           'bao' => 'CRM_Member_BAO_MembershipType',
@@ -412,6 +423,7 @@ class CRM_Member_DAO_MembershipType extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Max Related Members for Type'),
           'description' => ts('Maximum number of related memberships.'),
+          'where' => 'civicrm_membership_type.max_related',
           'table_name' => 'civicrm_membership_type',
           'entity' => 'MembershipType',
           'bao' => 'CRM_Member_BAO_MembershipType',
@@ -427,6 +439,7 @@ class CRM_Member_DAO_MembershipType extends CRM_Core_DAO {
           'title' => ts('Visible'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_membership_type.visibility',
           'table_name' => 'civicrm_membership_type',
           'entity' => 'MembershipType',
           'bao' => 'CRM_Member_BAO_MembershipType',
@@ -442,6 +455,7 @@ class CRM_Member_DAO_MembershipType extends CRM_Core_DAO {
           'name' => 'weight',
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Order'),
+          'where' => 'civicrm_membership_type.weight',
           'table_name' => 'civicrm_membership_type',
           'entity' => 'MembershipType',
           'bao' => 'CRM_Member_BAO_MembershipType',
@@ -457,6 +471,7 @@ class CRM_Member_DAO_MembershipType extends CRM_Core_DAO {
           'description' => ts('Receipt Text for membership signup'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_membership_type.receipt_text_signup',
           'table_name' => 'civicrm_membership_type',
           'entity' => 'MembershipType',
           'bao' => 'CRM_Member_BAO_MembershipType',
@@ -472,6 +487,7 @@ class CRM_Member_DAO_MembershipType extends CRM_Core_DAO {
           'description' => ts('Receipt Text for membership renewal'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_membership_type.receipt_text_renewal',
           'table_name' => 'civicrm_membership_type',
           'entity' => 'MembershipType',
           'bao' => 'CRM_Member_BAO_MembershipType',
@@ -485,6 +501,7 @@ class CRM_Member_DAO_MembershipType extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Auto Renew'),
           'description' => ts('0 = No auto-renew option; 1 = Give option, but not required; 2 = Auto-renew required;'),
+          'where' => 'civicrm_membership_type.auto_renew',
           'default' => '0',
           'table_name' => 'civicrm_membership_type',
           'entity' => 'MembershipType',
@@ -502,6 +519,7 @@ class CRM_Member_DAO_MembershipType extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Is Active'),
           'description' => ts('Is this membership_type enabled'),
+          'where' => 'civicrm_membership_type.is_active',
           'default' => '1',
           'table_name' => 'civicrm_membership_type',
           'entity' => 'MembershipType',
diff --git a/civicrm/CRM/Member/Form/MembershipRenewal.php b/civicrm/CRM/Member/Form/MembershipRenewal.php
index 096e45e65254bc327427cad20afe14df65d3f8c2..4c984618d31f36826e161e14fbd22493a08fca58 100644
--- a/civicrm/CRM/Member/Form/MembershipRenewal.php
+++ b/civicrm/CRM/Member/Form/MembershipRenewal.php
@@ -129,6 +129,21 @@ class CRM_Member_Form_MembershipRenewal extends CRM_Member_Form {
    *
    * @throws \Exception
    */
+
+  /**
+   * Set the renewal notification status message.
+   */
+  public function setRenewalMessage() {
+    $statusMsg = ts('%1 membership for %2 has been renewed.', array(1 => $this->membershipTypeName, 2 => $this->_memberDisplayName));
+
+    if ($this->isMailSent) {
+      $statusMsg .= ' ' . ts('A renewal confirmation and receipt has been sent to %1.', array(
+        1 => $this->_contributorEmail,
+      ));
+    }
+    CRM_Core_Session::setStatus($statusMsg, ts('Complete'), 'success');
+  }
+
   public function preProcess() {
 
     // This string makes up part of the class names, differentiating them (not sure why) from the membership fields.
@@ -459,21 +474,7 @@ class CRM_Member_Form_MembershipRenewal extends CRM_Member_Form {
 
     try {
       $this->submit();
-      $statusMsg = ts('%1 membership for %2 has been renewed.', [1 => $this->membershipTypeName, 2 => $this->_memberDisplayName]);
-
-      if ($this->endDate) {
-        $statusMsg .= ' ' . ts('The new membership End Date is %1.', [
-          1 => CRM_Utils_Date::customFormat(substr($this->endDate, 0, 8)),
-        ]);
-      }
-
-      if ($this->isMailSent) {
-        $statusMsg .= ' ' . ts('A renewal confirmation and receipt has been sent to %1.', [
-          1 => $this->_contributorEmail,
-        ]);
-        return $statusMsg;
-      }
-      return $statusMsg;
+      $this->setRenewalMessage();
     }
     catch (\Civi\Payment\Exception\PaymentProcessorException $e) {
       CRM_Core_Session::singleton()->setStatus($e->getMessage());
@@ -481,8 +482,6 @@ class CRM_Member_Form_MembershipRenewal extends CRM_Member_Form {
         "reset=1&action=renew&cid={$this->_contactID}&id={$this->_id}&context=membership&mode={$this->_mode}"
       ));
     }
-
-    CRM_Core_Session::setStatus($statusMsg, ts('Complete'), 'success');
   }
 
   /**
@@ -529,6 +528,7 @@ class CRM_Member_Form_MembershipRenewal extends CRM_Member_Form {
       $this->_params['description'] = ts("Contribution submitted by a staff person using member's credit card for renewal");
       $this->_params['amount'] = $this->_params['total_amount'];
       $this->_params['payment_instrument_id'] = $this->_paymentProcessor['payment_instrument_id'];
+      $this->_params['receive_date'] = $now;
 
       // at this point we've created a contact and stored its address etc
       // all the payment processors expect the name and address to be in the passed params
diff --git a/civicrm/CRM/PCP/DAO/PCP.php b/civicrm/CRM/PCP/DAO/PCP.php
index 20238b03d51773db4acfc68eefb457c8d77cb682..b33921cf73eeedc80fdc2efcf6583d9c0633e940 100644
--- a/civicrm/CRM/PCP/DAO/PCP.php
+++ b/civicrm/CRM/PCP/DAO/PCP.php
@@ -163,6 +163,7 @@ class CRM_PCP_DAO_PCP extends CRM_Core_DAO {
           'title' => ts('Personal Campaign Page ID'),
           'description' => ts('Personal Campaign Page ID'),
           'required' => TRUE,
+          'where' => 'civicrm_pcp.id',
           'table_name' => 'civicrm_pcp',
           'entity' => 'PCP',
           'bao' => 'CRM_PCP_BAO_PCP',
@@ -174,6 +175,7 @@ class CRM_PCP_DAO_PCP extends CRM_Core_DAO {
           'title' => ts('Contact ID'),
           'description' => ts('FK to Contact ID'),
           'required' => TRUE,
+          'where' => 'civicrm_pcp.contact_id',
           'table_name' => 'civicrm_pcp',
           'entity' => 'PCP',
           'bao' => 'CRM_PCP_BAO_PCP',
@@ -188,6 +190,7 @@ class CRM_PCP_DAO_PCP extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Personal Campaign Page Status'),
           'required' => TRUE,
+          'where' => 'civicrm_pcp.status_id',
           'table_name' => 'civicrm_pcp',
           'entity' => 'PCP',
           'bao' => 'CRM_PCP_BAO_PCP',
@@ -206,6 +209,7 @@ class CRM_PCP_DAO_PCP extends CRM_Core_DAO {
           'title' => ts('Personal Campaign Page Title'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_pcp.title',
           'default' => 'NULL',
           'table_name' => 'civicrm_pcp',
           'entity' => 'PCP',
@@ -219,6 +223,7 @@ class CRM_PCP_DAO_PCP extends CRM_Core_DAO {
           'name' => 'intro_text',
           'type' => CRM_Utils_Type::T_TEXT,
           'title' => ts('Intro Text'),
+          'where' => 'civicrm_pcp.intro_text',
           'default' => 'NULL',
           'table_name' => 'civicrm_pcp',
           'entity' => 'PCP',
@@ -232,6 +237,7 @@ class CRM_PCP_DAO_PCP extends CRM_Core_DAO {
           'name' => 'page_text',
           'type' => CRM_Utils_Type::T_TEXT,
           'title' => ts('Page Text'),
+          'where' => 'civicrm_pcp.page_text',
           'default' => 'NULL',
           'table_name' => 'civicrm_pcp',
           'entity' => 'PCP',
@@ -247,6 +253,7 @@ class CRM_PCP_DAO_PCP extends CRM_Core_DAO {
           'title' => ts('Donate Link Text'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_pcp.donate_link_text',
           'default' => 'NULL',
           'table_name' => 'civicrm_pcp',
           'entity' => 'PCP',
@@ -262,6 +269,7 @@ class CRM_PCP_DAO_PCP extends CRM_Core_DAO {
           'title' => ts('Contribution Page'),
           'description' => ts('The Contribution or Event Page which triggered this pcp'),
           'required' => TRUE,
+          'where' => 'civicrm_pcp.page_id',
           'table_name' => 'civicrm_pcp',
           'entity' => 'PCP',
           'bao' => 'CRM_PCP_BAO_PCP',
@@ -274,6 +282,7 @@ class CRM_PCP_DAO_PCP extends CRM_Core_DAO {
           'description' => ts('The type of PCP this is: contribute or event'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_pcp.page_type',
           'default' => 'contribute',
           'table_name' => 'civicrm_pcp',
           'entity' => 'PCP',
@@ -289,6 +298,7 @@ class CRM_PCP_DAO_PCP extends CRM_Core_DAO {
           'title' => ts('PCP Block'),
           'description' => ts('The pcp block that this pcp page was created from'),
           'required' => TRUE,
+          'where' => 'civicrm_pcp.pcp_block_id',
           'table_name' => 'civicrm_pcp',
           'entity' => 'PCP',
           'bao' => 'CRM_PCP_BAO_PCP',
@@ -298,6 +308,7 @@ class CRM_PCP_DAO_PCP extends CRM_Core_DAO {
           'name' => 'is_thermometer',
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Use Thermometer?'),
+          'where' => 'civicrm_pcp.is_thermometer',
           'default' => '0',
           'table_name' => 'civicrm_pcp',
           'entity' => 'PCP',
@@ -311,6 +322,7 @@ class CRM_PCP_DAO_PCP extends CRM_Core_DAO {
           'name' => 'is_honor_roll',
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Show Honor Roll?'),
+          'where' => 'civicrm_pcp.is_honor_roll',
           'default' => '0',
           'table_name' => 'civicrm_pcp',
           'entity' => 'PCP',
@@ -329,6 +341,7 @@ class CRM_PCP_DAO_PCP extends CRM_Core_DAO {
             20,
             2
           ],
+          'where' => 'civicrm_pcp.goal_amount',
           'table_name' => 'civicrm_pcp',
           'entity' => 'PCP',
           'bao' => 'CRM_PCP_BAO_PCP',
@@ -344,6 +357,7 @@ class CRM_PCP_DAO_PCP extends CRM_Core_DAO {
           'description' => ts('3 character string, value from config setting or input via user.'),
           'maxlength' => 3,
           'size' => CRM_Utils_Type::FOUR,
+          'where' => 'civicrm_pcp.currency',
           'default' => 'NULL',
           'table_name' => 'civicrm_pcp',
           'entity' => 'PCP',
@@ -364,6 +378,7 @@ class CRM_PCP_DAO_PCP extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Enabled?'),
           'description' => ts('Is Personal Campaign Page enabled/active?'),
+          'where' => 'civicrm_pcp.is_active',
           'default' => '0',
           'table_name' => 'civicrm_pcp',
           'entity' => 'PCP',
@@ -378,6 +393,7 @@ class CRM_PCP_DAO_PCP extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Notify Owner?'),
           'description' => ts('Notify owner via email when someone donates to page?'),
+          'where' => 'civicrm_pcp.is_notify',
           'default' => '0',
           'table_name' => 'civicrm_pcp',
           'entity' => 'PCP',
diff --git a/civicrm/CRM/PCP/DAO/PCPBlock.php b/civicrm/CRM/PCP/DAO/PCPBlock.php
index 89b76af0be2c276aa2471196c8163a668bb446c4..2d93ff55c85f5a4df8152edb7384224c713c3eb5 100644
--- a/civicrm/CRM/PCP/DAO/PCPBlock.php
+++ b/civicrm/CRM/PCP/DAO/PCPBlock.php
@@ -156,6 +156,7 @@ class CRM_PCP_DAO_PCPBlock extends CRM_Core_DAO {
           'title' => ts('PCP Block ID'),
           'description' => ts('PCP block Id'),
           'required' => TRUE,
+          'where' => 'civicrm_pcp_block.id',
           'table_name' => 'civicrm_pcp_block',
           'entity' => 'PCPBlock',
           'bao' => 'CRM_PCP_BAO_PCPBlock',
@@ -167,6 +168,7 @@ class CRM_PCP_DAO_PCPBlock extends CRM_Core_DAO {
           'title' => ts('Entity Table'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_pcp_block.entity_table',
           'table_name' => 'civicrm_pcp_block',
           'entity' => 'PCPBlock',
           'bao' => 'CRM_PCP_BAO_PCPBlock',
@@ -178,6 +180,7 @@ class CRM_PCP_DAO_PCPBlock extends CRM_Core_DAO {
           'title' => ts('Entity'),
           'description' => ts('FK to civicrm_contribution_page.id OR civicrm_event.id'),
           'required' => TRUE,
+          'where' => 'civicrm_pcp_block.entity_id',
           'table_name' => 'civicrm_pcp_block',
           'entity' => 'PCPBlock',
           'bao' => 'CRM_PCP_BAO_PCPBlock',
@@ -191,6 +194,7 @@ class CRM_PCP_DAO_PCPBlock extends CRM_Core_DAO {
           'required' => TRUE,
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_pcp_block.target_entity_type',
           'default' => 'contribute',
           'table_name' => 'civicrm_pcp_block',
           'entity' => 'PCPBlock',
@@ -203,6 +207,7 @@ class CRM_PCP_DAO_PCPBlock extends CRM_Core_DAO {
           'title' => ts('Target Entity ID'),
           'description' => ts('The entity that this pcp targets'),
           'required' => TRUE,
+          'where' => 'civicrm_pcp_block.target_entity_id',
           'table_name' => 'civicrm_pcp_block',
           'entity' => 'PCPBlock',
           'bao' => 'CRM_PCP_BAO_PCPBlock',
@@ -213,6 +218,7 @@ class CRM_PCP_DAO_PCPBlock extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Supporter Profile'),
           'description' => ts('FK to civicrm_uf_group.id. Does Personal Campaign Page require manual activation by administrator? (is inactive by default after setup)?'),
+          'where' => 'civicrm_pcp_block.supporter_profile_id',
           'default' => 'NULL',
           'table_name' => 'civicrm_pcp_block',
           'entity' => 'PCPBlock',
@@ -225,6 +231,7 @@ class CRM_PCP_DAO_PCPBlock extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Owner Notification'),
           'description' => ts('FK to civicrm_option_group with name = PCP owner notifications'),
+          'where' => 'civicrm_pcp_block.owner_notify_id',
           'default' => '0',
           'table_name' => 'civicrm_pcp_block',
           'entity' => 'PCPBlock',
@@ -243,6 +250,7 @@ class CRM_PCP_DAO_PCPBlock extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Approval Required?'),
           'description' => ts('Does Personal Campaign Page require manual activation by administrator? (is inactive by default after setup)?'),
+          'where' => 'civicrm_pcp_block.is_approval_needed',
           'default' => 'NULL',
           'table_name' => 'civicrm_pcp_block',
           'entity' => 'PCPBlock',
@@ -254,6 +262,7 @@ class CRM_PCP_DAO_PCPBlock extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Tell a Friend Enabled?'),
           'description' => ts('Does Personal Campaign Page allow using tell a friend?'),
+          'where' => 'civicrm_pcp_block.is_tellfriend_enabled',
           'default' => 'NULL',
           'table_name' => 'civicrm_pcp_block',
           'entity' => 'PCPBlock',
@@ -265,6 +274,7 @@ class CRM_PCP_DAO_PCPBlock extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Tell A Friend Limit'),
           'description' => ts('Maximum recipient fields allowed in tell a friend'),
+          'where' => 'civicrm_pcp_block.tellfriend_limit',
           'default' => 'NULL',
           'table_name' => 'civicrm_pcp_block',
           'entity' => 'PCPBlock',
@@ -278,6 +288,7 @@ class CRM_PCP_DAO_PCPBlock extends CRM_Core_DAO {
           'description' => ts('Link text for PCP.'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_pcp_block.link_text',
           'default' => 'NULL',
           'table_name' => 'civicrm_pcp_block',
           'entity' => 'PCPBlock',
@@ -289,6 +300,7 @@ class CRM_PCP_DAO_PCPBlock extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Enabled?'),
           'description' => ts('Is Personal Campaign Page Block enabled/active?'),
+          'where' => 'civicrm_pcp_block.is_active',
           'default' => '1',
           'table_name' => 'civicrm_pcp_block',
           'entity' => 'PCPBlock',
@@ -302,6 +314,7 @@ class CRM_PCP_DAO_PCPBlock extends CRM_Core_DAO {
           'description' => ts('If set, notification is automatically emailed to this email-address on create/update Personal Campaign Page'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_pcp_block.notify_email',
           'default' => 'NULL',
           'table_name' => 'civicrm_pcp_block',
           'entity' => 'PCPBlock',
diff --git a/civicrm/CRM/Pledge/BAO/PledgeBlock.php b/civicrm/CRM/Pledge/BAO/PledgeBlock.php
index bbba0e145584f8320fd0babef9e1b812c8084dae..732a61a450e53b1923f7dea4edc7261805cd5c44 100644
--- a/civicrm/CRM/Pledge/BAO/PledgeBlock.php
+++ b/civicrm/CRM/Pledge/BAO/PledgeBlock.php
@@ -308,15 +308,15 @@ class CRM_Pledge_BAO_PledgeBlock extends CRM_Pledge_DAO_PledgeBlock {
           foreach ($date as $field => $value) {
             switch ($field) {
               case 'contribution_date':
-                $form->addDate('start_date', ts('First installment payment'));
-                $paymentDate = $value = date('m/d/Y');
-                list($defaults['start_date'], $defaults['start_date_time']) = CRM_Utils_Date::setDateDefaults(NULL);
+                $form->add('datepicker', 'start_date', ts('First installment payment'), [], FALSE, ['time' => FALSE]);
+                $paymentDate = $value = date('Y-m-d');
+                $defaults['start_date'] = $value;
                 $form->assign('is_date', TRUE);
                 break;
 
               case 'calendar_date':
-                $form->addDate('start_date', ts('First installment payment'));
-                list($defaults['start_date'], $defaults['start_date_time']) = CRM_Utils_Date::setDateDefaults($value);
+                $form->add('datepicker', 'start_date', ts('First installment payment'), [], FALSE, ['time' => FALSE]);
+                $defaults['start_date'] = $value;
                 $form->assign('is_date', TRUE);
                 $paymentDate = $value;
                 break;
@@ -325,7 +325,7 @@ class CRM_Pledge_BAO_PledgeBlock extends CRM_Pledge_DAO_PledgeBlock {
                 $month = CRM_Utils_Date::getCalendarDayOfMonth();
                 $form->add('select', 'start_date', ts('Day of month installments paid'), $month);
                 $paymentDate = CRM_Pledge_BAO_Pledge::getPaymentDate($value);
-                list($defaults['start_date'], $defaults['start_date_time']) = CRM_Utils_Date::setDateDefaults($paymentDate);
+                $defaults['start_date'] = $paymentDate;
                 break;
 
               default:
diff --git a/civicrm/CRM/Pledge/DAO/Pledge.php b/civicrm/CRM/Pledge/DAO/Pledge.php
index de2f298916836ab2a8a68f28a980f7c4fff82e95..76e796bfc9a3a403ac2891bfeff8f4bb4d4ae3be 100644
--- a/civicrm/CRM/Pledge/DAO/Pledge.php
+++ b/civicrm/CRM/Pledge/DAO/Pledge.php
@@ -229,8 +229,6 @@ class CRM_Pledge_DAO_Pledge extends CRM_Core_DAO {
           'required' => TRUE,
           'import' => TRUE,
           'where' => 'civicrm_pledge.id',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_pledge',
           'entity' => 'Pledge',
@@ -245,8 +243,6 @@ class CRM_Pledge_DAO_Pledge extends CRM_Core_DAO {
           'required' => TRUE,
           'import' => TRUE,
           'where' => 'civicrm_pledge.contact_id',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_pledge',
           'entity' => 'Pledge',
@@ -262,6 +258,7 @@ class CRM_Pledge_DAO_Pledge extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Type'),
           'description' => ts('FK to Financial Type'),
+          'where' => 'civicrm_pledge.financial_type_id',
           'table_name' => 'civicrm_pledge',
           'entity' => 'Pledge',
           'bao' => 'CRM_Pledge_BAO_Pledge',
@@ -281,6 +278,7 @@ class CRM_Pledge_DAO_Pledge extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Pledge Contribution Page'),
           'description' => ts('The Contribution Page which triggered this contribution'),
+          'where' => 'civicrm_pledge.contribution_page_id',
           'table_name' => 'civicrm_pledge',
           'entity' => 'Pledge',
           'bao' => 'CRM_Pledge_BAO_Pledge',
@@ -299,8 +297,6 @@ class CRM_Pledge_DAO_Pledge extends CRM_Core_DAO {
           ],
           'import' => TRUE,
           'where' => 'civicrm_pledge.amount',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_pledge',
           'entity' => 'Pledge',
@@ -320,10 +316,8 @@ class CRM_Pledge_DAO_Pledge extends CRM_Core_DAO {
             20,
             2
           ],
-          'export' => TRUE,
           'where' => 'civicrm_pledge.original_installment_amount',
-          'headerPattern' => '',
-          'dataPattern' => '',
+          'export' => TRUE,
           'table_name' => 'civicrm_pledge',
           'entity' => 'Pledge',
           'bao' => 'CRM_Pledge_BAO_Pledge',
@@ -339,6 +333,7 @@ class CRM_Pledge_DAO_Pledge extends CRM_Core_DAO {
           'description' => ts('3 character string, value from config setting or input via user.'),
           'maxlength' => 3,
           'size' => CRM_Utils_Type::FOUR,
+          'where' => 'civicrm_pledge.currency',
           'default' => 'NULL',
           'table_name' => 'civicrm_pledge',
           'entity' => 'Pledge',
@@ -361,6 +356,7 @@ class CRM_Pledge_DAO_Pledge extends CRM_Core_DAO {
           'description' => ts('Time units for recurrence of pledge payments.'),
           'maxlength' => 8,
           'size' => CRM_Utils_Type::EIGHT,
+          'where' => 'civicrm_pledge.frequency_unit',
           'default' => 'month',
           'table_name' => 'civicrm_pledge',
           'entity' => 'Pledge',
@@ -381,6 +377,7 @@ class CRM_Pledge_DAO_Pledge extends CRM_Core_DAO {
           'title' => ts('Pledge Frequency Interval'),
           'description' => ts('Number of time units for recurrence of pledge payments.'),
           'required' => TRUE,
+          'where' => 'civicrm_pledge.frequency_interval',
           'default' => '1',
           'table_name' => 'civicrm_pledge',
           'entity' => 'Pledge',
@@ -396,6 +393,7 @@ class CRM_Pledge_DAO_Pledge extends CRM_Core_DAO {
           'title' => ts('Pledge day'),
           'description' => ts('Day in the period when the pledge payment is due e.g. 1st of month, 15th etc. Use this to set the scheduled dates for pledge payments.'),
           'required' => TRUE,
+          'where' => 'civicrm_pledge.frequency_day',
           'default' => '3',
           'table_name' => 'civicrm_pledge',
           'entity' => 'Pledge',
@@ -410,10 +408,8 @@ class CRM_Pledge_DAO_Pledge extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Pledge Number of Installments'),
           'description' => ts('Total number of payments to be made.'),
-          'export' => TRUE,
           'where' => 'civicrm_pledge.installments',
-          'headerPattern' => '',
-          'dataPattern' => '',
+          'export' => TRUE,
           'default' => '1',
           'table_name' => 'civicrm_pledge',
           'entity' => 'Pledge',
@@ -429,6 +425,7 @@ class CRM_Pledge_DAO_Pledge extends CRM_Core_DAO {
           'title' => ts('Pledge Start Date'),
           'description' => ts('The date the first scheduled pledge occurs.'),
           'required' => TRUE,
+          'where' => 'civicrm_pledge.start_date',
           'table_name' => 'civicrm_pledge',
           'entity' => 'Pledge',
           'bao' => 'CRM_Pledge_BAO_Pledge',
@@ -445,8 +442,6 @@ class CRM_Pledge_DAO_Pledge extends CRM_Core_DAO {
           'required' => TRUE,
           'import' => TRUE,
           'where' => 'civicrm_pledge.create_date',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_pledge',
           'entity' => 'Pledge',
@@ -461,6 +456,7 @@ class CRM_Pledge_DAO_Pledge extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
           'title' => ts('Pledge Acknowledged'),
           'description' => ts('When a pledge acknowledgement message was sent to the contributor.'),
+          'where' => 'civicrm_pledge.acknowledge_date',
           'table_name' => 'civicrm_pledge',
           'entity' => 'Pledge',
           'bao' => 'CRM_Pledge_BAO_Pledge',
@@ -474,6 +470,7 @@ class CRM_Pledge_DAO_Pledge extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
           'title' => ts('Pledge Modified Date'),
           'description' => ts('Last updated date for this pledge record.'),
+          'where' => 'civicrm_pledge.modified_date',
           'table_name' => 'civicrm_pledge',
           'entity' => 'Pledge',
           'bao' => 'CRM_Pledge_BAO_Pledge',
@@ -484,6 +481,7 @@ class CRM_Pledge_DAO_Pledge extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
           'title' => ts('Pledge Cancelled Date'),
           'description' => ts('Date this pledge was cancelled by contributor.'),
+          'where' => 'civicrm_pledge.cancel_date',
           'table_name' => 'civicrm_pledge',
           'entity' => 'Pledge',
           'bao' => 'CRM_Pledge_BAO_Pledge',
@@ -497,6 +495,7 @@ class CRM_Pledge_DAO_Pledge extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
           'title' => ts('Pledge End Date'),
           'description' => ts('Date this pledge finished successfully (total pledge payments equal to or greater than pledged amount).'),
+          'where' => 'civicrm_pledge.end_date',
           'table_name' => 'civicrm_pledge',
           'entity' => 'Pledge',
           'bao' => 'CRM_Pledge_BAO_Pledge',
@@ -510,6 +509,7 @@ class CRM_Pledge_DAO_Pledge extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Maximum Number of Reminders'),
           'description' => ts('The maximum number of payment reminders to send for any given payment.'),
+          'where' => 'civicrm_pledge.max_reminders',
           'default' => '1',
           'table_name' => 'civicrm_pledge',
           'entity' => 'Pledge',
@@ -524,6 +524,7 @@ class CRM_Pledge_DAO_Pledge extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Initial Reminder Day'),
           'description' => ts('Send initial reminder this many days prior to the payment due date.'),
+          'where' => 'civicrm_pledge.initial_reminder_day',
           'default' => '5',
           'table_name' => 'civicrm_pledge',
           'entity' => 'Pledge',
@@ -538,6 +539,7 @@ class CRM_Pledge_DAO_Pledge extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Additional Reminder Days'),
           'description' => ts('Send additional reminder this many days after last one sent, up to maximum number of reminders.'),
+          'where' => 'civicrm_pledge.additional_reminder_day',
           'default' => '5',
           'table_name' => 'civicrm_pledge',
           'entity' => 'Pledge',
@@ -554,8 +556,6 @@ class CRM_Pledge_DAO_Pledge extends CRM_Core_DAO {
           'description' => ts('Implicit foreign key to civicrm_option_values in the pledge_status option group.'),
           'import' => TRUE,
           'where' => 'civicrm_pledge.status_id',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => FALSE,
           'table_name' => 'civicrm_pledge',
           'entity' => 'Pledge',
@@ -572,8 +572,6 @@ class CRM_Pledge_DAO_Pledge extends CRM_Core_DAO {
           'title' => ts('Test'),
           'import' => TRUE,
           'where' => 'civicrm_pledge.is_test',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'default' => '0',
           'table_name' => 'civicrm_pledge',
@@ -591,8 +589,6 @@ class CRM_Pledge_DAO_Pledge extends CRM_Core_DAO {
           'description' => ts('The campaign for which this pledge has been initiated.'),
           'import' => TRUE,
           'where' => 'civicrm_pledge.campaign_id',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_pledge',
           'entity' => 'Pledge',
diff --git a/civicrm/CRM/Pledge/DAO/PledgeBlock.php b/civicrm/CRM/Pledge/DAO/PledgeBlock.php
index 381f297a2c12b15b46e6e729bf00b475721257cc..e319da634e738b34ddd4224596713b526a66458b 100644
--- a/civicrm/CRM/Pledge/DAO/PledgeBlock.php
+++ b/civicrm/CRM/Pledge/DAO/PledgeBlock.php
@@ -142,6 +142,7 @@ class CRM_Pledge_DAO_PledgeBlock extends CRM_Core_DAO {
           'title' => ts('Pledge Block ID'),
           'description' => ts('Pledge ID'),
           'required' => TRUE,
+          'where' => 'civicrm_pledge_block.id',
           'table_name' => 'civicrm_pledge_block',
           'entity' => 'PledgeBlock',
           'bao' => 'CRM_Pledge_BAO_PledgeBlock',
@@ -154,6 +155,7 @@ class CRM_Pledge_DAO_PledgeBlock extends CRM_Core_DAO {
           'description' => ts('physical tablename for entity being joined to pledge, e.g. civicrm_contact'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_pledge_block.entity_table',
           'table_name' => 'civicrm_pledge_block',
           'entity' => 'PledgeBlock',
           'bao' => 'CRM_Pledge_BAO_PledgeBlock',
@@ -165,6 +167,7 @@ class CRM_Pledge_DAO_PledgeBlock extends CRM_Core_DAO {
           'title' => ts('Entity Id'),
           'description' => ts('FK to entity table specified in entity_table column.'),
           'required' => TRUE,
+          'where' => 'civicrm_pledge_block.entity_id',
           'table_name' => 'civicrm_pledge_block',
           'entity' => 'PledgeBlock',
           'bao' => 'CRM_Pledge_BAO_PledgeBlock',
@@ -177,6 +180,7 @@ class CRM_Pledge_DAO_PledgeBlock extends CRM_Core_DAO {
           'description' => ts('Delimited list of supported frequency units'),
           'maxlength' => 128,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_pledge_block.pledge_frequency_unit',
           'table_name' => 'civicrm_pledge_block',
           'entity' => 'PledgeBlock',
           'bao' => 'CRM_Pledge_BAO_PledgeBlock',
@@ -188,6 +192,7 @@ class CRM_Pledge_DAO_PledgeBlock extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Expose Frequency Interval?'),
           'description' => ts('Is frequency interval exposed on the contribution form.'),
+          'where' => 'civicrm_pledge_block.is_pledge_interval',
           'default' => '0',
           'table_name' => 'civicrm_pledge_block',
           'entity' => 'PledgeBlock',
@@ -199,6 +204,7 @@ class CRM_Pledge_DAO_PledgeBlock extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Maximum Number of Reminders'),
           'description' => ts('The maximum number of payment reminders to send for any given payment.'),
+          'where' => 'civicrm_pledge_block.max_reminders',
           'default' => '1',
           'table_name' => 'civicrm_pledge_block',
           'entity' => 'PledgeBlock',
@@ -210,6 +216,7 @@ class CRM_Pledge_DAO_PledgeBlock extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Initial Reminder Day'),
           'description' => ts('Send initial reminder this many days prior to the payment due date.'),
+          'where' => 'civicrm_pledge_block.initial_reminder_day',
           'default' => '5',
           'table_name' => 'civicrm_pledge_block',
           'entity' => 'PledgeBlock',
@@ -221,6 +228,7 @@ class CRM_Pledge_DAO_PledgeBlock extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Additional Reminder Days'),
           'description' => ts('Send additional reminder this many days after last one sent, up to maximum number of reminders.'),
+          'where' => 'civicrm_pledge_block.additional_reminder_day',
           'default' => '5',
           'table_name' => 'civicrm_pledge_block',
           'entity' => 'PledgeBlock',
@@ -234,6 +242,7 @@ class CRM_Pledge_DAO_PledgeBlock extends CRM_Core_DAO {
           'description' => ts('The date the first scheduled pledge occurs.'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_pledge_block.pledge_start_date',
           'table_name' => 'civicrm_pledge_block',
           'entity' => 'PledgeBlock',
           'bao' => 'CRM_Pledge_BAO_PledgeBlock',
@@ -245,6 +254,7 @@ class CRM_Pledge_DAO_PledgeBlock extends CRM_Core_DAO {
           'title' => ts('Show Recurring Donation Start Date?'),
           'description' => ts('If true - recurring start date is shown.'),
           'required' => TRUE,
+          'where' => 'civicrm_pledge_block.is_pledge_start_date_visible',
           'default' => '0',
           'table_name' => 'civicrm_pledge_block',
           'entity' => 'PledgeBlock',
@@ -257,6 +267,7 @@ class CRM_Pledge_DAO_PledgeBlock extends CRM_Core_DAO {
           'title' => ts('Allow Edits to Recurring Donation Start Date?'),
           'description' => ts('If true - recurring start date is editable.'),
           'required' => TRUE,
+          'where' => 'civicrm_pledge_block.is_pledge_start_date_editable',
           'default' => '0',
           'table_name' => 'civicrm_pledge_block',
           'entity' => 'PledgeBlock',
diff --git a/civicrm/CRM/Pledge/DAO/PledgePayment.php b/civicrm/CRM/Pledge/DAO/PledgePayment.php
index d43a0f779135a5dfdfa3efa206db40b81ad44b1b..f3d80a9327e79e6899c8877191d1477f9aa0b1d4 100644
--- a/civicrm/CRM/Pledge/DAO/PledgePayment.php
+++ b/civicrm/CRM/Pledge/DAO/PledgePayment.php
@@ -133,8 +133,6 @@ class CRM_Pledge_DAO_PledgePayment extends CRM_Core_DAO {
           'required' => TRUE,
           'import' => TRUE,
           'where' => 'civicrm_pledge_payment.id',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_pledge_payment',
           'entity' => 'PledgePayment',
@@ -147,6 +145,7 @@ class CRM_Pledge_DAO_PledgePayment extends CRM_Core_DAO {
           'title' => ts('Pledge'),
           'description' => ts('FK to Pledge table'),
           'required' => TRUE,
+          'where' => 'civicrm_pledge_payment.pledge_id',
           'table_name' => 'civicrm_pledge_payment',
           'entity' => 'PledgePayment',
           'bao' => 'CRM_Pledge_BAO_PledgePayment',
@@ -158,6 +157,7 @@ class CRM_Pledge_DAO_PledgePayment extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Contribution'),
           'description' => ts('FK to contribution table.'),
+          'where' => 'civicrm_pledge_payment.contribution_id',
           'table_name' => 'civicrm_pledge_payment',
           'entity' => 'PledgePayment',
           'bao' => 'CRM_Pledge_BAO_PledgePayment',
@@ -176,8 +176,6 @@ class CRM_Pledge_DAO_PledgePayment extends CRM_Core_DAO {
           ],
           'import' => TRUE,
           'where' => 'civicrm_pledge_payment.scheduled_amount',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_pledge_payment',
           'entity' => 'PledgePayment',
@@ -195,8 +193,6 @@ class CRM_Pledge_DAO_PledgePayment extends CRM_Core_DAO {
           ],
           'import' => TRUE,
           'where' => 'civicrm_pledge_payment.actual_amount',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_pledge_payment',
           'entity' => 'PledgePayment',
@@ -210,6 +206,7 @@ class CRM_Pledge_DAO_PledgePayment extends CRM_Core_DAO {
           'description' => ts('3 character string, value from config setting or input via user.'),
           'maxlength' => 3,
           'size' => CRM_Utils_Type::FOUR,
+          'where' => 'civicrm_pledge_payment.currency',
           'default' => 'NULL',
           'table_name' => 'civicrm_pledge_payment',
           'entity' => 'PledgePayment',
@@ -233,8 +230,6 @@ class CRM_Pledge_DAO_PledgePayment extends CRM_Core_DAO {
           'required' => TRUE,
           'import' => TRUE,
           'where' => 'civicrm_pledge_payment.scheduled_date',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_pledge_payment',
           'entity' => 'PledgePayment',
@@ -252,8 +247,6 @@ class CRM_Pledge_DAO_PledgePayment extends CRM_Core_DAO {
           'description' => ts('The date that the most recent payment reminder was sent.'),
           'import' => TRUE,
           'where' => 'civicrm_pledge_payment.reminder_date',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_pledge_payment',
           'entity' => 'PledgePayment',
@@ -267,8 +260,6 @@ class CRM_Pledge_DAO_PledgePayment extends CRM_Core_DAO {
           'description' => ts('The number of payment reminders sent.'),
           'import' => TRUE,
           'where' => 'civicrm_pledge_payment.reminder_count',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'default' => '0',
           'table_name' => 'civicrm_pledge_payment',
@@ -282,8 +273,6 @@ class CRM_Pledge_DAO_PledgePayment extends CRM_Core_DAO {
           'title' => ts('Payment Status'),
           'import' => TRUE,
           'where' => 'civicrm_pledge_payment.status_id',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => FALSE,
           'table_name' => 'civicrm_pledge_payment',
           'entity' => 'PledgePayment',
diff --git a/civicrm/CRM/Price/DAO/LineItem.php b/civicrm/CRM/Price/DAO/LineItem.php
index 40dbb3f9996ceffe955f48623267923bd4182376..8d7ae16d29616b0a95d2a619f7142a9eebe522c1 100644
--- a/civicrm/CRM/Price/DAO/LineItem.php
+++ b/civicrm/CRM/Price/DAO/LineItem.php
@@ -167,6 +167,7 @@ class CRM_Price_DAO_LineItem extends CRM_Core_DAO {
           'title' => ts('Line Item ID'),
           'description' => ts('Line Item'),
           'required' => TRUE,
+          'where' => 'civicrm_line_item.id',
           'table_name' => 'civicrm_line_item',
           'entity' => 'LineItem',
           'bao' => 'CRM_Price_BAO_LineItem',
@@ -180,6 +181,7 @@ class CRM_Price_DAO_LineItem extends CRM_Core_DAO {
           'required' => TRUE,
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_line_item.entity_table',
           'table_name' => 'civicrm_line_item',
           'entity' => 'LineItem',
           'bao' => 'CRM_Price_BAO_LineItem',
@@ -191,6 +193,7 @@ class CRM_Price_DAO_LineItem extends CRM_Core_DAO {
           'title' => ts('Line Item Entity'),
           'description' => ts('entry in table'),
           'required' => TRUE,
+          'where' => 'civicrm_line_item.entity_id',
           'table_name' => 'civicrm_line_item',
           'entity' => 'LineItem',
           'bao' => 'CRM_Price_BAO_LineItem',
@@ -201,6 +204,7 @@ class CRM_Price_DAO_LineItem extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Line Item Contribution'),
           'description' => ts('FK to civicrm_contribution'),
+          'where' => 'civicrm_line_item.contribution_id',
           'table_name' => 'civicrm_line_item',
           'entity' => 'LineItem',
           'bao' => 'CRM_Price_BAO_LineItem',
@@ -212,6 +216,7 @@ class CRM_Price_DAO_LineItem extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Line Item Price Field'),
           'description' => ts('FK to civicrm_price_field'),
+          'where' => 'civicrm_line_item.price_field_id',
           'table_name' => 'civicrm_line_item',
           'entity' => 'LineItem',
           'bao' => 'CRM_Price_BAO_LineItem',
@@ -225,6 +230,7 @@ class CRM_Price_DAO_LineItem extends CRM_Core_DAO {
           'description' => ts('descriptive label for item - from price_field_value.label'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_line_item.label',
           'default' => 'NULL',
           'table_name' => 'civicrm_line_item',
           'entity' => 'LineItem',
@@ -244,6 +250,7 @@ class CRM_Price_DAO_LineItem extends CRM_Core_DAO {
             20,
             2
           ],
+          'where' => 'civicrm_line_item.qty',
           'table_name' => 'civicrm_line_item',
           'entity' => 'LineItem',
           'bao' => 'CRM_Price_BAO_LineItem',
@@ -262,6 +269,7 @@ class CRM_Price_DAO_LineItem extends CRM_Core_DAO {
             20,
             2
           ],
+          'where' => 'civicrm_line_item.unit_price',
           'table_name' => 'civicrm_line_item',
           'entity' => 'LineItem',
           'bao' => 'CRM_Price_BAO_LineItem',
@@ -280,6 +288,7 @@ class CRM_Price_DAO_LineItem extends CRM_Core_DAO {
             20,
             2
           ],
+          'where' => 'civicrm_line_item.line_total',
           'table_name' => 'civicrm_line_item',
           'entity' => 'LineItem',
           'bao' => 'CRM_Price_BAO_LineItem',
@@ -290,6 +299,7 @@ class CRM_Price_DAO_LineItem extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Line Item Participant Count'),
           'description' => ts('Participant count for field'),
+          'where' => 'civicrm_line_item.participant_count',
           'default' => 'NULL',
           'table_name' => 'civicrm_line_item',
           'entity' => 'LineItem',
@@ -304,6 +314,7 @@ class CRM_Price_DAO_LineItem extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Line Item Option'),
           'description' => ts('FK to civicrm_price_field_value'),
+          'where' => 'civicrm_line_item.price_field_value_id',
           'default' => 'NULL',
           'table_name' => 'civicrm_line_item',
           'entity' => 'LineItem',
@@ -316,6 +327,7 @@ class CRM_Price_DAO_LineItem extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Financial Type'),
           'description' => ts('FK to Financial Type.'),
+          'where' => 'civicrm_line_item.financial_type_id',
           'default' => 'NULL',
           'table_name' => 'civicrm_line_item',
           'entity' => 'LineItem',
@@ -341,6 +353,9 @@ class CRM_Price_DAO_LineItem extends CRM_Core_DAO {
             20,
             2
           ],
+          'where' => 'civicrm_line_item.non_deductible_amount',
+          'headerPattern' => '/non?.?deduct/i',
+          'dataPattern' => '/^\d+(\.\d{2})?$/',
           'default' => '0.0',
           'table_name' => 'civicrm_line_item',
           'entity' => 'LineItem',
diff --git a/civicrm/CRM/Price/DAO/PriceField.php b/civicrm/CRM/Price/DAO/PriceField.php
index 6211831f0b289fb0e69bf8128706e3e3fc76fddd..8f825a193812b14c0b48c47f5edc3032d4ada05c 100644
--- a/civicrm/CRM/Price/DAO/PriceField.php
+++ b/civicrm/CRM/Price/DAO/PriceField.php
@@ -182,6 +182,7 @@ class CRM_Price_DAO_PriceField extends CRM_Core_DAO {
           'title' => ts('Price Field ID'),
           'description' => ts('Price Field'),
           'required' => TRUE,
+          'where' => 'civicrm_price_field.id',
           'table_name' => 'civicrm_price_field',
           'entity' => 'PriceField',
           'bao' => 'CRM_Price_BAO_PriceField',
@@ -193,6 +194,7 @@ class CRM_Price_DAO_PriceField extends CRM_Core_DAO {
           'title' => ts('Price Set'),
           'description' => ts('FK to civicrm_price_set'),
           'required' => TRUE,
+          'where' => 'civicrm_price_field.price_set_id',
           'table_name' => 'civicrm_price_field',
           'entity' => 'PriceField',
           'bao' => 'CRM_Price_BAO_PriceField',
@@ -207,6 +209,7 @@ class CRM_Price_DAO_PriceField extends CRM_Core_DAO {
           'required' => TRUE,
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_price_field.name',
           'table_name' => 'civicrm_price_field',
           'entity' => 'PriceField',
           'bao' => 'CRM_Price_BAO_PriceField',
@@ -223,6 +226,7 @@ class CRM_Price_DAO_PriceField extends CRM_Core_DAO {
           'required' => TRUE,
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_price_field.label',
           'table_name' => 'civicrm_price_field',
           'entity' => 'PriceField',
           'bao' => 'CRM_Price_BAO_PriceField',
@@ -238,6 +242,7 @@ class CRM_Price_DAO_PriceField extends CRM_Core_DAO {
           'required' => TRUE,
           'maxlength' => 12,
           'size' => CRM_Utils_Type::TWELVE,
+          'where' => 'civicrm_price_field.html_type',
           'table_name' => 'civicrm_price_field',
           'entity' => 'PriceField',
           'bao' => 'CRM_Price_BAO_PriceField',
@@ -254,6 +259,7 @@ class CRM_Price_DAO_PriceField extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Price Field Quantity Required?'),
           'description' => ts('Enter a quantity for this field?'),
+          'where' => 'civicrm_price_field.is_enter_qty',
           'default' => '0',
           'table_name' => 'civicrm_price_field',
           'entity' => 'PriceField',
@@ -270,6 +276,7 @@ class CRM_Price_DAO_PriceField extends CRM_Core_DAO {
           'description' => ts('Description and/or help text to display before this field.'),
           'rows' => 4,
           'cols' => 80,
+          'where' => 'civicrm_price_field.help_pre',
           'table_name' => 'civicrm_price_field',
           'entity' => 'PriceField',
           'bao' => 'CRM_Price_BAO_PriceField',
@@ -285,6 +292,7 @@ class CRM_Price_DAO_PriceField extends CRM_Core_DAO {
           'description' => ts('Description and/or help text to display after this field.'),
           'rows' => 4,
           'cols' => 80,
+          'where' => 'civicrm_price_field.help_post',
           'table_name' => 'civicrm_price_field',
           'entity' => 'PriceField',
           'bao' => 'CRM_Price_BAO_PriceField',
@@ -298,6 +306,7 @@ class CRM_Price_DAO_PriceField extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Order'),
           'description' => ts('Order in which the fields should appear'),
+          'where' => 'civicrm_price_field.weight',
           'default' => '1',
           'table_name' => 'civicrm_price_field',
           'entity' => 'PriceField',
@@ -312,6 +321,7 @@ class CRM_Price_DAO_PriceField extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Price Field Show Amounts?'),
           'description' => ts('Should the price be displayed next to the label for each option?'),
+          'where' => 'civicrm_price_field.is_display_amounts',
           'default' => '1',
           'table_name' => 'civicrm_price_field',
           'entity' => 'PriceField',
@@ -326,6 +336,7 @@ class CRM_Price_DAO_PriceField extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Price Field Options per Row'),
           'description' => ts('number of options per line for checkbox and radio'),
+          'where' => 'civicrm_price_field.options_per_line',
           'default' => '1',
           'table_name' => 'civicrm_price_field',
           'entity' => 'PriceField',
@@ -340,6 +351,7 @@ class CRM_Price_DAO_PriceField extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Price Field Is Active?'),
           'description' => ts('Is this price field active'),
+          'where' => 'civicrm_price_field.is_active',
           'default' => '1',
           'table_name' => 'civicrm_price_field',
           'entity' => 'PriceField',
@@ -354,6 +366,7 @@ class CRM_Price_DAO_PriceField extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Price Field is Required?'),
           'description' => ts('Is this price field required (value must be > 1)'),
+          'where' => 'civicrm_price_field.is_required',
           'default' => '1',
           'table_name' => 'civicrm_price_field',
           'entity' => 'PriceField',
@@ -368,6 +381,7 @@ class CRM_Price_DAO_PriceField extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
           'title' => ts('Price Field Start Date'),
           'description' => ts('If non-zero, do not show this field before the date specified'),
+          'where' => 'civicrm_price_field.active_on',
           'default' => 'NULL',
           'table_name' => 'civicrm_price_field',
           'entity' => 'PriceField',
@@ -383,6 +397,7 @@ class CRM_Price_DAO_PriceField extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
           'title' => ts('Price Field End Date'),
           'description' => ts('If non-zero, do not show this field after the date specified'),
+          'where' => 'civicrm_price_field.expire_on',
           'default' => 'NULL',
           'table_name' => 'civicrm_price_field',
           'entity' => 'PriceField',
@@ -400,6 +415,7 @@ class CRM_Price_DAO_PriceField extends CRM_Core_DAO {
           'description' => ts('Optional scripting attributes for field'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_price_field.javascript',
           'table_name' => 'civicrm_price_field',
           'entity' => 'PriceField',
           'bao' => 'CRM_Price_BAO_PriceField',
@@ -413,6 +429,7 @@ class CRM_Price_DAO_PriceField extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Price Field Visibility'),
           'description' => ts('Implicit FK to civicrm_option_group with name = \'visibility\''),
+          'where' => 'civicrm_price_field.visibility_id',
           'default' => '1',
           'table_name' => 'civicrm_price_field',
           'entity' => 'PriceField',
diff --git a/civicrm/CRM/Price/DAO/PriceFieldValue.php b/civicrm/CRM/Price/DAO/PriceFieldValue.php
index c449711499b959c78c18f13dc031aa7762cc1ce2..bd6f7daa200124a763dca072396cdb0b3eab5f0c 100644
--- a/civicrm/CRM/Price/DAO/PriceFieldValue.php
+++ b/civicrm/CRM/Price/DAO/PriceFieldValue.php
@@ -193,6 +193,7 @@ class CRM_Price_DAO_PriceFieldValue extends CRM_Core_DAO {
           'title' => ts('Price Field Value ID'),
           'description' => ts('Price Field Value'),
           'required' => TRUE,
+          'where' => 'civicrm_price_field_value.id',
           'table_name' => 'civicrm_price_field_value',
           'entity' => 'PriceFieldValue',
           'bao' => 'CRM_Price_BAO_PriceFieldValue',
@@ -204,6 +205,7 @@ class CRM_Price_DAO_PriceFieldValue extends CRM_Core_DAO {
           'title' => ts('Price Field'),
           'description' => ts('FK to civicrm_price_field'),
           'required' => TRUE,
+          'where' => 'civicrm_price_field_value.price_field_id',
           'table_name' => 'civicrm_price_field_value',
           'entity' => 'PriceFieldValue',
           'bao' => 'CRM_Price_BAO_PriceFieldValue',
@@ -217,6 +219,7 @@ class CRM_Price_DAO_PriceFieldValue extends CRM_Core_DAO {
           'description' => ts('Price field option name'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_price_field_value.name',
           'table_name' => 'civicrm_price_field_value',
           'entity' => 'PriceFieldValue',
           'bao' => 'CRM_Price_BAO_PriceFieldValue',
@@ -232,6 +235,7 @@ class CRM_Price_DAO_PriceFieldValue extends CRM_Core_DAO {
           'description' => ts('Price field option label'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_price_field_value.label',
           'table_name' => 'civicrm_price_field_value',
           'entity' => 'PriceFieldValue',
           'bao' => 'CRM_Price_BAO_PriceFieldValue',
@@ -247,6 +251,7 @@ class CRM_Price_DAO_PriceFieldValue extends CRM_Core_DAO {
           'description' => ts('Price field option description.'),
           'rows' => 2,
           'cols' => 60,
+          'where' => 'civicrm_price_field_value.description',
           'default' => 'NULL',
           'table_name' => 'civicrm_price_field_value',
           'entity' => 'PriceFieldValue',
@@ -263,6 +268,7 @@ class CRM_Price_DAO_PriceFieldValue extends CRM_Core_DAO {
           'description' => ts('Price field option pre help text.'),
           'rows' => 2,
           'cols' => 60,
+          'where' => 'civicrm_price_field_value.help_pre',
           'default' => 'NULL',
           'table_name' => 'civicrm_price_field_value',
           'entity' => 'PriceFieldValue',
@@ -279,6 +285,7 @@ class CRM_Price_DAO_PriceFieldValue extends CRM_Core_DAO {
           'description' => ts('Price field option post field help.'),
           'rows' => 2,
           'cols' => 60,
+          'where' => 'civicrm_price_field_value.help_post',
           'default' => 'NULL',
           'table_name' => 'civicrm_price_field_value',
           'entity' => 'PriceFieldValue',
@@ -298,6 +305,7 @@ class CRM_Price_DAO_PriceFieldValue extends CRM_Core_DAO {
             18,
             9
           ],
+          'where' => 'civicrm_price_field_value.amount',
           'table_name' => 'civicrm_price_field_value',
           'entity' => 'PriceFieldValue',
           'bao' => 'CRM_Price_BAO_PriceFieldValue',
@@ -311,6 +319,7 @@ class CRM_Price_DAO_PriceFieldValue extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Count'),
           'description' => ts('Number of participants per field option'),
+          'where' => 'civicrm_price_field_value.count',
           'default' => 'NULL',
           'table_name' => 'civicrm_price_field_value',
           'entity' => 'PriceFieldValue',
@@ -325,6 +334,7 @@ class CRM_Price_DAO_PriceFieldValue extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Max Value'),
           'description' => ts('Max number of participants per field options'),
+          'where' => 'civicrm_price_field_value.max_value',
           'default' => 'NULL',
           'table_name' => 'civicrm_price_field_value',
           'entity' => 'PriceFieldValue',
@@ -339,6 +349,7 @@ class CRM_Price_DAO_PriceFieldValue extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Order'),
           'description' => ts('Order in which the field options should appear'),
+          'where' => 'civicrm_price_field_value.weight',
           'default' => '1',
           'table_name' => 'civicrm_price_field_value',
           'entity' => 'PriceFieldValue',
@@ -353,6 +364,7 @@ class CRM_Price_DAO_PriceFieldValue extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Membership Type'),
           'description' => ts('FK to Membership Type'),
+          'where' => 'civicrm_price_field_value.membership_type_id',
           'default' => 'NULL',
           'table_name' => 'civicrm_price_field_value',
           'entity' => 'PriceFieldValue',
@@ -368,6 +380,7 @@ class CRM_Price_DAO_PriceFieldValue extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Membership Num Terms'),
           'description' => ts('Number of terms for this membership'),
+          'where' => 'civicrm_price_field_value.membership_num_terms',
           'default' => 'NULL',
           'table_name' => 'civicrm_price_field_value',
           'entity' => 'PriceFieldValue',
@@ -382,6 +395,7 @@ class CRM_Price_DAO_PriceFieldValue extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Is Default Price Field Option?'),
           'description' => ts('Is this default price field option'),
+          'where' => 'civicrm_price_field_value.is_default',
           'default' => '0',
           'table_name' => 'civicrm_price_field_value',
           'entity' => 'PriceFieldValue',
@@ -396,6 +410,7 @@ class CRM_Price_DAO_PriceFieldValue extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Price Field Value is Active'),
           'description' => ts('Is this price field value active'),
+          'where' => 'civicrm_price_field_value.is_active',
           'default' => '1',
           'table_name' => 'civicrm_price_field_value',
           'entity' => 'PriceFieldValue',
@@ -407,6 +422,7 @@ class CRM_Price_DAO_PriceFieldValue extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Financial Type'),
           'description' => ts('FK to Financial Type.'),
+          'where' => 'civicrm_price_field_value.financial_type_id',
           'default' => 'NULL',
           'table_name' => 'civicrm_price_field_value',
           'entity' => 'PriceFieldValue',
@@ -432,6 +448,9 @@ class CRM_Price_DAO_PriceFieldValue extends CRM_Core_DAO {
             20,
             2
           ],
+          'where' => 'civicrm_price_field_value.non_deductible_amount',
+          'headerPattern' => '/non?.?deduct/i',
+          'dataPattern' => '/^\d+(\.\d{2})?$/',
           'default' => '0.0',
           'table_name' => 'civicrm_price_field_value',
           'entity' => 'PriceFieldValue',
@@ -446,6 +465,7 @@ class CRM_Price_DAO_PriceFieldValue extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Price Field Option Visibility'),
           'description' => ts('Implicit FK to civicrm_option_group with name = \'visibility\''),
+          'where' => 'civicrm_price_field_value.visibility_id',
           'default' => '1',
           'table_name' => 'civicrm_price_field_value',
           'entity' => 'PriceFieldValue',
diff --git a/civicrm/CRM/Price/DAO/PriceSet.php b/civicrm/CRM/Price/DAO/PriceSet.php
index ed8c4d685b866a874250d51feb17c12287583334..ae2e04ef8ea421b5b210664887a91d97ffda46e2 100644
--- a/civicrm/CRM/Price/DAO/PriceSet.php
+++ b/civicrm/CRM/Price/DAO/PriceSet.php
@@ -157,6 +157,7 @@ class CRM_Price_DAO_PriceSet extends CRM_Core_DAO {
           'title' => ts('Price Set ID'),
           'description' => ts('Price Set'),
           'required' => TRUE,
+          'where' => 'civicrm_price_set.id',
           'table_name' => 'civicrm_price_set',
           'entity' => 'PriceSet',
           'bao' => 'CRM_Price_BAO_PriceSet',
@@ -167,6 +168,7 @@ class CRM_Price_DAO_PriceSet extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Price Set Domain'),
           'description' => ts('Which Domain is this price-set for'),
+          'where' => 'civicrm_price_set.domain_id',
           'table_name' => 'civicrm_price_set',
           'entity' => 'PriceSet',
           'bao' => 'CRM_Price_BAO_PriceSet',
@@ -189,6 +191,7 @@ class CRM_Price_DAO_PriceSet extends CRM_Core_DAO {
           'required' => TRUE,
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_price_set.name',
           'table_name' => 'civicrm_price_set',
           'entity' => 'PriceSet',
           'bao' => 'CRM_Price_BAO_PriceSet',
@@ -205,6 +208,7 @@ class CRM_Price_DAO_PriceSet extends CRM_Core_DAO {
           'required' => TRUE,
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_price_set.title',
           'table_name' => 'civicrm_price_set',
           'entity' => 'PriceSet',
           'bao' => 'CRM_Price_BAO_PriceSet',
@@ -218,6 +222,7 @@ class CRM_Price_DAO_PriceSet extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Price Set Is Active?'),
           'description' => ts('Is this price set active'),
+          'where' => 'civicrm_price_set.is_active',
           'default' => '1',
           'table_name' => 'civicrm_price_set',
           'entity' => 'PriceSet',
@@ -234,6 +239,7 @@ class CRM_Price_DAO_PriceSet extends CRM_Core_DAO {
           'description' => ts('Description and/or help text to display before fields in form.'),
           'rows' => 4,
           'cols' => 80,
+          'where' => 'civicrm_price_set.help_pre',
           'table_name' => 'civicrm_price_set',
           'entity' => 'PriceSet',
           'bao' => 'CRM_Price_BAO_PriceSet',
@@ -249,6 +255,7 @@ class CRM_Price_DAO_PriceSet extends CRM_Core_DAO {
           'description' => ts('Description and/or help text to display after fields in form.'),
           'rows' => 4,
           'cols' => 80,
+          'where' => 'civicrm_price_set.help_post',
           'table_name' => 'civicrm_price_set',
           'entity' => 'PriceSet',
           'bao' => 'CRM_Price_BAO_PriceSet',
@@ -264,6 +271,7 @@ class CRM_Price_DAO_PriceSet extends CRM_Core_DAO {
           'description' => ts('Optional Javascript script function(s) included on the form with this price_set. Can be used for conditional'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_price_set.javascript',
           'table_name' => 'civicrm_price_set',
           'entity' => 'PriceSet',
           'bao' => 'CRM_Price_BAO_PriceSet',
@@ -280,6 +288,7 @@ class CRM_Price_DAO_PriceSet extends CRM_Core_DAO {
           'required' => TRUE,
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_price_set.extends',
           'table_name' => 'civicrm_price_set',
           'entity' => 'PriceSet',
           'bao' => 'CRM_Price_BAO_PriceSet',
@@ -298,6 +307,7 @@ class CRM_Price_DAO_PriceSet extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Financial Type'),
           'description' => ts('FK to Financial Type(for membership price sets only).'),
+          'where' => 'civicrm_price_set.financial_type_id',
           'default' => 'NULL',
           'table_name' => 'civicrm_price_set',
           'entity' => 'PriceSet',
@@ -318,6 +328,7 @@ class CRM_Price_DAO_PriceSet extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Is Price Set Quick Config?'),
           'description' => ts('Is set if edited on Contribution or Event Page rather than through Manage Price Sets'),
+          'where' => 'civicrm_price_set.is_quick_config',
           'default' => '0',
           'table_name' => 'civicrm_price_set',
           'entity' => 'PriceSet',
@@ -332,6 +343,7 @@ class CRM_Price_DAO_PriceSet extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Price Set Is Reserved'),
           'description' => ts('Is this a predefined system price set  (i.e. it can not be deleted, edited)?'),
+          'where' => 'civicrm_price_set.is_reserved',
           'default' => '0',
           'table_name' => 'civicrm_price_set',
           'entity' => 'PriceSet',
@@ -346,6 +358,7 @@ class CRM_Price_DAO_PriceSet extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Minimum Amount'),
           'description' => ts('Minimum Amount required for this set.'),
+          'where' => 'civicrm_price_set.min_amount',
           'default' => '0',
           'table_name' => 'civicrm_price_set',
           'entity' => 'PriceSet',
diff --git a/civicrm/CRM/Price/DAO/PriceSetEntity.php b/civicrm/CRM/Price/DAO/PriceSetEntity.php
index 0bef5929d79bb523bfaf4b3e81ae59e1ce852bfb..c665acc98a64b2ac112c7f3a03d9d29afb3c0903 100644
--- a/civicrm/CRM/Price/DAO/PriceSetEntity.php
+++ b/civicrm/CRM/Price/DAO/PriceSetEntity.php
@@ -94,6 +94,7 @@ class CRM_Price_DAO_PriceSetEntity extends CRM_Core_DAO {
           'title' => ts('Price Set Entity ID'),
           'description' => ts('Price Set Entity'),
           'required' => TRUE,
+          'where' => 'civicrm_price_set_entity.id',
           'table_name' => 'civicrm_price_set_entity',
           'entity' => 'PriceSetEntity',
           'bao' => 'CRM_Price_DAO_PriceSetEntity',
@@ -107,6 +108,7 @@ class CRM_Price_DAO_PriceSetEntity extends CRM_Core_DAO {
           'required' => TRUE,
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_price_set_entity.entity_table',
           'table_name' => 'civicrm_price_set_entity',
           'entity' => 'PriceSetEntity',
           'bao' => 'CRM_Price_DAO_PriceSetEntity',
@@ -118,6 +120,7 @@ class CRM_Price_DAO_PriceSetEntity extends CRM_Core_DAO {
           'title' => ts('Entity IF'),
           'description' => ts('Item in table'),
           'required' => TRUE,
+          'where' => 'civicrm_price_set_entity.entity_id',
           'table_name' => 'civicrm_price_set_entity',
           'entity' => 'PriceSetEntity',
           'bao' => 'CRM_Price_DAO_PriceSetEntity',
@@ -129,6 +132,7 @@ class CRM_Price_DAO_PriceSetEntity extends CRM_Core_DAO {
           'title' => ts('Price Set'),
           'description' => ts('price set being used'),
           'required' => TRUE,
+          'where' => 'civicrm_price_set_entity.price_set_id',
           'table_name' => 'civicrm_price_set_entity',
           'entity' => 'PriceSetEntity',
           'bao' => 'CRM_Price_DAO_PriceSetEntity',
diff --git a/civicrm/CRM/Queue/DAO/QueueItem.php b/civicrm/CRM/Queue/DAO/QueueItem.php
index 9c54006cbd8820d0f7b3743737f7126bf49f1f16..de2e97635b089e5670415ffa4b7b8e6bf0c6057b 100644
--- a/civicrm/CRM/Queue/DAO/QueueItem.php
+++ b/civicrm/CRM/Queue/DAO/QueueItem.php
@@ -87,6 +87,7 @@ class CRM_Queue_DAO_QueueItem extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Queue ID'),
           'required' => TRUE,
+          'where' => 'civicrm_queue_item.id',
           'table_name' => 'civicrm_queue_item',
           'entity' => 'QueueItem',
           'bao' => 'CRM_Queue_BAO_QueueItem',
@@ -100,6 +101,7 @@ class CRM_Queue_DAO_QueueItem extends CRM_Core_DAO {
           'required' => TRUE,
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_queue_item.queue_name',
           'table_name' => 'civicrm_queue_item',
           'entity' => 'QueueItem',
           'bao' => 'CRM_Queue_BAO_QueueItem',
@@ -113,6 +115,7 @@ class CRM_Queue_DAO_QueueItem extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Order'),
           'required' => TRUE,
+          'where' => 'civicrm_queue_item.weight',
           'table_name' => 'civicrm_queue_item',
           'entity' => 'QueueItem',
           'bao' => 'CRM_Queue_BAO_QueueItem',
@@ -127,6 +130,7 @@ class CRM_Queue_DAO_QueueItem extends CRM_Core_DAO {
           'title' => ts('Submit Time'),
           'description' => ts('date on which this item was submitted to the queue'),
           'required' => TRUE,
+          'where' => 'civicrm_queue_item.submit_time',
           'table_name' => 'civicrm_queue_item',
           'entity' => 'QueueItem',
           'bao' => 'CRM_Queue_BAO_QueueItem',
@@ -140,6 +144,7 @@ class CRM_Queue_DAO_QueueItem extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
           'title' => ts('Release Time'),
           'description' => ts('date on which this job becomes available; null if ASAP'),
+          'where' => 'civicrm_queue_item.release_time',
           'table_name' => 'civicrm_queue_item',
           'entity' => 'QueueItem',
           'bao' => 'CRM_Queue_BAO_QueueItem',
@@ -153,6 +158,7 @@ class CRM_Queue_DAO_QueueItem extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_TEXT,
           'title' => ts('Queue item data'),
           'description' => ts('Serialized queue data'),
+          'where' => 'civicrm_queue_item.data',
           'table_name' => 'civicrm_queue_item',
           'entity' => 'QueueItem',
           'bao' => 'CRM_Queue_BAO_QueueItem',
diff --git a/civicrm/CRM/Report/DAO/ReportInstance.php b/civicrm/CRM/Report/DAO/ReportInstance.php
index bd2d42c3ef4d0f9be9ded25b0816147b16df33c3..1d5eae4979ed48eeb9d09a3ae47797f2b38cd512 100644
--- a/civicrm/CRM/Report/DAO/ReportInstance.php
+++ b/civicrm/CRM/Report/DAO/ReportInstance.php
@@ -214,6 +214,7 @@ class CRM_Report_DAO_ReportInstance extends CRM_Core_DAO {
           'title' => ts('Report Instance ID'),
           'description' => ts('Report Instance ID'),
           'required' => TRUE,
+          'where' => 'civicrm_report_instance.id',
           'table_name' => 'civicrm_report_instance',
           'entity' => 'ReportInstance',
           'bao' => 'CRM_Report_BAO_ReportInstance',
@@ -225,6 +226,7 @@ class CRM_Report_DAO_ReportInstance extends CRM_Core_DAO {
           'title' => ts('Report Instance Domain ID'),
           'description' => ts('Which Domain is this instance for'),
           'required' => TRUE,
+          'where' => 'civicrm_report_instance.domain_id',
           'table_name' => 'civicrm_report_instance',
           'entity' => 'ReportInstance',
           'bao' => 'CRM_Report_BAO_ReportInstance',
@@ -243,6 +245,7 @@ class CRM_Report_DAO_ReportInstance extends CRM_Core_DAO {
           'description' => ts('Report Instance Title.'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_report_instance.title',
           'table_name' => 'civicrm_report_instance',
           'entity' => 'ReportInstance',
           'bao' => 'CRM_Report_BAO_ReportInstance',
@@ -259,6 +262,7 @@ class CRM_Report_DAO_ReportInstance extends CRM_Core_DAO {
           'required' => TRUE,
           'maxlength' => 512,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_report_instance.report_id',
           'table_name' => 'civicrm_report_instance',
           'entity' => 'ReportInstance',
           'bao' => 'CRM_Report_BAO_ReportInstance',
@@ -274,6 +278,7 @@ class CRM_Report_DAO_ReportInstance extends CRM_Core_DAO {
           'description' => ts('when combined with report_id/template uniquely identifies the instance'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_report_instance.name',
           'table_name' => 'civicrm_report_instance',
           'entity' => 'ReportInstance',
           'bao' => 'CRM_Report_BAO_ReportInstance',
@@ -289,6 +294,7 @@ class CRM_Report_DAO_ReportInstance extends CRM_Core_DAO {
           'description' => ts('arguments that are passed in the url when invoking the instance'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_report_instance.args',
           'table_name' => 'civicrm_report_instance',
           'entity' => 'ReportInstance',
           'bao' => 'CRM_Report_BAO_ReportInstance',
@@ -304,6 +310,7 @@ class CRM_Report_DAO_ReportInstance extends CRM_Core_DAO {
           'description' => ts('Report Instance description.'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_report_instance.description',
           'table_name' => 'civicrm_report_instance',
           'entity' => 'ReportInstance',
           'bao' => 'CRM_Report_BAO_ReportInstance',
@@ -319,6 +326,7 @@ class CRM_Report_DAO_ReportInstance extends CRM_Core_DAO {
           'description' => ts('permission required to be able to run this instance'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_report_instance.permission',
           'table_name' => 'civicrm_report_instance',
           'entity' => 'ReportInstance',
           'bao' => 'CRM_Report_BAO_ReportInstance',
@@ -334,6 +342,7 @@ class CRM_Report_DAO_ReportInstance extends CRM_Core_DAO {
           'description' => ts('role required to be able to run this instance'),
           'maxlength' => 1024,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_report_instance.grouprole',
           'table_name' => 'civicrm_report_instance',
           'entity' => 'ReportInstance',
           'bao' => 'CRM_Report_BAO_ReportInstance',
@@ -349,8 +358,6 @@ class CRM_Report_DAO_ReportInstance extends CRM_Core_DAO {
           'description' => ts('Submitted form values for this report'),
           'import' => TRUE,
           'where' => 'civicrm_report_instance.form_values',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_report_instance',
           'entity' => 'ReportInstance',
@@ -363,6 +370,7 @@ class CRM_Report_DAO_ReportInstance extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Report Instance is Active'),
           'description' => ts('Is this entry active?'),
+          'where' => 'civicrm_report_instance.is_active',
           'table_name' => 'civicrm_report_instance',
           'entity' => 'ReportInstance',
           'bao' => 'CRM_Report_BAO_ReportInstance',
@@ -376,6 +384,7 @@ class CRM_Report_DAO_ReportInstance extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Report Instance Created By'),
           'description' => ts('FK to contact table.'),
+          'where' => 'civicrm_report_instance.created_id',
           'table_name' => 'civicrm_report_instance',
           'entity' => 'ReportInstance',
           'bao' => 'CRM_Report_BAO_ReportInstance',
@@ -387,6 +396,7 @@ class CRM_Report_DAO_ReportInstance extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('Report Instance Owned By'),
           'description' => ts('FK to contact table.'),
+          'where' => 'civicrm_report_instance.owner_id',
           'table_name' => 'civicrm_report_instance',
           'entity' => 'ReportInstance',
           'bao' => 'CRM_Report_BAO_ReportInstance',
@@ -400,6 +410,7 @@ class CRM_Report_DAO_ReportInstance extends CRM_Core_DAO {
           'description' => ts('Subject of email'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_report_instance.email_subject',
           'table_name' => 'civicrm_report_instance',
           'entity' => 'ReportInstance',
           'bao' => 'CRM_Report_BAO_ReportInstance',
@@ -413,6 +424,7 @@ class CRM_Report_DAO_ReportInstance extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_TEXT,
           'title' => ts('Email Report Instance To'),
           'description' => ts('comma-separated list of email addresses to send the report to'),
+          'where' => 'civicrm_report_instance.email_to',
           'table_name' => 'civicrm_report_instance',
           'entity' => 'ReportInstance',
           'bao' => 'CRM_Report_BAO_ReportInstance',
@@ -426,6 +438,7 @@ class CRM_Report_DAO_ReportInstance extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_TEXT,
           'title' => ts('cc Email Report Instance To'),
           'description' => ts('comma-separated list of email addresses to send the report to'),
+          'where' => 'civicrm_report_instance.email_cc',
           'table_name' => 'civicrm_report_instance',
           'entity' => 'ReportInstance',
           'bao' => 'CRM_Report_BAO_ReportInstance',
@@ -441,6 +454,7 @@ class CRM_Report_DAO_ReportInstance extends CRM_Core_DAO {
           'description' => ts('comma-separated list of email addresses to send the report to'),
           'rows' => 4,
           'cols' => 60,
+          'where' => 'civicrm_report_instance.header',
           'table_name' => 'civicrm_report_instance',
           'entity' => 'ReportInstance',
           'bao' => 'CRM_Report_BAO_ReportInstance',
@@ -456,6 +470,7 @@ class CRM_Report_DAO_ReportInstance extends CRM_Core_DAO {
           'description' => ts('comma-separated list of email addresses to send the report to'),
           'rows' => 4,
           'cols' => 60,
+          'where' => 'civicrm_report_instance.footer',
           'table_name' => 'civicrm_report_instance',
           'entity' => 'ReportInstance',
           'bao' => 'CRM_Report_BAO_ReportInstance',
@@ -471,8 +486,6 @@ class CRM_Report_DAO_ReportInstance extends CRM_Core_DAO {
           'description' => ts('FK to navigation ID'),
           'import' => TRUE,
           'where' => 'civicrm_report_instance.navigation_id',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_report_instance',
           'entity' => 'ReportInstance',
@@ -487,8 +500,6 @@ class CRM_Report_DAO_ReportInstance extends CRM_Core_DAO {
           'description' => ts('FK to instance ID drilldown to'),
           'import' => TRUE,
           'where' => 'civicrm_report_instance.drilldown_id',
-          'headerPattern' => '',
-          'dataPattern' => '',
           'export' => TRUE,
           'table_name' => 'civicrm_report_instance',
           'entity' => 'ReportInstance',
@@ -500,6 +511,7 @@ class CRM_Report_DAO_ReportInstance extends CRM_Core_DAO {
           'name' => 'is_reserved',
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('Instance is Reserved'),
+          'where' => 'civicrm_report_instance.is_reserved',
           'default' => '0',
           'table_name' => 'civicrm_report_instance',
           'entity' => 'ReportInstance',
diff --git a/civicrm/CRM/Report/Form.php b/civicrm/CRM/Report/Form.php
index 45932218bc6e2f5abe3e317ffdcd31e22b2bf6ae..8e36623d68b2c8b127fbf924a467835fa53fd303 100644
--- a/civicrm/CRM/Report/Form.php
+++ b/civicrm/CRM/Report/Form.php
@@ -155,9 +155,6 @@ class CRM_Report_Form extends CRM_Core_Form {
    */
   protected $_groupFilter = FALSE;
 
-  // [ML] Required for civiexportexcel
-  public $supportsExportExcel = TRUE;
-
   /**
    * Has the report been optimised for group filtering.
    *
@@ -1304,7 +1301,10 @@ class CRM_Report_Form extends CRM_Core_Form {
             if (!empty($field['options']) ||
               $fieldName == 'state_province_id' || $fieldName == 'county_id'
             ) {
-              $element = $this->addElement('select', "{$fieldName}_op", ts('Operator:'), $operations);
+              $element = $this->addElement('select', "{$fieldName}_op", ts('Operator:'), $operations,
+                array('onchange' => "return showHideMaxMinVal( '$fieldName', this.value );")
+              );
+
               if (count($operations) <= 1) {
                 $element->freeze();
               }
@@ -1779,6 +1779,8 @@ class CRM_Report_Form extends CRM_Core_Form {
         $result = [
           'in' => ts('Is one of'),
           'notin' => ts('Is not one of'),
+          'nll' => ts('Is empty (Null)'),
+          'nnll' => ts('Is not empty (Null)'),
         ];
         return $result;
 
@@ -2235,7 +2237,6 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND
     while ($dao->fetch()) {
       $customFields[$dao->table_name . '_custom_' . $dao->id] = $dao->id;
     }
-    $dao->free();
 
     $entryFound = FALSE;
     foreach ($rows as $rowNum => $row) {
@@ -2806,11 +2807,6 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND
       $this->_absoluteUrl = TRUE;
       $this->addPaging = FALSE;
     }
-    elseif ($this->_outputMode == 'excel2007') {
-      $printOnly = TRUE;
-      $this->_absoluteUrl = TRUE;
-      $this->addPaging = FALSE;
-    }
     elseif ($this->_outputMode == 'group') {
       $this->assign('outputMode', 'group');
     }
@@ -3463,9 +3459,6 @@ WHERE cg.extends IN ('" . implode("','", $this->_customGroupExtends) . "') AND
     elseif ($this->_outputMode == 'csv') {
       CRM_Report_Utils_Report::export2csv($this, $rows);
     }
-    elseif ($this->_outputMode == 'excel2007') {
-      CRM_CiviExportExcel_Utils_Report::export2excel2007($this, $rows);
-    }
     elseif ($this->_outputMode == 'group') {
       $group = $this->_params['groups'];
       $this->add2group($group);
@@ -5638,7 +5631,7 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a
         'type' => CRM_Utils_Type::T_INT,
         'no_display' => TRUE,
         'required' => TRUE,
-        'dbAlias' => '(address_civireport.street_number % 2)',
+        'dbAlias' => "({$tableAlias}_civireport.street_number % 2)",
         'is_fields' => TRUE,
         'is_order_bys' => TRUE,
       ],
diff --git a/civicrm/CRM/Report/Form/Contribute/History.php b/civicrm/CRM/Report/Form/Contribute/History.php
index 584bd347da739d45e94c2cc0fbe7609434809341..321b6317c580f00d25c3998070e0d91203a77044 100644
--- a/civicrm/CRM/Report/Form/Contribute/History.php
+++ b/civicrm/CRM/Report/Form/Contribute/History.php
@@ -617,7 +617,6 @@ class CRM_Report_Form_Contribute_History extends CRM_Report_Form {
     while ($dao->fetch()) {
       $contactIds[] = $dao->cid;
     }
-    $dao->free();
     $this->setPager();
 
     $relationshipRows = [];
@@ -732,7 +731,6 @@ class CRM_Report_Form_Contribute_History extends CRM_Report_Form {
       }
       $rows[$dao->civicrm_contact_id]['aggregate_amount'] += $dao->civicrm_contribution_total_amount;
     }
-    $dao->free();
     return $rows;
   }
 
@@ -776,7 +774,6 @@ class CRM_Report_Form_Contribute_History extends CRM_Report_Form {
         $relatedContactIds[$dao->contact_id_a] = $dao->contact_id_a;
       }
     }
-    $dao->free();
     return [$relationshipRows, $relatedContactIds];
   }
 
diff --git a/civicrm/CRM/Report/Form/Event/Income.php b/civicrm/CRM/Report/Form/Event/Income.php
index bf62cd0f86499af2b2cf1432e8b1c6858aec20ce..81cc215fd663c3739eb7bc6e2fcbab9cefc07ea0 100644
--- a/civicrm/CRM/Report/Form/Event/Income.php
+++ b/civicrm/CRM/Report/Form/Event/Income.php
@@ -78,7 +78,6 @@ class CRM_Report_Form_Event_Income extends CRM_Report_Form {
 
     $eventID = implode(',', $eventIDs);
 
-    $participantStatus = CRM_Event_PseudoConstant::participantStatus(NULL, "is_counted = 1", "label");
     $participantRole = CRM_Event_PseudoConstant::participantRole();
     $paymentInstruments = CRM_Contribute_PseudoConstant::paymentInstrument();
 
@@ -90,15 +89,8 @@ class CRM_Report_Form_Event_Income extends CRM_Report_Form {
     if ($optionGroupDAO->find(TRUE)) {
       $optionGroupId = $optionGroupDAO->id;
     }
-    //show the income of active participant status (Counted = filter = 1)
-    $activeParticipantStatusIDArray = $activeParticipantStatusLabelArray = [];
-    foreach ($participantStatus as $id => $label) {
-      $activeParticipantStatusIDArray[] = $id;
-      $activeParticipantStatusLabelArray[] = $label;
-    }
-    $activeParticipantStatus = implode(',', $activeParticipantStatusIDArray);
-    $activeparticipnatStutusLabel = implode(', ', $activeParticipantStatusLabelArray);
-    $activeParticipantClause = " AND civicrm_participant.status_id IN ( $activeParticipantStatus ) ";
+
+    $activeParticipantClause = " AND civicrm_participant.status_id IN ( " . implode(',', array_keys($this->getActiveParticipantStatuses())) . " ) ";
     $select = [
       "civicrm_event.id as event_id",
       "civicrm_event.title as event_title",
@@ -133,7 +125,7 @@ class CRM_Report_Form_Event_Income extends CRM_Report_Form {
       $eventSummary[$eventDAO->event_id][ts('End Date')] = CRM_Utils_Date::customFormat($eventDAO->end_date);
       $eventSummary[$eventDAO->event_id][ts('Event Type')] = $eventDAO->event_type;
       $eventSummary[$eventDAO->event_id][ts('Event Income')] = CRM_Utils_Money::format($eventDAO->total, $eventDAO->currency);
-      $eventSummary[$eventDAO->event_id][ts('Registered Participant')] = "{$eventDAO->participant} ({$activeparticipnatStutusLabel})";
+      $eventSummary[$eventDAO->event_id][ts('Registered Participant')] = "{$eventDAO->participant} ({" . implode(', ', $this->getActiveParticipantStatuses()) . ")";
       $currency[$eventDAO->event_id] = $eventDAO->currency;
     }
     $this->assign_by_ref('summary', $eventSummary);
@@ -216,6 +208,7 @@ class CRM_Report_Form_Event_Income extends CRM_Report_Form {
 
     $statusDAO = $this->executeReportQuery($status);
 
+    $participantStatus = $this->getActiveParticipantStatuses();
     while ($statusDAO->fetch()) {
       $statusRows[$statusDAO->event_id][$participantStatus[$statusDAO->STATUSID]]['total'] = $statusDAO->participant;
       $statusRows[$statusDAO->event_id][$participantStatus[$statusDAO->STATUSID]]['round'] = round(($statusDAO->participant / $count[$statusDAO->event_id]) * 100, 2);
@@ -382,4 +375,13 @@ class CRM_Report_Form_Event_Income extends CRM_Report_Form {
     parent::endPostProcess();
   }
 
+  /**
+   * Get statuses with the counted filter set to TRUE.
+   *
+   * @return array
+   */
+  protected function getActiveParticipantStatuses() {
+    return CRM_Event_PseudoConstant::participantStatus(NULL, "is_counted = 1", "label");
+  }
+
 }
diff --git a/civicrm/CRM/Report/Form/Extended.php b/civicrm/CRM/Report/Form/Extended.php
deleted file mode 100644
index 873665e8cd877519c225882a4c16d08b786fca0d..0000000000000000000000000000000000000000
--- a/civicrm/CRM/Report/Form/Extended.php
+++ /dev/null
@@ -1,1420 +0,0 @@
-<?php
-/*
- +--------------------------------------------------------------------+
- | CiviCRM version 5                                                  |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019                                |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM.                                    |
- |                                                                    |
- | CiviCRM is free software; you can copy, modify, and distribute it  |
- | under the terms of the GNU Affero General Public License           |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception.   |
- |                                                                    |
- | CiviCRM is distributed in the hope that it will be useful, but     |
- | WITHOUT ANY WARRANTY; without even the implied warranty of         |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
- | See the GNU Affero General Public License for more details.        |
- |                                                                    |
- | You should have received a copy of the GNU Affero General Public   |
- | License and the CiviCRM Licensing Exception along                  |
- | with this program; if not, contact CiviCRM LLC                     |
- | at info[AT]civicrm[DOT]org. If you have questions about the        |
- | GNU Affero General Public License or the licensing of CiviCRM,     |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
- +--------------------------------------------------------------------+
- */
-
-/**
- *
- * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2019
- * $Id$
- *
- */
-class CRM_Report_Form_Extended extends CRM_Report_Form {
-  protected $_addressField = FALSE;
-
-  protected $_emailField = FALSE;
-
-  protected $_summary = NULL;
-
-  protected $_customGroupExtends = [];
-  protected $_baseTable = 'civicrm_contact';
-
-  /**
-   *
-   */
-  public function __construct() {
-    parent::__construct();
-  }
-
-  /**
-   *
-   */
-  public function preProcess() {
-    parent::preProcess();
-  }
-
-  /**
-   *
-   */
-  public function select() {
-    parent::select();
-  }
-
-  /**
-   * From clause build where baseTable & fromClauses are defined
-   */
-  public function from() {
-    if (!empty($this->_baseTable)) {
-      $this->buildACLClause($this->_aliases['civicrm_contact']);
-      $this->_from = "FROM {$this->_baseTable}   {$this->_aliases[$this->_baseTable]}";
-      $availableClauses = $this->getAvailableJoins();
-      foreach ($this->fromClauses() as $fromClause) {
-        $fn = $availableClauses[$fromClause]['callback'];
-        $this->$fn();
-      }
-      if (strstr($this->_from, 'civicrm_contact')) {
-        $this->_from .= $this->_aclFrom;
-      }
-    }
-  }
-
-  /**
-   * Define any from clauses in use (child classes to override)
-   *
-   * @return array
-   */
-  public function fromClauses() {
-    return [];
-  }
-
-  public function groupBy() {
-    parent::groupBy();
-    //@todo - need to re-visit this - bad behaviour from pa
-    if ($this->_groupBy == 'GROUP BY') {
-      $this->_groupBY = NULL;
-    }
-    // if a stat field has been selected the do a group by
-    if (!empty($this->_statFields) && empty($this->_groupBy)) {
-      $this->_groupBy[] = $this->_aliases[$this->_baseTable] . ".id";
-    }
-    //@todo - this should be in the parent function or at parent level - perhaps build query should do this?
-    if (!empty($this->_groupBy) && is_array($this->_groupBy)) {
-      $this->_groupBy = 'GROUP BY ' . implode(',', $this->_groupBy);
-    }
-  }
-
-  public function orderBy() {
-    parent::orderBy();
-  }
-
-  /**
-   * @param array $rows
-   *
-   * @return array
-   */
-  public function statistics(&$rows) {
-    return parent::statistics($rows);
-  }
-
-  public function postProcess() {
-    if (!empty($this->_aclTable) && !empty($this->_aliases[$this->_aclTable])) {
-      $this->buildACLClause($this->_aliases[$this->_aclTable]);
-    }
-    parent::postProcess();
-  }
-
-  /**
-   * 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) {
-    parent::alterDisplay($rows);
-
-    //THis is all generic functionality which can hopefully go into the parent class
-    // it introduces the option of defining an alter display function as part of the column definition
-    // @tod tidy up the iteration so it happens in this function
-    list($firstRow) = $rows;
-    // no result to alter
-    if (empty($firstRow)) {
-      return;
-    }
-    $selectedFields = array_keys($firstRow);
-
-    $alterfunctions = $altermap = [];
-    foreach ($this->_columns as $tablename => $table) {
-      if (array_key_exists('fields', $table)) {
-        foreach ($table['fields'] as $field => $specs) {
-          if (in_array($tablename . '_' . $field, $selectedFields) &&
-            array_key_exists('alter_display', $specs)
-          ) {
-            $alterfunctions[$tablename . '_' .
-            $field] = $specs['alter_display'];
-            $altermap[$tablename . '_' . $field] = $field;
-          }
-        }
-      }
-    }
-    if (empty($alterfunctions)) {
-      // - no manipulation to be done
-      return;
-    }
-
-    foreach ($rows as $index => & $row) {
-      foreach ($row as $selectedfield => $value) {
-        if (array_key_exists($selectedfield, $alterfunctions)) {
-          $rows[$index][$selectedfield] = $this->{$alterfunctions[$selectedfield]}($value, $row, $selectedfield, $altermap[$selectedfield]);
-        }
-      }
-    }
-  }
-
-  /**
-   * @return array
-   */
-  public function getLineItemColumns() {
-    return [
-      'civicrm_line_item' => [
-        'dao' => 'CRM_Price_BAO_LineItem',
-        'fields' => [
-          'qty' => [
-            'title' => ts('Quantity'),
-            'type' => CRM_Utils_Type::T_INT,
-            'statistics' => ['sum' => ts('Total Quantity Selected')],
-          ],
-          'unit_price' => [
-            'title' => ts('Unit Price'),
-          ],
-          'line_total' => [
-            'title' => ts('Line Total'),
-            'type' => CRM_Utils_Type::T_MONEY,
-            'statistics' => ['sum' => ts('Total of Line Items')],
-          ],
-        ],
-        'participant_count' => [
-          'title' => ts('Participant Count'),
-          'statistics' => ['sum' => ts('Total Participants')],
-        ],
-        'filters' => [
-          'qty' => [
-            'title' => ts('Quantity'),
-            'type' => CRM_Utils_Type::T_INT,
-            'operator' => CRM_Report_Form::OP_INT,
-          ],
-        ],
-        'group_bys' => [
-          'price_field_id' => [
-            'title' => ts('Price Field'),
-          ],
-          'price_field_value_id' => [
-            'title' => ts('Price Field Option'),
-          ],
-          'line_item_id' => [
-            'title' => ts('Individual Line Item'),
-            'name' => 'id',
-          ],
-        ],
-      ],
-    ];
-  }
-
-  /**
-   * @return array
-   */
-  public function getPriceFieldValueColumns() {
-    return [
-      'civicrm_price_field_value' => [
-        'dao' => 'CRM_Price_BAO_PriceFieldValue',
-        'fields' => [
-          'price_field_value_label' => [
-            'title' => ts('Price Field Value Label'),
-            'name' => 'label',
-          ],
-        ],
-        'filters' => [
-          'price_field_value_label' => [
-            'title' => ts('Price Fields Value Label'),
-            'type' => CRM_Utils_Type::T_STRING,
-            'operator' => 'like',
-            'name' => 'label',
-          ],
-        ],
-        'order_bys' => [
-          'label' => [
-            'title' => ts('Price Field Value Label'),
-          ],
-        ],
-        //note that we have a requirement to group by label such that all 'Promo book' lines
-        'group_bys' =>
-        // are grouped together across price sets but there may be a separate need to group
-        // by id so that entries in one price set are distinct from others. Not quite sure what
-        // to call the distinction for end users benefit
-        [
-          'price_field_value_label' => [
-            'title' => ts('Price Field Value Label'),
-            'name' => 'label',
-          ],
-        ],
-      ],
-    ];
-  }
-
-  /**
-   * @return array
-   */
-  public function getPriceFieldColumns() {
-    return [
-      'civicrm_price_field' => [
-        'dao' => 'CRM_Price_BAO_PriceField',
-        'fields' => [
-          'price_field_label' => [
-            'title' => ts('Price Field Label'),
-            'name' => 'label',
-          ],
-        ],
-        'filters' => [
-          'price_field_label' => [
-            'title' => ts('Price Field Label'),
-            'type' => CRM_Utils_Type::T_STRING,
-            'operator' => 'like',
-            'name' => 'label',
-          ],
-        ],
-        'order_bys' => [
-          'price_field_label' => [
-            'title' => ts('Price Field Label'),
-            'name' => 'label',
-          ],
-        ],
-        'group_bys' => [
-          'price_field_label' => [
-            'title' => ts('Price Field Label'),
-            'name' => 'label',
-          ],
-        ],
-      ],
-    ];
-  }
-
-  /**
-   * @return array
-   */
-  public function getParticipantColumns() {
-    static $_events = [];
-    if (!isset($_events['all'])) {
-      CRM_Core_PseudoConstant::populate($_events['all'], 'CRM_Event_DAO_Event', FALSE, 'title', 'is_active', "is_template IS NULL OR is_template = 0", 'end_date DESC');
-    }
-    return [
-      'civicrm_participant' => [
-        'dao' => 'CRM_Event_DAO_Participant',
-        'fields' => [
-          'participant_id' => ['title' => ts('Participant ID')],
-          'participant_record' => [
-            'name' => 'id',
-            'title' => ts('Participant ID'),
-          ],
-          'event_id' => [
-            'title' => ts('Event ID'),
-            'type' => CRM_Utils_Type::T_STRING,
-            'alter_display' => 'alterEventID',
-          ],
-          'status_id' => [
-            'title' => ts('Status'),
-            'alter_display' => 'alterParticipantStatus',
-          ],
-          'role_id' => [
-            'title' => ts('Role'),
-            'alter_display' => 'alterParticipantRole',
-          ],
-          'participant_fee_level' => NULL,
-          'participant_fee_amount' => NULL,
-          'participant_register_date' => ['title' => ts('Registration Date')],
-        ],
-        'grouping' => 'event-fields',
-        'filters' => [
-          'event_id' => [
-            'name' => 'event_id',
-            'title' => ts('Event'),
-            'operatorType' => CRM_Report_Form::OP_MULTISELECT,
-            'options' => $_events['all'],
-          ],
-          'sid' => [
-            'name' => 'status_id',
-            'title' => ts('Participant Status'),
-            'operatorType' => CRM_Report_Form::OP_MULTISELECT,
-            'options' => CRM_Event_PseudoConstant::participantStatus(NULL, NULL, 'label'),
-          ],
-          'rid' => [
-            'name' => 'role_id',
-            'title' => ts('Participant Role'),
-            'operatorType' => CRM_Report_Form::OP_MULTISELECT,
-            'options' => CRM_Event_PseudoConstant::participantRole(),
-          ],
-          'participant_register_date' => [
-            'title' => ts('Registration Date'),
-            'operatorType' => CRM_Report_Form::OP_DATE,
-          ],
-        ],
-        'order_bys' => [
-          'event_id' => [
-            'title' => ts('Event'),
-            'default_weight' => '1',
-            'default_order' => 'ASC',
-          ],
-        ],
-        'group_bys' => [
-          'event_id' => ['title' => ts('Event')],
-        ],
-      ],
-    ];
-  }
-
-  /**
-   * @return array
-   */
-  public function getMembershipColumns() {
-    return [
-      'civicrm_membership' => [
-        'dao' => 'CRM_Member_DAO_Membership',
-        'grouping' => 'member-fields',
-        'fields' => [
-          'membership_type_id' => [
-            'title' => ts('Membership Type'),
-            'required' => TRUE,
-            'alter_display' => 'alterMembershipTypeID',
-          ],
-          'status_id' => [
-            'title' => ts('Membership Status'),
-            'required' => TRUE,
-            'alter_display' => 'alterMembershipStatusID',
-          ],
-          'join_date' => NULL,
-          'start_date' => [
-            'title' => ts('Current Cycle Start Date'),
-          ],
-          'end_date' => [
-            'title' => ts('Current Membership Cycle End Date'),
-          ],
-        ],
-        'group_bys' => [
-          'membership_type_id' => [
-            'title' => ts('Membership Type'),
-          ],
-        ],
-        'filters' => [
-          'join_date' => [
-            'type' => CRM_Utils_Type::T_DATE,
-            'operatorType' => CRM_Report_Form::OP_DATE,
-          ],
-        ],
-      ],
-    ];
-  }
-
-  /**
-   * @return array
-   */
-  public function getMembershipTypeColumns() {
-    return [
-      'civicrm_membership_type' => [
-        'dao' => 'CRM_Member_DAO_MembershipType',
-        'grouping' => 'member-fields',
-        'filters' => [
-          'gid' => [
-            'name' => 'id',
-            'title' => ts('Membership Types'),
-            'operatorType' => CRM_Report_Form::OP_MULTISELECT,
-            'type' => CRM_Utils_Type::T_INT + CRM_Utils_Type::T_ENUM,
-            'options' => CRM_Member_PseudoConstant::membershipType(),
-          ],
-        ],
-      ],
-    ];
-  }
-
-  /**
-   * @return array
-   */
-  public function getEventColumns() {
-    return [
-      'civicrm_event' => [
-        'dao' => 'CRM_Event_DAO_Event',
-        'fields' => [
-          'id' => [
-            'no_display' => TRUE,
-            'required' => TRUE,
-          ],
-          'title' => [
-            'title' => ts('Event Title'),
-            'required' => TRUE,
-          ],
-          'event_type_id' => [
-            'title' => ts('Event Type'),
-            'required' => TRUE,
-            'alter_display' => 'alterEventType',
-          ],
-          'fee_label' => ['title' => ts('Fee Label')],
-          'event_start_date' => [
-            'title' => ts('Event Start Date'),
-          ],
-          'event_end_date' => ['title' => ts('Event End Date')],
-          'max_participants' => [
-            'title' => ts('Capacity'),
-            'type' => CRM_Utils_Type::T_INT,
-          ],
-        ],
-        'grouping' => 'event-fields',
-        'filters' => [
-          'event_type_id' => [
-            'name' => 'event_type_id',
-            'title' => ts('Event Type'),
-            'operatorType' => CRM_Report_Form::OP_MULTISELECT,
-            'options' => CRM_Core_OptionGroup::values('event_type'),
-          ],
-          'event_title' => [
-            'name' => 'title',
-            'title' => ts('Event Title'),
-            'operatorType' => CRM_Report_Form::OP_STRING,
-          ],
-        ],
-        'order_bys' => [
-          'event_type_id' => [
-            'title' => ts('Event Type'),
-            'default_weight' => '2',
-            'default_order' => 'ASC',
-          ],
-        ],
-        'group_bys' => [
-          'event_type_id' => [
-            'title' => ts('Event Type'),
-          ],
-        ],
-      ],
-    ];
-  }
-
-  /**
-   * @return array
-   */
-  public function getContributionColumns() {
-    return [
-      'civicrm_contribution' => [
-        'dao' => 'CRM_Contribute_DAO_Contribution',
-        'fields' => [
-          'contribution_id' => [
-            'name' => 'id',
-          ],
-          'financial_type_id' => [
-            'title' => ts('Financial Type'),
-            'default' => TRUE,
-            'alter_display' => 'alterContributionType',
-          ],
-          'payment_instrument_id' => [
-            'title' => ts('Payment Method'),
-            'alter_display' => 'alterPaymentType',
-          ],
-          'source' => ['title' => ts('Contribution Source')],
-          'trxn_id' => NULL,
-          'receive_date' => ['default' => TRUE],
-          'receipt_date' => NULL,
-          'fee_amount' => NULL,
-          'net_amount' => NULL,
-          'total_amount' => [
-            'title' => ts('Amount'),
-            'statistics' => ['sum' => ts('Total Amount')],
-            'type' => CRM_Utils_Type::T_MONEY,
-          ],
-        ],
-        'filters' => [
-          'receive_date' => ['operatorType' => CRM_Report_Form::OP_DATE],
-          'financial_type_id' => [
-            'title' => ts('Financial Type'),
-            'operatorType' => CRM_Report_Form::OP_MULTISELECT,
-            'options' => CRM_Contribute_PseudoConstant::financialType(),
-          ],
-          'payment_instrument_id' => [
-            'title' => ts('Payment Type'),
-            'operatorType' => CRM_Report_Form::OP_MULTISELECT,
-            'options' => CRM_Contribute_PseudoConstant::paymentInstrument(),
-          ],
-          'contribution_status_id' => [
-            'title' => ts('Contribution Status'),
-            'operatorType' => CRM_Report_Form::OP_MULTISELECT,
-            'options' => CRM_Contribute_PseudoConstant::contributionStatus(),
-          ],
-          'total_amount' => ['title' => ts('Contribution Amount')],
-        ],
-        'order_bys' => [
-          'payment_instrument_id' => [
-            'title' => ts('Payment Method'),
-          ],
-          'financial_type_id' => [
-            'title' => ts('Financial Type'),
-          ],
-        ],
-        'group_bys' => [
-          'financial_type_id' => ['title' => ts('Financial Type')],
-          'payment_instrument_id' => ['title' => ts('Payment Method')],
-          'contribution_id' => [
-            'title' => ts('Individual Contribution'),
-            'name' => 'id',
-          ],
-          'source' => ['title' => ts('Contribution Source')],
-        ],
-        'grouping' => 'contribution-fields',
-      ],
-    ];
-  }
-
-  /**
-   * @return array
-   */
-  public function getContactColumns() {
-    return [
-      'civicrm_contact' => [
-        'dao' => 'CRM_Contact_DAO_Contact',
-        'fields' => [
-          'display_name' => [
-            'title' => ts('Contact Name'),
-          ],
-          'id' => [
-            'title' => ts('Contact ID'),
-            'alter_display' => 'alterContactID',
-          ],
-          'first_name' => [
-            'title' => ts('First Name'),
-          ],
-          'last_name' => [
-            'title' => ts('Last Name'),
-          ],
-          'nick_name' => [
-            'title' => ts('Nickname'),
-            'alter_display' => 'alterNickname',
-          ],
-        ],
-        'filters' => [
-          'id' => [
-            'title' => ts('Contact ID'),
-          ],
-          'sort_name' => [
-            'title' => ts('Contact Name'),
-          ],
-        ],
-        'grouping' => 'contact-fields',
-        'order_bys' => [
-          'sort_name' => [
-            'title' => ts('Last Name, First Name'),
-            'default' => '1',
-            'default_weight' => '0',
-            'default_order' => 'ASC',
-          ],
-        ],
-      ],
-    ];
-  }
-
-  /**
-   * @return array
-   */
-  public function getCaseColumns() {
-    return [
-      'civicrm_case' => [
-        'dao' => 'CRM_Case_DAO_Case',
-        'fields' => [
-          'id' => [
-            'title' => ts('Case ID'),
-            'required' => FALSE,
-          ],
-          'subject' => [
-            'title' => ts('Case Subject'),
-            'default' => TRUE,
-          ],
-          'status_id' => [
-            'title' => ts('Status'),
-            'default' => TRUE,
-          ],
-          'case_type_id' => [
-            'title' => ts('Case Type'),
-            'default' => TRUE,
-          ],
-          'case_start_date' => [
-            'title' => ts('Case Start Date'),
-            'name' => 'start_date',
-            'default' => TRUE,
-          ],
-          'case_end_date' => [
-            'title' => ts('Case End Date'),
-            'name' => 'end_date',
-            'default' => TRUE,
-          ],
-          'case_duration' => [
-            'name' => 'duration',
-            'title' => ts('Duration (Days)'),
-            'default' => FALSE,
-          ],
-          'case_is_deleted' => [
-            'name' => 'is_deleted',
-            'title' => ts('Case Deleted?'),
-            'default' => FALSE,
-            'type' => CRM_Utils_Type::T_INT,
-          ],
-        ],
-        'filters' => [
-          'case_start_date' => [
-            'title' => ts('Case Start Date'),
-            'operatorType' => CRM_Report_Form::OP_DATE,
-            'type' => CRM_Utils_Type::T_DATE,
-            'name' => 'start_date',
-          ],
-          'case_end_date' => [
-            'title' => ts('Case End Date'),
-            'operatorType' => CRM_Report_Form::OP_DATE,
-            'type' => CRM_Utils_Type::T_DATE,
-            'name' => 'end_date',
-          ],
-          'case_type_id' => [
-            'title' => ts('Case Type'),
-            'operatorType' => CRM_Report_Form::OP_MULTISELECT,
-            'options' => $this->case_types,
-          ],
-          'case_status_id' => [
-            'title' => ts('Case Status'),
-            'operatorType' => CRM_Report_Form::OP_MULTISELECT,
-            'options' => $this->case_statuses,
-            'name' => 'status_id',
-          ],
-          'case_is_deleted' => [
-            'title' => ts('Case Deleted?'),
-            'type' => CRM_Report_Form::OP_INT,
-            'operatorType' => CRM_Report_Form::OP_SELECT,
-            'options' => $this->deleted_labels,
-            'default' => 0,
-            'name' => 'is_deleted',
-          ],
-        ],
-      ],
-    ];
-  }
-
-  /**
-   * Get address columns to add to array.
-   *
-   * @param array $options
-   *   Options for the report.
-   *   - prefix prefix to add (e.g. 'honor' when getting address details for honor contact
-   *   - prefix_label optional prefix lable eg. "Honoree " for front end
-   *   - group_by enable these fields for group by - default false
-   *   - order_by enable these fields for order by
-   *   - filters enable these fields for filtering
-   *   - defaults - (is this working?) values to pre-populate
-   *
-   * @return array
-   *   address columns definition
-   */
-  public function getAddressColumns($options = []) {
-    $defaultOptions = [
-      'prefix' => '',
-      'prefix_label' => '',
-      'group_by' => FALSE,
-      'order_by' => TRUE,
-      'filters' => TRUE,
-      'defaults' => [
-        'country_id' => TRUE,
-      ],
-    ];
-
-    $options = array_merge($defaultOptions, $options);
-
-    $addressFields = [
-      $options['prefix'] . 'civicrm_address' => [
-        'dao' => 'CRM_Core_DAO_Address',
-        'name' => 'civicrm_address',
-        'alias' => $options['prefix'] . 'civicrm_address',
-        'fields' => [
-          $options['prefix'] . 'name' => [
-            'title' => ts($options['prefix_label'] . 'Address Name'),
-            'default' => CRM_Utils_Array::value('name', $options['defaults'], FALSE),
-            'name' => 'name',
-          ],
-          $options['prefix'] . 'street_address' => [
-            'title' => ts($options['prefix_label'] . 'Street Address'),
-            'default' => CRM_Utils_Array::value('street_address', $options['defaults'], FALSE),
-            'name' => 'street_address',
-          ],
-          $options['prefix'] . 'supplemental_address_1' => [
-            'title' => ts($options['prefix_label'] .
-              'Supplementary Address Field 1'),
-            'default' => CRM_Utils_Array::value('supplemental_address_1', $options['defaults'], FALSE),
-            'name' => 'supplemental_address_1',
-          ],
-          $options['prefix'] . 'supplemental_address_2' => [
-            'title' => ts($options['prefix_label'] .
-              'Supplementary Address Field 2'),
-            'default' => CRM_Utils_Array::value('supplemental_address_2', $options['defaults'], FALSE),
-            'name' => 'supplemental_address_2',
-          ],
-          $options['prefix'] . 'supplemental_address_3' => [
-            'title' => ts($options['prefix_label'] .
-              'Supplementary Address Field 3'),
-            'default' => CRM_Utils_Array::value('supplemental_address_3', $options['defaults'], FALSE),
-            'name' => 'supplemental_address_3',
-          ],
-          $options['prefix'] . 'street_number' => [
-            'name' => 'street_number',
-            'title' => ts($options['prefix_label'] . 'Street Number'),
-            'type' => 1,
-            'default' => CRM_Utils_Array::value('street_number', $options['defaults'], FALSE),
-          ],
-          $options['prefix'] . 'street_name' => [
-            'name' => 'street_name',
-            'title' => ts($options['prefix_label'] . 'Street Name'),
-            'type' => 1,
-            'default' => CRM_Utils_Array::value('street_name', $options['defaults'], FALSE),
-          ],
-          $options['prefix'] . 'street_unit' => [
-            'name' => 'street_unit',
-            'title' => ts($options['prefix_label'] . 'Street Unit'),
-            'type' => 1,
-            'default' => CRM_Utils_Array::value('street_unit', $options['defaults'], FALSE),
-          ],
-          $options['prefix'] . 'city' => [
-            'title' => ts($options['prefix_label'] . 'City'),
-            'default' => CRM_Utils_Array::value('city', $options['defaults'], FALSE),
-            'name' => 'city',
-          ],
-          $options['prefix'] . 'postal_code' => [
-            'title' => ts($options['prefix_label'] . 'Postal Code'),
-            'default' => CRM_Utils_Array::value('postal_code', $options['defaults'], FALSE),
-            'name' => 'postal_code',
-          ],
-          $options['prefix'] . 'county_id' => [
-            'title' => ts($options['prefix_label'] . 'County'),
-            'default' => CRM_Utils_Array::value('county_id', $options['defaults'], FALSE),
-            'alter_display' => 'alterCountyID',
-            'name' => 'county_id',
-          ],
-          $options['prefix'] . 'state_province_id' => [
-            'title' => ts($options['prefix_label'] . 'State/Province'),
-            'default' => CRM_Utils_Array::value('state_province_id', $options['defaults'], FALSE),
-            'alter_display' => 'alterStateProvinceID',
-            'name' => 'state_province_id',
-          ],
-          $options['prefix'] . 'country_id' => [
-            'title' => ts($options['prefix_label'] . 'Country'),
-            'default' => CRM_Utils_Array::value('country_id', $options['defaults'], FALSE),
-            'alter_display' => 'alterCountryID',
-            'name' => 'country_id',
-          ],
-        ],
-        'grouping' => 'location-fields',
-      ],
-    ];
-
-    if ($options['filters']) {
-      $addressFields[$options['prefix'] . 'civicrm_address']['filters'] = [
-        $options['prefix'] . 'street_number' => [
-          'title' => ts($options['prefix_label'] . 'Street Number'),
-          'type' => 1,
-          'name' => 'street_number',
-        ],
-        $options['prefix'] . 'street_name' => [
-          'title' => ts($options['prefix_label'] . 'Street Name'),
-          'name' => $options['prefix'] . 'street_name',
-          'operator' => 'like',
-        ],
-        $options['prefix'] . 'postal_code' => [
-          'title' => ts($options['prefix_label'] . 'Postal Code'),
-          'type' => 1,
-          'name' => 'postal_code',
-        ],
-        $options['prefix'] . 'city' => [
-          'title' => ts($options['prefix_label'] . 'City'),
-          'operator' => 'like',
-          'name' => 'city',
-        ],
-        $options['prefix'] . 'county_id' => [
-          'name' => 'county_id',
-          'title' => ts($options['prefix_label'] . 'County'),
-          'type' => CRM_Utils_Type::T_INT,
-          'operatorType' => CRM_Report_Form::OP_MULTISELECT,
-          'options' => CRM_Core_PseudoConstant::county(),
-        ],
-        $options['prefix'] . 'state_province_id' => [
-          'name' => 'state_province_id',
-          'title' => ts($options['prefix_label'] . 'State/Province'),
-          'type' => CRM_Utils_Type::T_INT,
-          'operatorType' => CRM_Report_Form::OP_MULTISELECT,
-          'options' => CRM_Core_PseudoConstant::stateProvince(),
-        ],
-        $options['prefix'] . 'country_id' => [
-          'name' => 'country_id',
-          'title' => ts($options['prefix_label'] . 'Country'),
-          'type' => CRM_Utils_Type::T_INT,
-          'operatorType' => CRM_Report_Form::OP_MULTISELECT,
-          'options' => CRM_Core_PseudoConstant::country(),
-        ],
-      ];
-    }
-
-    if ($options['order_by']) {
-      $addressFields[$options['prefix'] .
-      'civicrm_address']['order_bys'] = [
-        $options['prefix'] . 'street_name' => [
-          'title' => ts($options['prefix_label'] . 'Street Name'),
-          'name' => 'street_name',
-        ],
-        $options['prefix'] . 'street_number' => [
-          'title' => ts($options['prefix_label'] . 'Odd / Even Street Number'),
-          'name' => 'street_number',
-        ],
-        $options['prefix'] . 'street_address' => [
-          'title' => ts($options['prefix_label'] . 'Street Address'),
-          'name' => 'street_address',
-        ],
-        $options['prefix'] . 'city' => [
-          'title' => ts($options['prefix_label'] . 'City'),
-          'name' => 'city',
-        ],
-        $options['prefix'] . 'postal_code' => [
-          'title' => ts($options['prefix_label'] . 'Post Code'),
-          'name' => 'postal_code',
-        ],
-      ];
-    }
-
-    if ($options['group_by']) {
-      $addressFields['civicrm_address']['group_bys'] = [
-        $options['prefix'] . 'street_address' => [
-          'title' => ts($options['prefix_label'] . 'Street Address'),
-          'name' => 'street_address',
-        ],
-        $options['prefix'] . 'city' => [
-          'title' => ts($options['prefix_label'] . 'City'),
-          'name' => 'city',
-        ],
-        $options['prefix'] . 'postal_code' => [
-          'title' => ts($options['prefix_label'] . 'Post Code'),
-          'name' => 'postal_code',
-        ],
-        $options['prefix'] . 'state_province_id' => [
-          'title' => ts($options['prefix_label'] . 'State/Province'),
-          'name' => 'state_province_id',
-        ],
-        $options['prefix'] . 'country_id' => [
-          'title' => ts($options['prefix_label'] . 'Country'),
-          'name' => 'country_id',
-        ],
-        $options['prefix'] . 'county_id' => [
-          'title' => ts($options['prefix_label'] . 'County'),
-          'name' => 'county_id',
-        ],
-      ];
-    }
-    return $addressFields;
-  }
-
-  /**
-   * Get Information about advertised Joins.
-   *
-   * @return array
-   */
-  public function getAvailableJoins() {
-    return [
-      'priceFieldValue_from_lineItem' => [
-        'leftTable' => 'civicrm_line_item',
-        'rightTable' => 'civicrm_price_field_value',
-        'callback' => 'joinPriceFieldValueFromLineItem',
-      ],
-      'priceField_from_lineItem' => [
-        'leftTable' => 'civicrm_line_item',
-        'rightTable' => 'civicrm_price_field',
-        'callback' => 'joinPriceFieldFromLineItem',
-      ],
-      'participant_from_lineItem' => [
-        'leftTable' => 'civicrm_line_item',
-        'rightTable' => 'civicrm_participant',
-        'callback' => 'joinParticipantFromLineItem',
-      ],
-      'contribution_from_lineItem' => [
-        'leftTable' => 'civicrm_line_item',
-        'rightTable' => 'civicrm_contribution',
-        'callback' => 'joinContributionFromLineItem',
-      ],
-      'membership_from_lineItem' => [
-        'leftTable' => 'civicrm_line_item',
-        'rightTable' => 'civicrm_membership',
-        'callback' => 'joinMembershipFromLineItem',
-      ],
-      'contribution_from_participant' => [
-        'leftTable' => 'civicrm_participant',
-        'rightTable' => 'civicrm_contribution',
-        'callback' => 'joinContributionFromParticipant',
-      ],
-      'contribution_from_membership' => [
-        'leftTable' => 'civicrm_membership',
-        'rightTable' => 'civicrm_contribution',
-        'callback' => 'joinContributionFromMembership',
-      ],
-      'membership_from_contribution' => [
-        'leftTable' => 'civicrm_contribution',
-        'rightTable' => 'civicrm_membership',
-        'callback' => 'joinMembershipFromContribution',
-      ],
-      'membershipType_from_membership' => [
-        'leftTable' => 'civicrm_membership',
-        'rightTable' => 'civicrm_membership_type',
-        'callback' => 'joinMembershipTypeFromMembership',
-      ],
-      'lineItem_from_contribution' => [
-        'leftTable' => 'civicrm_contribution',
-        'rightTable' => 'civicrm_line_item',
-        'callback' => 'joinLineItemFromContribution',
-      ],
-      'lineItem_from_membership' => [
-        'leftTable' => 'civicrm_membership',
-        'rightTable' => 'civicrm_line_item',
-        'callback' => 'joinLineItemFromMembership',
-      ],
-      'contact_from_participant' => [
-        'leftTable' => 'civicrm_participant',
-        'rightTable' => 'civicrm_contact',
-        'callback' => 'joinContactFromParticipant',
-      ],
-      'contact_from_membership' => [
-        'leftTable' => 'civicrm_membership',
-        'rightTable' => 'civicrm_contact',
-        'callback' => 'joinContactFromMembership',
-      ],
-      'contact_from_contribution' => [
-        'leftTable' => 'civicrm_contribution',
-        'rightTable' => 'civicrm_contact',
-        'callback' => 'joinContactFromContribution',
-      ],
-      'event_from_participant' => [
-        'leftTable' => 'civicrm_participant',
-        'rightTable' => 'civicrm_event',
-        'callback' => 'joinEventFromParticipant',
-      ],
-      'address_from_contact' => [
-        'leftTable' => 'civicrm_contact',
-        'rightTable' => 'civicrm_address',
-        'callback' => 'joinAddressFromContact',
-      ],
-    ];
-  }
-
-  /**
-   * Add join from contact table to address. Prefix will be added to both tables
-   * as it's assumed you are using it to get address of a secondary contact
-   *
-   * @param string $prefix
-   */
-  public function joinAddressFromContact($prefix = '') {
-    $this->_from .= " LEFT JOIN civicrm_address {$this->_aliases[$prefix .
-    'civicrm_address']}
-      ON {$this->_aliases[$prefix .
-    'civicrm_address']}.contact_id = {$this->_aliases[$prefix .
-    'civicrm_contact']}.id";
-  }
-
-  public function joinPriceFieldValueFromLineItem() {
-    $this->_from .= " LEFT JOIN civicrm_price_field_value {$this->_aliases['civicrm_price_field_value']}
-                          ON {$this->_aliases['civicrm_line_item']}.price_field_value_id = {$this->_aliases['civicrm_price_field_value']}.id";
-  }
-
-  public function joinPriceFieldFromLineItem() {
-    $this->_from .= "
-       LEFT JOIN civicrm_price_field {$this->_aliases['civicrm_price_field']}
-      ON {$this->_aliases['civicrm_line_item']}.price_field_id = {$this->_aliases['civicrm_price_field']}.id
-     ";
-  }
-
-  /**
-   * Define join from line item table to participant table.
-   */
-  public function joinParticipantFromLineItem() {
-    $this->_from .= " LEFT JOIN civicrm_participant {$this->_aliases['civicrm_participant']}
-      ON ( {$this->_aliases['civicrm_line_item']}.entity_id = {$this->_aliases['civicrm_participant']}.id
-      AND {$this->_aliases['civicrm_line_item']}.entity_table = 'civicrm_participant')
-    ";
-  }
-
-  /**
-   * Define join from line item table to Membership table. Seems to be still via contribution
-   * as the entity. Have made 'inner' to restrict does that make sense?
-   */
-  public function joinMembershipFromLineItem() {
-    $this->_from .= " INNER JOIN civicrm_contribution {$this->_aliases['civicrm_contribution']}
-      ON ( {$this->_aliases['civicrm_line_item']}.entity_id = {$this->_aliases['civicrm_contribution']}.id
-      AND {$this->_aliases['civicrm_line_item']}.entity_table = 'civicrm_contribution')
-      LEFT JOIN civicrm_membership_payment pp
-      ON {$this->_aliases['civicrm_contribution']}.id = pp.contribution_id
-      LEFT JOIN civicrm_membership {$this->_aliases['civicrm_membership']}
-      ON pp.membership_id = {$this->_aliases['civicrm_membership']}.id
-    ";
-  }
-
-  /**
-   * Define join from Participant to Contribution table.
-   */
-  public function joinContributionFromParticipant() {
-    $this->_from .= " LEFT JOIN civicrm_participant_payment pp
-        ON {$this->_aliases['civicrm_participant']}.id = pp.participant_id
-        LEFT JOIN civicrm_contribution {$this->_aliases['civicrm_contribution']}
-        ON pp.contribution_id = {$this->_aliases['civicrm_contribution']}.id
-      ";
-  }
-
-  /**
-   * Define join from Membership to Contribution table.
-   */
-  public function joinContributionFromMembership() {
-    $this->_from .= " LEFT JOIN civicrm_membership_payment pp
-        ON {$this->_aliases['civicrm_membership']}.id = pp.membership_id
-        LEFT JOIN civicrm_contribution {$this->_aliases['civicrm_contribution']}
-        ON pp.contribution_id = {$this->_aliases['civicrm_contribution']}.id
-      ";
-  }
-
-  public function joinParticipantFromContribution() {
-    $this->_from .= " LEFT JOIN civicrm_participant_payment pp
-                          ON {$this->_aliases['civicrm_contribution']}.id = pp.contribution_id
-        LEFT JOIN civicrm_participant {$this->_aliases['civicrm_participant']}
-                          ON pp.participant_id = {$this->_aliases['civicrm_participant']}.id";
-  }
-
-  public function joinMembershipFromContribution() {
-    $this->_from .= "
-       LEFT JOIN civicrm_membership_payment pp
-      ON {$this->_aliases['civicrm_contribution']}.id = pp.contribution_id
-      LEFT JOIN civicrm_membership {$this->_aliases['civicrm_membership']}
-      ON pp.membership_id = {$this->_aliases['civicrm_membership']}.id";
-  }
-
-  public function joinMembershipTypeFromMembership() {
-    $this->_from .= "
-       LEFT JOIN civicrm_membership_type {$this->_aliases['civicrm_membership_type']}
-      ON {$this->_aliases['civicrm_membership']}.membership_type_id = {$this->_aliases['civicrm_membership_type']}.id
-      ";
-  }
-
-  public function joinContributionFromLineItem() {
-
-    // this can be stored as a temp table & indexed for more speed. Not done at this state.
-    // another option is to cache it but I haven't tried to put that code in yet (have used it before for one hour caching
-    $this->_from .= "  LEFT JOIN (SELECT line_item_civireport.id as lid, contribution_civireport_direct.*
-FROM civicrm_line_item line_item_civireport
-LEFT JOIN civicrm_contribution contribution_civireport_direct
-                       ON (line_item_civireport.line_total > 0 AND line_item_civireport.entity_id = contribution_civireport_direct.id AND line_item_civireport.entity_table = 'civicrm_contribution')
-
-
-WHERE  contribution_civireport_direct.id IS NOT NULL
-
-UNION SELECT line_item_civireport.id as lid, contribution_civireport.*
-  FROM civicrm_line_item line_item_civireport
-  LEFT JOIN civicrm_participant participant_civireport
-                          ON (line_item_civireport.line_total > 0 AND line_item_civireport.entity_id = participant_civireport.id AND line_item_civireport.entity_table = 'civicrm_participant')
-
-LEFT JOIN civicrm_participant_payment pp
-                          ON participant_civireport.id = pp.participant_id
-        LEFT JOIN civicrm_contribution contribution_civireport
-                          ON pp.contribution_id = contribution_civireport.id
-
-UNION SELECT line_item_civireport.id as lid,contribution_civireport.*
-  FROM civicrm_line_item line_item_civireport
-  LEFT JOIN civicrm_membership membership_civireport
-                          ON (line_item_civireport.line_total > 0 AND line_item_civireport.entity_id =membership_civireport.id AND line_item_civireport.entity_table = 'civicrm_membership')
-
-LEFT JOIN civicrm_membership_payment pp
-                          ON membership_civireport.id = pp.membership_id
-        LEFT JOIN civicrm_contribution contribution_civireport
-                          ON pp.contribution_id = contribution_civireport.id
-) as {$this->_aliases['civicrm_contribution']}
-  ON {$this->_aliases['civicrm_contribution']}.lid = {$this->_aliases['civicrm_line_item']}.id
- ";
-  }
-
-  public function joinLineItemFromContribution() {
-
-    // this can be stored as a temp table & indexed for more speed. Not done at this stage.
-    // another option is to cache it but I haven't tried to put that code in yet (have used it before for one hour caching
-    $this->_from .= "
-       LEFT JOIN (
-SELECT contribution_civireport_direct.id AS contid, line_item_civireport.*
-FROM civicrm_contribution contribution_civireport_direct
-LEFT JOIN civicrm_line_item line_item_civireport ON (line_item_civireport.line_total > 0 AND line_item_civireport.entity_id = contribution_civireport_direct.id AND line_item_civireport.entity_table = 'civicrm_contribution')
-WHERE line_item_civireport.id IS NOT NULL
-
-UNION
-SELECT contribution_civireport_direct.id AS contid, line_item_civireport.*
-FROM civicrm_contribution contribution_civireport_direct
-LEFT JOIN civicrm_participant_payment pp ON contribution_civireport_direct.id = pp.contribution_id
-LEFT JOIN civicrm_participant p ON pp.participant_id = p.id
-LEFT JOIN civicrm_line_item line_item_civireport ON (line_item_civireport.line_total > 0 AND line_item_civireport.entity_id = p.id AND line_item_civireport.entity_table = 'civicrm_participant')
-WHERE line_item_civireport.id IS NOT NULL
-
-UNION
-
-SELECT contribution_civireport_direct.id AS contid, line_item_civireport.*
-FROM civicrm_contribution contribution_civireport_direct
-LEFT JOIN civicrm_membership_payment pp ON contribution_civireport_direct.id = pp.contribution_id
-LEFT JOIN civicrm_membership p ON pp.membership_id = p.id
-LEFT JOIN civicrm_line_item line_item_civireport ON (line_item_civireport.line_total > 0 AND line_item_civireport.entity_id = p.id AND line_item_civireport.entity_table = 'civicrm_membership')
-WHERE   line_item_civireport.id IS NOT NULL
-) as {$this->_aliases['civicrm_line_item']}
-  ON {$this->_aliases['civicrm_line_item']}.contid = {$this->_aliases['civicrm_contribution']}.id
-
-
-  ";
-  }
-
-  public function joinLineItemFromMembership() {
-
-    // this can be stored as a temp table & indexed for more speed. Not done at this stage.
-    // another option is to cache it but I haven't tried to put that code in yet (have used it before for one hour caching
-    $this->_from .= "
-       LEFT JOIN (
-SELECT contribution_civireport_direct.id AS contid, line_item_civireport.*
-FROM civicrm_contribution contribution_civireport_direct
-LEFT JOIN civicrm_line_item line_item_civireport
-ON (line_item_civireport.line_total > 0 AND line_item_civireport.entity_id = contribution_civireport_direct.id AND line_item_civireport.entity_table = 'civicrm_contribution')
-
-WHERE   line_item_civireport.id IS NOT NULL
-
-UNION
-
-SELECT contribution_civireport_direct.id AS contid, line_item_civireport.*
-FROM civicrm_contribution contribution_civireport_direct
-LEFT JOIN civicrm_membership_payment pp ON contribution_civireport_direct.id = pp.contribution_id
-LEFT JOIN civicrm_membership p ON pp.membership_id = p.id
-LEFT JOIN civicrm_line_item line_item_civireport ON (line_item_civireport.line_total > 0 AND line_item_civireport.entity_id = p.id AND line_item_civireport.entity_table = 'civicrm_membership')
-WHERE   line_item_civireport.id IS NOT NULL
-) as {$this->_aliases['civicrm_line_item']}
-  ON {$this->_aliases['civicrm_line_item']}.contid = {$this->_aliases['civicrm_contribution']}.id
-  ";
-  }
-
-  public function joinContactFromParticipant() {
-    $this->_from .= " LEFT JOIN civicrm_contact {$this->_aliases['civicrm_contact']}
-                          ON {$this->_aliases['civicrm_participant']}.contact_id = {$this->_aliases['civicrm_contact']}.id";
-  }
-
-  public function joinContactFromMembership() {
-    $this->_from .= " LEFT JOIN civicrm_contact {$this->_aliases['civicrm_contact']}
-                          ON {$this->_aliases['civicrm_membership']}.contact_id = {$this->_aliases['civicrm_contact']}.id";
-  }
-
-  public function joinContactFromContribution() {
-    $this->_from .= " LEFT JOIN civicrm_contact {$this->_aliases['civicrm_contact']}
-                          ON {$this->_aliases['civicrm_contribution']}.contact_id = {$this->_aliases['civicrm_contact']}.id";
-  }
-
-  public function joinEventFromParticipant() {
-    $this->_from .= "  LEFT JOIN civicrm_event {$this->_aliases['civicrm_event']}
-                    ON ({$this->_aliases['civicrm_event']}.id = {$this->_aliases['civicrm_participant']}.event_id ) AND
-                       ({$this->_aliases['civicrm_event']}.is_template IS NULL OR
-                        {$this->_aliases['civicrm_event']}.is_template = 0)";
-  }
-
-  /**
-   * Retrieve text for financial type from pseudoconstant.
-   *
-   * @param $value
-   * @param array $row
-   *
-   * @return string
-   */
-  public function alterNickName($value, &$row) {
-    if (empty($row['civicrm_contact_id'])) {
-      return NULL;
-    }
-    $contactID = $row['civicrm_contact_id'];
-    return "<div id=contact-{$contactID} class='crm-entity'>
-           <span class='crm-editable crmf-nick_name crm-editable-enabled'>
-           " . $value . "</span></div>";
-  }
-
-  /**
-   * Retrieve text for contribution type from pseudoconstant.
-   *
-   * @param $value
-   * @param array $row
-   *
-   * @return array|string
-   */
-  public function alterContributionType($value, &$row) {
-    return is_string(CRM_Contribute_PseudoConstant::financialType($value, FALSE)) ? CRM_Contribute_PseudoConstant::financialType($value, FALSE) : '';
-  }
-
-  /**
-   * Retrieve text for contribution status from pseudoconstant.
-   *
-   * @param $value
-   * @param array $row
-   *
-   * @return array
-   */
-  public function alterContributionStatus($value, &$row) {
-    return CRM_Contribute_PseudoConstant::contributionStatus($value);
-  }
-
-  /**
-   * Retrieve text for payment instrument from pseudoconstant.
-   *
-   * @param $value
-   * @param array $row
-   *
-   * @return array
-   */
-  public function alterEventType($value, &$row) {
-    return CRM_Event_PseudoConstant::eventType($value);
-  }
-
-  /**
-   * @param $value
-   * @param array $row
-   *
-   * @return array|string
-   */
-  public function alterEventID($value, &$row) {
-    return is_string(CRM_Event_PseudoConstant::event($value, FALSE)) ? CRM_Event_PseudoConstant::event($value, FALSE) : '';
-  }
-
-  /**
-   * @param $value
-   * @param array $row
-   *
-   * @return array|string
-   */
-  public function alterMembershipTypeID($value, &$row) {
-    return is_string(CRM_Member_PseudoConstant::membershipType($value, FALSE)) ? CRM_Member_PseudoConstant::membershipType($value, FALSE) : '';
-  }
-
-  /**
-   * @param $value
-   * @param array $row
-   *
-   * @return array|string
-   */
-  public function alterMembershipStatusID($value, &$row) {
-    return is_string(CRM_Member_PseudoConstant::membershipStatus($value, FALSE)) ? CRM_Member_PseudoConstant::membershipStatus($value, FALSE) : '';
-  }
-
-  /**
-   * @param $value
-   * @param array $row
-   * @param $selectedfield
-   * @param string $criteriaFieldName
-   *
-   * @return array
-   */
-  public function alterCountryID($value, &$row, $selectedfield, $criteriaFieldName) {
-    $url = CRM_Utils_System::url(CRM_Utils_System::currentPath(), "reset=1&force=1&{$criteriaFieldName}_op=in&{$criteriaFieldName}_value={$value}", $this->_absoluteUrl);
-    $row[$selectedfield . '_link'] = $url;
-    $row[$selectedfield .
-    '_hover'] = ts("%1 for this country.", [1 => $value]);
-    $countries = CRM_Core_PseudoConstant::country($value, FALSE);
-    if (!is_array($countries)) {
-      return $countries;
-    }
-  }
-
-  /**
-   * @param $value
-   * @param array $row
-   * @param $selectedfield
-   * @param string $criteriaFieldName
-   *
-   * @return array
-   */
-  public function alterCountyID($value, &$row, $selectedfield, $criteriaFieldName) {
-    $url = CRM_Utils_System::url(CRM_Utils_System::currentPath(), "reset=1&force=1&{$criteriaFieldName}_op=in&{$criteriaFieldName}_value={$value}", $this->_absoluteUrl);
-    $row[$selectedfield . '_link'] = $url;
-    $row[$selectedfield .
-    '_hover'] = ts("%1 for this county.", [1 => $value]);
-    $counties = CRM_Core_PseudoConstant::county($value, FALSE);
-    if (!is_array($counties)) {
-      return $counties;
-    }
-  }
-
-  /**
-   * @param $value
-   * @param array $row
-   * @param $selectedfield
-   * @param string $criteriaFieldName
-   *
-   * @return array
-   */
-  public function alterStateProvinceID($value, &$row, $selectedfield, $criteriaFieldName) {
-    $url = CRM_Utils_System::url(CRM_Utils_System::currentPath(), "reset=1&force=1&{$criteriaFieldName}_op=in&{$criteriaFieldName}_value={$value}", $this->_absoluteUrl);
-    $row[$selectedfield . '_link'] = $url;
-    $row[$selectedfield .
-    '_hover'] = ts("%1 for this state.", [1 => $value]);
-
-    $states = CRM_Core_PseudoConstant::stateProvince($value, FALSE);
-    if (!is_array($states)) {
-      return $states;
-    }
-  }
-
-  /**
-   * @param $value
-   * @param array $row
-   * @param string $fieldname
-   *
-   * @return mixed
-   */
-  public function alterContactID($value, &$row, $fieldname) {
-    $row[$fieldname . '_link'] = CRM_Utils_System::url("civicrm/contact/view",
-      'reset=1&cid=' . $value, $this->_absoluteUrl);
-    return $value;
-  }
-
-  /**
-   * @param $value
-   *
-   * @return array
-   */
-  public function alterParticipantStatus($value) {
-    if (empty($value)) {
-      return NULL;
-    }
-    return CRM_Event_PseudoConstant::participantStatus($value, FALSE, 'label');
-  }
-
-  /**
-   * @param $value
-   *
-   * @return string|void
-   */
-  public function alterParticipantRole($value) {
-    if (empty($value)) {
-      return NULL;
-    }
-    $roles = explode(CRM_Core_DAO::VALUE_SEPARATOR, $value);
-    $value = [];
-    foreach ($roles as $role) {
-      $value[$role] = CRM_Event_PseudoConstant::participantRole($role, FALSE);
-    }
-    return implode(', ', $value);
-  }
-
-  /**
-   * @param $value
-   *
-   * @return mixed
-   */
-  public function alterPaymentType($value) {
-    $paymentInstruments = CRM_Contribute_PseudoConstant::paymentInstrument();
-    return $paymentInstruments[$value];
-  }
-
-}
diff --git a/civicrm/CRM/Report/Utils/Get.php b/civicrm/CRM/Report/Utils/Get.php
index 02d9b57309619b52a4eb924da9483d88a9398614..992ff2c082a95c8ddc66a411bef17e46cfd23c05 100644
--- a/civicrm/CRM/Report/Utils/Get.php
+++ b/civicrm/CRM/Report/Utils/Get.php
@@ -178,6 +178,11 @@ class CRM_Report_Utils_Get {
         }
         break;
 
+      case 'nll':
+      case 'nnll':
+        $defaults["{$fieldName}_op"] = $fieldOP;
+        break;
+
       case 'in':
       case 'notin':
         // send the type as string so that multiple values can also be retrieved from url.
diff --git a/civicrm/CRM/SMS/DAO/Provider.php b/civicrm/CRM/SMS/DAO/Provider.php
index 969c212421af96a0f22fd1e94b717c9c862734f9..36da579b4f1c4f0abfa5a4952dba08ada39571e2 100644
--- a/civicrm/CRM/SMS/DAO/Provider.php
+++ b/civicrm/CRM/SMS/DAO/Provider.php
@@ -132,6 +132,7 @@ class CRM_SMS_DAO_Provider extends CRM_Core_DAO {
           'title' => ts('SMS Provider ID'),
           'description' => ts('SMS Provider ID'),
           'required' => TRUE,
+          'where' => 'civicrm_sms_provider.id',
           'table_name' => 'civicrm_sms_provider',
           'entity' => 'Provider',
           'bao' => 'CRM_SMS_BAO_Provider',
@@ -144,6 +145,7 @@ class CRM_SMS_DAO_Provider extends CRM_Core_DAO {
           'description' => ts('Provider internal name points to option_value of option_group sms_provider_name'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_sms_provider.name',
           'table_name' => 'civicrm_sms_provider',
           'entity' => 'Provider',
           'bao' => 'CRM_SMS_BAO_Provider',
@@ -156,6 +158,7 @@ class CRM_SMS_DAO_Provider extends CRM_Core_DAO {
           'description' => ts('Provider name visible to user'),
           'maxlength' => 64,
           'size' => CRM_Utils_Type::BIG,
+          'where' => 'civicrm_sms_provider.title',
           'table_name' => 'civicrm_sms_provider',
           'entity' => 'Provider',
           'bao' => 'CRM_SMS_BAO_Provider',
@@ -170,6 +173,7 @@ class CRM_SMS_DAO_Provider extends CRM_Core_DAO {
           'title' => ts('SMS Provider Username'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_sms_provider.username',
           'table_name' => 'civicrm_sms_provider',
           'entity' => 'Provider',
           'bao' => 'CRM_SMS_BAO_Provider',
@@ -184,6 +188,7 @@ class CRM_SMS_DAO_Provider extends CRM_Core_DAO {
           'title' => ts('SMS Provider Password'),
           'maxlength' => 255,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_sms_provider.password',
           'table_name' => 'civicrm_sms_provider',
           'entity' => 'Provider',
           'bao' => 'CRM_SMS_BAO_Provider',
@@ -198,6 +203,7 @@ class CRM_SMS_DAO_Provider extends CRM_Core_DAO {
           'title' => ts('SMS Provider API'),
           'description' => ts('points to value in civicrm_option_value for group sms_api_type'),
           'required' => TRUE,
+          'where' => 'civicrm_sms_provider.api_type',
           'table_name' => 'civicrm_sms_provider',
           'entity' => 'Provider',
           'bao' => 'CRM_SMS_BAO_Provider',
@@ -212,6 +218,7 @@ class CRM_SMS_DAO_Provider extends CRM_Core_DAO {
           'title' => ts('SMS Provider API URL'),
           'maxlength' => 128,
           'size' => CRM_Utils_Type::HUGE,
+          'where' => 'civicrm_sms_provider.api_url',
           'table_name' => 'civicrm_sms_provider',
           'entity' => 'Provider',
           'bao' => 'CRM_SMS_BAO_Provider',
@@ -225,6 +232,7 @@ class CRM_SMS_DAO_Provider extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_TEXT,
           'title' => ts('SMS Provider API Params'),
           'description' => ts('the api params in xml, http or smtp format'),
+          'where' => 'civicrm_sms_provider.api_params',
           'table_name' => 'civicrm_sms_provider',
           'entity' => 'Provider',
           'bao' => 'CRM_SMS_BAO_Provider',
@@ -237,6 +245,7 @@ class CRM_SMS_DAO_Provider extends CRM_Core_DAO {
           'name' => 'is_default',
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('SMS Provider is Default?'),
+          'where' => 'civicrm_sms_provider.is_default',
           'default' => '0',
           'table_name' => 'civicrm_sms_provider',
           'entity' => 'Provider',
@@ -250,6 +259,7 @@ class CRM_SMS_DAO_Provider extends CRM_Core_DAO {
           'name' => 'is_active',
           'type' => CRM_Utils_Type::T_BOOLEAN,
           'title' => ts('SMS Provider is Active?'),
+          'where' => 'civicrm_sms_provider.is_active',
           'default' => '0',
           'table_name' => 'civicrm_sms_provider',
           'entity' => 'Provider',
@@ -264,6 +274,7 @@ class CRM_SMS_DAO_Provider extends CRM_Core_DAO {
           'type' => CRM_Utils_Type::T_INT,
           'title' => ts('SMS Domain'),
           'description' => ts('Which Domain is this sms provider for'),
+          'where' => 'civicrm_sms_provider.domain_id',
           'table_name' => 'civicrm_sms_provider',
           'entity' => 'Provider',
           'bao' => 'CRM_SMS_BAO_Provider',
diff --git a/civicrm/CRM/SMS/Form/Schedule.php b/civicrm/CRM/SMS/Form/Schedule.php
index 82c3e594ff900539cbd30368802f184e72e23ce2..4a1fdefb4fe56b7b30b1d575ccbb333cbdc3de1a 100644
--- a/civicrm/CRM/SMS/Form/Schedule.php
+++ b/civicrm/CRM/SMS/Form/Schedule.php
@@ -67,8 +67,8 @@ class CRM_SMS_Form_Schedule extends CRM_Core_Form {
     $this->setAttribute('autocomplete', 'off');
 
     $sendOptions = [
-      $this->createElement('radio', NULL, NULL, 'Send immediately', 'send_immediate', ['id' => 'send_immediate', 'style' => 'margin-bottom: 10px;']),
-      $this->createElement('radio', NULL, NULL, 'Send at:', 'send_later', ['id' => 'send_later']),
+      $this->createElement('radio', NULL, NULL, ts('Send immediately'), 'send_immediate', ['id' => 'send_immediate', 'style' => 'margin-bottom: 10px;']),
+      $this->createElement('radio', NULL, NULL, ts('Send at:'), 'send_later', ['id' => 'send_later']),
     ];
     $this->addGroup($sendOptions, 'send_option', '', '<br>');
 
diff --git a/civicrm/CRM/UF/Form/Field.php b/civicrm/CRM/UF/Form/Field.php
index 9086dfc0b17fd18b31fc925a853082886cc89f17..8640d593f07e0cb7ee0fd41d316b11b32cf04d16 100644
--- a/civicrm/CRM/UF/Form/Field.php
+++ b/civicrm/CRM/UF/Form/Field.php
@@ -531,13 +531,8 @@ class CRM_UF_Form_Field extends CRM_Core_Form {
       $name = $this->_selectFields[$params['field_name'][1]];
     }
 
-    //Hack for Formatting Field Name
-    if ($params['field_name'][0] == 'Formatting') {
-      $fieldName = 'formatting_' . rand(1000, 9999);
-    }
-    else {
-      $fieldName = $params['field_name'][1];
-    }
+    // If field_name is missing, it's formatting
+    $fieldName = CRM_Utils_Array::value(1, $params['field_name'], 'formatting');
 
     //check for duplicate fields
     $apiFormattedParams = $params;
diff --git a/civicrm/CRM/Upgrade/Form.php b/civicrm/CRM/Upgrade/Form.php
index 483125451f1d7e7e6117121bd174a753297f77c6..313484198fbdba8be411622ab457e97a8ac3bf0c 100644
--- a/civicrm/CRM/Upgrade/Form.php
+++ b/civicrm/CRM/Upgrade/Form.php
@@ -49,6 +49,9 @@ class CRM_Upgrade_Form extends CRM_Core_Form {
 
   /**
    * Minimum php version required to run (equal to or lower than the minimum install version)
+   *
+   * Even though 5.6 is no longer supported, this value is left here for a while
+   * so as not to block stragglers from upgrading.
    */
   const MINIMUM_PHP_VERSION = '5.6';
 
diff --git a/civicrm/CRM/Upgrade/Incremental/General.php b/civicrm/CRM/Upgrade/Incremental/General.php
index 6bad3517082a500d747bf96107c7a376f0cc1f6e..67763939fffee382306d4b3411cbb8e60ae737cb 100644
--- a/civicrm/CRM/Upgrade/Incremental/General.php
+++ b/civicrm/CRM/Upgrade/Incremental/General.php
@@ -53,7 +53,7 @@ class CRM_Upgrade_Incremental_General {
    *
    * @see install/index.php
    */
-  const MIN_INSTALL_PHP_VER = '5.6';
+  const MIN_INSTALL_PHP_VER = '7.0';
 
   /**
    * Compute any messages which should be displayed before upgrade.
@@ -104,7 +104,7 @@ class CRM_Upgrade_Incremental_General {
       // ignore the matter and simply run CRM_Core_InnoDBIndexer::fixSchemaDifferences
       // after the upgrade.  But that's speculative.  For now, we'll leave this
       // advanced feature in the hands of the sysadmin.
-      $preUpgradeMessage .= '<br />' . ts('This database uses InnoDB Full Text Search for optimized searching. The upgrade procedure has not been tested with this feature. You should disable (and later re-enable) the feature by navigating to "Administer => System Settings => Miscellaneous".');
+      $preUpgradeMessage .= '<br />' . ts('This database uses InnoDB Full Text Search for optimized searching. The upgrade procedure has not been tested with this feature. You should disable (and later re-enable) the feature by navigating to "Administer => Customize Data and Screens => Search Preferences".');
     }
 
     $ftAclSetting = Civi::settings()->get('acl_financial_type');
diff --git a/civicrm/CRM/Upgrade/Incremental/php/FiveFourteen.php b/civicrm/CRM/Upgrade/Incremental/php/FiveFourteen.php
new file mode 100644
index 0000000000000000000000000000000000000000..97bca1d3700aec8132c7f742f793d529e6ac5135
--- /dev/null
+++ b/civicrm/CRM/Upgrade/Incremental/php/FiveFourteen.php
@@ -0,0 +1,106 @@
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 5                                                  |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2019                                |
+ +--------------------------------------------------------------------+
+ | This file is a part of CiviCRM.                                    |
+ |                                                                    |
+ | CiviCRM is free software; you can copy, modify, and distribute it  |
+ | under the terms of the GNU Affero General Public License           |
+ | Version 3, 19 November 2007.                                       |
+ |                                                                    |
+ | CiviCRM is distributed in the hope that it will be useful, but     |
+ | WITHOUT ANY WARRANTY; without even the implied warranty of         |
+ | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.               |
+ | See the GNU Affero General Public License for more details.        |
+ |                                                                    |
+ | You should have received a copy of the GNU Affero General Public   |
+ | License along with this program; if not, contact CiviCRM LLC       |
+ | at info[AT]civicrm[DOT]org. If you have questions about the        |
+ | GNU Affero General Public License or the licensing of CiviCRM,     |
+ | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
+ +--------------------------------------------------------------------+
+ */
+
+/**
+ * Upgrade logic for FiveFourteen */
+class CRM_Upgrade_Incremental_php_FiveFourteen extends CRM_Upgrade_Incremental_Base {
+
+  /**
+   * Compute any messages which should be displayed beforeupgrade.
+   *
+   * Note: This function is called iteratively for each upcoming
+   * revision to the database.
+   *
+   * @param string $preUpgradeMessage
+   * @param string $rev
+   *   a version number, e.g. '4.4.alpha1', '4.4.beta3', '4.4.0'.
+   * @param null $currentVer
+   */
+  public function setPreUpgradeMessage(&$preUpgradeMessage, $rev, $currentVer = NULL) {
+    // Example: Generate a pre-upgrade message.
+    // if ($rev == '5.12.34') {
+    //   $preUpgradeMessage .= '<p>' . ts('A new permission, "%1", has been added. This permission is now used to control access to the Manage Tags screen.', array(1 => ts('manage tags'))) . '</p>';
+    // }
+  }
+
+  /**
+   * Compute any messages which should be displayed after upgrade.
+   *
+   * @param string $postUpgradeMessage
+   *   alterable.
+   * @param string $rev
+   *   an intermediate version; note that setPostUpgradeMessage is called repeatedly with different $revs.
+   */
+  public function setPostUpgradeMessage(&$postUpgradeMessage, $rev) {
+    // Example: Generate a post-upgrade message.
+    // if ($rev == '5.12.34') {
+    //   $postUpgradeMessage .= '<br /><br />' . ts("By default, CiviCRM now disables the ability to import directly from SQL. To use this feature, you must explicitly grant permission 'import SQL datasource'.");
+    // }
+  }
+
+  /*
+   * Important! All upgrade functions MUST add a 'runSql' task.
+   * Uncomment and use the following template for a new upgrade version
+   * (change the x in the function name):
+   */
+
+  /**
+   * Upgrade function.
+   *
+   * @param string $rev
+   */
+  public function upgrade_5_14_alpha1($rev) {
+    $this->addTask(ts('Upgrade DB to %1: SQL', array(1 => $rev)), 'runSql', $rev);
+
+    // Only need to rebuild view if CiviCase is enabled: otherwise will be
+    // rebuilt when component is enabled
+    $config = CRM_Core_Config::singleton();
+    if (in_array('CiviCase', $config->enableComponents)) {
+      $this->addTask('Rebuild case activity views', 'rebuildCaseActivityView', $rev);
+    }
+    // Additional tasks here...
+    // Note: do not use ts() in the addTask description because it adds unnecessary strings to transifex.
+    // The above is an exception because 'Upgrade DB to %1: SQL' is generic & reusable.
+  }
+
+  /**
+   * Rebuild the view of recent and upcoming case activities
+   *
+   * See https://github.com/civicrm/civicrm-core/pull/14086 and
+   * https://lab.civicrm.org/dev/core/issues/832
+   *
+   * @param CRM_Queue_TaskContext $ctx
+   * @return bool
+   */
+  public static function rebuildCaseActivityView($ctx) {
+    if (!CRM_Case_BAO_Case::createCaseViews()) {
+      CRM_Core_Error::debug_log_message(ts("Could not create the MySQL views for CiviCase. Your mysql user needs to have the 'CREATE VIEW' permission"));
+      return FALSE;
+    }
+    return TRUE;
+  }
+
+}
diff --git a/civicrm/CRM/Upgrade/Incremental/sql/5.13.0.mysql.tpl b/civicrm/CRM/Upgrade/Incremental/sql/5.13.0.mysql.tpl
deleted file mode 100644
index f201cffd27510e4e1bee00856a01a812374c77da..0000000000000000000000000000000000000000
--- a/civicrm/CRM/Upgrade/Incremental/sql/5.13.0.mysql.tpl
+++ /dev/null
@@ -1 +0,0 @@
-{* file to handle db changes in 5.13.0 during upgrade *}
diff --git a/civicrm/CRM/Upgrade/Incremental/sql/5.13.1.mysql.tpl b/civicrm/CRM/Upgrade/Incremental/sql/5.13.1.mysql.tpl
deleted file mode 100644
index b505b4d89dd6b7a4287da1a37801efb0d42eedb8..0000000000000000000000000000000000000000
--- a/civicrm/CRM/Upgrade/Incremental/sql/5.13.1.mysql.tpl
+++ /dev/null
@@ -1 +0,0 @@
-{* file to handle db changes in 5.13.1 during upgrade *}
diff --git a/civicrm/CRM/Upgrade/Incremental/sql/5.13.2.mysql.tpl b/civicrm/CRM/Upgrade/Incremental/sql/5.13.2.mysql.tpl
deleted file mode 100644
index 62914f14d36c4bce282134a4b53e0b090943da76..0000000000000000000000000000000000000000
--- a/civicrm/CRM/Upgrade/Incremental/sql/5.13.2.mysql.tpl
+++ /dev/null
@@ -1 +0,0 @@
-{* file to handle db changes in 5.13.2 during upgrade *}
diff --git a/civicrm/CRM/Upgrade/Incremental/sql/5.13.3.mysql.tpl b/civicrm/CRM/Upgrade/Incremental/sql/5.13.3.mysql.tpl
deleted file mode 100644
index e342ef845e17161dfd0abae8c648f7153eb2e3bc..0000000000000000000000000000000000000000
--- a/civicrm/CRM/Upgrade/Incremental/sql/5.13.3.mysql.tpl
+++ /dev/null
@@ -1 +0,0 @@
-{* file to handle db changes in 5.13.3 during upgrade *}
diff --git a/civicrm/CRM/Upgrade/Incremental/sql/5.13.4.mysql.tpl b/civicrm/CRM/Upgrade/Incremental/sql/5.13.4.mysql.tpl
deleted file mode 100644
index 94e0312abc887abb5512fb647a1d7c0d0995a486..0000000000000000000000000000000000000000
--- a/civicrm/CRM/Upgrade/Incremental/sql/5.13.4.mysql.tpl
+++ /dev/null
@@ -1 +0,0 @@
-{* file to handle db changes in 5.13.4 during upgrade *}
diff --git a/civicrm/CRM/Upgrade/Incremental/sql/5.13.5.mysql.tpl b/civicrm/CRM/Upgrade/Incremental/sql/5.13.5.mysql.tpl
deleted file mode 100644
index cd0ca8eef8e601642fb828ed8b9457413b2baedf..0000000000000000000000000000000000000000
--- a/civicrm/CRM/Upgrade/Incremental/sql/5.13.5.mysql.tpl
+++ /dev/null
@@ -1 +0,0 @@
-{* file to handle db changes in 5.13.5 during upgrade *}
diff --git a/civicrm/CRM/Upgrade/Incremental/sql/5.14.0.mysql.tpl b/civicrm/CRM/Upgrade/Incremental/sql/5.14.0.mysql.tpl
new file mode 100644
index 0000000000000000000000000000000000000000..02ea631ca845739f71ada122c725560bf88687f3
--- /dev/null
+++ b/civicrm/CRM/Upgrade/Incremental/sql/5.14.0.mysql.tpl
@@ -0,0 +1 @@
+{* file to handle db changes in 5.14.0 during upgrade *}
diff --git a/civicrm/CRM/Upgrade/Incremental/sql/5.14.alpha1.mysql.tpl b/civicrm/CRM/Upgrade/Incremental/sql/5.14.alpha1.mysql.tpl
new file mode 100644
index 0000000000000000000000000000000000000000..051f6eac085d5303f43b3721674bf7b3b381936e
--- /dev/null
+++ b/civicrm/CRM/Upgrade/Incremental/sql/5.14.alpha1.mysql.tpl
@@ -0,0 +1 @@
+{* file to handle db changes in 5.14.alpha1 during upgrade *}
diff --git a/civicrm/CRM/Upgrade/Incremental/sql/5.14.beta1.mysql.tpl b/civicrm/CRM/Upgrade/Incremental/sql/5.14.beta1.mysql.tpl
new file mode 100644
index 0000000000000000000000000000000000000000..b596224cccbc9c8abbf8267331856e997a26122b
--- /dev/null
+++ b/civicrm/CRM/Upgrade/Incremental/sql/5.14.beta1.mysql.tpl
@@ -0,0 +1,7 @@
+{* file to handle db changes in 5.14.beta1 during upgrade *}
+
+SELECT @option_group_id_sfe            := max(id) from civicrm_option_group where name = 'safe_file_extension';
+
+INSERT INTO `civicrm_option_value` (`option_group_id`,  {localize field='label'}label{/localize}, `value`, `name`, `grouping`, `filter`, `is_default`, `weight`,  {localize field='description'}description{/localize}, `is_optgroup`, `is_reserved`, `is_active`, `component_id`, `visibility_id`, `icon`)
+VALUES  (@option_group_id_sfe, {localize}'ics'{/localize},  15, 'ics',   NULL, 0, 0, 15, {localize}NULL{/localize}, 0, 0, 1, NULL, NULL, NULL);
+
diff --git a/civicrm/CRM/Utils/Check/Component/Env.php b/civicrm/CRM/Utils/Check/Component/Env.php
index cbc58df44c1c91166aaf7ad0a84d6c1136ad823f..4ecc374275cf072277e5ff2a97b8c3115cc6427b 100644
--- a/civicrm/CRM/Utils/Check/Component/Env.php
+++ b/civicrm/CRM/Utils/Check/Component/Env.php
@@ -303,6 +303,10 @@ class CRM_Utils_Check_Component_Env extends CRM_Utils_Check_Component {
       );
     }
     else {
+      $cronLink = 'target="_blank" href="' . htmlentities(CRM_Utils_System::docURL2('sysadmin/setup/jobs/', TRUE)) . '""';
+      $msg .= '<p>' . ts('To enable scheduling support, please <a %1>set up the cron job</a>.', [
+        1 => $cronLink,
+      ]) . '</p>';
       $message = new CRM_Utils_Check_Message(
         __FUNCTION__,
         $msg,
@@ -310,11 +314,6 @@ class CRM_Utils_Check_Component_Env extends CRM_Utils_Check_Component {
         ($lastCron > gmdate('U') - 86400) ? \Psr\Log\LogLevel::WARNING : \Psr\Log\LogLevel::ERROR,
         'fa-clock-o'
       );
-      $docUrl = 'target="_blank" href="' . CRM_Utils_System::docURL(['resource' => 'wiki', 'page' => 'Managing Scheduled Jobs', 'URLonly' => TRUE]) . '""';
-      $message->addHelp(
-        ts('Configuring cron on your server is necessary for running scheduled jobs such as sending mail and scheduled reminders.') . '<br />' .
-        ts("Learn more in the <a %1>online documentation</a>.", [1 => $docUrl])
-      );
       $messages[] = $message;
     }
 
diff --git a/civicrm/CRM/Utils/Check/Component/FinancialTypeAcls.php b/civicrm/CRM/Utils/Check/Component/FinancialTypeAcls.php
index b641a6b8849022d3494a660462e0c4404fd514ea..d8a435d004ab51c476bedf692a323a2e321fc8fa 100644
--- a/civicrm/CRM/Utils/Check/Component/FinancialTypeAcls.php
+++ b/civicrm/CRM/Utils/Check/Component/FinancialTypeAcls.php
@@ -35,8 +35,8 @@ class CRM_Utils_Check_Component_FinancialTypeAcls extends CRM_Utils_Check_Compon
   public static function checkFinancialAclReport() {
     $messages = [];
     $ftAclSetting = Civi::settings()->get('acl_financial_type');
-    $financialAclExtension = civicrm_api3('extension', 'get', ['key' => 'biz.jmaconsulting.financialaclreport']);
-    if ($ftAclSetting && (($financialAclExtension['count'] == 1 && $financialAclExtension['status'] != 'Installed') || $financialAclExtension['count'] !== 1)) {
+    $financialAclExtension = civicrm_api3('extension', 'get', ['key' => 'biz.jmaconsulting.financialaclreport', 'sequential' => 1]);
+    if ($ftAclSetting && (($financialAclExtension['count'] == 1 && $financialAclExtension['values'][0]['status'] != 'Installed') || $financialAclExtension['count'] !== 1)) {
       $messages[] = new CRM_Utils_Check_Message(
         __FUNCTION__,
         ts('CiviCRM will in the future require the extension %1 for CiviCRM Reports to work correctly with the Financial Type ACLs. The extension can be downloaded <a href="%2">here</a>', [
diff --git a/civicrm/CRM/Utils/Hook.php b/civicrm/CRM/Utils/Hook.php
index a47f3076d7f7fb8b10009033570498125f853c82..9a48148b9f1b81f42013f887814da337e4e1c893 100644
--- a/civicrm/CRM/Utils/Hook.php
+++ b/civicrm/CRM/Utils/Hook.php
@@ -2217,6 +2217,24 @@ abstract class CRM_Utils_Hook {
     Civi::dispatcher()->dispatch('hook_civicrm_alterAngular', $event);
   }
 
+  /**
+   * This hook is called when building a link to a semi-static asset.
+   *
+   * @param string $asset
+   *   The name of the asset.
+   *   Ex: 'angular.json'
+   * @param array $params
+   *   List of optional arguments which influence the content.
+   * @return null
+   *   the return value is ignored
+   */
+  public static function getAssetUrl(&$asset, &$params) {
+    return self::singleton()->invoke(['asset', 'params'],
+      $asset, $params, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
+      'civicrm_getAssetUrl'
+    );
+  }
+
   /**
    * This hook is called whenever the system builds a new copy of
    * semi-static asset.
@@ -2386,9 +2404,6 @@ abstract class CRM_Utils_Hook {
    * @param string $region
    */
   public static function coreResourceList(&$list, $region) {
-    // First allow the cms integration to add to the list
-    CRM_Core_Config::singleton()->userSystem->appendCoreResources($list);
-
     self::singleton()->invoke(['list', 'region'], $list, $region,
       self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject,
       'civicrm_coreResourceList'
diff --git a/civicrm/CRM/Utils/System.php b/civicrm/CRM/Utils/System.php
index 1ac8d03d0be294cc14ffbf11bf05597ab8051e4e..4706b2672cf96f8f20a18eeec7df7b47e47c0069 100644
--- a/civicrm/CRM/Utils/System.php
+++ b/civicrm/CRM/Utils/System.php
@@ -51,6 +51,8 @@
  * @method static int getLoggedInUfID() Get current logged in user id.
  * @method static setHttpHeader(string $name, string $value) Set http header.
  * @method static array synchronizeUsers() Create CRM contacts for all existing CMS users.
+ * @method static appendCoreResources(\Civi\Core\Event\GenericHookEvent $e) Callback for hook_civicrm_coreResourceList.
+ * @method static alterAssetUrl(\Civi\Core\Event\GenericHookEvent $e) Callback for hook_civicrm_getAssetUrl.
  */
 class CRM_Utils_System {
 
@@ -1385,7 +1387,7 @@ class CRM_Utils_System {
    * @return mixed
    */
   public static function formatDocUrl($url) {
-    return preg_replace('#^user/#', 'user/en/stable/', $url);
+    return preg_replace('#^(user|sysadmin|dev)/#', '\1/en/stable/', $url);
   }
 
   /**
diff --git a/civicrm/CRM/Utils/System/Backdrop.php b/civicrm/CRM/Utils/System/Backdrop.php
index 7a3589a250a6ed37f5e4fba32a78f17adf0263b4..9c22b6b86b332ba3e7008d38b945df1f89dadddd 100644
--- a/civicrm/CRM/Utils/System/Backdrop.php
+++ b/civicrm/CRM/Utils/System/Backdrop.php
@@ -1042,11 +1042,11 @@ AND    u.status = 1
   /**
    * Append Backdrop CSS and JS to coreResourcesList.
    *
-   * @param array $list
+   * @param \Civi\Core\Event\GenericHookEvent $e
    */
-  public function appendCoreResources(&$list) {
-    $list[] = 'css/backdrop.css';
-    $list[] = 'js/crm.backdrop.js';
+  public function appendCoreResources(\Civi\Core\Event\GenericHookEvent $e) {
+    $e->list[] = 'css/backdrop.css';
+    $e->list[] = 'js/crm.backdrop.js';
   }
 
 }
diff --git a/civicrm/CRM/Utils/System/Base.php b/civicrm/CRM/Utils/System/Base.php
index bf6830d8e49f4c77c7a18e7e675adcc3afec0e20..8bb09e260fcd1a8cfec59cf5bb801894ab9dc5bb 100644
--- a/civicrm/CRM/Utils/System/Base.php
+++ b/civicrm/CRM/Utils/System/Base.php
@@ -914,9 +914,17 @@ abstract class CRM_Utils_System_Base {
   /**
    * Append to coreResourcesList.
    *
-   * @param array $list
+   * @param \Civi\Core\Event\GenericHookEvent $e
    */
-  public function appendCoreResources(&$list) {
+  public function appendCoreResources(\Civi\Core\Event\GenericHookEvent $e) {
+  }
+
+  /**
+   * Modify dynamic assets.
+   *
+   * @param \Civi\Core\Event\GenericHookEvent $e
+   */
+  public function alterAssetUrl(\Civi\Core\Event\GenericHookEvent $e) {
   }
 
   /**
diff --git a/civicrm/CRM/Utils/System/Drupal8.php b/civicrm/CRM/Utils/System/Drupal8.php
index d34007e5478a70174d8439b8bbf5fec9c003b55c..e280a40ba76f7db806c9150250eb0b9ea299cbd4 100644
--- a/civicrm/CRM/Utils/System/Drupal8.php
+++ b/civicrm/CRM/Utils/System/Drupal8.php
@@ -667,10 +667,10 @@ class CRM_Utils_System_Drupal8 extends CRM_Utils_System_DrupalBase {
   /**
    * Append Drupal8 js to coreResourcesList.
    *
-   * @param array $list
+   * @param \Civi\Core\Event\GenericHookEvent $e
    */
-  public function appendCoreResources(&$list) {
-    $list[] = 'js/crm.drupal8.js';
+  public function appendCoreResources(\Civi\Core\Event\GenericHookEvent $e) {
+    $e->list[] = 'js/crm.drupal8.js';
   }
 
 }
diff --git a/civicrm/CRM/Utils/System/Joomla.php b/civicrm/CRM/Utils/System/Joomla.php
index 91085841a2626380d158dcbd54e30c0600ab233d..fa5b4e5b68c1833edb43122c42ec2dd9748876e0 100644
--- a/civicrm/CRM/Utils/System/Joomla.php
+++ b/civicrm/CRM/Utils/System/Joomla.php
@@ -455,6 +455,12 @@ class CRM_Utils_System_Joomla extends CRM_Utils_System_Base {
       $instance->login($params);
     }
 
+    // Save details in Joomla session
+    $user = JFactory::getUser($uid);
+    $jsession = JFactory::getSession();
+    $jsession->set('user', $user);
+
+    // Save details in Civi session
     $session = CRM_Core_Session::singleton();
     $session->set('ufID', $uid);
     $session->set('userID', $contactID);
diff --git a/civicrm/CRM/Utils/System/WordPress.php b/civicrm/CRM/Utils/System/WordPress.php
index c987eff083da294603886be74d26e80bbb7f2030..a1a9c64fd3442faa8604b7f8f3f29e993cf585eb 100644
--- a/civicrm/CRM/Utils/System/WordPress.php
+++ b/civicrm/CRM/Utils/System/WordPress.php
@@ -798,10 +798,20 @@ class CRM_Utils_System_WordPress extends CRM_Utils_System_Base {
   /**
    * Append WP js to coreResourcesList.
    *
-   * @param array $list
+   * @param \Civi\Core\Event\GenericHookEvent $e
    */
-  public function appendCoreResources(&$list) {
-    $list[] = 'js/crm.wordpress.js';
+  public function appendCoreResources(\Civi\Core\Event\GenericHookEvent $e) {
+    $e->list[] = 'js/crm.wordpress.js';
+  }
+
+  /**
+   * @inheritDoc
+   */
+  public function alterAssetUrl(\Civi\Core\Event\GenericHookEvent $e) {
+    // Set menubar breakpoint to match WP admin theme
+    if ($e->asset == 'crm-menubar.css') {
+      $e->params['breakpoint'] = 783;
+    }
   }
 
   /**
@@ -820,13 +830,11 @@ class CRM_Utils_System_WordPress extends CRM_Utils_System_Base {
     $contactCreated = 0;
     $contactMatching = 0;
 
-    // previously used $wpdb - which means WordPress *must* be bootstrapped
-    $wpUsers = get_users(array(
-      'blog_id' => get_current_blog_id(),
-      'number' => -1,
-    ));
+    global $wpdb;
+    $wpUserIds = $wpdb->get_col("SELECT $wpdb->users.ID FROM $wpdb->users");
 
-    foreach ($wpUsers as $wpUserData) {
+    foreach ($wpUserIds as $wpUserId) {
+      $wpUserData = get_userdata($wpUserId);
       $contactCount++;
       if ($match = CRM_Core_BAO_UFMatch::synchronizeUFMatch($wpUserData,
         $wpUserData->$id,
diff --git a/civicrm/CRM/Utils/Type.php b/civicrm/CRM/Utils/Type.php
index e2786712a420786e263ea190cd925d0c160516db..ef066db8f0033c887e677f748852d25ed4cdbed0 100644
--- a/civicrm/CRM/Utils/Type.php
+++ b/civicrm/CRM/Utils/Type.php
@@ -456,18 +456,6 @@ class CRM_Utils_Type {
         }
         break;
 
-      case 'CommaSeparatedIntegers':
-        if (CRM_Utils_Rule::commaSeparatedIntegers($data)) {
-          return $data;
-        }
-        break;
-
-      case 'Boolean':
-        if (CRM_Utils_Rule::boolean($data)) {
-          return $data;
-        }
-        break;
-
       case 'Float':
       case 'Money':
         if (CRM_Utils_Rule::numeric($data)) {
@@ -520,47 +508,23 @@ class CRM_Utils_Type {
         }
         break;
 
-      case 'MysqlColumnNameOrAlias':
-        if (CRM_Utils_Rule::mysqlColumnNameOrAlias($data)) {
-          return $data;
-        }
-        break;
-
       case 'MysqlOrderByDirection':
         if (CRM_Utils_Rule::mysqlOrderByDirection($data)) {
           return strtolower($data);
         }
         break;
 
-      case 'MysqlOrderBy':
-        if (CRM_Utils_Rule::mysqlOrderBy($data)) {
-          return $data;
-        }
-        break;
-
       case 'ExtensionKey':
         if (CRM_Utils_Rule::checkExtensionKeyIsValid($data)) {
           return $data;
         }
         break;
 
-      case 'Json':
-        if (CRM_Utils_Rule::json($data)) {
-          return $data;
-        }
-        break;
-
-      case 'Alphanumeric':
-        if (CRM_Utils_Rule::alphanumeric($data)) {
-          return $data;
-        }
-        break;
-
-      case 'Color':
-        if (CRM_Utils_Rule::color($data)) {
+      default:
+        $check = lcfirst($type);
+        if (CRM_Utils_Rule::$check($data)) {
           return $data;
         }
-        break;
     }
 
     if ($abort) {
diff --git a/civicrm/Civi/API/Event/Event.php b/civicrm/Civi/API/Event/Event.php
index 7ea0d77f91ede5eb1cfb42e36172089e916064bb..d48848da90adb0d321cbad3bea1f90e1def78492 100644
--- a/civicrm/Civi/API/Event/Event.php
+++ b/civicrm/Civi/API/Event/Event.php
@@ -88,4 +88,17 @@ class Event extends \Symfony\Component\EventDispatcher\Event {
     return $this->apiRequest;
   }
 
+  /**
+   * Create a brief string identifying the entity/action. Useful for
+   * pithy matching/switching.
+   *
+   * Ex: if ($e->getApiRequestSig() === '3.contact.get') { ... }
+   *
+   * @return string
+   *   Ex: '3.contact.get'
+   */
+  public function getApiRequestSig() {
+    return mb_strtolower($this->apiRequest['version'] . '.' . $this->apiRequest['entity'] . '.' . $this->apiRequest['action']);
+  }
+
 }
diff --git a/civicrm/Civi/API/Event/PrepareEvent.php b/civicrm/Civi/API/Event/PrepareEvent.php
index cc06e179ec1fe5729f4c2cea248e099c5ba5f66c..972ba4adb169975c5e865bf08d98c975bbbdf099 100644
--- a/civicrm/Civi/API/Event/PrepareEvent.php
+++ b/civicrm/Civi/API/Event/PrepareEvent.php
@@ -26,6 +26,7 @@
  */
 
 namespace Civi\API\Event;
+use Civi\API\Provider\WrappingProvider;
 
 /**
  * Class PrepareEvent
@@ -43,4 +44,28 @@ class PrepareEvent extends Event {
     return $this;
   }
 
+  /**
+   * Replace the normal implementation of an API call with some wrapper.
+   *
+   * The wrapper has discretion to call -- or not call -- or iterate with --
+   * the original API implementation, with original or substituted arguments.
+   *
+   * Ex:
+   *
+   * $event->wrapApi(function($apiRequest, $continue){
+   *   echo "Hello\n";
+   *   $continue($apiRequest);
+   *   echo "Goodbye\n";
+   * });
+   *
+   * @param callable $callback
+   *   The custom API implementation.
+   *   Function(array $apiRequest, callable $continue).
+   * @return PrepareEvent
+   */
+  public function wrapApi($callback) {
+    $this->apiProvider = new WrappingProvider($callback, $this->apiProvider);
+    return $this;
+  }
+
 }
diff --git a/civicrm/Civi/API/Kernel.php b/civicrm/Civi/API/Kernel.php
index cc0cc3805f2c1934e0eb6baf2b071a78a21727e9..e5d3990217456ed73d3ca25ad1178a8661e24bb8 100644
--- a/civicrm/Civi/API/Kernel.php
+++ b/civicrm/Civi/API/Kernel.php
@@ -164,7 +164,7 @@ class Kernel {
 
     list($apiProvider, $apiRequest) = $this->resolve($apiRequest);
     $this->authorize($apiProvider, $apiRequest);
-    $apiRequest = $this->prepare($apiProvider, $apiRequest);
+    list ($apiProvider, $apiRequest) = $this->prepare($apiProvider, $apiRequest);
     $result = $apiProvider->invoke($apiRequest);
 
     return $this->respond($apiProvider, $apiRequest, $result);
@@ -250,12 +250,13 @@ class Kernel {
    * @param array $apiRequest
    *   The full description of the API request.
    * @return array
+   *   [0 => ProviderInterface $provider, 1 => array $apiRequest]
    *   The revised API request.
    */
   public function prepare($apiProvider, $apiRequest) {
     /** @var \Civi\API\Event\PrepareEvent $event */
     $event = $this->dispatcher->dispatch(Events::PREPARE, new PrepareEvent($apiProvider, $apiRequest, $this));
-    return $event->getApiRequest();
+    return [$event->getApiProvider(), $event->getApiRequest()];
   }
 
   /**
diff --git a/civicrm/Civi/API/Provider/WrappingProvider.php b/civicrm/Civi/API/Provider/WrappingProvider.php
new file mode 100644
index 0000000000000000000000000000000000000000..d2c08c5dd1e5b10a4c2a7304f8ebf3b7d62cee5f
--- /dev/null
+++ b/civicrm/Civi/API/Provider/WrappingProvider.php
@@ -0,0 +1,80 @@
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 5                                                  |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2018                                |
+ +--------------------------------------------------------------------+
+ | 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        |
+ +--------------------------------------------------------------------+
+ */
+
+namespace Civi\API\Provider;
+
+use Civi\API\Events;
+use Symfony\Component\EventDispatcher\EventSubscriberInterface;
+
+/**
+ * A wrapping provider overrides an existing API. It has discretion to pass-through
+ * to the original API (0 or many times) or to substitute with entirely different
+ * behavior.
+ *
+ * The WrappingProvider does yield any metadata of its own. It's primarily
+ * intended for dynamically decorating an existing API.
+ */
+class WrappingProvider implements ProviderInterface {
+
+  /**
+   * @var callable
+   *   Function($apiRequest, callable $continue)
+   */
+  protected $callback;
+
+  /**
+   * @var ProviderInterface
+   */
+  protected $original;
+
+  /**
+   * WrappingProvider constructor.
+   * @param callable $callback
+   * @param \Civi\API\Provider\ProviderInterface $original
+   */
+  public function __construct($callback, \Civi\API\Provider\ProviderInterface $original) {
+    $this->callback = $callback;
+    $this->original = $original;
+  }
+
+  public function invoke($apiRequest) {
+    // $continue = function($a) { return $this->original->invoke($a); };
+    $continue = [$this->original, 'invoke'];
+    return call_user_func($this->callback, $apiRequest, $continue);
+  }
+
+  public function getEntityNames($version) {
+    // return $version == $this->version ? [$this->entity] : [];
+    throw new \API_Exception("Not support: WrappingProvider::getEntityNames()");
+  }
+
+  public function getActionNames($version, $entity) {
+    // return $version == $this->version && $this->entity == $entity ? [$this->action] : [];
+    throw new \API_Exception("Not support: WrappingProvider::getActionNames()");
+  }
+
+}
diff --git a/civicrm/Civi/API/SelectQuery.php b/civicrm/Civi/API/SelectQuery.php
index f7b61cd8910b11025b36535ae360e4f64db82202..752159b3d7aa1213e723fd4fc64e1c85da8ca48b 100644
--- a/civicrm/Civi/API/SelectQuery.php
+++ b/civicrm/Civi/API/SelectQuery.php
@@ -105,7 +105,6 @@ abstract class SelectQuery {
     $this->apiFieldSpec = $this->getFields();
 
     $this->query = \CRM_Utils_SQL_Select::from($bao->tableName() . ' ' . self::MAIN_TABLE_ALIAS);
-    $bao->free();
 
     // Add ACLs first to avoid redundant subclauses
     $this->checkPermissions = $checkPermissions;
@@ -145,7 +144,6 @@ abstract class SelectQuery {
 
     while ($result_dao->fetch()) {
       if (in_array('count_rows', $this->select)) {
-        $result_dao->free();
         return (int) $result_dao->c;
       }
       $result_entities[$result_dao->id] = [];
@@ -166,7 +164,6 @@ abstract class SelectQuery {
         }
       };
     }
-    $result_dao->free();
     return $result_entities;
   }
 
diff --git a/civicrm/Civi/Core/AssetBuilder.php b/civicrm/Civi/Core/AssetBuilder.php
index b60f41e20bcc10c58c531b4d4b42767106618c9a..a53be59402aacd8783be82c73e45c79f1e3f3453 100644
--- a/civicrm/Civi/Core/AssetBuilder.php
+++ b/civicrm/Civi/Core/AssetBuilder.php
@@ -125,6 +125,8 @@ class AssetBuilder {
    *   Ex: 'http://example.org/files/civicrm/dyn/angular.abcd1234abcd1234.json'.
    */
   public function getUrl($name, $params = []) {
+    \CRM_Utils_Hook::getAssetUrl($name, $params);
+
     if (!$this->isValidName($name)) {
       throw new \RuntimeException("Invalid dynamic asset name");
     }
diff --git a/civicrm/Civi/Core/Container.php b/civicrm/Civi/Core/Container.php
index 201111773ad0fa6a036d7e7c91bb37fad6c5814e..9ce531d1bb776fc3ad3994afe6e9c98a2435afdf 100644
--- a/civicrm/Civi/Core/Container.php
+++ b/civicrm/Civi/Core/Container.php
@@ -321,6 +321,8 @@ class Container {
     $dispatcher->addListener('hook_civicrm_buildAsset', ['\CRM_Utils_VisualBundle', 'buildAssetJs']);
     $dispatcher->addListener('hook_civicrm_buildAsset', ['\CRM_Utils_VisualBundle', 'buildAssetCss']);
     $dispatcher->addListener('hook_civicrm_buildAsset', ['\CRM_Core_Resources', 'renderMenubarStylesheet']);
+    $dispatcher->addListener('hook_civicrm_coreResourceList', ['\CRM_Utils_System', 'appendCoreResources']);
+    $dispatcher->addListener('hook_civicrm_getAssetUrl', ['\CRM_Utils_System', 'alterAssetUrl']);
     $dispatcher->addListener('civi.dao.postInsert', ['\CRM_Core_BAO_RecurringEntity', 'triggerInsert']);
     $dispatcher->addListener('civi.dao.postUpdate', ['\CRM_Core_BAO_RecurringEntity', 'triggerUpdate']);
     $dispatcher->addListener('civi.dao.postDelete', ['\CRM_Core_BAO_RecurringEntity', 'triggerDelete']);
diff --git a/civicrm/Civi/Core/SettingsBag.php b/civicrm/Civi/Core/SettingsBag.php
index 613703305ac04f217598be20536f2020e30b6094..86d48bbb791e713400f320fc7fb0791a055127dd 100644
--- a/civicrm/Civi/Core/SettingsBag.php
+++ b/civicrm/Civi/Core/SettingsBag.php
@@ -392,7 +392,6 @@ class SettingsBag {
       // to save the field `group_name`, which is required in older schema.
       \CRM_Core_DAO::executeQuery(\CRM_Utils_SQL_Insert::dao($dao)->toSQL());
     }
-    $dao->free();
   }
 
 }
diff --git a/civicrm/Civi/Test/ContactTestTrait.php b/civicrm/Civi/Test/ContactTestTrait.php
new file mode 100644
index 0000000000000000000000000000000000000000..448231bb197312cd3cea3bb6ada85c8a758c6625
--- /dev/null
+++ b/civicrm/Civi/Test/ContactTestTrait.php
@@ -0,0 +1,249 @@
+<?php
+
+namespace Civi\Test;
+
+/**
+ * Class ContactTestTrait
+ * @package Civi\Test
+ *
+ * This trait defines a number of helper functions for managing
+ * test contacts. Generally, it depends on having access to the
+ * API test functions ($this->callAPISuccess()) and to the
+ * standard PHPUnit assertions ($this->assertEquals). It should
+ * not impose any other requirements for the downstream consumer class.
+ */
+trait ContactTestTrait {
+
+  abstract public function callAPISuccess($entity, $action, $params, $checkAgainst = NULL);
+
+  /**
+   * Emulate a logged in user since certain functions use that.
+   * value to store a record in the DB (like activity)
+   * CRM-8180
+   *
+   * @return int
+   *   Contact ID of the created user.
+   */
+  public function createLoggedInUser() {
+    $params = array(
+      'first_name' => 'Logged In',
+      'last_name' => 'User ' . rand(),
+      'contact_type' => 'Individual',
+      'domain_id' => \CRM_Core_Config::domainID(),
+    );
+    $contactID = $this->individualCreate($params);
+    $this->callAPISuccess('UFMatch', 'create', array(
+      'contact_id' => $contactID,
+      'uf_name' => 'superman',
+      'uf_id' => 6,
+    ));
+
+    $session = \CRM_Core_Session::singleton();
+    $session->set('userID', $contactID);
+    return $contactID;
+  }
+
+  /**
+   * Generic function to create Organisation, to be used in test cases
+   *
+   * @param array $params
+   *   parameters for civicrm_contact_add api function call
+   * @param int $seq
+   *   sequence number if creating multiple organizations
+   *
+   * @return int
+   *   id of Organisation created
+   */
+  public function organizationCreate($params = array(), $seq = 0) {
+    if (!$params) {
+      $params = array();
+    }
+    $params = array_merge($this->sampleContact('Organization', $seq), $params);
+    return $this->_contactCreate($params);
+  }
+
+  /**
+   * Generic function to create Individual, to be used in test cases
+   *
+   * @param array $params
+   *   parameters for civicrm_contact_add api function call
+   * @param int $seq
+   *   sequence number if creating multiple individuals
+   * @param bool $random
+   *
+   * @return int
+   *   id of Individual created
+   */
+  public function individualCreate($params = array(), $seq = 0, $random = FALSE) {
+    $params = array_merge($this->sampleContact('Individual', $seq, $random), $params);
+    return $this->_contactCreate($params);
+  }
+
+  /**
+   * Generic function to create Household, to be used in test cases
+   *
+   * @param array $params
+   *   parameters for civicrm_contact_add api function call
+   * @param int $seq
+   *   sequence number if creating multiple households
+   *
+   * @return int
+   *   id of Household created
+   */
+  public function householdCreate($params = array(), $seq = 0) {
+    $params = array_merge($this->sampleContact('Household', $seq), $params);
+    return $this->_contactCreate($params);
+  }
+
+  /**
+   * Helper function for getting sample contact properties.
+   *
+   * @param string $contact_type
+   *   enum contact type: Individual, Organization
+   * @param int $seq
+   *   sequence number for the values of this type
+   * @param bool $random
+   *
+   * @return array
+   *   properties of sample contact (ie. $params for API call)
+   */
+  public function sampleContact($contact_type, $seq = 0, $random = FALSE) {
+    $samples = array(
+      'Individual' => array(
+        // The number of values in each list need to be coprime numbers to not have duplicates
+        'first_name' => array('Anthony', 'Joe', 'Terrence', 'Lucie', 'Albert', 'Bill', 'Kim'),
+        'middle_name' => array('J.', 'M.', 'P', 'L.', 'K.', 'A.', 'B.', 'C.', 'D', 'E.', 'Z.'),
+        'last_name' => array('Anderson', 'Miller', 'Smith', 'Collins', 'Peterson'),
+      ),
+      'Organization' => array(
+        'organization_name' => array(
+          'Unit Test Organization',
+          'Acme',
+          'Roberts and Sons',
+          'Cryo Space Labs',
+          'Sharper Pens',
+        ),
+      ),
+      'Household' => array(
+        'household_name' => array('Unit Test household'),
+      ),
+    );
+    $params = array('contact_type' => $contact_type);
+    foreach ($samples[$contact_type] as $key => $values) {
+      $params[$key] = $values[$seq % count($values)];
+      if ($random) {
+        $params[$key] .= substr(sha1(rand()), 0, 5);
+      }
+    }
+    if ($contact_type == 'Individual') {
+      $params['email'] = strtolower(
+        $params['first_name'] . '_' . $params['last_name'] . '@civicrm.org'
+      );
+      $params['prefix_id'] = 3;
+      $params['suffix_id'] = 3;
+    }
+    return $params;
+  }
+
+  /**
+   * Private helper function for calling civicrm_contact_add.
+   *
+   * @param array $params
+   *   For civicrm_contact_add api function call.
+   *
+   * @throws \Exception
+   *
+   * @return int
+   *   id of Household created
+   */
+  private function _contactCreate($params) {
+    $result = $this->callAPISuccess('contact', 'create', $params);
+    if (!empty($result['is_error']) || empty($result['id'])) {
+      throw new \Exception('Could not create test contact, with message: ' . \CRM_Utils_Array::value('error_message', $result) . "\nBacktrace:" . \CRM_Utils_Array::value('trace', $result));
+    }
+    return $result['id'];
+  }
+
+  /**
+   * Delete contact, ensuring it is not the domain contact
+   *
+   * @param int $contactID
+   *   Contact ID to delete
+   */
+  public function contactDelete($contactID) {
+    $domain = new \CRM_Core_BAO_Domain();
+    $domain->contact_id = $contactID;
+    if (!$domain->find(TRUE)) {
+      $this->callAPISuccess('contact', 'delete', array(
+        'id' => $contactID,
+        'skip_undelete' => 1,
+      ));
+    }
+  }
+
+  /**
+   * Add a Group.
+   *
+   * @param array $params
+   * @return int
+   *   groupId of created group
+   */
+  public function groupCreate($params = array()) {
+    $params = array_merge(array(
+      'name' => 'Test Group 1',
+      'domain_id' => 1,
+      'title' => 'New Test Group Created',
+      'description' => 'New Test Group Created',
+      'is_active' => 1,
+      'visibility' => 'Public Pages',
+      'group_type' => array(
+        '1' => 1,
+        '2' => 1,
+      ),
+    ), $params);
+
+    $result = $this->callAPISuccess('Group', 'create', $params);
+    return $result['id'];
+  }
+
+  /**
+   * Delete a Group.
+   *
+   * @param int $gid
+   */
+  public function groupDelete($gid) {
+    $params = array(
+      'id' => $gid,
+    );
+
+    $this->callAPISuccess('Group', 'delete', $params);
+  }
+
+  /**
+   * Function to add a Group.
+   *
+   * @params array to add group
+   *
+   * @param int $groupID
+   * @param int $totalCount
+   * @param bool $random
+   * @return int
+   *   groupId of created group
+   */
+  public function groupContactCreate($groupID, $totalCount = 10, $random = FALSE) {
+    $params = array('group_id' => $groupID);
+    for ($i = 1; $i <= $totalCount; $i++) {
+      $contactID = $this->individualCreate(array(), 0, $random);
+      if ($i == 1) {
+        $params += array('contact_id' => $contactID);
+      }
+      else {
+        $params += array("contact_id.$i" => $contactID);
+      }
+    }
+    $result = $this->callAPISuccess('GroupContact', 'create', $params);
+
+    return $result;
+  }
+
+}
diff --git a/civicrm/Civi/Test/DbTestTrait.php b/civicrm/Civi/Test/DbTestTrait.php
new file mode 100644
index 0000000000000000000000000000000000000000..06b5e60b3c635fefcd663156b0d9ad82248bc7c2
--- /dev/null
+++ b/civicrm/Civi/Test/DbTestTrait.php
@@ -0,0 +1,189 @@
+<?php
+
+namespace Civi\Test;
+
+/**
+ * Class DbTestTrait
+ * @package Civi\Test
+ *
+ * This trait is intended for use with PHPUnit-based test cases.
+ */
+trait DbTestTrait {
+
+  abstract public function assertAttributesEquals($expectedValues, $actualValues, $message = NULL);
+
+  /**
+   * Generic function to compare expected values after an api call to retrieved.
+   * DB values.
+   *
+   * @daoName  string   DAO Name of object we're evaluating.
+   * @id       int      Id of object
+   * @match    array    Associative array of field name => expected value. Empty if asserting
+   *                      that a DELETE occurred
+   * @delete   boolean  True if we're checking that a DELETE action occurred.
+   * @param $daoName
+   * @param $id
+   * @param $match
+   * @param bool $delete
+   * @throws \PHPUnit_Framework_AssertionFailedError
+   */
+  public function assertDBState($daoName, $id, $match, $delete = FALSE) {
+    if (empty($id)) {
+      // adding this here since developers forget to check for an id
+      // and hence we get the first value in the db
+      $this->fail('ID not populated. Please fix your assertDBState usage!!!');
+    }
+
+    $object = new $daoName();
+    $object->id = $id;
+    $verifiedCount = 0;
+
+    // If we're asserting successful record deletion, make sure object is NOT found.
+    if ($delete) {
+      if ($object->find(TRUE)) {
+        $this->fail("Object not deleted by delete operation: $daoName, $id");
+      }
+      return;
+    }
+
+    // Otherwise check matches of DAO field values against expected values in $match.
+    if ($object->find(TRUE)) {
+      $fields = &$object->fields();
+      foreach ($fields as $name => $value) {
+        $dbName = $value['name'];
+        if (isset($match[$name])) {
+          $verifiedCount++;
+          $this->assertEquals($object->$dbName, $match[$name]);
+        }
+        elseif (isset($match[$dbName])) {
+          $verifiedCount++;
+          $this->assertEquals($object->$dbName, $match[$dbName]);
+        }
+      }
+    }
+    else {
+      $this->fail("Could not retrieve object: $daoName, $id");
+    }
+
+    $matchSize = count($match);
+    if ($verifiedCount != $matchSize) {
+      $this->fail("Did not verify all fields in match array: $daoName, $id. Verified count = $verifiedCount. Match array size = $matchSize");
+    }
+  }
+
+  /**
+   * Request a record from the DB by seachColumn+searchValue. Success if a record is found.
+   * @param string $daoName
+   * @param $searchValue
+   * @param $returnColumn
+   * @param $searchColumn
+   * @param $message
+   *
+   * @return null|string
+   * @throws \PHPUnit_Framework_AssertionFailedError
+   */
+  public function assertDBNotNull($daoName, $searchValue, $returnColumn, $searchColumn, $message) {
+    if (empty($searchValue)) {
+      $this->fail("empty value passed to assertDBNotNull");
+    }
+    $value = \CRM_Core_DAO::getFieldValue($daoName, $searchValue, $returnColumn, $searchColumn, TRUE);
+    $this->assertNotNull($value, $message);
+
+    return $value;
+  }
+
+  /**
+   * Request a record from the DB by seachColumn+searchValue. Success if returnColumn value is NULL.
+   * @param string $daoName
+   * @param $searchValue
+   * @param $returnColumn
+   * @param $searchColumn
+   * @param $message
+   */
+  public function assertDBNull($daoName, $searchValue, $returnColumn, $searchColumn, $message) {
+    $value = \CRM_Core_DAO::getFieldValue($daoName, $searchValue, $returnColumn, $searchColumn, TRUE);
+    $this->assertNull($value, $message);
+  }
+
+  /**
+   * Request a record from the DB by id. Success if row not found.
+   * @param string $daoName
+   * @param int $id
+   * @param null $message
+   */
+  public function assertDBRowNotExist($daoName, $id, $message = NULL) {
+    $message = $message ? $message : "$daoName (#$id) should not exist";
+    $value = \CRM_Core_DAO::getFieldValue($daoName, $id, 'id', 'id', TRUE);
+    $this->assertNull($value, $message);
+  }
+
+  /**
+   * Request a record from the DB by id. Success if row not found.
+   * @param string $daoName
+   * @param int $id
+   * @param null $message
+   */
+  public function assertDBRowExist($daoName, $id, $message = NULL) {
+    $message = $message ? $message : "$daoName (#$id) should exist";
+    $value = \CRM_Core_DAO::getFieldValue($daoName, $id, 'id', 'id', TRUE);
+    $this->assertEquals($id, $value, $message);
+  }
+
+  /**
+   * Compare a single column value in a retrieved DB record to an expected value.
+   * @param string $daoName
+   * @param $searchValue
+   * @param $returnColumn
+   * @param $searchColumn
+   * @param $expectedValue
+   * @param $message
+   */
+  public function assertDBCompareValue(
+    $daoName, $searchValue, $returnColumn, $searchColumn,
+    $expectedValue, $message
+  ) {
+    $value = \CRM_Core_DAO::getFieldValue($daoName, $searchValue, $returnColumn, $searchColumn, TRUE);
+    $this->assertEquals($expectedValue, $value, $message);
+  }
+
+  /**
+   * Compare all values in a single retrieved DB record to an array of expected values.
+   * @param string $daoName
+   * @param array $searchParams
+   * @param $expectedValues
+   */
+  public function assertDBCompareValues($daoName, $searchParams, $expectedValues) {
+    //get the values from db
+    $dbValues = array();
+    \CRM_Core_DAO::commonRetrieve($daoName, $searchParams, $dbValues);
+
+    // compare db values with expected values
+    $this->assertAttributesEquals($expectedValues, $dbValues);
+  }
+
+  /**
+   * Assert that a SQL query returns a given value.
+   *
+   * The first argument is an expected value. The remaining arguments are passed
+   * to CRM_Core_DAO::singleValueQuery
+   *
+   * Example: $this->assertSql(2, 'select count(*) from foo where foo.bar like "%1"',
+   * array(1 => array("Whiz", "String")));
+   * @param $expected
+   * @param $query
+   * @param array $params
+   * @param string $message
+   */
+  public function assertDBQuery($expected, $query, $params = array(), $message = '') {
+    if ($message) {
+      $message .= ': ';
+    }
+    $actual = \CRM_Core_DAO::singleValueQuery($query, $params);
+    $this->assertEquals($expected, $actual,
+      sprintf('%sexpected=[%s] actual=[%s] query=[%s]',
+        $message, $expected, $actual, \CRM_Core_DAO::composeQuery($query, $params, FALSE)
+      )
+    );
+  }
+
+}
diff --git a/civicrm/Civi/Test/GenericAssertionsTrait.php b/civicrm/Civi/Test/GenericAssertionsTrait.php
new file mode 100644
index 0000000000000000000000000000000000000000..1e969f7c39bea67fccc0d07832d767bb3aaba982
--- /dev/null
+++ b/civicrm/Civi/Test/GenericAssertionsTrait.php
@@ -0,0 +1,116 @@
+<?php
+
+namespace Civi\Test;
+
+/**
+ * Class ExtraAssertionsTrait
+ * @package Civi\Test
+ *
+ * A small library of generic assertions - which are slightly more sophisticated than
+ * the default (`assertEquals()`, `assertTrue()`) but *not* domain specific.
+ */
+trait GenericAssertionsTrait {
+
+  /**
+   * @param $expected
+   * @param $actual
+   * @param string $message
+   */
+  public function assertType($expected, $actual, $message = '') {
+    return $this->assertInternalType($expected, $actual, $message);
+  }
+
+  /**
+   * Assert that two array-trees are exactly equal, notwithstanding
+   * the sorting of keys
+   *
+   * @param array $expected
+   * @param array $actual
+   */
+  public function assertTreeEquals($expected, $actual) {
+    $e = array();
+    $a = array();
+    \CRM_Utils_Array::flatten($expected, $e, '', ':::');
+    \CRM_Utils_Array::flatten($actual, $a, '', ':::');
+    ksort($e);
+    ksort($a);
+
+    $this->assertEquals($e, $a);
+  }
+
+  /**
+   * Assert that two numbers are approximately equal.
+   *
+   * @param int|float $expected
+   * @param int|float $actual
+   * @param int|float $tolerance
+   * @param string $message
+   */
+  public function assertApproxEquals($expected, $actual, $tolerance, $message = NULL) {
+    if ($message === NULL) {
+      $message = sprintf("approx-equals: expected=[%.3f] actual=[%.3f] tolerance=[%.3f]", $expected, $actual, $tolerance);
+    }
+    $this->assertTrue(abs($actual - $expected) < $tolerance, $message);
+  }
+
+  /**
+   * Assert attributes are equal.
+   *
+   * @param $expectedValues
+   * @param $actualValues
+   * @param string $message
+   *
+   * @throws \PHPUnit_Framework_AssertionFailedError
+   */
+  public function assertAttributesEquals($expectedValues, $actualValues, $message = NULL) {
+    foreach ($expectedValues as $paramName => $paramValue) {
+      if (isset($actualValues[$paramName])) {
+        $this->assertEquals($paramValue, $actualValues[$paramName], "Value Mismatch On $paramName - value 1 is " . print_r($paramValue, TRUE) . "  value 2 is " . print_r($actualValues[$paramName], TRUE));
+      }
+      else {
+        $this->assertNull($expectedValues[$paramName], "Attribute '$paramName' not present in actual array and we expected it to be " . $expectedValues[$paramName]);
+      }
+    }
+  }
+
+  /**
+   * @param $key
+   * @param $list
+   */
+  public function assertArrayKeyExists($key, &$list) {
+    $result = isset($list[$key]) ? TRUE : FALSE;
+    $this->assertTrue($result, ts("%1 element exists?",
+      array(1 => $key)
+    ));
+  }
+
+  /**
+   * @param $key
+   * @param $list
+   */
+  public function assertArrayValueNotNull($key, &$list) {
+    $this->assertArrayKeyExists($key, $list);
+
+    $value = isset($list[$key]) ? $list[$key] : NULL;
+    $this->assertTrue($value,
+      ts("%1 element not null?",
+        array(1 => $key)
+      )
+    );
+  }
+
+  /**
+   * Assert the 2 arrays have the same values.
+   *
+   * @param array $array1
+   * @param array $array2
+   */
+  public function assertArrayValuesEqual($array1, $array2) {
+    $array1 = array_values($array1);
+    $array2 = array_values($array2);
+    sort($array1);
+    sort($array2);
+    $this->assertEquals($array1, $array2);
+  }
+
+}
diff --git a/civicrm/Civi/Test/MailingTestTrait.php b/civicrm/Civi/Test/MailingTestTrait.php
new file mode 100644
index 0000000000000000000000000000000000000000..6609750fbebcc369169164ce356dd91db03bd999
--- /dev/null
+++ b/civicrm/Civi/Test/MailingTestTrait.php
@@ -0,0 +1,45 @@
+<?php
+
+namespace Civi\Test;
+
+/**
+ * Class MailingTestTrait
+ * @package Civi\Test
+ *
+ * This trait defines a number of helper functions for managing
+ * test mailings.
+ */
+trait MailingTestTrait {
+
+  /**
+   * Helper function to create new mailing.
+   *
+   * @param array $params
+   *
+   * @return int
+   */
+  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'];
+  }
+
+  /**
+   * Helper function to delete mailing.
+   * @param $id
+   */
+  public function deleteMailing($id) {
+    $params = array(
+      'id' => $id,
+    );
+
+    $this->callAPISuccess('Mailing', 'delete', $params);
+  }
+
+}
diff --git a/civicrm/ang/crmMailingAB/WinnerDialogCtrl.js b/civicrm/ang/crmMailingAB/WinnerDialogCtrl.js
index aac6f77a391b7bef32c9b9bd2e9ffb38b2d851e7..f378f641c7f49a5c20401d69d581ded98f07dfd2 100644
--- a/civicrm/ang/crmMailingAB/WinnerDialogCtrl.js
+++ b/civicrm/ang/crmMailingAB/WinnerDialogCtrl.js
@@ -17,20 +17,11 @@
           text: ts('Submit final mailing'),
           icons: {primary: 'fa-paper-plane'},
           click: function() {
-            crmMailingMgr.mergeInto(abtest.mailings.c, abtest.mailings[mailingName], [
-              'name',
-              'recipients',
-              'scheduled_date'
-            ]);
-            crmStatus({start: ts('Saving...'), success: ''}, abtest.save())
-              .then(function() {
-                return crmStatus({start: ts('Submitting...'), success: ts('Submitted')},
-                  abtest.submitFinal().then(function(r) {
-                    delete abtest.$CrmMailingABReportCnt;
-                    return r;
-                  }));
-              })
-              .then(function() {
+            crmStatus({start: ts('Submitting...'), success: ts('Submitted')},
+              abtest.submitFinal(abtest.mailings[mailingName].id).then(function (r) {
+                delete abtest.$CrmMailingABReportCnt;
+              }))
+              .then(function () {
                 dialogService.close('selectWinnerDialog', abtest);
               });
           }
diff --git a/civicrm/ang/crmMailingAB/services.js b/civicrm/ang/crmMailingAB/services.js
index 447909c4a30d9956c6bb10c9dffd0dfe30bd767c..2e9fa9260bd0233ee78dcfe40aef114c00e51f3d 100644
--- a/civicrm/ang/crmMailingAB/services.js
+++ b/civicrm/ang/crmMailingAB/services.js
@@ -147,11 +147,12 @@
       // Schedule the final mailing
       // @return Promise CrmMailingAB
       // Note: Submission may cause the server state to change. Consider abtest.submit().then(...abtest.load()...)
-      submitFinal: function submitFinal() {
+      submitFinal: function submitFinal(winner_id) {
         var crmMailingAB = this;
         var params = {
           id: this.ab.id,
           status: 'Final',
+          winner_id: winner_id,
           approval_date: 'now',
           scheduled_date: this.mailings.c.scheduled_date ? this.mailings.c.scheduled_date : 'now'
         };
diff --git a/civicrm/api/v3/MailingAB.php b/civicrm/api/v3/MailingAB.php
index 077b8bf2d44a1aa987c35e7cf327e7920aab3101..ab3bafe58456f105ddd3c96ebc9ff2ed009290e5 100644
--- a/civicrm/api/v3/MailingAB.php
+++ b/civicrm/api/v3/MailingAB.php
@@ -93,6 +93,13 @@ function _civicrm_api3_mailing_a_b_submit_spec(&$spec) {
   $spec['approval_date'] = $mailingFields['approval_date'];
   $spec['approval_status_id'] = $mailingFields['approval_status_id'];
   $spec['approval_note'] = $mailingFields['approval_note'];
+  $spec['winner_id'] = [
+    'name' => 'winner_id',
+    'type' => 1,
+    'title' => 'Winner ID',
+    'description' => 'The experimental mailing with the best results. If specified, values are copied to the final mailing.',
+    'localizable' => 0,
+  ];
   // Note: we'll pass through approval_* fields to the underlying mailing, but they may be ignored
   // if the user doesn't have suitable permission. If separate approvals are required, they must be provided
   // outside the A/B Test UI.
@@ -149,6 +156,9 @@ function civicrm_api3_mailing_a_b_submit($params) {
       if ($dao->status != 'Testing') {
         throw new API_Exception("Cannot transition to state 'Final'");
       }
+      if (!empty($params['winner_id'])) {
+        _civicrm_api3_mailing_a_b_fill_winner($params['winner_id'], $dao->mailing_id_c);
+      }
       civicrm_api3('Mailing', 'submit', $submitParams + [
         'id' => $dao->mailing_id_c,
         '_skip_evil_bao_auto_recipients_' => 1,
@@ -168,6 +178,56 @@ function civicrm_api3_mailing_a_b_submit($params) {
   ]);
 }
 
+/**
+ * @param int $winner_id
+ *   The experimental mailing chosen as the "winner".
+ * @param int $final_id
+ *   The final mailing which should imitate the "winner".
+ * @throws \API_Exception
+ */
+function _civicrm_api3_mailing_a_b_fill_winner($winner_id, $final_id) {
+  $copyFields = [
+    // 'id',
+    // 'name',
+    'campaign_id',
+    'from_name',
+    'from_email',
+    'replyto_email',
+    'subject',
+    'dedupe_email',
+    // 'recipients',
+    'body_html',
+    'body_text',
+    'footer_id',
+    'header_id',
+    'visibility',
+    'url_tracking',
+    'dedupe_email',
+    'forward_replies',
+    'auto_responder',
+    'open_tracking',
+    'override_verp',
+    'optout_id',
+    'reply_id',
+    'resubscribe_id',
+    'unsubscribe_id'
+  ];
+  $f = CRM_Utils_SQL_Select::from('civicrm_mailing')
+    ->where('id = #id', ['id' => $winner_id])
+    ->select($copyFields)
+    ->execute()
+    ->fetchAll();
+  if (count($f) !== 1) {
+    throw new API_Exception('Invalid winner_id');
+  }
+  foreach ($f as $winner) {
+    civicrm_api3('Mailing', 'create', $winner + [
+      'id' => $final_id,
+      '_skip_evil_bao_auto_recipients_' => 1,
+    ]);
+  }
+}
+
 /**
  * Adjust Metadata for graph_stats action.
  *
diff --git a/civicrm/api/v3/Payment.php b/civicrm/api/v3/Payment.php
index 69367bf6f0878c6ee49e1b4d0c5a53c80e15c6bd..bab232ab49453c767b99a2feb32fbc62c648f395 100644
--- a/civicrm/api/v3/Payment.php
+++ b/civicrm/api/v3/Payment.php
@@ -104,15 +104,20 @@ function civicrm_api3_payment_cancel(&$params) {
     'financial_trxn_id' => $params['id'],
   ];
   $entity = civicrm_api3('EntityFinancialTrxn', 'getsingle', $eftParams);
-  $contributionId = $entity['entity_id'];
-  $params['total_amount'] = $entity['amount'];
-  unset($params['id']);
 
-  $trxn = CRM_Contribute_BAO_Contribution::recordAdditionalPayment($contributionId, $params, 'refund', NULL, FALSE);
+  $paymentParams = [
+    'total_amount' => -$entity['amount'],
+    'contribution_id' => $entity['entity_id'],
+    'trxn_date' => CRM_Utils_Array::value('trxn_date', $params, 'now'),
+  ];
 
-  $values = [];
-  _civicrm_api3_object_to_array_unique_fields($trxn, $values[$trxn->id]);
-  return civicrm_api3_create_success($values, $params, 'Payment', 'cancel', $trxn);
+  foreach (['trxn_id', 'payment_instrument_id'] as $permittedParam) {
+    if (isset($params[$permittedParam])) {
+      $paymentParams[$permittedParam] = $params[$permittedParam];
+    }
+  }
+  $result = civicrm_api3('Payment', 'create', $paymentParams);
+  return civicrm_api3_create_success($result['values'], $params, 'Payment', 'cancel');
 }
 
 /**
@@ -169,6 +174,10 @@ function _civicrm_api3_payment_create_spec(&$params) {
       'type' => CRM_Utils_Type::T_INT,
       'api.aliases' => ['payment_id'],
     ],
+    'trxn_date' => [
+      'title' => 'Cancel Date',
+      'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
+    ],
   ];
 }
 
@@ -233,6 +242,10 @@ function _civicrm_api3_payment_cancel_spec(&$params) {
       'type' => CRM_Utils_Type::T_INT,
       'api.aliases' => ['payment_id'],
     ],
+    'trxn_date' => [
+      'title' => 'Cancel Date',
+      'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
+    ],
   ];
 }
 
diff --git a/civicrm/api/v3/utils.php b/civicrm/api/v3/utils.php
index bac0826f5cd3db9dc791b891cd3aa6e3ce642b78..1e5d3836401b77ab01d0542f76d143cd3dda0e5b 100644
--- a/civicrm/api/v3/utils.php
+++ b/civicrm/api/v3/utils.php
@@ -2338,6 +2338,11 @@ function _civicrm_api3_api_match_pseudoconstant_value(&$value, $options, $fieldN
     return;
   }
 
+  // Hack for Profile formatting fields
+  if ($fieldName === 'field_name' && (strpos($value, 'formatting') === 0)) {
+    return;
+  }
+
   // Translate value into key
   // Cast $value to string to avoid a bug in array_search
   $newValue = array_search((string) $value, $options);
diff --git a/civicrm/bower_components/jquery-ui/.bower.json b/civicrm/bower_components/jquery-ui/.bower.json
index a37977e293dab1139234c1e11ff472e0011d1161..d28097dd886aa3254e1ae3f4b4c31a9a08723e8e 100644
--- a/civicrm/bower_components/jquery-ui/.bower.json
+++ b/civicrm/bower_components/jquery-ui/.bower.json
@@ -17,6 +17,6 @@
     "commit": "44ecf3794cc56b65954cc19737234a3119d036cc"
   },
   "_source": "https://github.com/components/jqueryui.git",
-  "_target": ">=1.9",
+  "_target": "~1.12",
   "_originalSource": "jquery-ui"
 }
\ No newline at end of file
diff --git a/civicrm/civicrm-version.php b/civicrm/civicrm-version.php
index bce2ea949c7fc8bff4e3712398ef3be05d68b632..8ff08178690743dd9673a4dc9416b818c845d39f 100644
--- a/civicrm/civicrm-version.php
+++ b/civicrm/civicrm-version.php
@@ -1,7 +1,7 @@
 <?php
 /** @deprecated */
 function civicrmVersion( ) {
-  return array( 'version'  => '5.13.5',
+  return array( 'version'  => '5.14.0',
                 'cms'      => 'Wordpress',
                 'revision' => '' );
 }
diff --git a/civicrm/css/contactSummary.css b/civicrm/css/contactSummary.css
index 4cb7aaa69b367877b1a8854dbcc898a186b9f0ca..813f0c491619ccb3643b305467e681c91f8fc9c0 100644
--- a/civicrm/css/contactSummary.css
+++ b/civicrm/css/contactSummary.css
@@ -49,7 +49,7 @@ div#crm-contact-thumbnail {
   min-height: 2.5em;
 }
 
-#crm-container div.crm-inline-edit .crm-edit-help {
+#crm-container div.crm-summary-block .crm-edit-help {
   display: none;
   position: absolute;
   right: 0;
diff --git a/civicrm/css/crm-menubar.css b/civicrm/css/crm-menubar.css
index 89b486963e872b54b53d406649d14ae1d1dad6ea..c3d0ffd22f1269c6f1d221125a09509880450c66 100644
--- a/civicrm/css/crm-menubar.css
+++ b/civicrm/css/crm-menubar.css
@@ -131,7 +131,7 @@ input#crm-qsearch-input {
   border: 1px solid #ccc;
   margin: 4px 4px 0;
   padding: 2px 8px;
-  height: 30px;
+  height: calc($menubarHeight - 10px);
   width: 30px;
   transition: width .5s .05s, background-color .3s .05s;
   color: black;
@@ -183,7 +183,7 @@ body.crm-menubar-over-cms-menu #crm-menubar-toggle-position a i {
   transform: rotate(180deg);
 }
 
-@media (min-width: 768px) {
+@media (min-width: $breakMin) {
 
   /* Switch to desktop layout
   -----------------------------------------------
@@ -219,12 +219,25 @@ body.crm-menubar-over-cms-menu #crm-menubar-toggle-position a i {
   }
 
   #civicrm-menu li a {
-    background-color: $semiTransparentMenuColor;
+    background-color: $menuItemColor;
     color: $textColor;
   }
 
   #civicrm-menu > li > a {
-    height: 40px;
+    height: $menubarHeight;
+    padding: 0 8px;
+  }
+
+  #civicrm-menu > li > a > * {
+    vertical-align: middle;
+  }
+
+  /* Pseudo-element to ensure vertical alignment */
+  #civicrm-menu > li:not(#crm-qsearch) > a:after {
+    content: '';
+    display: inline-block;
+    height: 100%;
+    vertical-align: middle;
   }
 
   #civicrm-menu > li > a.highlighted {
@@ -250,7 +263,7 @@ body.crm-menubar-over-cms-menu #crm-menubar-toggle-position a i {
   }
 }
 
-@media (max-width: 768px) {
+@media (max-width: $breakMax) {
   /* hide the menu in mobile view */
   #crm-menubar-state:not(:checked) ~ #civicrm-menu {
     display: none;
diff --git a/civicrm/css/menubar-backdrop.css b/civicrm/css/menubar-backdrop.css
index b238c51f40e1a51cc0628aa0be3eee90b93cdaa0..ef980b240b1624ef4c15eec0546cb217d3b9ff33 100644
--- a/civicrm/css/menubar-backdrop.css
+++ b/civicrm/css/menubar-backdrop.css
@@ -1,11 +1,11 @@
-@media (min-width: 768px) {
+@media (min-width: $breakMin) {
 
   body.crm-menubar-visible.crm-menubar-over-cms-menu {
     border-top: 0 none !important;
-    margin-top: 40px;
+    margin-top: $menubarHeight;
   }
   body.crm-menubar-visible.crm-menubar-over-cms-menu.crm-menubar-wrapped {
-    margin-top: 80px;
+    margin-top: calc($menubarHeight * 2);
   }
   body.crm-menubar-visible.crm-menubar-over-cms-menu #admin-bar {
     visibility: hidden;
@@ -28,7 +28,7 @@
   }
 
 }
-@media (max-width: 768px) {
+@media (max-width: $breakMax) {
 
   body.backdrop-admin-bar-position-absolute #civicrm-menu-nav {
     position: absolute;
diff --git a/civicrm/css/menubar-drupal7.css b/civicrm/css/menubar-drupal7.css
index 8317feb0220533e7d15fd924855786d17e251cb5..f5c663160b8e5ea679f4fdd21c13bd1c213ec395 100644
--- a/civicrm/css/menubar-drupal7.css
+++ b/civicrm/css/menubar-drupal7.css
@@ -1,14 +1,14 @@
-@media (min-width: 768px) {
+@media (min-width: $breakMin) {
 
   body.crm-menubar-visible.crm-menubar-over-cms-menu #toolbar {
     display: none;
   }
 
   body.crm-menubar-visible.crm-menubar-over-cms-menu {
-    padding-top: 40px !important;
+    padding-top: $menubarHeight !important;
   }
   body.crm-menubar-visible.crm-menubar-over-cms-menu.crm-menubar-wrapped {
-    padding-top: 80px !important;
+    padding-top: calc($menubarHeight * 2) !important;
   }
 
   body.crm-menubar-visible.crm-menubar-over-cms-menu #toolbar .toolbar-drawer {
@@ -47,10 +47,10 @@
     min-height: 30px;
   }
   body.crm-menubar-visible.crm-menubar-below-cms-menu.admin-menu {
-    padding-top: 40px !important;
+    padding-top: $menubarHeight !important;
   }
   body.crm-menubar-visible.crm-menubar-below-cms-menu.crm-menubar-wrapped.admin-menu {
-    padding-top: 80px !important;
+    padding-top: calc($menubarHeight * 2) !important;
   }
   body.crm-menubar-visible.crm-menubar-over-cms-menu #admin-menu {
     display: none;
@@ -67,7 +67,7 @@
 }
 
 /* For adminimal_admin_menu */
-@media (min-width: 768px) and (max-width: 1024px) {
+@media (min-width: $breakMin) and (max-width: 1024px) {
 
   body.crm-menubar-visible.crm-menubar-over-cms-menu.admin-menu.adminimal-menu > .slicknav_menu {
     display: none;
@@ -80,7 +80,7 @@
   }
 }
 
-@media (max-width: 768px) {
+@media (max-width: $breakMax) {
 
   body.toolbar.crm-menubar-visible #toolbar-home {
     visibility: hidden;
diff --git a/civicrm/css/menubar-drupal8.css b/civicrm/css/menubar-drupal8.css
index 868a7864dad005731fadb6116131b286f7bf90c3..c143dc967f130e30c4501f7c61df07c73bcd4dfc 100644
--- a/civicrm/css/menubar-drupal8.css
+++ b/civicrm/css/menubar-drupal8.css
@@ -24,21 +24,24 @@ nav#civicrm-menu-nav .crm-menubar-toggle-btn-icon {
   left: 44px;
 }
 
-@media (min-width: 768px) {
+@media (min-width: $breakMin) {
 
-  body.crm-menubar-visible.crm-menubar-over-cms-menu #toolbar-administration  {
+  body.crm-menubar-visible.crm-menubar-over-cms-menu #toolbar-administration {
     display: none;
   }
 
   body.crm-menubar-visible.crm-menubar-over-cms-menu {
-    padding-top: 40px !important;
+    padding-top: $menubarHeight !important;
   }
-  body.crm-menubar-visible.crm-menubar-over-cms-menu.crm-menubar-wrapped,
+  body.crm-menubar-visible.crm-menubar-over-cms-menu.crm-menubar-wrapped {
+    padding-top: calc($menubarHeight * 2) !important;
+  }
+  /* The Drupal menu is 40px tall so we add that to our menubar height */
   body.crm-menubar-visible.crm-menubar-below-cms-menu {
-    padding-top: 80px !important;
+    padding-top: calc($menubarHeight + 40px) !important;
   }
   body.crm-menubar-visible.crm-menubar-below-cms-menu.crm-menubar-wrapped {
-    padding-top: 120px !important;
+    padding-top: calc($menubarHeight * 2 + 40px) !important;
   }
 
   body.crm-menubar-below-cms-menu > #civicrm-menu-nav ul#civicrm-menu {
diff --git a/civicrm/css/menubar-joomla.css b/civicrm/css/menubar-joomla.css
index 482f8c2ac643b9f7324a2add0e65bfded763d848..48422b5e38d52b0beff4a0ebe7cbf39305f2cc38 100644
--- a/civicrm/css/menubar-joomla.css
+++ b/civicrm/css/menubar-joomla.css
@@ -1,21 +1,21 @@
-@media (min-width: 768px) {
+@media (min-width: $breakMin) {
 
   body.crm-menubar-over-cms-menu.crm-menubar-visible {
-    padding-top: 40px;
+    padding-top: $menubarHeight;
   }
   body.crm-menubar-over-cms-menu.crm-menubar-visible.crm-menubar-wrapped {
-    padding-top: 80px;
+    padding-top: calc($menubarHeight * 2);
   }
 
   body.crm-menubar-below-cms-menu.crm-menubar-visible {
-    margin-top: 40px;
+    margin-top: $menubarHeight;
   }
   body.crm-menubar-below-cms-menu.crm-menubar-visible.crm-menubar-wrapped {
-    margin-top: 80px;
+    margin-top: calc($menubarHeight * 2);
   }
 
 }
-@media (max-width: 768px) {
+@media (max-width: $breakMax) {
 
   body #civicrm-menu-nav {
     position: absolute;
diff --git a/civicrm/css/menubar-wordpress.css b/civicrm/css/menubar-wordpress.css
index 792b59e7dfbee94b5ffa55597ba8ba4945e6d0e2..e87fc6e5271735458f8a40d85d76cc4a43930139 100644
--- a/civicrm/css/menubar-wordpress.css
+++ b/civicrm/css/menubar-wordpress.css
@@ -1,4 +1,4 @@
-@media (min-width: 768px) {
+@media (min-width: $breakMin) {
 
   body.crm-menubar-over-cms-menu.crm-menubar-visible #wpbody {
     padding-top: 8px;
@@ -23,17 +23,17 @@
   }
 
   body.crm-menubar-below-cms-menu.crm-menubar-visible #wpbody {
-    padding-top: 40px;
+    padding-top: $menubarHeight;
   }
   body.crm-menubar-below-cms-menu.crm-menubar-visible.crm-menubar-wrapped #wpbody {
-    padding-top: 80px;
+    padding-top: calc($menubarHeight * 2);
   }
   body.crm-menubar-over-cms-menu.crm-menubar-visible.crm-menubar-wrapped #adminmenuwrap {
-    margin-top: 40px;
+    margin-top: $menubarHeight;
   }
 
 }
-@media (min-width: 768px) and (max-width: 960px) {
+@media (min-width: $breakMin) and (max-width: 960px) {
 
   /* For the auto-fold toolbar */
   .wp-toolbar body.crm-menubar-below-cms-menu.auto-fold > #civicrm-menu-nav #civicrm-menu {
@@ -42,7 +42,7 @@
   }
 
 }
-@media (max-width: 768px) {
+@media (max-width: $breakMax) {
 
   body #civicrm-menu-nav .crm-menubar-toggle-btn {
     position: absolute;
diff --git a/civicrm/extern/ipn.php b/civicrm/extern/ipn.php
index 6a673fb066c7614b6f5bd630c4f1ead34f3eacc9..8e6797ed9703d89a4e71cc8823afdc34f4b48a6e 100644
--- a/civicrm/extern/ipn.php
+++ b/civicrm/extern/ipn.php
@@ -29,6 +29,29 @@
  * @package CRM
  * @copyright CiviCRM LLC (c) 2004-2019
  * $Id$
+ *
+ * This script processes "Instant Payment Notifications" (IPNs).  Modern
+ * Payment Processors use the /civicrm/payment/ipn/123 endpoint instead (where
+ * 123 is the payment processor ID), however a quirk in the way PayPal works
+ * means that we need to maintain this script.
+ *
+ * Note on PayPal.
+ *
+ * Using PayPal Website Standard (which uses the old PayPal button API) the IPN
+ * endpoint is passed to PayPal with every transaction, and it is then stored
+ * by PayPal who unhelpfully do not give you any way to retrieve or change
+ * this.
+ *
+ * This means that if you provide URL1 when setting up a recurring
+ * contribution, then you will always need to maintain URL1 because all
+ * recurring payments against that will be sent to URL1.
+ *
+ * Note that this also affects you if you were to move your CiviCRM instance to
+ * another domain (if you do, get the webserver at the original domain to emit
+ * a 307 redirect to the new one, PayPal will re-send).
+ *
+ * Therefore, for the sake of these old recurring contributions, CiviCRM should
+ * maintain this script as part of core.
  */
 
 if (defined('PANTHEON_ENVIRONMENT')) {
@@ -52,9 +75,17 @@ else {
   // @todo upgrade standard per Pro
 }
 try {
-  //CRM-18245
-  if ($config->userFramework == 'Joomla') {
-    CRM_Utils_System::loadBootStrap();
+  switch ($config->userFramework) {
+    case 'Joomla':
+      // CRM-18245
+      CRM_Utils_System::loadBootStrap();
+      break;
+
+    default:
+      // Gitlab issues: #973, #1017
+      CRM_Utils_System::loadBootStrap([], FALSE);
+      break;
+
   }
   $paypalIPN->main();
 }
diff --git a/civicrm/extern/open.php b/civicrm/extern/open.php
index c48945c765372679a2c0e24957ae4feaac6e81b4..b5db5f7e70e34171a70420ac7888cbc1172c13f0 100644
--- a/civicrm/extern/open.php
+++ b/civicrm/extern/open.php
@@ -2,10 +2,12 @@
 require_once '../civicrm.config.php';
 require_once 'CRM/Core/Config.php';
 require_once 'CRM/Core/Error.php';
-require_once 'CRM/Utils/Array.php';
+require_once 'CRM/Utils/Type.php';
+require_once 'CRM/Utils/Rule.php';
+require_once 'CRM/Utils/Request.php';
 
 $config = CRM_Core_Config::singleton();
-$queue_id = CRM_Utils_Array::value('q', $_GET);
+$queue_id = CRM_Utils_Request::retrieveValue('q', 'Positive', NULL, FALSE, 'GET');
 if (!$queue_id) {
   echo "Missing input parameters\n";
   exit();
diff --git a/civicrm/extern/rest.php b/civicrm/extern/rest.php
index 6e1c581f178c6fedef836a4921cd187da971e4da..503de82ce77c83d33da77c8b73fe199564ab61dc 100644
--- a/civicrm/extern/rest.php
+++ b/civicrm/extern/rest.php
@@ -31,7 +31,6 @@ $config = CRM_Core_Config::singleton();
 if (defined('PANTHEON_ENVIRONMENT')) {
   ini_set('session.save_handler', 'files');
 }
-session_start();
 $rest = new CRM_Utils_REST();
 
 // Json-appropriate header will be set by CRM_Utils_Rest
diff --git a/civicrm/i/creditcard-icons.png b/civicrm/i/creditcard-icons.png
index 329106b4e73cf18e5a0b91f7923e88135f11de05..c5e8a15c87a564cabf7d8e10e9ae9c8da9b78f0e 100644
Binary files a/civicrm/i/creditcard-icons.png and b/civicrm/i/creditcard-icons.png differ
diff --git a/civicrm/install/index.php b/civicrm/install/index.php
index 6eaf8a50302199acda493b587ebfe779ff650ca4..9d86c115e18545f3162d6f05d7afcf49852e245b 100644
--- a/civicrm/install/index.php
+++ b/civicrm/install/index.php
@@ -623,7 +623,7 @@ class InstallRequirements {
 
     $this->requirePHPVersion(array(
       ts("PHP Configuration"),
-      ts("PHP5 installed"),
+      ts("PHP7 installed"),
     ));
 
     // Check that we can identify the root folder successfully
diff --git a/civicrm/js/model/crm.designer.js b/civicrm/js/model/crm.designer.js
index 752cf86415c8fb75292ce486a7400b7ccc2341c7..8ca76604eb683e3fcfde5510ffa952dbcfebcf8e 100644
--- a/civicrm/js/model/crm.designer.js
+++ b/civicrm/js/model/crm.designer.js
@@ -70,9 +70,7 @@
         label: this.getLabel(),
         entity_name: this.get('entityName'),
         field_type: this.getFieldSchema().civiFieldType,
-        // For some reason the 'formatting' field gets a random number appended in core so we mimic that here.
-        // TODO: Why?
-        field_name: this.get('fieldName') == 'formatting' ? 'formatting_' + (Math.floor(Math.random() * 8999) + 1000) : this.get('fieldName')
+        field_name: this.get('fieldName')
       });
       return model;
     }
diff --git a/civicrm/release-notes.md b/civicrm/release-notes.md
index 295abb5dcd2a55209b28329d1d0b53409326f540..f9756c2562cfb838f66fb07ebeb1986138a644bc 100644
--- a/civicrm/release-notes.md
+++ b/civicrm/release-notes.md
@@ -14,6 +14,17 @@ Other resources for identifying changes are:
     * https://github.com/civicrm/civicrm-joomla
     * https://github.com/civicrm/civicrm-wordpress
 
+## CiviCRM 5.14.0
+
+Released June 5, 2019
+
+- **[Synopsis](release-notes/5.14.0.md#synopsis)**
+- **[Features](release-notes/5.14.0.md#features)**
+- **[Bugs resolved](release-notes/5.14.0.md#bugs)**
+- **[Miscellany](release-notes/5.14.0.md#misc)**
+- **[Credits](release-notes/5.14.0.md#credits)**
+- **[Feedback](release-notes/5.14.0.md#feedback)**
+
 ## CiviCRM 5.13.5
 
 Released May 29, 2019
diff --git a/civicrm/release-notes/5.14.0.md b/civicrm/release-notes/5.14.0.md
new file mode 100644
index 0000000000000000000000000000000000000000..11b3008da7417ddb9da9e5b024b9d055bdcf8072
--- /dev/null
+++ b/civicrm/release-notes/5.14.0.md
@@ -0,0 +1,550 @@
+# CiviCRM 5.14.0
+
+Released June 5, 2019
+
+- **[Synopsis](#synopsis)**
+- **[Features](#features)**
+- **[Bugs resolved](#bugs)**
+- **[Miscellany](#misc)**
+- **[Credits](#credits)**
+- **[Feedback](#feedback)**
+
+## <a name="synopsis"></a>Synopsis
+
+| *Does this version...?*                                         |         |
+|:--------------------------------------------------------------- |:-------:|
+| Fix security vulnerabilities?                                   |   no    |
+| Change the database schema?                                     | **yes** |
+| Alter the API?                                                  | **yes** |
+| Require attention to configuration options?                     |   no    |
+| Fix problems installing or upgrading to a previous version?     | **yes** |
+| Introduce features?                                             | **yes** |
+| Fix bugs?                                                       | **yes** |
+
+## <a name="features"></a>Features
+
+### Core CiviCRM
+
+- **Minimum supported PHP version is 7.0
+  ([14437](https://github.com/civicrm/civicrm-core/pull/14437), [14459](https://github.com/civicrm/civicrm-core/pull/14459))**
+
+  CiviCRM now requires PHP 7.0 or higher.  While sites running PHP 5.6 will be
+  able to upgrade to CiviCRM 5.14.0, they will see an error message saying it is
+  no longer supported.  Upcoming changes to CiviCRM will not be evaluated with
+  regard to PHP 5.6 compatibility, and new sites installing CiviCRM must have
+  PHP 7.0 or higher.
+
+- **civi.api.prepare - Allow dynamic wrappers (preliminary work for
+  [dev/core#873](https://lab.civicrm.org/dev/core/issues/873):
+  [14047](https://github.com/civicrm/civicrm-core/pull/14047))**
+
+  This furthers the goal of allowing users to A/B test subject lines in Mosaico
+  by allowing extension developers to dynamically wrap an API using a listener
+  for the new civi.api.prepare event.
+
+- **Make DAO fields more consistent
+  ([14072](https://github.com/civicrm/civicrm-core/pull/14072))**
+
+  This PR makes it so the 'where' field is populated regardless of whether
+  import or export is set. The goal of this pull request is to simplify some of
+  the metadata based magic by trying to get the meaning of import & export
+  closer to the original intent.
+
+- **Hook to alter menubar css variables & fix breakpoint in WP
+  ([14135](https://github.com/civicrm/civicrm-core/pull/14135) and
+  [14420](https://github.com/civicrm/civicrm-core/pull/14420))**
+
+  A new hook, `hook_civicrm_getAssetUrl()`, allows modifying parameters for a
+  semi-static asset like a CSS file that takes certain parameters.  The result
+  is that the menu bar is more flexible and configurable, and this fixes a
+  couple of issues with it in WordPress at certain widths.
+
+- **Replace jcalendar instances with datepicker (continues
+  [dev/core#561](https://lab.civicrm.org/dev/core/issues/561):
+  [14150](https://github.com/civicrm/civicrm-core/pull/14150) and
+  [14099](https://github.com/civicrm/civicrm-core/pull/14099))**
+
+  The campaign search form and pledge forms now use datepicker instead of the
+  deprecated jcalendar for choosing dates.
+
+- **Result filter criteria doesn't show IS NULL/IS NOT NULL for operations
+  ([dev/core#865](https://lab.civicrm.org/dev/core/issues/865):
+  [14028](https://github.com/civicrm/civicrm-core/pull/14028))**
+
+  Allow users to access to the operations `IS NULL` and `IS NOT NULL` when
+  choosing report filters for multiselect fields.
+
+- **Allow url to set IS NULL/ NOT NULL in report for operations
+  ([dev/core#876](https://lab.civicrm.org/dev/core/issues/876):
+  [14052](https://github.com/civicrm/civicrm-core/pull/14052))**
+
+  Makes it so that the newly added filter options IS NULL/ NOT NULL (added
+  above) can be passed via URL.
+
+- **Convert dedupe select to select 2 and remove not-used var
+  ([14161](https://github.com/civicrm/civicrm-core/pull/14161))**
+
+  On the Dedupe rules form, the "Field" drop-downs are converted to Select2
+  fields.
+
+- **Add function filterLinks to return an array of links for an entity that can
+  be used by the API / form layer to generate a link
+  ([14112](https://github.com/civicrm/civicrm-core/pull/14112))**
+
+  Adds the function filterLinks (CRM_Core_Action::filterLinks()) which can be
+  used to generate link html client-side. This function is currently unused,
+  added in preparation for CiviCase link refactoring.
+
+- **Add serialize metadata to tag used_for field
+  ([14096](https://github.com/civicrm/civicrm-core/pull/14096))**
+
+  Add schema metadata to the Tag `used_for` field, which is a comma separated
+  list.
+
+- **Cron Status Check - Better hyperlinks
+  ([14085](https://github.com/civicrm/civicrm-core/pull/14085))**
+
+  Improves the System Status check "Cron Not Running" by including a link to
+  most up to date documentation.
+
+- **Add pseudoconstant to UFField dao
+  ([14041](https://github.com/civicrm/civicrm-core/pull/14041))**
+
+  Improves the UFField API by exposing the option list for the field
+  `fieldname`, before this change it was displayed as a text field instead of a
+  select.
+
+- **CQ: Switch core forms to be Entity Forms (continues
+  [dev/core#818](https://lab.civicrm.org/dev/core/issues/818):
+  [13887](https://github.com/civicrm/civicrm-core/pull/13887))**
+
+  The group settings form now relies upon a standard entity form for the most
+  part, with most fields defined by metadata.  This removes boilerplate code
+  from the specific form function, standardizing the form and facilitating later
+  form improvements that can be made across the board.
+
+### CiviContribute
+
+- **CQ: Refactor Recurring Contribution Forms (continues
+  [dev/core#846](https://lab.civicrm.org/dev/core/issues/846):
+  [13994](https://github.com/civicrm/civicrm-core/pull/13994) and
+  [13993](https://github.com/civicrm/civicrm-core/pull/13993)))**
+
+  This begins the process of converting recurring contribution forms to use
+  entity forms.  It standardizes the way in which the payment processor is
+  loaded in the 3 forms that update subscriptions.
+
+- **Call Payment.create from Payment.cancel
+  ([13689](https://github.com/civicrm/civicrm-core/pull/13689))**
+
+  This change improves the Payment.create API by adding handling for negative
+  amounts and moves the Payment.cancel API to use the Payment.create API instead
+  of a bespoke function.
+
+- **Switch to using ContributionRecur.cancel API from CancelSubscription form
+  ([14033](https://github.com/civicrm/civicrm-core/pull/14033))**
+
+  This change makes it so the CancelSubscription Form uses the
+  ContributionRecur.cancel API instead of a bespoke function.
+
+- **Update MasterCard icon to match branding guidelines
+  ([14078](https://github.com/civicrm/civicrm-core/pull/14078))**
+
+  Updates the MasterCard icon to match the MasterCard branding guidelines:
+  https://brand.mastercard.com/brandcenter/mastercard-brand-mark/downloads.html
+
+### CiviEvent
+
+- **Event Cart: add support for the Credit Card type icons
+  ([14175](https://github.com/civicrm/civicrm-core/pull/14175))**
+
+  Adds support for the Credit Card type icons (Amex, visa etc.) to Event Cart
+  registration forms.
+
+### Drupal Integration
+
+- **Drupal Views : relationships for standard groups
+  ([CRM-20006](https://issues.civicrm.org/jira/browse/CRM-20006):
+  [507](https://github.com/civicrm/civicrm-drupal/pull/507))**
+
+  Adds relationships for standard groups to the CiviCRM/Drupal Views
+  integration.
+
+- **Enable contribution views to filter on empty Receipt and Thank You dates
+  ([573](https://github.com/civicrm/civicrm-drupal/pull/573))**
+
+  Adds a view filter on "Thank You date" and "Receipt Date" for empty/not empty
+  which can be used to create a view showing contributions that
+  have/have not been thanked.
+
+## <a name="bugs"></a>Bugs resolved
+
+### Core CiviCRM
+
+- **Email processor filing all emails as .unknown attachments
+  ([dev/core#940](https://lab.civicrm.org/dev/core/issues/940):
+  [14208](https://github.com/civicrm/civicrm-core/pull/14208))**
+
+  Fixes a regression where emails being sent to the email-to-activity mailbox
+  were being saved with a `.unknown` extension and no content.
+
+- **.ics files should be whitelisted as file types for upload
+  ([dev/core#974](https://lab.civicrm.org/dev/core/issues/974):
+  [14531](https://github.com/civicrm/civicrm-core/pull/14351))**
+
+- **Regression - faster activity tab in 5.13 won't sort by source_name now
+  ([dev/core#934](https://lab.civicrm.org/dev/core/issues/934):
+  [14194](https://github.com/civicrm/civicrm-core/pull/14194) and
+  [14204](https://github.com/civicrm/civicrm-core/pull/14204))**
+
+- **Search displaying Related Contacts produces fatal error
+  ([dev/core#1002](https://lab.civicrm.org/dev/core/issues/1002):
+  [14409](https://github.com/civicrm/civicrm-core/pull/14409))**
+
+- **Error randomly appearing when Financial type ACL is enabled
+  ([dev/core#918](https://lab.civicrm.org/dev/core/issues/918):
+  [14165](https://github.com/civicrm/civicrm-core/pull/14165) and
+  [14168](https://github.com/civicrm/civicrm-core/pull/14168))**
+
+  Fixes an undefined index error `Undefined index: status in
+  CRM_Utils_Check_Component_FinancialTypeAcls::checkFinancialAclReport()` when a
+  site has a Financial Type ACL enabled.
+
+- **utf8mb4 warning keeps coming back up
+  ([dev/core#880](https://lab.civicrm.org/dev/core/issues/880):
+  [14123](https://github.com/civicrm/civicrm-core/pull/14123))**
+
+  This change makes it so users only receive the Mysql utf8mb4 status check
+  once, before this change the status check would show up whenever apache was
+  restarted.
+
+- **Fix import primary phone, primary email, add tests
+  ([14043](https://github.com/civicrm/civicrm-core/pull/14043))**
+
+  Fixes a bug where importing a phone (or email) & choosing 'Primary' as the
+  location type resulted in the creation of a duplicate, sometimes with no
+  location type.
+
+- **Fix upgrade message db setting location
+  ([14083](https://github.com/civicrm/civicrm-core/pull/14083))**
+
+  Updates the upgrade message "This database uses InnoDB Full Text Search for
+  optimized searching. The upgrade procedure has not been tested with this
+  feature. You should disable (and later re-enable) the feature by navigating
+  to..." to point to the right settings form "Administer => Customize Data and
+  Screens => Search Preferences" instead of "Administer => System Settings =>
+  Miscellaneous".
+
+- **Fix getAddressColumns() to respect tableAlias
+  ([14014](https://github.com/civicrm/civicrm-core/pull/14014))**
+
+  Fixes `CRM_Report_Form::getAddressColumns()` function so that it no longer
+  returns an error when used twice.
+
+- **Ensure edit tooltip is always initially hidden in contact summary block
+  ([14065](https://github.com/civicrm/civicrm-core/pull/14065))**
+
+  Ensures when a user does not have permission to edit a contact summary block,
+  the little "Edit" tooltip is hidden.
+
+- **Skip adding core resources when building assets
+  ([14010](https://github.com/civicrm/civicrm-core/pull/14010))**
+
+- **Advanced Search - Mailing column headers out of alignment
+  ([dev/core#248](https://lab.civicrm.org/dev/core/issues/248):
+  [14134](https://github.com/civicrm/civicrm-core/pull/14134))**
+
+- **Validate queue_id is a positive integer before passing to the BAO
+  ([14355](https://github.com/civicrm/civicrm-core/pull/14355))**
+
+-  **Fixes issue where contact's display name did not show on membership edit
+   If there was no registered email address
+   ([dev/core#1000](https://lab.civicrm.org/dev/core/issues/1000):
+   [14438](https://github.com/civicrm/civicrm-core/pull/14438))**
+
+### CiviCase
+
+- **Case activity query performs poorly on large databases
+  ([dev/core#832](https://lab.civicrm.org/dev/core/issues/832):
+  [14086](https://github.com/civicrm/civicrm-core/pull/14086) and
+  [14139](https://github.com/civicrm/civicrm-core/pull/14139))**
+
+  This change enhances performance of CiviCase by streamlining the Case Activity
+  Query which was crashing the server for some sites with large databases by
+  producing too many temporary files.
+
+- **Make `hook_civicrm_pre()` and `hook_civicrm_post()` fire on CaseContacts
+  ([14030](https://github.com/civicrm/civicrm-core/pull/14030))**
+
+### CiviContribute
+
+- **Always bootstrap CRM_Utils_System on legacy IPN endpoint
+  ([dev/drupal#66](https://lab.civicrm.org/dev/drupal/issues/66),
+  [dev/core#973](https://lab.civicrm.org/dev/core/issues/973), and
+  [dev/core#1017](https://lab.civicrm.org/dev/core/issues/1017):
+  [14406](https://github.com/civicrm/civicrm-core/pull/14406) and
+  [14430](https://github.com/civicrm/civicrm-core/pull/14430))**
+
+  This fixes a recent regression where recurring payments would fail to be
+  recorded in CiviCRM if the contribution was set to notify the legacy IPN URL.
+
+- **Fix checksum failure when editing recuring contributions
+  ([14407](https://github.com/civicrm/civicrm-core/pull/14407))**
+
+  Fixes a fatal error where checksum users were not able to cancel or update
+  recurring contributions.
+
+- **Fix error when exporting soft credits ([dev/core#1015](https://lab.civicrm.org/dev/core/issues/1015): [14453](https://github.com/civicrm/civicrm-core/pull/14453))** 
+
+### CiviEvent
+
+- **Event Cart: Pass the contactID to fix payment on Stripe
+  ([14173](https://github.com/civicrm/civicrm-core/pull/14173))**
+
+  Fixes a bug where a user could not complete an Event Registration using Event
+  Cart and the Stripe payment processor.
+
+- **Event Cart: Fix sending of email receipts
+  ([14170](https://github.com/civicrm/civicrm-core/pull/14170))**
+
+  Fixes fatal error being thrown when an email receipt was sent from an Event
+  Cart registration.
+
+- **Event Cart: Honor the allow_same_participant_emails setting
+  ([14174](https://github.com/civicrm/civicrm-core/pull/14174))**
+
+  Ensures the Event Cart Checkout process honors the "allow participants with
+  the same email address".
+
+- **Event Cart: Fix start_date formatting in line items during checkout
+  ([14169](https://github.com/civicrm/civicrm-core/pull/14169))**
+
+  Ensures start dates are formatted according to the site's localization
+  preference during the Event Cart checkout process.
+
+- **When creating a new event using a template, the new event screen is
+  taking the default values directly from the custom fields, and not from what's
+  saved in the event template.
+  ([CRM-18570](https://issues.civicrm.org/jira/browse/CRM-18570), [dev/core#553](https://lab.civicrm.org/dev/core/issues/553):
+  [14063](https://github.com/civicrm/civicrm-core/pull/14063))**
+
+### CiviMail
+
+- **Fixed double protocol being added in link by CKEditor.
+  ([14128](https://github.com/civicrm/civicrm-core/pull/14128))**
+
+  Fixes a bug where adding action tokens using the CKEditor link interface, and
+  then editing them could cause double protocols (ex: http://https:// or
+  http://http://).
+
+- **Fix ts() usage in CRM_SMS_Form_Schedule
+  ([14111](https://github.com/civicrm/civicrm-core/pull/14111))**
+
+  Allows translation of the "Send Mass SMS" form.
+
+### CiviMember
+
+- **Batch update membership type
+  ([dev/core#338](https://lab.civicrm.org/dev/core/issues/338):
+  [14064](https://github.com/civicrm/civicrm-core/pull/14064))**
+
+  Fixes a regression when batch updating membership types and copying values
+  down the column.
+
+- **Membership status processor ignoring records where is_override=0
+  ([dev/core#881](https://lab.civicrm.org/dev/core/issues/881):
+  [14059](https://github.com/civicrm/civicrm-core/pull/14059) and
+  [14073](https://github.com/civicrm/civicrm-core/pull/14073))**
+
+- **Back-office membership renewals don't display an on-screen notification
+  ([dev/membership#9](https://lab.civicrm.org/dev/membership/issues/9):
+  [14088](https://github.com/civicrm/civicrm-core/pull/14088))**
+
+- **Fix test / possible live error on submitting credit card renewals
+  ([14412](https://github.com/civicrm/civicrm-core/pull/14412))**
+
+  This resolves intermittent errors in unit tests when renewing memberships due
+  to the `receive_date` not being set.
+
+- **Fixed auto populate of contact reference field on membership signup form
+  ([14077](https://github.com/civicrm/civicrm-core/pull/14077))**
+
+### Drupal Integration
+
+- **Civi 5.12.1 renders Quicksearch unreadable on Drupal 8
+  ([dev/drupal#56](https://lab.civicrm.org/dev/drupal/issues/56):
+  [14080](https://github.com/civicrm/civicrm-core/pull/14080))**
+
+  Fixes a regression where the text in the Quicksearch box was too light to read
+  so that it is darker and easier to read.
+
+- **Don't render an empty mailto link for empty email addresses
+  ([540](https://github.com/civicrm/civicrm-drupal/pull/540))**
+
+  Fixes a bug in Views where an "email address" field set to output as a
+  `mailto:` link would still make a link if no email exists.
+
+- **Column next_sched_contribution should be next_sched_contribution_date for
+  Views integration
+  ([dev/drupal#48](https://lab.civicrm.org/dev/drupal/issues/48):
+  [578](https://github.com/civicrm/civicrm-drupal/pull/578))**
+
+### Joomla Integration
+
+- **Fix bug preventing affecting `cv --user` on Joomla
+  ([13890](https://github.com/civicrm/civicrm-core/pull/13890))**
+
+## <a name="misc"></a>Miscellany
+
+- **Bump PHP version to match core requirements
+  ([567](https://github.com/civicrm/civicrm-drupal/pull/567))**
+
+- **CiviUnitTestCase - Extract traits to facilitate extension testing
+  (preliminary work for
+  [dev/core#873](https://lab.civicrm.org/dev/core/issues/873):
+  [14044](https://github.com/civicrm/civicrm-core/pull/14044))**
+
+- **Refactor dedupe merger (preliminary work for
+  [dev/core#723](https://lab.civicrm.org/dev/core/issues/723):
+  [14144](https://github.com/civicrm/civicrm-core/pull/14144) and
+  [14146](https://github.com/civicrm/civicrm-core/pull/14146))**
+
+- **Replace all instances of CRM_Core_Fatal with throw new CRM_Core_Exception
+  (continues [dev/core#560](https://lab.civicrm.org/dev/core/issues/560):
+  [14143](https://github.com/civicrm/civicrm-core/pull/14143))**
+
+- **(Partial) Towards fixing E2E_Core_AssetBuilderTest on WordPress
+  ([14212](https://github.com/civicrm/civicrm-core/pull/14212/),
+  [14201](https://github.com/civicrm/civicrm-core/pull/14201))**
+
+- **(REF) Add unit tests on contribution recur trxn_id, contribution recur
+  processor id (preparation for
+  [dev/core#830](https://lab.civicrm.org/dev/core/issues/830):
+  [14119](https://github.com/civicrm/civicrm-core/pull/14119))**
+
+- **Remove instances of $dao->free (continues
+  [dev/core#562](https://lab.civicrm.org/dev/core/issues/562):
+  [14070](https://github.com/civicrm/civicrm-core/pull/14070),
+  [14071](https://github.com/civicrm/civicrm-core/pull/14071) and
+  [14037](https://github.com/civicrm/civicrm-core/pull/14037))**
+
+- **(NFC) Add tests of retreiving notes for display on a contact record a…
+  ([14094](https://github.com/civicrm/civicrm-core/pull/14094))**
+
+- **(NFC) Update CRM/Contact to match new coder style
+  ([14022](https://github.com/civicrm/civicrm-core/pull/14022))**
+
+- **(NFC) Minor code style fixes
+  ([14015](https://github.com/civicrm/civicrm-core/pull/14015))**
+
+- **(NFC) Add in unit test checking that E2E test returns sensible contac…
+  ([14076](https://github.com/civicrm/civicrm-core/pull/14076))**
+
+- **(NFC) Whitespace formatting for formButtons.tpl
+  ([14107](https://github.com/civicrm/civicrm-core/pull/14107))**
+
+- **(NFC) Expand unit test to show off double protocol error
+  ([14141](https://github.com/civicrm/civicrm-core/pull/14141))**
+
+- **(REF) Move gathering of location info to relevant function (towards
+  dev/core#723) ([14142](https://github.com/civicrm/civicrm-core/pull/14142))**
+
+- **(REF) Move the qfbug handling to it's own function (towards dev/core#723)
+  ([14140](https://github.com/civicrm/civicrm-core/pull/14140))**
+
+- **(REF) Use events for CMS resource loading
+  ([14131](https://github.com/civicrm/civicrm-core/pull/14131))**
+
+- **(REF) Extract getConflicts function
+  ([14148](https://github.com/civicrm/civicrm-core/pull/14148))**
+
+- **(REF) Extract get cfields function
+  ([14151](https://github.com/civicrm/civicrm-core/pull/14151))**
+
+- **(REF) Use variable for menubar height
+  ([14122](https://github.com/civicrm/civicrm-core/pull/14122))**
+
+- **(REF) Clean up CRM_Contribute_Form_SearchTest
+  ([14068](https://github.com/civicrm/civicrm-core/pull/14068))**
+
+- **(REF) Extract formatLocationBlock from import parsing
+  ([14040](https://github.com/civicrm/civicrm-core/pull/14040))**
+
+- **(REF) Function extraction in dedupe code
+  ([14157](https://github.com/civicrm/civicrm-core/pull/14157))**
+
+- **(REF) cleanup input parameters on extracted function
+  ([14050](https://github.com/civicrm/civicrm-core/pull/14050))**
+
+- **(REF) Fix accepted params in CustomValueTable::setValues
+  ([14079](https://github.com/civicrm/civicrm-core/pull/14079))**
+
+- **(REF) Fix unnecessary required param in contact BAO update
+  ([14075](https://github.com/civicrm/civicrm-core/pull/14075))**
+
+- **(REF) Reduce redundant code in CRM_Utils_Type::validate
+  ([14011](https://github.com/civicrm/civicrm-core/pull/14011))**
+
+- **(REF) Replace hardcoded IDs with pseudoconstants in activity form
+  ([14108](https://github.com/civicrm/civicrm-core/pull/14108))**
+
+- **(REF) Standardize UFField create function
+  ([14084](https://github.com/civicrm/civicrm-core/pull/14084))**
+
+- **(REF) Call formatLocationBlock from parent function.
+  ([14105](https://github.com/civicrm/civicrm-core/pull/14105))**
+
+- **(REF; dev/core#873) MailingAB - Migrate "copy winner" logic from JS to PHP
+  ([14045](https://github.com/civicrm/civicrm-core/pull/14045))**
+
+- **(REF) Don't pass activity object to addCaseActivityLinks
+  ([14110](https://github.com/civicrm/civicrm-core/pull/14110))**
+
+- **(REF) Use shared function to check inbound email permissions
+  ([14109](https://github.com/civicrm/civicrm-core/pull/14109))**
+
+- **(REF) Follow up tidy up on import fixes
+  ([14117](https://github.com/civicrm/civicrm-core/pull/14117))**
+
+- **Readability cleanup on EventIncome report (towards bringing it under
+  testing) ([13963](https://github.com/civicrm/civicrm-core/pull/13963))**
+
+- **Remove deprecated function
+  ([14039](https://github.com/civicrm/civicrm-core/pull/14039))**
+
+- **Revert "dev/core#553: Creating new event takes value from default value not
+  from saved template for custom fields"
+  ([14121](https://github.com/civicrm/civicrm-core/pull/14121))**
+
+- **Update docblock for doPayment function
+  ([13844](https://github.com/civicrm/civicrm-core/pull/13844))**
+
+- **(Cleanup) Remove CRM_Report_Form_Extended
+  ([14149](https://github.com/civicrm/civicrm-core/pull/14149))**
+
+## <a name="credits"></a>Credits
+
+This release was developed by the following code authors:
+
+AGH Strategies - Alice Frumin, Andrew Hunt; Agileware - Alok Patel; Australian
+Greens - Seamus Lee; Christian Wach; CiviCRM - Coleman Watts, Tim Otten;
+CiviDesk - Yashodha Chaku; Coop SymbioTIC - Mathieu Lutfy; Dave D; Electronic
+Frontier Foundation - Mark Burdett; Freeform Solutions - Herb van den Dool;
+Fuzion - Luke Stewart; Guillaume Rischard; JMA Consulting - Monish Deb; John
+Kingsnorth; Korlon - Stuart Gaston; Lighthouse Design and Consulting - Brian
+Shaughnessy; Megaphone Technology Consulting - Jon Goldberg; MJW Consulting -
+Matthew Wire; Pradeep Nayak; Squiffle Consulting - Aidan Saunders; Tadpole
+Collective - Kevin Cristiano; Wikimedia Foundation - Eileen McNaughton
+
+Most authors also reviewed code for this release; in addition, the following
+reviewers contributed their comments:
+
+AGH Strategies - Tommy Bobo; DevApp - Adam Kwiatkowski; Fuzion - Jitendra
+Purohit; JMA Consulting - Joe Murray; Nicol Wistreich; Palante - Morgan
+Robinson; Skvare - Mark Hanna; Tapash Datta;
+
+## <a name="feedback"></a>Feedback
+
+These release notes are edited by Alice Frumin and Andrew Hunt.  If you'd like
+to provide feedback on them, please log in to https://chat.civicrm.org/civicrm
+and contact `@agh1`.
diff --git a/civicrm/sql/civicrm_data.mysql b/civicrm/sql/civicrm_data.mysql
index 3366c9f6ce8232e7a12d244ce698f193b3a23910..74967271d03d883b87f4702a7929705599da72c6 100644
--- a/civicrm/sql/civicrm_data.mysql
+++ b/civicrm/sql/civicrm_data.mysql
@@ -5298,6 +5298,7 @@ VALUES
   (@option_group_id_sfe, 'docx', 12, 'docx',  NULL, 0, 0, 12, NULL, 0, 0, 1, NULL, NULL, NULL),
   (@option_group_id_sfe, 'xlsx', 13, 'xlsx',  NULL, 0, 0, 13, NULL, 0, 0, 1, NULL, NULL, NULL),
   (@option_group_id_sfe, 'odt',  14, 'odt',   NULL, 0, 0, 14, NULL, 0, 0, 1, NULL, NULL, NULL),
+  (@option_group_id_sfe, 'ics',  15, 'ics',   NULL, 0, 0, 15, NULL, 0, 0, 1, NULL, NULL, NULL),
 
   (@option_group_id_we, 'Textarea', 1, 'Textarea', NULL, 0, NULL, 1, NULL, 0, 1, 1, NULL, NULL, NULL),
   (@option_group_id_we, 'CKEditor', 2, 'CKEditor', NULL, 0, NULL, 2, NULL, 0, 1, 1, NULL, NULL, NULL),
@@ -24035,4 +24036,4 @@ INSERT INTO `civicrm_report_instance`
     ( `domain_id`, `title`, `report_id`, `description`, `permission`, `form_values`)
 VALUES
     (  @domainID, 'Survey Details', 'survey/detail', 'Detailed report for canvassing, phone-banking, walk lists or other surveys.', 'access CiviReport', 'a:39:{s:6:"fields";a:2:{s:9:"sort_name";s:1:"1";s:6:"result";s:1:"1";}s:22:"assignee_contact_id_op";s:2:"eq";s:25:"assignee_contact_id_value";s:0:"";s:12:"sort_name_op";s:3:"has";s:15:"sort_name_value";s:0:"";s:17:"street_number_min";s:0:"";s:17:"street_number_max";s:0:"";s:16:"street_number_op";s:3:"lte";s:19:"street_number_value";s:0:"";s:14:"street_name_op";s:3:"has";s:17:"street_name_value";s:0:"";s:15:"postal_code_min";s:0:"";s:15:"postal_code_max";s:0:"";s:14:"postal_code_op";s:3:"lte";s:17:"postal_code_value";s:0:"";s:7:"city_op";s:3:"has";s:10:"city_value";s:0:"";s:20:"state_province_id_op";s:2:"in";s:23:"state_province_id_value";a:0:{}s:13:"country_id_op";s:2:"in";s:16:"country_id_value";a:0:{}s:12:"survey_id_op";s:2:"in";s:15:"survey_id_value";a:0:{}s:12:"status_id_op";s:2:"eq";s:15:"status_id_value";s:1:"1";s:11:"custom_1_op";s:2:"in";s:14:"custom_1_value";a:0:{}s:11:"custom_2_op";s:2:"in";s:14:"custom_2_value";a:0:{}s:17:"custom_3_relative";s:1:"0";s:13:"custom_3_from";s:0:"";s:11:"custom_3_to";s:0:"";s:11:"description";s:75:"Detailed report for canvassing, phone-banking, walk lists or other surveys.";s:13:"email_subject";s:0:"";s:8:"email_to";s:0:"";s:8:"email_cc";s:0:"";s:10:"permission";s:17:"access CiviReport";s:6:"groups";s:0:"";s:9:"domain_id";i:1;}');
-UPDATE civicrm_domain SET version = '5.13.5';
+UPDATE civicrm_domain SET version = '5.14.0';
diff --git a/civicrm/sql/civicrm_generated.mysql b/civicrm/sql/civicrm_generated.mysql
index b2c60e87b78aab8a170ec9d9c62dc2cb0e483273..68573145eec8f69da28bba95e712e5a98c6af7f8 100644
--- a/civicrm/sql/civicrm_generated.mysql
+++ b/civicrm/sql/civicrm_generated.mysql
@@ -399,7 +399,7 @@ UNLOCK TABLES;
 
 LOCK TABLES `civicrm_domain` WRITE;
 /*!40000 ALTER TABLE `civicrm_domain` DISABLE KEYS */;
-INSERT INTO `civicrm_domain` (`id`, `name`, `description`, `config_backend`, `version`, `contact_id`, `locales`, `locale_custom_strings`) VALUES (1,'Default Domain Name',NULL,NULL,'5.13.5',1,NULL,'a:1:{s:5:\"en_US\";a:0:{}}');
+INSERT INTO `civicrm_domain` (`id`, `name`, `description`, `config_backend`, `version`, `contact_id`, `locales`, `locale_custom_strings`) VALUES (1,'Default Domain Name',NULL,NULL,'5.14.0',1,NULL,'a:1:{s:5:\"en_US\";a:0:{}}');
 /*!40000 ALTER TABLE `civicrm_domain` ENABLE KEYS */;
 UNLOCK TABLES;
 
@@ -1015,7 +1015,7 @@ UNLOCK TABLES;
 
 LOCK TABLES `civicrm_option_value` WRITE;
 /*!40000 ALTER TABLE `civicrm_option_value` DISABLE KEYS */;
-INSERT INTO `civicrm_option_value` (`id`, `option_group_id`, `label`, `value`, `name`, `grouping`, `filter`, `is_default`, `weight`, `description`, `is_optgroup`, `is_reserved`, `is_active`, `component_id`, `domain_id`, `visibility_id`, `icon`, `color`) VALUES (1,1,'Phone','1','Phone',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(2,1,'Email','2','Email',NULL,0,NULL,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(3,1,'Postal Mail','3','Postal Mail',NULL,0,NULL,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(4,1,'SMS','4','SMS',NULL,0,NULL,4,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(5,1,'Fax','5','Fax',NULL,0,NULL,5,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(6,2,'Meeting','1','Meeting',NULL,0,NULL,1,NULL,0,1,1,NULL,NULL,NULL,'fa-slideshare',NULL),(7,2,'Phone Call','2','Phone Call',NULL,0,NULL,2,NULL,0,1,1,NULL,NULL,NULL,'fa-phone',NULL),(8,2,'Email','3','Email',NULL,1,NULL,3,'Email sent.',0,1,1,NULL,NULL,NULL,'fa-envelope-o',NULL),(9,2,'Outbound SMS','4','SMS',NULL,1,NULL,4,'Text message (SMS) sent.',0,1,1,NULL,NULL,NULL,'fa-mobile',NULL),(10,2,'Event Registration','5','Event Registration',NULL,1,NULL,5,'Online or offline event registration.',0,1,1,1,NULL,NULL,NULL,NULL),(11,2,'Contribution','6','Contribution',NULL,1,NULL,6,'Online or offline contribution.',0,1,1,2,NULL,NULL,NULL,NULL),(12,2,'Membership Signup','7','Membership Signup',NULL,1,NULL,7,'Online or offline membership signup.',0,1,1,3,NULL,NULL,NULL,NULL),(13,2,'Membership Renewal','8','Membership Renewal',NULL,1,NULL,8,'Online or offline membership renewal.',0,1,1,3,NULL,NULL,NULL,NULL),(14,2,'Tell a Friend','9','Tell a Friend',NULL,1,NULL,9,'Send information about a contribution campaign or event to a friend.',0,1,1,NULL,NULL,NULL,NULL,NULL),(15,2,'Pledge Acknowledgment','10','Pledge Acknowledgment',NULL,1,NULL,10,'Send Pledge Acknowledgment.',0,1,1,6,NULL,NULL,NULL,NULL),(16,2,'Pledge Reminder','11','Pledge Reminder',NULL,1,NULL,11,'Send Pledge Reminder.',0,1,1,6,NULL,NULL,NULL,NULL),(17,2,'Inbound Email','12','Inbound Email',NULL,1,NULL,12,'Inbound Email.',0,1,1,NULL,NULL,NULL,NULL,NULL),(18,2,'Open Case','13','Open Case',NULL,0,0,13,'',0,1,1,7,NULL,NULL,'fa-folder-open-o',NULL),(19,2,'Follow up','14','Follow up',NULL,0,0,14,'',0,1,1,7,NULL,NULL,'fa-share-square-o',NULL),(20,2,'Change Case Type','15','Change Case Type',NULL,0,0,15,'',0,1,1,7,NULL,NULL,'fa-random',NULL),(21,2,'Change Case Status','16','Change Case Status',NULL,0,0,16,'',0,1,1,7,NULL,NULL,'fa-pencil-square-o',NULL),(22,2,'Change Case Subject','53','Change Case Subject',NULL,0,0,53,'',0,1,1,7,NULL,NULL,'fa-pencil-square-o',NULL),(23,2,'Change Custom Data','33','Change Custom Data',NULL,0,0,33,'',0,1,1,7,NULL,NULL,'fa-table',NULL),(24,2,'Membership Renewal Reminder','17','Membership Renewal Reminder',NULL,1,NULL,17,'offline membership renewal reminder.',0,1,1,3,NULL,NULL,NULL,NULL),(25,2,'Change Case Start Date','18','Change Case Start Date',NULL,0,0,18,'',0,1,1,7,NULL,NULL,'fa-calendar',NULL),(26,2,'Bulk Email','19','Bulk Email',NULL,1,NULL,19,'Bulk Email Sent.',0,1,1,NULL,NULL,NULL,NULL,NULL),(27,2,'Assign Case Role','20','Assign Case Role',NULL,0,0,20,'',0,1,1,7,NULL,NULL,'fa-user-plus',NULL),(28,2,'Remove Case Role','21','Remove Case Role',NULL,0,0,21,'',0,1,1,7,NULL,NULL,'fa-user-times',NULL),(29,2,'Print/Merge Document','22','Print PDF Letter',NULL,0,NULL,22,'Export letters and other printable documents.',0,1,1,NULL,NULL,NULL,'fa-file-pdf-o',NULL),(30,2,'Merge Case','23','Merge Case',NULL,0,NULL,23,'',0,1,1,7,NULL,NULL,'fa-compress',NULL),(31,2,'Reassigned Case','24','Reassigned Case',NULL,0,NULL,24,'',0,1,1,7,NULL,NULL,'fa-user-circle-o',NULL),(32,2,'Link Cases','25','Link Cases',NULL,0,NULL,25,'',0,1,1,7,NULL,NULL,'fa-link',NULL),(33,2,'Change Case Tags','26','Change Case Tags',NULL,0,0,26,'',0,1,1,7,NULL,NULL,'fa-tags',NULL),(34,2,'Add Client To Case','27','Add Client To Case',NULL,0,0,26,'',0,1,1,7,NULL,NULL,'fa-users',NULL),(35,2,'Survey','28','Survey',NULL,0,0,27,'',0,1,1,9,NULL,NULL,NULL,NULL),(36,2,'Canvass','29','Canvass',NULL,0,0,28,'',0,1,1,9,NULL,NULL,NULL,NULL),(37,2,'PhoneBank','30','PhoneBank',NULL,0,0,29,'',0,1,1,9,NULL,NULL,NULL,NULL),(38,2,'WalkList','31','WalkList',NULL,0,0,30,'',0,1,1,9,NULL,NULL,NULL,NULL),(39,2,'Petition Signature','32','Petition',NULL,0,0,31,'',0,1,1,9,NULL,NULL,NULL,NULL),(40,2,'Mass SMS','34','Mass SMS',NULL,1,NULL,34,'Mass SMS',0,1,1,NULL,NULL,NULL,NULL,NULL),(41,2,'Change Membership Status','35','Change Membership Status',NULL,1,NULL,35,'Change Membership Status.',0,1,1,3,NULL,NULL,NULL,NULL),(42,2,'Change Membership Type','36','Change Membership Type',NULL,1,NULL,36,'Change Membership Type.',0,1,1,3,NULL,NULL,NULL,NULL),(43,2,'Cancel Recurring Contribution','37','Cancel Recurring Contribution',NULL,1,0,37,'',0,1,1,2,NULL,NULL,NULL,NULL),(44,2,'Update Recurring Contribution Billing Details','38','Update Recurring Contribution Billing Details',NULL,1,0,38,'',0,1,1,2,NULL,NULL,NULL,NULL),(45,2,'Update Recurring Contribution','39','Update Recurring Contribution',NULL,1,0,39,'',0,1,1,2,NULL,NULL,NULL,NULL),(46,2,'Reminder Sent','40','Reminder Sent',NULL,1,0,40,'',0,1,1,NULL,NULL,NULL,NULL,NULL),(47,2,'Export Accounting Batch','41','Export Accounting Batch',NULL,1,0,41,'Export Accounting Batch',0,1,1,2,NULL,NULL,NULL,NULL),(48,2,'Create Batch','42','Create Batch',NULL,1,0,42,'Create Batch',0,1,1,2,NULL,NULL,NULL,NULL),(49,2,'Edit Batch','43','Edit Batch',NULL,1,0,43,'Edit Batch',0,1,1,2,NULL,NULL,NULL,NULL),(50,2,'SMS delivery','44','SMS delivery',NULL,1,NULL,44,'SMS delivery',0,1,1,NULL,NULL,NULL,NULL,NULL),(51,2,'Inbound SMS','45','Inbound SMS',NULL,1,NULL,45,'Inbound SMS',0,1,1,NULL,NULL,NULL,NULL,NULL),(52,2,'Payment','46','Payment',NULL,1,NULL,46,'Additional payment recorded for event or membership fee.',0,1,1,2,NULL,NULL,NULL,NULL),(53,2,'Refund','47','Refund',NULL,1,NULL,47,'Refund recorded for event or membership fee.',0,1,1,2,NULL,NULL,NULL,NULL),(54,2,'Change Registration','48','Change Registration',NULL,1,NULL,48,'Changes to an existing event registration.',0,1,1,1,NULL,NULL,NULL,NULL),(55,2,'Downloaded Invoice','49','Downloaded Invoice',NULL,1,NULL,49,'Downloaded Invoice.',0,1,1,NULL,NULL,NULL,NULL,NULL),(56,2,'Emailed Invoice','50','Emailed Invoice',NULL,1,NULL,50,'Emailed Invoice.',0,1,1,NULL,NULL,NULL,NULL,NULL),(57,2,'Contact Merged','51','Contact Merged',NULL,1,NULL,51,'Contact Merged',0,1,1,NULL,NULL,NULL,NULL,NULL),(58,2,'Contact Deleted by Merge','52','Contact Deleted by Merge',NULL,1,NULL,52,'Contact was merged into another contact',0,1,1,NULL,NULL,NULL,NULL,NULL),(59,2,'Failed Payment','54','Failed Payment',NULL,1,0,54,'Failed Payment',0,1,1,2,NULL,NULL,NULL,NULL),(60,3,'Female','1','Female',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(61,3,'Male','2','Male',NULL,0,NULL,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(62,3,'Other','3','Other',NULL,0,NULL,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(63,4,'Yahoo','1','Yahoo',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(64,4,'MSN','2','Msn',NULL,0,NULL,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(65,4,'AIM','3','Aim',NULL,0,NULL,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(66,4,'GTalk','4','Gtalk',NULL,0,NULL,4,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(67,4,'Jabber','5','Jabber',NULL,0,NULL,5,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(68,4,'Skype','6','Skype',NULL,0,NULL,6,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(69,5,'Sprint','1','Sprint',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(70,5,'Verizon','2','Verizon',NULL,0,NULL,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(71,5,'Cingular','3','Cingular',NULL,0,NULL,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(72,6,'Mrs.','1','Mrs.',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(73,6,'Ms.','2','Ms.',NULL,0,NULL,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(74,6,'Mr.','3','Mr.',NULL,0,NULL,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(75,6,'Dr.','4','Dr.',NULL,0,NULL,4,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(76,7,'Jr.','1','Jr.',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(77,7,'Sr.','2','Sr.',NULL,0,NULL,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(78,7,'II','3','II',NULL,0,NULL,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(79,7,'III','4','III',NULL,0,NULL,4,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(80,7,'IV','5','IV',NULL,0,NULL,5,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(81,7,'V','6','V',NULL,0,NULL,6,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(82,7,'VI','7','VI',NULL,0,NULL,7,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(83,7,'VII','8','VII',NULL,0,NULL,8,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(84,8,'Administrator','1','Admin',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(85,8,'Authenticated','2','Auth',NULL,0,NULL,2,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(86,9,'Visa','1','Visa',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(87,9,'MasterCard','2','MasterCard',NULL,0,NULL,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(88,9,'Amex','3','Amex',NULL,0,NULL,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(89,9,'Discover','4','Discover',NULL,0,NULL,4,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(90,10,'Credit Card','1','Credit Card',NULL,0,0,1,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(91,10,'Debit Card','2','Debit Card',NULL,0,0,2,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(92,10,'Cash','3','Cash',NULL,0,0,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(93,10,'Check','4','Check',NULL,0,1,4,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(94,10,'EFT','5','EFT',NULL,0,0,5,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(95,11,'Completed','1','Completed',NULL,0,NULL,1,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(96,11,'Pending','2','Pending',NULL,0,NULL,2,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(97,11,'Cancelled','3','Cancelled',NULL,0,NULL,3,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(98,11,'Failed','4','Failed',NULL,0,NULL,4,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(99,11,'In Progress','5','In Progress',NULL,0,NULL,5,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(100,11,'Overdue','6','Overdue',NULL,0,NULL,6,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(101,11,'Refunded','7','Refunded',NULL,0,NULL,7,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(102,11,'Partially paid','8','Partially paid',NULL,0,NULL,8,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(103,11,'Pending refund','9','Pending refund',NULL,0,NULL,9,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(104,11,'Chargeback','10','Chargeback',NULL,0,NULL,10,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(105,12,'Waiting Review','1','Waiting Review',NULL,0,NULL,1,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(106,12,'Approved','2','Approved',NULL,0,NULL,2,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(107,12,'Not Approved','3','Not Approved',NULL,0,NULL,3,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(108,13,'Owner chooses whether to receive notifications','1','owner_chooses',NULL,0,1,1,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(109,13,'Notifications are sent to ALL owners','2','all_owners',NULL,0,0,2,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(110,13,'Notifications are NOT available','3','no_notifications',NULL,0,0,3,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(111,14,'Attendee','1','Attendee',NULL,1,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(112,14,'Volunteer','2','Volunteer',NULL,1,NULL,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(113,14,'Host','3','Host',NULL,1,NULL,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(114,14,'Speaker','4','Speaker',NULL,1,NULL,4,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(115,15,'Conference','1','Conference',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(116,15,'Exhibition','2','Exhibition',NULL,0,NULL,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(117,15,'Fundraiser','3','Fundraiser',NULL,0,NULL,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(118,15,'Meeting','4','Meeting',NULL,0,NULL,4,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(119,15,'Performance','5','Performance',NULL,0,NULL,5,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(120,15,'Workshop','6','Workshop',NULL,0,NULL,6,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(121,16,'Activities','1','activity',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(122,16,'Relationships','2','rel',NULL,0,NULL,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(123,16,'Groups','3','group',NULL,0,NULL,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(124,16,'Notes','4','note',NULL,0,NULL,4,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(125,16,'Tags','5','tag',NULL,0,NULL,5,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(126,16,'Change Log','6','log',NULL,0,NULL,6,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(127,16,'Contributions','7','CiviContribute',NULL,0,NULL,7,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(128,16,'Memberships','8','CiviMember',NULL,0,NULL,8,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(129,16,'Events','9','CiviEvent',NULL,0,NULL,9,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(130,16,'Cases','10','CiviCase',NULL,0,NULL,10,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(131,16,'Grants','11','CiviGrant',NULL,0,NULL,11,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(132,16,'Pledges','13','CiviPledge',NULL,0,NULL,13,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(133,16,'Mailings','14','CiviMail',NULL,0,NULL,14,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(134,17,'Show Smart Groups on Demand','1','showondemand',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(135,17,'Always Show Smart Groups','2','alwaysshow',NULL,0,NULL,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(136,17,'Hide Smart Groups','3','hide',NULL,0,NULL,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(137,18,'Custom Data','1','CustomData',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(138,18,'Address','2','Address',NULL,0,NULL,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(139,18,'Communication Preferences','3','CommunicationPreferences',NULL,0,NULL,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(140,18,'Notes','4','Notes',NULL,0,NULL,4,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(141,18,'Demographics','5','Demographics',NULL,0,NULL,5,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(142,18,'Tags and Groups','6','TagsAndGroups',NULL,0,NULL,6,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(143,18,'Email','7','Email',NULL,1,NULL,7,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(144,18,'Phone','8','Phone',NULL,1,NULL,8,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(145,18,'Instant Messenger','9','IM',NULL,1,NULL,9,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(146,18,'Open ID','10','OpenID',NULL,1,NULL,10,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(147,18,'Website','11','Website',NULL,1,NULL,11,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(148,18,'Prefix','12','Prefix',NULL,2,NULL,12,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(149,18,'Formal Title','13','Formal Title',NULL,2,NULL,13,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(150,18,'First Name','14','First Name',NULL,2,NULL,14,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(151,18,'Middle Name','15','Middle Name',NULL,2,NULL,15,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(152,18,'Last Name','16','Last Name',NULL,2,NULL,16,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(153,18,'Suffix','17','Suffix',NULL,2,NULL,17,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(154,19,'Address Fields','1','location',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(155,19,'Custom Fields','2','custom',NULL,0,NULL,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(156,19,'Activities','3','activity',NULL,0,NULL,4,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(157,19,'Relationships','4','relationship',NULL,0,NULL,5,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(158,19,'Notes','5','notes',NULL,0,NULL,6,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(159,19,'Change Log','6','changeLog',NULL,0,NULL,7,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(160,19,'Contributions','7','CiviContribute',NULL,0,NULL,8,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(161,19,'Memberships','8','CiviMember',NULL,0,NULL,9,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(162,19,'Events','9','CiviEvent',NULL,0,NULL,10,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(163,19,'Cases','10','CiviCase',NULL,0,NULL,11,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(164,19,'Grants','12','CiviGrant',NULL,0,NULL,14,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(165,19,'Demographics','13','demographics',NULL,0,NULL,15,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(166,19,'Pledges','15','CiviPledge',NULL,0,NULL,17,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(167,19,'Contact Type','16','contactType',NULL,0,NULL,18,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(168,19,'Groups','17','groups',NULL,0,NULL,19,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(169,19,'Tags','18','tags',NULL,0,NULL,20,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(170,19,'Mailing','19','CiviMail',NULL,0,NULL,21,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(171,20,'Groups','1','Groups',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(172,20,'Contributions','2','CiviContribute',NULL,0,NULL,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(173,20,'Memberships','3','CiviMember',NULL,0,NULL,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(174,20,'Events','4','CiviEvent',NULL,0,NULL,4,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(175,20,'My Contacts / Organizations','5','Permissioned Orgs',NULL,0,NULL,5,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(176,20,'Pledges','7','CiviPledge',NULL,0,NULL,7,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(177,20,'Personal Campaign Pages','8','PCP',NULL,0,NULL,8,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(178,20,'Assigned Activities','9','Assigned Activities',NULL,0,NULL,9,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(179,20,'Invoices / Credit Notes','10','Invoices / Credit Notes',NULL,0,NULL,10,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(180,45,'Email Address','2','email',NULL,0,NULL,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(181,45,'Phone','3','phone',NULL,0,NULL,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(182,45,'Street Address','4','street_address',NULL,0,NULL,4,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(183,45,'City','5','city',NULL,0,NULL,5,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(184,45,'State/Province','6','state_province',NULL,0,NULL,6,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(185,45,'Country','7','country',NULL,0,NULL,7,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(186,45,'Postal Code','8','postal_code',NULL,0,NULL,8,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(187,46,'Email Address','2','email',NULL,0,NULL,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(188,46,'Phone','3','phone',NULL,0,NULL,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(189,46,'Street Address','4','street_address',NULL,0,NULL,4,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(190,46,'City','5','city',NULL,0,NULL,5,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(191,46,'State/Province','6','state_province',NULL,0,NULL,6,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(192,46,'Country','7','country',NULL,0,NULL,7,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(193,46,'Postal Code','8','country',NULL,0,NULL,8,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(194,21,'Street Address','1','street_address',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(195,21,'Supplemental Address 1','2','supplemental_address_1',NULL,0,NULL,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(196,21,'Supplemental Address 2','3','supplemental_address_2',NULL,0,NULL,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(197,21,'Supplemental Address 3','4','supplemental_address_3',NULL,0,NULL,4,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(198,21,'City','5','city',NULL,0,NULL,5,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(199,21,'Postal Code','6','postal_code',NULL,0,NULL,6,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(200,21,'Postal Code Suffix','7','postal_code_suffix',NULL,0,NULL,7,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(201,21,'County','8','county',NULL,0,NULL,8,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(202,21,'State/Province','9','state_province',NULL,0,NULL,9,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(203,21,'Country','10','country',NULL,0,NULL,10,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(204,21,'Latitude','11','geo_code_1',NULL,0,NULL,11,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(205,21,'Longitude','12','geo_code_2',NULL,0,NULL,12,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(206,21,'Address Name','13','address_name',NULL,0,NULL,13,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(207,21,'Street Address Parsing','14','street_address_parsing',NULL,0,NULL,14,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(208,22,'Access Control','1','Access Control',NULL,0,NULL,1,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(209,22,'Mailing List','2','Mailing List',NULL,0,NULL,2,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(210,23,'Submitted','1','Submitted',NULL,0,1,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(211,23,'Eligible','2','Eligible',NULL,0,NULL,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(212,23,'Ineligible','3','Ineligible',NULL,0,NULL,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(213,23,'Paid','4','Paid',NULL,0,NULL,4,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(214,23,'Awaiting Information','5','Awaiting Information',NULL,0,NULL,5,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(215,23,'Withdrawn','6','Withdrawn',NULL,0,NULL,6,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(216,23,'Approved for Payment','7','Approved for Payment',NULL,0,NULL,7,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(217,25,'CRM_Contact_Form_Search_Custom_Sample','1','CRM_Contact_Form_Search_Custom_Sample',NULL,0,NULL,1,'Household Name and State',0,0,1,NULL,NULL,NULL,NULL,NULL),(218,25,'CRM_Contact_Form_Search_Custom_ContributionAggregate','2','CRM_Contact_Form_Search_Custom_ContributionAggregate',NULL,0,NULL,2,'Contribution Aggregate',0,0,1,NULL,NULL,NULL,NULL,NULL),(219,25,'CRM_Contact_Form_Search_Custom_Basic','3','CRM_Contact_Form_Search_Custom_Basic',NULL,0,NULL,3,'Basic Search',0,0,1,NULL,NULL,NULL,NULL,NULL),(220,25,'CRM_Contact_Form_Search_Custom_Group','4','CRM_Contact_Form_Search_Custom_Group',NULL,0,NULL,4,'Include / Exclude Search',0,0,1,NULL,NULL,NULL,NULL,NULL),(221,25,'CRM_Contact_Form_Search_Custom_PostalMailing','5','CRM_Contact_Form_Search_Custom_PostalMailing',NULL,0,NULL,5,'Postal Mailing',0,0,1,NULL,NULL,NULL,NULL,NULL),(222,25,'CRM_Contact_Form_Search_Custom_Proximity','6','CRM_Contact_Form_Search_Custom_Proximity',NULL,0,NULL,6,'Proximity Search',0,0,1,NULL,NULL,NULL,NULL,NULL),(223,25,'CRM_Contact_Form_Search_Custom_EventAggregate','7','CRM_Contact_Form_Search_Custom_EventAggregate',NULL,0,NULL,7,'Event Aggregate',0,0,1,NULL,NULL,NULL,NULL,NULL),(224,25,'CRM_Contact_Form_Search_Custom_ActivitySearch','8','CRM_Contact_Form_Search_Custom_ActivitySearch',NULL,0,NULL,8,'Activity Search',0,0,1,NULL,NULL,NULL,NULL,NULL),(225,25,'CRM_Contact_Form_Search_Custom_PriceSet','9','CRM_Contact_Form_Search_Custom_PriceSet',NULL,0,NULL,9,'Price Set Details for Event Participants',0,0,1,NULL,NULL,NULL,NULL,NULL),(226,25,'CRM_Contact_Form_Search_Custom_ZipCodeRange','10','CRM_Contact_Form_Search_Custom_ZipCodeRange',NULL,0,NULL,10,'Zip Code Range',0,0,1,NULL,NULL,NULL,NULL,NULL),(227,25,'CRM_Contact_Form_Search_Custom_DateAdded','11','CRM_Contact_Form_Search_Custom_DateAdded',NULL,0,NULL,11,'Date Added to CiviCRM',0,0,1,NULL,NULL,NULL,NULL,NULL),(228,25,'CRM_Contact_Form_Search_Custom_MultipleValues','12','CRM_Contact_Form_Search_Custom_MultipleValues',NULL,0,NULL,12,'Custom Group Multiple Values Listing',0,0,1,NULL,NULL,NULL,NULL,NULL),(229,25,'CRM_Contact_Form_Search_Custom_ContribSYBNT','13','CRM_Contact_Form_Search_Custom_ContribSYBNT',NULL,0,NULL,13,'Contributions made in Year X and not Year Y',0,0,1,NULL,NULL,NULL,NULL,NULL),(230,25,'CRM_Contact_Form_Search_Custom_TagContributions','14','CRM_Contact_Form_Search_Custom_TagContributions',NULL,0,NULL,14,'Find Contribution Amounts by Tag',0,0,1,NULL,NULL,NULL,NULL,NULL),(231,25,'CRM_Contact_Form_Search_Custom_FullText','15','CRM_Contact_Form_Search_Custom_FullText',NULL,0,NULL,15,'Full-text Search',0,0,1,NULL,NULL,NULL,NULL,NULL),(232,41,'Constituent Report (Summary)','contact/summary','CRM_Report_Form_Contact_Summary',NULL,0,NULL,1,'Provides a list of address and telephone information for constituent records in your system.',0,0,1,NULL,NULL,NULL,NULL,NULL),(233,41,'Constituent Report (Detail)','contact/detail','CRM_Report_Form_Contact_Detail',NULL,0,NULL,2,'Provides contact-related information on contributions, memberships, events and activities.',0,0,1,NULL,NULL,NULL,NULL,NULL),(234,41,'Activity Details Report','activity','CRM_Report_Form_Activity',NULL,0,NULL,3,'Provides a list of constituent activity including activity statistics for one/all contacts during a given date range(required)',0,0,1,NULL,NULL,NULL,NULL,NULL),(235,41,'Walk / Phone List Report','walklist','CRM_Report_Form_Walklist_Walklist',NULL,0,NULL,4,'Provides a detailed report for your walk/phonelist for targeted contacts',0,0,0,NULL,NULL,NULL,NULL,NULL),(236,41,'Current Employer Report','contact/currentEmployer','CRM_Report_Form_Contact_CurrentEmployer',NULL,0,NULL,5,'Provides detail list of employer employee relationships along with employment details Ex Join Date',0,0,1,NULL,NULL,NULL,NULL,NULL),(237,41,'Contribution Summary Report','contribute/summary','CRM_Report_Form_Contribute_Summary',NULL,0,NULL,6,'Groups and totals contributions by criteria including contact, time period, financial type, contributor location, etc.',0,0,1,2,NULL,NULL,NULL,NULL),(238,41,'Contribution Detail Report','contribute/detail','CRM_Report_Form_Contribute_Detail',NULL,0,NULL,7,'Lists specific contributions by criteria including contact, time period, financial type, contributor location, etc. Contribution summary report points to this report for contribution details.',0,0,1,2,NULL,NULL,NULL,NULL),(239,41,'Repeat Contributions Report','contribute/repeat','CRM_Report_Form_Contribute_Repeat',NULL,0,NULL,8,'Given two date ranges, shows contacts who contributed in both the date ranges with the amount contributed in each and the percentage increase / decrease.',0,0,1,2,NULL,NULL,NULL,NULL),(240,41,'Contributions by Organization Report','contribute/organizationSummary','CRM_Report_Form_Contribute_OrganizationSummary',NULL,0,NULL,9,'Displays a detailed list of contributions grouped by organization, which includes contributions made by employees for the organisation.',0,0,1,2,NULL,NULL,NULL,NULL),(241,41,'Contributions by Household Report','contribute/householdSummary','CRM_Report_Form_Contribute_HouseholdSummary',NULL,0,NULL,10,'Displays a detailed list of contributions grouped by household which includes contributions made by members of the household.',0,0,1,2,NULL,NULL,NULL,NULL),(242,41,'Top Donors Report','contribute/topDonor','CRM_Report_Form_Contribute_TopDonor',NULL,0,NULL,11,'Provides a list of the top donors during a time period you define. You can include as many donors as you want (for example, top 100 of your donors).',0,0,1,2,NULL,NULL,NULL,NULL),(243,41,'SYBUNT Report','contribute/sybunt','CRM_Report_Form_Contribute_Sybunt',NULL,0,NULL,12,'SYBUNT means some year(s) but not this year. Provides a list of constituents who donated at some time in the history of your organization but did not donate during the time period you specify.',0,0,1,2,NULL,NULL,NULL,NULL),(244,41,'LYBUNT Report','contribute/lybunt','CRM_Report_Form_Contribute_Lybunt',NULL,0,NULL,13,'LYBUNT means last year but not this year. Provides a list of constituents who donated last year but did not donate during the time period you specify as the current year.',0,0,1,2,NULL,NULL,NULL,NULL),(245,41,'Soft Credit Report','contribute/softcredit','CRM_Report_Form_Contribute_SoftCredit',NULL,0,NULL,14,'Shows contributions made by contacts that have been soft-credited to other contacts.',0,0,1,2,NULL,NULL,NULL,NULL),(246,41,'Membership Report (Summary)','member/summary','CRM_Report_Form_Member_Summary',NULL,0,NULL,15,'Provides a summary of memberships by type and join date.',0,0,1,3,NULL,NULL,NULL,NULL),(247,41,'Membership Report (Detail)','member/detail','CRM_Report_Form_Member_Detail',NULL,0,NULL,16,'Provides a list of members along with their membership status and membership details (Join Date, Start Date, End Date). Can also display contributions (payments) associated with each membership.',0,0,1,3,NULL,NULL,NULL,NULL),(248,41,'Membership Report (Lapsed)','member/lapse','CRM_Report_Form_Member_Lapse',NULL,0,NULL,17,'Provides a list of memberships that lapsed or will lapse before the date you specify.',0,0,1,3,NULL,NULL,NULL,NULL),(249,41,'Event Participant Report (List)','event/participantListing','CRM_Report_Form_Event_ParticipantListing',NULL,0,NULL,18,'Provides lists of participants for an event.',0,0,1,1,NULL,NULL,NULL,NULL),(250,41,'Event Income Report (Summary)','event/summary','CRM_Report_Form_Event_Summary',NULL,0,NULL,19,'Provides an overview of event income. You can include key information such as event ID, registration, attendance, and income generated to help you determine the success of an event.',0,0,1,1,NULL,NULL,NULL,NULL),(251,41,'Event Income Report (Detail)','event/income','CRM_Report_Form_Event_Income',NULL,0,NULL,20,'Helps you to analyze the income generated by an event. The report can include details by participant type, status and payment method.',0,0,1,1,NULL,NULL,NULL,NULL),(252,41,'Pledge Detail Report','pledge/detail','CRM_Report_Form_Pledge_Detail',NULL,0,NULL,21,'List of pledges including amount pledged, pledge status, next payment date, balance due, total amount paid etc.',0,0,1,6,NULL,NULL,NULL,NULL),(253,41,'Pledged but not Paid Report','pledge/pbnp','CRM_Report_Form_Pledge_Pbnp',NULL,0,NULL,22,'Pledged but not Paid Report',0,0,1,6,NULL,NULL,NULL,NULL),(254,41,'Relationship Report','contact/relationship','CRM_Report_Form_Contact_Relationship',NULL,0,NULL,23,'Relationship Report',0,0,1,NULL,NULL,NULL,NULL,NULL),(255,41,'Case Summary Report','case/summary','CRM_Report_Form_Case_Summary',NULL,0,NULL,24,'Provides a summary of cases and their duration by date range, status, staff member and / or case role.',0,0,1,7,NULL,NULL,NULL,NULL),(256,41,'Case Time Spent Report','case/timespent','CRM_Report_Form_Case_TimeSpent',NULL,0,NULL,25,'Aggregates time spent on case and / or non-case activities by activity type and contact.',0,0,1,7,NULL,NULL,NULL,NULL),(257,41,'Contact Demographics Report','case/demographics','CRM_Report_Form_Case_Demographics',NULL,0,NULL,26,'Demographic breakdown for case clients (and or non-case contacts) in your database. Includes custom contact fields.',0,0,1,7,NULL,NULL,NULL,NULL),(258,41,'Database Log Report','contact/log','CRM_Report_Form_Contact_Log',NULL,0,NULL,27,'Log of contact and activity records created or updated in a given date range.',0,0,1,NULL,NULL,NULL,NULL,NULL),(259,41,'Activity Summary Report','activitySummary','CRM_Report_Form_ActivitySummary',NULL,0,NULL,28,'Shows activity statistics by type / date',0,0,1,NULL,NULL,NULL,NULL,NULL),(260,41,'Bookkeeping Transactions Report','contribute/bookkeeping','CRM_Report_Form_Contribute_Bookkeeping',NULL,0,0,29,'Shows Bookkeeping Transactions Report',0,0,1,2,NULL,NULL,NULL,NULL),(261,41,'Grant Report (Detail)','grant/detail','CRM_Report_Form_Grant_Detail',NULL,0,0,30,'Grant Report Detail',0,0,1,5,NULL,NULL,NULL,NULL),(262,41,'Participant list Count Report','event/participantlist','CRM_Report_Form_Event_ParticipantListCount',NULL,0,0,31,'Shows the Participant list with Participant Count.',0,0,1,1,NULL,NULL,NULL,NULL),(263,41,'Income Count Summary Report','event/incomesummary','CRM_Report_Form_Event_IncomeCountSummary',NULL,0,0,32,'Shows the Income Summary of events with Count.',0,0,1,1,NULL,NULL,NULL,NULL),(264,41,'Case Detail Report','case/detail','CRM_Report_Form_Case_Detail',NULL,0,0,33,'Case Details',0,0,1,7,NULL,NULL,NULL,NULL),(265,41,'Mail Bounce Report','Mailing/bounce','CRM_Report_Form_Mailing_Bounce',NULL,0,NULL,34,'Bounce Report for mailings',0,0,1,4,NULL,NULL,NULL,NULL),(266,41,'Mail Summary Report','Mailing/summary','CRM_Report_Form_Mailing_Summary',NULL,0,NULL,35,'Summary statistics for mailings',0,0,1,4,NULL,NULL,NULL,NULL),(267,41,'Mail Opened Report','Mailing/opened','CRM_Report_Form_Mailing_Opened',NULL,0,NULL,36,'Display contacts who opened emails from a mailing',0,0,1,4,NULL,NULL,NULL,NULL),(268,41,'Mail Click-Through Report','Mailing/clicks','CRM_Report_Form_Mailing_Clicks',NULL,0,NULL,37,'Display clicks from each mailing',0,0,1,4,NULL,NULL,NULL,NULL),(269,41,'Contact Logging Report (Summary)','logging/contact/summary','CRM_Report_Form_Contact_LoggingSummary',NULL,0,NULL,38,'Contact modification report for the logging infrastructure (summary).',0,0,0,NULL,NULL,NULL,NULL,NULL),(270,41,'Contact Logging Report (Detail)','logging/contact/detail','CRM_Report_Form_Contact_LoggingDetail',NULL,0,NULL,39,'Contact modification report for the logging infrastructure (detail).',0,0,0,NULL,NULL,NULL,NULL,NULL),(271,41,'Grant Report (Statistics)','grant/statistics','CRM_Report_Form_Grant_Statistics',NULL,0,NULL,42,'Shows statistics for Grants.',0,0,1,5,NULL,NULL,NULL,NULL),(272,41,'Survey Report (Detail)','survey/detail','CRM_Report_Form_Campaign_SurveyDetails',NULL,0,NULL,43,'Detailed report for canvassing, phone-banking, walk lists or other surveys.',0,0,1,9,NULL,NULL,NULL,NULL),(273,41,'Personal Campaign Page Report','contribute/pcp','CRM_Report_Form_Contribute_PCP',NULL,0,NULL,44,'Summarizes amount raised and number of contributors for each Personal Campaign Page.',0,0,1,2,NULL,NULL,NULL,NULL),(274,41,'Pledge Summary Report','pledge/summary','CRM_Report_Form_Pledge_Summary',NULL,0,NULL,45,'Groups and totals pledges by criteria including contact, time period, pledge status, location, etc.',0,0,1,6,NULL,NULL,NULL,NULL),(275,41,'Contribution Aggregate by Relationship','contribute/history','CRM_Report_Form_Contribute_History',NULL,0,NULL,46,'List contact\'s donation history, grouped by year, along with contributions attributed to any of the contact\'s related contacts.',0,0,1,2,NULL,NULL,NULL,NULL),(276,41,'Mail Detail Report','mailing/detail','CRM_Report_Form_Mailing_Detail',NULL,0,NULL,47,'Provides reporting on Intended and Successful Deliveries, Unsubscribes and Opt-outs, Replies and Forwards.',0,0,1,4,NULL,NULL,NULL,NULL),(277,41,'Contribution and Membership Details','member/contributionDetail','CRM_Report_Form_Member_ContributionDetail',NULL,0,NULL,48,'Contribution details for any type of contribution, plus associated membership information for contributions which are in payment for memberships.',0,0,1,3,NULL,NULL,NULL,NULL),(278,41,'Recurring Contributions Report','contribute/recur','CRM_Report_Form_Contribute_Recur',NULL,0,NULL,49,'Provides information about the status of recurring contributions',0,0,1,2,NULL,NULL,NULL,NULL),(279,41,'Recurring Contributions Summary','contribute/recursummary','CRM_Report_Form_Contribute_RecurSummary',NULL,0,NULL,49,'Provides simple summary for each payment instrument for which there are recurring contributions (e.g. Credit Card, Standing Order, Direct Debit, etc., NULL), showing within a given date range.',0,0,1,2,NULL,NULL,NULL,NULL),(280,41,'Deferred Revenue Details','contribute/deferredrevenue','CRM_Report_Form_Contribute_DeferredRevenue',NULL,0,NULL,50,'Deferred Revenue Details Report',0,0,1,2,NULL,NULL,NULL,NULL),(281,26,'Scheduled','1','Scheduled',NULL,0,1,1,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(282,26,'Completed','2','Completed',NULL,1,NULL,2,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(283,26,'Cancelled','3','Cancelled',NULL,2,NULL,3,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(284,26,'Left Message','4','Left Message',NULL,0,NULL,4,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(285,26,'Unreachable','5','Unreachable',NULL,2,NULL,5,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(286,26,'Not Required','6','Not Required',NULL,2,NULL,6,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(287,26,'Available','7','Available',NULL,0,NULL,7,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(288,26,'No-show','8','No_show',NULL,2,NULL,8,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(289,28,'Ongoing','1','Open','Opened',0,1,1,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(290,28,'Resolved','2','Closed','Closed',0,NULL,2,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(291,28,'Urgent','3','Urgent','Opened',0,NULL,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(292,29,'Name Only','1','Name Only',NULL,0,0,1,'CRM_Event_Page_ParticipantListing_Name',0,1,1,NULL,NULL,NULL,NULL,NULL),(293,29,'Name and Email','2','Name and Email',NULL,0,0,2,'CRM_Event_Page_ParticipantListing_NameAndEmail',0,1,1,NULL,NULL,NULL,NULL,NULL),(294,29,'Name, Status and Register Date','3','Name, Status and Register Date',NULL,0,0,3,'CRM_Event_Page_ParticipantListing_NameStatusAndDate',0,1,1,NULL,NULL,NULL,NULL,NULL),(295,30,'jpg','1','jpg',NULL,0,0,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(296,30,'jpeg','2','jpeg',NULL,0,0,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(297,30,'png','3','png',NULL,0,0,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(298,30,'gif','4','gif',NULL,0,0,4,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(299,30,'txt','5','txt',NULL,0,0,5,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(300,30,'pdf','6','pdf',NULL,0,0,6,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(301,30,'doc','7','doc',NULL,0,0,7,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(302,30,'xls','8','xls',NULL,0,0,8,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(303,30,'rtf','9','rtf',NULL,0,0,9,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(304,30,'csv','10','csv',NULL,0,0,10,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(305,30,'ppt','11','ppt',NULL,0,0,11,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(306,30,'docx','12','docx',NULL,0,0,12,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(307,30,'xlsx','13','xlsx',NULL,0,0,13,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(308,30,'odt','14','odt',NULL,0,0,14,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(309,33,'Textarea','1','Textarea',NULL,0,NULL,1,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(310,33,'CKEditor','2','CKEditor',NULL,0,NULL,2,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(311,32,'Search Builder','1','Search Builder',NULL,0,0,1,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(312,32,'Import Contact','2','Import Contact',NULL,0,0,2,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(313,32,'Import Activity','3','Import Activity',NULL,0,0,3,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(314,32,'Import Contribution','4','Import Contribution',NULL,0,0,4,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(315,32,'Import Membership','5','Import Membership',NULL,0,0,5,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(316,32,'Import Participant','6','Import Participant',NULL,0,0,6,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(317,32,'Export Contact','7','Export Contact',NULL,0,0,7,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(318,32,'Export Contribution','8','Export Contribution',NULL,0,0,8,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(319,32,'Export Membership','9','Export Membership',NULL,0,0,9,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(320,32,'Export Participant','10','Export Participant',NULL,0,0,10,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(321,32,'Export Pledge','11','Export Pledge',NULL,0,0,11,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(322,32,'Export Case','12','Export Case',NULL,0,0,12,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(323,32,'Export Grant','13','Export Grant',NULL,0,0,13,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(324,32,'Export Activity','14','Export Activity',NULL,0,0,14,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(325,34,'day','day','day',NULL,0,NULL,1,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(326,34,'week','week','week',NULL,0,NULL,2,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(327,34,'month','month','month',NULL,0,NULL,3,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(328,34,'year','year','year',NULL,0,NULL,4,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(329,35,'Phone','1','Phone',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(330,35,'Mobile','2','Mobile',NULL,0,NULL,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(331,35,'Fax','3','Fax',NULL,0,NULL,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(332,35,'Pager','4','Pager',NULL,0,NULL,4,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(333,35,'Voicemail','5','Voicemail',NULL,0,NULL,5,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(334,36,'Participant Role','1','ParticipantRole',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(335,36,'Participant Event Name','2','ParticipantEventName',NULL,0,NULL,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(336,36,'Participant Event Type','3','ParticipantEventType',NULL,0,NULL,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(337,37,'Public','1','public',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(338,37,'Admin','2','admin',NULL,0,NULL,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(339,38,'IMAP','1','IMAP',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(340,38,'Maildir','2','Maildir',NULL,0,NULL,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(341,38,'POP3','3','POP3',NULL,0,NULL,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(342,38,'Localdir','4','Localdir',NULL,0,NULL,4,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(343,39,'Urgent','1','Urgent',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(344,39,'Normal','2','Normal',NULL,0,NULL,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(345,39,'Low','3','Low',NULL,0,NULL,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(346,40,'Vancouver','city_','city_',NULL,0,NULL,1,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(347,40,'/(19|20)(\\d{2})-(\\d{1,2})-(\\d{1,2})/','date_','date_',NULL,1,NULL,2,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(348,42,'Dear {contact.first_name}','1','Dear {contact.first_name}',NULL,1,1,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(349,42,'Dear {contact.individual_prefix} {contact.first_name} {contact.last_name}','2','Dear {contact.individual_prefix} {contact.first_name} {contact.last_name}',NULL,1,0,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(350,42,'Dear {contact.individual_prefix} {contact.last_name}','3','Dear {contact.individual_prefix} {contact.last_name}',NULL,1,0,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(351,42,'Customized','4','Customized',NULL,0,0,4,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(352,42,'Dear {contact.household_name}','5','Dear {contact.household_name}',NULL,2,1,5,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(353,43,'Dear {contact.first_name}','1','Dear {contact.first_name}',NULL,1,1,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(354,43,'Dear {contact.individual_prefix} {contact.first_name} {contact.last_name}','2','Dear {contact.individual_prefix} {contact.first_name} {contact.last_name}',NULL,1,0,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(355,43,'Dear {contact.individual_prefix} {contact.last_name}','3','Dear {contact.individual_prefix} {contact.last_name}',NULL,1,0,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(356,43,'Customized','4','Customized',NULL,0,0,4,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(357,43,'Dear {contact.household_name}','5','Dear {contact.household_name}',NULL,2,1,5,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(358,44,'{contact.individual_prefix}{ } {contact.first_name}{ }{contact.middle_name}{ }{contact.last_name}{ }{contact.individual_suffix}','1','}{contact.individual_prefix}{ } {contact.first_name}{ }{contact.middle_name}{ }{contact.last_name}{ }{contact.individual_suffix}',NULL,1,1,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(359,44,'{contact.household_name}','2','{contact.household_name}',NULL,2,1,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(360,44,'{contact.organization_name}','3','{contact.organization_name}',NULL,3,1,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(361,44,'Customized','4','Customized',NULL,0,0,4,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(362,47,'Work','1','Work',NULL,0,1,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(363,47,'Main','2','Main',NULL,0,NULL,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(364,47,'Facebook','3','Facebook',NULL,0,NULL,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(365,47,'Google+','4','Google_',NULL,0,NULL,4,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(366,47,'Instagram','5','Instagram',NULL,0,NULL,5,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(367,47,'LinkedIn','6','LinkedIn',NULL,0,NULL,6,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(368,47,'MySpace','7','MySpace',NULL,0,NULL,7,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(369,47,'Pinterest','8','Pinterest',NULL,0,NULL,8,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(370,47,'SnapChat','9','SnapChat',NULL,0,NULL,9,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(371,47,'Tumblr','10','Tumblr',NULL,0,NULL,10,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(372,47,'Twitter','11','Twitter',NULL,0,NULL,11,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(373,47,'Vine','12','Vine ',NULL,0,NULL,12,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(374,48,'Contacts','civicrm_contact','Contacts',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(375,48,'Activities','civicrm_activity','Activities',NULL,0,NULL,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(376,48,'Cases','civicrm_case','Cases',NULL,0,NULL,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(377,48,'Attachments','civicrm_file','Attachements',NULL,0,NULL,4,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(378,49,'USD ($)','USD','USD',NULL,0,1,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(379,50,'Name Only','1','CRM_Event_Badge_Simple',NULL,0,0,1,'Simple Event Name Badge',0,1,1,NULL,NULL,NULL,NULL,NULL),(380,50,'Name Tent','2','CRM_Event_Badge_NameTent',NULL,0,0,2,'Name Tent',0,1,1,NULL,NULL,NULL,NULL,NULL),(381,50,'With Logo','3','CRM_Event_Badge_Logo',NULL,0,0,3,'You can set your own background image',0,1,1,NULL,NULL,NULL,NULL,NULL),(382,50,'5395 with Logo','4','CRM_Event_Badge_Logo5395',NULL,0,0,4,'Avery 5395 compatible labels with logo (4 up by 2, 59.2mm x 85.7mm)',0,1,1,NULL,NULL,NULL,NULL,NULL),(383,51,'None','0','None',NULL,0,1,1,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(384,51,'Author Only','1','Author Only',NULL,0,0,2,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(385,52,'Direct Mail','1','Direct Mail',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(386,52,'Referral Program','2','Referral Program',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(387,52,'Constituent Engagement','3','Constituent Engagement',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(388,53,'Planned','1','Planned',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(389,53,'In Progress','2','In Progress',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(390,53,'Completed','3','Completed',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(391,53,'Cancelled','4','Cancelled',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(392,56,'1','1','1',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(393,56,'2','2','2',NULL,0,NULL,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(394,56,'3','3','3',NULL,0,NULL,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(395,56,'4','4','4',NULL,0,NULL,4,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(396,56,'5','5','5',NULL,0,NULL,5,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(397,58,'Letter','{\"metric\":\"in\",\"width\":8.5,\"height\":11}','letter',NULL,NULL,1,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(398,58,'Legal','{\"metric\":\"in\",\"width\":8.5,\"height\":14}','legal',NULL,NULL,0,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(399,58,'Ledger','{\"metric\":\"in\",\"width\":17,\"height\":11}','ledger',NULL,NULL,0,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(400,58,'Tabloid','{\"metric\":\"in\",\"width\":11,\"height\":17}','tabloid',NULL,NULL,0,4,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(401,58,'Executive','{\"metric\":\"in\",\"width\":7.25,\"height\":10.5}','executive',NULL,NULL,0,5,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(402,58,'Folio','{\"metric\":\"in\",\"width\":8.5,\"height\":13}','folio',NULL,NULL,0,6,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(403,58,'Envelope #9','{\"metric\":\"pt\",\"width\":638.93,\"height\":278.93}','envelope-9',NULL,NULL,0,7,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(404,58,'Envelope #10','{\"metric\":\"pt\",\"width\":684,\"height\":297}','envelope-10',NULL,NULL,0,8,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(405,58,'Envelope #11','{\"metric\":\"pt\",\"width\":747,\"height\":324}','envelope-11',NULL,NULL,0,9,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(406,58,'Envelope #12','{\"metric\":\"pt\",\"width\":792,\"height\":342}','envelope-12',NULL,NULL,0,10,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(407,58,'Envelope #14','{\"metric\":\"pt\",\"width\":828,\"height\":360}','envelope-14',NULL,NULL,0,11,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(408,58,'Envelope ISO B4','{\"metric\":\"pt\",\"width\":1000.63,\"height\":708.66}','envelope-b4',NULL,NULL,0,12,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(409,58,'Envelope ISO B5','{\"metric\":\"pt\",\"width\":708.66,\"height\":498.9}','envelope-b5',NULL,NULL,0,13,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(410,58,'Envelope ISO B6','{\"metric\":\"pt\",\"width\":498.9,\"height\":354.33}','envelope-b6',NULL,NULL,0,14,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(411,58,'Envelope ISO C3','{\"metric\":\"pt\",\"width\":1298.27,\"height\":918.42}','envelope-c3',NULL,NULL,0,15,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(412,58,'Envelope ISO C4','{\"metric\":\"pt\",\"width\":918.42,\"height\":649.13}','envelope-c4',NULL,NULL,0,16,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(413,58,'Envelope ISO C5','{\"metric\":\"pt\",\"width\":649.13,\"height\":459.21}','envelope-c5',NULL,NULL,0,17,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(414,58,'Envelope ISO C6','{\"metric\":\"pt\",\"width\":459.21,\"height\":323.15}','envelope-c6',NULL,NULL,0,18,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(415,58,'Envelope ISO DL','{\"metric\":\"pt\",\"width\":623.622,\"height\":311.811}','envelope-dl',NULL,NULL,0,19,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(416,58,'ISO A0','{\"metric\":\"pt\",\"width\":2383.94,\"height\":3370.39}','a0',NULL,NULL,0,20,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(417,58,'ISO A1','{\"metric\":\"pt\",\"width\":1683.78,\"height\":2383.94}','a1',NULL,NULL,0,21,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(418,58,'ISO A2','{\"metric\":\"pt\",\"width\":1190.55,\"height\":1683.78}','a2',NULL,NULL,0,22,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(419,58,'ISO A3','{\"metric\":\"pt\",\"width\":841.89,\"height\":1190.55}','a3',NULL,NULL,0,23,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(420,58,'ISO A4','{\"metric\":\"pt\",\"width\":595.28,\"height\":841.89}','a4',NULL,NULL,0,24,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(421,58,'ISO A5','{\"metric\":\"pt\",\"width\":419.53,\"height\":595.28}','a5',NULL,NULL,0,25,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(422,58,'ISO A6','{\"metric\":\"pt\",\"width\":297.64,\"height\":419.53}','a6',NULL,NULL,0,26,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(423,58,'ISO A7','{\"metric\":\"pt\",\"width\":209.76,\"height\":297.64}','a7',NULL,NULL,0,27,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(424,58,'ISO A8','{\"metric\":\"pt\",\"width\":147.4,\"height\":209.76}','a8',NULL,NULL,0,28,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(425,58,'ISO A9','{\"metric\":\"pt\",\"width\":104.88,\"height\":147.4}','a9',NULL,NULL,0,29,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(426,58,'ISO A10','{\"metric\":\"pt\",\"width\":73.7,\"height\":104.88}','a10',NULL,NULL,0,30,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(427,58,'ISO B0','{\"metric\":\"pt\",\"width\":2834.65,\"height\":4008.19}','b0',NULL,NULL,0,31,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(428,58,'ISO B1','{\"metric\":\"pt\",\"width\":2004.09,\"height\":2834.65}','b1',NULL,NULL,0,32,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(429,58,'ISO B2','{\"metric\":\"pt\",\"width\":1417.32,\"height\":2004.09}','b2',NULL,NULL,0,33,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(430,58,'ISO B3','{\"metric\":\"pt\",\"width\":1000.63,\"height\":1417.32}','b3',NULL,NULL,0,34,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(431,58,'ISO B4','{\"metric\":\"pt\",\"width\":708.66,\"height\":1000.63}','b4',NULL,NULL,0,35,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(432,58,'ISO B5','{\"metric\":\"pt\",\"width\":498.9,\"height\":708.66}','b5',NULL,NULL,0,36,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(433,58,'ISO B6','{\"metric\":\"pt\",\"width\":354.33,\"height\":498.9}','b6',NULL,NULL,0,37,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(434,58,'ISO B7','{\"metric\":\"pt\",\"width\":249.45,\"height\":354.33}','b7',NULL,NULL,0,38,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(435,58,'ISO B8','{\"metric\":\"pt\",\"width\":175.75,\"height\":249.45}','b8',NULL,NULL,0,39,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(436,58,'ISO B9','{\"metric\":\"pt\",\"width\":124.72,\"height\":175.75}','b9',NULL,NULL,0,40,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(437,58,'ISO B10','{\"metric\":\"pt\",\"width\":87.87,\"height\":124.72}','b10',NULL,NULL,0,41,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(438,58,'ISO C0','{\"metric\":\"pt\",\"width\":2599.37,\"height\":3676.54}','c0',NULL,NULL,0,42,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(439,58,'ISO C1','{\"metric\":\"pt\",\"width\":1836.85,\"height\":2599.37}','c1',NULL,NULL,0,43,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(440,58,'ISO C2','{\"metric\":\"pt\",\"width\":1298.27,\"height\":1836.85}','c2',NULL,NULL,0,44,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(441,58,'ISO C3','{\"metric\":\"pt\",\"width\":918.43,\"height\":1298.27}','c3',NULL,NULL,0,45,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(442,58,'ISO C4','{\"metric\":\"pt\",\"width\":649.13,\"height\":918.43}','c4',NULL,NULL,0,46,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(443,58,'ISO C5','{\"metric\":\"pt\",\"width\":459.21,\"height\":649.13}','c5',NULL,NULL,0,47,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(444,58,'ISO C6','{\"metric\":\"pt\",\"width\":323.15,\"height\":459.21}','c6',NULL,NULL,0,48,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(445,58,'ISO C7','{\"metric\":\"pt\",\"width\":229.61,\"height\":323.15}','c7',NULL,NULL,0,49,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(446,58,'ISO C8','{\"metric\":\"pt\",\"width\":161.57,\"height\":229.61}','c8',NULL,NULL,0,50,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(447,58,'ISO C9','{\"metric\":\"pt\",\"width\":113.39,\"height\":161.57}','c9',NULL,NULL,0,51,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(448,58,'ISO C10','{\"metric\":\"pt\",\"width\":79.37,\"height\":113.39}','c10',NULL,NULL,0,52,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(449,58,'ISO RA0','{\"metric\":\"pt\",\"width\":2437.8,\"height\":3458.27}','ra0',NULL,NULL,0,53,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(450,58,'ISO RA1','{\"metric\":\"pt\",\"width\":1729.13,\"height\":2437.8}','ra1',NULL,NULL,0,54,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(451,58,'ISO RA2','{\"metric\":\"pt\",\"width\":1218.9,\"height\":1729.13}','ra2',NULL,NULL,0,55,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(452,58,'ISO RA3','{\"metric\":\"pt\",\"width\":864.57,\"height\":1218.9}','ra3',NULL,NULL,0,56,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(453,58,'ISO RA4','{\"metric\":\"pt\",\"width\":609.45,\"height\":864.57}','ra4',NULL,NULL,0,57,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(454,58,'ISO SRA0','{\"metric\":\"pt\",\"width\":2551.18,\"height\":3628.35}','sra0',NULL,NULL,0,58,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(455,58,'ISO SRA1','{\"metric\":\"pt\",\"width\":1814.17,\"height\":2551.18}','sra1',NULL,NULL,0,59,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(456,58,'ISO SRA2','{\"metric\":\"pt\",\"width\":1275.59,\"height\":1814.17}','sra2',NULL,NULL,0,60,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(457,58,'ISO SRA3','{\"metric\":\"pt\",\"width\":907.09,\"height\":1275.59}','sra3',NULL,NULL,0,61,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(458,58,'ISO SRA4','{\"metric\":\"pt\",\"width\":637.8,\"height\":907.09}','sra4',NULL,NULL,0,62,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(459,61,'Activity Assignees','1','Activity Assignees',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(460,61,'Activity Source','2','Activity Source',NULL,0,NULL,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(461,61,'Activity Targets','3','Activity Targets',NULL,0,NULL,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(462,71,'Asset','1','Asset',NULL,0,0,1,'Things you own',0,1,1,2,NULL,NULL,NULL,NULL),(463,71,'Liability','2','Liability',NULL,0,0,2,'Things you owe, like a grant still to be disbursed',0,1,1,2,NULL,NULL,NULL,NULL),(464,71,'Revenue','3','Revenue',NULL,0,1,3,'Income from contributions and sales of tickets and memberships',0,1,1,2,NULL,NULL,NULL,NULL),(465,71,'Cost of Sales','4','Cost of Sales',NULL,0,0,4,'Costs incurred to get revenue, e.g. premiums for donations, dinner for a fundraising dinner ticket',0,1,1,2,NULL,NULL,NULL,NULL),(466,71,'Expenses','5','Expenses',NULL,0,0,5,'Things that are paid for that are consumable, e.g. grants disbursed',0,1,1,2,NULL,NULL,NULL,NULL),(467,62,'Income Account is','1','Income Account is',NULL,0,1,1,'Income Account is',0,1,1,2,NULL,NULL,NULL,NULL),(468,62,'Credit/Contra Revenue Account is','2','Credit/Contra Revenue Account is',NULL,0,0,2,'Credit/Contra Revenue Account is',0,1,1,2,NULL,NULL,NULL,NULL),(469,62,'Accounts Receivable Account is','3','Accounts Receivable Account is',NULL,0,0,3,'Accounts Receivable Account is',0,1,1,2,NULL,NULL,NULL,NULL),(470,62,'Credit Liability Account is','4','Credit Liability Account is',NULL,0,0,4,'Credit Liability Account is',0,1,0,2,NULL,NULL,NULL,NULL),(471,62,'Expense Account is','5','Expense Account is',NULL,0,0,5,'Expense Account is',0,1,1,2,NULL,NULL,NULL,NULL),(472,62,'Asset Account is','6','Asset Account is',NULL,0,0,6,'Asset Account is',0,1,1,2,NULL,NULL,NULL,NULL),(473,62,'Cost of Sales Account is','7','Cost of Sales Account is',NULL,0,0,7,'Cost of Sales Account is',0,1,1,2,NULL,NULL,NULL,NULL),(474,62,'Premiums Inventory Account is','8','Premiums Inventory Account is',NULL,0,0,8,'Premiums Inventory Account is',0,1,1,2,NULL,NULL,NULL,NULL),(475,62,'Discounts Account is','9','Discounts Account is',NULL,0,0,9,'Discounts Account is',0,1,1,2,NULL,NULL,NULL,NULL),(476,62,'Sales Tax Account is','10','Sales Tax Account is',NULL,0,0,10,'Sales Tax Account is',0,1,1,2,NULL,NULL,NULL,NULL),(477,62,'Chargeback Account is','11','Chargeback Account is',NULL,0,0,11,'Chargeback Account is',0,1,1,2,NULL,NULL,NULL,NULL),(478,62,'Deferred Revenue Account is','12','Deferred Revenue Account is',NULL,0,0,12,'Deferred Revenue Account is',0,1,1,2,NULL,NULL,NULL,NULL),(479,63,'Participant Role','1','participant_role',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(480,64,'Morning Sessions','1','Morning Sessions',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(481,64,'Evening Sessions','2','Evening Sessions',NULL,0,NULL,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(482,65,'Contribution','1','Contribution',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(483,65,'Membership','2','Membership',NULL,0,NULL,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(484,65,'Pledge Payment','3','Pledge Payment',NULL,0,NULL,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(485,67,'Open','1','Open',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(486,67,'Closed','2','Closed',NULL,0,NULL,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(487,67,'Data Entry','3','Data Entry',NULL,0,NULL,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(488,67,'Reopened','4','Reopened',NULL,0,NULL,4,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(489,67,'Exported','5','Exported',NULL,0,NULL,5,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(490,66,'Manual Batch','1','Manual Batch',NULL,0,0,1,'Manual Batch',0,1,1,2,NULL,NULL,NULL,NULL),(491,66,'Automatic Batch','2','Automatic Batch',NULL,0,0,2,'Automatic Batch',0,1,1,2,NULL,NULL,NULL,NULL),(492,72,'Paid','1','Paid',NULL,0,0,1,'Paid',0,1,1,2,NULL,NULL,NULL,NULL),(493,72,'Partially paid','2','Partially paid',NULL,0,0,2,'Partially paid',0,1,1,2,NULL,NULL,NULL,NULL),(494,72,'Unpaid','3','Unpaid',NULL,0,0,1,'Unpaid',0,1,1,2,NULL,NULL,NULL,NULL),(495,68,'http','1','http',NULL,NULL,0,1,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(496,68,'xml','2','xml',NULL,NULL,0,2,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(497,68,'smtp','3','smtp',NULL,NULL,0,3,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(498,70,'Renewal Reminder (non-auto-renew memberships only)','1','Renewal Reminder (non-auto-renew memberships only)',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(499,70,'Auto-renew Memberships Only','2','Auto-renew Memberships Only',NULL,0,NULL,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(500,70,'Reminder for Both','3','Reminder for Both',NULL,0,NULL,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(501,73,'Event Badge','1','Event Badge',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(502,74,'Avery 5395','{\"name\":\"Avery 5395\",\"paper-size\":\"a4\",\"metric\":\"mm\",\"lMargin\":15,\"tMargin\":26,\"NX\":2,\"NY\":4,\"SpaceX\":10,\"SpaceY\":5,\"width\":83,\"height\":57,\"font-size\":12,\"orientation\":\"portrait\",\"font-name\":\"helvetica\",\"font-style\":\"\",\"lPadding\":3,\"tPadding\":3}','Avery 5395',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(503,74,'A6 Badge Portrait 150x106','{\"paper-size\":\"a4\",\"orientation\":\"landscape\",\"font-name\":\"times\",\"font-size\":6,\"font-style\":\"\",\"NX\":2,\"NY\":1,\"metric\":\"mm\",\"lMargin\":25,\"tMargin\":27,\"SpaceX\":0,\"SpaceY\":35,\"width\":106,\"height\":150,\"lPadding\":5,\"tPadding\":5}','A6 Badge Portrait 150x106',NULL,0,NULL,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(504,74,'Fattorini Name Badge 100x65','{\"paper-size\":\"a4\",\"orientation\":\"portrait\",\"font-name\":\"times\",\"font-size\":6,\"font-style\":\"\",\"NX\":2,\"NY\":4,\"metric\":\"mm\",\"lMargin\":6,\"tMargin\":19,\"SpaceX\":0,\"SpaceY\":0,\"width\":100,\"height\":65,\"lPadding\":0,\"tPadding\":0}','Fattorini Name Badge 100x65',NULL,0,NULL,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(505,74,'Hanging Badge 3-3/4\" x 4-3\"/4','{\"paper-size\":\"a4\",\"orientation\":\"portrait\",\"font-name\":\"times\",\"font-size\":6,\"font-style\":\"\",\"NX\":2,\"NY\":2,\"metric\":\"mm\",\"lMargin\":10,\"tMargin\":28,\"SpaceX\":0,\"SpaceY\":0,\"width\":96,\"height\":121,\"lPadding\":5,\"tPadding\":5}','Hanging Badge 3-3/4\" x 4-3\"/4',NULL,0,NULL,4,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(506,60,'Avery 3475','{\"paper-size\":\"a4\",\"orientation\":\"portrait\",\"font-name\":\"helvetica\",\"font-size\":10,\"font-style\":\"\",\"metric\":\"mm\",\"lMargin\":0,\"tMargin\":5,\"NX\":3,\"NY\":8,\"SpaceX\":0,\"SpaceY\":0,\"width\":70,\"height\":36,\"lPadding\":5.08,\"tPadding\":5.08}','3475','Avery',NULL,0,1,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(507,60,'Avery 5160','{\"paper-size\":\"letter\",\"orientation\":\"portrait\",\"font-name\":\"helvetica\",\"font-size\":8,\"font-style\":\"\",\"metric\":\"in\",\"lMargin\":0.21975,\"tMargin\":0.5,\"NX\":3,\"NY\":10,\"SpaceX\":0.14,\"SpaceY\":0,\"width\":2.5935,\"height\":1,\"lPadding\":0.20,\"tPadding\":0.20}','5160','Avery',NULL,0,2,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(508,60,'Avery 5161','{\"paper-size\":\"letter\",\"orientation\":\"portrait\",\"font-name\":\"helvetica\",\"font-size\":8,\"font-style\":\"\",\"metric\":\"in\",\"lMargin\":0.175,\"tMargin\":0.5,\"NX\":2,\"NY\":10,\"SpaceX\":0.15625,\"SpaceY\":0,\"width\":4,\"height\":1,\"lPadding\":0.20,\"tPadding\":0.20}','5161','Avery',NULL,0,3,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(509,60,'Avery 5162','{\"paper-size\":\"letter\",\"orientation\":\"portrait\",\"font-name\":\"helvetica\",\"font-size\":8,\"font-style\":\"\",\"metric\":\"in\",\"lMargin\":0.1525,\"tMargin\":0.88,\"NX\":2,\"NY\":7,\"SpaceX\":0.195,\"SpaceY\":0,\"width\":4,\"height\":1.33,\"lPadding\":0.20,\"tPadding\":0.20}','5162','Avery',NULL,0,4,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(510,60,'Avery 5163','{\"paper-size\":\"letter\",\"orientation\":\"portrait\",\"font-name\":\"helvetica\",\"font-size\":8,\"font-style\":\"\",\"metric\":\"in\",\"lMargin\":0.18,\"tMargin\":0.5,\"NX\":2,\"NY\":5,\"SpaceX\":0.14,\"SpaceY\":0,\"width\":4,\"height\":2,\"lPadding\":0.20,\"tPadding\":0.20}','5163','Avery',NULL,0,5,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(511,60,'Avery 5164','{\"paper-size\":\"letter\",\"orientation\":\"portrait\",\"font-name\":\"helvetica\",\"font-size\":12,\"font-style\":\"\",\"metric\":\"in\",\"lMargin\":0.156,\"tMargin\":0.5,\"NX\":2,\"NY\":3,\"SpaceX\":0.1875,\"SpaceY\":0,\"width\":4,\"height\":3.33,\"lPadding\":0.20,\"tPadding\":0.20}','5164','Avery',NULL,0,6,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(512,60,'Avery 8600','{\"paper-size\":\"letter\",\"orientation\":\"portrait\",\"font-name\":\"helvetica\",\"font-size\":8,\"font-style\":\"\",\"metric\":\"mm\",\"lMargin\":7.1,\"tMargin\":19,\"NX\":3,\"NY\":10,\"SpaceX\":9.5,\"SpaceY\":3.1,\"width\":66.6,\"height\":25.4,\"lPadding\":5.08,\"tPadding\":5.08}','8600','Avery',NULL,0,7,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(513,60,'Avery L7160','{\"paper-size\":\"a4\",\"orientation\":\"portrait\",\"font-name\":\"helvetica\",\"font-size\":9,\"font-style\":\"\",\"metric\":\"in\",\"lMargin\":0.28,\"tMargin\":0.6,\"NX\":3,\"NY\":7,\"SpaceX\":0.1,\"SpaceY\":0,\"width\":2.5,\"height\":1.5,\"lPadding\":0.20,\"tPadding\":0.20}','L7160','Avery',NULL,0,8,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(514,60,'Avery L7161','{\"paper-size\":\"a4\",\"orientation\":\"portrait\",\"font-name\":\"helvetica\",\"font-size\":9,\"font-style\":\"\",\"metric\":\"in\",\"lMargin\":0.28,\"tMargin\":0.35,\"NX\":3,\"NY\":6,\"SpaceX\":0.1,\"SpaceY\":0,\"width\":2.5,\"height\":1.83,\"lPadding\":0.20,\"tPadding\":0.20}','L7161','Avery',NULL,0,9,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(515,60,'Avery L7162','{\"paper-size\":\"a4\",\"orientation\":\"portrait\",\"font-name\":\"helvetica\",\"font-size\":9,\"font-style\":\"\",\"metric\":\"in\",\"lMargin\":0.18,\"tMargin\":0.51,\"NX\":2,\"NY\":8,\"SpaceX\":0.1,\"SpaceY\":0,\"width\":3.9,\"height\":1.33,\"lPadding\":0.20,\"tPadding\":0.20}','L7162','Avery',NULL,0,10,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(516,60,'Avery L7163','{\"paper-size\":\"a4\",\"orientation\":\"portrait\",\"font-name\":\"helvetica\",\"font-size\":9,\"font-style\":\"\",\"metric\":\"in\",\"lMargin\":0.18,\"tMargin\":0.6,\"NX\":2,\"NY\":7,\"SpaceX\":0.1,\"SpaceY\":0,\"width\":3.9,\"height\":1.5,\"lPadding\":0.20,\"tPadding\":0.20}','L7163','Avery',NULL,0,11,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(517,75,'Formal','1','formal',NULL,0,1,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(518,75,'Familiar','2','familiar',NULL,0,0,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(519,76,'Email','Email','Email',NULL,0,1,1,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(520,76,'SMS','SMS','SMS',NULL,0,0,2,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(521,76,'User Preference','User_Preference','User Preference',NULL,0,0,3,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(522,77,'Actual date only','1','Actual date only',NULL,NULL,0,1,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(523,77,'Each anniversary','2','Each anniversary',NULL,NULL,0,2,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(524,78,'Default','1','default',NULL,NULL,1,1,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(525,78,'CiviMail','2','civimail',NULL,NULL,0,2,NULL,0,1,1,4,NULL,NULL,NULL,NULL),(526,78,'CiviEvent','3','civievent',NULL,NULL,0,3,NULL,0,1,1,1,NULL,NULL,NULL,NULL),(527,81,'Production','Production','Production',NULL,NULL,1,1,'Production Environment',0,1,1,NULL,NULL,NULL,NULL,NULL),(528,81,'Staging','Staging','Staging',NULL,NULL,0,2,'Staging Environment',0,1,1,NULL,NULL,NULL,NULL,NULL),(529,81,'Development','Development','Development',NULL,NULL,0,3,'Development Environment',0,1,1,NULL,NULL,NULL,NULL,NULL),(530,79,'Today','this.day','this.day',NULL,NULL,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(531,79,'This week','this.week','this.week',NULL,NULL,NULL,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(532,79,'This calendar month','this.month','this.month',NULL,NULL,NULL,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(533,79,'This quarter','this.quarter','this.quarter',NULL,NULL,NULL,4,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(534,79,'This fiscal year','this.fiscal_year','this.fiscal_year',NULL,NULL,NULL,5,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(535,79,'This calendar year','this.year','this.year',NULL,NULL,NULL,6,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(536,79,'Yesterday','previous.day','previous.day',NULL,NULL,NULL,7,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(537,79,'Previous week','previous.week','previous.week',NULL,NULL,NULL,8,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(538,79,'Previous calendar month','previous.month','previous.month',NULL,NULL,NULL,9,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(539,79,'Previous quarter','previous.quarter','previous.quarter',NULL,NULL,NULL,10,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(540,79,'Previous fiscal year','previous.fiscal_year','previous.fiscal_year',NULL,NULL,NULL,11,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(541,79,'Previous calendar year','previous.year','previous.year',NULL,NULL,NULL,12,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(542,79,'Last 7 days including today','ending.week','ending.week',NULL,NULL,NULL,13,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(543,79,'Last 30 days including today','ending_30.day','ending.month',NULL,NULL,NULL,14,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(544,79,'Last 60 days including today','ending_60.day','ending_2.month',NULL,NULL,NULL,15,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(545,79,'Last 90 days including today','ending_90.day','ending.quarter',NULL,NULL,NULL,16,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(546,79,'Last 12 months including today','ending.year','ending.year',NULL,NULL,NULL,17,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(547,79,'Last 2 years including today','ending_2.year','ending_2.year',NULL,NULL,NULL,18,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(548,79,'Last 3 years including today','ending_3.year','ending_3.year',NULL,NULL,NULL,19,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(549,79,'Tomorrow','starting.day','starting.day',NULL,NULL,NULL,20,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(550,79,'Next week','next.week','next.week',NULL,NULL,NULL,21,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(551,79,'Next calendar month','next.month','next.month',NULL,NULL,NULL,22,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(552,79,'Next quarter','next.quarter','next.quarter',NULL,NULL,NULL,23,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(553,79,'Next fiscal year','next.fiscal_year','next.fiscal_year',NULL,NULL,NULL,24,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(554,79,'Next calendar year','next.year','next.year',NULL,NULL,NULL,25,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(555,79,'Next 7 days including today','starting.week','starting.week',NULL,NULL,NULL,26,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(556,79,'Next 30 days including today','starting.month','starting.month',NULL,NULL,NULL,27,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(557,79,'Next 60 days including today','starting_2.month','starting_2.month',NULL,NULL,NULL,28,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(558,79,'Next 90 days including today','starting.quarter','starting.quarter',NULL,NULL,NULL,29,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(559,79,'Next 12 months including today','starting.year','starting.year',NULL,NULL,NULL,30,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(560,79,'Current week to-date','current.week','current.week',NULL,NULL,NULL,31,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(561,79,'Current calendar month to-date','current.month','current.month',NULL,NULL,NULL,32,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(562,79,'Current quarter to-date','current.quarter','current.quarter',NULL,NULL,NULL,33,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(563,79,'Current calendar year to-date','current.year','current.year',NULL,NULL,NULL,34,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(564,79,'To end of yesterday','earlier.day','earlier.day',NULL,NULL,NULL,35,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(565,79,'To end of previous week','earlier.week','earlier.week',NULL,NULL,NULL,36,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(566,79,'To end of previous calendar month','earlier.month','earlier.month',NULL,NULL,NULL,37,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(567,79,'To end of previous quarter','earlier.quarter','earlier.quarter',NULL,NULL,NULL,38,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(568,79,'To end of previous calendar year','earlier.year','earlier.year',NULL,NULL,NULL,39,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(569,79,'From start of current day','greater.day','greater.day',NULL,NULL,NULL,40,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(570,79,'From start of current week','greater.week','greater.week',NULL,NULL,NULL,41,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(571,79,'From start of current calendar month','greater.month','greater.month',NULL,NULL,NULL,42,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(572,79,'From start of current quarter','greater.quarter','greater.quarter',NULL,NULL,NULL,43,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(573,79,'From start of current calendar year','greater.year','greater.year',NULL,NULL,NULL,44,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(574,79,'To end of current week','less.week','less.week',NULL,NULL,NULL,45,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(575,79,'To end of current calendar month','less.month','less.month',NULL,NULL,NULL,46,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(576,79,'To end of current quarter','less.quarter','less.quarter',NULL,NULL,NULL,47,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(577,79,'To end of current calendar year','less.year','less.year',NULL,NULL,NULL,48,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(578,79,'Previous 2 days','previous_2.day','previous_2.day',NULL,NULL,NULL,49,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(579,79,'Previous 2 weeks','previous_2.week','previous_2.week',NULL,NULL,NULL,50,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(580,79,'Previous 2 calendar months','previous_2.month','previous_2.month',NULL,NULL,NULL,51,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(581,79,'Previous 2 quarters','previous_2.quarter','previous_2.quarter',NULL,NULL,NULL,52,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(582,79,'Previous 2 calendar years','previous_2.year','previous_2.year',NULL,NULL,NULL,53,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(583,79,'Day prior to yesterday','previous_before.day','previous_before.day',NULL,NULL,NULL,54,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(584,79,'Week prior to previous week','previous_before.week','previous_before.week',NULL,NULL,NULL,55,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(585,79,'Month prior to previous calendar month','previous_before.month','previous_before.month',NULL,NULL,NULL,56,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(586,79,'Quarter prior to previous quarter','previous_before.quarter','previous_before.quarter',NULL,NULL,NULL,57,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(587,79,'Year prior to previous calendar year','previous_before.year','previous_before.year',NULL,NULL,NULL,58,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(588,79,'From end of previous week','greater_previous.week','greater_previous.week',NULL,NULL,NULL,59,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(589,79,'From end of previous calendar month','greater_previous.month','greater_previous.month',NULL,NULL,NULL,60,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(590,79,'From end of previous quarter','greater_previous.quarter','greater_previous.quarter',NULL,NULL,NULL,61,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(591,79,'From end of previous calendar year','greater_previous.year','greater_previous.year',NULL,NULL,NULL,62,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(592,80,'Completed','1','Completed',NULL,0,NULL,1,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(593,80,'Pending','2','Pending',NULL,0,NULL,2,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(594,80,'Cancelled','3','Cancelled',NULL,0,NULL,3,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(595,80,'In Progress','5','In Progress',NULL,0,NULL,4,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(596,80,'Overdue','6','Overdue',NULL,0,NULL,5,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(597,82,'None','1','NONE',NULL,0,1,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(598,82,'By relationship to case client','2','BY_RELATIONSHIP',NULL,0,0,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(599,82,'Specific contact','3','SPECIFIC_CONTACT',NULL,0,0,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(600,82,'User creating the case','4','USER_CREATING_THE_CASE',NULL,0,0,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(601,31,'\"FIXME\" <info@EXAMPLE.ORG>','1','\"FIXME\" <info@EXAMPLE.ORG>',NULL,0,1,1,'Default domain email address and from name.',0,0,1,NULL,1,NULL,NULL,NULL),(602,24,'Emergency','1','Emergency',NULL,0,1,1,NULL,0,0,1,NULL,1,NULL,NULL,NULL),(603,24,'Family Support','2','Family Support',NULL,0,NULL,2,NULL,0,0,1,NULL,1,NULL,NULL,NULL),(604,24,'General Protection','3','General Protection',NULL,0,NULL,3,NULL,0,0,1,NULL,1,NULL,NULL,NULL),(605,24,'Impunity','4','Impunity',NULL,0,NULL,4,NULL,0,0,1,NULL,1,NULL,NULL,NULL),(606,55,'Approved','1','Approved',NULL,0,1,1,NULL,0,1,1,4,1,NULL,NULL,NULL),(607,55,'Rejected','2','Rejected',NULL,0,0,2,NULL,0,1,1,4,1,NULL,NULL,NULL),(608,55,'None','3','None',NULL,0,0,3,NULL,0,1,1,4,1,NULL,NULL,NULL),(609,57,'Survey','Survey','civicrm_survey',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(610,57,'Cases','Case','civicrm_case',NULL,0,NULL,2,'CRM_Case_PseudoConstant::caseType;',0,0,1,NULL,NULL,NULL,NULL,NULL),(611,83,'Abkhaz','ab','ab_GE',NULL,NULL,0,1,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(612,83,'Afar','aa','aa_ET',NULL,NULL,0,2,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(613,83,'Afrikaans','af','af_ZA',NULL,NULL,0,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(614,83,'Akan','ak','ak_GH',NULL,NULL,0,4,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(615,83,'Albanian','sq','sq_AL',NULL,NULL,0,5,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(616,83,'Amharic','am','am_ET',NULL,NULL,0,6,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(617,83,'Arabic','ar','ar_EG',NULL,NULL,0,7,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(618,83,'Aragonese','an','an_ES',NULL,NULL,0,8,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(619,83,'Armenian','hy','hy_AM',NULL,NULL,0,9,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(620,83,'Assamese','as','as_IN',NULL,NULL,0,10,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(621,83,'Avaric','av','av_RU',NULL,NULL,0,11,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(622,83,'Avestan','ae','ae_XX',NULL,NULL,0,12,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(623,83,'Aymara','ay','ay_BO',NULL,NULL,0,13,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(624,83,'Azerbaijani','az','az_AZ',NULL,NULL,0,14,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(625,83,'Bambara','bm','bm_ML',NULL,NULL,0,15,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(626,83,'Bashkir','ba','ba_RU',NULL,NULL,0,16,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(627,83,'Basque','eu','eu_ES',NULL,NULL,0,17,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(628,83,'Belarusian','be','be_BY',NULL,NULL,0,18,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(629,83,'Bengali','bn','bn_BD',NULL,NULL,0,19,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(630,83,'Bihari','bh','bh_IN',NULL,NULL,0,20,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(631,83,'Bislama','bi','bi_VU',NULL,NULL,0,21,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(632,83,'Bosnian','bs','bs_BA',NULL,NULL,0,22,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(633,83,'Breton','br','br_FR',NULL,NULL,0,23,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(634,83,'Bulgarian','bg','bg_BG',NULL,NULL,0,24,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(635,83,'Burmese','my','my_MM',NULL,NULL,0,25,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(636,83,'Catalan; Valencian','ca','ca_ES',NULL,NULL,0,26,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(637,83,'Chamorro','ch','ch_GU',NULL,NULL,0,27,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(638,83,'Chechen','ce','ce_RU',NULL,NULL,0,28,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(639,83,'Chichewa; Chewa; Nyanja','ny','ny_MW',NULL,NULL,0,29,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(640,83,'Chinese (China)','zh','zh_CN',NULL,NULL,0,30,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(641,83,'Chinese (Taiwan)','zh','zh_TW',NULL,NULL,0,31,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(642,83,'Chuvash','cv','cv_RU',NULL,NULL,0,32,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(643,83,'Cornish','kw','kw_GB',NULL,NULL,0,33,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(644,83,'Corsican','co','co_FR',NULL,NULL,0,34,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(645,83,'Cree','cr','cr_CA',NULL,NULL,0,35,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(646,83,'Croatian','hr','hr_HR',NULL,NULL,0,36,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(647,83,'Czech','cs','cs_CZ',NULL,NULL,0,37,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(648,83,'Danish','da','da_DK',NULL,NULL,0,38,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(649,83,'Divehi; Dhivehi; Maldivian;','dv','dv_MV',NULL,NULL,0,39,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(650,83,'Dutch','nl','nl_NL',NULL,NULL,0,40,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(651,83,'Dzongkha','dz','dz_BT',NULL,NULL,0,41,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(652,83,'English (Australia)','en','en_AU',NULL,NULL,0,42,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(653,83,'English (Canada)','en','en_CA',NULL,NULL,0,43,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(654,83,'English (United Kingdom)','en','en_GB',NULL,NULL,0,44,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(655,83,'English (United States)','en','en_US',NULL,NULL,1,45,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(656,83,'Esperanto','eo','eo_XX',NULL,NULL,0,46,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(657,83,'Estonian','et','et_EE',NULL,NULL,0,47,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(658,83,'Ewe','ee','ee_GH',NULL,NULL,0,48,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(659,83,'Faroese','fo','fo_FO',NULL,NULL,0,49,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(660,83,'Fijian','fj','fj_FJ',NULL,NULL,0,50,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(661,83,'Finnish','fi','fi_FI',NULL,NULL,0,51,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(662,83,'French (Canada)','fr','fr_CA',NULL,NULL,0,52,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(663,83,'French (France)','fr','fr_FR',NULL,NULL,0,53,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(664,83,'Fula; Fulah; Pulaar; Pular','ff','ff_SN',NULL,NULL,0,54,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(665,83,'Galician','gl','gl_ES',NULL,NULL,0,55,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(666,83,'Georgian','ka','ka_GE',NULL,NULL,0,56,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(667,83,'German','de','de_DE',NULL,NULL,0,57,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(668,83,'German (Swiss)','de','de_CH',NULL,NULL,0,58,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(669,83,'Greek, Modern','el','el_GR',NULL,NULL,0,59,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(670,83,'Guarani­','gn','gn_PY',NULL,NULL,0,60,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(671,83,'Gujarati','gu','gu_IN',NULL,NULL,0,61,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(672,83,'Haitian; Haitian Creole','ht','ht_HT',NULL,NULL,0,62,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(673,83,'Hausa','ha','ha_NG',NULL,NULL,0,63,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(674,83,'Hebrew (modern)','he','he_IL',NULL,NULL,0,64,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(675,83,'Herero','hz','hz_NA',NULL,NULL,0,65,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(676,83,'Hindi','hi','hi_IN',NULL,NULL,0,66,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(677,83,'Hiri Motu','ho','ho_PG',NULL,NULL,0,67,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(678,83,'Hungarian','hu','hu_HU',NULL,NULL,0,68,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(679,83,'Interlingua','ia','ia_XX',NULL,NULL,0,69,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(680,83,'Indonesian','id','id_ID',NULL,NULL,0,70,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(681,83,'Interlingue','ie','ie_XX',NULL,NULL,0,71,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(682,83,'Irish','ga','ga_IE',NULL,NULL,0,72,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(683,83,'Igbo','ig','ig_NG',NULL,NULL,0,73,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(684,83,'Inupiaq','ik','ik_US',NULL,NULL,0,74,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(685,83,'Ido','io','io_XX',NULL,NULL,0,75,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(686,83,'Icelandic','is','is_IS',NULL,NULL,0,76,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(687,83,'Italian','it','it_IT',NULL,NULL,0,77,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(688,83,'Inuktitut','iu','iu_CA',NULL,NULL,0,78,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(689,83,'Japanese','ja','ja_JP',NULL,NULL,0,79,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(690,83,'Javanese','jv','jv_ID',NULL,NULL,0,80,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(691,83,'Kalaallisut, Greenlandic','kl','kl_GL',NULL,NULL,0,81,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(692,83,'Kannada','kn','kn_IN',NULL,NULL,0,82,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(693,83,'Kanuri','kr','kr_NE',NULL,NULL,0,83,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(694,83,'Kashmiri','ks','ks_IN',NULL,NULL,0,84,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(695,83,'Kazakh','kk','kk_KZ',NULL,NULL,0,85,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(696,83,'Khmer','km','km_KH',NULL,NULL,0,86,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(697,83,'Kikuyu, Gikuyu','ki','ki_KE',NULL,NULL,0,87,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(698,83,'Kinyarwanda','rw','rw_RW',NULL,NULL,0,88,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(699,83,'Kirghiz, Kyrgyz','ky','ky_KG',NULL,NULL,0,89,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(700,83,'Komi','kv','kv_RU',NULL,NULL,0,90,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(701,83,'Kongo','kg','kg_CD',NULL,NULL,0,91,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(702,83,'Korean','ko','ko_KR',NULL,NULL,0,92,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(703,83,'Kurdish','ku','ku_IQ',NULL,NULL,0,93,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(704,83,'Kwanyama, Kuanyama','kj','kj_NA',NULL,NULL,0,94,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(705,83,'Latin','la','la_VA',NULL,NULL,0,95,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(706,83,'Luxembourgish, Letzeburgesch','lb','lb_LU',NULL,NULL,0,96,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(707,83,'Luganda','lg','lg_UG',NULL,NULL,0,97,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(708,83,'Limburgish, Limburgan, Limburger','li','li_NL',NULL,NULL,0,98,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(709,83,'Lingala','ln','ln_CD',NULL,NULL,0,99,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(710,83,'Lao','lo','lo_LA',NULL,NULL,0,100,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(711,83,'Lithuanian','lt','lt_LT',NULL,NULL,0,101,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(712,83,'Luba-Katanga','lu','lu_CD',NULL,NULL,0,102,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(713,83,'Latvian','lv','lv_LV',NULL,NULL,0,103,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(714,83,'Manx','gv','gv_IM',NULL,NULL,0,104,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(715,83,'Macedonian','mk','mk_MK',NULL,NULL,0,105,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(716,83,'Malagasy','mg','mg_MG',NULL,NULL,0,106,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(717,83,'Malay','ms','ms_MY',NULL,NULL,0,107,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(718,83,'Malayalam','ml','ml_IN',NULL,NULL,0,108,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(719,83,'Maltese','mt','mt_MT',NULL,NULL,0,109,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(720,83,'Māori','mi','mi_NZ',NULL,NULL,0,110,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(721,83,'Marathi','mr','mr_IN',NULL,NULL,0,111,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(722,83,'Marshallese','mh','mh_MH',NULL,NULL,0,112,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(723,83,'Mongolian','mn','mn_MN',NULL,NULL,0,113,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(724,83,'Nauru','na','na_NR',NULL,NULL,0,114,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(725,83,'Navajo, Navaho','nv','nv_US',NULL,NULL,0,115,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(726,83,'Norwegian BokmÃ¥l','nb','nb_NO',NULL,NULL,0,116,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(727,83,'North Ndebele','nd','nd_ZW',NULL,NULL,0,117,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(728,83,'Nepali','ne','ne_NP',NULL,NULL,0,118,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(729,83,'Ndonga','ng','ng_NA',NULL,NULL,0,119,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(730,83,'Norwegian Nynorsk','nn','nn_NO',NULL,NULL,0,120,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(731,83,'Norwegian','no','no_NO',NULL,NULL,0,121,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(732,83,'Nuosu','ii','ii_CN',NULL,NULL,0,122,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(733,83,'South Ndebele','nr','nr_ZA',NULL,NULL,0,123,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(734,83,'Occitan (after 1500)','oc','oc_FR',NULL,NULL,0,124,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(735,83,'Ojibwa','oj','oj_CA',NULL,NULL,0,125,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(736,83,'Old Church Slavonic, Church Slavic, Church Slavonic, Old Bulgarian, Old Slavonic','cu','cu_BG',NULL,NULL,0,126,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(737,83,'Oromo','om','om_ET',NULL,NULL,0,127,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(738,83,'Oriya','or','or_IN',NULL,NULL,0,128,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(739,83,'Ossetian, Ossetic','os','os_GE',NULL,NULL,0,129,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(740,83,'Panjabi, Punjabi','pa','pa_IN',NULL,NULL,0,130,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(741,83,'Pali','pi','pi_KH',NULL,NULL,0,131,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(742,83,'Persian (Iran)','fa','fa_IR',NULL,NULL,0,132,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(743,83,'Polish','pl','pl_PL',NULL,NULL,0,133,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(744,83,'Pashto, Pushto','ps','ps_AF',NULL,NULL,0,134,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(745,83,'Portuguese (Brazil)','pt','pt_BR',NULL,NULL,0,135,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(746,83,'Portuguese (Portugal)','pt','pt_PT',NULL,NULL,0,136,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(747,83,'Quechua','qu','qu_PE',NULL,NULL,0,137,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(748,83,'Romansh','rm','rm_CH',NULL,NULL,0,138,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(749,83,'Kirundi','rn','rn_BI',NULL,NULL,0,139,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(750,83,'Romanian, Moldavian, Moldovan','ro','ro_RO',NULL,NULL,0,140,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(751,83,'Russian','ru','ru_RU',NULL,NULL,0,141,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(752,83,'Sanskrit','sa','sa_IN',NULL,NULL,0,142,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(753,83,'Sardinian','sc','sc_IT',NULL,NULL,0,143,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(754,83,'Sindhi','sd','sd_IN',NULL,NULL,0,144,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(755,83,'Northern Sami','se','se_NO',NULL,NULL,0,145,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(756,83,'Samoan','sm','sm_WS',NULL,NULL,0,146,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(757,83,'Sango','sg','sg_CF',NULL,NULL,0,147,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(758,83,'Serbian','sr','sr_RS',NULL,NULL,0,148,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(759,83,'Scottish Gaelic; Gaelic','gd','gd_GB',NULL,NULL,0,149,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(760,83,'Shona','sn','sn_ZW',NULL,NULL,0,150,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(761,83,'Sinhala, Sinhalese','si','si_LK',NULL,NULL,0,151,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(762,83,'Slovak','sk','sk_SK',NULL,NULL,0,152,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(763,83,'Slovene','sl','sl_SI',NULL,NULL,0,153,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(764,83,'Somali','so','so_SO',NULL,NULL,0,154,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(765,83,'Southern Sotho','st','st_ZA',NULL,NULL,0,155,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(766,83,'Spanish; Castilian (Spain)','es','es_ES',NULL,NULL,0,156,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(767,83,'Spanish; Castilian (Mexico)','es','es_MX',NULL,NULL,0,157,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(768,83,'Spanish; Castilian (Puerto Rico)','es','es_PR',NULL,NULL,0,158,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(769,83,'Sundanese','su','su_ID',NULL,NULL,0,159,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(770,83,'Swahili','sw','sw_TZ',NULL,NULL,0,160,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(771,83,'Swati','ss','ss_ZA',NULL,NULL,0,161,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(772,83,'Swedish','sv','sv_SE',NULL,NULL,0,162,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(773,83,'Tamil','ta','ta_IN',NULL,NULL,0,163,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(774,83,'Telugu','te','te_IN',NULL,NULL,0,164,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(775,83,'Tajik','tg','tg_TJ',NULL,NULL,0,165,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(776,83,'Thai','th','th_TH',NULL,NULL,0,166,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(777,83,'Tigrinya','ti','ti_ET',NULL,NULL,0,167,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(778,83,'Tibetan Standard, Tibetan, Central','bo','bo_CN',NULL,NULL,0,168,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(779,83,'Turkmen','tk','tk_TM',NULL,NULL,0,169,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(780,83,'Tagalog','tl','tl_PH',NULL,NULL,0,170,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(781,83,'Tswana','tn','tn_ZA',NULL,NULL,0,171,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(782,83,'Tonga (Tonga Islands)','to','to_TO',NULL,NULL,0,172,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(783,83,'Turkish','tr','tr_TR',NULL,NULL,0,173,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(784,83,'Tsonga','ts','ts_ZA',NULL,NULL,0,174,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(785,83,'Tatar','tt','tt_RU',NULL,NULL,0,175,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(786,83,'Twi','tw','tw_GH',NULL,NULL,0,176,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(787,83,'Tahitian','ty','ty_PF',NULL,NULL,0,177,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(788,83,'Uighur, Uyghur','ug','ug_CN',NULL,NULL,0,178,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(789,83,'Ukrainian','uk','uk_UA',NULL,NULL,0,179,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(790,83,'Urdu','ur','ur_PK',NULL,NULL,0,180,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(791,83,'Uzbek','uz','uz_UZ',NULL,NULL,0,181,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(792,83,'Venda','ve','ve_ZA',NULL,NULL,0,182,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(793,83,'Vietnamese','vi','vi_VN',NULL,NULL,0,183,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(794,83,'Volapük','vo','vo_XX',NULL,NULL,0,184,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(795,83,'Walloon','wa','wa_BE',NULL,NULL,0,185,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(796,83,'Welsh','cy','cy_GB',NULL,NULL,0,186,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(797,83,'Wolof','wo','wo_SN',NULL,NULL,0,187,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(798,83,'Western Frisian','fy','fy_NL',NULL,NULL,0,188,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(799,83,'Xhosa','xh','xh_ZA',NULL,NULL,0,189,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(800,83,'Yiddish','yi','yi_US',NULL,NULL,0,190,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(801,83,'Yoruba','yo','yo_NG',NULL,NULL,0,191,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(802,83,'Zhuang, Chuang','za','za_CN',NULL,NULL,0,192,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(803,83,'Zulu','zu','zu_ZA',NULL,NULL,0,193,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(804,84,'In Person','1','in_person',NULL,0,0,1,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(805,84,'Phone','2','phone',NULL,0,1,2,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(806,84,'Email','3','email',NULL,0,0,3,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(807,84,'Fax','4','fax',NULL,0,0,4,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(808,84,'Letter Mail','5','letter_mail',NULL,0,0,5,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(809,85,'Cases - Send Copy of an Activity','1','case_activity',NULL,NULL,0,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(810,86,'Contributions - Duplicate Organization Alert','1','contribution_dupalert',NULL,NULL,0,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(811,86,'Contributions - Receipt (off-line)','2','contribution_offline_receipt',NULL,NULL,0,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(812,86,'Contributions - Receipt (on-line)','3','contribution_online_receipt',NULL,NULL,0,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(813,86,'Contributions - Invoice','4','contribution_invoice_receipt',NULL,NULL,0,4,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(814,86,'Contributions - Recurring Start and End Notification','5','contribution_recurring_notify',NULL,NULL,0,5,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(815,86,'Contributions - Recurring Cancellation Notification','6','contribution_recurring_cancelled',NULL,NULL,0,6,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(816,86,'Contributions - Recurring Billing Updates','7','contribution_recurring_billing',NULL,NULL,0,7,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(817,86,'Contributions - Recurring Updates','8','contribution_recurring_edit',NULL,NULL,0,8,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(818,86,'Personal Campaign Pages - Admin Notification','9','pcp_notify',NULL,NULL,0,9,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(819,86,'Personal Campaign Pages - Supporter Status Change Notification','10','pcp_status_change',NULL,NULL,0,10,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(820,86,'Personal Campaign Pages - Supporter Welcome','11','pcp_supporter_notify',NULL,NULL,0,11,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(821,86,'Personal Campaign Pages - Owner Notification','12','pcp_owner_notify',NULL,NULL,0,12,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(822,86,'Additional Payment Receipt or Refund Notification','13','payment_or_refund_notification',NULL,NULL,0,13,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(823,87,'Events - Registration Confirmation and Receipt (off-line)','1','event_offline_receipt',NULL,NULL,0,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(824,87,'Events - Registration Confirmation and Receipt (on-line)','2','event_online_receipt',NULL,NULL,0,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(825,87,'Events - Receipt only','3','event_registration_receipt',NULL,NULL,0,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(826,87,'Events - Registration Cancellation Notice','4','participant_cancelled',NULL,NULL,0,4,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(827,87,'Events - Registration Confirmation Invite','5','participant_confirm',NULL,NULL,0,5,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(828,87,'Events - Pending Registration Expiration Notice','6','participant_expired',NULL,NULL,0,6,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(829,87,'Events - Registration Transferred Notice','7','participant_transferred',NULL,NULL,0,7,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(830,88,'Tell-a-Friend Email','1','friend',NULL,NULL,0,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(831,89,'Memberships - Signup and Renewal Receipts (off-line)','1','membership_offline_receipt',NULL,NULL,0,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(832,89,'Memberships - Receipt (on-line)','2','membership_online_receipt',NULL,NULL,0,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(833,89,'Memberships - Auto-renew Cancellation Notification','3','membership_autorenew_cancelled',NULL,NULL,0,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(834,89,'Memberships - Auto-renew Billing Updates','4','membership_autorenew_billing',NULL,NULL,0,4,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(835,90,'Test-drive - Receipt Header','1','test_preview',NULL,NULL,0,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(836,91,'Pledges - Acknowledgement','1','pledge_acknowledge',NULL,NULL,0,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(837,91,'Pledges - Payment Reminder','2','pledge_reminder',NULL,NULL,0,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(838,92,'Profiles - Admin Notification','1','uf_notify',NULL,NULL,0,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(839,93,'Petition - signature added','1','petition_sign',NULL,NULL,0,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(840,93,'Petition - need verification','2','petition_confirmation_needed',NULL,NULL,0,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(841,94,'In Honor of','1','in_honor_of',NULL,NULL,0,1,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(842,94,'In Memory of','2','in_memory_of',NULL,NULL,0,2,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(843,94,'Solicited','3','solicited',NULL,NULL,1,3,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(844,94,'Household','4','household',NULL,NULL,0,4,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(845,94,'Workplace Giving','5','workplace',NULL,NULL,0,5,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(846,94,'Foundation Affiliate','6','foundation_affiliate',NULL,NULL,0,6,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(847,94,'3rd-party Service','7','3rd-party_service',NULL,NULL,0,7,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(848,94,'Donor-advised Fund','8','donor-advised_fund',NULL,NULL,0,8,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(849,94,'Matched Gift','9','matched_gift',NULL,NULL,0,9,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(850,94,'Personal Campaign Page','10','pcp',NULL,NULL,0,10,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(851,94,'Gift','11','gift',NULL,NULL,0,11,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(852,2,'Interview','55','Interview',NULL,0,NULL,55,'Conduct a phone or in person interview.',0,0,1,NULL,NULL,NULL,'fa-comment-o',NULL);
+INSERT INTO `civicrm_option_value` (`id`, `option_group_id`, `label`, `value`, `name`, `grouping`, `filter`, `is_default`, `weight`, `description`, `is_optgroup`, `is_reserved`, `is_active`, `component_id`, `domain_id`, `visibility_id`, `icon`, `color`) VALUES (1,1,'Phone','1','Phone',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(2,1,'Email','2','Email',NULL,0,NULL,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(3,1,'Postal Mail','3','Postal Mail',NULL,0,NULL,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(4,1,'SMS','4','SMS',NULL,0,NULL,4,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(5,1,'Fax','5','Fax',NULL,0,NULL,5,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(6,2,'Meeting','1','Meeting',NULL,0,NULL,1,NULL,0,1,1,NULL,NULL,NULL,'fa-slideshare',NULL),(7,2,'Phone Call','2','Phone Call',NULL,0,NULL,2,NULL,0,1,1,NULL,NULL,NULL,'fa-phone',NULL),(8,2,'Email','3','Email',NULL,1,NULL,3,'Email sent.',0,1,1,NULL,NULL,NULL,'fa-envelope-o',NULL),(9,2,'Outbound SMS','4','SMS',NULL,1,NULL,4,'Text message (SMS) sent.',0,1,1,NULL,NULL,NULL,'fa-mobile',NULL),(10,2,'Event Registration','5','Event Registration',NULL,1,NULL,5,'Online or offline event registration.',0,1,1,1,NULL,NULL,NULL,NULL),(11,2,'Contribution','6','Contribution',NULL,1,NULL,6,'Online or offline contribution.',0,1,1,2,NULL,NULL,NULL,NULL),(12,2,'Membership Signup','7','Membership Signup',NULL,1,NULL,7,'Online or offline membership signup.',0,1,1,3,NULL,NULL,NULL,NULL),(13,2,'Membership Renewal','8','Membership Renewal',NULL,1,NULL,8,'Online or offline membership renewal.',0,1,1,3,NULL,NULL,NULL,NULL),(14,2,'Tell a Friend','9','Tell a Friend',NULL,1,NULL,9,'Send information about a contribution campaign or event to a friend.',0,1,1,NULL,NULL,NULL,NULL,NULL),(15,2,'Pledge Acknowledgment','10','Pledge Acknowledgment',NULL,1,NULL,10,'Send Pledge Acknowledgment.',0,1,1,6,NULL,NULL,NULL,NULL),(16,2,'Pledge Reminder','11','Pledge Reminder',NULL,1,NULL,11,'Send Pledge Reminder.',0,1,1,6,NULL,NULL,NULL,NULL),(17,2,'Inbound Email','12','Inbound Email',NULL,1,NULL,12,'Inbound Email.',0,1,1,NULL,NULL,NULL,NULL,NULL),(18,2,'Open Case','13','Open Case',NULL,0,0,13,'',0,1,1,7,NULL,NULL,'fa-folder-open-o',NULL),(19,2,'Follow up','14','Follow up',NULL,0,0,14,'',0,1,1,7,NULL,NULL,'fa-share-square-o',NULL),(20,2,'Change Case Type','15','Change Case Type',NULL,0,0,15,'',0,1,1,7,NULL,NULL,'fa-random',NULL),(21,2,'Change Case Status','16','Change Case Status',NULL,0,0,16,'',0,1,1,7,NULL,NULL,'fa-pencil-square-o',NULL),(22,2,'Change Case Subject','53','Change Case Subject',NULL,0,0,53,'',0,1,1,7,NULL,NULL,'fa-pencil-square-o',NULL),(23,2,'Change Custom Data','33','Change Custom Data',NULL,0,0,33,'',0,1,1,7,NULL,NULL,'fa-table',NULL),(24,2,'Membership Renewal Reminder','17','Membership Renewal Reminder',NULL,1,NULL,17,'offline membership renewal reminder.',0,1,1,3,NULL,NULL,NULL,NULL),(25,2,'Change Case Start Date','18','Change Case Start Date',NULL,0,0,18,'',0,1,1,7,NULL,NULL,'fa-calendar',NULL),(26,2,'Bulk Email','19','Bulk Email',NULL,1,NULL,19,'Bulk Email Sent.',0,1,1,NULL,NULL,NULL,NULL,NULL),(27,2,'Assign Case Role','20','Assign Case Role',NULL,0,0,20,'',0,1,1,7,NULL,NULL,'fa-user-plus',NULL),(28,2,'Remove Case Role','21','Remove Case Role',NULL,0,0,21,'',0,1,1,7,NULL,NULL,'fa-user-times',NULL),(29,2,'Print/Merge Document','22','Print PDF Letter',NULL,0,NULL,22,'Export letters and other printable documents.',0,1,1,NULL,NULL,NULL,'fa-file-pdf-o',NULL),(30,2,'Merge Case','23','Merge Case',NULL,0,NULL,23,'',0,1,1,7,NULL,NULL,'fa-compress',NULL),(31,2,'Reassigned Case','24','Reassigned Case',NULL,0,NULL,24,'',0,1,1,7,NULL,NULL,'fa-user-circle-o',NULL),(32,2,'Link Cases','25','Link Cases',NULL,0,NULL,25,'',0,1,1,7,NULL,NULL,'fa-link',NULL),(33,2,'Change Case Tags','26','Change Case Tags',NULL,0,0,26,'',0,1,1,7,NULL,NULL,'fa-tags',NULL),(34,2,'Add Client To Case','27','Add Client To Case',NULL,0,0,26,'',0,1,1,7,NULL,NULL,'fa-users',NULL),(35,2,'Survey','28','Survey',NULL,0,0,27,'',0,1,1,9,NULL,NULL,NULL,NULL),(36,2,'Canvass','29','Canvass',NULL,0,0,28,'',0,1,1,9,NULL,NULL,NULL,NULL),(37,2,'PhoneBank','30','PhoneBank',NULL,0,0,29,'',0,1,1,9,NULL,NULL,NULL,NULL),(38,2,'WalkList','31','WalkList',NULL,0,0,30,'',0,1,1,9,NULL,NULL,NULL,NULL),(39,2,'Petition Signature','32','Petition',NULL,0,0,31,'',0,1,1,9,NULL,NULL,NULL,NULL),(40,2,'Mass SMS','34','Mass SMS',NULL,1,NULL,34,'Mass SMS',0,1,1,NULL,NULL,NULL,NULL,NULL),(41,2,'Change Membership Status','35','Change Membership Status',NULL,1,NULL,35,'Change Membership Status.',0,1,1,3,NULL,NULL,NULL,NULL),(42,2,'Change Membership Type','36','Change Membership Type',NULL,1,NULL,36,'Change Membership Type.',0,1,1,3,NULL,NULL,NULL,NULL),(43,2,'Cancel Recurring Contribution','37','Cancel Recurring Contribution',NULL,1,0,37,'',0,1,1,2,NULL,NULL,NULL,NULL),(44,2,'Update Recurring Contribution Billing Details','38','Update Recurring Contribution Billing Details',NULL,1,0,38,'',0,1,1,2,NULL,NULL,NULL,NULL),(45,2,'Update Recurring Contribution','39','Update Recurring Contribution',NULL,1,0,39,'',0,1,1,2,NULL,NULL,NULL,NULL),(46,2,'Reminder Sent','40','Reminder Sent',NULL,1,0,40,'',0,1,1,NULL,NULL,NULL,NULL,NULL),(47,2,'Export Accounting Batch','41','Export Accounting Batch',NULL,1,0,41,'Export Accounting Batch',0,1,1,2,NULL,NULL,NULL,NULL),(48,2,'Create Batch','42','Create Batch',NULL,1,0,42,'Create Batch',0,1,1,2,NULL,NULL,NULL,NULL),(49,2,'Edit Batch','43','Edit Batch',NULL,1,0,43,'Edit Batch',0,1,1,2,NULL,NULL,NULL,NULL),(50,2,'SMS delivery','44','SMS delivery',NULL,1,NULL,44,'SMS delivery',0,1,1,NULL,NULL,NULL,NULL,NULL),(51,2,'Inbound SMS','45','Inbound SMS',NULL,1,NULL,45,'Inbound SMS',0,1,1,NULL,NULL,NULL,NULL,NULL),(52,2,'Payment','46','Payment',NULL,1,NULL,46,'Additional payment recorded for event or membership fee.',0,1,1,2,NULL,NULL,NULL,NULL),(53,2,'Refund','47','Refund',NULL,1,NULL,47,'Refund recorded for event or membership fee.',0,1,1,2,NULL,NULL,NULL,NULL),(54,2,'Change Registration','48','Change Registration',NULL,1,NULL,48,'Changes to an existing event registration.',0,1,1,1,NULL,NULL,NULL,NULL),(55,2,'Downloaded Invoice','49','Downloaded Invoice',NULL,1,NULL,49,'Downloaded Invoice.',0,1,1,NULL,NULL,NULL,NULL,NULL),(56,2,'Emailed Invoice','50','Emailed Invoice',NULL,1,NULL,50,'Emailed Invoice.',0,1,1,NULL,NULL,NULL,NULL,NULL),(57,2,'Contact Merged','51','Contact Merged',NULL,1,NULL,51,'Contact Merged',0,1,1,NULL,NULL,NULL,NULL,NULL),(58,2,'Contact Deleted by Merge','52','Contact Deleted by Merge',NULL,1,NULL,52,'Contact was merged into another contact',0,1,1,NULL,NULL,NULL,NULL,NULL),(59,2,'Failed Payment','54','Failed Payment',NULL,1,0,54,'Failed Payment',0,1,1,2,NULL,NULL,NULL,NULL),(60,3,'Female','1','Female',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(61,3,'Male','2','Male',NULL,0,NULL,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(62,3,'Other','3','Other',NULL,0,NULL,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(63,4,'Yahoo','1','Yahoo',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(64,4,'MSN','2','Msn',NULL,0,NULL,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(65,4,'AIM','3','Aim',NULL,0,NULL,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(66,4,'GTalk','4','Gtalk',NULL,0,NULL,4,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(67,4,'Jabber','5','Jabber',NULL,0,NULL,5,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(68,4,'Skype','6','Skype',NULL,0,NULL,6,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(69,5,'Sprint','1','Sprint',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(70,5,'Verizon','2','Verizon',NULL,0,NULL,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(71,5,'Cingular','3','Cingular',NULL,0,NULL,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(72,6,'Mrs.','1','Mrs.',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(73,6,'Ms.','2','Ms.',NULL,0,NULL,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(74,6,'Mr.','3','Mr.',NULL,0,NULL,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(75,6,'Dr.','4','Dr.',NULL,0,NULL,4,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(76,7,'Jr.','1','Jr.',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(77,7,'Sr.','2','Sr.',NULL,0,NULL,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(78,7,'II','3','II',NULL,0,NULL,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(79,7,'III','4','III',NULL,0,NULL,4,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(80,7,'IV','5','IV',NULL,0,NULL,5,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(81,7,'V','6','V',NULL,0,NULL,6,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(82,7,'VI','7','VI',NULL,0,NULL,7,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(83,7,'VII','8','VII',NULL,0,NULL,8,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(84,8,'Administrator','1','Admin',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(85,8,'Authenticated','2','Auth',NULL,0,NULL,2,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(86,9,'Visa','1','Visa',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(87,9,'MasterCard','2','MasterCard',NULL,0,NULL,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(88,9,'Amex','3','Amex',NULL,0,NULL,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(89,9,'Discover','4','Discover',NULL,0,NULL,4,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(90,10,'Credit Card','1','Credit Card',NULL,0,0,1,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(91,10,'Debit Card','2','Debit Card',NULL,0,0,2,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(92,10,'Cash','3','Cash',NULL,0,0,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(93,10,'Check','4','Check',NULL,0,1,4,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(94,10,'EFT','5','EFT',NULL,0,0,5,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(95,11,'Completed','1','Completed',NULL,0,NULL,1,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(96,11,'Pending','2','Pending',NULL,0,NULL,2,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(97,11,'Cancelled','3','Cancelled',NULL,0,NULL,3,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(98,11,'Failed','4','Failed',NULL,0,NULL,4,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(99,11,'In Progress','5','In Progress',NULL,0,NULL,5,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(100,11,'Overdue','6','Overdue',NULL,0,NULL,6,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(101,11,'Refunded','7','Refunded',NULL,0,NULL,7,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(102,11,'Partially paid','8','Partially paid',NULL,0,NULL,8,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(103,11,'Pending refund','9','Pending refund',NULL,0,NULL,9,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(104,11,'Chargeback','10','Chargeback',NULL,0,NULL,10,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(105,12,'Waiting Review','1','Waiting Review',NULL,0,NULL,1,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(106,12,'Approved','2','Approved',NULL,0,NULL,2,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(107,12,'Not Approved','3','Not Approved',NULL,0,NULL,3,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(108,13,'Owner chooses whether to receive notifications','1','owner_chooses',NULL,0,1,1,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(109,13,'Notifications are sent to ALL owners','2','all_owners',NULL,0,0,2,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(110,13,'Notifications are NOT available','3','no_notifications',NULL,0,0,3,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(111,14,'Attendee','1','Attendee',NULL,1,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(112,14,'Volunteer','2','Volunteer',NULL,1,NULL,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(113,14,'Host','3','Host',NULL,1,NULL,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(114,14,'Speaker','4','Speaker',NULL,1,NULL,4,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(115,15,'Conference','1','Conference',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(116,15,'Exhibition','2','Exhibition',NULL,0,NULL,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(117,15,'Fundraiser','3','Fundraiser',NULL,0,NULL,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(118,15,'Meeting','4','Meeting',NULL,0,NULL,4,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(119,15,'Performance','5','Performance',NULL,0,NULL,5,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(120,15,'Workshop','6','Workshop',NULL,0,NULL,6,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(121,16,'Activities','1','activity',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(122,16,'Relationships','2','rel',NULL,0,NULL,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(123,16,'Groups','3','group',NULL,0,NULL,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(124,16,'Notes','4','note',NULL,0,NULL,4,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(125,16,'Tags','5','tag',NULL,0,NULL,5,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(126,16,'Change Log','6','log',NULL,0,NULL,6,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(127,16,'Contributions','7','CiviContribute',NULL,0,NULL,7,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(128,16,'Memberships','8','CiviMember',NULL,0,NULL,8,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(129,16,'Events','9','CiviEvent',NULL,0,NULL,9,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(130,16,'Cases','10','CiviCase',NULL,0,NULL,10,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(131,16,'Grants','11','CiviGrant',NULL,0,NULL,11,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(132,16,'Pledges','13','CiviPledge',NULL,0,NULL,13,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(133,16,'Mailings','14','CiviMail',NULL,0,NULL,14,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(134,17,'Show Smart Groups on Demand','1','showondemand',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(135,17,'Always Show Smart Groups','2','alwaysshow',NULL,0,NULL,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(136,17,'Hide Smart Groups','3','hide',NULL,0,NULL,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(137,18,'Custom Data','1','CustomData',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(138,18,'Address','2','Address',NULL,0,NULL,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(139,18,'Communication Preferences','3','CommunicationPreferences',NULL,0,NULL,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(140,18,'Notes','4','Notes',NULL,0,NULL,4,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(141,18,'Demographics','5','Demographics',NULL,0,NULL,5,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(142,18,'Tags and Groups','6','TagsAndGroups',NULL,0,NULL,6,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(143,18,'Email','7','Email',NULL,1,NULL,7,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(144,18,'Phone','8','Phone',NULL,1,NULL,8,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(145,18,'Instant Messenger','9','IM',NULL,1,NULL,9,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(146,18,'Open ID','10','OpenID',NULL,1,NULL,10,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(147,18,'Website','11','Website',NULL,1,NULL,11,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(148,18,'Prefix','12','Prefix',NULL,2,NULL,12,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(149,18,'Formal Title','13','Formal Title',NULL,2,NULL,13,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(150,18,'First Name','14','First Name',NULL,2,NULL,14,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(151,18,'Middle Name','15','Middle Name',NULL,2,NULL,15,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(152,18,'Last Name','16','Last Name',NULL,2,NULL,16,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(153,18,'Suffix','17','Suffix',NULL,2,NULL,17,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(154,19,'Address Fields','1','location',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(155,19,'Custom Fields','2','custom',NULL,0,NULL,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(156,19,'Activities','3','activity',NULL,0,NULL,4,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(157,19,'Relationships','4','relationship',NULL,0,NULL,5,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(158,19,'Notes','5','notes',NULL,0,NULL,6,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(159,19,'Change Log','6','changeLog',NULL,0,NULL,7,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(160,19,'Contributions','7','CiviContribute',NULL,0,NULL,8,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(161,19,'Memberships','8','CiviMember',NULL,0,NULL,9,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(162,19,'Events','9','CiviEvent',NULL,0,NULL,10,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(163,19,'Cases','10','CiviCase',NULL,0,NULL,11,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(164,19,'Grants','12','CiviGrant',NULL,0,NULL,14,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(165,19,'Demographics','13','demographics',NULL,0,NULL,15,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(166,19,'Pledges','15','CiviPledge',NULL,0,NULL,17,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(167,19,'Contact Type','16','contactType',NULL,0,NULL,18,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(168,19,'Groups','17','groups',NULL,0,NULL,19,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(169,19,'Tags','18','tags',NULL,0,NULL,20,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(170,19,'Mailing','19','CiviMail',NULL,0,NULL,21,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(171,20,'Groups','1','Groups',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(172,20,'Contributions','2','CiviContribute',NULL,0,NULL,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(173,20,'Memberships','3','CiviMember',NULL,0,NULL,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(174,20,'Events','4','CiviEvent',NULL,0,NULL,4,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(175,20,'My Contacts / Organizations','5','Permissioned Orgs',NULL,0,NULL,5,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(176,20,'Pledges','7','CiviPledge',NULL,0,NULL,7,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(177,20,'Personal Campaign Pages','8','PCP',NULL,0,NULL,8,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(178,20,'Assigned Activities','9','Assigned Activities',NULL,0,NULL,9,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(179,20,'Invoices / Credit Notes','10','Invoices / Credit Notes',NULL,0,NULL,10,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(180,45,'Email Address','2','email',NULL,0,NULL,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(181,45,'Phone','3','phone',NULL,0,NULL,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(182,45,'Street Address','4','street_address',NULL,0,NULL,4,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(183,45,'City','5','city',NULL,0,NULL,5,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(184,45,'State/Province','6','state_province',NULL,0,NULL,6,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(185,45,'Country','7','country',NULL,0,NULL,7,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(186,45,'Postal Code','8','postal_code',NULL,0,NULL,8,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(187,46,'Email Address','2','email',NULL,0,NULL,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(188,46,'Phone','3','phone',NULL,0,NULL,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(189,46,'Street Address','4','street_address',NULL,0,NULL,4,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(190,46,'City','5','city',NULL,0,NULL,5,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(191,46,'State/Province','6','state_province',NULL,0,NULL,6,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(192,46,'Country','7','country',NULL,0,NULL,7,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(193,46,'Postal Code','8','country',NULL,0,NULL,8,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(194,21,'Street Address','1','street_address',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(195,21,'Supplemental Address 1','2','supplemental_address_1',NULL,0,NULL,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(196,21,'Supplemental Address 2','3','supplemental_address_2',NULL,0,NULL,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(197,21,'Supplemental Address 3','4','supplemental_address_3',NULL,0,NULL,4,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(198,21,'City','5','city',NULL,0,NULL,5,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(199,21,'Postal Code','6','postal_code',NULL,0,NULL,6,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(200,21,'Postal Code Suffix','7','postal_code_suffix',NULL,0,NULL,7,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(201,21,'County','8','county',NULL,0,NULL,8,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(202,21,'State/Province','9','state_province',NULL,0,NULL,9,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(203,21,'Country','10','country',NULL,0,NULL,10,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(204,21,'Latitude','11','geo_code_1',NULL,0,NULL,11,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(205,21,'Longitude','12','geo_code_2',NULL,0,NULL,12,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(206,21,'Address Name','13','address_name',NULL,0,NULL,13,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(207,21,'Street Address Parsing','14','street_address_parsing',NULL,0,NULL,14,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(208,22,'Access Control','1','Access Control',NULL,0,NULL,1,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(209,22,'Mailing List','2','Mailing List',NULL,0,NULL,2,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(210,23,'Submitted','1','Submitted',NULL,0,1,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(211,23,'Eligible','2','Eligible',NULL,0,NULL,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(212,23,'Ineligible','3','Ineligible',NULL,0,NULL,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(213,23,'Paid','4','Paid',NULL,0,NULL,4,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(214,23,'Awaiting Information','5','Awaiting Information',NULL,0,NULL,5,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(215,23,'Withdrawn','6','Withdrawn',NULL,0,NULL,6,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(216,23,'Approved for Payment','7','Approved for Payment',NULL,0,NULL,7,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(217,25,'CRM_Contact_Form_Search_Custom_Sample','1','CRM_Contact_Form_Search_Custom_Sample',NULL,0,NULL,1,'Household Name and State',0,0,1,NULL,NULL,NULL,NULL,NULL),(218,25,'CRM_Contact_Form_Search_Custom_ContributionAggregate','2','CRM_Contact_Form_Search_Custom_ContributionAggregate',NULL,0,NULL,2,'Contribution Aggregate',0,0,1,NULL,NULL,NULL,NULL,NULL),(219,25,'CRM_Contact_Form_Search_Custom_Basic','3','CRM_Contact_Form_Search_Custom_Basic',NULL,0,NULL,3,'Basic Search',0,0,1,NULL,NULL,NULL,NULL,NULL),(220,25,'CRM_Contact_Form_Search_Custom_Group','4','CRM_Contact_Form_Search_Custom_Group',NULL,0,NULL,4,'Include / Exclude Search',0,0,1,NULL,NULL,NULL,NULL,NULL),(221,25,'CRM_Contact_Form_Search_Custom_PostalMailing','5','CRM_Contact_Form_Search_Custom_PostalMailing',NULL,0,NULL,5,'Postal Mailing',0,0,1,NULL,NULL,NULL,NULL,NULL),(222,25,'CRM_Contact_Form_Search_Custom_Proximity','6','CRM_Contact_Form_Search_Custom_Proximity',NULL,0,NULL,6,'Proximity Search',0,0,1,NULL,NULL,NULL,NULL,NULL),(223,25,'CRM_Contact_Form_Search_Custom_EventAggregate','7','CRM_Contact_Form_Search_Custom_EventAggregate',NULL,0,NULL,7,'Event Aggregate',0,0,1,NULL,NULL,NULL,NULL,NULL),(224,25,'CRM_Contact_Form_Search_Custom_ActivitySearch','8','CRM_Contact_Form_Search_Custom_ActivitySearch',NULL,0,NULL,8,'Activity Search',0,0,1,NULL,NULL,NULL,NULL,NULL),(225,25,'CRM_Contact_Form_Search_Custom_PriceSet','9','CRM_Contact_Form_Search_Custom_PriceSet',NULL,0,NULL,9,'Price Set Details for Event Participants',0,0,1,NULL,NULL,NULL,NULL,NULL),(226,25,'CRM_Contact_Form_Search_Custom_ZipCodeRange','10','CRM_Contact_Form_Search_Custom_ZipCodeRange',NULL,0,NULL,10,'Zip Code Range',0,0,1,NULL,NULL,NULL,NULL,NULL),(227,25,'CRM_Contact_Form_Search_Custom_DateAdded','11','CRM_Contact_Form_Search_Custom_DateAdded',NULL,0,NULL,11,'Date Added to CiviCRM',0,0,1,NULL,NULL,NULL,NULL,NULL),(228,25,'CRM_Contact_Form_Search_Custom_MultipleValues','12','CRM_Contact_Form_Search_Custom_MultipleValues',NULL,0,NULL,12,'Custom Group Multiple Values Listing',0,0,1,NULL,NULL,NULL,NULL,NULL),(229,25,'CRM_Contact_Form_Search_Custom_ContribSYBNT','13','CRM_Contact_Form_Search_Custom_ContribSYBNT',NULL,0,NULL,13,'Contributions made in Year X and not Year Y',0,0,1,NULL,NULL,NULL,NULL,NULL),(230,25,'CRM_Contact_Form_Search_Custom_TagContributions','14','CRM_Contact_Form_Search_Custom_TagContributions',NULL,0,NULL,14,'Find Contribution Amounts by Tag',0,0,1,NULL,NULL,NULL,NULL,NULL),(231,25,'CRM_Contact_Form_Search_Custom_FullText','15','CRM_Contact_Form_Search_Custom_FullText',NULL,0,NULL,15,'Full-text Search',0,0,1,NULL,NULL,NULL,NULL,NULL),(232,41,'Constituent Report (Summary)','contact/summary','CRM_Report_Form_Contact_Summary',NULL,0,NULL,1,'Provides a list of address and telephone information for constituent records in your system.',0,0,1,NULL,NULL,NULL,NULL,NULL),(233,41,'Constituent Report (Detail)','contact/detail','CRM_Report_Form_Contact_Detail',NULL,0,NULL,2,'Provides contact-related information on contributions, memberships, events and activities.',0,0,1,NULL,NULL,NULL,NULL,NULL),(234,41,'Activity Details Report','activity','CRM_Report_Form_Activity',NULL,0,NULL,3,'Provides a list of constituent activity including activity statistics for one/all contacts during a given date range(required)',0,0,1,NULL,NULL,NULL,NULL,NULL),(235,41,'Walk / Phone List Report','walklist','CRM_Report_Form_Walklist_Walklist',NULL,0,NULL,4,'Provides a detailed report for your walk/phonelist for targeted contacts',0,0,0,NULL,NULL,NULL,NULL,NULL),(236,41,'Current Employer Report','contact/currentEmployer','CRM_Report_Form_Contact_CurrentEmployer',NULL,0,NULL,5,'Provides detail list of employer employee relationships along with employment details Ex Join Date',0,0,1,NULL,NULL,NULL,NULL,NULL),(237,41,'Contribution Summary Report','contribute/summary','CRM_Report_Form_Contribute_Summary',NULL,0,NULL,6,'Groups and totals contributions by criteria including contact, time period, financial type, contributor location, etc.',0,0,1,2,NULL,NULL,NULL,NULL),(238,41,'Contribution Detail Report','contribute/detail','CRM_Report_Form_Contribute_Detail',NULL,0,NULL,7,'Lists specific contributions by criteria including contact, time period, financial type, contributor location, etc. Contribution summary report points to this report for contribution details.',0,0,1,2,NULL,NULL,NULL,NULL),(239,41,'Repeat Contributions Report','contribute/repeat','CRM_Report_Form_Contribute_Repeat',NULL,0,NULL,8,'Given two date ranges, shows contacts who contributed in both the date ranges with the amount contributed in each and the percentage increase / decrease.',0,0,1,2,NULL,NULL,NULL,NULL),(240,41,'Contributions by Organization Report','contribute/organizationSummary','CRM_Report_Form_Contribute_OrganizationSummary',NULL,0,NULL,9,'Displays a detailed list of contributions grouped by organization, which includes contributions made by employees for the organisation.',0,0,1,2,NULL,NULL,NULL,NULL),(241,41,'Contributions by Household Report','contribute/householdSummary','CRM_Report_Form_Contribute_HouseholdSummary',NULL,0,NULL,10,'Displays a detailed list of contributions grouped by household which includes contributions made by members of the household.',0,0,1,2,NULL,NULL,NULL,NULL),(242,41,'Top Donors Report','contribute/topDonor','CRM_Report_Form_Contribute_TopDonor',NULL,0,NULL,11,'Provides a list of the top donors during a time period you define. You can include as many donors as you want (for example, top 100 of your donors).',0,0,1,2,NULL,NULL,NULL,NULL),(243,41,'SYBUNT Report','contribute/sybunt','CRM_Report_Form_Contribute_Sybunt',NULL,0,NULL,12,'SYBUNT means some year(s) but not this year. Provides a list of constituents who donated at some time in the history of your organization but did not donate during the time period you specify.',0,0,1,2,NULL,NULL,NULL,NULL),(244,41,'LYBUNT Report','contribute/lybunt','CRM_Report_Form_Contribute_Lybunt',NULL,0,NULL,13,'LYBUNT means last year but not this year. Provides a list of constituents who donated last year but did not donate during the time period you specify as the current year.',0,0,1,2,NULL,NULL,NULL,NULL),(245,41,'Soft Credit Report','contribute/softcredit','CRM_Report_Form_Contribute_SoftCredit',NULL,0,NULL,14,'Shows contributions made by contacts that have been soft-credited to other contacts.',0,0,1,2,NULL,NULL,NULL,NULL),(246,41,'Membership Report (Summary)','member/summary','CRM_Report_Form_Member_Summary',NULL,0,NULL,15,'Provides a summary of memberships by type and join date.',0,0,1,3,NULL,NULL,NULL,NULL),(247,41,'Membership Report (Detail)','member/detail','CRM_Report_Form_Member_Detail',NULL,0,NULL,16,'Provides a list of members along with their membership status and membership details (Join Date, Start Date, End Date). Can also display contributions (payments) associated with each membership.',0,0,1,3,NULL,NULL,NULL,NULL),(248,41,'Membership Report (Lapsed)','member/lapse','CRM_Report_Form_Member_Lapse',NULL,0,NULL,17,'Provides a list of memberships that lapsed or will lapse before the date you specify.',0,0,1,3,NULL,NULL,NULL,NULL),(249,41,'Event Participant Report (List)','event/participantListing','CRM_Report_Form_Event_ParticipantListing',NULL,0,NULL,18,'Provides lists of participants for an event.',0,0,1,1,NULL,NULL,NULL,NULL),(250,41,'Event Income Report (Summary)','event/summary','CRM_Report_Form_Event_Summary',NULL,0,NULL,19,'Provides an overview of event income. You can include key information such as event ID, registration, attendance, and income generated to help you determine the success of an event.',0,0,1,1,NULL,NULL,NULL,NULL),(251,41,'Event Income Report (Detail)','event/income','CRM_Report_Form_Event_Income',NULL,0,NULL,20,'Helps you to analyze the income generated by an event. The report can include details by participant type, status and payment method.',0,0,1,1,NULL,NULL,NULL,NULL),(252,41,'Pledge Detail Report','pledge/detail','CRM_Report_Form_Pledge_Detail',NULL,0,NULL,21,'List of pledges including amount pledged, pledge status, next payment date, balance due, total amount paid etc.',0,0,1,6,NULL,NULL,NULL,NULL),(253,41,'Pledged but not Paid Report','pledge/pbnp','CRM_Report_Form_Pledge_Pbnp',NULL,0,NULL,22,'Pledged but not Paid Report',0,0,1,6,NULL,NULL,NULL,NULL),(254,41,'Relationship Report','contact/relationship','CRM_Report_Form_Contact_Relationship',NULL,0,NULL,23,'Relationship Report',0,0,1,NULL,NULL,NULL,NULL,NULL),(255,41,'Case Summary Report','case/summary','CRM_Report_Form_Case_Summary',NULL,0,NULL,24,'Provides a summary of cases and their duration by date range, status, staff member and / or case role.',0,0,1,7,NULL,NULL,NULL,NULL),(256,41,'Case Time Spent Report','case/timespent','CRM_Report_Form_Case_TimeSpent',NULL,0,NULL,25,'Aggregates time spent on case and / or non-case activities by activity type and contact.',0,0,1,7,NULL,NULL,NULL,NULL),(257,41,'Contact Demographics Report','case/demographics','CRM_Report_Form_Case_Demographics',NULL,0,NULL,26,'Demographic breakdown for case clients (and or non-case contacts) in your database. Includes custom contact fields.',0,0,1,7,NULL,NULL,NULL,NULL),(258,41,'Database Log Report','contact/log','CRM_Report_Form_Contact_Log',NULL,0,NULL,27,'Log of contact and activity records created or updated in a given date range.',0,0,1,NULL,NULL,NULL,NULL,NULL),(259,41,'Activity Summary Report','activitySummary','CRM_Report_Form_ActivitySummary',NULL,0,NULL,28,'Shows activity statistics by type / date',0,0,1,NULL,NULL,NULL,NULL,NULL),(260,41,'Bookkeeping Transactions Report','contribute/bookkeeping','CRM_Report_Form_Contribute_Bookkeeping',NULL,0,0,29,'Shows Bookkeeping Transactions Report',0,0,1,2,NULL,NULL,NULL,NULL),(261,41,'Grant Report (Detail)','grant/detail','CRM_Report_Form_Grant_Detail',NULL,0,0,30,'Grant Report Detail',0,0,1,5,NULL,NULL,NULL,NULL),(262,41,'Participant list Count Report','event/participantlist','CRM_Report_Form_Event_ParticipantListCount',NULL,0,0,31,'Shows the Participant list with Participant Count.',0,0,1,1,NULL,NULL,NULL,NULL),(263,41,'Income Count Summary Report','event/incomesummary','CRM_Report_Form_Event_IncomeCountSummary',NULL,0,0,32,'Shows the Income Summary of events with Count.',0,0,1,1,NULL,NULL,NULL,NULL),(264,41,'Case Detail Report','case/detail','CRM_Report_Form_Case_Detail',NULL,0,0,33,'Case Details',0,0,1,7,NULL,NULL,NULL,NULL),(265,41,'Mail Bounce Report','Mailing/bounce','CRM_Report_Form_Mailing_Bounce',NULL,0,NULL,34,'Bounce Report for mailings',0,0,1,4,NULL,NULL,NULL,NULL),(266,41,'Mail Summary Report','Mailing/summary','CRM_Report_Form_Mailing_Summary',NULL,0,NULL,35,'Summary statistics for mailings',0,0,1,4,NULL,NULL,NULL,NULL),(267,41,'Mail Opened Report','Mailing/opened','CRM_Report_Form_Mailing_Opened',NULL,0,NULL,36,'Display contacts who opened emails from a mailing',0,0,1,4,NULL,NULL,NULL,NULL),(268,41,'Mail Click-Through Report','Mailing/clicks','CRM_Report_Form_Mailing_Clicks',NULL,0,NULL,37,'Display clicks from each mailing',0,0,1,4,NULL,NULL,NULL,NULL),(269,41,'Contact Logging Report (Summary)','logging/contact/summary','CRM_Report_Form_Contact_LoggingSummary',NULL,0,NULL,38,'Contact modification report for the logging infrastructure (summary).',0,0,0,NULL,NULL,NULL,NULL,NULL),(270,41,'Contact Logging Report (Detail)','logging/contact/detail','CRM_Report_Form_Contact_LoggingDetail',NULL,0,NULL,39,'Contact modification report for the logging infrastructure (detail).',0,0,0,NULL,NULL,NULL,NULL,NULL),(271,41,'Grant Report (Statistics)','grant/statistics','CRM_Report_Form_Grant_Statistics',NULL,0,NULL,42,'Shows statistics for Grants.',0,0,1,5,NULL,NULL,NULL,NULL),(272,41,'Survey Report (Detail)','survey/detail','CRM_Report_Form_Campaign_SurveyDetails',NULL,0,NULL,43,'Detailed report for canvassing, phone-banking, walk lists or other surveys.',0,0,1,9,NULL,NULL,NULL,NULL),(273,41,'Personal Campaign Page Report','contribute/pcp','CRM_Report_Form_Contribute_PCP',NULL,0,NULL,44,'Summarizes amount raised and number of contributors for each Personal Campaign Page.',0,0,1,2,NULL,NULL,NULL,NULL),(274,41,'Pledge Summary Report','pledge/summary','CRM_Report_Form_Pledge_Summary',NULL,0,NULL,45,'Groups and totals pledges by criteria including contact, time period, pledge status, location, etc.',0,0,1,6,NULL,NULL,NULL,NULL),(275,41,'Contribution Aggregate by Relationship','contribute/history','CRM_Report_Form_Contribute_History',NULL,0,NULL,46,'List contact\'s donation history, grouped by year, along with contributions attributed to any of the contact\'s related contacts.',0,0,1,2,NULL,NULL,NULL,NULL),(276,41,'Mail Detail Report','mailing/detail','CRM_Report_Form_Mailing_Detail',NULL,0,NULL,47,'Provides reporting on Intended and Successful Deliveries, Unsubscribes and Opt-outs, Replies and Forwards.',0,0,1,4,NULL,NULL,NULL,NULL),(277,41,'Contribution and Membership Details','member/contributionDetail','CRM_Report_Form_Member_ContributionDetail',NULL,0,NULL,48,'Contribution details for any type of contribution, plus associated membership information for contributions which are in payment for memberships.',0,0,1,3,NULL,NULL,NULL,NULL),(278,41,'Recurring Contributions Report','contribute/recur','CRM_Report_Form_Contribute_Recur',NULL,0,NULL,49,'Provides information about the status of recurring contributions',0,0,1,2,NULL,NULL,NULL,NULL),(279,41,'Recurring Contributions Summary','contribute/recursummary','CRM_Report_Form_Contribute_RecurSummary',NULL,0,NULL,49,'Provides simple summary for each payment instrument for which there are recurring contributions (e.g. Credit Card, Standing Order, Direct Debit, etc., NULL), showing within a given date range.',0,0,1,2,NULL,NULL,NULL,NULL),(280,41,'Deferred Revenue Details','contribute/deferredrevenue','CRM_Report_Form_Contribute_DeferredRevenue',NULL,0,NULL,50,'Deferred Revenue Details Report',0,0,1,2,NULL,NULL,NULL,NULL),(281,26,'Scheduled','1','Scheduled',NULL,0,1,1,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(282,26,'Completed','2','Completed',NULL,1,NULL,2,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(283,26,'Cancelled','3','Cancelled',NULL,2,NULL,3,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(284,26,'Left Message','4','Left Message',NULL,0,NULL,4,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(285,26,'Unreachable','5','Unreachable',NULL,2,NULL,5,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(286,26,'Not Required','6','Not Required',NULL,2,NULL,6,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(287,26,'Available','7','Available',NULL,0,NULL,7,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(288,26,'No-show','8','No_show',NULL,2,NULL,8,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(289,28,'Ongoing','1','Open','Opened',0,1,1,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(290,28,'Resolved','2','Closed','Closed',0,NULL,2,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(291,28,'Urgent','3','Urgent','Opened',0,NULL,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(292,29,'Name Only','1','Name Only',NULL,0,0,1,'CRM_Event_Page_ParticipantListing_Name',0,1,1,NULL,NULL,NULL,NULL,NULL),(293,29,'Name and Email','2','Name and Email',NULL,0,0,2,'CRM_Event_Page_ParticipantListing_NameAndEmail',0,1,1,NULL,NULL,NULL,NULL,NULL),(294,29,'Name, Status and Register Date','3','Name, Status and Register Date',NULL,0,0,3,'CRM_Event_Page_ParticipantListing_NameStatusAndDate',0,1,1,NULL,NULL,NULL,NULL,NULL),(295,30,'jpg','1','jpg',NULL,0,0,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(296,30,'jpeg','2','jpeg',NULL,0,0,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(297,30,'png','3','png',NULL,0,0,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(298,30,'gif','4','gif',NULL,0,0,4,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(299,30,'txt','5','txt',NULL,0,0,5,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(300,30,'pdf','6','pdf',NULL,0,0,6,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(301,30,'doc','7','doc',NULL,0,0,7,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(302,30,'xls','8','xls',NULL,0,0,8,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(303,30,'rtf','9','rtf',NULL,0,0,9,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(304,30,'csv','10','csv',NULL,0,0,10,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(305,30,'ppt','11','ppt',NULL,0,0,11,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(306,30,'docx','12','docx',NULL,0,0,12,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(307,30,'xlsx','13','xlsx',NULL,0,0,13,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(308,30,'odt','14','odt',NULL,0,0,14,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(309,30,'ics','15','ics',NULL,0,0,15,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(310,33,'Textarea','1','Textarea',NULL,0,NULL,1,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(311,33,'CKEditor','2','CKEditor',NULL,0,NULL,2,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(312,32,'Search Builder','1','Search Builder',NULL,0,0,1,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(313,32,'Import Contact','2','Import Contact',NULL,0,0,2,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(314,32,'Import Activity','3','Import Activity',NULL,0,0,3,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(315,32,'Import Contribution','4','Import Contribution',NULL,0,0,4,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(316,32,'Import Membership','5','Import Membership',NULL,0,0,5,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(317,32,'Import Participant','6','Import Participant',NULL,0,0,6,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(318,32,'Export Contact','7','Export Contact',NULL,0,0,7,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(319,32,'Export Contribution','8','Export Contribution',NULL,0,0,8,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(320,32,'Export Membership','9','Export Membership',NULL,0,0,9,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(321,32,'Export Participant','10','Export Participant',NULL,0,0,10,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(322,32,'Export Pledge','11','Export Pledge',NULL,0,0,11,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(323,32,'Export Case','12','Export Case',NULL,0,0,12,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(324,32,'Export Grant','13','Export Grant',NULL,0,0,13,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(325,32,'Export Activity','14','Export Activity',NULL,0,0,14,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(326,34,'day','day','day',NULL,0,NULL,1,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(327,34,'week','week','week',NULL,0,NULL,2,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(328,34,'month','month','month',NULL,0,NULL,3,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(329,34,'year','year','year',NULL,0,NULL,4,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(330,35,'Phone','1','Phone',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(331,35,'Mobile','2','Mobile',NULL,0,NULL,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(332,35,'Fax','3','Fax',NULL,0,NULL,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(333,35,'Pager','4','Pager',NULL,0,NULL,4,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(334,35,'Voicemail','5','Voicemail',NULL,0,NULL,5,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(335,36,'Participant Role','1','ParticipantRole',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(336,36,'Participant Event Name','2','ParticipantEventName',NULL,0,NULL,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(337,36,'Participant Event Type','3','ParticipantEventType',NULL,0,NULL,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(338,37,'Public','1','public',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(339,37,'Admin','2','admin',NULL,0,NULL,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(340,38,'IMAP','1','IMAP',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(341,38,'Maildir','2','Maildir',NULL,0,NULL,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(342,38,'POP3','3','POP3',NULL,0,NULL,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(343,38,'Localdir','4','Localdir',NULL,0,NULL,4,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(344,39,'Urgent','1','Urgent',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(345,39,'Normal','2','Normal',NULL,0,NULL,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(346,39,'Low','3','Low',NULL,0,NULL,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(347,40,'Vancouver','city_','city_',NULL,0,NULL,1,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(348,40,'/(19|20)(\\d{2})-(\\d{1,2})-(\\d{1,2})/','date_','date_',NULL,1,NULL,2,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(349,42,'Dear {contact.first_name}','1','Dear {contact.first_name}',NULL,1,1,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(350,42,'Dear {contact.individual_prefix} {contact.first_name} {contact.last_name}','2','Dear {contact.individual_prefix} {contact.first_name} {contact.last_name}',NULL,1,0,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(351,42,'Dear {contact.individual_prefix} {contact.last_name}','3','Dear {contact.individual_prefix} {contact.last_name}',NULL,1,0,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(352,42,'Customized','4','Customized',NULL,0,0,4,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(353,42,'Dear {contact.household_name}','5','Dear {contact.household_name}',NULL,2,1,5,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(354,43,'Dear {contact.first_name}','1','Dear {contact.first_name}',NULL,1,1,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(355,43,'Dear {contact.individual_prefix} {contact.first_name} {contact.last_name}','2','Dear {contact.individual_prefix} {contact.first_name} {contact.last_name}',NULL,1,0,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(356,43,'Dear {contact.individual_prefix} {contact.last_name}','3','Dear {contact.individual_prefix} {contact.last_name}',NULL,1,0,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(357,43,'Customized','4','Customized',NULL,0,0,4,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(358,43,'Dear {contact.household_name}','5','Dear {contact.household_name}',NULL,2,1,5,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(359,44,'{contact.individual_prefix}{ } {contact.first_name}{ }{contact.middle_name}{ }{contact.last_name}{ }{contact.individual_suffix}','1','}{contact.individual_prefix}{ } {contact.first_name}{ }{contact.middle_name}{ }{contact.last_name}{ }{contact.individual_suffix}',NULL,1,1,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(360,44,'{contact.household_name}','2','{contact.household_name}',NULL,2,1,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(361,44,'{contact.organization_name}','3','{contact.organization_name}',NULL,3,1,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(362,44,'Customized','4','Customized',NULL,0,0,4,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(363,47,'Work','1','Work',NULL,0,1,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(364,47,'Main','2','Main',NULL,0,NULL,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(365,47,'Facebook','3','Facebook',NULL,0,NULL,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(366,47,'Google+','4','Google_',NULL,0,NULL,4,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(367,47,'Instagram','5','Instagram',NULL,0,NULL,5,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(368,47,'LinkedIn','6','LinkedIn',NULL,0,NULL,6,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(369,47,'MySpace','7','MySpace',NULL,0,NULL,7,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(370,47,'Pinterest','8','Pinterest',NULL,0,NULL,8,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(371,47,'SnapChat','9','SnapChat',NULL,0,NULL,9,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(372,47,'Tumblr','10','Tumblr',NULL,0,NULL,10,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(373,47,'Twitter','11','Twitter',NULL,0,NULL,11,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(374,47,'Vine','12','Vine ',NULL,0,NULL,12,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(375,48,'Contacts','civicrm_contact','Contacts',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(376,48,'Activities','civicrm_activity','Activities',NULL,0,NULL,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(377,48,'Cases','civicrm_case','Cases',NULL,0,NULL,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(378,48,'Attachments','civicrm_file','Attachements',NULL,0,NULL,4,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(379,49,'USD ($)','USD','USD',NULL,0,1,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(380,50,'Name Only','1','CRM_Event_Badge_Simple',NULL,0,0,1,'Simple Event Name Badge',0,1,1,NULL,NULL,NULL,NULL,NULL),(381,50,'Name Tent','2','CRM_Event_Badge_NameTent',NULL,0,0,2,'Name Tent',0,1,1,NULL,NULL,NULL,NULL,NULL),(382,50,'With Logo','3','CRM_Event_Badge_Logo',NULL,0,0,3,'You can set your own background image',0,1,1,NULL,NULL,NULL,NULL,NULL),(383,50,'5395 with Logo','4','CRM_Event_Badge_Logo5395',NULL,0,0,4,'Avery 5395 compatible labels with logo (4 up by 2, 59.2mm x 85.7mm)',0,1,1,NULL,NULL,NULL,NULL,NULL),(384,51,'None','0','None',NULL,0,1,1,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(385,51,'Author Only','1','Author Only',NULL,0,0,2,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(386,52,'Direct Mail','1','Direct Mail',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(387,52,'Referral Program','2','Referral Program',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(388,52,'Constituent Engagement','3','Constituent Engagement',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(389,53,'Planned','1','Planned',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(390,53,'In Progress','2','In Progress',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(391,53,'Completed','3','Completed',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(392,53,'Cancelled','4','Cancelled',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(393,56,'1','1','1',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(394,56,'2','2','2',NULL,0,NULL,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(395,56,'3','3','3',NULL,0,NULL,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(396,56,'4','4','4',NULL,0,NULL,4,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(397,56,'5','5','5',NULL,0,NULL,5,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(398,58,'Letter','{\"metric\":\"in\",\"width\":8.5,\"height\":11}','letter',NULL,NULL,1,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(399,58,'Legal','{\"metric\":\"in\",\"width\":8.5,\"height\":14}','legal',NULL,NULL,0,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(400,58,'Ledger','{\"metric\":\"in\",\"width\":17,\"height\":11}','ledger',NULL,NULL,0,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(401,58,'Tabloid','{\"metric\":\"in\",\"width\":11,\"height\":17}','tabloid',NULL,NULL,0,4,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(402,58,'Executive','{\"metric\":\"in\",\"width\":7.25,\"height\":10.5}','executive',NULL,NULL,0,5,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(403,58,'Folio','{\"metric\":\"in\",\"width\":8.5,\"height\":13}','folio',NULL,NULL,0,6,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(404,58,'Envelope #9','{\"metric\":\"pt\",\"width\":638.93,\"height\":278.93}','envelope-9',NULL,NULL,0,7,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(405,58,'Envelope #10','{\"metric\":\"pt\",\"width\":684,\"height\":297}','envelope-10',NULL,NULL,0,8,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(406,58,'Envelope #11','{\"metric\":\"pt\",\"width\":747,\"height\":324}','envelope-11',NULL,NULL,0,9,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(407,58,'Envelope #12','{\"metric\":\"pt\",\"width\":792,\"height\":342}','envelope-12',NULL,NULL,0,10,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(408,58,'Envelope #14','{\"metric\":\"pt\",\"width\":828,\"height\":360}','envelope-14',NULL,NULL,0,11,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(409,58,'Envelope ISO B4','{\"metric\":\"pt\",\"width\":1000.63,\"height\":708.66}','envelope-b4',NULL,NULL,0,12,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(410,58,'Envelope ISO B5','{\"metric\":\"pt\",\"width\":708.66,\"height\":498.9}','envelope-b5',NULL,NULL,0,13,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(411,58,'Envelope ISO B6','{\"metric\":\"pt\",\"width\":498.9,\"height\":354.33}','envelope-b6',NULL,NULL,0,14,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(412,58,'Envelope ISO C3','{\"metric\":\"pt\",\"width\":1298.27,\"height\":918.42}','envelope-c3',NULL,NULL,0,15,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(413,58,'Envelope ISO C4','{\"metric\":\"pt\",\"width\":918.42,\"height\":649.13}','envelope-c4',NULL,NULL,0,16,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(414,58,'Envelope ISO C5','{\"metric\":\"pt\",\"width\":649.13,\"height\":459.21}','envelope-c5',NULL,NULL,0,17,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(415,58,'Envelope ISO C6','{\"metric\":\"pt\",\"width\":459.21,\"height\":323.15}','envelope-c6',NULL,NULL,0,18,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(416,58,'Envelope ISO DL','{\"metric\":\"pt\",\"width\":623.622,\"height\":311.811}','envelope-dl',NULL,NULL,0,19,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(417,58,'ISO A0','{\"metric\":\"pt\",\"width\":2383.94,\"height\":3370.39}','a0',NULL,NULL,0,20,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(418,58,'ISO A1','{\"metric\":\"pt\",\"width\":1683.78,\"height\":2383.94}','a1',NULL,NULL,0,21,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(419,58,'ISO A2','{\"metric\":\"pt\",\"width\":1190.55,\"height\":1683.78}','a2',NULL,NULL,0,22,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(420,58,'ISO A3','{\"metric\":\"pt\",\"width\":841.89,\"height\":1190.55}','a3',NULL,NULL,0,23,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(421,58,'ISO A4','{\"metric\":\"pt\",\"width\":595.28,\"height\":841.89}','a4',NULL,NULL,0,24,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(422,58,'ISO A5','{\"metric\":\"pt\",\"width\":419.53,\"height\":595.28}','a5',NULL,NULL,0,25,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(423,58,'ISO A6','{\"metric\":\"pt\",\"width\":297.64,\"height\":419.53}','a6',NULL,NULL,0,26,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(424,58,'ISO A7','{\"metric\":\"pt\",\"width\":209.76,\"height\":297.64}','a7',NULL,NULL,0,27,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(425,58,'ISO A8','{\"metric\":\"pt\",\"width\":147.4,\"height\":209.76}','a8',NULL,NULL,0,28,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(426,58,'ISO A9','{\"metric\":\"pt\",\"width\":104.88,\"height\":147.4}','a9',NULL,NULL,0,29,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(427,58,'ISO A10','{\"metric\":\"pt\",\"width\":73.7,\"height\":104.88}','a10',NULL,NULL,0,30,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(428,58,'ISO B0','{\"metric\":\"pt\",\"width\":2834.65,\"height\":4008.19}','b0',NULL,NULL,0,31,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(429,58,'ISO B1','{\"metric\":\"pt\",\"width\":2004.09,\"height\":2834.65}','b1',NULL,NULL,0,32,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(430,58,'ISO B2','{\"metric\":\"pt\",\"width\":1417.32,\"height\":2004.09}','b2',NULL,NULL,0,33,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(431,58,'ISO B3','{\"metric\":\"pt\",\"width\":1000.63,\"height\":1417.32}','b3',NULL,NULL,0,34,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(432,58,'ISO B4','{\"metric\":\"pt\",\"width\":708.66,\"height\":1000.63}','b4',NULL,NULL,0,35,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(433,58,'ISO B5','{\"metric\":\"pt\",\"width\":498.9,\"height\":708.66}','b5',NULL,NULL,0,36,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(434,58,'ISO B6','{\"metric\":\"pt\",\"width\":354.33,\"height\":498.9}','b6',NULL,NULL,0,37,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(435,58,'ISO B7','{\"metric\":\"pt\",\"width\":249.45,\"height\":354.33}','b7',NULL,NULL,0,38,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(436,58,'ISO B8','{\"metric\":\"pt\",\"width\":175.75,\"height\":249.45}','b8',NULL,NULL,0,39,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(437,58,'ISO B9','{\"metric\":\"pt\",\"width\":124.72,\"height\":175.75}','b9',NULL,NULL,0,40,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(438,58,'ISO B10','{\"metric\":\"pt\",\"width\":87.87,\"height\":124.72}','b10',NULL,NULL,0,41,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(439,58,'ISO C0','{\"metric\":\"pt\",\"width\":2599.37,\"height\":3676.54}','c0',NULL,NULL,0,42,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(440,58,'ISO C1','{\"metric\":\"pt\",\"width\":1836.85,\"height\":2599.37}','c1',NULL,NULL,0,43,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(441,58,'ISO C2','{\"metric\":\"pt\",\"width\":1298.27,\"height\":1836.85}','c2',NULL,NULL,0,44,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(442,58,'ISO C3','{\"metric\":\"pt\",\"width\":918.43,\"height\":1298.27}','c3',NULL,NULL,0,45,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(443,58,'ISO C4','{\"metric\":\"pt\",\"width\":649.13,\"height\":918.43}','c4',NULL,NULL,0,46,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(444,58,'ISO C5','{\"metric\":\"pt\",\"width\":459.21,\"height\":649.13}','c5',NULL,NULL,0,47,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(445,58,'ISO C6','{\"metric\":\"pt\",\"width\":323.15,\"height\":459.21}','c6',NULL,NULL,0,48,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(446,58,'ISO C7','{\"metric\":\"pt\",\"width\":229.61,\"height\":323.15}','c7',NULL,NULL,0,49,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(447,58,'ISO C8','{\"metric\":\"pt\",\"width\":161.57,\"height\":229.61}','c8',NULL,NULL,0,50,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(448,58,'ISO C9','{\"metric\":\"pt\",\"width\":113.39,\"height\":161.57}','c9',NULL,NULL,0,51,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(449,58,'ISO C10','{\"metric\":\"pt\",\"width\":79.37,\"height\":113.39}','c10',NULL,NULL,0,52,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(450,58,'ISO RA0','{\"metric\":\"pt\",\"width\":2437.8,\"height\":3458.27}','ra0',NULL,NULL,0,53,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(451,58,'ISO RA1','{\"metric\":\"pt\",\"width\":1729.13,\"height\":2437.8}','ra1',NULL,NULL,0,54,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(452,58,'ISO RA2','{\"metric\":\"pt\",\"width\":1218.9,\"height\":1729.13}','ra2',NULL,NULL,0,55,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(453,58,'ISO RA3','{\"metric\":\"pt\",\"width\":864.57,\"height\":1218.9}','ra3',NULL,NULL,0,56,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(454,58,'ISO RA4','{\"metric\":\"pt\",\"width\":609.45,\"height\":864.57}','ra4',NULL,NULL,0,57,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(455,58,'ISO SRA0','{\"metric\":\"pt\",\"width\":2551.18,\"height\":3628.35}','sra0',NULL,NULL,0,58,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(456,58,'ISO SRA1','{\"metric\":\"pt\",\"width\":1814.17,\"height\":2551.18}','sra1',NULL,NULL,0,59,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(457,58,'ISO SRA2','{\"metric\":\"pt\",\"width\":1275.59,\"height\":1814.17}','sra2',NULL,NULL,0,60,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(458,58,'ISO SRA3','{\"metric\":\"pt\",\"width\":907.09,\"height\":1275.59}','sra3',NULL,NULL,0,61,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(459,58,'ISO SRA4','{\"metric\":\"pt\",\"width\":637.8,\"height\":907.09}','sra4',NULL,NULL,0,62,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(460,61,'Activity Assignees','1','Activity Assignees',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(461,61,'Activity Source','2','Activity Source',NULL,0,NULL,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(462,61,'Activity Targets','3','Activity Targets',NULL,0,NULL,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(463,71,'Asset','1','Asset',NULL,0,0,1,'Things you own',0,1,1,2,NULL,NULL,NULL,NULL),(464,71,'Liability','2','Liability',NULL,0,0,2,'Things you owe, like a grant still to be disbursed',0,1,1,2,NULL,NULL,NULL,NULL),(465,71,'Revenue','3','Revenue',NULL,0,1,3,'Income from contributions and sales of tickets and memberships',0,1,1,2,NULL,NULL,NULL,NULL),(466,71,'Cost of Sales','4','Cost of Sales',NULL,0,0,4,'Costs incurred to get revenue, e.g. premiums for donations, dinner for a fundraising dinner ticket',0,1,1,2,NULL,NULL,NULL,NULL),(467,71,'Expenses','5','Expenses',NULL,0,0,5,'Things that are paid for that are consumable, e.g. grants disbursed',0,1,1,2,NULL,NULL,NULL,NULL),(468,62,'Income Account is','1','Income Account is',NULL,0,1,1,'Income Account is',0,1,1,2,NULL,NULL,NULL,NULL),(469,62,'Credit/Contra Revenue Account is','2','Credit/Contra Revenue Account is',NULL,0,0,2,'Credit/Contra Revenue Account is',0,1,1,2,NULL,NULL,NULL,NULL),(470,62,'Accounts Receivable Account is','3','Accounts Receivable Account is',NULL,0,0,3,'Accounts Receivable Account is',0,1,1,2,NULL,NULL,NULL,NULL),(471,62,'Credit Liability Account is','4','Credit Liability Account is',NULL,0,0,4,'Credit Liability Account is',0,1,0,2,NULL,NULL,NULL,NULL),(472,62,'Expense Account is','5','Expense Account is',NULL,0,0,5,'Expense Account is',0,1,1,2,NULL,NULL,NULL,NULL),(473,62,'Asset Account is','6','Asset Account is',NULL,0,0,6,'Asset Account is',0,1,1,2,NULL,NULL,NULL,NULL),(474,62,'Cost of Sales Account is','7','Cost of Sales Account is',NULL,0,0,7,'Cost of Sales Account is',0,1,1,2,NULL,NULL,NULL,NULL),(475,62,'Premiums Inventory Account is','8','Premiums Inventory Account is',NULL,0,0,8,'Premiums Inventory Account is',0,1,1,2,NULL,NULL,NULL,NULL),(476,62,'Discounts Account is','9','Discounts Account is',NULL,0,0,9,'Discounts Account is',0,1,1,2,NULL,NULL,NULL,NULL),(477,62,'Sales Tax Account is','10','Sales Tax Account is',NULL,0,0,10,'Sales Tax Account is',0,1,1,2,NULL,NULL,NULL,NULL),(478,62,'Chargeback Account is','11','Chargeback Account is',NULL,0,0,11,'Chargeback Account is',0,1,1,2,NULL,NULL,NULL,NULL),(479,62,'Deferred Revenue Account is','12','Deferred Revenue Account is',NULL,0,0,12,'Deferred Revenue Account is',0,1,1,2,NULL,NULL,NULL,NULL),(480,63,'Participant Role','1','participant_role',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(481,64,'Morning Sessions','1','Morning Sessions',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(482,64,'Evening Sessions','2','Evening Sessions',NULL,0,NULL,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(483,65,'Contribution','1','Contribution',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(484,65,'Membership','2','Membership',NULL,0,NULL,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(485,65,'Pledge Payment','3','Pledge Payment',NULL,0,NULL,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(486,67,'Open','1','Open',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(487,67,'Closed','2','Closed',NULL,0,NULL,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(488,67,'Data Entry','3','Data Entry',NULL,0,NULL,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(489,67,'Reopened','4','Reopened',NULL,0,NULL,4,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(490,67,'Exported','5','Exported',NULL,0,NULL,5,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(491,66,'Manual Batch','1','Manual Batch',NULL,0,0,1,'Manual Batch',0,1,1,2,NULL,NULL,NULL,NULL),(492,66,'Automatic Batch','2','Automatic Batch',NULL,0,0,2,'Automatic Batch',0,1,1,2,NULL,NULL,NULL,NULL),(493,72,'Paid','1','Paid',NULL,0,0,1,'Paid',0,1,1,2,NULL,NULL,NULL,NULL),(494,72,'Partially paid','2','Partially paid',NULL,0,0,2,'Partially paid',0,1,1,2,NULL,NULL,NULL,NULL),(495,72,'Unpaid','3','Unpaid',NULL,0,0,1,'Unpaid',0,1,1,2,NULL,NULL,NULL,NULL),(496,68,'http','1','http',NULL,NULL,0,1,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(497,68,'xml','2','xml',NULL,NULL,0,2,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(498,68,'smtp','3','smtp',NULL,NULL,0,3,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(499,70,'Renewal Reminder (non-auto-renew memberships only)','1','Renewal Reminder (non-auto-renew memberships only)',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(500,70,'Auto-renew Memberships Only','2','Auto-renew Memberships Only',NULL,0,NULL,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(501,70,'Reminder for Both','3','Reminder for Both',NULL,0,NULL,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(502,73,'Event Badge','1','Event Badge',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(503,74,'Avery 5395','{\"name\":\"Avery 5395\",\"paper-size\":\"a4\",\"metric\":\"mm\",\"lMargin\":15,\"tMargin\":26,\"NX\":2,\"NY\":4,\"SpaceX\":10,\"SpaceY\":5,\"width\":83,\"height\":57,\"font-size\":12,\"orientation\":\"portrait\",\"font-name\":\"helvetica\",\"font-style\":\"\",\"lPadding\":3,\"tPadding\":3}','Avery 5395',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(504,74,'A6 Badge Portrait 150x106','{\"paper-size\":\"a4\",\"orientation\":\"landscape\",\"font-name\":\"times\",\"font-size\":6,\"font-style\":\"\",\"NX\":2,\"NY\":1,\"metric\":\"mm\",\"lMargin\":25,\"tMargin\":27,\"SpaceX\":0,\"SpaceY\":35,\"width\":106,\"height\":150,\"lPadding\":5,\"tPadding\":5}','A6 Badge Portrait 150x106',NULL,0,NULL,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(505,74,'Fattorini Name Badge 100x65','{\"paper-size\":\"a4\",\"orientation\":\"portrait\",\"font-name\":\"times\",\"font-size\":6,\"font-style\":\"\",\"NX\":2,\"NY\":4,\"metric\":\"mm\",\"lMargin\":6,\"tMargin\":19,\"SpaceX\":0,\"SpaceY\":0,\"width\":100,\"height\":65,\"lPadding\":0,\"tPadding\":0}','Fattorini Name Badge 100x65',NULL,0,NULL,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(506,74,'Hanging Badge 3-3/4\" x 4-3\"/4','{\"paper-size\":\"a4\",\"orientation\":\"portrait\",\"font-name\":\"times\",\"font-size\":6,\"font-style\":\"\",\"NX\":2,\"NY\":2,\"metric\":\"mm\",\"lMargin\":10,\"tMargin\":28,\"SpaceX\":0,\"SpaceY\":0,\"width\":96,\"height\":121,\"lPadding\":5,\"tPadding\":5}','Hanging Badge 3-3/4\" x 4-3\"/4',NULL,0,NULL,4,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(507,60,'Avery 3475','{\"paper-size\":\"a4\",\"orientation\":\"portrait\",\"font-name\":\"helvetica\",\"font-size\":10,\"font-style\":\"\",\"metric\":\"mm\",\"lMargin\":0,\"tMargin\":5,\"NX\":3,\"NY\":8,\"SpaceX\":0,\"SpaceY\":0,\"width\":70,\"height\":36,\"lPadding\":5.08,\"tPadding\":5.08}','3475','Avery',NULL,0,1,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(508,60,'Avery 5160','{\"paper-size\":\"letter\",\"orientation\":\"portrait\",\"font-name\":\"helvetica\",\"font-size\":8,\"font-style\":\"\",\"metric\":\"in\",\"lMargin\":0.21975,\"tMargin\":0.5,\"NX\":3,\"NY\":10,\"SpaceX\":0.14,\"SpaceY\":0,\"width\":2.5935,\"height\":1,\"lPadding\":0.20,\"tPadding\":0.20}','5160','Avery',NULL,0,2,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(509,60,'Avery 5161','{\"paper-size\":\"letter\",\"orientation\":\"portrait\",\"font-name\":\"helvetica\",\"font-size\":8,\"font-style\":\"\",\"metric\":\"in\",\"lMargin\":0.175,\"tMargin\":0.5,\"NX\":2,\"NY\":10,\"SpaceX\":0.15625,\"SpaceY\":0,\"width\":4,\"height\":1,\"lPadding\":0.20,\"tPadding\":0.20}','5161','Avery',NULL,0,3,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(510,60,'Avery 5162','{\"paper-size\":\"letter\",\"orientation\":\"portrait\",\"font-name\":\"helvetica\",\"font-size\":8,\"font-style\":\"\",\"metric\":\"in\",\"lMargin\":0.1525,\"tMargin\":0.88,\"NX\":2,\"NY\":7,\"SpaceX\":0.195,\"SpaceY\":0,\"width\":4,\"height\":1.33,\"lPadding\":0.20,\"tPadding\":0.20}','5162','Avery',NULL,0,4,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(511,60,'Avery 5163','{\"paper-size\":\"letter\",\"orientation\":\"portrait\",\"font-name\":\"helvetica\",\"font-size\":8,\"font-style\":\"\",\"metric\":\"in\",\"lMargin\":0.18,\"tMargin\":0.5,\"NX\":2,\"NY\":5,\"SpaceX\":0.14,\"SpaceY\":0,\"width\":4,\"height\":2,\"lPadding\":0.20,\"tPadding\":0.20}','5163','Avery',NULL,0,5,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(512,60,'Avery 5164','{\"paper-size\":\"letter\",\"orientation\":\"portrait\",\"font-name\":\"helvetica\",\"font-size\":12,\"font-style\":\"\",\"metric\":\"in\",\"lMargin\":0.156,\"tMargin\":0.5,\"NX\":2,\"NY\":3,\"SpaceX\":0.1875,\"SpaceY\":0,\"width\":4,\"height\":3.33,\"lPadding\":0.20,\"tPadding\":0.20}','5164','Avery',NULL,0,6,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(513,60,'Avery 8600','{\"paper-size\":\"letter\",\"orientation\":\"portrait\",\"font-name\":\"helvetica\",\"font-size\":8,\"font-style\":\"\",\"metric\":\"mm\",\"lMargin\":7.1,\"tMargin\":19,\"NX\":3,\"NY\":10,\"SpaceX\":9.5,\"SpaceY\":3.1,\"width\":66.6,\"height\":25.4,\"lPadding\":5.08,\"tPadding\":5.08}','8600','Avery',NULL,0,7,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(514,60,'Avery L7160','{\"paper-size\":\"a4\",\"orientation\":\"portrait\",\"font-name\":\"helvetica\",\"font-size\":9,\"font-style\":\"\",\"metric\":\"in\",\"lMargin\":0.28,\"tMargin\":0.6,\"NX\":3,\"NY\":7,\"SpaceX\":0.1,\"SpaceY\":0,\"width\":2.5,\"height\":1.5,\"lPadding\":0.20,\"tPadding\":0.20}','L7160','Avery',NULL,0,8,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(515,60,'Avery L7161','{\"paper-size\":\"a4\",\"orientation\":\"portrait\",\"font-name\":\"helvetica\",\"font-size\":9,\"font-style\":\"\",\"metric\":\"in\",\"lMargin\":0.28,\"tMargin\":0.35,\"NX\":3,\"NY\":6,\"SpaceX\":0.1,\"SpaceY\":0,\"width\":2.5,\"height\":1.83,\"lPadding\":0.20,\"tPadding\":0.20}','L7161','Avery',NULL,0,9,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(516,60,'Avery L7162','{\"paper-size\":\"a4\",\"orientation\":\"portrait\",\"font-name\":\"helvetica\",\"font-size\":9,\"font-style\":\"\",\"metric\":\"in\",\"lMargin\":0.18,\"tMargin\":0.51,\"NX\":2,\"NY\":8,\"SpaceX\":0.1,\"SpaceY\":0,\"width\":3.9,\"height\":1.33,\"lPadding\":0.20,\"tPadding\":0.20}','L7162','Avery',NULL,0,10,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(517,60,'Avery L7163','{\"paper-size\":\"a4\",\"orientation\":\"portrait\",\"font-name\":\"helvetica\",\"font-size\":9,\"font-style\":\"\",\"metric\":\"in\",\"lMargin\":0.18,\"tMargin\":0.6,\"NX\":2,\"NY\":7,\"SpaceX\":0.1,\"SpaceY\":0,\"width\":3.9,\"height\":1.5,\"lPadding\":0.20,\"tPadding\":0.20}','L7163','Avery',NULL,0,11,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(518,75,'Formal','1','formal',NULL,0,1,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(519,75,'Familiar','2','familiar',NULL,0,0,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(520,76,'Email','Email','Email',NULL,0,1,1,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(521,76,'SMS','SMS','SMS',NULL,0,0,2,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(522,76,'User Preference','User_Preference','User Preference',NULL,0,0,3,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(523,77,'Actual date only','1','Actual date only',NULL,NULL,0,1,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(524,77,'Each anniversary','2','Each anniversary',NULL,NULL,0,2,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(525,78,'Default','1','default',NULL,NULL,1,1,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(526,78,'CiviMail','2','civimail',NULL,NULL,0,2,NULL,0,1,1,4,NULL,NULL,NULL,NULL),(527,78,'CiviEvent','3','civievent',NULL,NULL,0,3,NULL,0,1,1,1,NULL,NULL,NULL,NULL),(528,81,'Production','Production','Production',NULL,NULL,1,1,'Production Environment',0,1,1,NULL,NULL,NULL,NULL,NULL),(529,81,'Staging','Staging','Staging',NULL,NULL,0,2,'Staging Environment',0,1,1,NULL,NULL,NULL,NULL,NULL),(530,81,'Development','Development','Development',NULL,NULL,0,3,'Development Environment',0,1,1,NULL,NULL,NULL,NULL,NULL),(531,79,'Today','this.day','this.day',NULL,NULL,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(532,79,'This week','this.week','this.week',NULL,NULL,NULL,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(533,79,'This calendar month','this.month','this.month',NULL,NULL,NULL,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(534,79,'This quarter','this.quarter','this.quarter',NULL,NULL,NULL,4,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(535,79,'This fiscal year','this.fiscal_year','this.fiscal_year',NULL,NULL,NULL,5,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(536,79,'This calendar year','this.year','this.year',NULL,NULL,NULL,6,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(537,79,'Yesterday','previous.day','previous.day',NULL,NULL,NULL,7,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(538,79,'Previous week','previous.week','previous.week',NULL,NULL,NULL,8,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(539,79,'Previous calendar month','previous.month','previous.month',NULL,NULL,NULL,9,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(540,79,'Previous quarter','previous.quarter','previous.quarter',NULL,NULL,NULL,10,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(541,79,'Previous fiscal year','previous.fiscal_year','previous.fiscal_year',NULL,NULL,NULL,11,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(542,79,'Previous calendar year','previous.year','previous.year',NULL,NULL,NULL,12,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(543,79,'Last 7 days including today','ending.week','ending.week',NULL,NULL,NULL,13,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(544,79,'Last 30 days including today','ending_30.day','ending.month',NULL,NULL,NULL,14,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(545,79,'Last 60 days including today','ending_60.day','ending_2.month',NULL,NULL,NULL,15,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(546,79,'Last 90 days including today','ending_90.day','ending.quarter',NULL,NULL,NULL,16,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(547,79,'Last 12 months including today','ending.year','ending.year',NULL,NULL,NULL,17,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(548,79,'Last 2 years including today','ending_2.year','ending_2.year',NULL,NULL,NULL,18,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(549,79,'Last 3 years including today','ending_3.year','ending_3.year',NULL,NULL,NULL,19,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(550,79,'Tomorrow','starting.day','starting.day',NULL,NULL,NULL,20,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(551,79,'Next week','next.week','next.week',NULL,NULL,NULL,21,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(552,79,'Next calendar month','next.month','next.month',NULL,NULL,NULL,22,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(553,79,'Next quarter','next.quarter','next.quarter',NULL,NULL,NULL,23,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(554,79,'Next fiscal year','next.fiscal_year','next.fiscal_year',NULL,NULL,NULL,24,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(555,79,'Next calendar year','next.year','next.year',NULL,NULL,NULL,25,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(556,79,'Next 7 days including today','starting.week','starting.week',NULL,NULL,NULL,26,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(557,79,'Next 30 days including today','starting.month','starting.month',NULL,NULL,NULL,27,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(558,79,'Next 60 days including today','starting_2.month','starting_2.month',NULL,NULL,NULL,28,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(559,79,'Next 90 days including today','starting.quarter','starting.quarter',NULL,NULL,NULL,29,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(560,79,'Next 12 months including today','starting.year','starting.year',NULL,NULL,NULL,30,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(561,79,'Current week to-date','current.week','current.week',NULL,NULL,NULL,31,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(562,79,'Current calendar month to-date','current.month','current.month',NULL,NULL,NULL,32,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(563,79,'Current quarter to-date','current.quarter','current.quarter',NULL,NULL,NULL,33,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(564,79,'Current calendar year to-date','current.year','current.year',NULL,NULL,NULL,34,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(565,79,'To end of yesterday','earlier.day','earlier.day',NULL,NULL,NULL,35,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(566,79,'To end of previous week','earlier.week','earlier.week',NULL,NULL,NULL,36,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(567,79,'To end of previous calendar month','earlier.month','earlier.month',NULL,NULL,NULL,37,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(568,79,'To end of previous quarter','earlier.quarter','earlier.quarter',NULL,NULL,NULL,38,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(569,79,'To end of previous calendar year','earlier.year','earlier.year',NULL,NULL,NULL,39,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(570,79,'From start of current day','greater.day','greater.day',NULL,NULL,NULL,40,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(571,79,'From start of current week','greater.week','greater.week',NULL,NULL,NULL,41,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(572,79,'From start of current calendar month','greater.month','greater.month',NULL,NULL,NULL,42,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(573,79,'From start of current quarter','greater.quarter','greater.quarter',NULL,NULL,NULL,43,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(574,79,'From start of current calendar year','greater.year','greater.year',NULL,NULL,NULL,44,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(575,79,'To end of current week','less.week','less.week',NULL,NULL,NULL,45,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(576,79,'To end of current calendar month','less.month','less.month',NULL,NULL,NULL,46,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(577,79,'To end of current quarter','less.quarter','less.quarter',NULL,NULL,NULL,47,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(578,79,'To end of current calendar year','less.year','less.year',NULL,NULL,NULL,48,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(579,79,'Previous 2 days','previous_2.day','previous_2.day',NULL,NULL,NULL,49,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(580,79,'Previous 2 weeks','previous_2.week','previous_2.week',NULL,NULL,NULL,50,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(581,79,'Previous 2 calendar months','previous_2.month','previous_2.month',NULL,NULL,NULL,51,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(582,79,'Previous 2 quarters','previous_2.quarter','previous_2.quarter',NULL,NULL,NULL,52,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(583,79,'Previous 2 calendar years','previous_2.year','previous_2.year',NULL,NULL,NULL,53,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(584,79,'Day prior to yesterday','previous_before.day','previous_before.day',NULL,NULL,NULL,54,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(585,79,'Week prior to previous week','previous_before.week','previous_before.week',NULL,NULL,NULL,55,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(586,79,'Month prior to previous calendar month','previous_before.month','previous_before.month',NULL,NULL,NULL,56,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(587,79,'Quarter prior to previous quarter','previous_before.quarter','previous_before.quarter',NULL,NULL,NULL,57,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(588,79,'Year prior to previous calendar year','previous_before.year','previous_before.year',NULL,NULL,NULL,58,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(589,79,'From end of previous week','greater_previous.week','greater_previous.week',NULL,NULL,NULL,59,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(590,79,'From end of previous calendar month','greater_previous.month','greater_previous.month',NULL,NULL,NULL,60,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(591,79,'From end of previous quarter','greater_previous.quarter','greater_previous.quarter',NULL,NULL,NULL,61,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(592,79,'From end of previous calendar year','greater_previous.year','greater_previous.year',NULL,NULL,NULL,62,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(593,80,'Completed','1','Completed',NULL,0,NULL,1,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(594,80,'Pending','2','Pending',NULL,0,NULL,2,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(595,80,'Cancelled','3','Cancelled',NULL,0,NULL,3,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(596,80,'In Progress','5','In Progress',NULL,0,NULL,4,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(597,80,'Overdue','6','Overdue',NULL,0,NULL,5,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(598,82,'None','1','NONE',NULL,0,1,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(599,82,'By relationship to case client','2','BY_RELATIONSHIP',NULL,0,0,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(600,82,'Specific contact','3','SPECIFIC_CONTACT',NULL,0,0,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(601,82,'User creating the case','4','USER_CREATING_THE_CASE',NULL,0,0,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(602,31,'\"FIXME\" <info@EXAMPLE.ORG>','1','\"FIXME\" <info@EXAMPLE.ORG>',NULL,0,1,1,'Default domain email address and from name.',0,0,1,NULL,1,NULL,NULL,NULL),(603,24,'Emergency','1','Emergency',NULL,0,1,1,NULL,0,0,1,NULL,1,NULL,NULL,NULL),(604,24,'Family Support','2','Family Support',NULL,0,NULL,2,NULL,0,0,1,NULL,1,NULL,NULL,NULL),(605,24,'General Protection','3','General Protection',NULL,0,NULL,3,NULL,0,0,1,NULL,1,NULL,NULL,NULL),(606,24,'Impunity','4','Impunity',NULL,0,NULL,4,NULL,0,0,1,NULL,1,NULL,NULL,NULL),(607,55,'Approved','1','Approved',NULL,0,1,1,NULL,0,1,1,4,1,NULL,NULL,NULL),(608,55,'Rejected','2','Rejected',NULL,0,0,2,NULL,0,1,1,4,1,NULL,NULL,NULL),(609,55,'None','3','None',NULL,0,0,3,NULL,0,1,1,4,1,NULL,NULL,NULL),(610,57,'Survey','Survey','civicrm_survey',NULL,0,NULL,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(611,57,'Cases','Case','civicrm_case',NULL,0,NULL,2,'CRM_Case_PseudoConstant::caseType;',0,0,1,NULL,NULL,NULL,NULL,NULL),(612,83,'Abkhaz','ab','ab_GE',NULL,NULL,0,1,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(613,83,'Afar','aa','aa_ET',NULL,NULL,0,2,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(614,83,'Afrikaans','af','af_ZA',NULL,NULL,0,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(615,83,'Akan','ak','ak_GH',NULL,NULL,0,4,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(616,83,'Albanian','sq','sq_AL',NULL,NULL,0,5,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(617,83,'Amharic','am','am_ET',NULL,NULL,0,6,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(618,83,'Arabic','ar','ar_EG',NULL,NULL,0,7,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(619,83,'Aragonese','an','an_ES',NULL,NULL,0,8,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(620,83,'Armenian','hy','hy_AM',NULL,NULL,0,9,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(621,83,'Assamese','as','as_IN',NULL,NULL,0,10,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(622,83,'Avaric','av','av_RU',NULL,NULL,0,11,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(623,83,'Avestan','ae','ae_XX',NULL,NULL,0,12,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(624,83,'Aymara','ay','ay_BO',NULL,NULL,0,13,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(625,83,'Azerbaijani','az','az_AZ',NULL,NULL,0,14,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(626,83,'Bambara','bm','bm_ML',NULL,NULL,0,15,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(627,83,'Bashkir','ba','ba_RU',NULL,NULL,0,16,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(628,83,'Basque','eu','eu_ES',NULL,NULL,0,17,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(629,83,'Belarusian','be','be_BY',NULL,NULL,0,18,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(630,83,'Bengali','bn','bn_BD',NULL,NULL,0,19,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(631,83,'Bihari','bh','bh_IN',NULL,NULL,0,20,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(632,83,'Bislama','bi','bi_VU',NULL,NULL,0,21,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(633,83,'Bosnian','bs','bs_BA',NULL,NULL,0,22,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(634,83,'Breton','br','br_FR',NULL,NULL,0,23,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(635,83,'Bulgarian','bg','bg_BG',NULL,NULL,0,24,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(636,83,'Burmese','my','my_MM',NULL,NULL,0,25,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(637,83,'Catalan; Valencian','ca','ca_ES',NULL,NULL,0,26,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(638,83,'Chamorro','ch','ch_GU',NULL,NULL,0,27,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(639,83,'Chechen','ce','ce_RU',NULL,NULL,0,28,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(640,83,'Chichewa; Chewa; Nyanja','ny','ny_MW',NULL,NULL,0,29,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(641,83,'Chinese (China)','zh','zh_CN',NULL,NULL,0,30,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(642,83,'Chinese (Taiwan)','zh','zh_TW',NULL,NULL,0,31,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(643,83,'Chuvash','cv','cv_RU',NULL,NULL,0,32,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(644,83,'Cornish','kw','kw_GB',NULL,NULL,0,33,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(645,83,'Corsican','co','co_FR',NULL,NULL,0,34,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(646,83,'Cree','cr','cr_CA',NULL,NULL,0,35,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(647,83,'Croatian','hr','hr_HR',NULL,NULL,0,36,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(648,83,'Czech','cs','cs_CZ',NULL,NULL,0,37,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(649,83,'Danish','da','da_DK',NULL,NULL,0,38,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(650,83,'Divehi; Dhivehi; Maldivian;','dv','dv_MV',NULL,NULL,0,39,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(651,83,'Dutch','nl','nl_NL',NULL,NULL,0,40,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(652,83,'Dzongkha','dz','dz_BT',NULL,NULL,0,41,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(653,83,'English (Australia)','en','en_AU',NULL,NULL,0,42,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(654,83,'English (Canada)','en','en_CA',NULL,NULL,0,43,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(655,83,'English (United Kingdom)','en','en_GB',NULL,NULL,0,44,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(656,83,'English (United States)','en','en_US',NULL,NULL,1,45,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(657,83,'Esperanto','eo','eo_XX',NULL,NULL,0,46,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(658,83,'Estonian','et','et_EE',NULL,NULL,0,47,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(659,83,'Ewe','ee','ee_GH',NULL,NULL,0,48,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(660,83,'Faroese','fo','fo_FO',NULL,NULL,0,49,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(661,83,'Fijian','fj','fj_FJ',NULL,NULL,0,50,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(662,83,'Finnish','fi','fi_FI',NULL,NULL,0,51,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(663,83,'French (Canada)','fr','fr_CA',NULL,NULL,0,52,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(664,83,'French (France)','fr','fr_FR',NULL,NULL,0,53,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(665,83,'Fula; Fulah; Pulaar; Pular','ff','ff_SN',NULL,NULL,0,54,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(666,83,'Galician','gl','gl_ES',NULL,NULL,0,55,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(667,83,'Georgian','ka','ka_GE',NULL,NULL,0,56,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(668,83,'German','de','de_DE',NULL,NULL,0,57,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(669,83,'German (Swiss)','de','de_CH',NULL,NULL,0,58,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(670,83,'Greek, Modern','el','el_GR',NULL,NULL,0,59,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(671,83,'Guarani­','gn','gn_PY',NULL,NULL,0,60,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(672,83,'Gujarati','gu','gu_IN',NULL,NULL,0,61,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(673,83,'Haitian; Haitian Creole','ht','ht_HT',NULL,NULL,0,62,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(674,83,'Hausa','ha','ha_NG',NULL,NULL,0,63,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(675,83,'Hebrew (modern)','he','he_IL',NULL,NULL,0,64,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(676,83,'Herero','hz','hz_NA',NULL,NULL,0,65,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(677,83,'Hindi','hi','hi_IN',NULL,NULL,0,66,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(678,83,'Hiri Motu','ho','ho_PG',NULL,NULL,0,67,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(679,83,'Hungarian','hu','hu_HU',NULL,NULL,0,68,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(680,83,'Interlingua','ia','ia_XX',NULL,NULL,0,69,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(681,83,'Indonesian','id','id_ID',NULL,NULL,0,70,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(682,83,'Interlingue','ie','ie_XX',NULL,NULL,0,71,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(683,83,'Irish','ga','ga_IE',NULL,NULL,0,72,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(684,83,'Igbo','ig','ig_NG',NULL,NULL,0,73,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(685,83,'Inupiaq','ik','ik_US',NULL,NULL,0,74,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(686,83,'Ido','io','io_XX',NULL,NULL,0,75,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(687,83,'Icelandic','is','is_IS',NULL,NULL,0,76,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(688,83,'Italian','it','it_IT',NULL,NULL,0,77,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(689,83,'Inuktitut','iu','iu_CA',NULL,NULL,0,78,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(690,83,'Japanese','ja','ja_JP',NULL,NULL,0,79,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(691,83,'Javanese','jv','jv_ID',NULL,NULL,0,80,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(692,83,'Kalaallisut, Greenlandic','kl','kl_GL',NULL,NULL,0,81,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(693,83,'Kannada','kn','kn_IN',NULL,NULL,0,82,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(694,83,'Kanuri','kr','kr_NE',NULL,NULL,0,83,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(695,83,'Kashmiri','ks','ks_IN',NULL,NULL,0,84,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(696,83,'Kazakh','kk','kk_KZ',NULL,NULL,0,85,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(697,83,'Khmer','km','km_KH',NULL,NULL,0,86,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(698,83,'Kikuyu, Gikuyu','ki','ki_KE',NULL,NULL,0,87,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(699,83,'Kinyarwanda','rw','rw_RW',NULL,NULL,0,88,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(700,83,'Kirghiz, Kyrgyz','ky','ky_KG',NULL,NULL,0,89,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(701,83,'Komi','kv','kv_RU',NULL,NULL,0,90,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(702,83,'Kongo','kg','kg_CD',NULL,NULL,0,91,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(703,83,'Korean','ko','ko_KR',NULL,NULL,0,92,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(704,83,'Kurdish','ku','ku_IQ',NULL,NULL,0,93,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(705,83,'Kwanyama, Kuanyama','kj','kj_NA',NULL,NULL,0,94,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(706,83,'Latin','la','la_VA',NULL,NULL,0,95,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(707,83,'Luxembourgish, Letzeburgesch','lb','lb_LU',NULL,NULL,0,96,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(708,83,'Luganda','lg','lg_UG',NULL,NULL,0,97,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(709,83,'Limburgish, Limburgan, Limburger','li','li_NL',NULL,NULL,0,98,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(710,83,'Lingala','ln','ln_CD',NULL,NULL,0,99,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(711,83,'Lao','lo','lo_LA',NULL,NULL,0,100,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(712,83,'Lithuanian','lt','lt_LT',NULL,NULL,0,101,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(713,83,'Luba-Katanga','lu','lu_CD',NULL,NULL,0,102,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(714,83,'Latvian','lv','lv_LV',NULL,NULL,0,103,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(715,83,'Manx','gv','gv_IM',NULL,NULL,0,104,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(716,83,'Macedonian','mk','mk_MK',NULL,NULL,0,105,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(717,83,'Malagasy','mg','mg_MG',NULL,NULL,0,106,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(718,83,'Malay','ms','ms_MY',NULL,NULL,0,107,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(719,83,'Malayalam','ml','ml_IN',NULL,NULL,0,108,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(720,83,'Maltese','mt','mt_MT',NULL,NULL,0,109,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(721,83,'Māori','mi','mi_NZ',NULL,NULL,0,110,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(722,83,'Marathi','mr','mr_IN',NULL,NULL,0,111,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(723,83,'Marshallese','mh','mh_MH',NULL,NULL,0,112,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(724,83,'Mongolian','mn','mn_MN',NULL,NULL,0,113,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(725,83,'Nauru','na','na_NR',NULL,NULL,0,114,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(726,83,'Navajo, Navaho','nv','nv_US',NULL,NULL,0,115,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(727,83,'Norwegian BokmÃ¥l','nb','nb_NO',NULL,NULL,0,116,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(728,83,'North Ndebele','nd','nd_ZW',NULL,NULL,0,117,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(729,83,'Nepali','ne','ne_NP',NULL,NULL,0,118,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(730,83,'Ndonga','ng','ng_NA',NULL,NULL,0,119,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(731,83,'Norwegian Nynorsk','nn','nn_NO',NULL,NULL,0,120,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(732,83,'Norwegian','no','no_NO',NULL,NULL,0,121,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(733,83,'Nuosu','ii','ii_CN',NULL,NULL,0,122,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(734,83,'South Ndebele','nr','nr_ZA',NULL,NULL,0,123,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(735,83,'Occitan (after 1500)','oc','oc_FR',NULL,NULL,0,124,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(736,83,'Ojibwa','oj','oj_CA',NULL,NULL,0,125,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(737,83,'Old Church Slavonic, Church Slavic, Church Slavonic, Old Bulgarian, Old Slavonic','cu','cu_BG',NULL,NULL,0,126,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(738,83,'Oromo','om','om_ET',NULL,NULL,0,127,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(739,83,'Oriya','or','or_IN',NULL,NULL,0,128,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(740,83,'Ossetian, Ossetic','os','os_GE',NULL,NULL,0,129,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(741,83,'Panjabi, Punjabi','pa','pa_IN',NULL,NULL,0,130,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(742,83,'Pali','pi','pi_KH',NULL,NULL,0,131,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(743,83,'Persian (Iran)','fa','fa_IR',NULL,NULL,0,132,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(744,83,'Polish','pl','pl_PL',NULL,NULL,0,133,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(745,83,'Pashto, Pushto','ps','ps_AF',NULL,NULL,0,134,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(746,83,'Portuguese (Brazil)','pt','pt_BR',NULL,NULL,0,135,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(747,83,'Portuguese (Portugal)','pt','pt_PT',NULL,NULL,0,136,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(748,83,'Quechua','qu','qu_PE',NULL,NULL,0,137,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(749,83,'Romansh','rm','rm_CH',NULL,NULL,0,138,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(750,83,'Kirundi','rn','rn_BI',NULL,NULL,0,139,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(751,83,'Romanian, Moldavian, Moldovan','ro','ro_RO',NULL,NULL,0,140,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(752,83,'Russian','ru','ru_RU',NULL,NULL,0,141,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(753,83,'Sanskrit','sa','sa_IN',NULL,NULL,0,142,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(754,83,'Sardinian','sc','sc_IT',NULL,NULL,0,143,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(755,83,'Sindhi','sd','sd_IN',NULL,NULL,0,144,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(756,83,'Northern Sami','se','se_NO',NULL,NULL,0,145,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(757,83,'Samoan','sm','sm_WS',NULL,NULL,0,146,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(758,83,'Sango','sg','sg_CF',NULL,NULL,0,147,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(759,83,'Serbian','sr','sr_RS',NULL,NULL,0,148,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(760,83,'Scottish Gaelic; Gaelic','gd','gd_GB',NULL,NULL,0,149,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(761,83,'Shona','sn','sn_ZW',NULL,NULL,0,150,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(762,83,'Sinhala, Sinhalese','si','si_LK',NULL,NULL,0,151,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(763,83,'Slovak','sk','sk_SK',NULL,NULL,0,152,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(764,83,'Slovene','sl','sl_SI',NULL,NULL,0,153,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(765,83,'Somali','so','so_SO',NULL,NULL,0,154,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(766,83,'Southern Sotho','st','st_ZA',NULL,NULL,0,155,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(767,83,'Spanish; Castilian (Spain)','es','es_ES',NULL,NULL,0,156,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(768,83,'Spanish; Castilian (Mexico)','es','es_MX',NULL,NULL,0,157,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(769,83,'Spanish; Castilian (Puerto Rico)','es','es_PR',NULL,NULL,0,158,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(770,83,'Sundanese','su','su_ID',NULL,NULL,0,159,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(771,83,'Swahili','sw','sw_TZ',NULL,NULL,0,160,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(772,83,'Swati','ss','ss_ZA',NULL,NULL,0,161,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(773,83,'Swedish','sv','sv_SE',NULL,NULL,0,162,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(774,83,'Tamil','ta','ta_IN',NULL,NULL,0,163,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(775,83,'Telugu','te','te_IN',NULL,NULL,0,164,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(776,83,'Tajik','tg','tg_TJ',NULL,NULL,0,165,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(777,83,'Thai','th','th_TH',NULL,NULL,0,166,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(778,83,'Tigrinya','ti','ti_ET',NULL,NULL,0,167,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(779,83,'Tibetan Standard, Tibetan, Central','bo','bo_CN',NULL,NULL,0,168,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(780,83,'Turkmen','tk','tk_TM',NULL,NULL,0,169,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(781,83,'Tagalog','tl','tl_PH',NULL,NULL,0,170,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(782,83,'Tswana','tn','tn_ZA',NULL,NULL,0,171,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(783,83,'Tonga (Tonga Islands)','to','to_TO',NULL,NULL,0,172,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(784,83,'Turkish','tr','tr_TR',NULL,NULL,0,173,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(785,83,'Tsonga','ts','ts_ZA',NULL,NULL,0,174,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(786,83,'Tatar','tt','tt_RU',NULL,NULL,0,175,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(787,83,'Twi','tw','tw_GH',NULL,NULL,0,176,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(788,83,'Tahitian','ty','ty_PF',NULL,NULL,0,177,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(789,83,'Uighur, Uyghur','ug','ug_CN',NULL,NULL,0,178,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(790,83,'Ukrainian','uk','uk_UA',NULL,NULL,0,179,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(791,83,'Urdu','ur','ur_PK',NULL,NULL,0,180,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(792,83,'Uzbek','uz','uz_UZ',NULL,NULL,0,181,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(793,83,'Venda','ve','ve_ZA',NULL,NULL,0,182,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(794,83,'Vietnamese','vi','vi_VN',NULL,NULL,0,183,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(795,83,'Volapük','vo','vo_XX',NULL,NULL,0,184,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(796,83,'Walloon','wa','wa_BE',NULL,NULL,0,185,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(797,83,'Welsh','cy','cy_GB',NULL,NULL,0,186,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(798,83,'Wolof','wo','wo_SN',NULL,NULL,0,187,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(799,83,'Western Frisian','fy','fy_NL',NULL,NULL,0,188,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(800,83,'Xhosa','xh','xh_ZA',NULL,NULL,0,189,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(801,83,'Yiddish','yi','yi_US',NULL,NULL,0,190,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(802,83,'Yoruba','yo','yo_NG',NULL,NULL,0,191,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(803,83,'Zhuang, Chuang','za','za_CN',NULL,NULL,0,192,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(804,83,'Zulu','zu','zu_ZA',NULL,NULL,0,193,NULL,0,0,0,NULL,NULL,NULL,NULL,NULL),(805,84,'In Person','1','in_person',NULL,0,0,1,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(806,84,'Phone','2','phone',NULL,0,1,2,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(807,84,'Email','3','email',NULL,0,0,3,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(808,84,'Fax','4','fax',NULL,0,0,4,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(809,84,'Letter Mail','5','letter_mail',NULL,0,0,5,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(810,85,'Cases - Send Copy of an Activity','1','case_activity',NULL,NULL,0,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(811,86,'Contributions - Duplicate Organization Alert','1','contribution_dupalert',NULL,NULL,0,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(812,86,'Contributions - Receipt (off-line)','2','contribution_offline_receipt',NULL,NULL,0,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(813,86,'Contributions - Receipt (on-line)','3','contribution_online_receipt',NULL,NULL,0,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(814,86,'Contributions - Invoice','4','contribution_invoice_receipt',NULL,NULL,0,4,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(815,86,'Contributions - Recurring Start and End Notification','5','contribution_recurring_notify',NULL,NULL,0,5,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(816,86,'Contributions - Recurring Cancellation Notification','6','contribution_recurring_cancelled',NULL,NULL,0,6,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(817,86,'Contributions - Recurring Billing Updates','7','contribution_recurring_billing',NULL,NULL,0,7,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(818,86,'Contributions - Recurring Updates','8','contribution_recurring_edit',NULL,NULL,0,8,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(819,86,'Personal Campaign Pages - Admin Notification','9','pcp_notify',NULL,NULL,0,9,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(820,86,'Personal Campaign Pages - Supporter Status Change Notification','10','pcp_status_change',NULL,NULL,0,10,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(821,86,'Personal Campaign Pages - Supporter Welcome','11','pcp_supporter_notify',NULL,NULL,0,11,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(822,86,'Personal Campaign Pages - Owner Notification','12','pcp_owner_notify',NULL,NULL,0,12,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(823,86,'Additional Payment Receipt or Refund Notification','13','payment_or_refund_notification',NULL,NULL,0,13,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(824,87,'Events - Registration Confirmation and Receipt (off-line)','1','event_offline_receipt',NULL,NULL,0,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(825,87,'Events - Registration Confirmation and Receipt (on-line)','2','event_online_receipt',NULL,NULL,0,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(826,87,'Events - Receipt only','3','event_registration_receipt',NULL,NULL,0,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(827,87,'Events - Registration Cancellation Notice','4','participant_cancelled',NULL,NULL,0,4,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(828,87,'Events - Registration Confirmation Invite','5','participant_confirm',NULL,NULL,0,5,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(829,87,'Events - Pending Registration Expiration Notice','6','participant_expired',NULL,NULL,0,6,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(830,87,'Events - Registration Transferred Notice','7','participant_transferred',NULL,NULL,0,7,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(831,88,'Tell-a-Friend Email','1','friend',NULL,NULL,0,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(832,89,'Memberships - Signup and Renewal Receipts (off-line)','1','membership_offline_receipt',NULL,NULL,0,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(833,89,'Memberships - Receipt (on-line)','2','membership_online_receipt',NULL,NULL,0,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(834,89,'Memberships - Auto-renew Cancellation Notification','3','membership_autorenew_cancelled',NULL,NULL,0,3,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(835,89,'Memberships - Auto-renew Billing Updates','4','membership_autorenew_billing',NULL,NULL,0,4,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(836,90,'Test-drive - Receipt Header','1','test_preview',NULL,NULL,0,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(837,91,'Pledges - Acknowledgement','1','pledge_acknowledge',NULL,NULL,0,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(838,91,'Pledges - Payment Reminder','2','pledge_reminder',NULL,NULL,0,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(839,92,'Profiles - Admin Notification','1','uf_notify',NULL,NULL,0,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(840,93,'Petition - signature added','1','petition_sign',NULL,NULL,0,1,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(841,93,'Petition - need verification','2','petition_confirmation_needed',NULL,NULL,0,2,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(842,94,'In Honor of','1','in_honor_of',NULL,NULL,0,1,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(843,94,'In Memory of','2','in_memory_of',NULL,NULL,0,2,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(844,94,'Solicited','3','solicited',NULL,NULL,1,3,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(845,94,'Household','4','household',NULL,NULL,0,4,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(846,94,'Workplace Giving','5','workplace',NULL,NULL,0,5,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(847,94,'Foundation Affiliate','6','foundation_affiliate',NULL,NULL,0,6,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(848,94,'3rd-party Service','7','3rd-party_service',NULL,NULL,0,7,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(849,94,'Donor-advised Fund','8','donor-advised_fund',NULL,NULL,0,8,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(850,94,'Matched Gift','9','matched_gift',NULL,NULL,0,9,NULL,0,0,1,NULL,NULL,NULL,NULL,NULL),(851,94,'Personal Campaign Page','10','pcp',NULL,NULL,0,10,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(852,94,'Gift','11','gift',NULL,NULL,0,11,NULL,0,1,1,NULL,NULL,NULL,NULL,NULL),(853,2,'Interview','55','Interview',NULL,0,NULL,55,'Conduct a phone or in person interview.',0,0,1,NULL,NULL,NULL,'fa-comment-o',NULL);
 /*!40000 ALTER TABLE `civicrm_option_value` ENABLE KEYS */;
 UNLOCK TABLES;
 
diff --git a/civicrm/templates/CRM/Campaign/Form/Search/Campaign.tpl b/civicrm/templates/CRM/Campaign/Form/Search/Campaign.tpl
index 7a88582f2990be715f1eff28ec73428d2fd3b20e..d16b96871497b7f4367d6ac3ecaf242227300273 100644
--- a/civicrm/templates/CRM/Campaign/Form/Search/Campaign.tpl
+++ b/civicrm/templates/CRM/Campaign/Form/Search/Campaign.tpl
@@ -99,10 +99,10 @@
 
             <tr>
               <td>{$form.start_date.label}<br/>
-                {include file="CRM/common/jcalendar.tpl" elementName=start_date}
+                {$form.start_date.html}
               </td>
               <td>{$form.end_date.label}<br/>
-                {include file="CRM/common/jcalendar.tpl" elementName=end_date}
+                {$form.end_date.html}
               </td>
             </tr>
 
diff --git a/civicrm/templates/CRM/Contribute/Form/Contribution/Main.tpl b/civicrm/templates/CRM/Contribute/Form/Contribution/Main.tpl
index 838743a21760858683cfac21932358bcd302ee2d..898c4e028b6dc80e88715bc4d6c796457918fe0c 100644
--- a/civicrm/templates/CRM/Contribute/Form/Contribution/Main.tpl
+++ b/civicrm/templates/CRM/Contribute/Form/Contribution/Main.tpl
@@ -135,7 +135,7 @@
           <div class="clear"></div>
           {if $start_date_editable}
             {if $is_date}
-              <div class="label">{$form.start_date.label}</div><div class="content">{include file="CRM/common/jcalendar.tpl" elementName=start_date}</div>
+              <div class="label">{$form.start_date.label}</div><div class="content">{$form.start_date.html}</div>
             {else}
               <div class="label">{$form.start_date.label}</div><div class="content">{$form.start_date.html}</div>
             {/if}
diff --git a/civicrm/templates/CRM/Contribute/Form/ContributionPage/Amount.tpl b/civicrm/templates/CRM/Contribute/Form/ContributionPage/Amount.tpl
index 494ebba8eb936a7b3fbc1fcb7caf37f3ce65ebc0..3a5213dd85849a718e5e09391102d4cf37d6fff3 100644
--- a/civicrm/templates/CRM/Contribute/Form/ContributionPage/Amount.tpl
+++ b/civicrm/templates/CRM/Contribute/Form/ContributionPage/Amount.tpl
@@ -121,7 +121,7 @@
         </table>
     </div>
 {if $futurePaymentProcessor}
-    <span id="pledge_calendar_date_field">&nbsp;&nbsp;{include file="CRM/common/jcalendar.tpl" elementName=pledge_calendar_date}</span>
+    <span id="pledge_calendar_date_field">&nbsp;&nbsp;{$form.pledge_calendar_date.html}</span>
     <span id="pledge_calendar_month_field">&nbsp;&nbsp;{$form.pledge_calendar_month.html}<br/><span class="description">{ts}Recurring payment will be processed this day of the month following submission of this contribution page.{/ts}</span></span>
 {/if}
 
diff --git a/civicrm/templates/CRM/Event/Cart/Form/Checkout/Payment.tpl b/civicrm/templates/CRM/Event/Cart/Form/Checkout/Payment.tpl
index fb0a114c630c190b80be82f4bacde1baaf2d6873..1c9555bd4605f502f2de7b3866665d7d0444a411 100644
--- a/civicrm/templates/CRM/Event/Cart/Form/Checkout/Payment.tpl
+++ b/civicrm/templates/CRM/Event/Cart/Form/Checkout/Payment.tpl
@@ -21,7 +21,7 @@
     {foreach from=$line_items item=line_item}
       <tr class="event-line-item {$line_item.class}">
   <td class="event-title">
-    {$line_item.event->title} ({$line_item.event->start_date})
+    {$line_item.event->title} ({$line_item.event->start_date|crmDate})
   </td>
   <td class="participants-column">
     {$line_item.num_participants}<br/>
diff --git a/civicrm/templates/CRM/common/batchCopy.tpl b/civicrm/templates/CRM/common/batchCopy.tpl
index bb7bb1d17911ab2f02c889e887dace7d3313d63d..1febb52fc654f6f316710834b4c18dd3db4d1a06 100644
--- a/civicrm/templates/CRM/common/batchCopy.tpl
+++ b/civicrm/templates/CRM/common/batchCopy.tpl
@@ -98,7 +98,7 @@
         });
       }
       else {
-        if (elementId.is('select') === true && firstElement.parent().find(':input').select().index() >= 1 && firstElement.parent().find('select').select().index < 1) {
+        if (elementId.is('select') === true && firstElement.parent().find(':input').select().index() >= 1 && firstElement.parent().find('select').select().length > 1) {
           // its a multiselect case
           firstElement.parent().find(':input').select().each( function(count) {
             var firstElementValue = $(this).val();
diff --git a/civicrm/templates/CRM/common/formButtons.tpl b/civicrm/templates/CRM/common/formButtons.tpl
index 9f869f94d2084cf1eff84003b98b9eafd2433e2b..a264de1eae563d75a53aa8780836d7f900d40083 100644
--- a/civicrm/templates/CRM/common/formButtons.tpl
+++ b/civicrm/templates/CRM/common/formButtons.tpl
@@ -28,27 +28,27 @@
    by button and name. crmBtnType grabs type keyword from button name (e.g. 'upload', 'next', 'back', 'cancel') so
    types of buttons can be styled differently via css. *}
 {crmRegion name='form-buttons'}
-  {foreach from=$form.buttons item=button key=key name=btns}
-    {if $key|substring:0:4 EQ '_qf_'}
-        {if $location}
-          {assign var='html' value=$form.buttons.$key.html|crmReplace:id:"$key-$location"}
-        {else}
-          {assign var='html' value=$form.buttons.$key.html}
-        {/if}
-        {crmGetAttribute html=$html attr='crm-icon' assign='icon'}
-        {capture assign=iconPrefix}{$icon|truncate:3:"":true}{/capture}
-        {if $icon && $iconPrefix eq 'fa-'}
-          {assign var='buttonClass' value=' crm-i-button'}
-          {capture assign=iconDisp}<i class="crm-i {$icon}"></i>{/capture}
-        {elseif $icon}
-          {assign var='buttonClass' value=' crm-icon-button'}
-          {capture assign=iconDisp}<span class="crm-button-icon ui-icon-{$icon}"> </span>{/capture}
-        {/if}
-        {crmGetAttribute html=$html attr='disabled' assign='disabled'}
-        <span class="crm-button crm-button-type-{$key|crmBtnType} crm-button{$key}{$buttonClass}{if $disabled} crm-button-disabled{/if}"{if $buttonStyle} style="{$buttonStyle}"{/if}>
-          {$iconDisp}
-          {$html}
-        </span>
+{foreach from=$form.buttons item=button key=key name=btns}
+  {if $key|substring:0:4 EQ '_qf_'}
+    {if $location}
+      {assign var='html' value=$form.buttons.$key.html|crmReplace:id:"$key-$location"}
+    {else}
+      {assign var='html' value=$form.buttons.$key.html}
     {/if}
-  {/foreach}
+    {crmGetAttribute html=$html attr='crm-icon' assign='icon'}
+    {capture assign=iconPrefix}{$icon|truncate:3:"":true}{/capture}
+    {if $icon && $iconPrefix eq 'fa-'}
+      {assign var='buttonClass' value=' crm-i-button'}
+      {capture assign=iconDisp}<i class="crm-i {$icon}"></i>{/capture}
+    {elseif $icon}
+      {assign var='buttonClass' value=' crm-icon-button'}
+      {capture assign=iconDisp}<span class="crm-button-icon ui-icon-{$icon}"> </span>{/capture}
+    {/if}
+    {crmGetAttribute html=$html attr='disabled' assign='disabled'}
+    <span class="crm-button crm-button-type-{$key|crmBtnType} crm-button{$key}{$buttonClass}{if $disabled} crm-button-disabled{/if}"{if $buttonStyle} style="{$buttonStyle}"{/if}>
+      {$iconDisp}
+      {$html}
+    </span>
+  {/if}
+{/foreach}
 {/crmRegion}
diff --git a/civicrm/vendor/autoload.php b/civicrm/vendor/autoload.php
index 3ec10a2312ed75ad7e117d7856788c244767fe5a..1dd5edc3934a04a66d83474a68ff51aa1e8fb42f 100644
--- a/civicrm/vendor/autoload.php
+++ b/civicrm/vendor/autoload.php
@@ -4,4 +4,4 @@
 
 require_once __DIR__ . '/composer/autoload_real.php';
 
-return ComposerAutoloaderInit080dcc2b83d517009db7f36437dce13e::getLoader();
+return ComposerAutoloaderInit188b9eabfe4090f2e62fb6879322428c::getLoader();
diff --git a/civicrm/vendor/composer/autoload_real.php b/civicrm/vendor/composer/autoload_real.php
index 1a5336b056565fe30190fc41e7dd17ddda1311d6..f2d3d8865d9718adc22a21f0d8f7b3275ae30eae 100644
--- a/civicrm/vendor/composer/autoload_real.php
+++ b/civicrm/vendor/composer/autoload_real.php
@@ -2,7 +2,7 @@
 
 // autoload_real.php @generated by Composer
 
-class ComposerAutoloaderInit080dcc2b83d517009db7f36437dce13e
+class ComposerAutoloaderInit188b9eabfe4090f2e62fb6879322428c
 {
     private static $loader;
 
@@ -19,9 +19,9 @@ class ComposerAutoloaderInit080dcc2b83d517009db7f36437dce13e
             return self::$loader;
         }
 
-        spl_autoload_register(array('ComposerAutoloaderInit080dcc2b83d517009db7f36437dce13e', 'loadClassLoader'), true, true);
+        spl_autoload_register(array('ComposerAutoloaderInit188b9eabfe4090f2e62fb6879322428c', 'loadClassLoader'), true, true);
         self::$loader = $loader = new \Composer\Autoload\ClassLoader();
-        spl_autoload_unregister(array('ComposerAutoloaderInit080dcc2b83d517009db7f36437dce13e', 'loadClassLoader'));
+        spl_autoload_unregister(array('ComposerAutoloaderInit188b9eabfe4090f2e62fb6879322428c', 'loadClassLoader'));
 
         $includePaths = require __DIR__ . '/include_paths.php';
         $includePaths[] = get_include_path();
@@ -31,7 +31,7 @@ class ComposerAutoloaderInit080dcc2b83d517009db7f36437dce13e
         if ($useStaticLoader) {
             require_once __DIR__ . '/autoload_static.php';
 
-            call_user_func(\Composer\Autoload\ComposerStaticInit080dcc2b83d517009db7f36437dce13e::getInitializer($loader));
+            call_user_func(\Composer\Autoload\ComposerStaticInit188b9eabfe4090f2e62fb6879322428c::getInitializer($loader));
         } else {
             $map = require __DIR__ . '/autoload_namespaces.php';
             foreach ($map as $namespace => $path) {
@@ -52,19 +52,19 @@ class ComposerAutoloaderInit080dcc2b83d517009db7f36437dce13e
         $loader->register(true);
 
         if ($useStaticLoader) {
-            $includeFiles = Composer\Autoload\ComposerStaticInit080dcc2b83d517009db7f36437dce13e::$files;
+            $includeFiles = Composer\Autoload\ComposerStaticInit188b9eabfe4090f2e62fb6879322428c::$files;
         } else {
             $includeFiles = require __DIR__ . '/autoload_files.php';
         }
         foreach ($includeFiles as $fileIdentifier => $file) {
-            composerRequire080dcc2b83d517009db7f36437dce13e($fileIdentifier, $file);
+            composerRequire188b9eabfe4090f2e62fb6879322428c($fileIdentifier, $file);
         }
 
         return $loader;
     }
 }
 
-function composerRequire080dcc2b83d517009db7f36437dce13e($fileIdentifier, $file)
+function composerRequire188b9eabfe4090f2e62fb6879322428c($fileIdentifier, $file)
 {
     if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
         require $file;
diff --git a/civicrm/vendor/composer/autoload_static.php b/civicrm/vendor/composer/autoload_static.php
index b8a14ba424e83a84fb7f7af83d289aa75a5b563f..b244de637437bd42d63ad1f85717862ca945dbee 100644
--- a/civicrm/vendor/composer/autoload_static.php
+++ b/civicrm/vendor/composer/autoload_static.php
@@ -4,7 +4,7 @@
 
 namespace Composer\Autoload;
 
-class ComposerStaticInit080dcc2b83d517009db7f36437dce13e
+class ComposerStaticInit188b9eabfe4090f2e62fb6879322428c
 {
     public static $files = array (
         '320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php',
@@ -432,11 +432,11 @@ class ComposerStaticInit080dcc2b83d517009db7f36437dce13e
     public static function getInitializer(ClassLoader $loader)
     {
         return \Closure::bind(function () use ($loader) {
-            $loader->prefixLengthsPsr4 = ComposerStaticInit080dcc2b83d517009db7f36437dce13e::$prefixLengthsPsr4;
-            $loader->prefixDirsPsr4 = ComposerStaticInit080dcc2b83d517009db7f36437dce13e::$prefixDirsPsr4;
-            $loader->prefixesPsr0 = ComposerStaticInit080dcc2b83d517009db7f36437dce13e::$prefixesPsr0;
-            $loader->fallbackDirsPsr0 = ComposerStaticInit080dcc2b83d517009db7f36437dce13e::$fallbackDirsPsr0;
-            $loader->classMap = ComposerStaticInit080dcc2b83d517009db7f36437dce13e::$classMap;
+            $loader->prefixLengthsPsr4 = ComposerStaticInit188b9eabfe4090f2e62fb6879322428c::$prefixLengthsPsr4;
+            $loader->prefixDirsPsr4 = ComposerStaticInit188b9eabfe4090f2e62fb6879322428c::$prefixDirsPsr4;
+            $loader->prefixesPsr0 = ComposerStaticInit188b9eabfe4090f2e62fb6879322428c::$prefixesPsr0;
+            $loader->fallbackDirsPsr0 = ComposerStaticInit188b9eabfe4090f2e62fb6879322428c::$fallbackDirsPsr0;
+            $loader->classMap = ComposerStaticInit188b9eabfe4090f2e62fb6879322428c::$classMap;
 
         }, null, ClassLoader::class);
     }
diff --git a/civicrm/xml/schema/Contact/Group.xml b/civicrm/xml/schema/Contact/Group.xml
index 4deea9bf9639c99e2e4e652cfbe7cfd1989c8e2a..330e1a42dbc35b86bcdca5c8e9ca165b7c03d22e 100644
--- a/civicrm/xml/schema/Contact/Group.xml
+++ b/civicrm/xml/schema/Contact/Group.xml
@@ -35,6 +35,9 @@
     <localizable>true</localizable>
     <comment>Name of Group.</comment>
     <add>1.1</add>
+    <html>
+      <type>Text</type>
+    </html>
   </field>
   <field>
     <name>description</name>
diff --git a/civicrm/xml/schema/Contribute/ContributionRecur.xml b/civicrm/xml/schema/Contribute/ContributionRecur.xml
index b492bd9453056aa70554dcb93d4278178ddee8cd..1e3a211e07b0ad1d408c971a08e112432a784c45 100644
--- a/civicrm/xml/schema/Contribute/ContributionRecur.xml
+++ b/civicrm/xml/schema/Contribute/ContributionRecur.xml
@@ -7,6 +7,7 @@
   <log>true</log>
   <field>
     <name>id</name>
+    <uniqueName>contribution_recur_id</uniqueName>
     <title>Recurring Contribution ID</title>
     <type>int unsigned</type>
     <required>true</required>
@@ -172,6 +173,7 @@
   </field>
   <field>
     <name>processor_id</name>
+    <uniqueName>contribution_recur_processor_id</uniqueName>
     <title>Processor ID</title>
     <type>varchar</type>
     <length>255</length>
@@ -197,6 +199,7 @@
   </foreignKey>
   <field>
     <name>trxn_id</name>
+    <uniqueName>contribution_recur_trxn_id</uniqueName>
     <title>Transaction ID</title>
     <type>varchar</type>
     <length>255</length>
@@ -231,6 +234,7 @@
   </index>
   <field>
     <name>contribution_status_id</name>
+    <uniqueName>contribution_recur_contribution_status_id</uniqueName>
     <title>Status</title>
     <type>int unsigned</type>
     <default>1</default>
@@ -325,6 +329,7 @@
   <field>
     <name>payment_processor_id</name>
     <title>Payment Processor</title>
+    <uniqueName>contribution_recur_payment_processor_id</uniqueName>
     <type>int unsigned</type>
     <comment>Foreign key to civicrm_payment_processor.id</comment>
     <add>3.3</add>
diff --git a/civicrm/xml/schema/Core/Tag.xml b/civicrm/xml/schema/Core/Tag.xml
index 2b7b047f1816d51d6f7bdfa87a6a9f428631aa34..378845845169e53cd414c007156c53101705cb16 100644
--- a/civicrm/xml/schema/Core/Tag.xml
+++ b/civicrm/xml/schema/Core/Tag.xml
@@ -90,6 +90,7 @@
     <pseudoconstant>
       <optionGroupName>tag_used_for</optionGroupName>
     </pseudoconstant>
+    <serialize>COMMA</serialize>
     <add>3.2</add>
   </field>
   <field>
diff --git a/civicrm/xml/schema/Core/UFField.xml b/civicrm/xml/schema/Core/UFField.xml
index fd0322b49af398c1912a61825901ca489d7b15d2..fdcdcf83b3f348b5a1477518ff75ecfbf0a5326f 100644
--- a/civicrm/xml/schema/Core/UFField.xml
+++ b/civicrm/xml/schema/Core/UFField.xml
@@ -49,6 +49,9 @@
     <length>64</length>
     <required>true</required>
     <comment>Name for CiviCRM field which is being exposed for sharing.</comment>
+    <pseudoconstant>
+      <callback>CRM_Core_BAO_UFField::getAvailableFieldTitles</callback>
+    </pseudoconstant>
     <add>1.1</add>
   </field>
   <field>
diff --git a/civicrm/xml/templates/civicrm_data.tpl b/civicrm/xml/templates/civicrm_data.tpl
index f7ebf23464212872d413371fcdedc5f98aaab623..7407884c1b71d5ada0d167c7e6c4abcf1ea9397a 100644
--- a/civicrm/xml/templates/civicrm_data.tpl
+++ b/civicrm/xml/templates/civicrm_data.tpl
@@ -674,6 +674,7 @@ VALUES
   (@option_group_id_sfe, 'docx', 12, 'docx',  NULL, 0, 0, 12, NULL, 0, 0, 1, NULL, NULL, NULL),
   (@option_group_id_sfe, 'xlsx', 13, 'xlsx',  NULL, 0, 0, 13, NULL, 0, 0, 1, NULL, NULL, NULL),
   (@option_group_id_sfe, 'odt',  14, 'odt',   NULL, 0, 0, 14, NULL, 0, 0, 1, NULL, NULL, NULL),
+  (@option_group_id_sfe, 'ics',  15, 'ics',   NULL, 0, 0, 15, NULL, 0, 0, 1, NULL, NULL, NULL),
 
   (@option_group_id_we, '{ts escape="sql"}Textarea{/ts}', 1, 'Textarea', NULL, 0, NULL, 1, NULL, 0, 1, 1, NULL, NULL, NULL),
   (@option_group_id_we, 'CKEditor', 2, 'CKEditor', NULL, 0, NULL, 2, NULL, 0, 1, 1, NULL, NULL, NULL),
diff --git a/civicrm/xml/templates/dao.tpl b/civicrm/xml/templates/dao.tpl
index 8e0f26f42d10be32efe8ac63891d5690c9f78fb4..f4e39f4d6765c227a4009ce11a46d179668c41fd 100644
--- a/civicrm/xml/templates/dao.tpl
+++ b/civicrm/xml/templates/dao.tpl
@@ -116,18 +116,15 @@ class {$table.className} extends CRM_Core_DAO {ldelim}
 
 {if $field.import}
                       'import'    => {$field.import|strtoupper},
-                                                                      'where'     => '{$table.name}.{$field.name}',
-                                      'headerPattern' => '{$field.headerPattern}',
-                                      'dataPattern' => '{$field.dataPattern}',
+
 {/if} {* field.import *}
+  'where'     => '{$table.name}.{$field.name}',
+  {if $field.headerPattern}'headerPattern' => '{$field.headerPattern}',{/if}
+  {if $field.dataPattern}'dataPattern' => '{$field.dataPattern}',{/if}
 {if $field.export}
                       'export'    => {$field.export|strtoupper},
-                                      {if ! $field.import}
-                      'where'     => '{$table.name}.{$field.name}',
-                                      'headerPattern' => '{$field.headerPattern}',
-                                      'dataPattern' => '{$field.dataPattern}',
-              {/if}
 {/if} {* field.export *}
+
 {if $field.rule}
                       'rule'      => '{$field.rule}',
 {/if} {* field.rule *}
diff --git a/civicrm/xml/version.xml b/civicrm/xml/version.xml
index 9e0efdaaf38ab079d08e56fefb865377c560586b..e259b1857e13f02fb0b0bc8682f123fea422b3e9 100644
--- a/civicrm/xml/version.xml
+++ b/civicrm/xml/version.xml
@@ -1,4 +1,4 @@
 <?xml version="1.0" encoding="iso-8859-1" ?>
 <version>
-  <version_no>5.13.5</version_no>
+  <version_no>5.14.0</version_no>
 </version>