From fe26d42ada25990fb99ac5309de82810e2729deb Mon Sep 17 00:00:00 2001
From: Alex Arnaud
Date: Thu, 27 Sep 2018 13:15:50 +0000
Subject: [PATCH] Bug 17047: add a dedicated page for Mana setup
Signed-off-by: Michal Denar
Signed-off-by: Michal Denar
Signed-off-by: Kyle M Hall
Signed-off-by: Nick Clemens
---
Koha/Subscription/Frequency.pm | 4 -
admin/admin-home.pl | 2 +
admin/share_content.pl | 89 ++++++++++
.../atomicupdate/mana_02-add_Mana_syspref.sql | 3 +-
installer/data/mysql/sysprefs.sql | 2 +-
.../intranet-tmpl/lib/jquery/activatemana.js | 18 ---
.../mana/mana-report-search-result.inc | 29 ++--
.../mana/mana-subscription-search-result.inc | 33 ++--
.../prog/en/includes/reports-toolbar.inc | 24 +--
.../prog/en/includes/serials-menu.inc | 2 +-
.../prog/en/includes/serials-toolbar.inc | 54 +++----
.../prog/en/modules/admin/admin-home.tt | 18 ++-
.../prog/en/modules/admin/preferences.tt | 1 -
.../admin/preferences/web_services.pref | 6 +-
.../prog/en/modules/admin/share_content.tt | 152 ++++++++++++++++++
.../modules/reports/guided_reports_start.tt | 146 +++++++++--------
.../prog/en/modules/serials/serials-search.tt | 2 +-
.../en/modules/serials/subscription-add.tt | 9 +-
.../en/modules/serials/subscription-detail.tt | 2 +-
.../intranet-tmpl/prog/js/subscription-add.js | 6 +-
reports/guided_reports.pl | 4 +-
serials/subscription-add.pl | 5 +-
svc/mana/token | 55 -------
t/db_dependent/Koha/Subscription.t | 2 +
24 files changed, 427 insertions(+), 241 deletions(-)
create mode 100755 admin/share_content.pl
delete mode 100644 koha-tmpl/intranet-tmpl/lib/jquery/activatemana.js
create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/admin/share_content.tt
delete mode 100755 svc/mana/token
diff --git a/Koha/Subscription/Frequency.pm b/Koha/Subscription/Frequency.pm
index d7d06dc3c0..64dd327861 100644
--- a/Koha/Subscription/Frequency.pm
+++ b/Koha/Subscription/Frequency.pm
@@ -25,11 +25,7 @@ use base qw(Koha::Object);
=head1 NAME
-<<<<<<< b4c9007cc708d995838eae801a5a24b47435095e
-Koha::Subscription::Frequency - Koha Subscription Frequency Object class
-=======
Koha::Subscription::Frequency - Koha Subscription::Frequency Object class
->>>>>>> Bug 17047 subscriptions management with Mana-KB
=head1 API
diff --git a/admin/admin-home.pl b/admin/admin-home.pl
index ae16bf6680..f6a7b23ac1 100755
--- a/admin/admin-home.pl
+++ b/admin/admin-home.pl
@@ -25,6 +25,7 @@ use Koha::Plugins;
my $query = new CGI;
my $plugins_enabled = C4::Context->preference('UseKohaPlugins') && C4::Context->config("enable_plugins");
+my $mana_url = C4::Context->config('mana_config');
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
{
@@ -38,5 +39,6 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
);
$template->param( plugins_enabled => $plugins_enabled, );
+$template->param( mana_url => $mana_url, );
output_html_with_http_headers $query, $cookie, $template->output;
diff --git a/admin/share_content.pl b/admin/share_content.pl
new file mode 100755
index 0000000000..d900b3e6d6
--- /dev/null
+++ b/admin/share_content.pl
@@ -0,0 +1,89 @@
+#!/usr/bin/perl
+
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# Koha is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Koha; if not, see .
+
+use Modern::Perl;
+
+use CGI qw ( -utf8 );
+use JSON;
+use HTTP::Request;
+
+use C4::Auth;
+use C4::Output;
+
+use Koha::SharedContent;
+
+my $query = new CGI;
+my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+ {
+ template_name => "admin/share_content.tt",
+ query => $query,
+ type => "intranet",
+ authnotrequired => 0,
+ flagsrequired => { parameters => '*' },
+ debug => 1,
+ }
+);
+
+my $op = $query->param('op') || q||;
+
+if ( $op eq 'save' ) {
+ my $auto_share = $query->param('autosharewithmana');
+ my $mana = $query->param('mana');
+
+ C4::Context->set_preference('Mana', $mana);
+
+ if ( $auto_share ne '' ) {
+ C4::Context->set_preference('AutoShareWithMana', 'subscription');
+ } else {
+ C4::Context->set_preference('AutoShareWithMana', '');
+ }
+}
+
+if ( $op eq 'reset' ) {
+ C4::Context->set_preference('ManaToken', '');
+}
+
+if ( $op eq 'send' ) {
+ my $name = $query->param('lastname');
+ my $firstname = $query->param('firstname');
+ my $email = $query->param('email');
+
+ my $content = to_json({firstname => $firstname,
+ lastname => $name,
+ email => $email});
+
+ my $mana_ip = C4::Context->config('mana_config');
+ my $url = "$mana_ip/getsecuritytoken";
+ my $request = HTTP::Request->new( POST => $url );
+ $request->content($content);
+ my $result = Koha::SharedContent::process_request($request);
+
+ $template->param( result => $result );
+
+ if ( $result->{code} eq '201' && $result->{token} ) {
+ C4::Context->set_preference('ManaToken', $result->{token});
+ }
+}
+
+
+my $mana_url = C4::Context->config('mana_config') || '';
+
+$template->param(
+ mana_url => $mana_url,
+);
+
+output_html_with_http_headers $query, $cookie, $template->output;
diff --git a/installer/data/mysql/atomicupdate/mana_02-add_Mana_syspref.sql b/installer/data/mysql/atomicupdate/mana_02-add_Mana_syspref.sql
index dda85a5409..2a3c2738a8 100644
--- a/installer/data/mysql/atomicupdate/mana_02-add_Mana_syspref.sql
+++ b/installer/data/mysql/atomicupdate/mana_02-add_Mana_syspref.sql
@@ -1 +1,2 @@
-INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('Mana','2', 0|1|2,'request to Mana Webservice. Mana centralize commun information between other Koha to facilitate the creation of new subscriptions, vendors, report queries etc... You can search, share, import and comment the content of Mana.','Choice');
+INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
+('Mana','1',NULL,'request to Mana Webservice. Mana centralize common information between other Koha to facilitate the creation of new subscriptions, vendors, report queries etc... You can search, share, import and comment the content of Mana.','YesNo');
diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql
index f94efd63f9..bc012d370f 100644
--- a/installer/data/mysql/sysprefs.sql
+++ b/installer/data/mysql/sysprefs.sql
@@ -275,7 +275,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `
('LocalHoldsPriorityItemControl', 'holdingbranch', 'holdingbranch|homebranch', 'decides if the feature operates using the item''s home or holding library.', 'Choice'),
('LocalHoldsPriorityPatronControl', 'PickupLibrary', 'HomeLibrary|PickupLibrary', 'decides if the feature operates using the library set as the patron''s home library, or the library set as the pickup library for the given hold.', 'Choice'),
('makePreviousSerialAvailable','0','','make previous serial automatically available when collecting a new serial. Please note that the item-level_itypes syspref must be set to specific item.','YesNo'),
-('Mana','1',NULL,'request to Mana Webservice. Mana centralize commun information between other Koha to facilitate the creation of new subscriptions, vendors, report queries etc... You can search, share, import and comment the content of Mana.','YesNo'),
+('Mana','1',NULL,'request to Mana Webservice. Mana centralize common information between other Koha to facilitate the creation of new subscriptions, vendors, report queries etc... You can search, share, import and comment the content of Mana.','YesNo'),
('ManInvInNoissuesCharge','1',NULL,'MANUAL_INV charges block checkouts (added to noissuescharge).','YesNo'),
('MARCAuthorityControlField008','|| aca||aabn | a|a d',NULL,'Define the contents of MARC21 authority control field 008 position 06-39','Textarea'),
('MarcFieldDocURL', NULL, NULL, 'URL used for MARC field documentation. Following substitutions are available: {MARC} = marc flavour, eg. "MARC21" or "UNIMARC". {FIELD} = field number, eg. "000" or "048". {LANG} = user language, eg. "en" or "fi-FI"', 'free'),
diff --git a/koha-tmpl/intranet-tmpl/lib/jquery/activatemana.js b/koha-tmpl/intranet-tmpl/lib/jquery/activatemana.js
deleted file mode 100644
index 0e9b2e2eb2..0000000000
--- a/koha-tmpl/intranet-tmpl/lib/jquery/activatemana.js
+++ /dev/null
@@ -1,18 +0,0 @@
-$(document).ready(function(){
- $("#activatemana").on("click", function(){
- var mylastname = $("#lastname").val()
- var myfirstname = $("#firstname").val()
- var myemail = $("#email").val()
- $.ajax( {
- type: "POST",
- url: "/cgi-bin/koha/svc/mana/token",
- data: { lastname: mylastname, firstname: myfirstname, email: myemail},
- dataType: "json",
- })
- .done(function(result){
- $("#pref_ManaToken").val(result.token);
- $("#pref_ManaToken").trigger("input");
- });
- return false;
- });
-});
diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/mana/mana-report-search-result.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/mana/mana-report-search-result.inc
index b95600cb7b..fca1b12e3f 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/includes/mana/mana-report-search-result.inc
+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/mana/mana-report-search-result.inc
@@ -2,6 +2,7 @@
[% USE Koha %]
[% USE AuthorisedValues %]
[% USE Branches %]
+[% USE raw %]
+[% END %]
+[% INCLUDE 'intranet-bottom.inc' %]
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt
index 17d3ccba15..b8c4b0c24a 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt
@@ -137,7 +137,7 @@ canned reports and writing custom SQL reports.
[% IF report_converted %]
- The report "[% report_converted %]" has been converted.
+ The report "[% report_converted | html %]" has been converted.
[% END %]
@@ -179,7 +179,7 @@ canned reports and writing custom SQL reports.
[% IF manamsg %]
-
[% manamsg %]
+
[% manamsg | html %]
[% END %]
@@ -355,85 +355,78 @@ canned reports and writing custom SQL reports.
Please enter a report name and descriptive note before sharing (minimum 20 characters)
- [% IF ( languages_loop ) %]
- [% UNLESS ( one_language_enabled ) %]
-
-
Id:
-
-
Name:
-
-
SQL:
-
-
Group:
-
-
Type:
-
-
Notes:
-
-
-
-