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:58a499585518faad19d52d57dfb1f1ba)
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',
142 'name' => 'contact_id',
143 'type' => CRM_Utils_Type
::T_INT
,
144 'title' => ts('Contact ID'),
145 'description' => ts('Contact ID'),
147 'where' => 'civicrm_subscription_history.contact_id',
148 'table_name' => 'civicrm_subscription_history',
149 'entity' => 'SubscriptionHistory',
150 'bao' => 'CRM_Contact_BAO_SubscriptionHistory',
152 'FKClassName' => 'CRM_Contact_DAO_Contact',
154 'label' => ts("Contact"),
159 'name' => 'group_id',
160 'type' => CRM_Utils_Type
::T_INT
,
161 'title' => ts('Group ID'),
162 'description' => ts('Group ID'),
163 'where' => 'civicrm_subscription_history.group_id',
164 'table_name' => 'civicrm_subscription_history',
165 'entity' => 'SubscriptionHistory',
166 'bao' => 'CRM_Contact_BAO_SubscriptionHistory',
168 'FKClassName' => 'CRM_Contact_DAO_Group',
171 'label' => ts("Group"),
173 'pseudoconstant' => [
174 'table' => 'civicrm_group',
176 'labelColumn' => 'title',
182 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
183 'title' => ts('Group Membership Action Date'),
184 'description' => ts('Date of the (un)subscription'),
186 'where' => 'civicrm_subscription_history.date',
187 'default' => 'CURRENT_TIMESTAMP',
188 'table_name' => 'civicrm_subscription_history',
189 'entity' => 'SubscriptionHistory',
190 'bao' => 'CRM_Contact_BAO_SubscriptionHistory',
196 'type' => CRM_Utils_Type
::T_STRING
,
197 'title' => ts('Group Membership Action'),
198 'description' => ts('How the (un)subscription was triggered'),
200 'size' => CRM_Utils_Type
::EIGHT
,
201 'where' => 'civicrm_subscription_history.method',
202 'table_name' => 'civicrm_subscription_history',
203 'entity' => 'SubscriptionHistory',
204 'bao' => 'CRM_Contact_BAO_SubscriptionHistory',
209 'pseudoconstant' => [
210 'callback' => 'CRM_Core_SelectValues::getSubscriptionHistoryMethods',
216 'type' => CRM_Utils_Type
::T_STRING
,
217 'title' => ts('Group Membership Status'),
218 'description' => ts('The state of the contact within the group'),
220 'size' => CRM_Utils_Type
::EIGHT
,
221 'where' => 'civicrm_subscription_history.status',
222 'table_name' => 'civicrm_subscription_history',
223 'entity' => 'SubscriptionHistory',
224 'bao' => 'CRM_Contact_BAO_SubscriptionHistory',
226 'pseudoconstant' => [
227 'callback' => 'CRM_Core_SelectValues::groupContactStatus',
232 'name' => 'tracking',
233 'type' => CRM_Utils_Type
::T_STRING
,
234 'title' => ts('Group Membership Tracking'),
235 'description' => ts('IP address or other tracking info'),
237 'size' => CRM_Utils_Type
::HUGE
,
238 'where' => 'civicrm_subscription_history.tracking',
239 'table_name' => 'civicrm_subscription_history',
240 'entity' => 'SubscriptionHistory',
241 'bao' => 'CRM_Contact_BAO_SubscriptionHistory',
246 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
248 return Civi
::$statics[__CLASS__
]['fields'];
252 * Return a mapping from field-name to the corresponding key (as used in fields()).
255 * Array(string $name => string $uniqueName).
257 public static function &fieldKeys() {
258 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
259 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
261 return Civi
::$statics[__CLASS__
]['fieldKeys'];
265 * Returns the names of this table
269 public static function getTableName() {
270 return self
::$_tableName;
274 * Returns if this table needs to be logged
278 public function getLog() {
283 * Returns the list of fields that can be imported
285 * @param bool $prefix
289 public static function &import($prefix = FALSE) {
290 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'subscription_history', $prefix, []);
295 * Returns the list of fields that can be exported
297 * @param bool $prefix
301 public static function &export($prefix = FALSE) {
302 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'subscription_history', $prefix, []);
307 * Returns the list of indices
309 * @param bool $localize
313 public static function indices($localize = TRUE) {
315 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;