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

@@ -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;
@@ -118,6 +118,11 @@ class _Comment extends \IPS\Content\Comment
return $url;
}
/**
* @brief Value to set for the 'tab' parameter when redirecting to the comment (via _find())
*/
public static $tabParameter = array( 'activeTab' => 'comments' );
/**
* Can promote this comment/item?
*
+20 -10
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;
@@ -113,8 +113,10 @@ class _Report extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
/**
* Load by class and content_id
*
* @return \IPS\core\Reports\Report
* @throws OutofRangeException
* @param string $class Class to load
* @param int $id ID to load
* @return static
* @throws \OutofRangeException
*/
public static function loadByClassAndId( $class, $id )
{
@@ -213,7 +215,7 @@ class _Report extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
foreach ( $types as $class => $objects )
{
if ( in_array( 'IPS\Content\Comment', class_parents( $class ) ) )
if ( \in_array( 'IPS\Content\Comment', class_parents( $class ) ) )
{
$itemClass = $class::$itemClass;
$databaseTable = $class::$databaseTable;
@@ -233,7 +235,7 @@ class _Report extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
$objects[ $k ]->_data = array_merge( $objects[ $k ]->_data, $data );
}
}
elseif ( in_array( 'IPS\Content\Item', class_parents( $class ) ) )
elseif ( \in_array( 'IPS\Content\Item', class_parents( $class ) ) )
{
foreach( \IPS\Db::i()->select(
"{$class::$databasePrefix}{$class::$databaseColumnId} as itemId, {$class::$databasePrefix}{$class::$databaseColumnMap['title']} AS title",
@@ -293,6 +295,7 @@ class _Report extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
/**
* Stats for table view
*
* @param bool $includeFirstCommentInCommentCount Whether or not to include the first comment in the comment count
* @return array
*/
public function stats( $includeFirstCommentInCommentCount=TRUE )
@@ -412,6 +415,7 @@ class _Report extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
/**
* Get reports
*
* @param string|NULL $filterByType Report type to filter by, or NULL to not filter by type
* @return array
*/
public function reports( $filterByType=NULL)
@@ -473,7 +477,7 @@ class _Report extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
/**
* Lock auto moderation to prevent auto moderation from changing the status again
*
* @return void
* @return bool
*/
public function isAutoModerationLocked()
{
@@ -483,7 +487,7 @@ class _Report extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
/**
* Run any automatic moderation
*
* @return void
* @return bool|void
*/
public function runAutomaticModeration()
{
@@ -509,6 +513,12 @@ class _Report extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
return FALSE;
}
/* Is automatic moderation supported for this content type? */
if ( !( $reportedContent instanceof \IPS\Content\Hideable ) )
{
return FALSE;
}
/* Fetch a count of report flags so far */
$typeCounts = $this->getReportTypeCounts();
$ruleToUse = NULL;
@@ -552,7 +562,7 @@ class _Report extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
$typeCounts = array();
$total = 0;
$seen = array();
foreach( \IPS\Db::i()->select( '*', 'core_rc_reports', array( 'rid=? and report_type > 0', $this->id ) ) as $row )
foreach( \IPS\Db::i()->select( '*', 'core_rc_reports', array( 'rid=? and report_type > 0', $this->id ), NULL, NULL, NULL, NULL, \IPS\Db::SELECT_FROM_WRITE_SERVER ) as $row )
{
if ( isset( $seen[ $row['report_by'] ] ) )
{
@@ -569,8 +579,8 @@ class _Report extends \IPS\Content\Item implements \IPS\Content\ReadMarkers
{
if ( isset( $typeCounts[ $type ] ) )
{
$return[ $type ] = count( $typeCounts[ $type ] );
$total += count( $typeCounts[ $type ] );
$return[ $type ] = \count( $typeCounts[ $type ] );
$total += \count( $typeCounts[ $type ] );
}
else
{
+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' );
}
}
+16 -56
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;
@@ -70,7 +70,7 @@ class _Types extends \IPS\Node\Model
/**
* Form
*
* @param \IPS\Helpers\Form The form
* @param \IPS\Helpers\Form $form The form
* @return void
*/
public function form( &$form )
@@ -105,11 +105,12 @@ class _Types 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 )
@@ -121,7 +122,7 @@ class _Types extends \IPS\Node\Model
}
else
{
return parent::roots( $permissionCheck, $member, $where );
return parent::roots( $permissionCheck, $member, $where, $limit );
}
}
@@ -129,7 +130,7 @@ class _Types extends \IPS\Node\Model
* 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 type rules. Enable status needs to be checked in userland code when appropriate.
*/
public static function getStore()
{
@@ -142,33 +143,10 @@ class _Types 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 === 'type_id' ) and $extraWhereClause === NULL )
{
$type = static::getStore();
if ( isset( $type[ $id ] ) )
{
return static::constructFromData( $type[ $id ] );
}
else
{
throw new \OutOfRangeException;
}
}
return parent::load( $id, $idField, $extraWhereClause );
}
protected static $loadFromCache = TRUE;
/**
* Get item count
@@ -179,7 +157,7 @@ class _Types extends \IPS\Node\Model
*/
public function getItemCount()
{
return intval( \IPS\Db::i()->select( 'COUNT(*)', 'core_rc_reports', array( 'report_type=?', $this->id ) )->first() );
return \intval( \IPS\Db::i()->select( 'COUNT(*)', 'core_rc_reports', array( 'report_type=?', $this->id ) )->first() );
}
/**
@@ -195,7 +173,7 @@ class _Types extends \IPS\Node\Model
if ( $this->getItemCount() )
{
$form->add( new \IPS\Helpers\Form\Node( 'node_move_content', 0, TRUE, array( 'class' => get_class( $this ), 'disabled' => array( $this->_id ), 'disabledLang' => 'node_move_delete', 'zeroVal' => 'node_delete_content', 'subnodes' => FALSE, 'permissionCheck' => function( $node )
$form->add( new \IPS\Helpers\Form\Node( 'node_move_content', 0, TRUE, array( 'class' => \get_class( $this ), 'disabled' => array( $this->_id ), 'disabledLang' => 'node_move_delete', 'zeroVal' => 'node_delete_content', 'subnodes' => FALSE, 'permissionCheck' => function( $node )
{
return true;
} ) ) );
@@ -220,28 +198,10 @@ class _Types extends \IPS\Node\Model
$this->delete();
}
/**
* [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_types );
}
/**
* [ActiveRecord] Save Changed Columns
*
* @return void
*/
public function save()
{
parent::save();
unset( \IPS\Data\Store::i()->automatic_moderation_types );
}
protected $caches = array( 'automatic_moderation_types' );
}