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