From 47b8444fb8b33b527e8cedca31950589a7d57434 Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Thu, 25 Jun 2015 00:25:56 +0000 Subject: [PATCH] CRM-9764 Fix underfined property notices noticed by David --- CRM/Contact/Form/Search/Custom/ActivitySearch.php | 9 +++++---- CRM/Contact/Form/Search/Custom/Basic.php | 6 +++--- CRM/Contact/Form/Search/Custom/ContribSYBNT.php | 6 +++--- .../Form/Search/Custom/ContributionAggregate.php | 12 +++++++----- CRM/Contact/Form/Search/Custom/DateAdded.php | 10 +++++----- CRM/Contact/Form/Search/Custom/EventAggregate.php | 6 +++--- CRM/Contact/Form/Search/Custom/MultipleValues.php | 7 +++---- CRM/Contact/Form/Search/Custom/PostalMailing.php | 9 +++++---- CRM/Contact/Form/Search/Custom/PriceSet.php | 10 +++++----- CRM/Contact/Form/Search/Custom/Proximity.php | 10 +++++----- CRM/Contact/Form/Search/Custom/RandomSegment.php | 10 ++++++---- CRM/Contact/Form/Search/Custom/Sample.php | 7 ++++--- CRM/Contact/Form/Search/Custom/TagContributions.php | 6 +++--- CRM/Contact/Form/Search/Custom/ZipCodeRange.php | 7 ++++--- 14 files changed, 61 insertions(+), 54 deletions(-) diff --git a/CRM/Contact/Form/Search/Custom/ActivitySearch.php b/CRM/Contact/Form/Search/Custom/ActivitySearch.php index 9590cb644f..6072f7c18b 100644 --- a/CRM/Contact/Form/Search/Custom/ActivitySearch.php +++ b/CRM/Contact/Form/Search/Custom/ActivitySearch.php @@ -256,6 +256,7 @@ ORDER BY contact_a.sort_name'; * @return string */ public function from() { + $this->buildACLClause('contact_a'); $activityContacts = CRM_Core_OptionGroup::values('activity_contacts', FALSE, FALSE, FALSE, NULL, 'name'); $assigneeID = CRM_Utils_Array::key('Activity Assignees', $activityContacts); $targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts); @@ -282,10 +283,6 @@ ORDER BY contact_a.sort_name'; LEFT JOIN civicrm_contact contact_c ON assignment.contact_id = contact_c.id {$this->_aclFrom}"; - if ($this->_aclWhere) { - $this->_where .= " {$this->_aclWhere} "; - } - return $from; } @@ -363,6 +360,10 @@ ORDER BY contact_a.sort_name'; } } + if ($this->_aclWhere) { + $clauses[] = " {$this->_aclWhere} "; + } + return implode(' AND ', $clauses); } diff --git a/CRM/Contact/Form/Search/Custom/Basic.php b/CRM/Contact/Form/Search/Custom/Basic.php index f4256b02f1..b920a45188 100644 --- a/CRM/Contact/Form/Search/Custom/Basic.php +++ b/CRM/Contact/Form/Search/Custom/Basic.php @@ -183,9 +183,6 @@ class CRM_Contact_Form_Search_Custom_Basic extends CRM_Contact_Form_Search_Custo $this->buildACLClause('contact_a'); $from = $this->_query->_fromClause; $from .= "{$this->_aclFrom}"; - if ($this->_aclWhere) { - $this->_where .= " AND {$this->_aclWhere} "; - } return $from; } @@ -196,6 +193,9 @@ class CRM_Contact_Form_Search_Custom_Basic extends CRM_Contact_Form_Search_Custo */ public function where($includeContactIDs = FALSE) { if ($whereClause = $this->_query->whereClause()) { + if ($this->_aclWhere) { + $whereCluase .= " AND {$this->_aclWhere} "; + } return $whereClause; } return ' (1) '; diff --git a/CRM/Contact/Form/Search/Custom/ContribSYBNT.php b/CRM/Contact/Form/Search/Custom/ContribSYBNT.php index 1d51a84d71..cb9d54e226 100644 --- a/CRM/Contact/Form/Search/Custom/ContribSYBNT.php +++ b/CRM/Contact/Form/Search/Custom/ContribSYBNT.php @@ -181,9 +181,6 @@ class CRM_Contact_Form_Search_Custom_ContribSYBNT extends CRM_Contact_Form_Searc } $this->buildACLClause('contact_a'); - if ($this->_aclWhere) { - $where .= " AND {$this->_aclWhere} "; - } $sql = " SELECT $select FROM civicrm_contact AS contact_a {$this->_aclFrom} @@ -341,6 +338,9 @@ AND c.receive_date < {$this->start_date_1} $clauses[] = " xg.contact_id IS NULL "; } + if ($this->_aclWhere) { + $clauses[] .= " {$this->_aclWhere} "; + } return implode(' AND ', $clauses); } diff --git a/CRM/Contact/Form/Search/Custom/ContributionAggregate.php b/CRM/Contact/Form/Search/Custom/ContributionAggregate.php index 519be745de..fdbf2435d7 100644 --- a/CRM/Contact/Form/Search/Custom/ContributionAggregate.php +++ b/CRM/Contact/Form/Search/Custom/ContributionAggregate.php @@ -184,9 +184,7 @@ $having civicrm_contribution AS contrib, civicrm_contact AS contact_a {$this->_aclFrom} "; - if ($this->_aclWhere) { - $this->_where .= " {$this->_aclWhere} "; - } + return $from; } @@ -233,8 +231,12 @@ civicrm_contact AS contact_a {$this->_aclFrom} $financial_type_ids = implode(',', array_keys($this->_formValues['financial_type_id'])); $clauses[] = "contrib.financial_type_id IN ($financial_type_ids)"; } - - return implode(' AND ', $clauses); + if ($this->_aclWhere) { + return " {$this->_aclWhere} " . implode(' AND ', $clauses); + } + else { + return implode(' AND ', $clauses); + } } /** diff --git a/CRM/Contact/Form/Search/Custom/DateAdded.php b/CRM/Contact/Form/Search/Custom/DateAdded.php index 43baeb5d34..a2106ff25e 100644 --- a/CRM/Contact/Form/Search/Custom/DateAdded.php +++ b/CRM/Contact/Form/Search/Custom/DateAdded.php @@ -388,10 +388,6 @@ class CRM_Contact_Form_Search_Custom_DateAdded extends CRM_Contact_Form_Search_C $from .= " INNER JOIN Ig_{$this->_tableName} temptable1 ON (contact_a.id = temptable1.contact_id)"; } - if ($this->_aclWhere) { - $this->_where .= " AND {$this->_aclWhere} "; - } - return $from; } @@ -401,7 +397,11 @@ class CRM_Contact_Form_Search_Custom_DateAdded extends CRM_Contact_Form_Search_C * @return string */ public function where($includeContactIDs = FALSE) { - return '(1)'; + $where = '(1)'; + if ($this->_aclWhere) { + $where = " AND {$this->_aclWhere} "; + } + return $where; } /** diff --git a/CRM/Contact/Form/Search/Custom/EventAggregate.php b/CRM/Contact/Form/Search/Custom/EventAggregate.php index 5eb28b8a18..be637b99de 100644 --- a/CRM/Contact/Form/Search/Custom/EventAggregate.php +++ b/CRM/Contact/Form/Search/Custom/EventAggregate.php @@ -205,9 +205,6 @@ class CRM_Contact_Form_Search_Custom_EventAggregate extends CRM_Contact_Form_Sea left join civicrm_option_value on ( civicrm_option_value.value = civicrm_event.event_type_id AND civicrm_option_value.option_group_id = 14) {$this->_aclFrom}"; - if ($this->_aclWhere) { - $this->_where .= "{$this->_aclWhere} "; - } return $from; } @@ -265,6 +262,9 @@ class CRM_Contact_Form_Search_Custom_EventAggregate extends CRM_Contact_Form_Sea $event_type_ids = implode(',', array_keys($this->_formValues['event_type_id'])); $clauses[] = "civicrm_event.event_type_id IN ( $event_type_ids )"; } + if ($this->_aclWhere) { + $clauses[] = "{$this->_aclWhere} "; + } return implode(' AND ', $clauses); } diff --git a/CRM/Contact/Form/Search/Custom/MultipleValues.php b/CRM/Contact/Form/Search/Custom/MultipleValues.php index 701545516f..1323924668 100644 --- a/CRM/Contact/Form/Search/Custom/MultipleValues.php +++ b/CRM/Contact/Form/Search/Custom/MultipleValues.php @@ -229,10 +229,6 @@ contact_a.sort_name as sort_name, AND cgc.status = 'Added')"; } - if ($this->_aclWhere) { - $this->_where .= " AND {$this->_aclWhere} "; - } - return $from; } @@ -277,6 +273,9 @@ contact_a.sort_name as sort_name, if ($this->_group) { $clause[] = "cgc.group_id = {$this->_group}"; } + if ($this->_aclWhere) { + $clause[] = " AND {$this->_aclWhere} "; + } $where = '( 1 )'; if (!empty($clause)) { diff --git a/CRM/Contact/Form/Search/Custom/PostalMailing.php b/CRM/Contact/Form/Search/Custom/PostalMailing.php index 0f33fc6692..317cfc05e6 100644 --- a/CRM/Contact/Form/Search/Custom/PostalMailing.php +++ b/CRM/Contact/Form/Search/Custom/PostalMailing.php @@ -121,9 +121,6 @@ LEFT JOIN civicrm_address address ON (address.contact_id = c address.is_primary = 1 ) LEFT JOIN civicrm_state_province state_province ON state_province.id = address.state_province_id {$this->_aclFrom} "; - if ($this->_aclWhere) { - $this->_where .= " {$this->_aclWhere} "; - } return $from; } @@ -150,7 +147,11 @@ LEFT JOIN civicrm_state_province state_province ON state_province.id = address. (select cr.contact_id_b from civicrm_relationship cr where (cr.contact_id_a = cgc.contact_id AND (cr.relationship_type_id = 7 OR cr.relationship_type_id = 6))), cgc.contact_id )"; $clause[] = "contact_a.contact_type IN ('Individual','Household')"; - + + if ($this->_aclWhere) { + $clause[] = " {$this->_aclWhere} "; + } + if (!empty($clause)) { $where = implode(' AND ', $clause); } diff --git a/CRM/Contact/Form/Search/Custom/PriceSet.php b/CRM/Contact/Form/Search/Custom/PriceSet.php index 4793e00a11..01c39a5022 100644 --- a/CRM/Contact/Form/Search/Custom/PriceSet.php +++ b/CRM/Contact/Form/Search/Custom/PriceSet.php @@ -315,10 +315,6 @@ contact_a.display_name as display_name"; FROM civicrm_contact contact_a INNER JOIN {$this->_tableName} tempTable ON ( tempTable.contact_id = contact_a.id ) {$this->_aclFrom} "; - if ($this->_aclWhere) { - $this->_where .= " AND {$this->_aclWhere} "; - } - return $from; } @@ -328,7 +324,11 @@ INNER JOIN {$this->_tableName} tempTable ON ( tempTable.contact_id = contact_a.i * @return string */ public function where($includeContactIDs = FALSE) { - return ' ( 1 ) '; + $where = ' ( 1 ) '; + if ($this->_aclWhere) { + $where = " AND {$this->_aclWhere} "; + } + return $where; } /** diff --git a/CRM/Contact/Form/Search/Custom/Proximity.php b/CRM/Contact/Form/Search/Custom/Proximity.php index 3f9e8c632a..47633813d6 100644 --- a/CRM/Contact/Form/Search/Custom/Proximity.php +++ b/CRM/Contact/Form/Search/Custom/Proximity.php @@ -222,10 +222,6 @@ LEFT JOIN civicrm_group_contact cgc ON ( cgc.contact_id = contact_a.id AND cgc.s "; } - if ($this->_aclWhere) { - $this->_where .= " AND {$this->_aclWhere} "; - } - return $f; } @@ -257,7 +253,11 @@ AND cgc.group_id = {$this->_group} $where .= " AND contact_a.is_deleted != 1 "; $where .= "{$this->_where}"; - + + if ($this->_aclWhere) { + $where .= " AND {$this->_aclWhere} "; + } + return $this->whereClause($where, $params); } diff --git a/CRM/Contact/Form/Search/Custom/RandomSegment.php b/CRM/Contact/Form/Search/Custom/RandomSegment.php index d590a34834..0e972f2404 100644 --- a/CRM/Contact/Form/Search/Custom/RandomSegment.php +++ b/CRM/Contact/Form/Search/Custom/RandomSegment.php @@ -331,10 +331,6 @@ class CRM_Contact_Form_Search_Custom_RandomSegment extends CRM_Contact_Form_Sear $from .= " $fromTail"; - if ($this->_aclWhere) { - $this->_where .= " AND {$this->_aclWhere} "; - } - return $from; } @@ -345,6 +341,12 @@ class CRM_Contact_Form_Search_Custom_RandomSegment extends CRM_Contact_Form_Sear * @return string */ public function where($includeContactIDs = FALSE) { + $where = '(1)'; + + if ($this->_aclWhere) { + $where = " AND {$this->_aclWhere} "; + } + return '(1)'; } diff --git a/CRM/Contact/Form/Search/Custom/Sample.php b/CRM/Contact/Form/Search/Custom/Sample.php index 99929e5345..6f11d7830f 100644 --- a/CRM/Contact/Form/Search/Custom/Sample.php +++ b/CRM/Contact/Form/Search/Custom/Sample.php @@ -149,9 +149,6 @@ LEFT JOIN civicrm_email ON ( civicrm_email.contact_id = contact_a.id A civicrm_email.is_primary = 1 ) LEFT JOIN civicrm_state_province state_province ON state_province.id = address.state_province_id {$this->_aclFrom} "; - if ($this->_aclWhere) { - $this->_where .= " AND {$this->_aclWhere} "; - } return $from; } @@ -192,6 +189,10 @@ LEFT JOIN civicrm_state_province state_province ON state_province.id = address.s $params[$count] = array($state, 'Integer'); $clause[] = "state_province.id = %{$count}"; } + + if ($this->_aclWhere) { + $clause[] = " AND {$this->_aclWhere} "; + } if (!empty($clause)) { $where .= ' AND ' . implode(' AND ', $clause); diff --git a/CRM/Contact/Form/Search/Custom/TagContributions.php b/CRM/Contact/Form/Search/Custom/TagContributions.php index c57cbbea1b..30a3fae809 100644 --- a/CRM/Contact/Form/Search/Custom/TagContributions.php +++ b/CRM/Contact/Form/Search/Custom/TagContributions.php @@ -154,9 +154,6 @@ WHERE $where civicrm_entity_tag.entity_id = contact_a.id ) LEFT JOIN civicrm_tag ON civicrm_tag.id = civicrm_entity_tag.tag_id {$this->_aclFrom} "; - if ($this->_aclWhere) { - $this->_where .= " {$this->_aclWhere} "; - } return $from; } @@ -209,6 +206,9 @@ WHERE $where $clauses[] = "contact_a.id IN ( $contactIDs )"; } } + if ($this->_aclWhere) { + $clauses[] = " {$this->_aclWhere} "; + } return implode(' AND ', $clauses); } diff --git a/CRM/Contact/Form/Search/Custom/ZipCodeRange.php b/CRM/Contact/Form/Search/Custom/ZipCodeRange.php index 8ca17281b9..f661731e1b 100644 --- a/CRM/Contact/Form/Search/Custom/ZipCodeRange.php +++ b/CRM/Contact/Form/Search/Custom/ZipCodeRange.php @@ -140,9 +140,6 @@ LEFT JOIN civicrm_address address ON ( address.contact_id = contact_a.id A LEFT JOIN civicrm_email email ON ( email.contact_id = contact_a.id AND email.is_primary = 1 ) {$this->_aclFrom} "; - if ($this->_aclWhere) { - $this->_where .= " {$this->_aclWhere} "; - } return $from; } @@ -175,6 +172,10 @@ LEFT JOIN civicrm_email email ON ( email.contact_id = contact_a.id AND 2 => array(trim($high), 'Integer'), ); + if ($this->_aclWhere) { + $where .= " AND {$this->_aclWhere} "; + } + return $this->whereClause($where, $params); } -- 2.25.1