From a4cce21a509de3ecbd1044e8d34afa6bb4907231 Mon Sep 17 00:00:00 2001 From: Joe Murray Date: Wed, 20 Nov 2013 12:12:38 -0500 Subject: [PATCH] CRM-13793 assignment in condition code cleanup. Also line 107 fixed apparent bug. --- CRM/Contact/Page/AJAX.php | 48 +++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/CRM/Contact/Page/AJAX.php b/CRM/Contact/Page/AJAX.php index a60304a962..76e6d53fa4 100644 --- a/CRM/Contact/Page/AJAX.php +++ b/CRM/Contact/Page/AJAX.php @@ -104,7 +104,7 @@ class CRM_Contact_Page_AJAX { $returnProperties = array('filter', 'data_type', 'is_active'); $fldValues = array(); CRM_Core_DAO::commonRetrieve('CRM_Core_DAO_CustomField', $params, $cf, $returnProperties); - if (!$cf['id'] || !$cf['is_active'] || $cf['data_type'] = !'ContactReference') { + if (!$cf['id'] || !$cf['is_active'] || $cf['data_type'] != 'ContactReference') { echo "$name|error\n"; CRM_Utils_System::civiExit(); } @@ -428,7 +428,8 @@ class CRM_Contact_Page_AJAX { if (isset($_GET['org']) || isset($_GET['hh'])) { $json = FALSE; - if ($splitName = explode(' :: ', $name)) { + $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)); @@ -575,7 +576,8 @@ WHERE sort_name LIKE '%$name%'"; $customGroupID = CRM_Utils_Type::escape($_REQUEST['groupID'], 'Positive'); CRM_Core_BAO_CustomValue::deleteCustomValue($customValueID, $customGroupID); - if ($contactId = CRM_Utils_Array::value('contactId', $_REQUEST)) { + $contactId = CRM_Utils_Array::value('contactId', $_REQUEST); + if ($contactId) { echo CRM_Contact_BAO_Contact::getCountComponent('custom_' . $_REQUEST['groupID'], $contactId); } @@ -671,7 +673,8 @@ WHERE sort_name LIKE '%$name%'"; else { $noemail = CRM_Utils_Array::value('noemail', $_GET); $queryString = NULL; - if ($name = CRM_Utils_Array::value('name', $_GET)) { + $name = CRM_Utils_Array::value('name', $_GET); + if ($name) { $name = CRM_Utils_Type::escape($name, 'String'); if ($noemail) { $queryString = " cc.sort_name LIKE '%$name%'"; @@ -680,13 +683,16 @@ WHERE sort_name LIKE '%$name%'"; $queryString = " ( cc.sort_name LIKE '%$name%' OR ce.email LIKE '%$name%' ) "; } } - elseif ($cid = CRM_Utils_Array::value('cid', $_GET)) { - //check cid for interger - $contIDS = explode(',', $cid); - foreach ($contIDS as $contID) { - CRM_Utils_Type::escape($contID, 'Integer'); - } - $queryString = " cc.id IN ( $cid )"; + else { + $cid = CRM_Utils_Array::value('cid', $_GET); + if ($cid) { + //check cid for interger + $contIDS = explode(',', $cid); + foreach ($contIDS as $contID) { + CRM_Utils_Type::escape($contID, 'Integer'); + } + $queryString = " cc.id IN ( $cid )"; + } } if ($queryString) { @@ -768,18 +774,22 @@ LIMIT {$offset}, {$rowCount} //check for mobile type $phoneTypes = CRM_Core_OptionGroup::values('phone_type', TRUE, FALSE, FALSE, NULL, 'name'); $mobileType = CRM_Utils_Array::value('Mobile', $phoneTypes); - - if ($name = CRM_Utils_Array::value('name', $_GET)) { + + $name = CRM_Utils_Array::value('name', $_GET); + if ($name) { $name = CRM_Utils_Type::escape($name, 'String'); $queryString = " ( cc.sort_name LIKE '%$name%' OR cp.phone LIKE '%$name%' ) "; } - elseif ($cid = CRM_Utils_Array::value('cid', $_GET)) { - //check cid for interger - $contIDS = explode(',', $cid); - foreach ($contIDS as $contID) { - CRM_Utils_Type::escape($contID, 'Integer'); + else { + $cid = CRM_Utils_Array::value('cid', $_GET); + if ($cid) { + //check cid for interger + $contIDS = explode(',', $cid); + foreach ($contIDS as $contID) { + CRM_Utils_Type::escape($contID, 'Integer'); + } + $queryString = " cc.id IN ( $cid )"; } - $queryString = " cc.id IN ( $cid )"; } if ($queryString) { -- 2.25.1