Version 5.0.13
This commit is contained in:
1 parent
b89858b2ff
commit
5efe744c5f
1407 files changed
+69690
-30177
No files matched your search
@@ -23,6 +23,7 @@ use IPS\core\Reports\Comment as ReportComment;
|
||||
use IPS\DateTime;
|
||||
use IPS\Db;
|
||||
use IPS\Email;
|
||||
use IPS\Events\Event;
|
||||
use IPS\Http\Url;
|
||||
use IPS\IPS;
|
||||
use IPS\Log;
|
||||
@@ -149,6 +150,8 @@ class Report extends Item
|
||||
*/
|
||||
public static bool $skipIndexNow = TRUE;
|
||||
|
||||
protected static array|bool $_bypassDataLayerEvents = true;
|
||||
|
||||
|
||||
/**
|
||||
* Get all the report types for this report index
|
||||
@@ -189,6 +192,9 @@ class Report extends Item
|
||||
$this->status = $status;
|
||||
$this->save();
|
||||
|
||||
/* Fire an event */
|
||||
Event::fire( 'onCreateOrEdit', $this, [ array(), false ] );
|
||||
|
||||
/* We only need to notify if there is an outcome */
|
||||
if ( $status == static::STATUS_CLOSED or static::STATUS_REJECTED )
|
||||
{
|
||||
@@ -311,6 +317,9 @@ class Report extends Item
|
||||
$comment = ReportComment::create( $this, $content, TRUE, NULL, NULL, $member, new DateTime );
|
||||
$comment->save();
|
||||
|
||||
/* And fire an event for the comment */
|
||||
Event::fire( 'onCreateOrEdit', $comment, [ array(), true ] );
|
||||
|
||||
/* And add to the moderator log */
|
||||
Session::i()->modLog( 'modlog__action_update_report_status', array( $this->url()->__toString() => FALSE ) );
|
||||
}
|
||||
@@ -908,8 +917,6 @@ class Report extends Item
|
||||
}
|
||||
}
|
||||
|
||||
$extensionWhereClause = '';
|
||||
|
||||
/* Skip this if we have global permissions */
|
||||
if( is_array( $perms ) and !$perms['can_view_reports'] )
|
||||
{
|
||||
@@ -1001,4 +1008,43 @@ class Report extends Item
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get output for API
|
||||
*
|
||||
* @param Member|NULL $authorizedMember The member making the API request or NULL for API Key / client_credentials
|
||||
* @param bool $includeItem Should the assigned item be attached to the response?
|
||||
* @return array
|
||||
* @apiresponse int id ID
|
||||
* @apiresponse int date Date of report
|
||||
* @apiresponse \IPS\Member reported_by Member who reported the item
|
||||
* @apiresponse string item_class Content Class
|
||||
* @apiresponse int item_id Content ID
|
||||
* @apiresponse [\IPS\Content\Item|\IPS\Content\Comment] content Content Object
|
||||
*/
|
||||
public function apiOutput( Member $authorizedMember = NULL ): array
|
||||
{
|
||||
$className = $this->class;
|
||||
try
|
||||
{
|
||||
$reportedContent = $className::load( $this->content_id );
|
||||
}
|
||||
catch ( OutOfRangeException $ex )
|
||||
{
|
||||
/* No content, no moderation, no cry */
|
||||
$reportedContent = FALSE;
|
||||
}
|
||||
|
||||
$response = [];
|
||||
$response['id'] = $this->id;
|
||||
$response['date'] = $this->mapped('date');
|
||||
$response['reported_by'] = $this->author()->apiOutput($authorizedMember);
|
||||
$response['item_class'] = $this->class;
|
||||
$response['item_id'] = $this->content_id;
|
||||
$response['content'] = $reportedContent ? $reportedContent->apiOutput($authorizedMember) : NULL;
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user