protected function _get_user_groups($userid) { static $cache = array(); $userid = intval($userid); if (!$userid) { return array(29); } if (!isset($cache[$userid])) { $db = JFactory::getDbo(); $query = new KunenaDatabaseQuery(); $query->select('g.id'); $query->from('#__core_acl_aro AS o'); $query->join('INNER', '#__core_acl_groups_aro_map AS gm ON gm.aro_id=o.id'); $query->join('INNER', '#__core_acl_aro_groups AS g ON g.id = gm.group_id'); $query->where("(o.section_value='users' AND o.value=" . $db->quote($userid) . ')'); $db->setQuery($query); $cache[$userid] = $db->loadResultArray(); } return $cache[$userid]; }
/** * JXtended: Grabs all groups mapped to an ARO. * * A root group value can be specified for looking at sub-tree * (results include the root group) * * @param string The section value or the ARO or AXO * @param string The value of the ARO or AXO * @param integer The value of the group to start at (optional) * @param string The type of group, either ARO or AXO (optional) */ protected function acl_get_groups($sectionValue, $value, $rootGroupValue=NULL, $type='ARO') { static $cache = null; $db = JFactory::getDbo(); $type = strtolower($type); if ($type != 'aro' && $type != 'axo') { return array(); } if (($sectionValue === '' || $sectionValue === null) && ($value === '' || $value === null)) { return array(); } // Simple cache if ($cache === null) { $cache = array(); } // Generate unique cache id. $cacheId = 'acl_get_groups_'.$sectionValue.'-'.$value.'-'.$rootGroupValue.'-'.$type; if (!isset($cache[$cacheId])) { $query = new KunenaDatabaseQuery(); // Make sure we get the groups $query->select('DISTINCT g2.id'); $query->from('#__core_acl_'.$type.' AS o'); $query->join('INNER', '#__core_acl_groups_'.$type.'_map AS gm ON gm.'. $type .'_id=o.id'); $query->join('INNER', '#__core_acl_'.$type.'_groups AS g1 ON g1.id = gm.group_id'); $query->where('(o.section_value='. $db->quote($sectionValue) .' AND o.value='. $db->quote($value) .')'); /* * If root group value is specified, we have to narrow this query down * to just groups deeper in the tree then what is specified. * This essentially creates a virtual "subtree" and ignores all outside groups. * Useful for sites like sourceforge where you may seperate groups by "project". */ if ( $rootGroupValue != '') { $query->join('INNER', '#__core_acl_'.$type.'_groups AS g3 ON g3.value='. $db->quote($rootGroupValue)); $query->join('INNER', '#__core_acl_'.$type.'_groups AS g2 ON ((g2.lft BETWEEN g3.lft AND g1.lft) AND (g2.rgt BETWEEN g1.rgt AND g3.rgt))'); } else { $query->join('INNER', '#__core_acl_'.$type.'_groups AS g2 ON (g2.lft <= g1.lft AND g2.rgt >= g1.rgt)'); } $db->setQuery($query); $cache[$cacheId] = $db->loadResultArray(); } return $cache[$cacheId]; }
protected function checkSubscribers($category, &$userids) { $userlist = implode(',', $userids); $db = JFactory::getDBO(); $query = new KunenaDatabaseQuery(); $query->select('u.id'); $query->from('#__users AS u'); $query->where("u.block=0"); $query->where("u.id IN ({$userlist})"); if ($category->accesstype == 'joomla') { // Check against Joomla access level if ($category->access > 1) { // Special users = not in registered group $query->where("u.gid!=18"); } } elseif ($category->accesstype == 'none') { // Check against Joomla user groups $public = $this->_get_groups($category->pub_access, $category->pub_recurse); $admin = $category->pub_access > 0 ? $this->_get_groups($category->admin_access, $category->admin_recurse) : array(); $groups = implode(',', array_unique(array_merge($public, $admin))); if ($groups) { $query->join('LEFT', "#__noixacl_multigroups AS g ON g.id_user=u.id"); $query->where("(u.gid IN ({$groups}) OR g.id_group IN ({$groups}))"); } } else { return array(); } $db->setQuery($query); $userids = (array) $db->loadResultArray(); KunenaError::checkDatabaseError(); }