/** * Gets the parent groups that a leaf group belongs to in its branch back to the root of the tree * (including the leaf group id). * * @param mixed $groupId An integer or array of integers representing the identities to check. * * @return mixed array with the parent user groups. * * @since 11.1 */ public static function getGroupPath($groupId) { // Preload all groups if (empty(self::$userGroups)) { $db = JFactory::getDbo(); $query = $db->getQuery(true)->select('parent.id, parent.lft, parent.rgt')->from('#__usergroups AS parent')->order('parent.lft'); $db->setQuery($query); self::$userGroups = $db->loadObjectList('id'); } // Get parent groups and leaf group if (!isset(self::$userGroupPaths[$groupId])) { self::$userGroupPaths[$groupId] = array(); foreach (self::$userGroups as $group) { if ($group->lft <= self::$userGroups[$groupId]->lft && $group->rgt >= self::$userGroups[$groupId]->rgt) { self::$userGroupPaths[$groupId][] = $group->id; } } } return self::$userGroupPaths[$groupId]; }
/** * Returns false if the current user is not allowed to see this item * * @return bool */ public function isVisible() { $user = JFactory::getUser(); $params = JComponentHelper::getParams('com_eventgallery'); $minUserGroups = $params->get('eventgallery_default_usergroup'); // if no user groups are set at all if (strlen($this->getUserGroupIds()) == 0 && count($minUserGroups) == 0) { return true; } // use the default usergroups if the folder does not define any if (strlen($this->getUserGroupIds()) == 0) { $folderUserGroups = $minUserGroups; } else { $folderUserGroups = explode(',', $this->getUserGroupIds()); } // if the public user group is part of the folder user groups if (in_array(1, $folderUserGroups)) { return true; } $userUserGroups = $user->groups; foreach ($userUserGroups as $userUserGroup) { if (count(array_intersect(EventgalleryHelpersUsergroups::getGroupPath($userUserGroup), $folderUserGroups)) > 0) { return true; } } return false; }
<br> <?php } ?> <?php if (strlen($row->usergroupids) > 0 && $row->usergroupids != '1') { ?> <strong><?php echo JText::_('COM_EVENTGALLERY_EVENTS_USERGROUPS'); ?> </strong><br> <?php $usergroupids = explode(',', $row->usergroupids); $groups = array(); foreach ($usergroupids as $usergroupid) { $groups[] = EventgalleryHelpersUsergroups::getUserGroupName($usergroupid); } echo implode(',', $groups); ?> <br> <?php } ?> </small> </td> <td class="center"> <a href="<?php echo JRoute::_('index.php?option=com_eventgallery&view=comments&filter=folder=' . $row->folder); ?> "> <?php