CRM-14885 - Import DAO's
[civicrm-core.git] / CRM / Core / DAO / IM.php
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/Core/IM.xml
32 * DO NOT EDIT. Generated by CRM_Core_CodeGen
33 * (GenCodeChecksum:1f7e266130e31dbdaf5e2021c5ba09ea)
34 */
35 require_once 'CRM/Core/DAO.php';
36 require_once 'CRM/Utils/Type.php';
37 class CRM_Core_DAO_IM extends CRM_Core_DAO {
38 /**
39 * static instance to hold the table name
40 *
41 * @var string
42 */
43 static $_tableName = 'civicrm_im';
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;
62 /**
63 * static instance to hold the values that can
64 * be imported
65 *
66 * @var array
67 */
68 static $_import = null;
69 /**
70 * static instance to hold the values that can
71 * be exported
72 *
73 * @var array
74 */
75 static $_export = null;
76 /**
77 * static value to see if we should log any modifications to
78 * this table in the civicrm_log table
79 *
80 * @var boolean
81 */
82 static $_log = true;
83 /**
84 * Unique IM ID
85 *
86 * @var int unsigned
87 */
88 public $id;
89 /**
90 * FK to Contact ID
91 *
92 * @var int unsigned
93 */
94 public $contact_id;
95 /**
96 * Which Location does this email belong to.
97 *
98 * @var int unsigned
99 */
100 public $location_type_id;
101 /**
102 * IM screen name
103 *
104 * @var string
105 */
106 public $name;
107 /**
108 * Which IM Provider does this screen name belong to.
109 *
110 * @var int unsigned
111 */
112 public $provider_id;
113 /**
114 * Is this the primary IM for this contact and location.
115 *
116 * @var boolean
117 */
118 public $is_primary;
119 /**
120 * Is this the billing?
121 *
122 * @var boolean
123 */
124 public $is_billing;
125 /**
126 * class constructor
127 *
128 * @return civicrm_im
129 */
130 function __construct() {
131 $this->__table = 'civicrm_im';
132 parent::__construct();
133 }
134 /**
135 * Returns foreign keys and entity references
136 *
137 * @return array
138 * [CRM_Core_Reference_Interface]
139 */
140 static function getReferenceColumns() {
141 if (!self::$_links) {
142 self::$_links = static ::createReferenceColumns(__CLASS__);
143 self::$_links[] = new CRM_Core_Reference_Basic(self::getTableName() , 'contact_id', 'civicrm_contact', 'id');
144 }
145 return self::$_links;
146 }
147 /**
148 * Returns all the column names of this table
149 *
150 * @return array
151 */
152 static function &fields() {
153 if (!(self::$_fields)) {
154 self::$_fields = array(
155 'id' => array(
156 'name' => 'id',
157 'type' => CRM_Utils_Type::T_INT,
158 'title' => ts('Instant Messenger ID') ,
159 'description' => 'Unique IM ID',
160 'required' => true,
161 ) ,
162 'contact_id' => array(
163 'name' => 'contact_id',
164 'type' => CRM_Utils_Type::T_INT,
165 'title' => ts('IM Contact') ,
166 'description' => 'FK to Contact ID',
167 'FKClassName' => 'CRM_Contact_DAO_Contact',
168 ) ,
169 'location_type_id' => array(
170 'name' => 'location_type_id',
171 'type' => CRM_Utils_Type::T_INT,
172 'title' => ts('IM Location Type') ,
173 'description' => 'Which Location does this email belong to.',
174 'html' => array(
175 'type' => 'Select',
176 ) ,
177 'pseudoconstant' => array(
178 'table' => 'civicrm_location_type',
179 'keyColumn' => 'id',
180 'labelColumn' => 'display_name',
181 )
182 ) ,
183 'name' => array(
184 'name' => 'name',
185 'type' => CRM_Utils_Type::T_STRING,
186 'title' => ts('IM Screen Name') ,
187 'description' => 'IM screen name',
188 'maxlength' => 64,
189 'size' => CRM_Utils_Type::BIG,
190 'import' => true,
191 'where' => 'civicrm_im.name',
192 'headerPattern' => '/I(nstant )?M(ess.*)?|screen(\s+)?name/i',
193 'dataPattern' => '/^[A-Za-z][0-9A-Za-z]{20,}$/',
194 'export' => true,
195 'html' => array(
196 'type' => 'Text',
197 ) ,
198 ) ,
199 'provider_id' => array(
200 'name' => 'provider_id',
201 'type' => CRM_Utils_Type::T_INT,
202 'title' => ts('IM Provider') ,
203 'description' => 'Which IM Provider does this screen name belong to.',
204 'html' => array(
205 'type' => 'Select',
206 ) ,
207 'pseudoconstant' => array(
208 'optionGroupName' => 'instant_messenger_service',
209 'optionEditPath' => 'civicrm/admin/options/instant_messenger_service',
210 )
211 ) ,
212 'is_primary' => array(
213 'name' => 'is_primary',
214 'type' => CRM_Utils_Type::T_BOOLEAN,
215 'title' => ts('Is IM Primary?') ,
216 'description' => 'Is this the primary IM for this contact and location.',
217 ) ,
218 'is_billing' => array(
219 'name' => 'is_billing',
220 'type' => CRM_Utils_Type::T_BOOLEAN,
221 'title' => ts('Is IM Billing?') ,
222 'description' => 'Is this the billing?',
223 ) ,
224 );
225 }
226 return self::$_fields;
227 }
228 /**
229 * Returns an array containing, for each field, the arary key used for that
230 * field in self::$_fields.
231 *
232 * @return array
233 */
234 static function &fieldKeys() {
235 if (!(self::$_fieldKeys)) {
236 self::$_fieldKeys = array(
237 'id' => 'id',
238 'contact_id' => 'contact_id',
239 'location_type_id' => 'location_type_id',
240 'name' => 'name',
241 'provider_id' => 'provider_id',
242 'is_primary' => 'is_primary',
243 'is_billing' => 'is_billing',
244 );
245 }
246 return self::$_fieldKeys;
247 }
248 /**
249 * Returns the names of this table
250 *
251 * @return string
252 */
253 static function getTableName() {
254 return self::$_tableName;
255 }
256 /**
257 * Returns if this table needs to be logged
258 *
259 * @return boolean
260 */
261 function getLog() {
262 return self::$_log;
263 }
264 /**
265 * Returns the list of fields that can be imported
266 *
267 * @param bool $prefix
268 *
269 * @return array
270 */
271 static function &import($prefix = false) {
272 if (!(self::$_import)) {
273 self::$_import = array();
274 $fields = self::fields();
275 foreach($fields as $name => $field) {
276 if (CRM_Utils_Array::value('import', $field)) {
277 if ($prefix) {
278 self::$_import['im'] = & $fields[$name];
279 } else {
280 self::$_import[$name] = & $fields[$name];
281 }
282 }
283 }
284 }
285 return self::$_import;
286 }
287 /**
288 * Returns the list of fields that can be exported
289 *
290 * @param bool $prefix
291 *
292 * @return array
293 */
294 static function &export($prefix = false) {
295 if (!(self::$_export)) {
296 self::$_export = array();
297 $fields = self::fields();
298 foreach($fields as $name => $field) {
299 if (CRM_Utils_Array::value('export', $field)) {
300 if ($prefix) {
301 self::$_export['im'] = & $fields[$name];
302 } else {
303 self::$_export[$name] = & $fields[$name];
304 }
305 }
306 }
307 }
308 return self::$_export;
309 }
310 }