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