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