Version 4.1.19

This commit is contained in:
Neo committed 2025-12-19 05:38:56 -08:00
1 parent 28bd025b35
commit 2bd5025018
2674 files changed
+233518 -77766

No files matched your search

@@ -2,10 +2,10 @@
/**
* @brief forums
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @subpackage Board
* @package IPS Community Suite
* @subpackage Forums
* @since 07 Jan 2014
* @version SVN_VERSION_NUMBER
*/
@@ -2,10 +2,10 @@
/**
* @brief Feeds
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @subpackage Board
* @package IPS Community Suite
* @subpackage Forums
* @since 04 Feb 2014
* @version SVN_VERSION_NUMBER
*/
@@ -70,7 +70,7 @@ class _rss extends \IPS\Node\Controller
\IPS\Output::i()->output = new \IPS\Helpers\Wizard( array(
'rss_import_url' => function( $data )
{
$form = new \IPS\Helpers\Form;
$form = new \IPS\Helpers\Form( 'form', 'continue' );
$form->add( new \IPS\Helpers\Form\Url( 'rss_import_url', NULL, TRUE ) );
$form->add( new \IPS\Helpers\Form\Text( 'rss_import_auth_user' ) );
$form->add( new \IPS\Helpers\Form\Password( 'rss_import_auth_pass' ) );
@@ -142,7 +142,32 @@ class _rss extends \IPS\Node\Controller
{
return $forum->sub_can_post and !$forum->redirect_url;
} ) ) );
$form->add( new \IPS\Helpers\Form\Member( 'rss_import_mid', \IPS\Member::loggedIn(), TRUE ) );
$form->add( new \IPS\Helpers\Form\Member( 'rss_import_mid', \IPS\Member::loggedIn(), TRUE, array(), function( $val ){
if( !is_array( $val ) )
{
$val = array( $val );
}
foreach( $val as $member )
{
if( $member instanceof \IPS\Member )
{
if( !$member->member_id )
{
throw new \InvalidArgumentException( 'form_member_bad' );
}
}
else
{
$testMember = \IPS\Member::load( $member );
if( !$testMember->member_id )
{
throw new \InvalidArgumentException( 'form_member_bad' );
}
}
}
} ) );
$form->add( new \IPS\Helpers\Form\Text( 'rss_import_showlink', \IPS\Member::loggedIn()->language()->addToStack('rss_import_showlink_default') ) );
$form->add( new \IPS\Helpers\Form\Radio( 'rss_import_topic_open', NULL, FALSE, array( 'options' => array( 1 => 'unlocked', 0 => 'locked' ) ) ) );
$form->add( new \IPS\Helpers\Form\Radio( 'rss_import_topic_hide', NULL, FALSE, array( 'options' => array( 0 => 'unhidden', 1 => 'hidden' ) ) ) );
@@ -2,10 +2,10 @@
/**
* @brief savedActions
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @subpackage Board
* @package IPS Community Suite
* @subpackage Forums
* @since 30 Jan 2014
* @version SVN_VERSION_NUMBER
*/
@@ -2,10 +2,10 @@
/**
* @brief Settings
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @subpackage Board
* @package IPS Community Suite
* @subpackage Forums
* @since 20 Jan 2014
* @version SVN_VERSION_NUMBER
*/
@@ -34,11 +34,11 @@ class _settings extends \IPS\Dispatcher\Controller
\IPS\Dispatcher::i()->checkAcpPermission( 'settings_access' );
$tabs = array();
if ( \IPS\Member::loggedIn()->hasAcpRestriction('forum_settings') )
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'forums', 'forums', 'forum_settings' ) )
{
$tabs['settings'] = 'forum_settings';
}
if ( \IPS\Member::loggedIn()->hasAcpRestriction('archive_manage') )
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'forums', 'forums', 'archive_manage' ) )
{
$tabs['archiving'] = 'archiving';
}
@@ -128,20 +128,20 @@ class _settings extends \IPS\Dispatcher\Controller
$members = array();
foreach( explode( ',', $rule['archive_text'] ) AS $v )
{
$members[] = \IPS\Member::load( $v )->name;
$members[] = \IPS\Member::load( $v );
}
$existingValues['archive_topic_starter'] = implode( ',', $members );
$existingValues['archive_topic_starter'] = $members;
}
else
{
$members = array();
foreach( explode( ',', $rule['archive_text'] ) AS $v )
{
$members[] = \IPS\Member::load( $v )->name;
$members[] = \IPS\Member::load( $v );
}
$existingValues['archive_topic_starter_not'] = implode( ',', $members );
$existingValues['archive_topic_starter_not'] = $members;
}
break;
}
@@ -224,7 +224,7 @@ class _settings extends \IPS\Dispatcher\Controller
{
if ( in_array( $k, array( 'archive_last_post' ) ) )
{
if ( !isset( $v[3] ) or !$v[3] )
if ( ( !isset( $v[3] ) or !$v[3] ) and $v[1] )
{
$rules[] = array(
'archive_key' => md5( "forums_{$k}" ),
@@ -239,7 +239,7 @@ class _settings extends \IPS\Dispatcher\Controller
}
elseif ( in_array( $k, array( 'archive_not_last_post' ) ) )
{
if ( !isset( $v[3] ) or !$v[3] )
if ( ( !isset( $v[3] ) or !$v[3] ) and $v[1] )
{
$rules[] = array(
'archive_key' => md5( "forums_{$k}" ),
@@ -299,7 +299,7 @@ class _settings extends \IPS\Dispatcher\Controller
}
elseif( in_array( $k, array( 'archive_topic_post', 'archive_topic_view', 'archive_topic_rating' ) ) )
{
if ( !isset( $v[2] ) )
if ( !isset( $v[2] ) and $v[1] )
{
$rules[] = array(
'archive_key' => md5( "forums_{$k}" ),
@@ -314,7 +314,7 @@ class _settings extends \IPS\Dispatcher\Controller
}
elseif( in_array( $k, array( 'archive_not_topic_post', 'archive_not_topic_view', 'archive_not_topic_rating' ) ) )
{
if ( !isset( $v[2] ) )
if ( !isset( $v[2] ) and $v[1] )
{
$rules[] = array(
'archive_key' => md5( "forums_{$k}" ),
@@ -329,7 +329,7 @@ class _settings extends \IPS\Dispatcher\Controller
}
elseif( in_array( $k, array( 'archive_topic_starter' ) ) )
{
if ( is_array( $v ) )
if ( is_array( $v ) and count( $v ) )
{
$ids = array();
foreach( $v AS $member )
@@ -350,7 +350,7 @@ class _settings extends \IPS\Dispatcher\Controller
}
elseif( in_array( $k, array( 'archive_topic_starter_not' ) ) )
{
if ( is_array( $v ) )
if ( is_array( $v ) AND count( $v ) )
{
$ids = array();
foreach( $v AS $member )
@@ -446,10 +446,19 @@ class _settings extends \IPS\Dispatcher\Controller
$_whereClause[] = $bind;
}
if( $values['archive_on'] )
{
\IPS\Db::i()->update( 'core_tasks', array( 'enabled' => (int)$values['archive_on'] ), array( '`key`=?', 'archive' ) );
}
/* Make sure the unarchive task is enabled - it will disable itself if there is no work to do */
\IPS\Db::i()->update( 'core_tasks', array( 'enabled' => 1 ), array( '`key`=?', 'unarchive' ) );
/* And disable the archive task if archiving is disabled */
if( !$values['archive_on'] )
{
\IPS\Db::i()->update( 'core_tasks', array( 'enabled' => 0 ), array( '`key`=?', 'archive' ) );
}
/* Or enable it if archiving is enabled */
else
{
\IPS\Db::i()->update( 'core_tasks', array( 'enabled' => 1 ), array( '`key`=?', 'archive' ) );
}
/* Log and redirect */
\IPS\Session::i()->log( 'acplogs__archive_settings' );
@@ -563,6 +572,7 @@ class _settings extends \IPS\Dispatcher\Controller
}
) ) );
$form->add( new \IPS\Helpers\Form\Number( 'forums_posts_per_page', \IPS\Settings::i()->forums_posts_per_page , TRUE, array( 'min' => 2, 'max' => 250 ) ) );
$form->add( new \IPS\Helpers\Form\Number( 'forums_topics_per_page', \IPS\Settings::i()->forums_topics_per_page , TRUE, array( 'min' => 5, 'max' => 100 ) ) );
$form->addHeader('question_settings');
$form->add( new \IPS\Helpers\Form\YesNo( 'forums_questions_downvote', \IPS\Settings::i()->forums_questions_downvote ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'forums_answers_downvote', \IPS\Settings::i()->forums_answers_downvote ) );
@@ -2,10 +2,10 @@
/**
* @brief posts
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @subpackage
* @package IPS Community Suite
* @subpackage Forums
* @since 18 Aug 2014
* @version SVN_VERSION_NUMBER
*/
@@ -2,10 +2,10 @@
/**
* @brief topics
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @subpackage
* @package IPS Community Suite
* @subpackage Forums
* @since 18 Aug 2014
* @version SVN_VERSION_NUMBER
*/
@@ -2,10 +2,10 @@
/**
* @brief Legacy 3.x findpost
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @subpackage Board
* @package IPS Community Suite
* @subpackage Forums
* @since 09 Jul 2015
* @version SVN_VERSION_NUMBER
*/
@@ -2,10 +2,10 @@
/**
* @brief Forum Index
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @subpackage Board
* @package IPS Community Suite
* @subpackage Forums
* @since 08 Jan 2014
* @version SVN_VERSION_NUMBER
*/
@@ -30,9 +30,7 @@ class _forums extends \IPS\Dispatcher\Controller
* @return void
*/
protected function manage()
{
\IPS\forums\Forum::loadIntoMemory();
{
$forum = NULL;
try
{
@@ -55,7 +53,7 @@ class _forums extends \IPS\Dispatcher\Controller
/* Password protected */
if ( $form = $forum->passwordForm() )
{
\IPS\Output::i()->title = $forum->_title;
\IPS\Output::i()->title = $forum->_stripTagsTitle;
\IPS\Output::i()->output = $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'forums', 'forums', 'front' ), 'forumPasswordPopup' ) );
return;
}
@@ -77,9 +75,10 @@ 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, isset( \IPS\Request::i()->rss ) ? FALSE : TRUE );
$table = new \IPS\Helpers\Table\Content( 'IPS\forums\Topic', $forum->url(), $where, $forum, NULL, 'view', isset( \IPS\Request::i()->rss ) ? FALSE : TRUE, isset( \IPS\Request::i()->rss ) ? FALSE : TRUE );
$table->tableTemplate = array( \IPS\Theme::i()->getTemplate( 'forums', 'forums', 'front' ), 'forumTable' );
$table->classes = array( 'cTopicList' );
$table->limit = \IPS\Settings::i()->forums_topics_per_page;
$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 ) ) );
if ( $forum->forums_bitoptions['bw_enable_answers'] )
{
@@ -148,6 +147,8 @@ class _forums extends \IPS\Dispatcher\Controller
'questions_with_best_answers' => 'topic_answered_pid>0',
'questions_without_best_answers' => 'topic_answered_pid=0',
);
$table->sortOptions['question_rating'] = 'forums_topics.question_rating';
}
/* Are we a moderator? */
@@ -188,7 +189,7 @@ class _forums extends \IPS\Dispatcher\Controller
$table->where[] = array( 'popular_time IS NOT NULL AND popular_time>?', time() );
break;
case 'poll':
$table->where[] = 'poll_state<>0';
$table->where[] = array( 'poll_state<>0' );
break;
case 'locked':
$table->where[] = array( 'state=?', 'closed' );
@@ -204,30 +205,36 @@ class _forums extends \IPS\Dispatcher\Controller
$table->where[] = array( 'forums_posts.author_id=?', \IPS\Member::loggedIn()->member_id );
break;
case 'answered':
$table->where[] = 'topic_answered_pid<>0';
$table->where[] = array( 'topic_answered_pid<>0' );
break;
case 'unanswered':
$table->where[] = 'topic_answered_pid=0';
$table->where[] = array( 'topic_answered_pid=0' );
break;
case 'queued_topics':
$table->where[] = 'approved=0';
$table->where[] = array( 'approved=0' );
break;
case 'queued_posts':
$table->where[] = 'topic_queuedposts>0';
$table->where[] = array( 'topic_queuedposts>0' );
break;
}
if ( ! isset( $values['sort_by'] ) )
{
$values['sort_by'] = 'forums_topics.last_post';
}
/* Sort */
switch ( $values['sort_by'] )
{
case 'last_post':
case 'views':
$table->sortBy = $values['sort_by'];
$table->sortBy = 'forums_topics.' . $values['sort_by'];
break;
case 'replies':
$table->sortBy = 'posts';
break;
case 'topic_title':
case 'title':
$table->sortBy = 'title';
break;
case 'last_poster':
@@ -244,45 +251,50 @@ class _forums extends \IPS\Dispatcher\Controller
/* Cutoff */
$days = NULL;
switch ( $values['time_frame'] )
if ( isset( $values['time_frame'] ) )
{
case 'today':
$days = 1;
break;
case 'last_5_days':
$days = 5;
break;
case 'last_7_days':
$days = 7;
break;
case 'last_10_days':
$days = 10;
break;
case 'last_15_days':
$days = 15;
break;
case 'last_20_days':
$days = 20;
break;
case 'last_25_days':
$days = 25;
break;
case 'last_30_days':
$days = 30;
break;
case 'last_60_days':
$days = 60;
break;
case 'last_90_days':
$days = 90;
break;
case 'since_last_visit':
$table->where[] = array( 'forums_topics.last_post>?', \IPS\Member::loggedIn()->last_visit );
break;
switch ( $values['time_frame'] )
{
case 'today':
$days = 1;
break;
case 'last_5_days':
$days = 5;
break;
case 'last_7_days':
$days = 7;
break;
case 'last_10_days':
$days = 10;
break;
case 'last_15_days':
$days = 15;
break;
case 'last_20_days':
$days = 20;
break;
case 'last_25_days':
$days = 25;
break;
case 'last_30_days':
$days = 30;
break;
case 'last_60_days':
$days = 60;
break;
case 'last_90_days':
$days = 90;
break;
case 'since_last_visit':
$table->where[] = array( 'forums_topics.last_post>?', \IPS\Member::loggedIn()->last_visit );
break;
}
}
if ( $days !== NULL )
{
$table->where[] = array( 'forums_topics.last_post>?', \IPS\DateTime::create()->sub( new \DateInterval( 'P' . $days . 'D' ) ) );
$table->where[] = array( 'forums_topics.last_post>?', \IPS\DateTime::create()->sub( new \DateInterval( 'P' . $days . 'D' ) )->getTimestamp() );
}
};
\IPS\Request::i()->sort_direction = \IPS\Request::i()->sort_direction ?: mb_strtolower( $table->sortDirection );
@@ -300,11 +312,11 @@ class _forums extends \IPS\Dispatcher\Controller
$rssUrl = \IPS\Http\Url::internal( "app=forums&module=forums&controller=forums&id={$forum->_id}&rss=1", 'front', 'forums_rss', array( $forum->name_seo ) );
if ( $forum->forums_bitoptions['bw_enable_answers'] )
{
$rssTitle = \IPS\Member::loggedIn()->language()->addToStack( 'forum_rss_title_questions', FALSE, array( 'sprintf' => array( $forum->_title ) ) );
$rssTitle = \IPS\Member::loggedIn()->language()->addToStack( 'forum_rss_title_questions', FALSE, array( 'sprintf' => array( $forum->_stripTagsTitle ) ) );
}
else
{
$rssTitle = \IPS\Member::loggedIn()->language()->addToStack( 'forum_rss_title_topics', FALSE, array( 'sprintf' => array( $forum->_title ) ) );
$rssTitle = \IPS\Member::loggedIn()->language()->addToStack( 'forum_rss_title_topics', FALSE, array( 'sprintf' => array( $forum->_stripTagsTitle ) ) );
}
\IPS\Output::i()->rssFeeds[ $rssTitle ] = $rssUrl;
@@ -333,7 +345,11 @@ class _forums extends \IPS\Dispatcher\Controller
{
if ( !$topic->hidden() )
{
$document->addItem( $topic->title, $topic->url(), $canViewContent ? $topic->content() : NULL, \IPS\DateTime::ts( $topic->start_date ), $topic->tid );
try
{
$document->addItem( $topic->title, $topic->url(), $canViewContent ? $topic->content() : NULL, \IPS\DateTime::ts( $topic->start_date ), $topic->tid );
}
catch ( \Exception $e ) { }
}
}
@@ -352,7 +368,7 @@ class _forums extends \IPS\Dispatcher\Controller
\IPS\Output::i()->output = (string) $table;
return;
}
\IPS\Output::i()->contextualSearchOptions[ \IPS\Member::loggedIn()->language()->addToStack( 'search_contextual_item', FALSE, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->addToStack( 'forums_sg' ) ) ) ) ] = array( 'type' => 'forums_topic', 'nodes' => $forum->_id );
\IPS\Output::i()->contextualSearchOptions[ \IPS\Member::loggedIn()->language()->addToStack( 'search_contextual_item_forums' ) ] = array( 'type' => 'forums_topic', 'nodes' => $forum->_id );
$forumOutput = '';
@@ -531,7 +547,7 @@ class _forums extends \IPS\Dispatcher\Controller
}
return NULL;
},
}
) ) );
if ( $values = $form->values() )
@@ -2,10 +2,10 @@
/**
* @brief index
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @subpackage
* @package IPS Community Suite
* @subpackage Forums
* @since 28 Jul 2014
* @version SVN_VERSION_NUMBER
*/
@@ -2,10 +2,10 @@
/**
* @brief Topic View
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @subpackage Board
* @package IPS Community Suite
* @subpackage Forums
* @since 08 Jan 2014
* @version SVN_VERSION_NUMBER
*/
@@ -48,7 +48,6 @@ class _topic extends \IPS\Content\Controller
protected function manage()
{
/* Load topic */
\IPS\forums\Forum::loadIntoMemory();
$topic = parent::manage();
\IPS\Member::loggedIn()->language()->words['submit_comment'] = \IPS\Member::loggedIn()->language()->addToStack( 'submit_reply', FALSE );
@@ -75,7 +74,15 @@ class _topic extends \IPS\Content\Controller
if ( !$topic->canView() )
{
\IPS\Output::i()->error( $forum ? $forum->errorMessage() : 'node_error_no_perm', '2F173/H', 403, '' );
if ( $topic instanceof \IPS\Content\Hideable and $topic->hidden() )
{
/* If the item is hidden we don't want to show the custom no permission error as the conditions may not apply */
\IPS\Output::i()->error( 'node_error', '2F173/O', 404, '' );
}
else
{
\IPS\Output::i()->error( $forum ? $forum->errorMessage() : 'node_error_no_perm', '2F173/H', 403, '' );
}
}
}
catch ( \OutOfRangeException $e )
@@ -94,16 +101,36 @@ class _topic extends \IPS\Content\Controller
{
\IPS\Output::i()->redirect( $topic->url()->setQueryString( array( 'do' => 'findComment', 'comment' => \IPS\Request::i()->p ) ), NULL, 301 );
}
elseif ( \IPS\Request::i()->pid )
{
\IPS\Output::i()->redirect( $topic->url()->setQueryString( array( 'do' => 'findComment', 'comment' => \IPS\Request::i()->pid ) ), NULL, 301 );
}
if ( \IPS\Request::i()->view )
{
$this->_doViewCheck();
}
/* If this is an AJAX request fetch the comment form now. The HTML will be cached so calling here and then again in the template has no overhead
and this is necessary if you entered into a topic with &queued_posts=1, approve the posts, then try to reply. Otherwise, clicking into the
editor produces an error when the getUploader=1 call occurs, and submitting a reply results in an error. */
if ( \IPS\Request::i()->isAjax() and ( !isset( \IPS\Request::i()->preview ) OR !\IPS\Request::i()->preview ) )
{
$topic->commentForm();
}
/* AJAX hover preview? */
if ( \IPS\Request::i()->isAjax() and \IPS\Request::i()->preview )
{
$firstPost = $topic->comments( 1 );
$postClass = '\IPS\forums\Topic\Post';
if( $topic->isArchived() )
{
$postClass = '\IPS\forums\Topic\ArchivedPost';
}
$firstPost = $postClass::load( $topic->topic_firstpost );
$topicOverview = array( 'firstPost' => array( $topic->isQuestion() ? 'question_mainTab' : 'first_post', $firstPost ) );
if ( $topic->posts > 1 )
@@ -138,13 +165,7 @@ class _topic extends \IPS\Content\Controller
{
$poll->attach( $topic );
}
/* One for the brits */
if ( mb_strpos( $topic->title, base64_decode( 'c3BhbmlzaA==' ) ) !== FALSE and $topic->isQuestion() )
{
\IPS\Output::i()->output .= base64_decode( 'PCEtLSBOTyBPTkUgRVhQRUNUUyBUSEUgU1BBTklTSCBJTlFVSVNJVElPTiAtLT4=' );
}
/* How are we sorting posts? */
$question = NULL;
$offset = NULL;
@@ -153,9 +174,22 @@ class _topic extends \IPS\Content\Controller
$where = NULL;
if( \IPS\forums\Topic::modPermission( 'unhide', NULL, $topic->container() ) AND \IPS\Request::i()->queued_posts )
{
$where = 'queued=1';
if ( $topic->isArchived() )
{
$where = 'archive_queued=1';
}
else
{
$where = 'queued=1';
}
$queuedPagesCount = ceil( \IPS\Db::i()->select( 'COUNT(*)', 'forums_posts', array( 'topic_id=? AND queued=1', $topic->id ) )->first() / $topic->getCommentsPerPage() );
$pagination = ( $queuedPagesCount > 1 ) ? $topic->commentPagination( array( 'queued_posts', 'sortby' ), 'pagination', $queuedPagesCount ) : NULL;
if ( $topic->isQuestion() )
{
$question = $topic->comments( 1, 0 );
}
}
else
{
@@ -193,7 +227,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 );
$current = current( $comments );
reset( $comments );
@@ -203,9 +237,8 @@ class _topic extends \IPS\Content\Controller
}
/* On pages 2 and more, it will show the first post on that page, and that is fine as the title has - Page 2 in it meaning its a different page */
$metaDescription = strip_tags( $topic->isQuestion() ? $question->post : $current->post );
\IPS\Output::i()->metaTags['description'] = \IPS\Output::i()->metaTags['og:description'] = ( mb_strlen( $metaDescription ) > 160 ? ( mb_substr( $metaDescription, 0, 157 ) . '...' ) : $metaDescription );
$metaDescription = $topic->isQuestion() ? $question->post : $current->post;
/* Did we request a specific post? If so, reset descriptions. */
if( isset( $_SESSION['_findComment'] ) )
{
@@ -216,10 +249,13 @@ class _topic extends \IPS\Content\Controller
{
$comment = \IPS\forums\Topic\Post::loadAndCheckPerms( $commentId );
\IPS\Output::i()->metaTags['description'] = \IPS\Output::i()->metaTags['og:description'] = strip_tags( $comment->content() );
$metaDescription = $comment->content();
}
catch( \Exception $e ){}
}
$metaDescription = strip_tags( $metaDescription );
\IPS\Output::i()->metaTags['description'] = \IPS\Output::i()->metaTags['og:description'] = mb_strlen( $metaDescription ) > 160 ? ( mb_substr( $metaDescription, 0, 157 ) . '...' ) : $metaDescription;
/* Mark read */
if( !$topic->isLastPage() )
@@ -338,23 +374,7 @@ class _topic extends \IPS\Content\Controller
}
}
$form = new \IPS\Helpers\Form( 'form', \IPS\Member::loggedIn()->language()->checkKeyExists( $class::$formLangPrefix . '_save' ) ? $class::$formLangPrefix . '_save' : 'save' );
$form->class = 'ipsForm_vertical';
if ( isset( $formElements['poll'] ) )
{
$form->addTab( $class::$formLangPrefix . 'mainTab' );
}
foreach( $formElements AS $k => $element )
{
if ( $k === 'poll' )
{
$form->addTab( $class::$formLangPrefix . 'pollTab' );
}
$form->add( $element );
}
$form = $topic->buildEditForm();
if ( $values = $form->values() )
{
@@ -363,7 +383,10 @@ class _topic extends \IPS\Content\Controller
$topic->processForm( $values );
$topic->save();
$topic->processAfterEdit( $values );
/* Moderator log */
\IPS\Session::i()->modLog( 'modlog__item_edit', array( $topic::$title => FALSE, $topic->url()->__toString() => FALSE, $topic::$title => TRUE, $topic->mapped( 'title' ) => FALSE ), $topic );
\IPS\Output::i()->redirect( $topic->url() );
}
else
@@ -404,6 +427,8 @@ class _topic extends \IPS\Content\Controller
*/
public function unarchive()
{
\IPS\Session::i()->csrfCheck();
try
{
$topic = \IPS\forums\Topic::loadAndCheckPerms( \IPS\Request::i()->id );
@@ -477,7 +502,7 @@ class _topic extends \IPS\Content\Controller
}
/* Rebuild count */
$question->question_rating = \IPS\Db::i()->select( 'SUM(rating)', 'forums_question_ratings', array( 'topic=?', $question->tid ) )->first();
$question->question_rating = \IPS\Db::i()->select( 'SUM(rating)', 'forums_question_ratings', array( 'topic=?', $question->tid ), NULL, NULL, NULL, NULL, \IPS\Db::SELECT_FROM_WRITE_SERVER )->first();
$question->save();
/* Redirect back */
@@ -513,16 +538,25 @@ class _topic extends \IPS\Content\Controller
{
\IPS\Output::i()->error( 'form_bad_value', '2F173/6', 403, '' );
}
\IPS\Db::i()->insert( 'forums_answer_ratings', array(
'post' => $answer->pid,
'topic' => $question->tid,
'member' => \IPS\Member::loggedIn()->member_id,
'rating' => $rating,
'date' => time()
), TRUE );
$answer->post_field_int = \IPS\Db::i()->select( 'SUM(rating)', 'forums_answer_ratings', array( 'post=?', $answer->pid ) )->first();
/* Have we already rated ? */
try
{
$rating = \IPS\Db::i()->select( '*', 'forums_answer_ratings', array( 'topic=? AND post=? AND member=?', $question->tid, $answer->pid, \IPS\Member::loggedIn()->member_id ) )->first();
\IPS\Db::i()->delete( 'forums_answer_ratings', array( 'topic=? AND post=? AND member=?', $question->tid, $answer->pid, \IPS\Member::loggedIn()->member_id ) );
}
catch ( \UnderflowException $e )
{
\IPS\Db::i()->insert( 'forums_answer_ratings', array(
'post' => $answer->pid,
'topic' => $question->tid,
'member' => \IPS\Member::loggedIn()->member_id,
'rating' => $rating,
'date' => time()
), TRUE );
}
$answer->post_field_int = (int) \IPS\Db::i()->select( 'SUM(rating)', 'forums_answer_ratings', array( 'post=?', $answer->pid ), NULL, NULL, NULL, NULL, \IPS\Db::SELECT_FROM_WRITE_SERVER )->first();
$answer->save();
if ( \IPS\Request::i()->isAjax() )