diff --git a/Admin/Install/Navigation.install.json b/Admin/Install/Navigation.install.json
index c921fde..9dea4bc 100755
--- a/Admin/Install/Navigation.install.json
+++ b/Admin/Install/Navigation.install.json
@@ -139,8 +139,38 @@
"pid": "/admin/module",
"type": 3,
"subtype": 1,
+ "name": "Info",
+ "uri": "{/prefix}admin/module/info?{?}",
+ "target": "self",
+ "icon": null,
+ "order": 4,
+ "from": "Admin",
+ "permission": { "permission": 2, "type": null, "element": null },
+ "parent": 1000105001,
+ "children": []
+ },
+ {
+ "id": 1000105201,
+ "pid": "/admin/module",
+ "type": 3,
+ "subtype": 1,
"name": "Settings",
- "uri": "{/prefix}admin/module/setting?{?}",
+ "uri": "{/prefix}admin/module/settings?{?}",
+ "target": "self",
+ "icon": null,
+ "order": 4,
+ "from": "Admin",
+ "permission": { "permission": 2, "type": null, "element": null },
+ "parent": 1000105001,
+ "children": []
+ },
+ {
+ "id": 1000105301,
+ "pid": "/admin/module",
+ "type": 3,
+ "subtype": 1,
+ "name": "Log",
+ "uri": "{/prefix}admin/module/log?{?}",
"target": "self",
"icon": null,
"order": 4,
diff --git a/Admin/Routes/Web/Backend.php b/Admin/Routes/Web/Backend.php
index b77eff0..ebcd2bb 100755
--- a/Admin/Routes/Web/Backend.php
+++ b/Admin/Routes/Web/Backend.php
@@ -103,9 +103,31 @@ return [
],
],
],
+ '^.*/admin/module/info\?.*$' => [
+ [
+ 'dest' => '\Modules\Admin\Controller\BackendController:viewModuleInfo',
+ 'verb' => RouteVerb::GET,
+ 'permission' => [
+ 'module' => BackendController::MODULE_NAME,
+ 'type' => PermissionType::READ,
+ 'state' => PermissionState::MODULE,
+ ],
+ ],
+ ],
'^.*/admin/module/settings\?.*$' => [
[
- 'dest' => '\Modules\Admin\Controller\BackendController:viewModuleProfile',
+ 'dest' => '\Modules\Admin\Controller\BackendController:viewModuleSettings',
+ 'verb' => RouteVerb::GET,
+ 'permission' => [
+ 'module' => BackendController::MODULE_NAME,
+ 'type' => PermissionType::READ,
+ 'state' => PermissionState::MODULE,
+ ],
+ ],
+ ],
+ '^.*/admin/module/log\?.*$' => [
+ [
+ 'dest' => '\Modules\Admin\Controller\BackendController:viewModuleLog',
'verb' => RouteVerb::GET,
'permission' => [
'module' => BackendController::MODULE_NAME,
diff --git a/Controller/ApiController.php b/Controller/ApiController.php
index 3acb76f..9e048b3 100755
--- a/Controller/ApiController.php
+++ b/Controller/ApiController.php
@@ -838,6 +838,17 @@ final class ApiController extends Controller
$this->fillJsonResponse($request, $response, NotificationLevel::OK, 'Account', 'Account successfully created. Link: Account', $account);
}
+ /**
+ * Create directory for an account
+ *
+ * @param int $id Account id
+ * @param string $name Name of the directory/account
+ * @param int $createdBy Creator of the directory
+ *
+ * @return Collection
+ *
+ * @since 1.0.0
+ */
private function createMediaDirForAccount(int $id, string $name, int $createdBy) : Collection
{
$collection = new Collection();
diff --git a/Controller/BackendController.php b/Controller/BackendController.php
index 97574a8..b2dcd4d 100755
--- a/Controller/BackendController.php
+++ b/Controller/BackendController.php
@@ -15,6 +15,7 @@ declare(strict_types=1);
namespace Modules\Admin\Controller;
use Model\SettingMapper;
+use Model\NullSetting;
use Model\SettingsEnum;
use Modules\Admin\Models\AccountMapper;
use Modules\Admin\Models\AccountPermissionMapper;
@@ -361,10 +362,11 @@ final class BackendController extends Controller
*
* @since 1.0.0
*/
- public function viewModuleProfile(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface
+ public function viewModuleInfo(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface
{
$view = new View($this->app->l11nManager, $request, $response);
- $view->setTemplate('/Modules/Admin/Theme/Backend/modules-single');
+ $view->setTemplate('/Modules/Admin/Theme/Backend/modules-info');
+ $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1000105001, $request, $response));
$id = $request->getData('id') ?? '';
$view->setData('modules', $this->app->moduleManager->getAllModules());
@@ -372,21 +374,58 @@ final class BackendController extends Controller
$view->setData('installed', $installed = $this->app->moduleManager->getInstalledModules());
$view->setData('id', $id);
- $path = \realpath(__DIR__ . '/../' . $id . '/info.json');
-
- if (isset($installed[$id]) && $path !== false) {
- $info = new ModuleInfo($path);
- $info->load();
-
- $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(
- $info->getId(),
- $request, $response
- ));
- }
-
$groupPermission = GroupMapper::getPermissionForModule($id);
$view->setData('groupPermissions', $groupPermission);
+ return $view;
+ }
+
+ /**
+ * Method which generates the module profile view.
+ *
+ * @param RequestAbstract $request Request
+ * @param ResponseAbstract $response Response
+ * @param mixed $data Generic data
+ *
+ * @return RenderableInterface Response can be rendered
+ *
+ * @since 1.0.0
+ */
+ public function viewModuleSettings(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface
+ {
+ $view = new View($this->app->l11nManager, $request, $response);
+ $view->setTemplate('/Modules/Admin/Theme/Backend/modules-settings');
+ $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1000105001, $request, $response));
+
+ $id = $request->getData('id') ?? '';
+
+ $settings = SettingMapper::getFor($id, 'module');
+ if (!($settings instanceof NullSetting)) {
+ $view->setData('settings', !\is_array($settings) ? [$settings] : $settings);
+ }
+
+ return $view;
+ }
+
+ /**
+ * Method which generates the module profile view.
+ *
+ * @param RequestAbstract $request Request
+ * @param ResponseAbstract $response Response
+ * @param mixed $data Generic data
+ *
+ * @return RenderableInterface Response can be rendered
+ *
+ * @since 1.0.0
+ */
+ public function viewModuleLog(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface
+ {
+ $view = new View($this->app->l11nManager, $request, $response);
+ $view->setTemplate('/Modules/Admin/Theme/Backend/modules-log');
+ $view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1000105001, $request, $response));
+
+ $id = $request->getData('id') ?? '';
+
// audit log
if ($request->getData('ptype') === 'p') {
$view->setData('auditlogs', AuditMapper::with('module', (string) $request->getData('id'), [Audit::class])::getBeforePivot((int) $request->getData('audit'), null, 25));
diff --git a/Theme/Backend/Lang/Navigation.en.lang.php b/Theme/Backend/Lang/Navigation.en.lang.php
index 581c2e7..cc63fac 100755
--- a/Theme/Backend/Lang/Navigation.en.lang.php
+++ b/Theme/Backend/Lang/Navigation.en.lang.php
@@ -22,6 +22,9 @@ return [
'List' => 'List',
'Members' => 'Members',
'Modules' => 'Modules',
+ 'Settings' => 'Settings',
+ 'Log' => 'Log',
+ 'Info' => 'Info',
'Account' => 'Account',
'Accounts' => 'Accounts',
],
diff --git a/Theme/Backend/modules-info.tpl.php b/Theme/Backend/modules-info.tpl.php
new file mode 100644
index 0000000..3697efe
--- /dev/null
+++ b/Theme/Backend/modules-info.tpl.php
@@ -0,0 +1,125 @@
+getData('modules');
+$active = $this->getData('active');
+$installed = $this->getData('installed');
+$id = $this->getData('id');
+
+echo $this->getData('nav')->render();
+?>
+
+
+
+
+
= $this->printHtml($modules[$id]->getExternalName()); ?>
+
+
+
+
+
+ | = $this->getHtml('Name'); ?>
+ | = $this->printHtml($modules[$id]->getExternalName()); ?>
+ |
+ | = $this->getHtml('Version'); ?>
+ | = $this->printHtml($modules[$id]->getVersion()); ?>
+ |
+ | = $this->getHtml('CreatedBy'); ?>
+ | = $this->printHtml($modules[$id]->get()['creator']['name']); ?>
+ |
+ | = $this->getHtml('Website'); ?>
+ | = $this->printHtml($modules[$id]->get()['creator']['website']); ?>
+ |
+ | = $this->getHtml('Description'); ?>
+ | = $this->printHtml($modules[$id]->get()['description']); ?>
+ |
+
+
+
+
+
+
+
+
= $this->getHtml('Settings'); ?>
+
+
+
+
+
+
+
+
+
+
+ = $this->getHtml('Permissions'); ?>
+
+
+ | = $this->getHtml('ID', '0', '0'); ?>
+ | Type
+ | = $this->getHtml('Name'); ?>
+ |
+ getData('groupPermissions');
+ foreach ($groupPermissions as $key => $value) : ++$c;
+ $url = UriFactory::build('{/prefix}admin/group/settings?{?}&id=' . $value->getId()); ?>
+
+ |
+ | Group
+ | = $value->name; ?>
+
+
+ |
| = $this->getHtml('Empty', '0', '0'); ?>
+
+ |
+
+
+
diff --git a/Theme/Backend/modules-log.tpl.php b/Theme/Backend/modules-log.tpl.php
new file mode 100644
index 0000000..6a7b01f
--- /dev/null
+++ b/Theme/Backend/modules-log.tpl.php
@@ -0,0 +1,78 @@
+getData('auditlogs') ?? [];
+
+$previous = empty($audits) ? HttpHeader::getAllHeaders()['Referer'] ?? '{/prefix}admin/module/settings?id={?id}#{\#}' : '{/prefix}admin/module/settings?{?}&audit=' . \reset($audits)->getId() . '&ptype=p#{\#}';
+$next = empty($audits) ? HttpHeader::getAllHeaders()['Referer'] ?? '{/prefix}admin/module/settings?id={?id}#{\#}' : '{/prefix}admin/module/settings?{?}&audit=' . \end($audits)->getId() . '&ptype=n#{\#}';
+
+echo $this->getData('nav')->render();
+?>
+
+
+
+
+
= $this->getHtml('Audits', 'Auditor'); ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+ | = $this->getHtml('ID', '0', '0'); ?>
+ | = $this->getHtml('Module', 'Auditor'); ?>
+ | = $this->getHtml('Type', 'Auditor'); ?>
+ | = $this->getHtml('Trigger', 'Auditor'); ?>
+ | = $this->getHtml('Content', 'Auditor'); ?>
+ | = $this->getHtml('By', 'Auditor'); ?>
+ | = $this->getHtml('Ref', 'Auditor'); ?>
+ | = $this->getHtml('Date', 'Auditor'); ?>
+ |
+ $audit) : ++$count;
+ $url = UriFactory::build('{/prefix}admin/audit/single?{?}&id=' . $audit->getId()); ?>
+
+ | = $audit->getId(); ?>
+ | = $this->printHtml($audit->getModule()); ?>
+ | = $audit->getType(); ?>
+ | = $this->printHtml($audit->getTrigger()); ?>
+ | = $this->printHtml($audit->getContent()); ?>
+ | = $this->printHtml($audit->createdBy->login); ?>
+ | = $this->printHtml($audit->getRef()); ?>
+ | = $audit->createdAt->format('Y-m-d H:i'); ?>
+
+
+ |
| = $this->getHtml('Empty', '0', '0'); ?>
+
+ |
+
+
+
+
diff --git a/Theme/Backend/modules-settings.tpl.php b/Theme/Backend/modules-settings.tpl.php
index e69de29..9cfdaca 100755
--- a/Theme/Backend/modules-settings.tpl.php
+++ b/Theme/Backend/modules-settings.tpl.php
@@ -0,0 +1,115 @@
+getData('settings') ?? [];
+
+echo $this->getData('nav')->render();
+?>
+
+
+
+
+
+
+
+
+
request->uri->fragment === 'c-tab-2' ? ' checked' : ''; ?>>
+
+
+
+
+
= $this->getHtml('Settings'); ?>
+
+
+
+
+
+
+
+
diff --git a/Theme/Backend/modules-single.tpl.php b/Theme/Backend/modules-single.tpl.php
deleted file mode 100755
index b7f7cd0..0000000
--- a/Theme/Backend/modules-single.tpl.php
+++ /dev/null
@@ -1,198 +0,0 @@
-getData('modules');
-$active = $this->getData('active');
-$installed = $this->getData('installed');
-$id = $this->getData('id');
-$audits = $this->getData('auditlogs') ?? [];
-
-$nav = $this->getData('nav');
-
-$previous = empty($audits) ? HttpHeader::getAllHeaders()['Referer'] ?? '{/prefix}admin/module/settings?id={?id}#{\#}' : '{/prefix}admin/module/settings?{?}&audit=' . \reset($audits)->getId() . '&ptype=p#{\#}';
-$next = empty($audits) ? HttpHeader::getAllHeaders()['Referer'] ?? '{/prefix}admin/module/settings?id={?id}#{\#}' : '{/prefix}admin/module/settings?{?}&audit=' . \end($audits)->getId() . '&ptype=n#{\#}';
-
-if ($nav !== null) {
- echo $this->getData('nav')->render();
-}
-?>
-
-
-
-
-
-
-
-
-
request->uri->fragment === 'c-tab-1' ? ' checked' : ''; ?>>
-
-
-
-
-
= $this->printHtml($modules[$id]->getExternalName()); ?>
-
-
-
-
-
- | = $this->getHtml('Name'); ?>
- | = $this->printHtml($modules[$id]->getExternalName()); ?>
- |
- | = $this->getHtml('Version'); ?>
- | = $this->printHtml($modules[$id]->getVersion()); ?>
- |
- | = $this->getHtml('CreatedBy'); ?>
- | = $this->printHtml($modules[$id]->get()['creator']['name']); ?>
- |
- | = $this->getHtml('Website'); ?>
- | = $this->printHtml($modules[$id]->get()['creator']['website']); ?>
- |
- | = $this->getHtml('Description'); ?>
- | = $this->printHtml($modules[$id]->get()['description']); ?>
- |
-
-
-
-
-
-
-
-
= $this->getHtml('Settings'); ?>
-
-
-
-
-
-
-
-
-
-
- = $this->getHtml('Permissions'); ?>
-
-
- | = $this->getHtml('ID', '0', '0'); ?>
- | Type
- | = $this->getHtml('Name'); ?>
- |
- getData('groupPermissions');
- foreach ($groupPermissions as $key => $value) : ++$c;
- $url = UriFactory::build('{/prefix}admin/group/settings?{?}&id=' . $value->getId()); ?>
-
- |
- | Group
- | = $value->name; ?>
-
-
- |
| = $this->getHtml('Empty', '0', '0'); ?>
-
- |
-
-
-
-
-
-
request->uri->fragment === 'c-tab-2' ? ' checked' : ''; ?>>
-
-
-
-
-
= $this->getHtml('Audits', 'Auditor'); ?>
-
-
-
-
-
-
-
-
-
-
-
-
-
- | = $this->getHtml('ID', '0', '0'); ?>
- | = $this->getHtml('Module', 'Auditor'); ?>
- | = $this->getHtml('Type', 'Auditor'); ?>
- | = $this->getHtml('Trigger', 'Auditor'); ?>
- | = $this->getHtml('Content', 'Auditor'); ?>
- | = $this->getHtml('By', 'Auditor'); ?>
- | = $this->getHtml('Ref', 'Auditor'); ?>
- | = $this->getHtml('Date', 'Auditor'); ?>
- |
- $audit) : ++$count;
- $url = UriFactory::build('{/prefix}admin/audit/single?{?}&id=' . $audit->getId()); ?>
-
- | = $audit->getId(); ?>
- | = $this->printHtml($audit->getModule()); ?>
- | = $audit->getType(); ?>
- | = $this->printHtml($audit->getTrigger()); ?>
- | = $this->printHtml($audit->getContent()); ?>
- | = $this->printHtml($audit->createdBy->login); ?>
- | = $this->printHtml($audit->getRef()); ?>
- | = $audit->createdAt->format('Y-m-d H:i'); ?>
-
-
- |
| = $this->getHtml('Empty', '0', '0'); ?>
-
- |
-
-
-
-
-
-
-
diff --git a/tests/Controller/ApiControllerTest.php b/tests/Controller/ApiControllerTest.php
index 6ef496c..36f1ce2 100755
--- a/tests/Controller/ApiControllerTest.php
+++ b/tests/Controller/ApiControllerTest.php
@@ -47,6 +47,9 @@ class ApiControllerTest extends \PHPUnit\Framework\TestCase
*/
protected ModuleAbstract $module;
+ /**
+ * {@inheritdoc}
+ */
protected function setUp() : void
{
$this->app = new class() extends ApplicationAbstract
diff --git a/tests/Models/ModuleTest.php b/tests/Models/ModuleTest.php
index c6eace2..ba6f170 100755
--- a/tests/Models/ModuleTest.php
+++ b/tests/Models/ModuleTest.php
@@ -26,6 +26,9 @@ class ModuleTest extends \PHPUnit\Framework\TestCase
{
protected Module $module;
+ /**
+ * {@inheritdoc}
+ */
protected function setUp() : void
{
$this->module = new Module();