本文整理汇总了PHP中KunenaForumCategoryHelper::getCategories方法的典型用法代码示例。如果您正苦于以下问题:PHP KunenaForumCategoryHelper::getCategories方法的具体用法?PHP KunenaForumCategoryHelper::getCategories怎么用?PHP KunenaForumCategoryHelper::getCategories使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KunenaForumCategoryHelper
的用法示例。
在下文中一共展示了KunenaForumCategoryHelper::getCategories方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: prune
function prune()
{
if (!JRequest::checkToken()) {
$this->app->enqueueMessage(JText::_('COM_KUNENA_ERROR_TOKEN'), 'error');
$this->setRedirect(KunenaRoute::_($this->baseurl, false));
return;
}
$categories = KunenaForumCategoryHelper::getCategories(JRequest::getVar('prune_forum', array(0)), false, 'admin');
if (!$categories) {
$this->app->enqueueMessage(JText::_('COM_KUNENA_CHOOSEFORUMTOPRUNE'), 'error');
$this->setRedirect(KunenaRoute::_($this->baseurl, false));
return;
}
// Convert days to seconds for timestamp functions...
$prune_days = JRequest::getInt('prune_days', 36500);
$prune_date = JFactory::getDate()->toUnix() - $prune_days * 86400;
$trashdelete = JRequest::getInt('trashdelete', 0);
$where = array();
$where[] = " AND tt.last_post_time < {$prune_date}";
$controloptions = JRequest::getString('controloptions', 0);
if ($controloptions == 'answered') {
$where[] = 'AND tt.posts>1';
} elseif ($controloptions == 'unanswered') {
$where[] = 'AND tt.posts=1';
} elseif ($controloptions == 'locked') {
$where[] = 'AND tt.locked>0';
} elseif ($controloptions == 'deleted') {
$where[] = 'AND tt.hold IN (2,3)';
} elseif ($controloptions == 'unapproved') {
$where[] = 'AND tt.hold=1';
} elseif ($controloptions == 'shadow') {
$where[] = 'AND tt.moved_id>0';
} elseif ($controloptions == 'normal') {
$where[] = 'AND tt.locked=0';
} elseif ($controloptions == 'all') {
// No filtering
} else {
$where[] = 'AND 0';
}
// Keep sticky topics?
if (JRequest::getInt('keepsticky', 1)) {
$where[] = ' AND tt.ordering=0';
}
$where = implode(' ', $where);
$params = array('where' => $where);
$count = 0;
foreach ($categories as $category) {
if ($trashdelete) {
$count += $category->purge($prune_date, $params);
} else {
$count += $category->trash($prune_date, $params);
}
}
if ($trashdelete) {
$this->app->enqueueMessage("" . JText::_('COM_KUNENA_FORUMPRUNEDFOR') . " " . $prune_days . " " . JText::_('COM_KUNENA_PRUNEDAYS') . "; " . JText::_('COM_KUNENA_PRUNEDELETED') . " {$count} " . JText::_('COM_KUNENA_PRUNETHREADS'));
} else {
$this->app->enqueueMessage("" . JText::_('COM_KUNENA_FORUMPRUNEDFOR') . " " . $prune_days . " " . JText::_('COM_KUNENA_PRUNEDAYS') . "; " . JText::_('COM_KUNENA_PRUNETRASHED') . " {$count} " . JText::_('COM_KUNENA_PRUNETHREADS'));
}
$this->setRedirect(KunenaRoute::_($this->baseurl, false));
}
示例2: getCategories
/**
* Get categories for a specific user.
*
* @param bool|array|int $ids The category ids to load.
* @param mixed $user The user id to load.
*
* @return KunenaForumCategoryUser[]
*/
static public function getCategories($ids = false, $user = null)
{
$user = KunenaUserHelper::get($user);
if ($ids === false)
{
// Get categories which are seen by current user
$ids = KunenaForumCategoryHelper::getCategories();
}
elseif (!is_array ($ids) )
{
$ids = array($ids);
}
// Convert category objects into ids
foreach ($ids as $i => $id)
{
if ($id instanceof KunenaForumCategory) $ids[$i] = $id->id;
}
$ids = array_unique($ids);
self::loadCategories($ids, $user);
$list = array ();
foreach ( $ids as $id )
{
if (!empty(self::$_instances [$user->userid][$id])) {
$list [$id] = self::$_instances [$user->userid][$id];
}
}
return $list;
}
示例3: testGetCategories
/**
* Test getCategories()
*/
public function testGetCategories() {
$categories = KunenaForumCategoryHelper::getCategories();
$categoryusers = KunenaForumCategoryUserHelper::getCategories();
foreach ($categories as $category) {
$this->assertTrue(isset($categoryusers[$category->id]));
$this->assertEquals($category->id, $categoryusers[$category->id]->category_id);
}
}
示例4: getSubscriptions
static public function getSubscriptions($user = null) {
$user = KunenaUserHelper::get($user);
$db = JFactory::getDBO ();
$query = "SELECT category_id FROM #__kunena_user_categories WHERE user_id={$db->Quote($user->userid)} AND subscribed=1";
$db->setQuery ( $query );
$subscribed = (array) $db->loadResultArray ();
if (KunenaError::checkDatabaseError()) return;
return KunenaForumCategoryHelper::getCategories($subscribed);
}
示例5: testGetAllCategories
/**
* Test getCategories()
*/
public function testGetAllCategories() {
$categories = KunenaForumCategoryHelper::getCategories();
$this->assertInternalType('array', $categories);
foreach ($categories as $id=>$category) {
$this->assertEquals($id, $category->id);
$this->assertTrue($category->exists());
$this->assertSame($category, KunenaForumCategoryHelper::get($id));
}
}
示例6: 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) );
}
示例7: 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');
}
示例8: getLatestTopics
/**
* @param mixed $categories
* @param int $limitstart
* @param int $limit
* @param array $params
*
* @return array|KunenaForumTopic[]
*/
public static function getLatestTopics($categories = false, $limitstart = 0, $limit = 0, $params = array())
{
KUNENA_PROFILER ? KunenaProfiler::instance()->start('function ' . __CLASS__ . '::' . __FUNCTION__ . '()') : null;
$db = JFactory::getDBO();
$config = KunenaFactory::getConfig();
if ($limit < 1 && empty($params['nolimit'])) {
$limit = $config->threads_per_page;
}
$reverse = isset($params['reverse']) ? (int) $params['reverse'] : 0;
$orderby = isset($params['orderby']) ? (string) $params['orderby'] : 'tt.last_post_time DESC';
$starttime = isset($params['starttime']) ? (int) $params['starttime'] : 0;
$user = isset($params['user']) ? KunenaUserHelper::get($params['user']) : KunenaUserHelper::getMyself();
$hold = isset($params['hold']) ? (string) $params['hold'] : 0;
$moved = isset($params['moved']) ? (string) $params['moved'] : 0;
$where = isset($params['where']) ? (string) $params['where'] : '';
if (strstr('ut.last_', $orderby)) {
$post_time_field = 'ut.last_post_time';
} elseif (strstr('tt.first_', $orderby)) {
$post_time_field = 'tt.first_post_time';
} else {
$post_time_field = 'tt.last_post_time';
}
$categories = KunenaForumCategoryHelper::getCategories($categories, $reverse);
$catlist = array();
foreach ($categories as $category) {
$catlist += $category->getChannels();
}
if (empty($catlist)) {
KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function ' . __CLASS__ . '::' . __FUNCTION__ . '()') : null;
return array(0, array());
}
$catlist = implode(',', array_keys($catlist));
$whereuser = array();
if (!empty($params['started'])) {
$whereuser[] = 'ut.owner=1';
}
if (!empty($params['replied'])) {
$whereuser[] = '(ut.owner=0 AND ut.posts>0)';
}
if (!empty($params['posted'])) {
$whereuser[] = 'ut.posts>0';
}
if (!empty($params['favorited'])) {
$whereuser[] = 'ut.favorite=1';
}
if (!empty($params['subscribed'])) {
$whereuser[] = 'ut.subscribed=1';
}
if ($config->keywords || $config->userkeywords) {
$kwids = array();
if (!empty($params['keywords'])) {
$keywords = KunenaKeywordHelper::getByKeywords($params['keywords']);
foreach ($keywords as $keyword) {
$kwids[] = $keyword->id;
}
$kwids = implode(',', $kwids);
}
//TODO: add support for keywords (example:)
/* SELECT tt.*, COUNT(*) AS score FROM #__kunena_keywords_map AS km
INNER JOIN #__kunena_topics` AS tt ON km.topic_id=tt.id
WHERE km.keyword_id IN (1,2) AND km.user_id IN (0,62)
GROUP BY topic_id
ORDER BY score DESC, tt.last_post_time DESC */
}
$wheretime = $starttime ? " AND {$post_time_field}>{$db->Quote($starttime)}" : '';
$whereuser = $whereuser ? " AND ut.user_id={$db->Quote($user->userid)} AND (" . implode(' OR ', $whereuser) . ')' : '';
$where = "tt.hold IN ({$hold}) AND tt.category_id IN ({$catlist}) {$whereuser} {$wheretime} {$where}";
if (!$moved) {
$where .= " AND tt.moved_id='0'";
}
// Get total count
if ($whereuser) {
$query = "SELECT COUNT(*) FROM #__kunena_user_topics AS ut INNER JOIN #__kunena_topics AS tt ON tt.id=ut.topic_id WHERE {$where}";
} else {
$query = "SELECT COUNT(*) FROM #__kunena_topics AS tt WHERE {$where}";
}
$db->setQuery($query);
$total = (int) $db->loadResult();
if (KunenaError::checkDatabaseError() || !$total) {
KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function ' . __CLASS__ . '::' . __FUNCTION__ . '()') : null;
return array(0, array());
}
// If out of range, use last page
if ($limit && $total < $limitstart) {
$limitstart = intval($total / $limit) * $limit;
}
// Get items
if ($whereuser) {
$query = "SELECT tt.*, ut.posts AS myposts, ut.last_post_id AS my_last_post_id, ut.favorite, tt.last_post_id AS lastread, 0 AS unread\r\n\t\t\t\tFROM #__kunena_user_topics AS ut\r\n\t\t\t\tINNER JOIN #__kunena_topics AS tt ON tt.id=ut.topic_id\r\n\t\t\t\tWHERE {$where} ORDER BY {$orderby}";
} else {
$query = "SELECT tt.*, ut.posts AS myposts, ut.last_post_id AS my_last_post_id, ut.favorite, tt.last_post_id AS lastread, 0 AS unread\r\n\t\t\t\tFROM #__kunena_topics AS tt\r\n\t\t\t\tLEFT JOIN #__kunena_user_topics AS ut ON tt.id=ut.topic_id AND ut.user_id={$db->Quote($user->userid)}\r\n\t\t\t\tWHERE {$where} ORDER BY {$orderby}";
}
//.........这里部分代码省略.........
示例9: getLatestMessages
/**
* @param bool|array|int $categories
* @param int $limitstart
* @param int $limit
* @param array $params
*
* @return array
*/
public static function getLatestMessages($categories = false, $limitstart = 0, $limit = 0, $params = array())
{
$reverse = isset($params['reverse']) ? (int) $params['reverse'] : 0;
$orderby = isset($params['orderby']) ? (string) $params['orderby'] : 'm.time DESC';
$starttime = isset($params['starttime']) ? (int) $params['starttime'] : 0;
$mode = isset($params['mode']) ? $params['mode'] : 'recent';
$user = isset($params['user']) ? $params['user'] : false;
$where = isset($params['where']) ? (string) $params['where'] : '';
$childforums = isset($params['childforums']) ? (bool) $params['childforums'] : false;
$db = JFactory::getDBO();
// FIXME: use right config setting
if ($limit < 1 && empty($params['nolimit'])) {
$limit = KunenaFactory::getConfig()->threads_per_page;
}
$query = $db->getQuery(true);
$query->select('m.*, t.message')->from('#__kunena_messages AS m')->innerJoin('#__kunena_messages_text AS t ON m.id = t.mesid')->where('m.moved=0')->order($orderby);
$authorise = 'read';
$hold = 'm.hold=0';
$userfield = 'm.userid';
switch ($mode) {
case 'unapproved':
$authorise = 'approve';
$hold = "m.hold=1";
break;
case 'deleted':
$authorise = 'undelete';
$hold = "m.hold>=2";
break;
case 'mythanks':
$userfield = 'th.userid';
$query->innerJoin('#__kunena_thankyou AS th ON m.id = th.postid');
break;
case 'thankyou':
$userfield = 'th.targetuserid';
$query->innerJoin('#__kunena_thankyou AS th ON m.id = th.postid');
break;
case 'recent':
default:
}
if (is_array($categories) && in_array(0, $categories)) {
$categories = false;
}
$categories = KunenaForumCategoryHelper::getCategories($categories, $reverse, 'topic.' . $authorise);
if ($childforums) {
$categories += KunenaForumCategoryHelper::getChildren($categories, -1, array('action' => 'topic.' . $authorise));
}
$catlist = array();
foreach ($categories as $category) {
$catlist += $category->getChannels();
}
if (empty($catlist)) {
return array(0, array());
}
$allowed = implode(',', array_keys($catlist));
$query->where("m.catid IN ({$allowed})");
$query->where($hold);
if ($user) {
$query->where("{$userfield}={$db->Quote($user)}");
}
// Negative time means no time
if ($starttime == 0) {
$starttime = KunenaFactory::getSession()->lasttime;
} elseif ($starttime > 0) {
$starttime = JFactory::getDate()->toUnix() - $starttime * 3600;
}
if ($starttime > 0) {
$query->where("m.time>{$db->Quote($starttime)}");
}
if ($where) {
$query->where($where);
}
$cquery = clone $query;
$cquery->clear('select')->clear('order')->select('COUNT(*)');
$db->setQuery($cquery);
$total = (int) $db->loadResult();
if (KunenaError::checkDatabaseError() || !$total) {
return array(0, array());
}
// If out of range, use last page
if ($limit && $total < $limitstart) {
$limitstart = intval($total / $limit) * $limit;
}
$db->setQuery($query, $limitstart, $limit);
$results = $db->loadAssocList();
if (KunenaError::checkDatabaseError()) {
return array(0, array());
}
$messages = array();
foreach ($results as $result) {
$instance = new KunenaForumMessage($result);
$instance->exists(true);
self::$_instances[$instance->id] = $instance;
//.........这里部分代码省略.........
示例10: DisplayCreate
protected function DisplayCreate($tpl = null)
{
$this->setLayout('edit');
// Get captcha
$captcha = KunenaSpamRecaptcha::getInstance();
if ($captcha->enabled()) {
$this->captchaHtml = $captcha->getHtml();
if (!$this->captchaHtml) {
$this->app->enqueueMessage($captcha->getError(), 'error');
$this->redirectBack();
return;
}
}
// Get saved message
$saved = $this->app->getUserState('com_kunena.postfields');
// Get topic icons if allowed
if ($this->config->topicicons) {
$this->topicIcons = $this->ktemplate->getTopicIcons(false, $saved ? $saved['icon_id'] : 0);
}
$categories = KunenaForumCategoryHelper::getCategories();
$arrayanynomousbox = array();
$arraypollcatid = array();
foreach ($categories as $category) {
if (!$category->isSection() && $category->allow_anonymous) {
$arrayanynomousbox[] = '"' . $category->id . '":' . $category->post_anonymous;
}
if (!$category->isSection() && $category->allow_polls) {
$arraypollcatid[] = '"' . $category->id . '":1';
}
}
$arrayanynomousbox = implode(',', $arrayanynomousbox);
$arraypollcatid = implode(',', $arraypollcatid);
$this->document->addScriptDeclaration('var arrayanynomousbox={' . $arrayanynomousbox . '}');
$this->document->addScriptDeclaration('var pollcategoriesid = {' . $arraypollcatid . '};');
$cat_params = array('ordering' => 'ordering', 'toplevel' => 0, 'sections' => 0, 'direction' => 1, 'hide_lonely' => 1, 'action' => 'topic.create');
$this->catid = $this->state->get('item.catid');
$this->category = KunenaForumCategoryHelper::get($this->catid);
list($this->topic, $this->message) = $this->category->newTopic($saved);
if (!$this->topic->category_id) {
$msg = JText::sprintf('COM_KUNENA_POST_NEW_TOPIC_NO_PERMISSIONS', $this->topic->getError());
$this->app->enqueueMessage($msg, 'notice');
return false;
}
$options = array();
$selected = $this->topic->category_id;
if ($this->config->pickup_category) {
$options[] = JHtml::_('select.option', '', JText::_('COM_KUNENA_SELECT_CATEGORY'), 'value', 'text');
$selected = 0;
}
if ($saved) {
$selected = $saved['catid'];
}
$this->selectcatlist = JHtml::_('kunenaforum.categorylist', 'catid', $this->catid, $options, $cat_params, 'class="inputbox required"', 'value', 'text', $selected, 'postcatid');
$this->_prepareDocument('create');
$this->action = 'post';
$this->allowedExtensions = KunenaAttachmentHelper::getExtensions($this->category);
if ($arraypollcatid) {
$this->poll = $this->topic->getPoll();
}
$this->post_anonymous = $saved ? $saved['anonymous'] : !empty($this->category->post_anonymous);
$this->subscriptionschecked = $saved ? $saved['subscribe'] : $this->config->subscriptionschecked == 1;
$this->app->setUserState('com_kunena.postfields', null);
$this->render('Topic/Edit', $tpl);
}
示例11: getUserMessages
/**
* Get messages where a user received (or said) Thank You
* @param int $userid
* @param bool $target
* @param int $limitstart
* @param int $limit
* @return Objectlist List of the wanted messages
*/
static public function getUserMessages($userid, $target=true, $limitstart=0, $limit=10) {
$db = JFactory::getDBO();
$field = 'targetuserid';
if (!$target)
$field = 'userid';
$categories = KunenaForumCategoryHelper::getCategories();
$catlist = implode(',', array_keys($categories));
$query = "SELECT m.catid, m.thread, m.id
FROM #__kunena_thankyou AS t
INNER JOIN #__kunena_messages AS m ON m.id=t.postid
INNER JOIN #__kunena_topics AS tt ON m.thread=tt.id
WHERE m.catid IN ({$catlist}) AND m.hold=0 AND tt.hold=0 AND t.{$field}={$db->quote(intval($userid))}";
$db->setQuery ( $query, (int) $limitstart, (int) $limit );
$results = $db->loadObjectList ();
KunenaError::checkDatabaseError();
return $results;
}
示例12: loadCategories
function loadCategories() {
KUNENA_PROFILER ? KunenaProfiler::instance()->start('function '.__CLASS__.'::'.__FUNCTION__.'()') : null;
$categories = KunenaForumCategoryHelper::getCategories();
self::$catidcache = array();
foreach ($categories as $id=>$category) {
self::$catidcache[$id] = self::stringURLSafe ( $category->name );
}
KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function '.__CLASS__.'::'.__FUNCTION__.'()') : null;
}
示例13: before
/**
* Prepare category index display.
*
* @return void
*/
protected function before()
{
parent::before();
$this->me = KunenaUserHelper::getMyself();
// Get sections to display.
$catid = $this->input->getInt('catid', 0);
if ($catid) {
$sections = KunenaForumCategoryHelper::getCategories($catid);
} else {
$sections = KunenaForumCategoryHelper::getChildren();
}
$sectionIds = array();
$this->more[$catid] = 0;
foreach ($sections as $key => $category) {
$this->categories[$category->id] = array();
$this->more[$category->id] = 0;
// Display only categories which are supposed to show up.
if ($catid || $category->params->get('display.index.parent', 3) > 0) {
if ($catid || $category->params->get('display.index.children', 3) > 1) {
$sectionIds[] = $category->id;
} else {
$this->more[$category->id]++;
}
} else {
$this->more[$category->parent_id]++;
unset($sections[$key]);
continue;
}
}
// Get categories and subcategories.
if (empty($sections)) {
return;
}
$this->sections = $sections;
$categories = KunenaForumCategoryHelper::getChildren($sectionIds);
if (empty($categories)) {
return;
}
$categoryIds = array();
$topicIds = array();
$userIds = array();
$postIds = array();
foreach ($categories as $key => $category) {
$this->more[$category->id] = 0;
// Display only categories which are supposed to show up.
if ($catid || $category->params->get('display.index.parent', 3) > 1) {
if ($catid || $category->getParent()->params->get('display.index.children', 3) > 2 && $category->params->get('display.index.children', 3) > 2) {
$categoryIds[] = $category->id;
} else {
$this->more[$category->id]++;
}
} else {
$this->more[$category->parent_id]++;
unset($categories[$key]);
continue;
}
// Get list of topics.
$last = $category->getLastCategory();
if ($last->last_topic_id) {
$topicIds[$last->last_topic_id] = $last->last_topic_id;
}
$this->categories[$category->parent_id][] = $category;
$rssURL = $category->getRSSUrl();
if (!empty($rssURL)) {
$category->rssURL = $category->getRSSUrl();
}
}
$subcategories = KunenaForumCategoryHelper::getChildren($categoryIds);
foreach ($subcategories as $category) {
// Display only categories which are supposed to show up.
if ($catid || $category->params->get('display.index.parent', 3) > 2) {
$this->categories[$category->parent_id][] = $category;
} else {
$this->more[$category->parent_id]++;
}
}
// Pre-fetch topics (also display unauthorized topics as they are in allowed categories).
$topics = KunenaForumTopicHelper::getTopics($topicIds, 'none');
// Pre-fetch users (and get last post ids for moderators).
foreach ($topics as $topic) {
$userIds[$topic->last_post_userid] = $topic->last_post_userid;
$postIds[$topic->id] = $topic->last_post_id;
}
KunenaUserHelper::loadUsers($userIds);
KunenaForumMessageHelper::getMessages($postIds);
// Pre-fetch user related stuff.
$this->pending = array();
if ($this->me->exists() && !$this->me->isBanned()) {
// Load new topic counts.
KunenaForumCategoryHelper::getNewTopics(array_keys($categories + $subcategories));
// Get categories which are moderated by current user.
$access = KunenaAccess::getInstance();
$moderate = $access->getAdminStatus($this->me) + $access->getModeratorStatus($this->me);
if (!empty($moderate[0])) {
// Global moderators.
//.........这里部分代码省略.........
示例14: before
/**
* Prepare topic creation form.
*
* @return bool
*
* @throws RuntimeException
*/
protected function before()
{
parent::before();
$catid = $this->input->getInt('catid', 0);
$saved = $this->app->getUserState('com_kunena.postfields');
$this->me = KunenaUserHelper::getMyself();
$this->template = KunenaFactory::getTemplate();
$categories = KunenaForumCategoryHelper::getCategories();
$arrayanynomousbox = array();
$arraypollcatid = array();
foreach ($categories as $category) {
if (!$category->isSection() && $category->allow_anonymous) {
$arrayanynomousbox[] = '"' . $category->id . '":' . $category->post_anonymous;
}
if (!$category->isSection() && $category->allow_polls) {
$arraypollcatid[] = '"' . $category->id . '":1';
}
}
$arrayanynomousbox = implode(',', $arrayanynomousbox);
$arraypollcatid = implode(',', $arraypollcatid);
// FIXME: We need to proxy this...
$this->document = JFactory::getDocument();
$this->document->addScriptDeclaration('var arrayanynomousbox={' . $arrayanynomousbox . '}');
$this->document->addScriptDeclaration('var pollcategoriesid = {' . $arraypollcatid . '};');
$this->category = KunenaForumCategoryHelper::get($catid);
list($this->topic, $this->message) = $this->category->newTopic($saved);
$this->template->setCategoryIconset($this->topic->getCategory()->iconset);
// Get topic icons if they are enabled.
if ($this->config->topicicons) {
$this->topicIcons = $this->template->getTopicIcons(false, $saved ? $saved['icon_id'] : 0, $this->topic->getCategory()->iconset);
}
if ($this->topic->isAuthorised('create') && $this->me->canDoCaptcha()) {
if (JPluginHelper::isEnabled('captcha')) {
$plugin = JPluginHelper::getPlugin('captcha');
$params = new JRegistry($plugin[0]->params);
$captcha_pubkey = $params->get('public_key');
$catcha_privkey = $params->get('private_key');
if (!empty($captcha_pubkey) && !empty($catcha_privkey)) {
JPluginHelper::importPlugin('captcha');
$dispatcher = JDispatcher::getInstance();
$result = $dispatcher->trigger('onInit', 'dynamic_recaptcha_1');
$this->captchaEnabled = $result[0];
}
}
} else {
$this->captchaEnabled = false;
}
if (!$this->topic->category_id) {
throw new KunenaExceptionAuthorise(JText::sprintf('COM_KUNENA_POST_NEW_TOPIC_NO_PERMISSIONS', $this->topic->getError()), $this->me->exists() ? 403 : 401);
}
$options = array();
$selected = $this->topic->category_id;
if ($this->config->pickup_category) {
$options[] = JHtml::_('select.option', '', JText::_('COM_KUNENA_SELECT_CATEGORY'), 'value', 'text');
$selected = 0;
}
if ($saved) {
$selected = $saved['catid'];
}
$cat_params = array('ordering' => 'ordering', 'toplevel' => 0, 'sections' => 0, 'direction' => 1, 'hide_lonely' => 1, 'action' => 'topic.create');
$this->selectcatlist = JHtml::_('kunenaforum.categorylist', 'catid', $catid, $options, $cat_params, 'class="form-control inputbox required"', 'value', 'text', $selected, 'postcatid');
$this->action = 'post';
$this->allowedExtensions = KunenaAttachmentHelper::getExtensions($this->category);
if ($arraypollcatid) {
$this->poll = $this->topic->getPoll();
}
$this->post_anonymous = $saved ? $saved['anonymous'] : !empty($this->category->post_anonymous);
$this->subscriptionschecked = $saved ? $saved['subscribe'] : $this->config->subscriptionschecked == 1;
$this->app->setUserState('com_kunena.postfields', null);
$this->canSubscribe = $this->canSubscribe();
$this->headerText = JText::_('COM_KUNENA_NEW_TOPIC');
return true;
}
示例15: getChannels
public function getChannels($action='read') {
KUNENA_PROFILER ? KunenaProfiler::instance()->start('function '.__CLASS__.'::'.__FUNCTION__.'()') : null;
if ($this->_channels === false) {
$this->_channels['none'] = array();
if (!$this->published || $this->parent_id == 0 || (!$this->numTopics && $this->locked)) {
// Unpublished categories and sections do not have channels
} elseif (empty($this->channels) || $this->channels == $this->id) {
// No channels defined
$this->_channels['none'][$this->id] = $this;
} else {
// Fetch all channels
$ids = array_flip(explode(',', $this->channels));
if (isset($ids[0]) || isset($ids['THIS'])) {
// Handle current category
$this->_channels['none'][$this->id] = $this;
}
if (!empty($ids)) {
// More category channels
$this->_channels['none'] += KunenaForumCategoryHelper::getCategories(array_keys($ids), null, 'none');
}
if (isset($ids['CHILDREN'])) {
// Children category channels
$this->_channels['none'] += KunenaForumCategoryHelper::getChildren($this->id, 1, array($action=>'none'));
}
}
}
if (!isset($this->_channels[$action])) {
$this->_channels[$action] = array();
foreach ($this->_channels['none'] as $channel) {
if (($channel->id == $this->id && $action == 'read') || $channel->authorise($action, null, false))
$this->_channels[$action][$channel->id] = $channel;
}
}
KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function '.__CLASS__.'::'.__FUNCTION__.'()') : null;
return $this->_channels[$action];
}