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:fd8cbc2ef621cc092f3f91c1f0f749d4)
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;
36 * @var int|string|null
37 * (SQL type: int unsigned)
38 * Note that values will be retrieved from the database as a string.
46 * (SQL type: int unsigned)
47 * Note that values will be retrieved from the database as a string.
54 * @var int|string|null
55 * (SQL type: int unsigned)
56 * Note that values will be retrieved from the database as a string.
61 * Date of the (un)subscription
64 * (SQL type: timestamp)
65 * Note that values will be retrieved from the database as a string.
70 * How the (un)subscription was triggered
73 * (SQL type: varchar(8))
74 * Note that values will be retrieved from the database as a string.
79 * The state of the contact within the group
82 * (SQL type: varchar(8))
83 * Note that values will be retrieved from the database as a string.
88 * IP address or other tracking info
91 * (SQL type: varchar(255))
92 * Note that values will be retrieved from the database as a string.
99 public function __construct() {
100 $this->__table
= 'civicrm_subscription_history';
101 parent
::__construct();
105 * Returns localized title of this entity.
107 * @param bool $plural
108 * Whether to return the plural version of the title.
110 public static function getEntityTitle($plural = FALSE) {
111 return $plural ?
ts('Subscription Histories') : ts('Subscription History');
115 * Returns foreign keys and entity references.
118 * [CRM_Core_Reference_Interface]
120 public static function getReferenceColumns() {
121 if (!isset(Civi
::$statics[__CLASS__
]['links'])) {
122 Civi
::$statics[__CLASS__
]['links'] = static::createReferenceColumns(__CLASS__
);
123 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'contact_id', 'civicrm_contact', 'id');
124 Civi
::$statics[__CLASS__
]['links'][] = new CRM_Core_Reference_Basic(self
::getTableName(), 'group_id', 'civicrm_group', 'id');
125 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'links_callback', Civi
::$statics[__CLASS__
]['links']);
127 return Civi
::$statics[__CLASS__
]['links'];
131 * Returns all the column names of this table
135 public static function &fields() {
136 if (!isset(Civi
::$statics[__CLASS__
]['fields'])) {
137 Civi
::$statics[__CLASS__
]['fields'] = [
140 'type' => CRM_Utils_Type
::T_INT
,
141 'title' => ts('Group Membership History ID'),
142 'description' => ts('Internal ID'),
144 'where' => 'civicrm_subscription_history.id',
145 'table_name' => 'civicrm_subscription_history',
146 'entity' => 'SubscriptionHistory',
147 'bao' => 'CRM_Contact_BAO_SubscriptionHistory',
156 'name' => 'contact_id',
157 'type' => CRM_Utils_Type
::T_INT
,
158 'title' => ts('Contact ID'),
159 'description' => ts('Contact ID'),
161 'where' => 'civicrm_subscription_history.contact_id',
162 'table_name' => 'civicrm_subscription_history',
163 'entity' => 'SubscriptionHistory',
164 'bao' => 'CRM_Contact_BAO_SubscriptionHistory',
166 'FKClassName' => 'CRM_Contact_DAO_Contact',
168 'label' => ts("Contact"),
173 'name' => 'group_id',
174 'type' => CRM_Utils_Type
::T_INT
,
175 'title' => ts('Group ID'),
176 'description' => ts('Group ID'),
177 'where' => 'civicrm_subscription_history.group_id',
178 'table_name' => 'civicrm_subscription_history',
179 'entity' => 'SubscriptionHistory',
180 'bao' => 'CRM_Contact_BAO_SubscriptionHistory',
182 'FKClassName' => 'CRM_Contact_DAO_Group',
185 'label' => ts("Group"),
187 'pseudoconstant' => [
188 'table' => 'civicrm_group',
190 'labelColumn' => 'title',
196 'type' => CRM_Utils_Type
::T_TIMESTAMP
,
197 'title' => ts('Group Membership Action Date'),
198 'description' => ts('Date of the (un)subscription'),
200 'where' => 'civicrm_subscription_history.date',
201 'default' => 'CURRENT_TIMESTAMP',
202 'table_name' => 'civicrm_subscription_history',
203 'entity' => 'SubscriptionHistory',
204 'bao' => 'CRM_Contact_BAO_SubscriptionHistory',
210 'type' => CRM_Utils_Type
::T_STRING
,
211 'title' => ts('Group Membership Action'),
212 'description' => ts('How the (un)subscription was triggered'),
214 'size' => CRM_Utils_Type
::EIGHT
,
215 'where' => 'civicrm_subscription_history.method',
216 'table_name' => 'civicrm_subscription_history',
217 'entity' => 'SubscriptionHistory',
218 'bao' => 'CRM_Contact_BAO_SubscriptionHistory',
223 'pseudoconstant' => [
224 'callback' => 'CRM_Core_SelectValues::getSubscriptionHistoryMethods',
230 'type' => CRM_Utils_Type
::T_STRING
,
231 'title' => ts('Group Membership Status'),
232 'description' => ts('The state of the contact within the group'),
234 'size' => CRM_Utils_Type
::EIGHT
,
235 'where' => 'civicrm_subscription_history.status',
236 'table_name' => 'civicrm_subscription_history',
237 'entity' => 'SubscriptionHistory',
238 'bao' => 'CRM_Contact_BAO_SubscriptionHistory',
240 'pseudoconstant' => [
241 'callback' => 'CRM_Core_SelectValues::groupContactStatus',
246 'name' => 'tracking',
247 'type' => CRM_Utils_Type
::T_STRING
,
248 'title' => ts('Group Membership Tracking'),
249 'description' => ts('IP address or other tracking info'),
251 'size' => CRM_Utils_Type
::HUGE
,
252 'where' => 'civicrm_subscription_history.tracking',
253 'table_name' => 'civicrm_subscription_history',
254 'entity' => 'SubscriptionHistory',
255 'bao' => 'CRM_Contact_BAO_SubscriptionHistory',
260 CRM_Core_DAO_AllCoreTables
::invoke(__CLASS__
, 'fields_callback', Civi
::$statics[__CLASS__
]['fields']);
262 return Civi
::$statics[__CLASS__
]['fields'];
266 * Return a mapping from field-name to the corresponding key (as used in fields()).
269 * Array(string $name => string $uniqueName).
271 public static function &fieldKeys() {
272 if (!isset(Civi
::$statics[__CLASS__
]['fieldKeys'])) {
273 Civi
::$statics[__CLASS__
]['fieldKeys'] = array_flip(CRM_Utils_Array
::collect('name', self
::fields()));
275 return Civi
::$statics[__CLASS__
]['fieldKeys'];
279 * Returns the names of this table
283 public static function getTableName() {
284 return self
::$_tableName;
288 * Returns if this table needs to be logged
292 public function getLog() {
297 * Returns the list of fields that can be imported
299 * @param bool $prefix
303 public static function &import($prefix = FALSE) {
304 $r = CRM_Core_DAO_AllCoreTables
::getImports(__CLASS__
, 'subscription_history', $prefix, []);
309 * Returns the list of fields that can be exported
311 * @param bool $prefix
315 public static function &export($prefix = FALSE) {
316 $r = CRM_Core_DAO_AllCoreTables
::getExports(__CLASS__
, 'subscription_history', $prefix, []);
321 * Returns the list of indices
323 * @param bool $localize
327 public static function indices($localize = TRUE) {
329 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables
::multilingualize(__CLASS__
, $indices) : $indices;