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:4aa1411720f09f9ad8e2feb2a8d2a833)
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 localized title of this entity.
91 public static function getEntityTitle() {
92 return ts('Subscription Histories');
96 * Returns foreign keys and entity references.
99 * [CRM_Core_Reference_Interface]
101 public static function getReferenceColumns() {
102 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
103 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
104 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contact_id', 'civicrm_contact', 'id');
105 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'group_id', 'civicrm_group', 'id');
106 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
108 return Civi
::$statics[__CLASS__
]['links'];
112 * Returns all the column names of this table
116 public static function &fields() {
117 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
118 Civi
::$statics[__CLASS__
]['fields'] = [
121 'type' => CRM_Utils_Type
::T_INT
,
122 'title' => ts('Group Membership History ID'),
123 'description' => ts('Internal Id'),
125 'where' => 'civicrm_subscription_history.id',
126 'table_name' => 'civicrm_subscription_history',
127 'entity' => 'SubscriptionHistory',
128 'bao' => 'CRM_Contact_BAO_SubscriptionHistory',
133 'name' => 'contact_id',
134 'type' => CRM_Utils_Type
::T_INT
,
135 'title' => ts('Contact ID'),
136 'description' => ts('Contact Id'),
138 'where' => 'civicrm_subscription_history.contact_id',
139 'table_name' => 'civicrm_subscription_history',
140 'entity' => 'SubscriptionHistory',
141 'bao' => 'CRM_Contact_BAO_SubscriptionHistory',
143 'FKClassName' => 'CRM_Contact_DAO_Contact',
147 'name' => 'group_id',
148 'type' => CRM_Utils_Type
::T_INT
,
149 'title' => ts('Group'),
150 'description' => ts('Group Id'),
151 'where' => 'civicrm_subscription_history.group_id',
152 'table_name' => 'civicrm_subscription_history',
153 'entity' => 'SubscriptionHistory',
154 'bao' => 'CRM_Contact_BAO_SubscriptionHistory',
156 'FKClassName' => 'CRM_Contact_DAO_Group',
160 'pseudoconstant' => [
161 'table' => 'civicrm_group',
163 'labelColumn' => 'title',
169 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
170 'title' => ts('Group Membership Action Date'),
171 'description' => ts('Date of the (un)subscription'),
173 'where' => 'civicrm_subscription_history.date',
174 'default' => 'CURRENT_TIMESTAMP',
175 'table_name' => 'civicrm_subscription_history',
176 'entity' => 'SubscriptionHistory',
177 'bao' => 'CRM_Contact_BAO_SubscriptionHistory',
183 'type' => CRM_Utils_Type
::T_STRING
,
184 'title' => ts('Group Membership Action'),
185 'description' => ts('How the (un)subscription was triggered'),
187 'size' => CRM_Utils_Type
::EIGHT
,
188 'where' => 'civicrm_subscription_history.method',
189 'table_name' => 'civicrm_subscription_history',
190 'entity' => 'SubscriptionHistory',
191 'bao' => 'CRM_Contact_BAO_SubscriptionHistory',
196 'pseudoconstant' => [
197 'callback' => 'CRM_Core_SelectValues::getSubscriptionHistoryMethods',
203 'type' => CRM_Utils_Type
::T_STRING
,
204 'title' => ts('Group Membership Status'),
205 'description' => ts('The state of the contact within the group'),
207 'size' => CRM_Utils_Type
::EIGHT
,
208 'where' => 'civicrm_subscription_history.status',
209 'table_name' => 'civicrm_subscription_history',
210 'entity' => 'SubscriptionHistory',
211 'bao' => 'CRM_Contact_BAO_SubscriptionHistory',
213 'pseudoconstant' => [
214 'callback' => 'CRM_Core_SelectValues::groupContactStatus',
219 'name' => 'tracking',
220 'type' => CRM_Utils_Type
::T_STRING
,
221 'title' => ts('Group Membership Tracking'),
222 'description' => ts('IP address or other tracking info'),
224 'size' => CRM_Utils_Type
::HUGE
,
225 'where' => 'civicrm_subscription_history.tracking',
226 'table_name' => 'civicrm_subscription_history',
227 'entity' => 'SubscriptionHistory',
228 'bao' => 'CRM_Contact_BAO_SubscriptionHistory',
233 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
235 return Civi
::$statics[__CLASS__
]['fields'];
239 * Return a mapping from field-name to the corresponding key (as used in fields()).
242 * Array(string $name => string $uniqueName).
244 public static function &fieldKeys() {
245 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
246 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
248 return Civi
::$statics[__CLASS__
]['fieldKeys'];
252 * Returns the names of this table
256 public static function getTableName() {
257 return self
::$_tableName;
261 * Returns if this table needs to be logged
265 public function getLog() {
270 * Returns the list of fields that can be imported
272 * @param bool $prefix
276 public static function &import($prefix = FALSE) {
277 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'subscription_history', $prefix, []);
282 * Returns the list of fields that can be exported
284 * @param bool $prefix
288 public static function &export($prefix = FALSE) {
289 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'subscription_history', $prefix, []);
294 * Returns the list of indices
296 * @param bool $localize
300 public static function indices($localize = TRUE) {
302 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;