class CRM_Contact_Form_Search_Custom_ActivitySearch extends CRM_Contact_Form_Search_Custom_Base implements CRM_Contact_Form_Search_Interface {
protected $_formValues;
+ protected $_aclFrom = NULL;
+ protected $_aclWhere = NULL;
/**
* @param $formValues
$targetID = CRM_Utils_Array::key('Activity Targets', $activityContacts);
$sourceID = CRM_Utils_Array::key('Activity Source', $activityContacts);
- return "
+ $from = "
civicrm_activity activity
LEFT JOIN civicrm_activity_contact target
ON activity.id = target.activity_id AND target.record_type_id = {$targetID}
LEFT JOIN civicrm_activity_contact assignment
ON activity.id = assignment.activity_id AND assignment.record_type_id = {$assigneeID}
LEFT JOIN civicrm_contact contact_c
- ON assignment.contact_id = contact_c.id ";
+ ON assignment.contact_id = contact_c.id {$this->_aclFrom}";
+
+ if ($this->_aclWhere) {
+ $this->_where .= " {$this->_aclWhere} ";
+ }
+
+ return $from;
}
/**
* @param int $offset
* @param int $rowcount
* @param null $sort
- * @param boolean $returnSQL Not used; included for consistency with parent; SQL is always returned
+ * @param bool $returnSQL Not used; included for consistency with parent; SQL is always returned
*
* @return string
*/
return NULL;
}
+ /**
+ * @param string $tableAlias
+ */
+ public function buildACLClause($tableAlias = 'contact') {
+ list($this->_aclFrom, $this->_aclWhere) = CRM_Contact_BAO_Contact_Permission::cacheClause($tableAlias);
+ }
+
}
class CRM_Contact_Form_Search_Custom_Basic extends CRM_Contact_Form_Search_Custom_Base implements CRM_Contact_Form_Search_Interface {
protected $_query;
+ protected $_aclFrom = NULL;
+ protected $_aclWhere = NULL;
/**
* @param $formValues
* @return string
*/
public function from() {
- return $this->_query->_fromClause;
+ $this->buildACLClause('contact_a');
+ $from = $this->_query->_fromClause;
+ $from .= "{$this->_aclFrom}";
+ if ($this->_aclWhere) {
+ $this->_where .= " AND {$this->_aclWhere} ";
+ }
+ return $from;
}
/**
return $this->_query;
}
+ /**
+ * @param string $tableAlias
+ */
+ public function buildACLClause($tableAlias = 'contact') {
+ list($this->_aclFrom, $this->_aclWhere) = CRM_Contact_BAO_Contact_Permission::cacheClause($tableAlias);
+ }
+
}
class CRM_Contact_Form_Search_Custom_ContribSYBNT extends CRM_Contact_Form_Search_Custom_Base implements CRM_Contact_Form_Search_Interface {
protected $_formValues;
+ protected $_aclFrom = NULL;
+ protected $_aclWhere = NULL;
public $_permissionedComponent;
/**
* @param int $offset
* @param int $rowcount
* @param null $sort
- * @param boolean $returnSQL Not used; included for consistency with parent; SQL is always returned
+ * @param bool $returnSQL Not used; included for consistency with parent; SQL is always returned
*
* @return string
*/
";
}
-
+ $this->buildACLClause('contact_a');
+ if ($this->_aclWhere) {
+ $where .= " AND {$this->_aclWhere} ";
+ }
$sql = "
SELECT $select
-FROM civicrm_contact AS contact_a
+FROM civicrm_contact AS contact_a {$this->_aclFrom}
LEFT JOIN civicrm_contribution contrib_1 ON contrib_1.contact_id = contact_a.id
$from
WHERE contrib_1.contact_id = contact_a.id
$clauses[] = " xg.contact_id IS NULL ";
}
- return implode(' AND ', $clauses);
+ return "{$this->_where} AND " . implode(' AND ', $clauses);
}
/**
}
}
+ /**
+ * @param string $tableAlias
+ */
+ public function buildACLClause($tableAlias = 'contact') {
+ list($this->_aclFrom, $this->_aclWhere) = CRM_Contact_BAO_Contact_Permission::cacheClause($tableAlias);
+ }
+
}
class CRM_Contact_Form_Search_Custom_ContributionAggregate extends CRM_Contact_Form_Search_Custom_Base implements CRM_Contact_Form_Search_Interface {
protected $_formValues;
+ protected $_aclFrom = NULL;
+ protected $_aclWhere = NULL;
public $_permissionedComponent;
/**
* @return string
*/
public function from() {
- return "
+ $this->buildACLClause('contact_a');
+ $from = "
civicrm_contribution AS contrib,
-civicrm_contact AS contact_a
+civicrm_contact AS contact_a {$this->aclFrom}
";
+ if ($this->_aclWhere) {
+ $this->_where .= " {$this->_aclWhere} ";
+ }
+ return $from;
}
/**
$clauses[] = "contrib.financial_type_id IN ($financial_type_ids)";
}
- return implode(' AND ', $clauses);
+ return "{$this->_where} AND " . implode(' AND ', $clauses);
}
/**
* @param int $offset
* @param int $rowcount
* @param null $sort
- * @param boolean $returnSQL Not used; included for consistency with parent; SQL is always returned
+ * @param bool $returnSQL Not used; included for consistency with parent; SQL is always returned
*
* @return string
*/
return NULL;
}
+ /**
+ * @param string $tableAlias
+ */
+ public function buildACLClause($tableAlias = 'contact') {
+ list($this->_aclFrom, $this->_aclWhere) = CRM_Contact_BAO_Contact_Permission::cacheClause($tableAlias);
+ }
+
}
class CRM_Contact_Form_Search_Custom_DateAdded extends CRM_Contact_Form_Search_Custom_Base implements CRM_Contact_Form_Search_Interface {
protected $_debug = 0;
+ protected $_aclFrom = NULL;
+ protected $_aclWhere = NULL;
/**
* @param $formValues
}
}
// end if( $this->_groups ) condition
-
+ $this->buildACLClause('contact_a');
$from = "FROM civicrm_contact contact_a";
/* We need to join to this again to get the date_added value */
- $from .= " INNER JOIN dates_{$this->_tableName} d ON (contact_a.id = d.id)";
+ $from .= " INNER JOIN dates_{$this->_tableName} d ON (contact_a.id = d.id) {$this->_aclFrom}";
// Only include groups in the search query of one or more Include OR Exclude groups has been selected.
// CRM-6356
$from .= " INNER JOIN Ig_{$this->_tableName} temptable1 ON (contact_a.id = temptable1.contact_id)";
}
+ if ($this->_aclWhere) {
+ $this->_where .= " AND {$this->_aclWhere} ";
+ }
+
return $from;
}
}
}
+ /**
+ * @param string $tableAlias
+ */
+ public function buildACLClause($tableAlias = 'contact') {
+ list($this->_aclFrom, $this->_aclWhere) = CRM_Contact_BAO_Contact_Permission::cacheClause($tableAlias);
+ }
+
}
class CRM_Contact_Form_Search_Custom_EventAggregate extends CRM_Contact_Form_Search_Custom_Base implements CRM_Contact_Form_Search_Interface {
protected $_formValues;
+ protected $_aclFrom = NULL;
+ protected $_aclWhere = NULL;
public $_permissionedComponent;
/**
* @return string
*/
public function from() {
- return "
+ $this->buildACLClause('contact_a');
+ $from = "
civicrm_participant_payment
left join civicrm_participant
on civicrm_participant_payment.participant_id=civicrm_participant.id
on civicrm_contribution.id = civicrm_participant_payment.contribution_id
left join civicrm_option_value on
- ( civicrm_option_value.value = civicrm_event.event_type_id AND civicrm_option_value.option_group_id = 14)";
+ ( 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;
}
/**
* @param int $offset
* @param int $rowcount
* @param null $sort
- * @param boolean $returnSQL Not used; included for consistency with parent; SQL is always returned
+ * @param bool $returnSQL Not used; included for consistency with parent; SQL is always returned
*
* @return string
*/
}
}
+ /**
+ * @param string $tableAlias
+ */
+ public function buildACLClause($tableAlias = 'contact') {
+ list($this->_aclFrom, $this->_aclWhere) = CRM_Contact_BAO_Contact_Permission::cacheClause($tableAlias);
+ }
+
}
protected $_groupTree;
protected $_tables;
protected $_options;
+ protected $_aclFrom = NULL;
+ protected $_aclWhere = NULL;
/**
* @param $formValues
* @return string
*/
public function from() {
- $from = "FROM civicrm_contact contact_a";
+ $this->buildACLClause('contact_a');
+ $from = "FROM civicrm_contact contact_a {$this->_aclFrom}";
$customFrom = array();
// lets do an INNER JOIN so we get only relevant values rather than all values
if (!empty($this->_tables)) {
AND cgc.status = 'Added')";
}
+ if ($this->_aclWhere) {
+ $this->_where .= " AND {$this->_aclWhere} ";
+ }
+
return $from;
}
$where .= ' AND ' . implode(' AND ', $clause);
}
+ $where .= "{$this->_where} ";
+
return $this->whereClause($where, $params);
}
CRM_Utils_System::setTitle($title);
}
+ /**
+ * @param string $tableAlias
+ */
+ public function buildACLClause($tableAlias = 'contact') {
+ list($this->_aclFrom, $this->_aclWhere) = CRM_Contact_BAO_Contact_Permission::cacheClause($tableAlias);
+ }
+
}
*
*/
class CRM_Contact_Form_Search_Custom_PostalMailing extends CRM_Contact_Form_Search_Custom_Base implements CRM_Contact_Form_Search_Interface {
+ protected $_aclFrom = NULL;
+ protected $_aclWhere = NULL;
/**
* @param $formValues
*/
* @return string
*/
public function from() {
- return "
+ $this->buildACLClause('contact_a');
+ $from = "
FROM civicrm_group_contact as cgc,
civicrm_contact as contact_a
LEFT JOIN civicrm_address address ON (address.contact_id = contact_a.id AND
address.is_primary = 1 )
-LEFT JOIN civicrm_state_province state_province ON state_province.id = address.state_province_id
+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;
}
/**
$clause[] = "contact_a.contact_type IN ('Individual','Household')";
if (!empty($clause)) {
- $where = implode(' AND ', $clause);
+ $where = "{$this->_where} AND " . implode(' AND ', $clause);
}
return $this->whereClause($where, $params);
return 'CRM/Contact/Form/Search/Custom.tpl';
}
+ /**
+ * @param string $tableAlias
+ */
+ public function buildACLClause($tableAlias = 'contact') {
+ list($this->_aclFrom, $this->_aclWhere) = CRM_Contact_BAO_Contact_Permission::cacheClause($tableAlias);
+ }
+
}
class CRM_Contact_Form_Search_Custom_PriceSet extends CRM_Contact_Form_Search_Custom_Base implements CRM_Contact_Form_Search_Interface {
protected $_eventID = NULL;
-
+ protected $_aclFrom = NULL;
+ protected $_aclWhere = NULL;
protected $_tableName = NULL;
public $_permissionedComponent;
* @return string
*/
public function from() {
- return "
+ $this->buildACLClause('contact_a');
+ $from = "
FROM civicrm_contact contact_a
-INNER JOIN {$this->_tableName} tempTable ON ( tempTable.contact_id = contact_a.id )
+INNER JOIN {$this->_tableName} tempTable ON ( tempTable.contact_id = contact_a.id ) {$this->_aclFrom}
";
+ if ($this->_aclWhere) {
+ $this->_where .= " AND {$this->_aclWhere} ";
+ }
+
+ return $from;
}
/**
}
}
+ /**
+ * @param string $tableAlias
+ */
+ public function buildACLClause($tableAlias = 'contact') {
+ list($this->_aclFrom, $this->_aclWhere) = CRM_Contact_BAO_Contact_Permission::cacheClause($tableAlias);
+ }
+
}
protected $_latitude = NULL;
protected $_longitude = NULL;
protected $_distance = NULL;
+ protected $_aclFrom = NULL;
+ protected $_aclWhere = NULL;
/**
* @param $formValues
* @return string
*/
public function from() {
+ $this->buildACLClause('contact_a');
$f = "
FROM civicrm_contact contact_a
LEFT JOIN civicrm_address address ON ( address.contact_id = contact_a.id AND
address.is_primary = 1 )
LEFT JOIN civicrm_state_province state_province ON state_province.id = address.state_province_id
-LEFT JOIN civicrm_country country ON country.id = address.country_id
+LEFT JOIN civicrm_country country ON country.id = address.country_id {$this->_aclFrom}
";
// This prevents duplicate rows when contacts have more than one tag any you select "any tag"
";
}
+ if ($this->_aclWhere) {
+ $this->_where .= " AND {$this->_aclWhere} ";
+ }
+
return $f;
}
}
$where .= " AND contact_a.is_deleted != 1 ";
+ $where .= "{$this->_where}";
return $this->whereClause($where, $params);
}
}
}
+ /**
+ * @param string $tableAlias
+ */
+ public function buildACLClause($tableAlias = 'contact') {
+ list($this->_aclFrom, $this->_aclWhere) = CRM_Contact_BAO_Contact_Permission::cacheClause($tableAlias);
+ }
+
}
class CRM_Contact_Form_Search_Custom_RandomSegment extends CRM_Contact_Form_Search_Custom_Base implements CRM_Contact_Form_Search_Interface {
protected $_debug = 0;
+ protected $_aclFrom = NULL;
+ protected $_aclWhere = NULL;
/**
* @param $formValues
CRM_Core_DAO::executeQuery($insertGroupNameQuery);
}
}
+ $this->buildACLClause('contact_a');
$from = "FROM civicrm_contact contact_a";
$from = "FROM random_{$this->_tableName} random";
- $from .= " INNER JOIN civicrm_contact contact_a ON random.id = contact_a.id";
+ $from .= " INNER JOIN civicrm_contact contact_a ON random.id = contact_a.id {$this->_aclFrom}";
$from .= " $fromTail";
+ if ($this->_aclWhere) {
+ $this->_where .= " AND {$this->_aclWhere} ";
+ }
+
return $from;
+
}
/**
return NULL;
}
+ /**
+ * @param string $tableAlias
+ */
+ public function buildACLClause($tableAlias = 'contact') {
+ list($this->_aclFrom, $this->_aclWhere) = CRM_Contact_BAO_Contact_Permission::cacheClause($tableAlias);
+ }
+
}
*
*/
class CRM_Contact_Form_Search_Custom_Sample extends CRM_Contact_Form_Search_Custom_Base implements CRM_Contact_Form_Search_Interface {
+ protected $_aclFrom = NULL;
+ protected $_aclWhere = NULL;
/**
* @param $formValues
*/
* @return string
*/
public function from() {
- return "
+ $this->buildACLClause('contact_a');
+ $from = "
FROM civicrm_contact contact_a
LEFT JOIN civicrm_address address ON ( address.contact_id = contact_a.id AND
address.is_primary = 1 )
LEFT JOIN civicrm_email ON ( civicrm_email.contact_id = contact_a.id AND
civicrm_email.is_primary = 1 )
-LEFT JOIN civicrm_state_province state_province ON state_province.id = address.state_province_id
+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;
}
/**
public function where($includeContactIDs = FALSE) {
$params = array();
$where = "contact_a.contact_type = 'Household'";
+ $where .= "{$this->_where}";
$count = 1;
$clause = array();
}
}
+ /**
+ * @param string $tableAlias
+ */
+ public function buildACLClause($tableAlias = 'contact') {
+ list($this->_aclFrom, $this->_aclWhere) = CRM_Contact_BAO_Contact_Permission::cacheClause($tableAlias);
+ }
+
}
class CRM_Contact_Form_Search_Custom_TagContributions extends CRM_Contact_Form_Search_Custom_Base implements CRM_Contact_Form_Search_Interface {
protected $_formValues;
+ protected $_aclFrom = NULL;
+ protected $_aclWhere = NULL;
public $_permissionedComponent;
/**
* @return string
*/
public function from() {
- return "
+ $this->buildACLClause('contact_a');
+ $from = "
civicrm_contribution,
civicrm_contact contact_a
LEFT JOIN civicrm_entity_tag ON ( civicrm_entity_tag.entity_table = 'civicrm_contact' AND
civicrm_entity_tag.entity_id = contact_a.id )
- LEFT JOIN civicrm_tag ON civicrm_tag.id = civicrm_entity_tag.tag_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;
}
/*
* @param int $offset
* @param int $rowcount
* @param null $sort
- * @param boolean $returnSQL Not used; included for consistency with parent; SQL is always returned
+ * @param bool $returnSQL Not used; included for consistency with parent; SQL is always returned
*
* @return string
*/
return NULL;
}
+ /**
+ * @param string $tableAlias
+ */
+ public function buildACLClause($tableAlias = 'contact') {
+ list($this->_aclFrom, $this->_aclWhere) = CRM_Contact_BAO_Contact_Permission::cacheClause($tableAlias);
+ }
+
}
*
*/
class CRM_Contact_Form_Search_Custom_ZipCodeRange extends CRM_Contact_Form_Search_Custom_Base implements CRM_Contact_Form_Search_Interface {
+ protected $_aclFrom = NULL;
+ protected $_aclWhere = NULL;
/**
* @param $formValues
*/
* @return string
*/
public function from() {
- return "
+ $this->buildACLClause('contact_a');
+ $from = "
FROM civicrm_contact contact_a
LEFT JOIN civicrm_address address ON ( address.contact_id = contact_a.id AND
address.is_primary = 1 )
LEFT JOIN civicrm_email email ON ( email.contact_id = contact_a.id AND
- email.is_primary = 1 )
+ email.is_primary = 1 ) {$this->_aclFrom}
";
+ if ($this->_aclWhere) {
+ $this->_where .= " {$this->_aclWhere} ";
+ }
+ return $from;
}
/**
2 => array(trim($high), 'Integer'),
);
+ $where .= "{$this->_where} ";
+
return $this->whereClause($where, $params);
}
}
}
+ /**
+ * @param string $tableAlias
+ */
+ public function buildACLClause($tableAlias = 'contact') {
+ list($this->_aclFrom, $this->_aclWhere) = CRM_Contact_BAO_Contact_Permission::cacheClause($tableAlias);
+ }
+
}