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
|
||||
* Basic Forum Search
|
||||
* Last Updated: $Date: 2012-07-05 11:04:28 -0400 (Thu, 05 Jul 2012) $
|
||||
* Last Updated: $Date: 2013-05-21 20:51:17 -0400 (Tue, 21 May 2013) $
|
||||
* </pre>
|
||||
*
|
||||
* @author $Author: mmecham $
|
||||
* @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 $Rev: 11035 $
|
||||
* @version $Rev: 12263 $
|
||||
*/
|
||||
|
||||
if ( ! defined( 'IN_IPB' ) )
|
||||
@@ -48,7 +48,7 @@ class search_engine_forums extends search_engine
|
||||
}
|
||||
|
||||
/* Get live or archive */
|
||||
$this->searchArchives = ( ipsRegistry::$request['search_app_filters']['forums']['liveOrArchive'] == 'archive' ) ? true : false;
|
||||
$this->searchArchives = ( isset(ipsRegistry::$request['search_app_filters']['forums']['liveOrArchive']) && ipsRegistry::$request['search_app_filters']['forums']['liveOrArchive'] == 'archive' ) ? true : false;
|
||||
|
||||
if ( $this->searchArchives )
|
||||
{
|
||||
@@ -173,6 +173,7 @@ class search_engine_forums extends search_engine
|
||||
'where' => $this->_buildWhereStatement( $search_term, IPSSearchRegistry::searchTitleOnly(), '', null, ( IPSSearchRegistry::get('opt.searchType') == 'content' || IPSSearchRegistry::get('in.search_author') ) ? false : true ),
|
||||
'limit' => array(0, IPSSearchRegistry::get('set.hardLimit') + 1),
|
||||
'order' => $sortKey . ' ' . $sort_order,
|
||||
'group' => ( $this->settings['forum_search_groupby'] AND IPSSearchRegistry::get('opt.noPostPreview') ) ? "p.topic_id" : '',
|
||||
'add_join' => array( array( 'select' => 't.title, t.posts, t.views',
|
||||
'from' => array( 'topics' => 't' ),
|
||||
'where' => 't.tid=p.'.$this->table['topic_id'],
|
||||
@@ -180,6 +181,8 @@ class search_engine_forums extends search_engine
|
||||
}
|
||||
else
|
||||
{
|
||||
IPSSearchRegistry::set('set.returnType', 'tids' );
|
||||
|
||||
/* Do the search */
|
||||
$this->DB->build( array(
|
||||
'select' => "t.tid as id, t.tid as topic_id, t.title, t.posts, t.views, t.last_post",
|
||||
@@ -228,12 +231,12 @@ class search_engine_forums extends search_engine
|
||||
$_tagIds[] = $data['tag_meta_id'];
|
||||
}
|
||||
|
||||
$this->DB->build( array('select' => "t.tid as id, t.tid as topic_id, t.title, t.posts, t.views, t.last_post",
|
||||
$this->DB->build( array('select' => "t.tid as id, t.tid as topic_id, t.title, t.posts, t.views, t.last_post, t.topic_firstpost",
|
||||
'from' => array( 'topics' => 't' ),
|
||||
'where' => 't.tid IN (' . implode( ",", $_tagIds ) . ')',
|
||||
'where' => 't.tid IN (' . implode( ",", $_tagIds ) . ') AND ' . $this->_buildWhereStatement( $search_term, IPSSearchRegistry::searchTitleOnly() ),
|
||||
'limit' => array(0, IPSSearchRegistry::get('set.hardLimit') + 1),
|
||||
'order' => 't.'.str_replace( 'post_date', 'topic_firstpost', $sortKey ) . ' ' . $sort_order,
|
||||
'add_join' => array( array( 'select' => 'p.'.$this->table['pid'],
|
||||
'order' => 't.'.str_replace( 'post_date', 'last_post', $sortKey ) . ' ' . $sort_order,
|
||||
'add_join' => array( array( 'select' => 'p.' . $this->table['post_date'] . ', p.'.$this->table['pid'],
|
||||
'from' => array( $this->table['_table_'] => 'p' ),
|
||||
'where' => 'p.'.$this->table['pid'].'=t.topic_firstpost',
|
||||
'type' => 'left' ) ) ) );
|
||||
@@ -268,14 +271,14 @@ class search_engine_forums extends search_engine
|
||||
}
|
||||
|
||||
/* Set vars */
|
||||
IPSSearch::$ask = $sortKey;
|
||||
IPSSearch::$ask = ( IPSSearchRegistry::get('set.returnType') == 'tids' ) ? 'last_post' : $this->table['post_date'];
|
||||
IPSSearch::$aso = strtolower( $sort_order );
|
||||
IPSSearch::$ast = $sortType;
|
||||
|
||||
/* Sort */
|
||||
if ( count( $_rows ) )
|
||||
{
|
||||
usort( $_rows, array("IPSSearch", "usort") );
|
||||
//usort( $_rows, array("IPSSearch", "usort") ); See http://community.invisionpower.com/resources/bugs.html/_/ip-board/incorrect-search-order-of-topic-list-r40835
|
||||
|
||||
/* Build result array */
|
||||
foreach( $_rows as $r )
|
||||
@@ -310,9 +313,10 @@ class search_engine_forums extends search_engine
|
||||
* @return nothin'
|
||||
*/
|
||||
public function viewUserContent( $member )
|
||||
{
|
||||
{
|
||||
$sort_by = IPSSearchRegistry::get('in.search_sort_by');
|
||||
$sort_order = IPSSearchRegistry::get('in.search_sort_order');
|
||||
$followedOnly = $this->memberData['member_id'] ? IPSSearchRegistry::get('in.vncFollowFilterOn' ) : false;
|
||||
|
||||
switch( IPSSearchRegistry::get('in.userMode') )
|
||||
{
|
||||
@@ -361,18 +365,60 @@ class search_engine_forums extends search_engine
|
||||
$perPage = IPSSearchRegistry::get('opt.search_per_page');
|
||||
|
||||
/* Get list of good forum IDs */
|
||||
$forumIdsOk = $this->registry->class_forums->fetchSearchableForumIds( $this->memberData['member_id'] );
|
||||
$forumIdsOk = array();
|
||||
|
||||
if( $this->memberData['member_id'] != $member['member_id'] )
|
||||
{
|
||||
$forumIdsOk = $this->registry->class_forums->fetchSearchableForumIds( $this->memberData['member_id'] );
|
||||
}
|
||||
|
||||
/* Only show VNC results from specified forums? */
|
||||
if( is_array(IPSSearchRegistry::get('forums.vncForumFilters')) AND count(IPSSearchRegistry::get('forums.vncForumFilters')) )
|
||||
{
|
||||
$_newIdsOk = array();
|
||||
|
||||
foreach( IPSSearchRegistry::get('forums.vncForumFilters') as $forumId )
|
||||
{
|
||||
if( in_array( $forumId, $forumIdsOk ) )
|
||||
{
|
||||
$_newIdsOk[] = $forumId;
|
||||
}
|
||||
}
|
||||
|
||||
$forumIdsOk = $_newIdsOk;
|
||||
}
|
||||
|
||||
/* Fetch forum rel ids */
|
||||
if ( $followedOnly )
|
||||
{
|
||||
require_once( IPS_ROOT_PATH . 'sources/classes/like/composite.php' );/*noLibHook*/
|
||||
$like = classes_like::bootstrap( 'forums', 'topics' );
|
||||
|
||||
$followedTopics = $like->getDataByMemberIdAndArea( $this->memberData['member_id'] );
|
||||
$followedTopics = ( $followedTopics === null ) ? array() : array_keys( $followedTopics );
|
||||
|
||||
if ( ! count( $followedTopics ) )
|
||||
{
|
||||
/* Return it */
|
||||
return array( 'count' => 0, 'resultSet' => array() );
|
||||
}
|
||||
|
||||
$topic_where[] = ( "t.tid IN (" . implode( ',', $followedTopics ) . ")" );
|
||||
}
|
||||
|
||||
//-----------------------------------------
|
||||
// No forums?
|
||||
//-----------------------------------------
|
||||
|
||||
if( !count( $forumIdsOk ) )
|
||||
{
|
||||
return array( 'count' => 0, 'resultSet' => array() );
|
||||
}
|
||||
|
||||
$topic_where[] = "t.forum_id IN (" . implode( ",", $forumIdsOk ) . ")";
|
||||
if( $this->memberData['member_id'] != $member['member_id'] )
|
||||
{
|
||||
if( !count( $forumIdsOk ) )
|
||||
{
|
||||
return array( 'count' => 0, 'resultSet' => array() );
|
||||
}
|
||||
|
||||
$topic_where[] = "t.forum_id IN (" . implode( ",", $forumIdsOk ) . ")";
|
||||
}
|
||||
|
||||
if ( IPSSearchRegistry::get('in.userMode') != 'title' )
|
||||
{
|
||||
@@ -439,7 +485,13 @@ class search_engine_forums extends search_engine
|
||||
|
||||
/* Not archives */
|
||||
$topic_where[] = $this->registry->class_forums->fetchTopicArchiveQuery( array('not', 'exclude' ), 't.' );
|
||||
|
||||
|
||||
/* Searching by time period */
|
||||
if ( IPSSearchRegistry::get('in.period_in_seconds') )
|
||||
{
|
||||
$topic_where[] = "t.last_post > " . ( IPS_UNIX_TIME_NOW - IPSSearchRegistry::get('in.period_in_seconds') );
|
||||
}
|
||||
|
||||
/* Manual fetch if user content all */
|
||||
if ( IPSSearchRegistry::get('in.userMode') == 'all' )
|
||||
{
|
||||
@@ -457,7 +509,7 @@ class search_engine_forums extends search_engine
|
||||
{
|
||||
$pids[ $t['tid'] ] = $t['last_post'];
|
||||
}
|
||||
|
||||
|
||||
$where = ( array_merge( (array) $where, (array) $topic_where ) );
|
||||
$where = implode( " AND ", $where );
|
||||
|
||||
@@ -465,18 +517,20 @@ class search_engine_forums extends search_engine
|
||||
$this->DB->build( array( 'select' => 'p.pid',
|
||||
'from' => array('posts' => 'p' ),
|
||||
'where' => $where,
|
||||
'add_join' => array( array( 'select' => 't.tid, t.last_post, t.topic_firstpost',
|
||||
'add_join' => array( array( 'select' => 't.tid, t.forum_id, t.last_post, t.topic_firstpost',
|
||||
'from' => array( 'topics' => 't' ),
|
||||
'where' => 'p.topic_id=t.tid',
|
||||
'type' => 'left' ) ),
|
||||
'order' => 'p.pid DESC',
|
||||
'limit' => array( 0, 1000 ) ) );
|
||||
|
||||
'order' => 'p.post_date DESC',
|
||||
'limit' => array( 0, 5000 ) ) );
|
||||
|
||||
|
||||
$this->DB->execute();
|
||||
|
||||
while( $t = $this->DB->fetch() )
|
||||
{
|
||||
$pids[ $t['tid'] ] = $t['last_post'];
|
||||
$pids[ $t['tid'] ] = $t['last_post'];
|
||||
$tidsForFilter[ $t['tid'] ] = array( 'tid' => $t['tid'], 'forum_id' => $t['forum_id'], 'last_post' => $t['last_post'] );
|
||||
}
|
||||
|
||||
$count = array( 'count' => count( $pids ) );
|
||||
@@ -502,7 +556,7 @@ class search_engine_forums extends search_engine
|
||||
/* Fetch the count */
|
||||
if ( $count['count'] )
|
||||
{
|
||||
$this->DB->build( array( 'select' => 'tid',
|
||||
$this->DB->build( array( 'select' => 'tid, forum_id, last_post',
|
||||
'from' => 'topics t',
|
||||
'where' => $where,
|
||||
'order' => $sortKey . ' ' . $sort_order,
|
||||
@@ -513,6 +567,7 @@ class search_engine_forums extends search_engine
|
||||
while( $row = $this->DB->fetch( $inner ) )
|
||||
{
|
||||
$tids[ $row['tid'] ] = $row['tid'];
|
||||
$tidsForFilter[ $row['tid'] ] = array( 'tid' => $row['tid'], 'forum_id' => $row['forum_id'], 'last_post' => $row['last_post'] );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -532,7 +587,7 @@ class search_engine_forums extends search_engine
|
||||
/* Fetch the count */
|
||||
if ( $count['count'] )
|
||||
{
|
||||
$this->DB->build( array( 'select' => 'tid',
|
||||
$this->DB->build( array( 'select' => 'tid, forum_id, last_post',
|
||||
'from' => array('topics' => 't' ),
|
||||
'where' => $where,
|
||||
'add_join' => array( array( 'select' => 'p.pid',
|
||||
@@ -541,15 +596,24 @@ class search_engine_forums extends search_engine
|
||||
'type' => 'left' ) ),
|
||||
'order' => $sortKey . ' ' . $sort_order,
|
||||
'limit' => array( $start, $perPage ) ) );
|
||||
|
||||
|
||||
$inner = $this->DB->execute();
|
||||
|
||||
while( $row = $this->DB->fetch( $inner ) )
|
||||
{
|
||||
$tids[ $row['pid'] ] = $row['pid'];
|
||||
$tidsForFilter[ $row['tid'] ] = array( 'tid' => $row['tid'], 'forum_id' => $row['forum_id'], 'last_post' => $row['last_post'] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Unread only? */
|
||||
if( IPSSearchRegistry::get('in.period') == 'unread' )
|
||||
{
|
||||
$filter = $this->registry->class_forums->postProcessVncTids( $tidsForFilter );
|
||||
$count['count'] = $filter['count'];
|
||||
$tids = $filter['tids'];
|
||||
}
|
||||
|
||||
/* Fix to 1000 results max */
|
||||
$count['count'] = ( $count['count'] > 1000 ) ? 1000 : $count['count'];
|
||||
@@ -573,6 +637,7 @@ class search_engine_forums extends search_engine
|
||||
$forumIdsOk = array();
|
||||
$where = array();
|
||||
$_tidsOnly = array();
|
||||
$noLimit = FALSE;
|
||||
|
||||
/* Loop through the forums and build a list of forums we're allowed access to */
|
||||
$bvnp = explode( ',', $this->settings['vnp_block_forums'] );
|
||||
@@ -588,7 +653,7 @@ class search_engine_forums extends search_engine
|
||||
IPSSearchRegistry::set('in.search_sort_order' , 'desc' );
|
||||
IPSSearchRegistry::set('opt.searchType' , 'titles' );
|
||||
IPSSearchRegistry::set('opt.noPostPreview' , true );
|
||||
|
||||
|
||||
//-----------------------------------------
|
||||
// Only content we have participated in?
|
||||
//-----------------------------------------
|
||||
@@ -596,7 +661,7 @@ class search_engine_forums extends search_engine
|
||||
if( IPSSearchRegistry::get('in.userMode') )
|
||||
{
|
||||
$_tempResults = $this->viewUserContent( $this->memberData );
|
||||
|
||||
|
||||
if( $_tempResults['count'] )
|
||||
{
|
||||
$_tidsOnly = array_merge( $_tidsOnly, $_tempResults['resultSet'] );
|
||||
@@ -640,7 +705,7 @@ class search_engine_forums extends search_engine
|
||||
|
||||
$like = classes_like::bootstrap( 'forums', 'topics' );
|
||||
|
||||
$followedTopics = $like->getDataByMemberIdAndArea( $this->memberData['member_id'] );
|
||||
$followedTopics = $like->getDataByMemberIdAndArea( $this->memberData['member_id'], 5000 );
|
||||
$followedTopics = ( $followedTopics === null ) ? array() : array_keys( $followedTopics );
|
||||
}
|
||||
|
||||
@@ -752,7 +817,7 @@ class search_engine_forums extends search_engine
|
||||
}
|
||||
|
||||
$where[] = $this->registry->class_forums->fetchTopicArchiveQuery( array('not', 'exclude' ) );
|
||||
|
||||
|
||||
/* add perm */
|
||||
$where[] = $permWhere;
|
||||
$_ffWhere = '';
|
||||
@@ -787,30 +852,31 @@ class search_engine_forums extends search_engine
|
||||
else if( count($_tidsOnly) )
|
||||
{
|
||||
$where[] = "( tid IN(" . implode( ',', $_tidsOnly ) . ')' . $_ffWhere . ' )';
|
||||
$noLimit = TRUE; // If we're here, we've already limited in $this->viewUserContent()
|
||||
}
|
||||
else if( count($followedTopics) )
|
||||
{
|
||||
$where[] = "( tid IN(" . implode( ',', $followedTopics ) . ')' . $_ffWhere . ' )';
|
||||
}
|
||||
|
||||
|
||||
$where = implode( " AND ", $where );
|
||||
|
||||
/* Fetch the count */
|
||||
$count = $this->DB->buildAndFetch( array( 'select' => 'count(*) as count',
|
||||
'from' => 'topics',
|
||||
'where' => $where ) );
|
||||
|
||||
|
||||
/* Fetch the count */
|
||||
if ( $count['count'] )
|
||||
{
|
||||
$limit = ( IPSSearchRegistry::get('in.period') != 'unread' ) ? array( $start, $perPage ) : array( 0, 1200 );
|
||||
$limit = $noLimit ? NULL : ( IPSSearchRegistry::get('in.period') != 'unread' ) ? array( $start, $perPage ) : array( 0, 1200 );
|
||||
|
||||
$this->DB->build( array( 'select' => 'tid, forum_id, last_post',
|
||||
'from' => 'topics',
|
||||
'where' => $where,
|
||||
'order' => 'last_post DESC',
|
||||
'limit' => $limit ) );
|
||||
|
||||
|
||||
$inner = $this->DB->execute();
|
||||
|
||||
while( $row = $this->DB->fetch( $inner ) )
|
||||
@@ -830,9 +896,9 @@ class search_engine_forums extends search_engine
|
||||
}
|
||||
else
|
||||
{
|
||||
$data = array( 'count' => $count['count'], 'resultSet' => array_keys( $rtids) );
|
||||
$data = array( 'count' => ( ( isset( $_tempResults['count'] ) and $_tempResults['count'] > $count['count'] ) ? $_tempResults['count'] : $count['count'] ), 'resultSet' => array_keys( $rtids) ); // For explaination of why we check $_tempResults, see bug report 38178
|
||||
}
|
||||
|
||||
|
||||
/* Return it */
|
||||
return $data;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user