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