Merge pull request #12056 from eileenmcnaughton/pcp
[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' => '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' => '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' => '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' => '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' => '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' => 'Is this the primary IM for this contact and location.',
193 'table_name' => 'civicrm_im',
194 'entity' => 'IM',
195 'bao' => 'CRM_Core_BAO_IM',
196 'localizable' => 0,
197 ],
198 'is_billing' => [
199 'name' => 'is_billing',
200 'type' => CRM_Utils_Type::T_BOOLEAN,
201 'title' => ts('Is IM Billing?'),
202 'description' => 'Is this the billing?',
203 'table_name' => 'civicrm_im',
204 'entity' => 'IM',
205 'bao' => 'CRM_Core_BAO_IM',
206 'localizable' => 0,
207 ],
208 ];
209 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
210 }
211 return Civi::$statics[__CLASS__]['fields'];
212 }
213
214 /**
215 * Return a mapping from field-name to the corresponding key (as used in fields()).
216 *
217 * @return array
218 * Array(string $name => string $uniqueName).
219 */
220 public static function &fieldKeys() {
221 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
222 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
223 }
224 return Civi::$statics[__CLASS__]['fieldKeys'];
225 }
226
227 /**
228 * Returns the names of this table
229 *
230 * @return string
231 */
232 public static function getTableName() {
233 return self::$_tableName;
234 }
235
236 /**
237 * Returns if this table needs to be logged
238 *
239 * @return bool
240 */
241 public function getLog() {
242 return self::$_log;
243 }
244
245 /**
246 * Returns the list of fields that can be imported
247 *
248 * @param bool $prefix
249 *
250 * @return array
251 */
252 public static function &import($prefix = FALSE) {
253 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'im', $prefix, []);
254 return $r;
255 }
256
257 /**
258 * Returns the list of fields that can be exported
259 *
260 * @param bool $prefix
261 *
262 * @return array
263 */
264 public static function &export($prefix = FALSE) {
265 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'im', $prefix, []);
266 return $r;
267 }
268
269 /**
270 * Returns the list of indices
271 *
272 * @param bool $localize
273 *
274 * @return array
275 */
276 public static function indices($localize = TRUE) {
277 $indices = [
278 'index_location_type' => [
279 'name' => 'index_location_type',
280 'field' => [
281 0 => 'location_type_id',
282 ],
283 'localizable' => FALSE,
284 'sig' => 'civicrm_im::0::location_type_id',
285 ],
286 'UI_provider_id' => [
287 'name' => 'UI_provider_id',
288 'field' => [
289 0 => 'provider_id',
290 ],
291 'localizable' => FALSE,
292 'sig' => 'civicrm_im::0::provider_id',
293 ],
294 'index_is_primary' => [
295 'name' => 'index_is_primary',
296 'field' => [
297 0 => 'is_primary',
298 ],
299 'localizable' => FALSE,
300 'sig' => 'civicrm_im::0::is_primary',
301 ],
302 'index_is_billing' => [
303 'name' => 'index_is_billing',
304 'field' => [
305 0 => 'is_billing',
306 ],
307 'localizable' => FALSE,
308 'sig' => 'civicrm_im::0::is_billing',
309 ],
310 ];
311 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
312 }
313
314 }