Commit 52cda5dc authored by mattwire's avatar mattwire

Move UPPER() from sql to php domain

parent a6323558
......@@ -431,7 +431,7 @@ class CRM_Activity_Selector_Search extends CRM_Core_Selector_Base implements CRM
* @return mixed
*/
public function alphabetQuery() {
return $this->_query->searchQuery(NULL, NULL, NULL, FALSE, FALSE, TRUE);
return $this->_query->alphabetQuery();
}
/**
......
......@@ -456,7 +456,7 @@ class CRM_Case_Selector_Search extends CRM_Core_Selector_Base {
* @return mixed
*/
public function alphabetQuery() {
return $this->_query->searchQuery(NULL, NULL, NULL, FALSE, FALSE, TRUE);
return $this->_query->alphabetQuery();
}
/**
......
......@@ -1384,7 +1384,7 @@ class CRM_Contact_BAO_Query {
}
}
elseif ($sortByChar) {
$select = 'SELECT DISTINCT UPPER(LEFT(contact_a.sort_name, 1)) as sort_name';
$select = 'SELECT DISTINCT LEFT(contact_a.sort_name, 1) as sort_name';
$from = $this->_simpleFromClause;
}
elseif ($groupContacts) {
......@@ -4896,6 +4896,22 @@ civicrm_relationship.start_date > {$today}
return $dao;
}
/**
* Create and query the db for a contact search.
*
* @return CRM_Core_DAO
*/
public function alphabetQuery() {
$query = $this->getSearchSQL(NULL, NULL, NULL, FALSE, FALSE, TRUE);
$dao = CRM_Core_DAO::executeQuery($query);
// We can always call this - it will only re-enable if it was originally enabled.
CRM_Core_DAO::reenableFullGroupByMode();
return $dao;
}
/**
* Fetch a list of contacts for displaying a search results page
*
......@@ -6249,25 +6265,19 @@ AND displayRelType.is_active = 1
}
}
elseif ($sortByChar) {
$orderByArray = array("UPPER(LEFT(contact_a.sort_name, 1)) asc");
$orderBy = " sort_name asc";
}
else {
$orderBy = " contact_a.sort_name ASC, contact_a.id";
}
}
if (!$orderBy && empty($orderByArray)) {
if (!$orderBy) {
return [NULL, $additionalFromClause];
}
// Remove this here & add it at the end for simplicity.
$order = trim($orderBy);
$orderByArray = explode(',', $order);
// hack for order clause
if (!empty($orderByArray)) {
$order = implode(', ', $orderByArray);
}
else {
$orderByArray = explode(',', $order);
}
foreach ($orderByArray as $orderByClause) {
$orderByClauseParts = explode(' ', trim($orderByClause));
$field = $orderByClauseParts[0];
......
......@@ -1192,7 +1192,7 @@ class CRM_Contact_Selector extends CRM_Core_Selector_Base implements CRM_Core_Se
* @return CRM_Contact_DAO_Contact
*/
public function alphabetQuery() {
return $this->_query->searchQuery(NULL, NULL, NULL, FALSE, FALSE, TRUE);
return $this->_query->alphabetQuery();
}
/**
......
......@@ -619,7 +619,7 @@ class CRM_Contribute_Selector_Search extends CRM_Core_Selector_Base implements C
* @return mixed
*/
public function alphabetQuery() {
return $this->_query->searchQuery(NULL, NULL, NULL, FALSE, FALSE, TRUE);
return $this->_query->alphabetQuery();
}
/**
......
......@@ -530,7 +530,7 @@ class CRM_Event_Selector_Search extends CRM_Core_Selector_Base implements CRM_Co
* @return mixed
*/
public function alphabetQuery() {
return $this->_query->searchQuery(NULL, NULL, NULL, FALSE, FALSE, TRUE);
return $this->_query->alphabetQuery();
}
/**
......
......@@ -389,7 +389,7 @@ class CRM_Mailing_Selector_Search extends CRM_Core_Selector_Base implements CRM_
* @return mixed
*/
public function alphabetQuery() {
return $this->_query->searchQuery(NULL, NULL, NULL, FALSE, FALSE, TRUE);
return $this->_query->alphabetQuery();
}
/**
......
......@@ -543,7 +543,7 @@ class CRM_Member_Selector_Search extends CRM_Core_Selector_Base implements CRM_C
* @return mixed
*/
public function alphabetQuery() {
return $this->_query->searchQuery(NULL, NULL, NULL, FALSE, FALSE, TRUE);
return $this->_query->alphabetQuery();
}
/**
......
......@@ -113,7 +113,7 @@ class CRM_Utils_PagerAToZ {
$dynamicAlphabets = array();
while ($result->fetch()) {
$dynamicAlphabets[] = $result->sort_name;
$dynamicAlphabets[] = strtoupper($result->sort_name);
}
return $dynamicAlphabets;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment