Bug 17047: add a dedicated page for Mana setup
authorAlex Arnaud <alex.arnaud@biblibre.com>
Thu, 27 Sep 2018 13:15:50 +0000 (13:15 +0000)
committerNick Clemens <nick@bywatersolutions.com>
Wed, 23 Jan 2019 14:39:26 +0000 (14:39 +0000)
Signed-off-by: Michal Denar <black23@gmail.com>

Signed-off-by: Michal Denar <black23@gmail.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

24 files changed:
Koha/Subscription/Frequency.pm
admin/admin-home.pl
admin/share_content.pl [new file with mode: 0755]
installer/data/mysql/atomicupdate/mana_02-add_Mana_syspref.sql
installer/data/mysql/sysprefs.sql
koha-tmpl/intranet-tmpl/lib/jquery/activatemana.js [deleted file]
koha-tmpl/intranet-tmpl/prog/en/includes/mana/mana-report-search-result.inc
koha-tmpl/intranet-tmpl/prog/en/includes/mana/mana-subscription-search-result.inc
koha-tmpl/intranet-tmpl/prog/en/includes/reports-toolbar.inc
koha-tmpl/intranet-tmpl/prog/en/includes/serials-menu.inc
koha-tmpl/intranet-tmpl/prog/en/includes/serials-toolbar.inc
koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt
koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences.tt
koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/web_services.pref
koha-tmpl/intranet-tmpl/prog/en/modules/admin/share_content.tt [new file with mode: 0644]
koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt
koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-search.tt
koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt
koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt
koha-tmpl/intranet-tmpl/prog/js/subscription-add.js
reports/guided_reports.pl
serials/subscription-add.pl
svc/mana/token [deleted file]
t/db_dependent/Koha/Subscription.t

index d7d06dc..64dd327 100644 (file)
@@ -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
 
index ae16bf6..f6a7b23 100755 (executable)
@@ -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 (executable)
index 0000000..d900b3e
--- /dev/null
@@ -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 <http://www.gnu.org/licenses>.
+
+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;
index dda85a5..2a3c273 100644 (file)
@@ -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');
index f94efd6..bc012d3 100644 (file)
@@ -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 (file)
index 0e9b2e2..0000000
+++ /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;
-    });
-});
index b95600c..fca1b12 100644 (file)
@@ -2,6 +2,7 @@
 [% USE Koha %]
 [% USE AuthorisedValues %]
 [% USE Branches %]
+[% USE raw %]
 
 <script type="text/javascript">
 //<![CDATA[
@@ -45,30 +46,30 @@ $(document).ready(function() {
             [% FOREACH report IN reports %]
                 [% UNLESS report.cannotdisplay %]
                     [% IF report.nbofcomment > highWarned %]
-                  <tr id="row[% report.id %]" class = "high-warned-row">
+                  <tr id="row[% report.id | $raw %]" class = "high-warned-row">
                     [% ELSIF report.nbofcomment > warned %]
-                  <tr id="row[% report.id %]" class = "warned-row">
+                  <tr id="row[% report.id | $raw %]" class = "warned-row">
                     [% ELSIF report.nbofcomment > lowWarned %]
-                  <tr id="row[% report.id %]" class = "highlighted-row">
+                  <tr id="row[% report.id | $raw %]" class = "highlighted-row">
                     [% END %]
-                    <input hidden class="rowid" value="[% report.id %]">
-                    <td>[% IF ( report.report_name ) %][% report.report_name %][% END %]</td>
-                    <td title="[% report.savedsql |html %]"><div>
+                    <input hidden class="rowid" value="[% report.id | $raw %]">
+                    <td>[% IF ( report.report_name ) %][% report.report_name | html %][% END %]</td>
+                    <td title="[% report.savedsql | html %]"><div>
                         [% IF report.notes.length > 200 %]
-                            [% report.notes.substr(0,200) %]<a class="showbutton">Show More</a></div><div hidden>
+                            [% report.notes.substr(0,200) | html %]<a class="showbutton">Show More</a></div><div hidden>
                         [% END %]
-                            [% report.notes %]
+                            [% report.notes | html %]
                         [% IF report.notes.length > 200 %]
                                 <a class="hidebutton">Show Less</a></div> </td>
                         [% END %]
-                    <td> [% report.type %] </td>
-                    <td>[% IF ( report.nbofusers ) %][% report.nbofusers %][% END %]</td>
-                    <td><span title="[% report.lastimport %]">[% report.lastimport | $KohaDates %]</span></td>
-                    <td>[% FOREACH comment IN report.comments %][% comment.message %] ([% comment.nb %]) <br>[% END %]</td>
+                    <td> [% report.type | html %] </td>
+                    <td>[% IF ( report.nbofusers ) %][% report.nbofusers | $raw %][% END %]</td>
+                    <td><span title="[% report.lastimport | $KohaDates %]">[% report.lastimport | $KohaDates %]</span></td>
+                    <td>[% FOREACH comment IN report.comments %][% comment.message | html %] ([% comment.nb | $raw %]) <br>[% END %]</td>
 
                     [% UNLESS search_only %]
                         <td>
-                            <button class="mana-use" id="mana-use-[% report.id %]"><i class="fa fa-inbox"></i> Use</button>
+                            <button class="mana-use" id="mana-use-[% report.id | $raw %]"><i class="fa fa-inbox"></i> Use</button>
                         </td>
                     [% END %]
                   </tr>
@@ -77,5 +78,5 @@ $(document).ready(function() {
         </tbody>
     </table>
 [% ELSE %]
-    <h4> [% msg %]  statuscode: [% statuscode %]</h4>
+    <h4> [% msg | html %]  statuscode: [% statuscode | $raw %]</h4>
 [% END %]
index 34c3f42..4570191 100644 (file)
@@ -2,6 +2,7 @@
 [% USE Koha %]
 [% USE AuthorisedValues %]
 [% USE Branches %]
+[% USE raw %]
 [% INCLUDE 'mana.inc' %]
 <script type="text/javascript">
 //<![CDATA[
@@ -35,29 +36,29 @@ $(document).ready(function() {
             [% FOREACH subscription IN subscriptions %]
                 [% UNLESS subscription.cannotdisplay %]
                     [% IF subscription.nbofcomment > highWarned  %]
-                    <tr id="row[% subscription.subscriptionid %]" class = "high-warned-row" title="this resource has been reported more than [% highWarned %] times, take care!">
+                    <tr id="row[% subscription.subscriptionid | $raw %]" class = "high-warned-row" title="this resource has been reported more than [% highWarned | html %] times, take care!">
                     [% ELSIF subscription.nbofcomment > warned  %]
-                    <tr id="row[% subscription.subscriptionid %]" class = "warned-row" title="this resource has been reported more than [% warned %] times, take care!">
+                    <tr id="row[% subscription.subscriptionid | $raw %]" class = "warned-row" title="this resource has been reported more than [% warned | html %] times, take care!">
                     [% ELSIF subscription.nbofcomment > lowWarned  %]
-                    <tr id="row[% subscription.subscriptionid %]" class = "highlighted-row" title="this resource has been reported more than [% lowWarned %] times, take care!">
+                    <tr id="row[% subscription.subscriptionid | $raw %]" class = "highlighted-row" title="this resource has been reported more than [% lowWarned | html %] times, take care!">
                     [% END %]
-                    <input hidden class="rowid" value="[% subscription.id %]">
-                        <td>[% IF ( subscription.issn ) %][% subscription.issn %][% END %]</td>
-                        <td>[% subscription.title %]</a></td>
-                        <td>[% IF ( subscription.publishercode ) %][% subscription.publishercode %][% END %]</td>
-                        <td>[% IF ( subscription.sfdescription ) %][% subscription.sfdescription %][% END %]</td>
-                        <td>[% IF ( subscription.numberingmethod ) %][% subscription.numberingmethod %][% END %]</td>
-                        <td>[% IF ( subscription.nbofusers ) %][% subscription.nbofusers %][% END %]</td>
-                        <td><span title="[% subscription.lastimport %]">[% subscription.lastimport | $KohaDates %]</span></td>
-                        <td>[% FOREACH comment IN subscription.comments %][% comment.message %] ([% comment.nb %]) <br>[% END %]</td>
+                    <input hidden class="rowid" value="[% subscription.id | $raw %]">
+                        <td>[% IF ( subscription.issn ) %][% subscription.issn | html %][% END %]</td>
+                        <td>[% subscription.title | html %]</a></td>
+                        <td>[% IF ( subscription.publishercode ) %][% subscription.publishercode | html %][% END %]</td>
+                        <td>[% IF ( subscription.sfdescription ) %][% subscription.sfdescription | html %][% END %]</td>
+                        <td>[% IF ( subscription.numberingmethod ) %][% subscription.numberingmethod | html %][% END %]</td>
+                        <td>[% IF ( subscription.nbofusers ) %][% subscription.nbofusers | $raw %][% END %]</td>
+                        <td><span title="[% subscription.lastimport | $KohaDates %]">[% subscription.lastimport | $KohaDates %]</span></td>
+                        <td>[% FOREACH comment IN subscription.comments %][% comment.message | html %] ([% comment.nb | $raw %]) <br>[% END %]</td>
 
                         [% UNLESS search_only %]
                             <td>
-                                <button class="mana-use" id="mana-use-[% subscription.id %]"><i class="fa fa-inbox"></i> Use</button>
-                                <select class="mana-actions" id="mana-actions-[% subscription.id %]">
+                                <button class="mana-use" id="mana-use-[% subscription.id | $raw %]"><i class="fa fa-inbox"></i> Use</button>
+                                <select class="mana-actions" id="mana-actions-[% subscription.id | $raw %]">
                                     <option selected disabled>Report mistake</option>
                                     [% FOREACH comment IN subscription.comments %]
-                                        <option value="[% comment.id %]"> [% comment.message %] ([% comment.nb %])</option>
+                                        <option value="[% comment.id | $raw %]"> [% comment.message | html %] ([% comment.nb | $raw %])</option>
                                     [% END %]
                                         <option>other</option>
                                 </select>
@@ -70,7 +71,7 @@ $(document).ready(function() {
         </tbody>
     </table>
 [% ELSE %]
-    <h4>Mana search fails with the code: [% statuscode %] </h4>
+    <h4>Mana search fails with the code: [% statuscode | html %] </h4>
 [% END %]
 
 <div id="comment_box" class="modal" tabindex="-1" role="dialog" aria-labelledby="mana_search_result_label" style="display: none;">
index 9a2c4bb..cc1b083 100644 (file)
@@ -55,8 +55,8 @@
                 <button class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown"> Report mistake <span class="caret"></span></button>
                 <ul class="dropdown-menu">
                     [% FOREACH c IN mana_comments %]
-                        <li class="mana-comment" data-id="[% c.id %]">
-                            <a href="#">[% c.message %] ([% c.nb %])</a>
+                        <li class="mana-comment" data-id="[% c.id | $raw %]">
+                            <a href="#">[% c.message | html %] ([% c.nb | html %])</a>
                         </li>
                     [% END %]
                     <li role="separator" class="divider"></li>
@@ -73,7 +73,7 @@
                         </div>
                         <div class="modal-body">
                             <input hidden id="mana-resource" value="report">
-                            <input hidden id="mana-resource-id" value="[% mana_id %]">
+                            <input hidden id="mana-resource-id" value="[% mana_id | $raw %]">
                             <div>
                                 <input type="text" maxlength="35" size="35" id="mana-comment">
                             </div>
                     <h3 id="mana_search_result_label"> Mana Search</h3>
                 </div>
                 <div>
-                    <form id="search_form" style="margin-left: 5%">
-                        Please enter a few key words:
-                        <input type=text id=mana_search_field>
-                        <input type=button class="mana_search_button" value="Search">
-                    </form>
                     <div class="modal-body">
+                        <fieldset>
+                            <form id="mana_search_form" style="margin-left: 5%">
+                                Please enter a few key words:
+                                <input type="text" id="mana_search_field">
+                                <input type="submit" class="mana_search_button" value="Search">
+                            </form>
+                        </fieldset>
+                        <div class="mana_result_content">
+                        </div>
                     </div>
                 </div>
             </div>
     }
 
     function mana_search( textquery ){
+        $(document.body).css({'cursor' : 'wait'});
         $.ajax({
             type: "POST",
             url: "/cgi-bin/koha/svc/mana/search",
             dataType: "html",
         })
         .done( function( result ) {
-            $("#mana_search_result .modal-body").html(result);
+            $(document.body).css({'cursor' : 'default'});
+            $("#mana_search_result .modal-body .mana_result_content").html(result);
             $("#mana_search_result_label").text(_("Results from Mana Knowledge Base"));
             $("#mana_results_datatable").dataTable($.extend(true, {}, dataTablesDefaults,{
                 "sPaginationType":"four_button",
index 257c429..af85c11 100644 (file)
@@ -31,7 +31,7 @@
         </a>
     </li>
     <li><a href="/cgi-bin/koha/serials/add_fields.pl">Add subscription fields</a></li>
-    [% IF Koha.Preference('Mana') %]
+    [% IF Koha.Preference('Mana') == 1 %]
         <li><a href="/cgi-bin/koha/serials/serials-search.pl?mana=1">Search on Mana</a></li>
     [% END %]
 </ul>
index 4bba329..e8aabde 100644 (file)
@@ -7,7 +7,7 @@
             [% ELSE %]
                 <div class="btn-group"><a id="newsubscription" class="btn btn-default btn-sm" href="/cgi-bin/koha/serials/subscription-add.pl"><i class="fa fa-plus"></i> New subscription</a></div>
             [% END %]
-            [% IF Koha.Preference('Mana') and Koha.Preference('AutoShareWithMana').grep('subscription').size == 0 %]
+            [% IF Koha.Preference('Mana') == 1 and Koha.Preference('AutoShareWithMana').grep('subscription').size == 0 %]
                 [% IF one_language_enabled==0 or mana_id %]
                     <div class="btn-group"><a data-toggle="modal" data-toggle="tooltip" title="Share the subscription with other librairies. Your email address will be associated to your sharing." data-target="#mana_share_modal" class="btn btn-default btn-sm"><i class="fa fa-share-alt"></i> Share</a></div>
                 [% ELSE %]
@@ -66,8 +66,8 @@
                 <button class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown"> Report mistake <span class="caret"></span></button>
                 <ul class="dropdown-menu">
                     [% FOREACH c IN mana_comments %]
-                        <li class="mana-comment" data-id="[% c.id %]">
-                            <a href="#">[% c.message %] ([% c.nb %])</a>
+                        <li class="mana-comment" data-id="[% c.id | $raw %]">
+                            <a href="#">[% c.message | html %] ([% c.nb | html %])</a>
                         </li>
                     [% END %]
                     <li role="separator" class="divider"></li>
@@ -84,7 +84,7 @@
                         </div>
                         <div class="modal-body">
                             <input hidden id="mana-resource" value="subscription">
-                            <input hidden id="mana-resource-id" value="[% mana_id %]">
+                            <input hidden id="mana-resource-id" value="[% mana_id | $raw %]">
                             <div>
                                 <input type="text" maxlength="35" size="35" id="mana-comment">
                             </div>
     <div class="modal-dialog">
         <div class="modal-content">
             <div class="modal-header">
-                <h3 id="mana_share_modal_label">Share [% bibliotitle %] to Mana</h3>
+                <h3 id="mana_share_modal_label">Share [% bibliotitle | html %] to Mana</h3>
             </div>
             <div class="modal-body">
                 [% IF (mana_id) %]
                     <div class="alert">
-<h1>[% (mana_id) %]</h1>
+<h1>[% mana_id | $raw %]</h1>
                         <p>Your subscription is already linked with a Mana subscription model. Share it if you have made modifications, otherwise it will do nothing.</p>
                     </div>
                 [% END %]
                     [% UNLESS ( one_language_enabled ) %]
                         <div class="rows">
                                 <li><span class="label">Frequency: </span>
-                                        [% frequency.description %]
+                                        [% frequency.description | html %]
                                 </li>
                                 <li><span class="label">Number pattern: </span>
-                                    [% numberpattern.label %]
+                                    [% numberpattern.label | html %]
                                 </li>
                             </ol>
                         </div>
                                                     [% FOREACH sublanguages_loo IN languages_loo.sublanguages_loop %]
                                                         [% IF ( sublanguages_loo.enabled ) %]
                                                             [% IF ( sublanguages_loo.sublanguage_current ) %]
-                                                                <option value="[% languages_loo.rfc4646_subtag %]" selected>
-                                                                    [% sublanguages_loo.native_description %]
-                                                                    [% sublanguages_loo.script_description %]
-                                                                    [% sublanguages_loo.region_description %]
-                                                                    [% sublanguages_loo.variant_description %]
-                                                                    ([% sublanguages_loo.rfc4646_subtag %])
+                                                                <option value="[% languages_loo.rfc4646_subtag | html %]" selected>
+                                                                    [% sublanguages_loo.native_description | html %]
+                                                                    [% sublanguages_loo.script_description | html %]
+                                                                    [% sublanguages_loo.region_description | html %]
+                                                                    [% sublanguages_loo.variant_description | html %]
+                                                                    ([% sublanguages_loo.rfc4646_subtag | html %])
                                                                 </option>
                                                             [% ELSE %]
-                                                                <option value="[% languages_loo.rfc4646_subtag %]">
-                                                                    [% sublanguages_loo.native_description %]
-                                                                    [% sublanguages_loo.script_description %]
-                                                                    [% sublanguages_loo.region_description %]
-                                                                    [% sublanguages_loo.variant_description %]
-                                                                    ([% sublanguages_loo.rfc4646_subtag %])
+                                                                <option value="[% languages_loo.rfc4646_subtag | html %]">
+                                                                    [% sublanguages_loo.native_description | html %]
+                                                                    [% sublanguages_loo.script_description | html %]
+                                                                    [% sublanguages_loo.region_description | html %]
+                                                                    [% sublanguages_loo.variant_description | html %]
+                                                                    ([% sublanguages_loo.rfc4646_subtag | html %])
                                                                 </option>
                                                             [% END %]
                                                         [% END %]
                                                 [% ELSE %]
                                                     [% IF ( languages_loo.group_enabled ) %]
                                                         [% IF ( languages_loo.current ) %]
-                                                            <option value="[% languages_loo.rfc4646_subtag %]" selected>
+                                                            <option value="[% languages_loo.rfc4646_subtag | html %]" selected>
                                                                 [% IF ( languages_loo.native_description ) %]
-                                                                    [% languages_loo.native_description %]
+                                                                    [% languages_loo.native_description | html %]
                                                                 [% ELSE %]
-                                                                    [% languages_loo.rfc4646_subtag %]
+                                                                    [% languages_loo.rfc4646_subtag | html %]
                                                                 [% END %]
                                                             </option>
                                                         [% ELSE %]
-                                                            <option value="[% languages_loo.rfc4646_subtag %]">
+                                                            <option value="[% languages_loo.rfc4646_subtag | html %]">
                                                                 [% IF ( languages_loo.native_description ) %]
-                                                                    [% languages_loo.native_description %]
+                                                                    [% languages_loo.native_description | html %]
                                                                 [% ELSE %]
-                                                                    [% languages_loo.rfc4646_subtag %]
+                                                                    [% languages_loo.rfc4646_subtag | html %]
                                                                 [% END %]
                                                             </option>
                                                         [% END %]
                                         [% END %]
                                     </select>
                                     <input type="hidden" id="op" name="op" value="share"/>
-                                    <input type="hidden" id="subscriptionid" name="subscriptionid" value="[% subscriptionid %]"/>
+                                    <input type="hidden" id="subscriptionid" name="subscriptionid" value="[% subscriptionid | $raw %]"/>
                                 </fieldset>
                             </form>
                         </div>
index e1e7767..2cc41d5 100644 (file)
 <div class="main container-fluid">
     <div class="row">
         <div class="col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2">
-            [% IF ( Koha.Preference('Mana') == 2) %]
-                <fieldset>
-                    <p><center> You haven't decided if you want to activate Mana Knowlede Base, please let us know by clicking<center></p>
-                    <a href=/cgi-bin/koha/admin/preferences.pl?tab=&op=search&searchfield=request+to+mana+webservice><center>Here</center></a>
-                </fieldset>
+            [% IF ( Koha.Preference('Mana') == 1) && !mana_url %]
+                <div class="dialog message">
+                    <p><center>The Mana Knowledge Base feature is enabled but not configured.</center></p>
+                    <p>This feature allows you to retrieve and share data (subscription patterns and reports) with other Koha libaries.</p>
+                    <p>
+                        Ask your system administrator to configure this feature, or remove this note by disabling the 'Mana' system preference
+                        <a href=/cgi-bin/koha/admin/share_content.pl>here.</a>
+                    </p>
+                </div>
            [% END %]
         <h1>Koha administration</h1>
         <div class="row">
                         <dt><a href="/cgi-bin/koha/admin/usage_statistics.pl">Share your usage statistics</a></dt>
                         <dd>Share with the Koha community the usage statistics of your Koha installation.</dd>
                     [% END %]
+                    [% IF ( CAN_user_parameters ) %]
+                        <dt><a href="/cgi-bin/koha/admin/share_content.pl">Using Mana-KB</a></dt>
+                        <dd>Share content (subscriptions, reports) with Koha communty</dd>
+                    [% END %]
                 </dl>
             [% END %]
             </div>
index d9d705c..6cc0570 100644 (file)
     [% Asset.js("lib/jquery/plugins/humanmsg.js") | $raw %]
     [% Asset.js("js/ajax.js") | $raw %]
     [% Asset.js("js/pages/preferences.js") | $raw %]
-    [% Asset.js("lib/jquery/activatemana.js") | $raw %]
     [%# Add WYSIWYG editor for htmlarea system preferences %]
     [% INCLUDE 'wysiwyg-systempreferences.inc' %]
 [% END %]
index fe4a942..f9aa27b 100644 (file)
@@ -63,15 +63,13 @@ Web services:
         -
             - pref: Mana
               choices:
-                  0: Disable
-                  1: Enable
-                  2: No, let me think about it
+                yes: Enable
+                no: Disable
             - 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. The informations shared with Mana KB are shared under the CC-0 license. More infos about CC-0 license on https://creativecommons.org/choose/zero/
         -
              - "Security token used to authenticate on mana:"
              - pref: ManaToken
                class: Text
-             - <br> You need a security token to authenticate on Mana. If this sytem preference is empty, please fill in the following form, you will receive an email to confirm and activate your token. <br> <form> First name <input name="firstname" type="text" id="firstname"> <br> Last name <input name="lastname" type=text id=lastname> <br> Email address <input name="email" type=text id=email><br> <input type=submit id=activatemana value="Send"></form>
         -
             - 'Fields automatically shared with mana'
             - pref: AutoShareWithMana
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/share_content.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/share_content.tt
new file mode 100644 (file)
index 0000000..5c4ec62
--- /dev/null
@@ -0,0 +1,152 @@
+[% USE raw %]
+[% USE Asset %]
+[% SET footerjs = 1 %]
+[% USE Koha %]
+[% INCLUDE 'doc-head-open.inc' %]
+<title>Koha &rsaquo; Administration &rsaquo; Koha usage statistics</title>
+[% INCLUDE 'doc-head-close.inc' %]
+</head>
+
+<body id="admin_usage_statistics" class="admin">
+[% INCLUDE 'header.inc' %]
+[% INCLUDE 'cat-search.inc' %]
+
+<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> &rsaquo; Usage statistics</div>
+
+<div class="main container-fluid">
+    <div class="row">
+        <div class="col-sm-10 col-sm-push-2">
+            <div class="col-sm-6">
+                [% IF result.code != 201 && result.msg %]
+                    <div class="alert alert-danger" role="alert">
+                        [% result.msg | html %]
+                    </div>
+                [% END %]
+
+                [% IF result.code == 201  %]
+                    <div class="dialog message" role="alert">
+Well done! You successfully created your Mana KB account. Check your mailbox and follow instructions.
+                    </div>
+                [% END %]
+
+                [% UNLESS (mana_url) %]
+                    <div class="alert alert-danger" role="alert">
+                        Mana config is currently empty, this feature will not work. Please contact your site administartor.
+                    </div>
+                [% END %]
+
+                <h1>Share content with the Koha community using Mana KB</h1>
+                <p>Mana-kb is a global knowledge base for library-centric data. It has been designed initially to interact with Koha, the Open Source ILS, but can be used by any other software.</p>
+
+                <p>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. The informations shared with Mana KB are shared under the CC-0 license. More infos about CC-0 license <a href="https://creativecommons.org/choose/zero/">here</a>.</p>
+
+                <p>Learn more about Mana on the <a href="https://wiki.koha-community.org/wiki/Mana_central_database">official documentation</a>.</p>
+
+                [% IF (mana_url) %]
+                <p> Your Mana KB server is currently: <strong>[% mana_url | url %]</strong></p>
+                [% END %]
+
+                <form id="mana_preference" method="post">
+                    <fieldset class="rows">
+                        <ol>
+                            <li>
+                                <label for="mana">Use Mana KB for sharing content: </label>
+                                <select name="mana">
+                                    [% IF Koha.Preference('Mana') == 0 %]
+                                        <option value="0" selected="selected">No</option>
+                                    [% ELSE %]
+                                        <option value="0"">No</option>
+                                    [% END %]
+
+                                    [% IF Koha.Preference('Mana') == 1 %]
+                                        <option value="1" selected="selected">Yes</option>
+                                    [% ELSE %]
+                                        <option value="1">Yes</option>
+                                    [% END %]
+                                </select>
+                                <div class="hint">Enable Mana allow you to search, import and comment content from Mana server, and, to share your own.</div>
+                            </li>
+                            <li>
+                                <label for="autosharewithmana">Auto subscriptions sharing: </label>
+                                [% IF Koha.Preference('AutoShareWithMana').grep('subscription').size == 0 %]
+                                    <input type="checkbox" name="autosharewithmana">
+                                [% ELSE %]
+                                    <input type="checkbox" name="autosharewithmana" checked="checked">
+                                [% END %]
+                                <div class="hint">If checked, new subscriptions you created yourself will be automatically shared with Mana KB.</div>
+                            </li>
+                            <li>
+                                <input type="hidden" name="op" value="save">
+                                <input type="submit" value="Save">
+                            </li>
+                        </ol>
+                    </fieldset>
+                </form>
+
+                [% UNLESS Koha.Preference('ManaToken') %]
+                    <h3>Configure Mana KB</h3>
+                    <p>Once you have enabled Mana, let's start to set it up. Type your first name, last name, email address and click on send. This will send a account creation request to Mana KB that will respond back with a Mana token (a crypted id that uniquely identify your Koha). This token will automatically be saved in your database. Just after that, you will receive an email. Read it and follow the instructions.</p>
+                [% END %]
+
+                [% IF Koha.Preference('ManaToken') %]
+                    <form id="mana_token" method="post">
+                        <fieldset class="rows" id="mana_token">
+                        <legend>Mana KB token</legend>
+                            <ol>
+                                <li>
+                                    <label for="token">Mana token: </label>
+                                    <input type="text" name="token" value="[% Koha.Preference('ManaToken') | html %]" size="50" disabled="disabled">
+                                    <div class="hint">Your unique security token used for authentication on Mana KB service (anti spam).</div>
+                                </li>
+                                <li>
+                                    <input type="hidden" name="op" value="reset">
+                                    <input type="submit" value="Reset your token">
+                                </li>
+                            </ol>
+                        </fieldset>
+                    </form>
+                [% ELSE %]
+                    <form id="mana_request" method="post">
+                        <fieldset class="rows" id="mana_subscription">
+                            <ol>
+                                <li>
+                                    <label for="firstname">First name: </label>
+                                    <input type="text" name="firstname">
+                                </li>
+                                <li>
+                                    <label for="lastname">Last name: </label>
+                                    <input type="text" name="lastname">
+                                </li>
+                                <li>
+                                    <label for="email">Email: </label>
+                                    <input type="text" name="email" size="45" required="required">
+                                </li>
+                                <li>
+                                    <input type="hidden" name="op" value="send">
+                                    <input type="submit" value="Send to Mana KB">
+                                </li>
+                            </ol>
+                        </fieldset>
+                    </form>
+                [% END %]
+            </div>
+        </div> <!-- /.col-sm-10.col-sm-push-2 -->
+
+        <div class="col-sm-2 col-sm-pull-10">
+            <aside>
+                [% INCLUDE 'admin-menu.inc' %]
+            </aside>
+        </div> <!-- /.col-sm-2.col-sm-pull-10 -->
+     </div> <!-- /.row -->
+
+[% MACRO jsinclude BLOCK %]
+    [% Asset.js("js/admin-menu.js") | $raw %]
+    <script>
+        $(document).ready(function() {
+            $('#mana_token').submit(function() {
+                return confirm("This will delete the Mana token from Koha. Do you want to continue?");
+            });
+        });
+    </script>
+[% END %]
+[% INCLUDE 'intranet-bottom.inc' %]
index 17d3ccb..b8c4b0c 100644 (file)
@@ -137,7 +137,7 @@ canned reports and writing custom SQL reports.</p>
 
 [% IF report_converted %]
     <div class="dialog message">
-        The report "[% report_converted %]" has been converted.
+        The report "[% report_converted | html %]" has been converted.
     </div>
 [% END %]
 
@@ -179,7 +179,7 @@ canned reports and writing custom SQL reports.</p>
 <div style="display:inline-block">
     [% IF manamsg %]
      <div id="mana_search" class="dialog message">
-        <p> [% manamsg %] </p>
+        <p> [% manamsg | html %] </p>
     </div>
     [% END %]
 
@@ -355,85 +355,78 @@ canned reports and writing custom SQL reports.</p>
                 <div id="note-error" class="alert alert-danger" role="alert">
                     Please enter a report name and descriptive note before sharing (minimum 20 characters)
                 </div>
-                [% IF ( languages_loop ) %]
-                    [% UNLESS ( one_language_enabled ) %]
-                        <div class="shared_infos rows">
-                                <li> <span class="label">Id: </span><div id="shared_id"></div>
-                                </li>
-                                <li> <span class="label">Name: </span><div id="shared_name"></div>
-                                </li>
-                                <li> <span class="label">SQL: </span><div id="shared_sql"></div>
-                                </li>
-                                <li> <span class="label">Group: </span><div id="shared_group"></div>
-                                </li>
-                                <li> <span class="label">Type: </span><div id="shared_type"></div>
-                                </li>
-                                <li> <span class="label">Notes: </span><div id="shared_notes"></div>
-                                </li>
-
-                        </div>
-                        <div class="rows">
-                            <form method="post" id="mana_share_form" action="/cgi-bin/koha/reports/guided_reports.pl?phase=Share" class="validated" >
-                                <input type="hidden" name="phase" value="Share">
-
-                                <fieldset class="shared_infos">
-                                    <label for="mana_language">Language:</label>
-                                    <select id="mana_language" name="mana_language">
-                                        [% FOREACH languages_loo IN languages_loop %]
-                                            [% IF ( languages_loo.group_enabled ) %]
-                                                [% IF ( languages_loo.plural ) %]
-                                                    [% FOREACH sublanguages_loo IN languages_loo.sublanguages_loop %]
-                                                        [% IF ( sublanguages_loo.enabled ) %]
-                                                            [% IF ( sublanguages_loo.sublanguage_current ) %]
-                                                                <option value="[% languages_loo.rfc4646_subtag %]" selected>
-                                                                    [% sublanguages_loo.native_description %]
-                                                                    [% sublanguages_loo.script_description %]
-                                                                    [% sublanguages_loo.region_description %]
-
-                                                                    [% sublanguages_loo.variant_description %]
-                                                                    ([% sublanguages_loo.rfc4646_subtag %])
-                                                                </option>
-                                                            [% ELSE %]
-                                                                <option value="[% languages_loo.rfc4646_subtag %]">
-                                                                    [% sublanguages_loo.native_description %]
-                                                                    [% sublanguages_loo.script_description %]
-                                                                    [% sublanguages_loo.region_description %]
-                                                                    [% sublanguages_loo.variant_description %]
-                                                                    ([% sublanguages_loo.rfc4646_subtag %])
-                                                                </option>
-                                                            [% END %]
-                                                        [% END %]
-                                                    [% END %]
-                                                [% ELSE %]
-                                                    [% IF ( languages_loo.group_enabled ) %]
-                                                        [% IF ( languages_loo.current ) %]
-                                                            <option value="[% languages_loo.rfc4646_subtag %]" selected>
-                                                                [% IF ( languages_loo.native_description ) %]
-                                                                    [% languages_loo.native_description %]
-                                                                [% ELSE %]
-                                                                    [% languages_loo.rfc4646_subtag %]
-                                                                [% END %]
+                <div class="shared_infos rows">
+                    <li><span class="label">Id: </span><div id="shared_id"></div></li>
+                    <li><span class="label">Name: </span><div id="shared_name"></div></li>
+                    <li><span class="label">SQL: </span><div id="shared_sql"></div></li>
+                    <li><span class="label">Group: </span><div id="shared_group"></div></li>
+                    <li><span class="label">Type: </span><div id="shared_type"></div></li>
+                    <li><span class="label">Notes: </span><div id="shared_notes"></div></li>
+                </div>
+                <div class="rows">
+                    <form method="post" id="mana_share_form" action="/cgi-bin/koha/reports/guided_reports.pl" class="validated" >
+                        <input type="hidden" name="phase" value="Share">
+
+                        [% IF (languages_loop) %]
+                            <fieldset class="shared_infos">
+                                <label for="mana_language">Language:</label>
+                                <select id="mana_language" name="mana_language">
+                                    [% FOREACH languages_loo IN languages_loop %]
+                                        [% IF ( languages_loo.group_enabled ) %]
+                                            [% IF ( languages_loo.plural ) %]
+                                                [% FOREACH sublanguages_loo IN languages_loo.sublanguages_loop %]
+                                                    [% IF ( sublanguages_loo.enabled ) %]
+                                                        [% IF ( sublanguages_loo.sublanguage_current ) %]
+                                                            <option value="[% languages_loo.rfc4646_subtag | html %]" selected>
+                                                                [% sublanguages_loo.native_description | html %]
+                                                                [% sublanguages_loo.script_description | html %]
+                                                                [% sublanguages_loo.region_description | html %]
+
+                                                                [% sublanguages_loo.variant_description | html %]
+                                                                ([% sublanguages_loo.rfc4646_subtag | html %])
                                                             </option>
                                                         [% ELSE %]
-                                                            <option value="[% languages_loo.rfc4646_subtag %]">
-                                                                [% IF ( languages_loo.native_description ) %]
-                                                                    [% languages_loo.native_description %]
-                                                                [% ELSE %]
-                                                                    [% languages_loo.rfc4646_subtag %]
-                                                                [% END %]
+                                                            <option value="[% languages_loo.rfc4646_subtag | html %]">
+                                                                [% sublanguages_loo.native_description | html %]
+                                                                [% sublanguages_loo.script_description | html %]
+                                                                [% sublanguages_loo.region_description | html %]
+                                                                [% sublanguages_loo.variant_description | html %]
+                                                                ([% sublanguages_loo.rfc4646_subtag | html %])
                                                             </option>
                                                         [% END %]
                                                     [% END %]
                                                 [% END %]
+                                            [% ELSE %]
+                                                [% IF ( languages_loo.group_enabled ) %]
+                                                    [% IF ( languages_loo.current ) %]
+                                                        <option value="[% languages_loo.rfc4646_subtag | html %]" selected>
+                                                            [% IF ( languages_loo.native_description ) %]
+                                                                [% languages_loo.native_description | html %]
+                                                            [% ELSE %]
+                                                                [% languages_loo.rfc4646_subtag | html %]
+                                                            [% END %]
+                                                        </option>
+                                                    [% ELSE %]
+                                                        <option value="[% languages_loo.rfc4646_subtag | html %]">
+                                                            [% IF ( languages_loo.native_description ) %]
+                                                                [% languages_loo.native_description | html %]
+                                                            [% ELSE %]
+                                                                [% languages_loo.rfc4646_subtag | html %]
+                                                            [% END %]
+                                                        </option>
+                                                    [% END %]
+                                                [% END %]
                                             [% END %]
                                         [% END %]
-                                    </select>
-                                    <input type="hidden" id="reportid" name="reportid" value="[% savedreport.id %]"/>
-                                </fieldset>
-                            </form>
-                        </div>
-                    [% END %]
-                [% END %]
+                                    [% END %]
+                                </select>
+                            </fieldset>
+                        [% ELSE %]
+                            <input type="hidden" name="mana_language" value="[% lang | html %]">
+                        [% END %]
+                        <input type="hidden" id="reportid" name="reportid"/>
+                    </form>
+                </div>
             </div>
             <div class="modal-footer">
                 <button class="btn" id="ManaCloseButton" data-dismiss="modal" aria-hidden="true">Close</button>
@@ -1291,6 +1284,7 @@ canned reports and writing custom SQL reports.</p>
                     $("#note-error").show();
                 }
                 else{
+                    $("#reportid").val($(this).closest("tr").find(".report_id").text());
                     $("#shared_id").html($(this).closest("tr").find(".report_id").text());
                     $("#shared_name").html($(this).closest("tr").find(".report_name").text());
                     $("#shared_sql").html($(this).closest("tr").find(".report_sql").val());
@@ -1496,7 +1490,11 @@ canned reports and writing custom SQL reports.</p>
             });
 
             $('div#ManaShareButton').click(function() {
-                window.location="/cgi-bin/koha/reports/guided_reports.pl?phase=Share";
+                $("#mana_share_form").submit();
+            });
+
+            $("#mana_search_form").submit(function(e){
+                e.preventDefault();
             });
         });
 
index adc7428..bbca46c 100644 (file)
                 $(".ui-datepicker-trigger").hide();
                 $("label[for=location], select#location_filter").hide();
                 [% FOR field IN additional_fields_for_subscription %]
-                      $("label[for=additional_field_[% field.id %]], input#additional_field_[% field.id %]").hide();
+                      $("label[for=additional_field_[% field.id | $raw %]], input#additional_field_[% field.id | $raw %]").hide();
                 [% END %]
             [% END %]
         });
index a7bb471..e194a6c 100644 (file)
@@ -214,11 +214,10 @@ width: 300px;  /* not enough for IE7 apparently */
 
                 <div id="page_2">
                     <div class="col-md-6">
-                [% IF ( Koha.Preference('Mana') == 2) %]
+                [% IF ( Koha.Preference('Mana') == 1) && !mana_url %]
                     <fieldset>
-                        <p><center>You haven't activated the Mana Knowledge Base, click
-                        <a href=/cgi-bin/koha/admin/preferences.pl?tab=&op=search&searchfield=request+to+mana+webservice>here</a>
-                         to configure.</center></p>
+                        <p><center>The Mana Knowledge Base can be used to import subscription patterns submitted by other libraries and save you extra work. Ask your system administrator to configure this service and complete the configuration, or remove this message by disabling the system preference
+                        <a href=/cgi-bin/koha/admin/preferences.pl?tab=&op=search&searchfield=request+to+mana+webservice>here</a></center></p>
                     </fieldset>
                 [% END %]
 
@@ -529,7 +528,7 @@ width: 300px;  /* not enough for IE7 apparently */
         [% FOREACH field IN dont_export_field_loop %]
             tags.push("[% field.fieldid | html %]");
         [% END %]
-        var mana_enabled = [% Koha.Preference('Mana') %]
+        var mana_enabled = [% IF (Koha.Preference('Mana') && mana_url) %]1[% ELSE %]0[% END %];
         var MSG_LINK_TO_VENDOR = _("If you wish to claim late or missing issues you must link this subscription to a vendor. Click OK to ignore or Cancel to return and enter a vendor");
         var MSG_LINK_BIBLIO = _("You must choose or create a bibliographic record");
         var MSG_REQUIRED_SUB_LENGTH = _("You must choose a subscription length or an end date.");
index 141b63a..193b707 100644 (file)
@@ -62,7 +62,7 @@
     [% IF mana_code.defined %]
         <div id="alert-community" class="dialog message">
             <p>
-                [% mana_code %]
+                [% mana_code | html %]
             </p>
         </div>
     [% END %]
index da8abd1..776c9fd 100644 (file)
@@ -507,7 +507,9 @@ function mana_use(mana_id){
 }
 
 $(document).ready(function() {
-    mana_search();
+    if ( mana_enabled == 1 ) {
+        mana_search();
+    }
     $("#displayexample").hide();
     $("#mana_search_result").modal("hide");
     $("#aqbooksellerid").on('keypress', function(e) {
@@ -617,7 +619,7 @@ $(document).ready(function() {
     });
     $("#subscription_add_next").on("click",function(){
         if ( Check_page1() ){
-            if ( mana_enabled ) {
+            if ( mana_enabled == 1 ) {
                 mana_search();
             }
             show_page_2();
index 511d939..80edc2a 100755 (executable)
@@ -678,7 +678,9 @@ elsif ( $phase eq 'Save Report' ) {
 }
 
 elsif ($phase eq 'Share'){
-    my $result = Koha::SharedContent::send_entity($input->param('mana_language'), $borrowernumber, scalar $input->param('reportid'), 'report');
+    my $lang = $input->param('mana_language') || '';
+    my $reportid = $input->param('reportid');
+    my $result = Koha::SharedContent::send_entity($lang, $borrowernumber, $reportid, 'report');
     if ( $result ) {
         print $input->redirect("/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved&manamsg=".$result->{msg});
     }else{
index 2edb78d..31198c6 100755 (executable)
@@ -52,7 +52,7 @@ my $sub_length;
 my $permission =
   ( $op eq 'modify' || $op eq 'modsubscription' ) ? "edit_subscription" : "create_subscription";
 
-my ($template, $loggedinuser, $cookie)
+our ($template, $loggedinuser, $cookie)
 = get_template_and_user({template_name => "serials/subscription-add.tt",
                                query => $query,
                                type => "intranet",
@@ -68,6 +68,9 @@ my $sub_on;
 my $subs;
 our $firstissuedate;
 
+my $mana_url = C4::Context->config('mana_config');
+$template->param( 'mana_url' => $mana_url );
+
 if ($op eq 'modify' || $op eq 'dup' || $op eq 'modsubscription') {
 
     my $subscriptionid = $query->param('subscriptionid');
diff --git a/svc/mana/token b/svc/mana/token
deleted file mode 100755 (executable)
index 3ea6254..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-#!/usr/bin/perl
-
-# Copyright 2016 BibLibre Baptiste Wojtkowski
-#
-# 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::SharedContent;
-use C4::Auth qw(check_cookie_auth);
-
-use CGI;
-use JSON;
-
-my $input = new CGI;
-binmode STDOUT, ":encoding(UTF-8)";
-print $input->header( -type => 'text/plain', -charset => 'UTF-8' );
-
-my ( $auth_status, $sessionID ) =
-  check_cookie_auth( $input->cookie('CGISESSID'),
-    { serials => 'create_subscription' } );
-
-if ( $auth_status ne "ok" ) {
-    exit 0;
-}
-
-my $mana_ip = C4::Context->config('mana_config');
-
-my $url = "$mana_ip/getsecuritytoken";
-my $request = HTTP::Request->new( POST => $url );
-
-my $content;
-$content->{ firstname }= $input->param("firstname");
-$content->{ lastname }= $input->param("lastname");
-$content->{ email }= $input->param("email");
-my $json = to_json( $content, { utf8 => 1 } );
-$request->content($json);
-my $result = Koha::SharedContent::process_request($request);
-
-print(to_json($result));
index fadaae7..926bdc1 100644 (file)
@@ -32,6 +32,8 @@ use t::lib::TestBuilder;
 my $schema = Koha::Database->new->schema;
 $schema->storage->txn_begin;
 
+my $builder     = t::lib::TestBuilder->new;
+
 use_ok('Koha::Subscription');
 
 subtest 'Koha::Subscription->biblio' => sub {