Bugzilla – Attachment 80197 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: add a dedicated page for Mana setup
Bug-17047-add-a-dedicated-page-for-Mana-setup.patch (text/plain), 18.25 KB, created by
Michal Denar
on 2018-10-08 07:22:59 UTC
(
hide
)
Description:
Bug 17047: add a dedicated page for Mana setup
Filename:
MIME Type:
Creator:
Michal Denar
Created:
2018-10-08 07:22:59 UTC
Size:
18.25 KB
patch
obsolete
>From bb3e97c0849e5dfbf96ff506d8b374d2e5d03154 Mon Sep 17 00:00:00 2001 >From: Alex Arnaud <alex.arnaud@biblibre.com> >Date: Thu, 27 Sep 2018 13:15:50 +0000 >Subject: [PATCH] Bug 17047: add a dedicated page for Mana setup > >Signed-off-by: Michal Denar <black23@gmail.com> > >Signed-off-by: Michal Denar <black23@gmail.com> >--- > admin/share_content.pl | 89 ++++++++++++ > koha-tmpl/intranet-tmpl/lib/jquery/activatemana.js | 18 --- > .../prog/en/modules/admin/admin-home.tt | 8 +- > .../prog/en/modules/admin/preferences.tt | 1 - > .../en/modules/admin/preferences/web_services.pref | 1 - > .../prog/en/modules/admin/share_content.tt | 158 +++++++++++++++++++++ > svc/mana/token | 55 ------- > 7 files changed, 252 insertions(+), 78 deletions(-) > create mode 100755 admin/share_content.pl > delete mode 100644 koha-tmpl/intranet-tmpl/lib/jquery/activatemana.js > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/admin/share_content.tt > delete mode 100755 svc/mana/token > >diff --git a/admin/share_content.pl b/admin/share_content.pl >new file mode 100755 >index 0000000..d900b3e >--- /dev/null >+++ b/admin/share_content.pl >@@ -0,0 +1,89 @@ >+#!/usr/bin/perl >+ >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <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; >diff --git a/koha-tmpl/intranet-tmpl/lib/jquery/activatemana.js b/koha-tmpl/intranet-tmpl/lib/jquery/activatemana.js >deleted file mode 100644 >index 0e9b2e2..0000000 >--- a/koha-tmpl/intranet-tmpl/lib/jquery/activatemana.js >+++ /dev/null >@@ -1,18 +0,0 @@ >-$(document).ready(function(){ >- $("#activatemana").on("click", function(){ >- var mylastname = $("#lastname").val() >- var myfirstname = $("#firstname").val() >- var myemail = $("#email").val() >- $.ajax( { >- type: "POST", >- url: "/cgi-bin/koha/svc/mana/token", >- data: { lastname: mylastname, firstname: myfirstname, email: myemail}, >- dataType: "json", >- }) >- .done(function(result){ >- $("#pref_ManaToken").val(result.token); >- $("#pref_ManaToken").trigger("input"); >- }); >- return false; >- }); >-}); >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt >index 06c5a77..3350c5b 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt >@@ -14,10 +14,10 @@ > <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> >+ <div class="dialog alert"> > <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> >+ <a href=/cgi-bin/koha/admin/share_content.pl><center>Here</center></a> >+ </div> > [% END %] > <h1>Koha administration</h1> > <div class="row"> >@@ -141,6 +141,8 @@ > [% END %] > <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> >+ <dt><a href="/cgi-bin/koha/admin/share_content.pl">Using Mana-KB</a></dt> >+ <dd>Share content (subscriptions, reports) with Koha communty</dd> > </dl> > </div> > </div> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences.tt >index d9d705c..6cc0570 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences.tt >@@ -197,7 +197,6 @@ > [% 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 %] >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 fe4a942..7b13f80 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 >@@ -71,7 +71,6 @@ Web services: > - "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 >index 0000000..9fce6f6 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/share_content.tt >@@ -0,0 +1,158 @@ >+[% USE raw %] >+[% USE Asset %] >+[% SET footerjs = 1 %] >+[% USE Koha %] >+[% INCLUDE 'doc-head-open.inc' %] >+<title>Koha › Administration › 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> › <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> › 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 %] >+ >+ [% IF Koha.Preference('Mana') == 2 %] >+ <option value="2" selected="selected">No, let me think about it</option> >+ [% ELSE %] >+ <option value="2">No, let me think about it</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' %] >diff --git a/svc/mana/token b/svc/mana/token >deleted file mode 100755 >index 3ea6254..0000000 >--- a/svc/mana/token >+++ /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)); >-- >2.1.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