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