Merge pull request #10549 from jitendrapurohit/CRM-20761
[civicrm-core.git] / CRM / Core / DAO / IM.php
CommitLineData
e501603b
TO
1<?php
2/*
3+--------------------------------------------------------------------+
4| CiviCRM version 4.7 |
5+--------------------------------------------------------------------+
0f03f337 6| Copyright CiviCRM LLC (c) 2004-2017 |
e501603b
TO
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
0f03f337 29 * @copyright CiviCRM LLC (c) 2004-2017
e501603b
TO
30 *
31 * Generated from xml/schema/CRM/Core/IM.xml
32 * DO NOT EDIT. Generated by CRM_Core_CodeGen
e7a6b91a 33 * (GenCodeChecksum:fe754a68bdda23ca881ac6425750eeba)
e501603b
TO
34 */
35require_once 'CRM/Core/DAO.php';
36require_once 'CRM/Utils/Type.php';
f41f0342 37/**
38 * CRM_Core_DAO_IM constructor.
39 */
e501603b
TO
40class CRM_Core_DAO_IM extends CRM_Core_DAO {
41 /**
f41f0342 42 * Static instance to hold the table name.
e501603b
TO
43 *
44 * @var string
45 */
46 static $_tableName = 'civicrm_im';
e501603b 47 /**
f41f0342 48 * Should CiviCRM log any modifications to this table in the civicrm_log table.
e501603b
TO
49 *
50 * @var boolean
51 */
52 static $_log = true;
53 /**
54 * Unique IM ID
55 *
56 * @var int unsigned
57 */
58 public $id;
59 /**
60 * FK to Contact ID
61 *
62 * @var int unsigned
63 */
64 public $contact_id;
65 /**
66 * Which Location does this email belong to.
67 *
68 * @var int unsigned
69 */
70 public $location_type_id;
71 /**
72 * IM screen name
73 *
74 * @var string
75 */
76 public $name;
77 /**
78 * Which IM Provider does this screen name belong to.
79 *
80 * @var int unsigned
81 */
82 public $provider_id;
83 /**
84 * Is this the primary IM for this contact and location.
85 *
86 * @var boolean
87 */
88 public $is_primary;
89 /**
90 * Is this the billing?
91 *
92 * @var boolean
93 */
94 public $is_billing;
95 /**
f41f0342 96 * Class constructor.
e501603b
TO
97 */
98 function __construct() {
99 $this->__table = 'civicrm_im';
100 parent::__construct();
101 }
102 /**
f41f0342 103 * Returns foreign keys and entity references.
e501603b
TO
104 *
105 * @return array
106 * [CRM_Core_Reference_Interface]
107 */
108 static function getReferenceColumns() {
346aaaba
TO
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() , 'contact_id', 'civicrm_contact', 'id');
112 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
e501603b 113 }
346aaaba 114 return Civi::$statics[__CLASS__]['links'];
e501603b
TO
115 }
116 /**
117 * Returns all the column names of this table
118 *
119 * @return array
120 */
121 static function &fields() {
346aaaba
TO
122 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
123 Civi::$statics[__CLASS__]['fields'] = array(
e501603b
TO
124 'id' => array(
125 'name' => 'id',
126 'type' => CRM_Utils_Type::T_INT,
127 'title' => ts('Instant Messenger ID') ,
128 'description' => 'Unique IM ID',
129 'required' => true,
522a26c9 130 'table_name' => 'civicrm_im',
131 'entity' => 'IM',
132 'bao' => 'CRM_Core_BAO_IM',
6a7e5e5d 133 'localizable' => 0,
e501603b
TO
134 ) ,
135 'contact_id' => array(
136 'name' => 'contact_id',
137 'type' => CRM_Utils_Type::T_INT,
138 'title' => ts('IM Contact') ,
139 'description' => 'FK to Contact ID',
522a26c9 140 'table_name' => 'civicrm_im',
141 'entity' => 'IM',
142 'bao' => 'CRM_Core_BAO_IM',
6a7e5e5d 143 'localizable' => 0,
e501603b
TO
144 'FKClassName' => 'CRM_Contact_DAO_Contact',
145 ) ,
146 'location_type_id' => array(
147 'name' => 'location_type_id',
148 'type' => CRM_Utils_Type::T_INT,
149 'title' => ts('IM Location Type') ,
150 'description' => 'Which Location does this email belong to.',
522a26c9 151 'table_name' => 'civicrm_im',
152 'entity' => 'IM',
153 'bao' => 'CRM_Core_BAO_IM',
6a7e5e5d 154 'localizable' => 0,
e501603b
TO
155 'html' => array(
156 'type' => 'Select',
157 ) ,
158 'pseudoconstant' => array(
159 'table' => 'civicrm_location_type',
160 'keyColumn' => 'id',
161 'labelColumn' => 'display_name',
162 )
163 ) ,
164 'name' => array(
165 'name' => 'name',
166 'type' => CRM_Utils_Type::T_STRING,
167 'title' => ts('IM Screen Name') ,
168 'description' => 'IM screen name',
169 'maxlength' => 64,
170 'size' => CRM_Utils_Type::BIG,
171 'import' => true,
172 'where' => 'civicrm_im.name',
173 'headerPattern' => '/I(nstant )?M(ess.*)?|screen(\s+)?name/i',
174 'dataPattern' => '/^[A-Za-z][0-9A-Za-z]{20,}$/',
175 'export' => true,
522a26c9 176 'table_name' => 'civicrm_im',
177 'entity' => 'IM',
178 'bao' => 'CRM_Core_BAO_IM',
6a7e5e5d 179 'localizable' => 0,
e501603b
TO
180 'html' => array(
181 'type' => 'Text',
182 ) ,
183 ) ,
184 'provider_id' => array(
185 'name' => 'provider_id',
186 'type' => CRM_Utils_Type::T_INT,
187 'title' => ts('IM Provider') ,
188 'description' => 'Which IM Provider does this screen name belong to.',
522a26c9 189 'table_name' => 'civicrm_im',
190 'entity' => 'IM',
191 'bao' => 'CRM_Core_BAO_IM',
6a7e5e5d 192 'localizable' => 0,
e501603b
TO
193 'html' => array(
194 'type' => 'Select',
195 ) ,
196 'pseudoconstant' => array(
197 'optionGroupName' => 'instant_messenger_service',
198 'optionEditPath' => 'civicrm/admin/options/instant_messenger_service',
199 )
200 ) ,
201 'is_primary' => array(
202 'name' => 'is_primary',
203 'type' => CRM_Utils_Type::T_BOOLEAN,
204 'title' => ts('Is IM Primary?') ,
205 'description' => 'Is this the primary IM for this contact and location.',
522a26c9 206 'table_name' => 'civicrm_im',
207 'entity' => 'IM',
208 'bao' => 'CRM_Core_BAO_IM',
6a7e5e5d 209 'localizable' => 0,
e501603b
TO
210 ) ,
211 'is_billing' => array(
212 'name' => 'is_billing',
213 'type' => CRM_Utils_Type::T_BOOLEAN,
214 'title' => ts('Is IM Billing?') ,
215 'description' => 'Is this the billing?',
522a26c9 216 'table_name' => 'civicrm_im',
217 'entity' => 'IM',
218 'bao' => 'CRM_Core_BAO_IM',
6a7e5e5d 219 'localizable' => 0,
e501603b
TO
220 ) ,
221 );
346aaaba 222 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 223 }
346aaaba 224 return Civi::$statics[__CLASS__]['fields'];
e501603b
TO
225 }
226 /**
bd8e0b14 227 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
228 *
229 * @return array
bd8e0b14 230 * Array(string $name => string $uniqueName).
e501603b
TO
231 */
232 static function &fieldKeys() {
bd8e0b14
TO
233 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
234 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 235 }
bd8e0b14 236 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b
TO
237 }
238 /**
239 * Returns the names of this table
240 *
241 * @return string
242 */
243 static function getTableName() {
244 return self::$_tableName;
245 }
246 /**
247 * Returns if this table needs to be logged
248 *
249 * @return boolean
250 */
251 function getLog() {
252 return self::$_log;
253 }
254 /**
255 * Returns the list of fields that can be imported
256 *
257 * @param bool $prefix
258 *
259 * @return array
260 */
261 static function &import($prefix = false) {
60808919
TO
262 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'im', $prefix, array());
263 return $r;
e501603b
TO
264 }
265 /**
266 * Returns the list of fields that can be exported
267 *
268 * @param bool $prefix
269 *
270 * @return array
271 */
272 static function &export($prefix = false) {
60808919
TO
273 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'im', $prefix, array());
274 return $r;
e501603b 275 }
e7a6b91a
AS
276 /**
277 * Returns the list of indices
278 */
279 public static function indices($localize = TRUE) {
280 $indices = array(
281 'index_location_type' => array(
282 'name' => 'index_location_type',
283 'field' => array(
284 0 => 'location_type_id',
285 ) ,
286 'localizable' => false,
287 'sig' => 'civicrm_im::0::location_type_id',
288 ) ,
289 'UI_provider_id' => array(
290 'name' => 'UI_provider_id',
291 'field' => array(
292 0 => 'provider_id',
293 ) ,
294 'localizable' => false,
295 'sig' => 'civicrm_im::0::provider_id',
296 ) ,
297 'index_is_primary' => array(
298 'name' => 'index_is_primary',
299 'field' => array(
300 0 => 'is_primary',
301 ) ,
302 'localizable' => false,
303 'sig' => 'civicrm_im::0::is_primary',
304 ) ,
305 'index_is_billing' => array(
306 'name' => 'index_is_billing',
307 'field' => array(
308 0 => 'is_billing',
309 ) ,
310 'localizable' => false,
311 'sig' => 'civicrm_im::0::is_billing',
312 ) ,
313 );
314 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
315 }
e501603b 316}