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