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