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:d44807afb48eb3aa89bdae6db574f89e)
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 * Should CiviCRM log any modifications to this table in the civicrm_log table.
38 public static $_log = TRUE;
55 * Which Location does this email belong to.
59 public $location_type_id;
69 * Which IM Provider does this screen name belong to.
76 * Is this the primary IM for this contact and location.
83 * Is this the billing?
92 public function __construct() {
93 $this->__table
= 'civicrm_im';
94 parent
::__construct();
98 * Returns localized title of this entity.
100 * @param bool $plural
101 * Whether to return the plural version of the title.
103 public static function getEntityTitle($plural = FALSE) {
104 return $plural ?
ts('Instant Messaging') : ts('Instant Messaging');
108 * Returns foreign keys and entity references.
111 * [CRM_Core_Reference_Interface]
113 public static function getReferenceColumns() {
114 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
115 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
116 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contact_id', 'civicrm_contact', 'id');
117 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
119 return Civi
::$statics[__CLASS__
]['links'];
123 * Returns all the column names of this table
127 public static function &fields() {
128 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
129 Civi
::$statics[__CLASS__
]['fields'] = [
132 'type' => CRM_Utils_Type
::T_INT
,
133 'title' => ts('Instant Messenger ID'),
134 'description' => ts('Unique IM ID'),
136 'where' => 'civicrm_im.id',
137 'table_name' => 'civicrm_im',
139 'bao' => 'CRM_Core_BAO_IM',
144 'name' => 'contact_id',
145 'type' => CRM_Utils_Type
::T_INT
,
146 'title' => ts('IM Contact'),
147 'description' => ts('FK to Contact ID'),
148 'where' => 'civicrm_im.contact_id',
149 'table_name' => 'civicrm_im',
151 'bao' => 'CRM_Core_BAO_IM',
153 'FKClassName' => 'CRM_Contact_DAO_Contact',
156 'location_type_id' => [
157 'name' => 'location_type_id',
158 'type' => CRM_Utils_Type
::T_INT
,
159 'title' => ts('IM Location Type'),
160 'description' => ts('Which Location does this email belong to.'),
161 'where' => 'civicrm_im.location_type_id',
162 'table_name' => 'civicrm_im',
164 'bao' => 'CRM_Core_BAO_IM',
169 'pseudoconstant' => [
170 'table' => 'civicrm_location_type',
172 'labelColumn' => 'display_name',
178 'type' => CRM_Utils_Type
::T_STRING
,
179 'title' => ts('IM Screen Name'),
180 'description' => ts('IM screen name'),
182 'size' => CRM_Utils_Type
::BIG
,
184 'where' => 'civicrm_im.name',
185 'headerPattern' => '/I(nstant )?M(ess.*)?|screen(\s+)?name/i',
186 'dataPattern' => '/^[A-Za-z][0-9A-Za-z]{20,}$/',
188 'table_name' => 'civicrm_im',
190 'bao' => 'CRM_Core_BAO_IM',
198 'name' => 'provider_id',
199 'type' => CRM_Utils_Type
::T_INT
,
200 'title' => ts('IM Provider'),
201 'description' => ts('Which IM Provider does this screen name belong to.'),
202 'where' => 'civicrm_im.provider_id',
203 'table_name' => 'civicrm_im',
205 'bao' => 'CRM_Core_BAO_IM',
210 'pseudoconstant' => [
211 'optionGroupName' => 'instant_messenger_service',
212 'optionEditPath' => 'civicrm/admin/options/instant_messenger_service',
217 'name' => 'is_primary',
218 'type' => CRM_Utils_Type
::T_BOOLEAN
,
219 'title' => ts('Primary IM'),
220 'description' => ts('Is this the primary IM for this contact and location.'),
221 'where' => 'civicrm_im.is_primary',
223 'table_name' => 'civicrm_im',
225 'bao' => 'CRM_Core_BAO_IM',
233 'name' => 'is_billing',
234 'type' => CRM_Utils_Type
::T_BOOLEAN
,
235 'title' => ts('Is IM Billing?'),
236 'description' => ts('Is this the billing?'),
237 'where' => 'civicrm_im.is_billing',
239 'table_name' => 'civicrm_im',
241 'bao' => 'CRM_Core_BAO_IM',
246 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
248 return Civi
::$statics[__CLASS__
]['fields'];
252 * Return a mapping from field-name to the corresponding key (as used in fields()).
255 * Array(string $name => string $uniqueName).
257 public static function &fieldKeys() {
258 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
259 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
261 return Civi
::$statics[__CLASS__
]['fieldKeys'];
265 * Returns the names of this table
269 public static function getTableName() {
270 return self
::$_tableName;
274 * Returns if this table needs to be logged
278 public function getLog() {
283 * Returns the list of fields that can be imported
285 * @param bool $prefix
289 public static function &import($prefix = FALSE) {
290 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'im', $prefix, []);
295 * Returns the list of fields that can be exported
297 * @param bool $prefix
301 public static function &export($prefix = FALSE) {
302 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'im', $prefix, []);
307 * Returns the list of indices
309 * @param bool $localize
313 public static function indices($localize = TRUE) {
315 'index_location_type' => [
316 'name' => 'index_location_type',
318 0 => 'location_type_id',
320 'localizable' => FALSE,
321 'sig' => 'civicrm_im::0::location_type_id',
323 'UI_provider_id' => [
324 'name' => 'UI_provider_id',
328 'localizable' => FALSE,
329 'sig' => 'civicrm_im::0::provider_id',
331 'index_is_primary' => [
332 'name' => 'index_is_primary',
336 'localizable' => FALSE,
337 'sig' => 'civicrm_im::0::is_primary',
339 'index_is_billing' => [
340 'name' => 'index_is_billing',
344 'localizable' => FALSE,
345 'sig' => 'civicrm_im::0::is_billing',
348 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;