<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.6 |
+ | CiviCRM version 4.7 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014 |
+ | Copyright CiviCRM LLC (c) 2004-2015 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2014
+ * @copyright CiviCRM LLC (c) 2004-2015
* $Id$
*
*/
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
*/
$from = $this->from();
+ $select = $this->select();
if ($justIDs) {
- $select = $this->select();
$select .= ', contact_a.id, display_name';
}
else {
- $select = $this->select();
$select = "
DISTINCT contact_a.id as contact_id,
contact_a.display_name as display_name,
- $select
-";
-
+ $select ";
}
-
+ $this->buildACLClause('contact_a');
$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
$dao = CRM_Core_DAO::executeQuery($query);
$sql = "SELECT contact_a.id as contact_id FROM CustomSearch_SYBNT_temp as contact_a";
}
-
return $sql;
}
$clauses[] = " xg.contact_id IS NULL ";
}
-
+ if ($this->_aclWhere) {
+ $clauses[] .= " {$this->_aclWhere} ";
+ }
return implode(' AND ', $clauses);
}
}
}
+ /**
+ * @param string $tableAlias
+ */
+ public function buildACLClause($tableAlias = 'contact') {
+ list($this->_aclFrom, $this->_aclWhere) = CRM_Contact_BAO_Contact_Permission::cacheClause($tableAlias);
+ }
+
}