Merge pull request #583 from yashodha/CRM-12463
[civicrm-core.git] / api / v3 / Contact.php
index 0b84bf2d27e4551c71f5aaba98fba00b769f2895..cb603cb60175f3e19d4fc62ef80aa63900c447d8 100644 (file)
@@ -142,6 +142,10 @@ function _civicrm_api3_contact_create_spec(&$params) {
     'title' => 'Current Employer',
     'description' => 'Name of Current Employer',
   );
+  $params['dupe_check'] = array(
+    'title' => 'Check for Duplicates',
+    'description' => 'Throw error if contact create matches dedupe rule',
+  );
 }
 
 /**
@@ -728,6 +732,13 @@ function civicrm_api3_contact_getquick($params) {
       ";
   }
 
+  $orderByInner = "";
+  $orderByOuter = "ORDER BY exactFirst";
+  if ($config->includeOrderByClause) {
+    $orderByInner = "ORDER BY sort_name";
+    $orderByOuter .= ", sort_name";
+  }
+
   //CRM-5954
   $query = "
         SELECT DISTINCT(id), data, sort_name {$selectAliases}
@@ -744,10 +755,10 @@ function civicrm_api3_contact_getquick($params) {
     {$aclFrom}
     {$additionalFrom} {$includeEmailFrom}
     {$whereClause}
-    ORDER BY sort_name
+    {$orderByInner}
     LIMIT 0, {$limit} )
 ) t
-ORDER BY exactFirst, sort_name
+{$orderByOuter}
 LIMIT    0, {$limit}
     ";
   // send query to hook to be modified if needed