Merge pull request #21453 from eileenmcnaughton/member_tokens
[civicrm-core.git] / CRM / Mailing / DAO / Recipients.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Mailing/Recipients.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:b3c4d09f9c6afa1f96dc0d1cdbaec935)
10 */
11
12 /**
13 * Database access object for the Recipients entity.
14 */
15 class CRM_Mailing_DAO_Recipients extends CRM_Core_DAO {
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '';
18 const COMPONENT = 'CiviMail';
19
20 /**
21 * Static instance to hold the table name.
22 *
23 * @var string
24 */
25 public static $_tableName = 'civicrm_mailing_recipients';
26
27 /**
28 * Should CiviCRM log any modifications to this table in the civicrm_log table.
29 *
30 * @var bool
31 */
32 public static $_log = FALSE;
33
34 /**
35 * @var int
36 */
37 public $id;
38
39 /**
40 * The ID of the mailing this Job will send.
41 *
42 * @var int
43 */
44 public $mailing_id;
45
46 /**
47 * FK to Contact
48 *
49 * @var int
50 */
51 public $contact_id;
52
53 /**
54 * FK to Email
55 *
56 * @var int
57 */
58 public $email_id;
59
60 /**
61 * FK to Phone
62 *
63 * @var int
64 */
65 public $phone_id;
66
67 /**
68 * Class constructor.
69 */
70 public function __construct() {
71 $this->__table = 'civicrm_mailing_recipients';
72 parent::__construct();
73 }
74
75 /**
76 * Returns localized title of this entity.
77 *
78 * @param bool $plural
79 * Whether to return the plural version of the title.
80 */
81 public static function getEntityTitle($plural = FALSE) {
82 return $plural ? ts('Recipients') : ts('Recipient');
83 }
84
85 /**
86 * Returns foreign keys and entity references.
87 *
88 * @return array
89 * [CRM_Core_Reference_Interface]
90 */
91 public static function getReferenceColumns() {
92 if (!isset(Civi::$statics[__CLASS__]['links'])) {
93 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
94 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'mailing_id', 'civicrm_mailing', 'id');
95 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id');
96 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'email_id', 'civicrm_email', 'id');
97 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'phone_id', 'civicrm_phone', 'id');
98 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
99 }
100 return Civi::$statics[__CLASS__]['links'];
101 }
102
103 /**
104 * Returns all the column names of this table
105 *
106 * @return array
107 */
108 public static function &fields() {
109 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
110 Civi::$statics[__CLASS__]['fields'] = [
111 'id' => [
112 'name' => 'id',
113 'type' => CRM_Utils_Type::T_INT,
114 'title' => ts('Mailing Recipients ID'),
115 'required' => TRUE,
116 'where' => 'civicrm_mailing_recipients.id',
117 'table_name' => 'civicrm_mailing_recipients',
118 'entity' => 'Recipients',
119 'bao' => 'CRM_Mailing_BAO_Recipients',
120 'localizable' => 0,
121 'html' => [
122 'type' => 'Number',
123 ],
124 'readonly' => TRUE,
125 'add' => NULL,
126 ],
127 'mailing_id' => [
128 'name' => 'mailing_id',
129 'type' => CRM_Utils_Type::T_INT,
130 'title' => ts('Mailing ID'),
131 'description' => ts('The ID of the mailing this Job will send.'),
132 'required' => TRUE,
133 'where' => 'civicrm_mailing_recipients.mailing_id',
134 'table_name' => 'civicrm_mailing_recipients',
135 'entity' => 'Recipients',
136 'bao' => 'CRM_Mailing_BAO_Recipients',
137 'localizable' => 0,
138 'FKClassName' => 'CRM_Mailing_DAO_Mailing',
139 'html' => [
140 'label' => ts("Mailing"),
141 ],
142 'add' => NULL,
143 ],
144 'contact_id' => [
145 'name' => 'contact_id',
146 'type' => CRM_Utils_Type::T_INT,
147 'title' => ts('Recipient ID'),
148 'description' => ts('FK to Contact'),
149 'required' => TRUE,
150 'where' => 'civicrm_mailing_recipients.contact_id',
151 'table_name' => 'civicrm_mailing_recipients',
152 'entity' => 'Recipients',
153 'bao' => 'CRM_Mailing_BAO_Recipients',
154 'localizable' => 0,
155 'FKClassName' => 'CRM_Contact_DAO_Contact',
156 'html' => [
157 'label' => ts("Recipient"),
158 ],
159 'add' => NULL,
160 ],
161 'email_id' => [
162 'name' => 'email_id',
163 'type' => CRM_Utils_Type::T_INT,
164 'title' => ts('Email ID'),
165 'description' => ts('FK to Email'),
166 'where' => 'civicrm_mailing_recipients.email_id',
167 'default' => 'NULL',
168 'table_name' => 'civicrm_mailing_recipients',
169 'entity' => 'Recipients',
170 'bao' => 'CRM_Mailing_BAO_Recipients',
171 'localizable' => 0,
172 'FKClassName' => 'CRM_Core_DAO_Email',
173 'html' => [
174 'label' => ts("Email"),
175 ],
176 'add' => NULL,
177 ],
178 'phone_id' => [
179 'name' => 'phone_id',
180 'type' => CRM_Utils_Type::T_INT,
181 'title' => ts('Phone ID'),
182 'description' => ts('FK to Phone'),
183 'where' => 'civicrm_mailing_recipients.phone_id',
184 'default' => 'NULL',
185 'table_name' => 'civicrm_mailing_recipients',
186 'entity' => 'Recipients',
187 'bao' => 'CRM_Mailing_BAO_Recipients',
188 'localizable' => 0,
189 'FKClassName' => 'CRM_Core_DAO_Phone',
190 'html' => [
191 'label' => ts("Phone"),
192 ],
193 'add' => NULL,
194 ],
195 ];
196 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
197 }
198 return Civi::$statics[__CLASS__]['fields'];
199 }
200
201 /**
202 * Return a mapping from field-name to the corresponding key (as used in fields()).
203 *
204 * @return array
205 * Array(string $name => string $uniqueName).
206 */
207 public static function &fieldKeys() {
208 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
209 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
210 }
211 return Civi::$statics[__CLASS__]['fieldKeys'];
212 }
213
214 /**
215 * Returns the names of this table
216 *
217 * @return string
218 */
219 public static function getTableName() {
220 return self::$_tableName;
221 }
222
223 /**
224 * Returns if this table needs to be logged
225 *
226 * @return bool
227 */
228 public function getLog() {
229 return self::$_log;
230 }
231
232 /**
233 * Returns the list of fields that can be imported
234 *
235 * @param bool $prefix
236 *
237 * @return array
238 */
239 public static function &import($prefix = FALSE) {
240 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'mailing_recipients', $prefix, []);
241 return $r;
242 }
243
244 /**
245 * Returns the list of fields that can be exported
246 *
247 * @param bool $prefix
248 *
249 * @return array
250 */
251 public static function &export($prefix = FALSE) {
252 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'mailing_recipients', $prefix, []);
253 return $r;
254 }
255
256 /**
257 * Returns the list of indices
258 *
259 * @param bool $localize
260 *
261 * @return array
262 */
263 public static function indices($localize = TRUE) {
264 $indices = [];
265 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
266 }
267
268 }