Merge pull request #9417 from ineffyble/CRM-19581
[civicrm-core.git] / CRM / Contact / DAO / Group.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/Contact/Group.xml
32 * DO NOT EDIT. Generated by CRM_Core_CodeGen
437fafcf 33 * (GenCodeChecksum:dfc60eae37cca2aa63dc674d2613264c)
e501603b
TO
34 */
35require_once 'CRM/Core/DAO.php';
36require_once 'CRM/Utils/Type.php';
37class CRM_Contact_DAO_Group extends CRM_Core_DAO {
38 /**
39 * static instance to hold the table name
40 *
41 * @var string
42 */
43 static $_tableName = 'civicrm_group';
e501603b
TO
44 /**
45 * static value to see if we should log any modifications to
46 * this table in the civicrm_log table
47 *
48 * @var boolean
49 */
50 static $_log = true;
51 /**
52 * Group ID
53 *
54 * @var int unsigned
55 */
56 public $id;
57 /**
58 * Internal name of Group.
59 *
60 * @var string
61 */
62 public $name;
63 /**
64 * Name of Group.
65 *
66 * @var string
67 */
68 public $title;
69 /**
70 * Optional verbose description of the group.
71 *
72 * @var text
73 */
74 public $description;
75 /**
76 * Module or process which created this group.
77 *
78 * @var string
79 */
80 public $source;
81 /**
82 * FK to saved search table.
83 *
84 * @var int unsigned
85 */
86 public $saved_search_id;
87 /**
88 * Is this entry active?
89 *
90 * @var boolean
91 */
92 public $is_active;
93 /**
94 * In what context(s) is this field visible.
95 *
96 * @var string
97 */
98 public $visibility;
99 /**
100 * the sql where clause if a saved search acl
101 *
102 * @var text
103 */
104 public $where_clause;
105 /**
106 * the tables to be included in a select data
107 *
108 * @var text
109 */
110 public $select_tables;
111 /**
112 * the tables to be included in the count statement
113 *
114 * @var text
115 */
116 public $where_tables;
117 /**
118 * FK to group type
119 *
120 * @var string
121 */
122 public $group_type;
123 /**
124 * Date when we created the cache for a smart group
125 *
126 * @var timestamp
127 */
128 public $cache_date;
129 /**
130 * Date and time when we need to refresh the cache next.
131 *
132 * @var timestamp
133 */
134 public $refresh_date;
135 /**
136 * IDs of the parent(s)
137 *
138 * @var text
139 */
140 public $parents;
141 /**
142 * IDs of the child(ren)
143 *
144 * @var text
145 */
146 public $children;
147 /**
148 * Is this group hidden?
149 *
150 * @var boolean
151 */
152 public $is_hidden;
153 /**
154 *
155 * @var boolean
156 */
157 public $is_reserved;
158 /**
159 * FK to contact table.
160 *
161 * @var int unsigned
162 */
163 public $created_id;
164 /**
165 * FK to contact table.
166 *
167 * @var int unsigned
168 */
169 public $modified_id;
170 /**
171 * class constructor
172 *
173 * @return civicrm_group
174 */
175 function __construct() {
176 $this->__table = 'civicrm_group';
177 parent::__construct();
178 }
179 /**
180 * Returns foreign keys and entity references
181 *
182 * @return array
183 * [CRM_Core_Reference_Interface]
184 */
185 static function getReferenceColumns() {
346aaaba
TO
186 if (!isset(Civi::$statics[__CLASS__]['links'])) {
187 Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
188 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'saved_search_id', 'civicrm_saved_search', 'id');
189 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'created_id', 'civicrm_contact', 'id');
190 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'modified_id', 'civicrm_contact', 'id');
191 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
e501603b 192 }
346aaaba 193 return Civi::$statics[__CLASS__]['links'];
e501603b
TO
194 }
195 /**
196 * Returns all the column names of this table
197 *
198 * @return array
199 */
200 static function &fields() {
346aaaba
TO
201 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
202 Civi::$statics[__CLASS__]['fields'] = array(
e501603b
TO
203 'id' => array(
204 'name' => 'id',
205 'type' => CRM_Utils_Type::T_INT,
206 'title' => ts('Group ID') ,
207 'description' => 'Group ID',
208 'required' => true,
209 ) ,
210 'name' => array(
211 'name' => 'name',
212 'type' => CRM_Utils_Type::T_STRING,
213 'title' => ts('Group Name') ,
214 'description' => 'Internal name of Group.',
215 'maxlength' => 64,
216 'size' => CRM_Utils_Type::BIG,
217 ) ,
218 'title' => array(
219 'name' => 'title',
220 'type' => CRM_Utils_Type::T_STRING,
221 'title' => ts('Group Title') ,
222 'description' => 'Name of Group.',
223 'maxlength' => 64,
224 'size' => CRM_Utils_Type::BIG,
225 ) ,
226 'description' => array(
227 'name' => 'description',
228 'type' => CRM_Utils_Type::T_TEXT,
229 'title' => ts('Group Description') ,
230 'description' => 'Optional verbose description of the group.',
231 'rows' => 2,
232 'cols' => 60,
233 'html' => array(
234 'type' => 'TextArea',
235 ) ,
236 ) ,
237 'source' => array(
238 'name' => 'source',
239 'type' => CRM_Utils_Type::T_STRING,
240 'title' => ts('Group Source') ,
241 'description' => 'Module or process which created this group.',
242 'maxlength' => 64,
243 'size' => CRM_Utils_Type::BIG,
244 ) ,
245 'saved_search_id' => array(
246 'name' => 'saved_search_id',
247 'type' => CRM_Utils_Type::T_INT,
248 'title' => ts('Saved Search ID') ,
249 'description' => 'FK to saved search table.',
250 'FKClassName' => 'CRM_Contact_DAO_SavedSearch',
251 ) ,
252 'is_active' => array(
253 'name' => 'is_active',
254 'type' => CRM_Utils_Type::T_BOOLEAN,
255 'title' => ts('Group Enabled') ,
256 'description' => 'Is this entry active?',
257 ) ,
258 'visibility' => array(
259 'name' => 'visibility',
260 'type' => CRM_Utils_Type::T_STRING,
261 'title' => ts('Group Visibility Setting') ,
262 'description' => 'In what context(s) is this field visible.',
263 'maxlength' => 24,
264 'size' => CRM_Utils_Type::MEDIUM,
265 'default' => 'User and User Admin Only',
266 'html' => array(
267 'type' => 'Select',
268 ) ,
269 'pseudoconstant' => array(
270 'callback' => 'CRM_Core_SelectValues::groupVisibility',
271 )
272 ) ,
273 'where_clause' => array(
274 'name' => 'where_clause',
275 'type' => CRM_Utils_Type::T_TEXT,
276 'title' => ts('Group Where Clause') ,
277 'description' => 'the sql where clause if a saved search acl',
278 ) ,
279 'select_tables' => array(
280 'name' => 'select_tables',
281 'type' => CRM_Utils_Type::T_TEXT,
282 'title' => ts('Tables For Select Clause') ,
283 'description' => 'the tables to be included in a select data',
284 ) ,
285 'where_tables' => array(
286 'name' => 'where_tables',
287 'type' => CRM_Utils_Type::T_TEXT,
288 'title' => ts('Tables For Where Clause') ,
289 'description' => 'the tables to be included in the count statement',
290 ) ,
291 'group_type' => array(
292 'name' => 'group_type',
293 'type' => CRM_Utils_Type::T_STRING,
294 'title' => ts('Group Type') ,
295 'description' => 'FK to group type',
296 'maxlength' => 128,
297 'size' => CRM_Utils_Type::HUGE,
298 'pseudoconstant' => array(
299 'optionGroupName' => 'group_type',
300 'optionEditPath' => 'civicrm/admin/options/group_type',
301 )
302 ) ,
303 'cache_date' => array(
304 'name' => 'cache_date',
305 'type' => CRM_Utils_Type::T_TIMESTAMP,
306 'title' => ts('Group Cache Date') ,
307 'description' => 'Date when we created the cache for a smart group',
308 'required' => false,
309 ) ,
310 'refresh_date' => array(
311 'name' => 'refresh_date',
312 'type' => CRM_Utils_Type::T_TIMESTAMP,
313 'title' => ts('Next Group Refresh Time') ,
314 'description' => 'Date and time when we need to refresh the cache next.',
315 'required' => false,
316 ) ,
317 'parents' => array(
318 'name' => 'parents',
319 'type' => CRM_Utils_Type::T_TEXT,
320 'title' => ts('Group Parents') ,
321 'description' => 'IDs of the parent(s)',
322 ) ,
323 'children' => array(
324 'name' => 'children',
325 'type' => CRM_Utils_Type::T_TEXT,
326 'title' => ts('Group Children') ,
327 'description' => 'IDs of the child(ren)',
328 ) ,
329 'is_hidden' => array(
330 'name' => 'is_hidden',
331 'type' => CRM_Utils_Type::T_BOOLEAN,
332 'title' => ts('Group is Hidden') ,
333 'description' => 'Is this group hidden?',
334 ) ,
335 'is_reserved' => array(
336 'name' => 'is_reserved',
337 'type' => CRM_Utils_Type::T_BOOLEAN,
338 'title' => ts('Group is Reserved') ,
339 ) ,
340 'created_id' => array(
341 'name' => 'created_id',
342 'type' => CRM_Utils_Type::T_INT,
343 'title' => ts('Group Created By') ,
344 'description' => 'FK to contact table.',
345 'FKClassName' => 'CRM_Contact_DAO_Contact',
346 ) ,
347 'modified_id' => array(
348 'name' => 'modified_id',
349 'type' => CRM_Utils_Type::T_INT,
350 'title' => ts('Group Modified By') ,
351 'description' => 'FK to contact table.',
352 'FKClassName' => 'CRM_Contact_DAO_Contact',
353 ) ,
354 );
346aaaba 355 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 356 }
346aaaba 357 return Civi::$statics[__CLASS__]['fields'];
e501603b
TO
358 }
359 /**
bd8e0b14 360 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
361 *
362 * @return array
bd8e0b14 363 * Array(string $name => string $uniqueName).
e501603b
TO
364 */
365 static function &fieldKeys() {
bd8e0b14
TO
366 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
367 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 368 }
bd8e0b14 369 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b
TO
370 }
371 /**
372 * Returns the names of this table
373 *
374 * @return string
375 */
376 static function getTableName() {
377 return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
378 }
379 /**
380 * Returns if this table needs to be logged
381 *
382 * @return boolean
383 */
384 function getLog() {
385 return self::$_log;
386 }
387 /**
388 * Returns the list of fields that can be imported
389 *
390 * @param bool $prefix
391 *
392 * @return array
393 */
394 static function &import($prefix = false) {
60808919
TO
395 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'group', $prefix, array());
396 return $r;
e501603b
TO
397 }
398 /**
399 * Returns the list of fields that can be exported
400 *
401 * @param bool $prefix
402 *
403 * @return array
404 */
405 static function &export($prefix = false) {
60808919
TO
406 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'group', $prefix, array());
407 return $r;
e501603b
TO
408 }
409}