From 20e41014b93ff35ec1937117b0935254e9f3bb24 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Thu, 14 Jan 2016 20:33:52 -0500 Subject: [PATCH] CRM-17645 - More consistent function naming --- CRM/Case/BAO/Case.php | 2 +- CRM/Case/BAO/CaseContact.php | 4 ++-- CRM/Case/BAO/Query.php | 2 +- CRM/Contact/BAO/Contact.php | 2 +- CRM/Contact/BAO/Relationship.php | 2 +- CRM/Core/BAO/UFMatch.php | 2 +- CRM/Core/DAO.php | 8 ++++---- CRM/Core/DAO/permissions.php | 8 ++++---- Civi/API/SelectQuery.php | 2 +- 9 files changed, 16 insertions(+), 16 deletions(-) diff --git a/CRM/Case/BAO/Case.php b/CRM/Case/BAO/Case.php index fc1ec29308..b3e77b25ab 100644 --- a/CRM/Case/BAO/Case.php +++ b/CRM/Case/BAO/Case.php @@ -3121,7 +3121,7 @@ WHERE id IN (' . implode(',', $copiedActivityIds) . ')'; /** * @inheritDoc */ - public function apiWhereClause() { + public function addSelectWhereClause() { $clauses = array( 'id' => array(), // Only case admins can view deleted cases diff --git a/CRM/Case/BAO/CaseContact.php b/CRM/Case/BAO/CaseContact.php index dbb50a0287..08751a224c 100644 --- a/CRM/Case/BAO/CaseContact.php +++ b/CRM/Case/BAO/CaseContact.php @@ -80,7 +80,7 @@ class CRM_Case_BAO_CaseContact extends CRM_Case_DAO_CaseContact { /** * @inheritDoc */ - public function apiWhereClause() { + public function addSelectWhereClause() { // In order to make things easier for downstream developers, we reuse and adapt case acls here. // This doesn't yield the most straightforward query, but hopefully the sql engine will sort it out. $clauses = array( @@ -90,7 +90,7 @@ class CRM_Case_BAO_CaseContact extends CRM_Case_DAO_CaseContact { ); $caseSubclauses = array(); $caseBao = new CRM_Case_BAO_Case(); - foreach ($caseBao->apiWhereClause() as $field => $fieldClauses) { + foreach ($caseBao->addSelectWhereClause() as $field => $fieldClauses) { if ($field == 'id' && $fieldClauses) { $clauses['case_id'] = array_merge($clauses['case_id'], (array) $fieldClauses); } diff --git a/CRM/Case/BAO/Query.php b/CRM/Case/BAO/Query.php index cbfb04b1e7..19867be3c0 100644 --- a/CRM/Case/BAO/Query.php +++ b/CRM/Case/BAO/Query.php @@ -233,7 +233,7 @@ class CRM_Case_BAO_Query { } } // Add acl clause - $aclClauses = array_filter(CRM_Case_BAO_Case::getAclClause()); + $aclClauses = array_filter(CRM_Case_BAO_Case::getSelectWhereClause()); foreach ($aclClauses as $clause) { $query->_where[0][] = $clause; } diff --git a/CRM/Contact/BAO/Contact.php b/CRM/Contact/BAO/Contact.php index 5d7819955d..a8813dc283 100644 --- a/CRM/Contact/BAO/Contact.php +++ b/CRM/Contact/BAO/Contact.php @@ -3428,7 +3428,7 @@ LEFT JOIN civicrm_address add2 ON ( add1.master_id = add2.id ) /** * @inheritDoc */ - public function apiWhereClause() { + public function addSelectWhereClause() { $clauses = array( 'id' => CRM_Contact_BAO_Contact_Permission::cacheSubquery(), ); diff --git a/CRM/Contact/BAO/Relationship.php b/CRM/Contact/BAO/Relationship.php index cf5b940251..58ed491d0f 100644 --- a/CRM/Contact/BAO/Relationship.php +++ b/CRM/Contact/BAO/Relationship.php @@ -2104,7 +2104,7 @@ AND cc.sort_name LIKE '%$name%'"; /** * @inheritDoc */ - public function apiWhereClause() { + public function addSelectWhereClause() { // Generate an acl clause for both contacts in the relationship $clauses = array( 'contact_id_a' => CRM_Contact_BAO_Contact_Permission::cacheSubquery(), diff --git a/CRM/Core/BAO/UFMatch.php b/CRM/Core/BAO/UFMatch.php index af8d7f3513..151252ce81 100644 --- a/CRM/Core/BAO/UFMatch.php +++ b/CRM/Core/BAO/UFMatch.php @@ -636,7 +636,7 @@ AND domain_id = %4 /** * @inheritDoc */ - public function apiWhereClause() { + public function addSelectWhereClause() { // Prevent default behavior of joining ACLs onto the contact_id field $clauses = array(); CRM_Utils_Hook::selectWhereClause($this, $clauses); diff --git a/CRM/Core/DAO.php b/CRM/Core/DAO.php index 43e88b9610..1fed8486c7 100644 --- a/CRM/Core/DAO.php +++ b/CRM/Core/DAO.php @@ -2453,7 +2453,7 @@ SELECT contact_id } /** - * Generates clauses suitable for adding to WHERE or ON when doing an api.get for this entity + * Generates acl clauses suitable for adding to WHERE or ON when doing an api.get for this entity * * Return format is in the form of fieldname => clauses starting with an operator. e.g.: * @code @@ -2466,7 +2466,7 @@ SELECT contact_id * * @return array */ - public function apiWhereClause() { + public function addSelectWhereClause() { $clauses = array(); $fields = $this->fields(); $cidField = CRM_Utils_Array::value('contact_id', $fields); @@ -2481,13 +2481,13 @@ SELECT contact_id * @param string $tableAlias * @return array */ - public static function getAclClause($tableAlias = NULL) { + public static function getSelectWhereClause($tableAlias = NULL) { $bao = new static(); if ($tableAlias === NULL) { $tableAlias = $bao->tableName(); } $clauses = array(); - foreach ((array) $bao->apiWhereClause() as $field => $vals) { + foreach ((array) $bao->addSelectWhereClause() as $field => $vals) { $clauses[$field] = NULL; if ($vals) { $clauses[$field] = "`$tableAlias`.`$field` " . implode(" AND `$tableAlias`.`$field` ", (array) $vals); diff --git a/CRM/Core/DAO/permissions.php b/CRM/Core/DAO/permissions.php index a09cbadbce..dab7812857 100644 --- a/CRM/Core/DAO/permissions.php +++ b/CRM/Core/DAO/permissions.php @@ -108,7 +108,7 @@ function _civicrm_api3_permissions($entity, $action, &$params) { // Contact-related data permissions. // CRM-14094 - Users can edit and delete contact-related objects using inline edit with 'edit all contacts' permission $permissions['address'] = array( - // get is managed by BAO::apiWhereClause + // get is managed by BAO::addSelectWhereClause 'get' => array(), 'default' => array( 'access CiviCRM', @@ -119,7 +119,7 @@ function _civicrm_api3_permissions($entity, $action, &$params) { $permissions['phone'] = $permissions['address']; $permissions['website'] = $permissions['address']; $permissions['im'] = $permissions['address']; - // @todo - implement CRM_Core_BAO_EntityTag::apiWhereClause and remove this heavy-handed restriction + // @todo - implement CRM_Core_BAO_EntityTag::addSelectWhereClause and remove this heavy-handed restriction $permissions['entity_tag'] = array('get' => array('access CiviCRM', 'view all contacts')) + $permissions['address']; // @todo - ditto $permissions['note'] = $permissions['entity_tag']; @@ -134,7 +134,7 @@ function _civicrm_api3_permissions($entity, $action, &$params) { //relationship permissions $permissions['relationship'] = array( - // get is managed by BAO::apiWhereClause + // get is managed by BAO::addSelectWhereClause 'get' => array(), 'delete' => array( 'access CiviCRM', @@ -179,7 +179,7 @@ function _civicrm_api3_permissions($entity, $action, &$params) { 'delete in CiviCase', ), 'default' => array( - // This is the minimum permission needed. Finer-grained access is controlled by CRM_Case_BAO_Case::apiWhereClause + // This is the minimum permission needed. Finer-grained access is controlled by CRM_Case_BAO_Case::addSelectWhereClause 'access my cases and activities', ), ); diff --git a/Civi/API/SelectQuery.php b/Civi/API/SelectQuery.php index ceea6f5a1d..728f9377a2 100644 --- a/Civi/API/SelectQuery.php +++ b/Civi/API/SelectQuery.php @@ -518,7 +518,7 @@ class SelectQuery { if (count($stack) === 1 && in_array($stack[0], $this->aclFields)) { return NULL; } - $clauses = $baoName::getAclClause($tableAlias); + $clauses = $baoName::getSelectWhereClause($tableAlias); if (!$stack) { // Track field clauses added to the main entity $this->aclFields = array_keys($clauses); -- 2.25.1