5 * @copyright CiviCRM LLC https://civicrm.org/licensing
7 * Generated from xml/schema/CRM/Core/IM.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:aa43f28e70d1de3571aa1775f71d7990)
13 * Database access object for the IM entity.
15 class CRM_Core_DAO_IM
extends CRM_Core_DAO
{
16 const EXT
= 'civicrm';
17 const TABLE_ADDED
= '1.1';
20 * Static instance to hold the table name.
24 public static $_tableName = 'civicrm_im';
27 * Icon associated with this entity.
31 public static $_icon = 'fa-comments-o';
34 * Field to show when displaying a record.
38 public static $_labelField = 'name';
41 * Should CiviCRM log any modifications to this table in the civicrm_log table.
45 public static $_log = TRUE;
50 * @var int|string|null
51 * (SQL type: int unsigned)
52 * Note that values will be retrieved from the database as a string.
59 * @var int|string|null
60 * (SQL type: int unsigned)
61 * Note that values will be retrieved from the database as a string.
66 * Which Location does this email belong to.
68 * @var int|string|null
69 * (SQL type: int unsigned)
70 * Note that values will be retrieved from the database as a string.
72 public $location_type_id;
78 * (SQL type: varchar(64))
79 * Note that values will be retrieved from the database as a string.
84 * Which IM Provider does this screen name belong to.
86 * @var int|string|null
87 * (SQL type: int unsigned)
88 * Note that values will be retrieved from the database as a string.
93 * Is this the primary IM for this contact and location.
97 * Note that values will be retrieved from the database as a string.
102 * Is this the billing?
105 * (SQL type: tinyint)
106 * Note that values will be retrieved from the database as a string.
113 public function __construct() {
114 $this->__table
= 'civicrm_im';
115 parent
::__construct();
119 * Returns localized title of this entity.
121 * @param bool $plural
122 * Whether to return the plural version of the title.
124 public static function getEntityTitle($plural = FALSE) {
125 return $plural ?
ts('Instant Messaging') : ts('Instant Messaging');
129 * Returns foreign keys and entity references.
132 * [CRM_Core_Reference_Interface]
134 public static function getReferenceColumns() {
135 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
136 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
137 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contact_id', 'civicrm_contact', 'id');
138 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
140 return Civi
::$statics[__CLASS__
]['links'];
144 * Returns all the column names of this table
148 public static function &fields() {
149 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
150 Civi
::$statics[__CLASS__
]['fields'] = [
153 'type' => CRM_Utils_Type
::T_INT
,
154 'title' => ts('Instant Messenger ID'),
155 'description' => ts('Unique IM ID'),
157 'where' => 'civicrm_im.id',
158 'table_name' => 'civicrm_im',
160 'bao' => 'CRM_Core_BAO_IM',
169 'name' => 'contact_id',
170 'type' => CRM_Utils_Type
::T_INT
,
171 'title' => ts('Contact ID'),
172 'description' => ts('FK to Contact ID'),
173 'where' => 'civicrm_im.contact_id',
174 'table_name' => 'civicrm_im',
176 'bao' => 'CRM_Core_BAO_IM',
178 'FKClassName' => 'CRM_Contact_DAO_Contact',
180 'label' => ts("Contact"),
184 'location_type_id' => [
185 'name' => 'location_type_id',
186 'type' => CRM_Utils_Type
::T_INT
,
187 'title' => ts('IM Location Type'),
188 'description' => ts('Which Location does this email belong to.'),
189 'where' => 'civicrm_im.location_type_id',
190 'table_name' => 'civicrm_im',
192 'bao' => 'CRM_Core_BAO_IM',
197 'pseudoconstant' => [
198 'table' => 'civicrm_location_type',
200 'labelColumn' => 'display_name',
206 'type' => CRM_Utils_Type
::T_STRING
,
207 'title' => ts('IM Screen Name'),
208 'description' => ts('IM screen name'),
210 'size' => CRM_Utils_Type
::BIG
,
212 'where' => 'civicrm_im.name',
213 'headerPattern' => '/I(nstant )?M(ess.*)?|screen(\s+)?name/i',
214 'dataPattern' => '/^[A-Za-z][0-9A-Za-z]{20,}$/',
216 'table_name' => 'civicrm_im',
218 'bao' => 'CRM_Core_BAO_IM',
226 'name' => 'provider_id',
227 'type' => CRM_Utils_Type
::T_INT
,
228 'title' => ts('IM Provider'),
229 'description' => ts('Which IM Provider does this screen name belong to.'),
230 'where' => 'civicrm_im.provider_id',
231 'table_name' => 'civicrm_im',
233 'bao' => 'CRM_Core_BAO_IM',
238 'pseudoconstant' => [
239 'optionGroupName' => 'instant_messenger_service',
240 'optionEditPath' => 'civicrm/admin/options/instant_messenger_service',
245 'name' => 'is_primary',
246 'type' => CRM_Utils_Type
::T_BOOLEAN
,
247 'title' => ts('Primary IM'),
248 'description' => ts('Is this the primary IM for this contact and location.'),
250 'where' => 'civicrm_im.is_primary',
252 'table_name' => 'civicrm_im',
254 'bao' => 'CRM_Core_BAO_IM',
262 'name' => 'is_billing',
263 'type' => CRM_Utils_Type
::T_BOOLEAN
,
264 'title' => ts('Is IM Billing?'),
265 'description' => ts('Is this the billing?'),
267 'where' => 'civicrm_im.is_billing',
269 'table_name' => 'civicrm_im',
271 'bao' => 'CRM_Core_BAO_IM',
276 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
278 return Civi
::$statics[__CLASS__
]['fields'];
282 * Return a mapping from field-name to the corresponding key (as used in fields()).
285 * Array(string $name => string $uniqueName).
287 public static function &fieldKeys() {
288 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
289 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
291 return Civi
::$statics[__CLASS__
]['fieldKeys'];
295 * Returns the names of this table
299 public static function getTableName() {
300 return self
::$_tableName;
304 * Returns if this table needs to be logged
308 public function getLog() {
313 * Returns the list of fields that can be imported
315 * @param bool $prefix
319 public static function &import($prefix = FALSE) {
320 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'im', $prefix, []);
325 * Returns the list of fields that can be exported
327 * @param bool $prefix
331 public static function &export($prefix = FALSE) {
332 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'im', $prefix, []);
337 * Returns the list of indices
339 * @param bool $localize
343 public static function indices($localize = TRUE) {
345 'index_location_type' => [
346 'name' => 'index_location_type',
348 0 => 'location_type_id',
350 'localizable' => FALSE,
351 'sig' => 'civicrm_im::0::location_type_id',
353 'UI_provider_id' => [
354 'name' => 'UI_provider_id',
358 'localizable' => FALSE,
359 'sig' => 'civicrm_im::0::provider_id',
361 'index_is_primary' => [
362 'name' => 'index_is_primary',
366 'localizable' => FALSE,
367 'sig' => 'civicrm_im::0::is_primary',
369 'index_is_billing' => [
370 'name' => 'index_is_billing',
374 'localizable' => FALSE,
375 'sig' => 'civicrm_im::0::is_billing',
378 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;