Version 5.0.0 beta 1
This commit is contained in:
1 parent
25ddeb65d6
commit
15c7beabc5
6736 files changed
+627902
-497943
No files matched your search
@@ -12,31 +12,39 @@
|
||||
namespace IPS\forums\modules\front\forums;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\forums\Topic\Post;
|
||||
use IPS\Output;
|
||||
use IPS\Request;
|
||||
use OutOfRangeException;
|
||||
use function defined;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Legacy 3.x findpost
|
||||
*/
|
||||
class _findpost extends \IPS\Dispatcher\Controller
|
||||
class findpost extends Controller
|
||||
{
|
||||
/**
|
||||
* Route
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
protected function manage() : void
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\Output::i()->redirect( \IPS\forums\Topic\Post::loadAndCheckPerms( \IPS\Request::i()->pid )->url(), NULL, 301 );
|
||||
Output::i()->redirect( Post::loadAndCheckPerms( Request::i()->pid )->url(), NULL );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
catch ( OutOfRangeException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2F284/1', 404, '' );
|
||||
Output::i()->error( 'node_error', '2F284/1', 404, '' );
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -12,42 +12,66 @@
|
||||
namespace IPS\forums\modules\front\forums;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use Exception;
|
||||
use IPS\Application;
|
||||
use IPS\Application\Module;
|
||||
use IPS\Db;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\forums\Forum;
|
||||
use IPS\Helpers\Table\Content;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\Output;
|
||||
use IPS\Request;
|
||||
use IPS\Session;
|
||||
use IPS\Settings;
|
||||
use IPS\Theme;
|
||||
use function count;
|
||||
use function defined;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* index
|
||||
*/
|
||||
class _index extends \IPS\Dispatcher\Controller
|
||||
class index extends Controller
|
||||
{
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
public function execute() : void
|
||||
{
|
||||
if ( isset( \IPS\Request::i()->forumId ) and ! \IPS\forums\Forum::isSimpleView() )
|
||||
if ( isset( Request::i()->forumId ) and ! Forum::isSimpleView() )
|
||||
{
|
||||
/* This is a simple view URL, but we're not using simple view, so redirect */
|
||||
$ids = explode( ',', \IPS\Request::i()->forumId );
|
||||
$ids = explode( ',', Request::i()->forumId );
|
||||
$firstId = array_shift( $ids );
|
||||
if ( $firstId )
|
||||
{
|
||||
try
|
||||
{
|
||||
$forum = \IPS\forums\Forum::loadAndCheckPerms( $firstId );
|
||||
\IPS\Output::i()->redirect( $forum->url(), '', 302 );
|
||||
$forum = Forum::loadAndCheckPerms( $firstId );
|
||||
Output::i()->redirect( $forum->url(), '', 302 );
|
||||
}
|
||||
catch( \Exception $ex ) { }
|
||||
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' ) );
|
||||
Output::i()->jsFiles = array_merge( Output::i()->jsFiles, Output::i()->js('front_browse.js', 'gallery' ) );
|
||||
Output::i()->jsFiles = array_merge( Output::i()->jsFiles, Output::i()->js('front_forum.js', 'forums' ) );
|
||||
|
||||
if ( Application::appIsEnabled('cloud') )
|
||||
{
|
||||
Output::i()->jsFiles = array_merge( Output::i()->jsFiles, Output::i()->js( 'front_realtime.js', 'cloud', 'front' ) );
|
||||
}
|
||||
|
||||
parent::execute();
|
||||
}
|
||||
@@ -57,22 +81,21 @@ class _index extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @param string $method Desired method
|
||||
* @param array $args Arguments
|
||||
* @return void
|
||||
*/
|
||||
public function __call( $method, $args )
|
||||
public function __call( string $method, mixed $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 ( Forum::isSimpleView() and isset( Request::i()->do ) and isset( Request::i()->forumId ) and ! mb_stristr( 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 = new forums( $this->url );
|
||||
Request::i()->id = Request::i()->forumId;
|
||||
$controller->execute();
|
||||
|
||||
}
|
||||
catch( \Exception $ex ) { }
|
||||
catch( Exception $ex ) { }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,47 +104,49 @@ class _index extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
protected function manage() : void
|
||||
{
|
||||
/* Load into memory */
|
||||
\IPS\forums\Forum::loadIntoMemory();
|
||||
Forum::loadIntoMemory();
|
||||
|
||||
/* 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() )
|
||||
if ( $theOnlyForum = Forum::theOnlyForum() AND !Forum::isSimpleView() )
|
||||
{
|
||||
$controller = new \IPS\forums\modules\front\forums\forums( $this->url );
|
||||
return $controller->_forum( $theOnlyForum );
|
||||
$controller = new forums( $this->url );
|
||||
$controller->_forum( $theOnlyForum );
|
||||
return;
|
||||
}
|
||||
|
||||
/* Prepare output */
|
||||
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'global_core.js', 'core', 'global' ) );
|
||||
if ( \IPS\forums\Forum::isSimpleView() )
|
||||
Output::i()->jsFiles = array_merge( Output::i()->jsFiles, Output::i()->js( 'global_core.js', 'core', 'global' ) );
|
||||
if ( Forum::isSimpleView() )
|
||||
{
|
||||
\IPS\Output::i()->title = ( isset( \IPS\Request::i()->page ) AND \IPS\Request::i()->page > 1 ) ? \IPS\Member::loggedIn()->language()->addToStack( 'title_with_page_number', FALSE, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->addToStack( 'forums' ), \IPS\Request::i()->page ) ) ) : \IPS\Member::loggedIn()->language()->addToStack( 'forums' );
|
||||
Output::i()->title = ( isset( Request::i()->page ) AND Request::i()->page > 1 ) ? Member::loggedIn()->language()->addToStack( 'title_with_page_number', FALSE, array( 'sprintf' => array( Member::loggedIn()->language()->addToStack( 'forums' ), Request::i()->page ) ) ) : Member::loggedIn()->language()->addToStack( 'forums' );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'forums' );
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack( 'forums' );
|
||||
}
|
||||
\IPS\Output::i()->linkTags['canonical'] = (string) \IPS\Http\Url::internal( 'app=forums&module=forums&controller=index', 'front', 'forums' );
|
||||
\IPS\Output::i()->metaTags['og:title'] = \IPS\Settings::i()->board_name;
|
||||
\IPS\Output::i()->metaTags['og:type'] = 'website';
|
||||
\IPS\Output::i()->metaTags['og:url'] = (string) \IPS\Http\Url::internal( 'app=forums&module=forums&controller=index', 'front', 'forums' );
|
||||
Output::i()->linkTags['canonical'] = (string) Url::internal( 'app=forums&module=forums&controller=index', 'front', 'forums' );
|
||||
Output::i()->metaTags['og:title'] = Settings::i()->board_name;
|
||||
Output::i()->metaTags['og:type'] = 'website';
|
||||
Output::i()->metaTags['og:url'] = (string) Url::internal( 'app=forums&module=forums&controller=index', 'front', 'forums' );
|
||||
|
||||
/* Set Online Location */
|
||||
$permissions = \IPS\Dispatcher::i()->module->permissions();
|
||||
\IPS\Session::i()->setLocation( \IPS\Http\Url::internal( 'app=forums&module=forums&controller=index', 'front', 'forums' ), explode( ',', $permissions['perm_view'] ), 'loc_forums_index' );
|
||||
$permissions = Dispatcher::i()->module->permissions();
|
||||
Session::i()->setLocation( Url::internal( 'app=forums&module=forums&controller=index', 'front', 'forums' ), explode( ',', $permissions['perm_view'] ), 'loc_forums_index' );
|
||||
|
||||
/* Display */
|
||||
if ( \IPS\forums\Forum::isSimpleView() )
|
||||
if ( Forum::isSimpleView() )
|
||||
{
|
||||
$where = array();
|
||||
if ( \IPS\forums\Forum::customPermissionNodes() )
|
||||
|
||||
if ( Forum::customPermissionNodes() )
|
||||
{
|
||||
$where = array( 'container' => array( array( 'forums_forums.password IS NULL' ) ) );
|
||||
}
|
||||
|
||||
if ( !\IPS\Settings::i()->club_nodes_in_apps OR !\IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( 'core', 'clubs', 'front' ) ) )
|
||||
if ( !Settings::i()->club_nodes_in_apps OR !Member::loggedIn()->canAccessModule( Module::get( 'core', 'clubs', 'front' ) ) )
|
||||
{
|
||||
$where['container'][] = array( 'forums_forums.club_id IS NULL' );
|
||||
}
|
||||
@@ -129,17 +154,17 @@ class _index extends \IPS\Dispatcher\Controller
|
||||
$map = array();
|
||||
$ids = array();
|
||||
|
||||
if ( isset( \IPS\Request::i()->forumId ) )
|
||||
if ( isset( Request::i()->forumId ) )
|
||||
{
|
||||
$ids = explode( ',', \IPS\Request::i()->forumId );
|
||||
$ids = explode( ',', Request::i()->forumId );
|
||||
}
|
||||
else if ( isset( \IPS\Request::i()->cookie['forums_flowIds'] ) )
|
||||
else if ( isset( Request::i()->cookie['forums_flowIds'] ) )
|
||||
{
|
||||
$ids = explode( ',', \IPS\Request::i()->cookie['forums_flowIds'] );
|
||||
$ids = explode( ',', Request::i()->cookie['forums_flowIds'] );
|
||||
}
|
||||
|
||||
/* Inline forum IDs? */
|
||||
if ( \count( $ids ) )
|
||||
if ( count( $ids ) )
|
||||
{
|
||||
$toUnset = [];
|
||||
foreach( $ids as $id )
|
||||
@@ -149,7 +174,7 @@ class _index extends \IPS\Dispatcher\Controller
|
||||
if ( $id == 'clubs' )
|
||||
{
|
||||
$map['clubs'] = 'clubs';
|
||||
foreach ( \IPS\forums\Forum::clubNodes() as $child )
|
||||
foreach ( Forum::clubNodes() as $child )
|
||||
{
|
||||
$forumIds[ $child->id ] = $child->id;
|
||||
}
|
||||
@@ -157,93 +182,74 @@ class _index extends \IPS\Dispatcher\Controller
|
||||
else
|
||||
{
|
||||
/* Panic not, they are all loaded into memory at this point */
|
||||
$forum = \IPS\forums\Forum::load( $id );
|
||||
$forum = Forum::load( $id );
|
||||
|
||||
$map[ $forum->parent_id ][] = $forum->_id;
|
||||
$forumIds[] = $forum->id;
|
||||
}
|
||||
}
|
||||
catch( \Exception $ex ) {
|
||||
catch( Exception $ex )
|
||||
{
|
||||
$toUnset[] = $id;
|
||||
}
|
||||
}
|
||||
|
||||
/* Redirect to a page with valid forum ids */
|
||||
if( $ids and count($forumIds ) AND $toUnset )
|
||||
{
|
||||
$newUrl = $this->url;
|
||||
$newUrl = $newUrl->setQueryString( 'forumId', implode( ',', array_diff( $ids, $toUnset ) ) );
|
||||
\IPS\Output::i()->redirect( $newUrl );
|
||||
Output::i()->redirect( $newUrl );
|
||||
}
|
||||
|
||||
if ( \count( $forumIds ) )
|
||||
if ( count( $forumIds ) )
|
||||
{
|
||||
$where['container'][] = array( \IPS\Db::i()->in( 'forums_forums.id', array_filter( $forumIds ) ) );
|
||||
$where['container'][] = array( Db::i()->in( 'forums_forums.id', array_filter( $forumIds ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
/* 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 = new Content( 'IPS\forums\Topic', Url::internal( 'app=forums&module=forums&controller=index', 'front', 'forums' ), $where, NULL, NULL, 'read' );
|
||||
$table->tableTemplate = array( Theme::i()->getTemplate( 'index' ), 'simplifiedForumTable' );
|
||||
$table->classes = array( 'ipsData--topic-list' );
|
||||
$table->limit = Settings::i()->forums_topics_per_page;
|
||||
|
||||
if ( \IPS\forums\Forum::getMemberListView() == 'snippet' )
|
||||
if ( Member::loggedIn()->getLayoutValue('forums_topic') == 'snippet' )
|
||||
{
|
||||
$table->rowsTemplate = array( \IPS\Theme::i()->getTemplate( 'index' ), 'simplifiedTopicRowSnippet' );
|
||||
$table->rowsTemplate = array( Theme::i()->getTemplate( 'index' ), 'simplifiedTopicRowSnippet' );
|
||||
}
|
||||
else
|
||||
{
|
||||
$table->rowsTemplate = array( \IPS\Theme::i()->getTemplate( 'index' ), 'simplifiedTopicRow' );
|
||||
$table->rowsTemplate = array( Theme::i()->getTemplate( 'index' ), 'simplifiedTopicRow' );
|
||||
}
|
||||
|
||||
$table->honorPinned = \IPS\Settings::i()->forums_fluid_pinned;
|
||||
$table->honorPinned = 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 );
|
||||
Output::i()->output = Theme::i()->getTemplate( 'index' )->simplifiedView( $table );
|
||||
|
||||
if( \IPS\forums\Forum::theOnlyForum() === NULL )
|
||||
if( Forum::theOnlyForum() === NULL )
|
||||
{
|
||||
\IPS\Output::i()->sidebar['contextual'] = \IPS\Theme::i()->getTemplate( 'index' )->simplifiedViewSidebar( $forumIds, $map );
|
||||
Output::i()->sidebar['contextual'] = Theme::i()->getTemplate( 'index' )->simplifiedViewSidebar( $forumIds, $map );
|
||||
}
|
||||
|
||||
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 ) );
|
||||
$allForumIds = iterator_to_array( Db::i()->select( 'id', 'forums_forums', $where['container'] ) );
|
||||
Output::i()->contextualSearchOptions[ Member::loggedIn()->language()->addToStack('forums_chosen_forums') ] = array( 'type' => 'forums_topic', 'nodes' => implode( ',', $allForumIds ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Merge in follower counts to the immediately visible forums */
|
||||
if ( \IPS\forums\Forum::getMemberView() === 'grid' )
|
||||
if ( Member::loggedIn()->getLayoutValue('forums_forum') )
|
||||
{
|
||||
\IPS\forums\Forum::populateFollowerCounts();
|
||||
Forum::populateFollowerCounts();
|
||||
}
|
||||
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'index' )->index();
|
||||
Output::i()->output = Theme::i()->getTemplate( 'index' )->index();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the viewing method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setMethod()
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
|
||||
$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, 'type' => 'index' ) );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=forums&module=forums&controller=index', 'front', 'forums' ) );
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user