commiting uncommited changes on live site
[weblabels.fsf.org.git] / crm.fsf.org / 20131203 / files / sites / all / modules-new / civicrm / CRM / Admin / Page / ParticipantStatusType.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
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-2015
32 * $Id$
33 *
34 */
35 class CRM_Admin_Page_ParticipantStatusType extends CRM_Core_Page_Basic {
36
37 public $useLivePageJS = TRUE;
38
39 /**
40 * @return string
41 */
42 public function getBAOName() {
43 return 'CRM_Event_BAO_ParticipantStatusType';
44 }
45
46 /**
47 * @return array
48 */
49 public function &links() {
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'),
67 'ref' => 'crm-enable-disable',
68 'title' => ts('Disable Status'),
69 ),
70 CRM_Core_Action::ENABLE => array(
71 'name' => ts('Enable'),
72 'ref' => 'crm-enable-disable',
73 'title' => ts('Enable Status'),
74 ),
75 );
76 }
77 return $links;
78 }
79
80 public function browse() {
81 $statusTypes = array();
82
83 $dao = new CRM_Event_DAO_ParticipantStatusType();
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
90 $disablable = array(
91 'On waitlist',
92 'Awaiting approval',
93 'Pending from waitlist',
94 'Pending from approval',
95 'Rejected',
96 );
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;
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 );
118 $statusTypes[$dao->id]['visibility'] = $visibilities[$dao->visibility_id];
119 }
120 $this->assign('rows', $statusTypes);
121 }
122
123 /**
124 * @return string
125 */
126 public function editForm() {
127 return 'CRM_Admin_Form_ParticipantStatusType';
128 }
129
130 /**
131 * @return string
132 */
133 public function editName() {
134 return 'Participant Status';
135 }
136
137 /**
138 * @param null $mode
139 *
140 * @return string
141 */
142 public function userContext($mode = NULL) {
143 return 'civicrm/admin/participant_status';
144 }
145
146 }