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:7c033b0631f14da30172883b14686574)
13 * Database access object for the SubscriptionHistory entity.
15 class CRM_Contact_DAO_SubscriptionHistory
extends CRM_Core_DAO
{
16 const EXT
= 'civicrm';
17 const TABLE_ADDED
= '1.1';
20 * Static instance to hold the table name.
24 public static $_tableName = 'civicrm_subscription_history';
27 * Should CiviCRM log any modifications to this table in the civicrm_log table.
31 public static $_log = TRUE;
55 * Date of the (un)subscription
62 * How the (un)subscription was triggered
69 * The state of the contact within the group
76 * IP address or other tracking info
85 public function __construct() {
86 $this->__table
= 'civicrm_subscription_history';
87 parent
::__construct();
91 * Returns localized title of this entity.
93 public static function getEntityTitle() {
94 return ts('Subscription Histories');
98 * Returns foreign keys and entity references.
101 * [CRM_Core_Reference_Interface]
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']);
110 return Civi
::$statics[__CLASS__
]['links'];
114 * Returns all the column names of this table
118 public static function &fields() {
119 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
120 Civi
::$statics[__CLASS__
]['fields'] = [
123 'type' => CRM_Utils_Type
::T_INT
,
124 'title' => ts('Group Membership History ID'),
125 'description' => ts('Internal Id'),
127 'where' => 'civicrm_subscription_history.id',
128 'table_name' => 'civicrm_subscription_history',
129 'entity' => 'SubscriptionHistory',
130 'bao' => 'CRM_Contact_BAO_SubscriptionHistory',
135 'name' => 'contact_id',
136 'type' => CRM_Utils_Type
::T_INT
,
137 'title' => ts('Contact ID'),
138 'description' => ts('Contact Id'),
140 'where' => 'civicrm_subscription_history.contact_id',
141 'table_name' => 'civicrm_subscription_history',
142 'entity' => 'SubscriptionHistory',
143 'bao' => 'CRM_Contact_BAO_SubscriptionHistory',
145 'FKClassName' => 'CRM_Contact_DAO_Contact',
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',
158 'FKClassName' => 'CRM_Contact_DAO_Group',
162 'pseudoconstant' => [
163 'table' => 'civicrm_group',
165 'labelColumn' => 'title',
171 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
172 'title' => ts('Group Membership Action Date'),
173 'description' => ts('Date of the (un)subscription'),
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',
185 'type' => CRM_Utils_Type
::T_STRING
,
186 'title' => ts('Group Membership Action'),
187 'description' => ts('How the (un)subscription was triggered'),
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',
198 'pseudoconstant' => [
199 'callback' => 'CRM_Core_SelectValues::getSubscriptionHistoryMethods',
205 'type' => CRM_Utils_Type
::T_STRING
,
206 'title' => ts('Group Membership Status'),
207 'description' => ts('The state of the contact within the group'),
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',
215 'pseudoconstant' => [
216 'callback' => 'CRM_Core_SelectValues::groupContactStatus',
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'),
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',
235 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
237 return Civi
::$statics[__CLASS__
]['fields'];
241 * Return a mapping from field-name to the corresponding key (as used in fields()).
244 * Array(string $name => string $uniqueName).
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()));
250 return Civi
::$statics[__CLASS__
]['fieldKeys'];
254 * Returns the names of this table
258 public static function getTableName() {
259 return self
::$_tableName;
263 * Returns if this table needs to be logged
267 public function getLog() {
272 * Returns the list of fields that can be imported
274 * @param bool $prefix
278 public static function &import($prefix = FALSE) {
279 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'subscription_history', $prefix, []);
284 * Returns the list of fields that can be exported
286 * @param bool $prefix
290 public static function &export($prefix = FALSE) {
291 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'subscription_history', $prefix, []);
296 * Returns the list of indices
298 * @param bool $localize
302 public static function indices($localize = TRUE) {
304 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;