$session = CRM_Core_Session::singleton();
// check if registration link should be displayed
foreach ($info as $id => $event) {
+ //@todo FIXME - validRegistraionRequest takes eventID not contactID as a param
+ // this is called via an obscure patch from Joomla event block rendering (only)
$info[$id]['onlineRegistration'] = CRM_Event_BAO_Event::validRegistrationRequest($event,
$session->get('userID')
);
}
}
- public static function event($type = CRM_Core_Permission::VIEW, $eventID = NULL) {
+ public static function event($type = CRM_Core_Permission::VIEW, $eventID = NULL, $context = '') {
+ if(!empty($context)) {
+ if(CRM_Core_Permission::check($context)) {
+ return TRUE;
+ }
+ }
$events = CRM_Event_PseudoConstant::event(NULL, TRUE);
$includeEvents = array();
}
// check 'view event info' permission
+ //@todo - per CRM-14626 we have resolved that 'view event info' means 'view ALL event info'
+ // and passing in the specific permission here will short-circuit the evaluation of permission to
+ // see specific events (doesn't seem relevant to this call
+ // however, since this function is accessed only by a convoluted call from a joomla block function
+ // it seems safer not to touch here. Suggestion is that CRM_Core_Permission::check(array or relevant permissions) would
+ // be clearer & safer here
$permissions = CRM_Core_Permission::event(CRM_Core_Permission::VIEW);
// check if we're in shopping cart mode for events
return CRM_Core_DAO::singleValueQuery($query);
}
- static function validRegistrationRequest($values, $contactID) {
+ /**
+ * Check if event registration is valid according to permissions AND Dates
+ *
+ * @param array $values
+ * @param integer $eventID
+ * @return boolean
+ */
+ static function validRegistrationRequest($values, $eventID) {
// check that the user has permission to register for this event
$hasPermission = CRM_Core_Permission::event(CRM_Core_Permission::EDIT,
- $contactID
+ $eventID, 'register for events'
);
return $hasPermission && self::validRegistrationDate($values);
$transaction = new CRM_Core_Transaction();
$this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
- if (!CRM_Core_Permission::check('register for events')) {
+ if (!CRM_Core_Permission::event(CRM_Core_Permission::VIEW, $this->_id, 'register for events')) {
CRM_Core_Error::fatal(ts('You do not have permission to register for this event'));
}
- if (!CRM_Core_Permission::event(CRM_Core_Permission::VIEW, $this->_id)) {
- CRM_Core_Error::fatal(ts('You cannot register for an event you do not have permission to view'));
- }
$cart = CRM_Event_Cart_BAO_Cart::find_or_create_for_current_session();
$event_in_cart = $cart->add_event($this->_id);
);
// this is the first time we are hitting this, so check for permissions here
- if (!CRM_Core_Permission::event(CRM_Core_Permission::EDIT, $this->_eventId)) {
+ if (!CRM_Core_Permission::event(CRM_Core_Permission::EDIT, $this->_eventId, 'register for events')) {
CRM_Core_Error::statusBounce(ts('You do not have permission to register for this event'), $infoUrl);
}
}
}
+ /**
+ * @todo - combine this with CRM_Event_BAO_Event::validRegistrationRequest
+ * (probably extract relevant values here & call that with them & handle bounces & redirects here -as
+ * those belong in the form layer)
+ *
+ * @param string $redirect
+ */
function checkValidEvent($redirect = NULL) {
// is the event active (enabled)?
if (!$this->_values['event']['is_active']) {
$config = CRM_Core_Config::singleton();
// ensure that the user has permission to see this page
if (!CRM_Core_Permission::event(CRM_Core_Permission::VIEW,
- $this->_id
+ $this->_id, 'view event info'
)) {
CRM_Utils_System::setUFMessage(ts('You do not have permission to view this event'));
return CRM_Utils_System::permissionDenied();
// Add Event Type to $values in case folks want to display it
$values['event']['event_type'] = CRM_Utils_Array::value($values['event']['event_type_id'], CRM_Event_PseudoConstant::eventType());
-
+
$this->assign('isShowLocation', CRM_Utils_Array::value('is_show_location', $values['event']));
// show event fees.