Add auditor module

This commit is contained in:
Dennis Eichhorn 2017-09-03 20:24:57 +02:00
commit 36434d3efa
22 changed files with 529 additions and 0 deletions

40
Admin/Activate.php Normal file
View File

@ -0,0 +1,40 @@
<?php
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
declare(strict_types=1);
namespace Modules\Auditor\Admin;
use phpOMS\DataStorage\Database\DatabasePool;
use phpOMS\Module\ActivateAbstract;
use phpOMS\Module\InfoManager;
/**
* Navigation class.
*
* @category Modules
* @package Modules\Admin
* @license OMS License 1.0
* @link http://orange-management.com
* @since 1.0.0
*/
class Activate extends ActivateAbstract
{
/**
* {@inheritdoc}
*/
public static function activate(DatabasePool $dbPool, InfoManager $info)
{
parent::activate($dbPool, $info);
}
}

40
Admin/Deactivate.php Normal file
View File

@ -0,0 +1,40 @@
<?php
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
declare(strict_types=1);
namespace Modules\Auditor\Admin;
use phpOMS\DataStorage\Database\DatabasePool;
use phpOMS\Module\DeactivateAbstract;
use phpOMS\Module\InfoManager;
/**
* Navigation class.
*
* @category Modules
* @package Modules\Admin
* @license OMS License 1.0
* @link http://orange-management.com
* @since 1.0.0
*/
class Deactivate extends DeactivateAbstract
{
/**
* {@inheritdoc}
*/
public static function deactivate(DatabasePool $dbPool, InfoManager $info)
{
parent::deactivate($dbPool, $info);
}
}

View File

@ -0,0 +1,33 @@
[
{
"id": 1006201001,
"pid": "754a08ddf8bcb1cf22f310f09206dd783d42f7dd",
"type": 2,
"subtype": 1,
"name": "Auditor",
"uri": "{/base}/{/lang}/backend/admin/aduit/list?{?}",
"target": "self",
"icon": null,
"order": 75,
"from": "Auditor",
"permission": null,
"parent": 1000101001,
"children": [
{
"id": 1006202001,
"pid": "dbc72ec850137bfcf6cb862625c680ae0ee6def2",
"type": 3,
"subtype": 1,
"name": "List",
"uri": "{/base}/{/lang}/backend/admin/aduit/list?{?}",
"target": "self",
"icon": null,
"order": 1,
"from": "Auditor",
"permission": null,
"parent": 1006201001,
"children": []
}
]
}
]

View File

@ -0,0 +1,37 @@
<?php
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
declare(strict_types=1);
namespace Modules\Auditor\Admin\Install;
use phpOMS\DataStorage\Database\DatabasePool;
/**
* Navigation class.
*
* @category Modules
* @package Modules\Admin
* @license OMS License 1.0
* @link http://orange-management.com
* @since 1.0.0
*/
class Navigation
{
public static function install(string $path, DatabasePool $dbPool)
{
$navData = json_decode(file_get_contents(__DIR__ . '/Navigation.install.json'), true);
$class = '\\Modules\\Navigation\\Admin\\Installer';
/** @var $class \Modules\Navigation\Admin\Installer */
$class::installExternal($dbPool, $navData);
}
}

68
Admin/Installer.php Normal file
View File

