mirror of
https://github.com/Karaka-Management/oms-Auditor.git
synced 2026-02-03 15:58:40 +00:00
add ip support for auditor
This commit is contained in:
parent
2b4aea1c8d
commit
5533a0f039
|
|
@ -47,6 +47,7 @@ final class ApiController extends Controller
|
|||
* @param string $module Module name
|
||||
* @param string $ref Reference to other model
|
||||
* @param string $content Message
|
||||
* @param string $ip Ip
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
|
|
@ -62,11 +63,12 @@ final class ApiController extends Controller
|
|||
int $subtype = 0,
|
||||
string $module = null,
|
||||
string $ref = null,
|
||||
string $content = null
|
||||
string $content = null,
|
||||
string $ip = null
|
||||
) : void
|
||||
{
|
||||
$newString = StringUtils::stringify($new, \JSON_PRETTY_PRINT);
|
||||
$audit = new Audit(new NullAccount($account), null, $newString, $type, $subtype, $module, $ref, $content);
|
||||
$audit = new Audit(new NullAccount($account), null, $newString, $type, $subtype, $module, $ref, $content, \ip2long($ip ?? '127.0.0.1'));
|
||||
|
||||
AuditMapper::create($audit);
|
||||
}
|
||||
|
|
@ -82,6 +84,7 @@ final class ApiController extends Controller
|
|||
* @param string $module Module name
|
||||
* @param string $ref Reference to other model
|
||||
* @param string $content Message
|
||||
* @param string $ip Ip
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
|
|
@ -97,12 +100,13 @@ final class ApiController extends Controller
|
|||
int $subtype = 0,
|
||||
string $module = null,
|
||||
string $ref = null,
|
||||
string $content = null
|
||||
string $content = null,
|
||||
string $ip = null
|
||||
) : void
|
||||
{
|
||||
$oldString = StringUtils::stringify($old, \JSON_PRETTY_PRINT);
|
||||
$newString = StringUtils::stringify($new, \JSON_PRETTY_PRINT);
|
||||
$audit = new Audit(new NullAccount($account), $oldString, $newString, $type, $subtype, $module, $ref, $content);
|
||||
$audit = new Audit(new NullAccount($account), $oldString, $newString, $type, $subtype, $module, $ref, $content, \ip2long($ip ?? '127.0.0.1'));
|
||||
|
||||
AuditMapper::create($audit);
|
||||
}
|
||||
|
|
@ -118,6 +122,7 @@ final class ApiController extends Controller
|
|||
* @param string $module Module name
|
||||
* @param string $ref Reference to other model
|
||||
* @param string $content Message
|
||||
* @param string $ip Ip
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
|
|
@ -133,11 +138,12 @@ final class ApiController extends Controller
|
|||
int $subtype = 0,
|
||||
string $module = null,
|
||||
string $ref = null,
|
||||
string $content = null
|
||||
string $content = null,
|
||||
string $ip = null
|
||||
) : void
|
||||
{
|
||||
$oldString = StringUtils::stringify($old, \JSON_PRETTY_PRINT);
|
||||
$audit = new Audit(new NullAccount($account), $oldString, null, $type, $subtype, $module, $ref, $content);
|
||||
$audit = new Audit(new NullAccount($account), $oldString, null, $type, $subtype, $module, $ref, $content, \ip2long($ip ?? '127.0.0.1'));
|
||||
|
||||
AuditMapper::create($audit);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -130,6 +130,7 @@ class Audit
|
|||
* @param null|string $module Module id
|
||||
* @param null|string $ref Dynamic reference to model
|
||||
* @param null|string $content Additional audit information
|
||||
* @param int $ip Ip
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
|
|
@ -141,7 +142,8 @@ class Audit
|
|||
int $subtype = 0,
|
||||
string $module = null,
|
||||
string $ref = null,
|
||||
string $content = null
|
||||
string $content = null,
|
||||
int $ip = 0
|
||||
) {
|
||||
$this->createdAt = new \DateTime('now');
|
||||
$this->createdBy = $account ?? new NullAccount();
|
||||
|
|
@ -152,6 +154,7 @@ class Audit
|
|||
$this->module = $module;
|
||||
$this->ref = $ref;
|
||||
$this->content = $content;
|
||||
$this->ip = $ip;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -275,4 +278,16 @@ class Audit
|
|||
{
|
||||
return $this->createdAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ip.
|
||||
*
|
||||
* @return int
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getIp() : int
|
||||
{
|
||||
return $this->ip;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,8 +71,8 @@ echo $this->getData('nav')->render(); ?>
|
|||
<?php endif; ?>
|
||||
</table>
|
||||
<div class="portlet-foot">
|
||||
<a class="button" href="<?= UriFactory::build($previous); ?>"><?= $this->getHtml('Previous', '0', '0'); ?></a>
|
||||
<a class="button" href="<?= UriFactory::build($next); ?>"><?= $this->getHtml('Next', '0', '0'); ?></a>
|
||||
<a tabindex="0" class="button" href="<?= UriFactory::build($previous); ?>"><?= $this->getHtml('Previous', '0', '0'); ?></a>
|
||||
<a tabindex="0" class="button" href="<?= UriFactory::build($next); ?>"><?= $this->getHtml('Next', '0', '0'); ?></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -12,24 +12,44 @@
|
|||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
use phpOMS\Views\ViewAbstract;
|
||||
|
||||
/** @var \Modules\Auditor\Models\Audit $audit */
|
||||
$audit = $this->getData('audit');
|
||||
|
||||
/**
|
||||
* @var \phpOMS\Views\View $this
|
||||
*/
|
||||
|
||||
echo $this->getData('nav')->render();
|
||||
?>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<div class="portlet">
|
||||
<article>
|
||||
<pre><?= \phpOMS\Utils\StringUtils::createDiffMarkup(
|
||||
\phpOMS\Views\ViewAbstract::html($this->getData('audit')->getOld() ?? ''),
|
||||
\phpOMS\Views\ViewAbstract::html($this->getData('audit')->getNew() ?? ''),
|
||||
"\n"
|
||||
); ?>
|
||||
</pre>
|
||||
</article>
|
||||
<div class="portlet-body">
|
||||
<table class="list">
|
||||
<tr>
|
||||
<th>Created By
|
||||
<td><?= $audit->getCreatedBy()->getName1(); ?>
|
||||
<tr>
|
||||
<th>Created At
|
||||
<td><?= $this->getDateTime($audit->getCreatedAt(), 'long'); ?>
|
||||
<tr>
|
||||
<th>Module
|
||||
<td><?= $audit->getModule(); ?>
|
||||
<tr>
|
||||
<th>IP
|
||||
<td><?= \long2ip($audit->getIp()); ?>
|
||||
</table>
|
||||
<article>
|
||||
<pre><?= \phpOMS\Utils\StringUtils::createDiffMarkup(
|
||||
ViewAbstract::html($audit->getOld() ?? ''),
|
||||
ViewAbstract::html($audit->getNew() ?? ''),
|
||||
"\n"
|
||||
); ?>
|
||||
</pre>
|
||||
</article>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
Loading…
Reference in New Issue
Block a user