Files
XenForoRomhackPlazaAddon/XF/Entity/ApprovalQueue.php

41 lines
1.3 KiB
PHP
Raw Permalink Normal View History

2026-06-16 16:21:43 +02:00
<?php
namespace RomhackPlaza\Master\XF\Entity;
use RomhackPlaza\Master\Helper\Helpers;
class ApprovalQueue extends XFCP_ApprovalQueue
{
protected function _postSave()
{
parent::_postSave();
if( $this->isInsert() ){
$contentId = $this->content_id;
$contentType = $this->content_type;
\XF::runLater(function () use ($contentId, $contentType) {
$entity = \XF::app()->getContentTypeFieldValue($contentType, 'entity');
if( !$entity ){
return;
}
$content = \XF::em()->find($entity, $contentId);
$user = $contentType === 'user' ? $content : $content->User;
$service = \XF::service('RomhackPlaza\Master:Discord\BotService');
$service->createAction( 'approval_queue', [
'content_title' => Helpers::getContentTitle( $content, $contentType ),
'approval_item_url' => \XF::app()->router('public')->buildLink('canonical:approval-queue' ),
'approval_username' => $user?->username ?? '',
'approval_user_url' => $user?->user_id ? \XF::app()->router('public')->buildLink('canonical:members', $user ) : '',
'content_type' => $contentType,
]);
});
}
}
}