Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
232624b1 | 4 | | CiviCRM version 4.4 | |
6a488035 TO |
5 | +--------------------------------------------------------------------+ |
6 | | Copyright CiviCRM LLC (c) 2004-2013 | | |
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 | +--------------------------------------------------------------------+ | |
26 | */ | |
27 | ||
28 | /** | |
29 | * | |
30 | * @package CRM | |
31 | * @copyright CiviCRM LLC (c) 2004-2013 | |
32 | * $Id$ | |
33 | * | |
34 | */ | |
35 | class CRM_Admin_Page_ParticipantStatus extends CRM_Core_Page_Basic { | |
36 | function getBAOName() { | |
37 | return 'CRM_Event_BAO_ParticipantStatusType'; | |
38 | } | |
39 | ||
40 | function &links() { | |
41 | static $links = NULL; | |
42 | if ($links === NULL) { | |
43 | $links = array( | |
44 | CRM_Core_Action::UPDATE => array( | |
45 | 'name' => ts('Edit'), | |
46 | 'url' => 'civicrm/admin/participant_status', | |
47 | 'qs' => 'action=update&id=%%id%%&reset=1', | |
48 | 'title' => ts('Edit Status'), | |
49 | ), | |
50 | CRM_Core_Action::DELETE => array( | |
51 | 'name' => ts('Delete'), | |
52 | 'url' => 'civicrm/admin/participant_status', | |
53 | 'qs' => 'action=delete&id=%%id%%', | |
54 | 'title' => ts('Delete Status'), | |
55 | ), | |
56 | CRM_Core_Action::DISABLE => array( | |
57 | 'name' => ts('Disable'), | |
4d17a233 | 58 | 'ref' => 'crm-enable-disable', |
6a488035 TO |
59 | 'title' => ts('Disable Status'), |
60 | ), | |
61 | CRM_Core_Action::ENABLE => array( | |
62 | 'name' => ts('Enable'), | |
4d17a233 | 63 | 'ref' => 'crm-enable-disable', |
6a488035 TO |
64 | 'title' => ts('Enable Status'), |
65 | ), | |
66 | ); | |
67 | } | |
68 | return $links; | |
69 | } | |
70 | ||
71 | function browse() { | |
4d17a233 | 72 | CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); |
6a488035 TO |
73 | $statusTypes = array(); |
74 | ||
75 | $dao = new CRM_Event_DAO_ParticipantStatusType; | |
76 | $dao->orderBy('weight'); | |
77 | $dao->find(); | |
78 | ||
79 | $visibilities = CRM_Core_PseudoConstant::visibility(); | |
80 | ||
81 | // these statuses are reserved, but disabled by default - so should be disablable after being enabled | |
82 | $disablable = array('On waitlist', 'Awaiting approval', 'Pending from waitlist', 'Pending from approval', 'Rejected'); | |
83 | ||
84 | while ($dao->fetch()) { | |
85 | CRM_Core_DAO::storeValues($dao, $statusTypes[$dao->id]); | |
86 | $action = array_sum(array_keys($this->links())); | |
87 | if ($dao->is_reserved) { | |
88 | $action -= CRM_Core_Action::DELETE; | |
89 | if (!in_array($dao->name, $disablable)) { | |
90 | $action -= CRM_Core_Action::DISABLE; | |
91 | } | |
92 | } | |
93 | $action -= $dao->is_active ? CRM_Core_Action::ENABLE : CRM_Core_Action::DISABLE; | |
87dab4a4 AH |
94 | $statusTypes[$dao->id]['action'] = CRM_Core_Action::formLink( |
95 | self::links(), | |
96 | $action, | |
97 | array('id' => $dao->id), | |
98 | ts('more'), | |
99 | FALSE, | |
100 | 'participantStatusType.manage.action', | |
101 | 'ParticipantStatusType', | |
102 | $dao->id | |
103 | ); | |
6a488035 TO |
104 | $statusTypes[$dao->id]['visibility'] = $visibilities[$dao->visibility_id]; |
105 | } | |
106 | $this->assign('rows', $statusTypes); | |
107 | } | |
108 | ||
109 | function editForm() { | |
110 | return 'CRM_Admin_Form_ParticipantStatus'; | |
111 | } | |
112 | ||
113 | function editName() { | |
114 | return 'Participant Status'; | |
115 | } | |
116 | ||
117 | function userContext($mode = NULL) { | |
118 | return 'civicrm/admin/participant_status'; | |
119 | } | |
120 | } | |
121 |