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