Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
bc77d7c0 | 4 | | Copyright CiviCRM LLC. All rights reserved. | |
6a488035 | 5 | | | |
bc77d7c0 TO |
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 | | |
6a488035 | 9 | +--------------------------------------------------------------------+ |
d25dd0ee | 10 | */ |
6a488035 TO |
11 | |
12 | /** | |
13 | * | |
14 | * @package CRM | |
ca5cec67 | 15 | * @copyright CiviCRM LLC https://civicrm.org/licensing |
6a488035 TO |
16 | * $Id$ |
17 | * | |
18 | */ | |
19 | ||
20 | /** | |
21 | * Page for displaying list of membership types | |
22 | */ | |
23 | class CRM_Member_Page_MembershipStatus extends CRM_Core_Page_Basic { | |
24 | ||
96f50de2 CW |
25 | public $useLivePageJS = TRUE; |
26 | ||
6a488035 | 27 | /** |
fe482240 | 28 | * The action links that we need to display for the browse screen. |
6a488035 TO |
29 | * |
30 | * @var array | |
6a488035 | 31 | */ |
971e129b | 32 | public static $_links = NULL; |
6a488035 TO |
33 | |
34 | /** | |
fe482240 | 35 | * Get BAO Name. |
6a488035 | 36 | * |
a6c01b45 CW |
37 | * @return string |
38 | * Classname of BAO. | |
6a488035 | 39 | */ |
00be9182 | 40 | public function getBAOName() { |
6a488035 TO |
41 | return 'CRM_Member_BAO_MembershipStatus'; |
42 | } | |
43 | ||
44 | /** | |
fe482240 | 45 | * Get action Links. |
6a488035 | 46 | * |
a6c01b45 CW |
47 | * @return array |
48 | * (reference) of action links | |
6a488035 | 49 | */ |
00be9182 | 50 | public function &links() { |
6a488035 | 51 | if (!(self::$_links)) { |
be2fb01f CW |
52 | self::$_links = [ |
53 | CRM_Core_Action::UPDATE => [ | |
6a488035 TO |
54 | 'name' => ts('Edit'), |
55 | 'url' => 'civicrm/admin/member/membershipStatus', | |
56 | 'qs' => 'action=update&id=%%id%%&reset=1', | |
57 | 'title' => ts('Edit Membership Status'), | |
be2fb01f CW |
58 | ], |
59 | CRM_Core_Action::DISABLE => [ | |
6a488035 | 60 | 'name' => ts('Disable'), |
4d17a233 | 61 | 'ref' => 'crm-enable-disable', |
6a488035 | 62 | 'title' => ts('Disable Membership Status'), |
be2fb01f CW |
63 | ], |
64 | CRM_Core_Action::ENABLE => [ | |
6a488035 | 65 | 'name' => ts('Enable'), |
4d17a233 | 66 | 'ref' => 'crm-enable-disable', |
6a488035 | 67 | 'title' => ts('Enable Membership Status'), |
be2fb01f CW |
68 | ], |
69 | CRM_Core_Action::DELETE => [ | |
6a488035 TO |
70 | 'name' => ts('Delete'), |
71 | 'url' => 'civicrm/admin/member/membershipStatus', | |
72 | 'qs' => 'action=delete&id=%%id%%', | |
73 | 'title' => ts('Delete Membership Status'), | |
be2fb01f CW |
74 | ], |
75 | ]; | |
6a488035 TO |
76 | } |
77 | return self::$_links; | |
78 | } | |
79 | ||
6a488035 TO |
80 | /** |
81 | * Browse all custom data groups. | |
82 | * | |
83 | * | |
84 | * @return void | |
6a488035 | 85 | */ |
00be9182 | 86 | public function browse() { |
6a488035 | 87 | // get all custom groups sorted by weight |
be2fb01f | 88 | $membershipStatus = []; |
6a488035 TO |
89 | $dao = new CRM_Member_DAO_MembershipStatus(); |
90 | ||
91 | $dao->orderBy('weight'); | |
92 | $dao->find(); | |
93 | ||
94 | while ($dao->fetch()) { | |
be2fb01f | 95 | $membershipStatus[$dao->id] = []; |
6a488035 TO |
96 | CRM_Core_DAO::storeValues($dao, $membershipStatus[$dao->id]); |
97 | ||
98 | // form all action links | |
99 | $action = array_sum(array_keys($this->links())); | |
100 | // update enable/disable links depending on if it is is_reserved or is_active | |
101 | if (!$dao->is_reserved) { | |
102 | if ($dao->is_active) { | |
103 | $action -= CRM_Core_Action::ENABLE; | |
104 | } | |
105 | else { | |
106 | $action -= CRM_Core_Action::DISABLE; | |
107 | } | |
108 | $membershipStatus[$dao->id]['action'] = CRM_Core_Action::formLink(self::links(), $action, | |
be2fb01f | 109 | ['id' => $dao->id], |
87dab4a4 AH |
110 | ts('more'), |
111 | FALSE, | |
112 | 'membershipStatus.manage.action', | |
113 | 'MembershipStatus', | |
114 | $dao->id | |
6a488035 TO |
115 | ); |
116 | } | |
117 | if ($startEvent = CRM_Utils_Array::value('start_event', $membershipStatus[$dao->id])) { | |
118 | $membershipStatus[$dao->id]['start_event'] = ($startEvent == 'join_date') ? 'member since' : str_replace("_", " ", $startEvent); | |
119 | } | |
120 | if ($endEvent = CRM_Utils_Array::value('end_event', $membershipStatus[$dao->id])) { | |
121 | $membershipStatus[$dao->id]['end_event'] = ($endEvent == 'join_date') ? 'member since' : str_replace("_", " ", $endEvent); | |
122 | } | |
123 | } | |
124 | // Add order changing widget to selector | |
125 | $returnURL = CRM_Utils_System::url('civicrm/admin/member/membershipStatus', "reset=1&action=browse"); | |
126 | CRM_Utils_Weight::addOrder($membershipStatus, 'CRM_Member_DAO_MembershipStatus', | |
127 | 'id', $returnURL | |
128 | ); | |
129 | ||
130 | $this->assign('rows', $membershipStatus); | |
131 | } | |
132 | ||
133 | /** | |
fe482240 | 134 | * Get name of edit form. |
6a488035 | 135 | * |
a6c01b45 CW |
136 | * @return string |
137 | * Classname of edit form. | |
6a488035 | 138 | */ |
00be9182 | 139 | public function editForm() { |
6a488035 TO |
140 | return 'CRM_Member_Form_MembershipStatus'; |
141 | } | |
142 | ||
143 | /** | |
fe482240 | 144 | * Get edit form name. |
6a488035 | 145 | * |
a6c01b45 CW |
146 | * @return string |
147 | * name of this page. | |
6a488035 | 148 | */ |
00be9182 | 149 | public function editName() { |
6a488035 TO |
150 | return 'Membership Status'; |
151 | } | |
152 | ||
153 | /** | |
154 | * Get user context. | |
155 | * | |
da6b46f4 EM |
156 | * @param null $mode |
157 | * | |
a6c01b45 CW |
158 | * @return string |
159 | * user context. | |
6a488035 | 160 | */ |
00be9182 | 161 | public function userContext($mode = NULL) { |
6a488035 TO |
162 | return 'civicrm/admin/member/membershipStatus'; |
163 | } | |
96025800 | 164 | |
6a488035 | 165 | } |