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 | 16 | */ |
84403e23 | 17 | class CRM_Admin_Page_ParticipantStatusType extends CRM_Core_Page_Basic { |
96f50de2 CW |
18 | |
19 | public $useLivePageJS = TRUE; | |
e0ef6999 EM |
20 | |
21 | /** | |
ce064e4f | 22 | * Get BAO name. |
23 | * | |
e0ef6999 EM |
24 | * @return string |
25 | */ | |
00be9182 | 26 | public function getBAOName() { |
6a488035 TO |
27 | return 'CRM_Event_BAO_ParticipantStatusType'; |
28 | } | |
29 | ||
e0ef6999 EM |
30 | /** |
31 | * @return array | |
32 | */ | |
00be9182 | 33 | public function &links() { |
6a488035 TO |
34 | static $links = NULL; |
35 | if ($links === NULL) { | |
be2fb01f CW |
36 | $links = [ |
37 | CRM_Core_Action::UPDATE => [ | |
6a488035 TO |
38 | 'name' => ts('Edit'), |
39 | 'url' => 'civicrm/admin/participant_status', | |
40 | 'qs' => 'action=update&id=%%id%%&reset=1', | |
41 | 'title' => ts('Edit Status'), | |
be2fb01f CW |
42 | ], |
43 | CRM_Core_Action::DELETE => [ | |
6a488035 TO |
44 | 'name' => ts('Delete'), |
45 | 'url' => 'civicrm/admin/participant_status', | |
46 | 'qs' => 'action=delete&id=%%id%%', | |
47 | 'title' => ts('Delete Status'), | |
be2fb01f CW |
48 | ], |
49 | CRM_Core_Action::DISABLE => [ | |
6a488035 | 50 | 'name' => ts('Disable'), |
4d17a233 | 51 | 'ref' => 'crm-enable-disable', |
6a488035 | 52 | 'title' => ts('Disable Status'), |
be2fb01f CW |
53 | ], |
54 | CRM_Core_Action::ENABLE => [ | |
6a488035 | 55 | 'name' => ts('Enable'), |
4d17a233 | 56 | 'ref' => 'crm-enable-disable', |
6a488035 | 57 | 'title' => ts('Enable Status'), |
be2fb01f CW |
58 | ], |
59 | ]; | |
6a488035 TO |
60 | } |
61 | return $links; | |
62 | } | |
63 | ||
00be9182 | 64 | public function browse() { |
be2fb01f | 65 | $statusTypes = []; |
6a488035 | 66 | |
389bcebf | 67 | $dao = new CRM_Event_DAO_ParticipantStatusType(); |
6a488035 TO |
68 | $dao->orderBy('weight'); |
69 | $dao->find(); | |
70 | ||
71 | $visibilities = CRM_Core_PseudoConstant::visibility(); | |
72 | ||
73 | // these statuses are reserved, but disabled by default - so should be disablable after being enabled | |
be2fb01f | 74 | $disablable = [ |
353ffa53 TO |
75 | 'On waitlist', |
76 | 'Awaiting approval', | |
77 | 'Pending from waitlist', | |
78 | 'Pending from approval', | |
389bcebf | 79 | 'Rejected', |
be2fb01f | 80 | ]; |
6a488035 TO |
81 | |
82 | while ($dao->fetch()) { | |
83 | CRM_Core_DAO::storeValues($dao, $statusTypes[$dao->id]); | |
84 | $action = array_sum(array_keys($this->links())); | |
85 | if ($dao->is_reserved) { | |
86 | $action -= CRM_Core_Action::DELETE; | |
87 | if (!in_array($dao->name, $disablable)) { | |
88 | $action -= CRM_Core_Action::DISABLE; | |
89 | } | |
90 | } | |
91 | $action -= $dao->is_active ? CRM_Core_Action::ENABLE : CRM_Core_Action::DISABLE; | |
87dab4a4 AH |
92 | $statusTypes[$dao->id]['action'] = CRM_Core_Action::formLink( |
93 | self::links(), | |
94 | $action, | |
be2fb01f | 95 | ['id' => $dao->id], |
87dab4a4 AH |
96 | ts('more'), |
97 | FALSE, | |
98 | 'participantStatusType.manage.action', | |
99 | 'ParticipantStatusType', | |
100 | $dao->id | |
101 | ); | |
6a488035 TO |
102 | $statusTypes[$dao->id]['visibility'] = $visibilities[$dao->visibility_id]; |
103 | } | |
104 | $this->assign('rows', $statusTypes); | |
105 | } | |
106 | ||
e0ef6999 EM |
107 | /** |
108 | * @return string | |
109 | */ | |
00be9182 | 110 | public function editForm() { |
84403e23 | 111 | return 'CRM_Admin_Form_ParticipantStatusType'; |
6a488035 TO |
112 | } |
113 | ||
e0ef6999 EM |
114 | /** |
115 | * @return string | |
116 | */ | |
00be9182 | 117 | public function editName() { |
6a488035 TO |
118 | return 'Participant Status'; |
119 | } | |
120 | ||
e0ef6999 EM |
121 | /** |
122 | * @param null $mode | |
123 | * | |
124 | * @return string | |
125 | */ | |
00be9182 | 126 | public function userContext($mode = NULL) { |
6a488035 TO |
127 | return 'civicrm/admin/participant_status'; |
128 | } | |
96025800 | 129 | |
6a488035 | 130 | } |