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