xml/templates/dao.tpl - Centralize export() / import() logic
[civicrm-core.git] / CRM / Core / DAO / Tag.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/Core/Tag.xml
32 * DO NOT EDIT. Generated by CRM_Core_CodeGen
437fafcf 33 * (GenCodeChecksum:e62b7ed2ffb1714200328dd2b08cdc9c)
e501603b
TO
34 */
35require_once 'CRM/Core/DAO.php';
36require_once 'CRM/Utils/Type.php';
37class CRM_Core_DAO_Tag extends CRM_Core_DAO {
38 /**
39 * static instance to hold the table name
40 *
41 * @var string
42 */
43 static $_tableName = 'civicrm_tag';
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 = true;
83 /**
84 * Tag ID
85 *
86 * @var int unsigned
87 */
88 public $id;
89 /**
90 * Name of Tag.
91 *
92 * @var string
93 */
94 public $name;
95 /**
96 * Optional verbose description of the tag.
97 *
98 * @var string
99 */
100 public $description;
101 /**
102 * Optional parent id for this tag.
103 *
104 * @var int unsigned
105 */
106 public $parent_id;
107 /**
108 * Is this tag selectable / displayed
109 *
110 * @var boolean
111 */
112 public $is_selectable;
113 /**
114 *
115 * @var boolean
116 */
117 public $is_reserved;
118 /**
119 *
120 * @var boolean
121 */
122 public $is_tagset;
123 /**
124 *
125 * @var string
126 */
127 public $used_for;
128 /**
129 * FK to civicrm_contact, who created this tag
130 *
131 * @var int unsigned
132 */
133 public $created_id;
134 /**
135 * Date and time that tag was created.
136 *
137 * @var datetime
138 */
139 public $created_date;
140 /**
141 * class constructor
142 *
143 * @return civicrm_tag
144 */
145 function __construct() {
146 $this->__table = 'civicrm_tag';
147 parent::__construct();
148 }
149 /**
150 * Returns foreign keys and entity references
151 *
152 * @return array
153 * [CRM_Core_Reference_Interface]
154 */
155 static function getReferenceColumns() {
156 if (!self::$_links) {
157 self::$_links = static ::createReferenceColumns(__CLASS__);
158 self::$_links[] = new CRM_Core_Reference_Basic(self::getTableName() , 'parent_id', 'civicrm_tag', 'id');
159 self::$_links[] = new CRM_Core_Reference_Basic(self::getTableName() , 'created_id', 'civicrm_contact', 'id');
160 }
161 return self::$_links;
162 }
163 /**
164 * Returns all the column names of this table
165 *
166 * @return array
167 */
168 static function &fields() {
169 if (!(self::$_fields)) {
170 self::$_fields = array(
171 'id' => array(
172 'name' => 'id',
173 'type' => CRM_Utils_Type::T_INT,
174 'title' => ts('Tag ID') ,
175 'description' => 'Tag ID',
176 'required' => true,
177 ) ,
178 'name' => array(
179 'name' => 'name',
180 'type' => CRM_Utils_Type::T_STRING,
181 'title' => ts('Tag Name') ,
182 'description' => 'Name of Tag.',
183 'required' => true,
184 'maxlength' => 64,
185 'size' => CRM_Utils_Type::BIG,
186 ) ,
187 'description' => array(
188 'name' => 'description',
189 'type' => CRM_Utils_Type::T_STRING,
190 'title' => ts('Description') ,
191 'description' => 'Optional verbose description of the tag.',
192 'maxlength' => 255,
193 'size' => CRM_Utils_Type::HUGE,
194 ) ,
195 'parent_id' => array(
196 'name' => 'parent_id',
197 'type' => CRM_Utils_Type::T_INT,
198 'title' => ts('Parent Tag') ,
199 'description' => 'Optional parent id for this tag.',
200 'default' => 'NULL',
201 'FKClassName' => 'CRM_Core_DAO_Tag',
202 ) ,
203 'is_selectable' => array(
204 'name' => 'is_selectable',
205 'type' => CRM_Utils_Type::T_BOOLEAN,
206 'title' => ts('Display Tag?') ,
207 'description' => 'Is this tag selectable / displayed',
208 'default' => '1',
209 ) ,
210 'is_reserved' => array(
211 'name' => 'is_reserved',
212 'type' => CRM_Utils_Type::T_BOOLEAN,
213 'title' => ts('Reserved') ,
214 ) ,
215 'is_tagset' => array(
216 'name' => 'is_tagset',
217 'type' => CRM_Utils_Type::T_BOOLEAN,
218 'title' => ts('Tagset') ,
219 ) ,
220 'used_for' => array(
221 'name' => 'used_for',
222 'type' => CRM_Utils_Type::T_STRING,
223 'title' => ts('Used For') ,
224 'maxlength' => 64,
225 'size' => CRM_Utils_Type::BIG,
226 'default' => 'NULL',
227 'html' => array(
228 'type' => 'Select',
229 ) ,
230 'pseudoconstant' => array(
231 'optionGroupName' => 'tag_used_for',
232 'optionEditPath' => 'civicrm/admin/options/tag_used_for',
233 )
234 ) ,
235 'created_id' => array(
236 'name' => 'created_id',
237 'type' => CRM_Utils_Type::T_INT,
238 'title' => ts('Tag Created By') ,
239 'description' => 'FK to civicrm_contact, who created this tag',
240 'FKClassName' => 'CRM_Contact_DAO_Contact',
241 ) ,
242 'created_date' => array(
243 'name' => 'created_date',
244 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
245 'title' => ts('Tag Created Date') ,
246 'description' => 'Date and time that tag was created.',
247 ) ,
248 );
249 }
250 return self::$_fields;
251 }
252 /**
253 * Returns an array containing, for each field, the arary key used for that
254 * field in self::$_fields.
255 *
256 * @return array
257 */
258 static function &fieldKeys() {
259 if (!(self::$_fieldKeys)) {
260 self::$_fieldKeys = array(
261 'id' => 'id',
262 'name' => 'name',
263 'description' => 'description',
264 'parent_id' => 'parent_id',
265 'is_selectable' => 'is_selectable',
266 'is_reserved' => 'is_reserved',
267 'is_tagset' => 'is_tagset',
268 'used_for' => 'used_for',
269 'created_id' => 'created_id',
270 'created_date' => 'created_date',
271 );
272 }
273 return self::$_fieldKeys;
274 }
275 /**
276 * Returns the names of this table
277 *
278 * @return string
279 */
280 static function getTableName() {
281 return self::$_tableName;
282 }
283 /**
284 * Returns if this table needs to be logged
285 *
286 * @return boolean
287 */
288 function getLog() {
289 return self::$_log;
290 }
291 /**
292 * Returns the list of fields that can be imported
293 *
294 * @param bool $prefix
295 *
296 * @return array
297 */
298 static function &import($prefix = false) {
299 if (!(self::$_import)) {
300 self::$_import = array();
301 $fields = self::fields();
302 foreach($fields as $name => $field) {
303 if (CRM_Utils_Array::value('import', $field)) {
304 if ($prefix) {
305 self::$_import['tag'] = & $fields[$name];
306 } else {
307 self::$_import[$name] = & $fields[$name];
308 }
309 }
310 }
311 }
312 return self::$_import;
313 }
314 /**
315 * Returns the list of fields that can be exported
316 *
317 * @param bool $prefix
318 *
319 * @return array
320 */
321 static function &export($prefix = false) {
322 if (!(self::$_export)) {
323 self::$_export = array();
324 $fields = self::fields();
325 foreach($fields as $name => $field) {
326 if (CRM_Utils_Array::value('export', $field)) {
327 if ($prefix) {
328 self::$_export['tag'] = & $fields[$name];
329 } else {
330 self::$_export[$name] = & $fields[$name];
331 }
332 }
333 }
334 }
335 return self::$_export;
336 }
337}