DAOs with singular/plural options for entity titles
[civicrm-core.git] / CRM / Mailing / DAO / MailingGroup.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Mailing/MailingGroup.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:4ab3dccb8706ec8f03072118ff2e9c12)
10 */
11
12 /**
13 * Database access object for the MailingGroup entity.
14 */
15 class CRM_Mailing_DAO_MailingGroup extends CRM_Core_DAO {
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '';
18
19 /**
20 * Static instance to hold the table name.
21 *
22 * @var string
23 */
24 public static $_tableName = 'civicrm_mailing_group';
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 = FALSE;
32
33 /**
34 * @var int
35 */
36 public $id;
37
38 /**
39 * The ID of a previous mailing to include/exclude recipients.
40 *
41 * @var int
42 */
43 public $mailing_id;
44
45 /**
46 * Are the members of the group included or excluded?.
47 *
48 * @var string
49 */
50 public $group_type;
51
52 /**
53 * Name of table where item being referenced is stored.
54 *
55 * @var string
56 */
57 public $entity_table;
58
59 /**
60 * Foreign key to the referenced item.
61 *
62 * @var int
63 */
64 public $entity_id;
65
66 /**
67 * The filtering search. custom search id or -1 for civicrm api search
68 *
69 * @var int
70 */
71 public $search_id;
72
73 /**
74 * The arguments to be sent to the search function
75 *
76 * @var text
77 */
78 public $search_args;
79
80 /**
81 * Class constructor.
82 */
83 public function __construct() {
84 $this->__table = 'civicrm_mailing_group';
85 parent::__construct();
86 }
87
88 /**
89 * Returns localized title of this entity.
90 *
91 * @param bool $plural
92 * Whether to return the plural version of the title.
93 */
94 public static function getEntityTitle($plural = FALSE) {
95 return $plural ? ts('Mailing Groups') : ts('Mailing Group');
96 }
97
98 /**
99 * Returns foreign keys and entity references.
100 *
101 * @return array
102 * [CRM_Core_Reference_Interface]
103 */
104 public static function getReferenceColumns() {
105 if (!isset(Civi::$statics[__CLASS__]['links'])) {
106 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
107 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'mailing_id', 'civicrm_mailing', 'id');
108 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName(), 'entity_id', NULL, 'id', 'entity_table');
109 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
110 }
111 return Civi::$statics[__CLASS__]['links'];
112 }
113
114 /**
115 * Returns all the column names of this table
116 *
117 * @return array
118 */
119 public static function &fields() {
120 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
121 Civi::$statics[__CLASS__]['fields'] = [
122 'id' => [
123 'name' => 'id',
124 'type' => CRM_Utils_Type::T_INT,
125 'title' => ts('Mailing Group ID'),
126 'required' => TRUE,
127 'where' => 'civicrm_mailing_group.id',
128 'table_name' => 'civicrm_mailing_group',
129 'entity' => 'MailingGroup',
130 'bao' => 'CRM_Mailing_DAO_MailingGroup',
131 'localizable' => 0,
132 'add' => NULL,
133 ],
134 'mailing_id' => [
135 'name' => 'mailing_id',
136 'type' => CRM_Utils_Type::T_INT,
137 'title' => ts('Mailing'),
138 'description' => ts('The ID of a previous mailing to include/exclude recipients.'),
139 'required' => TRUE,
140 'where' => 'civicrm_mailing_group.mailing_id',
141 'table_name' => 'civicrm_mailing_group',
142 'entity' => 'MailingGroup',
143 'bao' => 'CRM_Mailing_DAO_MailingGroup',
144 'localizable' => 0,
145 'FKClassName' => 'CRM_Mailing_DAO_Mailing',
146 'add' => NULL,
147 ],
148 'group_type' => [
149 'name' => 'group_type',
150 'type' => CRM_Utils_Type::T_STRING,
151 'title' => ts('Mailing Group Type'),
152 'description' => ts('Are the members of the group included or excluded?.'),
153 'maxlength' => 8,
154 'size' => CRM_Utils_Type::EIGHT,
155 'where' => 'civicrm_mailing_group.group_type',
156 'table_name' => 'civicrm_mailing_group',
157 'entity' => 'MailingGroup',
158 'bao' => 'CRM_Mailing_DAO_MailingGroup',
159 'localizable' => 0,
160 'html' => [
161 'type' => 'Select',
162 ],
163 'pseudoconstant' => [
164 'callback' => 'CRM_Core_SelectValues::getMailingGroupTypes',
165 ],
166 'add' => NULL,
167 ],
168 'entity_table' => [
169 'name' => 'entity_table',
170 'type' => CRM_Utils_Type::T_STRING,
171 'title' => ts('Mailing Group Entity Table'),
172 'description' => ts('Name of table where item being referenced is stored.'),
173 'required' => TRUE,
174 'maxlength' => 64,
175 'size' => CRM_Utils_Type::BIG,
176 'where' => 'civicrm_mailing_group.entity_table',
177 'table_name' => 'civicrm_mailing_group',
178 'entity' => 'MailingGroup',
179 'bao' => 'CRM_Mailing_DAO_MailingGroup',
180 'localizable' => 0,
181 'pseudoconstant' => [
182 'callback' => 'CRM_Mailing_BAO_Mailing::mailingGroupEntityTables',
183 ],
184 'add' => NULL,
185 ],
186 'entity_id' => [
187 'name' => 'entity_id',
188 'type' => CRM_Utils_Type::T_INT,
189 'title' => ts('Mailing Group Entity'),
190 'description' => ts('Foreign key to the referenced item.'),
191 'required' => TRUE,
192 'where' => 'civicrm_mailing_group.entity_id',
193 'table_name' => 'civicrm_mailing_group',
194 'entity' => 'MailingGroup',
195 'bao' => 'CRM_Mailing_DAO_MailingGroup',
196 'localizable' => 0,
197 'add' => NULL,
198 ],
199 'search_id' => [
200 'name' => 'search_id',
201 'type' => CRM_Utils_Type::T_INT,
202 'title' => ts('Mailing Group Search'),
203 'description' => ts('The filtering search. custom search id or -1 for civicrm api search'),
204 'where' => 'civicrm_mailing_group.search_id',
205 'table_name' => 'civicrm_mailing_group',
206 'entity' => 'MailingGroup',
207 'bao' => 'CRM_Mailing_DAO_MailingGroup',
208 'localizable' => 0,
209 'add' => NULL,
210 ],
211 'search_args' => [
212 'name' => 'search_args',
213 'type' => CRM_Utils_Type::T_TEXT,
214 'title' => ts('Mailing Group Search Arguments'),
215 'description' => ts('The arguments to be sent to the search function'),
216 'where' => 'civicrm_mailing_group.search_args',
217 'table_name' => 'civicrm_mailing_group',
218 'entity' => 'MailingGroup',
219 'bao' => 'CRM_Mailing_DAO_MailingGroup',
220 'localizable' => 0,
221 'add' => NULL,
222 ],
223 ];
224 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
225 }
226 return Civi::$statics[__CLASS__]['fields'];
227 }
228
229 /**
230 * Return a mapping from field-name to the corresponding key (as used in fields()).
231 *
232 * @return array
233 * Array(string $name => string $uniqueName).
234 */
235 public static function &fieldKeys() {
236 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
237 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
238 }
239 return Civi::$statics[__CLASS__]['fieldKeys'];
240 }
241
242 /**
243 * Returns the names of this table
244 *
245 * @return string
246 */
247 public static function getTableName() {
248 return self::$_tableName;
249 }
250
251 /**
252 * Returns if this table needs to be logged
253 *
254 * @return bool
255 */
256 public function getLog() {
257 return self::$_log;
258 }
259
260 /**
261 * Returns the list of fields that can be imported
262 *
263 * @param bool $prefix
264 *
265 * @return array
266 */
267 public static function &import($prefix = FALSE) {
268 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'mailing_group', $prefix, []);
269 return $r;
270 }
271
272 /**
273 * Returns the list of fields that can be exported
274 *
275 * @param bool $prefix
276 *
277 * @return array
278 */
279 public static function &export($prefix = FALSE) {
280 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'mailing_group', $prefix, []);
281 return $r;
282 }
283
284 /**
285 * Returns the list of indices
286 *
287 * @param bool $localize
288 *
289 * @return array
290 */
291 public static function indices($localize = TRUE) {
292 $indices = [];
293 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
294 }
295
296 }