Comment fix
[civicrm-core.git] / tests / phpunit / CRMTraits / ACL / PermissionTrait.php
CommitLineData
2f6c641a 1<?php
2/*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2018 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
9 | |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
13 | |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
18 | |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
26 */
27
28/**
29 * Trait ACL_Permission_Trait.
30 *
31 * Trait for working with ACLs in tests
32 */
33trait CRMTraits_ACL_PermissionTrait {
34
35 protected $allowedContactId = 0;
36 protected $allowedContacts = [];
37
38 /**
39 * All results returned.
40 *
41 * @implements CRM_Utils_Hook::aclWhereClause
42 *
43 * @param string $type
44 * @param array $tables
45 * @param array $whereTables
46 * @param int $contactID
47 * @param string $where
48 */
49 public function aclWhereHookAllResults($type, &$tables, &$whereTables, &$contactID, &$where) {
50 $where = " (1) ";
51 }
52
53 /**
54 * All but first results returned.
55 *
56 * @implements CRM_Utils_Hook::aclWhereClause
57 *
58 * @param string $type
59 * @param array $tables
60 * @param array $whereTables
61 * @param int $contactID
62 * @param string $where
63 */
64 public function aclWhereOnlySecond($type, &$tables, &$whereTables, &$contactID, &$where) {
65 $where = " contact_a.id > 1";
66 }
67
68 /**
69 * Only specified contact returned.
70 *
71 * @implements CRM_Utils_Hook::aclWhereClause
72 *
73 * @param string $type
74 * @param array $tables
75 * @param array $whereTables
76 * @param int $contactID
77 * @param string $where
78 */
79 public function aclWhereOnlyOne($type, &$tables, &$whereTables, &$contactID, &$where) {
80 $where = " contact_a.id = " . $this->allowedContactId;
81 }
82
83}