Version 5.0.0 beta 1
This commit is contained in:
1 parent
25ddeb65d6
commit
15c7beabc5
6736 files changed
+627902
-497943
No files matched your search
@@ -11,85 +11,127 @@
|
||||
namespace IPS\core\Warnings;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use DateInterval;
|
||||
use DomainException;
|
||||
use Exception;
|
||||
use InvalidArgumentException;
|
||||
use IPS\Api\Webhook;
|
||||
use IPS\Application;
|
||||
use IPS\Content;
|
||||
use IPS\Content\Comment;
|
||||
use IPS\Content\Item;
|
||||
use IPS\core\Messenger\Conversation;
|
||||
use IPS\core\Messenger\Message;
|
||||
use IPS\DateTime;
|
||||
use IPS\Db;
|
||||
use IPS\Email;
|
||||
use IPS\File;
|
||||
use IPS\Helpers\Form\CheckboxSet;
|
||||
use IPS\Helpers\Form\Date;
|
||||
use IPS\Helpers\Form\Editor;
|
||||
use IPS\Helpers\Form\Number;
|
||||
use IPS\Helpers\Form\Select;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Log;
|
||||
use IPS\Member;
|
||||
use IPS\Node\Model;
|
||||
use IPS\Notification;
|
||||
use IPS\Output;
|
||||
use IPS\Request;
|
||||
use IPS\Session;
|
||||
use IPS\Settings;
|
||||
use IPS\Task;
|
||||
use IPS\Theme;
|
||||
use OutOfRangeException;
|
||||
use UnderflowException;
|
||||
use function count;
|
||||
use function defined;
|
||||
use function get_class;
|
||||
use function in_array;
|
||||
use function intval;
|
||||
use function is_numeric;
|
||||
use const IPS\NOTIFICATION_BACKGROUND_THRESHOLD;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Warning Model
|
||||
*/
|
||||
class _Warning extends \IPS\Content\Item
|
||||
class Warning extends Item
|
||||
{
|
||||
/* !\IPS\Patterns\ActiveRecord */
|
||||
|
||||
/**
|
||||
* @brief Database Table
|
||||
*/
|
||||
public static $databaseTable = 'core_members_warn_logs';
|
||||
public static ?string $databaseTable = 'core_members_warn_logs';
|
||||
|
||||
/**
|
||||
* @brief Database Prefix
|
||||
*/
|
||||
public static $databasePrefix = 'wl_';
|
||||
public static string $databasePrefix = 'wl_';
|
||||
|
||||
/**
|
||||
* @brief Multiton Store
|
||||
*/
|
||||
protected static $multitons;
|
||||
protected static array $multitons;
|
||||
|
||||
/**
|
||||
* @brief Title
|
||||
*/
|
||||
public static $title = 'warning';
|
||||
public static string $title = 'warning';
|
||||
|
||||
/**
|
||||
* @return \DateInterval|null
|
||||
* @return DateInterval|null
|
||||
*/
|
||||
public function get_mq_interval()
|
||||
public function get_mq_interval() : ?DateInterval
|
||||
{
|
||||
if( $this->mq != -1 )
|
||||
{
|
||||
try
|
||||
{
|
||||
return new \DateInterval( $this->mq );
|
||||
return new DateInterval( $this->mq );
|
||||
}
|
||||
catch( \Exception $e ){}
|
||||
catch( Exception $e ){}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateInterval|null
|
||||
* @return DateInterval|null
|
||||
*/
|
||||
public function get_rpa_interval()
|
||||
public function get_rpa_interval() : ?DateInterval
|
||||
{
|
||||
if( $this->rpa != -1 )
|
||||
{
|
||||
try
|
||||
{
|
||||
return new \DateInterval( $this->rpa );
|
||||
return new DateInterval( $this->rpa );
|
||||
}
|
||||
catch( \Exception $e ){}
|
||||
catch( Exception $e ){}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateInterval|null
|
||||
* @return DateInterval|null
|
||||
*/
|
||||
public function get_suspend_interval()
|
||||
public function get_suspend_interval() : ?DateInterval
|
||||
{
|
||||
if( $this->suspend != -1 )
|
||||
{
|
||||
try
|
||||
{
|
||||
return new \DateInterval( $this->suspend );
|
||||
return new DateInterval( $this->suspend );
|
||||
}
|
||||
catch( \Exception $e ){}
|
||||
catch( Exception $e ){}
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -98,10 +140,10 @@ class _Warning extends \IPS\Content\Item
|
||||
/**
|
||||
* Should posting this increment the poster's post count?
|
||||
*
|
||||
* @param \IPS\Node\Model|NULL $container Container
|
||||
* @return void
|
||||
* @param Model|NULL $container Container
|
||||
* @return bool
|
||||
*/
|
||||
public static function incrementPostCount( \IPS\Node\Model $container = NULL )
|
||||
public static function incrementPostCount( ?Model $container = NULL ): bool
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@@ -109,12 +151,12 @@ class _Warning extends \IPS\Content\Item
|
||||
/**
|
||||
* Load record based on a URL
|
||||
*
|
||||
* @param \IPS\Http\Url $url URL to load from
|
||||
* @param Url $url URL to load from
|
||||
* @return static
|
||||
* @throws \InvalidArgumentException
|
||||
* @throws \OutOfRangeException
|
||||
* @throws InvalidArgumentException
|
||||
* @throws OutOfRangeException
|
||||
*/
|
||||
public static function loadFromUrl( \IPS\Http\Url $url )
|
||||
public static function loadFromUrl( Url $url ): static
|
||||
{
|
||||
return static::load( $url->hiddenQueryString['w'] );
|
||||
}
|
||||
@@ -124,9 +166,9 @@ class _Warning extends \IPS\Content\Item
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function undo()
|
||||
public function undo() : void
|
||||
{
|
||||
$member = \IPS\Member::load( $this->member );
|
||||
$member = Member::load( $this->member );
|
||||
|
||||
/* Take off the points */
|
||||
if ( ( !$this->expire_date or $this->expire_date == -1 ) or $this->expire_date > time() )
|
||||
@@ -146,11 +188,11 @@ class _Warning extends \IPS\Content\Item
|
||||
{
|
||||
try
|
||||
{
|
||||
$latest = \IPS\Db::i()->select( '*', 'core_members_warn_logs', array( "wl_member=? AND wl_{$w}<>0 AND wl_id !=?", $member->member_id, $this->id ), 'wl_date DESC' )->first();
|
||||
$latest = Db::i()->select( '*', 'core_members_warn_logs', array( "wl_member=? AND wl_{$w}<>0 AND wl_id !=?", $member->member_id, $this->id ), 'wl_date DESC' )->first();
|
||||
$member->$m = $latest[ 'wl_' . $w ];
|
||||
$consequences[ $m ] = $latest['wl_id'];
|
||||
}
|
||||
catch ( \UnderflowException $e )
|
||||
catch ( UnderflowException $e )
|
||||
{
|
||||
$member->$m = 0;
|
||||
$consequences[ $m ] = 0;
|
||||
@@ -174,16 +216,16 @@ class _Warning extends \IPS\Content\Item
|
||||
/**
|
||||
* Delete warning
|
||||
*
|
||||
* @return void
|
||||
* @return void
|
||||
*/
|
||||
public function delete()
|
||||
public function delete(): void
|
||||
{
|
||||
/* Unaknowledged Warnings? */
|
||||
$member = \IPS\Member::load( $this->member );
|
||||
$member = Member::load( $this->member );
|
||||
|
||||
if ( \IPS\Settings::i()->warnings_acknowledge )
|
||||
if ( Settings::i()->warnings_acknowledge )
|
||||
{
|
||||
$count = \IPS\Db::i()->select( 'COUNT(*)', 'core_members_warn_logs', array( "wl_member=? AND wl_id<>? AND wl_acknowledged=0", $member->member_id, $this->id ) )->first();
|
||||
$count = Db::i()->select( 'COUNT(*)', 'core_members_warn_logs', array( "wl_member=? AND wl_id<>? AND wl_acknowledged=0", $member->member_id, $this->id ) )->first();
|
||||
$member->members_bitoptions['unacknowledged_warnings'] = (bool) $count;
|
||||
}
|
||||
else
|
||||
@@ -201,18 +243,18 @@ class _Warning extends \IPS\Content\Item
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function unclaimAttachments()
|
||||
protected function unclaimAttachments(): void
|
||||
{
|
||||
\IPS\File::unclaimAttachments( 'core_Modcp', $this->id, NULL, 'member' );
|
||||
\IPS\File::unclaimAttachments( 'core_Modcp', $this->id, NULL, 'mod' );
|
||||
File::unclaimAttachments( 'core_Modcp', $this->id, NULL, 'member' );
|
||||
File::unclaimAttachments( 'core_Modcp', $this->id, NULL, 'mod' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Content for Warning
|
||||
*
|
||||
* @return \IPS\Content|NULL
|
||||
* @return Content|NULL
|
||||
*/
|
||||
public function content()
|
||||
public function contentObject(): ?Content
|
||||
{
|
||||
if ( $this->content_app and $this->content_module )
|
||||
{
|
||||
@@ -222,14 +264,14 @@ class _Warning extends \IPS\Content\Item
|
||||
{
|
||||
if ( $this->content_id2 )
|
||||
{
|
||||
return \IPS\core\Messenger\Message::load( $this->content_id2 );
|
||||
return Message::load( $this->content_id2 );
|
||||
}
|
||||
else
|
||||
{
|
||||
return \IPS\core\Messenger\Conversation::load( $this->content_id2 );
|
||||
return Conversation::load( $this->content_id2 );
|
||||
}
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
catch ( OutOfRangeException $e )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
@@ -238,7 +280,7 @@ class _Warning extends \IPS\Content\Item
|
||||
{
|
||||
try
|
||||
{
|
||||
$extensions = \IPS\Application::load( $this->content_app )->extensions( 'core', 'ContentRouter' );
|
||||
$extensions = Application::load( $this->content_app )->extensions( 'core', 'ContentRouter' );
|
||||
foreach ( $extensions as $ext )
|
||||
{
|
||||
foreach ( $ext->classes as $class )
|
||||
@@ -249,7 +291,7 @@ class _Warning extends \IPS\Content\Item
|
||||
{
|
||||
return $class::load( $this->content_id1 );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
catch ( OutOfRangeException $e )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
@@ -260,7 +302,7 @@ class _Warning extends \IPS\Content\Item
|
||||
{
|
||||
return $commentClass::load( $this->content_id2 );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
catch ( OutOfRangeException $e )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
@@ -271,7 +313,7 @@ class _Warning extends \IPS\Content\Item
|
||||
{
|
||||
return $reviewClass::load( $this->content_id2 );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
catch ( OutOfRangeException $e )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
@@ -279,7 +321,7 @@ class _Warning extends \IPS\Content\Item
|
||||
}
|
||||
}
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
catch ( OutOfRangeException $e )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
@@ -294,12 +336,12 @@ class _Warning extends \IPS\Content\Item
|
||||
/**
|
||||
* @brief Application
|
||||
*/
|
||||
public static $application = 'core';
|
||||
public static string $application = 'core';
|
||||
|
||||
/**
|
||||
* @brief Database Column Map
|
||||
*/
|
||||
public static $databaseColumnMap = array(
|
||||
public static array $databaseColumnMap = array(
|
||||
'date' => 'date',
|
||||
'author' => 'moderator',
|
||||
);
|
||||
@@ -307,25 +349,25 @@ class _Warning extends \IPS\Content\Item
|
||||
/**
|
||||
* @brief Language prefix for forms
|
||||
*/
|
||||
public static $formLangPrefix = 'warn_';
|
||||
public static string $formLangPrefix = 'warn_';
|
||||
|
||||
/**
|
||||
* Get elements for add/edit form
|
||||
*
|
||||
* @param \IPS\Content\Item|NULL $item The current item if editing or NULL if creating
|
||||
* @param int $container Container (e.g. forum) ID, if appropriate
|
||||
* @param Item|null $item The current item if editing or NULL if creating
|
||||
* @param Model|null $container Container (e.g. forum) ID, if appropriate
|
||||
* @return array
|
||||
*/
|
||||
public static function formElements( $item=NULL, \IPS\Node\Model $container=NULL )
|
||||
public static function formElements( ?Item $item=NULL, ?Model $container=NULL ): array
|
||||
{
|
||||
/* Get the reasons */
|
||||
$reasons = array();
|
||||
$roots = \IPS\core\Warnings\Reason::roots();
|
||||
$roots = Reason::roots();
|
||||
foreach ( $roots as $reason )
|
||||
{
|
||||
$reasons[ $reason->_id ] = $reason->_title;
|
||||
}
|
||||
if ( \IPS\Member::loggedIn()->modPermission('warnings_enable_other') )
|
||||
if ( Member::loggedIn()->modPermission('warnings_enable_other') )
|
||||
{
|
||||
$reasons['other'] = 'core_warn_reason_other';
|
||||
}
|
||||
@@ -337,66 +379,66 @@ class _Warning extends \IPS\Content\Item
|
||||
}
|
||||
|
||||
/* Build the form */
|
||||
$elements[] = new \IPS\Helpers\Form\Select( 'warn_reason', NULL, TRUE, array( 'options' => $reasons ) );
|
||||
$elements[] = new \IPS\Helpers\Form\Number( 'warn_points', 0, FALSE, array( 'valueToggles' => array( 'warn_remove' ), 'disabled' => ( !$first->points_override ) ) );
|
||||
$elements[] = new \IPS\Helpers\Form\Date( 'warn_remove', -1, FALSE, array( 'time' => TRUE, 'unlimited' => -1, 'unlimitedLang' => 'never' ), NULL, NULL, NULL, 'warn_remove' );
|
||||
$elements[] = new \IPS\Helpers\Form\Number( 'warn_cheeve_point_reduction', $first->cheev_point_reduction, FALSE, array( 'disabled' => ( !$first->cheev_override ) ) );
|
||||
$elements[] = new \IPS\Helpers\Form\Editor( 'warn_member_note', NULL, FALSE, array( 'app' => 'core', 'key' => 'Modcp', 'autoSaveKey' => "warn-member-" . \IPS\Request::i()->id, 'attachIds' => ( $item === NULL ? NULL : array( $item->id, NULL, 'member' ) ), 'minimize' => 'warn_member_note_placeholder' ) );
|
||||
$elements[] = new \IPS\Helpers\Form\Editor( 'warn_mod_note', NULL, FALSE, array( 'app' => 'core', 'key' => 'Modcp', 'autoSaveKey' => "warn-mod-" . \IPS\Request::i()->id, 'attachIds' => ( $item === NULL ? NULL : array( $item->id, NULL, 'mod' ) ), 'minimize' => 'warn_mod_note_placeholder' ) );
|
||||
$elements[] = new \IPS\Helpers\Form\CheckboxSet( 'warn_punishment', array(), FALSE, array(
|
||||
$elements[] = new Select( 'warn_reason', NULL, TRUE, array( 'options' => $reasons ) );
|
||||
$elements[] = new Number( 'warn_points', 0, FALSE, array( 'valueToggles' => array( 'warn_remove' ), 'disabled' => ( !$first->points_override ) ) );
|
||||
$elements[] = new Date( 'warn_remove', -1, FALSE, array( 'time' => TRUE, 'unlimited' => -1, 'unlimitedLang' => 'never' ), NULL, NULL, NULL, 'warn_remove' );
|
||||
$elements[] = new Number( 'warn_cheeve_point_reduction', $first->cheev_point_reduction, FALSE, array( 'disabled' => ( !$first->cheev_override ) ) );
|
||||
$elements[] = new Editor( 'warn_member_note', NULL, FALSE, array( 'app' => 'core', 'key' => 'Modcp', 'autoSaveKey' => "warn-member-" . Request::i()->id, 'attachIds' => ( $item === NULL ? NULL : array( $item->id, NULL, 'member' ) ), 'minimize' => 'warn_member_note_placeholder' ) );
|
||||
$elements[] = new Editor( 'warn_mod_note', NULL, FALSE, array( 'app' => 'core', 'key' => 'Modcp', 'autoSaveKey' => "warn-mod-" . Request::i()->id, 'attachIds' => ( $item === NULL ? NULL : array( $item->id, NULL, 'mod' ) ), 'minimize' => 'warn_mod_note_placeholder' ) );
|
||||
$elements[] = new CheckboxSet( 'warn_punishment', array(), FALSE, array(
|
||||
'options' => array( 'mq' => 'warn_mq', 'rpa' => 'warn_rpa', 'suspend' => 'warn_suspend' ),
|
||||
'toggles' => array( 'mq' => array( 'form_warn_mq' ), 'rpa' => array( 'form_warn_rpa' ), 'suspend' => array( 'form_warn_suspend' ) ),
|
||||
) );
|
||||
$elements[] = new \IPS\Helpers\Form\Date( 'warn_mq', -1, FALSE, array( 'time' => TRUE, 'unlimited' => -1, 'unlimitedLang' => 'indefinitely' ), function( $val )
|
||||
$elements[] = new Date( 'warn_mq', -1, FALSE, array( 'time' => TRUE, 'unlimited' => -1, 'unlimitedLang' => 'indefinitely' ), function( $val )
|
||||
{
|
||||
if( $val )
|
||||
{
|
||||
$now = new \IPS\DateTime;
|
||||
$now = new DateTime;
|
||||
|
||||
if( $val !== -1 and $val->getTimestamp() < $now->getTimestamp() )
|
||||
{
|
||||
throw new \DomainException( 'error_date_not_future' );
|
||||
throw new DomainException( 'error_date_not_future' );
|
||||
}
|
||||
}
|
||||
|
||||
}, \IPS\Member::loggedIn()->language()->addToStack('until'), NULL, NULL, 'warn_mq' );
|
||||
}, Member::loggedIn()->language()->addToStack('until'), NULL, 'warn_mq' );
|
||||
|
||||
$elements[] = new \IPS\Helpers\Form\Date( 'warn_rpa', -1, FALSE, array( 'time' => TRUE, 'unlimited' => -1, 'unlimitedLang' => 'indefinitely' ), function( $val )
|
||||
$elements[] = new Date( 'warn_rpa', -1, FALSE, array( 'time' => TRUE, 'unlimited' => -1, 'unlimitedLang' => 'indefinitely' ), function( $val )
|
||||
{
|
||||
if( $val )
|
||||
{
|
||||
$now = new \IPS\DateTime;
|
||||
$now = new DateTime;
|
||||
|
||||
if( $val !== -1 and $val->getTimestamp() < $now->getTimestamp() )
|
||||
{
|
||||
throw new \DomainException( 'error_date_not_future' );
|
||||
throw new DomainException( 'error_date_not_future' );
|
||||
}
|
||||
}
|
||||
|
||||
}, \IPS\Member::loggedIn()->language()->addToStack('until'), NULL, NULL, 'warn_rpa' );
|
||||
}, Member::loggedIn()->language()->addToStack('until'), NULL, 'warn_rpa' );
|
||||
|
||||
$elements[] = new \IPS\Helpers\Form\Date( 'warn_suspend', -1, FALSE, array( 'time' => TRUE, 'unlimited' => -1, 'unlimitedLang' => 'indefinitely' ), function( $val )
|
||||
$elements[] = new Date( 'warn_suspend', -1, FALSE, array( 'time' => TRUE, 'unlimited' => -1, 'unlimitedLang' => 'indefinitely' ), function( $val )
|
||||
{
|
||||
if( $val )
|
||||
{
|
||||
$now = new \IPS\DateTime;
|
||||
$now = new DateTime;
|
||||
|
||||
if( $val !== -1 and $val->getTimestamp() < $now->getTimestamp() )
|
||||
{
|
||||
throw new \DomainException( 'error_date_not_future' );
|
||||
throw new DomainException( 'error_date_not_future' );
|
||||
}
|
||||
}
|
||||
|
||||
}, \IPS\Member::loggedIn()->language()->addToStack('until'), NULL, NULL, 'warn_suspend' );
|
||||
}, Member::loggedIn()->language()->addToStack('until'), NULL, 'warn_suspend' );
|
||||
|
||||
$member = \IPS\Member::load( \IPS\Request::i()->id );
|
||||
$member = Member::load( Request::i()->id );
|
||||
|
||||
if( $member->temp_ban OR $member->mod_posts OR $member->restrict_post )
|
||||
{
|
||||
$elements[] = \IPS\Member::loggedIn()->language()->addToStack('member_existing_penalties', TRUE, array( 'sprintf' => $member->name ) );
|
||||
$elements[] = Member::loggedIn()->language()->addToStack('member_existing_penalties', TRUE, array( 'sprintf' => $member->name ) );
|
||||
}
|
||||
|
||||
\IPS\Member::loggedIn()->language()->words['warn_cheeve_point_reduction_desc'] = \IPS\Member::loggedIn()->language()->addToStack( 'warn_cheeve_point_reduction__desc', FALSE, [ 'sprintf' => [ $member->name, $member->achievements_points, $member->name ] ] );
|
||||
Member::loggedIn()->language()->words['warn_cheeve_point_reduction_desc'] = Member::loggedIn()->language()->addToStack( 'warn_cheeve_point_reduction__desc', FALSE, [ 'sprintf' => [ $member->name, $member->achievements_points, $member->name ] ] );
|
||||
|
||||
/* Return */
|
||||
return $elements;
|
||||
@@ -405,20 +447,20 @@ class _Warning extends \IPS\Content\Item
|
||||
/**
|
||||
* Process created object BEFORE the object has been created
|
||||
*
|
||||
* @param array $values Values from form
|
||||
* @param array $values Values from form
|
||||
* @return void
|
||||
*/
|
||||
protected function processBeforeCreate( $values )
|
||||
protected function processBeforeCreate( array $values ): void
|
||||
{
|
||||
$this->member = \IPS\Request::i()->member;
|
||||
$this->member = Request::i()->member;
|
||||
|
||||
/* Permission Check */
|
||||
if ( !\IPS\Member::loggedIn()->canWarn( \IPS\Member::load( $this->member ) ) )
|
||||
if ( !Member::loggedIn()->canWarn( Member::load( $this->member ) ) )
|
||||
{
|
||||
\IPS\Output::i()->error( 'no_module_permission', '2C150/3', 403, '' );
|
||||
Output::i()->error( 'no_module_permission', '2C150/3', 403, '' );
|
||||
}
|
||||
|
||||
$values = $this->processWarning( $values, \IPS\Member::loggedIn() );
|
||||
$values = $this->processWarning($values, Member::loggedIn());
|
||||
|
||||
parent::processBeforeCreate( $values );
|
||||
}
|
||||
@@ -426,16 +468,16 @@ class _Warning extends \IPS\Content\Item
|
||||
/**
|
||||
* Process created object AFTER the object has been created
|
||||
*
|
||||
* @param \IPS\Content\Comment|NULL $comment The first comment
|
||||
* @param Comment|NULL $comment The first comment
|
||||
* @param array $values Values from form
|
||||
* @return void
|
||||
*/
|
||||
protected function processAfterCreate( $comment, $values )
|
||||
protected function processAfterCreate( ?Comment $comment, array $values ): void
|
||||
{
|
||||
\IPS\File::claimAttachments( "warn-member-{$this->member}", $this->id, NULL, 'member' );
|
||||
\IPS\File::claimAttachments( "warn-mod-{$this->member}", $this->id, NULL, 'mod' );
|
||||
File::claimAttachments( "warn-member-{$this->member}", $this->id, NULL, 'member' );
|
||||
File::claimAttachments( "warn-mod-{$this->member}", $this->id, NULL, 'mod' );
|
||||
|
||||
$member = \IPS\Member::load( $this->member );
|
||||
$member = Member::load( $this->member );
|
||||
if ( $this->points )
|
||||
{
|
||||
$member->warn_level += $this->points;
|
||||
@@ -448,7 +490,7 @@ class _Warning extends \IPS\Content\Item
|
||||
$consequences[ $v ] = $this->$k;
|
||||
if ( $this->$k != -1 )
|
||||
{
|
||||
$member->$v = \IPS\DateTime::create()->add( new \DateInterval( $this->$k ) )->getTimestamp();
|
||||
$member->$v = DateTime::create()->add( new DateInterval( $this->$k ) )->getTimestamp();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -477,34 +519,34 @@ class _Warning extends \IPS\Content\Item
|
||||
$consequences['cheev_point_reduction'] = $this->cheev_point_reduction;
|
||||
}
|
||||
|
||||
$member->members_bitoptions['unacknowledged_warnings'] = (bool) \IPS\Settings::i()->warnings_acknowledge;
|
||||
$member->members_bitoptions['unacknowledged_warnings'] = (bool) Settings::i()->warnings_acknowledge;
|
||||
$member->save();
|
||||
$member->logHistory( 'core', 'warning', array( 'wid' => $this->id, 'points' => $this->points, 'reason' => $this->reason, 'consequences' => $consequences ) );
|
||||
|
||||
/* Moderator log */
|
||||
\IPS\Session::i()->modLog( 'modlog__action_warn_user', array( $member->name => FALSE ) );
|
||||
Session::i()->modLog( 'modlog__action_warn_user', array( $member->name => FALSE ) );
|
||||
|
||||
/* Webhook */
|
||||
\IPS\Api\Webhook::fire( 'member_warned', $this );
|
||||
Webhook::fire( 'member_warned', $this );
|
||||
parent::processAfterCreate( $comment, $values );
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the warning values
|
||||
*
|
||||
* @param array $values Values from form submission
|
||||
* @param \IPS\Member $member Moderator to process warning under
|
||||
* @param bool $reset Reset points based on reason
|
||||
* @param array $values Values from form submission
|
||||
* @param Member $member Moderator to process warning under
|
||||
* @param bool $reset Reset points based on reason
|
||||
* @return array
|
||||
*/
|
||||
public function processWarning( $values, $member, $reset=FALSE )
|
||||
public function processWarning (array $values, Member $member, bool $reset=FALSE ): array
|
||||
{
|
||||
/* Work out points and expiry date */
|
||||
$this->expire_date = NULL;
|
||||
$this->points = $values['warn_points'];
|
||||
if ( \is_numeric( $values['warn_reason'] ) )
|
||||
if ( is_numeric( $values['warn_reason'] ) )
|
||||
{
|
||||
$reason = \IPS\core\Warnings\Reason::load( $values['warn_reason'] );
|
||||
$reason = Reason::load( $values['warn_reason'] );
|
||||
if ( !$reason->points_override OR ( !$this->points AND $reset ) )
|
||||
{
|
||||
$this->points = $reason->points;
|
||||
@@ -519,14 +561,14 @@ class _Warning extends \IPS\Content\Item
|
||||
{
|
||||
if ( $reason->remove and $reason->remove != -1 )
|
||||
{
|
||||
$expire = \IPS\DateTime::create();
|
||||
$expire = DateTime::create();
|
||||
if ( $reason->remove_unit == 'h' )
|
||||
{
|
||||
$expire->add( new \DateInterval( "PT{$reason->remove}H" ) );
|
||||
$expire->add( new DateInterval( "PT{$reason->remove}H" ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$expire->add( new \DateInterval( "P{$reason->remove}D" ) );
|
||||
$expire->add( new DateInterval( "P{$reason->remove}D" ) );
|
||||
}
|
||||
$this->expire_date = $expire->getTimestamp();
|
||||
}
|
||||
@@ -538,7 +580,7 @@ class _Warning extends \IPS\Content\Item
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( $values['warn_remove'] instanceof \IPS\DateTime )
|
||||
if ( $values['warn_remove'] instanceof DateTime )
|
||||
{
|
||||
$this->expire_date = $values['warn_remove']->getTimestamp();
|
||||
}
|
||||
@@ -563,7 +605,7 @@ class _Warning extends \IPS\Content\Item
|
||||
{
|
||||
$this->reason = 0;
|
||||
|
||||
if ( $values['warn_remove'] instanceof \IPS\DateTime )
|
||||
if ( $values['warn_remove'] instanceof DateTime )
|
||||
{
|
||||
$this->expire_date = $values['warn_remove']->getTimestamp();
|
||||
}
|
||||
@@ -580,12 +622,12 @@ class _Warning extends \IPS\Content\Item
|
||||
/* If we can't override the action, change it back */
|
||||
try
|
||||
{
|
||||
$action = \IPS\Db::i()->select( '*', 'core_members_warn_actions', array( 'wa_points<=?', ( \IPS\Member::load( $this->member )->warn_level + $this->points ) ), 'wa_points DESC', 1 )->first();
|
||||
$action = Db::i()->select( '*', 'core_members_warn_actions', array( 'wa_points<=?', ( Member::load( $this->member )->warn_level + $this->points ) ), 'wa_points DESC', 1 )->first();
|
||||
if ( !$action['wa_override'] )
|
||||
{
|
||||
foreach ( array( 'mq', 'rpa', 'suspend' ) as $k )
|
||||
{
|
||||
if( !\in_array( $k, $values['warn_punishment'] ) )
|
||||
if( !in_array( $k, $values['warn_punishment'] ) )
|
||||
{
|
||||
$values['warn_punishment'][] = $k;
|
||||
}
|
||||
@@ -596,7 +638,7 @@ class _Warning extends \IPS\Content\Item
|
||||
}
|
||||
elseif ( $action[ 'wa_' . $k ] )
|
||||
{
|
||||
$values[ 'warn_' . $k ] = \IPS\DateTime::create()->add( new \DateInterval( $action[ 'wa_' . $k . '_unit' ] == 'h' ? "PT{$action[ 'wa_' . $k ]}H" : "P{$action[ 'wa_' . $k ]}D" ) );
|
||||
$values[ 'warn_' . $k ] = DateTime::create()->add( new DateInterval( $action[ 'wa_' . $k . '_unit' ] == 'h' ? "PT{$action[ 'wa_' . $k ]}H" : "P{$action[ 'wa_' . $k ]}D" ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -605,7 +647,7 @@ class _Warning extends \IPS\Content\Item
|
||||
}
|
||||
}
|
||||
}
|
||||
catch ( \UnderflowException $e )
|
||||
catch ( UnderflowException $e )
|
||||
{
|
||||
if ( !$member->modPermission('warning_custom_noaction') )
|
||||
{
|
||||
@@ -621,7 +663,7 @@ class _Warning extends \IPS\Content\Item
|
||||
{
|
||||
if ( $values['warn_' . $p ] === NULL )
|
||||
{
|
||||
\IPS\Output::i()->error( 'no_warning_action_time', '1C150/2', 403, '' );
|
||||
Output::i()->error( 'no_warning_action_time', '1C150/2', 403, '' );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -630,15 +672,15 @@ class _Warning extends \IPS\Content\Item
|
||||
$this->note_mods = $values['warn_mod_note'];
|
||||
|
||||
/* Set acknowledged */
|
||||
$this->acknowledged = !\IPS\Settings::i()->warnings_acknowledge;
|
||||
$this->acknowledged = !Settings::i()->warnings_acknowledge;
|
||||
|
||||
/* Construct referrer */
|
||||
$ref = \IPS\Request::i()->ref ? json_decode( base64_decode( \IPS\Request::i()->ref ), TRUE ) : NULL;
|
||||
$this->content_app = isset( $ref['app'] ) ? $ref['app'] : NULL;
|
||||
$this->content_module = isset( $ref['module'] ) ? $ref['module'] : NULL;
|
||||
$this->content_id1 = isset( $ref['id_1'] ) ? $ref['id_1'] : NULL;
|
||||
$this->content_id2 = isset( $ref['id_2'] ) ? $ref['id_2'] : NULL;
|
||||
if ( $content = $this->content() and !$content->canView() )
|
||||
$ref = Request::i()->ref ? json_decode( base64_decode( Request::i()->ref ), TRUE ) : NULL;
|
||||
$this->content_app = $ref['app'] ?? NULL;
|
||||
$this->content_module = $ref['module'] ?? NULL;
|
||||
$this->content_id1 = $ref['id_1'] ?? NULL;
|
||||
$this->content_id2 = $ref['id_2'] ?? NULL;
|
||||
if ( $content = $this->contentObject() and !$content->canView() )
|
||||
{
|
||||
$this->content_app = NULL;
|
||||
$this->content_module = NULL;
|
||||
@@ -647,19 +689,19 @@ class _Warning extends \IPS\Content\Item
|
||||
}
|
||||
|
||||
/* Work out the timeframes for the penalties */
|
||||
if ( \count( $values['warn_punishment'] ) )
|
||||
if ( count( $values['warn_punishment'] ) )
|
||||
{
|
||||
foreach ( array( 'mq', 'rpa', 'suspend' ) as $f )
|
||||
{
|
||||
if ( !\in_array( $f, $values['warn_punishment'] ) OR $values['warn_' . $f ] === 0 )
|
||||
if ( !in_array( $f, $values['warn_punishment'] ) OR $values['warn_' . $f ] === 0 )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( $values[ 'warn_' . $f ] instanceof \IPS\DateTime )
|
||||
if ( $values[ 'warn_' . $f ] instanceof DateTime )
|
||||
{
|
||||
$difference = \IPS\DateTime::create()->setTimezone( $values[ 'warn_' . $f ]->getTimezone() )->diff( $values[ 'warn_' . $f ] );
|
||||
|
||||
$difference = DateTime::create()->setTimezone( $values[ 'warn_' . $f ]->getTimezone() )->diff( $values[ 'warn_' . $f ] );
|
||||
|
||||
/**
|
||||
* Due to a bug in PHP 8.0, DateTime::diff() can return -1 for the hour, and an extra day. We need to look for this specifically and set hour to 23, and reduce days by 1. This bug is fixed in 8.1, so this should be removed when that version is required.
|
||||
* @see <a href='https://bugs.php.net/bug.php?id=66545'>#66545</a>
|
||||
@@ -672,7 +714,7 @@ class _Warning extends \IPS\Content\Item
|
||||
$difference->d = $difference->d - 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$period = 'P';
|
||||
foreach ( array( 'y' => 'Y', 'm' => 'M', 'd' => 'D' ) as $k => $v )
|
||||
{
|
||||
@@ -711,10 +753,10 @@ class _Warning extends \IPS\Content\Item
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getModerators()
|
||||
public function getModerators() : array
|
||||
{
|
||||
$moderators = array( 'm' => array(), 'g' => array() );
|
||||
foreach ( \IPS\Db::i()->select( '*', 'core_moderators' ) as $mod )
|
||||
foreach ( Db::i()->select( '*', 'core_moderators' ) as $mod )
|
||||
{
|
||||
$canView = FALSE;
|
||||
|
||||
@@ -745,19 +787,19 @@ class _Warning extends \IPS\Content\Item
|
||||
/**
|
||||
* Build and return the WHERE statements for warning notifications
|
||||
*
|
||||
* @param array $moderators Moderator data
|
||||
* @param array $moderators Moderator data
|
||||
* @return array
|
||||
*/
|
||||
public function buildNotificationsWhere( $moderators )
|
||||
public function buildNotificationsWhere( array $moderators ): array
|
||||
{
|
||||
$where = array();
|
||||
if ( !empty( $moderators['m'] ) )
|
||||
{
|
||||
$where[] = \IPS\Db::i()->in( 'member_id', $moderators['m'] );
|
||||
$where[] = Db::i()->in( 'member_id', $moderators['m'] );
|
||||
}
|
||||
|
||||
$where[] = \IPS\Db::i()->in( 'member_group_id', $moderators['g'] );
|
||||
$where[] = \IPS\Db::i()->findInSet( 'mgroup_others', $moderators['g'] );
|
||||
$where[] = Db::i()->in( 'member_group_id', $moderators['g'] );
|
||||
$where[] = Db::i()->findInSet( 'mgroup_others', $moderators['g'] );
|
||||
|
||||
/* Don't annoy the acting moderator with a notification for the warning they /just/ issued */
|
||||
return array(
|
||||
@@ -773,12 +815,12 @@ class _Warning extends \IPS\Content\Item
|
||||
/**
|
||||
* Get notification count
|
||||
*
|
||||
* @param array $moderators Moderator data
|
||||
* @param array $moderators Moderator data
|
||||
* @return int
|
||||
*/
|
||||
public function notificationsCount( $moderators )
|
||||
public function notificationsCount( array $moderators ): int
|
||||
{
|
||||
return \IPS\Db::i()->select(
|
||||
return Db::i()->select(
|
||||
'COUNT(*)',
|
||||
'core_members',
|
||||
$this->buildNotificationsWhere( $moderators )
|
||||
@@ -790,35 +832,35 @@ class _Warning extends \IPS\Content\Item
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function sendNotifications()
|
||||
public function sendNotifications(): void
|
||||
{
|
||||
/* Queue if there's lots, or just send them */
|
||||
if ( $this->notificationsCount( $this->getModerators() ) > \IPS\NOTIFICATION_BACKGROUND_THRESHOLD )
|
||||
if ( $this->notificationsCount( $this->getModerators() ) > NOTIFICATION_BACKGROUND_THRESHOLD )
|
||||
{
|
||||
\IPS\Task::queue( 'core', 'WarnNotifications', array( 'class' => \get_class( $this ), 'item' => $this->id, 'sentTo' => array() ), 1 );
|
||||
Task::queue( 'core', 'WarnNotifications', array( 'class' => get_class( $this ), 'item' => $this->id, 'sentTo' => array() ), 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sendNotificationsBatch();
|
||||
}
|
||||
|
||||
\IPS\Email::buildFromTemplate( 'core', 'warning', array( $this ), \IPS\Email::TYPE_TRANSACTIONAL )->send( \IPS\Member::load( $this->member ) );
|
||||
Email::buildFromTemplate( 'core', 'warning', array( $this ), Email::TYPE_TRANSACTIONAL )->send( Member::load( $this->member ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Send notifications batch
|
||||
*
|
||||
* @param int $offset Current offset
|
||||
* @param array $sentTo Members who have already received a notification and how - e.g. array( 1 => array( 'inline', 'email' )
|
||||
* @param string|NULL $extra Additional data
|
||||
* @param int $offset Current offset
|
||||
* @param array $sentTo Members who have already received a notification and how - e.g. array( 1 => array( 'inline', 'email' )
|
||||
* @param string|null $extra Additional data
|
||||
* @return int|null New offset or NULL if complete
|
||||
*/
|
||||
public function sendNotificationsBatch( $offset=0, &$sentTo=array(), $extra=NULL )
|
||||
public function sendNotificationsBatch( int $offset=0, array &$sentTo=array(), string $extra=null ): ?int
|
||||
{
|
||||
$moderators = $this->getModerators();
|
||||
$notification = new \IPS\Notification( \IPS\Application::load('core'), 'warning_mods', $this, array( $this ) );
|
||||
$notification = new Notification( Application::load('core'), 'warning_mods', $this, array( $this ) );
|
||||
|
||||
$members = \IPS\Db::i()->select(
|
||||
$members = Db::i()->select(
|
||||
'*',
|
||||
'core_members',
|
||||
$this->buildNotificationsWhere( $moderators ),
|
||||
@@ -827,8 +869,8 @@ class _Warning extends \IPS\Content\Item
|
||||
);
|
||||
foreach ( $members as $member )
|
||||
{
|
||||
\IPS\Log::debug( "Sent notification to {$member['name']}", 'warn_fix' );
|
||||
$notification->recipients->attach( \IPS\Member::constructFromData( $member ) );
|
||||
Log::debug( "Sent notification to {$member['name']}", 'warn_fix' );
|
||||
$notification->recipients->attach( Member::constructFromData( $member ) );
|
||||
}
|
||||
|
||||
$sentTo = $notification->send( $sentTo );
|
||||
@@ -845,21 +887,21 @@ class _Warning extends \IPS\Content\Item
|
||||
/**
|
||||
* @brief Cached URLs
|
||||
*/
|
||||
protected $_url = array();
|
||||
protected mixed $_url = array();
|
||||
|
||||
/**
|
||||
* Get URL
|
||||
*
|
||||
* @param string|NULL $action Action
|
||||
* @return \IPS\Http\Url
|
||||
* @return Url
|
||||
*/
|
||||
public function url( $action=NULL )
|
||||
public function url( string|null $action=NULL ): Url
|
||||
{
|
||||
$_key = md5( $action );
|
||||
$_key = $action ? md5( $action ) : NULL;
|
||||
|
||||
if( !isset( $this->_url[ $_key ] ) )
|
||||
{
|
||||
$this->_url[ $_key ] = \IPS\Http\Url::internal( "app=core&module=system&controller=warnings&id={$this->member}&w={$this->id}", 'front', 'warn_view', \IPS\Member::load( $this->member )->members_seo_name );
|
||||
$this->_url[ $_key ] = Url::internal( "app=core&module=system&controller=warnings&id={$this->member}&w={$this->id}", 'front', 'warn_view', Member::load( $this->member )->members_seo_name );
|
||||
|
||||
if ( $action )
|
||||
{
|
||||
@@ -873,14 +915,14 @@ class _Warning extends \IPS\Content\Item
|
||||
/**
|
||||
* Get mapped value
|
||||
*
|
||||
* @param string $key date,content,ip_address,first
|
||||
* @param string $key date,content,ip_address,first
|
||||
* @return mixed
|
||||
*/
|
||||
public function mapped( $key )
|
||||
public function mapped( string $key ): mixed
|
||||
{
|
||||
if ( $key === 'title' )
|
||||
{
|
||||
return \IPS\Member::loggedIn()->language()->addToStack( "core_warn_reason_{$this->reason}" );
|
||||
return Member::loggedIn()->language()->addToStack( "core_warn_reason_{$this->reason}" );
|
||||
}
|
||||
return parent::mapped( $key );
|
||||
}
|
||||
@@ -890,18 +932,18 @@ class _Warning extends \IPS\Content\Item
|
||||
/**
|
||||
* Can give warning?
|
||||
*
|
||||
* @param \IPS\Member $member The member
|
||||
* @param \IPS\Node\Model|NULL $container Container (e.g. forum), if appropriate
|
||||
* @param bool $showError If TRUE, rather than returning a boolean value, will display an error
|
||||
* @param Member $member The member
|
||||
* @param Model|NULL $container Container (e.g. forum), if appropriate
|
||||
* @param bool $showError If TRUE, rather than returning a boolean value, will display an error
|
||||
* @return bool
|
||||
* @note If we can't see warnings, we can't issue them either
|
||||
*/
|
||||
public static function canCreate( \IPS\Member $member, \IPS\Node\Model $container=NULL, $showError=FALSE )
|
||||
public static function canCreate( Member $member, Model $container=null, bool $showError=FALSE ): bool
|
||||
{
|
||||
$return = $member->modPermission('mod_can_warn') && $member->modPermission('mod_see_warn');
|
||||
if ( !$return and $showError )
|
||||
{
|
||||
\IPS\Output::i()->error( 'no_module_permission', '2C150/1', 403, '' );
|
||||
Output::i()->error( 'no_module_permission', '2C150/1', 403, '' );
|
||||
}
|
||||
|
||||
return $return;
|
||||
@@ -910,31 +952,31 @@ class _Warning extends \IPS\Content\Item
|
||||
/**
|
||||
* Does a member have permission to access?
|
||||
*
|
||||
* @param \IPS\Member $member The member to check for
|
||||
* @param Member|null $member The member to check for
|
||||
* @return bool
|
||||
*/
|
||||
public function canView( $member=NULL )
|
||||
public function canView( Member $member=null ): bool
|
||||
{
|
||||
$member = $member ?: \IPS\Member::loggedIn();
|
||||
$member = $member ?: Member::loggedIn();
|
||||
return $member->modPermission('mod_see_warn') or $this->member === $member->member_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Does a member have permission to view the details of the warning?
|
||||
*
|
||||
* @param \IPS\Member $member The member to check for
|
||||
* @param Member|null $member The member to check for
|
||||
* @return bool
|
||||
*/
|
||||
public function canViewDetails( $member=NULL )
|
||||
public function canViewDetails( Member $member=null ): bool
|
||||
{
|
||||
$member = $member ?: \IPS\Member::loggedIn();
|
||||
$member = $member ?: Member::loggedIn();
|
||||
|
||||
if ( $member->modPermission('mod_see_warn') )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if ( \IPS\Settings::i()->warn_show_own and $this->member === $member->member_id )
|
||||
if ( Settings::i()->warn_show_own and $this->member === $member->member_id )
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
@@ -945,24 +987,24 @@ class _Warning extends \IPS\Content\Item
|
||||
/**
|
||||
* Can acknowledge?
|
||||
*
|
||||
* @param \IPS\Member|NULL $member The member to check for (NULL for currently logged in member)
|
||||
* @param Member|null $member The member to check for (NULL for currently logged in member)
|
||||
* @return bool
|
||||
*/
|
||||
public function canAcknowledge( $member=NULL )
|
||||
public function canAcknowledge( Member $member=NULL ): bool
|
||||
{
|
||||
$member = $member ?: \IPS\Member::loggedIn();
|
||||
return \intval($this->member) === \intval($member->member_id);
|
||||
$member = $member ?: Member::loggedIn();
|
||||
return intval($this->member) === intval($member->member_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Can delete?
|
||||
*
|
||||
* @param \IPS\Member|NULL $member The member to check for (NULL for currently logged in member)
|
||||
* @param Member|null $member The member to check for (NULL for currently logged in member)
|
||||
* @return bool
|
||||
*/
|
||||
public function canDelete( $member=NULL )
|
||||
public function canDelete( Member $member=NULL ): bool
|
||||
{
|
||||
$member = $member ?: \IPS\Member::loggedIn();
|
||||
$member = $member ?: Member::loggedIn();
|
||||
return ( $member->modPermission('mod_revoke_warn') and $member->modPermission('mod_see_warn') );
|
||||
}
|
||||
|
||||
@@ -971,16 +1013,16 @@ class _Warning extends \IPS\Content\Item
|
||||
/**
|
||||
* @brief Enable table hover URL
|
||||
*/
|
||||
public $tableHoverUrl = TRUE;
|
||||
public ?bool $tableHoverUrl = TRUE;
|
||||
|
||||
/**
|
||||
* Icon for table view
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function tableIcon()
|
||||
public function tableIcon(): array
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate( 'modcp', 'core', 'front' )->warningRowPoints( $this->points );
|
||||
return Theme::i()->getTemplate( 'modcp', 'core', 'front' )->warningRowPoints( $this->points );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -988,7 +1030,7 @@ class _Warning extends \IPS\Content\Item
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function tableDescription()
|
||||
public function tableDescription(): string
|
||||
{
|
||||
return $this->note_mods;
|
||||
}
|
||||
@@ -996,8 +1038,8 @@ class _Warning extends \IPS\Content\Item
|
||||
/**
|
||||
* Get output for API
|
||||
*
|
||||
* @param \IPS\Member|NULL $authorizedMember The member making the API request or NULL for API Key / client_credentials
|
||||
* @return array
|
||||
* @param Member|NULL $authorizedMember The member making the API request or NULL for API Key / client_credentials
|
||||
* @return array
|
||||
* @apiresponse int id ID number
|
||||
* @apiresponse \IPS\Member member Member who was warned
|
||||
* @apiresponse \IPS\Member moderator Moderator who performed the warning
|
||||
@@ -1015,24 +1057,24 @@ class _Warning extends \IPS\Content\Item
|
||||
* @apiresponse bool suspendPermanent Member is permanently on suspension
|
||||
* @apiresponse string|NULL suspend DateTimeInterval (from date) when the member will be unsuspended or null
|
||||
*/
|
||||
public function apiOutput( \IPS\Member $authorizedMember = NULL )
|
||||
public function apiOutput( Member $authorizedMember = NULL ): array
|
||||
{
|
||||
$response = array(
|
||||
'id' => $this->id,
|
||||
'member' => \IPS\Member::load( $this->member )->apiOutput( $authorizedMember ),
|
||||
'moderator' => \IPS\Member::load( $this->moderator )->apiOutput( $authorizedMember ),
|
||||
'member' => Member::load( $this->member )->apiOutput( $authorizedMember ),
|
||||
'moderator' => Member::load( $this->moderator )->apiOutput( $authorizedMember ),
|
||||
'points' => $this->points,
|
||||
'reason' => $this->reason ? \IPS\core\Warnings\Reason::load( $this->reason )->apiOutput() : NULL,
|
||||
'expiration' => ( $this->expire_date == -1 ) ? $this->expire_date : \IPS\DateTime::ts( $this->expire_date )->rfc3339(),
|
||||
'date' => \IPS\DateTime::ts( $this->date )->rfc3339(),
|
||||
'acknowledged' => (bool) $this->acknowledged,
|
||||
'reason' => $this->reason ? Reason::load( $this->reason )->apiOutput() : NULL,
|
||||
'expiration' => ( $this->expire_date == -1 ) ? $this->expire_date : DateTime::ts( $this->expire_date )->rfc3339(),
|
||||
'date' => DateTime::ts( $this->date )->rfc3339(),
|
||||
'acknowledged' => $this->acknowledged,
|
||||
'memberNotes' => $this->note_member,
|
||||
'modQueue' => ( $this->mq != -1 ) ? $this->mq : null,
|
||||
'restrictPosts' => ( $this->rpa != -1 ) ? $this->rpa : null,
|
||||
'suspend' => ( $this->suspend != -1 ) ? $this->suspend : null,
|
||||
'modQueuePermanent' => ( $this->mq == -1 ) ? true : false,
|
||||
'restrictPostsPermanent' => ( $this->restrictPosts == -1 ) ? true : false,
|
||||
'suspendPermanent' => ( $this->suspend == -1 ) ? true : false,
|
||||
'modQueuePermanent' => $this->mq == -1,
|
||||
'restrictPostsPermanent' => $this->restrictPosts == -1,
|
||||
'suspendPermanent' => $this->suspend == -1,
|
||||
);
|
||||
|
||||
if( $authorizedMember === NULL )
|
||||
|
||||
Reference in new issue
Block a user