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:c38d68dcab2d037fc65d4e59bd30d1d4)
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.
94 * Whether to return the plural version of the title.
96 public static function getEntityTitle($plural = FALSE) {
97 return $plural ?
ts('Subscription Histories') : ts('Subscription History');
101 * Returns foreign keys and entity references.
104 * [CRM_Core_Reference_Interface]
106 public static function getReferenceColumns() {
107 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
108 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
109 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contact_id', 'civicrm_contact', 'id');
110 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'group_id', 'civicrm_group', 'id');
111 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
113 return Civi
::$statics[__CLASS__
]['links'];
117 * Returns all the column names of this table
121 public static function &fields() {
122 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
123 Civi
::$statics[__CLASS__
]['fields'] = [
126 'type' => CRM_Utils_Type
::T_INT
,
127 'title' => ts('Group Membership History ID'),
128 'description' => ts('Internal Id'),
130 'where' => 'civicrm_subscription_history.id',
131 'table_name' => 'civicrm_subscription_history',
132 'entity' => 'SubscriptionHistory',
133 'bao' => 'CRM_Contact_BAO_SubscriptionHistory',
138 'name' => 'contact_id',
139 'type' => CRM_Utils_Type
::T_INT
,
140 'title' => ts('Contact ID'),
141 'description' => ts('Contact Id'),
143 'where' => 'civicrm_subscription_history.contact_id',
144 'table_name' => 'civicrm_subscription_history',
145 'entity' => 'SubscriptionHistory',
146 'bao' => 'CRM_Contact_BAO_SubscriptionHistory',
148 'FKClassName' => 'CRM_Contact_DAO_Contact',
152 'name' => 'group_id',
153 'type' => CRM_Utils_Type
::T_INT
,
154 'title' => ts('Group'),
155 'description' => ts('Group Id'),
156 'where' => 'civicrm_subscription_history.group_id',
157 'table_name' => 'civicrm_subscription_history',
158 'entity' => 'SubscriptionHistory',
159 'bao' => 'CRM_Contact_BAO_SubscriptionHistory',
161 'FKClassName' => 'CRM_Contact_DAO_Group',
165 'pseudoconstant' => [
166 'table' => 'civicrm_group',
168 'labelColumn' => 'title',
174 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
175 'title' => ts('Group Membership Action Date'),
176 'description' => ts('Date of the (un)subscription'),
178 'where' => 'civicrm_subscription_history.date',
179 'default' => 'CURRENT_TIMESTAMP',
180 'table_name' => 'civicrm_subscription_history',
181 'entity' => 'SubscriptionHistory',
182 'bao' => 'CRM_Contact_BAO_SubscriptionHistory',
188 'type' => CRM_Utils_Type
::T_STRING
,
189 'title' => ts('Group Membership Action'),
190 'description' => ts('How the (un)subscription was triggered'),
192 'size' => CRM_Utils_Type
::EIGHT
,
193 'where' => 'civicrm_subscription_history.method',
194 'table_name' => 'civicrm_subscription_history',
195 'entity' => 'SubscriptionHistory',
196 'bao' => 'CRM_Contact_BAO_SubscriptionHistory',
201 'pseudoconstant' => [
202 'callback' => 'CRM_Core_SelectValues::getSubscriptionHistoryMethods',
208 'type' => CRM_Utils_Type
::T_STRING
,
209 'title' => ts('Group Membership Status'),
210 'description' => ts('The state of the contact within the group'),
212 'size' => CRM_Utils_Type
::EIGHT
,
213 'where' => 'civicrm_subscription_history.status',
214 'table_name' => 'civicrm_subscription_history',
215 'entity' => 'SubscriptionHistory',
216 'bao' => 'CRM_Contact_BAO_SubscriptionHistory',
218 'pseudoconstant' => [
219 'callback' => 'CRM_Core_SelectValues::groupContactStatus',
224 'name' => 'tracking',
225 'type' => CRM_Utils_Type
::T_STRING
,
226 'title' => ts('Group Membership Tracking'),
227 'description' => ts('IP address or other tracking info'),
229 'size' => CRM_Utils_Type
::HUGE
,
230 'where' => 'civicrm_subscription_history.tracking',
231 'table_name' => 'civicrm_subscription_history',
232 'entity' => 'SubscriptionHistory',
233 'bao' => 'CRM_Contact_BAO_SubscriptionHistory',
238 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
240 return Civi
::$statics[__CLASS__
]['fields'];
244 * Return a mapping from field-name to the corresponding key (as used in fields()).
247 * Array(string $name => string $uniqueName).
249 public static function &fieldKeys() {
250 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
251 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
253 return Civi
::$statics[__CLASS__
]['fieldKeys'];
257 * Returns the names of this table
261 public static function getTableName() {
262 return self
::$_tableName;
266 * Returns if this table needs to be logged
270 public function getLog() {
275 * Returns the list of fields that can be imported
277 * @param bool $prefix
281 public static function &import($prefix = FALSE) {
282 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'subscription_history', $prefix, []);
287 * Returns the list of fields that can be exported
289 * @param bool $prefix
293 public static function &export($prefix = FALSE) {
294 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'subscription_history', $prefix, []);
299 * Returns the list of indices
301 * @param bool $localize
305 public static function indices($localize = TRUE) {
307 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;