A lot of things.
This commit is contained in:
33
Api/Controller/ThreadController.php
Normal file
33
Api/Controller/ThreadController.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?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()
|
||||
]);
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user