Bugzilla – Attachment 122872 Details for
Bug 24387
Rename News tool
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24387: Rename "News" with "Additional contents"
Bug-24387-Rename-News-with-Additional-contents.patch (text/plain), 154.05 KB, created by
Jonathan Druart
on 2021-07-16 07:16:56 UTC
(
hide
)
Description:
Bug 24387: Rename "News" with "Additional contents"
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2021-07-16 07:16:56 UTC
Size:
154.05 KB
patch
obsolete
>From 6c38b6dbf86c6630280c474570cab39f3abad905 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >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. >--- > 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 177a4f51f67..a7e5e458a1e 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'"; >@@ -1653,8 +1653,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 73b254cb5ee..210a9ea0de3 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 { > </overdue> > > <news> >- <<opac_news.*>> >+ <<additional_contents.*>> > </news> > > 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 152e7770238..c0c321458f3 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 00000000000..fa32aa6318a >--- /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 <http://www.gnu.org/licenses>. >+ >+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 <kyle@bywatersolutions.com> >+ >+=cut >+ >+1; >diff --git a/Koha/Manual.pm b/Koha/Manual.pm >index a69c079806f..30a815545e0 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 5bb78a6a30e..00000000000 >--- 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 <http://www.gnu.org/licenses>. >- >-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 <kyle@bywatersolutions.com> >- >-=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 75669de861f..c37abece4ea 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 00000000000..26e3681ae81 >--- /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\.', '<<additional_contents.') >+ |); >+ $dbh->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 db40a3a4cce..aae1fb558b7 100644 >--- a/installer/data/mysql/en/mandatory/sample_notices.yml >+++ b/installer/data/mysql/en/mandatory/sample_notices.yml >@@ -528,9 +528,9 @@ tables: > - "<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>" >diff --git a/installer/data/mysql/en/optional/sample_news.yml b/installer/data/mysql/en/optional/sample_news.yml >index badff452a3a..8368027c65b 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 a0d6c489131..d525626175e 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<ul>\r\n<li><a href=\"http://koha-community.org/documentation/\">lisez la documentation de Koha ;</a></li>\r\n<li><a href=\"http://wiki.koha-community.org\">lisez et participez au Wiki de Koha ;</a></li>\r\n<li><a href=\"http://koha-community.org/support/\">abonnez-vous aux listes de discussion ;</a></li>\r\n<li><a href=\"http://bugs.koha-community.org\">signalez des bugs ;</a></li>\r\n<li><a href=\"https://wiki.koha-community.org/wiki/Version_Control_Using_Git\">proposez des correctifs et des améliorations ;</a></li>\r\n<li><a href=\"http://koha-community.org/support/\">discutez avec les utilisateurs et les développeurs de Koha.</a></li>\r\n</ul>\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<ul>\r\n<li><a href=\"http://koha-community.org/documentation/\">lisez la documentation de Koha ;</a></li>\r\n<li><a href=\"http://wiki.koha-community.org\">lisez et participez au Wiki de Koha ;</a></li>\r\n<li><a href=\"http://koha-community.org/support/\">abonnez-vous aux listes de discussion ;</a></li>\r\n<li><a href=\"http://bugs.koha-community.org\">signalez des bugs ;</a></li>\r\n<li><a href=\"https://wiki.koha-community.org/wiki/Version_Control_Using_Git\">proposez des correctifs et des améliorations ;</a></li>\r\n<li><a href=\"http://koha-community.org/support/\">discutez avec les utilisateurs et les développeurs de Koha.</a></li>\r\n</ul>\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 3bb351231f7..5cd66e49e1d 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 <<borrowers.firstname>> <<borrowers.surname>>,\r\n\r\nLe prêt de ce document arrive à expiration aujourd\'hui.\r\n\r\n<<biblio.title>>, <<biblio.author>> (<<items.barcode>>)\r\n\r\nMerci de nous le retourner.\r\n\r\n<<branches.branchname>>','email'), > ('circulation','DUEDGST','','Document à rendre aujourd\'hui (Résumé)',0,'Document à rendre aujourd\'hui','Bonjour <<borrowers.firstname>> <<borrowers.surname>>,\r\n\r\nVous avez <<count>> document(s) dont le prêt arrive à expiration.\r\n\r\nMerci de nous le(s) retourner rapidement.\r\n\r\n<<branches.branchname>>','email'), > ('circulation','ISSUEQSLIP','','Ticket rapide de prêts',1,'Ticket rapide de prêts','<h3><<branches.branchname>></h3>\r\nEmprunté par <<borrowers.firstname>> <<borrowers.surname>> <br />\r\n(<<borrowers.cardnumber>>) <br />\r\n\r\n<<today>><br />\r\n\r\n<h4>Emprunté(s) aujourd\'hui</h4>\r\n<checkedout>\r\n<p>\r\n<<biblio.title>><br />\r\nCode-barres : <<items.barcode>><br />\r\nDate de retour : <<issues.date_due>><br />\r\n</p>\r\n</checkedout>','email'), >-('circulation','ISSUESLIP','','Ticket de prêts',1,'Ticket de prêts','<h3><<branches.branchname>></h3>\r\nEmprunté par <<borrowers.firstname>> <<borrowers.surname>> <br />\r\n(<<borrowers.cardnumber>>) <br />\r\n\r\n<<today>><br />\r\n\r\n<h4>Emprunté(s) aujourd\'hui</h4>\r\n<checkedout>\r\n<p>\r\n<<biblio.title>> <br />\r\nCode-barres : <<items.barcode>><br />\r\nDate de retour : <<issues.date_due>><br />\r\n</p>\r\n</checkedout>\r\n\r\n<h4>Retards</h4>\r\n<overdue>\r\n<p>\r\n<<biblio.title>> <br />\r\nCode-barres : <<items.barcode>><br />\r\nDate de retour : <<issues.date_due>><br />\r\n</p>\r\n</overdue>\r\n\r\n<hr>\r\n\r\n<h4 style=\"text-align: center; font-style:italic;\">Nouvelles</h4>\r\n<news>\r\n<div class=\"newsitem\">\r\n<h5 style=\"margin-bottom: 1px; margin-top: 1px\"><b><<opac_news.title>></b></h5>\r\n<p style=\"margin-bottom: 1px; margin-top: 1px\"><<opac_news.content>></p>\r\n<p class=\"newsfooter\" style=\"font-size: 8pt; font-style:italic; margin-bottom: 1px; margin-top: 1px\">Publiée le <<opac_news.published_on>></p>\r\n<hr />\r\n</div>\r\n</news>','email'), >+('circulation','ISSUESLIP','','Ticket de prêts',1,'Ticket de prêts','<h3><<branches.branchname>></h3>\r\nEmprunté par <<borrowers.firstname>> <<borrowers.surname>> <br />\r\n(<<borrowers.cardnumber>>) <br />\r\n\r\n<<today>><br />\r\n\r\n<h4>Emprunté(s) aujourd\'hui</h4>\r\n<checkedout>\r\n<p>\r\n<<biblio.title>> <br />\r\nCode-barres : <<items.barcode>><br />\r\nDate de retour : <<issues.date_due>><br />\r\n</p>\r\n</checkedout>\r\n\r\n<h4>Retards</h4>\r\n<overdue>\r\n<p>\r\n<<biblio.title>> <br />\r\nCode-barres : <<items.barcode>><br />\r\nDate de retour : <<issues.date_due>><br />\r\n</p>\r\n</overdue>\r\n\r\n<hr>\r\n\r\n<h4 style=\"text-align: center; font-style:italic;\">Nouvelles</h4>\r\n<news>\r\n<div class=\"newsitem\">\r\n<h5 style=\"margin-bottom: 1px; margin-top: 1px\"><b><<additional_contents.title>></b></h5>\r\n<p style=\"margin-bottom: 1px; margin-top: 1px\"><<additional_contents.content>></p>\r\n<p class=\"newsfooter\" style=\"font-size: 8pt; font-style:italic; margin-bottom: 1px; margin-top: 1px\">Publiée le <<additional_contents.published_on>></p>\r\n<hr />\r\n</div>\r\n</news>','email'), > ('circulation','ODUE','','Document(s) en retard',0,'Document(s) en retard','Bonjour <<borrowers.firstname>> <<borrowers.surname>>,\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<<branches.branchname>>\r\n<<branches.branchaddress1>>\r\n<<branches.branchaddress2>> <<branches.branchaddress3>>\r\nTél : <<branches.branchphone>>\r\nFax : <<branches.branchfax>>\r\nCourriel : <<branches.branchemail>>\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<item>\"<<biblio.title>>\" par <<biblio.author>>, <<items.itemcallnumber>>, code-barres : <<items.barcode>> Amende : <<items.fine>></item>\r\n\r\nMerci de votre attention.\r\n\r\n<<branches.branchname>>','email'), > ('circulation','PREDUE','','Document à rendre bientôt',0,'Document à rendre bientôt','Bonjour <<borrowers.firstname>> <<borrowers.surname>>,\r\n\r\nNous souhaitons vous informer que le prêt de ce document arrive bientôt à expiration :\r\n\r\n<<biblio.title>>, <<biblio.author>> (<<items.barcode>>)\r\n\r\nMerci.\r\n\r\n<<branches.branchname>>','email'), > ('circulation','PREDUEDGST','','Document à rendre bientôt (Résumé)',0,'Document(s) à rendre bientôt','Bonjour <<borrowers.firstname>> <<borrowers.surname>>,\r\n\r\nVous avez <<count>> document(s) dont le prêt arrive bientôt à expiration.\r\n\r\n<<branches.branchname>>','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 22bb673a685..a0cee7092e7 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 : <<issues.date_due>><br /> > <h4 style="text-align: center; font-style:italic;">Nouvelles</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>', 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 a0d6c489131..d525626175e 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<ul>\r\n<li><a href=\"http://koha-community.org/documentation/\">lisez la documentation de Koha ;</a></li>\r\n<li><a href=\"http://wiki.koha-community.org\">lisez et participez au Wiki de Koha ;</a></li>\r\n<li><a href=\"http://koha-community.org/support/\">abonnez-vous aux listes de discussion ;</a></li>\r\n<li><a href=\"http://bugs.koha-community.org\">signalez des bugs ;</a></li>\r\n<li><a href=\"https://wiki.koha-community.org/wiki/Version_Control_Using_Git\">proposez des correctifs et des améliorations ;</a></li>\r\n<li><a href=\"http://koha-community.org/support/\">discutez avec les utilisateurs et les développeurs de Koha.</a></li>\r\n</ul>\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<ul>\r\n<li><a href=\"http://koha-community.org/documentation/\">lisez la documentation de Koha ;</a></li>\r\n<li><a href=\"http://wiki.koha-community.org\">lisez et participez au Wiki de Koha ;</a></li>\r\n<li><a href=\"http://koha-community.org/support/\">abonnez-vous aux listes de discussion ;</a></li>\r\n<li><a href=\"http://bugs.koha-community.org\">signalez des bugs ;</a></li>\r\n<li><a href=\"https://wiki.koha-community.org/wiki/Version_Control_Using_Git\">proposez des correctifs et des améliorations ;</a></li>\r\n<li><a href=\"http://koha-community.org/support/\">discutez avec les utilisateurs et les développeurs de Koha.</a></li>\r\n</ul>\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 58dadc1541c..f89d7682b10 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -3906,28 +3906,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 6b66e42c142..730ae625d2f 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'), >@@ -351,7 +352,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 edb52f0fdd4..f1c2d8883be 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 14d500af76f..bf54ff7735b 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: <<issues.date_due>><br /> > <h4 style="text-align: center; font-style:italic;">Nyheter</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">Publisert <<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">Publisert <<additional_contents.published_on>></p> > <hr /> > </div> > </news>', 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 fb7cba9884c..ec23a419c54 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<ul>\r\n<li><a href=\"http://koha-community.org/documentation/\">Les dokumentasjon</a></li>\r\n<li><a href=\"http://wiki.koha-community.org\">Les eller bidra til Koha sin wiki</a></li>\r\n<li><a href=\"http://koha-community.org/get-involved/\">Les og delta i diskusjoner</a></li>\r\n<li><a href=\"http://bugs.koha-community.org\">Meld fra om feil og mangler</a></li>\r\n<li><a href=\"http://wiki.koha-community.org/wiki/Version_Control_Using_Git\">Send inn feilrettinger med Git (versjonskontrollsystem)</a></li>\r\n<li><a href=\"http://koha-community.org/get-involved/irc/\">Chat med Koha-brukere og -utviklere</a></li>\r\n</ul>\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 1ffce70b1f4..cc253be52e1 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 > </span> > <span class="permissioncode">([% name | html %])</span> >- [%- CASE 'edit_news' -%] >- <span class="sub_permission edit_news_subpermission"> >- Write news for the OPAC and staff interfaces >+ [%- CASE 'edit_additional_contents' -%] >+ <span class="sub_permission edit_additional_contents_subpermission"> >+ Write additional contents for the OPAC and staff interfaces (news and HTML customizations) > </span> > <span class="permissioncode">([% name | html %])</span> > [%- 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 cf2b0c887e8..0b5f33110fb 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 %] > </ul> > [% 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 ) %] > <h5>Additional tools</h5> > <ul> > [% IF ( CAN_user_tools_edit_calendar ) %] >@@ -106,8 +106,9 @@ > [% IF ( CAN_user_tools_view_system_logs ) %] > <li><a href="/cgi-bin/koha/tools/viewlog.pl">Log viewer</a></li> > [% END %] >- [% IF ( CAN_user_tools_edit_news ) %] >- <li><a href="/cgi-bin/koha/tools/koha-news.pl">News</a></li> >+ [% IF ( CAN_user_tools_edit_additional_contents ) %] >+ <li><a href="/cgi-bin/koha/tools/additional-contents.pl?category=news">News</a></li> >+ <li><a href="/cgi-bin/koha/tools/additional-contents.pl?category=html_customizations">HTML customizations</a></li> > [% END %] > [% IF ( CAN_user_tools_schedule_tasks ) %] > <li><a href="/cgi-bin/koha/tools/scheduler.pl">Task scheduler</a></li> >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 33cef05398f..4a569b4cae9 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 01ac0447832..0f56178b937 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 @@ > <div class="newsbody">[% koha_new.content | $raw %]</div> > <p class="newsfooter"> Posted on [% koha_new.published_on | $KohaDates %][% IF( show_author && koha_new.author ) %] by <span class="newsauthor">[% INCLUDE 'patron-title.inc' patron=koha_new.author %]<br />[% END %] > [% IF ( CAN_user_tools ) %] >- <a href="/cgi-bin/koha/tools/koha-news.pl?op=add_form&id=[% koha_new.idnew | uri %]">Edit</a> >- | <a class="news_delete" href="/cgi-bin/koha/tools/koha-news.pl?op=del&ids=[% koha_new.idnew | html %]">Delete</a> >- | <a href="/cgi-bin/koha/tools/koha-news.pl?op=add_form">New</a> >+ <a href="/cgi-bin/koha/tools/additional-contents.pl?op=add_form&id=[% koha_new.idnew | uri %]">Edit</a> >+ | <a class="news_delete" href="/cgi-bin/koha/tools/additional-contents.pl?op=del&ids=[% koha_new.idnew | html %]">Delete</a> >+ | <a href="/cgi-bin/koha/tools/additional-contents.pl?op=add_form">New</a> > [% END %] > </p> > </div> > [% END %] >- </div><!-- /koha-news --> >+ </div><!-- /additional-contents --> > [% END %] > [% IF ( daily_quote ) %] > <div id="area-news"> >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 00000000000..8aebc2f012e >--- /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' %] >+<title>Additional contents › Tools › Koha</title> >+[% INCLUDE 'doc-head-close.inc' %] >+[% UNLESS ( wysiwyg ) %] >+ [% Asset.css("lib/codemirror/codemirror.css") | $raw %] >+ [% Asset.css("lib/codemirror/lint.min.css") | $raw %] >+ <style> >+ .CodeMirror { >+ resize: vertical; >+ z-index: 0; >+ } >+ </style> >+[% END %] >+</head> >+ >+<body id="tools_additional-contents" class="tools"> >+[% INCLUDE 'header.inc' %] >+[% INCLUDE 'cat-search.inc' %] >+ >+<nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb"> >+ <ol> >+ <li> >+ <a href="/cgi-bin/koha/mainpage.pl">Home</a> >+ </li> >+ <li> >+ <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> >+ </li> >+ >+ [% IF op == 'add_form' %] >+ <li> >+ <a href="/cgi-bin/koha/tools/additional-contents.pl">Additional contents</a> >+ </li> >+ <li> >+ <a href="#" aria-current="page"> >+ [% IF additional_content.idnew %] >+ Modify additional content >+ [% ELSE %] >+ Add additional content >+ [% END %] >+ </a> >+ </li> >+ [% ELSE %] >+ <li> >+ <a href="#" aria-current="page"> >+ Additional contents >+ ([% IF category == 'news' %]News[% ELSE %]HTML customizations[% END %]) >+ </a> >+ </li> >+ [% END %] >+ </ol> >+</nav> >+ >+[% IF op == 'add_form' %] >+<div class="main container-fluid"> >+ <div class="row"> >+ <div class="col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2"> >+[% ELSE %] >+<div class="main container-fluid"> >+ <div class="row"> >+ <div class="col-sm-10 col-sm-push-2"> >+[% END %] >+ >+<main> >+ >+ [% FOR m IN messages %] >+ <div class="dialog [% m.type | html %]"> >+ [% 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 %] >+ </div> >+ [% END %] >+ >+ [% IF op == 'add_form' %] >+ [% PROCESS add_form %] >+ [% ELSE %] >+ [% PROCESS list %] >+ [% END %] >+ >+</main> >+ >+ [% IF op != 'add_form' %] >+ </div> <!-- /.col-sm-10.col-sm-push-2 --> >+ >+ <div class="col-sm-2 col-sm-pull-10"> >+ <aside> >+ >+ <div id="news-filter"> >+ <form action="/cgi-bin/koha/tools/additional-contents.pl" method="get"> >+ <h4>Filter</h4> >+ <fieldset class="brief"> >+ <ol> >+ <li> >+ <label for="news_keyword">Keyword:</label> >+ <input type="text" name="news_keyword" id="news_keyword" /> >+ </li> >+ <li> >+ <label for="news_display_location">Display location:</label> >+ <select name="news_display_location" id="news_display_location"> >+ <option value="">All</option> >+ [% PROCESS locations_options category => category %] >+ </select> >+ </li> >+ <li> >+ <label for="news_library">Library: </label> >+ <select id="news_library" name="news_library"> >+ <option value=""></option> >+ <option value="">All libraries</option> >+ [% PROCESS options_for_libraries libraries => Branches.all( selected => branchcode, unfiltered => 1, ) %] >+ </select> >+ </li> >+ <li> >+ <label> >+ <input type="checkbox" name="show_expired" id="show_expired" /> Show expired >+ </label> >+ </li> >+ </ol> >+ </fieldset> >+ </form> >+ </div> >+ >+ [% INCLUDE 'tools-menu.inc' %] >+ </aside> >+ </div> <!-- /.col-sm-2.col-sm-pull-10 --> >+ [% END %] >+ </div> <!-- /.row --> >+</div> <!-- /.main.container-fluid --> >+ >+[% BLOCK add_form %] >+ [% IF additional_content %] >+ <h1>Modify an additional content</h1> >+ [% ELSE %] >+ <h1>New additional content ([% IF category == 'news' %]News[% ELSE %]HTML customizations[% END %])</h1> >+ [% END %] >+ >+ <div id="toolbar" class="btn-toolbar"> >+ <div class="btn-group"> >+ <button class="btn btn-default" id="submit_form"><i class="fa fa-save"></i> Save</button> >+ </div> >+ <a class="btn btn-default cancel" href="/cgi-bin/koha/tools/additional-contents.pl"><i class="fa fa-remove"></i> Cancel</a> >+ </div> >+ >+ <form id="add_additional_content" method="post" action="/cgi-bin/koha/tools/additional-contents.pl" class="validate"> >+ <input type="hidden" name="op" value="add_validate" /> >+ <input type="hidden" name="id" value="[% additional_content.idnew | html %]" /> >+ <input type="hidden" name="category" value="[% category | html %]" /> >+ <fieldset class="rows"> >+ <ol> >+ <li> >+ [% IF additional_content %] >+ <span class="label">Code:</span> [% additional_content.code | html %] >+ <input type="hidden" id="code" name="code" value="[% additional_content.code | html %]" /> >+ [% ELSE %] >+ <label for="code" class="required">Code:</label> >+ <input type="text" id="code" name="code" size="20" maxlength="20" value="" required="required"/> >+ <span class="required">Required</span> >+ [% END %] >+ </li> >+ <li> >+ <label for="location">Display location:</label> >+ <select id="location" name="location"> >+ [% PROCESS locations_options location => additional_content.location %] >+ </select> >+ </li> >+ <li> >+ <label for="branchcode">Library: </label> >+ <select id="branchcode" name="branchcode"> >+ [% IF additional_content.branchcode == '' %] >+ <option value="" selected="selected">All libraries</option> >+ [% ELSE %] >+ <option value="">All libraries</option> >+ [% END %] >+ [% PROCESS options_for_libraries libraries => Branches.all( selected => additional_content.branchcode, unfiltered => 1, ) %] >+ </select> >+ </li> >+ [% UNLESS languages.size %] >+ <li> >+ <label for="title" class="required">Title: </label> >+ <input id="title" size="30" type="text" name="title" value="[% additional_content.title | html %]" required="required" class="required" /> <span class="required">Required</span> >+ </li> >+ [% END %] >+ <li> >+ <label for="from">Publication date: </label> >+ <input id="from" type="text" name="published_on" size="15" value="[% additional_content.published_on | html %]" class="datepickerfrom" /> >+ <div class="hint">[% INCLUDE 'date-format.inc' %]</div> >+ </li> >+ <li> >+ <label for="to">Expiration date: </label> >+ <input id="to" type="text" name="expirationdate" size="15" value="[% additional_content.expirationdate | html %]" class="datepickerto" /> >+ <div class="hint"> >+ [% INCLUDE 'date-format.inc' %] >+ [% IF category == 'news' %] >+ <br>News will still be accessible by direct URL if expired. >+ [% END %] >+ </div> >+ </li> >+ <li> >+ <label for="number">Appear in position: </label> >+ [% IF ( additional_content.number ) %] >+ <input id="number" size="3" name="number" type="text" value="[% additional_content.number | html %]" /> >+ [% ELSE %] >+ <input id="number" size="3" name="number" type="text" /> >+ [% END %] >+ </li> >+ </ol> >+ </fieldset> >+ >+ [% IF languages.size %] >+ <div style="clear:both"></div> >+ <div id="tabs"> >+ <ul> >+ [% FOR language IN languages %] >+ [% IF language.lang == 'default' %] >+ <li><a href="#lang_default">Default</a></li> >+ [% ELSE %] >+ <li><a href="#lang_[% language.lang | uri %]">[% language.description %]</a></li> >+ [% END %] >+ [% END %] >+ </ul> >+ >+ [% FOR language IN languages %] >+ <div id="lang_[% language.lang | uri %]" class="lang" data-lang="[% language.description | html %]"> >+ <div style="clear:both;"> >+ >+ <fieldset>[%# FIXME We should remove list-style:none; and use class="rows" here but it does not work. Owen please help! %] >+ <ol> >+ <li style="list-style: none;"> >+ <label for="title_[% language.lang | html %]">Title: </label> >+ <input id="title_[% language.lang| html %]" size="30" type="text" name="title" value="[% translated_contents.item(language.lang).title | html %]"></span> >+ </li> >+ <li style="list-style: none;"> >+ <label for="content_[% language.lang | html %]">Content: </label> >+ <textarea name="content" id="content_[% language.lang | html %]" cols="75" rows="10">[% translated_contents.item(language.lang).content | html %]</textarea> >+ <input type="hidden" name="lang" value="[% language.lang %]" /> >+ </li> >+ </ol> >+ </fieldset> >+ </div> >+ </div> >+ [% END %] >+ </div> >+ [% ELSE %] >+ <div id="lang_default"> >+ <div style="clear:both;"> >+ <textarea name="content" id="content_default" cols="75" rows="10">[% additional_content.content | html %]</textarea> >+ </div> >+ </div> >+ [% END %] >+ </form> >+[% END %] >+ >+[% BLOCK list %] >+ >+ <div id="toolbar" class="btn-toolbar"> >+ <a class="btn btn-default" id="newentry" href="/cgi-bin/koha/tools/additional-contents.pl?op=add_form&category=[% category | html %]"><i class="fa fa-plus"></i> New entry</a> >+ </div> >+ >+ <h2>Additional contents ([% IF category == 'news' %]News[% ELSE %]HTML customizations[% END %])</h2> >+ [% IF category == 'news' %] >+ See <a href="/cgi-bin/koha/tools/additional-contents.pl?category=html_customizations">HTML customizations</a> >+ [% ELSE %] >+ See <a href="/cgi-bin/koha/tools/additional-contents.pl?category=news">News</a> >+ [% END %] >+ >+ [% IF additional_contents.count %] >+ <form id="del_form" method="post" action="/cgi-bin/koha/tools/additional-contents.pl"> >+ <table id="table_additional_contents"> >+ <thead> >+ <tr> >+ <th class="NoSort"> </th> >+ <th>Location</th> >+ <th>Library</th> >+ <th>Number</th> >+ <th>Publication date</th> >+ <th>Expiration date</th> >+ <th class="anti-the">Title</th> >+ <th>Author</th> >+ <th class="anti-the">News</th> >+ <th class="NoSort noExport">Actions</th> >+ </tr> >+ </thead> >+ <tbody> >+ [% FOREACH c IN additional_contents%] >+ [% IF ( c.is_expired ) %]<tr class="expired">[% ELSE %]<tr>[% END %] >+ <td> >+ <input type="checkbox" name="ids" value="[% c.idnew | html %]" /> >+ </td> >+ <td> >+ [% 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 %] >+ </td> >+ <td> >+ [% IF ( c.branchcode == "" ) -%] >+ All libraries >+ [% ELSE %][% c.library.branchname | html %] >+ [% END %] >+ </td> >+ <td>[% c.number | html %]</td> >+ <td data-order="[% c.published_on | html %]">[% c.published_on | $KohaDates %]</td> >+ <td data-order="[% c.expirationdate | html %]">[% c.expirationdate | $KohaDates %] [% IF ( c.is_expired ) %](<span class="expired">expired</span>)[% END %]</td> >+ <td>[% c.title | html %]</td> >+ <td>[% IF ( c.author) %][% INCLUDE 'patron-title.inc' patron=c.author %][% END %]</td> >+ <td> >+ <div class="btn-group"> >+ <a class="preview_news btn btn-default btn-xs" data-number="[% loop.count | html %]"><i class="fa fa-eye" aria-hidden="true"></i> Preview content</a> >+ </div> >+ <div id="contentModal[% loop.count | html %]" class="modal" tabindex="-1" role="dialog" data-number="[% loop.count | html %]"> >+ <div class="modal-dialog" role="document"> >+ <div class="modal-content modal-lg"> >+ <div class="modal-header"> >+ <h5 class="modal-title">Preview of: "[% c.title | html %]"</h5> >+ </div> >+ <div class="modal-body"> >+ [% c.content | $raw %] >+ </div> >+ <div class="modal-footer"> >+ <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button> >+ </div> >+ </div> >+ </div> >+ </td> >+ <td class="actions"> >+ [% IF ( wysiwyg ) %] >+ [% SET editmode = "wysiwyg" %] >+ [% ELSE %] >+ [% SET editmode = "text" %] >+ [% END %] >+ <div class="btn-group dropup"> >+ <a href="/cgi-bin/koha/tools/additional-contents.pl?op=add_form&id=[% c.idnew | uri %]&editmode=[% editmode | uri %]" class="btn btn-default btn-xs"> <i class="fa fa-pencil"></i> Edit</a><button class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown"> >+ <span class="caret"></span> >+ </button> >+ <ul class="dropdown-menu pull-right"> >+ <li> >+ [% IF ( wysiwyg ) %] >+ <a href="/cgi-bin/koha/tools/additional-contents.pl?op=add_form&id=[% c.idnew | uri %]&editmode=text"><i class="fa fa-pencil"></i> Edit with text editor</a> >+ [% ELSE %] >+ <a href="/cgi-bin/koha/tools/additional-contents.pl?op=add_form&id=[% c.idnew | uri %]&editmode=wysiwyg"><i class="fa fa-pencil"></i> Edit with WYSIWYG editor</a> >+ [% END %] >+ </li> >+ </ul> >+ </div> >+ <div class="btn-group"> >+ <a href="/cgi-bin/koha/tools/additional-contents.pl?op=del&ids=[% c.idnew | uri %]" class="delete_news btn btn-default btn-xs"><i class="fa fa-trash"></i> Delete</a> >+ </div> >+ </td> >+ </tr> >+ [% END %] >+ </tbody> >+ </table> >+ <input type="hidden" name="op" value="del" /> >+ <fieldset class="action"><input type="submit" class="button" value="Delete selected" /></fieldset> >+ </form> >+ [% ELSE %] >+ <div class="dialog message">There are no additional contents.</div> >+ [% END %] >+[% END %] >+ >+[% BLOCK locations_options %] >+ [% IF category == 'news' %] >+ [% IF location == "staff_and_opac" %] >+ <option value="staff_and_opac" selected="selected">Librarian and OPAC interfaces</option> >+ [% ELSE %] >+ <option value="staff_and_opac">Librarian and OPAC interfaces</option> >+ [% END %] >+ >+ [% IF location == "staff_only" %] >+ <option value="staff_only" selected="selected">Librarian interface</option> >+ [% ELSE %] >+ <option value="staff_only">Librarian interface</option> >+ [% END %] >+ >+ [% IF location == "opac_only" %] >+ <option value="opac_only" selected="selected">OPAC</option> >+ [% ELSE %] >+ <option value="opac_only">OPAC</option> >+ [% END %] >+ >+ [% IF location == "slip" %] >+ <option value="slip" selected="selected">Slip</option> >+ [% ELSE %] >+ <option value="slip">Slip</option> >+ [% END %] >+ [% ELSE %] >+ [% FOREACH l IN [ 'OpacNavRight', 'opacheader', 'OpacCustomSearch', 'OpacMainUserBlock', 'opaccredits', 'OpacLoginInstructions', 'OpacSuggestionInstructions', 'ArticleRequestsDisclaimerText' ] %] >+ [% IF l == location %] >+ <option value="[% l | html %]" selected="selected">[% l | html %]</option> >+ [% ELSE %] >+ <option value="[% l | html %]">[% l | html %]</option> >+ [% 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' %] >+ <script> >+ $('.preview_news').click( function() { >+ modalNumber = $(this).attr('data-number'); >+ $('.modal[data-number="'+modalNumber+'"]').modal('show'); >+ }) >+ function Checkbox(){ >+ var form = document.getElementById('del_form'); >+ var inputs = form.getElementsByTagName('input'); >+ var checked = false; >+ for (var i=0; i<inputs.length; i++) { >+ if (inputs[i].type == 'checkbox' && inputs[i].name == 'ids') { >+ checked = inputs[i].checked; >+ if (checked) return true; >+ } >+ } >+ } >+ >+ function filterDataTable( table, column, term ){ >+ if( column ){ >+ table.column( column ).search( term ).draw(); >+ } else { >+ table.search( term ).draw(); >+ } >+ clearFilter( term ); >+ } >+ >+ function clearFilter( term ){ >+ if( term == "" ){ >+ $(".dt_button_clear_filter").addClass("disabled"); >+ } else { >+ $(".dt_button_clear_filter").removeClass("disabled"); >+ } >+ } >+ >+ /* Custom table search configuration: If a table row >+ has an "expired" class, hide it UNLESS the >+ show_expired checkbox is checked */ >+ $.fn.dataTable.ext.search.push( >+ function( settings, searchData, index, rowData, counter ) { >+ var row = $(settings.aoData[index].nTr); >+ if( row.hasClass("expired") && !$("#show_expired").prop("checked") ){ >+ return false; >+ } else { >+ return true; >+ } >+ } >+ ); >+ >+ $(document).ready(function() { >+ >+ var table = $("#table_additional_contents").DataTable($.extend(true, {}, dataTablesDefaults, { >+ "order": [[ 4, "desc" ]], >+ "aoColumnDefs": [ >+ { "sortable": false, "searchable": false, 'targets': [ 'NoSort' ] }, >+ { "type": "anti-the", "targets": [ "anti-the" ] } >+ ], >+ "sPaginationType": "full_numbers" >+ })); >+ >+ $(".delete_news").on("click", function(){ >+ return confirmDelete( _("Are you sure you want to delete this news item? This cannot be undone.") ); >+ }); >+ >+ $("#del_form").on("submit",function(){ >+ if ( Checkbox() ) { >+ return confirmDelete( _("Are you sure you want to delete the selected news?") ); >+ } else { >+ alert(_("Please select a news item to delete.")); >+ return false; >+ } >+ }); >+ >+ $("#show_expired").on("change", function(){ >+ /* redraw the DataTable according to the custom search function */ >+ table.draw(); >+ }); >+ >+ table.on( 'search.dt', function () { >+ var term = table.search(); >+ $("#news_keyword").val( term ); >+ }); >+ >+ $("#news_keyword").on("keyup", function(){ >+ var term = $(this).val(); >+ filterDataTable( table, null, term ); >+ }); >+ >+ $("#news_display_location").on("change", function(){ >+ var term = $(this).val(); >+ filterDataTable( table, 1, term ); >+ }); >+ >+ $("#news_library").on("change", function(){ >+ // Table must be filtered by the <option>'s text, not its value >+ var opt = $(this).find("option:selected").text(); >+ filterDataTable( table, 2, opt ); >+ }); >+ >+ $(".dt_button_clear_filter").on("click", function(){ >+ table.search('').columns().search('').draw(); >+ $("#news-filter select").each(function(){ >+ $(this).val(""); >+ }); >+ }); >+ }); >+ </script> >+ [% ELSE %] >+ <script> >+ $(document).ready(function() { >+ $("#tabs").tabs(); >+ $("#add_additional_content").validate({ >+ submitHandler: function(form){ >+ if ( ! $("#title_default").val().length > 0 ) { >+ alert(__("Please specify a title for 'Default'")); >+ return false; >+ } >+ >+ form.submit(); >+ } >+ }); >+ >+ $("#submit_form").on("click",function(){ >+ $("#add_additional_content").submit(); >+ }); >+ >+ Sticky = $("#toolbar"); >+ Sticky.hcSticky({ >+ stickTo: ".main", >+ stickyClass: "floating" >+ }); >+ >+ }); >+ </script> >+ [% 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 %] >+ <script> >+ var editor = CodeMirror.fromTextArea(document.getElementById('content'), { >+ lineNumbers: true, >+ lineWrapping: true, >+ lint: true, >+ mode: "text/html", >+ gutters: ["CodeMirror-lint-markers"], >+ viewportMargin: Infinity, >+ }); >+ </script> >+ [% ELSE %] >+ [% Asset.js("lib/tiny_mce/tinymce.min.js") | $raw %] >+ [% INCLUDE 'str/tinymce_i18n.inc' %] >+ <script> >+ tinyMCE.init({ >+ verify_html: false, >+ force_br_newlines : false, >+ force_p_newlines : false, >+ forced_root_block : '', >+ branding : false, >+ relative_urls : false, >+ content_css : "[% interface | html %]/[% theme | html %]/css/tinymce.css", >+ menubar : "file edit view insert format tools table", >+ mode : "specific_textareas", >+ plugins : "autoresize table hr link image charmap lists code emoticons", >+ extended_valid_elements:"style,link[href|rel]", >+ custom_elements:"style,link,~link", >+ toolbar : [ >+ "formatselect | bold italic | cut copy paste | alignleft aligncenter alignright | outdent indent | image link unlink anchor cleanup hr", >+ "table | bullist numlist | undo redo | removeformat | emoticons charmap | forecolor backcolor | code visualaid help" >+ ], >+ }); >+ </script> >+ [% 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 35d7177291d..00000000000 >--- 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' %] >-<title>News › Tools › Koha</title> >-[% INCLUDE 'doc-head-close.inc' %] >-[% UNLESS ( wysiwyg ) %] >- [% Asset.css("lib/codemirror/codemirror.css") | $raw %] >- [% Asset.css("lib/codemirror/lint.min.css") | $raw %] >- <style> >- .CodeMirror { >- resize: vertical; >- z-index: 0; >- } >- </style> >-[% END %] >-</head> >- >-<body id="tools_koha-news" class="tools"> >-[% INCLUDE 'header.inc' %] >-[% INCLUDE 'cat-search.inc' %] >- >-<nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb"> >- <ol> >- <li> >- <a href="/cgi-bin/koha/mainpage.pl">Home</a> >- </li> >- <li> >- <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> >- </li> >- >- [% IF ( add_form ) %] >- <li> >- <a href="/cgi-bin/koha/tools/koha-news.pl">News</a> >- </li> >- <li> >- <a href="#" aria-current="page"> >- [% IF ( id ) %] >- Edit news item >- [% ELSE %] >- Add news item >- [% END %] >- </a> >- </li> >- [% ELSE %] >- <li> >- <a href="#" aria-current="page"> >- News >- </a> >- </li> >- [% END %] >- </ol> >-</nav> >- >-[% IF ( add_form ) %] >- <div class="main container-fluid"> >- <div class="row"> >- <div class="col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2"> >-[% ELSE %] >- <div class="main container-fluid"> >- <div class="row"> >- <div class="col-sm-10 col-sm-push-2"> >-[% END %] >- <main> >- >-[% UNLESS ( add_form ) %] >- [% IF error_message == 'title_missing' %] >- <div class="dialog alert">Error: Required news title missing!</div> >- [% END %] >-<h2>News</h2> >-<div id="toolbar" class="btn-toolbar"> >- <a class="btn btn-default" id="newentry" href="/cgi-bin/koha/tools/koha-news.pl?op=add_form&lang=[% lang | html %]"><i class="fa fa-plus"></i> New entry</a> >-</div> >-[% END %] >- >-[% IF ( add_form ) %] >- [% IF ( op == 'add' ) %] >- [% default_lang = lang %] >- [% ELSE %] >- [% default_lang = new_detail.lang %] >- [% END %] >- <form name="add_form" method="post" action="/cgi-bin/koha/tools/koha-news.pl" > >- <input type="hidden" name="op" value="[% op | html %]" /> >- <input type="hidden" name="id" value="[% id | html %]" /> >- <fieldset class="rows"> >- <legend>OPAC and Koha news</legend> >- <ol> <li> >- <label for="lang">Display location:</label> >- <select id="lang" name="lang"> >- [% PROCESS lang_locations language => default_lang %] >- </select> >- </li> >- <li> >- <label for="branch">Library: </label> >- <select id="branch" name="branch"> >- [% IF ( new_detail.branchcode == '' ) %] >- <option value="" selected="selected">All libraries</option> >- [% ELSE %] >- <option value="" >All libraries</option> >- [% END %] >- [% PROCESS options_for_libraries libraries => Branches.all( selected => new_detail.branchcode, unfiltered => 1, ) %] >- </select> >- </li> >- <li> >- <label for="title" class="required">Title: </label> >- <input id="title" size="30" type="text" name="title" value="[% new_detail.title | html %]" required="required" class="required" /> <span class="required">Required</span> >- </li> >- <li> >- <label for="from">Publication date: </label> >- <input id="from" type="text" name="published_on" size="15" value="[% new_detail.published_on | html %]" class="datepickerfrom" /> >- <div class="hint">[% INCLUDE 'date-format.inc' %]</div> >- </li> >- <li> >- <label for="to">Expiration date: </label> >- <input id="to" type="text" name="expirationdate" size="15" value="[% new_detail.expirationdate | html %]" class="datepickerto" /> >- <div class="hint"> >- [% INCLUDE 'date-format.inc' %] >- <br>News will still be accessible by direct URL if expired. >- </div> >- </li> >- <li> >- <label for="number">Appear in position: </label> >- [% IF ( new_detail.number ) %] >- <input id="number" size="3" name="number" type="text" value="[% new_detail.number | html %]" /> >- [% ELSE %] >- <input id="number" size="3" name="number" type="text" /> >- [% END %] >- </li> >- <li><label for="content">News: </label> >- <textarea name="content" id="content" cols="75" rows="10">[% new_detail.content | html %]</textarea> >- </li> >- </ol> >- </fieldset> >- >- <fieldset class="action"><input class="button" type="submit" value="Submit" /> <a class="cancel" href="/cgi-bin/koha/tools/koha-news.pl">Cancel</a></fieldset> >- </form> >- [% ELSE %] >- [% IF ( opac_news.count ) %] >- <form id="del_form" method="post" action="/cgi-bin/koha/tools/koha-news.pl"> >- <table id="newst"> >- <thead> <tr> >- <th class="NoSort"> </th> >- <th>Location</th> >- <th>Library</th> >- <th>Number</th> >- <th>Publication date</th> >- <th>Expiration date</th> >- <th class="anti-the">Title</th> >- <th>Author</th> >- <th class="anti-the">News</th> >- <th class="NoSort noExport">Actions</th> >- </tr></thead> >- <tbody>[% FOREACH opac_new IN opac_news %] >- [% IF ( opac_new.is_expired ) %] >- <tr class="expired"> >- [% ELSE %] >- <tr> >- [% END %] >- <td> >- <input type="checkbox" name="ids" value="[% opac_new.idnew | html %]" /> >- </td> >- <td>[% SWITCH opac_new.lang %] >- [% CASE "koha" %] >- Librarian interface (koha) >- [% CASE "slip" %] >- Slip >- [% CASE "" %] >- All >- [% CASE %] >- OPAC ([% opac_new.lang | html %]) >- [% END %] >- </td> >- <td>[% IF ( opac_new.branchcode == "" ) -%] >- All libraries >- [% ELSE %][% opac_new.library.branchname | html %] >- [% END %]</td> >- <td>[% opac_new.number | html %]</td> >- <td data-order="[% opac_new.published_on | html %]">[% opac_new.published_on | $KohaDates %]</td> >- <td data-order="[% opac_new.expirationdate | html %]">[% opac_new.expirationdate | $KohaDates %] [% IF ( opac_new.is_expired ) %](<span class="expired">expired</span>)[% END %]</td> >- <td>[% opac_new.title | html %]</td> >- <td>[% IF ( opac_new.author) %][% INCLUDE 'patron-title.inc' patron=opac_new.author %][% END %]</td> >- <td> >- <div class="btn-group"> >- <a class="preview_news btn btn-default btn-xs" data-number="[% loop.count | html %]"><i class="fa fa-eye" aria-hidden="true"></i> Preview content</a> >- </div> >- <div id="contentModal[% loop.count | html %]" class="modal" tabindex="-1" role="dialog" data-number="[% loop.count | html %]"> >- <div class="modal-dialog" role="document"> >- <div class="modal-content modal-lg"> >- <div class="modal-header"> >- <h5 class="modal-title">Preview of: "[% opac_new.title | html %]"</h5> >- </div> >- <div class="modal-body"> >- [% opac_new.content | $raw %] >- </div> >- <div class="modal-footer"> >- <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button> >- </div> >- </div> >- </div> >- </td> >- <td class="actions"> >- [% IF ( wysiwyg ) %] >- [% SET editmode = "wysiwyg" %] >- [% ELSE %] >- [% SET editmode = "text" %] >- [% END %] >- <div class="btn-group dropup"> >- <a href="/cgi-bin/koha/tools/koha-news.pl?op=add_form&id=[% opac_new.idnew | uri %]&editmode=[% editmode | uri %]" class="btn btn-default btn-xs"> <i class="fa fa-pencil"></i> Edit</a><button class="btn btn-default btn-xs dropdown-toggle" data-toggle="dropdown"> >- <span class="caret"></span> >- </button> >- <ul class="dropdown-menu pull-right"> >- <li> >- [% IF ( wysiwyg ) %] >- <a href="/cgi-bin/koha/tools/koha-news.pl?op=add_form&id=[% opac_new.idnew | uri %]&editmode=text"><i class="fa fa-pencil"></i> Edit with text editor</a> >- [% ELSE %] >- <a href="/cgi-bin/koha/tools/koha-news.pl?op=add_form&id=[% opac_new.idnew | uri %]&editmode=wysiwyg"><i class="fa fa-pencil"></i> Edit with WYSIWYG editor</a> >- [% END %] >- </li> >- </ul> >- </div> >- <div class="btn-group"> >- <a href="/cgi-bin/koha/tools/koha-news.pl?op=del&ids=[% opac_new.idnew | uri %]" class="delete_news btn btn-default btn-xs"><i class="fa fa-trash"></i> Delete</a> >- </div> >- </td> >- </tr> >- [% END %]</tbody> >- </table> >- <input type="hidden" name="op" value="del" /> >- <fieldset class="action"><input type="submit" class="button" value="Delete selected" /></fieldset> >- </form> >- [% ELSE %] >- <div class="dialog message">There are no news items.</div> >- [% END %] >- [% END %] >- >- </main> >- [% UNLESS ( add_form ) %] >- </div> <!-- /.col-sm-10.col-sm-push-2 --> >- >- <div class="col-sm-2 col-sm-pull-10"> >- <aside> >- >- <div id="news-filter"> >- <form action="/cgi-bin/koha/tools/koha-news.pl" method="get"> >- <h4>Filter</h4> >- <fieldset class="brief"> >- <ol> >- <li> >- <label for="news_keyword">Keyword:</label> >- <input type="text" name="news_keyword" id="news_keyword" /> >- </li> >- <li> >- <label for="news_display_location">Display location:</label> >- <select name="news_display_location" id="news_display_location"> >- [% PROCESS lang_locations %] >- </select> >- </li> >- <li> >- <label for="news_library">Library: </label> >- <select id="news_library" name="news_library"> >- <option value=""></option> >- <option value="">All libraries</option> >- [% PROCESS options_for_libraries libraries => Branches.all( selected => branchcode, unfiltered => 1, ) %] >- </select> >- </li> >- <li> >- <label> >- <input type="checkbox" name="show_expired" id="show_expired" /> Show expired >- </label> >- </li> >- </ol> >- </fieldset> >- </form> >- </div> >- >- [% INCLUDE 'tools-menu.inc' %] >- </aside> >- </div> <!-- /.col-sm-2.col-sm-pull-10 --> >- [% END %] >- </div> <!-- /.row --> >- </div> <!-- /.main.container-fluid --> >- >- >-[% MACRO jsinclude BLOCK %] >- [% INCLUDE 'calendar.inc' %] >- [% Asset.js("js/tools-menu.js") | $raw %] >- [% IF ( opac_news.count ) %] >- [% INCLUDE 'datatables.inc' %] >- <script> >- $('.preview_news').click( function() { >- modalNumber = $(this).attr('data-number'); >- $('.modal[data-number="'+modalNumber+'"]').modal('show'); >- }) >- function Checkbox(){ >- var form = document.getElementById('del_form'); >- var inputs = form.getElementsByTagName('input'); >- var checked = false; >- for (var i=0; i<inputs.length; i++) { >- if (inputs[i].type == 'checkbox' && inputs[i].name == 'ids') { >- checked = inputs[i].checked; >- if (checked) return true; >- } >- } >- } >- >- function filterDataTable( table, column, term ){ >- if( column ){ >- table.column( column ).search( term ).draw(); >- } else { >- table.search( term ).draw(); >- } >- clearFilter( term ); >- } >- >- function clearFilter( term ){ >- if( term == "" ){ >- $(".dt_button_clear_filter").addClass("disabled"); >- } else { >- $(".dt_button_clear_filter").removeClass("disabled"); >- } >- } >- >- /* Custom table search configuration: If a table row >- has an "expired" class, hide it UNLESS the >- show_expired checkbox is checked */ >- $.fn.dataTable.ext.search.push( >- function( settings, searchData, index, rowData, counter ) { >- var row = $(settings.aoData[index].nTr); >- if( row.hasClass("expired") && !$("#show_expired").prop("checked") ){ >- return false; >- } else { >- return true; >- } >- } >- ); >- >- $(document).ready(function() { >- var newst = $("#newst").DataTable($.extend(true, {}, dataTablesDefaults, { >- "order": [[ 4, "desc" ]], >- "aoColumnDefs": [ >- { "sortable": false, "searchable": false, 'targets': [ 'NoSort' ] }, >- { "type": "anti-the", "targets": [ "anti-the" ] } >- ], >- "sPaginationType": "full_numbers" >- })); >- >- $(".delete_news").on("click", function(){ >- return confirmDelete( _("Are you sure you want to delete this news item? This cannot be undone.") ); >- }); >- >- $("#del_form").on("submit",function(){ >- if ( Checkbox() ) { >- return confirmDelete( _("Are you sure you want to delete the selected news?") ); >- } else { >- alert(_("Please select a news item to delete.")); >- return false; >- } >- }); >- >- $("#show_expired").on("change", function(){ >- /* redraw the DataTable according to the custom search function */ >- newst.draw(); >- }); >- >- newst.on( 'search.dt', function () { >- var term = newst.search(); >- $("#news_keyword").val( term ); >- }); >- >- $("#news_keyword").on("keyup", function(){ >- var term = $(this).val(); >- filterDataTable( newst, null, term ); >- }); >- >- $("#news_display_location").on("change", function(){ >- var term = $(this).val(); >- filterDataTable( newst, 1, term ); >- }); >- >- $("#news_library").on("change", function(){ >- // Table must be filtered by the <option>'s text, not its value >- var opt = $(this).find("option:selected").text(); >- filterDataTable( newst, 2, opt ); >- }); >- >- $(".dt_button_clear_filter").on("click", function(){ >- newst.search('').columns().search('').draw(); >- $("#news-filter select").each(function(){ >- $(this).val(""); >- }); >- }); >- }); >- </script> >- [% 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 %] >- <script> >- var editor = CodeMirror.fromTextArea(document.getElementById('content'), { >- lineNumbers: true, >- lineWrapping: true, >- lint: true, >- mode: "text/html", >- gutters: ["CodeMirror-lint-markers"], >- viewportMargin: Infinity, >- }); >- </script> >- [% ELSE %] >- [% Asset.js("lib/tiny_mce/tinymce.min.js") | $raw %] >- [% INCLUDE 'str/tinymce_i18n.inc' %] >- <script> >- tinyMCE.init({ >- verify_html: false, >- force_br_newlines : false, >- force_p_newlines : false, >- forced_root_block : '', >- branding : false, >- relative_urls : false, >- content_css : "[% interface | html %]/[% theme | html %]/css/tinymce.css", >- menubar : "file edit view insert format tools table", >- mode : "specific_textareas", >- plugins : "autoresize table hr link image charmap lists code emoticons", >- extended_valid_elements:"style,link[href|rel]", >- custom_elements:"style,link,~link", >- toolbar : [ >- "formatselect | bold italic | cut copy paste | alignleft aligncenter alignright | outdent indent | image link unlink anchor cleanup hr", >- "table | bullist numlist | undo redo | removeformat | emoticons charmap | forecolor backcolor | code visualaid help" >- ], >- }); >- </script> >- [% END # /IF NewsToolEditor %] >-[% END %] >- >-[% BLOCK lang_locations %] >- [% IF ( language == "" ) %] >- <option value="" selected="selected"></option> >- [% ELSE %] >- <option value="">All</option> >- [% END %] >- [% IF ( language == "koha" ) %] >- <option value="koha" selected="selected">Librarian interface</option> >- [% ELSE %] >- <option value="koha">Librarian interface</option> >- [% END %] >- [% IF ( language == "slip" ) %] >- <option value="slip" selected="selected">Slip</option> >- [% ELSE %] >- <option value="slip">Slip</option> >- [% END %] >- [% FOREACH lang_lis IN lang_list %] >- <optgroup label="[% lang_lis.language | html %]"> >- [% 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 ) %] >- <option value="[% location_lang | html %]" selected="selected">[% location | html %] ([% lang_lis.language | html %])</option> >- [% ELSE %] >- <option value="[% location_lang | html %]">[% location | html %] ([% lang_lis.language | html %])</option> >- [% END %] >- [% END %] >- </optgroup> >- [% 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 f9f66787c3a..ab4af6b8e2a 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 >@@ -93,7 +93,7 @@ > > > <div class="col-sm-4 col-sm-push-4"> >-[% 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 ) %] > <h3>Additional tools</h3> > [% END %] > <dl> >@@ -112,9 +112,12 @@ > <dd>Browse the system logs</dd> > [% END %] > >- [% IF ( CAN_user_tools_edit_news ) %] >- <dt><a href="/cgi-bin/koha/tools/koha-news.pl">News</a></dt> >+ [% IF ( CAN_user_tools_edit_additional_contents ) %] >+ <dt><a href="/cgi-bin/koha/tools/additional-contents.pl?category=news">News</a></dt> > <dd>Write news for the OPAC and staff interfaces</dd> >+ >+ <dt><a href="/cgi-bin/koha/tools/additional-contents.pl?category=html_customizations">HTML customizations</a></dt> >+ <dd>Write HTML customizations</dd> > [% 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 fa51c437d64..b03cf6c5371 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 ) %] > > <div id="wrapper"> > <div id="header-region" class="noprint"> >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 3c872b95c6a..254118387cd 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 ) %] > > <div id="wrapper"> > <div id="header-region" class="noprint"> >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc >index e44ae2f111f..6d41ff90fea 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 ) %] > > <div id="wrapper"> > <div id="header-region" class="noprint"> >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 c103f0ec4cf..2d1a80da1d1 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 665d32087d5..36908723f6d 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 ) %] > <title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog</title> > [% 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 86211c80823..4e13defc683 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' %] > <title> > [% 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 0dfabad069a..d46100fcbe9 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</title> > [% 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 35f84bf57a2..b688de43d1f 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' %] > <title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog</title> > [% 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 2cef56f6dff..eedcd6a092b 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' %] > <title>[% 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 c146e55a034..70f55d7c7c1 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 0999f58199c..bc8dc88905c 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 5b98333b85a..bf63962ae04 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 a969424fff2..60d700e3e8a 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 17d7ad87518..67b74bf1f2b 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 c332faf0c87..b4873584610 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 596a89711d6..0cbffac37cc 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 7e72517eb63..0aa71f2e74d 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 00000000000..da3e57c91af >--- /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 cfc8066104f..00000000000 >--- 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 b913d0ee59d..68b9eed4498 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.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 24387
:
122737
|
122738
|
122746
|
122748
|
122872
|
122873
|
122874
|
122878
|
122879
|
122880
|
123730
|
123731
|
123732
|
123733
|
123734
|
123795
|
123796
|
123797
|
123798
|
123803
|
123811
|
123854
|
123855
|
123856
|
124867
|
125545
|
142653