Merge pull request #9680 from h-c-c/CRM-19881
[civicrm-core.git] / CRM / Core / DAO / IM.php
CommitLineData
e501603b
TO
1<?php
2/*
3+--------------------------------------------------------------------+
4| CiviCRM version 4.7 |
5+--------------------------------------------------------------------+
0f03f337 6| Copyright CiviCRM LLC (c) 2004-2017 |
e501603b
TO
7+--------------------------------------------------------------------+
8| This file is a part of CiviCRM. |
9| |
10| CiviCRM is free software; you can copy, modify, and distribute it |
11| under the terms of the GNU Affero General Public License |
12| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
13| |
14| CiviCRM is distributed in the hope that it will be useful, but |
15| WITHOUT ANY WARRANTY; without even the implied warranty of |
16| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17| See the GNU Affero General Public License for more details. |
18| |
19| You should have received a copy of the GNU Affero General Public |
20| License and the CiviCRM Licensing Exception along |
21| with this program; if not, contact CiviCRM LLC |
22| at info[AT]civicrm[DOT]org. If you have questions about the |
23| GNU Affero General Public License or the licensing of CiviCRM, |
24| see the CiviCRM license FAQ at http://civicrm.org/licensing |
25+--------------------------------------------------------------------+
26*/
27/**
28 * @package CRM
0f03f337 29 * @copyright CiviCRM LLC (c) 2004-2017
e501603b
TO
30 *
31 * Generated from xml/schema/CRM/Core/IM.xml
32 * DO NOT EDIT. Generated by CRM_Core_CodeGen
522a26c9 33 * (GenCodeChecksum:53a1953d19c17bde7f130123db0284fb)
e501603b
TO
34 */
35require_once 'CRM/Core/DAO.php';
36require_once 'CRM/Utils/Type.php';
f41f0342 37/**
38 * CRM_Core_DAO_IM constructor.
39 */
e501603b
TO
40class CRM_Core_DAO_IM extends CRM_Core_DAO {
41 /**
f41f0342 42 * Static instance to hold the table name.
e501603b
TO
43 *
44 * @var string
45 */
46 static $_tableName = 'civicrm_im';
e501603b 47 /**
f41f0342 48 * Should CiviCRM log any modifications to this table in the civicrm_log table.
e501603b
TO
49 *
50 * @var boolean
51 */
52 static $_log = true;
53 /**
54 * Unique IM ID
55 *
56 * @var int unsigned
57 */
58 public $id;
59 /**
60 * FK to Contact ID
61 *
62 * @var int unsigned
63 */
64 public $contact_id;
65 /**
66 * Which Location does this email belong to.
67 *
68 * @var int unsigned
69 */
70 public $location_type_id;
71 /**
72 * IM screen name
73 *
74 * @var string
75 */
76 public $name;
77 /**
78 * Which IM Provider does this screen name belong to.
79 *
80 * @var int unsigned
81 */
82 public $provider_id;
83 /**
84 * Is this the primary IM for this contact and location.
85 *
86 * @var boolean
87 */
88 public $is_primary;
89 /**
90 * Is this the billing?
91 *
92 * @var boolean
93 */
94 public $is_billing;
95 /**
f41f0342 96 * Class constructor.
e501603b
TO
97 */
98 function __construct() {
99 $this->__table = 'civicrm_im';
100 parent::__construct();
101 }
102 /**
f41f0342 103 * Returns foreign keys and entity references.
e501603b
TO
104 *
105 * @return array
106 * [CRM_Core_Reference_Interface]
107 */
108 static function getReferenceColumns() {
346aaaba
TO
109 if (!isset(Civi::$statics[__CLASS__]['links'])) {
110 Civi::$statics[__CLASS__]['links'] = static ::createReferenceColumns(__CLASS__);
111 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName() , 'contact_id', 'civicrm_contact', 'id');
112 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
e501603b 113 }
346aaaba 114 return Civi::$statics[__CLASS__]['links'];
e501603b
TO
115 }
116 /**
117 * Returns all the column names of this table
118 *
119 * @return array
120 */
121 static function &fields() {
346aaaba
TO
122 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
123 Civi::$statics[__CLASS__]['fields'] = array(
e501603b
TO
124 'id' => array(
125 'name' => 'id',
126 'type' => CRM_Utils_Type::T_INT,
127 'title' => ts('Instant Messenger ID') ,
128 'description' => 'Unique IM ID',
129 'required' => true,
522a26c9 130 'table_name' => 'civicrm_im',
131 'entity' => 'IM',
132 'bao' => 'CRM_Core_BAO_IM',
e501603b
TO
133 ) ,
134 'contact_id' => array(
135 'name' => 'contact_id',
136 'type' => CRM_Utils_Type::T_INT,
137 'title' => ts('IM Contact') ,
138 'description' => 'FK to Contact ID',
522a26c9 139 'table_name' => 'civicrm_im',
140 'entity' => 'IM',
141 'bao' => 'CRM_Core_BAO_IM',
e501603b
TO
142 'FKClassName' => 'CRM_Contact_DAO_Contact',
143 ) ,
144 'location_type_id' => array(
145 'name' => 'location_type_id',
146 'type' => CRM_Utils_Type::T_INT,
147 'title' => ts('IM Location Type') ,
148 'description' => 'Which Location does this email belong to.',
522a26c9 149 'table_name' => 'civicrm_im',
150 'entity' => 'IM',
151 'bao' => 'CRM_Core_BAO_IM',
e501603b
TO
152 'html' => array(
153 'type' => 'Select',
154 ) ,
155 'pseudoconstant' => array(
156 'table' => 'civicrm_location_type',
157 'keyColumn' => 'id',
158 'labelColumn' => 'display_name',
159 )
160 ) ,
161 'name' => array(
162 'name' => 'name',
163 'type' => CRM_Utils_Type::T_STRING,
164 'title' => ts('IM Screen Name') ,
165 'description' => 'IM screen name',
166 'maxlength' => 64,
167 'size' => CRM_Utils_Type::BIG,
168 'import' => true,
169 'where' => 'civicrm_im.name',
170 'headerPattern' => '/I(nstant )?M(ess.*)?|screen(\s+)?name/i',
171 'dataPattern' => '/^[A-Za-z][0-9A-Za-z]{20,}$/',
172 'export' => true,
522a26c9 173 'table_name' => 'civicrm_im',
174 'entity' => 'IM',
175 'bao' => 'CRM_Core_BAO_IM',
e501603b
TO
176 'html' => array(
177 'type' => 'Text',
178 ) ,
179 ) ,
180 'provider_id' => array(
181 'name' => 'provider_id',
182 'type' => CRM_Utils_Type::T_INT,
183 'title' => ts('IM Provider') ,
184 'description' => 'Which IM Provider does this screen name belong to.',
522a26c9 185 'table_name' => 'civicrm_im',
186 'entity' => 'IM',
187 'bao' => 'CRM_Core_BAO_IM',
e501603b
TO
188 'html' => array(
189 'type' => 'Select',
190 ) ,
191 'pseudoconstant' => array(
192 'optionGroupName' => 'instant_messenger_service',
193 'optionEditPath' => 'civicrm/admin/options/instant_messenger_service',
194 )
195 ) ,
196 'is_primary' => array(
197 'name' => 'is_primary',
198 'type' => CRM_Utils_Type::T_BOOLEAN,
199 'title' => ts('Is IM Primary?') ,
200 'description' => 'Is this the primary IM for this contact and location.',
522a26c9 201 'table_name' => 'civicrm_im',
202 'entity' => 'IM',
203 'bao' => 'CRM_Core_BAO_IM',
e501603b
TO
204 ) ,
205 'is_billing' => array(
206 'name' => 'is_billing',
207 'type' => CRM_Utils_Type::T_BOOLEAN,
208 'title' => ts('Is IM Billing?') ,
209 'description' => 'Is this the billing?',
522a26c9 210 'table_name' => 'civicrm_im',
211 'entity' => 'IM',
212 'bao' => 'CRM_Core_BAO_IM',
e501603b
TO
213 ) ,
214 );
346aaaba 215 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 216 }
346aaaba 217 return Civi::$statics[__CLASS__]['fields'];
e501603b
TO
218 }
219 /**
bd8e0b14 220 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
221 *
222 * @return array
bd8e0b14 223 * Array(string $name => string $uniqueName).
e501603b
TO
224 */
225 static function &fieldKeys() {
bd8e0b14
TO
226 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
227 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 228 }
bd8e0b14 229 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b
TO
230 }
231 /**
232 * Returns the names of this table
233 *
234 * @return string
235 */
236 static function getTableName() {
237 return self::$_tableName;
238 }
239 /**
240 * Returns if this table needs to be logged
241 *
242 * @return boolean
243 */
244 function getLog() {
245 return self::$_log;
246 }
247 /**
248 * Returns the list of fields that can be imported
249 *
250 * @param bool $prefix
251 *
252 * @return array
253 */
254 static function &import($prefix = false) {
60808919
TO
255 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'im', $prefix, array());
256 return $r;
e501603b
TO
257 }
258 /**
259 * Returns the list of fields that can be exported
260 *
261 * @param bool $prefix
262 *
263 * @return array
264 */
265 static function &export($prefix = false) {
60808919
TO
266 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'im', $prefix, array());
267 return $r;
e501603b
TO
268 }
269}