From 2b18830b830e14b38aed57d024bfcac76565802d Mon Sep 17 00:00:00 2001 From: Daniel Tartavel Date: Mon, 13 Jun 2022 19:23:22 +0200 Subject: [PATCH] ajout des commmandes enable/disable hooks --- apiserver/apiserver.php | 8 ++++++-- apiserver/cmd_functions.php | 20 ++++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/apiserver/apiserver.php b/apiserver/apiserver.php index e6c6787..3f0c3a7 100644 --- a/apiserver/apiserver.php +++ b/apiserver/apiserver.php @@ -119,9 +119,13 @@ function apiServer($read) case "type": logger(DEBUG, $command . _(" reached"), __FILE__ . ":" . __LINE__); //htmlSend($spawn, apiDisplayByType($argList)); - /*case "stats": + case "enable": logger(DEBUG, $command . _(" reached"), __FILE__ . ":" . __LINE__); - displayStats($spawn, $argList);*/ + htmlSend($spawn, apiHookActive($argList, true)); + break; + case "disable": + logger(DEBUG, $command . _(" reached"), __FILE__ . ":" . __LINE__); + htmlSend($spawn, apiHookActive($argList, false)); break; case "verbose": logger(DEBUG, $command . _(" reached"), __FILE__ . ":" . __LINE__); diff --git a/apiserver/cmd_functions.php b/apiserver/cmd_functions.php index fe4623c..5bccbfa 100644 --- a/apiserver/cmd_functions.php +++ b/apiserver/cmd_functions.php @@ -507,6 +507,26 @@ function PropertiesDashboard($argList) } return "json=" . $response; } + +function apiHookActive($argList, $status) +{ + global $hooks; + if (array_key_exists($argList["hook"], $hooks)) + { + $hooks[$argList["hook"]]->active = $status; + if ($status) + { + return $argList["hook"] . _(" has been enabled"); + }else + { + return $argList["hook"] . _(" has been disabled"); + } + }else + { + return _("Hook does not exists"); + } + +} /* function apiDisplayByType($argList) {