Skip to content

Commit

Permalink
CRM-17867 - Set checkPermission before running getAclClause
Browse files Browse the repository at this point in the history
  • Loading branch information
colemanw committed Mar 15, 2016
1 parent 675ddc4 commit f06de23
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
6 changes: 4 additions & 2 deletions Civi/API/SelectQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,15 @@ abstract class SelectQuery {
/**
* @var string|bool
*/
public $checkPermissions;
protected $checkPermissions;

protected $apiVersion;

/**
* @param string $entity
* @param bool $checkPermissions
*/
public function __construct($entity) {
public function __construct($entity, $checkPermissions) {
$this->entity = $entity;
require_once 'api/v3/utils.php';
$baoName = _civicrm_api3_get_BAO($entity);
Expand All @@ -106,6 +107,7 @@ public function __construct($entity) {
$bao->free();

// Add ACLs first to avoid redundant subclauses
$this->checkPermissions = $checkPermissions;
$this->query->where($this->getAclClause(self::MAIN_TABLE_ALIAS, $baoName));
}

Expand Down
4 changes: 2 additions & 2 deletions Civi/Test/HeadlessInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @package Civi\Test
*
* To run your test against a fake, headless database, flag it with the
* HeadlessInterface. CiviTestListener will automatically boot
* HeadlessInterface. CiviTestListener will automatically boot Civi.
*
* Alternatively, if you wish to run a test in a live (CMS-enabled) environment,
* flag it with EndToEndInterface.
Expand All @@ -23,7 +23,7 @@
interface HeadlessInterface {

/**
* The setupHeadless functions runs at the start of each test case, right before
* The setupHeadless function runs at the start of each test case, right before
* the headless environment reboots.
*
* It should perform any necessary steps required for putting the database
Expand Down
3 changes: 1 addition & 2 deletions api/v3/utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -1337,7 +1337,7 @@ function _civicrm_api3_basic_get($bao_name, $params, $returnAsSuccess = TRUE, $e
$entity = CRM_Core_DAO_AllCoreTables::getBriefName(str_replace('_BAO_', '_DAO_', $bao_name));
$options = _civicrm_api3_get_options_from_params($params);

$query = new \Civi\API\Api3SelectQuery($entity);
$query = new \Civi\API\Api3SelectQuery($entity, CRM_Utils_Array::value('check_permissions', $params, FALSE));
$query->where = $params;
if ($options['is_count']) {
$query->select = array('count');
Expand All @@ -1349,7 +1349,6 @@ function _civicrm_api3_basic_get($bao_name, $params, $returnAsSuccess = TRUE, $e
}
$query->limit = $options['limit'];
$query->offset = $options['offset'];
$query->checkPermissions = CRM_Utils_Array::value('check_permissions', $params, FALSE);
$query->merge($sql);
$result = $query->run();

Expand Down

0 comments on commit f06de23

Please sign in to comment.