Version 4.3.0

This commit is contained in:
Neo committed 2025-12-19 05:47:12 -08:00
1 parent 96997ddd8e
commit fe1acf984a
1349 files changed
+116159 -67711

No files matched your search

+70 -14
View File
@@ -22,6 +22,30 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
*/
class _Index extends \IPS\Content\Search\Index
{
/**
* Get index data
*
* @param \IPS\Content\Searchable $object Item to add
* @return array|NULL
*/
public function indexData( \IPS\Content\Searchable $object )
{
$indexData = parent::indexData( $object );
if( $indexData === NULL )
{
return $indexData;
}
/* The index_title in core_search_index is varchar(255) so we have to limit to this length */
if( $indexData['index_title'] !== NULL )
{
$indexData['index_title'] = mb_substr( $indexData['index_title'], 0, 255 );
}
return $indexData;
}
/**
* Index an item
*
@@ -37,9 +61,6 @@ class _Index extends \IPS\Content\Search\Index
/* If we got the data... */
if( $indexData )
{
/* MySQL specific look up hash for easy referencing across tables */
$indexData['index_class_type_id_hash'] = md5( $indexData['index_class'] . ':' . $indexData['index_object_id'] );
/* If nobody has permission to access it, just remove it */
if ( !$indexData['index_permissions'] )
{
@@ -188,13 +209,6 @@ class _Index extends \IPS\Content\Search\Index
\IPS\Db::i()->update( 'core_search_index', array( 'index_item_index_id' => $newIndexId ), array( \IPS\Db::i()->in( 'index_class', array( $class, $class::$itemClass ) ) . ' AND index_item_id=?', $object->$itemColumnId ) );
}
}
/* And also set core_follow.follow_index_id */
if ( $object instanceof \IPS\Content\Comment )
{
$class = $class::$itemClass;
}
\IPS\Db::i()->update( 'core_follow', array( 'follow_index_id' => $newIndexId ), array( 'follow_app=? AND follow_area=? AND follow_rel_id=?', $object::$application, mb_strtolower( mb_substr( $class, mb_strrpos( $class, '\\' ) + 1 ) ), $object->$databaseColumnId ) );
}
}
@@ -318,17 +332,22 @@ class _Index extends \IPS\Content\Search\Index
/**
* Removes all content for a classs
*
* @param string $class The class
* @param int|NULL $containerId The container ID to update, or NULL
* @param string $class The class
* @param int|NULL $containerId The container ID to delete, or NULL
* @param int|NULL $authorId The author ID to delete, or NULL
* @return void
*/
public function removeClassFromSearchIndex( $class, $containerId=NULL )
public function removeClassFromSearchIndex( $class, $containerId=NULL, $authorId=NULL )
{
$where = array( array( 'index_class=?', $class ) );
if ( $containerId !== NULL )
{
$where[] = array( 'index_container_id=?', $containerId );
}
if ( $authorId !== NULL )
{
$where[] = array( 'index_author=?', $authorId );
}
\IPS\Db::i()->delete( 'core_search_index_item_map', array( 'index_class=? and index_item_id IN( ? )', $class, \IPS\Db::i()->select( 'index_item_id', 'core_search_index', $where ) ) );
\IPS\Db::i()->delete( 'core_search_index_tags', array( 'index_id IN( ? )', \IPS\Db::i()->select( 'index_id', 'core_search_index', $where ) ) );
@@ -494,8 +513,45 @@ class _Index extends \IPS\Content\Search\Index
\IPS\Db::i()->update( 'core_search_index', array( 'index_is_last_comment' => 1 ), array( 'index_class=? AND index_object_id=?', $latest['index_class'], $latest['index_object_id'] ) );
/* Now reset the item index with the latest comment time */
\IPS\Db::i()->update( 'core_search_index', array( 'index_date_updated' => $latest['index_date_updated'] ), array( \IPS\Db::i()->in( 'index_class', $classes ) . ' AND index_item_id=? AND index_object_id=?', $indexItemId, $indexItemId ) );
\IPS\Db::i()->update( 'core_search_index', array( 'index_date_updated' => $latest['index_date_updated'], 'index_date_commented' => $latest['index_date_commented'] ), array( \IPS\Db::i()->in( 'index_class', $classes ) . ' AND index_item_id=? AND index_object_id=?', $indexItemId, $indexItemId ) );
}
catch( \Exception $ex ) { }
}
/**
* Given a list of item index IDs, return the ones that a given member has participated in
*
* @param array $itemIndexIds Item index IDs
* @param \IPS\Member $member The member
* @return array
*/
public function iPostedIn( array $itemIndexIds, \IPS\Member $member )
{
return iterator_to_array( \IPS\Db::i()->select( 'index_item_index_id', 'core_search_index', array( array( \IPS\Db::i()->in( 'index_item_index_id', $itemIndexIds ) ), array( 'index_author=?', $member->member_id ) ) )->setKeyField('index_item_index_id') );
}
/**
* Given a list of "index_class_type_id_hash"s, return the ones that a given member has permission to view
*
* @param array $itemIndexIds Item index IDs
* @param \IPS\Member $member The member
* @return array
*/
public function hashesWithPermission( array $hashes, \IPS\Member $member )
{
return iterator_to_array( \IPS\Db::i()->select( 'index_class_type_id_hash', array( 'core_search_index', 'si' ), array(
array( "( si.index_permissions = '*' OR " . \IPS\Db::i()->findInSet( 'si.index_permissions', \IPS\Member::loggedIn()->permissionArray() ) . ' AND si.index_hidden=0 )' ),
array( \IPS\Db::i()->in( 'si.index_class_type_id_hash', $hashes ) )
) )->setKeyField('index_class_type_id_hash') );
}
/**
* Get timestamp of oldest thing in index
*
* @return int|null
*/
public function firstIndexDate()
{
return \IPS\Db::i()->select( 'MIN(index_date_updated)', 'core_search_index' )->first();
}
}