use Modern::Perl;
use C4::Context;
use Koha::DateUtils;
+use C4::Log qw(logaction);
+use Koha::News;
use vars qw(@ISA @EXPORT);
my $sth = $dbh->prepare("INSERT INTO opac_news ( $field_string ) VALUES ( $values_string )");
$sth->execute(@values);
$retval = 1;
+
+ #log the NEW OPAC news entry
+ if (C4::Context->preference("NewsLog")) {
+ logaction('OPACNEWS', 'ADD' , undef, $href_entry->{lang} . ' | ' . $href_entry->{content});
+ }
}
return $retval;
}
$sth->execute(@values);
$retval = 1;
}
+
+ #log new OPAC news modification
+ if (C4::Context->preference("NewsLog")) {
+ logaction('OPACNEWS', 'MODIFY' , undef, $href_entry->{lang} . ' | ' . $href_entry->{content});
+ }
return $retval;
}
sub del_opac_new {
my ($ids) = @_;
if ($ids) {
+
+ #log new OPAC news deletion
+ if (C4::Context->preference("NewsLog")) {
+ foreach my $newsid ( split(/,/, $ids )) {
+ my $n = Koha::News->find( $newsid );
+ logaction('OPACNEWS', 'DELETE', undef, $n->unblessed->{lang} . ' | ' . $n->unblessed->{content} );
+ }
+ }
+
my $dbh = C4::Context->dbh;
my $sth = $dbh->prepare("DELETE FROM opac_news WHERE idnew IN ($ids)");
$sth->execute();
} else {
return 0;
}
+
}
sub get_opac_new {
--- /dev/null
+$DBversion = 'XXX'; # will be replaced by the RM
+if( CheckVersion( $DBversion ) ) {
+ $dbh->do( q| INSERT IGNORE INTO systempreferences (variable, value, explanation, options, type) VALUES ('NewsLog', '0', 'If enabled, log OPAC News changes', '', 'YesNo'); | );
+
+ # Always end with this (adjust the bug info)
+ NewVersion( $DBversion, 26205, "Log OPAC News changes");
+}
('minPasswordLength','8',NULL,'Specify the minimum length of a patron/staff password','free'),
('NewItemsDefaultLocation','','','If set, all new items will have a location of the given Location Code ( Authorized Value type LOC )',''),
('NewsAuthorDisplay','none','none|opac|staff|both','Display the author name for news items.','Choice'),
+('NewsLog','0',NULL,'If ON, log OPAC news changes','YesNo'),
('NewsToolEditor','tinymce','tinymce|codemirror','Choose tool for editing News.', 'Choice'),
('noissuescharge','5','','Define maximum amount withstanding before checkouts are blocked','Integer'),
('NoIssuesChargeGuarantees','','','Define maximum amount withstanding before checkouts are blocked','Integer'),
on: Log
off: "Don't log"
- " changes to notice templates."
-
+ -
+ - pref: NewsLog
+ choices:
+ on: Log
+ off: "Don't log"
+ - " changes to OPAC news"
Debugging:
-
- pref: DumpTemplateVarsIntranet
[% CASE 'SEARCHENGINE' %]Search engine
[% CASE 'NOTICES' %]Notices[% UNLESS Koha.Preference('NoticesLog') %] <i class="fa fa-warning" title="Log not enabled"></i>[% END %]
+[% CASE 'OPACNEWS' %]OPAC News[% UNLESS Koha.Preference('NewsLog') %] <i class="fa fa-warning" title="Log not enabled"></i>[% END %]
[% CASE %][% module | html %]
[% END %]
[% END %]
[% ELSE %]
<label for="moduleALL" class="viewlog"><input type="checkbox" id="moduleALL" name="modules" value=""> All</label>
[% END %]
- [% FOREACH modx IN [ 'AUTH' 'CATALOGUING' 'AUTHORITIES' 'MEMBERS' 'ACQUISITIONS' 'SERIAL' 'HOLDS' 'ILL' 'CIRCULATION' 'CLAIMS' 'FINES' 'SYSTEMPREFERENCE' 'CRONJOBS', 'REPORTS', 'SEARCHENGINE', 'NOTICES' ] %]
+ [% FOREACH modx IN [ 'AUTH' 'CATALOGUING' 'AUTHORITIES' 'MEMBERS' 'ACQUISITIONS' 'SERIAL' 'HOLDS' 'ILL' 'CIRCULATION' 'CLAIMS' 'FINES' 'SYSTEMPREFERENCE' 'CRONJOBS', 'REPORTS', 'SEARCHENGINE', 'NOTICES', 'OPACNEWS' ] %]
[% IF modules.grep(modx).size %]
<label for="module[% modx | html %]" class="viewlog"><input type="checkbox" id="module[% modx | html %]" name="modules" value="[% modx | html %]" checked="checked"> [% PROCESS translate_log_module module=modx %]</label>
[% ELSE %]
[% IF ( loopro.module == 'CIRCULATION' ) %]
<a href="/cgi-bin/koha/catalogue/moredetail.pl?itemnumber=[% loopro.info | uri %]&biblionumber=[% loopro.biblionumber | uri %]&bi=[% loopro.biblioitemnumber | uri %]#item[% loopro.info | uri %]" title="Display detail for this item">Item [% loopro.barcode | html %]</a>
[% ELSE %]
- [% IF loopro.module == "SYSTEMPREFERENCE" || loopro.module == "REPORTS" %]
+ [% IF loopro.module == "SYSTEMPREFERENCE" || loopro.module == "REPORTS" || loopro.module == "OPACNEWS" %]
<div class="loginfo" id="loginfo[% loopro.action_id | html %]">[% loopro.info | trim | html %]</div>
<div class="compare_info" id="compare_info[% loopro.action_id | html %]">
<label><input type="checkbox" name="diff" id="action_id[% loopro.action_id | html %]" data-actionid="[% loopro.action_id | html %]" data-filter="[% FOREACH info IN loopro.info.split(' \| ') %][% IF loop.first %][% info | html %][% END %][% END %]" class="compare" /> Compare</label>