Merge pull request #22848 from braders/extension-manager-notices
[civicrm-core.git] / CRM / Admin / Page / ParticipantStatusType.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 *
14 * @package CRM
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
16 */
17 class CRM_Admin_Page_ParticipantStatusType extends CRM_Core_Page_Basic {
18
19 public $useLivePageJS = TRUE;
20
21 /**
22 * Get BAO name.
23 *
24 * @return string
25 */
26 public function getBAOName() {
27 return 'CRM_Event_BAO_ParticipantStatusType';
28 }
29
30 /**
31 * @return array
32 */
33 public function &links() {
34 static $links = NULL;
35 if ($links === NULL) {
36 $links = [
37 CRM_Core_Action::UPDATE => [
38 'name' => ts('Edit'),
39 'url' => 'civicrm/admin/participant_status',
40 'qs' => 'action=update&id=%%id%%&reset=1',
41 'title' => ts('Edit Status'),
42 ],
43 CRM_Core_Action::DELETE => [
44 'name' => ts('Delete'),
45 'url' => 'civicrm/admin/participant_status',
46 'qs' => 'action=delete&id=%%id%%',
47 'title' => ts('Delete Status'),
48 ],
49 CRM_Core_Action::DISABLE => [
50 'name' => ts('Disable'),
51 'ref' => 'crm-enable-disable',
52 'title' => ts('Disable Status'),
53 ],
54 CRM_Core_Action::ENABLE => [
55 'name' => ts('Enable'),
56 'ref' => 'crm-enable-disable',
57 'title' => ts('Enable Status'),
58 ],
59 ];
60 }
61 return $links;
62 }
63
64 public function browse() {
65 $statusTypes = [];
66
67 $dao = new CRM_Event_DAO_ParticipantStatusType();
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
74 $disablable = [
75 'On waitlist',
76 'Awaiting approval',
77 'Pending from waitlist',
78 'Pending from approval',
79 'Rejected',
80 ];
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;
92 $statusTypes[$dao->id]['action'] = CRM_Core_Action::formLink(
93 self::links(),
94 $action,
95 ['id' => $dao->id],
96 ts('more'),
97 FALSE,
98 'participantStatusType.manage.action',
99 'ParticipantStatusType',
100 $dao->id
101 );
102 $statusTypes[$dao->id]['visibility'] = $visibilities[$dao->visibility_id];
103 }
104 $this->assign('rows', $statusTypes);
105 }
106
107 /**
108 * @return string
109 */
110 public function editForm() {
111 return 'CRM_Admin_Form_ParticipantStatusType';
112 }
113
114 /**
115 * @return string
116 */
117 public function editName() {
118 return 'Participant Status';
119 }
120
121 /**
122 * @param null $mode
123 *
124 * @return string
125 */
126 public function userContext($mode = NULL) {
127 return 'civicrm/admin/participant_status';
128 }
129
130 }