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:179c338e66288123b7ca45c78ad57fcc)
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;
62 * Which Location does this email belong to.
66 public $location_type_id;
76 * Which IM Provider does this screen name belong to.
83 * Is this the primary IM for this contact and location.
90 * Is this the billing?
99 public function __construct() {
100 $this->__table
= 'civicrm_im';
101 parent
::__construct();
105 * Returns localized title of this entity.
107 * @param bool $plural
108 * Whether to return the plural version of the title.
110 public static function getEntityTitle($plural = FALSE) {
111 return $plural ?
ts('Instant Messaging') : ts('Instant Messaging');
115 * Returns foreign keys and entity references.
118 * [CRM_Core_Reference_Interface]
120 public static function getReferenceColumns() {
121 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
122 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
123 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contact_id', 'civicrm_contact', 'id');
124 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
126 return Civi
::$statics[__CLASS__
]['links'];
130 * Returns all the column names of this table
134 public static function &fields() {
135 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
136 Civi
::$statics[__CLASS__
]['fields'] = [
139 'type' => CRM_Utils_Type
::T_INT
,
140 'title' => ts('Instant Messenger ID'),
141 'description' => ts('Unique IM ID'),
143 'where' => 'civicrm_im.id',
144 'table_name' => 'civicrm_im',
146 'bao' => 'CRM_Core_BAO_IM',
155 'name' => 'contact_id',
156 'type' => CRM_Utils_Type
::T_INT
,
157 'title' => ts('Contact ID'),
158 'description' => ts('FK to Contact ID'),
159 'where' => 'civicrm_im.contact_id',
160 'table_name' => 'civicrm_im',
162 'bao' => 'CRM_Core_BAO_IM',
164 'FKClassName' => 'CRM_Contact_DAO_Contact',
166 'label' => ts("Contact"),
170 'location_type_id' => [
171 'name' => 'location_type_id',
172 'type' => CRM_Utils_Type
::T_INT
,
173 'title' => ts('IM Location Type'),
174 'description' => ts('Which Location does this email belong to.'),
175 'where' => 'civicrm_im.location_type_id',
176 'table_name' => 'civicrm_im',
178 'bao' => 'CRM_Core_BAO_IM',
183 'pseudoconstant' => [
184 'table' => 'civicrm_location_type',
186 'labelColumn' => 'display_name',
192 'type' => CRM_Utils_Type
::T_STRING
,
193 'title' => ts('IM Screen Name'),
194 'description' => ts('IM screen name'),
196 'size' => CRM_Utils_Type
::BIG
,
198 'where' => 'civicrm_im.name',
199 'headerPattern' => '/I(nstant )?M(ess.*)?|screen(\s+)?name/i',
200 'dataPattern' => '/^[A-Za-z][0-9A-Za-z]{20,}$/',
202 'table_name' => 'civicrm_im',
204 'bao' => 'CRM_Core_BAO_IM',
212 'name' => 'provider_id',
213 'type' => CRM_Utils_Type
::T_INT
,
214 'title' => ts('IM Provider'),
215 'description' => ts('Which IM Provider does this screen name belong to.'),
216 'where' => 'civicrm_im.provider_id',
217 'table_name' => 'civicrm_im',
219 'bao' => 'CRM_Core_BAO_IM',
224 'pseudoconstant' => [
225 'optionGroupName' => 'instant_messenger_service',
226 'optionEditPath' => 'civicrm/admin/options/instant_messenger_service',
231 'name' => 'is_primary',
232 'type' => CRM_Utils_Type
::T_BOOLEAN
,
233 'title' => ts('Primary IM'),
234 'description' => ts('Is this the primary IM for this contact and location.'),
235 'where' => 'civicrm_im.is_primary',
237 'table_name' => 'civicrm_im',
239 'bao' => 'CRM_Core_BAO_IM',
247 'name' => 'is_billing',
248 'type' => CRM_Utils_Type
::T_BOOLEAN
,
249 'title' => ts('Is IM Billing?'),
250 'description' => ts('Is this the billing?'),
251 'where' => 'civicrm_im.is_billing',
253 'table_name' => 'civicrm_im',
255 'bao' => 'CRM_Core_BAO_IM',
260 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
262 return Civi
::$statics[__CLASS__
]['fields'];
266 * Return a mapping from field-name to the corresponding key (as used in fields()).
269 * Array(string $name => string $uniqueName).
271 public static function &fieldKeys() {
272 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
273 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
275 return Civi
::$statics[__CLASS__
]['fieldKeys'];
279 * Returns the names of this table
283 public static function getTableName() {
284 return self
::$_tableName;
288 * Returns if this table needs to be logged
292 public function getLog() {
297 * Returns the list of fields that can be imported
299 * @param bool $prefix
303 public static function &import($prefix = FALSE) {
304 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'im', $prefix, []);
309 * Returns the list of fields that can be exported
311 * @param bool $prefix
315 public static function &export($prefix = FALSE) {
316 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'im', $prefix, []);
321 * Returns the list of indices
323 * @param bool $localize
327 public static function indices($localize = TRUE) {
329 'index_location_type' => [
330 'name' => 'index_location_type',
332 0 => 'location_type_id',
334 'localizable' => FALSE,
335 'sig' => 'civicrm_im::0::location_type_id',
337 'UI_provider_id' => [
338 'name' => 'UI_provider_id',
342 'localizable' => FALSE,
343 'sig' => 'civicrm_im::0::provider_id',
345 'index_is_primary' => [
346 'name' => 'index_is_primary',
350 'localizable' => FALSE,
351 'sig' => 'civicrm_im::0::is_primary',
353 'index_is_billing' => [
354 'name' => 'index_is_billing',
358 'localizable' => FALSE,
359 'sig' => 'civicrm_im::0::is_billing',
362 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;