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