Version 4.1.2

This commit is contained in:
Neo committed 2025-12-19 05:32:19 -08:00
1 parent 3ba79295ee
commit 28bd025b35
1131 files changed
+63658 -20579

No files matched your search

@@ -55,6 +55,7 @@ class _forums extends \IPS\Dispatcher\Controller
/* Password protected */
if ( $form = $forum->passwordForm() )
{
\IPS\Output::i()->title = $forum->_title;
\IPS\Output::i()->output = $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'forums', 'forums', 'front' ), 'forumPasswordPopup' ) );
return;
}
@@ -76,7 +77,7 @@ class _forums extends \IPS\Dispatcher\Controller
}
/* Init table (it won't show anything until after the password check, but it sets navigation and titles) */
$table = new \IPS\Helpers\Table\Content( 'IPS\forums\Topic', $forum->url(), $where, $forum, NULL, NULL );
$table = new \IPS\Helpers\Table\Content( 'IPS\forums\Topic', $forum->url(), $where, $forum, NULL, NULL, isset( \IPS\Request::i()->rss ) ? FALSE : TRUE );
$table->tableTemplate = array( \IPS\Theme::i()->getTemplate( 'forums', 'forums', 'front' ), 'forumTable' );
$table->classes = array( 'cTopicList' );
$table->title = \IPS\Member::loggedIn()->language()->addToStack( ( $forum->forums_bitoptions['bw_enable_answers'] ) ? 'count_questions_in_forum' : 'count_topics_in_forum', FALSE, array( 'pluralize' => array( $forum->topics ) ) );
@@ -310,6 +311,7 @@ class _forums extends \IPS\Dispatcher\Controller
/* Or actually show RSS feed */
if ( isset( \IPS\Request::i()->rss ) )
{
/* Set the title, either topics or questions */
if ( $forum->forums_bitoptions['bw_enable_answers'] )
{
$rssTitle = sprintf( \IPS\Member::loggedIn()->language()->get( 'forum_rss_title_questions'), \IPS\Member::loggedIn()->language()->get( "forums_forum_{$forum->id}" ) );
@@ -318,21 +320,24 @@ class _forums extends \IPS\Dispatcher\Controller
{
$rssTitle = sprintf( \IPS\Member::loggedIn()->language()->get( 'forum_rss_title_topics'), \IPS\Member::loggedIn()->language()->get( "forums_forum_{$forum->id}" ) );
}
$document = \IPS\Xml\Rss::newDocument( $forum->url(), $rssTitle, $rssTitle );
/* We can't include "moved" links in the RSS feed, as there is no content to include ( $topic->content() results in BadMethodCallException) */
/* Don't include "moved" links in the RSS feed, as there is no content to include ( $topic->content() results in BadMethodCallException) */
$table->where[] = array( 'forums_topics.moved_to IS NULL' );
/* Can we view the content (permission_showtopic may allow us to view the list, but not the content)? */
$canViewContent = $forum->can('read');
/* Build the document */
$document = \IPS\Xml\Rss::newDocument( $forum->url(), $rssTitle, $rssTitle );
foreach ( $table->getRows( array() ) as $topic )
{
if ( ! $topic->hidden() )
if ( !$topic->hidden() )
{
$document->addItem( $topic->title, $topic->url(), $topic->content(), \IPS\DateTime::ts( $topic->last_post ), $topic->tid );
$document->addItem( $topic->title, $topic->url(), $canViewContent ? $topic->content() : NULL, \IPS\DateTime::ts( $topic->start_date ), $topic->tid );
}
}
/* @note application/rss+xml is not a registered IANA mime-type so we need to stick with text/xml for RSS */
/* 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' );
}
}
@@ -423,7 +428,7 @@ class _forums extends \IPS\Dispatcher\Controller
$hasModOptions = TRUE;
}
$formTemplate = $form->customTemplate( array( call_user_func_array( array( \IPS\Theme::i(), 'getTemplate' ), array( 'submit', 'forums' ) ), 'createTopicForm' ), $forum, $hasModOptions );
$formTemplate = $form->customTemplate( array( call_user_func_array( array( \IPS\Theme::i(), 'getTemplate' ), array( 'submit', 'forums' ) ), 'createTopicForm' ), $forum, $hasModOptions, NULL );
if ( \IPS\forums\Topic::moderateNewItems( \IPS\Member::loggedIn() ) )
{
@@ -162,6 +162,12 @@ class _topic extends \IPS\Content\Controller
if ( $topic->isQuestion() )
{
$question = $topic->comments( 1, 0 );
try
{
$question->warning = \IPS\core\Warnings\Warning::constructFromData( \IPS\Db::i()->select( '*', 'core_members_warn_logs', array( array( 'wl_content_app=? AND wl_content_module=? AND wl_content_id1=? AND wl_content_id2=?', 'forums', 'forums-comment', $question->topic_id, $question->pid ) ) )->first() );
}
catch ( \UnderflowException $e ) { }
$page = ( isset( \IPS\Request::i()->page ) ) ? intval( \IPS\Request::i()->page ) : 1;
if( $page < 1 )
@@ -313,18 +319,23 @@ class _topic extends \IPS\Content\Controller
\IPS\Member::loggedIn()->language()->words['topic_mainTab'] = \IPS\Member::loggedIn()->language()->addToStack( 'question_mainTab', FALSE );
}
if ( !$topic->canEdit() )
if ( !$topic->canEdit() and !\IPS\Request::i()->form_submitted ) // We check if the form has been submitted to prevent the user loosing their content
{
\IPS\Output::i()->error( 'node_noperm_edit', '2F173/E', 403, '' );
\IPS\Output::i()->error( 'edit_no_perm_err', '2F173/E', 403, '' );
}
$formElements = $class::formElements( $topic, $forum );
$hasModOptions = FALSE;
if ( $class::modPermission( 'lock', NULL, $forum ) )
/* We used to just check against the ability to lock, however this may not be enough - a moderator could pin, for example, but not lock */
foreach( array( 'lock', 'pin', 'hide', 'feature' ) AS $perm )
{
$hasModOptions = TRUE;
if ( $class::modPermission( $perm, NULL, $forum ) )
{
$hasModOptions = TRUE;
break;
}
}
$form = new \IPS\Helpers\Form( 'form', \IPS\Member::loggedIn()->language()->checkKeyExists( $class::$formLangPrefix . '_save' ) ? $class::$formLangPrefix . '_save' : 'save' );
@@ -347,14 +358,21 @@ class _topic extends \IPS\Content\Controller
if ( $values = $form->values() )
{
$topic->processForm( $values );
$topic->save();
$topic->processAfterEdit( $values );
\IPS\Output::i()->redirect( $topic->url() );
if ( $topic->canEdit() )
{
$topic->processForm( $values );
$topic->save();
$topic->processAfterEdit( $values );
\IPS\Output::i()->redirect( $topic->url() );
}
else
{
$form->error = \IPS\Member::loggedIn()->language()->addToStack('edit_no_perm_err');
}
}
$formTemplate = $form->customTemplate( array( call_user_func_array( array( \IPS\Theme::i(), 'getTemplate' ), array( 'submit', 'forums' ) ), 'createTopicForm' ), $forum, $hasModOptions );
$formTemplate = $form->customTemplate( array( call_user_func_array( array( \IPS\Theme::i(), 'getTemplate' ), array( 'submit', 'forums' ) ), 'createTopicForm' ), $forum, $hasModOptions, $topic );
$title = $forum->forums_bitoptions['bw_enable_answers'] ? 'edit_question' : 'edit_topic';
@@ -401,6 +419,9 @@ class _topic extends \IPS\Content\Controller
$topic->topic_archive_status = \IPS\forums\Topic::ARCHIVE_RESTORE;
$topic->save();
/* Log */
\IPS\Session::i()->modLog( 'modlog__unarchived_topic', array( $topic->url()->__toString() => FALSE, $topic->mapped( 'title' ) => FALSE ), $topic );
\IPS\Output::i()->redirect( $topic->url() );
}
@@ -412,8 +433,10 @@ class _topic extends \IPS\Content\Controller
*/
public function rateQuestion()
{
/* CSRF Check */
\IPS\Session::i()->csrfCheck();
/* Get the question */
try
{
$question = \IPS\forums\Topic::loadAndCheckPerms( \IPS\Request::i()->id );
@@ -423,28 +446,41 @@ class _topic extends \IPS\Content\Controller
\IPS\Output::i()->error( 'node_error', '2F173/8', 404, '' );
}
if ( !$question->canVote() )
{
\IPS\Output::i()->error( 'no_module_permission', '2F173/9', 403, '' );
}
/* Voting up or down? */
$rating = intval( \IPS\Request::i()->rating );
if ( $rating !== 1 and $rating !== -1 )
{
\IPS\Output::i()->error( 'form_bad_value', '2F173/A', 403, '' );
}
\IPS\Db::i()->insert( 'forums_question_ratings', array(
'topic' => $question->tid,
'forum' => $question->forum_id,
'member' => \IPS\Member::loggedIn()->member_id,
'rating' => $rating,
'date' => time()
), TRUE );
/* Check we can cast this vote */
if ( !$question->canVote( $rating ) )
{
\IPS\Output::i()->error( 'no_module_permission', '2F173/9', 403, '' );
}
/* If we have an existing vote, we're just undoing that, otherwise, insert the vote */
$ratings = $question->votes();
if ( isset( $ratings[ \IPS\Member::loggedIn()->member_id ] ) )
{
\IPS\Db::i()->delete( 'forums_question_ratings', array( 'topic=? AND member=?', $question->tid, \IPS\Member::loggedIn()->member_id ) );
}
else
{
\IPS\Db::i()->insert( 'forums_question_ratings', array(
'topic' => $question->tid,
'forum' => $question->forum_id,
'member' => \IPS\Member::loggedIn()->member_id,
'rating' => $rating,
'date' => time()
), TRUE );
}
/* Rebuild count */
$question->question_rating = \IPS\Db::i()->select( 'SUM(rating)', 'forums_question_ratings', array( 'topic=?', $question->tid ) )->first();
$question->save();
/* Redirect back */
\IPS\Output::i()->redirect( $question->url() );
}
@@ -614,7 +650,6 @@ class _topic extends \IPS\Content\Controller
/* Log */
\IPS\Session::i()->modLog( 'modlog__saved_action', array( 'forums_mmod_' . $action->mm_id => TRUE, $topic->url()->__toString() => FALSE, $topic->mapped( 'title' ) => FALSE ), $topic );
\IPS\Output::i()->redirect( $topic->url() );
}
catch ( \LogicException $e )
@@ -651,6 +686,29 @@ class _topic extends \IPS\Content\Controller
\IPS\Output::i()->error( 'no_module_permission', '2F173/C', 403, 'no_module_permission_guest' );
}
}
/**
* We need to use the custom widget poll template for ajax methods
*
* @return void
*/
public function widgetPoll()
{
try
{
$topic = \IPS\forums\Topic::loadAndCheckPerms( \IPS\Request::i()->id );
}
catch( \OutOfRangeException $ex )
{
\IPS\Output::i()->error( 'node_error', '2F173/N', 403, '' );
}
$poll = $topic->getPoll();
$poll->displayTemplate = array( \IPS\Theme::i()->getTemplate( 'widgets', 'forums', 'front' ), 'pollWidget' );
$poll->url = $topic->url();
\IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate( 'widgets', 'forums', 'front' )->poll( $topic, $poll );
}
/**
* Edit Comment/Review