fix activity report

This commit is contained in:
Jean-Christian Paul Denis 2023-10-23 23:33:24 +02:00
parent 52a60eb47a
commit 726c973ec2
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951

View File

@ -22,6 +22,10 @@ use Dotclear\Plugin\activityReport\{
*/ */
class ActivityReportAction extends Process class ActivityReportAction extends Process
{ {
private const CINECTURLINK_CREATE = 'cinecturlink2Create';
private const CINECTURLINK_UPDATE = 'cinecturlink2Update';
private const CINECTURLINK_DELETE = 'cinecturlink2Delete';
public static function init(): bool public static function init(): bool
{ {
return self::status(true); return self::status(true);
@ -37,7 +41,7 @@ class ActivityReportAction extends Process
// from BEHAVIOR cinecturlink2AfterAddLink in cinecturlink2/inc/class.cinecturlink2.php // from BEHAVIOR cinecturlink2AfterAddLink in cinecturlink2/inc/class.cinecturlink2.php
$group->add(new Action( $group->add(new Action(
'cinecturlink2Create', self::CINECTURLINK_CREATE,
__('link creation'), __('link creation'),
__('A new cineturlink named "%s" was added by "%s"'), __('A new cineturlink named "%s" was added by "%s"'),
'cinecturlink2AfterAddLink', 'cinecturlink2AfterAddLink',
@ -45,7 +49,7 @@ class ActivityReportAction extends Process
)); ));
// from BEHAVIOR cinecturlink2AfterUpdLink in cinecturlink2/inc/class.cinecturlink2.php // from BEHAVIOR cinecturlink2AfterUpdLink in cinecturlink2/inc/class.cinecturlink2.php
$group->add(new Action( $group->add(new Action(
'cinecturlink2Update', self::CINECTURLINK_UPDATE,
__('updating link'), __('updating link'),
__('Cinecturlink named "%s" has been updated by "%s"'), __('Cinecturlink named "%s" has been updated by "%s"'),
'cinecturlink2AfterUpdLink', 'cinecturlink2AfterUpdLink',
@ -53,7 +57,7 @@ class ActivityReportAction extends Process
)); ));
// from BEHAVIOR cinecturlink2BeforeDelLink in cinecturlink2/inc/class.cinecturlink2.php // from BEHAVIOR cinecturlink2BeforeDelLink in cinecturlink2/inc/class.cinecturlink2.php
$group->add(new Action( $group->add(new Action(
'cinecturlink2Delete', self::CINECTURLINK_DELETE,
__('link deletion'), __('link deletion'),
__('Cinecturlink named "%s" has been deleted by "%s"'), __('Cinecturlink named "%s" has been deleted by "%s"'),
'cinecturlink2BeforeDelLink', 'cinecturlink2BeforeDelLink',
@ -67,32 +71,33 @@ class ActivityReportAction extends Process
public static function addLink(Cursor $cur): void public static function addLink(Cursor $cur): void
{ {
$logs = [ self::addLog(
(string) $cur->getField('link_title'), self::CINECTURLINK_CREATE,
(string) App::auth()->getInfo('user_cn'), (string) $cur->getField('link_title')
]; );
ActivityReport::instance()->addLog('cinecturlink2', 'create', $logs);
} }
public static function updLink(Cursor $cur, int $id): void public static function updLink(Cursor $cur, int $id): void
{ {
$rs = (new Utils())->getLinks(['link_id' => $id]); self::addLog(
self::CINECTURLINK_UPDATE,
$logs = [ (string) (new Utils())->getLinks(['link_id' => $id])->field('link_title')
(string) $rs->field('link_title'), );
(string) App::auth()->getInfo('user_cn'),
];
ActivityReport::instance()->addLog('cinecturlink2', 'update', $logs);
} }
public static function delLink(int $id): void public static function delLink(int $id): void
{ {
$rs = (new Utils())->getLinks(['link_id' => $id]); self::addLog(
self::CINECTURLINK_DELETE,
(string) (new Utils())->getLinks(['link_id' => $id])->field('link_title')
);
}
$logs = [ private static function addLog(string $action, string $title)
(string) $rs->field('link_title'), {
ActivityReport::instance()->addLog(My::id(), $action, [
$title,
(string) App::auth()->getInfo('user_cn'), (string) App::auth()->getInfo('user_cn'),
]; ]);
ActivityReport::instance()->addLog('cinecturlink2', 'delete', $logs);
} }
} }