/** * Method to get a list of events. */ public function getItems() { $items = parent::getItems(); if (empty($items)) { return array(); } $user = JemFactory::getUser(); $userId = $user->get('id'); $guest = $user->get('guest'); $groups = $user->getAuthorisedViewLevels(); $input = JFactory::getApplication()->input; $calendarMultiday = $this->getState('filter.calendar_multiday'); # Get the global params $globalParams = JComponentHelper::getParams('com_jem', true); # Convert the parameter fields into objects. foreach ($items as $index => $item) { $eventParams = new JRegistry; $eventParams->loadString($item->attribs); $item->params = clone $this->getState('params'); $item->params->merge($eventParams); # adding categories $item->categories = $this->getCategories($item->id); # check if the item-categories is empty, if so the user has no access to that event at all. if (empty($item->categories)) { unset ($items[$index]); } else { # write access permissions. $item->params->set('access-edit', $user->can('edit', 'event', $item->id, $item->created_by)); } } // foreach if ($items) { /*$items =*/ JemHelper::getAttendeesNumbers($items); if ($calendarMultiday) { $items = self::calendarMultiday($items); } } return $items; }
/** * Method to get a list of events. */ public function getItems() { $items = parent::getItems(); if ($items) { $app = JFactory::getApplication(); $user = JFactory::getUser(); $userId = $user->get('id'); $guest = $user->get('guest'); $groups = $user->getAuthorisedViewLevels(); $input = JFactory::getApplication()->input; $calendarMultiday = $this->getState('filter.calendar_multiday'); # Convert the parameter fields into objects. foreach ($items as $index => $item) { $eventParams = new JRegistry(); $eventParams->loadString($item->attribs); if ($this->getState('params')) { $item->params = clone $this->getState('params'); } else { $params = new JRegistry(); $item->params = $params; } $item->params->merge($eventParams); # access permissions. if (!$guest) { $asset = 'com_jem.event.' . $item->id; # Check general edit permission first. if ($user->authorise('core.edit', $asset)) { $item->params->set('access-edit', true); } elseif (!empty($userId) && $user->authorise('core.edit.own', $asset)) { # Check for a valid user and that they are the owner. if ($userId == $item->created_by) { $item->params->set('access-edit', true); } } } # adding categories $item->categories = $this->getCategories($item->id); # retrieving filter-access $access = $this->getState('filter.access'); if ($access) { // If the access filter has been set, we already have only the events this user can view. $item->params->set('access-view', true); } else { $user = JFactory::getUser(); $groups = $user->getAuthorisedViewLevels(); $item->params->set('access-view', in_array($item->access, $groups)); } # check if the item-categories is empty, if so the user has no access to that event at all. if (empty($item->categories)) { unset($items[$index]); } } if ($items) { $items = JemHelper::getAttendeesNumbers($items); if ($calendarMultiday) { $items = self::calendarMultiday($items); } } return $items; } else { return array(); } }