| Server IP : 35.236.43.222 / Your IP : 216.73.216.143 Web Server : Apache System : Linux order-form-vm-001 5.10.0-37-cloud-amd64 #1 SMP Debian 5.10.247-1 (2025-12-11) x86_64 User : deploy ( 1002) PHP Version : 8.1.31 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/ravel.network/public/wp-content/plugins/independent-analytics/IAWP/AJAX/ |
Upload File : |
<?php
namespace IAWP\AJAX;
use IAWP\Illuminate_Builder;
use IAWP\Query;
use IAWP\Report_Finder;
/** @internal */
class Delete_Report extends \IAWP\AJAX\AJAX
{
/**
* @return array
*/
protected function action_required_fields() : array
{
return ['id'];
}
/**
* @return string
*/
protected function action_name() : string
{
return 'iawp_delete_report';
}
/**
* @return void
*/
protected function action_callback() : void
{
$reports_table = Query::get_table_name(Query::REPORTS);
$existing_report = Illuminate_Builder::new()->from($reports_table)->where('report_id', '=', $this->get_field('id'))->first();
if (\is_null($existing_report)) {
\wp_send_json_error();
}
$report_finder = Report_Finder::new();
$reports = $report_finder->get_saved_reports_for_type($existing_report->type);
$report_index = 0;
foreach ($reports as $index => $report) {
if ($report->id() === $existing_report->report_id) {
$report_index = $index;
}
}
if (\array_key_exists($report_index + 1, $reports)) {
$report = $reports[$report_index + 1];
} elseif ($report_index > 0 && \array_key_exists($report_index - 1, $reports)) {
$report = $reports[$report_index - 1];
}
Illuminate_Builder::new()->from($reports_table)->where('report_id', '=', $this->get_field('id'))->delete();
\wp_send_json_success(['url' => $report->url()]);
}
}