xml/templates/dao.tpl - Centralize export() / import() logic
[civicrm-core.git] / CRM / Cxn / DAO / Cxn.php
CommitLineData
e501603b
TO
1<?php
2/*
3+--------------------------------------------------------------------+
4| CiviCRM version 4.7 |
5+--------------------------------------------------------------------+
6| Copyright CiviCRM LLC (c) 2004-2016 |
7+--------------------------------------------------------------------+
8| This file is a part of CiviCRM. |
9| |
10| CiviCRM is free software; you can copy, modify, and distribute it |
11| under the terms of the GNU Affero General Public License |
12| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
13| |
14| CiviCRM is distributed in the hope that it will be useful, but |
15| WITHOUT ANY WARRANTY; without even the implied warranty of |
16| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17| See the GNU Affero General Public License for more details. |
18| |
19| You should have received a copy of the GNU Affero General Public |
20| License and the CiviCRM Licensing Exception along |
21| with this program; if not, contact CiviCRM LLC |
22| at info[AT]civicrm[DOT]org. If you have questions about the |
23| GNU Affero General Public License or the licensing of CiviCRM, |
24| see the CiviCRM license FAQ at http://civicrm.org/licensing |
25+--------------------------------------------------------------------+
26*/
27/**
28 * @package CRM
29 * @copyright CiviCRM LLC (c) 2004-2016
30 *
31 * Generated from xml/schema/CRM/Cxn/Cxn.xml
32 * DO NOT EDIT. Generated by CRM_Core_CodeGen
437fafcf 33 * (GenCodeChecksum:486a0a360a4a9913e94e3879e51300f6)
e501603b
TO
34 */
35require_once 'CRM/Core/DAO.php';
36require_once 'CRM/Utils/Type.php';
37class CRM_Cxn_DAO_Cxn extends CRM_Core_DAO {
38 /**
39 * static instance to hold the table name
40 *
41 * @var string
42 */
43 static $_tableName = 'civicrm_cxn';
44 /**
45 * static instance to hold the field values
46 *
47 * @var array
48 */
49 static $_fields = null;
50 /**
51 * static instance to hold the keys used in $_fields for each field.
52 *
53 * @var array
54 */
55 static $_fieldKeys = null;
56 /**
57 * static instance to hold the FK relationships
58 *
59 * @var string
60 */
61 static $_links = null;
62 /**
63 * static instance to hold the values that can
64 * be imported
65 *
66 * @var array
67 */
68 static $_import = null;
69 /**
70 * static instance to hold the values that can
71 * be exported
72 *
73 * @var array
74 */
75 static $_export = null;
76 /**
77 * static value to see if we should log any modifications to
78 * this table in the civicrm_log table
79 *
80 * @var boolean
81 */
82 static $_log = false;
83 /**
84 * Connection ID
85 *
86 * @var int unsigned
87 */
88 public $id;
89 /**
90 * Application GUID
91 *
92 * @var string
93 */
94 public $app_guid;
95 /**
96 * Application Metadata (JSON)
97 *
98 * @var text
99 */
100 public $app_meta;
101 /**
102 * Connection GUID
103 *
104 * @var string
105 */
106 public $cxn_guid;
107 /**
108 * Shared secret
109 *
110 * @var text
111 */
112 public $secret;
113 /**
114 * Permissions approved for the service (JSON)
115 *
116 * @var text
117 */
118 public $perm;
119 /**
120 * Options for the service (JSON)
121 *
122 * @var text
123 */
124 public $options;
125 /**
126 * Is connection currently enabled?
127 *
128 * @var boolean
129 */
130 public $is_active;
131 /**
132 * When was the connection was created.
133 *
134 * @var timestamp
135 */
136 public $created_date;
137 /**
138 * When the connection was created or modified.
139 *
140 * @var timestamp
141 */
142 public $modified_date;
143 /**
144 * The last time the application metadata was fetched.
145 *
146 * @var timestamp
147 */
148 public $fetched_date;
149 /**
150 * class constructor
151 *
152 * @return civicrm_cxn
153 */
154 function __construct() {
155 $this->__table = 'civicrm_cxn';
156 parent::__construct();
157 }
158 /**
159 * Returns all the column names of this table
160 *
161 * @return array
162 */
163 static function &fields() {
164 if (!(self::$_fields)) {
165 self::$_fields = array(
166 'id' => array(
167 'name' => 'id',
168 'type' => CRM_Utils_Type::T_INT,
169 'title' => ts('Connection ID') ,
170 'description' => 'Connection ID',
171 'required' => true,
172 ) ,
173 'app_guid' => array(
174 'name' => 'app_guid',
175 'type' => CRM_Utils_Type::T_STRING,
176 'title' => ts('Application GUID') ,
177 'description' => 'Application GUID',
178 'maxlength' => 128,
179 'size' => CRM_Utils_Type::HUGE,
180 ) ,
181 'app_meta' => array(
182 'name' => 'app_meta',
183 'type' => CRM_Utils_Type::T_TEXT,
184 'title' => ts('Application Metadata (JSON)') ,
185 'description' => 'Application Metadata (JSON)',
186 ) ,
187 'cxn_guid' => array(
188 'name' => 'cxn_guid',
189 'type' => CRM_Utils_Type::T_STRING,
190 'title' => ts('Connection GUID') ,
191 'description' => 'Connection GUID',
192 'maxlength' => 128,
193 'size' => CRM_Utils_Type::HUGE,
194 ) ,
195 'secret' => array(
196 'name' => 'secret',
197 'type' => CRM_Utils_Type::T_TEXT,
198 'title' => ts('Secret') ,
199 'description' => 'Shared secret',
200 ) ,
201 'perm' => array(
202 'name' => 'perm',
203 'type' => CRM_Utils_Type::T_TEXT,
204 'title' => ts('Perm') ,
205 'description' => 'Permissions approved for the service (JSON)',
206 ) ,
207 'options' => array(
208 'name' => 'options',
209 'type' => CRM_Utils_Type::T_TEXT,
210 'title' => ts('Options') ,
211 'description' => 'Options for the service (JSON)',
212 ) ,
213 'is_active' => array(
214 'name' => 'is_active',
215 'type' => CRM_Utils_Type::T_BOOLEAN,
216 'title' => ts('Is Active') ,
217 'description' => 'Is connection currently enabled?',
218 'default' => '1',
219 ) ,
220 'created_date' => array(
221 'name' => 'created_date',
222 'type' => CRM_Utils_Type::T_TIMESTAMP,
223 'title' => ts('Created Date') ,
224 'description' => 'When was the connection was created.',
225 'required' => false,
226 'default' => 'NULL',
227 ) ,
228 'modified_date' => array(
229 'name' => 'modified_date',
230 'type' => CRM_Utils_Type::T_TIMESTAMP,
231 'title' => ts('Modified Date') ,
232 'description' => 'When the connection was created or modified.',
233 'required' => false,
234 'default' => 'CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP',
235 ) ,
236 'fetched_date' => array(
237 'name' => 'fetched_date',
238 'type' => CRM_Utils_Type::T_TIMESTAMP,
239 'title' => ts('Fetched Date') ,
240 'description' => 'The last time the application metadata was fetched.',
241 'required' => false,
242 'default' => 'NULL',
243 ) ,
244 );
245 }
246 return self::$_fields;
247 }
248 /**
249 * Returns an array containing, for each field, the arary key used for that
250 * field in self::$_fields.
251 *
252 * @return array
253 */
254 static function &fieldKeys() {
255 if (!(self::$_fieldKeys)) {
256 self::$_fieldKeys = array(
257 'id' => 'id',
258 'app_guid' => 'app_guid',
259 'app_meta' => 'app_meta',
260 'cxn_guid' => 'cxn_guid',
261 'secret' => 'secret',
262 'perm' => 'perm',
263 'options' => 'options',
264 'is_active' => 'is_active',
265 'created_date' => 'created_date',
266 'modified_date' => 'modified_date',
267 'fetched_date' => 'fetched_date',
268 );
269 }
270 return self::$_fieldKeys;
271 }
272 /**
273 * Returns the names of this table
274 *
275 * @return string
276 */
277 static function getTableName() {
278 return self::$_tableName;
279 }
280 /**
281 * Returns if this table needs to be logged
282 *
283 * @return boolean
284 */
285 function getLog() {
286 return self::$_log;
287 }
288 /**
289 * Returns the list of fields that can be imported
290 *
291 * @param bool $prefix
292 *
293 * @return array
294 */
295 static function &import($prefix = false) {
296 if (!(self::$_import)) {
297 self::$_import = array();
298 $fields = self::fields();
299 foreach($fields as $name => $field) {
300 if (CRM_Utils_Array::value('import', $field)) {
301 if ($prefix) {
302 self::$_import['cxn'] = & $fields[$name];
303 } else {
304 self::$_import[$name] = & $fields[$name];
305 }
306 }
307 }
308 }
309 return self::$_import;
310 }
311 /**
312 * Returns the list of fields that can be exported
313 *
314 * @param bool $prefix
315 *
316 * @return array
317 */
318 static function &export($prefix = false) {
319 if (!(self::$_export)) {
320 self::$_export = array();
321 $fields = self::fields();
322 foreach($fields as $name => $field) {
323 if (CRM_Utils_Array::value('export', $field)) {
324 if ($prefix) {
325 self::$_export['cxn'] = & $fields[$name];
326 } else {
327 self::$_export[$name] = & $fields[$name];
328 }
329 }
330 }
331 }
332 return self::$_export;
333 }
334}