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