| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * @package CRM |
| 5 | * @copyright CiviCRM LLC https://civicrm.org/licensing |
| 6 | * |
| 7 | * Generated from xml/schema/CRM/Contact/SubscriptionHistory.xml |
| 8 | * DO NOT EDIT. Generated by CRM_Core_CodeGen |
| 9 | * (GenCodeChecksum:c38d68dcab2d037fc65d4e59bd30d1d4) |
| 10 | */ |
| 11 | |
| 12 | /** |
| 13 | * Database access object for the SubscriptionHistory entity. |
| 14 | */ |
| 15 | class CRM_Contact_DAO_SubscriptionHistory extends CRM_Core_DAO { |
| 16 | const EXT = 'civicrm'; |
| 17 | const TABLE_ADDED = '1.1'; |
| 18 | |
| 19 | /** |
| 20 | * Static instance to hold the table name. |
| 21 | * |
| 22 | * @var string |
| 23 | */ |
| 24 | public static $_tableName = 'civicrm_subscription_history'; |
| 25 | |
| 26 | /** |
| 27 | * Should CiviCRM log any modifications to this table in the civicrm_log table. |
| 28 | * |
| 29 | * @var bool |
| 30 | */ |
| 31 | public static $_log = TRUE; |
| 32 | |
| 33 | /** |
| 34 | * Internal Id |
| 35 | * |
| 36 | * @var int |
| 37 | */ |
| 38 | public $id; |
| 39 | |
| 40 | /** |
| 41 | * Contact Id |
| 42 | * |
| 43 | * @var int |
| 44 | */ |
| 45 | public $contact_id; |
| 46 | |
| 47 | /** |
| 48 | * Group Id |
| 49 | * |
| 50 | * @var int |
| 51 | */ |
| 52 | public $group_id; |
| 53 | |
| 54 | /** |
| 55 | * Date of the (un)subscription |
| 56 | * |
| 57 | * @var timestamp |
| 58 | */ |
| 59 | public $date; |
| 60 | |
| 61 | /** |
| 62 | * How the (un)subscription was triggered |
| 63 | * |
| 64 | * @var string |
| 65 | */ |
| 66 | public $method; |
| 67 | |
| 68 | /** |
| 69 | * The state of the contact within the group |
| 70 | * |
| 71 | * @var string |
| 72 | */ |
| 73 | public $status; |
| 74 | |
| 75 | /** |
| 76 | * IP address or other tracking info |
| 77 | * |
| 78 | * @var string |
| 79 | */ |
| 80 | public $tracking; |
| 81 | |
| 82 | /** |
| 83 | * Class constructor. |
| 84 | */ |
| 85 | public function __construct() { |
| 86 | $this->__table = 'civicrm_subscription_history'; |
| 87 | parent::__construct(); |
| 88 | } |
| 89 | |
| 90 | /** |
| 91 | * Returns localized title of this entity. |
| 92 | * |
| 93 | * @param bool $plural |
| 94 | * Whether to return the plural version of the title. |
| 95 | */ |
| 96 | public static function getEntityTitle($plural = FALSE) { |
| 97 | return $plural ? ts('Subscription Histories') : ts('Subscription History'); |
| 98 | } |
| 99 | |
| 100 | /** |
| 101 | * Returns foreign keys and entity references. |
| 102 | * |
| 103 | * @return array |
| 104 | * [CRM_Core_Reference_Interface] |
| 105 | */ |
| 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']); |
| 112 | } |
| 113 | return Civi::$statics[__CLASS__]['links']; |
| 114 | } |
| 115 | |
| 116 | /** |
| 117 | * Returns all the column names of this table |
| 118 | * |
| 119 | * @return array |
| 120 | */ |
| 121 | public static function &fields() { |
| 122 | if (!isset(Civi::$statics[__CLASS__]['fields'])) { |
| 123 | Civi::$statics[__CLASS__]['fields'] = [ |
| 124 | 'id' => [ |
| 125 | 'name' => 'id', |
| 126 | 'type' => CRM_Utils_Type::T_INT, |
| 127 | 'title' => ts('Group Membership History ID'), |
| 128 | 'description' => ts('Internal Id'), |
| 129 | 'required' => TRUE, |
| 130 | 'where' => 'civicrm_subscription_history.id', |
| 131 | 'table_name' => 'civicrm_subscription_history', |
| 132 | 'entity' => 'SubscriptionHistory', |
| 133 | 'bao' => 'CRM_Contact_BAO_SubscriptionHistory', |
| 134 | 'localizable' => 0, |
| 135 | 'add' => '1.1', |
| 136 | ], |
| 137 | 'contact_id' => [ |
| 138 | 'name' => 'contact_id', |
| 139 | 'type' => CRM_Utils_Type::T_INT, |
| 140 | 'title' => ts('Contact ID'), |
| 141 | 'description' => ts('Contact Id'), |
| 142 | 'required' => TRUE, |
| 143 | 'where' => 'civicrm_subscription_history.contact_id', |
| 144 | 'table_name' => 'civicrm_subscription_history', |
| 145 | 'entity' => 'SubscriptionHistory', |
| 146 | 'bao' => 'CRM_Contact_BAO_SubscriptionHistory', |
| 147 | 'localizable' => 0, |
| 148 | 'FKClassName' => 'CRM_Contact_DAO_Contact', |
| 149 | 'add' => '1.1', |
| 150 | ], |
| 151 | 'group_id' => [ |
| 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', |
| 160 | 'localizable' => 0, |
| 161 | 'FKClassName' => 'CRM_Contact_DAO_Group', |
| 162 | 'html' => [ |
| 163 | 'type' => 'Select', |
| 164 | ], |
| 165 | 'pseudoconstant' => [ |
| 166 | 'table' => 'civicrm_group', |
| 167 | 'keyColumn' => 'id', |
| 168 | 'labelColumn' => 'title', |
| 169 | ], |
| 170 | 'add' => '1.1', |
| 171 | ], |
| 172 | 'date' => [ |
| 173 | 'name' => 'date', |
| 174 | 'type' => CRM_Utils_Type::T_TIMESTAMP, |
| 175 | 'title' => ts('Group Membership Action Date'), |
| 176 | 'description' => ts('Date of the (un)subscription'), |
| 177 | 'required' => TRUE, |
| 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', |
| 183 | 'localizable' => 0, |
| 184 | 'add' => '1.1', |
| 185 | ], |
| 186 | 'method' => [ |
| 187 | 'name' => 'method', |
| 188 | 'type' => CRM_Utils_Type::T_STRING, |
| 189 | 'title' => ts('Group Membership Action'), |
| 190 | 'description' => ts('How the (un)subscription was triggered'), |
| 191 | 'maxlength' => 8, |
| 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', |
| 197 | 'localizable' => 0, |
| 198 | 'html' => [ |
| 199 | 'type' => 'Select', |
| 200 | ], |
| 201 | 'pseudoconstant' => [ |
| 202 | 'callback' => 'CRM_Core_SelectValues::getSubscriptionHistoryMethods', |
| 203 | ], |
| 204 | 'add' => '1.1', |
| 205 | ], |
| 206 | 'status' => [ |
| 207 | 'name' => 'status', |
| 208 | 'type' => CRM_Utils_Type::T_STRING, |
| 209 | 'title' => ts('Group Membership Status'), |
| 210 | 'description' => ts('The state of the contact within the group'), |
| 211 | 'maxlength' => 8, |
| 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', |
| 217 | 'localizable' => 0, |
| 218 | 'pseudoconstant' => [ |
| 219 | 'callback' => 'CRM_Core_SelectValues::groupContactStatus', |
| 220 | ], |
| 221 | 'add' => '1.1', |
| 222 | ], |
| 223 | 'tracking' => [ |
| 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'), |
| 228 | 'maxlength' => 255, |
| 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', |
| 234 | 'localizable' => 0, |
| 235 | 'add' => '1.1', |
| 236 | ], |
| 237 | ]; |
| 238 | CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']); |
| 239 | } |
| 240 | return Civi::$statics[__CLASS__]['fields']; |
| 241 | } |
| 242 | |
| 243 | /** |
| 244 | * Return a mapping from field-name to the corresponding key (as used in fields()). |
| 245 | * |
| 246 | * @return array |
| 247 | * Array(string $name => string $uniqueName). |
| 248 | */ |
| 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())); |
| 252 | } |
| 253 | return Civi::$statics[__CLASS__]['fieldKeys']; |
| 254 | } |
| 255 | |
| 256 | /** |
| 257 | * Returns the names of this table |
| 258 | * |
| 259 | * @return string |
| 260 | */ |
| 261 | public static function getTableName() { |
| 262 | return self::$_tableName; |
| 263 | } |
| 264 | |
| 265 | /** |
| 266 | * Returns if this table needs to be logged |
| 267 | * |
| 268 | * @return bool |
| 269 | */ |
| 270 | public function getLog() { |
| 271 | return self::$_log; |
| 272 | } |
| 273 | |
| 274 | /** |
| 275 | * Returns the list of fields that can be imported |
| 276 | * |
| 277 | * @param bool $prefix |
| 278 | * |
| 279 | * @return array |
| 280 | */ |
| 281 | public static function &import($prefix = FALSE) { |
| 282 | $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'subscription_history', $prefix, []); |
| 283 | return $r; |
| 284 | } |
| 285 | |
| 286 | /** |
| 287 | * Returns the list of fields that can be exported |
| 288 | * |
| 289 | * @param bool $prefix |
| 290 | * |
| 291 | * @return array |
| 292 | */ |
| 293 | public static function &export($prefix = FALSE) { |
| 294 | $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'subscription_history', $prefix, []); |
| 295 | return $r; |
| 296 | } |
| 297 | |
| 298 | /** |
| 299 | * Returns the list of indices |
| 300 | * |
| 301 | * @param bool $localize |
| 302 | * |
| 303 | * @return array |
| 304 | */ |
| 305 | public static function indices($localize = TRUE) { |
| 306 | $indices = []; |
| 307 | return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices; |
| 308 | } |
| 309 | |
| 310 | } |