Skip to content

Commit 43e87ed

Browse files
committed
added admin action logs, improved admin page, creating a new websites now copies system configuration from website 1
1 parent e48d074 commit 43e87ed

File tree

2 files changed

+125
-0
lines changed

2 files changed

+125
-0
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?php
2+
/**
3+
* SiteBase
4+
* PHP Version 7.0
5+
*
6+
* @category CMS / Framework
7+
* @package Degami\Sitebase
8+
* @author Mirko De Grandis <degami@github.com>
9+
* @license MIT https://opensource.org/licenses/mit-license.php
10+
* @link https://github.com/degami/sitebase
11+
*/
12+
namespace App\Site\Migrations;
13+
14+
use \App\Base\Abstracts\DBMigration;
15+
use \Psr\Container\ContainerInterface;
16+
use \Degami\SqlSchema\Index;
17+
use \Degami\SqlSchema\Table;
18+
19+
/**
20+
* "admin_action_log" table migration
21+
*/
22+
class CreateAdminActionLogTableMigration extends DBMigration
23+
{
24+
/**
25+
* @var string table name
26+
*/
27+
protected $tableName = 'admin_action_log';
28+
29+
/**
30+
* {@inheritdocs}
31+
*
32+
* @return string
33+
*/
34+
public function getName()
35+
{
36+
return '06_'.parent::getName();
37+
}
38+
39+
/**
40+
* {@inheritdocs}
41+
*
42+
* @param Table $table
43+
* @return Table
44+
*/
45+
public function addDBTableDefinition(Table $table)
46+
{
47+
$table->addColumn('id', 'INT', null, ['UNSIGNED'], false)
48+
->addColumn('website_id', 'INT', null, ['UNSIGNED'])
49+
->addColumn('url', 'VARCHAR', [1024])
50+
->addColumn('method', 'VARCHAR', [10])
51+
->addColumn('ip_address', 'VARCHAR', [32])
52+
->addColumn('user_id', 'INT', null, ['UNSIGNED'], 'NULL')
53+
->addColumn('action', 'VARCHAR', [1024])
54+
->addColumn('route_info', 'TEXT')
55+
->addColumn('log_data', 'TEXT')
56+
->addColumn('created_at', 'TIMESTAMP', null, [], false, 'CURRENT_TIMESTAMP()')
57+
->addColumn('updated_at', 'TIMESTAMP', null, [], false, 'CURRENT_TIMESTAMP()')
58+
->addIndex(null, 'id', Index::TYPE_PRIMARY)
59+
->addForeignKey('fk_adminactionlog_website_id', ['website_id'], 'website', ['id'])
60+
->addForeignKey('fk_adminactionlog_user_id', ['user_id'], 'user', ['id'])
61+
->setAutoIncrementColumn('id');
62+
63+
return $table;
64+
}
65+
}

app/site/models/AdminActionLog.php

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?php
2+
/**
3+
* SiteBase
4+
* PHP Version 7.0
5+
*
6+
* @category CMS / Framework
7+
* @package Degami\Sitebase
8+
* @author Mirko De Grandis <degami@github.com>
9+
* @license MIT https://opensource.org/licenses/mit-license.php
10+
* @link https://github.com/degami/sitebase
11+
*/
12+
namespace App\Site\Models;
13+
14+
use \App\Site\Routing\RouteInfo;
15+
use \App\Base\Abstracts\BasePage;
16+
use \Symfony\Component\HttpFoundation\Request;
17+
18+
/**
19+
* Admin Action Log Model
20+
*
21+
* @method int getId()
22+
* @method int getWebsiteId()
23+
* @method string getUrl()
24+
* @method string getMethod()
25+
* @method string getUserId()
26+
* @method string getIpAddress()
27+
* @method RouteInfo getRouteInfo()
28+
* @method mixed getLogData()
29+
* @method \DateTime getCreatedAt()
30+
* @method \DateTime getUpdatedAt()
31+
*/
32+
class AdminActionLog extends RequestLog
33+
{
34+
/**
35+
* fills log with request object
36+
*
37+
* @param Request $request
38+
* @param BaseHtmlPage|null $controller
39+
* @return self
40+
*/
41+
public function fillWithRequest(Request $request, BasePage $controller = null)
42+
{
43+
parent::fillWithRequest($request, $controller);
44+
$this->setRouteInfo(serialize($controller->getRouteInfo()));
45+
$this->setAction($controller->getRouteInfo()->getRouteName());
46+
return $this;
47+
}
48+
49+
public function getRouteInfo()
50+
{
51+
$route_info = unserialize($this->getData('route_info'));
52+
return $route_info;
53+
}
54+
55+
public function getLogData()
56+
{
57+
$log_data = $this->getData('log_data');
58+
var_dump($log_data);
59+
}
60+
}

0 commit comments

Comments
 (0)