Merge pull request #17709 from spalmstr/dev/core#1768
[civicrm-core.git] / CRM / Contact / DAO / ContactType.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Contact/ContactType.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:34f2ee23181ddce3050484b6e30b0e72)
10 */
11
12 /**
13 * Database access object for the ContactType entity.
14 */
15 class CRM_Contact_DAO_ContactType extends CRM_Core_DAO {
16
17 /**
18 * Static instance to hold the table name.
19 *
20 * @var string
21 */
22 public static $_tableName = 'civicrm_contact_type';
23
24 /**
25 * Should CiviCRM log any modifications to this table in the civicrm_log table.
26 *
27 * @var bool
28 */
29 public static $_log = FALSE;
30
31 /**
32 * Contact Type ID
33 *
34 * @var int
35 */
36 public $id;
37
38 /**
39 * Internal name of Contact Type (or Subtype).
40 *
41 * @var string
42 */
43 public $name;
44
45 /**
46 * localized Name of Contact Type.
47 *
48 * @var string
49 */
50 public $label;
51
52 /**
53 * localized Optional verbose description of the type.
54 *
55 * @var text
56 */
57 public $description;
58
59 /**
60 * URL of image if any.
61 *
62 * @var string
63 */
64 public $image_URL;
65
66 /**
67 * Optional FK to parent contact type.
68 *
69 * @var int
70 */
71 public $parent_id;
72
73 /**
74 * Is this entry active?
75 *
76 * @var bool
77 */
78 public $is_active;
79
80 /**
81 * Is this contact type a predefined system type
82 *
83 * @var bool
84 */
85 public $is_reserved;
86
87 /**
88 * Class constructor.
89 */
90 public function __construct() {
91 $this->__table = 'civicrm_contact_type';
92 parent::__construct();
93 }
94
95 /**
96 * Returns localized title of this entity.
97 */
98 public static function getEntityTitle() {
99 return ts('Contact Types');
100 }
101
102 /**
103 * Returns foreign keys and entity references.
104 *
105 * @return array
106 * [CRM_Core_Reference_Interface]
107 */
108 public static function getReferenceColumns() {
109 if (!isset(Civi::$statics[__CLASS__]['links'])) {
110 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
111 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'parent_id', 'civicrm_contact_type', 'id');
112 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
113 }
114 return Civi::$statics[__CLASS__]['links'];
115 }
116
117 /**
118 * Returns all the column names of this table
119 *
120 * @return array
121 */
122 public static function &fields() {
123 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
124 Civi::$statics[__CLASS__]['fields'] = [
125 'id' => [
126 'name' => 'id',
127 'type' => CRM_Utils_Type::T_INT,
128 'title' => ts('Contact Type ID'),
129 'description' => ts('Contact Type ID'),
130 'required' => TRUE,
131 'where' => 'civicrm_contact_type.id',
132 'table_name' => 'civicrm_contact_type',
133 'entity' => 'ContactType',
134 'bao' => 'CRM_Contact_BAO_ContactType',
135 'localizable' => 0,
136 'add' => '1.1',
137 ],
138 'name' => [
139 'name' => 'name',
140 'type' => CRM_Utils_Type::T_STRING,
141 'title' => ts('Name'),
142 'description' => ts('Internal name of Contact Type (or Subtype).'),
143 'required' => TRUE,
144 'maxlength' => 64,
145 'size' => CRM_Utils_Type::BIG,
146 'where' => 'civicrm_contact_type.name',
147 'table_name' => 'civicrm_contact_type',
148 'entity' => 'ContactType',
149 'bao' => 'CRM_Contact_BAO_ContactType',
150 'localizable' => 0,
151 'add' => '3.1',
152 ],
153 'label' => [
154 'name' => 'label',
155 'type' => CRM_Utils_Type::T_STRING,
156 'title' => ts('Contact Type Label'),
157 'description' => ts('localized Name of Contact Type.'),
158 'maxlength' => 64,
159 'size' => CRM_Utils_Type::BIG,
160 'where' => 'civicrm_contact_type.label',
161 'table_name' => 'civicrm_contact_type',
162 'entity' => 'ContactType',
163 'bao' => 'CRM_Contact_BAO_ContactType',
164 'localizable' => 1,
165 'add' => '3.1',
166 ],
167 'description' => [
168 'name' => 'description',
169 'type' => CRM_Utils_Type::T_TEXT,
170 'title' => ts('Contact Type Description'),
171 'description' => ts('localized Optional verbose description of the type.'),
172 'rows' => 2,
173 'cols' => 60,
174 'where' => 'civicrm_contact_type.description',
175 'table_name' => 'civicrm_contact_type',
176 'entity' => 'ContactType',
177 'bao' => 'CRM_Contact_BAO_ContactType',
178 'localizable' => 1,
179 'html' => [
180 'type' => 'TextArea',
181 ],
182 'add' => '3.1',
183 ],
184 'image_URL' => [
185 'name' => 'image_URL',
186 'type' => CRM_Utils_Type::T_STRING,
187 'title' => ts('Contact Type Image URL'),
188 'description' => ts('URL of image if any.'),
189 'maxlength' => 255,
190 'size' => CRM_Utils_Type::HUGE,
191 'where' => 'civicrm_contact_type.image_URL',
192 'table_name' => 'civicrm_contact_type',
193 'entity' => 'ContactType',
194 'bao' => 'CRM_Contact_BAO_ContactType',
195 'localizable' => 0,
196 'add' => '3.1',
197 ],
198 'parent_id' => [
199 'name' => 'parent_id',
200 'type' => CRM_Utils_Type::T_INT,
201 'title' => ts('Contact Type Parent'),
202 'description' => ts('Optional FK to parent contact type.'),
203 'where' => 'civicrm_contact_type.parent_id',
204 'table_name' => 'civicrm_contact_type',
205 'entity' => 'ContactType',
206 'bao' => 'CRM_Contact_BAO_ContactType',
207 'localizable' => 0,
208 'FKClassName' => 'CRM_Contact_DAO_ContactType',
209 'pseudoconstant' => [
210 'table' => 'civicrm_contact_type',
211 'keyColumn' => 'id',
212 'labelColumn' => 'label',
213 'condition' => 'parent_id IS NULL',
214 ],
215 'add' => '3.1',
216 ],
217 'is_active' => [
218 'name' => 'is_active',
219 'type' => CRM_Utils_Type::T_BOOLEAN,
220 'title' => ts('Contact Type Is Active?'),
221 'description' => ts('Is this entry active?'),
222 'where' => 'civicrm_contact_type.is_active',
223 'default' => '1',
224 'table_name' => 'civicrm_contact_type',
225 'entity' => 'ContactType',
226 'bao' => 'CRM_Contact_BAO_ContactType',
227 'localizable' => 0,
228 'add' => '3.1',
229 ],
230 'is_reserved' => [
231 'name' => 'is_reserved',
232 'type' => CRM_Utils_Type::T_BOOLEAN,
233 'title' => ts('Contact Type is Reserved?'),
234 'description' => ts('Is this contact type a predefined system type'),
235 'where' => 'civicrm_contact_type.is_reserved',
236 'default' => '0',
237 'table_name' => 'civicrm_contact_type',
238 'entity' => 'ContactType',
239 'bao' => 'CRM_Contact_BAO_ContactType',
240 'localizable' => 0,
241 'add' => '3.1',
242 ],
243 ];
244 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
245 }
246 return Civi::$statics[__CLASS__]['fields'];
247 }
248
249 /**
250 * Return a mapping from field-name to the corresponding key (as used in fields()).
251 *
252 * @return array
253 * Array(string $name => string $uniqueName).
254 */
255 public static function &fieldKeys() {
256 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
257 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
258 }
259 return Civi::$statics[__CLASS__]['fieldKeys'];
260 }
261
262 /**
263 * Returns the names of this table
264 *
265 * @return string
266 */
267 public static function getTableName() {
268 return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
269 }
270
271 /**
272 * Returns if this table needs to be logged
273 *
274 * @return bool
275 */
276 public function getLog() {
277 return self::$_log;
278 }
279
280 /**
281 * Returns the list of fields that can be imported
282 *
283 * @param bool $prefix
284 *
285 * @return array
286 */
287 public static function &import($prefix = FALSE) {
288 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'contact_type', $prefix, []);
289 return $r;
290 }
291
292 /**
293 * Returns the list of fields that can be exported
294 *
295 * @param bool $prefix
296 *
297 * @return array
298 */
299 public static function &export($prefix = FALSE) {
300 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'contact_type', $prefix, []);
301 return $r;
302 }
303
304 /**
305 * Returns the list of indices
306 *
307 * @param bool $localize
308 *
309 * @return array
310 */
311 public static function indices($localize = TRUE) {
312 $indices = [
313 'contact_type' => [
314 'name' => 'contact_type',
315 'field' => [
316 0 => 'name',
317 ],
318 'localizable' => FALSE,
319 'unique' => TRUE,
320 'sig' => 'civicrm_contact_type::1::name',
321 ],
322 ];
323 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
324 }
325
326 }