Add in unit test of searching when price field value label has changed
[civicrm-core.git] / CRM / Event / Info.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2019 |
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 * This class introduces component to the system and provides all the
30 * information about it. It needs to extend CRM_Core_Component_Info
31 * abstract class.
32 *
33 * @package CRM
34 * @copyright CiviCRM LLC (c) 2004-2019
35 * $Id$
36 *
37 */
38 class CRM_Event_Info extends CRM_Core_Component_Info {
39
40 /**
41 * @var string
42 * @inheritDoc
43 */
44 protected $keyword = 'event';
45
46 /**
47 * @inheritDoc
48 * @return array
49 */
50 public function getInfo() {
51 return [
52 'name' => 'CiviEvent',
53 'translatedName' => ts('CiviEvent'),
54 'title' => ts('CiviCRM Event Engine'),
55 'search' => 1,
56 'showActivitiesInCore' => 1,
57 ];
58 }
59
60 /**
61 * @inheritDoc
62 * @param bool $getAllUnconditionally
63 * @param bool $descriptions
64 * Whether to return permission descriptions
65 *
66 * @return array
67 */
68 public function getPermissions($getAllUnconditionally = FALSE, $descriptions = FALSE) {
69 $permissions = [
70 'access CiviEvent' => [
71 ts('access CiviEvent'),
72 ts('Create events, view all events, and view participant records (for visible contacts)'),
73 ],
74 'edit event participants' => [
75 ts('edit event participants'),
76 ts('Record and update backend event registrations'),
77 ],
78 'edit all events' => [
79 ts('edit all events'),
80 ts('Edit events even without specific ACL granted'),
81 ],
82 'register for events' => [
83 ts('register for events'),
84 ts('Register for events online'),
85 ],
86 'view event info' => [
87 ts('view event info'),
88 ts('View online event information pages'),
89 ],
90 'view event participants' => [
91 ts('view event participants'),
92 ],
93 'delete in CiviEvent' => [
94 ts('delete in CiviEvent'),
95 ts('Delete participants and events that you can edit'),
96 ],
97 'manage event profiles' => [
98 ts('manage event profiles'),
99 ts('Allow users to create, edit and copy event-related profile forms used for online event registration.'),
100 ],
101 ];
102
103 if (!$descriptions) {
104 foreach ($permissions as $name => $attr) {
105 $permissions[$name] = array_shift($attr);
106 }
107 }
108
109 return $permissions;
110 }
111
112 /**
113 * @return array
114 */
115 public function getAnonymousPermissionWarnings() {
116 return [
117 'access CiviEvent',
118 ];
119 }
120
121 /**
122 * @inheritDoc
123 * @return array
124 */
125 public function getUserDashboardElement() {
126 return [
127 'name' => ts('Events'),
128 'title' => ts('Your Event(s)'),
129 'perm' => ['register for events'],
130 'weight' => 20,
131 ];
132 }
133
134 /**
135 * @inheritDoc
136 * @return array
137 */
138 public function registerTab() {
139 return [
140 'title' => ts('Events'),
141 'id' => 'participant',
142 'url' => 'participant',
143 'weight' => 40,
144 ];
145 }
146
147 /**
148 * @inheritDoc
149 * @return string
150 */
151 public function getIcon() {
152 return 'crm-i fa-calendar';
153 }
154
155 /**
156 * @inheritDoc
157 * @return array
158 */
159 public function registerAdvancedSearchPane() {
160 return [
161 'title' => ts('Events'),
162 'weight' => 40,
163 ];
164 }
165
166 /**
167 * @inheritDoc
168 * @return array
169 */
170 public function getActivityTypes() {
171 $types = [];
172 $types['Event'] = [
173 'title' => ts('Event'),
174 'callback' => 'CRM_Event_Page_EventInfo::run()',
175 ];
176 return $types;
177 }
178
179 /**
180 * add shortcut to Create New.
181 * @param $shortCuts
182 * @param $newCredit
183 */
184 public function creatNewShortcut(&$shortCuts, $newCredit) {
185 if (CRM_Core_Permission::check('access CiviEvent') &&
186 CRM_Core_Permission::check('edit event participants')
187 ) {
188 $shortCut[] = [
189 'path' => 'civicrm/participant/add',
190 'query' => "reset=1&action=add&context=standalone",
191 'ref' => 'new-participant',
192 'title' => ts('Event Registration'),
193 ];
194 if ($newCredit) {
195 $title = ts('Event Registration') . '<br />&nbsp;&nbsp;(' . ts('credit card') . ')';
196 $shortCut[0]['shortCuts'][] = [
197 'path' => 'civicrm/participant/add',
198 'query' => "reset=1&action=add&context=standalone&mode=live",
199 'ref' => 'new-participant-cc',
200 'title' => $title,
201 ];
202 }
203 $shortCuts = array_merge($shortCuts, $shortCut);
204 }
205 }
206
207 }