function loadAllowedCategories($user) { $user = JFactory::getUser($user); $accesslevels = (array) $user->authorisedLevels(); $groups_r = (array) JAccess::getGroupsByUser($user->id, true); $groups = (array) JAccess::getGroupsByUser($user->id, false); $categories = KunenaCategory::loadCategories(); $catlist = array(); foreach ($categories as $category) { // Check if user is a moderator if (self::isModerator($user->id, $category->id)) { $catlist[$category->id] = $category->id; } elseif ($category->accesstype == 'joomla.level') { if (in_array($category->access, $accesslevels)) { $catlist[$category->id] = $category->id; } } elseif ($category->accesstype == 'none') { $pub_access = in_array($category->pub_access, $category->pub_recurse ? $groups_r : $groups); $admin_access = in_array($category->admin_access, $category->admin_recurse ? $groups_r : $groups); if ($pub_access || $admin_access) { $catlist[$category->id] = $category->id; } } } return $catlist; }
protected function loadAllowedCategories($user) { $user = JFactory::getUser($user); $db = JFactory::getDBO(); // Get Joomla group for current user if ($user->id != 0) { $acl = JFactory::getACL(); $gid = $acl->getAroGroup($user->id)->id; } else { $gid = 0; } // Get NoixACL multigroups for current user $query = "SELECT g.id\n\t\tFROM #__core_acl_aro_groups AS g\n\t\tINNER JOIN #__noixacl_multigroups AS m\n\t\tWHERE g.id = m.id_group AND m.id_user = {$db->quote($user->id)}"; $db->setQuery($query); $multigroups = (array) $db->loadResultArray(); $multigroups[] = $user->gid; if (KunenaError::checkDatabaseError()) { return array(); } // Get NoixACL access levels for all user groups $groups = implode(',', $multigroups); $query = "SELECT l.id_levels\n\t\tFROM #__noixacl_groups_level AS l\n\t\tWHERE l.id_group IN ({$groups})"; $db->setQuery($query); $levels = array_unique(explode(',', implode(',', (array) $db->loadResultArray()))); if (KunenaError::checkDatabaseError()) { return array(); } $categories = KunenaCategory::loadCategories(); $catlist = array(); foreach ($categories as $category) { // Check if user is a moderator if (self::isModerator($user->id, $category->id)) { $catlist[$category->id] = $category->id; } elseif ($category->accesstype == 'joomla') { if ($category->access <= $user->get('aid')) { $catlist[$category->id] = $category->id; } } elseif ($category->accesstype == 'noixacl') { if (in_array($category->access, $levels)) { $catlist[$category->id] = $category->id; } } elseif ($category->accesstype == 'none') { if ($category->pub_access == 0 || $user->id > 0 && ($category->pub_access == -1 || $category->pub_access > 0 && self::_has_rights($multigroups, $category->pub_access, $category->pub_recurse) || $category->admin_access > 0 && self::_has_rights($multigroups, $category->admin_access, $category->admin_recurse))) { $catlist[$category->id] = $category->id; } } } return $catlist; }
protected function loadAllowedCategories($user) { $user = JFactory::getUser($user); // Workaround for missing aid $my = JFactory::getUser(); if ($user->id == $my->id) { // Current user $user = $my; } elseif ($user->id) { // Other users $aid->aid = 1; $acl = JFactory::getACL(); $grp = $acl->getAroGroup($user->id); if ($acl->is_group_child_of($grp->name, 'Registered') || $acl->is_group_child_of($grp->name, 'Public Backend')) { $user->aid = 2; } } // Get all Joomla user groups for current user $usergroups = $this->_get_user_groups($user->id); $categories = KunenaCategory::loadCategories(); $catlist = array(); foreach ($categories as $category) { // Check if user is a moderator if (self::isModerator($user->id, $category->id)) { $catlist[$category->id] = $category->id; } elseif ($category->accesstype == 'joomla.level') { // 0 = Public, 1 = Registered, 2 = Special if ($category->access <= $user->get('aid')) { $catlist[$category->id] = $category->id; } } elseif ($category->accesstype == 'none') { // pub_access: 0 = Public, -1 = All registered, 1 = Nobody, >1 = Group ID // admin_access: 0 = Nobody, >1 = Group ID if ($category->pub_access == 0 || $user->id > 0 && $category->pub_access == -1 || $category->pub_access > 1 && self::_has_rights($usergroups, $category->pub_access, $category->pub_recurse) || $category->pub_access > 0 && $category->admin_access > 0 && $category->admin_access != $category->pub_access && self::_has_rights($usergroups, $category->admin_access, $category->admin_recurse)) { $catlist[$category->id] = $category->id; } } } return $catlist; }
function deleteForum($cid = null, $option) { $redirect = JURI::base() . "index.php?option={$option}&task=showAdministration"; $kunena_app = JFactory::getApplication(); if (!JRequest::checkToken()) { $kunena_app->enqueueMessage(JText::_('COM_KUNENA_ERROR_TOKEN'), 'error'); while (@ob_end_clean()) { } $kunena_app->redirect($redirect); } if (empty($cid)) { $kunena_app->enqueueMessage(JText::_('COM_KUNENA_A_NO_CATEGORIES_SELECTED'), 'notice'); while (@ob_end_clean()) { } $kunena_app->redirect($redirect); } kimport('category'); $categories = KunenaCategory::loadCategories($cid); $kunena_my = JFactory::getUser(); foreach ($categories as $category) { if (!$category->isCheckedOut($kunena_my->id)) { if (!$category->delete()) { $kunena_app->enqueueMessage(JText::sprintf('COM_KUNENA_A_CATEGORY_DELETE_FAILED', $category->id, $category->getError()), 'notice'); } else { $catid[] = $category->id; } } else { $kunena_app->enqueueMessage(JText::sprintf('COM_KUNENA_A_CATEGORY_CHECKED_OUT', $category->id), 'notice'); } } while (@ob_end_clean()) { } $kunena_app->redirect($redirect); }