INFRA-132 - Fix spacing of @return tag in comments
[civicrm-core.git] / CRM / Admin / Page / ParticipantStatusType.php
CommitLineData
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 +--------------------------------------------------------------------+
26*/
27
28/**
29 *
30 * @package CRM
06b69b18 31 * @copyright CiviCRM LLC (c) 2004-2014
6a488035
TO
32 * $Id$
33 *
34 */
84403e23 35class 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
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('On waitlist', 'Awaiting approval', 'Pending from waitlist', 'Pending from approval', 'Rejected');
91
92 while ($dao->fetch()) {
93 CRM_Core_DAO::storeValues($dao, $statusTypes[$dao->id]);
94 $action = array_sum(array_keys($this->links()));
95 if ($dao->is_reserved) {
96 $action -= CRM_Core_Action::DELETE;
97 if (!in_array($dao->name, $disablable)) {
98 $action -= CRM_Core_Action::DISABLE;
99 }
100 }
101 $action -= $dao->is_active ? CRM_Core_Action::ENABLE : CRM_Core_Action::DISABLE;
87dab4a4
AH
102 $statusTypes[$dao->id]['action'] = CRM_Core_Action::formLink(
103 self::links(),
104 $action,
105 array('id' => $dao->id),
106 ts('more'),
107 FALSE,
108 'participantStatusType.manage.action',
109 'ParticipantStatusType',
110 $dao->id
111 );
6a488035
TO
112 $statusTypes[$dao->id]['visibility'] = $visibilities[$dao->visibility_id];
113 }
114 $this->assign('rows', $statusTypes);
115 }
116
e0ef6999
EM
117 /**
118 * @return string
119 */
00be9182 120 public function editForm() {
84403e23 121 return 'CRM_Admin_Form_ParticipantStatusType';
6a488035
TO
122 }
123
e0ef6999
EM
124 /**
125 * @return string
126 */
00be9182 127 public function editName() {
6a488035
TO
128 return 'Participant Status';
129 }
130
e0ef6999
EM
131 /**
132 * @param null $mode
133 *
134 * @return string
135 */
00be9182 136 public function userContext($mode = NULL) {
6a488035
TO
137 return 'civicrm/admin/participant_status';
138 }
139}