Merge pull request #19606 from civicrm/5.35
[civicrm-core.git] / CRM / Campaign / DAO / CampaignGroup.php
1 <?php
2
3 /**
4 * @package CRM
5 * @copyright CiviCRM LLC https://civicrm.org/licensing
6 *
7 * Generated from xml/schema/CRM/Campaign/CampaignGroup.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
9 * (GenCodeChecksum:6eb5e63424f42236328b3c11428382e6)
10 */
11
12 /**
13 * Database access object for the CampaignGroup entity.
14 */
15 class CRM_Campaign_DAO_CampaignGroup extends CRM_Core_DAO {
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '3.3';
18 const COMPONENT = 'CiviCampaign';
19
20 /**
21 * Static instance to hold the table name.
22 *
23 * @var string
24 */
25 public static $_tableName = 'civicrm_campaign_group';
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 * Campaign Group id.
36 *
37 * @var int
38 */
39 public $id;
40
41 /**
42 * Foreign key to the activity Campaign.
43 *
44 * @var int
45 */
46 public $campaign_id;
47
48 /**
49 * Type of Group.
50 *
51 * @var string
52 */
53 public $group_type;
54
55 /**
56 * Name of table where item being referenced is stored.
57 *
58 * @var string
59 */
60 public $entity_table;
61
62 /**
63 * Entity id of referenced table.
64 *
65 * @var int
66 */
67 public $entity_id;
68
69 /**
70 * Class constructor.
71 */
72 public function __construct() {
73 $this->__table = 'civicrm_campaign_group';
74 parent::__construct();
75 }
76
77 /**
78 * Returns localized title of this entity.
79 *
80 * @param bool $plural
81 * Whether to return the plural version of the title.
82 */
83 public static function getEntityTitle($plural = FALSE) {
84 return $plural ? ts('Campaign Groups') : ts('Campaign Group');
85 }
86
87 /**
88 * Returns foreign keys and entity references.
89 *
90 * @return array
91 * [CRM_Core_Reference_Interface]
92 */
93 public static function getReferenceColumns() {
94 if (!isset(Civi::$statics[__CLASS__]['links'])) {
95 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
96 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'campaign_id', 'civicrm_campaign', 'id');
97 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Dynamic(self::getTableName(), 'entity_id', NULL, 'id', 'entity_table');
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('Campaign Group ID'),
115 'description' => ts('Campaign Group id.'),
116 'required' => TRUE,
117 'where' => 'civicrm_campaign_group.id',
118 'table_name' => 'civicrm_campaign_group',
119 'entity' => 'CampaignGroup',
120 'bao' => 'CRM_Campaign_DAO_CampaignGroup',
121 'localizable' => 0,
122 'html' => [
123 'type' => 'Number',
124 ],
125 'add' => '3.3',
126 ],
127 'campaign_id' => [
128 'name' => 'campaign_id',
129 'type' => CRM_Utils_Type::T_INT,
130 'title' => ts('Campaign ID'),
131 'description' => ts('Foreign key to the activity Campaign.'),
132 'required' => TRUE,
133 'where' => 'civicrm_campaign_group.campaign_id',
134 'table_name' => 'civicrm_campaign_group',
135 'entity' => 'CampaignGroup',
136 'bao' => 'CRM_Campaign_DAO_CampaignGroup',
137 'localizable' => 0,
138 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
139 'html' => [
140 'label' => ts("Campaign"),
141 ],
142 'add' => '3.3',
143 ],
144 'group_type' => [
145 'name' => 'group_type',
146 'type' => CRM_Utils_Type::T_STRING,
147 'title' => ts('Campaign Group Type'),
148 'description' => ts('Type of Group.'),
149 'maxlength' => 8,
150 'size' => CRM_Utils_Type::EIGHT,
151 'where' => 'civicrm_campaign_group.group_type',
152 'default' => 'NULL',
153 'table_name' => 'civicrm_campaign_group',
154 'entity' => 'CampaignGroup',
155 'bao' => 'CRM_Campaign_DAO_CampaignGroup',
156 'localizable' => 0,
157 'html' => [
158 'type' => 'Select',
159 ],
160 'pseudoconstant' => [
161 'callback' => 'CRM_Core_SelectValues::getCampaignGroupTypes',
162 ],
163 'add' => NULL,
164 ],
165 'entity_table' => [
166 'name' => 'entity_table',
167 'type' => CRM_Utils_Type::T_STRING,
168 'title' => ts('Entity Table'),
169 'description' => ts('Name of table where item being referenced is stored.'),
170 'maxlength' => 64,
171 'size' => CRM_Utils_Type::BIG,
172 'where' => 'civicrm_campaign_group.entity_table',
173 'default' => 'NULL',
174 'table_name' => 'civicrm_campaign_group',
175 'entity' => 'CampaignGroup',
176 'bao' => 'CRM_Campaign_DAO_CampaignGroup',
177 'localizable' => 0,
178 'add' => '3.3',
179 ],
180 'entity_id' => [
181 'name' => 'entity_id',
182 'type' => CRM_Utils_Type::T_INT,
183 'title' => ts('Entity ID'),
184 'description' => ts('Entity id of referenced table.'),
185 'where' => 'civicrm_campaign_group.entity_id',
186 'default' => 'NULL',
187 'table_name' => 'civicrm_campaign_group',
188 'entity' => 'CampaignGroup',
189 'bao' => 'CRM_Campaign_DAO_CampaignGroup',
190 'localizable' => 0,
191 'add' => '3.3',
192 ],
193 ];
194 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
195 }
196 return Civi::$statics[__CLASS__]['fields'];
197 }
198
199 /**
200 * Return a mapping from field-name to the corresponding key (as used in fields()).
201 *
202 * @return array
203 * Array(string $name => string $uniqueName).
204 */
205 public static function &fieldKeys() {
206 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
207 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
208 }
209 return Civi::$statics[__CLASS__]['fieldKeys'];
210 }
211
212 /**
213 * Returns the names of this table
214 *
215 * @return string
216 */
217 public static function getTableName() {
218 return self::$_tableName;
219 }
220
221 /**
222 * Returns if this table needs to be logged
223 *
224 * @return bool
225 */
226 public function getLog() {
227 return self::$_log;
228 }
229
230 /**
231 * Returns the list of fields that can be imported
232 *
233 * @param bool $prefix
234 *
235 * @return array
236 */
237 public static function &import($prefix = FALSE) {
238 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'campaign_group', $prefix, []);
239 return $r;
240 }
241
242 /**
243 * Returns the list of fields that can be exported
244 *
245 * @param bool $prefix
246 *
247 * @return array
248 */
249 public static function &export($prefix = FALSE) {
250 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'campaign_group', $prefix, []);
251 return $r;
252 }
253
254 /**
255 * Returns the list of indices
256 *
257 * @param bool $localize
258 *
259 * @return array
260 */
261 public static function indices($localize = TRUE) {
262 $indices = [];
263 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
264 }
265
266 }