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