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