Merge pull request #19701 from civicrm/5.35
[civicrm-core.git] / CRM / ACL / DAO / EntityRole.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/ACL/EntityRole.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:07069f5da0948ab48d78987d2fdfbec3)
10 */
11
12 /**
13 * Database access object for the EntityRole entity.
14 */
15 class CRM_ACL_DAO_EntityRole extends CRM_Core_DAO {
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '1.6';
18
19 /**
20 * Static instance to hold the table name.
21 *
22 * @var string
23 */
24 public static $_tableName = 'civicrm_acl_entity_role';
25
26 /**
27 * Should CiviCRM log any modifications to this table in the civicrm_log table.
28 *
29 * @var bool
30 */
31 public static $_log = FALSE;
32
33 /**
34 * Unique table ID
35 *
36 * @var int
37 */
38 public $id;
39
40 /**
41 * Foreign Key to ACL Role (which is an option value pair and hence an implicit FK)
42 *
43 * @var int
44 */
45 public $acl_role_id;
46
47 /**
48 * Table of the object joined to the ACL Role (Contact or Group)
49 *
50 * @var string
51 */
52 public $entity_table;
53
54 /**
55 * ID of the group/contact object being joined
56 *
57 * @var int
58 */
59 public $entity_id;
60
61 /**
62 * Is this property active?
63 *
64 * @var bool
65 */
66 public $is_active;
67
68 /**
69 * Class constructor.
70 */
71 public function __construct() {
72 $this->__table = 'civicrm_acl_entity_role';
73 parent::__construct();
74 }
75
76 /**
77 * Returns localized title of this entity.
78 *
79 * @param bool $plural
80 * Whether to return the plural version of the title.
81 */
82 public static function getEntityTitle($plural = FALSE) {
83 return $plural ? ts('Entity Roles') : ts('Entity Role');
84 }
85
86 /**
87 * Returns foreign keys and entity references.
88 *
89 * @return array
90 * [CRM_Core_Reference_Interface]
91 */
92 public static function getReferenceColumns() {
93 if (!isset(Civi::$statics[__CLASS__]['links'])) {
94 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
95 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName(), 'entity_id', NULL, 'id', 'entity_table');
96 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
97 }
98 return Civi::$statics[__CLASS__]['links'];
99 }
100
101 /**
102 * Returns all the column names of this table
103 *
104 * @return array
105 */
106 public static function &fields() {
107 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
108 Civi::$statics[__CLASS__]['fields'] = [
109 'id' => [
110 'name' => 'id',
111 'type' => CRM_Utils_Type::T_INT,
112 'title' => ts('Entity Role'),
113 'description' => ts('Unique table ID'),
114 'required' => TRUE,
115 'where' => 'civicrm_acl_entity_role.id',
116 'table_name' => 'civicrm_acl_entity_role',
117 'entity' => 'EntityRole',
118 'bao' => 'CRM_ACL_BAO_EntityRole',
119 'localizable' => 0,
120 'html' => [
121 'type' => 'Number',
122 ],
123 'readonly' => TRUE,
124 'add' => '1.6',
125 ],
126 'acl_role_id' => [
127 'name' => 'acl_role_id',
128 'type' => CRM_Utils_Type::T_INT,
129 'title' => ts('ACL Role ID'),
130 'description' => ts('Foreign Key to ACL Role (which is an option value pair and hence an implicit FK)'),
131 'required' => TRUE,
132 'where' => 'civicrm_acl_entity_role.acl_role_id',
133 'table_name' => 'civicrm_acl_entity_role',
134 'entity' => 'EntityRole',
135 'bao' => 'CRM_ACL_BAO_EntityRole',
136 'localizable' => 0,
137 'add' => '1.6',
138 ],
139 'entity_table' => [
140 'name' => 'entity_table',
141 'type' => CRM_Utils_Type::T_STRING,
142 'title' => ts('Entity Table'),
143 'description' => ts('Table of the object joined to the ACL Role (Contact or Group)'),
144 'required' => TRUE,
145 'maxlength' => 64,
146 'size' => CRM_Utils_Type::BIG,
147 'where' => 'civicrm_acl_entity_role.entity_table',
148 'table_name' => 'civicrm_acl_entity_role',
149 'entity' => 'EntityRole',
150 'bao' => 'CRM_ACL_BAO_EntityRole',
151 'localizable' => 0,
152 'add' => '1.6',
153 ],
154 'entity_id' => [
155 'name' => 'entity_id',
156 'type' => CRM_Utils_Type::T_INT,
157 'title' => ts('ACL Entity ID'),
158 'description' => ts('ID of the group/contact object being joined'),
159 'required' => TRUE,
160 'where' => 'civicrm_acl_entity_role.entity_id',
161 'table_name' => 'civicrm_acl_entity_role',
162 'entity' => 'EntityRole',
163 'bao' => 'CRM_ACL_BAO_EntityRole',
164 'localizable' => 0,
165 'add' => '1.6',
166 ],
167 'is_active' => [
168 'name' => 'is_active',
169 'type' => CRM_Utils_Type::T_BOOLEAN,
170 'title' => ts('ACL Entity Role is Active'),
171 'description' => ts('Is this property active?'),
172 'where' => 'civicrm_acl_entity_role.is_active',
173 'table_name' => 'civicrm_acl_entity_role',
174 'entity' => 'EntityRole',
175 'bao' => 'CRM_ACL_BAO_EntityRole',
176 'localizable' => 0,
177 'add' => '1.6',
178 ],
179 ];
180 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
181 }
182 return Civi::$statics[__CLASS__]['fields'];
183 }
184
185 /**
186 * Return a mapping from field-name to the corresponding key (as used in fields()).
187 *
188 * @return array
189 * Array(string $name => string $uniqueName).
190 */
191 public static function &fieldKeys() {
192 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
193 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
194 }
195 return Civi::$statics[__CLASS__]['fieldKeys'];
196 }
197
198 /**
199 * Returns the names of this table
200 *
201 * @return string
202 */
203 public static function getTableName() {
204 return self::$_tableName;
205 }
206
207 /**
208 * Returns if this table needs to be logged
209 *
210 * @return bool
211 */
212 public function getLog() {
213 return self::$_log;
214 }
215
216 /**
217 * Returns the list of fields that can be imported
218 *
219 * @param bool $prefix
220 *
221 * @return array
222 */
223 public static function &import($prefix = FALSE) {
224 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'acl_entity_role', $prefix, []);
225 return $r;
226 }
227
228 /**
229 * Returns the list of fields that can be exported
230 *
231 * @param bool $prefix
232 *
233 * @return array
234 */
235 public static function &export($prefix = FALSE) {
236 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'acl_entity_role', $prefix, []);
237 return $r;
238 }
239
240 /**
241 * Returns the list of indices
242 *
243 * @param bool $localize
244 *
245 * @return array
246 */
247 public static function indices($localize = TRUE) {
248 $indices = [
249 'index_role' => [
250 'name' => 'index_role',
251 'field' => [
252 0 => 'acl_role_id',
253 ],
254 'localizable' => FALSE,
255 'sig' => 'civicrm_acl_entity_role::0::acl_role_id',
256 ],
257 'index_entity' => [
258 'name' => 'index_entity',
259 'field' => [
260 0 => 'entity_table',
261 1 => 'entity_id',
262 ],
263 'localizable' => FALSE,
264 'sig' => 'civicrm_acl_entity_role::0::entity_table::entity_id',
265 ],
266 ];
267 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
268 }
269
270 }