improve audit logs

This commit is contained in:
Dennis Eichhorn 2020-07-31 00:04:39 +02:00
parent 721fca3579
commit e29fa51baa
10 changed files with 13 additions and 262 deletions

View File

@ -27,36 +27,6 @@
"permission": { "permission": 2, "type": null, "element": null },
"parent": 1006201001,
"children": []
},
{
"id": 1006203001,
"pid": "/admin/audit",
"type": 3,
"subtype": 1,
"name": "Modules",
"uri": "{/prefix}admin/audit/module/list",
"target": "self",
"icon": null,
"order": 5,
"from": "Auditor",
"permission": { "permission": 2, "type": null, "element": null },
"parent": 1006201001,
"children": []
},
{
"id": 1006204001,
"pid": "/admin/audit",
"type": 3,
"subtype": 1,
"name": "Accounts",
"uri": "{/prefix}admin/audit/account/list",
"target": "self",
"icon": null,
"order": 10,
"from": "Auditor",
"permission": { "permission": 2, "type": null, "element": null },
"parent": 1006201001,
"children": []
}
]
}

View File

@ -23,12 +23,12 @@
},
"auditor_audit_type": {
"name": "auditor_audit_type",
"type": "TINYINT",
"type": "INT",
"null": false
},
"auditor_audit_subtype": {
"name": "auditor_audit_subtype",
"type": "TINYINT",
"type": "INT",
"null": false
},
"auditor_audit_content": {

View File

@ -111,7 +111,7 @@ final class ApiController extends Controller
return;
}
$audit = new Audit(new NullAccount($account), $oldString, $newString, $type, $subtype, $module, $ref, $content, \ip2long($ip ?? '127.0.0.1'));
$audit = new Audit(new NullAccount($account), $oldString, $newString, $type, $subtype, $module, $ref, $content, \ip2long($ip ?? '127.0.0.1'));
AuditMapper::create($audit);
}

View File

@ -86,101 +86,4 @@ final class BackendController extends Controller
return $view;
}
/**
* Routing end-point for application behaviour.
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param mixed $data Generic data
*
* @return RenderableInterface
*
* @since 1.0.0
* @codeCoverageIgnore
*/
public function viewAuditorModuleList(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface
{
$view = new View($this->app->l11nManager, $request, $response);
$view->setTemplate('/Modules/Auditor/Theme/Backend/module-list');
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1006201001, $request, $response));
$list = $this->app->moduleManager->getAllModules();
$view->setData('modules', $list);
return $view;
}
/**
* Routing end-point for application behaviour.
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param mixed $data Generic data
*
* @return RenderableInterface
*
* @since 1.0.0
* @codeCoverageIgnore
*/
public function viewAuditorModuleSingle(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface
{
$view = new View($this->app->l11nManager, $request, $response);
$view->setTemplate('/Modules/Auditor/Theme/Backend/module-single');
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1006201001, $request, $response));
/** @var \Modules\Auditor\Models\Audit[] $list */
$list = AuditMapper::get(50);
$view->setData('audits', $list);
return $view;
}
/**
* Routing end-point for application behaviour.
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param mixed $data Generic data
*
* @return RenderableInterface
*
* @since 1.0.0
* @codeCoverageIgnore
*/
public function viewAuditorAccountList(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface
{
$view = new View($this->app->l11nManager, $request, $response);
$view->setTemplate('/Modules/Auditor/Theme/Backend/account-list');
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1006201001, $request, $response));
$view->setData('accounts', AccountMapper::getNewest(50, null, RelationType::NONE));
return $view;
}
/**
* Routing end-point for application behaviour.
*
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param mixed $data Generic data
*
* @return RenderableInterface
*
* @since 1.0.0
* @codeCoverageIgnore
*/
public function viewAuditorAccountSingle(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface
{
$view = new View($this->app->l11nManager, $request, $response);
$view->setTemplate('/Modules/Auditor/Theme/Backend/account-single');
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1006201001, $request, $response));
/** @var \Modules\Auditor\Models\Audit[] $list */
$list = AuditMapper::get(50);
$view->setData('audits', $list);
return $view;
}
}

View File

