Version 4.2.0

This commit is contained in:
Neo committed 2025-12-19 05:44:59 -08:00
1 parent 0dc2aee5ed
commit 96997ddd8e
2074 files changed
+125454 -55780

No files matched your search

@@ -1,13 +1,12 @@
<?php
/**
* @brief Legacy 3.x findpost
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @subpackage Forums
* @since 09 Jul 2015
* @version SVN_VERSION_NUMBER
*/
namespace IPS\forums\modules\front\forums;
@@ -1,13 +1,12 @@
<?php
/**
* @brief Forum Index
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @subpackage Forums
* @since 08 Jan 2014
* @version SVN_VERSION_NUMBER
*/
namespace IPS\forums\modules\front\forums;
@@ -50,11 +49,20 @@ class _forums extends \IPS\Dispatcher\Controller
*/
public function _forum( $forum )
{
/* Is simple mode on? If so, redirect to the index page */
if ( \IPS\forums\Forum::isSimpleView( $forum ) )
{
if ( ! isset( \IPS\Request::i()->url()->hiddenQueryString['rss'] ) )
{
\IPS\Output::i()->redirect( $forum->url(), '', 302 );
}
}
/* Password protected */
if ( $form = $forum->passwordForm() )
{
\IPS\Output::i()->title = $forum->_stripTagsTitle;
\IPS\Output::i()->output = $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'forums', 'forums', 'front' ), 'forumPasswordPopup' ) );
\IPS\Output::i()->output = $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'forums', 'forums', 'front' ), 'forumPasswordPopup' ), $forum );
return;
}
@@ -461,7 +469,20 @@ class _forums extends \IPS\Dispatcher\Controller
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'submit' )->createTopic( $formTemplate, $forum, $title );
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( $title );
if ( !\IPS\forums\Forum::theOnlyForum() )
if ( $club = $forum->club() )
{
\IPS\core\FrontNavigation::$clubTabActive = TRUE;
\IPS\Output::i()->breadcrumb = array();
\IPS\Output::i()->breadcrumb[] = array( \IPS\Http\Url::internal( 'app=core&module=clubs&controller=directory', 'front', 'clubs_list' ), \IPS\Member::loggedIn()->language()->addToStack('module__core_clubs') );
\IPS\Output::i()->breadcrumb[] = array( $club->url(), $club->name );
\IPS\Output::i()->breadcrumb[] = array( $forum->url(), $forum->_title );
if ( \IPS\Settings::i()->clubs_header == 'sidebar' )
{
\IPS\Output::i()->sidebar['contextual'] = \IPS\Theme::i()->getTemplate( 'clubs', 'core' )->header( $club, $forum, 'sidebar' );
}
}
elseif ( !\IPS\forums\Forum::theOnlyForum() )
{
try
{
@@ -1,13 +1,12 @@
<?php
/**
* @brief index
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @subpackage Forums
* @since 28 Jul 2014
* @version SVN_VERSION_NUMBER
*/
namespace IPS\forums\modules\front\forums;
@@ -31,11 +30,51 @@ class _index extends \IPS\Dispatcher\Controller
*/
public function execute()
{
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js('front_browse.js', 'gallery' ) );
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js('front_forum.js', 'forums' ) );
if ( isset( \IPS\Request::i()->forumId ) and ! \IPS\forums\Forum::isSimpleView() )
{
/* This is a simple view URL, but we're not using simple view, so redirect */
$ids = explode( ',', \IPS\Request::i()->forumId );
$firstId = array_shift( $ids );
if ( $firstId )
{
try
{
$forum = \IPS\forums\Forum::loadAndCheckPerms( $firstId );
\IPS\Output::i()->redirect( $forum->url(), '', 302 );
}
catch( \Exception $ex ) { }
}
}
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js('front_browse.js', 'gallery' ) );
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js('front_forum.js', 'forums' ) );
parent::execute();
}
/**
* Handle forum things that are directed here when simple view is on
*
* @param string $method Desired method
* @param array $args Arguments
* @return void
*/
public function __call( $method, $args )
{
if ( \IPS\forums\Forum::isSimpleView() and isset( \IPS\Request::i()->do ) and isset( \IPS\Request::i()->forumId ) and ! mb_stristr( \IPS\Request::i()->forumId, ',' ) )
{
/* If we have a specific do action that this controller does not handle, then we really want the full forum view to handle it */
try
{
/* Panic not, they are all loaded into memory at this point */
$controller = new \IPS\forums\modules\front\forums\forums( $this->url );
\IPS\Request::i()->id = \IPS\Request::i()->forumId;
$controller->execute();
}
catch( \Exception $ex ) { }
}
}
/**
* Manage
@@ -46,9 +85,9 @@ class _index extends \IPS\Dispatcher\Controller
{
/* Load into memory */
\IPS\forums\Forum::loadIntoMemory();
/* Is there only one forum? */
if ( $theOnlyForum = \IPS\forums\Forum::theOnlyForum() )
/* Is there only one forum? But don't redirect if it's simple view mode... */
if ( $theOnlyForum = \IPS\forums\Forum::theOnlyForum() AND !\IPS\forums\Forum::isSimpleView() )
{
$controller = new \IPS\forums\modules\front\forums\forums( $this->url );
return $controller->_forum( $theOnlyForum );
@@ -67,7 +106,146 @@ class _index extends \IPS\Dispatcher\Controller
\IPS\Session::i()->setLocation( \IPS\Http\Url::internal( 'app=forums&module=forums&controller=index', 'front', 'forums' ), explode( ',', $permissions['perm_view'] ), 'loc_forums_index' );
/* Display */
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'index' )->index();
}
if ( \IPS\forums\Forum::isSimpleView() )
{
$where = array( 'container' => array( array( 'forums_forums.password IS NULL AND forums_forums.can_view_others=1 AND forums_forums.club_id IS NULL' ) ) );
$forumIds = array();
$parentIds = array();
$map = array();
$ids = array();
if ( isset( \IPS\Request::i()->forumId ) )
{
$ids = explode( ',', \IPS\Request::i()->forumId );
}
else if ( isset( \IPS\Request::i()->cookie['forums_flowIds'] ) )
{
$ids = explode( ',', \IPS\Request::i()->cookie['forums_flowIds'] );
}
/* Inline forum IDs? */
if ( count( $ids ) )
{
foreach( $ids as $id )
{
try
{
/* Panic not, they are all loaded into memory at this point */
$forum = \IPS\forums\Forum::load( $id );
if ( $forum->hasChildren() )
{
/* This is a root category, so fetch all children */
$this->getParentIds( $forum, $parentIds );
$forumIds[] = $forum->id;
}
else
{
$map[ $forum->parent_id ][] = $forum->_id;
$forumIds[] = $forum->id;
}
}
catch( \Exception $ex ) { }
}
/* Now remove all children that are in the same category */
foreach( $map as $parent => $children )
{
if ( in_array( $parent, $parentIds ) )
{
$forumIds = array_diff( $forumIds, $children );
}
}
$or = array();
if ( count( $forumIds ) )
{
$or[] = \IPS\Db::i()->in( 'forums_forums.id', array_filter( $forumIds ) );
}
if ( count( $parentIds ) )
{
$or[] = \IPS\Db::i()->in( 'forums_forums.parent_id', array_filter( $parentIds ) );
}
if ( count( $or ) )
{
$where['container'][] = array( '(' . implode( ' OR ', $or ) . ')' );
}
}
/* Simplified view */
$table = new \IPS\Helpers\Table\Content( 'IPS\forums\Topic', \IPS\Http\Url::internal( 'app=forums&module=forums&controller=index', 'front', 'forums' ), $where, NULL, NULL, 'read' );
$table->tableTemplate = array( \IPS\Theme::i()->getTemplate( 'index' ), 'simplifiedForumTable' );
$table->classes = array( 'cTopicList' );
$table->limit = \IPS\Settings::i()->forums_topics_per_page;
$table->rowsTemplate = array( \IPS\Theme::i()->getTemplate( 'index' ), 'simplifiedTopicRow' );
$table->honorPinned = \IPS\Settings::i()->forums_fluid_pinned;
$table->hover = TRUE;
$table->sortOptions['num_replies'] = $table->sortOptions['num_comments'];
unset( $table->sortOptions['num_comments'] );
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'index' )->simplifiedView( $table );
if( \IPS\forums\Forum::theOnlyForum() === NULL )
{
\IPS\Output::i()->sidebar['contextual'] = \IPS\Theme::i()->getTemplate( 'index' )->simplifiedViewSidebar( $forumIds, $parentIds );
}
if ( isset( $where['container'] ) )
{
$allForumIds = iterator_to_array( \IPS\Db::i()->select( 'id', 'forums_forums', $where['container'] ) );
\IPS\Output::i()->contextualSearchOptions[ \IPS\Member::loggedIn()->language()->addToStack('forums_chosen_forums') ] = array( 'type' => 'forums_topic', 'nodes' => implode( ',', $allForumIds ) );
}
}
else
{
/* Standard view */
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'index' )->index();
}
}
/**
* Recursively collect parents
*
* @param \IPS\forums\Forum $forum Forum object
* @param array $parentIds ParentIds to use
* @return void
*/
protected function getParentIds( $forum, &$parentIds )
{
if ( $forum->hasChildren() )
{
$parentIds[ $forum->id ] = $forum->id;
foreach( $forum->children() as $child )
{
if ( $child->hasChildren() )
{
$parentIds[ $child->id ] = $child->id;
$this->getParentIds( $child, $parentIds );
}
}
}
}
/**
* Set the viewing method
*
* @return void
*/
protected function setMethod()
{
$method = ( isset( \IPS\Request::i()->method ) ) ? \IPS\Request::i()->method : \IPS\Settings::i()->forums_default_view;
\IPS\Request::i()->setCookie( 'forum_view', $method, ( new \IPS\DateTime )->add( new \DateInterval( 'P1Y' ) ) );
if ( \IPS\Member::loggedIn()->member_id )
{
\IPS\Db::i()->replace( 'forums_view_method', array( 'member_id' => \IPS\Member::loggedIn()->member_id, 'method' => $method ) );
}
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=forums&module=forums&controller=index', 'front', 'forums' ) );
}
}
@@ -1,13 +1,12 @@
<?php
/**
* @brief Topic View
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @subpackage Forums
* @since 08 Jan 2014
* @version SVN_VERSION_NUMBER
*/
namespace IPS\forums\modules\front\forums;
@@ -52,7 +51,7 @@ class _topic extends \IPS\Content\Controller
\IPS\Member::loggedIn()->language()->words['submit_comment'] = \IPS\Member::loggedIn()->language()->addToStack( 'submit_reply', FALSE );
/* If there's only one forum we actually don't want the nav */
if ( \IPS\forums\Forum::theOnlyForum() )
if ( \IPS\forums\Forum::theOnlyForum() or \IPS\forums\Forum::isSimpleView() )
{
$topicBreadcrumb = array_pop( \IPS\Output::i()->breadcrumb );
\IPS\Output::i()->breadcrumb = isset( \IPS\Output::i()->breadcrumb['module'] ) ? array( 'module' => \IPS\Output::i()->breadcrumb['module'] ) : array();
@@ -227,7 +226,7 @@ class _topic extends \IPS\Content\Controller
}
$pagination = ( $topic->commentPageCount() > 1 ) ? $topic->commentPagination( array( 'sortby' ) ) : NULL;
}
$comments = $topic->comments( NULL, $offset, $order, $orderDirection, NULL, NULL, NULL, $where );
$comments = $topic->comments( NULL, $offset, $order, $orderDirection, NULL, NULL, NULL, $where, FALSE, ( isset( \IPS\Request::i()->showDeleted ) ) );
$current = current( $comments );
reset( $comments );
@@ -298,6 +297,97 @@ class _topic extends \IPS\Content\Controller
$nextUnread = NULL;
}
/* Add Json-LD */
\IPS\Output::i()->jsonLd['topic'] = array(
'@context' => "http://schema.org",
'@type' => $topic->isQuestion() ? 'Question' : 'DiscussionForumPosting',
'url' => (string) $topic->url(),
'discussionUrl' => (string) $topic->url(),
'name' => htmlspecialchars( $topic->mapped('title'), ENT_QUOTES | \IPS\HTMLENTITIES, 'UTF-8', FALSE ),
'headline' => htmlspecialchars( $topic->mapped('title'), ENT_QUOTES | \IPS\HTMLENTITIES, 'UTF-8', FALSE ),
'text' => strip_tags( $topic->isQuestion() ? $question->truncated() : $current->truncated() ),
'dateCreated' => \IPS\DateTime::ts( $topic->start_date )->format( \IPS\DateTime::ISO8601 ),
'datePublished' => \IPS\DateTime::ts( $topic->start_date )->format( \IPS\DateTime::ISO8601 ),
'pageStart' => 1,
'pageEnd' => $topic->commentPageCount(),
/* Image is required, but we don't have "topic images", so we'll use topic starter's profile photo for now */
'image' => \IPS\Member::load( $topic->starter_id )->get_photo(),
'author' => array(
'@type' => 'Person',
'name' => htmlspecialchars( $topic->starter_name ?: \IPS\Member::load( $topic->starter_id )->name, ENT_QUOTES | \IPS\HTMLENTITIES, 'UTF-8', FALSE ),
'url' => (string) \IPS\Member::load( $topic->starter_id )->url(),
'image' => \IPS\Member::load( $topic->starter_id )->get_photo()
),
'interactionStatistic' => array(
array(
'@type' => 'InteractionCounter',
'interactionType' => "http://schema.org/ViewAction",
'userInteractionCount' => $topic->views
),
array(
'@type' => 'InteractionCounter',
'interactionType' => "http://schema.org/CommentAction",
'userInteractionCount' => $topic->posts
),
array(
'@type' => 'InteractionCounter',
'interactionType' => "http://schema.org/FollowAction",
'userInteractionCount' => \IPS\forums\Topic::containerFollowerCount( $topic->container() )
),
)
);
if( $topic->isQuestion() )
{
\IPS\Output::i()->jsonLd['topic']['answerCount'] = $topic->posts ? $topic->posts - 1 : 0;
\IPS\Output::i()->jsonLd['topic']['upvoteCount'] = intval( $topic->question_rating );
if( $topic->topic_answered_pid )
{
try
{
$answer = \IPS\forums\Topic\Post::load( $topic->topic_answered_pid );
\IPS\Output::i()->jsonLd['topic']['acceptedAnswer'] = array(
'@type' => 'Answer',
'text' => strip_tags( $answer->truncated() ),
'url' => (string) $answer->url(),
'mainEntityOfPage' => (string) $topic->url(),
'dateCreated' => \IPS\DateTime::ts( $answer->post_date )->format( \IPS\DateTime::ISO8601 ),
'upvoteCount' => $answer->post_field_int,
'author' => array(
'@type' => 'Person',
'name' => htmlspecialchars( $answer->author_name ?: \IPS\Member::load( $answer->author_id )->name, ENT_QUOTES | \IPS\HTMLENTITIES, 'UTF-8', FALSE ),
'url' => (string) \IPS\Member::load( $answer->author_id )->url(),
'image' => \IPS\Member::load( $answer->author_id )->get_photo()
),
);
}
catch( \OutOfRangeException $e ){}
}
}
else
{
\IPS\Output::i()->jsonLd['topic']['comment'] = array();
foreach( $comments as $comment )
{
\IPS\Output::i()->jsonLd['topic']['comment'][] = array(
'@type' => 'Comment',
'url' => (string) $comment->url(),
'author' => array(
'@type' => 'Person',
'name' => htmlspecialchars( $comment->author_name ?: \IPS\Member::load( $comment->author_id )->name, ENT_QUOTES | \IPS\HTMLENTITIES, 'UTF-8', FALSE ),
'url' => (string) \IPS\Member::load( $comment->author_id )->url(),
'image' => \IPS\Member::load( $comment->author_id )->get_photo()
),
'dateCreated' => \IPS\DateTime::ts( $comment->post_date )->format( \IPS\DateTime::ISO8601 ),
'text' => strip_tags( $comment->truncated() ),
'mainEntityOfPage' => (string) $topic->url(),
);
}
}
/* Show topic */
\IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate( 'topics' )->topic( $topic, $comments, $question, $votes, $nextUnread, $pagination, $topicVotes );
}
@@ -403,7 +493,7 @@ class _topic extends \IPS\Content\Controller
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'submit' )->createTopic( $formTemplate, $forum, $title );
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( $title );
if ( !\IPS\forums\Forum::theOnlyForum() )
if ( !\IPS\forums\Forum::theOnlyForum() and ! \IPS\forums\Forum::isSimpleView() )
{
try
{
@@ -450,6 +540,37 @@ class _topic extends \IPS\Content\Controller
\IPS\Output::i()->redirect( $topic->url() );
}
/**
* Remove the archive exclude flag
*
* @return void
*/
public function removeArchiveExclude()
{
\IPS\Session::i()->csrfCheck();
try
{
$topic = \IPS\forums\Topic::loadAndCheckPerms( \IPS\Request::i()->id );
if ( !$topic->canRemoveArchiveExcludeFlag() )
{
throw new \OutOfRangeException;
}
}
catch ( \OutOfRangeException $e )
{
\IPS\Output::i()->error( 'node_error', '2F173/P', 404, '' );
}
$topic->topic_archive_status = \IPS\forums\Topic::ARCHIVE_NOT;
$topic->save();
/* Log */
\IPS\Session::i()->modLog( 'modlog__removed_archive_exclude_topic', array( $topic->url()->__toString() => FALSE, $topic->mapped( 'title' ) => FALSE ), $topic );
\IPS\Output::i()->redirect( $topic->url() );
}
/**
* Rate Question