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