mirror of
https://github.com/Karaka-Management/oms-Auditor.git
synced 2026-02-16 13:38:41 +00:00
fixes Orange-Management/phpOMS#224 and fixes Orange-Management/phpOMS#212
This commit is contained in:
parent
020fe62595
commit
0225b9b5c6
|
|
@ -14,10 +14,11 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace Modules\Auditor\Controller;
|
namespace Modules\Auditor\Controller;
|
||||||
|
|
||||||
|
use Modules\Admin\Models\NullAccount;
|
||||||
use Modules\Auditor\Models\Audit;
|
use Modules\Auditor\Models\Audit;
|
||||||
use Modules\Auditor\Models\AuditMapper;
|
use Modules\Auditor\Models\AuditMapper;
|
||||||
use phpOMS\Account\Account;
|
|
||||||
|
|
||||||
|
use phpOMS\Account\Account;
|
||||||
use phpOMS\Utils\StringUtils;
|
use phpOMS\Utils\StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -65,7 +66,7 @@ final class ApiController extends Controller
|
||||||
) : void
|
) : void
|
||||||
{
|
{
|
||||||
$newString = StringUtils::stringify($new, \JSON_PRETTY_PRINT);
|
$newString = StringUtils::stringify($new, \JSON_PRETTY_PRINT);
|
||||||
$audit = new Audit($account, null, $newString, $type, $subtype, $module, $ref, $content);
|
$audit = new Audit(new NullAccount($account), null, $newString, $type, $subtype, $module, $ref, $content);
|
||||||
|
|
||||||
AuditMapper::create($audit);
|
AuditMapper::create($audit);
|
||||||
}
|
}
|
||||||
|
|
@ -101,7 +102,7 @@ final class ApiController extends Controller
|
||||||
{
|
{
|
||||||
$oldString = StringUtils::stringify($old, \JSON_PRETTY_PRINT);
|
$oldString = StringUtils::stringify($old, \JSON_PRETTY_PRINT);
|
||||||
$newString = StringUtils::stringify($new, \JSON_PRETTY_PRINT);
|
$newString = StringUtils::stringify($new, \JSON_PRETTY_PRINT);
|
||||||
$audit = new Audit($account, $oldString, $newString, $type, $subtype, $module, $ref, $content);
|
$audit = new Audit(new NullAccount($account), $oldString, $newString, $type, $subtype, $module, $ref, $content);
|
||||||
|
|
||||||
AuditMapper::create($audit);
|
AuditMapper::create($audit);
|
||||||
}
|
}
|
||||||
|
|
@ -136,7 +137,7 @@ final class ApiController extends Controller
|
||||||
) : void
|
) : void
|
||||||
{
|
{
|
||||||
$oldString = StringUtils::stringify($old, \JSON_PRETTY_PRINT);
|
$oldString = StringUtils::stringify($old, \JSON_PRETTY_PRINT);
|
||||||
$audit = new Audit($account, $oldString, null, $type, $subtype, $module, $ref, $content);
|
$audit = new Audit(new NullAccount($account), $oldString, null, $type, $subtype, $module, $ref, $content);
|
||||||
|
|
||||||
AuditMapper::create($audit);
|
AuditMapper::create($audit);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace Modules\Auditor\Models;
|
namespace Modules\Auditor\Models;
|
||||||
|
|
||||||
|
use Modules\Admin\Models\NullAccount;
|
||||||
use phpOMS\Account\Account;
|
use phpOMS\Account\Account;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -97,10 +98,10 @@ class Audit
|
||||||
/**
|
/**
|
||||||
* Account.
|
* Account.
|
||||||
*
|
*
|
||||||
* @var int|Account
|
* @var Account
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
private $createdBy;
|
private Account $createdBy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created at.
|
* Created at.
|
||||||
|
|
@ -121,7 +122,7 @@ class Audit
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
* @param int|Account $account Account of the creator
|
* @param Account $account Account of the creator
|
||||||
* @param null|string $old Old value
|
* @param null|string $old Old value
|
||||||
* @param null|string $new New value
|
* @param null|string $new New value
|
||||||
* @param int $type Type of the audit
|
* @param int $type Type of the audit
|
||||||
|
|
@ -133,7 +134,7 @@ class Audit
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
$account = 0,
|
Account $account = null,
|
||||||
string $old = null,
|
string $old = null,
|
||||||
string $new = null,
|
string $new = null,
|
||||||
int $type = 0,
|
int $type = 0,
|
||||||
|
|
@ -143,7 +144,7 @@ class Audit
|
||||||
string $content = null
|
string $content = null
|
||||||
) {
|
) {
|
||||||
$this->createdAt = new \DateTime('now');
|
$this->createdAt = new \DateTime('now');
|
||||||
$this->createdBy = $account;
|
$this->createdBy = $account ?? new NullAccount();
|
||||||
$this->old = $old;
|
$this->old = $old;
|
||||||
$this->new = $new;
|
$this->new = $new;
|
||||||
$this->type = $type;
|
$this->type = $type;
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ final class AuditMapper extends DataMapperAbstract
|
||||||
*/
|
*/
|
||||||
protected static array $columns = [
|
protected static array $columns = [
|
||||||
'auditor_audit_id' => ['name' => 'auditor_audit_id', 'type' => 'int', 'internal' => 'id'],
|
'auditor_audit_id' => ['name' => 'auditor_audit_id', 'type' => 'int', 'internal' => 'id'],
|
||||||
'auditor_audit_created_by' => ['name' => 'auditor_audit_created_by', 'type' => 'int', 'internal' => 'createdBy'],
|
'auditor_audit_created_by' => ['name' => 'auditor_audit_created_by', 'type' => 'int', 'internal' => 'createdBy', 'readonly' => true],
|
||||||
'auditor_audit_created_at' => ['name' => 'auditor_audit_created_at', 'type' => 'DateTime', 'internal' => 'createdAt', 'readonly' => true],
|
'auditor_audit_created_at' => ['name' => 'auditor_audit_created_at', 'type' => 'DateTime', 'internal' => 'createdAt', 'readonly' => true],
|
||||||
'auditor_audit_ip' => ['name' => 'auditor_audit_ip', 'type' => 'int', 'internal' => 'ip'],
|
'auditor_audit_ip' => ['name' => 'auditor_audit_ip', 'type' => 'int', 'internal' => 'ip'],
|
||||||
'auditor_audit_module' => ['name' => 'auditor_audit_module', 'type' => 'string', 'internal' => 'module'],
|
'auditor_audit_module' => ['name' => 'auditor_audit_module', 'type' => 'string', 'internal' => 'module'],
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user