本文整理汇总了PHP中KunenaFactory::getAccessControl方法的典型用法代码示例。如果您正苦于以下问题:PHP KunenaFactory::getAccessControl方法的具体用法?PHP KunenaFactory::getAccessControl怎么用?PHP KunenaFactory::getAccessControl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KunenaFactory
的用法示例。
在下文中一共展示了KunenaFactory::getAccessControl方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: populateState
protected function populateState() {
$app = JFactory::getApplication ();
$this->me = KunenaUserHelper::get();
$config = KunenaFactory::getConfig ();
$active = $app->getMenu ()->getActive ();
$active = $active ? (int) $active->id : 0;
$layout = $this->getWord ( 'layout', 'default' );
$layout = $this->me->getTopicLayout ();
$this->setState ( 'layout', $layout );
$template = KunenaFactory::getTemplate();
$profile_location = $template->params->get('avatarPosition', 'left');
$profile_direction = $profile_location == 'left' || $profile_location == 'right' ? 'vertical' : 'horizontal';
$this->setState ( 'profile.location', $profile_location );
$this->setState ( 'profile.direction', $profile_direction );
$catid = $this->getInt ( 'catid', 0 );
$this->setState ( 'item.catid', $catid );
$id = $this->getInt ( 'id', 0 );
$this->setState ( 'item.id', $id );
$id = $this->getInt ( 'mesid', 0 );
$this->setState ( 'item.mesid', $id );
$access = KunenaFactory::getAccessControl();
$value = $access->getAllowedHold($this->me, $catid);
$this->setState ( 'hold', $value );
$value = $this->getInt ( 'limit', 0 );
if ($value < 1) $value = $config->messages_per_page;
$this->setState ( 'list.limit', $value );
$value = $this->getUserStateFromRequest ( "com_kunena.topic_{$active}_{$layout}_list_ordering", 'filter_order', 'time', 'cmd' );
//$this->setState ( 'list.ordering', $value );
$value = $this->getInt ( 'limitstart', 0 );
if ($value < 0) $value = 0;
$this->setState ( 'list.start', $value );
$value = $this->getUserStateFromRequest ( "com_kunena.topic_{$active}_{$layout}_list_direction", 'filter_order_Dir', '', 'word' );
if (!$value) {
if ($this->me->ordering != '0') {
$value = $this->me->ordering == '1' ? 'desc' : 'asc';
} else {
$value = $config->default_sort == 'asc' ? 'asc' : 'desc';
}
}
if ($value != 'asc')
$value = 'desc';
$this->setState ( 'list.direction', $value );
}
示例2: getDatabaseError
function getDatabaseError() {
$db = JFactory::getDBO();
if ($db->getErrorNum ()) {
$app = JFactory::getApplication();
$my = JFactory::getUser();
$acl = KunenaFactory::getAccessControl();
if ($acl->isAdmin ($my)) {
return $db->getErrorMsg();
} else {
return 'Kunena '.JText::_ ( 'COM_KUNENA_INTERNAL_ERROR' );
}
}
}
示例3: __construct
function __construct($func, $page = 0)
{
$this->func = JString::strtolower($func);
$this->userid = JRequest::getInt('userid');
if (!$this->userid) {
$this->userid = null;
}
$this->catid = 0;
$this->hasSubCats = '';
$this->mode = 'threads';
$this->header = '';
$this->db = JFactory::getDBO();
$this->user = JFactory::getUser($this->userid);
$this->my = JFactory::getUser();
$this->myprofile = KunenaFactory::getUser();
$this->session = KunenaFactory::getSession();
$this->config = KunenaFactory::getConfig();
$this->latestcategory = explode(',', $this->config->latestcategory);
$this->latestcategory_in = $this->config->latestcategory_in;
$this->page = $page < 1 ? 1 : $page;
$this->threads_per_page = $this->config->threads_per_page;
$this->offset = ($this->page - 1) * $this->threads_per_page;
$this->prevCheck = $this->session->lasttime;
$this->app =& JFactory::getApplication();
$this->document =& JFactory::getDocument();
$this->show_list_time = JRequest::getInt('sel', $this->config->show_list_time);
$this->allow = 1;
$this->highlight = 0;
$this->tabclass = array("row1", "row2");
if (!$this->my->id && $this->show_list_time == 0) {
$this->show_list_time = $this->config->show_list_time;
}
$this->columns = CKunenaTools::isModerator($this->my->id, $this->catid) ? 6 : 5;
$this->showposts = 0;
$access = KunenaFactory::getAccessControl();
$this->hold = $access->getAllowedHold($this->myprofile, $this->catid);
$template = KunenaFactory::getTemplate();
$this->params = $template->params;
$this->actionDropdown[] = JHTML::_('select.option', '', JText::_('COM_KUNENA_BULK_CHOOSE_ACTION'));
}
示例4: isModerator
public function isModerator($catid = 0) {
$acl = KunenaFactory::getAccessControl ();
return $acl->isModerator ( $this, $catid );
}
示例5: testRemoveModerator
/**
* Test removeModerator()
*
* @param KunenaForumCategory $category
* @return KunenaForumCategory
* @depends testAddModerator
*/
public function testRemoveModerator(KunenaForumCategory $category) {
$admin = KunenaFactory::getUser('admin');
$access = KunenaFactory::getAccessControl ();
$this->assertTrue($category->removeModerator($admin), "Check that administrator can loose moderator status ({$category->getError()})");
$this->assertFalse((bool)$admin->moderator, "Check that user is not moderator");
$mod = $access->getModeratorStatus ($admin);
$this->assertTrue(empty($mod[$category->id]), "Check that user is not category moderator");
return $category;
}
示例6: getCategories
static public function getCategories($ids = false, $reverse = false, $authorise='read') {
KUNENA_PROFILER ? KunenaProfiler::instance()->start('function '.__CLASS__.'::'.__FUNCTION__.'()') : null;
if (self::$_instances === false) {
self::loadCategories();
}
if ($ids === false) {
$ids = self::$_instances;
if ($authorise == 'none') {
KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function '.__CLASS__.'::'.__FUNCTION__.'()') : null;
return $ids;
}
} elseif (is_array ($ids) ) {
$ids = array_flip($ids);
} else {
$ids = array(intval($ids)=>1);
}
$list = array ();
if (!$reverse) {
$allowed = $authorise != 'none' ? array_intersect_key($ids, KunenaFactory::getAccessControl ()->getAllowedCategories ( null, 'read' )) : $ids;
$list = array_intersect_key(self::$_instances, $allowed);
if ($authorise != 'none' && $authorise != 'read') {
foreach ( $list as $category ) {
if (!$category->authorise($authorise, null, true)) {
unset($list [$category->id]);
}
}
}
} else {
$allowed = $authorise != 'none' ? array_intersect_key(self::$_instances, KunenaFactory::getAccessControl ()->getAllowedCategories ( null, 'read' )) : self::$_instances;
$list = array_diff_key($allowed, $ids);
if ($authorise != 'none' && $authorise != 'read') {
foreach ( $list as $category ) {
if (!$category->authorise($authorise, null, true)) {
unset($list [$category->id]);
}
}
}
}
KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function '.__CLASS__.'::'.__FUNCTION__.'()') : null;
return $list;
}
示例7: save
function save() {
$db = JFactory::getDBO ();
$app = JFactory::getApplication ();
if (! JRequest::checkToken ()) {
$app->enqueueMessage ( JText::_ ( 'COM_KUNENA_ERROR_TOKEN' ), 'error' );
$app->redirect ( KunenaRoute::_($this->baseurl, false) );
}
$newview = JRequest::getVar ( 'newview' );
$newrank = JRequest::getVar ( 'newrank' );
$signature = JRequest::getVar ( 'message' );
$deleteSig = JRequest::getVar ( 'deleteSig' );
$moderator = JRequest::getInt ( 'moderator' );
$uid = JRequest::getInt ( 'uid' );
$avatar = JRequest::getVar ( 'avatar' );
$deleteAvatar = JRequest::getVar ( 'deleteAvatar' );
$neworder = JRequest::getInt ( 'neworder' );
$modCatids = $moderator ? JRequest::getVar ( 'catid', array () ) : array();
if ($deleteSig == 1) {
$signature = "";
}
$avatar = '';
if ($deleteAvatar == 1) {
$avatar = ",avatar=''";
}
$db->setQuery ( "UPDATE #__kunena_users SET signature={$db->quote($signature)}, view='$newview', ordering='$neworder', rank='$newrank' $avatar WHERE userid='$uid'" );
$db->query ();
if (KunenaError::checkDatabaseError()) return;
$app->enqueueMessage ( JText::_ ( 'COM_KUNENA_USER_PROFILE_SAVED_SUCCESSFULLY' ) );
// Update moderator rights
$me = KunenaUserHelper::getMyself();
$categories = KunenaForumCategoryHelper::getCategories(false, false, 'admin');
$user = KunenaFactory::getUser($uid);
foreach ($categories as $category) {
$category->setModerator($user, in_array($category->id, $modCatids));
}
// Global moderator is a special case
if ($me->isAdmin()) {
KunenaFactory::getAccessControl()->setModerator(0, $user, in_array(0, $modCatids));
}
$app->redirect ( KunenaRoute::_($this->baseurl, false) );
}
示例8: getAdminOptions
public function getAdminOptions() {
$category = $this->getAdminCategory();
if (!$category) return false;
$catList = array ();
$catList [] = JHTML::_ ( 'select.option', 0, JText::_ ( 'COM_KUNENA_TOPLEVEL' ) );
// make a standard yes/no list
$published = array ();
$published [] = JHTML::_ ( 'select.option', 1, JText::_ ( 'COM_KUNENA_PUBLISHED' ) );
$published [] = JHTML::_ ( 'select.option', 0, JText::_ ( 'COM_KUNENA_UNPUBLISHED' ) );
// make a standard yes/no list
$yesno = array ();
$yesno [] = JHTML::_ ( 'select.option', 0, JText::_ ( 'COM_KUNENA_ANN_NO' ) );
$yesno [] = JHTML::_ ( 'select.option', 1, JText::_ ( 'COM_KUNENA_ANN_YES' ) );
//create custom group levels to include into the public group selectList
$pub_groups = array ();
$adm_groups = array ();
$pub_groups [] = JHTML::_ ( 'select.option', 1, JText::_ ( 'COM_KUNENA_NOBODY' ) );
$pub_groups [] = JHTML::_ ( 'select.option', 0, JText::_ ( 'COM_KUNENA_EVERYBODY' ) );
$pub_groups [] = JHTML::_ ( 'select.option', - 1, JText::_ ( 'COM_KUNENA_ALLREGISTERED' ) );
// Create the access control lists
if (version_compare(JVERSION, '1.6','>')) {
// Joomla 1.6
$accessLists ['pub_access'] = JHTML::_ ( 'access.usergroup', 'pub_access', $category->pub_access, 'class="inputbox" size="10"', false);
$accessLists ['admin_access'] = JHTML::_ ( 'access.usergroup', 'admin_access', $category->admin_access, 'class="inputbox" size="10"', false);
} else {
// Joomla 1.5
$pub_groups = array ();
$pub_groups [] = JHTML::_ ( 'select.option', 1, JText::_('COM_KUNENA_NOBODY') );
$pub_groups [] = JHTML::_ ( 'select.option', 0, JText::_('COM_KUNENA_PUBLIC') );
$pub_groups [] = JHTML::_ ( 'select.option', - 1, JText::_('COM_KUNENA_ALLREGISTERED') );
$adm_groups = array ();
$adm_groups [] = JHTML::_ ( 'select.option', 0, JText::_('COM_KUNENA_NOBODY') );
$acl = JFactory::getACL ();
$joomlagroups = $acl->get_group_children_tree ( null, 'USERS', false );
foreach ($joomlagroups as &$group) {
$group->text = preg_replace('/(^ |\. | )/', '- ', $group->text);
}
$pub_groups = array_merge ( $pub_groups, $joomlagroups );
$adm_groups = array_merge ( $adm_groups, $joomlagroups );
// Create the access control lists for Joomla 1.5
$accessLists ['pub_access'] = JHTML::_ ( 'select.genericlist', $pub_groups, 'pub_access', 'class="inputbox" size="10"', 'value', 'text', $category->pub_access );
$accessLists ['admin_access'] = JHTML::_ ( 'select.genericlist', $adm_groups, 'admin_access', 'class="inputbox" size="10"', 'value', 'text', $category->admin_access );
}
// Anonymous posts default
$post_anonymous = array ();
$post_anonymous [] = JHTML::_ ( 'select.option', '0', JText::_ ( 'COM_KUNENA_CATEGORY_ANONYMOUS_X_REG' ) );
$post_anonymous [] = JHTML::_ ( 'select.option', '1', JText::_ ( 'COM_KUNENA_CATEGORY_ANONYMOUS_X_ANO' ) );
$cat_params = array ();
$cat_params['ordering'] = 'ordering';
$cat_params['toplevel'] = JText::_('COM_KUNENA_TOPLEVEL');
$cat_params['sections'] = 1;
$cat_params['unpublished'] = 1;
$cat_params['catid'] = $category->id;
$cat_params['action'] = 'admin';
$channels_params = array();
$channels_params['catid'] = $category->id;
$channels_params['action'] = 'admin';
$channels_options = array();
$channels_options [] = JHTML::_ ( 'select.option', 'THIS', JText::_ ( 'COM_KUNENA_CATEGORY_CHANNELS_OPTION_THIS' ) );
$channels_options [] = JHTML::_ ( 'select.option', 'CHILDREN', JText::_ ( 'COM_KUNENA_CATEGORY_CHANNELS_OPTION_CHILDREN' ) );
if (empty($category->channels)) $category->channels = 'THIS';
$topic_ordering_options = array();
$topic_ordering_options[] = JHTML::_ ( 'select.option', 'lastpost', JText::_ ( 'COM_KUNENA_CATEGORY_TOPIC_ORDERING_OPTION_LASTPOST' ) );
$topic_ordering_options[] = JHTML::_ ( 'select.option', 'creation', JText::_ ( 'COM_KUNENA_CATEGORY_TOPIC_ORDERING_OPTION_CREATION' ) );
$topic_ordering_options[] = JHTML::_ ( 'select.option', 'alpha', JText::_ ( 'COM_KUNENA_CATEGORY_TOPIC_ORDERING_OPTION_ALPHA' ) );
$lists = array ();
$lists ['accesstypes'] = KunenaFactory::getAccessControl()->getAccessTypesList($category);
$lists ['accesslevels'] = KunenaFactory::getAccessControl()->getAccessLevelsList($category);
$lists ['access'] = KunenaFactory::getAccessControl()->getAccessLevelsList($category);
$lists ['pub_access'] = $accessLists ['pub_access'];
$lists ['admin_access'] = $accessLists ['admin_access'];
$lists ['categories'] = JHTML::_('kunenaforum.categorylist', 'parent_id', 0, null, $cat_params, 'class="inputbox"', 'value', 'text', $category->parent_id);
$lists ['channels'] = JHTML::_('kunenaforum.categorylist', 'channels[]', 0, $channels_options, $channels_params, 'class="inputbox" multiple="multiple"', 'value', 'text', explode(',', $category->channels));
$lists ['published'] = JHTML::_ ( 'select.genericlist', $published, 'published', 'class="inputbox"', 'value', 'text', $category->published );
$lists ['pub_recurse'] = JHTML::_ ( 'select.genericlist', $yesno, 'pub_recurse', 'class="inputbox" size="1"', 'value', 'text', $category->pub_recurse );
$lists ['admin_recurse'] = JHTML::_ ( 'select.genericlist', $yesno, 'admin_recurse', 'class="inputbox" size="1"', 'value', 'text', $category->admin_recurse );
$lists ['forumLocked'] = JHTML::_ ( 'select.genericlist', $yesno, 'locked', 'class="inputbox" size="1"', 'value', 'text', $category->locked );
$lists ['forumReview'] = JHTML::_ ( 'select.genericlist', $yesno, 'review', 'class="inputbox" size="1"', 'value', 'text', $category->review );
$lists ['allow_polls'] = JHTML::_ ( 'select.genericlist', $yesno, 'allow_polls', 'class="inputbox" size="1"', 'value', 'text', $category->allow_polls );
$lists ['allow_anonymous'] = JHTML::_ ( 'select.genericlist', $yesno, 'allow_anonymous', 'class="inputbox" size="1"', 'value', 'text', $category->allow_anonymous );
$lists ['post_anonymous'] = JHTML::_ ( 'select.genericlist', $post_anonymous, 'post_anonymous', 'class="inputbox" size="1"', 'value', 'text', $category->post_anonymous );
$lists ['topic_ordering'] = JHTML::_ ( 'select.genericlist', $topic_ordering_options, 'topic_ordering', 'class="inputbox" size="1"', 'value', 'text', $category->topic_ordering );
// TODO:
/*
$topicicons = array ();
jimport( 'joomla.filesystem.folder' );
$topiciconslist = JFolder::folders(JPATH_ROOT.'/media/kunena/topicicons');
foreach( $topiciconslist as $icon ) {
$topicicons[] = JHTML::_ ( 'select.option', $icon, $icon );
//.........这里部分代码省略.........
示例9: editForum
function editForum($id, $option)
{
$kunena_app = JFactory::getApplication();
$kunena_my = JFactory::getUser();
kimport('category');
$category = KunenaCategory::getInstance($id);
if ($category->isCheckedOut($kunena_my->id)) {
$kunena_app->enqueueMessage(JText::sprintf('COM_KUNENA_A_CATEGORY_CHECKED_OUT', $category->id), 'notice');
while (@ob_end_clean()) {
}
$kunena_app->redirect(JURI::base() . "index.php?option={$option}&task=showAdministration");
}
$kunena_db = JFactory::getDBO();
$kunena_acl = JFactory::getACL();
$kunena_config = KunenaFactory::getConfig();
if ($category->exists()) {
$category->checkout($kunena_my->id);
} else {
// New category is by default child of the first section -- this will help new users to do it right
$kunena_db->setQuery("SELECT a.id, a.name FROM #__kunena_categories AS a WHERE parent='0' AND id!='{$category->id}' ORDER BY ordering");
$sections = $kunena_db->loadObjectList();
KunenaError::checkDatabaseError();
$category->parent = empty($sections) ? 0 : $sections[0]->id;
$category->published = 0;
$category->ordering = 9999;
$category->pub_recurse = 1;
$category->admin_recurse = 1;
if (KUNENA_JOOMLA_COMPAT == '1.5') {
$category->accesstype = 'none';
$category->access = 0;
$category->pub_access = 0;
$category->admin_access = 0;
} else {
$category->accesstype = 'joomla.level';
$category->access = 1;
$category->pub_access = 1;
$category->admin_access = 8;
}
$category->moderated = 1;
}
$catList = array();
$catList[] = JHTML::_('select.option', 0, JText::_('COM_KUNENA_TOPLEVEL'));
$categoryList = CKunenaTools::KSelectList('parent', $catList, 'class="inputbox"', true, 'parent', $category->parent);
// make a standard yes/no list
$yesno = array();
$yesno[] = JHTML::_('select.option', '0', JText::_('COM_KUNENA_ANN_NO'));
$yesno[] = JHTML::_('select.option', '1', JText::_('COM_KUNENA_ANN_YES'));
//Create all kinds of Lists
$lists = array();
$accessLists = array();
//create custom group levels to include into the public group selectList
if (KUNENA_JOOMLA_COMPAT == '1.5') {
$pub_groups = array();
$pub_groups[] = JHTML::_('select.option', 1, JText::_('COM_KUNENA_NOBODY'));
$pub_groups[] = JHTML::_('select.option', 0, JText::_('COM_KUNENA_PUBLIC'));
$pub_groups[] = JHTML::_('select.option', -1, JText::_('COM_KUNENA_ALLREGISTERED'));
$adm_groups = array();
$adm_groups[] = JHTML::_('select.option', 0, JText::_('COM_KUNENA_NOBODY'));
$joomlagroups = $kunena_acl->get_group_children_tree(null, 'USERS', false);
foreach ($joomlagroups as &$group) {
$group->text = preg_replace('/(^ |\\. | )/', '- ', $group->text);
}
$pub_groups = array_merge($pub_groups, $joomlagroups);
$adm_groups = array_merge($adm_groups, $joomlagroups);
// Create the access control lists for Joomla 1.5
$accessLists['pub_access'] = JHTML::_('select.genericlist', $pub_groups, 'pub_access', 'class="inputbox" size="10"', 'value', 'text', $category->pub_access);
$accessLists['admin_access'] = JHTML::_('select.genericlist', $adm_groups, 'admin_access', 'class="inputbox" size="10"', 'value', 'text', $category->admin_access);
} else {
// Create the access control lists for Joomla 1.6
$accessLists['pub_access'] = JHTML::_('access.usergroup', 'pub_access', $category->pub_access, 'class="inputbox" size="10"', false);
$accessLists['admin_access'] = JHTML::_('access.usergroup', 'admin_access', $category->admin_access, 'class="inputbox" size="10"', false);
}
// Anonymous posts default
$post_anonymous = array();
$post_anonymous[] = JHTML::_('select.option', '0', JText::_('COM_KUNENA_CATEGORY_ANONYMOUS_X_REG'));
$post_anonymous[] = JHTML::_('select.option', '1', JText::_('COM_KUNENA_CATEGORY_ANONYMOUS_X_ANO'));
$lists['accesstypes'] = KunenaFactory::getAccessControl()->getAccessTypesList($category);
$lists['accesslevels'] = KunenaFactory::getAccessControl()->getAccessLevelsList($category);
$lists['pub_recurse'] = JHTML::_('select.genericlist', $yesno, 'pub_recurse', 'class="inputbox" size="1"', 'value', 'text', $category->pub_recurse);
$lists['admin_recurse'] = JHTML::_('select.genericlist', $yesno, 'admin_recurse', 'class="inputbox" size="1"', 'value', 'text', $category->admin_recurse);
$lists['forumLocked'] = JHTML::_('select.genericlist', $yesno, 'locked', 'class="inputbox" size="1"', 'value', 'text', $category->locked);
$lists['forumModerated'] = JHTML::_('select.genericlist', $yesno, 'moderated', 'class="inputbox" size="1"', 'value', 'text', $category->moderated);
$lists['forumReview'] = JHTML::_('select.genericlist', $yesno, 'review', 'class="inputbox" size="1"', 'value', 'text', $category->review);
$lists['allow_polls'] = JHTML::_('select.genericlist', $yesno, 'allow_polls', 'class="inputbox" size="1"', 'value', 'text', $category->allow_polls);
$lists['allow_anonymous'] = JHTML::_('select.genericlist', $yesno, 'allow_anonymous', 'class="inputbox" size="1"', 'value', 'text', $category->allow_anonymous);
$lists['post_anonymous'] = JHTML::_('select.genericlist', $post_anonymous, 'post_anonymous', 'class="inputbox" size="1"', 'value', 'text', $category->post_anonymous);
//get a list of moderators, if forum/category is moderated
$moderatorList = array();
if ($category->moderated == 1 && $category->exists()) {
$kunena_db->setQuery("SELECT * FROM #__kunena_moderation AS a INNER JOIN #__users as u ON a.userid=u.id where a.catid={$category->id}");
$moderatorList = $kunena_db->loadObjectList();
KunenaError::checkDatabaseError();
}
html_Kunena::editForum($category, $categoryList, $moderatorList, $lists, $accessLists, $option, $kunena_config);
}
示例10: authoriseRead
protected function authoriseRead($user) {
// Check that user can read topic
if (!$this->exists()) {
return JText::_ ( 'COM_KUNENA_NO_ACCESS' );
}
if ($this->hold > 1 || ($this->hold && !$this->getUserTopic($user)->owner)) {
$access = KunenaFactory::getAccessControl();
$hold = $access->getAllowedHold($user->userid, $this->category_id, false);
if (!in_array($this->hold, $hold)) {
return JText::_ ( 'COM_KUNENA_NO_ACCESS' );
}
}
}
示例11: getAllowedForums
function getAllowedForums($uid)
{
$acl = KunenaFactory::getAccessControl();
return $acl->getAllowedCategories($uid);
}
示例12: canRead
public function canRead($action = '-read-')
{
// Load must have been performed successfully!
if (!$this->parent) {
return false;
// Error has already been set, either in construct() or load()
}
// Do not perform rest of the checks to administrators
if (CKunenaTools::isAdmin()) {
return true;
// ACCEPT!
}
// Category must be visible
if (!$this->_session->canRead($this->parent->catid)) {
return $this->setError($action, JText::_('COM_KUNENA_NO_ACCESS'));
}
// Check unapproved, deleted etc messages
$access = KunenaFactory::getAccessControl();
$hold = $access->getAllowedHold($this->_my->id, $this->parent->catid, false);
if ($this->parent->hold == 1 && $this->_my->id == $this->parent->userid) {
// User can see his own post before it gets approved
} else {
if (!in_array($this->parent->hold, $hold) || !in_array($this->parent->topichold, $hold)) {
// User is not allowed to see this post
return $this->setError($action, JText::_('COM_KUNENA_POST_INVALID'));
}
}
return true;
}
示例13: getLocation
public function getLocation($mesid, $direction = 'asc', $hold=null) {
if (!$hold) {
$me = KunenaFactory::getUser();
$access = KunenaFactory::getAccessControl();
$hold = $access->getAllowedHold($me->userid, $mesid, false);
}
if (!isset(self::$_location [$mesid])) {
self::loadLocation(array($mesid));
}
$location = self::$_location [$mesid];
$count = 0;
foreach ($location->hold as $meshold=>$values) {
if (isset($hold[$meshold])) {
$count += $values[$direction = 'asc' ? 'before' : 'after'];
if ($direction == 'both') $count += $values['before'];
}
}
return $count;
}
示例14: GetMessageURL
function GetMessageURL($pid, $catid = 0, $limit = 0, $xhtml = true)
{
$kunena_config = KunenaFactory::getConfig();
$myprofile = KunenaFactory::getUser();
if ($myprofile->ordering != '0') {
$topic_ordering = $myprofile->ordering == '1' ? '>=' : '<=';
} else {
$topic_ordering = $kunena_config->default_sort == 'asc' ? '<=' : '>=';
}
$maxmin = $topic_ordering == '<=' ? 'MAX' : 'MIN';
if ($limit < 1) {
$limit = $kunena_config->messages_per_page;
}
$access = KunenaFactory::getAccessControl();
$hold = $access->getAllowedHold($myprofile, $catid);
$kunena_db = JFactory::getDBO();
// First determine the thread, latest post and number of posts for the post supplied
$kunena_db->setQuery("SELECT a.thread AS thread, {$maxmin}(a.id) AS latest_id, MAX(a.catid) AS catid, COUNT(*) AS totalmessages\n FROM #__kunena_messages AS a, (SELECT thread FROM #__kunena_messages WHERE id={$kunena_db->Quote($pid)}) AS b\n WHERE a.thread = b.thread AND a.hold IN ({$hold}) AND a.id {$topic_ordering} {$kunena_db->Quote($pid)}\n GROUP BY a.thread");
$result = $kunena_db->loadObject();
if (KunenaError::checkDatabaseError()) {
return;
}
if (!is_object($result)) {
return KunenaRoute::_(KUNENA_LIVEURLREL . '&func=showcat&catid=' . $result->catid, $xhtml);
}
return CKunenaLink::GetThreadPageURL('view', $result->catid, $result->thread, ceil($result->totalmessages / $limit), $limit, $result->latest_id, $xhtml);
}
示例15: getCategoryTree
function getCategoryTree(&$xmap, &$parent, &$params, $parentCat)
{
$database =& JFactory::getDBO();
$kunenaSession = KunenaFactory::getSession();
$kunenaSession->updateAllowedForums();
$catlist = $kunenaSession->allowed;
$list = array();
$query = "SELECT id as cat_id, name as cat_title, ordering FROM #__kunena_categories WHERE parent={$parentCat} AND published=1 and id in ({$catlist}) ORDER BY name";
$database->setQuery($query);
$cats = $database->loadObjectList();
/* get list of categories */
$xmap->changeLevel(1);
foreach ($cats as $cat) {
$node = new stdclass();
$node->id = $parent->id;
$node->browserNav = $parent->browserNav;
$node->uid = $parent->uid . 'c' . $cat->cat_id;
$node->name = $cat->cat_title;
$node->priority = $params['cat_priority'];
$node->changefreq = $params['cat_changefreq'];
$node->link = 'index.php?option=com_kunena&func=showcat&catid=' . $cat->cat_id . '&Itemid=' . $parent->id;
$node->expandible = true;
if ($xmap->printNode($node) !== FALSE) {
xmap_com_kunena::getCategoryTree($xmap, $parent, $params, $cat->cat_id);
}
}
if ($params['include_topics']) {
$access = KunenaFactory::getAccessControl();
$hold = $access->getAllowedHold(self::$profile, $parentCat);
$query = "SELECT t.id, t.catid as cat_id, t.subject as forum_name, max(m.time) as modified, count(m.id) as msgcount " . "FROM #__kunena_messages AS t " . "INNER JOIN #__kunena_messages AS m ON t.id = m.thread " . "WHERE t.catid={$parentCat} " . "AND t.hold in ({$hold}) " . "AND t.parent=0 " . $params['days'] . "GROUP BY m.`thread`" . "ORDER BY " . $params['topics_order'] . $params['limit'];
$database->setQuery($query);
#echo str_replace('#__','jos_',$database->getQuery());
$forums = $database->loadObjectList();
//get list of forums
foreach ($forums as $forum) {
$node = new stdclass();
$node->id = $parent->id;
$node->browserNav = $parent->browserNav;
$node->uid = $parent->uid . 't' . $forum->id;
$node->name = $forum->forum_name;
$node->priority = $params['topic_priority'];
$node->changefreq = $params['topic_changefreq'];
$node->modified = intval($forum->modified);
$node->link = 'index.php?option=com_kunena&func=view&catid=' . $forum->cat_id . '&id=' . $forum->id . '&Itemid=' . $parent->id;
$node->expandible = false;
if ($xmap->printNode($node) !== FALSE) {
if ($params['include_pagination'] && $forum->msgcount > self::$config->messages_per_page) {
$msgPerPage = self::$config->messages_per_page;
$threadPages = ceil($forum->msgcount / $msgPerPage);
for ($i = 2; $i <= $threadPages; $i++) {
$subnode = new stdclass();
$subnode->id = $node->id;
$subnode->uid = $node->uid . 'p' . $i;
$subnode->name = "[{$i}]";
$subnode->seq = $i;
$subnode->link = $node->link . '&limit=' . $msgPerPage . '&limitstart=' . ($i - 1) * $msgPerPage;
$subnode->browserNav = $node->browserNav;
$subnode->priority = $node->priority;
$subnode->changefreq = $node->changefreq;
$subnode->modified = $node->modified;
$xmap->printNode($subnode);
}
}
}
}
}
$xmap->changeLevel(-1);
}