From 6984fe8082dd79bde6e33003e8b27503133be417 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Tue, 10 Feb 2015 05:05:49 -0800 Subject: [PATCH] CRM-15926 - CRM_Contact_Page_AJAX::search - Remove old, unused helper --- CRM/Contact/Page/AJAX.php | 182 ---------------------------------- CRM/Core/xml/Menu/Contact.xml | 5 - 2 files changed, 187 deletions(-) diff --git a/CRM/Contact/Page/AJAX.php b/CRM/Contact/Page/AJAX.php index 96a9e6fa58..268b7f8cd6 100644 --- a/CRM/Contact/Page/AJAX.php +++ b/CRM/Contact/Page/AJAX.php @@ -336,188 +336,6 @@ class CRM_Contact_Page_AJAX { CRM_Utils_System::civiExit(); } - /** - * @deprecated - * Old quicksearch function. No longer used in core. - * @todo: Remove this function and associated menu entry in CiviCRM 5 - */ - static function search() { - $json = TRUE; - $name = CRM_Utils_Array::value('name', $_GET, ''); - if (!array_key_exists('name', $_GET)) { - $name = CRM_Utils_Array::value('s', $_GET) . '%'; - $json = FALSE; - } - $name = CRM_Utils_Type::escape($name, 'String'); - $whereIdClause = ''; - if (!empty($_GET['id'])) { - $json = TRUE; - if (is_numeric($_GET['id'])) { - $id = CRM_Utils_Type::escape($_GET['id'], 'Integer'); - $whereIdClause = " AND civicrm_contact.id = {$id}"; - } - else { - $name = $_GET['id']; - } - } - - $elements = array(); - if ($name || isset($id)) { - $name = $name . '%'; - - //contact's based of relationhip type - $relType = NULL; - if (isset($_GET['rel'])) { - $relation = explode('_', $_GET['rel']); - $relType = CRM_Utils_Type::escape($relation[0], 'Integer'); - $rel = CRM_Utils_Type::escape($relation[2], 'String'); - } - - //shared household info - $shared = NULL; - if (isset($_GET['sh'])) { - $shared = CRM_Utils_Type::escape($_GET['sh'], 'Integer'); - if ($shared == 1) { - $contactType = 'Household'; - $cName = 'household_name'; - } - else { - $contactType = 'Organization'; - $cName = 'organization_name'; - } - } - - // contacts of type household - $hh = $addStreet = $addCity = NULL; - if (isset($_GET['hh'])) { - $hh = CRM_Utils_Type::escape($_GET['hh'], 'Integer'); - } - - //organization info - $organization = $street = $city = NULL; - if (isset($_GET['org'])) { - $organization = CRM_Utils_Type::escape($_GET['org'], 'Integer'); - } - - if (isset($_GET['org']) || isset($_GET['hh'])) { - $json = FALSE; - $splitName = explode(' :: ', $name); - if ($splitName) { - $contactName = trim(CRM_Utils_Array::value('0', $splitName)); - $street = trim(CRM_Utils_Array::value('1', $splitName)); - $city = trim(CRM_Utils_Array::value('2', $splitName)); - } - else { - $contactName = $name; - } - - if ($street) { - $addStreet = "AND civicrm_address.street_address LIKE '$street%'"; - } - if ($city) { - $addCity = "AND civicrm_address.city LIKE '$city%'"; - } - } - - if ($organization) { - - $query = " -SELECT CONCAT_WS(' :: ',sort_name,LEFT(street_address,25),city) 'sort_name', -civicrm_contact.id 'id' -FROM civicrm_contact -LEFT JOIN civicrm_address ON ( civicrm_contact.id = civicrm_address.contact_id - AND civicrm_address.is_primary=1 - ) -WHERE civicrm_contact.contact_type='Organization' AND organization_name LIKE '%$contactName%' -{$addStreet} {$addCity} {$whereIdClause} -ORDER BY organization_name "; - } - elseif ($shared) { - $query = " -SELECT CONCAT_WS(':::' , sort_name, supplemental_address_1, sp.abbreviation, postal_code, cc.name )'sort_name' , civicrm_contact.id 'id' , civicrm_contact.display_name 'disp' FROM civicrm_contact LEFT JOIN civicrm_address ON (civicrm_contact.id =civicrm_address.contact_id AND civicrm_address.is_primary =1 )LEFT JOIN civicrm_state_province sp ON (civicrm_address.state_province_id =sp.id )LEFT JOIN civicrm_country cc ON (civicrm_address.country_id =cc.id )WHERE civicrm_contact.contact_type ='{$contactType}' AND {$cName} LIKE '%$name%' {$whereIdClause} ORDER BY {$cName} "; - } - elseif ($hh) { - $query = " -SELECT CONCAT_WS(' :: ' , sort_name, LEFT(street_address,25),city) 'sort_name' , location_type_id 'location_type_id', is_primary 'is_primary', is_billing 'is_billing', civicrm_contact.id 'id' -FROM civicrm_contact -LEFT JOIN civicrm_address ON (civicrm_contact.id =civicrm_address.contact_id AND civicrm_address.is_primary =1 ) -WHERE civicrm_contact.contact_type ='Household' -AND household_name LIKE '%$contactName%' {$addStreet} {$addCity} {$whereIdClause} ORDER BY household_name "; - } - elseif ($relType) { - if (!empty($_GET['case'])) { - $query = " -SELECT distinct(c.id), c.sort_name -FROM civicrm_contact c -LEFT JOIN civicrm_relationship ON civicrm_relationship.contact_id_{$rel} = c.id -WHERE c.sort_name LIKE '%$name%' -AND civicrm_relationship.relationship_type_id = $relType -GROUP BY sort_name -"; - } - } - else { - - $query = " -SELECT sort_name, id -FROM civicrm_contact -WHERE sort_name LIKE '%$name' -{$whereIdClause} -ORDER BY sort_name "; - } - - $limit = 10; - if (isset($_GET['limit'])) { - $limit = CRM_Utils_Type::escape($_GET['limit'], 'Positive'); - } - - $query .= " LIMIT 0,{$limit}"; - - $dao = CRM_Core_DAO::executeQuery($query); - - if ($shared) { - while ($dao->fetch()) { - echo $dao->sort_name; - CRM_Utils_System::civiExit(); - } - } - else { - while ($dao->fetch()) { - if ($json) { - $elements[] = array('name' => addslashes($dao->sort_name), - 'id' => $dao->id, - ); - } - else { - echo $elements = "$dao->sort_name|$dao->id|$dao->location_type_id|$dao->is_primary|$dao->is_billing\n"; - } - } - //for adding new household address / organization - if (empty($elements) && !$json && ($hh || $organization)) { - echo CRM_Utils_Array::value('s', $_GET); - } - } - } - - if (isset($_GET['sh'])) { - echo ""; - CRM_Utils_System::civiExit(); - } - - if (empty($elements)) { - $name = str_replace('%', '', $name); - $elements[] = array( - 'name' => $name, - 'id' => $name, - ); - } - - if ($json) { - CRM_Utils_JSON::output($elements); - } - CRM_Utils_System::civiExit(); - } - /** * Function to delete custom value * diff --git a/CRM/Core/xml/Menu/Contact.xml b/CRM/Core/xml/Menu/Contact.xml index ddba9d7e7c..fb60205d36 100644 --- a/CRM/Core/xml/Menu/Contact.xml +++ b/CRM/Core/xml/Menu/Contact.xml @@ -250,11 +250,6 @@ CiviCRM Blog CRM_Dashlet_Page_Blog - - civicrm/ajax/search - CRM_Contact_Page_AJAX::search - access CiviCRM - civicrm/ajax/relation CRM_Contact_Page_AJAX::relationship -- 2.25.1