Merge pull request #20845 from herbdool/issue-899
[civicrm-core.git] / CRM / Member / DAO / Membership.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/Member/Membership.xml
8 * DO NOT EDIT. Generated by CRM_Core_CodeGen
28979d65 9 * (GenCodeChecksum:0619aa3946bcadcab1919672c9ecf35a)
e501603b 10 */
c3fc2621 11
f41f0342 12/**
c3fc2621 13 * Database access object for the Membership entity.
f41f0342 14 */
e501603b 15class CRM_Member_DAO_Membership extends CRM_Core_DAO {
929a1c14
CW
16 const EXT = 'civicrm';
17 const TABLE_ADDED = '1.5';
d31fb4e3 18 const COMPONENT = 'CiviMember';
c3fc2621 19
e501603b 20 /**
f41f0342 21 * Static instance to hold the table name.
e501603b
TO
22 *
23 * @var string
24 */
fa45b5b9 25 public static $_tableName = 'civicrm_membership';
c3fc2621 26
449c4e6b
CW
27 /**
28 * Icon associated with this entity.
29 *
30 * @var string
31 */
32 public static $_icon = 'fa-id-badge';
33
e501603b 34 /**
f41f0342 35 * Should CiviCRM log any modifications to this table in the civicrm_log table.
e501603b 36 *
c3fc2621 37 * @var bool
e501603b 38 */
fa45b5b9 39 public static $_log = TRUE;
c3fc2621 40
a7bd99ff
CW
41 /**
42 * Paths for accessing this entity in the UI.
43 *
44 * @var string[]
45 */
46 protected static $_paths = [
5c385299 47 'add' => 'civicrm/member/add?reset=1&action=add&context=standalone',
a7bd99ff 48 'view' => 'civicrm/contact/view/membership?reset=1&action=view&id=[id]&cid=[contact_id]',
5c385299 49 'update' => 'civicrm/contact/view/membership?reset=1&action=update&id=[id]&cid=[contact_id]',
a7bd99ff
CW
50 'delete' => 'civicrm/contact/view/membership?reset=1&action=delete&id=[id]&cid=[contact_id]',
51 ];
52
e501603b 53 /**
2cbbebe8 54 * Membership ID
e501603b 55 *
28979d65
CW
56 * @var int|string|null
57 * (SQL type: int unsigned)
58 * Note that values will be retrieved from the database as a string.
e501603b
TO
59 */
60 public $id;
c3fc2621 61
e501603b
TO
62 /**
63 * FK to Contact ID
64 *
28979d65
CW
65 * @var int|string
66 * (SQL type: int unsigned)
67 * Note that values will be retrieved from the database as a string.
e501603b
TO
68 */
69 public $contact_id;
c3fc2621 70
e501603b
TO
71 /**
72 * FK to Membership Type
73 *
28979d65
CW
74 * @var int|string
75 * (SQL type: int unsigned)
76 * Note that values will be retrieved from the database as a string.
e501603b
TO
77 */
78 public $membership_type_id;
c3fc2621 79
e501603b
TO
80 /**
81 * Beginning of initial membership period (member since...).
82 *
28979d65
CW
83 * @var string|null
84 * (SQL type: date)
85 * Note that values will be retrieved from the database as a string.
e501603b
TO
86 */
87 public $join_date;
c3fc2621 88
e501603b
TO
89 /**
90 * Beginning of current uninterrupted membership period.
91 *
28979d65
CW
92 * @var string|null
93 * (SQL type: date)
94 * Note that values will be retrieved from the database as a string.
e501603b
TO
95 */
96 public $start_date;
c3fc2621 97
e501603b
TO
98 /**
99 * Current membership period expire date.
100 *
28979d65
CW
101 * @var string|null
102 * (SQL type: date)
103 * Note that values will be retrieved from the database as a string.
e501603b
TO
104 */
105 public $end_date;
c3fc2621 106
e501603b 107 /**
28979d65
CW
108 * @var string|null
109 * (SQL type: varchar(128))
110 * Note that values will be retrieved from the database as a string.
e501603b
TO
111 */
112 public $source;
c3fc2621 113
e501603b
TO
114 /**
115 * FK to Membership Status
116 *
28979d65
CW
117 * @var int|string
118 * (SQL type: int unsigned)
119 * Note that values will be retrieved from the database as a string.
e501603b
TO
120 */
121 public $status_id;
c3fc2621 122
e501603b
TO
123 /**
124 * Admin users may set a manual status which overrides the calculated status. When this flag is true, automated status update scripts should NOT modify status for the record.
125 *
28979d65
CW
126 * @var bool|string|null
127 * (SQL type: tinyint)
128 * Note that values will be retrieved from the database as a string.
e501603b
TO
129 */
130 public $is_override;
c3fc2621 131
e136f704
O
132 /**
133 * Then end date of membership status override if 'Override until selected date' override type is selected.
134 *
28979d65
CW
135 * @var string|null
136 * (SQL type: date)
137 * Note that values will be retrieved from the database as a string.
e136f704
O
138 */
139 public $status_override_end_date;
140
e501603b
TO
141 /**
142 * Optional FK to Parent Membership.
143 *
28979d65
CW
144 * @var int|string|null
145 * (SQL type: int unsigned)
146 * Note that values will be retrieved from the database as a string.
e501603b
TO
147 */
148 public $owner_membership_id;
c3fc2621 149
e501603b
TO
150 /**
151 * Maximum number of related memberships (membership_type override).
152 *
28979d65
CW
153 * @var int|string|null
154 * (SQL type: int)
155 * Note that values will be retrieved from the database as a string.
e501603b
TO
156 */
157 public $max_related;
c3fc2621 158
e501603b 159 /**
28979d65
CW
160 * @var bool|string|null
161 * (SQL type: tinyint)
162 * Note that values will be retrieved from the database as a string.
e501603b
TO
163 */
164 public $is_test;
c3fc2621 165
e501603b 166 /**
28979d65
CW
167 * @var bool|string|null
168 * (SQL type: tinyint)
169 * Note that values will be retrieved from the database as a string.
e501603b
TO
170 */
171 public $is_pay_later;
c3fc2621 172
e501603b
TO
173 /**
174 * Conditional foreign key to civicrm_contribution_recur id. Each membership in connection with a recurring contribution carries a foreign key to the recurring contribution record. This assumes we can track these processor initiated events.
175 *
28979d65
CW
176 * @var int|string|null
177 * (SQL type: int unsigned)
178 * Note that values will be retrieved from the database as a string.
e501603b
TO
179 */
180 public $contribution_recur_id;
c3fc2621 181
e501603b
TO
182 /**
183 * The campaign for which this membership is attached.
184 *
28979d65
CW
185 * @var int|string|null
186 * (SQL type: int unsigned)
187 * Note that values will be retrieved from the database as a string.
e501603b
TO
188 */
189 public $campaign_id;
c3fc2621 190
e501603b 191 /**
f41f0342 192 * Class constructor.
e501603b 193 */
c3fc2621 194 public function __construct() {
e501603b
TO
195 $this->__table = 'civicrm_membership';
196 parent::__construct();
197 }
c3fc2621 198
449c4e6b
CW
199 /**
200 * Returns localized title of this entity.
7b66c3b5
AH
201 *
202 * @param bool $plural
203 * Whether to return the plural version of the title.
449c4e6b 204 */
7b66c3b5
AH
205 public static function getEntityTitle($plural = FALSE) {
206 return $plural ? ts('Memberships') : ts('Membership');
449c4e6b
CW
207 }
208
2562d09a
CW
209 /**
210 * Returns user-friendly description of this entity.
211 *
212 * @return string
213 */
214 public static function getEntityDescription() {
215 return ts('Records of contacts belonging to an organization\'s membership program.');
216 }
217
e501603b 218 /**
f41f0342 219 * Returns foreign keys and entity references.
e501603b
TO
220 *
221 * @return array
222 * [CRM_Core_Reference_Interface]
223 */
c3fc2621 224 public static function getReferenceColumns() {
346aaaba 225 if (!isset(Civi::$statics[__CLASS__]['links'])) {
fa45b5b9 226 Civi::$statics[__CLASS__]['links'] = static::createReferenceColumns(__CLASS__);
c3fc2621
CW
227 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contact_id', 'civicrm_contact', 'id');
228 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'membership_type_id', 'civicrm_membership_type', 'id');
229 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'status_id', 'civicrm_membership_status', 'id');
230 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'owner_membership_id', 'civicrm_membership', 'id');
231 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'contribution_recur_id', 'civicrm_contribution_recur', 'id');
232 Civi::$statics[__CLASS__]['links'][] = new CRM_Core_Reference_Basic(self::getTableName(), 'campaign_id', 'civicrm_campaign', 'id');
346aaaba 233 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'links_callback', Civi::$statics[__CLASS__]['links']);
e501603b 234 }
346aaaba 235 return Civi::$statics[__CLASS__]['links'];
e501603b 236 }
c3fc2621 237
e501603b
TO
238 /**
239 * Returns all the column names of this table
240 *
241 * @return array
242 */
c3fc2621 243 public static function &fields() {
346aaaba 244 if (!isset(Civi::$statics[__CLASS__]['fields'])) {
c3fc2621
CW
245 Civi::$statics[__CLASS__]['fields'] = [
246 'membership_id' => [
e501603b
TO
247 'name' => 'id',
248 'type' => CRM_Utils_Type::T_INT,
c3fc2621 249 'title' => ts('Membership ID'),
2cbbebe8 250 'description' => ts('Membership ID'),
c3fc2621
CW
251 'required' => TRUE,
252 'import' => TRUE,
e501603b
TO
253 'where' => 'civicrm_membership.id',
254 'headerPattern' => '/^(m(embership\s)?id)$/i',
c3fc2621 255 'export' => TRUE,
522a26c9 256 'table_name' => 'civicrm_membership',
257 'entity' => 'Membership',
258 'bao' => 'CRM_Member_BAO_Membership',
6a7e5e5d 259 'localizable' => 0,
2cbbebe8
A
260 'html' => [
261 'type' => 'Number',
262 ],
1fe423d6 263 'readonly' => TRUE,
a9d0587b 264 'add' => '1.5',
c3fc2621
CW
265 ],
266 'membership_contact_id' => [
e501603b
TO
267 'name' => 'contact_id',
268 'type' => CRM_Utils_Type::T_INT,
c3fc2621 269 'title' => ts('Contact ID'),
215b423e 270 'description' => ts('FK to Contact ID'),
c3fc2621
CW
271 'required' => TRUE,
272 'import' => TRUE,
e501603b
TO
273 'where' => 'civicrm_membership.contact_id',
274 'headerPattern' => '/contact(.?id)?/i',
275 'dataPattern' => '/^\d+$/',
c3fc2621 276 'export' => TRUE,
522a26c9 277 'table_name' => 'civicrm_membership',
278 'entity' => 'Membership',
279 'bao' => 'CRM_Member_BAO_Membership',
6a7e5e5d 280 'localizable' => 0,
e501603b 281 'FKClassName' => 'CRM_Contact_DAO_Contact',
c3fc2621 282 'html' => [
e501603b 283 'type' => 'EntityRef',
2cbbebe8 284 'label' => ts("Contact"),
c3fc2621 285 ],
a9d0587b 286 'add' => '1.5',
c3fc2621
CW
287 ],
288 'membership_type_id' => [
e501603b
TO
289 'name' => 'membership_type_id',
290 'type' => CRM_Utils_Type::T_INT,
2cbbebe8 291 'title' => ts('Membership Type ID'),
215b423e 292 'description' => ts('FK to Membership Type'),
c3fc2621
CW
293 'required' => TRUE,
294 'import' => TRUE,
e501603b
TO
295 'where' => 'civicrm_membership.membership_type_id',
296 'headerPattern' => '/^(m(embership\s)?type)$/i',
c3fc2621 297 'export' => FALSE,
522a26c9 298 'table_name' => 'civicrm_membership',
299 'entity' => 'Membership',
300 'bao' => 'CRM_Member_BAO_Membership',
6a7e5e5d 301 'localizable' => 0,
e501603b 302 'FKClassName' => 'CRM_Member_DAO_MembershipType',
c3fc2621 303 'html' => [
e501603b 304 'type' => 'Select',
03ee227b 305 'label' => ts("Membership Type"),
c3fc2621
CW
306 ],
307 'pseudoconstant' => [
e501603b
TO
308 'table' => 'civicrm_membership_type',
309 'keyColumn' => 'id',
310 'labelColumn' => 'name',
e6ca0a57 311 ],
a9d0587b 312 'add' => '1.5',
c3fc2621 313 ],
09ba1975 314 'membership_join_date' => [
e501603b
TO
315 'name' => 'join_date',
316 'type' => CRM_Utils_Type::T_DATE,
c3fc2621 317 'title' => ts('Member Since'),
215b423e 318 'description' => ts('Beginning of initial membership period (member since...).'),
c3fc2621 319 'import' => TRUE,
e501603b
TO
320 'where' => 'civicrm_membership.join_date',
321 'headerPattern' => '/^join|(j(oin\s)?date)$/i',
322 'dataPattern' => '/\d{4}-?\d{2}-?\d{2}/',
c3fc2621 323 'export' => TRUE,
522a26c9 324 'table_name' => 'civicrm_membership',
325 'entity' => 'Membership',
326 'bao' => 'CRM_Member_BAO_Membership',
6a7e5e5d 327 'localizable' => 0,
c3fc2621 328 'html' => [
e501603b 329 'type' => 'Select Date',
24317d89 330 'formatType' => 'activityDate',
c3fc2621 331 ],
a9d0587b 332 'add' => '1.5',
c3fc2621
CW
333 ],
334 'membership_start_date' => [
e501603b
TO
335 'name' => 'start_date',
336 'type' => CRM_Utils_Type::T_DATE,
c3fc2621 337 'title' => ts('Membership Start Date'),
215b423e 338 'description' => ts('Beginning of current uninterrupted membership period.'),
c3fc2621 339 'import' => TRUE,
e501603b
TO
340 'where' => 'civicrm_membership.start_date',
341 'headerPattern' => '/(member(ship)?.)?start(s)?(.date$)?/i',
342 'dataPattern' => '/\d{4}-?\d{2}-?\d{2}/',
c3fc2621 343 'export' => TRUE,
522a26c9 344 'table_name' => 'civicrm_membership',
345 'entity' => 'Membership',
346 'bao' => 'CRM_Member_BAO_Membership',
6a7e5e5d 347 'localizable' => 0,
c3fc2621 348 'html' => [
e501603b 349 'type' => 'Select Date',
24317d89 350 'formatType' => 'activityDate',
c3fc2621 351 ],
a9d0587b 352 'add' => '1.5',
c3fc2621
CW
353 ],
354 'membership_end_date' => [
e501603b
TO
355 'name' => 'end_date',
356 'type' => CRM_Utils_Type::T_DATE,
c3fc2621 357 'title' => ts('Membership Expiration Date'),
215b423e 358 'description' => ts('Current membership period expire date.'),
c3fc2621 359 'import' => TRUE,
e501603b
TO
360 'where' => 'civicrm_membership.end_date',
361 'headerPattern' => '/(member(ship)?.)?end(s)?(.date$)?/i',
362 'dataPattern' => '/\d{4}-?\d{2}-?\d{2}/',
c3fc2621 363 'export' => TRUE,
522a26c9 364 'table_name' => 'civicrm_membership',
365 'entity' => 'Membership',
366 'bao' => 'CRM_Member_BAO_Membership',
6a7e5e5d 367 'localizable' => 0,
c3fc2621 368 'html' => [
e501603b 369 'type' => 'Select Date',
24317d89 370 'formatType' => 'activityDate',
c3fc2621 371 ],
a9d0587b 372 'add' => '1.5',
c3fc2621
CW
373 ],
374 'membership_source' => [
e501603b
TO
375 'name' => 'source',
376 'type' => CRM_Utils_Type::T_STRING,
c3fc2621 377 'title' => ts('Source'),
e501603b
TO
378 'maxlength' => 128,
379 'size' => CRM_Utils_Type::HUGE,
c3fc2621 380 'import' => TRUE,
e501603b
TO
381 'where' => 'civicrm_membership.source',
382 'headerPattern' => '/^(member(ship?))?source$/i',
c3fc2621 383 'export' => TRUE,
522a26c9 384 'table_name' => 'civicrm_membership',
385 'entity' => 'Membership',
386 'bao' => 'CRM_Member_BAO_Membership',
6a7e5e5d 387 'localizable' => 0,
c3fc2621 388 'html' => [
e501603b 389 'type' => 'Text',
c3fc2621 390 ],
a9d0587b 391 'add' => '1.5',
c3fc2621
CW
392 ],
393 'status_id' => [
e501603b
TO
394 'name' => 'status_id',
395 'type' => CRM_Utils_Type::T_INT,
2cbbebe8 396 'title' => ts('Status ID'),
215b423e 397 'description' => ts('FK to Membership Status'),
c3fc2621
CW
398 'required' => TRUE,
399 'import' => TRUE,
e501603b
TO
400 'where' => 'civicrm_membership.status_id',
401 'headerPattern' => '/(member(ship|).)?(status)$/i',
c3fc2621 402 'export' => FALSE,
522a26c9 403 'table_name' => 'civicrm_membership',
404 'entity' => 'Membership',
405 'bao' => 'CRM_Member_BAO_Membership',
6a7e5e5d 406 'localizable' => 0,
e501603b 407 'FKClassName' => 'CRM_Member_DAO_MembershipStatus',
c3fc2621 408 'html' => [
e501603b 409 'type' => 'Select',
2cbbebe8 410 'label' => ts("Status"),
c3fc2621
CW
411 ],
412 'pseudoconstant' => [
e501603b
TO
413 'table' => 'civicrm_membership_status',
414 'keyColumn' => 'id',
415 'labelColumn' => 'label',
e6ca0a57 416 ],
a9d0587b 417 'add' => '1.5',
c3fc2621 418 ],
8f67d99a 419 'member_is_override' => [
e501603b
TO
420 'name' => 'is_override',
421 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621 422 'title' => ts('Status Override'),
215b423e 423 'description' => ts('Admin users may set a manual status which overrides the calculated status. When this flag is true, automated status update scripts should NOT modify status for the record.'),
c3fc2621 424 'import' => TRUE,
e501603b
TO
425 'where' => 'civicrm_membership.is_override',
426 'headerPattern' => '/override$/i',
c3fc2621 427 'export' => TRUE,
522a26c9 428 'table_name' => 'civicrm_membership',
429 'entity' => 'Membership',
430 'bao' => 'CRM_Member_BAO_Membership',
6a7e5e5d 431 'localizable' => 0,
c3fc2621 432 'html' => [
e501603b 433 'type' => 'CheckBox',
c3fc2621 434 ],
a9d0587b 435 'add' => '1.5',
c3fc2621 436 ],
e136f704
O
437 'status_override_end_date' => [
438 'name' => 'status_override_end_date',
439 'type' => CRM_Utils_Type::T_DATE,
440 'title' => ts('Status Override End Date'),
215b423e 441 'description' => ts('Then end date of membership status override if \'Override until selected date\' override type is selected.'),
e136f704
O
442 'import' => TRUE,
443 'where' => 'civicrm_membership.status_override_end_date',
e136f704 444 'export' => TRUE,
5fb0de1f 445 'default' => NULL,
e136f704
O
446 'table_name' => 'civicrm_membership',
447 'entity' => 'Membership',
448 'bao' => 'CRM_Member_BAO_Membership',
449 'localizable' => 0,
450 'html' => [
451 'type' => 'Select Date',
efcda6b9 452 'formatType' => 'activityDate',
e136f704 453 ],
a9d0587b 454 'add' => '4.7',
e136f704 455 ],
c3fc2621 456 'owner_membership_id' => [
e501603b
TO
457 'name' => 'owner_membership_id',
458 'type' => CRM_Utils_Type::T_INT,
c3fc2621 459 'title' => ts('Primary Member ID'),
215b423e 460 'description' => ts('Optional FK to Parent Membership.'),
e501603b 461 'where' => 'civicrm_membership.owner_membership_id',
a36434b9 462 'export' => TRUE,
522a26c9 463 'table_name' => 'civicrm_membership',
464 'entity' => 'Membership',
465 'bao' => 'CRM_Member_BAO_Membership',
6a7e5e5d 466 'localizable' => 0,
e501603b 467 'FKClassName' => 'CRM_Member_DAO_Membership',
2cbbebe8
A
468 'html' => [
469 'label' => ts("Primary Member"),
470 ],
a9d0587b 471 'add' => '1.7',
c3fc2621
CW
472 ],
473 'max_related' => [
e501603b
TO
474 'name' => 'max_related',
475 'type' => CRM_Utils_Type::T_INT,
c3fc2621 476 'title' => ts('Max Related'),
215b423e 477 'description' => ts('Maximum number of related memberships (membership_type override).'),
a36434b9 478 'where' => 'civicrm_membership.max_related',
8f67d99a 479 'export' => TRUE,
522a26c9 480 'table_name' => 'civicrm_membership',
481 'entity' => 'Membership',
482 'bao' => 'CRM_Member_BAO_Membership',
6a7e5e5d 483 'localizable' => 0,
c3fc2621 484 'html' => [
e501603b 485 'type' => 'Text',
c23563e3 486 'label' => ts("Maximum number of related memberships"),
c3fc2621 487 ],
a9d0587b 488 'add' => '4.3',
c3fc2621
CW
489 ],
490 'member_is_test' => [
e501603b
TO
491 'name' => 'is_test',
492 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621
CW
493 'title' => ts('Test'),
494 'import' => TRUE,
e501603b
TO
495 'where' => 'civicrm_membership.is_test',
496 'headerPattern' => '/(is.)?test(.member(ship)?)?/i',
c3fc2621 497 'export' => TRUE,
45a83e42 498 'default' => '0',
522a26c9 499 'table_name' => 'civicrm_membership',
500 'entity' => 'Membership',
501 'bao' => 'CRM_Member_BAO_Membership',
6a7e5e5d 502 'localizable' => 0,
c3fc2621 503 'html' => [
e501603b 504 'type' => 'CheckBox',
c3fc2621 505 ],
a9d0587b 506 'add' => NULL,
c3fc2621
CW
507 ],
508 'member_is_pay_later' => [
e501603b
TO
509 'name' => 'is_pay_later',
510 'type' => CRM_Utils_Type::T_BOOLEAN,
c3fc2621
CW
511 'title' => ts('Is Pay Later'),
512 'import' => TRUE,
e501603b
TO
513 'where' => 'civicrm_membership.is_pay_later',
514 'headerPattern' => '/(is.)?(pay(.)?later)$/i',
c3fc2621 515 'export' => TRUE,
45a83e42 516 'default' => '0',
522a26c9 517 'table_name' => 'civicrm_membership',
518 'entity' => 'Membership',
519 'bao' => 'CRM_Member_BAO_Membership',
6a7e5e5d 520 'localizable' => 0,
c3fc2621 521 'html' => [
e501603b 522 'type' => 'CheckBox',
c3fc2621 523 ],
a9d0587b 524 'add' => '2.1',
c3fc2621 525 ],
8f67d99a 526 'membership_recur_id' => [
e501603b
TO
527 'name' => 'contribution_recur_id',
528 'type' => CRM_Utils_Type::T_INT,
2cbbebe8 529 'title' => ts('Recurring Contribution ID'),
215b423e 530 'description' => ts('Conditional foreign key to civicrm_contribution_recur id. Each membership in connection with a recurring contribution carries a foreign key to the recurring contribution record. This assumes we can track these processor initiated events.'),
a36434b9 531 'where' => 'civicrm_membership.contribution_recur_id',
8f67d99a 532 'export' => TRUE,
522a26c9 533 'table_name' => 'civicrm_membership',
534 'entity' => 'Membership',
535 'bao' => 'CRM_Member_BAO_Membership',
6a7e5e5d 536 'localizable' => 0,
e501603b 537 'FKClassName' => 'CRM_Contribute_DAO_ContributionRecur',
2cbbebe8
A
538 'html' => [
539 'label' => ts("Recurring Contribution"),
540 ],
a9d0587b 541 'add' => '3.3',
c3fc2621
CW
542 ],
543 'member_campaign_id' => [
e501603b
TO
544 'name' => 'campaign_id',
545 'type' => CRM_Utils_Type::T_INT,
2cbbebe8 546 'title' => ts('Campaign ID'),
215b423e 547 'description' => ts('The campaign for which this membership is attached.'),
c3fc2621 548 'import' => TRUE,
e501603b 549 'where' => 'civicrm_membership.campaign_id',
c3fc2621 550 'export' => TRUE,
522a26c9 551 'table_name' => 'civicrm_membership',
552 'entity' => 'Membership',
553 'bao' => 'CRM_Member_BAO_Membership',
6a7e5e5d 554 'localizable' => 0,
e501603b 555 'FKClassName' => 'CRM_Campaign_DAO_Campaign',
88c31c05 556 'component' => 'CiviCampaign',
c3fc2621 557 'html' => [
8813f972 558 'type' => 'EntityRef',
2cbbebe8 559 'label' => ts("Campaign"),
c3fc2621 560 ],
25ad69f2
CW
561 'pseudoconstant' => [
562 'table' => 'civicrm_campaign',
563 'keyColumn' => 'id',
564 'labelColumn' => 'title',
565 'prefetch' => 'FALSE',
566 ],
a9d0587b 567 'add' => '3.4',
c3fc2621
CW
568 ],
569 ];
346aaaba 570 CRM_Core_DAO_AllCoreTables::invoke(__CLASS__, 'fields_callback', Civi::$statics[__CLASS__]['fields']);
e501603b 571 }
346aaaba 572 return Civi::$statics[__CLASS__]['fields'];
e501603b 573 }
c3fc2621 574
e501603b 575 /**
bd8e0b14 576 * Return a mapping from field-name to the corresponding key (as used in fields()).
e501603b
TO
577 *
578 * @return array
bd8e0b14 579 * Array(string $name => string $uniqueName).
e501603b 580 */
c3fc2621 581 public static function &fieldKeys() {
bd8e0b14
TO
582 if (!isset(Civi::$statics[__CLASS__]['fieldKeys'])) {
583 Civi::$statics[__CLASS__]['fieldKeys'] = array_flip(CRM_Utils_Array::collect('name', self::fields()));
e501603b 584 }
bd8e0b14 585 return Civi::$statics[__CLASS__]['fieldKeys'];
e501603b 586 }
c3fc2621 587
e501603b
TO
588 /**
589 * Returns the names of this table
590 *
591 * @return string
592 */
c3fc2621 593 public static function getTableName() {
e501603b
TO
594 return self::$_tableName;
595 }
c3fc2621 596
e501603b
TO
597 /**
598 * Returns if this table needs to be logged
599 *
c3fc2621 600 * @return bool
e501603b 601 */
c3fc2621 602 public function getLog() {
e501603b
TO
603 return self::$_log;
604 }
c3fc2621 605
e501603b
TO
606 /**
607 * Returns the list of fields that can be imported
608 *
609 * @param bool $prefix
610 *
611 * @return array
612 */
c3fc2621
CW
613 public static function &import($prefix = FALSE) {
614 $r = CRM_Core_DAO_AllCoreTables::getImports(__CLASS__, 'membership', $prefix, []);
60808919 615 return $r;
e501603b 616 }
c3fc2621 617
e501603b
TO
618 /**
619 * Returns the list of fields that can be exported
620 *
621 * @param bool $prefix
622 *
623 * @return array
624 */
c3fc2621
CW
625 public static function &export($prefix = FALSE) {
626 $r = CRM_Core_DAO_AllCoreTables::getExports(__CLASS__, 'membership', $prefix, []);
60808919 627 return $r;
e501603b 628 }
c3fc2621 629
e7a6b91a
AS
630 /**
631 * Returns the list of indices
c3fc2621
CW
632 *
633 * @param bool $localize
634 *
635 * @return array
e7a6b91a
AS
636 */
637 public static function indices($localize = TRUE) {
c3fc2621
CW
638 $indices = [
639 'index_owner_membership_id' => [
e7a6b91a 640 'name' => 'index_owner_membership_id',
c3fc2621 641 'field' => [
e7a6b91a 642 0 => 'owner_membership_id',
c3fc2621
CW
643 ],
644 'localizable' => FALSE,
e7a6b91a 645 'sig' => 'civicrm_membership::0::owner_membership_id',
c3fc2621
CW
646 ],
647 ];
e7a6b91a
AS
648 return ($localize && !empty($indices)) ? CRM_Core_DAO_AllCoreTables::multilingualize(__CLASS__, $indices) : $indices;
649 }
c3fc2621 650
e501603b 651}