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