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