@@ -, +, @@ management - a system preference (NoticesLog) which allows you to enable logging changes for notices and slips - logging new notices, changes to notices, and deletion of notices - filtering in the log viewer so you can show all changes for a specific notice - a comparison feature, so you can see what changes were made to a notice. --- .../intranet-tmpl/prog/en/modules/tools/viewlog.tt | 48 ++++++++++++---------- tools/letter.pl | 41 ++++++++++++++---- tools/viewlog.pl | 10 +++++ 3 files changed, 69 insertions(+), 30 deletions(-) --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt @@ -96,6 +96,7 @@ [% CASE 'SEARCHENGINE' %]Search engine +[% CASE 'NOTICES' %]Notices[% UNLESS Koha.Preference('NoticesLog') %] [% END %] [% CASE %][% module | html %] [% END %] [% END %] @@ -190,7 +191,7 @@ [% ELSE %] [% END %] - [% FOREACH modx IN [ 'AUTH' 'CATALOGUING' 'AUTHORITIES' 'MEMBERS' 'ACQUISITIONS' 'SERIAL' 'HOLDS' 'ILL' 'CIRCULATION' 'LETTER' 'FINES' 'SYSTEMPREFERENCE' 'CRONJOBS', 'REPORTS', 'SEARCHENGINE' ] %] + [% FOREACH modx IN [ 'AUTH' 'CATALOGUING' 'AUTHORITIES' 'MEMBERS' 'ACQUISITIONS' 'SERIAL' 'HOLDS' 'ILL' 'CIRCULATION' 'LETTER' 'FINES' 'SYSTEMPREFERENCE' 'CRONJOBS', 'REPORTS', 'SEARCHENGINE', 'NOTICES' ] %] [% IF modules.grep(modx).size %] [% ELSE %] @@ -324,27 +325,27 @@ [% ELSE %] [% loopro.object | html %] [% END %] + [% ELSIF ( loopro.module == 'CATALOGUING' ) %] + [% IF ( loopro.info.substr(0, 4) == 'item' ) %] + Item [% loopro.object | html %] from + Biblio [% loopro.biblionumber | html %] + [% ELSIF ( loopro.info.substr(0, 6) == 'biblio' ) %] + Biblio [% loopro.object | html %] + [% ELSE %] + [% loopro.object | html %] + [% END %] + [% ELSIF ( loopro.module == 'SERIAL' ) %] + Subscription [% loopro.object | html %] + [% ELSIF ( loopro.module == 'AUTHORITIES' ) %] + Authority [% loopro.object | html %] + [% ELSIF ( loopro.module == 'NOTICES' ) %] + [% IF ( loopro.notice ) %] + Notice [% loopro.notice.title | html %] ([% loopro.notice.code | html %]) + [% ELSE %] + [% loopro.object | html %] + [% END %] [% ELSE %] - [% IF ( loopro.module == 'CATALOGUING' ) %] - [% IF ( loopro.info.substr(0, 4) == 'item' ) %] - Item [% loopro.object | html %] from - Biblio [% loopro.biblionumber | html %] - [% ELSIF ( loopro.info.substr(0, 6) == 'biblio' ) %] - Biblio [% loopro.object | html %] - [% ELSE %] - [% loopro.object | html %] - [% END %] - [% ELSE %] - [% IF ( loopro.module == 'SERIAL' ) %] - Subscription [% loopro.object | html %] - [% ELSE %] - [% IF ( loopro.module == 'AUTHORITIES' ) %] - Authority [% loopro.object | html %] - [% ELSE %] - [% loopro.object | html %] - [% END %] - [% END %] - [% END %] + [% loopro.object | html %] [% END %] @@ -356,6 +357,11 @@
+ [% ELSIF loopro.module == "NOTICES" %] +
[% loopro.info | trim | html %]
+
+ +
[% ELSE %]
[% loopro.info | html %] --- a/tools/letter.pl +++ a/tools/letter.pl @@ -46,6 +46,7 @@ use C4::Auth; use C4::Context; use C4::Output; use C4::Letters; +use C4::Log; use Koha::Patron::Attribute::Types; @@ -315,6 +316,10 @@ sub add_validate { next; } elsif ( $letter and $letter->{message_transport_type} eq $mtt and $letter->{lang} eq $lang ) { + logaction( 'NOTICES', 'MODIFY', $letter->{id}, $content, + 'Intranet' ) + if ( C4::Context->preference("NoticesLog") + && $content ne $letter->{content} ); $dbh->do( q{ UPDATE letter @@ -326,11 +331,22 @@ sub add_validate { $branchcode, $oldmodule, $code, $mtt, $lang ); } else { - $dbh->do( - q{INSERT INTO letter (branchcode,module,code,name,is_html,title,content,message_transport_type, lang) VALUES (?,?,?,?,?,?,?,?,?)}, - undef, - $branchcode || '', $module, $code, $name, $is_html || 0, $title, $content, $mtt, $lang - ); + my $letter = Koha::Notice::Template->new( + { + branchcode => $branchcode, + module => $module, + code => $code, + name => $name, + is_html => $is_html, + title => $title, + content => $content, + message_transport_type => $mtt, + lang => $lang + } + )->store; + logaction( 'NOTICES', 'CREATE', $letter->id, $letter->content, + 'Intranet' ) + if C4::Context->preference("NoticesLog"); } } # set up default display @@ -350,16 +366,23 @@ sub delete_confirm { } sub delete_confirmed { - my ($branchcode, $module, $code, $mtt, $lang) = @_; - C4::Letters::DelLetter( + my ( $branchcode, $module, $code, $mtt, $lang ) = @_; + my $letters = Koha::Notice::Templates->search( { branchcode => $branchcode || '', module => $module, code => $code, - mtt => $mtt, - lang => $lang, + ( $mtt ? ( message_transport_type => $mtt ) : () ), + ( $lang ? ( lang => $lang ) : () ), } ); + while ( my $letter = $letters->next ) { + logaction( 'NOTICES', 'DELETE', $letter->id, $letter->content, + 'Intranet' ) + if C4::Context->preference("NoticesLog"); + $letter->delete; + } + # setup default display for screen default_display($branchcode); return; --- a/tools/viewlog.pl +++ a/tools/viewlog.pl @@ -186,6 +186,16 @@ if ($do_it) { } } } + + if ( $log->module eq 'NOTICES' ) { + if ( $log->object ) { + my $notice = Koha::Notice::Templates->find( { id => $log->object } ); + if ($notice && $output eq 'screen') { + $result->{notice} = $notice->unblessed; + } + } + } + push @data, $result; } if ( $output eq "screen" ) { --