Merge pull request #11703 from eileenmcnaughton/export
[civicrm-core.git] / CRM / Contact / DAO / SubscriptionHistory.php
CommitLineData
e501603b 1<?php
c3fc2621 2
e501603b
TO
3/**
4 * @package CRM
8c9251b3 5 * @copyright CiviCRM LLC (c) 2004-2018
e501603b
TO
6 *
7 * Generated from xml/schema/CRM/Contact/SubscriptionHistory.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
5a393bfc 9 * (GenCodeChecksum:8b7f0a4e3593bc26947b4bb6cf54c2d2)
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 */
22 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 */
c3fc2621
CW
29 static $_log = TRUE;
30
e501603b
TO
31 /**
32 * Internal Id
33 *
34 * @var int unsigned
35 */
36 public $id;
c3fc2621 37
e501603b
TO
38 /**
39 * Contact Id
40 *
41 * @var int unsigned
42 */
43 public $contact_id;
c3fc2621 44
e501603b
TO
45 /**
46 * Group Id
47 *
48 * @var int unsigned
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
TO
95 if (!isset(Civi::$statics[__CLASS__]['links'])) {
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'),
e501603b 116 'description' => 'Internal Id',
c3fc2621 117 'required' => TRUE,
522a26c9 118 'table_name' => 'civicrm_subscription_history',
119 'entity' => 'SubscriptionHistory',
120 'bao' => 'CRM_Contact_BAO_SubscriptionHistory',
6a7e5e5d 121 'localizable' => 0,
c3fc2621
CW
122 ],
123 'contact_id' => [
e501603b
TO
124 'name' => 'contact_id',
125 'type' => CRM_Utils_Type::T_INT,
c3fc2621 126 'title' => ts('Contact ID'),
e501603b 127 'description' => 'Contact Id',
c3fc2621 128 'required' => TRUE,
522a26c9 129 'table_name' => 'civicrm_subscription_history',
130 'entity' => 'SubscriptionHistory',
131 'bao' => 'CRM_Contact_BAO_SubscriptionHistory',
6a7e5e5d 132 'localizable' => 0,
e501603b 133 'FKClassName' => 'CRM_Contact_DAO_Contact',
c3fc2621
CW
134 ],
135 'group_id' => [
e501603b
TO
136 'name' => 'group_id',
137 'type' => CRM_Utils_Type::T_INT,
c3fc2621 138 'title' => ts('Group'),
e501603b 139 'description' => 'Group Id',
522a26c9 140 'table_name' => 'civicrm_subscription_history',
141 'entity' => 'SubscriptionHistory',
142 'bao' => 'CRM_Contact_BAO_SubscriptionHistory',
6a7e5e5d 143 'localizable' => 0,
e501603b 144 'FKClassName' => 'CRM_Contact_DAO_Group',
c3fc2621 145 'html' => [
e501603b 146 'type' => 'Select',
c3fc2621
CW
147 ],
148 'pseudoconstant' => [
e501603b
TO
149 'table' => 'civicrm_group',
150 'keyColumn' => 'id',
151 'labelColumn' => 'title',
c3fc2621
CW
152 ]
153 ],
154 'date' => [
e501603b 155 'name' => 'date',
5a393bfc 156 'type' => CRM_Utils_Type::T_TIMESTAMP,
c3fc2621 157 'title' => ts('Group Membership Action Date'),
e501603b 158 'description' => 'Date of the (un)subscription',
c3fc2621 159 'required' => TRUE,
5a393bfc 160 'default' => 'CURRENT_TIMESTAMP',
522a26c9 161 'table_name' => 'civicrm_subscription_history',
162 'entity' => 'SubscriptionHistory',
163 'bao' => 'CRM_Contact_BAO_SubscriptionHistory',
6a7e5e5d 164 'localizable' => 0,
c3fc2621
CW
165 ],
166 'method' => [
e501603b
TO
167 'name' => 'method',
168 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 169 'title' => ts('Group Membership Action'),
e501603b
TO
170 'description' => 'How the (un)subscription was triggered',
171 'maxlength' => 8,
172 'size' => CRM_Utils_Type::EIGHT,
522a26c9 173 'table_name' => 'civicrm_subscription_history',
174 'entity' => 'SubscriptionHistory',
175 'bao' => 'CRM_Contact_BAO_SubscriptionHistory',
6a7e5e5d 176 'localizable' => 0,
c3fc2621 177 'html' => [
e501603b 178 'type' => 'Select',
c3fc2621
CW
179 ],
180 'pseudoconstant' => [
e501603b 181 'callback' => 'CRM_Core_SelectValues::getSubscriptionHistoryMethods',
c3fc2621
CW
182 ]
183 ],
184 'status' => [
e501603b
TO
185 'name' => 'status',
186 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 187 'title' => ts('Group Membership Status'),
e501603b
TO
188 'description' => 'The state of the contact within the group',
189 'maxlength' => 8,
190 'size' => CRM_Utils_Type::EIGHT,
522a26c9 191 'table_name' => 'civicrm_subscription_history',
192 'entity' => 'SubscriptionHistory',
193 'bao' => 'CRM_Contact_BAO_SubscriptionHistory',
6a7e5e5d 194 'localizable' => 0,
c3fc2621 195 'pseudoconstant' => [
e501603b 196 'callback' => 'CRM_Core_SelectValues::groupContactStatus',
c3fc2621
CW
197 ]
198 ],
199 'tracking' => [
e501603b
TO
200 'name' => 'tracking',
201 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 202 'title' => ts('Group Membership Tracking'),
e501603b
TO
203 'description' => 'IP address or other tracking info',
204 'maxlength' => 255,
205 'size' => CRM_Utils_Type::HUGE,
522a26c9 206 'table_name' => 'civicrm_subscription_history',
207 'entity' => 'SubscriptionHistory',
208 'bao' => 'CRM_Contact_BAO_SubscriptionHistory',
6a7e5e5d 209 'localizable' => 0,
c3fc2621
CW
210 ],
211 ];
346aaaba 212 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 213 }
346aaaba 214 return Civi::$statics[__CLASS__]['fields'];
e501603b 215 }
c3fc2621 216
e501603b 217 /**
bd8e0b14 218 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
219 *
220 * @return array
bd8e0b14 221 * Array(string $name => string $uniqueName).
e501603b 222 */
c3fc2621 223 public static function &fieldKeys() {
bd8e0b14
TO
224 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
225 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 226 }
bd8e0b14 227 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 228 }
c3fc2621 229
e501603b
TO
230 /**
231 * Returns the names of this table
232 *
233 * @return string
234 */
c3fc2621 235 public static function getTableName() {
e501603b
TO
236 return self::$_tableName;
237 }
c3fc2621 238
e501603b
TO
239 /**
240 * Returns if this table needs to be logged
241 *
c3fc2621 242 * @return bool
e501603b 243 */
c3fc2621 244 public function getLog() {
e501603b
TO
245 return self::$_log;
246 }
c3fc2621 247
e501603b
TO
248 /**
249 * Returns the list of fields that can be imported
250 *
251 * @param bool $prefix
252 *
253 * @return array
254 */
c3fc2621
CW
255 public static function &import($prefix = FALSE) {
256 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'subscription_history', $prefix, []);
60808919 257 return $r;
e501603b 258 }
c3fc2621 259
e501603b
TO
260 /**
261 * Returns the list of fields that can be exported
262 *
263 * @param bool $prefix
264 *
265 * @return array
266 */
c3fc2621
CW
267 public static function &export($prefix = FALSE) {
268 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'subscription_history', $prefix, []);
60808919 269 return $r;
e501603b 270 }
c3fc2621 271
e7a6b91a
AS
272 /**
273 * Returns the list of indices
c3fc2621
CW
274 *
275 * @param bool $localize
276 *
277 * @return array
e7a6b91a
AS
278 */
279 public static function indices($localize = TRUE) {
c3fc2621 280 $indices = [];
e7a6b91a
AS
281 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
282 }
c3fc2621 283
e501603b 284}