(NFC) (dev/core#878) Simplify '@copyright' annotation
[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
74db51d3 9 * (GenCodeChecksum:161f6ed400e9511cd2e5751941634cc4)
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 {
c3fc2621 16
e501603b 17 /**
f41f0342 18 * Static instance to hold the table name.
e501603b
TO
19 *
20 * @var string
21 */
fa45b5b9 22 public static $_tableName = 'civicrm_subscription_history';
c3fc2621 23
e501603b 24 /**
f41f0342 25 * Should CiviCRM log any modifications to this table in the civicrm_log table.
e501603b 26 *
c3fc2621 27 * @var bool
e501603b 28 */
fa45b5b9 29 public static $_log = TRUE;
c3fc2621 30
e501603b
TO
31 /**
32 * Internal Id
33 *
e6ca0a57 34 * @var int
e501603b
TO
35 */
36 public $id;
c3fc2621 37
e501603b
TO
38 /**
39 * Contact Id
40 *
e6ca0a57 41 * @var int
e501603b
TO
42 */
43 public $contact_id;
c3fc2621 44
e501603b
TO
45 /**
46 * Group Id
47 *
e6ca0a57 48 * @var int
e501603b
TO
49 */
50 public $group_id;
c3fc2621 51
e501603b
TO
52 /**
53 * Date of the (un)subscription
54 *
5a393bfc 55 * @var timestamp
e501603b
TO
56 */
57 public $date;
c3fc2621 58
e501603b
TO
59 /**
60 * How the (un)subscription was triggered
61 *
62 * @var string
63 */
64 public $method;
c3fc2621 65
e501603b
TO
66 /**
67 * The state of the contact within the group
68 *
69 * @var string
70 */
71 public $status;
c3fc2621 72
e501603b
TO
73 /**
74 * IP address or other tracking info
75 *
76 * @var string
77 */
78 public $tracking;
c3fc2621 79
e501603b 80 /**
f41f0342 81 * Class constructor.
e501603b 82 */
c3fc2621 83 public function __construct() {
e501603b
TO
84 $this->__table = 'civicrm_subscription_history';
85 parent::__construct();
86 }
c3fc2621 87
e501603b 88 /**
f41f0342 89 * Returns foreign keys and entity references.
e501603b
TO
90 *
91 * @return array
92 * [CRM_Core_Reference_Interface]
93 */
c3fc2621 94 public static function getReferenceColumns() {
346aaaba 95 if (!isset(Civi::$statics[__CLASS__]['links'])) {
fa45b5b9 96 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
c3fc2621
CW
97 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id');
98 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'group_id', 'civicrm_group', 'id');
346aaaba 99 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
e501603b 100 }
346aaaba 101 return Civi::$statics[__CLASS__]['links'];
e501603b 102 }
c3fc2621 103
e501603b
TO
104 /**
105 * Returns all the column names of this table
106 *
107 * @return array
108 */
c3fc2621 109 public static function &fields() {
346aaaba 110 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
c3fc2621
CW
111 Civi::$statics[__CLASS__]['fields'] = [
112 'id' => [
e501603b
TO
113 'name' => 'id',
114 'type' => CRM_Utils_Type::T_INT,
c3fc2621 115 'title' => ts('Group Membership History ID'),
215b423e 116 'description' => ts('Internal Id'),
c3fc2621 117 'required' => TRUE,
a36434b9 118 'where' => 'civicrm_subscription_history.id',
522a26c9 119 'table_name' => 'civicrm_subscription_history',
120 'entity' => 'SubscriptionHistory',
121 'bao' => 'CRM_Contact_BAO_SubscriptionHistory',
6a7e5e5d 122 'localizable' => 0,
c3fc2621
CW
123 ],
124 'contact_id' => [
e501603b
TO
125 'name' => 'contact_id',
126 'type' => CRM_Utils_Type::T_INT,
c3fc2621 127 'title' => ts('Contact ID'),
215b423e 128 'description' => ts('Contact Id'),
c3fc2621 129 'required' => TRUE,
a36434b9 130 'where' => 'civicrm_subscription_history.contact_id',
522a26c9 131 'table_name' => 'civicrm_subscription_history',
132 'entity' => 'SubscriptionHistory',
133 'bao' => 'CRM_Contact_BAO_SubscriptionHistory',
6a7e5e5d 134 'localizable' => 0,
e501603b 135 'FKClassName' => 'CRM_Contact_DAO_Contact',
c3fc2621
CW
136 ],
137 'group_id' => [
e501603b
TO
138 'name' => 'group_id',
139 'type' => CRM_Utils_Type::T_INT,
c3fc2621 140 'title' => ts('Group'),
215b423e 141 'description' => ts('Group Id'),
a36434b9 142 'where' => 'civicrm_subscription_history.group_id',
522a26c9 143 'table_name' => 'civicrm_subscription_history',
144 'entity' => 'SubscriptionHistory',
145 'bao' => 'CRM_Contact_BAO_SubscriptionHistory',
6a7e5e5d 146 'localizable' => 0,
e501603b 147 'FKClassName' => 'CRM_Contact_DAO_Group',
c3fc2621 148 'html' => [
e501603b 149 'type' => 'Select',
c3fc2621
CW
150 ],
151 'pseudoconstant' => [
e501603b
TO
152 'table' => 'civicrm_group',
153 'keyColumn' => 'id',
154 'labelColumn' => 'title',
e6ca0a57 155 ],
c3fc2621
CW
156 ],
157 'date' => [
e501603b 158 'name' => 'date',
5a393bfc 159 'type' => CRM_Utils_Type::T_TIMESTAMP,
c3fc2621 160 'title' => ts('Group Membership Action Date'),
215b423e 161 'description' => ts('Date of the (un)subscription'),
c3fc2621 162 'required' => TRUE,
a36434b9 163 'where' => 'civicrm_subscription_history.date',
5a393bfc 164 'default' => 'CURRENT_TIMESTAMP',
522a26c9 165 'table_name' => 'civicrm_subscription_history',
166 'entity' => 'SubscriptionHistory',
167 'bao' => 'CRM_Contact_BAO_SubscriptionHistory',
6a7e5e5d 168 'localizable' => 0,
c3fc2621
CW
169 ],
170 'method' => [
e501603b
TO
171 'name' => 'method',
172 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 173 'title' => ts('Group Membership Action'),
215b423e 174 'description' => ts('How the (un)subscription was triggered'),
e501603b
TO
175 'maxlength' => 8,
176 'size' => CRM_Utils_Type::EIGHT,
a36434b9 177 'where' => 'civicrm_subscription_history.method',
522a26c9 178 'table_name' => 'civicrm_subscription_history',
179 'entity' => 'SubscriptionHistory',
180 'bao' => 'CRM_Contact_BAO_SubscriptionHistory',
6a7e5e5d 181 'localizable' => 0,
c3fc2621 182 'html' => [
e501603b 183 'type' => 'Select',
c3fc2621
CW
184 ],
185 'pseudoconstant' => [
e501603b 186 'callback' => 'CRM_Core_SelectValues::getSubscriptionHistoryMethods',
e6ca0a57 187 ],
c3fc2621
CW
188 ],
189 'status' => [
e501603b
TO
190 'name' => 'status',
191 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 192 'title' => ts('Group Membership Status'),
215b423e 193 'description' => ts('The state of the contact within the group'),
e501603b
TO
194 'maxlength' => 8,
195 'size' => CRM_Utils_Type::EIGHT,
a36434b9 196 'where' => 'civicrm_subscription_history.status',
522a26c9 197 'table_name' => 'civicrm_subscription_history',
198 'entity' => 'SubscriptionHistory',
199 'bao' => 'CRM_Contact_BAO_SubscriptionHistory',
6a7e5e5d 200 'localizable' => 0,
c3fc2621 201 'pseudoconstant' => [
e501603b 202 'callback' => 'CRM_Core_SelectValues::groupContactStatus',
e6ca0a57 203 ],
c3fc2621
CW
204 ],
205 'tracking' => [
e501603b
TO
206 'name' => 'tracking',
207 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 208 'title' => ts('Group Membership Tracking'),
215b423e 209 'description' => ts('IP address or other tracking info'),
e501603b
TO
210 'maxlength' => 255,
211 'size' => CRM_Utils_Type::HUGE,
a36434b9 212 'where' => 'civicrm_subscription_history.tracking',
522a26c9 213 'table_name' => 'civicrm_subscription_history',
214 'entity' => 'SubscriptionHistory',
215 'bao' => 'CRM_Contact_BAO_SubscriptionHistory',
6a7e5e5d 216 'localizable' => 0,
c3fc2621
CW
217 ],
218 ];
346aaaba 219 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 220 }
346aaaba 221 return Civi::$statics[__CLASS__]['fields'];
e501603b 222 }
c3fc2621 223
e501603b 224 /**
bd8e0b14 225 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
226 *
227 * @return array
bd8e0b14 228 * Array(string $name => string $uniqueName).
e501603b 229 */
c3fc2621 230 public static function &fieldKeys() {
bd8e0b14
TO
231 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
232 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 233 }
bd8e0b14 234 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 235 }
c3fc2621 236
e501603b
TO
237 /**
238 * Returns the names of this table
239 *
240 * @return string
241 */
c3fc2621 242 public static function getTableName() {
e501603b
TO
243 return self::$_tableName;
244 }
c3fc2621 245
e501603b
TO
246 /**
247 * Returns if this table needs to be logged
248 *
c3fc2621 249 * @return bool
e501603b 250 */
c3fc2621 251 public function getLog() {
e501603b
TO
252 return self::$_log;
253 }
c3fc2621 254
e501603b
TO
255 /**
256 * Returns the list of fields that can be imported
257 *
258 * @param bool $prefix
259 *
260 * @return array
261 */
c3fc2621
CW
262 public static function &import($prefix = FALSE) {
263 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'subscription_history', $prefix, []);
60808919 264 return $r;
e501603b 265 }
c3fc2621 266
e501603b
TO
267 /**
268 * Returns the list of fields that can be exported
269 *
270 * @param bool $prefix
271 *
272 * @return array
273 */
c3fc2621
CW
274 public static function &export($prefix = FALSE) {
275 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'subscription_history', $prefix, []);
60808919 276 return $r;
e501603b 277 }
c3fc2621 278
e7a6b91a
AS
279 /**
280 * Returns the list of indices
c3fc2621
CW
281 *
282 * @param bool $localize
283 *
284 * @return array
e7a6b91a
AS
285 */
286 public static function indices($localize = TRUE) {
c3fc2621 287 $indices = [];
e7a6b91a
AS
288 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
289 }
c3fc2621 290
e501603b 291}