Merge pull request #16100 from jitendrapurohit/dev-1473
[civicrm-core.git] / CRM / ACL / BAO / EntityRole.php
CommitLineData
6a488035 1<?php
6a488035
TO
2/*
3 +--------------------------------------------------------------------+
bc77d7c0 4 | Copyright CiviCRM LLC. All rights reserved. |
6a488035 5 | |
bc77d7c0
TO
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
6a488035 9 +--------------------------------------------------------------------+
d25dd0ee 10 */
6a488035
TO
11
12/**
13 *
14 * @package CRM
ca5cec67 15 * @copyright CiviCRM LLC https://civicrm.org/licensing
6a488035
TO
16 */
17
18/**
3819f101 19 * Access Control EntityRole.
6a488035
TO
20 */
21class CRM_ACL_BAO_EntityRole extends CRM_ACL_DAO_EntityRole {
683bf891 22 public static $_entityTable = NULL;
6a488035 23
28518c90 24 /**
3819f101 25 * Get entity table.
26 *
28518c90
EM
27 * @return array|null
28 */
00be9182 29 public static function entityTable() {
6a488035 30 if (!self::$_entityTable) {
cf0d1c08 31 self::$_entityTable = [
6a488035
TO
32 'civicrm_contact' => ts('Contact'),
33 'civicrm_group' => ts('Group'),
cf0d1c08 34 ];
6a488035
TO
35 }
36 return self::$_entityTable;
37 }
38
28518c90 39 /**
c490a46a 40 * @param array $params
28518c90
EM
41 *
42 * @return CRM_ACL_DAO_EntityRole
43 */
00be9182 44 public static function create(&$params) {
6a488035
TO
45 $dao = new CRM_ACL_DAO_EntityRole();
46 $dao->copyValues($params);
6a488035 47 $dao->save();
663072a5 48 return $dao;
6a488035
TO
49 }
50
28518c90 51 /**
c490a46a 52 * @param array $params
28518c90
EM
53 * @param $defaults
54 */
00be9182 55 public static function retrieve(&$params, &$defaults) {
6a488035
TO
56 CRM_Core_DAO::commonRetrieve('CRM_ACL_DAO_EntityRole', $params, $defaults);
57 }
58
59 /**
fe482240 60 * Update the is_active flag in the db.
6a488035 61 *
b758c7d5
TO
62 * @param int $id
63 * Id of the database record.
64 * @param bool $is_active
65 * Value we want to set the is_active field.
6a488035 66 *
8a4fede3 67 * @return bool
68 * true if we found and updated the object, else false
6a488035 69 */
00be9182 70 public static function setIsActive($id, $is_active) {
6a488035
TO
71 return CRM_Core_DAO::setFieldValue('CRM_ACL_DAO_EntityRole', $id, 'is_active', $is_active);
72 }
73
74 /**
d2e5d2ce 75 * Delete Entity Role records.
6a488035 76 *
b758c7d5
TO
77 * @param int $entityRoleId
78 * ID of the EntityRole record to be deleted.
6a488035 79 *
6a488035 80 */
00be9182 81 public static function del($entityRoleId) {
6a488035
TO
82 $entityDAO = new CRM_ACL_DAO_EntityRole();
83 $entityDAO->id = $entityRoleId;
84 $entityDAO->find(TRUE);
85 $entityDAO->delete();
86 }
96025800 87
6a488035 88}