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

+31 -69
View File
@@ -11,7 +11,7 @@
namespace IPS\core\Reports;
/* 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;
@@ -75,7 +75,7 @@ class _Rules extends \IPS\Node\Model
/**
* Form
*
* @param \IPS\Helpers\Form The form
* @param \IPS\Helpers\Form $form The form
* @return void
*/
public function form( &$form )
@@ -188,7 +188,7 @@ class _Rules extends \IPS\Node\Model
/* Now we have to remove any fields that aren't valid... */
foreach( $values as $k => $v )
{
if( !in_array( $k, array( 'rule_filters', 'rule_points_needed', 'rule_enabled', 'rule_types', 'rule_position' ) ) )
if( !\in_array( $k, array( 'rule_filters', 'rule_points_needed', 'rule_enabled', 'rule_types', 'rule_position' ) ) )
{
unset( $values[ $k ] );
}
@@ -213,11 +213,12 @@ class _Rules 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 ) )
{
$return = array();
foreach( static::getStore() AS $node )
@@ -229,27 +230,15 @@ class _Rules extends \IPS\Node\Model
}
else
{
return parent::roots( $permissionCheck, $member, $where );
return parent::roots( $permissionCheck, $member, $where, $limit );
}
}
/**
* Set Enabled
*
* @return void
*/
public function set__enabled( $enabled )
{
parent::set__enabled( $enabled );
unset( \IPS\Data\Store::i()->automatic_moderation_rules );
}
/**
* Get data store
*
* @return array
* @note Note that all records are returned, even disabled promotion rules. Enable status needs to be checked in userland code when appropriate.
* @note Note that all records are returned, even disabled report rules. Enable status needs to be checked in userland code when appropriate.
*/
public static function getStore()
{
@@ -262,57 +251,16 @@ class _Rules 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 === 'rule_id' ) and $extraWhereClause === NULL )
{
$rule = static::getStore();
if ( isset( $rule[ $id ] ) )
{
return static::constructFromData( $rule[ $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()->automatic_moderation_rules );
}
/**
* [ActiveRecord] Save Changed Columns
*
* @return void
*/
public function save()
{
parent::save();
unset( \IPS\Data\Store::i()->automatic_moderation_rules );
}
protected $caches = array( 'automatic_moderation_rules' );
/**
* @brief Cache extensions so we only need to load them once
@@ -339,7 +287,7 @@ class _Rules extends \IPS\Node\Model
}
/* Nothing flagged as bad? Back you go */
if ( ! count( $typeCounts ) )
if ( ! \count( $typeCounts ) )
{
return FALSE;
}
@@ -398,8 +346,10 @@ class _Rules extends \IPS\Node\Model
);
}
/*
/**
* Return a warning if this promotion uses not existing groups
*
* @return string
*/
public function get__description()
{
@@ -424,4 +374,16 @@ class _Rules extends \IPS\Node\Model
return \IPS\Member::loggedIn()->language()->addToStack( 'automaticmoderation_row_desc', TRUE, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->formatList( $descriptions ) ) ) );
}
/**
* Returns the hide reason language string
*
* @param null|int $languageId Language ID (or NULL to use default language)
* @return string
*/
public static function getDefaultHideReason( $languageId = NULL )
{
$languageId = $languageId ? : \IPS\Lang::defaultLanguage() ;
return \IPS\Lang::load( $languageId )->get( 'automaticmoderation_hide_reason' );
}
}