xml/templates/dao.tpl - Simplify fieldKeys()
[civicrm-core.git] / CRM / Contact / DAO / ContactType.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/ContactType.xml
32 * DO NOT EDIT. Generated by CRM_Core_CodeGen
437fafcf 33 * (GenCodeChecksum:5cd581b1cd8b3dc4f942b1612a1daff0)
e501603b
TO
34 */
35require_once 'CRM/Core/DAO.php';
36require_once 'CRM/Utils/Type.php';
37class CRM_Contact_DAO_ContactType extends CRM_Core_DAO {
38 /**
39 * static instance to hold the table name
40 *
41 * @var string
42 */
43 static $_tableName = 'civicrm_contact_type';
44 /**
45 * static instance to hold the field values
46 *
47 * @var array
48 */
49 static $_fields = null;
50 /**
51 * static instance to hold the keys used in $_fields for each field.
52 *
53 * @var array
54 */
55 static $_fieldKeys = null;
56 /**
57 * static instance to hold the FK relationships
58 *
59 * @var string
60 */
61 static $_links = null;
e501603b
TO
62 /**
63 * static value to see if we should log any modifications to
64 * this table in the civicrm_log table
65 *
66 * @var boolean
67 */
68 static $_log = false;
69 /**
70 * Contact Type ID
71 *
72 * @var int unsigned
73 */
74 public $id;
75 /**
76 * Internal name of Contact Type (or Subtype).
77 *
78 * @var string
79 */
80 public $name;
81 /**
82 * localized Name of Contact Type.
83 *
84 * @var string
85 */
86 public $label;
87 /**
88 * localized Optional verbose description of the type.
89 *
90 * @var text
91 */
92 public $description;
93 /**
94 * URL of image if any.
95 *
96 * @var string
97 */
98 public $image_URL;
99 /**
100 * Optional FK to parent contact type.
101 *
102 * @var int unsigned
103 */
104 public $parent_id;
105 /**
106 * Is this entry active?
107 *
108 * @var boolean
109 */
110 public $is_active;
111 /**
112 * Is this contact type a predefined system type
113 *
114 * @var boolean
115 */
116 public $is_reserved;
117 /**
118 * class constructor
119 *
120 * @return civicrm_contact_type
121 */
122 function __construct() {
123 $this->__table = 'civicrm_contact_type';
124 parent::__construct();
125 }
126 /**
127 * Returns foreign keys and entity references
128 *
129 * @return array
130 * [CRM_Core_Reference_Interface]
131 */
132 static function getReferenceColumns() {
133 if (!self::$_links) {
134 self::$_links = static ::createReferenceColumns(__CLASS__);
135 self::$_links[] = new CRM_Core_Reference_Basic(self::getTableName() , 'parent_id', 'civicrm_contact_type', 'id');
136 }
137 return self::$_links;
138 }
139 /**
140 * Returns all the column names of this table
141 *
142 * @return array
143 */
144 static function &fields() {
145 if (!(self::$_fields)) {
146 self::$_fields = array(
147 'id' => array(
148 'name' => 'id',
149 'type' => CRM_Utils_Type::T_INT,
150 'title' => ts('Contact Type ID') ,
151 'description' => 'Contact Type ID',
152 'required' => true,
153 ) ,
154 'name' => array(
155 'name' => 'name',
156 'type' => CRM_Utils_Type::T_STRING,
157 'title' => ts('Name') ,
158 'description' => 'Internal name of Contact Type (or Subtype).',
159 'maxlength' => 64,
160 'size' => CRM_Utils_Type::BIG,
161 ) ,
162 'label' => array(
163 'name' => 'label',
164 'type' => CRM_Utils_Type::T_STRING,
165 'title' => ts('Contact Type Label') ,
166 'description' => 'localized Name of Contact Type.',
167 'maxlength' => 64,
168 'size' => CRM_Utils_Type::BIG,
169 ) ,
170 'description' => array(
171 'name' => 'description',
172 'type' => CRM_Utils_Type::T_TEXT,
173 'title' => ts('Contact Type Description') ,
174 'description' => 'localized Optional verbose description of the type.',
175 'rows' => 2,
176 'cols' => 60,
177 'html' => array(
178 'type' => 'TextArea',
179 ) ,
180 ) ,
181 'image_URL' => array(
182 'name' => 'image_URL',
183 'type' => CRM_Utils_Type::T_STRING,
184 'title' => ts('Contact Type Image URL') ,
185 'description' => 'URL of image if any.',
186 'maxlength' => 255,
187 'size' => CRM_Utils_Type::HUGE,
188 ) ,
189 'parent_id' => array(
190 'name' => 'parent_id',
191 'type' => CRM_Utils_Type::T_INT,
192 'title' => ts('Contact Type Parent') ,
193 'description' => 'Optional FK to parent contact type.',
194 'FKClassName' => 'CRM_Contact_DAO_ContactType',
195 'pseudoconstant' => array(
196 'table' => 'civicrm_contact_type',
197 'keyColumn' => 'id',
198 'labelColumn' => 'label',
199 'condition' => 'parent_id IS NULL',
200 )
201 ) ,
202 'is_active' => array(
203 'name' => 'is_active',
204 'type' => CRM_Utils_Type::T_BOOLEAN,
205 'title' => ts('Contact Type Is Active?') ,
206 'description' => 'Is this entry active?',
207 ) ,
208 'is_reserved' => array(
209 'name' => 'is_reserved',
210 'type' => CRM_Utils_Type::T_BOOLEAN,
211 'title' => ts('Contact Type is Reserved?') ,
212 'description' => 'Is this contact type a predefined system type',
213 ) ,
214 );
215 }
216 return self::$_fields;
217 }
218 /**
219 * Returns an array containing, for each field, the arary key used for that
220 * field in self::$_fields.
221 *
222 * @return array
223 */
224 static function &fieldKeys() {
225 if (!(self::$_fieldKeys)) {
226 self::$_fieldKeys = array(
227 'id' => 'id',
228 'name' => 'name',
229 'label' => 'label',
230 'description' => 'description',
231 'image_URL' => 'image_URL',
232 'parent_id' => 'parent_id',
233 'is_active' => 'is_active',
234 'is_reserved' => 'is_reserved',
235 );
236 }
237 return self::$_fieldKeys;
238 }
239 /**
240 * Returns the names of this table
241 *
242 * @return string
243 */
244 static function getTableName() {
245 return CRM_Core_DAO::getLocaleTableName(self::$_tableName);
246 }
247 /**
248 * Returns if this table needs to be logged
249 *
250 * @return boolean
251 */
252 function getLog() {
253 return self::$_log;
254 }
255 /**
256 * Returns the list of fields that can be imported
257 *
258 * @param bool $prefix
259 *
260 * @return array
261 */
262 static function &import($prefix = false) {
60808919
TO
263 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'contact_type', $prefix, array());
264 return $r;
e501603b
TO
265 }
266 /**
267 * Returns the list of fields that can be exported
268 *
269 * @param bool $prefix
270 *
271 * @return array
272 */
273 static function &export($prefix = false) {
60808919
TO
274 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'contact_type', $prefix, array());
275 return $r;
e501603b
TO
276 }
277}