3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
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 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
21 * Page for displaying list of membership types
23 class CRM_Member_Page_MembershipStatus
extends CRM_Core_Page_Basic
{
25 public $useLivePageJS = TRUE;
28 * The action links that we need to display for the browse screen.
32 public static $_links = NULL;
40 public function getBAOName() {
41 return 'CRM_Member_BAO_MembershipStatus';
48 * (reference) of action links
50 public function &links() {
51 if (!(self
::$_links)) {
53 CRM_Core_Action
::UPDATE
=> [
55 'url' => 'civicrm/admin/member/membershipStatus',
56 'qs' => 'action=update&id=%%id%%&reset=1',
57 'title' => ts('Edit Membership Status'),
59 CRM_Core_Action
::DISABLE
=> [
60 'name' => ts('Disable'),
61 'ref' => 'crm-enable-disable',
62 'title' => ts('Disable Membership Status'),
64 CRM_Core_Action
::ENABLE
=> [
65 'name' => ts('Enable'),
66 'ref' => 'crm-enable-disable',
67 'title' => ts('Enable Membership Status'),
69 CRM_Core_Action
::DELETE
=> [
70 'name' => ts('Delete'),
71 'url' => 'civicrm/admin/member/membershipStatus',
72 'qs' => 'action=delete&id=%%id%%',
73 'title' => ts('Delete Membership Status'),
81 * Browse all custom data groups.
86 public function browse() {
87 // get all custom groups sorted by weight
88 $membershipStatus = [];
89 $dao = new CRM_Member_DAO_MembershipStatus();
91 $dao->orderBy('weight');
94 while ($dao->fetch()) {
95 $membershipStatus[$dao->id
] = [];
96 CRM_Core_DAO
::storeValues($dao, $membershipStatus[$dao->id
]);
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
;
106 $action -= CRM_Core_Action
::DISABLE
;
108 $membershipStatus[$dao->id
]['action'] = CRM_Core_Action
::formLink(self
::links(), $action,
112 'membershipStatus.manage.action',
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);
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);
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',
130 $this->assign('rows', $membershipStatus);
134 * Get name of edit form.
137 * Classname of edit form.
139 public function editForm() {
140 return 'CRM_Member_Form_MembershipStatus';
144 * Get edit form name.
149 public function editName() {
150 return 'Membership Status';
161 public function userContext($mode = NULL) {
162 return 'civicrm/admin/member/membershipStatus';