@ -1,48 +0,0 @@
<?php
/**
* Orange Management
*
* PHP Version 7.4
*
* @package Modules\Auditor
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
/**
* @var \phpOMS\Views\View $this
*/
$accounts = $this->getData('accounts');
echo $this->getData('nav')->render(); ?>
<div class="row">
<div class="col-xs-12">
<div class="box wf-100">
<table class="default">
<caption><?= $this->getHtml('Audits') ?><i class="fa fa-download floatRight download btn"></i></caption>
<thead>
<tr>
<td><?= $this->getHtml('ID', '0', '0'); ?>
<td class="wf-100"><?= $this->getHtml('Name') ?>
<td class="wf-100"><?= $this->getHtml('Email') ?>
<tbody>
<?php $count = 0; foreach ($accounts as $key => $account) : ++$count;
$url = \phpOMS\Uri\UriFactory::build('{/prefix}admin/audit/single?{?}&id=' . $account->getId()); ?>
<tr tabindex="0" data-href="<?= $url; ?>">
<td><?= $this->printHtml($account->getId()); ?>
<td><?= $this->printHtml(
\sprintf('%3$s %2$s %1$s', $account->getName1(), $account->getName2(), $account->getName3())
); ?>
<td><?= $this->printHtml($account->getEmail()); ?>
<?php endforeach; ?>
<?php if ($count === 0) : ?>
<tr><td colspan="2" class="empty"><?= $this->getHtml('Empty', '0', '0'); ?>
<?php endif; ?>
</table>
</div>
</div>
</div>

View File

@ -1,19 +0,0 @@
<?php
/**
* Orange Management
*
* PHP Version 7.4
*
* @package Modules\Auditor
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
/**
* @var \phpOMS\Views\View $this
*/
echo $this->getData('nav')->render();

View File

@ -33,7 +33,7 @@ echo $this->getData('nav')->render(); ?>
<colgroup>
<col style="width: 100px">
<col style="width: 150px">
<col style="width: 75px">
<col style="width: 100px">
<col style="width: 75px">
<col>
<col>

View File

@ -40,6 +40,15 @@ echo $this->getData('nav')->render();
<div class="portlet">
<div class="portlet-body">
<table class="list">
<tr>
<th>Type
<td>
<?php if ($audit->getOld() === null) : echo 'CREATE'; ?>
<?php elseif ($audit->getOld() !== null && $audit->getNew() !== null) : echo 'UPDATE'; ?>
<?php elseif ($audit->getNew() === null) : echo 'DELETE'; ?>
<?php else : echo 'UNKNOWN'; ?>
<?php endif; ?>
<tr>
<th>Created By
<td><?= $audit->getCreatedBy()->getName1(); ?>

View File

@ -1,45 +0,0 @@
<?php
/**
* Orange Management
*
* PHP Version 7.4
*
* @package Modules\Auditor
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
/**
* @var \phpOMS\Views\View $this
*/
$modules = $this->getData('modules');
echo $this->getData('nav')->render(); ?>
<div class="row">
<div class="col-xs-12">
<div class="box wf-100">
<table class="default">
<caption><?= $this->getHtml('Audits') ?><i class="fa fa-download floatRight download btn"></i></caption>
<thead>
<tr>
<td><?= $this->getHtml('ID', '0', '0'); ?>
<td class="wf-100"><?= $this->getHtml('Name') ?>
<tbody>
<?php $count = 0; foreach ($modules as $key => $module) : ++$count;
$url = \phpOMS\Uri\UriFactory::build('{/prefix}admin/audit/single?{?}&id=' . $module['name']['id']); ?>
<tr tabindex="0" data-href="<?= $url; ?>">
<td><?= $this->printHtml($module['name']['id']); ?>
<td><?= $this->printHtml($module['name']['external']); ?>
<?php endforeach; ?>
<?php if ($count === 0) : ?>
<tr><td colspan="2" class="empty"><?= $this->getHtml('Empty', '0', '0'); ?>
<?php endif; ?>
</table>
</div>
</div>
</div>

View File

@ -1,19 +0,0 @@
<?php
/**
* Orange Management
*
* PHP Version 7.4
*
* @package Modules\Auditor
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
/**
* @var \phpOMS\Views\View $this
*/
echo $this->getData('nav')->render();