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