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