Version 5.0.0 beta 4

This commit is contained in:
Neo committed 2025-12-19 16:57:00 -08:00
1 parent e86153356a
commit 2f24f9de48
276 files changed
+8614 -6044

No files matched your search

+71 -14
View File
@@ -19,8 +19,11 @@ use ErrorException;
use Exception;
use InvalidArgumentException;
use IPS\Api\Webhook;
use IPS\cloud\Application as CloudApplication;
use IPS\Content\Search\SearchContent;
use IPS\core\Feature;
use IPS\Helpers\Form\Email;
use IPS\Helpers\Form\Select;
use IPS\Helpers\Form\TextArea;
use IPS\Helpers\Form\Upload;
use IPS\Helpers\Form\Url as FormUrl;
@@ -398,7 +401,12 @@ class Controller extends CoverPhotoController
}
Output::i()->sidebar['contextual'] .= $item->ui( 'sidebar' );
if( Application::appIsEnabled( 'cloud' ) )
{
Output::setCacheTime( CloudApplication::getCacheDateForPage( $item->mapped('updated'), ( ( $item::$application === 'forums' and $item->isArchived() ) ? 'archived' : 'content' ) ) );
}
/* Return */
return $item;
}
@@ -1470,7 +1478,26 @@ class Controller extends CoverPhotoController
}
if ( $values = $form->values() )
{
$report = $item->report( $values['report_message'], ( isset( $values['report_type'] ) ) ? $values['report_type'] : 0 );
$guestDetails = [];
if ( ! Member::loggedIn()->member_id and Settings::i()->report_capture_guest_details )
{
$guestDetails = [ 'name' => $values['report_guest_name'], 'email' => $values['report_guest_email'] ];
/* Has this guest already reported this? */
try
{
$index = Db::i()->select( '*', 'core_rc_index', [ 'class=? and content_id=?', \get_class( $item ), $item->$idColumn ] )->first();
$report = Db::i()->select( '*', 'core_rc_reports', [ 'rid=? and guest_email=?', $index['id'], $values['report_guest_email'] ] )->first();
Output::i()->error( 'report_err_already_reported', '2S136/11', 403, '' );
}
catch( \UnderflowException )
{
/* The query failed, so this is a new report */
}
}
$report = $item->report( $values['report_message'], ( isset( $values['report_type'] ) ) ? $values['report_type'] : 0, null, $guestDetails );
File::claimAttachments( "report-{$class::$application}-{$class::$module}-{$item->$idColumn}", $report->id );
if ( Request::i()->isAjax() )
{
@@ -3337,7 +3364,7 @@ class Controller extends CoverPhotoController
}
/* Show form */
$form = new Form( NULL, 'report_submit' );
$form = new Form( 'report_submit', 'report_submit' );
$form->class = 'ipsForm--vertical ipsForm--report';
$itemIdColumn = $class::$databaseColumnId;
$idColumn = $comment::$databaseColumnId;
@@ -3355,17 +3382,28 @@ class Controller extends CoverPhotoController
return;
}
catch( Exception $e ) { }
$options = array( Report::TYPE_MESSAGE => Member::loggedIn()->language()->addToStack('report_message_comment') );
foreach( Types::roots() as $type )
{
$options[ $type->id ] = $type->_title;
}
$form->add( new Radio( 'report_type', NULL, FALSE, array( 'options' => $options ) ) );
}
$form->add( new Editor( 'report_message', NULL, FALSE, array( 'app' => 'core', 'key' => 'Reports', 'autoSaveKey' => "report-{$class::$application}-{$class::$module}-{$item->$itemIdColumn}-{$comment->$idColumn}", 'minimize' => 'report_message_placeholder' ) ) );
$options = array( Report::TYPE_MESSAGE => Member::loggedIn()->language()->addToStack('report_message_comment') );
foreach( Types::roots() as $type )
{
$options[ $type->id ] = $type->_title;
}
if ( count( $options ) > 1 )
{
$form->add( new Select( 'report_type', null, false, ['options' => $options] ) );
}
if ( ! Member::loggedIn()->member_id and Settings::i()->report_capture_guest_details )
{
/* Guest details */
$form->add( new Text( 'report_guest_name', null, Settings::i()->report_guest_details_name_mandatory ) );
$form->add( new Email( 'report_guest_email', null, true ) );
}
$form->add( new Editor( 'report_message', null, (bool) Settings::i()->report_content_mandatory, array( 'app' => 'core', 'key' => 'Reports', 'autoSaveKey' => "report-{$class::$application}-{$class::$module}-{$item->$itemIdColumn}-{$comment->$idColumn}", 'minimize' => Settings::i()->report_content_mandatory ? 'report_message_placeholder_mandatory' : 'report_message_placeholder' ) ) );
if ( !Request::i()->isAjax() )
{
Member::loggedIn()->language()->words['report_message'] = Member::loggedIn()->language()->addToStack('report_message_fallback');
@@ -3378,7 +3416,26 @@ class Controller extends CoverPhotoController
if ( $values = $form->values() )
{
$report = $comment->report( $values['report_message'], ( isset( $values['report_type'] ) ) ? $values['report_type'] : 0 );
$guestDetails = [];
if ( ! Member::loggedIn()->member_id and Settings::i()->report_capture_guest_details )
{
$guestDetails = [ 'name' => $values['report_guest_name'], 'email' => $values['report_guest_email'] ];
/* Has this guest already reported this? */
try
{
$index = Db::i()->select( '*', 'core_rc_index', [ 'class=? and content_id=?', \get_class( $comment ), $comment->$idColumn ] )->first();
$report = Db::i()->select( '*', 'core_rc_reports', [ 'rid=? and guest_email=?', $index['id'], $values['report_guest_email'] ] )->first();
Output::i()->error( 'report_err_already_reported', '2S136/11', 403, '' );
}
catch( \UnderflowException )
{
/* The query failed, so this is a new report */
}
}
$report = $comment->report( $values['report_message'], ( isset( $values['report_type'] ) ) ? $values['report_type'] : 0, null, $guestDetails );
File::claimAttachments( "report-{$class::$application}-{$class::$module}-{$item->$itemIdColumn}-{$comment->$idColumn}", $report->id );
if ( Request::i()->isAjax() )
{