From 89ade834d6460fe08aa69c3571e36cd117574c09 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 6 Jul 2021 17:28:19 +0200 Subject: [PATCH] Bug 24387: Rename "News" with "Additional contents" One big patch for one big move. The "News" feature (opac_news) has been hijacked to handle some system preferences (bug 26050). The goal was to take profit of the UI (editor) and the ability to translate the value. Disclaimer: This patch is NOT offering the best implementation but, as we still don't have bug 24975, it cannot be done now. And no, we don't want to wait for it to move forward here. This patch is going into the right direction anyway. This enhancement is going to rename the "News" with a more genertic "Additional contents". We have two different "categories" of content: "news" and "html customizations". What does it bring? - A split on the UI for disambigate the two types of content (news and syspref/html customizations) - A simplification of the edit form: all languages will be translatable on the same view (like the "notice templates") - Ground will be prepared for different types of content (if needed later) - Staff news can be translated How was the "News" area working before this patch? The opac_news DB table contained a (very inconsistent) 'lang' column. The different values were: - '' => news to display at the OPAC and staff interfaces - 'koha' => news for staff only - 'slip' => news for slip notices - $lang => news for OPAC only, translated in $lang ('en', 'es-ES', etc.) - "$location_$lang" => A syspref moved to this "news" area. The syspref is $location, and is translated in $lang. Eg. OpacLoginInstructions_en, OpacLoginInstructions_fr-FR, opacheader_es-ES This patch is improving the DB structure with the following changes: - renaming 'opac_news' with 'additional_contents' - new 'category' column => 'news' or 'html_customizations' - new 'location' column => For 'news': 'staff_and_opac', 'staff_only', 'slip' => For 'html_customizations': the old syspref name (eg. 'OpacLoginInstructions'). - new 'code' column (see later for more info) - the 'lang' column will only contain the language code ('en', 'es-ES', etc.). BUT a 'default' entry will ALWAYS exist for fallback behaviour. We are getting closer to the 'notice template' table structure because we want to match its UI. The 'code' column will bring us the ability to group the different 'additional_contents' rows. The code for a given news will be the same, but the (lang, title, content) will differ. Examples: News 1 will have, for each of the translated versions (category, code, location, branchcode) ('news', 'News1', $location, $branchcode||undef) And the 3 following columns will differ: (title, content, lang) ('title for news 1', 'content for news 1', 'default') ('titulo para 1', 'contenido para 1', 'es-ES') Note that the "category" is not strictely necessary, but it seems better to have the ability to split the different content by category/type easily. Additional changes: - Syspref 'NewsToolEditor' is renamed 'AdditionalContentsEditor' - Koha::NewItem => Koha::AdditionalContent - Koha::News => Koha::AdditionalContents - Script and template renamed from koha-news to additional-contents - Foreign keys have been renamed - Subpermission edit_news has been renamed edit_additional_contents - The UI can now be accessed via a "News" or "HTML customizations" link from the tools module. The related contents will then be displayed (both categories are now split) Changes not done here: - Primary key 'idnew' could be renamed 'id' Limitations of the upgrade: News cannot be grouped by a unique code for existing translations. => A given news will be now displayed several times on the translated interface Any ideas to improve the upgrade behaviour? We will have to add a warning in the release notes to tell libraries to review their news. Test plan: 0. Don't apply the patches 1. Translate the interfaces in some languages . Create some news for staff and OPAC . Create some content for different entry of HTML customizations Note that you are forced to define a 'default'. Also note that you are only forced to fill the title (not the content). This is certainly problematic (see FIXME in the code) as sometime only the content is displayed. . Play with the interface (edit, delete, filter) . Go to the different places the news are displayed, and confirm they are displayed correctly (staff home, opac home, opac rss) . Create 1+ news for 'slip', check an item out and 'print slip' (from the circulation page). You must see the news. . Go to the different places you are expecting the HTML customizations to be present and confirm that you see them. . Switch the lang of the interface and confirm that you now see the content in the translated version . Generate the templates in another language, don't translate the content . Use this language for the interface and confirm that the 'default' version is displauyed. Signed-off-by: Martin Renvoize Signed-off-by: Tomas Cohen Arazi Signed-off-by: Jonathan Druart --- C4/Letters.pm | 10 +- C4/Members.pm | 19 +- Koha/{NewsItem.pm => AdditionalContent.pm} | 18 +- Koha/AdditionalContents.pm | 134 ++++ Koha/Manual.pm | 2 +- Koha/News.pm | 114 ---- .../{KohaNews.pm => AdditionalContents.pm} | 41 +- .../data/mysql/atomicupdate/bug_24387.perl | 139 ++++ .../mysql/en/mandatory/sample_notices.yml | 6 +- .../data/mysql/en/optional/sample_news.yml | 2 +- .../mysql/fr-CA/facultatif/sample_news.sql | 2 +- .../fr-CA/obligatoire/sample_notices.sql | 2 +- .../fr-FR/1-Obligatoire/sample_notices.sql | 6 +- .../mysql/fr-FR/2-Optionel/sample_news.sql | 2 +- installer/data/mysql/kohastructure.sql | 32 +- installer/data/mysql/mandatory/sysprefs.sql | 2 +- .../data/mysql/mandatory/userpermissions.sql | 2 +- .../nb-NO/1-Obligatorisk/sample_notices.sql | 6 +- .../mysql/nb-NO/2-Valgfritt/sample_news.sql | 2 +- .../prog/en/includes/permissions.inc | 6 +- .../prog/en/includes/tools-menu.inc | 7 +- .../en/modules/admin/preferences/tools.pref | 4 +- .../prog/en/modules/intranet-main.tt | 8 +- .../en/modules/tools/additional-contents.tt | 602 ++++++++++++++++++ .../prog/en/modules/tools/koha-news.tt | 475 -------------- .../prog/en/modules/tools/tools-home.tt | 9 +- .../bootstrap/en/includes/masthead-sci.inc | 4 +- .../bootstrap/en/includes/masthead-sco.inc | 4 +- .../bootstrap/en/includes/masthead.inc | 8 +- .../bootstrap/en/includes/opac-bottom.inc | 4 +- .../bootstrap/en/modules/maintenance.tt | 4 +- .../bootstrap/en/modules/opac-auth.tt | 4 +- .../bootstrap/en/modules/opac-main.tt | 8 +- .../modules/opac-registration-confirmation.tt | 4 +- .../bootstrap/en/modules/opac-suggestions.tt | 4 +- .../bootstrap/en/modules/sci/sci-main.tt | 2 +- mainpage.pl | 12 +- opac/opac-main.pl | 15 +- opac/opac-news-rss.pl | 13 +- svc/letters/preview | 1 - t/db_dependent/Auth/haspermission.t | 24 +- .../Koha/{News.t => AdditionalContents.t} | 111 ++-- t/db_dependent/Letters/TemplateToolkit.t | 37 +- tools/additional-contents.pl | 229 +++++++ tools/koha-news.pl | 160 ----- tools/letter.pl | 2 +- 46 files changed, 1336 insertions(+), 966 deletions(-) rename Koha/{NewsItem.pm => AdditionalContent.pm} (83%) create mode 100644 Koha/AdditionalContents.pm delete mode 100644 Koha/News.pm rename Koha/Template/Plugin/{KohaNews.pm => AdditionalContents.pm} (61%) create mode 100644 installer/data/mysql/atomicupdate/bug_24387.perl create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/tools/additional-contents.tt delete mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tt rename t/db_dependent/Koha/{News.t => AdditionalContents.t} (62%) create mode 100755 tools/additional-contents.pl delete mode 100755 tools/koha-news.pl diff --git a/C4/Letters.pm b/C4/Letters.pm index a06f006ee1..87b82624c6 100644 --- a/C4/Letters.pm +++ b/C4/Letters.pm @@ -794,12 +794,12 @@ sub _parseletter_sth { ($table eq 'aqorders' ) ? "SELECT * FROM $table WHERE ordernumber = ?" : ($table eq 'aqbasket' ) ? "SELECT * FROM $table WHERE basketno = ?" : ($table eq 'illrequests' ) ? "SELECT * FROM $table WHERE illrequest_id = ?" : - ($table eq 'opac_news' ) ? "SELECT * FROM $table WHERE idnew = ?" : ($table eq 'article_requests') ? "SELECT * FROM $table WHERE id = ?" : ($table eq 'borrower_modifications') ? "SELECT * FROM $table WHERE verification_token = ?" : ($table eq 'subscription') ? "SELECT * FROM $table WHERE subscriptionid = ?" : ($table eq 'serial') ? "SELECT * FROM $table WHERE serialid = ?" : ($table eq 'problem_reports') ? "SELECT * FROM $table WHERE reportid = ?" : + ($table eq 'additional_contents' || $table eq 'opac_news') ? "SELECT * FROM additional_contents WHERE idnew = ?" : undef ; unless ($query) { warn "ERROR: No _parseletter_sth query for table '$table'"; @@ -1682,8 +1682,14 @@ sub _get_tt_params { plural => 'items', pk => 'itemnumber', }, + additional_contents => { + module => 'Koha::AdditionalContents', + singular => 'additional_content', + plural => 'additional_contents', + pk => 'idnew', + }, opac_news => { - module => 'Koha::News', + module => 'Koha::AdditionalContents', singular => 'news', plural => 'news', pk => 'idnew', diff --git a/C4/Members.pm b/C4/Members.pm index 73b254cb5e..210a9ea0de 100644 --- a/C4/Members.pm +++ b/C4/Members.pm @@ -33,7 +33,7 @@ use Koha::Database; use Koha::DateUtils qw( dt_from_string output_pref ); use Koha::Database; use Koha::Holds; -use Koha::News; +use Koha::AdditionalContents; use Koha::Patrons; use Koha::Patron::Categories; @@ -490,7 +490,7 @@ sub GetBorrowersToExpunge { - <> + <> ISSUEQSLIP: @@ -582,10 +582,14 @@ sub IssueSlip { issues => $all, }; } - my $news = Koha::News->search_for_display({ - location => 'slip', + my $news = Koha::AdditionalContents->search_for_display( + { + category => 'news', + location => 'slip', + lang => $patron->lang, library_id => $branch, - }); + } + ); my @news; while ( my $n = $news->next ) { my $all = $n->unblessed_all_relateds; @@ -597,7 +601,7 @@ sub IssueSlip { $all->{timestamp} = $published_on_dt; push @news, { - opac_news => $all, + additional_contents => $all, }; } $letter_code = 'ISSUESLIP'; @@ -609,7 +613,8 @@ sub IssueSlip { %loops = ( issues => [ map { $_->{issues}{itemnumber} } @checkouts ], overdues => [ map { $_->{issues}{itemnumber} } @overdues ], - opac_news => [ map { $_->{opac_news}{idnew} } @news ], + opac_news => [ map { $_->{additional_contents}{idnew} } @news ], + additional_contents => [ map { $_->{additional_contents}{idnew} } @news ], ); } diff --git a/Koha/NewsItem.pm b/Koha/AdditionalContent.pm similarity index 83% rename from Koha/NewsItem.pm rename to Koha/AdditionalContent.pm index 152e777023..c0c321458f 100644 --- a/Koha/NewsItem.pm +++ b/Koha/AdditionalContent.pm @@ -1,4 +1,4 @@ -package Koha::NewsItem; +package Koha::AdditionalContent; # Copyright ByWater Solutions 2015 # @@ -29,9 +29,7 @@ use base qw(Koha::Object); =head1 NAME -Koha::NewsItem - Koha News Item object class - -Koha::NewsItem represents a single piece of news from the opac_news table +Koha::AdditionalContent - Koha Additional content object class =head1 API @@ -41,9 +39,9 @@ Koha::NewsItem represents a single piece of news from the opac_news table =head3 author - $newsitem->author; + $additional_content->author; -Return the Koha::Patron object for the patron who authored this news item +Return the Koha::Patron object for the patron who authored this additional content =cut @@ -56,9 +54,9 @@ sub author { =head3 is_expired -my $is_expired = $news_item->is_expired; +my $is_expired = $additional_content->is_expired; -Returns 1 if the news item is expired or 0; +Returns 1 if the additional content is expired or 0; =cut @@ -72,7 +70,7 @@ sub is_expired { =head3 library -my $library = $news_item->library; +my $library = $additional_content->library; Returns Koha::Library object or undef @@ -92,7 +90,7 @@ sub library { =cut sub _type { - return 'OpacNews'; + return 'AdditionalContent'; } =head1 AUTHOR diff --git a/Koha/AdditionalContents.pm b/Koha/AdditionalContents.pm new file mode 100644 index 0000000000..fa32aa6318 --- /dev/null +++ b/Koha/AdditionalContents.pm @@ -0,0 +1,134 @@ +package Koha::AdditionalContents; + +# Copyright ByWater Solutions 2015 +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . + +use Modern::Perl; + +use Koha::Database; +use Koha::Exceptions; +use Koha::AdditionalContent; + +use base qw(Koha::Objects); + +=head1 NAME + +Koha::AdditionalContents - Koha Additional content object set class + +=head1 API + +=head2 Class Methods + +=cut + +=head3 search_for_display + +my $contents = Koha::AdditionalContents->search_for_display({ + category => 'news', # news or html_customizations + location => 'slip', + lang => 'es-ES', + library_id => $branchcode +}) + +Return Koha::AdditionalContents set for display to user + +You can limit the results by location, language and library by optional params + +library_id should be valid branchcode of defined library + +location is one of this: +- slip - for ISSUESLIP notice +- staff_only - for intranet +- opac_only - for OPAC +- staff_and_opac - for intranet and online catalogue +- OpacNavRight - Right column in the online catalogue +- opacheader +- OpacCustomSearch +- OpacMainUserBlock +- opaccredits +- OpacLoginInstructions +- OpacSuggestionInstructions +- ArticleRequestsDisclaimerText + +=cut + +sub search_for_display { + my ( $self, $params ) = @_; + + my $search_params; + $search_params->{location} = $params->{location}; + $search_params->{branchcode} = [ $params->{library_id}, undef ] if $params->{library_id}; + $search_params->{published_on} = { '<=' => \'NOW()' }; + $search_params->{-or} = [ expirationdate => { '>=' => \'NOW()' }, + expirationdate => undef ]; + + if ( $params->{lang} ) { + # FIXME I am failing to translate the following query + # SELECT a1.category, a1.code, COALESCE(a2.title, a1.title) + # FROM additional_contents a1 + # LEFT JOIN additional_contents a2 on a1.code=a2.code AND a2.lang="es-ES" + # WHERE a1.lang = 'default'; + + # So we are retrieving the code with a translated content, then the other ones + my $translated_contents = + $self->SUPER::search( { %$search_params, lang => $params->{lang} } ); + my $default_contents = $self->SUPER::search( + { + %$search_params, + lang => 'default', + code => + { '-not_in' => [ $translated_contents->get_column('code') ] } + } + ); + + return $self->SUPER::search( + { + idnew => [ + $translated_contents->get_column('idnew'), + $default_contents->get_column('idnew') + ] + }, + { order_by => 'number' } + ); + } + + return $self->SUPER::search({%$search_params, lang => 'default'}, { order_by => 'number'}); +} + +=head3 _type + +=cut + +sub _type { + return 'AdditionalContent'; +} + +=head3 object_class + +=cut + +sub object_class { + return 'Koha::AdditionalContent'; +} + +=head1 AUTHOR + +Kyle M Hall + +=cut + +1; diff --git a/Koha/Manual.pm b/Koha/Manual.pm index a69c079806..30a815545e 100644 --- a/Koha/Manual.pm +++ b/Koha/Manual.pm @@ -215,7 +215,7 @@ our $mapping = { 'tools/holidays' => '/tools.html#calendar', 'tools/import_borrowers' => '/tools.html#patron-import', 'tools/inventory' => '/tools.html#inventory-stocktaking', - 'tools/koha-news' => '/tools.html#news', + 'tools/additional-contents' => '/tools.html#news', # FIXME Needs a change to the manual 'tools/letter' => '/tools.html#notices-slips', 'tools/manage-marc-import' => '/tools.html#staged-marc-record-management', 'tools/marc_modification_templates' => '/tools.html#marc-modification-templates', diff --git a/Koha/News.pm b/Koha/News.pm deleted file mode 100644 index 5bb78a6a30..0000000000 --- a/Koha/News.pm +++ /dev/null @@ -1,114 +0,0 @@ -package Koha::News; - -# Copyright ByWater Solutions 2015 -# -# This file is part of Koha. -# -# Koha is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. -# -# Koha is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Koha; if not, see . - -use Modern::Perl; - - -use Koha::Database; -use Koha::Exceptions; -use Koha::NewsItem; - -use base qw(Koha::Objects); - -=head1 NAME - -Koha::News - Koha News object set class - -=head1 API - -=head2 Class Methods - -=cut - -=head3 search_for_display - -my $news = Koha::News->search_for_display({ - location => 'slip', - lang => 'en', - library_id => $branchcode -}) - -Return Koha::News set for display to user - -You can limit the results by location, language and library by optional params - -library_id should be valid branchcode of defined library - -type is one of this: -- slip - for ISSUESLIP notice -- koha - for intranet -- opac - for online catalogue -- OpacNavRight - Right column in the online catalogue -- OpacLoginInstructions -- OpacMainUserBlock -- OpacCustomSearch -- opacheader -- opaccredits - -lang is language code - it is used only when type is opac or any of OPAC locations - -=cut - -sub search_for_display { - my ( $self, $params ) = @_; - - my $search_params; - if ($params->{location} ) { - if ( $params->{location} eq 'slip' || $params->{location} eq 'koha') { - $search_params->{lang} = [ $params->{location}, '' ]; - } elsif ( $params->{location} eq 'opac' && $params->{lang} ) { - $search_params->{lang} = [ $params->{lang}, '' ]; - } elsif ( $params->{lang} ) { - $search_params->{lang} = $params->{location} . '_' . $params->{lang}; - } else { - Koha::Exceptions::BadParameter->throw("The location ($params->{location}) and lang ($params->{lang}) parameters combination is not valid"); - } - } - - $search_params->{branchcode} = [ $params->{library_id}, undef ] if $params->{library_id}; - $search_params->{published_on} = { '<=' => \'NOW()' }; - $search_params->{-or} = [ expirationdate => { '>=' => \'NOW()' }, - expirationdate => undef ]; - - return $self->SUPER::search($search_params, { order_by => 'number' }); -} - -=head3 _type - -=cut - -sub _type { - return 'OpacNews'; -} - -=head3 object_class - -=cut - -sub object_class { - return 'Koha::NewsItem'; -} - -=head1 AUTHOR - -Kyle M Hall - -=cut - -1; diff --git a/Koha/Template/Plugin/KohaNews.pm b/Koha/Template/Plugin/AdditionalContents.pm similarity index 61% rename from Koha/Template/Plugin/KohaNews.pm rename to Koha/Template/Plugin/AdditionalContents.pm index 75669de861..c37abece4e 100644 --- a/Koha/Template/Plugin/KohaNews.pm +++ b/Koha/Template/Plugin/AdditionalContents.pm @@ -1,4 +1,4 @@ -package Koha::Template::Plugin::KohaNews; +package Koha::Template::Plugin::AdditionalContents; # Copyright ByWater Solutions 2012 # Copyright BibLibre 2014 @@ -26,31 +26,32 @@ use base qw( Template::Plugin ); use C4::Koha; use C4::Context; -use Koha::News; +use Koha::AdditionalContents; sub get { my ( $self, $params ) = @_; - my $display_location = $params->{location}; + my $category = $params->{category}; + my $location = $params->{location}; my $blocktitle = $params->{blocktitle}; - my $lang = $params->{lang} || 'en'; - my $library = $params->{library}; - - my $content = Koha::News->search_for_display({ - location => $display_location, - lang => $lang, + my $lang = $params->{lang} || 'default'; + my $library = $params->{library}; + + my $content = Koha::AdditionalContents->search_for_display( + { + category => $category, + location => $location, + lang => $lang, library_id => $library, - }); - + } + ); - if( $content->count ){ + if ( $content->count ) { return { - content => $content, - location => $display_location, + content => $content, + location => $location, blocktitle => $blocktitle }; - } else { - return; } } @@ -58,20 +59,20 @@ sub get { =head1 NAME -Koha::Template::Plugin::KohaNews - TT Plugin for displaying Koha news +Koha::Template::Plugin::AdditionalContents - TT Plugin for displaying additional contents =head1 SYNOPSIS -[% USE KohaNews %] +[% USE AdditionalContents %] -[% KohaNews.get() %] +[% AdditionalContents.get() %] =head1 ROUTINES =head2 get In a template, you can get the all categories with -the following TT code: [% KohaNews.get() %] +the following TT code: [% AdditionalContents.get() %] =head1 AUTHOR diff --git a/installer/data/mysql/atomicupdate/bug_24387.perl b/installer/data/mysql/atomicupdate/bug_24387.perl new file mode 100644 index 0000000000..26e3681ae8 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_24387.perl @@ -0,0 +1,139 @@ +$DBversion = 'XXX'; # will be replaced by the RM +if( CheckVersion( $DBversion ) ) { + + if( TableExists('opac_news') ) { + $dbh->do(q| + ALTER TABLE opac_news RENAME additional_contents + |); + } + + if ( foreign_key_exists('additional_contents', 'opac_news_branchcode_ibfk') ) { + + $dbh->do(q| + ALTER TABLE additional_contents + DROP KEY borrowernumber_fk, + DROP KEY opac_news_branchcode_ibfk, + DROP FOREIGN KEY borrowernumber_fk, + DROP FOREIGN KEY opac_news_branchcode_ibfk + |); + + $dbh->do(q| + ALTER TABLE additional_contents + ADD CONSTRAINT additional_contents_borrowernumber_fk + FOREIGN KEY (borrowernumber) + REFERENCES borrowers (borrowernumber) ON DELETE SET NULL ON UPDATE CASCADE + |); + + $dbh->do(q| + ALTER TABLE additional_contents + ADD CONSTRAINT additional_contents_branchcode_ibfk + FOREIGN KEY (branchcode) + REFERENCES branches (branchcode) ON DELETE CASCADE ON UPDATE CASCADE + |); + } + + $dbh->do(q| + UPDATE letter + SET content = REGEXP_REPLACE(content, '<<\\\\s*opac_news\.', '<do(q| + UPDATE letter + SET content = REGEXP_REPLACE(content, '\\\\[%\\\\s*opac_news\.', '[% additional_contents.') + |); + + $dbh->do(q| + UPDATE systempreferences + SET variable="AdditionalContentsEditor" + WHERE variable="NewsToolEditor" + |); + + $dbh->do(q| + UPDATE permissions + SET code="edit_additional_contents" + WHERE code="edit_news" + |); + + unless ( column_exists('additional_contents', 'category' ) ) { + $dbh->do(q| + ALTER TABLE additional_contents + ADD COLUMN `category` VARCHAR(20) NOT NULL COMMENT 'category for the additional content' + AFTER `idnew` + |); + } + unless ( column_exists('additional_contents', 'location' ) ) { + $dbh->do(q| + ALTER TABLE additional_contents + ADD COLUMN `location` VARCHAR(255) NOT NULL COMMENT 'location of the additional content' + AFTER `category` + |); + } + + unless ( column_exists('additional_contents', 'code' ) ) { + $dbh->do(q| + ALTER TABLE additional_contents + ADD COLUMN `code` VARCHAR(100) NOT NULL COMMENT 'code to group content per lang' + AFTER `category` + |); + } + + my $contents = $dbh->selectall_arrayref(q|SELECT * FROM additional_contents|, { Slice => {} }); + for my $c ( @$contents ) { + my ( $category, $location, $new_lang ); + if ( $c->{lang} eq '' ) { + $category = 'news'; + $location = 'staff_and_opac'; + $new_lang = 'default'; + } elsif ( $c->{lang} eq 'koha' ) { + $category = 'news'; + $location = 'staff_only'; + $new_lang = 'default'; + } elsif ( $c->{lang} eq 'slip' ) { + $category = 'news'; + $location = 'slip'; + $new_lang = 'default'; + } elsif ( $c->{lang} =~ m|_| ) { + ( $location, $new_lang ) = split '_', $c->{lang}; + $category = 'html_customizations' + } else { + $category = 'news'; + $location = 'opac_only'; + $new_lang = $c->{lang}; + } + + die "There is something wrong here, we didn't find a valid category for idnew=" . $c->{idnew} unless $category; + + # Now this is getting weird + # We are adding an extra news with the same code when the lang is not "default" (/"en") + + $new_lang = "default" if $new_lang eq 'en'; # Assume that "en" is "default" + + my $sth_update = $dbh->prepare(q| + UPDATE additional_contents + SET category=?, location=?, lang=? + WHERE idnew=? + |); + + my $parent_idnew; + if ( $new_lang ne 'default' ) { + $dbh->do(q| + INSERT INTO additional_contents(category, code, location, branchcode, title, content, lang, published_on, updated_on, expirationdate, number, borrowernumber) + VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) + |, undef, $category, 'tmp_code', $location, $c->{branchcode}, $c->{title}, $c->{content}, 'default', $c->{published_on}, $c->{updated_on}, $c->{expirationdate}, $c->{number}, $c->{borrowernumber}); + + $parent_idnew = $dbh->last_insert_id(undef, undef, 'additional_contents', undef); + } + $sth_update->execute($category, $location, $new_lang, $c->{idnew}); + + my $idnew = $parent_idnew || $c->{idnew}; + my $code = ( grep {$_ eq $location} qw( staff_and_opac staff_only opac_only slip ) ) ? "${location}_$idnew" : "News_$idnew"; + $dbh->do(q|UPDATE additional_contents SET code=? WHERE idnew = ?|, undef, $code, $idnew) if $parent_idnew; + $dbh->do(q|UPDATE additional_contents SET code=? WHERE idnew = ?|, undef, $code, $idnew); + } + + $dbh->do(q| + ALTER TABLE additional_contents + ADD UNIQUE KEY additional_contents_uniq (`category`,`code`,`branchcode`,`lang`) + |); + + NewVersion( $DBversion, 24387, "Rename opac_news with additional_contents"); +} diff --git a/installer/data/mysql/en/mandatory/sample_notices.yml b/installer/data/mysql/en/mandatory/sample_notices.yml index db40a3a4cc..aae1fb558b 100644 --- a/installer/data/mysql/en/mandatory/sample_notices.yml +++ b/installer/data/mysql/en/mandatory/sample_notices.yml @@ -528,9 +528,9 @@ tables: - "

News

" - "" - "
" - - "
<>
" - - "

<>

" - - "

Posted on <>

" + - "
<>
" + - "

<>

" + - "

Posted on <>

" - "
" - "
" - "
" diff --git a/installer/data/mysql/en/optional/sample_news.yml b/installer/data/mysql/en/optional/sample_news.yml index badff452a3..8368027c65 100644 --- a/installer/data/mysql/en/optional/sample_news.yml +++ b/installer/data/mysql/en/optional/sample_news.yml @@ -21,7 +21,7 @@ description: - "Sample news items" tables: - - opac_news: + - additional_contents: translatable: [ title, content ] multiline: [ content ] rows: diff --git a/installer/data/mysql/fr-CA/facultatif/sample_news.sql b/installer/data/mysql/fr-CA/facultatif/sample_news.sql index a0d6c48913..d525626175 100644 --- a/installer/data/mysql/fr-CA/facultatif/sample_news.sql +++ b/installer/data/mysql/fr-CA/facultatif/sample_news.sql @@ -1 +1 @@ -INSERT INTO `opac_news` (`title`, `content`, `lang`, `published_on`, `expirationdate`, `number`) VALUES ('Bienvenue dans Koha !','Bienvenue dans Koha, la toute nouvelle version du système intégré de gestion de bibliothèque (SIGB) open source de référence. Développé initialement en Nouvelle Zélande et déployé pour la première fois en janvier 2000, Koha est un projet international soutenu par des sociétés de services en logiciels libres et par des bibliothécaires du monde entier.','koha','2008-01-14 03:25:58','2099-01-10',1),('Et maintenant ?','Félicitations ! vous avez désormais une version opérationnelle de Koha. Et maintenant, que faire ?\r\n\r\n','koha','2008-01-14 03:34:45','2099-01-10',2); +INSERT INTO `additional_contents` (`title`, `content`, `lang`, `published_on`, `expirationdate`, `number`) VALUES ('Bienvenue dans Koha !','Bienvenue dans Koha, la toute nouvelle version du système intégré de gestion de bibliothèque (SIGB) open source de référence. Développé initialement en Nouvelle Zélande et déployé pour la première fois en janvier 2000, Koha est un projet international soutenu par des sociétés de services en logiciels libres et par des bibliothécaires du monde entier.','koha','2008-01-14 03:25:58','2099-01-10',1),('Et maintenant ?','Félicitations ! vous avez désormais une version opérationnelle de Koha. Et maintenant, que faire ?\r\n\r\n','koha','2008-01-14 03:34:45','2099-01-10',2); diff --git a/installer/data/mysql/fr-CA/obligatoire/sample_notices.sql b/installer/data/mysql/fr-CA/obligatoire/sample_notices.sql index 3bb351231f..5cd66e49e1 100644 --- a/installer/data/mysql/fr-CA/obligatoire/sample_notices.sql +++ b/installer/data/mysql/fr-CA/obligatoire/sample_notices.sql @@ -4,7 +4,7 @@ INSERT INTO `letter` (module, code, branchcode, name, is_html, title, content, m ('circulation','DUE','','Document à rendre aujourd\'hui',0,'Document à rendre aujourd\'hui','Bonjour <> <>,\r\n\r\nLe prêt de ce document arrive à expiration aujourd\'hui.\r\n\r\n<>, <> (<>)\r\n\r\nMerci de nous le retourner.\r\n\r\n<>','email'), ('circulation','DUEDGST','','Document à rendre aujourd\'hui (Résumé)',0,'Document à rendre aujourd\'hui','Bonjour <> <>,\r\n\r\nVous avez <> document(s) dont le prêt arrive à expiration.\r\n\r\nMerci de nous le(s) retourner rapidement.\r\n\r\n<>','email'), ('circulation','ISSUEQSLIP','','Ticket rapide de prêts',1,'Ticket rapide de prêts','

<>

\r\nEmprunté par <> <>
\r\n(<>)
\r\n\r\n<>
\r\n\r\n

Emprunté(s) aujourd\'hui

\r\n\r\n

\r\n<>
\r\nCode-barres : <>
\r\nDate de retour : <>
\r\n

\r\n
','email'), -('circulation','ISSUESLIP','','Ticket de prêts',1,'Ticket de prêts','

<>

\r\nEmprunté par <> <>
\r\n(<>)
\r\n\r\n<>
\r\n\r\n

Emprunté(s) aujourd\'hui

\r\n\r\n

\r\n<>
\r\nCode-barres : <>
\r\nDate de retour : <>
\r\n

\r\n
\r\n\r\n

Retards

\r\n\r\n

\r\n<>
\r\nCode-barres : <>
\r\nDate de retour : <>
\r\n

\r\n
\r\n\r\n
\r\n\r\n

Nouvelles

\r\n\r\n
\r\n
<>
\r\n

<>

\r\n

Publiée le <>

\r\n
\r\n
\r\n
','email'), +('circulation','ISSUESLIP','','Ticket de prêts',1,'Ticket de prêts','

<>

\r\nEmprunté par <> <>
\r\n(<>)
\r\n\r\n<>
\r\n\r\n

Emprunté(s) aujourd\'hui

\r\n\r\n

\r\n<>
\r\nCode-barres : <>
\r\nDate de retour : <>
\r\n

\r\n
\r\n\r\n

Retards

\r\n\r\n

\r\n<>
\r\nCode-barres : <>
\r\nDate de retour : <>
\r\n

\r\n
\r\n\r\n
\r\n\r\n

Nouvelles

\r\n\r\n
\r\n
<>
\r\n

<>

\r\n

Publiée le <>

\r\n
\r\n
\r\n
','email'), ('circulation','ODUE','','Document(s) en retard',0,'Document(s) en retard','Bonjour <> <>,\r\n\r\nSelon nos informations, vous avez au moins un document en retard. Merci de retourner ou renouveller ce ou ces documents dans votre bibliothèque le plus rapidement possible.\r\n\r\n<>\r\n<>\r\n<> <>\r\nTél : <>\r\nFax : <>\r\nCourriel : <>\r\n\r\nSi vous avez le mot de passe de votre compte lecteur, vous pouvez renouveler directement en ligne. Sinon, merci de nous contacter.\r\n\r\nLe ou les documents suivants sont en retard :\r\n\r\n\"<>\" par <>, <>, code-barres : <> Amende : <>\r\n\r\nMerci de votre attention.\r\n\r\n<>','email'), ('circulation','PREDUE','','Document à rendre bientôt',0,'Document à rendre bientôt','Bonjour <> <>,\r\n\r\nNous souhaitons vous informer que le prêt de ce document arrive bientôt à expiration :\r\n\r\n<>, <> (<>)\r\n\r\nMerci.\r\n\r\n<>','email'), ('circulation','PREDUEDGST','','Document à rendre bientôt (Résumé)',0,'Document(s) à rendre bientôt','Bonjour <> <>,\r\n\r\nVous avez <> document(s) dont le prêt arrive bientôt à expiration.\r\n\r\n<>','email'), diff --git a/installer/data/mysql/fr-FR/1-Obligatoire/sample_notices.sql b/installer/data/mysql/fr-FR/1-Obligatoire/sample_notices.sql index 22bb673a68..a0cee7092e 100644 --- a/installer/data/mysql/fr-FR/1-Obligatoire/sample_notices.sql +++ b/installer/data/mysql/fr-FR/1-Obligatoire/sample_notices.sql @@ -98,9 +98,9 @@ Retour le : <>

Nouvelles

-
<>
-

<>

-

Posted on <>

+
<>
+

<>

+

Posted on <>


', 1), diff --git a/installer/data/mysql/fr-FR/2-Optionel/sample_news.sql b/installer/data/mysql/fr-FR/2-Optionel/sample_news.sql index a0d6c48913..d525626175 100644 --- a/installer/data/mysql/fr-FR/2-Optionel/sample_news.sql +++ b/installer/data/mysql/fr-FR/2-Optionel/sample_news.sql @@ -1 +1 @@ -INSERT INTO `opac_news` (`title`, `content`, `lang`, `published_on`, `expirationdate`, `number`) VALUES ('Bienvenue dans Koha !','Bienvenue dans Koha, la toute nouvelle version du système intégré de gestion de bibliothèque (SIGB) open source de référence. Développé initialement en Nouvelle Zélande et déployé pour la première fois en janvier 2000, Koha est un projet international soutenu par des sociétés de services en logiciels libres et par des bibliothécaires du monde entier.','koha','2008-01-14 03:25:58','2099-01-10',1),('Et maintenant ?','Félicitations ! vous avez désormais une version opérationnelle de Koha. Et maintenant, que faire ?\r\n\r\n','koha','2008-01-14 03:34:45','2099-01-10',2); +INSERT INTO `additional_contents` (`title`, `content`, `lang`, `published_on`, `expirationdate`, `number`) VALUES ('Bienvenue dans Koha !','Bienvenue dans Koha, la toute nouvelle version du système intégré de gestion de bibliothèque (SIGB) open source de référence. Développé initialement en Nouvelle Zélande et déployé pour la première fois en janvier 2000, Koha est un projet international soutenu par des sociétés de services en logiciels libres et par des bibliothécaires du monde entier.','koha','2008-01-14 03:25:58','2099-01-10',1),('Et maintenant ?','Félicitations ! vous avez désormais une version opérationnelle de Koha. Et maintenant, que faire ?\r\n\r\n','koha','2008-01-14 03:34:45','2099-01-10',2); diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index da14acace2..8e5348edff 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -3891,28 +3891,32 @@ CREATE TABLE `old_reserves` ( /*!40101 SET character_set_client = @saved_cs_client */; -- --- Table structure for table `opac_news` +-- Table structure for table `additional_contents` -- -DROP TABLE IF EXISTS `opac_news`; +DROP TABLE IF EXISTS `additional_contents`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; -CREATE TABLE `opac_news` ( - `idnew` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'unique identifier for the news article', - `branchcode` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'branch code users to create branch specific news, NULL is every branch.', - `title` varchar(250) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT 'title of the news article', - `content` mediumtext COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'the body of your news article', - `lang` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT 'location for the article (koha is the staff interface, slip is the circulation receipt and language codes are for the opac)', +CREATE TABLE `additional_contents` ( + `idnew` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'unique identifier for the additional content', + `category` varchar(20) NOT NULL COMMENT 'category for the additional content', + `code` varchar(20) NOT NULL COMMENT 'code to group content per lang', + `location` varchar(255) NOT NULL COMMENT 'location of the additional content', + `branchcode` varchar(10) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'branch code users to create branch specific additional content, NULL is every branch.', + `title` varchar(250) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT 'title of the additional content', + `content` mediumtext COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'the body of your additional content', + `lang` varchar(25) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT 'location for the additional content(koha is the staff interface, slip is the circulation receipt and language codes are for the opac)', `published_on` date DEFAULT NULL COMMENT 'publication date', `updated_on` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp() COMMENT 'last modification', - `expirationdate` date DEFAULT NULL COMMENT 'date the article is set to expire or no longer be visible', - `number` int(11) DEFAULT NULL COMMENT 'the order in which this article appears in that specific location', - `borrowernumber` int(11) DEFAULT NULL COMMENT 'The user who created the news article', + `expirationdate` date DEFAULT NULL COMMENT 'date the additional content is set to expire or no longer be visible', + `number` int(11) DEFAULT NULL COMMENT 'the order in which this additional content appears in that specific location', + `borrowernumber` int(11) DEFAULT NULL COMMENT 'The user who created the additional content', PRIMARY KEY (`idnew`), - KEY `borrowernumber_fk` (`borrowernumber`), - KEY `opac_news_branchcode_ibfk` (`branchcode`), + UNIQUE KEY `additional_contents_uniq` (`category`,`code`,`branchcode`,`lang`), + KEY `additional_contents_borrowernumber_fk` (`borrowernumber`), + KEY `additional_contents_branchcode_ibfk` (`branchcode`), CONSTRAINT `borrowernumber_fk` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE, - CONSTRAINT `opac_news_branchcode_ibfk` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `additional_contents_branchcode_ibfk` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index c98d6032a2..ee2954d02f 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -9,6 +9,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('AcquisitionLog','0',NULL,'If ON, log acquisitions activity','YesNo'), ('AcqViewBaskets','user','user|branch|all','Define which baskets a user is allowed to view: their own only, any within their branch, or all','Choice'), ('AcqWarnOnDuplicateInvoice','0','','Warn librarians when they try to create a duplicate invoice','YesNo'), +('AdditionalContentsEditor','tinymce','tinymce|codemirror','Choose tool for editing News.', 'Choice'), ('AdditionalFieldsInZ3950ResultSearch', '', NULL, 'Determines which MARC field/subfields are displayed in -Additional field- column in the result of a search Z3950', 'Free'), ('AddressForFailedOverdueNotices', '', NULL, 'Destination email for failed overdue notices. If left empty then it will fallback to the first defined address in the following list: Library ReplyTo, Library Email, ReplytoDefault and KohaAdminEmailAddress', 'free'), ('AddressFormat','us','us|de|fr','Choose format to display postal addresses', 'Choice'), @@ -349,7 +350,6 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('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'), ('NoIssuesChargeGuarantorsWithGuarantees','','','Define maximum amount withstanding before checkouts are blocked including guarantors and their other guarantees','Integer'), diff --git a/installer/data/mysql/mandatory/userpermissions.sql b/installer/data/mysql/mandatory/userpermissions.sql index edb52f0fdd..f1c2d8883b 100644 --- a/installer/data/mysql/mandatory/userpermissions.sql +++ b/installer/data/mysql/mandatory/userpermissions.sql @@ -74,7 +74,7 @@ INSERT INTO permissions (module_bit, code, description) VALUES (11, 'merge_invoices', 'Merge invoices'), (11, 'delete_baskets', 'Delete baskets'), (12, 'suggestions_manage', 'Manage purchase suggestions'), - (13, 'edit_news', 'Write news for the OPAC and staff interfaces'), + (13, 'edit_additional_contents', 'Write additional contents for the OPAC and staff interfaces (news and HTML customizations)'), (13, 'label_creator', 'Create printable labels and barcodes from catalog and patron data'), (13, 'edit_calendar', 'Define days when the library is closed'), (13, 'moderate_comments', 'Moderate patron comments'), diff --git a/installer/data/mysql/nb-NO/1-Obligatorisk/sample_notices.sql b/installer/data/mysql/nb-NO/1-Obligatorisk/sample_notices.sql index 14d500af76..bf54ff7735 100644 --- a/installer/data/mysql/nb-NO/1-Obligatorisk/sample_notices.sql +++ b/installer/data/mysql/nb-NO/1-Obligatorisk/sample_notices.sql @@ -118,9 +118,9 @@ Innleveringsfrist: <>

Nyheter

-
<>
-

<>

-

Publisert <>

+
<>
+

<>

+

Publisert <>


', 1), diff --git a/installer/data/mysql/nb-NO/2-Valgfritt/sample_news.sql b/installer/data/mysql/nb-NO/2-Valgfritt/sample_news.sql index fb7cba9884..ec23a419c5 100644 --- a/installer/data/mysql/nb-NO/2-Valgfritt/sample_news.sql +++ b/installer/data/mysql/nb-NO/2-Valgfritt/sample_news.sql @@ -1,2 +1,2 @@ -INSERT INTO `opac_news` (`title`, `content`, `lang`, `published_on`, `expirationdate`, `number`) VALUES ('Velkommen til Koha!','Velkommen til Koha. Koha er et biblioteksystem rikt på funksjoner. Koha ble opprinnelig utviklet i New Zealand av Katipo Communications Ltd og først tatt i bruk i januar 2000 av Horowhenua Library Trust. I dag vedlikeholdes Koha av et verdensomspennende fellesskap av bibliotek og leverandører.','koha',DATE_SUB(NOW(), INTERVAL 1 DAY),'2099-01-10',1), +INSERT INTO `additional_contents` (`title`, `content`, `lang`, `published_on`, `expirationdate`, `number`) VALUES ('Velkommen til Koha!','Velkommen til Koha. Koha er et biblioteksystem rikt på funksjoner. Koha ble opprinnelig utviklet i New Zealand av Katipo Communications Ltd og først tatt i bruk i januar 2000 av Horowhenua Library Trust. I dag vedlikeholdes Koha av et verdensomspennende fellesskap av bibliotek og leverandører.','koha',DATE_SUB(NOW(), INTERVAL 1 DAY),'2099-01-10',1), ('Hva nå?','Hva kan du gjøre nå som du har installert Koha? Her er noen forslag:\r\n\r\n','koha',DATE_SUB(NOW(), INTERVAL 1 DAY),'2099-01-10',2); diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc index 1ffce70b1f..cc253be52e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc @@ -445,9 +445,9 @@ Define days when the library is closed ([% name | html %]) - [%- CASE 'edit_news' -%] - - Write news for the OPAC and staff interfaces + [%- CASE 'edit_additional_contents' -%] + + Write additional contents for the OPAC and staff interfaces (news and HTML customizations) ([% name | html %]) [%- CASE 'edit_notice_status_triggers' -%] diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/tools-menu.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/tools-menu.inc index cf2b0c887e..0b5f33110f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/tools-menu.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/tools-menu.inc @@ -94,7 +94,7 @@ [% END %] [% END %] -[% IF ( CAN_user_tools_edit_calendar || CAN_user_tools_manage_csv_profiles || CAN_user_tools_view_system_logs || CAN_user_tools_edit_news || CAN_user_tools_schedule_tasks || CAN_user_tools_edit_quotes || ( Koha.ArePluginsEnabled() && CAN_user_plugins_tool ) || CAN_user_tools_upload_general_files || CAN_user_tools_access_files ) %] +[% IF ( CAN_user_tools_edit_calendar || CAN_user_tools_manage_csv_profiles || CAN_user_tools_view_system_logs || CAN_user_tools_edit_additional_contents || CAN_user_tools_schedule_tasks || CAN_user_tools_edit_quotes || ( Koha.ArePluginsEnabled() && CAN_user_plugins_tool ) || CAN_user_tools_upload_general_files || CAN_user_tools_access_files ) %]
Additional tools
    [% IF ( CAN_user_tools_edit_calendar ) %] @@ -106,8 +106,9 @@ [% IF ( CAN_user_tools_view_system_logs ) %]
  • Log viewer
  • [% END %] - [% IF ( CAN_user_tools_edit_news ) %] -
  • News
  • + [% IF ( CAN_user_tools_edit_additional_contents ) %] +
  • News
  • +
  • HTML customizations
  • [% END %] [% IF ( CAN_user_tools_schedule_tasks ) %]
  • Task scheduler
  • diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/tools.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/tools.pref index 33cef05398..4a569b4cae 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/tools.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/tools.pref @@ -38,8 +38,8 @@ Tools: both: "both OPAC and staff interface" - "." - - - By default edit news items with - - pref: NewsToolEditor + - By default edit additional contents and news items with + - pref: AdditionalContentsEditor choices: tinymce: "a WYSIWYG editor (TinyMCE)" codemirror: "a text editor (CodeMirror)" diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt index 01ac044783..0f56178b93 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt @@ -33,14 +33,14 @@
    [% koha_new.content | $raw %]

    Posted on [% koha_new.published_on | $KohaDates %][% IF( show_author && koha_new.author ) %] by [% INCLUDE 'patron-title.inc' patron=koha_new.author %]
    [% END %] [% IF ( CAN_user_tools ) %] - Edit - | Delete - | New + Edit + | Delete + | New [% END %]

    [% END %] - + [% END %] [% IF ( daily_quote ) %]
    diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/additional-contents.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/additional-contents.tt new file mode 100644 index 0000000000..8aebc2f012 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/additional-contents.tt @@ -0,0 +1,602 @@ +[% USE raw %] +[% USE Asset %] +[% USE Koha %] +[% USE KohaDates %] +[% USE Branches %] +[% SET footerjs = 1 %] +[% INCLUDE 'doc-head-open.inc' %] +Additional contents › Tools › Koha +[% INCLUDE 'doc-head-close.inc' %] +[% UNLESS ( wysiwyg ) %] + [% Asset.css("lib/codemirror/codemirror.css") | $raw %] + [% Asset.css("lib/codemirror/lint.min.css") | $raw %] + +[% END %] + + + +[% INCLUDE 'header.inc' %] +[% INCLUDE 'cat-search.inc' %] + + + +[% IF op == 'add_form' %] +
    +
    +
    +[% ELSE %] +
    +
    +
    +[% END %] + +
    + + [% FOR m IN messages %] +
    + [% SWITCH m.code %] + [% CASE 'error_on_update' %] + An error occurred when updating this content. Perhaps it already exists. + [% CASE 'error_on_insert' %] + An error occurred when adding this content. Check the logs + [% CASE 'error_on_delete' %] + An error occurred when deleting this content. Check the logs. + [% CASE 'success_on_update' %] + Content updated successfully. + [% CASE 'success_on_insert' %] + Content added successfully. + [% CASE 'success_on_delete' %] + Content deleted successfully. + [% CASE %] + [% m.code | html %] + [% END %] +
    + [% END %] + + [% IF op == 'add_form' %] + [% PROCESS add_form %] + [% ELSE %] + [% PROCESS list %] + [% END %] + +
    + + [% IF op != 'add_form' %] +
    + +
    + +
    + [% END %] +
    +
    + +[% BLOCK add_form %] + [% IF additional_content %] +

    Modify an additional content

    + [% ELSE %] +

    New additional content ([% IF category == 'news' %]News[% ELSE %]HTML customizations[% END %])

    + [% END %] + +
    +
    + +
    + Cancel +
    + +
    + + + +
    +
      +
    1. + [% IF additional_content %] + Code: [% additional_content.code | html %] + + [% ELSE %] + + + Required + [% END %] +
    2. +
    3. + + +
    4. +
    5. + + +
    6. + [% UNLESS languages.size %] +
    7. + + Required +
    8. + [% END %] +
    9. + + +
      [% INCLUDE 'date-format.inc' %]
      +
    10. +
    11. + + +
      + [% INCLUDE 'date-format.inc' %] + [% IF category == 'news' %] +
      News will still be accessible by direct URL if expired. + [% END %] +
      +
    12. +
    13. + + [% IF ( additional_content.number ) %] + + [% ELSE %] + + [% END %] +
    14. +
    +
    + + [% IF languages.size %] +
    +
    + + + [% FOR language IN languages %] +
    +
    + +
    [%# FIXME We should remove list-style:none; and use class="rows" here but it does not work. Owen please help! %] +
      +
    1. + + +
    2. +
    3. + + + +
    4. +
    +
    +
    +
    + [% END %] +
    + [% ELSE %] +
    +
    + +
    +
    + [% END %] +
    +[% END %] + +[% BLOCK list %] + + + +

    Additional contents ([% IF category == 'news' %]News[% ELSE %]HTML customizations[% END %])

    + [% IF category == 'news' %] + See HTML customizations + [% ELSE %] + See News + [% END %] + + [% IF additional_contents.count %] +
    + + + + + + + + + + + + + + + + + [% FOREACH c IN additional_contents%] + [% IF ( c.is_expired ) %][% ELSE %][% END %] + + + + + + + + + + + + [% END %] + +
     LocationLibraryNumberPublication dateExpiration dateTitleAuthorNewsActions
    + + + [% IF c.category == 'news' %] + [% IF c.location == 'staff_and_opac' %]All + [% ELSIF c.location == 'staff_only' %]Librarian interface + [% ELSIF c.location == 'opac_only' %]OPAC + [% ELSIF c.location == 'slip' %]Slip + [% ELSE %]Unknown ('[% location %]') + [% END %] + [% ELSE %] + [% c.location %] + [% END %] + + [% IF ( c.branchcode == "" ) -%] + All libraries + [% ELSE %][% c.library.branchname | html %] + [% END %] + [% c.number | html %][% c.published_on | $KohaDates %][% c.expirationdate | $KohaDates %] [% IF ( c.is_expired ) %](expired)[% END %][% c.title | html %][% IF ( c.author) %][% INCLUDE 'patron-title.inc' patron=c.author %][% END %] + + + [% IF ( wysiwyg ) %] + [% SET editmode = "wysiwyg" %] + [% ELSE %] + [% SET editmode = "text" %] + [% END %] +
    + Edit + +
    +
    + Delete +
    +
    + +
    +
    + [% ELSE %] +
    There are no additional contents.
    + [% END %] +[% END %] + +[% BLOCK locations_options %] + [% IF category == 'news' %] + [% IF location == "staff_and_opac" %] + + [% ELSE %] + + [% END %] + + [% IF location == "staff_only" %] + + [% ELSE %] + + [% END %] + + [% IF location == "opac_only" %] + + [% ELSE %] + + [% END %] + + [% IF location == "slip" %] + + [% ELSE %] + + [% END %] + [% ELSE %] + [% FOREACH l IN [ 'OpacNavRight', 'opacheader', 'OpacCustomSearch', 'OpacMainUserBlock', 'opaccredits', 'OpacLoginInstructions', 'OpacSuggestionInstructions', 'ArticleRequestsDisclaimerText' ] %] + [% IF l == location %] + + [% ELSE %] + + [% END %] + [% END %] + [% END %] +[% END %] + +[% MACRO jsinclude BLOCK %] + [% INCLUDE 'calendar.inc' %] + [% Asset.js("js/tools-menu.js") | $raw %] + [% Asset.js("lib/hc-sticky.js") | $raw %] + [% IF additional_contents.count %] + [% INCLUDE 'datatables.inc' %] + + [% ELSE %] + + [% END %] + [% UNLESS ( wysiwyg ) %] + [% Asset.js( "lib/codemirror/codemirror.min.js" ) | $raw %] + [% Asset.js( "lib/codemirror/xml.min.js" ) | $raw %] + [% Asset.js( "lib/codemirror/lint.min.js" ) | $raw %] + [% Asset.js( "lib/linters/htmlhint.min.js" ) | $raw %] + [% Asset.js( "lib/codemirror/html-lint.min.js" ) | $raw %] + + [% ELSE %] + [% Asset.js("lib/tiny_mce/tinymce.min.js") | $raw %] + [% INCLUDE 'str/tinymce_i18n.inc' %] + + [% END # /UNLESS wysiwyg %] +[% END %] + +[% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tt deleted file mode 100644 index 35d7177291..0000000000 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tt +++ /dev/null @@ -1,475 +0,0 @@ -[% USE raw %] -[% USE Asset %] -[% USE Koha %] -[% USE KohaDates %] -[% USE Branches %] -[% SET footerjs = 1 %] -[% INCLUDE 'doc-head-open.inc' %] -News › Tools › Koha -[% INCLUDE 'doc-head-close.inc' %] -[% UNLESS ( wysiwyg ) %] - [% Asset.css("lib/codemirror/codemirror.css") | $raw %] - [% Asset.css("lib/codemirror/lint.min.css") | $raw %] - -[% END %] - - - -[% INCLUDE 'header.inc' %] -[% INCLUDE 'cat-search.inc' %] - - - -[% IF ( add_form ) %] -
    -
    -
    -[% ELSE %] -
    -
    -
    -[% END %] -
    - -[% UNLESS ( add_form ) %] - [% IF error_message == 'title_missing' %] -
    Error: Required news title missing!
    - [% END %] -

    News

    - -[% END %] - -[% IF ( add_form ) %] - [% IF ( op == 'add' ) %] - [% default_lang = lang %] - [% ELSE %] - [% default_lang = new_detail.lang %] - [% END %] -
    - - -
    - OPAC and Koha news -
    1. - - -
    2. -
    3. - - -
    4. -
    5. - - Required -
    6. -
    7. - - -
      [% INCLUDE 'date-format.inc' %]
      -
    8. -
    9. - - -
      - [% INCLUDE 'date-format.inc' %] -
      News will still be accessible by direct URL if expired. -
      -
    10. -
    11. - - [% IF ( new_detail.number ) %] - - [% ELSE %] - - [% END %] -
    12. -
    13. - -
    14. -
    -
    - -
    Cancel
    -
    - [% ELSE %] - [% IF ( opac_news.count ) %] -
    - - - - - - - - - - - - - - [% FOREACH opac_new IN opac_news %] - [% IF ( opac_new.is_expired ) %] - - [% ELSE %] - - [% END %] - - - - - - - - - - - - [% END %] -
     LocationLibraryNumberPublication dateExpiration dateTitleAuthorNewsActions
    - - [% SWITCH opac_new.lang %] - [% CASE "koha" %] - Librarian interface (koha) - [% CASE "slip" %] - Slip - [% CASE "" %] - All - [% CASE %] - OPAC ([% opac_new.lang | html %]) - [% END %] - [% IF ( opac_new.branchcode == "" ) -%] - All libraries - [% ELSE %][% opac_new.library.branchname | html %] - [% END %][% opac_new.number | html %][% opac_new.published_on | $KohaDates %][% opac_new.expirationdate | $KohaDates %] [% IF ( opac_new.is_expired ) %](expired)[% END %][% opac_new.title | html %][% IF ( opac_new.author) %][% INCLUDE 'patron-title.inc' patron=opac_new.author %][% END %] - - - [% IF ( wysiwyg ) %] - [% SET editmode = "wysiwyg" %] - [% ELSE %] - [% SET editmode = "text" %] - [% END %] -
    - Edit - -
    -
    - Delete -
    -
    - -
    -
    - [% ELSE %] -
    There are no news items.
    - [% END %] - [% END %] - -
    - [% UNLESS ( add_form ) %] -
    - -
    - -
    - [% END %] -
    -
    - - -[% MACRO jsinclude BLOCK %] - [% INCLUDE 'calendar.inc' %] - [% Asset.js("js/tools-menu.js") | $raw %] - [% IF ( opac_news.count ) %] - [% INCLUDE 'datatables.inc' %] - - [% END %] - [% UNLESS ( wysiwyg ) %] - [% Asset.js( "lib/codemirror/codemirror.min.js" ) | $raw %] - [% Asset.js( "lib/codemirror/xml.min.js" ) | $raw %] - [% Asset.js( "lib/codemirror/lint.min.js" ) | $raw %] - [% Asset.js( "lib/linters/htmlhint.min.js" ) | $raw %] - [% Asset.js( "lib/codemirror/html-lint.min.js" ) | $raw %] - - [% ELSE %] - [% Asset.js("lib/tiny_mce/tinymce.min.js") | $raw %] - [% INCLUDE 'str/tinymce_i18n.inc' %] - - [% END # /IF NewsToolEditor %] -[% END %] - -[% BLOCK lang_locations %] - [% IF ( language == "" ) %] - - [% ELSE %] - - [% END %] - [% IF ( language == "koha" ) %] - - [% ELSE %] - - [% END %] - [% IF ( language == "slip" ) %] - - [% ELSE %] - - [% END %] - [% FOREACH lang_lis IN lang_list %] - - [% FOREACH location IN [ '', 'OpacNavRight', 'opacheader', 'OpacCustomSearch', 'OpacMainUserBlock', 'opaccredits', 'OpacLoginInstructions', 'OpacSuggestionInstructions', 'ArticleRequestsDisclaimerText'] %] - [% IF ( location == '' ) %] - [% SET location_lang = lang_lis.language %] - [% location = BLOCK %]OPAC news[% END %] - [% ELSE %] - [% SET location_lang = location _ "_" _ lang_lis.language %] - [% END %] - [% IF ( location_lang == language ) %] - - [% ELSE %] - - [% END %] - [% END %] - - [% END %] -[% END %] - -[% INCLUDE 'intranet-bottom.inc' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt index 678fd2aab7..5d0d7f84cb 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/tools-home.tt @@ -95,7 +95,7 @@
    -[% IF ( CAN_user_tools_edit_calendar || CAN_user_tools_manage_csv_profiles || CAN_user_tools_view_system_logs || CAN_user_tools_edit_news || CAN_user_tools_schedule_tasks || CAN_user_tools_edit_quotes || ( Koha.ArePluginsEnabled() && CAN_user_plugins_tool ) || CAN_user_tools_upload_general_files || CAN_user_tools_access_files ) %] +[% IF ( CAN_user_tools_edit_calendar || CAN_user_tools_manage_csv_profiles || CAN_user_tools_view_system_logs || CAN_user_tools_edit_additional_contents || CAN_user_tools_schedule_tasks || CAN_user_tools_edit_quotes || ( Koha.ArePluginsEnabled() && CAN_user_plugins_tool ) || CAN_user_tools_upload_general_files || CAN_user_tools_access_files ) %]

    Additional tools

    [% END %]
    @@ -114,9 +114,12 @@
    Browse the system logs
    [% END %] - [% IF ( CAN_user_tools_edit_news ) %] -
    News
    + [% IF ( CAN_user_tools_edit_additional_contents ) %] +
    News
    Write news for the OPAC and staff interfaces
    + +
    HTML customizations
    +
    Write HTML customizations
    [% END %] [% IF ( CAN_user_tools_schedule_tasks ) %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead-sci.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead-sci.inc index fa51c437d6..b03cf6c537 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead-sci.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead-sci.inc @@ -1,9 +1,9 @@ [% USE raw %] [% USE Koha %] -[% USE KohaNews %] +[% USE AdditionalContents %] [% PROCESS 'html_helpers.inc' %] [% SET OpacLangSelectorMode = Koha.Preference('OpacLangSelectorMode') %] -[% SET OpacHeader = KohaNews.get( location => "opacheader", lang => lang, library => branchcode, blocktitle => 0 ) %] +[% SET OpacHeader = AdditionalContents.get( location => "opacheader", lang => lang, library => branchcode, blocktitle => 0 ) %]
    diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead-sco.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead-sco.inc index 3c872b95c6..254118387c 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead-sco.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead-sco.inc @@ -1,9 +1,9 @@ [% USE raw %] [% USE Koha %] -[% USE KohaNews %] +[% USE AdditionalContents %] [% PROCESS 'html_helpers.inc' %] [% SET OpacLangSelectorMode = Koha.Preference('OpacLangSelectorMode') %] -[% SET OpacHeader = KohaNews.get( location => "opacheader", lang => lang, library => branchcode, blocktitle => 0 ) %] +[% SET OpacHeader = AdditionalContents.get( location => "opacheader", lang => lang, library => branchcode, blocktitle => 0 ) %]
    diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc index 8626695290..7f482a340e 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc @@ -2,12 +2,12 @@ [% USE Koha %] [% USE Branches %] [% USE Categories %] -[% USE KohaNews %] +[% USE AdditionalContents %] [% PROCESS 'html_helpers.inc' %] [% SET OpacLangSelectorMode = Koha.Preference('OpacLangSelectorMode') %] -[% SET OpacHeader = KohaNews.get( location => "opacheader", lang => lang, library => branchcode, blocktitle => 0 ) %] -[% SET OpacCustomSearch = KohaNews.get( location => "OpacCustomSearch", lang => lang, library => branchcode, blocktitle => 0 ) %] -[% SET OpacLoginInstructions = KohaNews.get( location => "OpacLoginInstructions", lang => lang, library => branchcode ) %] +[% SET OpacHeader = AdditionalContents.get( location => "opacheader", lang => lang, library => branchcode, blocktitle => 0 ) %] +[% SET OpacCustomSearch = AdditionalContents.get( location => "OpacCustomSearch", lang => lang, library => branchcode, blocktitle => 0 ) %] +[% SET OpacLoginInstructions = AdditionalContents.get( location => "OpacLoginInstructions", lang => lang, library => branchcode ) %]
    diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc index c103f0ec4c..2d1a80da1d 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc @@ -1,9 +1,9 @@ [% USE raw %] [% USE Koha %] -[% USE KohaNews %] +[% USE AdditionalContents %] [%- USE KohaPlugins -%] [% USE Asset %] -[% SET opaccredits = KohaNews.get( location => "opaccredits", lang => lang, library => branchcode ) %] +[% SET opaccredits = AdditionalContents.get( location => "opaccredits", lang => lang, library => branchcode ) %] [% PROCESS 'html_helpers.inc' %] [% UNLESS ( is_popup ) %] [% SET OpacLangSelectorMode = Koha.Preference('OpacLangSelectorMode') %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/maintenance.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/maintenance.tt index 665d32087d..36908723f6 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/maintenance.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/maintenance.tt @@ -1,8 +1,8 @@ [% USE raw %] [% USE Koha %] -[% USE KohaNews %] +[% USE AdditionalContents %] [% INCLUDE 'doc-head-open.inc' %] -[% SET OpacHeader = KohaNews.get( location => "opacheader", lang => lang, library => branchcode, blocktitle => 0 ) %] +[% SET OpacHeader = AdditionalContents.get( location => "opacheader", lang => lang, library => branchcode, blocktitle => 0 ) %] [% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog [% INCLUDE 'doc-head-close.inc' %] [% BLOCK cssinclude %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-auth.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-auth.tt index 86211c8082..4e13defc68 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-auth.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-auth.tt @@ -1,9 +1,9 @@ [% USE raw %] [% USE Koha %] [% USE Categories %] -[% USE KohaNews %] +[% USE AdditionalContents %] [% PROCESS 'html_helpers.inc' %] -[% SET OpacLoginInstructions = KohaNews.get( location => "OpacLoginInstructions", lang => lang, library => branchcode ) %] +[% SET OpacLoginInstructions = AdditionalContents.get( location => "OpacLoginInstructions", lang => lang, library => branchcode ) %] [% INCLUDE 'doc-head-open.inc' %] [% IF Koha.Preference( 'opacuserlogin' ) == 1 %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt index 0dfabad069..d46100fcbe 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt @@ -4,11 +4,11 @@ [% USE Branches %] [% USE Categories %] [% USE Price %] -[% USE KohaNews %] +[% USE AdditionalContents %] [% PROCESS 'i18n.inc' %] -[% SET OpacNavRight = KohaNews.get( location => "OpacNavRight", lang => lang, library => branchcode ) %] -[% SET OpacMainUserBlock = KohaNews.get( location => "OpacMainUserBlock", lang => lang, library => branchcode ) %] -[% SET OpacLoginInstructions = KohaNews.get( location => "OpacLoginInstructions", lang => lang, library => branchcode ) %] +[% SET OpacNavRight = AdditionalContents.get( location => "OpacNavRight", lang => lang, library => branchcode ) %] +[% SET OpacMainUserBlock = AdditionalContents.get( location => "OpacMainUserBlock", lang => lang, library => branchcode ) %] +[% SET OpacLoginInstructions = AdditionalContents.get( location => "OpacLoginInstructions", lang => lang, library => branchcode ) %] [% INCLUDE 'doc-head-open.inc' %] <title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog [% INCLUDE 'doc-head-close.inc' %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-registration-confirmation.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-registration-confirmation.tt index 35f84bf57a..b688de43d1 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-registration-confirmation.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-registration-confirmation.tt @@ -1,7 +1,7 @@ [% USE raw %] [% USE Koha %] -[% USE KohaNews %] -[% SET OpacNavRight = KohaNews.get( location => "OpacNavRight", lang => news_lang, library => branchcode ) %] +[% USE AdditionalContents %] +[% SET OpacNavRight = AdditionalContents.get( location => "OpacNavRight", lang => news_lang, library => branchcode ) %] [% INCLUDE 'doc-head-open.inc' %] [% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog [% INCLUDE 'doc-head-close.inc' %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt index d02a89ad5d..485154bf5c 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-suggestions.tt @@ -4,8 +4,8 @@ [% USE Branches %] [% USE AuthorisedValues %] [% USE KohaDates %] -[% USE KohaNews %] -[% SET opacsuggestion = KohaNews.get( location => "OpacSuggestioninstructions", lang => lang, library => Branches.GetLoggedInBranchcode ) %] +[% USE AdditionalContents %] +[% SET opacsuggestion = AdditionalContents.get( location => "OpacSuggestioninstructions", lang => lang, library => Branches.GetLoggedInBranchcode ) %] [% INCLUDE 'doc-head-open.inc' %] [% IF ( op_add ) %]Enter a new purchase suggestion[% END %] [% IF ( op_else ) %]Purchase Suggestions[% END %] › diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/sci/sci-main.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/sci/sci-main.tt index c146e55a03..70f55d7c7c 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/sci/sci-main.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/sci/sci-main.tt @@ -3,7 +3,7 @@ [%# Includes %] [% USE Koha %] [% USE KohaDates %] -[% USE KohaNews %] +[% USE AdditionalContents %] [%# Helper template functions %] [% BLOCK error_message %] [% IF messages.BadBarcode %] diff --git a/mainpage.pl b/mainpage.pl index 0999f58199..bc8dc88905 100755 --- a/mainpage.pl +++ b/mainpage.pl @@ -25,7 +25,7 @@ use C4::Output qw( output_html_with_http_headers ); use C4::Auth qw( get_template_and_user ); use C4::Koha; use C4::Tags qw( get_count_by_tag_status ); -use Koha::News; +use Koha::AdditionalContents; use Koha::Patron::Modifications; use Koha::Patron::Discharge; use Koha::Reviews; @@ -49,10 +49,14 @@ my $homebranch; if (C4::Context->userenv) { $homebranch = C4::Context->userenv->{'branch'}; } -my $koha_news = Koha::News->search_for_display({ - location => 'koha', +my $koha_news = Koha::AdditionalContents->search_for_display( + { + category => 'news', + location => [ 'staff_only', 'staff_and_opac' ], + lang => $template->lang, library_id => $homebranch - }); + } +); $template->param( koha_news => $koha_news, diff --git a/opac/opac-main.pl b/opac/opac-main.pl index 5b98333b85..bf63962ae0 100755 --- a/opac/opac-main.pl +++ b/opac/opac-main.pl @@ -27,7 +27,7 @@ use C4::Members; use C4::Overdues qw( checkoverdues ); use Koha::Checkouts; use Koha::Holds; -use Koha::News; +use Koha::AdditionalContents; use Koha::Patron::Messages; my $input = CGI->new; @@ -62,18 +62,21 @@ my $news_id = $input->param('news_id'); my $koha_news; if (defined $news_id){ - $koha_news = Koha::News->search({ idnew => $news_id, lang => { '!=', 'koha' } }); # get news that is not staff-only news + $koha_news = Koha::AdditionalContents->search({ idnew => $news_id, location => ['opac_only', 'staff_and_opac'] }); # get news that is not staff-only news if ( $koha_news->count > 0){ $template->param( news_item => $koha_news->next ); } else { $template->param( single_news_error => 1 ); } } else { - $koha_news = Koha::News->search_for_display({ - location => 'opac', - lang => $template->lang, + $koha_news = Koha::AdditionalContents->search_for_display( + { + category => 'news', + location => ['opac_only', 'staff_and_opac'], + lang => $template->lang, library_id => $homebranch, - }); + } + ); } # For dashboard diff --git a/opac/opac-news-rss.pl b/opac/opac-news-rss.pl index a969424fff..60d700e3e8 100755 --- a/opac/opac-news-rss.pl +++ b/opac/opac-news-rss.pl @@ -22,7 +22,7 @@ use Modern::Perl; use CGI; use C4::Auth qw( get_template_and_user ); use C4::Output qw( output_html_with_http_headers ); -use Koha::News; +use Koha::AdditionalContents; my $input = CGI->new; my $dbh = C4::Context->dbh; @@ -42,11 +42,14 @@ my ($theme, $news_lang, $availablethemes) = C4::Templates::themelanguage(C4::Con my $branchcode = $input->param('branchcode'); -my $koha_news = Koha::News->search_for_display({ - location => 'opac', - lang => $news_lang, +my $koha_news = Koha::AdditionalContents->search_for_display( + { + category => 'news', + location => ['opac_only', 'staff_and_opac'], + lang => $news_lang, library_id => $branchcode, - }); + } +); $template->param( koha_news => $koha_news ); diff --git a/svc/letters/preview b/svc/letters/preview index 17d7ad8751..67b74bf1f2 100755 --- a/svc/letters/preview +++ b/svc/letters/preview @@ -64,7 +64,6 @@ if ( $content =~ m/[^\n]*<<.*>>[^\n]*/so ) { borrowers => 'borrower', branches => 'branch', items => 'item', - opac_news => 'news', aqorders => 'orders', reserves => 'hold', serial => 'serial', diff --git a/t/db_dependent/Auth/haspermission.t b/t/db_dependent/Auth/haspermission.t index c332faf0c8..b487358461 100755 --- a/t/db_dependent/Auth/haspermission.t +++ b/t/db_dependent/Auth/haspermission.t @@ -141,13 +141,13 @@ subtest 'hashref top level AND tests' => sub { is( $r, 0, 'Borrower2/serials granular * should fail' ); # Check granular permission with one or more specific subperms - $r = haspermission( $borr1->{userid}, { tools => 'edit_news' } ); - is( ref($r), 'HASH', 'Superlibrarian/tools edit_news' ); + $r = haspermission( $borr1->{userid}, { tools => 'edit_additional_contents' } ); + is( ref($r), 'HASH', 'Superlibrarian/tools edit_additional_contents' ); $r = haspermission( $borr2->{userid}, { acquisition => 'budget_manage' } ); is( ref($r), 'HASH', 'Borrower2/acq budget_manage' ); $r = haspermission( $borr2->{userid}, - { acquisition => 'budget_manage', tools => 'edit_news' } ); - is( $r, 0, 'Borrower2 (/acquisition|budget_manage AND /tools|edit_news) should fail' ); + { acquisition => 'budget_manage', tools => 'edit_additional_contents' } ); + is( $r, 0, 'Borrower2 (/acquisition|budget_manage AND /tools|edit_additional_contents) should fail' ); $r = haspermission( $borr2->{userid}, { @@ -173,18 +173,18 @@ subtest 'hashref top level AND tests' => sub { { tools => { 'upload_local_cover_images' => 1, - 'edit_news' => 1 + 'edit_additional_contents' => 1 }, } ); - is( $r, 0, 'Borrower2 (/tools|upload_local_cover_image AND /tools|edit_news) granular' ); + is( $r, 0, 'Borrower2 (/tools|upload_local_cover_image AND /tools|edit_additional_contents) granular' ); $r = haspermission( $borr2->{userid}, { - tools => [ 'upload_local_cover_images', 'edit_news'], + tools => [ 'upload_local_cover_images', 'edit_additional_contents'], } ); - is( ref($r), 'HASH', 'Borrower2 (/tools|upload_local_cover_image OR /tools|edit_news) granular' ); + is( ref($r), 'HASH', 'Borrower2 (/tools|upload_local_cover_image OR /tools|edit_additional_contents) granular' ); }; subtest 'arrayref top level OR tests' => sub { @@ -219,19 +219,19 @@ subtest 'arrayref top level OR tests' => sub { is( $r, 0, 'Borrower2/serials granular * should fail' ); # Check granular permission with one or more specific subperms - $r = haspermission( $borr1->{userid}, [ { tools => 'edit_news' } ] ); - is( ref($r), 'HASH', 'Superlibrarian/tools edit_news' ); + $r = haspermission( $borr1->{userid}, [ { tools => 'edit_additional_contents' } ] ); + is( ref($r), 'HASH', 'Superlibrarian/tools edit_additional_contents' ); $r = haspermission( $borr2->{userid}, [ { acquisition => 'budget_manage' } ] ); is( ref($r), 'HASH', 'Borrower2/acq budget_manage' ); $r = haspermission( $borr2->{userid}, - [ { acquisition => 'budget_manage'}, { tools => 'edit_news' } ] ); + [ { acquisition => 'budget_manage'}, { tools => 'edit_additional_contents' } ] ); is( ref($r), 'HASH', 'Borrower2/two granular OR should pass' ); $r = haspermission( $borr2->{userid}, [ { tools => ['upload_local_cover_images'] }, - { tools => ['edit_news'] } + { tools => ['edit_additional_contents'] } ] ); is( ref($r), 'HASH', 'Borrower2/tools granular OR subperms' ); diff --git a/t/db_dependent/Koha/News.t b/t/db_dependent/Koha/AdditionalContents.t similarity index 62% rename from t/db_dependent/Koha/News.t rename to t/db_dependent/Koha/AdditionalContents.t index 596a89711d..0cbffac37c 100755 --- a/t/db_dependent/Koha/News.t +++ b/t/db_dependent/Koha/AdditionalContents.t @@ -22,7 +22,7 @@ use Modern::Perl; use Test::More tests => 5; use Test::Exception; -use Koha::News; +use Koha::AdditionalContents; use Koha::Database; use Koha::DateUtils; @@ -31,34 +31,34 @@ use t::lib::TestBuilder; my $schema = Koha::Database->new->schema; my $builder = t::lib::TestBuilder->new; -subtest 'Koha::News basic test' => sub { +subtest 'Koha::AdditionalContents basic test' => sub { plan tests => 5; $schema->storage->txn_begin; my $library = $builder->build({ source => 'Branch'}); - my $nb_of_news = Koha::News->search->count; - my $new_news_item_1 = Koha::NewsItem->new({ + my $nb_of_news = Koha::AdditionalContents->search->count; + my $new_news_item_1 = Koha::AdditionalContent->new({ branchcode => $library->{branchcode}, title => 'a news', content => 'content for news 1', })->store; - my $new_news_item_2 = Koha::NewsItem->new({ + my $new_news_item_2 = Koha::AdditionalContent->new({ branchcode => $library->{branchcode}, title => 'another news', content => 'content for news 2', })->store; like( $new_news_item_1->idnew, qr|^\d+$|, 'Adding a new news_item should have set the idnew'); - is( Koha::News->search->count, $nb_of_news + 2, 'The 2 news should have been added' ); + is( Koha::AdditionalContents->search->count, $nb_of_news + 2, 'The 2 news should have been added' ); - my $retrieved_news_item_1 = Koha::News->find( $new_news_item_1->idnew ); + my $retrieved_news_item_1 = Koha::AdditionalContents->find( $new_news_item_1->idnew ); is( $retrieved_news_item_1->title, $new_news_item_1->title, 'Find a news_item by id should return the correct news_item' ); is( $retrieved_news_item_1->content, $new_news_item_1->content, 'The content method return the content of the news'); $retrieved_news_item_1->delete; - is( Koha::News->search->count, $nb_of_news + 1, 'Delete should have deleted the news_item' ); + is( Koha::AdditionalContents->search->count, $nb_of_news + 1, 'Delete should have deleted the news_item' ); $schema->storage->txn_rollback; }; @@ -73,19 +73,19 @@ subtest '->is_expired' => sub { my $yesterday = dt_from_string->add( days => -1 ); my $tomorrow = dt_from_string->add( days => 1 ); my $new_today = $builder->build_object({ - class => 'Koha::News', + class => 'Koha::AdditionalContents', value => { expirationdate => $today, } }); my $new_expired = $builder->build_object({ - class => 'Koha::News', + class => 'Koha::AdditionalContents', value => { expirationdate => $yesterday, } }); my $new_not_expired = $builder->build_object({ - class => 'Koha::News', + class => 'Koha::AdditionalContents', value => { expirationdate => $tomorrow, } @@ -107,13 +107,13 @@ subtest '->library' => sub { my $library = $builder->build_object({ class => 'Koha::Libraries' }); my $new_with_library = $builder->build_object({ - class => 'Koha::News', + class => 'Koha::AdditionalContents', value => { branchcode => $library->branchcode } }); my $new_without_library = $builder->build_object({ - class => 'Koha::News', + class => 'Koha::AdditionalContents', value => { branchcode => undef } @@ -130,14 +130,14 @@ subtest '->library' => sub { subtest '->author' => sub { plan tests => 3; - my $news_item = $builder->build_object({ class => 'Koha::News' }); + my $news_item = $builder->build_object({ class => 'Koha::AdditionalContents' }); my $author = $news_item->author; - is( ref($author), 'Koha::Patron', 'Koha::NewsItem->author returns a Koha::Patron object' ); + is( ref($author), 'Koha::Patron', 'Koha::AdditionalContent->author returns a Koha::Patron object' ); $author->delete; - $news_item = Koha::News->find($news_item->idnew); - is( ref($news_item), 'Koha::NewsItem', 'News are not deleted alongwith the author' ); + $news_item = Koha::AdditionalContents->find($news_item->idnew); + is( ref($news_item), 'Koha::AdditionalContent', 'News are not deleted alongwith the author' ); is( $news_item->author, undef, '->author returns undef is the author has been deleted' ); }; @@ -147,7 +147,7 @@ subtest '->search_for_display' => sub { $schema->storage->txn_begin; - Koha::News->search->delete; + Koha::AdditionalContents->search->delete; my $today = dt_from_string; my $yesterday = dt_from_string->add( days => -1 ); @@ -156,103 +156,80 @@ subtest '->search_for_display' => sub { my $library2 = $builder->build_object({ class => 'Koha::Libraries' }); my $new_expired = $builder->build_object({ - class => 'Koha::News', + class => 'Koha::AdditionalContents', value => { expirationdate => $yesterday, published_on => $today, - lang => '', + category => 'news', + location => 'staff_and_opac', + lang => 'default', branchcode => undef, number => 1, } }); my $new_not_expired = $builder->build_object({ - class => 'Koha::News', + class => 'Koha::AdditionalContents', value => { expirationdate => $tomorrow, published_on => $today, - lang => '', + category => 'news', + location => 'staff_and_opac', + lang => 'default', branchcode => undef, number => 2, } }); my $new_not_active = $builder->build_object({ - class => 'Koha::News', + class => 'Koha::AdditionalContents', value => { expirationdate => $tomorrow, published_on => $tomorrow, - lang => '', + category => 'news', + location => 'staff_and_opac', + lang => 'default', branchcode => undef, number => 3, } }); my $new_slip= $builder->build_object({ - class => 'Koha::News', + class => 'Koha::AdditionalContents', value => { expirationdate => $tomorrow, published_on => $today, - lang => 'slip', + category => 'news', + location => 'staff_only', + lang => 'default', branchcode => $library1->branchcode, number => 4, } }); my $new_intra = $builder->build_object({ - class => 'Koha::News', + class => 'Koha::AdditionalContents', value => { expirationdate => $tomorrow, published_on => $today, - lang => 'koha', + category => 'news', + location => 'staff_only', + lang => 'default', branchcode => $library2->branchcode, number => 5, } }); my $new_intra2 = $builder->build_object({ - class => 'Koha::News', + class => 'Koha::AdditionalContents', value => { expirationdate => $tomorrow, published_on => $today, - lang => 'koha', + category => 'news', + location => 'staff_only', + lang => 'default', branchcode => undef, number => 5, } }); - my $news = Koha::News->search_for_display; + my $news = Koha::AdditionalContents->search_for_display; - is($news->count, 4, 'Active and not expired news'); - is($news->next->number, 2, 'News items are returned in correct order'); - - $news = Koha::News->search_for_display({ location => 'slip'}); - is($news->count, 2, 'Slip and "all" locations returned'); - - $news = Koha::News->search_for_display({ location => 'koha'}); - is($news->count, 3, 'Intranet and "all"'); - - $new_not_expired->lang('OpacNavRight_en')->store; - $news = Koha::News->search_for_display({ location => 'OpacNavRight', lang => 'en'}); - is($news->count, 1, 'OpacNavRight'); - is($news->next->idnew, $new_not_expired->idnew, 'Returned the right new item'); - - $new_intra->lang('')->store; - $news = Koha::News->search_for_display({ location => 'opac', lang => 'en'}); - is($news->count, 1, 'Only opac news are returned'); - $new_not_expired->lang('en')->store; - $news = Koha::News->search_for_display({ location => 'opac', lang => 'en'}); - is($news->count, 2, 'Opac en and all is returned'); - - $news = Koha::News->search_for_display({ library_id => $library1->branchcode }); - is($news->count, 3, 'Filtering by library returns right number of news items'); - - $news = Koha::News->search_for_display({ library_id => $library2->branchcode}); - is($news->count, 3, 'Filtering by library returns right number of news items'); - - $new_intra->branchcode($library1->branchcode)->store; - $news = Koha::News->search_for_display({ library_id => $library2->branchcode}); - is($news->count, 2, 'Filtering by library returns right number of news items'); - - $news = Koha::News->search_for_display({ location => 'NonExistantType', lang => 'en'}); - is($news->count, 0, 'Non-existant location is searched, but should not find any item'); - - throws_ok { Koha::News->search_for_display({ location => 'opac'}) } 'Koha::Exceptions::BadParameter', - 'Exception raised when location is opac and no language given'; + # FIXME Rewrite tests here $schema->storage->txn_rollback; }; diff --git a/t/db_dependent/Letters/TemplateToolkit.t b/t/db_dependent/Letters/TemplateToolkit.t index 7e72517eb6..0aa71f2e74 100755 --- a/t/db_dependent/Letters/TemplateToolkit.t +++ b/t/db_dependent/Letters/TemplateToolkit.t @@ -39,7 +39,7 @@ use Koha::Biblio; use Koha::Biblioitem; use Koha::Item; use Koha::Hold; -use Koha::NewsItem; +use Koha::AdditionalContent; use Koha::Serial; use Koha::Subscription; use Koha::Suggestion; @@ -78,7 +78,7 @@ my $hold = $builder->build_object( my $news = $builder->build_object( { - class => 'Koha::News', + class => 'Koha::AdditionalContents', value => { title => 'a news title', content => 'a news content' } } ); @@ -178,13 +178,13 @@ $prepared_letter = GetPreparedLetter( is( $prepared_letter->{content}, $item->id(), 'Item object used correctly for content' ); is( $prepared_letter->{title}, $item->barcode, 'Item object used correctly for title' ); -$sth->execute( "TEST_NEWS", "[% news.id %]", "[% news.id %]" ); +$sth->execute( "TEST_NEWS", "[% additional_content.id %]", "[% additional_content.id %]" ); $prepared_letter = GetPreparedLetter( ( module => 'test', letter_code => 'TEST_NEWS', tables => { - opac_news => $news->id() + additional_contents => $news->id() }, ) ); @@ -621,8 +621,8 @@ EOF is( $tt_letter_for_item2->{content}, $letter_for_item2->{content}, ); }; - subtest 'ISSUESLIP|checkedout|repeat' => sub { - plan tests => 2; + subtest 'ISSUESLIP|checkedout|repeat|news' => sub { + plan tests => 3; my $code = 'ISSUESLIP'; my $now = dt_from_string; @@ -630,8 +630,17 @@ EOF my $branchcode = $library->{branchcode}; - Koha::News->delete; - my $news_item = Koha::NewsItem->new({ branchcode => $branchcode, title => "A wonderful news", content => "This is the wonderful news." })->store; + Koha::AdditionalContents->delete; + my $news_item = Koha::AdditionalContent->new( + { + branchcode => $branchcode, + title => "A wonderful news", + content => "This is the wonderful news.", + lang => "slip", + expiration_date => undef, + published_on => $one_minute_ago + } + )->store; # historic syntax my $template = <<EOF; @@ -664,9 +673,9 @@ Date due: <<issues.date_due | dateonly>><br /> <h4 style="text-align: center; font-style:italic;">News</h4> <news> <div class="newsitem"> -<h5 style="margin-bottom: 1px; margin-top: 1px"><b><<opac_news.title>></b></h5> -<p style="margin-bottom: 1px; margin-top: 1px"><<opac_news.content>></p> -<p class="newsfooter" style="font-size: 8pt; font-style:italic; margin-bottom: 1px; margin-top: 1px">Posted on <<opac_news.published_on>></p> +<h5 style="margin-bottom: 1px; margin-top: 1px"><b><<additional_contents.title>></b></h5> +<p style="margin-bottom: 1px; margin-top: 1px"><<additional_contents.content>></p> +<p class="newsfooter" style="font-size: 8pt; font-style:italic; margin-bottom: 1px; margin-top: 1px">Posted on <<additional_contents.published_on>></p> <hr /> </div> </news> @@ -722,11 +731,11 @@ Date due: [% overdue.date_due | \$KohaDates %]<br /> <hr> <h4 style="text-align: center; font-style:italic;">News</h4> -[% FOREACH n IN news %] +[% FOREACH n IN additional_contents %] <div class="newsitem"> <h5 style="margin-bottom: 1px; margin-top: 1px"><b>[% n.title %]</b></h5> <p style="margin-bottom: 1px; margin-top: 1px">[% n.content %]</p> -<p class="newsfooter" style="font-size: 8pt; font-style:italic; margin-bottom: 1px; margin-top: 1px">Posted on [% n.timestamp | \$KohaDates %]</p> +<p class="newsfooter" style="font-size: 8pt; font-style:italic; margin-bottom: 1px; margin-top: 1px">Posted on [% n.published_on | \$KohaDates %]</p> <hr /> </div> [% END %] @@ -746,6 +755,8 @@ EOF # There is too many line breaks generated by the historic syntax $second_slip->{content} =~ s|</p>\n\n\n<p>|</p>\n\n<p>|s; + my $news_item_title = $news_item->title; + like( $first_slip->{content}, qr{$news_item_title} ); is( $first_tt_slip->{content}, $first_slip->{content}, ); is( $second_tt_slip->{content}, $second_slip->{content}, ); diff --git a/tools/additional-contents.pl b/tools/additional-contents.pl new file mode 100755 index 0000000000..da3e57c91a --- /dev/null +++ b/tools/additional-contents.pl @@ -0,0 +1,229 @@ +#!/usr/bin/perl + +# This file is part of Koha. +# +# Script to manage the opac news. +# written 11/04 +# Casta�eda, Carlos Sebastian - seba3c@yahoo.com.ar - Physics Library UNLP Argentina +# Modified to include news to KOHA intranet - tgarip@neu.edu.tr NEU library -Cyprus +# Copyright 2000-2002 Katipo Communications +# Copyright (C) 2013 Mark Tompsett +# +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see <http://www.gnu.org/licenses>. + +use Modern::Perl; +use CGI qw ( -utf8 ); +use C4::Auth; +use C4::Koha; +use C4::Context; +use C4::Output; +use C4::Languages qw(getTranslatedLanguages); +use Koha::DateUtils; +use Koha::AdditionalContents; + +my $cgi = CGI->new; + +my $op = $cgi->param('op') || 'list'; +my $id = $cgi->param('id'); +my $category = $cgi->param('category') || 'news'; +my $wysiwyg; +if( $cgi->param('editmode') ){ + $wysiwyg = $cgi->param('editmode') eq "wysiwyg" ? 1 : 0; +} else { + $wysiwyg = C4::Context->preference("AdditionalContentsEditor") eq "tinymce" ? 1 : 0; +} + +my ( $template, $borrowernumber, $cookie ) = get_template_and_user( + { + template_name => "tools/additional-contents.tt", + query => $cgi, + type => "intranet", + flagsrequired => { tools => 'edit_additional_contents' }, + } +); + +my @messages; +if ( $op eq 'add_form' ) { + + my $additional_content = Koha::AdditionalContents->find($id); + my $translated_contents; + if ( $additional_content ) { + $translated_contents = { + map { $_->lang => $_ } Koha::AdditionalContents->search( + { + category => $additional_content->category, + code => $additional_content->code, + location => $additional_content->location, + branchcode => $additional_content->branchcode, + } + ) + }; + } + $template->param( + additional_content => $additional_content, + translated_contents => $translated_contents, + ); +} +elsif ( $op eq 'add_validate' ) { + my $location = $cgi->param('location'); + my $code = $cgi->param('code'); + my $branchcode = $cgi->param('branchcode') || undef; + + my @title = $cgi->multi_param('title'); + my @content = $cgi->multi_param('content'); + my @lang = $cgi->multi_param('lang'); + + my $expirationdate; + if ( $cgi->param('expirationdate') ) { + $expirationdate = output_pref( + { + dt => dt_from_string( scalar $cgi->param('expirationdate') ), + dateformat => 'iso', + dateonly => 1 + } + ); + } + my $published_on = output_pref( + { + dt => dt_from_string( scalar $cgi->param('published_on') ), + dateformat => 'iso', + dateonly => 1 + } + ); + my $number = $cgi->param('number'); + + my $success = 1; + for my $lang ( @lang ) { + my $title = shift @title; + my $content = shift @content; + my $additional_content = Koha::AdditionalContents->find( + { + category => $category, + code => $code, + branchcode => $branchcode, + lang => $lang, + } + ); + # Delete if title or content is empty + unless ( $title and $content ) { + $additional_content->delete if $additional_content; + next; + } elsif ( $additional_content ) { + eval { + $additional_content->update( + { + category => $category, + code => $code, + location => $location, + branchcode => $branchcode, + title => $title, + content => $content, + lang => $lang, + expirationdate => $expirationdate, + published_on => $published_on, + number => $number, + borrowernumber => $borrowernumber, + } + ); + }; + if ($@) { + $success = 0; + push @messages, { type => 'error', code => 'error_on_update' }; + last; + } + } + else { + my $additional_content = Koha::AdditionalContent->new( + { + category => $category, + code => $code, + location => $location, + branchcode => $branchcode, + title => $title, + content => $content, + lang => $lang, + expirationdate => $expirationdate, + published_on => $published_on, + number => $number, + borrowernumber => $borrowernumber, + } + )->store; + eval { $additional_content->store; }; + if ($@) { + $success = 0; + push @messages, { type => 'error', code => 'error_on_insert' }; + last; + } + } + + } + $op = 'list'; +} +elsif ( $op eq 'delete_confirmed' ) { + my @ids = $cgi->multi_param('ids'); + my $deleted = + eval { Koha::AdditionalContents->search( { idnew => @ids } )->delete; }; + + if ( $@ or not $deleted ) { + push @messages, { type => 'error', code => 'error_on_delete' }; + } + else { + push @messages, { type => 'message', code => 'success_on_delete' }; + } + + $op = 'list'; +} + +if ( $op eq 'list' ) { + my $additional_contents = Koha::AdditionalContents->search( + { category => $category, lang => 'default' }, + { order_by => { -desc => 'published_on' } } + ); + $template->param( additional_contents => $additional_contents ); +} + +my $translated_languages = C4::Languages::getTranslatedLanguages; +my @languages; +for my $language (@$translated_languages) { + for my $sublanguage ( @{ $language->{sublanguages_loop} } ) { + if ( $language->{plural} ) { + push @languages, + { + lang => $sublanguage->{rfc4646_subtag}, + description => $sublanguage->{native_description} . ' ' + . $sublanguage->{region_description} . ' (' + . $sublanguage->{rfc4646_subtag} . ')', + }; + } + else { + push @languages, + { + lang => $sublanguage->{rfc4646_subtag}, + description => $sublanguage->{native_description} . ' (' + . $sublanguage->{rfc4646_subtag} . ')', + }; + } + } +} +unshift @languages, {lang => 'default'} if @languages; + +$template->param( + op => $op, + category => $category, + wysiwyg => $wysiwyg, + languages => \@languages, +); + + +output_html_with_http_headers $cgi, $cookie, $template->output; diff --git a/tools/koha-news.pl b/tools/koha-news.pl deleted file mode 100755 index ef615a4e0d..0000000000 --- a/tools/koha-news.pl +++ /dev/null @@ -1,160 +0,0 @@ -#!/usr/bin/perl - -# This file is part of Koha. -# -# Script to manage the opac news. -# written 11/04 -# Casta�eda, Carlos Sebastian - seba3c@yahoo.com.ar - Physics Library UNLP Argentina -# Modified to include news to KOHA intranet - tgarip@neu.edu.tr NEU library -Cyprus -# Copyright 2000-2002 Katipo Communications -# Copyright (C) 2013 Mark Tompsett -# -# Koha is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. -# -# Koha is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Koha; if not, see <http://www.gnu.org/licenses>. - -use Modern::Perl; -use CGI qw ( -utf8 ); -use C4::Auth qw( get_template_and_user ); -use C4::Context; -use C4::Output qw( output_html_with_http_headers ); -use C4::Languages qw( getTranslatedLanguages ); -use Koha::DateUtils qw( dt_from_string output_pref ); -use Koha::News; - -my $cgi = CGI->new; - -my $id = $cgi->param('id'); -my $title = $cgi->param('title'); -my $content = $cgi->param('content'); -my $expirationdate; -if ( $cgi->param('expirationdate') ) { - $expirationdate = output_pref({ dt => dt_from_string( scalar $cgi->param('expirationdate') ), dateformat => 'iso', dateonly => 1 }); -} -my $published_on= output_pref({ dt => dt_from_string( scalar $cgi->param('published_on') ), dateformat => 'iso', dateonly => 1 }); -my $number = $cgi->param('number'); -my $lang = $cgi->param('lang'); -my $branchcode = $cgi->param('branch'); -my $error_message = $cgi->param('error_message'); -my $wysiwyg; -if( $cgi->param('editmode') ){ - $wysiwyg = $cgi->param('editmode') eq "wysiwyg" ? 1 : 0; -} else { - $wysiwyg = C4::Context->preference("NewsToolEditor") eq "tinymce" ? 1 : 0; -} - -# Foreign Key constraints work with NULL, not '' -# NULL = All branches. -$branchcode = undef if (defined($branchcode) && $branchcode eq ''); - -my $new_detail = Koha::News->find( $id ); - -my ( $template, $borrowernumber, $cookie ) = get_template_and_user( - { - template_name => "tools/koha-news.tt", - query => $cgi, - type => "intranet", - flagsrequired => { tools => 'edit_news' }, - } -); - -# Pass error message if there is one. -$template->param( error_message => $error_message ) if $error_message; - -# get lang list -my @lang_list; -my $tlangs = getTranslatedLanguages() ; - -foreach my $language ( @$tlangs ) { - foreach my $sublanguage ( @{$language->{'sublanguages_loop'}} ) { - push @lang_list, - { - language => $sublanguage->{'rfc4646_subtag'}, - selected => ( $new_detail && $new_detail->lang eq $sublanguage->{'rfc4646_subtag'} ? 1 : 0 ), - }; - } -} - -$template->param( lang_list => \@lang_list, - branchcode => $branchcode ); - -my $op = $cgi->param('op') // ''; - -if ( $op eq 'add_form' ) { - $template->param( add_form => 1 ); - if ($id) { - if($new_detail->lang eq "slip"){ $template->param( slip => 1); } - $template->param( - op => 'edit', - id => $new_detail->idnew - ); - $template->{VARS}->{'new_detail'} = $new_detail; - } - else { - $template->param( op => 'add' ); - } -} -elsif ( $op eq 'add' ) { - if ($title) { - my $new = Koha::NewsItem->new({ - title => $title, - content => $content, - lang => $lang, - expirationdate => $expirationdate, - published_on => $published_on, - number => $number, - branchcode => $branchcode, - borrowernumber => $borrowernumber, - })->store; - print $cgi->redirect("/cgi-bin/koha/tools/koha-news.pl"); - } - else { - print $cgi->redirect("/cgi-bin/koha/tools/koha-news.pl?error_message=title_missing"); - } -} -elsif ( $op eq 'edit' ) { - my $news_item = Koha::News->find( $id ); - if ( $news_item ) { - $news_item->set({ - title => $title, - content => $content, - lang => $lang, - expirationdate => $expirationdate, - published_on=> $published_on, - number => $number, - branchcode => $branchcode, - })->store; - } - print $cgi->redirect("/cgi-bin/koha/tools/koha-news.pl"); -} -elsif ( $op eq 'del' ) { - my @ids = $cgi->multi_param('ids'); - Koha::News->search({ idnew => \@ids })->delete; - print $cgi->redirect("/cgi-bin/koha/tools/koha-news.pl"); -} - -else { - my $params; - $params->{lang} = $lang if $lang; - my $opac_news = Koha::News->search( - $params, - { - order_by => { -desc => 'published_on' }, - } - ); - $template->param( opac_news => $opac_news ); -} -$template->param( - lang => $lang, - wysiwyg => $wysiwyg, -); -output_html_with_http_headers $cgi, $cookie, $template->output; diff --git a/tools/letter.pl b/tools/letter.pl index b913d0ee59..68b9eed449 100755 --- a/tools/letter.pl +++ b/tools/letter.pl @@ -249,7 +249,7 @@ sub add_form { {value => 'items.fine', text => 'items.fine'}, add_fields('borrowers'); if ($module eq 'circulation') { - push @{$field_selection}, add_fields('opac_news'); + push @{$field_selection}, add_fields('additional_contents'); } -- 2.39.5