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