Files
Romhack-Plaza---File-Server/src/Endpoints/Editorfilelist.php

65 lines
1.8 KiB
PHP
Raw Normal View History

2026-01-29 18:43:58 +01:00
<?php
namespace RomhackPlazaFS\Endpoints;
use RomhackPlazaFS\Library\Data;
2026-01-30 11:03:44 +01:00
use RomhackPlazaFS\Library\Log;
2026-01-29 18:43:58 +01:00
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
{
2026-01-30 11:03:44 +01:00
return true;
2026-01-29 18:43:58 +01:00
}
protected function require_token(): bool
{
2026-01-30 11:03:44 +01:00
return true;
2026-01-29 18:43:58 +01:00
}
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 );
2026-01-30 11:03:44 +01:00
new Log( __class__, "WP Id=" . $this->token_info['user_id'], $this->post_id, $this->custom_post_type );
2026-01-29 18:43:58 +01:00
RomhackPlazaFS::success_response( $response );
}
}