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