db032d503fe6d0629eb42caf200e96d017497a74
[civicrm-core.git] / CRM / Contact / DAO / ContactType.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC (c) 2004-2019
6 *
7 * Generated from xml/schema/CRM/Contact/ContactType.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:ab123a55d492c003df354c32e8b9863c)
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 unsigned
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 unsigned
70 */
71 public $parent_id;
72
73 /**
74 * Is this entry active?
75 *
76 * @var boolean
77 */
78 public $is_active;
79
80 /**
81 * Is this contact type a predefined system type
82 *
83 * @var boolean
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 foreign keys and entity references.
97 *
98 * @return array
99 * [CRM_Core_Reference_Interface]
100 */
101 public static function getReferenceColumns() {
102 if (!isset(Civi::$statics[__CLASS__]['links'])) {
103 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
104 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'parent_id', 'civicrm_contact_type', 'id');
105 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
106 }
107 return Civi::$statics[__CLASS__]['links'];
108 }
109
110 /**
111 * Returns all the column names of this table
112 *
113 * @return array
114 */
115 public static function &fields() {
116 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
117 Civi::$statics[__CLASS__]['fields'] = [
118 'id' => [
119 'name' => 'id',
120 'type' => CRM_Utils_Type::T_INT,
121 'title' => ts('Contact Type ID'),
122 'description' => ts('Contact Type ID'),
123 'required' => TRUE,
124 'table_name' => 'civicrm_contact_type',
125 'entity' => 'ContactType',
126 'bao' => 'CRM_Contact_BAO_ContactType',
127 'localizable' => 0,
128 ],
129 'name' => [
130 'name' => 'name',
131 'type' => CRM_Utils_Type::T_STRING,
132 'title' => ts('Name'),
133 'description' => ts('Internal name of Contact Type (or Subtype).'),
134 'maxlength' => 64,
135 'size' => CRM_Utils_Type::BIG,
136 'table_name' => 'civicrm_contact_type',
137 'entity' => 'ContactType',
138 'bao' => 'CRM_Contact_BAO_ContactType',
139 'localizable' => 0,
140 ],
141 'label' => [
142 'name' => 'label',
143 'type' => CRM_Utils_Type::T_STRING,
144 'title' => ts('Contact Type Label'),
145 'description' => ts('localized Name of Contact Type.'),
146 'maxlength' => 64,
147 'size' => CRM_Utils_Type::BIG,
148 'table_name' => 'civicrm_contact_type',
149 'entity' => 'ContactType',
150 'bao' => 'CRM_Contact_BAO_ContactType',
151 'localizable' => 1,
152 ],
153 'description' => [
154 'name' => 'description',
155 'type' => CRM_Utils_Type::T_TEXT,
156 'title' => ts('Contact Type Description'),
157 'description' => ts('localized Optional verbose description of the type.'),
158 'rows' => 2,
159 'cols' => 60,
160 'table_name' => 'civicrm_contact_type',
161 'entity' => 'ContactType',
162 'bao' => 'CRM_Contact_BAO_ContactType',
163 'localizable' => 1,
164 'html' => [
165 'type' => 'TextArea',
166 ],
167 ],
168 'image_URL' => [
169 'name' => 'image_URL',
170 'type' => CRM_Utils_Type::T_STRING,
171 'title' => ts('Contact Type Image URL'),
172 'description' => ts('URL of image if any.'),
173 'maxlength' => 255,
174 'size' => CRM_Utils_Type::HUGE,
175 'table_name' => 'civicrm_contact_type',
176 'entity' => 'ContactType',
177 'bao' => 'CRM_Contact_BAO_ContactType',
178 'localizable' => 0,
179 ],
180 'parent_id' => [
181 'name' => 'parent_id',
182 'type' => CRM_Utils_Type::T_INT,
183 'title' => ts('Contact Type Parent'),
184 'description' => ts('Optional FK to parent contact type.'),
185 'table_name' => 'civicrm_contact_type',
186 'entity' => 'ContactType',
187 'bao' => 'CRM_Contact_BAO_ContactType',
188 'localizable' => 0,
189 'FKClassName' => 'CRM_Contact_DAO_ContactType',
190 'pseudoconstant' => [
191 'table' => 'civicrm_contact_type',
192 'keyColumn' => 'id',
193 'labelColumn' => 'label',
194 'condition' => 'parent_id IS NULL',
195 ]
196 ],
197 'is_active' => [
198 'name' => 'is_active',
199 'type' => CRM_Utils_Type::T_BOOLEAN,
200 'title' => ts('Contact Type Is Active?'),
201 'description' => ts('Is this entry active?'),
202 'table_name' => 'civicrm_contact_type',
203 'entity' => 'ContactType',
204 'bao' => 'CRM_Contact_BAO_ContactType',
205 'localizable' => 0,
206 ],
207 'is_reserved' => [
208 'name' => 'is_reserved',
209 'type' => CRM_Utils_Type::T_BOOLEAN,
210 'title' => ts('Contact Type is Reserved?'),
211 'description' => ts('Is this contact type a predefined system type'),
212 'table_name' => 'civicrm_contact_type',
213 'entity' => 'ContactType',
214 'bao' => 'CRM_Contact_BAO_ContactType',
215 'localizable' => 0,
216 ],
217 ];
218 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
219 }
220 return Civi::$statics[__CLASS__]['fields'];
221 }
222
223 /**
224 * Return a mapping from field-name to the corresponding key (as used in fields()).
225 *
226 * @return array
227 * Array(string $name => string $uniqueName).
228 */
229 public static function &fieldKeys() {
230 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
231 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
232 }
233 return Civi::$statics[__CLASS__]['fieldKeys'];
234 }
235
236 /**
237 * Returns the names of this table
238 *
239 * @return string
240 */
241 public static function getTableName() {
242 return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
243 }
244
245 /**
246 * Returns if this table needs to be logged
247 *
248 * @return bool
249 */
250 public function getLog() {
251 return self::$_log;
252 }
253
254 /**
255 * Returns the list of fields that can be imported
256 *
257 * @param bool $prefix
258 *
259 * @return array
260 */
261 public static function &import($prefix = FALSE) {
262 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'contact_type', $prefix, []);
263 return $r;
264 }
265
266 /**
267 * Returns the list of fields that can be exported
268 *
269 * @param bool $prefix
270 *
271 * @return array
272 */
273 public static function &export($prefix = FALSE) {
274 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'contact_type', $prefix, []);
275 return $r;
276 }
277
278 /**
279 * Returns the list of indices
280 *
281 * @param bool $localize
282 *
283 * @return array
284 */
285 public static function indices($localize = TRUE) {
286 $indices = [
287 'contact_type' => [
288 'name' => 'contact_type',
289 'field' => [
290 0 => 'name',
291 ],
292 'localizable' => FALSE,
293 'unique' => TRUE,
294 'sig' => 'civicrm_contact_type::1::name',
295 ],
296 ];
297 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
298 }
299
300 }