5 * @copyright CiviCRM LLC https://civicrm.org/licensing
7 * Generated from xml/schema/CRM/Contact/SubscriptionHistory.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:161f6ed400e9511cd2e5751941634cc4)
13 * Database access object for the SubscriptionHistory entity.
15 class CRM_Contact_DAO_SubscriptionHistory
extends CRM_Core_DAO
{
18 * Static instance to hold the table name.
22 public static $_tableName = 'civicrm_subscription_history';
25 * Should CiviCRM log any modifications to this table in the civicrm_log table.
29 public static $_log = TRUE;
53 * Date of the (un)subscription
60 * How the (un)subscription was triggered
67 * The state of the contact within the group
74 * IP address or other tracking info
83 public function __construct() {
84 $this->__table
= 'civicrm_subscription_history';
85 parent
::__construct();
89 * Returns foreign keys and entity references.
92 * [CRM_Core_Reference_Interface]
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']);
101 return Civi
::$statics[__CLASS__
]['links'];
105 * Returns all the column names of this table
109 public static function &fields() {
110 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
111 Civi
::$statics[__CLASS__
]['fields'] = [
114 'type' => CRM_Utils_Type
::T_INT
,
115 'title' => ts('Group Membership History ID'),
116 'description' => ts('Internal Id'),
118 'where' => 'civicrm_subscription_history.id',
119 'table_name' => 'civicrm_subscription_history',
120 'entity' => 'SubscriptionHistory',
121 'bao' => 'CRM_Contact_BAO_SubscriptionHistory',
125 'name' => 'contact_id',
126 'type' => CRM_Utils_Type
::T_INT
,
127 'title' => ts('Contact ID'),
128 'description' => ts('Contact Id'),
130 'where' => 'civicrm_subscription_history.contact_id',
131 'table_name' => 'civicrm_subscription_history',
132 'entity' => 'SubscriptionHistory',
133 'bao' => 'CRM_Contact_BAO_SubscriptionHistory',
135 'FKClassName' => 'CRM_Contact_DAO_Contact',
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',
147 'FKClassName' => 'CRM_Contact_DAO_Group',
151 'pseudoconstant' => [
152 'table' => 'civicrm_group',
154 'labelColumn' => 'title',
159 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
160 'title' => ts('Group Membership Action Date'),
161 'description' => ts('Date of the (un)subscription'),
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',
172 'type' => CRM_Utils_Type
::T_STRING
,
173 'title' => ts('Group Membership Action'),
174 'description' => ts('How the (un)subscription was triggered'),
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',
185 'pseudoconstant' => [
186 'callback' => 'CRM_Core_SelectValues::getSubscriptionHistoryMethods',
191 'type' => CRM_Utils_Type
::T_STRING
,
192 'title' => ts('Group Membership Status'),
193 'description' => ts('The state of the contact within the group'),
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',
201 'pseudoconstant' => [
202 'callback' => 'CRM_Core_SelectValues::groupContactStatus',
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'),
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',
219 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
221 return Civi
::$statics[__CLASS__
]['fields'];
225 * Return a mapping from field-name to the corresponding key (as used in fields()).
228 * Array(string $name => string $uniqueName).
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()));
234 return Civi
::$statics[__CLASS__
]['fieldKeys'];
238 * Returns the names of this table
242 public static function getTableName() {
243 return self
::$_tableName;
247 * Returns if this table needs to be logged
251 public function getLog() {
256 * Returns the list of fields that can be imported
258 * @param bool $prefix
262 public static function &import($prefix = FALSE) {
263 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'subscription_history', $prefix, []);
268 * Returns the list of fields that can be exported
270 * @param bool $prefix
274 public static function &export($prefix = FALSE) {
275 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'subscription_history', $prefix, []);
280 * Returns the list of indices
282 * @param bool $localize
286 public static function indices($localize = TRUE) {
288 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;