本文整理汇总了PHP中KunenaAccess类的典型用法代码示例。如果您正苦于以下问题:PHP KunenaAccess类的具体用法?PHP KunenaAccess怎么用?PHP KunenaAccess使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了KunenaAccess类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: before
/**
* Prepare search results display.
*
* @return void
*/
protected function before()
{
parent::before();
require_once KPATH_SITE . '/models/search.php';
$this->model = new KunenaModelSearch(array(), $this->input);
$this->model->initialize($this->getOptions(), $this->getOptions()->get('embedded', false));
$this->state = $this->model->getState();
$this->me = KunenaUserHelper::getMyself();
$this->message_ordering = $this->me->getMessageOrdering();
$this->searchwords = $this->model->getSearchWords();
$this->isModerator = ($this->me->isAdmin() || KunenaAccess::getInstance()->getModeratorStatus());
$this->results = array();
$this->total = $this->model->getTotal();
$this->results = $this->model->getResults();
$this->pagination = new KunenaPagination(
$this->total,
$this->state->get('list.start'),
$this->state->get('list.limit')
);
$this->error = $this->model->getError();
}
示例2: prepareTopics
/**
* Prepare topics by pre-loading needed information.
*
* @param array $userIds List of additional user Ids to be loaded.
* @param array $mesIds List of additional message Ids to be loaded.
*
* @return void
*/
protected function prepareTopics(array $userIds = array(), array $mesIds = array())
{
// Collect user Ids for avatar prefetch when integrated.
$lastIds = array();
foreach ($this->topics as $topic) {
$userIds[(int) $topic->first_post_userid] = (int) $topic->first_post_userid;
$userIds[(int) $topic->last_post_userid] = (int) $topic->last_post_userid;
$lastIds[(int) $topic->last_post_id] = (int) $topic->last_post_id;
}
// Prefetch all users/avatars to avoid user by user queries during template iterations.
if (!empty($userIds)) {
KunenaUserHelper::loadUsers($userIds);
}
$topicIds = array_keys($this->topics);
KunenaForumTopicHelper::getUserTopics($topicIds);
/* KunenaForumTopicHelper::getKeywords($topicIds); */
$mesIds += KunenaForumTopicHelper::fetchNewStatus($this->topics);
// Fetch also last post positions when user can see unapproved or deleted posts.
// TODO: Optimize? Take account of configuration option...
if ($this->me->isAdmin() || KunenaAccess::getInstance()->getModeratorStatus()) {
$mesIds += $lastIds;
}
// Load position information for all selected messages.
if ($mesIds) {
KunenaForumMessageHelper::loadLocation($mesIds);
}
}
示例3: displayDefault
function displayDefault($tpl = null)
{
$this->message_ordering = $this->me->getMessageOrdering();
//TODO: Need to move the select markup outside of view. Otherwise difficult to stylize
$this->searchwords = $this->get('SearchWords');
$this->isModerator = ($this->me->isAdmin() || KunenaAccess::getInstance()->getModeratorStatus($this->me));
$this->results = array();
$this->total = $this->get('Total');
if ($this->total)
{
$this->results = $this->get('Results');
$this->search_class = ' open';
$this->search_style = ' style="display: none;"';
$this->search_title = JText::_('COM_KUNENA_TOGGLER_EXPAND');
}
else
{
$this->search_class = ' close';
$this->search_style = '';
$this->search_title = JText::_('COM_KUNENA_TOGGLER_COLLAPSE');
}
$this->selected = ' selected="selected"';
$this->checked = ' checked="checked"';
$this->error = $this->get('Error');
$this->_prepareDocument();
$this->render('Search', $tpl);
}
示例4: getInstance
public static function getInstance() {
KUNENA_PROFILER ? KunenaProfiler::instance()->start('function '.__CLASS__.'::'.__FUNCTION__.'()') : null;
if (!self::$instance) {
self::$instance = new KunenaAccess();
}
KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function '.__CLASS__.'::'.__FUNCTION__.'()') : null;
return self::$instance;
}
示例5: onAfterReply
public function onAfterReply($message)
{
if (JString::strlen($message->message) > $this->params->get('activity_points_limit', 0)) {
CFactory::load('libraries', 'userpoints');
CUserPoints::assignPoint('com_kunena.thread.reply');
}
// Get users who have subscribed to the topic, excluding current user.
$acl = KunenaAccess::getInstance();
$subscribers = $acl->getSubscribers($message->catid, $message->thread, KunenaAccess::TOPIC_SUBSCRIPTION, false, false, array($message->userid));
foreach ($subscribers as $userid) {
$actor = CFactory::getUser($message->userid);
$target = CFactory::getUser($userid);
$params = new CParameter('');
$params->set('actorName', $actor->getDisplayName());
$params->set('recipientName', $target->getDisplayName());
$params->set('url', JUri::getInstance()->toString(array('scheme', 'host', 'port')) . $message->getPermaUrl(null));
// {url} tag for activity. Used when hovering over avatar in notification window, as well as in email notification
$params->set('title', $message->displayField('subject'));
// (title) tag in language file
$params->set('title_url', $message->getPermaUrl());
// Make the title in notification - linkable
$params->set('message', $message->displayField('message'));
// (message) tag in language file
$params->set('actor', $actor->getDisplayName());
// Actor in the stream
$params->set('actor_url', 'index.php?option=com_community&view=profile&userid=' . $actor->id);
// Actor Link
// Finally, send notifications
CNotificationLibrary::add('kunena_reply', $actor->id, $target->id, JText::sprintf('PLG_KUNENA_COMMUNITY_ACTIVITY_REPLY_TITLE_ACT'), JText::sprintf('PLG_KUNENA_COMMUNITY_ACTIVITY_REPLY_TEXT'), '', $params);
}
/* Activity stream */
$act = new stdClass();
$act->cmd = 'wall.write';
$act->actor = $message->userid;
$act->target = 0;
// no target
$act->title = JText::_('{single}{actor}{/single}{multiple}{actors}{/multiple} ' . JText::sprintf('PLG_KUNENA_COMMUNITY_ACTIVITY_REPLY_TITLE', '<a href="' . $message->getTopic()->getUrl() . '">' . $message->subject . '</a>'));
$act->content = $this->buildContent($message);
$act->app = 'kunena.thread.reply';
$act->cid = $message->thread;
$act->access = $this->getAccess($message->getCategory());
// Comments and like support
$act->comment_id = $message->thread;
$act->comment_type = 'kunena.thread.reply';
$act->like_id = $message->thread;
$act->like_type = 'kunena.thread.reply';
// Do not add private activities
if ($act->access > 20) {
return;
}
CFactory::load('libraries', 'activities');
$table = CActivityStream::add($act);
if (is_object($table)) {
$table->like_id = $table->id;
$table->store();
}
}
示例6: before
/**
* Prepare search form display.
*
* @return void
*/
protected function before()
{
parent::before();
require_once KPATH_SITE . '/models/search.php';
$this->model = new KunenaModelSearch(array(), $this->input);
$this->model->initialize($this->getOptions(), $this->getOptions()->get('embedded', false));
$this->state = $this->model->getState();
$this->me = KunenaUserHelper::getMyself();
$this->isModerator = $this->me->isAdmin() || KunenaAccess::getInstance()->getModeratorStatus();
$this->error = $this->model->getError();
}
示例7: displaySubscriptions
function displaySubscriptions()
{
$id = $this->app->input->get('id', 0, 'int');
$topic = KunenaForumTopicHelper::get($id);
$acl = KunenaAccess::getInstance();
$cat_subscribers = $acl->loadSubscribers($topic, KunenaAccess::CATEGORY_SUBSCRIPTION);
$this->cat_subscribers_users = KunenaUserHelper::loadUsers($cat_subscribers);
$topic_subscribers = $acl->loadSubscribers($topic, KunenaAccess::TOPIC_SUBSCRIPTION);
$this->topic_subscribers_users = KunenaUserHelper::loadUsers($topic_subscribers);
$this->cat_topic_subscribers = $acl->getSubscribers($topic->getCategory()->id, $id, KunenaAccess::CATEGORY_SUBSCRIPTION | KunenaAccess::TOPIC_SUBSCRIPTION, 1, 1);
$this->display();
}
示例8: populateState
protected function populateState() {
$active = $this->app->getMenu ()->getActive ();
$active = $active ? (int) $active->id : 0;
$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 = KunenaAccess::getInstance();
$value = $access->getAllowedHold($this->me, $catid);
$this->setState ( 'hold', $value );
$value = $this->getInt ( 'limit', 0 );
if ($value < 1 || $value > 100) $value = $this->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 = $this->config->default_sort == 'asc' ? 'asc' : 'desc';
}
}
if ($value != 'asc')
$value = 'desc';
$this->setState ( 'list.direction', $value );
}
示例9: save
function save()
{
$db = JFactory::getDBO();
if (!JRequest::checkToken()) {
$this->app->enqueueMessage(JText::_('COM_KUNENA_ERROR_TOKEN'), 'error');
$this->app->redirect(KunenaRoute::_($this->baseurl, false));
}
$newview = JRequest::getVar('newview');
$newrank = JRequest::getVar('newrank');
$signature = JRequest::getVar('signature');
$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;
}
$this->app->enqueueMessage(JText::_('COM_KUNENA_USER_PROFILE_SAVED_SUCCESSFULLY'));
// Update moderator rights
$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 ($this->me->isAdmin()) {
KunenaAccess::getInstance()->setModerator(0, $user, in_array(0, $modCatids));
}
$this->app->redirect(KunenaRoute::_($this->baseurl, false));
}
示例10: displayForumJump
function displayForumJump($tpl = null)
{
if ($this->offline) {
return;
}
$allowed = md5(serialize(KunenaAccess::getInstance()->getAllowedCategories()));
$cache = JFactory::getCache('com_kunena', 'output');
if ($cache->start("{$this->ktemplate->name}.common.jump.{$allowed}", 'com_kunena.template')) {
return;
}
$options = array();
$options[] = JHtml::_('select.option', '0', JText::_('COM_KUNENA_FORUM_TOP'));
$cat_params = array('sections' => 1, 'catid' => 0);
$this->categorylist = JHtml::_('kunenaforum.categorylist', 'catid', 0, $options, $cat_params, 'class="inputbox fbs" size="1" onchange = "this.form.submit()"', 'value', 'text', $this->catid);
$result = $this->loadTemplateFile($tpl);
if (JError::isError($result)) {
return $result;
}
echo $result;
$cache->end();
}
示例11: before
/**
* Prepare topic list for moderators.
*
* @return void
*/
protected function before()
{
parent::before();
$this->me = KunenaUserHelper::getMyself();
$access = KunenaAccess::getInstance();
$this->moreUri = null;
$params = $this->app->getParams('com_kunena');
$start = $this->input->getInt('limitstart', 0);
$limit = $this->input->getInt('limit', 0);
if ($limit < 1 || $limit > 100) {
$limit = $this->config->threads_per_page;
}
// Get configuration from menu item.
$categoryIds = $params->get('topics_categories', array());
$reverse = !$params->get('topics_catselection', 1);
// Make sure that category list is an array.
if (!is_array($categoryIds)) {
$categoryIds = explode(',', $categoryIds);
}
if (!$reverse && empty($categoryIds) || in_array(0, $categoryIds)) {
$categoryIds = false;
}
$categories = KunenaForumCategoryHelper::getCategories($categoryIds, $reverse);
$finder = new KunenaForumTopicFinder();
$finder->filterByCategories($categories)->filterAnsweredBy(array_keys($access->getModerators() + $access->getAdmins()), true)->filterByMoved(false)->where('locked', '=', 0);
$this->pagination = new KunenaPagination($finder->count(), $start, $limit);
if ($this->moreUri) {
$this->pagination->setUri($this->moreUri);
}
$this->topics = $finder->order('last_post_time', -1)->start($this->pagination->limitstart)->limit($this->pagination->limit)->find();
if ($this->topics) {
$this->prepareTopics();
}
$actions = array('delete', 'approve', 'undelete', 'move', 'permdelete');
$this->actions = $this->getTopicActions($this->topics, $actions);
// TODO <-
$this->headerText = JText::_('Topics Needing Attention');
}
示例12: getListmodcats
public function getListmodcats()
{
$user = $this->getUser();
$modCatList = array_keys(KunenaAccess::getInstance()->getModeratorStatus($user));
if (empty($modCatList)) {
$modCatList[] = 0;
}
$categoryList = array();
if ($this->me->isAdmin()) {
$categoryList[] = JHtml::_('select.option', 0, JText::_('COM_KUNENA_GLOBAL_MODERATOR'));
}
$params = array('sections' => false, 'action' => 'read');
$modCats = JHtml::_('kunenaforum.categorylist', 'catid[]', 0, $categoryList, $params, 'class="inputbox" multiple="multiple" size="15"', 'value', 'text', $modCatList, 'kforums');
return $modCats;
}
示例13: getType
/**
* @param int $catid
* @param bool|string $code
*
* @return string
*/
public function getType($catid = 0, $code = false)
{
static $types = array('admin' => 'COM_KUNENA_VIEW_ADMIN', 'globalmod' => 'COM_KUNENA_VIEW_GLOBAL_MODERATOR', 'moderator' => 'COM_KUNENA_VIEW_MODERATOR', 'user' => 'COM_KUNENA_VIEW_USER', 'guest' => 'COM_KUNENA_VIEW_VISITOR', 'banned' => 'COM_KUNENA_VIEW_BANNED', 'blocked' => 'COM_KUNENA_VIEW_BANNED');
$moderatedCategories = KunenaAccess::getInstance()->getModeratorStatus($this);
if (!$this->_type) {
if ($this->userid == 0) {
$this->_type = 'guest';
} elseif ($this->isBanned()) {
$this->_type = 'banned';
} elseif ($this->isAdmin(KunenaForumCategoryHelper::get($catid))) {
$this->_type = 'admin';
} elseif ($this->isModerator(null)) {
$this->_type = 'globalmod';
} elseif (!$catid && !empty($moderatedCategories)) {
$this->_type = 'moderator';
} elseif ($catid && isset($moderatedCategories[$catid])) {
$this->_type = 'moderator';
} else {
$this->_type = 'user';
}
$userClasses = KunenaFactory::getTemplate()->getUserClasses();
$this->_class = isset($userClasses[$this->_type]) ? $userClasses[$this->_type] : $userClasses[0] . $this->_type;
}
return $code == 'class' ? $this->_class : ($code == false ? $types[$this->_type] : $this->_type);
}
示例14:
?>
<label id="childforums-lbl">
<input type="checkbox" name="childforums" value="1" <?php
if ($this->state->get('query.childforums')) {
echo 'checked="checked"';
}
?>
/>
<span onclick="document.searchform.childforums.checked=(! document.searchform.childforums.checked);"><?php
echo JText::_('COM_KUNENA_SEARCH_SEARCHIN_CHILDREN');
?>
</span>
</label>
</fieldset>
<?php
if (KunenaAccess::getInstance()->getModeratorStatus()) {
?>
<fieldset class="fieldset">
<legend><?php
echo JText::_('COM_KUNENA_SEARCH_SHOW');
?>
</legend>
<input id="show0" type="radio" name="show" value="0" <?php
if ($this->state->get('query.show') == 0) {
echo 'checked="checked"';
}
?>
/>
<label for="show0"><?php
echo JText::_('COM_KUNENA_SEARCH_SHOW_NORMAL');
?>
示例15: getSubscribers
/**
* Get a list of subscribers for a thread
*
* @since 5.0
* @access public
* @param string
* @return
*/
public function getSubscribers($message)
{
$config = KunenaFactory::getConfig();
if ($message->hold > 1) {
return false;
} elseif ($message->hold == 1) {
$mailsubs = 0;
$mailmods = $config->mailmod >= 0;
$mailadmins = $config->mailadmin >= 0;
} else {
$mailsubs = (bool) $config->allowsubscriptions;
$mailmods = $config->mailmod >= 1;
$mailadmins = $config->mailadmin >= 1;
}
$once = false;
if ($mailsubs) {
if (!$message->parent) {
// New topic: Send email only to category subscribers
$mailsubs = $config->category_subscriptions != 'disabled' ? KunenaAccess::CATEGORY_SUBSCRIPTION : 0;
$once = $config->category_subscriptions == 'topic';
} elseif ($config->category_subscriptions != 'post') {
// Existing topic: Send email only to topic subscribers
$mailsubs = $config->topic_subscriptions != 'disabled' ? KunenaAccess::TOPIC_SUBSCRIPTION : 0;
$once = $config->topic_subscriptions == 'first';
} else {
// Existing topic: Send email to both category and topic subscribers
$mailsubs = $config->topic_subscriptions == 'disabled' ? KunenaAccess::CATEGORY_SUBSCRIPTION : KunenaAccess::CATEGORY_SUBSCRIPTION | KunenaAccess::TOPIC_SUBSCRIPTION;
// FIXME: category subcription can override topic
$once = $config->topic_subscriptions == 'first';
}
}
//get all subscribers, moderators and admins who will get the email
$me = KunenaUserHelper::get();
$acl = KunenaAccess::getInstance();
$subscribers = $acl->getSubscribers($message->catid, $message->thread, $mailsubs, $mailmods, $mailadmins, $me->userid);
if (!$subscribers) {
return false;
}
$result = array();
foreach ($subscribers as $subscriber) {
if ($subscriber->id) {
$result[] = $subscriber->id;
}
}
return $result;
}