Commit | Line | Data |
---|---|---|
6a488035 | 1 | <?php |
6a488035 TO |
2 | /* |
3 | +--------------------------------------------------------------------+ | |
39de6fd5 | 4 | | CiviCRM version 4.6 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
06b69b18 | 6 | | Copyright CiviCRM LLC (c) 2004-2014 | |
6a488035 TO |
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 | * | |
30 | * @package CRM | |
06b69b18 | 31 | * @copyright CiviCRM LLC (c) 2004-2014 |
6a488035 TO |
32 | * $Id$ |
33 | * | |
34 | */ | |
35 | ||
36 | /** | |
37 | * Access Control EntityRole | |
38 | */ | |
39 | class CRM_ACL_BAO_EntityRole extends CRM_ACL_DAO_EntityRole { | |
40 | static $_entityTable = NULL; | |
41 | ||
28518c90 EM |
42 | /** |
43 | * @return array|null | |
44 | */ | |
00be9182 | 45 | public static function entityTable() { |
6a488035 TO |
46 | if (!self::$_entityTable) { |
47 | self::$_entityTable = array( | |
48 | 'civicrm_contact' => ts('Contact'), | |
49 | 'civicrm_group' => ts('Group'), | |
50 | ); | |
51 | } | |
52 | return self::$_entityTable; | |
53 | } | |
54 | ||
28518c90 | 55 | /** |
c490a46a | 56 | * @param array $params |
28518c90 EM |
57 | * |
58 | * @return CRM_ACL_DAO_EntityRole | |
59 | */ | |
00be9182 | 60 | public static function create(&$params) { |
6a488035 TO |
61 | $dao = new CRM_ACL_DAO_EntityRole(); |
62 | $dao->copyValues($params); | |
6a488035 | 63 | $dao->save(); |
663072a5 | 64 | return $dao; |
6a488035 TO |
65 | } |
66 | ||
28518c90 | 67 | /** |
c490a46a | 68 | * @param array $params |
28518c90 EM |
69 | * @param $defaults |
70 | */ | |
00be9182 | 71 | public static function retrieve(&$params, &$defaults) { |
6a488035 TO |
72 | CRM_Core_DAO::commonRetrieve('CRM_ACL_DAO_EntityRole', $params, $defaults); |
73 | } | |
74 | ||
75 | /** | |
100fef9d | 76 | * Update the is_active flag in the db |
6a488035 | 77 | * |
b758c7d5 TO |
78 | * @param int $id |
79 | * Id of the database record. | |
80 | * @param bool $is_active | |
81 | * Value we want to set the is_active field. | |
6a488035 | 82 | * |
a6c01b45 CW |
83 | * @return Object |
84 | * DAO object on sucess, null otherwise | |
6a488035 | 85 | */ |
00be9182 | 86 | public static function setIsActive($id, $is_active) { |
6a488035 TO |
87 | return CRM_Core_DAO::setFieldValue('CRM_ACL_DAO_EntityRole', $id, 'is_active', $is_active); |
88 | } | |
89 | ||
90 | /** | |
100fef9d | 91 | * Delete Entity Role records |
6a488035 | 92 | * |
b758c7d5 TO |
93 | * @param int $entityRoleId |
94 | * ID of the EntityRole record to be deleted. | |
6a488035 | 95 | * |
6a488035 | 96 | */ |
00be9182 | 97 | public static function del($entityRoleId) { |
6a488035 TO |
98 | $entityDAO = new CRM_ACL_DAO_EntityRole(); |
99 | $entityDAO->id = $entityRoleId; | |
100 | $entityDAO->find(TRUE); | |
101 | $entityDAO->delete(); | |
102 | } | |
103 | } |