Version 3.4.5
This commit is contained in:
1 parent
fb6b5baabc
commit
e4478369d8
1360 files changed
+228921
-179445
No files matched your search
@@ -2,18 +2,18 @@
|
||||
/**
|
||||
* <pre>
|
||||
* Invision Power Services
|
||||
* IP.Board v3.3.4
|
||||
* IP.Board v3.4.5
|
||||
* Moderator actions
|
||||
* Last Updated: $Date: 2012-06-15 08:09:05 -0400 (Fri, 15 Jun 2012) $
|
||||
* Last Updated: $Date: 2013-05-08 12:08:00 -0400 (Wed, 08 May 2013) $
|
||||
* </pre>
|
||||
*
|
||||
* @author $Author: AndyMillne $
|
||||
* @author $Author: bfarber $
|
||||
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/company/standards.php#license
|
||||
* @package IP.Board
|
||||
* @subpackage Forums
|
||||
* @link http://www.invisionpower.com
|
||||
* @version $Revision: 10929 $
|
||||
* @version $Revision: 12237 $
|
||||
*/
|
||||
|
||||
if ( ! defined( 'IN_IPB' ) )
|
||||
@@ -50,7 +50,7 @@ class app_forums_classes_topics
|
||||
private $_countPosts = 0;
|
||||
private $_countTopics = 0;
|
||||
private $_archiveReader = null;
|
||||
|
||||
private $_parser = null;
|
||||
/**
|
||||
* Return errors, instead of printing
|
||||
*
|
||||
@@ -186,7 +186,19 @@ class app_forums_classes_topics
|
||||
/* May have loaded topic data previously */
|
||||
if ( empty( $this->registry->class_forums->topic_cache['tid'] ) )
|
||||
{
|
||||
$this->DB->build( array( 'select' => '*', 'from' => 'topics', 'where' => 'tid=' . $topicId ) );
|
||||
/* Load tagging stuff */
|
||||
if ( ! $this->registry->isClassLoaded('tags') )
|
||||
{
|
||||
require_once( IPS_ROOT_PATH . 'sources/classes/tags/bootstrap.php' );/*noLibHook*/
|
||||
$this->registry->setClass( 'tags', classes_tags_bootstrap::run( 'forums', 'topics' ) );
|
||||
}
|
||||
|
||||
$this->DB->build( array(
|
||||
'select' => 't.*',
|
||||
'from' => array( 'topics' => 't' ),
|
||||
'where' => 't.tid=' . $topicId,
|
||||
'add_join' => array( $this->registry->tags->getCacheJoin( array( 'meta_id_field' => 't.tid' ) ) )
|
||||
) );
|
||||
$this->DB->execute();
|
||||
|
||||
$this->setTopicData( $this->DB->fetch() );
|
||||
@@ -220,7 +232,7 @@ class app_forums_classes_topics
|
||||
}
|
||||
|
||||
/* Set up */
|
||||
$this->topicData = $this->setUpTopic( $this->topicData );
|
||||
$this->topicData = $this->setUpTopic( $this->topicData );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -245,7 +257,11 @@ class app_forums_classes_topics
|
||||
|
||||
/* Got any unread posts? */
|
||||
$topic['hasUnreadPosts'] = ( $this->registry->classItemMarking->isRead( array( 'forumID' => $topic['forum_id'], 'itemID' => $topic['tid'], 'itemLastUpdate' => $topic['last_post'] ), 'forums' ) ) ? false : true;
|
||||
|
||||
|
||||
$topic['Perms'] = array( 'canQueuePosts' => $this->registry->class_forums->canQueuePosts( $topic['forum_id'] ),
|
||||
'canAnswerTopic' => $this->registry->topics->canAnswerTopic( $topic ),
|
||||
'canRateAnswer' => $this->registry->topics->canRateAnsweredPost( $topic ) );
|
||||
|
||||
return $topic;
|
||||
}
|
||||
|
||||
@@ -274,16 +290,6 @@ class app_forums_classes_topics
|
||||
$tid = intval( $tid );
|
||||
$topicData = $this->getTopicById( $tid );
|
||||
|
||||
if ( $this->settings['post_order_column'] != 'post_date' )
|
||||
{
|
||||
$this->settings['post_order_column'] = 'pid';
|
||||
}
|
||||
|
||||
if ( $this->settings['post_order_sort'] != 'desc' )
|
||||
{
|
||||
$this->settings['post_order_sort'] = 'asc';
|
||||
}
|
||||
|
||||
/* Is this archived? */
|
||||
if ( $this->isArchived( $topicData ) )
|
||||
{
|
||||
@@ -307,8 +313,8 @@ class app_forums_classes_topics
|
||||
|
||||
/* Get last post info */
|
||||
$_post = $this->getPosts( array( 'onlyVisible' => true,
|
||||
'sortField' => $this->settings['post_order_column'],
|
||||
'sortOrder' => ( $this->settings['post_order_sort'] == 'asc' ) ? 'desc' : 'asc',
|
||||
'sortField' => 'post_date',
|
||||
'sortOrder' => 'desc',
|
||||
'topicId' => array( $tid ),
|
||||
'limit' => 1,
|
||||
'archiveToNative' => true,
|
||||
@@ -318,8 +324,8 @@ class app_forums_classes_topics
|
||||
|
||||
/* Get first post info */
|
||||
$_post = $this->getPosts( array( 'onlyVisible' => true,
|
||||
'sortField' => $this->settings['post_order_column'],
|
||||
'sortOrder' => $this->settings['post_order_sort'],
|
||||
'sortField' => 'post_date',
|
||||
'sortOrder' => 'asc',
|
||||
'topicId' => array( $tid ),
|
||||
'limit' => 1,
|
||||
'archiveToNative' => true,
|
||||
@@ -345,6 +351,9 @@ class app_forums_classes_topics
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Touch tags to rebuild cache */
|
||||
$this->registry->getClass('tags')->rebuildCache( array( 'meta_id' => $tid ) );
|
||||
|
||||
/* Fetch replies */
|
||||
$_queued = $this->registry->class_forums->fetchPostHiddenQuery( array( 'visible' ), '' );
|
||||
$posts = $this->DB->buildAndFetch( array( 'select' => 'COUNT(*) as posts', 'from' => 'posts', 'where' => "topic_id={$tid} and {$_queued}" ) );
|
||||
@@ -362,8 +371,8 @@ class app_forums_classes_topics
|
||||
|
||||
/* Get last post info */
|
||||
$_post = $this->getPosts( array( 'onlyVisible' => true,
|
||||
'sortField' => $this->settings['post_order_column'],
|
||||
'sortOrder' => ( $this->settings['post_order_sort'] == 'asc' ) ? 'desc' : 'asc',
|
||||
'sortField' => 'post_date',
|
||||
'sortOrder' => 'desc',
|
||||
'topicId' => array( $tid ),
|
||||
'limit' => 1 ) );
|
||||
|
||||
@@ -371,8 +380,8 @@ class app_forums_classes_topics
|
||||
|
||||
/* Get first post info */
|
||||
$_post = $this->getPosts( array( 'onlyVisible' => true,
|
||||
'sortField' => $this->settings['post_order_column'],
|
||||
'sortOrder' => $this->settings['post_order_sort'],
|
||||
'sortField' => 'post_date',
|
||||
'sortOrder' => 'asc',
|
||||
'topicId' => array( $tid ),
|
||||
'limit' => 1 ) );
|
||||
|
||||
@@ -392,6 +401,7 @@ class app_forums_classes_topics
|
||||
$this->DB->setDataType( array( 'starter_name', 'last_poster_name' ), 'string' );
|
||||
|
||||
$this->DB->update( 'topics', array( 'last_post' => intval($last_post['post_date'] ? $last_post['post_date'] : $first_post['post_date']),
|
||||
'last_real_post' => intval($last_post['post_date'] ? $last_post['post_date'] : $first_post['post_date']),
|
||||
'last_poster_id' => intval($last_post['author_id'] ? $last_post['author_id'] : ( $pcount > 0 ? 0 : $first_post['author_id'] )),
|
||||
'last_poster_name' => $_last_poster_name,
|
||||
'poll_state' => empty($first_post['has_poll_id']) ? 0 : 1,
|
||||
@@ -488,19 +498,31 @@ class app_forums_classes_topics
|
||||
* @param boolean Check for archived topic
|
||||
* @return array Post Data
|
||||
*/
|
||||
public function getPostById( $pid, $checkArchived=false )
|
||||
public function getPostById( $pid, $checkArchived=false, $additionalFilters=array() )
|
||||
{
|
||||
$post = array();
|
||||
$post = array();
|
||||
$additionalFilters = ( is_array( $additionalFilters ) ) ? $additionalFilters : array( $additionalFilters );
|
||||
|
||||
if ( ! empty($pid) )
|
||||
{
|
||||
$posts = $this->getPosts( array( 'postId' => array( $pid ),
|
||||
'checkArchived' => $checkArchived ) );
|
||||
$posts = $this->getPosts( array_merge( $additionalFilters, array( 'postId' => array( $pid ),
|
||||
'checkArchived' => $checkArchived ) ) );
|
||||
|
||||
$post = $posts[ $pid ];
|
||||
|
||||
}
|
||||
|
||||
/* Bitwise options */
|
||||
$_tmp = IPSBWOptions::thaw( $post['post_bwoptions'], 'posts', 'forums' );
|
||||
|
||||
if ( count( $_tmp ) )
|
||||
{
|
||||
foreach( $_tmp as $k => $v )
|
||||
{
|
||||
$post[ $k ] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
return $post;
|
||||
}
|
||||
|
||||
@@ -685,7 +707,7 @@ class app_forums_classes_topics
|
||||
'limit' => $limit ? $limit : '',
|
||||
'order' => $order ? $order : 't.tid asc',
|
||||
'add_join' => $joins ) );
|
||||
|
||||
|
||||
$o = $this->DB->execute();
|
||||
|
||||
while( $topic = $this->DB->fetch( $o ) )
|
||||
@@ -726,7 +748,7 @@ class app_forums_classes_topics
|
||||
|
||||
/**
|
||||
* getTopicsCount
|
||||
* Fetches number of topics based on different critera (useful for pagination when combined with getPosts())
|
||||
* Fetches number of topics based on different critera (useful for pagination when combined with getTopics())
|
||||
* @return int
|
||||
*/
|
||||
public function getTopicsCount()
|
||||
@@ -745,6 +767,7 @@ class app_forums_classes_topics
|
||||
* forumId Get posts matching the (array) forum ids, (int) forum ID
|
||||
* notForumId Get posts NOT matching the (array) forum ids, (int) forum ID
|
||||
* postId Get posts matching the (array) post ids, (int) post id
|
||||
* postDate Get posts matching the (array) post dates, (int) post date
|
||||
* authorId Get posts matching the (array) author ids, (int) author id
|
||||
* memberData Set memberData (this->memberData is used otherwise)
|
||||
* onlyViewable Set whether this member can view them or not. (default is true ) NOTE: Will not check to see if parent topic is viewable!
|
||||
@@ -786,46 +809,58 @@ class app_forums_classes_topics
|
||||
}
|
||||
|
||||
$posts = $this->_archiveReader->getPosts( $filters );
|
||||
|
||||
/* If we just need the count let's go */
|
||||
if ( $filters['getCountOnly'] )
|
||||
{
|
||||
return $posts;
|
||||
}
|
||||
|
||||
/* Fetch topics */
|
||||
$tids = array();
|
||||
$mids = array();
|
||||
|
||||
foreach( $posts as $id => $post )
|
||||
|
||||
if ( !empty( $posts ) )
|
||||
{
|
||||
$tids[ $post['topic_id'] ] = $post['topic_id'];
|
||||
|
||||
if ( $post['author_id'] )
|
||||
foreach( $posts as $id => $post )
|
||||
{
|
||||
$mids[ $post['author_id'] ] = $post['author_id'];
|
||||
$tids[ $post['topic_id'] ] = $post['topic_id'];
|
||||
|
||||
if ( $post['author_id'] )
|
||||
{
|
||||
$mids[ $post['author_id'] ] = $post['author_id'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$topics = $this->getTopics( array( 'topicId' => $tids ) );
|
||||
$members = IPSMember::load( $mids );
|
||||
|
||||
foreach( $posts as $id => $post )
|
||||
if ( !empty( $posts ) )
|
||||
{
|
||||
$posts[ $id ] = array_merge( $topics[ $post['topic_id'] ], $post );
|
||||
|
||||
if ( $post['author_id'] )
|
||||
foreach( $posts as $id => $post )
|
||||
{
|
||||
$_mem = $members[ $post['author_id'] ];
|
||||
unset( $_mem['title'] );
|
||||
|
||||
$posts[ $id ] = array_merge( $_mem, $post );
|
||||
$posts[ $id ] = array_merge( $topics[ $post['topic_id'] ], $post );
|
||||
|
||||
if ( $post['author_id'] )
|
||||
{
|
||||
$_mem = $members[ $post['author_id'] ];
|
||||
unset( $_mem['title'] );
|
||||
|
||||
$posts[ $id ] = array_merge( $_mem, $post );
|
||||
}
|
||||
|
||||
if ( ! empty( $filters['parse'] ) )
|
||||
{
|
||||
$this->setTopicData( $post );
|
||||
$this->setPermissionData();
|
||||
$posts[ $id ] = $this->parsePost( $posts[ $id ] );
|
||||
}
|
||||
|
||||
$posts[ $id ]['tid'] = $post['topic_id'];
|
||||
$posts[ $id ]['_postType'] = $this->registry->class_forums->fetchHiddenType( $post );
|
||||
$posts[ $id ]['_topicType'] = $this->registry->class_forums->fetchHiddenTopicType( $post );
|
||||
}
|
||||
|
||||
if ( ! empty( $filters['parse'] ) )
|
||||
{
|
||||
$this->setTopicData( $post );
|
||||
$this->setPermissionData();
|
||||
$posts[ $id ] = $this->parsePost( $posts[ $id ] );
|
||||
}
|
||||
|
||||
$posts[ $id ]['tid'] = $post['topic_id'];
|
||||
$posts[ $id ]['_postType'] = $this->registry->class_forums->fetchHiddenType( $post );
|
||||
$posts[ $id ]['_topicType'] = $this->registry->class_forums->fetchHiddenTopicType( $post );
|
||||
}
|
||||
|
||||
return $posts;
|
||||
@@ -838,7 +873,14 @@ class app_forums_classes_topics
|
||||
$filters['postId'] = ( ! is_array( $filters['postId'] ) ) ? array( $filters['postId'] ) : $filters['postId'];
|
||||
$where[] = "p." . $this->getPostTableField( 'pid', $isArchived ) . " IN (" . implode( ',',$filters['postId'] ) . ")";
|
||||
}
|
||||
|
||||
|
||||
/* Posts */
|
||||
if ( ! empty( $filters['postDate'] ) )
|
||||
{
|
||||
$filters['postDate'] = ( ! is_array( $filters['postDate'] ) ) ? array( $filters['postDate'] ) : $filters['postDate'];
|
||||
$where[] = "p." . $this->getPostTableField( 'post_date', $isArchived ) . " IN (" . implode( ',',$filters['postDate'] ) . ")";
|
||||
}
|
||||
|
||||
/* Topics */
|
||||
if ( ! empty( $filters['topicId'] ) )
|
||||
{
|
||||
@@ -879,12 +921,37 @@ class app_forums_classes_topics
|
||||
$where[] = "p.". $this->getPostTableField( 'pid', $isArchived ) . " < " . intval( $filters['pidIsLess'] );
|
||||
}
|
||||
|
||||
/* Author is ignored */
|
||||
if ( ! empty( $filters['notIgnored'] ) )
|
||||
{
|
||||
$ignoredUsers = array();
|
||||
|
||||
foreach( $this->member->ignored_users as $_i )
|
||||
{
|
||||
if( $_i['ignore_topics'] )
|
||||
{
|
||||
$ignoredUsers[] = $_i['ignore_ignore_id'];
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! empty( $ignoredUsers ) )
|
||||
{
|
||||
$where[] = "p." . $this->getPostTableField( 'author_id', $isArchived ) . " NOT IN (" . implode( ',',$ignoredUsers ) . ")";
|
||||
}
|
||||
}
|
||||
|
||||
/* Date is greater */
|
||||
if ( ! empty( $filters['dateIsGreater'] ) )
|
||||
{
|
||||
$where[] = "p.". $this->getPostTableField( 'post_date', $isArchived ) . " > " . intval( $filters['dateIsGreater'] );
|
||||
}
|
||||
|
||||
/* Date is less */
|
||||
if ( ! empty( $filters['dateIsLess'] ) )
|
||||
{
|
||||
$where[] = "p.". $this->getPostTableField( 'post_date', $isArchived ) . " < " . intval( $filters['dateIsLess'] );
|
||||
}
|
||||
|
||||
/* Visible / specific filters */
|
||||
if ( ! empty( $filters['postType'] ) && is_array( $filters['postType'] ) )
|
||||
{
|
||||
@@ -1224,6 +1291,8 @@ class app_forums_classes_topics
|
||||
'where' => "forum_id LIKE '%,{$forumData['id']},%' AND (member_id={$this->memberData['member_id']} OR (is_group=1 AND group_id IN({$member_group_ids})))" ) );
|
||||
|
||||
$this->moderatorData = ( is_array( $this->moderatorData ) ) ? $this->moderatorData : array();
|
||||
|
||||
$this->moderatorData = array_merge( $this->moderatorData, IPSBWOptions::thaw( $this->moderatorData['mod_bitoptions'], 'moderators', 'forums' ) );
|
||||
}
|
||||
|
||||
return $this->moderatorData;
|
||||
@@ -1270,18 +1339,17 @@ class app_forums_classes_topics
|
||||
public function isOnLastPage( $topicData=false )
|
||||
{
|
||||
$topicData = ( ! is_array( $topicData ) ) ? $this->getTopicData() : $topicData;
|
||||
$st = intval( $this->request['st'] );
|
||||
$page = intval( $this->request['page'] );
|
||||
$perPage = $this->settings['display_max_posts'];
|
||||
$posts = intval( $topicData['posts'] ) + 1;
|
||||
|
||||
$maxPage = ceil( $posts / $perPage );
|
||||
|
||||
if ( $posts <= $perPage )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
$maxSt = ( ceil( $posts / $perPage ) - 1 ) * $perPage;
|
||||
|
||||
if ( $st == $maxSt )
|
||||
if ( $maxPage == $page )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -1509,16 +1577,20 @@ class app_forums_classes_topics
|
||||
* Can make a reply to this topic
|
||||
* @return string locked / moved / no_reply / reply
|
||||
*/
|
||||
public function getReplyStatus()
|
||||
public function getReplyStatus( $topicData=array() )
|
||||
{
|
||||
if ( empty( $topicData['tid'] ) )
|
||||
{
|
||||
$topicData = $this->getTopicData();
|
||||
}
|
||||
|
||||
/* Is we archived? */
|
||||
if ( $this->isArchived( $this->getTopicData() ) )
|
||||
if ( $this->isArchived( $topicData ) )
|
||||
{
|
||||
return 'archived';
|
||||
}
|
||||
|
||||
/* Init */
|
||||
$topicData = $this->getTopicData();
|
||||
$forumData = $this->registry->getClass('class_forums')->getForumbyId( $topicData['forum_id'] );
|
||||
|
||||
$status = '';
|
||||
@@ -1554,7 +1626,7 @@ class app_forums_classes_topics
|
||||
else
|
||||
{
|
||||
if ( $this->memberData['member_id'] AND ( ( ( $this->memberData['member_id'] == $topicData['starter_id'] ) AND ! $this->memberData['g_reply_own_topics'] ) OR ( ( $this->memberData['member_id'] != $topicData['starter_id'] ) AND ! $this->memberData['g_reply_other_topics'] ) ) )
|
||||
{
|
||||
{
|
||||
$status = "no_reply";
|
||||
}
|
||||
else if ( $this->registry->permissions->check( 'reply', $forumData ) == TRUE )
|
||||
@@ -1686,7 +1758,7 @@ class app_forums_classes_topics
|
||||
// Rebuild SEO title on the fly, if needed
|
||||
//-----------------------------------------
|
||||
|
||||
if( ! $topic['title_seo'] )
|
||||
if( ! $topic['title_seo'] AND $topic['tid'] )
|
||||
{
|
||||
$topic['title_seo'] = IPSText::makeSeoTitle( $topic['title'] );
|
||||
|
||||
@@ -1734,7 +1806,7 @@ class app_forums_classes_topics
|
||||
|
||||
if ( $topic['_hasUnread'] )
|
||||
{
|
||||
$topic['_unreadUrl'] = $this->registry->output->buildSEOUrl( 'showtopic=' . $topic['tid'] . '&view=getnewpost', 'public', $topic['title_seo'], 'showtopicunread' );
|
||||
$topic['_unreadUrl'] = $this->registry->output->buildSEOUrl( 'showtopic=' . $topic['tid'] . '&view=getnewpost', 'public', $topic['title_seo'], 'showtopic' );
|
||||
}
|
||||
|
||||
$topic['_url'] = $this->registry->output->buildSEOUrl( 'showtopic=' . $topic['tid'], 'public', $topic['title_seo'], 'showtopic' );
|
||||
@@ -1763,7 +1835,7 @@ class app_forums_classes_topics
|
||||
else
|
||||
{
|
||||
$topic['last_poster_name'] = $this->settings['guest_name_pre'] . $topic['last_poster_name'] . $this->settings['guest_name_suf'];
|
||||
$topic['last_poster'] = $this->registry->getClass('output')->getTemplate('global')->userHoverCard( array( 'member_id' => 0, 'members_display_name' => $this->settings['guest_name_pre'] . $topic['last_poster_name'] . $this->settings['guest_name_suf'] ) );
|
||||
$topic['last_poster'] = $this->registry->getClass('output')->getTemplate('global')->userHoverCard( array( 'member_id' => 0, 'members_display_name' => $topic['last_poster_name'] ) );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
@@ -1881,6 +1953,9 @@ class app_forums_classes_topics
|
||||
$topic['tags'] = $this->registry->tags->formatCacheJoinData( $topic );
|
||||
}
|
||||
|
||||
/* Answered */
|
||||
$topic['_answeredPid'] = $this->getTopicAnswerPid( $topic );
|
||||
|
||||
return $topic;
|
||||
}
|
||||
|
||||
@@ -1902,7 +1977,7 @@ class app_forums_classes_topics
|
||||
$poster = array();
|
||||
|
||||
/* Bitwise options */
|
||||
$_tmp = IPSBWOptions::thaw( $post['post_bwoptions'], 'post', 'forums' );
|
||||
$_tmp = IPSBWOptions::thaw( $post['post_bwoptions'], 'posts', 'forums' );
|
||||
|
||||
if ( count( $_tmp ) )
|
||||
{
|
||||
@@ -1948,13 +2023,43 @@ class app_forums_classes_topics
|
||||
$post['_isHidden'] = ( $this->registry->getClass('class_forums')->fetchHiddenType( $post ) == 'hidden' ) ? true : false;
|
||||
$post['_isDeleted'] = ( $this->registry->getClass('class_forums')->fetchHiddenType( $post ) == 'sdelete' ) ? true : false;
|
||||
|
||||
/* Answered post */
|
||||
try
|
||||
{
|
||||
$post['_isMarkedAnswered'] = ( $this->postIsAnswer( $post, $topicData ) ) ? true : false;
|
||||
}
|
||||
catch( Exception $e )
|
||||
{
|
||||
$post['_isMarkedAnswered'] = false;
|
||||
}
|
||||
|
||||
$post['_canMarkUnanswered'] = ( $post['_isMarkedAnswered'] === true && $this->canUnanswerTopic( $topicData ) ) ? true : false;
|
||||
$post['_canAnswer'] = ( $post['_isMarkedAnswered'] === false && $this->canAnswerTopic( $topicData ) ) ? true : false;
|
||||
|
||||
$post['PermalinkUrlBit'] = '';
|
||||
|
||||
/* Queued */
|
||||
if ( $topicData['topic_firstpost'] == $post['pid'] and ( $post['_isHidden'] OR $topicData['_isHidden'] ) )
|
||||
{
|
||||
$post['queued'] = 1;
|
||||
$post['_isHidden'] = true;
|
||||
}
|
||||
|
||||
|
||||
if ( $topicData['topic_queuedposts'] || $topicData['topic_deleted_posts'] )
|
||||
{
|
||||
if ( $topicData['topic_queuedposts'] && $topicData['Perms']['canQueuePosts'] )
|
||||
{
|
||||
/* We have hidden data that is viewable */
|
||||
$post['PermalinkUrlBit'] = '&p=' . $post['pid'];
|
||||
}
|
||||
|
||||
if ( $topicData['topic_deleted_posts'] && $post['_softDeleteSee'] )
|
||||
{
|
||||
/* We have hidden data that is viewable */
|
||||
$post['PermalinkUrlBit'] = '&p=' . $post['pid'];
|
||||
}
|
||||
}
|
||||
|
||||
/* Edited stuff */
|
||||
$post['edit_by'] = "";
|
||||
|
||||
@@ -1970,15 +2075,24 @@ class app_forums_classes_topics
|
||||
{
|
||||
$_NOW2 = IPSDebug::getMemoryDebugFlag();
|
||||
|
||||
IPSText::getTextClass('bbcode')->parse_smilies = $post['use_emo'];
|
||||
IPSText::getTextClass('bbcode')->parse_html = ( $forumData['use_html'] and $poster['g_dohtml'] and $post['post_htmlstate'] ) ? 1 : 0;
|
||||
IPSText::getTextClass('bbcode')->parse_nl2br = $post['post_htmlstate'] == 2 ? 1 : 0;
|
||||
IPSText::getTextClass('bbcode')->parse_bbcode = $forumData['use_ibc'];
|
||||
IPSText::getTextClass('bbcode')->parsing_section = 'topics';
|
||||
IPSText::getTextClass('bbcode')->parsing_mgroup = $post['member_group_id'];
|
||||
IPSText::getTextClass('bbcode')->parsing_mgroup_others = $post['mgroup_others'];
|
||||
/* Grab the parser file */
|
||||
if ( $this->_parser === null )
|
||||
{
|
||||
/* Load parser */
|
||||
$classToLoad = IPSLib::loadLibrary( IPS_ROOT_PATH . 'sources/classes/text/parser.php', 'classes_text_parser' );
|
||||
$this->_parser = new $classToLoad();
|
||||
}
|
||||
|
||||
/* set up parser */
|
||||
$this->_parser->set( array( 'memberData' => array( 'member_id' => $post['member_id'],
|
||||
'member_group_id' => $post['member_group_id'],
|
||||
'mgroup_others' => $post['mgroup_others'] ),
|
||||
'parseBBCode' => $forumData['use_ibc'],
|
||||
'parseHtml' => ( $forumData['use_html'] and $poster['g_dohtml'] and $post['post_htmlstate'] ) ? 1 : 0,
|
||||
'parseEmoticons' => $post['use_emo'],
|
||||
'parseArea' => 'topics' ) );
|
||||
|
||||
$post['post'] = IPSText::getTextClass('bbcode')->preDisplayParse( $post['post'] );
|
||||
$post['post'] = $this->_parser->display( $post['post'] );
|
||||
|
||||
IPSDebug::setMemoryDebugFlag( "topics::parsePostRow - bbcode parse - Completed", $_NOW2 );
|
||||
|
||||
@@ -2059,7 +2173,7 @@ class app_forums_classes_topics
|
||||
{
|
||||
if( in_array( $post['author_id'], $topicData['ignoredUsers'] ) )
|
||||
{
|
||||
if ( ! strstr( $this->settings['cannot_ignore_groups'], ','.$post['post']['member_group_id'].',' ) )
|
||||
if ( ! strstr( $this->settings['cannot_ignore_groups'], ','.$post['member_group_id'].',' ) )
|
||||
{
|
||||
$post['_ignored'] = 1;
|
||||
}
|
||||
@@ -2081,6 +2195,9 @@ class app_forums_classes_topics
|
||||
/* Memory debug */
|
||||
IPSDebug::setMemoryDebugFlag( "PID: ".$post['pid']. " - Completed", $_NOW );
|
||||
|
||||
/* Excerpt */
|
||||
$post['_excerpt'] = IPSText::truncate( str_replace( array( '<br />', '<br>', "\n", '</p>', '<p>' ), ' ', $post['post'] ), 500 );
|
||||
|
||||
return array( 'post' => $post, 'author' => $poster );
|
||||
}
|
||||
|
||||
@@ -2172,6 +2289,7 @@ class app_forums_classes_topics
|
||||
$this->DB->loadCacheFile( IPSLib::getAppDir('forums') . '/sql/' . ips_DBRegistry::getDriverType() . '_topics_queries.php', 'topics_sql_queries' );
|
||||
|
||||
$this->DB->buildFromCache( 'restoreRecentPost', array( 'query' => $query, 'date' => $date ), 'topics_sql_queries' );
|
||||
$this->DB->allow_sub_select = true;
|
||||
$this->DB->execute();
|
||||
}
|
||||
}
|
||||
@@ -2246,6 +2364,329 @@ class app_forums_classes_topics
|
||||
return $this->fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Coverts a page number to a start value
|
||||
* @param int $page
|
||||
*/
|
||||
public function pageToSt( $page )
|
||||
{
|
||||
$page = intval( $page );
|
||||
|
||||
return ( $page > 1 ) ? ( ( $page - 1 ) * $this->settings['display_max_posts'] ) : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Coverts a st value to a page number
|
||||
* @param int $page
|
||||
*/
|
||||
public function stToPage( $st )
|
||||
{
|
||||
$st = intval( $st );
|
||||
|
||||
return ( $st > 0 ) ? ( ceil( $st / $this->settings['display_max_posts'] ) + 1 ) : 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns page number of post
|
||||
* @param mixed $post
|
||||
* @return int
|
||||
*/
|
||||
public function postToPage( $post )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Get post...
|
||||
//-----------------------------------------
|
||||
|
||||
$post = is_array( $post ) ? $post : $this->getPostById( $post, false, array( 'onlyViewable' => true ) );
|
||||
|
||||
/* Get the correct page number */
|
||||
$_perms = array( 'visible' );
|
||||
|
||||
if ( $this->registry->getClass('class_forums')->canSeeSoftDeletedPosts( $post['forum_id'] ? $post['forum_id'] : false ) )
|
||||
{
|
||||
$_perms[] = 'sdelete';
|
||||
}
|
||||
|
||||
if ( $this->registry->getClass('class_forums')->canQueuePosts( $post['forum_id'] ? $post['forum_id'] : false ) )
|
||||
{
|
||||
$_perms[] = 'hidden';
|
||||
}
|
||||
|
||||
$query = $this->registry->class_forums->fetchPostHiddenQuery( $_perms );
|
||||
|
||||
$sort_value = $post['pid'];
|
||||
$sort_field = ($this->settings['post_order_column'] == 'pid') ? 'pid' : 'post_date';
|
||||
|
||||
if( $sort_field == 'post_date' )
|
||||
{
|
||||
if( $post['post_date'] )
|
||||
{
|
||||
$sort_value = $post['post_date'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$date = $this->DB->buildAndFetch( array( 'select' => 'post_date', 'from' => 'posts', 'where' => 'pid=' . $post['pid'] ) );
|
||||
|
||||
$sort_value = $date['post_date'];
|
||||
}
|
||||
}
|
||||
|
||||
$this->DB->build( array( 'select' => 'COUNT(*) as posts', 'from' => 'posts', 'where' => "topic_id={$post['topic_id']} AND {$sort_field} <=" . intval( $sort_value ) . ' AND ' . $query ) );
|
||||
$this->DB->execute();
|
||||
|
||||
$cposts = $this->DB->fetch();
|
||||
|
||||
if ( (($cposts['posts']) % $this->settings['display_max_posts']) == 0 )
|
||||
{
|
||||
$pages = ($cposts['posts']) / $this->settings['display_max_posts'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$number = ( ($cposts['posts']) / $this->settings['display_max_posts'] );
|
||||
$pages = ceil($number);
|
||||
}
|
||||
|
||||
$st = ($pages - 1) * $this->settings['display_max_posts'];
|
||||
|
||||
if( $this->settings['post_order_sort'] == 'desc' )
|
||||
{
|
||||
$st = (ceil(($cposts['posts']/$this->settings['display_max_posts'])) - $pages) * $this->settings['display_max_posts'];
|
||||
}
|
||||
|
||||
return intval( $this->registry->getClass('topics')->stToPage( $st ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark a topic as 'answered'
|
||||
* @param mixed $topic
|
||||
* @param mixed $post
|
||||
*/
|
||||
public function answerTopicSingle( $post, $topic=null )
|
||||
{
|
||||
if ( is_numeric( $post ) )
|
||||
{
|
||||
$post = $this->getPostById( $post );
|
||||
}
|
||||
|
||||
if ( $topic === null )
|
||||
{
|
||||
$topic = $post['topic_id'];
|
||||
}
|
||||
|
||||
if ( is_numeric( $topic ) )
|
||||
{
|
||||
$topic = $this->getTopicById( $topic );
|
||||
}
|
||||
|
||||
if ( ! $topic['tid'] || ! $post['pid'] )
|
||||
{
|
||||
throw new Exception( 'missing_data' );
|
||||
}
|
||||
|
||||
if ( $this->canAnswerTopic( $topic ) !== true )
|
||||
{
|
||||
throw new Exception( 'no_permission' );
|
||||
}
|
||||
|
||||
/* Remove flag for all other posts in this topic */
|
||||
$sql = IPSBWOptions::sql( 'bw_post_answered', 'post_bwoptions', 'posts', 'forums', 'invert' );
|
||||
$where = IPSBWOptions::sql( 'bw_post_answered', 'post_bwoptions', 'posts', 'forums', 'has' );
|
||||
|
||||
$this->DB->update( 'posts', 'post_bwoptions=' . $sql, 'topic_id=' . $topic['tid'] . ' AND ' . $where, false, true );
|
||||
|
||||
/* Update post */
|
||||
$post['bw_post_answered'] = 1;
|
||||
|
||||
$this->DB->update( 'posts', array( 'post_bwoptions' => IPSBWOptions::freeze( $post, 'posts', 'forums' ) ), 'pid=' . $post['pid'] );
|
||||
|
||||
/* Update topic */
|
||||
$this->DB->update( 'topics', array( 'topic_answered_pid' => $post['pid'] ), 'tid=' . $topic['tid'] );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark a topic as 'unAnswered'
|
||||
* @param mixed $topic
|
||||
* @param mixed $post
|
||||
*/
|
||||
public function unAnswerTopicSingle( $post, $topic=null )
|
||||
{
|
||||
if ( is_numeric( $post ) )
|
||||
{
|
||||
$post = $this->getPostById( $post );
|
||||
}
|
||||
|
||||
if ( $topic === null )
|
||||
{
|
||||
$topic = $post['topic_id'];
|
||||
}
|
||||
|
||||
if ( is_numeric( $topic ) )
|
||||
{
|
||||
$topic = $this->getTopicById( $topic );
|
||||
}
|
||||
|
||||
if ( ! $topic['tid'] || ! $post['pid'] )
|
||||
{
|
||||
throw new Exception( 'missing_data' );
|
||||
}
|
||||
|
||||
if ( $this->canAnswerTopic( $topic ) !== true )
|
||||
{
|
||||
throw new Exception( 'no_permission' );
|
||||
}
|
||||
|
||||
/* Remove flag this post */
|
||||
$sql = IPSBWOptions::sql( 'bw_post_answered', 'post_bwoptions', 'posts', 'forums', 'invert' );
|
||||
$where = IPSBWOptions::sql( 'bw_post_answered', 'post_bwoptions', 'posts', 'forums', 'has' );
|
||||
|
||||
$this->DB->update( 'posts', 'post_bwoptions=' . $sql, 'pid=' . $post['pid'] . ' AND ' . $where, false, true );
|
||||
|
||||
/* Update topic */
|
||||
$this->DB->update( 'topics', array( 'topic_answered_pid' => 0 ), 'tid=' . $topic['tid'] );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the answered PID (or false if nothing)
|
||||
* @param mixed $topic
|
||||
*/
|
||||
public function getTopicAnswerPid( $topic )
|
||||
{
|
||||
if ( is_numeric( $topic ) )
|
||||
{
|
||||
$topic = $this->getTopicById( $topic );
|
||||
}
|
||||
|
||||
if ( $this->registry->class_forums->answerTopicsEnabled( $topic['forum_id'] ) !== true )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return ( ! empty( $topic['topic_answered_pid'] ) ) ? $topic['topic_answered_pid'] : false;
|
||||
}
|
||||
/**
|
||||
* Is this post the answer?
|
||||
* @param mixed $post
|
||||
* @param mixed $topic
|
||||
*/
|
||||
public function postIsAnswer( $post, $topic=null )
|
||||
{
|
||||
if ( is_numeric( $post ) )
|
||||
{
|
||||
$post = $this->getPostById( $post );
|
||||
}
|
||||
|
||||
if ( $topic === null )
|
||||
{
|
||||
$topic = $post['topic_id'];
|
||||
}
|
||||
|
||||
if ( is_numeric( $topic ) )
|
||||
{
|
||||
$topic = $this->getTopicById( $topic );
|
||||
}
|
||||
|
||||
if ( ! $topic['tid'] || ! $post['pid'] )
|
||||
{
|
||||
throw new Exception( 'missing_data' );
|
||||
}
|
||||
|
||||
if ( $this->registry->class_forums->answerTopicsEnabled( $topic['forum_id'] ) !== true )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return ( ! empty( $post['bw_post_answered'] ) ) ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can mark a post as answered
|
||||
* @param mixed Array or int
|
||||
* @return boolean
|
||||
*/
|
||||
public function canAnswerTopic( $topic )
|
||||
{
|
||||
if ( is_numeric( $topic ) )
|
||||
{
|
||||
$topic = $this->getTopicById( $topic );
|
||||
}
|
||||
|
||||
if ( $this->registry->class_forums->answerTopicsEnabled( $topic['forum_id'] ) !== true )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$forumData = $this->registry->class_forums->getForumById( $topic['forum_id'] );
|
||||
|
||||
if ( $this->memberData['g_is_supmod'] || ( $forumData['bw_enable_answers_member'] && $topic['starter_id'] && ( $topic['starter_id'] == $this->memberData['member_id'] ) ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$moderator = $this->getModeratorData();
|
||||
|
||||
return ( $moderator['bw_can_toggle_answered_post'] ) ? true : false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Can mark a post as unanswered
|
||||
* @param mixed Array or int
|
||||
* @return boolean
|
||||
*/
|
||||
public function canUnanswerTopic( $topic )
|
||||
{
|
||||
if ( is_numeric( $topic ) )
|
||||
{
|
||||
$topic = $this->getTopicById( $topic );
|
||||
}
|
||||
|
||||
if ( $this->registry->class_forums->answerTopicsEnabled( $topic['forum_id'] ) !== true )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$forumData = $this->registry->class_forums->getForumById( $topic['forum_id'] );
|
||||
|
||||
if ( $this->memberData['g_is_supmod'] || ( $forumData['bw_enable_answers_member'] && $topic['starter_id'] && ( $topic['starter_id'] == $this->memberData['member_id'] ) ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$moderator = $this->getModeratorData();
|
||||
|
||||
return ( $moderator['bw_can_toggle_answered_post'] ) ? true : false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed Array or int
|
||||
* @return boolean
|
||||
*/
|
||||
public function canRateAnsweredPost( $topic )
|
||||
{
|
||||
if ( is_numeric( $topic ) )
|
||||
{
|
||||
$topic = $this->getTopicById( $topic );
|
||||
}
|
||||
|
||||
if ( $this->registry->class_forums->answerTopicsEnabled( $topic['forum_id'] ) !== true )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( $this->getReplyStatus( $topic ) == 'reply' )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set post filters
|
||||
* Takes user input and cleans it up a bit
|
||||
|
||||
Reference in new issue
Block a user