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