Files
luos/workflow/engine/methods/setup/cronAjax.php

65 lines
1.9 KiB
PHP
Raw Normal View History

<?php
2018-08-20 14:40:30 -04:00
use ProcessMaker\BusinessModel\Files\Cron;
2023-03-24 17:55:53 +00:00
use ProcessMaker\Exception\RBACException;
// Include global object RBAC
global $RBAC;
// Check if the current user have the correct permissions to access to this resource, if not throws a RBAC Exception with code 403
if ($RBAC->userCanAccess('PM_SETUP') !== 1 || $RBAC->userCanAccess('PM_SETUP_LOGS') !== 1) {
throw new RBACException('ID_ACCESS_DENIED', 403);
}
2018-08-20 14:40:30 -04:00
$option = isset($_REQUEST["option"]) ? $_REQUEST["option"] : null;
2018-08-20 14:40:30 -04:00
$response = [];
switch ($option) {
case "LST":
$pageSize = $_REQUEST["pageSize"];
2017-10-10 12:33:25 -04:00
$workspace = config("system.workspace");
$status = $_REQUEST["status"];
$dateFrom = $_REQUEST["dateFrom"];
$dateTo = $_REQUEST["dateTo"];
2018-08-20 14:40:30 -04:00
$filter = [
"workspace" => $workspace,
"status" => $status,
"dateFrom" => str_replace("T00:00:00", null, $dateFrom),
"dateTo" => str_replace("T00:00:00", null, $dateTo)
];
2018-08-20 14:40:30 -04:00
$start = (int) isset($_REQUEST["start"]) ? $_REQUEST["start"] : 0;
$limit = (int) isset($_REQUEST["limit"]) ? $_REQUEST["limit"] : $pageSize;
2018-08-20 14:40:30 -04:00
$cron = new Cron();
list ($count, $data) = $cron->getData($filter, $start, $limit);
2018-08-20 14:40:30 -04:00
$response = [
"success" => true,
"resultTotal" => $count,
"resultRoot" => $data
];
break;
case "EMPTY":
$status = 1;
try {
$file = PATH_DATA . "log" . PATH_SEP . "cron.log";
2018-08-20 14:40:30 -04:00
if (file_exists($file)) {
unlink($file);
}
$response["status"] = "OK";
G::auditLog("ClearCron");
} catch (Exception $e) {
$response["message"] = $e->getMessage();
$status = 0;
}
if ($status == 0) {
$response["status"] = "ERROR";
}
break;
}
2018-08-20 14:40:30 -04:00
echo G::json_encode($response);