33 lines
884 B
PHP
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()
|
|
]);
|
|
|
|
}
|
|
} |