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