Version 4.5.0
This commit is contained in:
1 parent
1a0c7fd3c2
commit
f79dcf067a
3791 files changed
+248032
-76372
No files matched your search
@@ -11,7 +11,7 @@
|
||||
namespace IPS\Content\Search;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -109,7 +109,7 @@ class _Results extends \ArrayIterator
|
||||
$membersToLoad[ $result['index_author'] ] = $result['index_author'];
|
||||
}
|
||||
|
||||
if ( in_array( 'IPS\Content\Comment', class_parents( $result['index_class'] ) ) )
|
||||
if ( \in_array( 'IPS\Content\Comment', class_parents( $result['index_class'] ) ) )
|
||||
{
|
||||
$commentClass = $result['index_class'];
|
||||
$itemsToLoad[ $commentClass::$itemClass ][ $result['index_item_id'] ] = $result['index_item_id'];
|
||||
@@ -131,7 +131,7 @@ class _Results extends \ArrayIterator
|
||||
}
|
||||
else
|
||||
{
|
||||
$itemClass = in_array( 'IPS\Content\Comment', class_parents( $class ) ) ? $class::$itemClass : $class;
|
||||
$itemClass = \in_array( 'IPS\Content\Comment', class_parents( $class ) ) ? $class::$itemClass : $class;
|
||||
if ( isset( $itemClass::$containerNodeClass ) )
|
||||
{
|
||||
$containerClass = $itemClass::$containerNodeClass;
|
||||
@@ -148,7 +148,7 @@ class _Results extends \ArrayIterator
|
||||
$reputationIds[ $result['index_class'] ][ $result['index_object_id'] ] = $result['index_object_id'];
|
||||
}
|
||||
|
||||
if ( in_array( 'IPS\Content\Review', class_parents( $result['index_class'] ) ) )
|
||||
if ( \in_array( 'IPS\Content\Review', class_parents( $result['index_class'] ) ) )
|
||||
{
|
||||
$reviewRatings[ $result['index_class'] ][ $result['index_object_id'] ] = $result['index_object_id'];
|
||||
}
|
||||
@@ -188,7 +188,7 @@ class _Results extends \ArrayIterator
|
||||
}
|
||||
|
||||
/* Load author data */
|
||||
if( count( $membersToLoad ) )
|
||||
if( \count( $membersToLoad ) )
|
||||
{
|
||||
$this->authorData = iterator_to_array( \IPS\Db::i()->select( \IPS\Member::columnsForPhoto(), 'core_members', \IPS\Db::i()->in( 'member_id', $membersToLoad ) )->setKeyField( 'member_id' ) );
|
||||
}
|
||||
@@ -201,7 +201,7 @@ class _Results extends \ArrayIterator
|
||||
|
||||
/* Load reputation data */
|
||||
$reputation = array();
|
||||
if ( count( $reputationIds ) )
|
||||
if ( \count( $reputationIds ) )
|
||||
{
|
||||
$clause = array();
|
||||
$binds = array();
|
||||
@@ -234,13 +234,13 @@ class _Results extends \ArrayIterator
|
||||
}
|
||||
|
||||
/* Load data for the "I posted in this" stars */
|
||||
if ( count( $itemIndexIds ) and \IPS\Member::loggedIn()->member_id )
|
||||
if ( \count( $itemIndexIds ) and \IPS\Member::loggedIn()->member_id )
|
||||
{
|
||||
$this->iPostedIn = \IPS\Content\Search\Index::i()->iPostedIn( $itemIndexIds, \IPS\Member::loggedIn() );
|
||||
}
|
||||
|
||||
/* Load tags and prefixes */
|
||||
if ( count( $itemIndexIds ) and \IPS\Settings::i()->search_method == 'mysql' )
|
||||
if ( \count( $itemIndexIds ) and \IPS\Settings::i()->search_method == 'mysql' )
|
||||
{
|
||||
$this->tags = iterator_to_array( \IPS\Db::i()->select( 'index_id, GROUP_CONCAT(index_tag) as index_tags', 'core_search_index_tags', array( array( \IPS\Db::i()->in( 'index_id', $itemIndexIds ) ), array( 'index_is_prefix = 0' ) ), NULL, NULL, 'index_id' )->setKeyField('index_id') );
|
||||
$this->prefixes = iterator_to_array( \IPS\Db::i()->select( 'index_id, index_tag as index_prefix', 'core_search_index_tags', array( array( \IPS\Db::i()->in( 'index_id', $itemIndexIds ) ), array( 'index_is_prefix = 1' ) ) )->setKeyField('index_id') );
|
||||
@@ -260,7 +260,7 @@ class _Results extends \ArrayIterator
|
||||
$data = parent::current();
|
||||
|
||||
$class = $data['index_class'];
|
||||
$itemClass = in_array( 'IPS\Content\Comment', class_parents( $class ) ) ? $class::$itemClass : $class;
|
||||
$itemClass = \in_array( 'IPS\Content\Comment', class_parents( $class ) ) ? $class::$itemClass : $class;
|
||||
$containerClass = isset( $itemClass::$containerNodeClass ) ? $itemClass::$containerNodeClass : NULL;
|
||||
|
||||
$reputationData = array();
|
||||
@@ -278,8 +278,13 @@ class _Results extends \ArrayIterator
|
||||
/* Ensure we have an item if results are gathered from the map table */
|
||||
if ( ! isset( $this->itemData[ $itemClass ][ $data['index_item_id'] ] ) )
|
||||
{
|
||||
/* This should not happen in production, so debug log and move on to the next item */
|
||||
/* This should not happen in production, so debug log */
|
||||
\IPS\Log::debug( "index_item_id ID " . $data['index_item_id'] . " for " . $itemClass . " has no itemData" , 'searchResults' );
|
||||
|
||||
/* Then cleanup/remove the item now */
|
||||
\IPS\Content\Search\Index::i()->directIndexRemoval( $data['index_class'], $data['index_object_id'] );
|
||||
|
||||
/* And continue, moving on to the next item */
|
||||
static::next();
|
||||
return static::current();
|
||||
}
|
||||
@@ -325,7 +330,7 @@ class _Results extends \ArrayIterator
|
||||
$containerData,
|
||||
$reputationData,
|
||||
isset( $this->reviewRatings[ $data['index_class'] ][ $data['index_object_id'] ] ) ? $this->reviewRatings[ $data['index_class'] ][ $data['index_object_id'] ] : NULL,
|
||||
in_array( $data['index_item_index_id'], $this->iPostedIn ),
|
||||
\in_array( $data['index_item_index_id'], $this->iPostedIn ),
|
||||
$reactions
|
||||
);
|
||||
}
|
||||
@@ -354,11 +359,11 @@ class _Results extends \ArrayIterator
|
||||
{
|
||||
if ( $allRows )
|
||||
{
|
||||
if ( is_integer( $this->countAllRows ) )
|
||||
if ( \is_integer( $this->countAllRows ) )
|
||||
{
|
||||
return $this->countAllRows;
|
||||
}
|
||||
else if ( gettype( $this->countAllRows ) === 'object' and get_class( $this->countAllRows ) === 'IPS\Db\Select' )
|
||||
else if ( \gettype( $this->countAllRows ) === 'object' and \get_class( $this->countAllRows ) === 'IPS\Db\Select' )
|
||||
{
|
||||
$this->countAllRows = $this->countAllRows->first();
|
||||
|
||||
@@ -378,7 +383,7 @@ class _Results extends \ArrayIterator
|
||||
/**
|
||||
* Add in "extra" items
|
||||
*
|
||||
* @param array $extra Types ('register', 'follow_member', 'follow_content', 'photo', 'like', 'rep_neg')
|
||||
* @param array $extra Types ('register', 'follow_member', 'follow_content', 'photo', 'votes', 'like', 'rep_neg')
|
||||
* @param \IPS\Member|NULL $author The author to limit extra items to
|
||||
* @param \IPS\DateTime|NULL $lastTime If provided, only items since this date is included. If NULL, it works out which to include based on what results are being shown
|
||||
* @param \IPS\DateTime|NULL $firstTime If provided, only items before this date is included. If NULL, it works out which to include based on what results are being shown
|
||||
@@ -431,9 +436,9 @@ class _Results extends \ArrayIterator
|
||||
if ( $lastTime )
|
||||
{
|
||||
/* Users registered */
|
||||
if ( in_array( 'register', $extra ) )
|
||||
if ( \in_array( 'register', $extra ) )
|
||||
{
|
||||
$where = array( array( 'joined>?', $lastTime ), array( '( name<>? and email<>? )', '', '' ), array( 'temp_ban!=?', '-1' ) );
|
||||
$where = array( array( 'joined>?', $lastTime ), array( 'completed=?', true ), array( 'temp_ban!=?', '-1' ) );
|
||||
if ( $firstTime )
|
||||
{
|
||||
$where[] = array( 'joined<?', $firstTime );
|
||||
@@ -451,7 +456,7 @@ class _Results extends \ArrayIterator
|
||||
{
|
||||
$extraItems[] = new Result\Custom(
|
||||
\IPS\DateTime::ts( $member['joined'] ),
|
||||
\IPS\Member::loggedIn()->language()->addToStack( 'activity_member_joined', FALSE, array( 'htmlsprintf' => \IPS\Theme::i()->getTemplate( 'global', 'core', 'front' )->userLinkFromData( $member['member_id'], $member['name'], $member['members_seo_name'] ) ) ),
|
||||
\IPS\Member::loggedIn()->language()->addToStack( 'activity_member_joined', FALSE, array( 'htmlsprintf' => \IPS\Theme::i()->getTemplate( 'global', 'core', 'front' )->userLinkFromData( $member['member_id'], $member['name'], $member['members_seo_name'], $member['member_group_id'] ) ) ),
|
||||
\IPS\Theme::i()->getTemplate( 'global', 'core', 'front' )->userPhotoFromData( $member['member_id'], $member['name'], $member['members_seo_name'], \IPS\Member::photoUrl( $member ), 'tiny' )
|
||||
);
|
||||
}
|
||||
@@ -459,9 +464,9 @@ class _Results extends \ArrayIterator
|
||||
}
|
||||
|
||||
/* Users changed photo */
|
||||
if ( in_array( 'photo', $extra ) )
|
||||
if ( \in_array( 'photo', $extra ) )
|
||||
{
|
||||
$where = array( array( 'photo_last_update>? AND photo_last_update>(joined+300)', $lastTime ), array( '( name<>? and email<>? )', '', '' ) );
|
||||
$where = array( array( 'photo_last_update>? AND photo_last_update>(joined+300)', $lastTime ), array( 'completed=?', true ) );
|
||||
if ( $firstTime )
|
||||
{
|
||||
$where[] = array( 'photo_last_update<?', $firstTime );
|
||||
@@ -474,23 +479,23 @@ class _Results extends \ArrayIterator
|
||||
{
|
||||
$extraItems[] = new Result\Custom(
|
||||
\IPS\DateTime::ts( $member['photo_last_update'] ),
|
||||
\IPS\Member::loggedIn()->language()->addToStack( 'activity_member_updated_photo', FALSE, array( 'htmlsprintf' => \IPS\Theme::i()->getTemplate( 'global', 'core', 'front' )->userLinkFromData( $member['member_id'], $member['name'], $member['members_seo_name'] ) ) ),
|
||||
\IPS\Member::loggedIn()->language()->addToStack( 'activity_member_updated_photo', FALSE, array( 'htmlsprintf' => \IPS\Theme::i()->getTemplate( 'global', 'core', 'front' )->userLinkFromData( $member['member_id'], $member['name'], $member['members_seo_name'], $member['member_group_id'] ) ) ),
|
||||
\IPS\Theme::i()->getTemplate( 'global', 'core', 'front' )->userPhotoFromData( $member['member_id'], $member['name'], $member['members_seo_name'], \IPS\Member::photoUrl( $member ), 'tiny' )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/* Follow */
|
||||
if ( in_array( 'follow_member', $extra ) or in_array( 'follow_content', $extra ) )
|
||||
if ( \in_array( 'follow_member', $extra ) or \in_array( 'follow_content', $extra ) )
|
||||
{
|
||||
$where = array( array( 'follow_is_anon=0' ), array( 'follow_added>?', $lastTime ) );
|
||||
if ( $firstTime )
|
||||
{
|
||||
$where[] = array( 'follow_added<?', $firstTime );
|
||||
}
|
||||
if ( in_array( 'follow_member', $extra ) xor in_array( 'follow_content', $extra ) )
|
||||
if ( \in_array( 'follow_member', $extra ) xor \in_array( 'follow_content', $extra ) )
|
||||
{
|
||||
if ( in_array( 'follow_member', $extra ) )
|
||||
if ( \in_array( 'follow_member', $extra ) )
|
||||
{
|
||||
$where[] = array( 'follow_app=? AND follow_area=?', 'core', 'member' );
|
||||
}
|
||||
@@ -501,11 +506,11 @@ class _Results extends \ArrayIterator
|
||||
}
|
||||
if ( $author )
|
||||
{
|
||||
if ( in_array( 'follow_member', $extra ) and in_array( 'follow_content', $extra ) )
|
||||
if ( \in_array( 'follow_member', $extra ) and \in_array( 'follow_content', $extra ) )
|
||||
{
|
||||
$where[] = array( '( follow_member_id=? OR ( follow_app=? AND follow_area=? AND follow_rel_id=? ) )', $author->member_id, 'core', 'member', $author->member_id );
|
||||
$where[] = array( '( follow_id IN (?) )', \IPS\Db::i()->select( 'follow_id', 'core_follow', array( '( follow_member_id=? OR ( follow_app=? AND follow_area=? AND follow_rel_id=? ) )', $author->member_id, 'core', 'member', $author->member_id ) ) );
|
||||
}
|
||||
elseif ( in_array( 'follow_member', $extra ) )
|
||||
elseif ( \in_array( 'follow_member', $extra ) )
|
||||
{
|
||||
$where[] = array( 'follow_rel_id=?', $author->member_id );
|
||||
}
|
||||
@@ -538,22 +543,40 @@ class _Results extends \ArrayIterator
|
||||
{
|
||||
if ( class_exists( $class ) )
|
||||
{
|
||||
$thingBeingFollowed = $class::loadAndCheckPerms( $follow['follow_rel_id'] );
|
||||
$urlToThing = \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->basicUrl( $thingBeingFollowed->url(), FALSE, $thingBeingFollowed instanceof \IPS\Node\Model ? $thingBeingFollowed->_title : $thingBeingFollowed->mapped('title'), FALSE );
|
||||
/* It is possible we've already queried and fetched this item, so attempt to pull from our search results first */
|
||||
$urlToThing = NULL;
|
||||
|
||||
foreach( $results as $result )
|
||||
{
|
||||
$result = $result->asArray();
|
||||
|
||||
if( $result['indexData']['index_class'] == $class AND $result['indexData']['index_object_id'] == $follow['follow_rel_id'] )
|
||||
{
|
||||
$urlToThing = \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->basicUrl( $class::urlFromIndexData( $result['indexData'], $result['itemData'] ), FALSE, $result['indexData']['index_title'], FALSE );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( $urlToThing === NULL )
|
||||
{
|
||||
$thingBeingFollowed = $class::loadAndCheckPerms( $follow['follow_rel_id'] );
|
||||
$urlToThing = \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->basicUrl( $thingBeingFollowed->url(), FALSE, $thingBeingFollowed instanceof \IPS\Node\Model ? $thingBeingFollowed->_title : $thingBeingFollowed->mapped('title'), FALSE );
|
||||
}
|
||||
|
||||
/* Do we need to merge with the last result? */
|
||||
if( $lastClass !== NULL AND $lastClass === $class AND $lastMember === $follow['follow_member_id'] AND count( $extraItems ) )
|
||||
if( $lastClass !== NULL AND $lastClass === $class AND $lastMember === $follow['follow_member_id'] AND \count( $extraItems ) )
|
||||
{
|
||||
$extraItem = array_pop( $extraItems );
|
||||
|
||||
$mergeList = array_filter( array_merge( array( $urlToThing ), $extraItem->getMergeData() ) );
|
||||
$listToDisplay = $mergeList;
|
||||
|
||||
if( count( $mergeList ) > 3 )
|
||||
if( \count( $mergeList ) > 3 )
|
||||
{
|
||||
$listToDisplay = array_slice( $mergeList, 0, 3 );
|
||||
$listToDisplay[] = \IPS\Member::loggedIn()->language()->addToStack( 'and_x_others', FALSE, array( 'pluralize' => array( count( $mergeList ) - 3 ) ) );
|
||||
$listToDisplay = \array_slice( $mergeList, 0, 3 );
|
||||
$listToDisplay[] = \IPS\Member::loggedIn()->language()->addToStack( 'x_others', FALSE, array( 'pluralize' => array( \count( $mergeList ) - 3 ) ) );
|
||||
}
|
||||
|
||||
$extraItem->mergeInData( \IPS\Member::loggedIn()->language()->addToStack( 'activity_member_followed', FALSE, array( 'htmlsprintf' => array( \IPS\Theme::i()->getTemplate( 'global', 'core', 'front' )->userLink( \IPS\Member::load( $follow['follow_member_id'] ) ), \IPS\Member::loggedIn()->language()->formatList( $listToDisplay ) ) ) ), $urlToThing );
|
||||
$extraItems[] = $extraItem;
|
||||
}
|
||||
@@ -578,7 +601,7 @@ class _Results extends \ArrayIterator
|
||||
}
|
||||
|
||||
/* Likes */
|
||||
if ( \IPS\Settings::i()->reputation_enabled and \IPS\Member::loggedIn()->group['gbw_view_reps'] and ( in_array( 'like', $extra ) or in_array( 'react', $extra ) ) )
|
||||
if ( \IPS\Settings::i()->reputation_enabled and \IPS\Member::loggedIn()->group['gbw_view_reps'] and ( \in_array( 'like', $extra ) or \in_array( 'react', $extra ) ) )
|
||||
{
|
||||
$where = array( array( 'rep_date>?', $lastTime ) );
|
||||
$where[] = array( 'reaction_enabled=?', 1 );
|
||||
@@ -612,7 +635,7 @@ class _Results extends \ArrayIterator
|
||||
}
|
||||
|
||||
/* Clubs */
|
||||
if ( \IPS\Settings::i()->clubs and in_array( 'clubs', $extra ) )
|
||||
if ( \IPS\Settings::i()->clubs and \in_array( 'clubs', $extra ) )
|
||||
{
|
||||
$where = array( array( 'created>?', $lastTime ) );
|
||||
if ( $firstTime )
|
||||
|
||||
Reference in new issue
Block a user