Version 4.5.0
This commit is contained in:
1 parent
1a0c7fd3c2
commit
f79dcf067a
3791 files changed
+248032
-76372
No files matched your search
@@ -16,19 +16,102 @@ namespace IPS\forums;
|
||||
*/
|
||||
class _Application extends \IPS\Application
|
||||
{
|
||||
|
||||
/**
|
||||
* Init
|
||||
*
|
||||
* @param void
|
||||
* @return void
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
/* If the viewing member cannot view the board (ex: guests must login first), then send a 404 Not Found header here, before the Login page shows in the dispatcher */
|
||||
if ( !\IPS\Member::loggedIn()->group['g_view_board'] and ( \IPS\Request::i()->module == 'forums' and \IPS\Request::i()->controller == 'forums' and isset( \IPS\Request::i()->rss ) ) )
|
||||
/* Handle RSS requests */
|
||||
if ( \IPS\Request::i()->module == 'forums' and \IPS\Request::i()->controller == 'forums' and isset( \IPS\Request::i()->rss ) )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2F219/1', 404, '' );
|
||||
$member = NULL;
|
||||
if( \IPS\Request::i()->member AND \IPS\Request::i()->key )
|
||||
{
|
||||
$member = \IPS\Member::load( \IPS\Request::i()->member );
|
||||
if( !\IPS\Login::compareHashes( md5( ( $member->members_pass_hash ?: $member->email ) . $member->members_pass_salt ), (string) \IPS\Request::i()->key ) )
|
||||
{
|
||||
$member = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
$this->sendForumRss( $member ?? new \IPS\Member );
|
||||
|
||||
if( !\IPS\Member::loggedIn()->group['g_view_board'] )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2F219/1', 404, '' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the forum's RSS feed for the indicated member
|
||||
*
|
||||
* @param \IPS\Member $member Member
|
||||
* @return void
|
||||
*/
|
||||
protected function sendForumRss( $member )
|
||||
{
|
||||
try
|
||||
{
|
||||
$forum = \IPS\forums\Forum::load( \IPS\Request::i()->id );
|
||||
|
||||
if( !$forum->can( 'view', $member ) )
|
||||
{
|
||||
throw new \OutOfRangeException;
|
||||
}
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
/* We'll let the regular controller handle the error */
|
||||
return;
|
||||
}
|
||||
|
||||
/* RSS feeds are not available if the setting is off, or there is nothing to include */
|
||||
if ( !\IPS\Settings::i()->forums_rss OR !$forum->topics )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* Users can see topics posted by other users? Also, exclude moved links. */
|
||||
$where = array( array( 'forums_topics.moved_to IS NULL' ), array( 'forums_topics.forum_id=?', $forum->id ) );
|
||||
if ( !$forum->memberCanAccessOthersTopics( $member ) )
|
||||
{
|
||||
$where[] = array( 'starter_id = ?', $member->member_id );
|
||||
}
|
||||
|
||||
/* Init table (it won't show anything until after the password check, but it sets navigation and titles) */
|
||||
$iterator = \IPS\forums\Topic::getItemsWithPermission( $where, 'forums_topics.last_post DESC', \IPS\Settings::i()->forums_topics_per_page, 'view', \IPS\Content\Hideable::FILTER_PUBLIC_ONLY, 0, $member, FALSE, FALSE, FALSE, FALSE, NULL, $forum, TRUE, TRUE, TRUE, FALSE );
|
||||
|
||||
/* Set the title, either topics or questions */
|
||||
if ( $forum->forums_bitoptions['bw_enable_answers'] )
|
||||
{
|
||||
$rssTitle = sprintf( $member->language()->get( 'forum_rss_title_questions'), $member->language()->get( "forums_forum_{$forum->id}" ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$rssTitle = sprintf( $member->language()->get( 'forum_rss_title_topics'), $member->language()->get( "forums_forum_{$forum->id}" ) );
|
||||
}
|
||||
|
||||
/* Can we view the content (permission_showtopic may allow us to view the list, but not the content)? */
|
||||
$canViewContent = $forum->can('read', $member );
|
||||
|
||||
/* Build the document */
|
||||
$document = \IPS\Xml\Rss::newDocument( $forum->url(), $rssTitle, $rssTitle );
|
||||
foreach ( $iterator as $topic )
|
||||
{
|
||||
try
|
||||
{
|
||||
$document->addItem( $topic->title, $topic->url(), $canViewContent ? $topic->content() : NULL, \IPS\DateTime::ts( $topic->start_date ), $topic->tid );
|
||||
}
|
||||
catch ( \Exception $e ) { }
|
||||
}
|
||||
|
||||
/* Display - note application/rss+xml is not a registered IANA mime-type so we need to stick with text/xml for RSS */
|
||||
\IPS\Output::i()->sendOutput( $document->asXML(), 200, 'text/xml', array(), TRUE );
|
||||
}
|
||||
|
||||
/**
|
||||
* Archive Query
|
||||
@@ -39,6 +122,12 @@ class _Application extends \IPS\Application
|
||||
public static function archiveWhere( $rules )
|
||||
{
|
||||
$where = array();
|
||||
|
||||
if ( \IPS\CIC )
|
||||
{
|
||||
return \IPS\Cicloud\getForumArchiveWhere();
|
||||
}
|
||||
|
||||
foreach ( $rules as $rule )
|
||||
{
|
||||
$clause = NULL;
|
||||
@@ -177,8 +266,8 @@ class _Application extends \IPS\Application
|
||||
*/
|
||||
public function convertLegacyParameters()
|
||||
{
|
||||
/* Convert &showtopic= @link */
|
||||
if ( isset( \IPS\Request::i()->showtopic ) and is_numeric( \IPS\Request::i()->showtopic ) )
|
||||
/* Convert &showtopic= (link) */
|
||||
if ( isset( \IPS\Request::i()->showtopic ) and \is_numeric( \IPS\Request::i()->showtopic ) )
|
||||
{
|
||||
$base = NULL;
|
||||
$seoTemplate = NULL;
|
||||
@@ -198,19 +287,19 @@ class _Application extends \IPS\Application
|
||||
|
||||
$url = \IPS\Http\Url::internal( 'app=forums&module=forums&controller=topic&id=' . \IPS\Request::i()->showtopic, $base, $seoTemplate, $seoTitles );
|
||||
|
||||
if ( isset( \IPS\Request::i()->p ) or isset( \IPS\Request::i()->findpost ) )
|
||||
if ( isset( \IPS\Request::i()->p ) or isset( \IPS\Request::i()->findpost ) or isset( \IPS\Request::i()->comment ) )
|
||||
{
|
||||
$url = $url->setQueryString( array( 'do' => 'findComment', 'comment' => \IPS\Request::i()->p ?: \IPS\Request::i()->findpost ) );
|
||||
$url = $url->setQueryString( array( 'do' => 'findComment', 'comment' => \IPS\Request::i()->p ?: ( \IPS\Request::i()->findpost ?: \IPS\Request::i()->comment ) ) );
|
||||
}
|
||||
elseif ( isset( \IPS\Request::i()->page ) )
|
||||
{
|
||||
$url = $url->setQueryString( array( 'page' => \IPS\Request::i()->page ) );
|
||||
$url = $url->setPage( 'page', \IPS\Request::i()->page );
|
||||
}
|
||||
\IPS\Output::i()->redirect( $url );
|
||||
}
|
||||
|
||||
/* Convert &showforum= */
|
||||
if ( isset( \IPS\Request::i()->showforum ) and is_numeric( \IPS\Request::i()->showforum ) )
|
||||
if ( isset( \IPS\Request::i()->showforum ) and \is_numeric( \IPS\Request::i()->showforum ) )
|
||||
{
|
||||
$base = NULL;
|
||||
$seoTemplate = NULL;
|
||||
@@ -233,7 +322,7 @@ class _Application extends \IPS\Application
|
||||
}
|
||||
|
||||
/* Convert /topic/123-example/&p= */
|
||||
if ( isset( \IPS\Request::i()->p ) AND is_numeric( \IPS\Request::i()->p ) AND ( \IPS\Request::i()->url() instanceof \IPS\Http\Url\Friendly ) AND \IPS\Request::i()->url()->seoTemplate == 'forums_topic' )
|
||||
if ( isset( \IPS\Request::i()->p ) AND \is_numeric( \IPS\Request::i()->p ) AND ( \IPS\Request::i()->url() instanceof \IPS\Http\Url\Friendly ) AND \IPS\Request::i()->url()->seoTemplate == 'forums_topic' )
|
||||
{
|
||||
/* We do this a little differently as the topic seo title is already known at this point */
|
||||
try
|
||||
@@ -244,4 +333,16 @@ class _Application extends \IPS\Application
|
||||
catch( \Exception $e ) {}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array of specific links to add to the sitemap
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function sitemapLinks()
|
||||
{
|
||||
return array(
|
||||
\IPS\Http\Url::internal( 'app=forums&module=forums&controller=index', 'front', 'forums' ),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user