Version 5.0.13

This commit is contained in:
Neo committed 2025-12-19 19:04:57 -08:00
1 parent b89858b2ff
commit 5efe744c5f
1407 files changed
+69690 -30177

No files matched your search

+46 -5
View File
@@ -21,6 +21,7 @@ use IPS\Application;
use IPS\Content;
use IPS\Content\Comment;
use IPS\Content\Item;
use IPS\core\DataLayer;
use IPS\core\Messenger\Conversation;
use IPS\core\Messenger\Message;
use IPS\DateTime;
@@ -33,11 +34,13 @@ use IPS\Helpers\Form\Editor;
use IPS\Helpers\Form\Number;
use IPS\Helpers\Form\Select;
use IPS\Http\Url;
use IPS\Lang;
use IPS\Log;
use IPS\Member;
use IPS\Node\Model;
use IPS\Notification;
use IPS\Output;
use IPS\Platform\Bridge;
use IPS\Request;
use IPS\Session;
use IPS\Settings;
@@ -65,6 +68,7 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
class Warning extends Item
{
/* !\IPS\Patterns\ActiveRecord */
protected static array|bool $_bypassDataLayerEvents = true;
/**
* @brief Database Table
@@ -371,7 +375,8 @@ class Warning extends Item
{
$reasons['other'] = 'core_warn_reason_other';
}
$first = null;
foreach( $roots AS $root )
{
$first = $root;
@@ -379,15 +384,15 @@ class Warning extends Item
}
/* Build the form */
$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 Select( 'warn_reason', NULL, !empty( $reasons ), array( 'options' => $reasons ) );
$elements[] = new Number( 'warn_points', 0, FALSE, array( 'valueToggles' => array( 'warn_remove' ), 'disabled' => ( $first and !$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 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' ) ),
'toggles' => array( 'mq' => array( 'warn_mq' ), 'rpa' => array( 'warn_rpa' ), 'suspend' => array( 'warn_suspend' ) ),
) );
$elements[] = new Date( 'warn_mq', -1, FALSE, array( 'time' => TRUE, 'unlimited' => -1, 'unlimitedLang' => 'indefinitely' ), function( $val )
{
@@ -523,6 +528,12 @@ class Warning extends Item
$member->save();
$member->logHistory( 'core', 'warning', array( 'wid' => $this->id, 'points' => $this->points, 'reason' => $this->reason, 'consequences' => $consequences ) );
/* Data Layer */
if ( DataLayer::enabled( 'analytics_full' ) )
{
DataLayer::i()->addEvent( 'warning_created', $this->getDataLayerProperties() );
}
/* Moderator log */
Session::i()->modLog( 'modlog__action_warn_user', array( $member->name => FALSE ) );
@@ -531,6 +542,36 @@ class Warning extends Item
parent::processAfterCreate( $comment, $values );
}
/**
* @param Comment|null $comment
* @param array $createOrEditValues
* @param bool $clearCache=false
* @return array
*/
public function getDataLayerProperties( ?Comment $comment = null, array $createOrEditValues = [], bool $clearCache=false ): array
{
if ( $comment !== null )
{
return parent::getDataLayerProperties( $comment, $createOrEditValues, $clearCache );
}
static $properties = null;
if ( $clearCache or $properties === null )
{
$lang = Lang::load( Lang::defaultLanguage() );
$reasonString = $lang->addToStack( ( $this->reason and $lang->checkKeyExists( Reason::$titleLangPrefix . $this->reason ) ) ? ( Reason::$titleLangPrefix . $this->reason ) : 'core_warn_reason_other' );
$lang->parseOutputForDisplay( $reasonString );
$properties = DataLayer::i()->filterProperties([
'warn_reason' => $reasonString,
'warn_reason_id' => $this->reason,
'warn_points' => $this->points,
'warn_member_id' => DataLayer::i()->getSsoId( $this->member ),
'warn_mod_id' => DataLayer::i()->getSsoId( $this->moderator ),
]);
}
return $properties;
}
/**
* Process the warning values
*