Regenerate DAOs with readonly attribute for id fields
[civicrm-core.git] / CRM / Contact / DAO / SubscriptionHistory.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Contact/SubscriptionHistory.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:1be13f7e21dd920626bc68f889907b68)
10 */
11
12 /**
13 * Database access object for the SubscriptionHistory entity.
14 */
15 class CRM_Contact_DAO_SubscriptionHistory extends CRM_Core_DAO {
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '1.1';
18
19 /**
20 * Static instance to hold the table name.
21 *
22 * @var string
23 */
24 public static $_tableName = 'civicrm_subscription_history';
25
26 /**
27 * Should CiviCRM log any modifications to this table in the civicrm_log table.
28 *
29 * @var bool
30 */
31 public static $_log = TRUE;
32
33 /**
34 * Internal ID
35 *
36 * @var int
37 */
38 public $id;
39
40 /**
41 * Contact ID
42 *
43 * @var int
44 */
45 public $contact_id;
46
47 /**
48 * Group ID
49 *
50 * @var int
51 */
52 public $group_id;
53
54 /**
55 * Date of the (un)subscription
56 *
57 * @var timestamp
58 */
59 public $date;
60
61 /**
62 * How the (un)subscription was triggered
63 *
64 * @var string
65 */
66 public $method;
67
68 /**
69 * The state of the contact within the group
70 *
71 * @var string
72 */
73 public $status;
74
75 /**
76 * IP address or other tracking info
77 *
78 * @var string
79 */
80 public $tracking;
81
82 /**
83 * Class constructor.
84 */
85 public function __construct() {
86 $this->__table = 'civicrm_subscription_history';
87 parent::__construct();
88 }
89
90 /**
91 * Returns localized title of this entity.
92 *
93 * @param bool $plural
94 * Whether to return the plural version of the title.
95 */
96 public static function getEntityTitle($plural = FALSE) {
97 return $plural ? ts('Subscription Histories') : ts('Subscription History');
98 }
99
100 /**
101 * Returns foreign keys and entity references.
102 *
103 * @return array
104 * [CRM_Core_Reference_Interface]
105 */
106 public static function getReferenceColumns() {
107 if (!isset(Civi::$statics[__CLASS__]['links'])) {
108 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
109 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id');
110 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'group_id', 'civicrm_group', 'id');
111 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
112 }
113 return Civi::$statics[__CLASS__]['links'];
114 }
115
116 /**
117 * Returns all the column names of this table
118 *
119 * @return array
120 */
121 public static function &fields() {
122 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
123 Civi::$statics[__CLASS__]['fields'] = [
124 'id' => [
125 'name' => 'id',
126 'type' => CRM_Utils_Type::T_INT,
127 'title' => ts('Group Membership History ID'),
128 'description' => ts('Internal ID'),
129 'required' => TRUE,
130 'where' => 'civicrm_subscription_history.id',
131 'table_name' => 'civicrm_subscription_history',
132 'entity' => 'SubscriptionHistory',
133 'bao' => 'CRM_Contact_BAO_SubscriptionHistory',
134 'localizable' => 0,
135 'html' => [
136 'type' => 'Number',
137 ],
138 'readonly' => TRUE,
139 'add' => '1.1',
140 ],
141 'contact_id' => [
142 'name' => 'contact_id',
143 'type' => CRM_Utils_Type::T_INT,
144 'title' => ts('Contact ID'),
145 'description' => ts('Contact ID'),
146 'required' => TRUE,
147 'where' => 'civicrm_subscription_history.contact_id',
148 'table_name' => 'civicrm_subscription_history',
149 'entity' => 'SubscriptionHistory',
150 'bao' => 'CRM_Contact_BAO_SubscriptionHistory',
151 'localizable' => 0,
152 'FKClassName' => 'CRM_Contact_DAO_Contact',
153 'html' => [
154 'label' => ts("Contact"),
155 ],
156 'add' => '1.1',
157 ],
158 'group_id' => [
159 'name' => 'group_id',
160 'type' => CRM_Utils_Type::T_INT,
161 'title' => ts('Group ID'),
162 'description' => ts('Group ID'),
163 'where' => 'civicrm_subscription_history.group_id',
164 'table_name' => 'civicrm_subscription_history',
165 'entity' => 'SubscriptionHistory',
166 'bao' => 'CRM_Contact_BAO_SubscriptionHistory',
167 'localizable' => 0,
168 'FKClassName' => 'CRM_Contact_DAO_Group',
169 'html' => [
170 'type' => 'Select',
171 'label' => ts("Group"),
172 ],
173 'pseudoconstant' => [
174 'table' => 'civicrm_group',
175 'keyColumn' => 'id',
176 'labelColumn' => 'title',
177 ],
178 'add' => '1.1',
179 ],
180 'date' => [
181 'name' => 'date',
182 'type' => CRM_Utils_Type::T_TIMESTAMP,
183 'title' => ts('Group Membership Action Date'),
184 'description' => ts('Date of the (un)subscription'),
185 'required' => TRUE,
186 'where' => 'civicrm_subscription_history.date',
187 'default' => 'CURRENT_TIMESTAMP',
188 'table_name' => 'civicrm_subscription_history',
189 'entity' => 'SubscriptionHistory',
190 'bao' => 'CRM_Contact_BAO_SubscriptionHistory',
191 'localizable' => 0,
192 'add' => '1.1',
193 ],
194 'method' => [
195 'name' => 'method',
196 'type' => CRM_Utils_Type::T_STRING,
197 'title' => ts('Group Membership Action'),
198 'description' => ts('How the (un)subscription was triggered'),
199 'maxlength' => 8,
200 'size' => CRM_Utils_Type::EIGHT,
201 'where' => 'civicrm_subscription_history.method',
202 'table_name' => 'civicrm_subscription_history',
203 'entity' => 'SubscriptionHistory',
204 'bao' => 'CRM_Contact_BAO_SubscriptionHistory',
205 'localizable' => 0,
206 'html' => [
207 'type' => 'Select',
208 ],
209 'pseudoconstant' => [
210 'callback' => 'CRM_Core_SelectValues::getSubscriptionHistoryMethods',
211 ],
212 'add' => '1.1',
213 ],
214 'status' => [
215 'name' => 'status',
216 'type' => CRM_Utils_Type::T_STRING,
217 'title' => ts('Group Membership Status'),
218 'description' => ts('The state of the contact within the group'),
219 'maxlength' => 8,
220 'size' => CRM_Utils_Type::EIGHT,
221 'where' => 'civicrm_subscription_history.status',
222 'table_name' => 'civicrm_subscription_history',
223 'entity' => 'SubscriptionHistory',
224 'bao' => 'CRM_Contact_BAO_SubscriptionHistory',
225 'localizable' => 0,
226 'pseudoconstant' => [
227 'callback' => 'CRM_Core_SelectValues::groupContactStatus',
228 ],
229 'add' => '1.1',
230 ],
231 'tracking' => [
232 'name' => 'tracking',
233 'type' => CRM_Utils_Type::T_STRING,
234 'title' => ts('Group Membership Tracking'),
235 'description' => ts('IP address or other tracking info'),
236 'maxlength' => 255,
237 'size' => CRM_Utils_Type::HUGE,
238 'where' => 'civicrm_subscription_history.tracking',
239 'table_name' => 'civicrm_subscription_history',
240 'entity' => 'SubscriptionHistory',
241 'bao' => 'CRM_Contact_BAO_SubscriptionHistory',
242 'localizable' => 0,
243 'add' => '1.1',
244 ],
245 ];
246 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
247 }
248 return Civi::$statics[__CLASS__]['fields'];
249 }
250
251 /**
252 * Return a mapping from field-name to the corresponding key (as used in fields()).
253 *
254 * @return array
255 * Array(string $name => string $uniqueName).
256 */
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()));
260 }
261 return Civi::$statics[__CLASS__]['fieldKeys'];
262 }
263
264 /**
265 * Returns the names of this table
266 *
267 * @return string
268 */
269 public static function getTableName() {
270 return self::$_tableName;
271 }
272
273 /**
274 * Returns if this table needs to be logged
275 *
276 * @return bool
277 */
278 public function getLog() {
279 return self::$_log;
280 }
281
282 /**
283 * Returns the list of fields that can be imported
284 *
285 * @param bool $prefix
286 *
287 * @return array
288 */
289 public static function &import($prefix = FALSE) {
290 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'subscription_history', $prefix, []);
291 return $r;
292 }
293
294 /**
295 * Returns the list of fields that can be exported
296 *
297 * @param bool $prefix
298 *
299 * @return array
300 */
301 public static function &export($prefix = FALSE) {
302 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'subscription_history', $prefix, []);
303 return $r;
304 }
305
306 /**
307 * Returns the list of indices
308 *
309 * @param bool $localize
310 *
311 * @return array
312 */
313 public static function indices($localize = TRUE) {
314 $indices = [];
315 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
316 }
317
318 }