Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
39de6fd5 | 4 | | CiviCRM version 4.6 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
06b69b18 | 6 | | Copyright CiviCRM LLC (c) 2004-2014 | |
6a488035 TO |
7 | +--------------------------------------------------------------------+ |
8 | | This file is a part of CiviCRM. | | |
9 | | | | |
10 | | CiviCRM is free software; you can copy, modify, and distribute it | | |
11 | | under the terms of the GNU Affero General Public License | | |
12 | | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | | |
13 | | | | |
14 | | CiviCRM is distributed in the hope that it will be useful, but | | |
15 | | WITHOUT ANY WARRANTY; without even the implied warranty of | | |
16 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | | |
17 | | See the GNU Affero General Public License for more details. | | |
18 | | | | |
19 | | You should have received a copy of the GNU Affero General Public | | |
20 | | License and the CiviCRM Licensing Exception along | | |
21 | | with this program; if not, contact CiviCRM LLC | | |
22 | | at info[AT]civicrm[DOT]org. If you have questions about the | | |
23 | | GNU Affero General Public License or the licensing of CiviCRM, | | |
24 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | | |
25 | +--------------------------------------------------------------------+ | |
d25dd0ee | 26 | */ |
6a488035 TO |
27 | |
28 | /** | |
29 | * | |
30 | * @package CRM | |
06b69b18 | 31 | * @copyright CiviCRM LLC (c) 2004-2014 |
6a488035 TO |
32 | * $Id$ |
33 | * | |
34 | */ | |
84403e23 | 35 | class CRM_Admin_Page_ParticipantStatusType extends CRM_Core_Page_Basic { |
96f50de2 CW |
36 | |
37 | public $useLivePageJS = TRUE; | |
e0ef6999 EM |
38 | |
39 | /** | |
40 | * @return string | |
41 | */ | |
00be9182 | 42 | public function getBAOName() { |
6a488035 TO |
43 | return 'CRM_Event_BAO_ParticipantStatusType'; |
44 | } | |
45 | ||
e0ef6999 EM |
46 | /** |
47 | * @return array | |
48 | */ | |
00be9182 | 49 | public function &links() { |
6a488035 TO |
50 | static $links = NULL; |
51 | if ($links === NULL) { | |
52 | $links = array( | |
53 | CRM_Core_Action::UPDATE => array( | |
54 | 'name' => ts('Edit'), | |
55 | 'url' => 'civicrm/admin/participant_status', | |
56 | 'qs' => 'action=update&id=%%id%%&reset=1', | |
57 | 'title' => ts('Edit Status'), | |
58 | ), | |
59 | CRM_Core_Action::DELETE => array( | |
60 | 'name' => ts('Delete'), | |
61 | 'url' => 'civicrm/admin/participant_status', | |
62 | 'qs' => 'action=delete&id=%%id%%', | |
63 | 'title' => ts('Delete Status'), | |
64 | ), | |
65 | CRM_Core_Action::DISABLE => array( | |
66 | 'name' => ts('Disable'), | |
4d17a233 | 67 | 'ref' => 'crm-enable-disable', |
6a488035 TO |
68 | 'title' => ts('Disable Status'), |
69 | ), | |
70 | CRM_Core_Action::ENABLE => array( | |
71 | 'name' => ts('Enable'), | |
4d17a233 | 72 | 'ref' => 'crm-enable-disable', |
6a488035 TO |
73 | 'title' => ts('Enable Status'), |
74 | ), | |
75 | ); | |
76 | } | |
77 | return $links; | |
78 | } | |
79 | ||
00be9182 | 80 | public function browse() { |
6a488035 TO |
81 | $statusTypes = array(); |
82 | ||
389bcebf | 83 | $dao = new CRM_Event_DAO_ParticipantStatusType(); |
6a488035 TO |
84 | $dao->orderBy('weight'); |
85 | $dao->find(); | |
86 | ||
87 | $visibilities = CRM_Core_PseudoConstant::visibility(); | |
88 | ||
89 | // these statuses are reserved, but disabled by default - so should be disablable after being enabled | |
353ffa53 TO |
90 | $disablable = array( |
91 | 'On waitlist', | |
92 | 'Awaiting approval', | |
93 | 'Pending from waitlist', | |
94 | 'Pending from approval', | |
389bcebf | 95 | 'Rejected', |
353ffa53 | 96 | ); |
6a488035 TO |
97 | |
98 | while ($dao->fetch()) { | |
99 | CRM_Core_DAO::storeValues($dao, $statusTypes[$dao->id]); | |
100 | $action = array_sum(array_keys($this->links())); | |
101 | if ($dao->is_reserved) { | |
102 | $action -= CRM_Core_Action::DELETE; | |
103 | if (!in_array($dao->name, $disablable)) { | |
104 | $action -= CRM_Core_Action::DISABLE; | |
105 | } | |
106 | } | |
107 | $action -= $dao->is_active ? CRM_Core_Action::ENABLE : CRM_Core_Action::DISABLE; | |
87dab4a4 AH |
108 | $statusTypes[$dao->id]['action'] = CRM_Core_Action::formLink( |
109 | self::links(), | |
110 | $action, | |
111 | array('id' => $dao->id), | |
112 | ts('more'), | |
113 | FALSE, | |
114 | 'participantStatusType.manage.action', | |
115 | 'ParticipantStatusType', | |
116 | $dao->id | |
117 | ); | |
6a488035 TO |
118 | $statusTypes[$dao->id]['visibility'] = $visibilities[$dao->visibility_id]; |
119 | } | |
120 | $this->assign('rows', $statusTypes); | |
121 | } | |
122 | ||
e0ef6999 EM |
123 | /** |
124 | * @return string | |
125 | */ | |
00be9182 | 126 | public function editForm() { |
84403e23 | 127 | return 'CRM_Admin_Form_ParticipantStatusType'; |
6a488035 TO |
128 | } |
129 | ||
e0ef6999 EM |
130 | /** |
131 | * @return string | |
132 | */ | |
00be9182 | 133 | public function editName() { |
6a488035 TO |
134 | return 'Participant Status'; |
135 | } | |
136 | ||
e0ef6999 EM |
137 | /** |
138 | * @param null $mode | |
139 | * | |
140 | * @return string | |
141 | */ | |
00be9182 | 142 | public function userContext($mode = NULL) { |
6a488035 TO |
143 | return 'civicrm/admin/participant_status'; |
144 | } | |
96025800 | 145 | |
6a488035 | 146 | } |