mirror of
https://github.com/Karaka-Management/oms-Admin.git
synced 2026-01-11 13:38:39 +00:00
move event forwarding from workflow to admin
This commit is contained in:
parent
c301b29a66
commit
d5fb81c723
19
Admin/Hooks/Web/Api.php
Normal file
19
Admin/Hooks/Web/Api.php
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
/**
|
||||
* Karaka
|
||||
*
|
||||
* PHP Version 8.0
|
||||
*
|
||||
* @package Modules\Admin
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://karaka.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
return [
|
||||
'/.*/' => [
|
||||
'callback' => ['\Modules\Admin\Controller\ApiController:cliEventCall'],
|
||||
],
|
||||
];
|
||||
|
|
@ -28,6 +28,8 @@ use phpOMS\Message\Mail\SubmitType;
|
|||
use phpOMS\Module\InstallerAbstract;
|
||||
use phpOMS\Module\ModuleInfo;
|
||||
use phpOMS\System\File\PathException;
|
||||
use phpOMS\System\OperatingSystem;
|
||||
use phpOMS\System\SystemType;
|
||||
|
||||
/**
|
||||
* Installer class.
|
||||
|
|
@ -83,9 +85,13 @@ final class Installer extends InstallerAbstract
|
|||
SettingMapper::create()->execute(new Setting(0, SettingsEnum::PASSWORD_HISTORY, '3', '\\d+'));
|
||||
SettingMapper::create()->execute(new Setting(0, SettingsEnum::LOGGING_STATUS, '1', '[0-3]'));
|
||||
SettingMapper::create()->execute(new Setting(0, SettingsEnum::LOGGING_PATH, ''));
|
||||
|
||||
SettingMapper::create()->execute(new Setting(0, SettingsEnum::DEFAULT_ORGANIZATION, '1', '\\d+'));
|
||||
|
||||
SettingMapper::create()->execute(new Setting(0, SettingsEnum::LOGIN_STATUS, '1', '[0-3]'));
|
||||
|
||||
SettingMapper::create()->execute(new Setting(0, SettingsEnum::DEFAULT_LOCALIZATION, '1', '\\d+'));
|
||||
|
||||
SettingMapper::create()->execute(new Setting(0, SettingsEnum::MAIL_SERVER_ADDR, 'admin@karaka.email', "(?:[a-z0-9!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+\/=?^_`{|}~-]+)*|\"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*\")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9]))\.){3}(?:(2(5[0-5]|[0-4][0-9])|1[0-9][0-9]|[1-9]?[0-9])|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])", module: 'Admin'));
|
||||
SettingMapper::create()->execute(new Setting(0, SettingsEnum::MAIL_SERVER_TYPE, SubmitType::MAIL, module: 'Admin'));
|
||||
SettingMapper::create()->execute(new Setting(0, SettingsEnum::MAIL_SERVER_USER, '', module: 'Admin'));
|
||||
|
|
@ -95,6 +101,21 @@ final class Installer extends InstallerAbstract
|
|||
SettingMapper::create()->execute(new Setting(0, SettingsEnum::MAIL_SERVER_KEYPASS, '', module: 'Admin'));
|
||||
SettingMapper::create()->execute(new Setting(0, SettingsEnum::MAIL_SERVER_TLS, (string) false, module: 'Admin'));
|
||||
|
||||
SettingMapper::create()->execute(
|
||||
new Setting(
|
||||
0,
|
||||
SettingsEnum::CLI_ACTIVE,
|
||||
(string) (
|
||||
\stripos(\shell_exec(
|
||||
(OperatingSystem::getSystem() === SystemType::WIN
|
||||
? 'php.exe'
|
||||
: 'php'
|
||||
) .' cli.php -v'
|
||||
), 'Version:') !== false
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$l11n = Localization::fromLanguage('en');
|
||||
LocalizationMapper::create()->execute($l11n);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
use phpOMS\Router\RouteVerb;
|
||||
|
||||
return [
|
||||
'^$' => [
|
||||
'^/* .*?$' => [
|
||||
[
|
||||
'dest' => '\Modules\Admin\Controller\CliController:viewEmptyCommand',
|
||||
'verb' => RouteVerb::ANY,
|
||||
|
|
|
|||
|
|
@ -64,6 +64,8 @@ use phpOMS\Module\ModuleInfo;
|
|||
use phpOMS\Module\ModuleStatus;
|
||||
use phpOMS\System\File\Local\File;
|
||||
use phpOMS\System\MimeType;
|
||||
use phpOMS\System\OperatingSystem;
|
||||
use phpOMS\System\SystemType;
|
||||
use phpOMS\System\SystemUtils;
|
||||
use phpOMS\Uri\HttpUri;
|
||||
use phpOMS\Uri\UriFactory;
|
||||
|
|
@ -1972,4 +1974,36 @@ final class ApiController extends Controller
|
|||
private function runUpdate(string $updateFile) : void
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Api method to make a call to the cli app
|
||||
*
|
||||
* @param mixed $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function cliEventCall(...$data) : void
|
||||
{
|
||||
$cliEventHandling = (bool) ($this->app->appSettings->get(null, SettingsEnum::CLI_ACTIVE)->content ?? false);
|
||||
|
||||
if ($cliEventHandling) {
|
||||
$count = \count($data);
|
||||
|
||||
SystemUtils::runProc(
|
||||
OperatingSystem::getSystem() === SystemType::WIN ? 'php.exe' : 'php',
|
||||
\escapeshellarg(\realpath(__DIR__ . '/../../../cli.php')) . ' '
|
||||
. 'post:/admin/event' . ' '
|
||||
. '-g ' . \escapeshellarg($data[$count - 2]) . ' '
|
||||
. '-i ' . \escapeshellarg($data[$count - 1]) . ' '
|
||||
. '-d ' . \escapeshellarg(\json_encode($data)),
|
||||
true
|
||||
);
|
||||
} else {
|
||||
$this->app->moduleManager->get('Workflow')->runWorkflowFromHook($data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,7 +49,12 @@ final class CliController extends Controller
|
|||
public function viewEmptyCommand(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface
|
||||
{
|
||||
$view = new View($this->app->l11nManager, $request, $response);
|
||||
$view->setTemplate('/Modules/Admin/Theme/Cli/empty-command');
|
||||
|
||||
if ($request->hasData('v')) {
|
||||
$view->setTemplate('/Modules/Admin/Theme/Cli/version-command');
|
||||
} else {
|
||||
$view->setTemplate('/Modules/Admin/Theme/Cli/empty-command');
|
||||
}
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
<?= 'Test output';
|
||||
<?= 'Use "get:/help/module/{module_name}" to get help for a specific installed module.';
|
||||
|
|
|
|||
1
Theme/Cli/version-command.tpl.php
Normal file
1
Theme/Cli/version-command.tpl.php
Normal file
|
|
@ -0,0 +1 @@
|
|||
<?= 'Version: 1.0.0';
|
||||
Loading…
Reference in New Issue
Block a user