Merge pull request #8944 from totten/master-givi
[civicrm-core.git] / CRM / Core / DAO / IM.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2016 |
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
29 * @copyright CiviCRM LLC (c) 2004-2016
30 *
31 * Generated from xml/schema/CRM/Core/IM.xml
32 * DO NOT EDIT. Generated by CRM_Core_CodeGen
33 * (GenCodeChecksum:f8e6b92d253482e7ad6cfd663e583d66)
34 */
35 require_once 'CRM/Core/DAO.php';
36 require_once 'CRM/Utils/Type.php';
37 class CRM_Core_DAO_IM extends CRM_Core_DAO {
38 /**
39 * static instance to hold the table name
40 *
41 * @var string
42 */
43 static $_tableName = 'civicrm_im';
44 /**
45 * static value to see if we should log any modifications to
46 * this table in the civicrm_log table
47 *
48 * @var boolean
49 */
50 static $_log = true;
51 /**
52 * Unique IM ID
53 *
54 * @var int unsigned
55 */
56 public $id;
57 /**
58 * FK to Contact ID
59 *
60 * @var int unsigned
61 */
62 public $contact_id;
63 /**
64 * Which Location does this email belong to.
65 *
66 * @var int unsigned
67 */
68 public $location_type_id;
69 /**
70 * IM screen name
71 *
72 * @var string
73 */
74 public $name;
75 /**
76 * Which IM Provider does this screen name belong to.
77 *
78 * @var int unsigned
79 */
80 public $provider_id;
81 /**
82 * Is this the primary IM for this contact and location.
83 *
84 * @var boolean
85 */
86 public $is_primary;
87 /**
88 * Is this the billing?
89 *
90 * @var boolean
91 */
92 public $is_billing;
93 /**
94 * class constructor
95 *
96 * @return civicrm_im
97 */
98 function __construct() {
99 $this->__table = 'civicrm_im';
100 parent::__construct();
101 }
102 /**
103 * Returns foreign keys and entity references
104 *
105 * @return array
106 * [CRM_Core_Reference_Interface]
107 */
108 static function getReferenceColumns() {
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']);
113 }
114 return Civi::$statics[__CLASS__]['links'];
115 }
116 /**
117 * Returns all the column names of this table
118 *
119 * @return array
120 */
121 static function &fields() {
122 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
123 Civi::$statics[__CLASS__]['fields'] = array(
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,
130 ) ,
131 'contact_id' => array(
132 'name' => 'contact_id',
133 'type' => CRM_Utils_Type::T_INT,
134 'title' => ts('IM Contact') ,
135 'description' => 'FK to Contact ID',
136 'FKClassName' => 'CRM_Contact_DAO_Contact',
137 ) ,
138 'location_type_id' => array(
139 'name' => 'location_type_id',
140 'type' => CRM_Utils_Type::T_INT,
141 'title' => ts('IM Location Type') ,
142 'description' => 'Which Location does this email belong to.',
143 'html' => array(
144 'type' => 'Select',
145 ) ,
146 'pseudoconstant' => array(
147 'table' => 'civicrm_location_type',
148 'keyColumn' => 'id',
149 'labelColumn' => 'display_name',
150 )
151 ) ,
152 'name' => array(
153 'name' => 'name',
154 'type' => CRM_Utils_Type::T_STRING,
155 'title' => ts('IM Screen Name') ,
156 'description' => 'IM screen name',
157 'maxlength' => 64,
158 'size' => CRM_Utils_Type::BIG,
159 'import' => true,
160 'where' => 'civicrm_im.name',
161 'headerPattern' => '/I(nstant )?M(ess.*)?|screen(\s+)?name/i',
162 'dataPattern' => '/^[A-Za-z][0-9A-Za-z]{20,}$/',
163 'export' => true,
164 'html' => array(
165 'type' => 'Text',
166 ) ,
167 ) ,
168 'provider_id' => array(
169 'name' => 'provider_id',
170 'type' => CRM_Utils_Type::T_INT,
171 'title' => ts('IM Provider') ,
172 'description' => 'Which IM Provider does this screen name belong to.',
173 'html' => array(
174 'type' => 'Select',
175 ) ,
176 'pseudoconstant' => array(
177 'optionGroupName' => 'instant_messenger_service',
178 'optionEditPath' => 'civicrm/admin/options/instant_messenger_service',
179 )
180 ) ,
181 'is_primary' => array(
182 'name' => 'is_primary',
183 'type' => CRM_Utils_Type::T_BOOLEAN,
184 'title' => ts('Is IM Primary?') ,
185 'description' => 'Is this the primary IM for this contact and location.',
186 ) ,
187 'is_billing' => array(
188 'name' => 'is_billing',
189 'type' => CRM_Utils_Type::T_BOOLEAN,
190 'title' => ts('Is IM Billing?') ,
191 'description' => 'Is this the billing?',
192 ) ,
193 );
194 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
195 }
196 return Civi::$statics[__CLASS__]['fields'];
197 }
198 /**
199 * Return a mapping from field-name to the corresponding key (as used in fields()).
200 *
201 * @return array
202 * Array(string $name => string $uniqueName).
203 */
204 static function &fieldKeys() {
205 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
206 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
207 }
208 return Civi::$statics[__CLASS__]['fieldKeys'];
209 }
210 /**
211 * Returns the names of this table
212 *
213 * @return string
214 */
215 static function getTableName() {
216 return self::$_tableName;
217 }
218 /**
219 * Returns if this table needs to be logged
220 *
221 * @return boolean
222 */
223 function getLog() {
224 return self::$_log;
225 }
226 /**
227 * Returns the list of fields that can be imported
228 *
229 * @param bool $prefix
230 *
231 * @return array
232 */
233 static function &import($prefix = false) {
234 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'im', $prefix, array());
235 return $r;
236 }
237 /**
238 * Returns the list of fields that can be exported
239 *
240 * @param bool $prefix
241 *
242 * @return array
243 */
244 static function &export($prefix = false) {
245 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'im', $prefix, array());
246 return $r;
247 }
248 }