Merge pull request #16100 from jitendrapurohit/dev-1473
[civicrm-core.git] / CRM / Member / StatusOverrideTypes.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
5 | |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
10 */
11
12 /**
13 * Membership status override types.
14 *
15 * @package CRM
16 * @copyright CiviCRM LLC https://civicrm.org/licensing
17 *
18 */
19 class CRM_Member_StatusOverrideTypes {
20 /**
21 * The membership status is not overridden
22 * and its is subject to membership status rules.
23 */
24 const NO = 0;
25
26 /**
27 * The membership will stay at the selected status
28 * and its status is NOT subject to membership
29 * status rules.
30 */
31 const PERMANENT = 1;
32
33 /**
34 * The membership status will stay at the
35 * selected status and it is NOT subject to membership status rules.
36 * However, on the selected date(status_override_end_date),
37 * the status override type will automatically change to "NO" thus then
38 * the membership becomes subject to membership status rules.
39 */
40 const UNTIL_DATE = 2;
41
42 /**
43 * Gets the list of override types
44 * as a list of options to be used
45 * for select input.
46 *
47 * @return array
48 * In ['Type 1 Value' => 'Type 1 Label'] format
49 */
50 public static function getSelectOptions() {
51 return [
52 self::NO => ts('No'),
53 self::PERMANENT => ts('Override Permanently'),
54 self::UNTIL_DATE => ts('Override Until Selected Date'),
55 ];
56 }
57
58 /**
59 * Determines if the override type means
60 * that the membership is overridden or not.
61 * For now, only "NO" type means that the membership
62 * status is not overridden.
63 *
64 * @param $overrideType
65 *
66 * @return bool
67 */
68 public static function isOverridden($overrideType) {
69 if ($overrideType == self::NO) {
70 return FALSE;
71 }
72
73 return TRUE;
74 }
75
76 public static function isNo($overrideType) {
77 if ($overrideType != self::NO) {
78 return FALSE;
79 }
80
81 return TRUE;
82 }
83
84 public static function isPermanent($overrideType) {
85 if ($overrideType != self::PERMANENT) {
86 return FALSE;
87 }
88
89 return TRUE;
90 }
91
92 public static function isUntilDate($overrideType) {
93 if ($overrideType != self::UNTIL_DATE) {
94 return FALSE;
95 }
96
97 return TRUE;
98 }
99
100 }