Bugzilla – Attachment 73740 Details for
Bug 17047
Mana Knowledge Base : Data sharing
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17047 security token agst flooding for Mana-KB
Bug-17047-security-token-agst-flooding-for-Mana-KB.patch (text/plain), 32.33 KB, created by
Alex Arnaud
on 2018-04-06 08:26:36 UTC
(
hide
)
Description:
Bug 17047 security token agst flooding for Mana-KB
Filename:
MIME Type:
Creator:
Alex Arnaud
Created:
2018-04-06 08:26:36 UTC
Size:
32.33 KB
patch
obsolete
>From a47b05c6a5781fa61cdc4cd13d80e184757adac7 Mon Sep 17 00:00:00 2001 >From: Baptiste Wojtkowski <baptiste.wojtkowski@biblibre.com> >Date: Thu, 20 Apr 2017 12:09:37 +0000 >Subject: [PATCH] Bug 17047 security token agst flooding for Mana-KB > >Rework messages from Mana-KB. > >- Add A syspref contains an authentication token. The token will be used to prevent anaonymous flooding of Mana-KB >- To get an Authentication token, you have to fill a form and validate your e-mail address >- Messages return codes are now correctly displayed and there shouldn't be any crash when Mana-KB webservices return a wrong answer or doesn't answer > >Test plan: > 1 - Apply Patch + update database > 2 - Copy the three lines about mana config in etc/koha-conf.xml in ../etc/koha-conf.xml (after <backupdir> for example) > <!-- URL of the mana KB server --> > <!-- alternative value http://mana-test.koha-community.org to query the test server --> > <mana_config>https://mana-kb.koha-community.org</mana_config> > 3 - Check Mana syspref and AutoShareWithMana syspref are not activated > 4 - Search the syspref ManaToken and follow the instructions > 5 - subscriptions > - Try create a new subscription for a first serial => Mana-KB shouldn't show you anything (except if the base hase been filled) > - Share this serial with Mana-KB (on the serial individual's page there must be a Share button) > - Try to create a new subscription for serial nr1 => a message should appear when you click on "next", click on "use", the fields should automaticaly appear > - Activate AutoShareWithMana => Subscriptions > - Create a new subscription for a second serial > - There shouldn't be any Share button > - Create a second subscription => the message should appear, click again on use > > 6 - SQL Report > - Create a new SQL report, without notes. > - On the table with all report (reports > use saved), there should be the action "Share" > - If you click on share, you have an error message > - Create a new report, with a title and notes longer than 20 characters > - You can share it with mana => you will have a success message > - On (report > use saved), there must be a message inviting you to search on Mana-KB for more results, enter a few word from title, notes, type of the report you shared, it should appear. You can use it, it will load it into your report list. > > 7 - Report mistakes. > - On any table containing Mana-KB search results, you can report a mistake and add a comment. > > 8 - For each previous test, try to send wrong data, to delete the security token, to send nothing: it should show a correct warning message. > >Signed-off-by: Brendan A Gallagher <brendan@bywatersolutions.com> > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > Koha/SharedContent.pm | 42 +++++--- > .../mysql/atomicupdate/mana_04-add_mana_token.sql | 2 + > koha-tmpl/intranet-tmpl/lib/jquery/activatemana.js | 20 ++++ > .../en/includes/mana/mana-report-search-result.inc | 90 +++++++++-------- > .../mana/mana-subscription-search-result.inc | 112 +++++++++++---------- > .../prog/en/includes/serials-toolbar.inc | 1 + > .../en/modules/admin/preferences/web_services.pref | 5 + > .../en/modules/reports/guided_reports_start.tt | 8 +- > .../prog/en/modules/serials/subscription-add.tt | 2 +- > .../prog/en/modules/serials/subscription-detail.tt | 6 +- > .../intranet-tmpl/prog/js/subscription-add.js | 2 +- > reports/guided_reports.pl | 6 +- > serials/subscription-add.pl | 4 +- > serials/subscription-detail.pl | 2 +- > svc/mana/getToken | 55 ++++++++++ > svc/mana/search | 2 + > 16 files changed, 226 insertions(+), 133 deletions(-) > create mode 100644 installer/data/mysql/atomicupdate/mana_04-add_mana_token.sql > create mode 100644 koha-tmpl/intranet-tmpl/lib/jquery/activatemana.js > create mode 100755 svc/mana/getToken > >diff --git a/Koha/SharedContent.pm b/Koha/SharedContent.pm >index 7ac12f4..9bd4d09 100644 >--- a/Koha/SharedContent.pm >+++ b/Koha/SharedContent.pm >@@ -24,23 +24,33 @@ use LWP::UserAgent; > > use Koha::Serials; > use Koha::Reports; >+use C4::Context; > > our $MANA_IP = C4::Context->config('mana_config'); > > sub manaRequest { > my $mana_request = shift; > my $result; >- > $mana_request->content_type('application/json'); > my $userAgent = LWP::UserAgent->new; >+ if ( $mana_request->method eq "POST" ){ >+ my $content; >+ if ($mana_request->content) {$content = from_json( $mana_request->content )}; >+ $content->{securitytoken} = C4::Context->preference("ManaToken"); >+ $mana_request->content( to_json($content) ); >+ } >+ > my $response = $userAgent->request($mana_request); > >- if ( $response->code ne "204" ) { >- $result = from_json( $response->decoded_content ); >- } >+ eval { $result = from_json( $response->decoded_content ); }; > $result->{code} = $response->code; >- >- return $result if ( $response->code =~ /^2..$/ ); >+ if ( $@ ){ >+ $result->{msg} = $response->{_msg}; >+ } >+ if ($response->is_error){ >+ $result->{msg} = "An error occurred, mana server returned: ".$result->{msg}; >+ } >+ return $result ; > } > > sub manaIncrementRequest { >@@ -71,7 +81,6 @@ sub manaPostRequest { > $content->{bulk_import} = 0; > my $json = to_json( $content, { utf8 => 1 } ); > $request->content($json); >- > return manaRequest($request); > } > >@@ -88,13 +97,15 @@ sub manaShareInfos{ > my $mana_email; > if ( $loggedinuser ne 0 ) { > my $borrower = Koha::Patrons->find($loggedinuser); >- $mana_email = $borrower->email >- if ( ( not defined($mana_email) ) or ( $mana_email eq '' ) ); >- $mana_email = $borrower->emailpro >- if ( ( not defined($mana_email) ) or ( $mana_email eq '' ) ); >- $mana_email = >- Koha::Libraries->find( C4::Context->userenv->{'branch'} )->branchemail >- if ( ( not defined($mana_email) ) or ( $mana_email eq '' ) ); >+ if ($borrower){ >+ $mana_email = $borrower->email >+ if ( ( not defined($mana_email) ) or ( $mana_email eq '' ) ); >+ $mana_email = $borrower->emailpro >+ if ( ( not defined($mana_email) ) or ( $mana_email eq '' ) ); >+ $mana_email = >+ Koha::Libraries->find( C4::Context->userenv->{'branch'} )->branchemail >+ if ( ( not defined($mana_email) ) or ( $mana_email eq '' ) ); >+ } > } > $mana_email = C4::Context->preference('KohaAdminEmailAddress') > if ( ( not defined($mana_email) ) or ( $mana_email eq '' ) ); >@@ -114,8 +125,9 @@ sub manaShareInfos{ > > my $result = Koha::SharedContent::manaPostRequest( $ressourcetype, > $ressource_mana_info ); >+ > if ( $result and ($result->{code} eq "200" or $result->{code} eq "201") ) { >- $ressource->set( { mana_id => $result->{id} } )->store; >+ eval { $ressource->set( { mana_id => $result->{id} } )->store }; > } > return $result; > } >diff --git a/installer/data/mysql/atomicupdate/mana_04-add_mana_token.sql b/installer/data/mysql/atomicupdate/mana_04-add_mana_token.sql >new file mode 100644 >index 0000000..200f3e5 >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/mana_04-add_mana_token.sql >@@ -0,0 +1,2 @@ >+INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES >+('ManaToken','',NULL,'Security token used for authentication on Mana KB service (anti spam)','Textarea'); >diff --git a/koha-tmpl/intranet-tmpl/lib/jquery/activatemana.js b/koha-tmpl/intranet-tmpl/lib/jquery/activatemana.js >new file mode 100644 >index 0000000..b1cb9c9 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/lib/jquery/activatemana.js >@@ -0,0 +1,20 @@ >+$(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/getToken", >+ data: { lastname: mylastname, firstname: myfirstname, email: myemail}, >+ dataType: "json", >+ }) >+ .done(function(result){ >+ console.log(result.token); >+ $("#pref_ManaToken").val(result.token); >+ $("#pref_ManaToken").trigger("input"); >+ }).fail( function( result ){ >+ }); >+ 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 7f74257..455f453 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 >@@ -3,32 +3,31 @@ > [% USE AuthorisedValues %] > [% USE Branches %] > >-<table id="mana_results_datatable" width=100%> >- <thead> >- <tr> >- <th>Report Name</th> >- <th class="anti-the" width=35%>Notes</th> >- <th>Type</th> >- <th title="number of libraries using this pattern"># of users</th> >- <th class="title-string" title="last time a library used this pattern">Last import</th> >- <th> Comments </th> >- [% UNLESS search_only %] >- <th class="NoSort">Actions</th> >- [% END %] >- </tr> >- </thead> >- <tbody> >- [% FOREACH report IN reports %] >- [% UNLESS report.cannotdisplay %] >- <tr id="row[% report.id %]" >- [% IF report.nbofcomment > highWarned %] >- class = "high-warned-row" >- [% ELSIF report.nbofcomment > warned %] >- class = "warned-row" >- [% ELSIF report.nbofcomment > lowWarned %] >- class = "highlighted-row" >- [% END %] >- > >+[% IF statuscode == "200" AND reports %] >+ <table id="mana_results_datatable" width=100%> >+ <thead> >+ <tr> >+ <th>Report Name</th> >+ <th class="anti-the" width=35%>Notes</th> >+ <th>Type</th> >+ <th title="number of libraries using this pattern"># of users</th> >+ <th class="title-string" title="last time a library used this pattern">Last import</th> >+ <th> Comments </th> >+ [% UNLESS search_only %] >+ <th class="NoSort">Actions</th> >+ [% END %] >+ </tr> >+ </thead> >+ <tbody> >+ [% FOREACH report IN reports %] >+ [% UNLESS report.cannotdisplay %] >+ [% IF report.nbofcomment > highWarned %] >+ <tr id="row[% report.id %]" class = "high-warned-row"> >+ [% ELSIF report.nbofcomment > warned %] >+ <tr id="row[% report.id %]" class = "warned-row"> >+ [% ELSIF report.nbofcomment > lowWarned %] >+ <tr id="row[% report.id %]" 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 %]"><div> >@@ -37,32 +36,35 @@ > [% END %] > [% report.notes %] > [% IF report.notes.length > 200 %] >- <a class="hidebutton">Show Less</a></div> </td> >+ <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>[% FOREACH comment IN report.comments %][% comment.message %] ([% comment.nb %]) <br>[% END %]</td> > > [% UNLESS search_only %] >- <td> >- <button onclick="mana_use([% report.id %])"> <i class="fa fa-inbox"></i> Use</button> >- <input hidden type="text" id="selectedcomment"> >- <select> >- <option selected disabled>Report mistake</option> >- [% FOREACH comment IN report.comments %] >- <option class="actionreport1" value="[% comment.id %]" onclick="mana_increment('[% comment.id %]', 'resource_comment', 'nb')"> [% comment.message %] ([% comment.nb %]) >- [% END %] >- <option data-toggle="modal" onclick="($('#selected_id').val($('.rowid').val()))" data-target="#comment_box"> other >- </select> >- <button hidden class="actionreport2" hidden> Cancel</button> >- </td> >+ <td> >+ <button onclick="mana_use([% report.id %])"> <i class="fa fa-inbox"></i> Use</button> >+ <input hidden type="text" id="selectedcomment"> >+ <select> >+ <option selected disabled>Report mistake</option> >+ [% FOREACH comment IN report.comments %] >+ <option class="actionreport1" value="[% comment.id %]" onclick="mana_increment('[% comment.id %]', 'resource_comment', 'nb')"> [% comment.message %] ([% comment.nb %]) >+ [% END %] >+ <option data-toggle="modal" onclick="($('#selected_id').val($('.rowid').val()))" data-target="#comment_box"> other >+ </select> >+ <button hidden class="actionreport2" hidden> Cancel</button> >+ </td> > [% END %] >- </tr> >+ </tr> >+ [% END %] > [% END %] >- [% END %] >- </tbody> >-</table> >+ </tbody> >+ </table> >+[% ELSE %] >+ <h4> [% msg %] statuscode: [% statuscode %]</h4> >+[% END %] > > <div id="comment_box" class="modal" tabindex="-1" role="dialog" aria-labelledby="mana_search_result_label" style="display: none;"> > <div class="modal-dialog modal-lg" style="width: 30%"> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/mana/mana-subscription-search-result.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/mana/mana-subscription-search-result.inc >index 447ab50..35f666f 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/mana/mana-subscription-search-result.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/mana/mana-subscription-search-result.inc >@@ -5,63 +5,65 @@ > > > >-<table id="mana_results_datatable" width=100%> >- <thead> >- <tr> >- <th>ISSN</th> >- <th class="anti-the" width=50%>Title</th> >- <th> Published by </th> >- <th>Frequency</th> >- <th>Numbering pattern</th> >- <th title="number of libraries using this pattern"># of users</th> >- <th class="title-string" title="last time a library used this pattern">Last import</th> >- <th> Comments </th> >- [% UNLESS search_only %] >- <th class="NoSort">Actions</th> >- [% END %] >- </tr> >- </thead> >- <tbody> >- [% FOREACH subscription IN subscriptions %] >- [% UNLESS subscription.cannotdisplay %] >- <tr id="row[% subscription.subscriptionid %]" >- [% IF subscription.nbofcomment > highWarned %] >- class = "high-warned-row" title="this resource has been reported more than [% highWarned %] times, take care!" >- [% ELSIF subscription.nbofcomment > warned %] >- class = "warned-row" title="this resource has been reported more than [% warned %] times, take care!" >- [% ELSIF subscription.nbofcomment > lowWarned %] >- class = "highlighted-row" title="this resource has been reported more than [% lowWarned %] 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> >- >- [% UNLESS search_only %] >- <td> >- <button onclick="mana_use([% subscription.id %])"> <i class="fa fa-inbox"></i> Use</button> >- <input hidden type="text" id="selectedcomment"> >- <select> >- <option selected disabled>Report mistake</option> >- [% FOREACH comment IN subscription.comments %] >- <option class="actionreport1" value="[% comment.id %]" onclick="mana_increment('[% comment.id %]', 'resource_comment', 'nb')"> [% comment.message %] ([% comment.nb %]) >- [% END %] >- <option data-toggle="modal" onclick="($('#selected_id').val($('.rowid').val()))" data-target="#comment_box"> other >- </select> >- <button hidden class="actionreport2" hidden> Cancel</button> >- </td> >+[% IF statuscode == "200" %] >+ <table id="mana_results_datatable" width=100%> >+ <thead> >+ <tr> >+ <th>ISSN</th> >+ <th class="anti-the" width=50%>Title</th> >+ <th> Published by </th> >+ <th>Frequency</th> >+ <th>Numbering pattern</th> >+ <th title="number of libraries using this pattern"># of users</th> >+ <th class="title-string" title="last time a library used this pattern">Last import</th> >+ <th> Comments </th> >+ [% UNLESS search_only %] >+ <th class="NoSort">Actions</th> >+ [% END %] >+ </tr> >+ </thead> >+ <tbody> >+ [% 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!"> >+ [% ELSIF subscription.nbofcomment > warned %] >+ <tr id="row[% subscription.subscriptionid %]" class = "warned-row" title="this resource has been reported more than [% warned %] 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!"> > [% END %] >- </tr> >+ <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> >+ >+ [% UNLESS search_only %] >+ <td> >+ <button onclick="mana_use([% subscription.id %])"> <i class="fa fa-inbox"></i> Use</button> >+ <input hidden type="text" id="selectedcomment"> >+ <select> >+ <option selected disabled>Report mistake</option> >+ [% FOREACH comment IN subscription.comments %] >+ <option class="actionreport1" value="[% comment.id %]" onclick="mana_increment('[% comment.id %]', 'resource_comment', 'nb')"> [% comment.message %] ([% comment.nb %]) >+ [% END %] >+ <option data-toggle="modal" onclick="($('#selected_id').val($('.rowid').val()))" data-target="#comment_box"> other >+ </select> >+ <button hidden class="actionreport2" hidden> Cancel</button> >+ </td> >+ [% END %] >+ </tr> >+ [% END %] > [% END %] >- [% END %] >- </tbody> >-</table> >+ </tbody> >+ </table> >+[% ELSE %] >+ <h4> [% msg %] statuscode: [% statuscode %] </h4> >+[% END %] > > <div id="comment_box" class="modal" tabindex="-1" role="dialog" aria-labelledby="mana_search_result_label" style="display: none;"> > <div class="modal-dialog modal-lg" style="width: 30%"> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/serials-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/serials-toolbar.inc >index 86ff761..fcfaceb 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/serials-toolbar.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/serials-toolbar.inc >@@ -80,6 +80,7 @@ > <div class="modal-body"> > [% IF (mana_id) %] > <div class="alert"> >+<h1>[% (mana_id) %]</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 %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/web_services.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/web_services.pref >index 96040c0..4160853 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/web_services.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/web_services.pref >@@ -62,6 +62,11 @@ Web services: > 2: No, let me think about it > - 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. <script src=/intranet-tmpl/lib/jquery/activatemana.js></script> <br> <form> Firstname <input name="firstname" type="text" id="firstname"> <br> Lastname <input name="lastname" type=text id=lastname> <br> email <input name="email" type=text id=email><br> <input type=submit id=activatemana value="Send"></form> >+ - > - 'Fields automatically shared with mana' > - pref: AutoShareWithMana > multiple: >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 87d9aff..bcc13d7 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 >@@ -179,13 +179,9 @@ canned reports and writing custom SQL reports.</p> > </select> > </div> > <div style="display:inline-block"> >- [% IF (manamsg == 'success') %] >+ [% IF manamsg %] > <div id="mana_search" class="dialog message"> >- <p> Shared successfully! Thanks for your help.</p> >- </div> >- [% ELSIF (manamsg == 'fail') %] >- <div id="mana_search" class="dialog message"> >- <p> An error occured while sharing, please try again later.</p> >+ <p> [% manamsg %] </p> > </div> > [% END %] > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt >index b718ead..f7d499b 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt >@@ -213,7 +213,7 @@ width: 300px; /* not enough for IE7 apparently */ > </fieldset> > [% END %] > >- <div id="mana_search" class="dialog message"> >+ <div hidden id="mana_search" class="dialog message"> > <p>Subscription found on Mana Knowledge Base:</p><p> <a style="cursor:pointer" data-toggle="modal" data-target="#mana_search_result">Quick fill</a></p> > </div> > <div id="subscription_form_planning"> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt >index 206ad9b..4fd5b90 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt >@@ -51,11 +51,7 @@ > [% IF mana_code.defined %] > <div id="alert-community" class="dialog message"> > <p> >- [% IF (mana_code == 201) %] >- The export is done, thank you for your contribution. >- [% ELSIF (mana_code == 200) %] >- The model already exists on Mana, thank you for your contribution. >- [% END %] >+ [% mana_code %] > </p> > </div> > [% END %] >diff --git a/koha-tmpl/intranet-tmpl/prog/js/subscription-add.js b/koha-tmpl/intranet-tmpl/prog/js/subscription-add.js >index f1ca56e..4a091f2 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/subscription-add.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/subscription-add.js >@@ -415,7 +415,7 @@ function mana_search() { > { 'sType': "anti-the", 'aTargets' : [ 'anti-the'] } > ] > })); >- if($("td.dataTables_empty").length == 0){ >+ if( $("#mana_results_datatable").length && $("td.dataTables_empty").length == 0){ > $("#mana_search").show(); > } > $( "select[class='actionreport1']" ).show(); >diff --git a/reports/guided_reports.pl b/reports/guided_reports.pl >index 3850fb4..4754c36 100755 >--- a/reports/guided_reports.pl >+++ b/reports/guided_reports.pl >@@ -672,10 +672,10 @@ elsif ( $phase eq 'Save Report' ) { > > elsif ($phase eq 'Share'){ > my $result = Koha::SharedContent::manaShareInfos($input, $borrowernumber, $input->param('reportid'), 'report'); >- if ( $result and ($result->{code} eq "200" or $result->{code} eq "201") ) { >- print $input->redirect("/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved&manamsg=success"); >+ if ( $result ) { >+ print $input->redirect("/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved&manamsg=".$result->{msg}); > }else{ >- print $input->redirect("/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved&manamsg=fail"); >+ print $input->redirect("/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved&manamsg=noanswer"); > } > } > elsif ($phase eq 'Run this report'){ >diff --git a/serials/subscription-add.pl b/serials/subscription-add.pl >index 1db4eab..e0ee70e 100755 >--- a/serials/subscription-add.pl >+++ b/serials/subscription-add.pl >@@ -403,9 +403,9 @@ sub redirect_add_subscription { > $staffdisplaycount, $opacdisplaycount, $graceperiod, $location, $enddate, > $skip_serialseq, $itemtype, $previousitemtype, $mana_id > ); >- if ( grep { $_ eq "subscription" } split(/,/, C4::Context->preference('AutoShareWithMana')) ){ >+ if ( (C4::Context->preference('Mana')) and ( grep { $_ eq "subscription" } split(/,/, C4::Context->preference('AutoShareWithMana'))) ){ > my $result = Koha::SharedContent::manaShareInfos( $query, $loggedinuser, $subscriptionid, 'subscription'); >- $template->param( mana_code => $result->{code} ); >+ $template->param( mana_msg => $result->{msg} ); > } > my $additional_fields = Koha::AdditionalField->all( { tablename => 'subscription' } ); > insert_additional_fields( $additional_fields, $biblionumber, $subscriptionid ); >diff --git a/serials/subscription-detail.pl b/serials/subscription-detail.pl >index 5a363ad..6c25f7e 100755 >--- a/serials/subscription-detail.pl >+++ b/serials/subscription-detail.pl >@@ -101,7 +101,7 @@ if ($op eq 'del') { > } > elsif ( $op and $op eq "share" ) { > my $result = Koha::SharedContent::manaShareInfos($query, $loggedinuser, $subscriptionid, 'subscription'); >- $template->param( mana_code => $result->{code} ); >+ $template->param( mana_code => $result->{msg} ); > $subs->{mana_id} = $result->{id}; > } > >diff --git a/svc/mana/getToken b/svc/mana/getToken >new file mode 100755 >index 0000000..e9e89ad >--- /dev/null >+++ b/svc/mana/getToken >@@ -0,0 +1,55 @@ >+#!/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::manaRequest($request); >+ >+print(to_json($result)); >diff --git a/svc/mana/search b/svc/mana/search >index 57123e3..5ae14b3 100755 >--- a/svc/mana/search >+++ b/svc/mana/search >@@ -73,5 +73,7 @@ foreach my $resource (@{ $result->{data} }){ > } > > $template->param( $input->param('resource')."s" => $result->{data} ); >+$template->param( statuscode => $result->{code} ); >+$template->param( msg => $result->{msg} ); > > output_with_http_headers $input, $cookie, $template->output, 'json'; >-- >2.7.4
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 17047
:
56175
|
56176
|
56177
|
56178
|
56179
|
56180
|
56181
|
59728
|
59729
|
59931
|
61905
|
62045
|
62046
|
62047
|
62048
|
62049
|
62050
|
62051
|
62052
|
62053
|
62054
|
62075
|
62465
|
62475
|
62485
|
62540
|
62542
|
62543
|
62544
|
62545
|
62546
|
62547
|
62548
|
62549
|
62550
|
62551
|
62552
|
62553
|
62589
|
62591
|
62592
|
62593
|
62594
|
62595
|
62596
|
62597
|
62598
|
62599
|
62603
|
62604
|
62605
|
62606
|
62607
|
62768
|
63476
|
63601
|
63618
|
63619
|
63620
|
63621
|
63622
|
63623
|
64484
|
64530
|
64618
|
64619
|
64620
|
64621
|
64622
|
64623
|
64624
|
64625
|
64626
|
64627
|
64628
|
64629
|
64630
|
64631
|
64632
|
64633
|
64634
|
64635
|
64636
|
64637
|
64638
|
64639
|
64640
|
64641
|
64642
|
64643
|
64648
|
64649
|
64650
|
64651
|
64652
|
64653
|
64654
|
64706
|
64962
|
65058
|
65059
|
65060
|
65061
|
65062
|
65063
|
65064
|
65065
|
65773
|
66667
|
66668
|
66987
|
67003
|
67004
|
67005
|
67006
|
67009
|
67010
|
67011
|
67012
|
67013
|
67014
|
67015
|
67016
|
67017
|
67018
|
67019
|
67020
|
67021
|
67022
|
67023
|
69034
|
69035
|
69036
|
69037
|
69038
|
69039
|
69040
|
69041
|
69091
|
70203
|
70204
|
70205
|
70206
|
70208
|
70209
|
70210
|
70211
|
70561
|
70874
|
72660
|
72661
|
72662
|
72663
|
72664
|
72665
|
72666
|
72667
|
72668
|
72669
|
72670
|
73699
|
73737
|
73738
|
73739
|
73740
|
73741
|
73742
|
73743
|
73744
|
73745
|
73746
|
73747
|
73748
|
73975
|
73976
|
73977
|
73978
|
73979
|
73980
|
73981
|
73982
|
73983
|
73984
|
73985
|
73986
|
76673
|
76674
|
76675
|
76676
|
76677
|
76678
|
76679
|
76680
|
76681
|
76682
|
76683
|
76684
|
78215
|
78216
|
78217
|
78218
|
78219
|
78220
|
78221
|
78222
|
78223
|
78224
|
78225
|
78226
|
78227
|
78228
|
78229
|
79868
|
79869
|
79870
|
79871
|
79872
|
79874
|
79877
|
79878
|
79879
|
79880
|
79881
|
79882
|
79883
|
79884
|
79885
|
79886
|
79887
|
79888
|
79922
|
79923
|
79924
|
79925
|
79926
|
79927
|
79928
|
79929
|
79930
|
79931
|
79932
|
79933
|
79934
|
79935
|
79936
|
79937
|
79938
|
79939
|
80183
|
80184
|
80185
|
80186
|
80187
|
80188
|
80189
|
80190
|
80191
|
80192
|
80193
|
80194
|
80195
|
80196
|
80197
|
80198
|
80199
|
80200
|
80471
|
80472
|
80473
|
80907
|
80908
|
80909
|
80910
|
80911
|
80912
|
80913
|
80914
|
80915
|
80916
|
80917
|
80918
|
80919
|
80920
|
80921
|
80922
|
80923
|
80924
|
81935
|
81936
|
81937
|
81938
|
81939
|
81940
|
81941
|
81942
|
81943
|
81944
|
81945
|
81946
|
81947
|
81948
|
81949
|
81950
|
81951
|
81952
|
81968
|
83863
|
83864
|
83865
|
83866
|
83867
|
83868
|
83869
|
83870
|
83871
|
83872
|
83873
|
83874
|
83875
|
83876
|
83877
|
83878
|
83879
|
83880
|
83881
|
83892
|
83893
|
83894
|
83895
|
83896
|
83897
|
83898
|
83899
|
83900
|
83901
|
83902
|
83903
|
83904
|
83905
|
83906
|
83907
|
83908
|
83909
|
83910
|
83911
|
83912
|
84142
|
84145
|
84210
|
84260
|
84261
|
84262
|
84263
|
84264
|
84265
|
84323
|
84324
|
84325
|
84326
|
84327
|
84328
|
84329
|
84332