DAOs with singular/plural options for entity titles
[civicrm-core.git] / CRM / Mailing / Event / DAO / Subscribe.php
CommitLineData
e501603b 1<?php
c3fc2621 2
e501603b
TO
3/**
4 * @package CRM
ca5cec67 5 * @copyright CiviCRM LLC https://civicrm.org/licensing
e501603b
TO
6 *
7 * Generated from xml/schema/CRM/Mailing/Event/Subscribe.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
7b66c3b5 9 * (GenCodeChecksum:b5a2a60211ad6eb943a6aa0db5f88840)
e501603b 10 */
c3fc2621 11
f41f0342 12/**
c3fc2621 13 * Database access object for the Subscribe entity.
f41f0342 14 */
e501603b 15class CRM_Mailing_Event_DAO_Subscribe extends CRM_Core_DAO {
929a1c14
CW
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '';
c3fc2621 18
e501603b 19 /**
f41f0342 20 * Static instance to hold the table name.
e501603b
TO
21 *
22 * @var string
23 */
fa45b5b9 24 public static $_tableName = 'civicrm_mailing_event_subscribe';
c3fc2621 25
e501603b 26 /**
f41f0342 27 * Should CiviCRM log any modifications to this table in the civicrm_log table.
e501603b 28 *
c3fc2621 29 * @var bool
e501603b 30 */
fa45b5b9 31 public static $_log = FALSE;
c3fc2621 32
e501603b 33 /**
e6ca0a57 34 * @var int
e501603b
TO
35 */
36 public $id;
c3fc2621 37
e501603b
TO
38 /**
39 * FK to Group
40 *
e6ca0a57 41 * @var int
e501603b
TO
42 */
43 public $group_id;
c3fc2621 44
e501603b
TO
45 /**
46 * FK to Contact
47 *
e6ca0a57 48 * @var int
e501603b
TO
49 */
50 public $contact_id;
c3fc2621 51
e501603b
TO
52 /**
53 * Security hash
54 *
55 * @var string
56 */
57 public $hash;
c3fc2621 58
e501603b
TO
59 /**
60 * When this subscription event occurred.
61 *
6c2b97b7 62 * @var timestamp
e501603b
TO
63 */
64 public $time_stamp;
c3fc2621 65
e501603b 66 /**
f41f0342 67 * Class constructor.
e501603b 68 */
c3fc2621 69 public function __construct() {
e501603b
TO
70 $this->__table = 'civicrm_mailing_event_subscribe';
71 parent::__construct();
72 }
c3fc2621 73
449c4e6b
CW
74 /**
75 * Returns localized title of this entity.
7b66c3b5
AH
76 *
77 * @param bool $plural
78 * Whether to return the plural version of the title.
449c4e6b 79 */
7b66c3b5
AH
80 public static function getEntityTitle($plural = FALSE) {
81 return $plural ? ts('Subscribes') : ts('Subscribe');
449c4e6b
CW
82 }
83
e501603b 84 /**
f41f0342 85 * Returns foreign keys and entity references.
e501603b
TO
86 *
87 * @return array
88 * [CRM_Core_Reference_Interface]
89 */
c3fc2621 90 public static function getReferenceColumns() {
346aaaba 91 if (!isset(Civi::$statics[__CLASS__]['links'])) {
a36434b9 92 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
c3fc2621
CW
93 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'group_id', 'civicrm_group', 'id');
94 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id');
346aaaba 95 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
e501603b 96 }
346aaaba 97 return Civi::$statics[__CLASS__]['links'];
e501603b 98 }
c3fc2621 99
e501603b
TO
100 /**
101 * Returns all the column names of this table
102 *
103 * @return array
104 */
c3fc2621 105 public static function &fields() {
346aaaba 106 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
c3fc2621
CW
107 Civi::$statics[__CLASS__]['fields'] = [
108 'id' => [
e501603b
TO
109 'name' => 'id',
110 'type' => CRM_Utils_Type::T_INT,
c3fc2621
CW
111 'title' => ts('Mailing Subscribe ID'),
112 'required' => TRUE,
a36434b9 113 'where' => 'civicrm_mailing_event_subscribe.id',
522a26c9 114 'table_name' => 'civicrm_mailing_event_subscribe',
115 'entity' => 'Subscribe',
116 'bao' => 'CRM_Mailing_Event_BAO_Subscribe',
6a7e5e5d 117 'localizable' => 0,
a9d0587b 118 'add' => NULL,
c3fc2621
CW
119 ],
120 'group_id' => [
e501603b
TO
121 'name' => 'group_id',
122 'type' => CRM_Utils_Type::T_INT,
c3fc2621 123 'title' => ts('Mailing Subscribe Group'),
215b423e 124 'description' => ts('FK to Group'),
c3fc2621 125 'required' => TRUE,
a36434b9 126 'where' => 'civicrm_mailing_event_subscribe.group_id',
522a26c9 127 'table_name' => 'civicrm_mailing_event_subscribe',
128 'entity' => 'Subscribe',
129 'bao' => 'CRM_Mailing_Event_BAO_Subscribe',
6a7e5e5d 130 'localizable' => 0,
e501603b 131 'FKClassName' => 'CRM_Contact_DAO_Group',
c3fc2621 132 'html' => [
e501603b 133 'type' => 'Select',
c3fc2621
CW
134 ],
135 'pseudoconstant' => [
e501603b
TO
136 'table' => 'civicrm_group',
137 'keyColumn' => 'id',
138 'labelColumn' => 'title',
e6ca0a57 139 ],
a9d0587b 140 'add' => NULL,
c3fc2621
CW
141 ],
142 'contact_id' => [
e501603b
TO
143 'name' => 'contact_id',
144 'type' => CRM_Utils_Type::T_INT,
c3fc2621 145 'title' => ts('Mailing Subscribe Contact'),
215b423e 146 'description' => ts('FK to Contact'),
c3fc2621 147 'required' => TRUE,
a36434b9 148 'where' => 'civicrm_mailing_event_subscribe.contact_id',
522a26c9 149 'table_name' => 'civicrm_mailing_event_subscribe',
150 'entity' => 'Subscribe',
151 'bao' => 'CRM_Mailing_Event_BAO_Subscribe',
6a7e5e5d 152 'localizable' => 0,
e501603b 153 'FKClassName' => 'CRM_Contact_DAO_Contact',
a9d0587b 154 'add' => NULL,
c3fc2621
CW
155 ],
156 'hash' => [
e501603b
TO
157 'name' => 'hash',
158 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 159 'title' => ts('Mailing Subscribe Hash'),
215b423e 160 'description' => ts('Security hash'),
c3fc2621 161 'required' => TRUE,
e501603b
TO
162 'maxlength' => 255,
163 'size' => CRM_Utils_Type::HUGE,
a36434b9 164 'where' => 'civicrm_mailing_event_subscribe.hash',
522a26c9 165 'table_name' => 'civicrm_mailing_event_subscribe',
166 'entity' => 'Subscribe',
167 'bao' => 'CRM_Mailing_Event_BAO_Subscribe',
6a7e5e5d 168 'localizable' => 0,
a9d0587b 169 'add' => NULL,
c3fc2621
CW
170 ],
171 'time_stamp' => [
e501603b 172 'name' => 'time_stamp',
6c2b97b7 173 'type' => CRM_Utils_Type::T_TIMESTAMP,
c3fc2621 174 'title' => ts('Mailing Subscribe Timestamp'),
215b423e 175 'description' => ts('When this subscription event occurred.'),
c3fc2621 176 'required' => TRUE,
a36434b9 177 'where' => 'civicrm_mailing_event_subscribe.time_stamp',
6c2b97b7 178 'default' => 'CURRENT_TIMESTAMP',
522a26c9 179 'table_name' => 'civicrm_mailing_event_subscribe',
180 'entity' => 'Subscribe',
181 'bao' => 'CRM_Mailing_Event_BAO_Subscribe',
6a7e5e5d 182 'localizable' => 0,
a9d0587b 183 'add' => NULL,
c3fc2621
CW
184 ],
185 ];
346aaaba 186 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 187 }
346aaaba 188 return Civi::$statics[__CLASS__]['fields'];
e501603b 189 }
c3fc2621 190
e501603b 191 /**
bd8e0b14 192 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
193 *
194 * @return array
bd8e0b14 195 * Array(string $name => string $uniqueName).
e501603b 196 */
c3fc2621 197 public static function &fieldKeys() {
bd8e0b14
TO
198 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
199 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 200 }
bd8e0b14 201 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 202 }
c3fc2621 203
e501603b
TO
204 /**
205 * Returns the names of this table
206 *
207 * @return string
208 */
c3fc2621 209 public static function getTableName() {
e501603b
TO
210 return self::$_tableName;
211 }
c3fc2621 212
e501603b
TO
213 /**
214 * Returns if this table needs to be logged
215 *
c3fc2621 216 * @return bool
e501603b 217 */
c3fc2621 218 public function getLog() {
e501603b
TO
219 return self::$_log;
220 }
c3fc2621 221
e501603b
TO
222 /**
223 * Returns the list of fields that can be imported
224 *
225 * @param bool $prefix
226 *
227 * @return array
228 */
c3fc2621
CW
229 public static function &import($prefix = FALSE) {
230 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'mailing_event_subscribe', $prefix, []);
60808919 231 return $r;
e501603b 232 }
c3fc2621 233
e501603b
TO
234 /**
235 * Returns the list of fields that can be exported
236 *
237 * @param bool $prefix
238 *
239 * @return array
240 */
c3fc2621
CW
241 public static function &export($prefix = FALSE) {
242 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'mailing_event_subscribe', $prefix, []);
60808919 243 return $r;
e501603b 244 }
c3fc2621 245
e7a6b91a
AS
246 /**
247 * Returns the list of indices
c3fc2621
CW
248 *
249 * @param bool $localize
250 *
251 * @return array
e7a6b91a
AS
252 */
253 public static function indices($localize = TRUE) {
c3fc2621 254 $indices = [];
e7a6b91a
AS
255 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
256 }
c3fc2621 257
e501603b 258}