Files
XenForoRomhackPlazaAddon/Api/Controller/ThreadController.php
2026-06-08 16:25:52 +02:00

33 lines
884 B
PHP

<?php
namespace RomhackPlaza\Master\Api\Controller;
use XF\Api\Controller\AbstractController;
use XF\ControllerPlugin\UndeletePlugin;
use XF\Entity\Thread;
use XF\Mvc\ParameterBag;
class ThreadController extends AbstractController
{
public function actionPost(ParameterBag $params)
{
$this->assertApiScope('thread:write');
/** @var Thread $thread */
$thread = $this->assertRecordExists('XF:Thread', $params->thread_id, ['FirstPost'] );
if( $thread->discussion_state !== 'deleted' )
return $this->error("This thread is not deleted.", 'not_deleted' );
if(!$thread->canUndelete($error)){
return $this->noPermission($error);
}
$thread->discussion_state = 'visible';
$thread->save();
return $this->apiSuccess([
'thread' => $thread->toApiResult()
]);
}
}