mirror of
https://github.com/Karaka-Management/oms-Admin.git
synced 2026-01-11 13:38:39 +00:00
bug fixes
This commit is contained in:
parent
7da35d00d5
commit
fc7fc8055c
|
|
@ -66,6 +66,12 @@ use phpOMS\Utils\Parser\Markdown\Markdown;
|
|||
use phpOMS\Utils\StringUtils;
|
||||
use phpOMS\Validation\Network\Email as EmailValidator;
|
||||
use phpOMS\Version\Version;
|
||||
use phpOMS\Application\ApplicationInfo;
|
||||
use phpOMS\Module\ModuleInfo;
|
||||
use Modules\Admin\Models\Module;
|
||||
use phpOMS\DataStorage\Database\Query\Builder;
|
||||
use phpOMS\Message\Http\HttpResponse;
|
||||
use phpOMS\Module\ModuleStatus;
|
||||
|
||||
/**
|
||||
* Admin controller class.
|
||||
|
|
@ -490,11 +496,11 @@ final class ApiController extends Controller
|
|||
return;
|
||||
}
|
||||
|
||||
$info = new ApplicationInfo(__DIR__ . '/../../../' . $app);
|
||||
$info->load();
|
||||
$appInfo = new ApplicationInfo(__DIR__ . '/../../../' . $app . '/info.json');
|
||||
$appInfo->load();
|
||||
|
||||
// handle dependencies
|
||||
$dependencies = $info->getDependencies();
|
||||
$dependencies = $appInfo->getDependencies();
|
||||
$installed = $this->app->moduleManager->getInstalledModules();
|
||||
|
||||
foreach ($dependencies as $key => $version) {
|
||||
|
|
@ -512,7 +518,7 @@ final class ApiController extends Controller
|
|||
|
||||
// handle providing
|
||||
if ($result) {
|
||||
$providing = $info->getProviding();
|
||||
$providing = $appInfo->getProviding();
|
||||
|
||||
foreach ($providing as $key => $version) {
|
||||
if (isset($installed[$key])) {
|
||||
|
|
@ -520,6 +526,17 @@ final class ApiController extends Controller
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// handle Routes of already installed modules
|
||||
// @todo: what about navigation links, works for Api and Backend but only since the Navigation module is installed afterwards. Other applications don't have this and would not have the links?
|
||||
foreach ($installed as $module => $data) {
|
||||
$class = '\Modules\\' . $module . '\Admin\Installer';
|
||||
|
||||
$moduleInfo = new ModuleInfo(__DIR__ . '/../../../Modules/' . $module . '/info.json');
|
||||
$moduleInfo->load();
|
||||
|
||||
$class::reInit($moduleInfo, $appInfo);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -667,7 +684,7 @@ final class ApiController extends Controller
|
|||
*/
|
||||
public function apiGroupDelete(RequestAbstract $request, ResponseAbstract $response, $data = null) : void
|
||||
{
|
||||
if (((int) $request->getId('id')) === 3) {
|
||||
if (((int) $request->getData('id')) === 3) {
|
||||
// admin group cannot be deleted
|
||||
$this->fillJsonResponse($request, $response, NotificationLevel::ERROR, 'Group', 'Admin group cannot be deleted', []);
|
||||
|
||||
|
|
@ -1063,9 +1080,66 @@ final class ApiController extends Controller
|
|||
|
||||
break;
|
||||
case ModuleStatusUpdateType::INSTALL:
|
||||
$done = $module === 'Admin' ? false : $this->app->moduleManager->install($module);
|
||||
$done = $this->app->moduleManager->isInstalled($module) ? true : false;
|
||||
$msg = $done ? 'Module successfully installed.' : 'Module not installed.';
|
||||
|
||||
if ($done) {
|
||||
break;
|
||||
}
|
||||
|
||||
$moduleInfo = new ModuleInfo(__DIR__ . '/../../../Modules/' . $module . '/info.json');
|
||||
$moduleInfo->load();
|
||||
|
||||
// install dependencies
|
||||
$dependencies = $moduleInfo->getDependencies();
|
||||
foreach ($dependencies as $key => $version) {
|
||||
$iResponse = new HttpResponse();
|
||||
$iRequest = new HttpRequest(new HttpUri(''));
|
||||
$iRequest->header->account = 1;
|
||||
$iRequest->setData('status', ModuleStatusUpdateType::INSTALL);
|
||||
|
||||
$iRequest->setData('module', $key, true);
|
||||
$this->apiModuleStatusUpdate($iRequest, $iResponse);
|
||||
}
|
||||
|
||||
// install module
|
||||
$moduleObj = new Module();
|
||||
$moduleObj->id = $module;
|
||||
$moduleObj->theme = 'Default';
|
||||
$moduleObj->path = $moduleInfo->getDirectory();
|
||||
$moduleObj->version = $moduleInfo->getVersion();
|
||||
|
||||
$moduleObj->setStatus(ModuleStatus::AVAILABLE);
|
||||
|
||||
ModuleMapper::create($moduleObj);
|
||||
|
||||
$done = $this->app->moduleManager->install($module);
|
||||
$msg = $done ? 'Module successfully installed.' : 'Module not installed.';
|
||||
|
||||
$moduleObj->setStatus(ModuleStatus::ACTIVE);
|
||||
ModuleMapper::update($moduleObj);
|
||||
|
||||
$queryLoad = new Builder($this->app->dbPool->get('insert'));
|
||||
$queryLoad->insert('module_load_pid', 'module_load_type', 'module_load_from', 'module_load_for', 'module_load_file')
|
||||
->into('module_load');
|
||||
|
||||
$load = $moduleInfo->getLoad();
|
||||
foreach ($load as $val) {
|
||||
foreach ($val['pid'] as $pid) {
|
||||
$queryLoad->values(
|
||||
\sha1(\str_replace('/', '', $pid)),
|
||||
(int) $val['type'],
|
||||
$val['from'],
|
||||
$val['for'],
|
||||
$val['file']
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($queryLoad->getValues())) {
|
||||
$queryLoad->execute();
|
||||
}
|
||||
|
||||
break;
|
||||
case ModuleStatusUpdateType::UNINSTALL:
|
||||
$done = $module === 'Admin' ? false : $this->app->moduleManager->uninstall($module);
|
||||
|
|
@ -1208,7 +1282,7 @@ final class ApiController extends Controller
|
|||
*/
|
||||
public function apiAddGroupPermission(RequestAbstract $request, ResponseAbstract $response, $data = null) : void
|
||||
{
|
||||
if (((int) $request->getId('permissionref')) === 3) {
|
||||
if (((int) $request->getData('permissionref')) === 3) {
|
||||
// admin group cannot be deleted
|
||||
$this->fillJsonResponse($request, $response, NotificationLevel::ERROR, 'Group', 'Admin group permissions cannot get modified', []);
|
||||
|
||||
|
|
|
|||
|
|
@ -57,4 +57,16 @@ class App
|
|||
* @since 1.0.0
|
||||
*/
|
||||
public int $status = ApplicationStatus::NORMAL;
|
||||
|
||||
/**
|
||||
* Get id
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getId() : int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
}
|
||||
|
|
@ -33,7 +33,7 @@ class Module
|
|||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
protected string $id = '';
|
||||
public string $id = '';
|
||||
|
||||
/**
|
||||
* Module name.
|
||||
|
|
@ -44,12 +44,28 @@ class Module
|
|||
public string $name = '';
|
||||
|
||||
/**
|
||||
* Module description.
|
||||
* Module path.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public string $description = '';
|
||||
public string $path = '';
|
||||
|
||||
/**
|
||||
* Module version.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public string $version = '';
|
||||
|
||||
/**
|
||||
* Module theme.
|
||||
*
|
||||
* @var string
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public string $theme = '';
|
||||
|
||||
/**
|
||||
* Group status.
|
||||
|
|
@ -147,8 +163,9 @@ class Module
|
|||
return [
|
||||
'id' => $this->id,
|
||||
'name' => $this->name,
|
||||
'path' => $this->path,
|
||||
'version' => $this->version,
|
||||
'status' => $this->status,
|
||||
'description' => $this->description,
|
||||
'createdAt' => $this->createdAt,
|
||||
];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,10 @@ final class ModuleMapper extends DataMapperAbstract
|
|||
*/
|
||||
protected static array $columns = [
|
||||
'module_id' => ['name' => 'module_id', 'type' => 'string', 'internal' => 'id'],
|
||||
'module_active' => ['name' => 'module_active', 'type' => 'int', 'internal' => 'status'],
|
||||
'module_path' => ['name' => 'module_path', 'type' => 'string', 'internal' => 'path'],
|
||||
'module_theme' => ['name' => 'module_theme', 'type' => 'string', 'internal' => 'theme'],
|
||||
'module_version' => ['name' => 'module_version', 'type' => 'string', 'internal' => 'version'],
|
||||
'module_status' => ['name' => 'module_status', 'type' => 'int', 'internal' => 'status'],
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
@ -52,4 +55,6 @@ final class ModuleMapper extends DataMapperAbstract
|
|||
* @since 1.0.0
|
||||
*/
|
||||
protected static string $primaryField = 'module_id';
|
||||
|
||||
protected static bool $autoincrement = false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user