@ -0,0 +1,68 @@
<?php
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
declare(strict_types=1);
namespace Modules\Auditor\Admin;
use phpOMS\DataStorage\Database\DatabaseType;
use phpOMS\DataStorage\Database\DatabasePool;
use phpOMS\Module\InfoManager;
use phpOMS\Module\InstallerAbstract;
/**
* Auditor install class.
*
* @category Modules
* @package Modules\Auditor
* @license OMS License 1.0
* @link http://orange-management.com
* @since 1.0.0
*/
class Installer extends InstallerAbstract
{
/**
* {@inheritdoc}
*/
public static function install(string $path, DatabasePool $dbPool, InfoManager $info)
{
parent::install(__DIR__ . '/..', $dbPool, $info);
switch ($dbPool->get('core')->getType()) {
case DatabaseType::MYSQL:
$dbPool->get('core')->con->prepare(
'CREATE TABLE if NOT EXISTS `' . $dbPool->get('core')->prefix . 'auditor_audit` (
`auditor_audit_id` int(11) NOT NULL AUTO_INCREMENT,
`auditor_audit_module` int(11) NOT NULL,
`auditor_audit_ref` int(11) NOT NULL,
`auditor_audit_type` smallint(3) NOT NULL,
`auditor_audit_subtype` smallint(3) NOT NULL,
`auditor_audit_content` text NOT NULL,
`auditor_audit_old` text NOT NULL,
`auditor_audit_new` text NOT NULL,
`auditor_audit_created_at` datetime NOT NULL,
`auditor_audit_created_by` int(11) NOT NULL,
`auditor_audit_ip` int(11) NOT NULL,
PRIMARY KEY (`auditor_audit_id`),
KEY `auditor_audit_created_by` (`auditor_audit_created_by`)
)ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;'
)->execute();
$dbPool->get('core')->con->prepare(
'ALTER TABLE `' . $dbPool->get('core')->prefix . 'auditor_audit`
ADD CONSTRAINT `' . $dbPool->get('core')->prefix . 'auditor_audit_ibfk_1` FOREIGN KEY (`auditor_audit_created_by`) REFERENCES `' . $dbPool->get('core')->prefix . 'account` (`account_id`);'
)->execute();
break;
}
}
}

6
Admin/Routes/Web/Api.php Normal file
View File

@ -0,0 +1,6 @@
<?php
use phpOMS\Router\RouteVerb;
return [
];

View File

@ -0,0 +1,18 @@
<?php
use phpOMS\Router\RouteVerb;
return [
'^.*/backend/admin/auditor/list.*$' => [
[
'dest' => '\Modules\Auditor\Controller:viewAuditorList',
'verb' => RouteVerb::GET,
],
],
'^.*/backend/admin/auditor/single.*$' => [
[
'dest' => '\Modules\Auditor\Controller:viewAuditorSingle',
'verb' => RouteVerb::GET,
],
],
];

3
Admin/Routes/console.php Normal file
View File

@ -0,0 +1,3 @@
<?php
$moduleRoutes = [];

3
Admin/Routes/socket.php Normal file
View File

@ -0,0 +1,3 @@
<?php
$moduleRoutes = [];

39
Admin/Uninstall.php Normal file
View File

@ -0,0 +1,39 @@
<?php
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
declare(strict_types=1);
namespace Modules\Auditor\Admin;
use phpOMS\DataStorage\Database\DatabasePool;
use phpOMS\Module\UninstallAbstract;
/**
* Navigation class.
*
* @category Modules
* @package Modules\Admin
* @license OMS License 1.0
* @link http://orange-management.com
* @since 1.0.0
*/
class Uninstall extends UninstallAbstract
{
/**
* {@inheritdoc}
*/
public static function uninstall(DatabasePool $dbPool, InfoManager $info)
{
parent::uninstall($dbPool, $info);
}
}

42
Admin/Update.php Normal file
View File

@ -0,0 +1,42 @@
<?php
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
declare(strict_types=1);
namespace Modules\Auditor\Admin;
use phpOMS\DataStorage\Database\DatabasePool;
use phpOMS\Module\UpdateAbstract;
use phpOMS\System\File\Directory;
/**
* Navigation class.
*
* @category Modules
* @package Modules\Admin
* @license OMS License 1.0
* @link http://orange-management.com
* @since 1.0.0
*/
class Update extends UpdateAbstract
{
/**
* {@inheritdoc}
*/
public static function update(DatabasePool $dbPool, array $info)
{
Directory::deletePath(__DIR__ . '/Update');
mkdir('Update');
parent::update($dbPool, $info);
}
}

