Merge pull request #11433 from octo-happiness/CRM-20866
[civicrm-core.git] / CRM / Core / DAO / Tag.php
CommitLineData
e501603b
TO
1<?php
2/*
3+--------------------------------------------------------------------+
4| CiviCRM version 4.7 |
5+--------------------------------------------------------------------+
0f03f337 6| Copyright CiviCRM LLC (c) 2004-2017 |
e501603b
TO
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
0f03f337 29 * @copyright CiviCRM LLC (c) 2004-2017
e501603b
TO
30 *
31 * Generated from xml/schema/CRM/Core/Tag.xml
32 * DO NOT EDIT. Generated by CRM_Core_CodeGen
e7a6b91a 33 * (GenCodeChecksum:eb22ef992569566021a7faeaf43f0c25)
e501603b
TO
34 */
35require_once 'CRM/Core/DAO.php';
36require_once 'CRM/Utils/Type.php';
f41f0342 37/**
38 * CRM_Core_DAO_Tag constructor.
39 */
e501603b
TO
40class CRM_Core_DAO_Tag extends CRM_Core_DAO {
41 /**
f41f0342 42 * Static instance to hold the table name.
e501603b
TO
43 *
44 * @var string
45 */
46 static $_tableName = 'civicrm_tag';
e501603b 47 /**
f41f0342 48 * Should CiviCRM log any modifications to this table in the civicrm_log table.
e501603b
TO
49 *
50 * @var boolean
51 */
52 static $_log = true;
53 /**
54 * Tag ID
55 *
56 * @var int unsigned
57 */
58 public $id;
59 /**
60 * Name of Tag.
61 *
62 * @var string
63 */
64 public $name;
65 /**
66 * Optional verbose description of the tag.
67 *
68 * @var string
69 */
70 public $description;
71 /**
72 * Optional parent id for this tag.
73 *
74 * @var int unsigned
75 */
76 public $parent_id;
77 /**
78 * Is this tag selectable / displayed
79 *
80 * @var boolean
81 */
82 public $is_selectable;
83 /**
84 *
85 * @var boolean
86 */
87 public $is_reserved;
88 /**
89 *
90 * @var boolean
91 */
92 public $is_tagset;
93 /**
94 *
95 * @var string
96 */
97 public $used_for;
98 /**
99 * FK to civicrm_contact, who created this tag
100 *
101 * @var int unsigned
102 */
103 public $created_id;
d73974ac
CW
104 /**
105 * Hex color value e.g. #ffffff
106 *
107 * @var string
108 */
109 public $color;
e501603b
TO
110 /**
111 * Date and time that tag was created.
112 *
113 * @var datetime
114 */
115 public $created_date;
116 /**
f41f0342 117 * Class constructor.
e501603b
TO
118 */
119 function __construct() {
120 $this->__table = 'civicrm_tag';
121 parent::__construct();
122 }
123 /**
f41f0342 124 * Returns foreign keys and entity references.
e501603b
TO
125 *
126 * @return array
127 * [CRM_Core_Reference_Interface]
128 */
129 static function getReferenceColumns() {
346aaaba
TO
130 if (!isset(Civi::$statics[__CLASS__]['links'])) {
131 Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
132 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'parent_id', 'civicrm_tag', 'id');
133 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'created_id', 'civicrm_contact', 'id');
134 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
e501603b 135 }
346aaaba 136 return Civi::$statics[__CLASS__]['links'];
e501603b
TO
137 }
138 /**
139 * Returns all the column names of this table
140 *
141 * @return array
142 */
143 static function &fields() {
346aaaba
TO
144 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
145 Civi::$statics[__CLASS__]['fields'] = array(
e501603b
TO
146 'id' => array(
147 'name' => 'id',
148 'type' => CRM_Utils_Type::T_INT,
149 'title' => ts('Tag ID') ,
150 'description' => 'Tag ID',
151 'required' => true,
522a26c9 152 'table_name' => 'civicrm_tag',
153 'entity' => 'Tag',
154 'bao' => 'CRM_Core_BAO_Tag',
6a7e5e5d 155 'localizable' => 0,
e501603b
TO
156 ) ,
157 'name' => array(
158 'name' => 'name',
159 'type' => CRM_Utils_Type::T_STRING,
160 'title' => ts('Tag Name') ,
161 'description' => 'Name of Tag.',
162 'required' => true,
163 'maxlength' => 64,
164 'size' => CRM_Utils_Type::BIG,
522a26c9 165 'table_name' => 'civicrm_tag',
166 'entity' => 'Tag',
167 'bao' => 'CRM_Core_BAO_Tag',
6a7e5e5d 168 'localizable' => 0,
e501603b
TO
169 ) ,
170 'description' => array(
171 'name' => 'description',
172 'type' => CRM_Utils_Type::T_STRING,
173 'title' => ts('Description') ,
174 'description' => 'Optional verbose description of the tag.',
175 'maxlength' => 255,
176 'size' => CRM_Utils_Type::HUGE,
522a26c9 177 'table_name' => 'civicrm_tag',
178 'entity' => 'Tag',
179 'bao' => 'CRM_Core_BAO_Tag',
6a7e5e5d 180 'localizable' => 0,
e501603b
TO
181 ) ,
182 'parent_id' => array(
183 'name' => 'parent_id',
184 'type' => CRM_Utils_Type::T_INT,
185 'title' => ts('Parent Tag') ,
186 'description' => 'Optional parent id for this tag.',
187 'default' => 'NULL',
522a26c9 188 'table_name' => 'civicrm_tag',
189 'entity' => 'Tag',
190 'bao' => 'CRM_Core_BAO_Tag',
6a7e5e5d 191 'localizable' => 0,
e501603b
TO
192 'FKClassName' => 'CRM_Core_DAO_Tag',
193 ) ,
194 'is_selectable' => array(
195 'name' => 'is_selectable',
196 'type' => CRM_Utils_Type::T_BOOLEAN,
197 'title' => ts('Display Tag?') ,
198 'description' => 'Is this tag selectable / displayed',
199 'default' => '1',
522a26c9 200 'table_name' => 'civicrm_tag',
201 'entity' => 'Tag',
202 'bao' => 'CRM_Core_BAO_Tag',
6a7e5e5d 203 'localizable' => 0,
e501603b
TO
204 ) ,
205 'is_reserved' => array(
206 'name' => 'is_reserved',
207 'type' => CRM_Utils_Type::T_BOOLEAN,
208 'title' => ts('Reserved') ,
522a26c9 209 'table_name' => 'civicrm_tag',
210 'entity' => 'Tag',
211 'bao' => 'CRM_Core_BAO_Tag',
6a7e5e5d 212 'localizable' => 0,
e501603b
TO
213 ) ,
214 'is_tagset' => array(
215 'name' => 'is_tagset',
216 'type' => CRM_Utils_Type::T_BOOLEAN,
217 'title' => ts('Tagset') ,
522a26c9 218 'table_name' => 'civicrm_tag',
219 'entity' => 'Tag',
220 'bao' => 'CRM_Core_BAO_Tag',
6a7e5e5d 221 'localizable' => 0,
e501603b
TO
222 ) ,
223 'used_for' => array(
224 'name' => 'used_for',
225 'type' => CRM_Utils_Type::T_STRING,
226 'title' => ts('Used For') ,
227 'maxlength' => 64,
228 'size' => CRM_Utils_Type::BIG,
229 'default' => 'NULL',
522a26c9 230 'table_name' => 'civicrm_tag',
231 'entity' => 'Tag',
232 'bao' => 'CRM_Core_BAO_Tag',
6a7e5e5d 233 'localizable' => 0,
e501603b
TO
234 'html' => array(
235 'type' => 'Select',
236 ) ,
237 'pseudoconstant' => array(
238 'optionGroupName' => 'tag_used_for',
239 'optionEditPath' => 'civicrm/admin/options/tag_used_for',
240 )
241 ) ,
242 'created_id' => array(
243 'name' => 'created_id',
244 'type' => CRM_Utils_Type::T_INT,
245 'title' => ts('Tag Created By') ,
246 'description' => 'FK to civicrm_contact, who created this tag',
522a26c9 247 'table_name' => 'civicrm_tag',
248 'entity' => 'Tag',
249 'bao' => 'CRM_Core_BAO_Tag',
6a7e5e5d 250 'localizable' => 0,
e501603b
TO
251 'FKClassName' => 'CRM_Contact_DAO_Contact',
252 ) ,
d73974ac
CW
253 'color' => array(
254 'name' => 'color',
255 'type' => CRM_Utils_Type::T_STRING,
256 'title' => ts('Color') ,
257 'description' => 'Hex color value e.g. #ffffff',
258 'maxlength' => 255,
259 'size' => CRM_Utils_Type::HUGE,
260 'default' => 'NULL',
522a26c9 261 'table_name' => 'civicrm_tag',
262 'entity' => 'Tag',
263 'bao' => 'CRM_Core_BAO_Tag',
6a7e5e5d 264 'localizable' => 0,
d73974ac 265 ) ,
e501603b
TO
266 'created_date' => array(
267 'name' => 'created_date',
268 'type' => CRM_Utils_Type::T_DATE + CRM_Utils_Type::T_TIME,
269 'title' => ts('Tag Created Date') ,
270 'description' => 'Date and time that tag was created.',
522a26c9 271 'table_name' => 'civicrm_tag',
272 'entity' => 'Tag',
273 'bao' => 'CRM_Core_BAO_Tag',
6a7e5e5d 274 'localizable' => 0,
e501603b
TO
275 ) ,
276 );
346aaaba 277 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 278 }
346aaaba 279 return Civi::$statics[__CLASS__]['fields'];
e501603b
TO
280 }
281 /**
bd8e0b14 282 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
283 *
284 * @return array
bd8e0b14 285 * Array(string $name => string $uniqueName).
e501603b
TO
286 */
287 static function &fieldKeys() {
bd8e0b14
TO
288 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
289 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 290 }
bd8e0b14 291 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b
TO
292 }
293 /**
294 * Returns the names of this table
295 *
296 * @return string
297 */
298 static function getTableName() {
299 return self::$_tableName;
300 }
301 /**
302 * Returns if this table needs to be logged
303 *
304 * @return boolean
305 */
306 function getLog() {
307 return self::$_log;
308 }
309 /**
310 * Returns the list of fields that can be imported
311 *
312 * @param bool $prefix
313 *
314 * @return array
315 */
316 static function &import($prefix = false) {
60808919
TO
317 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'tag', $prefix, array());
318 return $r;
e501603b
TO
319 }
320 /**
321 * Returns the list of fields that can be exported
322 *
323 * @param bool $prefix
324 *
325 * @return array
326 */
327 static function &export($prefix = false) {
60808919
TO
328 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'tag', $prefix, array());
329 return $r;
e501603b 330 }
e7a6b91a
AS
331 /**
332 * Returns the list of indices
333 */
334 public static function indices($localize = TRUE) {
335 $indices = array(
336 'UI_name' => array(
337 'name' => 'UI_name',
338 'field' => array(
339 0 => 'name',
340 ) ,
341 'localizable' => false,
342 'unique' => true,
343 'sig' => 'civicrm_tag::1::name',
344 ) ,
345 );
346 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
347 }
e501603b 348}