Version 4.5.0

This commit is contained in:
Neo committed 2025-12-19 05:51:58 -08:00
1 parent 1a0c7fd3c2
commit f79dcf067a
3791 files changed
+248032 -76372

No files matched your search

+82 -53
View File
@@ -11,7 +11,7 @@
namespace IPS\Content;
/* 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;
@@ -85,7 +85,7 @@ class _Reaction extends \IPS\Node\Model
/**
* Form
*
* @param \IPS\Helpers\Form The form
* @param \IPS\Helpers\Form $form The form
* @return void
*/
public function form( &$form )
@@ -147,7 +147,7 @@ class _Reaction extends \IPS\Node\Model
/**
* Get Description
*
* @return strong
* @return string
*/
public function get__description()
{
@@ -171,13 +171,14 @@ class _Reaction extends \IPS\Node\Model
* @param string|NULL $permissionCheck The permission key to check for or NULl to not check permissions
* @param \IPS\Member|NULL $member The member to check permissions for or NULL for the currently logged in member
* @param mixed $where Additional WHERE clause
* @param array|NULL $limit Limit/offset to use, or NULL for no limit (default)
* @return array
*/
public static function roots( $permissionCheck='view', $member=NULL, $where=array() )
public static function roots( $permissionCheck='view', $member=NULL, $where=array(), $limit=NULL )
{
if ( !count( $where ) )
if ( !\count( $where ) )
{
$cacheKey = md5( get_called_class() . $permissionCheck );
$cacheKey = md5( \get_called_class() . $permissionCheck );
if( isset( static::$rootsResult[ $cacheKey ] ) )
{
@@ -185,7 +186,7 @@ class _Reaction extends \IPS\Node\Model
}
static::$rootsResult[ $cacheKey ] = array();
foreach( static::reactionStore() AS $reaction )
foreach( static::getStore() AS $reaction )
{
static::$rootsResult[ $cacheKey ][ $reaction['reaction_id'] ] = static::constructFromData( $reaction );
}
@@ -194,7 +195,7 @@ class _Reaction extends \IPS\Node\Model
}
else
{
return parent::roots( $permissionCheck, $member, $where );
return parent::roots( $permissionCheck, $member, $where, $limit );
}
}
@@ -218,8 +219,19 @@ class _Reaction extends \IPS\Node\Model
* Reaction Store
*
* @return array
* @deprecated
*/
public static function reactionStore()
{
return static::getStore();
}
/**
* Reaction Store
*
* @return array
*/
public static function getStore()
{
if ( !isset( \IPS\Data\Store::i()->reactions ) )
{
@@ -240,57 +252,27 @@ class _Reaction extends \IPS\Node\Model
}
/**
* Load Record
*
* @see \IPS\Db::build
* @param int|string $id ID
* @param string $idField The database column that the $id parameter pertains to (NULL will use static::$databaseColumnId)
* @param mixed $extraWhereClause Additional where clause(s) (see \IPS\Db::build for details)
* @return static
* @throws \InvalidArgumentException
* @throws \OutOfRangeException
* @brief [ActiveRecord] Attempt to load from cache
* @note If this is set to TRUE you MUST define a getStore() method to return the objects from cache
*/
public static function load( $id, $idField=NULL, $extraWhereClause=NULL )
{
if ( ( $idField === NULL or $idField === 'reaction_id' ) and $extraWhereClause === NULL )
{
$reactions = static::reactionStore();
if ( isset( $reactions[ $id ] ) )
{
return static::constructFromData( $reactions[ $id ] );
}
else
{
throw new \OutOfRangeException;
}
}
return parent::load( $id, $idField, $extraWhereClause );
}
protected static $loadFromCache = TRUE;
/**
* [ActiveRecord] Delete
*
* @return void
* @brief [ActiveRecord] Caches
* @note Defined cache keys will be cleared automatically as needed
*/
public function delete()
{
parent::delete();
unset( \IPS\Data\Store::i()->reactions );
static::updateLikeModeSetting();
}
protected $caches = array( 'reactions' );
/**
* [ActiveRecord] Save Changed Columns
* Clear any defined caches
*
* @return void
* @param bool $removeMultiton Should the multiton record also be removed?
* @return void
*/
public function save()
public function clearCaches( $removeMultiton=FALSE )
{
parent::save();
unset( \IPS\Data\Store::i()->reactions );
parent::clearCaches( $removeMultiton );
static::updateLikeModeSetting();
}
@@ -337,7 +319,7 @@ class _Reaction extends \IPS\Node\Model
*/
public static function updateLikeModeSetting()
{
\IPS\Settings::i()->changeValues( array( 'reaction_is_likemode' => intval( count( static::enabledReactions() ) == 1 ) ) );
\IPS\Settings::i()->changeValues( array( 'reaction_is_likemode' => \intval( \count( static::enabledReactions() ) == 1 ) ) );
}
/**
@@ -354,4 +336,51 @@ class _Reaction extends \IPS\Node\Model
}
);
}
/**
* [ActiveRecord] Duplicate
*
* @return void
*/
public function __clone()
{
if ( $this->skipCloneDuplication === TRUE )
{
return;
}
$oldIcon = $this->icon;
parent::__clone();
try
{
$icon = \IPS\File::get( 'core_Reaction', $oldIcon );
$newIcon = \IPS\File::create( 'core_Reaction', $icon->originalFilename, $icon->contents() );
$this->icon = (string) $newIcon;
}
catch ( \Exception $e )
{
$this->icon = NULL;
}
$this->save();
}
/**
* Delete Record
*
* @return void
*/
public function delete()
{
try
{
\IPS\File::get( 'core_Reaction', $this->icon )->delete();
}
catch( \Exception $ex ) { }
parent::delete();
}
}