0
Controller.js Normal file
View File

102
Controller.php Normal file
View File

@ -0,0 +1,102 @@
<?php
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
declare(strict_types=1);
namespace Modules\Auditor;
use phpOMS\Asset\AssetType;
use phpOMS\Contract\RenderableInterface;
use phpOMS\Message\RequestAbstract;
use phpOMS\Message\ResponseAbstract;
use phpOMS\Module\ModuleAbstract;
use phpOMS\Module\WebInterface;
use phpOMS\Views\View;
use phpOMS\Views\ViewLayout;
/**
* Calendar controller class.
*
* @category Modules
* @package Auditor
* @license OMS License 1.0
* @link http://orange-management.com
* @since 1.0.0
*/
class Controller extends ModuleAbstract implements WebInterface
{
/**
* Module path.
*
* @var string
* @since 1.0.0
*/
/* public */ const MODULE_PATH = __DIR__;
/**
* Module version.
*
* @var string
* @since 1.0.0
*/
/* public */ const MODULE_VERSION = '1.0.0';
/**
* Module name.
*
* @var string
* @since 1.0.0
*/
/* public */ const MODULE_NAME = 'Auditor';
/**
* Providing.
*
* @var string
* @since 1.0.0
*/
protected static $providing = [];
/**
* Dependencies.
*
* @var string
* @since 1.0.0
*/
protected static $dependencies = [
];
public function viewAuditorList(RequestAbstract $request, ResponseAbstract $response, $data = null) : \Serializable
{
$view = new View($this->app, $request, $response);
$view->setTemplate('/Modules/Auditor/Theme/Backend/auditor-list');
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1005801001, $request, $response));
$list = AuditMapper::getNewest(50);
$view->setData('audits', $list);
return $view;
}
public function viewAuditorSingle(RequestAbstract $request, ResponseAbstract $response, $data = null) : \Serializable
{
$view = new View($this->app, $request, $response);
$view->setTemplate('/Modules/Auditor/Theme/Backend/auditor-single');
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1005801001, $request, $response));
$list = AuditMapper::get(50);
$view->setData('audits', $list);
return $view;
}
}

0
Models/Audit.php Normal file
View File

0
Models/AuditMapper.php Normal file
View File

0
README.md Normal file
View File

View File

@ -0,0 +1,19 @@
<?php
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
return ['Navigation' => [
'Create' => 'Create',
'Auditor' => 'Auditor',
'Audit' => 'Audit',
'List' => 'List',
]];

View File

@ -0,0 +1,15 @@
<?php
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
return ['Navigation' => [
]];

View File

@ -0,0 +1,19 @@
<?php
/**
* Orange Management
*
* PHP Version 7.1
*
* @category TBD
* @package TBD
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
return ['Auditor' => [
'Created' => 'Created',
'Creator' => 'Creator',
'Auditor' => 'Auditor',
'Audit' => 'Audit',
]];

View File

View File

45
info.json Normal file
View File

@ -0,0 +1,45 @@
{
"name": {
"id": 1006200000,
"internal": "Auditor",
"external": "Auditor"
},
"category": "Admin",
"version": "1.0.0",
"requirements": {
"phpOMS": "1.0.0",
"phpOMS-db": "1.0.0"
},
"creator": {
"name": "Orange Management",
"website": "www.spl1nes.com"
},
"description": "The administration module.",
"directory": "Auditor",
"dependencies": {
"Admin" : "1.0.0"
},
"providing": {
"Navigation": "*"
},
"load": [
{
"pid": [
"dbc72ec850137bfcf6cb862625c680ae0ee6def2"
],
"type": 4,
"for": "Content",
"file": "Auditor",
"from": "Auditor"
},
{
"pid": [
"754a08ddf8bcb1cf22f310f09206dd783d42f7dd"
],
"type": 5,
"from": "Auditor",
"for": "Navigation",
"file": "Navigation"
}
]
}