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