Merge pull request #19610 from ahed-compucorp/dev/core#2372
[civicrm-core.git] / CRM / Cxn / DAO / Cxn.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Cxn/Cxn.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:157ccfb9fab7c31b02b22cf6d79fe686)
10 */
11
12 /**
13 * Database access object for the Cxn entity.
14 */
15 class CRM_Cxn_DAO_Cxn extends CRM_Core_DAO {
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '4.6';
18
19 /**
20 * Static instance to hold the table name.
21 *
22 * @var string
23 */
24 public static $_tableName = 'civicrm_cxn';
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 * Connection ID
35 *
36 * @var int
37 */
38 public $id;
39
40 /**
41 * Application GUID
42 *
43 * @var string
44 */
45 public $app_guid;
46
47 /**
48 * Application Metadata (JSON)
49 *
50 * @var text
51 */
52 public $app_meta;
53
54 /**
55 * Connection GUID
56 *
57 * @var string
58 */
59 public $cxn_guid;
60
61 /**
62 * Shared secret
63 *
64 * @var text
65 */
66 public $secret;
67
68 /**
69 * Permissions approved for the service (JSON)
70 *
71 * @var text
72 */
73 public $perm;
74
75 /**
76 * Options for the service (JSON)
77 *
78 * @var text
79 */
80 public $options;
81
82 /**
83 * Is connection currently enabled?
84 *
85 * @var bool
86 */
87 public $is_active;
88
89 /**
90 * When was the connection was created.
91 *
92 * @var timestamp
93 */
94 public $created_date;
95
96 /**
97 * When the connection was created or modified.
98 *
99 * @var timestamp
100 */
101 public $modified_date;
102
103 /**
104 * The last time the application metadata was fetched.
105 *
106 * @var timestamp
107 */
108 public $fetched_date;
109
110 /**
111 * Class constructor.
112 */
113 public function __construct() {
114 $this->__table = 'civicrm_cxn';
115 parent::__construct();
116 }
117
118 /**
119 * Returns localized title of this entity.
120 *
121 * @param bool $plural
122 * Whether to return the plural version of the title.
123 */
124 public static function getEntityTitle($plural = FALSE) {
125 return $plural ? ts('Cxns') : ts('Cxn');
126 }
127
128 /**
129 * Returns all the column names of this table
130 *
131 * @return array
132 */
133 public static function &fields() {
134 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
135 Civi::$statics[__CLASS__]['fields'] = [
136 'id' => [
137 'name' => 'id',
138 'type' => CRM_Utils_Type::T_INT,
139 'title' => ts('Connection ID'),
140 'description' => ts('Connection ID'),
141 'required' => TRUE,
142 'where' => 'civicrm_cxn.id',
143 'table_name' => 'civicrm_cxn',
144 'entity' => 'Cxn',
145 'bao' => 'CRM_Cxn_BAO_Cxn',
146 'localizable' => 0,
147 'html' => [
148 'type' => 'Number',
149 ],
150 'readonly' => TRUE,
151 'add' => '4.6',
152 ],
153 'app_guid' => [
154 'name' => 'app_guid',
155 'type' => CRM_Utils_Type::T_STRING,
156 'title' => ts('Application GUID'),
157 'description' => ts('Application GUID'),
158 'maxlength' => 128,
159 'size' => CRM_Utils_Type::HUGE,
160 'where' => 'civicrm_cxn.app_guid',
161 'table_name' => 'civicrm_cxn',
162 'entity' => 'Cxn',
163 'bao' => 'CRM_Cxn_BAO_Cxn',
164 'localizable' => 0,
165 'add' => '4.6',
166 ],
167 'app_meta' => [
168 'name' => 'app_meta',
169 'type' => CRM_Utils_Type::T_TEXT,
170 'title' => ts('Application Metadata (JSON)'),
171 'description' => ts('Application Metadata (JSON)'),
172 'where' => 'civicrm_cxn.app_meta',
173 'table_name' => 'civicrm_cxn',
174 'entity' => 'Cxn',
175 'bao' => 'CRM_Cxn_BAO_Cxn',
176 'localizable' => 0,
177 'add' => '4.6',
178 ],
179 'cxn_guid' => [
180 'name' => 'cxn_guid',
181 'type' => CRM_Utils_Type::T_STRING,
182 'title' => ts('Connection GUID'),
183 'description' => ts('Connection GUID'),
184 'maxlength' => 128,
185 'size' => CRM_Utils_Type::HUGE,
186 'where' => 'civicrm_cxn.cxn_guid',
187 'table_name' => 'civicrm_cxn',
188 'entity' => 'Cxn',
189 'bao' => 'CRM_Cxn_BAO_Cxn',
190 'localizable' => 0,
191 'add' => '4.6',
192 ],
193 'secret' => [
194 'name' => 'secret',
195 'type' => CRM_Utils_Type::T_TEXT,
196 'title' => ts('Secret'),
197 'description' => ts('Shared secret'),
198 'where' => 'civicrm_cxn.secret',
199 'table_name' => 'civicrm_cxn',
200 'entity' => 'Cxn',
201 'bao' => 'CRM_Cxn_BAO_Cxn',
202 'localizable' => 0,
203 'html' => [
204 'label' => ts("Secret"),
205 ],
206 'add' => '4.6',
207 ],
208 'perm' => [
209 'name' => 'perm',
210 'type' => CRM_Utils_Type::T_TEXT,
211 'title' => ts('Perm'),
212 'description' => ts('Permissions approved for the service (JSON)'),
213 'where' => 'civicrm_cxn.perm',
214 'table_name' => 'civicrm_cxn',
215 'entity' => 'Cxn',
216 'bao' => 'CRM_Cxn_BAO_Cxn',
217 'localizable' => 0,
218 'html' => [
219 'label' => ts("Permissions"),
220 ],
221 'add' => '4.6',
222 ],
223 'options' => [
224 'name' => 'options',
225 'type' => CRM_Utils_Type::T_TEXT,
226 'title' => ts('Options'),
227 'description' => ts('Options for the service (JSON)'),
228 'where' => 'civicrm_cxn.options',
229 'table_name' => 'civicrm_cxn',
230 'entity' => 'Cxn',
231 'bao' => 'CRM_Cxn_BAO_Cxn',
232 'localizable' => 0,
233 'serialize' => self::SERIALIZE_JSON,
234 'html' => [
235 'label' => ts("Options"),
236 ],
237 'add' => '4.6',
238 ],
239 'is_active' => [
240 'name' => 'is_active',
241 'type' => CRM_Utils_Type::T_BOOLEAN,
242 'title' => ts('Is Active'),
243 'description' => ts('Is connection currently enabled?'),
244 'where' => 'civicrm_cxn.is_active',
245 'default' => '1',
246 'table_name' => 'civicrm_cxn',
247 'entity' => 'Cxn',
248 'bao' => 'CRM_Cxn_BAO_Cxn',
249 'localizable' => 0,
250 'add' => '4.6',
251 ],
252 'created_date' => [
253 'name' => 'created_date',
254 'type' => CRM_Utils_Type::T_TIMESTAMP,
255 'title' => ts('Created Date'),
256 'description' => ts('When was the connection was created.'),
257 'required' => FALSE,
258 'where' => 'civicrm_cxn.created_date',
259 'default' => 'NULL',
260 'table_name' => 'civicrm_cxn',
261 'entity' => 'Cxn',
262 'bao' => 'CRM_Cxn_BAO_Cxn',
263 'localizable' => 0,
264 'html' => [
265 'label' => ts("Created Date"),
266 ],
267 'add' => '4.6',
268 ],
269 'modified_date' => [
270 'name' => 'modified_date',
271 'type' => CRM_Utils_Type::T_TIMESTAMP,
272 'title' => ts('Modified Date'),
273 'description' => ts('When the connection was created or modified.'),
274 'required' => FALSE,
275 'where' => 'civicrm_cxn.modified_date',
276 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
277 'table_name' => 'civicrm_cxn',
278 'entity' => 'Cxn',
279 'bao' => 'CRM_Cxn_BAO_Cxn',
280 'localizable' => 0,
281 'html' => [
282 'label' => ts("Modified Date"),
283 ],
284 'add' => '4.6',
285 ],
286 'fetched_date' => [
287 'name' => 'fetched_date',
288 'type' => CRM_Utils_Type::T_TIMESTAMP,
289 'title' => ts('Fetched Date'),
290 'description' => ts('The last time the application metadata was fetched.'),
291 'required' => FALSE,
292 'where' => 'civicrm_cxn.fetched_date',
293 'default' => 'NULL',
294 'table_name' => 'civicrm_cxn',
295 'entity' => 'Cxn',
296 'bao' => 'CRM_Cxn_BAO_Cxn',
297 'localizable' => 0,
298 'html' => [
299 'label' => ts("Fetched Date"),
300 ],
301 'add' => '4.6',
302 ],
303 ];
304 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
305 }
306 return Civi::$statics[__CLASS__]['fields'];
307 }
308
309 /**
310 * Return a mapping from field-name to the corresponding key (as used in fields()).
311 *
312 * @return array
313 * Array(string $name => string $uniqueName).
314 */
315 public static function &fieldKeys() {
316 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
317 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
318 }
319 return Civi::$statics[__CLASS__]['fieldKeys'];
320 }
321
322 /**
323 * Returns the names of this table
324 *
325 * @return string
326 */
327 public static function getTableName() {
328 return self::$_tableName;
329 }
330
331 /**
332 * Returns if this table needs to be logged
333 *
334 * @return bool
335 */
336 public function getLog() {
337 return self::$_log;
338 }
339
340 /**
341 * Returns the list of fields that can be imported
342 *
343 * @param bool $prefix
344 *
345 * @return array
346 */
347 public static function &import($prefix = FALSE) {
348 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'cxn', $prefix, []);
349 return $r;
350 }
351
352 /**
353 * Returns the list of fields that can be exported
354 *
355 * @param bool $prefix
356 *
357 * @return array
358 */
359 public static function &export($prefix = FALSE) {
360 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'cxn', $prefix, []);
361 return $r;
362 }
363
364 /**
365 * Returns the list of indices
366 *
367 * @param bool $localize
368 *
369 * @return array
370 */
371 public static function indices($localize = TRUE) {
372 $indices = [
373 'UI_appid' => [
374 'name' => 'UI_appid',
375 'field' => [
376 0 => 'app_guid',
377 ],
378 'localizable' => FALSE,
379 'unique' => TRUE,
380 'sig' => 'civicrm_cxn::1::app_guid',
381 ],
382 'UI_keypair_cxnid' => [
383 'name' => 'UI_keypair_cxnid',
384 'field' => [
385 0 => 'cxn_guid',
386 ],
387 'localizable' => FALSE,
388 'unique' => TRUE,
389 'sig' => 'civicrm_cxn::1::cxn_guid',
390 ],
391 ];
392 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
393 }
394
395 }