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