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