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