65 lines
1.8 KiB
PHP
65 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace RomhackPlazaFS\Endpoints;
|
|
use RomhackPlazaFS\Library\Data;
|
|
use RomhackPlazaFS\Library\Log;
|
|
use RomhackPlazaFS\RomhackPlazaFS;
|
|
|
|
defined( 'ROMHACKPLAZA_FS' ) || exit;
|
|
|
|
class Editorfilelist extends Abstract_Endpoint {
|
|
|
|
private int $post_id;
|
|
private string $custom_post_type;
|
|
protected function private_endpoint(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
protected function require_token(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
protected function get_post_params(): void {
|
|
|
|
$this->post_id = $this->swiffer_post( "post_id", "int" );
|
|
if( $this->post_id < 1 )
|
|
RomhackPlazaFS::invalid_parameter_stop( "post_id", "POST" );
|
|
|
|
$this->custom_post_type = $this->swiffer_post( "post_type", "string" );
|
|
if( $this->custom_post_type === "" )
|
|
RomhackPlazaFS::invalid_parameter_stop( "post_type", "POST" );
|
|
|
|
}
|
|
|
|
protected function process(): void {
|
|
|
|
$data = Data::setup(
|
|
$this->custom_post_type,
|
|
$this->post_id
|
|
);
|
|
$private = Data::setup(
|
|
$this->custom_post_type,
|
|
$this->post_id,
|
|
flags: Data::F_PRIVATE_FILE
|
|
);
|
|
$archived = Data::setup(
|
|
$this->custom_post_type,
|
|
$this->post_id,
|
|
flags: Data::F_ARCHIVED_FILE
|
|
);
|
|
|
|
$response = [];
|
|
$response['files'] = $data->list_files( $this->custom_post_type, $this->post_id );
|
|
$response['private'] = $private->list_files( $this->custom_post_type, $this->post_id );
|
|
$response['archived'] = $archived->list_files( $this->custom_post_type, $this->post_id );
|
|
|
|
new Log( __class__, "WP Id=" . $this->token_info['user_id'], $this->post_id, $this->custom_post_type );
|
|
|
|
RomhackPlazaFS::success_response( $response );
|
|
|
|
}
|
|
|
|
|
|
} |