Merge pull request #18430 from eileenmcnaughton/open
[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
7b66c3b5 9 * (GenCodeChecksum:10e6547299a52750abd62b96dfacc9de)
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,
a9d0587b 147 'add' => '4.6',
c3fc2621
CW
148 ],
149 'app_guid' => [
e501603b
TO
150 'name' => 'app_guid',
151 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 152 'title' => ts('Application GUID'),
215b423e 153 'description' => ts('Application GUID'),
e501603b
TO
154 'maxlength' => 128,
155 'size' => CRM_Utils_Type::HUGE,
a36434b9 156 'where' => 'civicrm_cxn.app_guid',
522a26c9 157 'table_name' => 'civicrm_cxn',
158 'entity' => 'Cxn',
159 'bao' => 'CRM_Cxn_BAO_Cxn',
6a7e5e5d 160 'localizable' => 0,
a9d0587b 161 'add' => '4.6',
c3fc2621
CW
162 ],
163 'app_meta' => [
e501603b
TO
164 'name' => 'app_meta',
165 'type' => CRM_Utils_Type::T_TEXT,
c3fc2621 166 'title' => ts('Application Metadata (JSON)'),
215b423e 167 'description' => ts('Application Metadata (JSON)'),
a36434b9 168 'where' => 'civicrm_cxn.app_meta',
522a26c9 169 'table_name' => 'civicrm_cxn',
170 'entity' => 'Cxn',
171 'bao' => 'CRM_Cxn_BAO_Cxn',
6a7e5e5d 172 'localizable' => 0,
a9d0587b 173 'add' => '4.6',
c3fc2621
CW
174 ],
175 'cxn_guid' => [
e501603b
TO
176 'name' => 'cxn_guid',
177 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 178 'title' => ts('Connection GUID'),
215b423e 179 'description' => ts('Connection GUID'),
e501603b
TO
180 'maxlength' => 128,
181 'size' => CRM_Utils_Type::HUGE,
a36434b9 182 'where' => 'civicrm_cxn.cxn_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 'secret' => [
e501603b
TO
190 'name' => 'secret',
191 'type' => CRM_Utils_Type::T_TEXT,
c3fc2621 192 'title' => ts('Secret'),
215b423e 193 'description' => ts('Shared secret'),
a36434b9 194 'where' => 'civicrm_cxn.secret',
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 'perm' => [
e501603b
TO
202 'name' => 'perm',
203 'type' => CRM_Utils_Type::T_TEXT,
c3fc2621 204 'title' => ts('Perm'),
215b423e 205 'description' => ts('Permissions approved for the service (JSON)'),
a36434b9 206 'where' => 'civicrm_cxn.perm',
522a26c9 207 'table_name' => 'civicrm_cxn',
208 'entity' => 'Cxn',
209 'bao' => 'CRM_Cxn_BAO_Cxn',
6a7e5e5d 210 'localizable' => 0,
a9d0587b 211 'add' => '4.6',
c3fc2621
CW
212 ],
213 'options' => [
e501603b
TO
214 'name' => 'options',
215 'type' => CRM_Utils_Type::T_TEXT,
c3fc2621 216 'title' => ts('Options'),
215b423e 217 'description' => ts('Options for the service (JSON)'),
a36434b9 218 'where' => 'civicrm_cxn.options',
522a26c9 219 'table_name' => 'civicrm_cxn',
220 'entity' => 'Cxn',
221 'bao' => 'CRM_Cxn_BAO_Cxn',
6a7e5e5d 222 'localizable' => 0,
d0127d84 223 'serialize' => self::SERIALIZE_JSON,
a9d0587b 224 'add' => '4.6',
c3fc2621
CW
225 ],
226 'is_active' => [
e501603b
TO
227 'name' => 'is_active',
228 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 229 'title' => ts('Is Active'),
215b423e 230 'description' => ts('Is connection currently enabled?'),
a36434b9 231 'where' => 'civicrm_cxn.is_active',
e501603b 232 'default' => '1',
522a26c9 233 'table_name' => 'civicrm_cxn',
234 'entity' => 'Cxn',
235 'bao' => 'CRM_Cxn_BAO_Cxn',
6a7e5e5d 236 'localizable' => 0,
a9d0587b 237 'add' => '4.6',
c3fc2621
CW
238 ],
239 'created_date' => [
e501603b
TO
240 'name' => 'created_date',
241 'type' => CRM_Utils_Type::T_TIMESTAMP,
c3fc2621 242 'title' => ts('Created Date'),
215b423e 243 'description' => ts('When was the connection was created.'),
c3fc2621 244 'required' => FALSE,
a36434b9 245 'where' => 'civicrm_cxn.created_date',
e501603b 246 'default' => 'NULL',
522a26c9 247 'table_name' => 'civicrm_cxn',
248 'entity' => 'Cxn',
249 'bao' => 'CRM_Cxn_BAO_Cxn',
6a7e5e5d 250 'localizable' => 0,
a9d0587b 251 'add' => '4.6',
c3fc2621
CW
252 ],
253 'modified_date' => [
e501603b
TO
254 'name' => 'modified_date',
255 'type' => CRM_Utils_Type::T_TIMESTAMP,
c3fc2621 256 'title' => ts('Modified Date'),
215b423e 257 'description' => ts('When the connection was created or modified.'),
c3fc2621 258 'required' => FALSE,
a36434b9 259 'where' => 'civicrm_cxn.modified_date',
e501603b 260 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
522a26c9 261 'table_name' => 'civicrm_cxn',
262 'entity' => 'Cxn',
263 'bao' => 'CRM_Cxn_BAO_Cxn',
6a7e5e5d 264 'localizable' => 0,
a9d0587b 265 'add' => '4.6',
c3fc2621
CW
266 ],
267 'fetched_date' => [
e501603b
TO
268 'name' => 'fetched_date',
269 'type' => CRM_Utils_Type::T_TIMESTAMP,
c3fc2621 270 'title' => ts('Fetched Date'),
215b423e 271 'description' => ts('The last time the application metadata was fetched.'),
c3fc2621 272 'required' => FALSE,
a36434b9 273 'where' => 'civicrm_cxn.fetched_date',
e501603b 274 'default' => 'NULL',
522a26c9 275 'table_name' => 'civicrm_cxn',
276 'entity' => 'Cxn',
277 'bao' => 'CRM_Cxn_BAO_Cxn',
6a7e5e5d 278 'localizable' => 0,
a9d0587b 279 'add' => '4.6',
c3fc2621
CW
280 ],
281 ];
346aaaba 282 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 283 }
346aaaba 284 return Civi::$statics[__CLASS__]['fields'];
e501603b 285 }
c3fc2621 286
e501603b 287 /**
bd8e0b14 288 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
289 *
290 * @return array
bd8e0b14 291 * Array(string $name => string $uniqueName).
e501603b 292 */
c3fc2621 293 public static function &fieldKeys() {
bd8e0b14
TO
294 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
295 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 296 }
bd8e0b14 297 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 298 }
c3fc2621 299
e501603b
TO
300 /**
301 * Returns the names of this table
302 *
303 * @return string
304 */
c3fc2621 305 public static function getTableName() {
e501603b
TO
306 return self::$_tableName;
307 }
c3fc2621 308
e501603b
TO
309 /**
310 * Returns if this table needs to be logged
311 *
c3fc2621 312 * @return bool
e501603b 313 */
c3fc2621 314 public function getLog() {
e501603b
TO
315 return self::$_log;
316 }
c3fc2621 317
e501603b
TO
318 /**
319 * Returns the list of fields that can be imported
320 *
321 * @param bool $prefix
322 *
323 * @return array
324 */
c3fc2621
CW
325 public static function &import($prefix = FALSE) {
326 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'cxn', $prefix, []);
60808919 327 return $r;
e501603b 328 }
c3fc2621 329
e501603b
TO
330 /**
331 * Returns the list of fields that can be exported
332 *
333 * @param bool $prefix
334 *
335 * @return array
336 */
c3fc2621
CW
337 public static function &export($prefix = FALSE) {
338 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'cxn', $prefix, []);
60808919 339 return $r;
e501603b 340 }
c3fc2621 341
e7a6b91a
AS
342 /**
343 * Returns the list of indices
c3fc2621
CW
344 *
345 * @param bool $localize
346 *
347 * @return array
e7a6b91a
AS
348 */
349 public static function indices($localize = TRUE) {
c3fc2621
CW
350 $indices = [
351 'UI_appid' => [
e7a6b91a 352 'name' => 'UI_appid',
c3fc2621 353 'field' => [
e7a6b91a 354 0 => 'app_guid',
c3fc2621
CW
355 ],
356 'localizable' => FALSE,
357 'unique' => TRUE,
e7a6b91a 358 'sig' => 'civicrm_cxn::1::app_guid',
c3fc2621
CW
359 ],
360 'UI_keypair_cxnid' => [
e7a6b91a 361 'name' => 'UI_keypair_cxnid',
c3fc2621 362 'field' => [
e7a6b91a 363 0 => 'cxn_guid',
c3fc2621
CW
364 ],
365 'localizable' => FALSE,
366 'unique' => TRUE,
e7a6b91a 367 'sig' => 'civicrm_cxn::1::cxn_guid',
c3fc2621
CW
368 ],
369 ];
e7a6b91a
AS
370 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
371 }
c3fc2621 372
e501603b 373}