View | Details | Raw Unified | Return to bug 17047
Collapse All | Expand All

(-)a/Koha/SharedContent.pm (-8 / +18 lines)
Lines 24-46 use LWP::UserAgent; Link Here
24
24
25
use Koha::Serials;
25
use Koha::Serials;
26
use Koha::Reports;
26
use Koha::Reports;
27
use C4::Context;
27
28
28
our $MANA_IP = C4::Context->config('mana_config');
29
our $MANA_IP = C4::Context->config('mana_config');
29
30
30
sub manaRequest {
31
sub manaRequest {
31
    my $mana_request = shift;
32
    my $mana_request = shift;
32
    my $result;
33
    my $result;
33
34
    $mana_request->content_type('application/json');
34
    $mana_request->content_type('application/json');
35
    my $userAgent = LWP::UserAgent->new;
35
    my $userAgent = LWP::UserAgent->new;
36
    if ( $mana_request->method eq "POST" ){
37
        my $content;
38
        if ($mana_request->content) {$content = from_json( $mana_request->content )};
39
        $content->{securitytoken} = C4::Context->preference("ManaToken");
40
        $mana_request->content( to_json($content) );
41
    }
42
36
    my $response  = $userAgent->request($mana_request);
43
    my $response  = $userAgent->request($mana_request);
37
44
38
    if ( $response->code ne "204" ) {
45
    eval { $result = from_json( $response->decoded_content ); };
39
        $result = from_json( $response->decoded_content );
40
    }
41
    $result->{code} = $response->code;
46
    $result->{code} = $response->code;
42
47
    if ( $@ ){
43
    return $result if ( $response->code =~ /^2..$/ );
48
        $result->{msg} = $response->{_msg};
49
    }
50
    if ($response->is_error){
51
        $result->{msg} = "An error occurred, mana server returned: ".$result->{msg};
52
    }
53
    return $result ;
44
}
54
}
45
55
46
sub manaIncrementRequest {
56
sub manaIncrementRequest {
Lines 71-77 sub manaPostRequest { Link Here
71
    $content->{bulk_import} = 0;
81
    $content->{bulk_import} = 0;
72
    my $json = to_json( $content, { utf8 => 1 } );
82
    my $json = to_json( $content, { utf8 => 1 } );
73
    $request->content($json);
83
    $request->content($json);
74
75
    return manaRequest($request);
84
    return manaRequest($request);
76
}
85
}
77
86
Lines 114-121 sub manaShareInfos{ Link Here
114
123
115
    my $result = Koha::SharedContent::manaPostRequest( $ressourcetype,
124
    my $result = Koha::SharedContent::manaPostRequest( $ressourcetype,
116
        $ressource_mana_info );
125
        $ressource_mana_info );
126
117
    if ( $result and ($result->{code} eq "200" or $result->{code} eq "201") ) {
127
    if ( $result and ($result->{code} eq "200" or $result->{code} eq "201") ) {
118
        $ressource->set( { mana_id => $result->{id} } )->store;
128
       eval { $ressource->set( { mana_id => $result->{id} } )->store };
119
    }
129
    }
120
    return $result;
130
    return $result;
121
}
131
}
(-)a/installer/data/mysql/atomicupdate/mana_04-add_mana_token.sql (+2 lines)
Line 0 Link Here
1
INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
2
('ManaToken','',NULL,'Security token used for authentication on Mana KB service (anti spam)','Textarea');
(-)a/koha-tmpl/intranet-tmpl/lib/jquery/activatemana.js (+20 lines)
Line 0 Link Here
1
$(document).ready(function(){
2
    $("#activatemana").on("click", function(){
3
        var mylastname = $("#lastname").val()
4
        var myfirstname = $("#firstname").val()
5
        var myemail = $("#email").val()
6
        $.ajax( {
7
            type: "POST",
8
            url: "/cgi-bin/koha/svc/mana/getToken",
9
            data: { lastname: mylastname, firstname: myfirstname, email: myemail},
10
            dataType: "json",
11
        })
12
        .done(function(result){
13
            console.log(result.token);
14
                $("#pref_ManaToken").val(result.token);
15
                $("#pref_ManaToken").trigger("input");
16
        }).fail( function( result ){
17
        });
18
        return false;
19
    });
20
});
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/mana/mana-report-search-result.inc (-44 / +46 lines)
Lines 3-34 Link Here
3
[% USE AuthorisedValues %]
3
[% USE AuthorisedValues %]
4
[% USE Branches %]
4
[% USE Branches %]
5
5
6
<table id="mana_results_datatable" width=100%>
6
[% IF statuscode == "200" %]
7
    <thead>
7
    <table id="mana_results_datatable" width=100%>
8
        <tr>
8
        <thead>
9
            <th>Report Name</th>
9
            <tr>
10
            <th class="anti-the" width=35%>Notes</th>
10
                <th>Report Name</th>
11
            <th>Type</th>
11
                <th class="anti-the" width=35%>Notes</th>
12
            <th title="number of libraries using this pattern"># of users</th>
12
                <th>Type</th>
13
            <th class="title-string" title="last time a library used this pattern">Last import</th>
13
                <th title="number of libraries using this pattern"># of users</th>
14
            <th> Comments </th>
14
                <th class="title-string" title="last time a library used this pattern">Last import</th>
15
            [% UNLESS search_only %]
15
                <th> Comments </th>
16
              <th class="NoSort">Actions</th>
16
                [% UNLESS search_only %]
17
            [% END %]
17
                  <th class="NoSort">Actions</th>
18
        </tr>
18
                [% END %]
19
    </thead>
19
            </tr>
20
    <tbody>
20
        </thead>
21
        [% FOREACH report IN reports %]
21
        <tbody>
22
            [% UNLESS report.cannotdisplay %]
22
            [% FOREACH report IN reports %]
23
                <tr id="row[% report.id %]"
23
                [% UNLESS report.cannotdisplay %]
24
                     [% IF report.nbofcomment > highWarned  %]
24
                    [% IF report.nbofcomment > highWarned %]
25
                        class = "high-warned-row"
25
                  <tr id="row[% report.id %]" class = "high-warned-row">
26
                     [% ELSIF report.nbofcomment > warned  %]
26
                    [% ELSIF report.nbofcomment > warned %]
27
                        class = "warned-row"
27
                  <tr id="row[% report.id %]" class = "warned-row">
28
                     [% ELSIF report.nbofcomment > lowWarned  %]
28
                    [% ELSIF report.nbofcomment > lowWarned %]
29
                        class = "highlighted-row"
29
                  <tr id="row[% report.id %]" class = "highlighted-row">
30
                     [% END %]
30
                    [% END %]
31
                >
32
                    <input hidden class="rowid" value="[% report.id %]">
31
                    <input hidden class="rowid" value="[% report.id %]">
33
                    <td>[% IF ( report.report_name ) %][% report.report_name %][% END %]</td>
32
                    <td>[% IF ( report.report_name ) %][% report.report_name %][% END %]</td>
34
                    <td title="[% report.savedsql %]"><div>
33
                    <td title="[% report.savedsql %]"><div>
Lines 37-68 Link Here
37
                        [% END %]
36
                        [% END %]
38
                            [% report.notes %]
37
                            [% report.notes %]
39
                        [% IF report.notes.length > 200 %]
38
                        [% IF report.notes.length > 200 %]
40
                            <a class="hidebutton">Show Less</a></div> </td>
39
                                <a class="hidebutton">Show Less</a></div> </td>
41
                        [% END %]
40
                        [% END %]
42
                    <td> [% report.type %] </td>
41
                    <td> [% report.type %] </td>
43
                    <td>[% IF ( report.nbofusers ) %][% report.nbofusers %][% END %]</td>
42
                    <td>[% IF ( report.nbofusers ) %][% report.nbofusers %][% END %]</td>
44
                    <td><span title="[% report.lastimport %]">[% report.lastimport | $KohaDates %]</span></td>
43
                    <td><span title="[% report.lastimport %]">[% report.lastimport | $KohaDates %]</span></td>
45
		    <td>[% FOREACH comment IN report.comments %][% comment.message %] ([% comment.nb %]) <br>[% END %]</td>
44
                    <td>[% FOREACH comment IN report.comments %][% comment.message %] ([% comment.nb %]) <br>[% END %]</td>
46
45
47
                    [% UNLESS search_only %]
46
                    [% UNLESS search_only %]
48
                      <td>
47
                        <td>
49
                          <button onclick="mana_use([% report.id %])"> <i class="fa fa-inbox"></i> Use</button>
48
                            <button onclick="mana_use([% report.id %])"> <i class="fa fa-inbox"></i> Use</button>
50
                          <input hidden type="text" id="selectedcomment">
49
                            <input hidden type="text" id="selectedcomment">
51
                          <select>
50
                            <select>
52
                              <option selected disabled>Report mistake</option>
51
                                <option selected disabled>Report mistake</option>
53
                              [% FOREACH comment IN report.comments %]
52
                                [% FOREACH comment IN report.comments %]
54
                                  <option class="actionreport1" value="[% comment.id %]" onclick="mana_increment('[% comment.id %]', 'resource_comment', 'nb')"> [% comment.message %] ([% comment.nb %])
53
                                    <option class="actionreport1" value="[% comment.id %]" onclick="mana_increment('[% comment.id %]', 'resource_comment', 'nb')"> [% comment.message %] ([% comment.nb %])
55
                              [% END %]
54
                                [% END %]
56
                                  <option data-toggle="modal" onclick="($('#selected_id').val($('.rowid').val()))" data-target="#comment_box"> other
55
                                    <option data-toggle="modal" onclick="($('#selected_id').val($('.rowid').val()))" data-target="#comment_box"> other
57
                          </select>
56
                            </select>
58
                          <button hidden class="actionreport2" hidden> Cancel</button>
57
                            <button hidden class="actionreport2" hidden> Cancel</button>
59
                      </td>
58
                        </td>
60
                    [% END %]
59
                    [% END %]
61
                </tr>
60
                  </tr>
61
                [% END %]
62
            [% END %]
62
            [% END %]
63
        [% END %]
63
        </tbody>
64
    </tbody>
64
    </table>
65
</table>
65
[% ELSE %]
66
    <h4> [% msg %] </h4>
67
[% END %]
66
68
67
<div id="comment_box" class="modal" tabindex="-1" role="dialog" aria-labelledby="mana_search_result_label" style="display: none;">
69
<div id="comment_box" class="modal" tabindex="-1" role="dialog" aria-labelledby="mana_search_result_label" style="display: none;">
68
    <div class="modal-dialog modal-lg" style="width: 30%">
70
    <div class="modal-dialog modal-lg" style="width: 30%">
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/mana/mana-subscription-search-result.inc (-55 / +57 lines)
Lines 5-67 Link Here
5
5
6
6
7
7
8
<table id="mana_results_datatable" width=100%>
8
[% IF statuscode == "200" %]
9
    <thead>
9
    <table id="mana_results_datatable" width=100%>
10
        <tr>
10
        <thead>
11
            <th>ISSN</th>
11
            <tr>
12
            <th class="anti-the" width=50%>Title</th>
12
                <th>ISSN</th>
13
            <th> Published by </th>
13
                <th class="anti-the" width=50%>Title</th>
14
            <th>Frequency</th>
14
                <th> Published by </th>
15
            <th>Numbering pattern</th>
15
                <th>Frequency</th>
16
            <th title="number of libraries using this pattern"># of users</th>
16
                <th>Numbering pattern</th>
17
            <th class="title-string" title="last time a library used this pattern">Last import</th>
17
                <th title="number of libraries using this pattern"># of users</th>
18
            <th> Comments </th>
18
                <th class="title-string" title="last time a library used this pattern">Last import</th>
19
            [% UNLESS search_only %]
19
                <th> Comments </th>
20
              <th class="NoSort">Actions</th>
20
                [% UNLESS search_only %]
21
            [% END %]
21
                  <th class="NoSort">Actions</th>
22
        </tr>
22
                [% END %]
23
    </thead>
23
            </tr>
24
    <tbody>
24
        </thead>
25
        [% FOREACH subscription IN subscriptions %]
25
        <tbody>
26
            [% UNLESS subscription.cannotdisplay %]
26
            [% FOREACH subscription IN subscriptions %]
27
                <tr id="row[% subscription.subscriptionid %]"
27
                [% UNLESS subscription.cannotdisplay %]
28
                     [% IF subscription.nbofcomment > highWarned  %]
28
                    [% IF subscription.nbofcomment > highWarned  %]
29
                        class = "high-warned-row" title="this resource has been reported more than [% highWarned %] times, take care!"
29
                    <tr id="row[% subscription.subscriptionid %]" class = "high-warned-row" title="this resource has been reported more than [% highWarned %] times, take care!">
30
                     [% ELSIF subscription.nbofcomment > warned  %]
30
                    [% ELSIF subscription.nbofcomment > warned  %]
31
                        class = "warned-row" title="this resource has been reported more than [% warned %] times, take care!"
31
                    <tr id="row[% subscription.subscriptionid %]" class = "warned-row" title="this resource has been reported more than [% warned %] times, take care!">
32
                     [% ELSIF subscription.nbofcomment > lowWarned  %]
32
                    [% ELSIF subscription.nbofcomment > lowWarned  %]
33
                        class = "highlighted-row" title="this resource has been reported more than [% lowWarned %] times, take care!"
33
                    <tr id="row[% subscription.subscriptionid %]" class = "highlighted-row" title="this resource has been reported more than [% lowWarned %] times, take care!">
34
                     [% END %]
35
                >
36
                <input hidden class="rowid" value="[% subscription.id %]">
37
                    <td>[% IF ( subscription.issn ) %][% subscription.issn %][% END %]</td>
38
                    <td>[% subscription.title %]</a></td>
39
                    <td>[% IF ( subscription.publishercode ) %][% subscription.publishercode %][% END %]</td>
40
                    <td>[% IF ( subscription.sfdescription ) %][% subscription.sfdescription %][% END %]</td>
41
                    <td>[% IF ( subscription.numberingmethod ) %][% subscription.numberingmethod %][% END %]</td>
42
                    <td>[% IF ( subscription.nbofusers ) %][% subscription.nbofusers %][% END %]</td>
43
                    <td><span title="[% subscription.lastimport %]">[% subscription.lastimport | $KohaDates %]</span></td>
44
		    <td>[% FOREACH comment IN subscription.comments %][% comment.message %] ([% comment.nb %]) <br>[% END %]</td>
45
46
                    [% UNLESS search_only %]
47
                      <td>
48
                          <button onclick="mana_use([% subscription.id %])"> <i class="fa fa-inbox"></i> Use</button>
49
                          <input hidden type="text" id="selectedcomment">
50
                          <select>
51
                              <option selected disabled>Report mistake</option>
52
                              [% FOREACH comment IN subscription.comments %]
53
                                  <option class="actionreport1" value="[% comment.id %]" onclick="mana_increment('[% comment.id %]', 'resource_comment', 'nb')"> [% comment.message %] ([% comment.nb %])
54
                              [% END %]
55
                                  <option data-toggle="modal" onclick="($('#selected_id').val($('.rowid').val()))" data-target="#comment_box"> other
56
                          </select>
57
                          <button hidden class="actionreport2" hidden> Cancel</button>
58
                      </td>
59
                    [% END %]
34
                    [% END %]
60
                </tr>
35
                    <input hidden class="rowid" value="[% subscription.id %]">
36
                        <td>[% IF ( subscription.issn ) %][% subscription.issn %][% END %]</td>
37
                        <td>[% subscription.title %]</a></td>
38
                        <td>[% IF ( subscription.publishercode ) %][% subscription.publishercode %][% END %]</td>
39
                        <td>[% IF ( subscription.sfdescription ) %][% subscription.sfdescription %][% END %]</td>
40
                        <td>[% IF ( subscription.numberingmethod ) %][% subscription.numberingmethod %][% END %]</td>
41
                        <td>[% IF ( subscription.nbofusers ) %][% subscription.nbofusers %][% END %]</td>
42
                        <td><span title="[% subscription.lastimport %]">[% subscription.lastimport | $KohaDates %]</span></td>
43
                        <td>[% FOREACH comment IN subscription.comments %][% comment.message %] ([% comment.nb %]) <br>[% END %]</td>
44
45
                        [% UNLESS search_only %]
46
                            <td>
47
                                <button onclick="mana_use([% subscription.id %])"> <i class="fa fa-inbox"></i> Use</button>
48
                                <input hidden type="text" id="selectedcomment">
49
                                <select>
50
                                    <option selected disabled>Report mistake</option>
51
                                    [% FOREACH comment IN subscription.comments %]
52
                                        <option class="actionreport1" value="[% comment.id %]" onclick="mana_increment('[% comment.id %]', 'resource_comment', 'nb')"> [% comment.message %] ([% comment.nb %])
53
                                    [% END %]
54
                                        <option data-toggle="modal" onclick="($('#selected_id').val($('.rowid').val()))" data-target="#comment_box"> other
55
                                </select>
56
                                <button hidden class="actionreport2" hidden> Cancel</button>
57
                            </td>
58
                        [% END %]
59
                    </tr>
60
                [% END %]
61
            [% END %]
61
            [% END %]
62
        [% END %]
62
        </tbody>
63
    </tbody>
63
    </table>
64
</table>
64
[% ELSE %]
65
    <h4> [% msg %] </h4>
66
[% END %]
65
67
66
<div id="comment_box" class="modal" tabindex="-1" role="dialog" aria-labelledby="mana_search_result_label" style="display: none;">
68
<div id="comment_box" class="modal" tabindex="-1" role="dialog" aria-labelledby="mana_search_result_label" style="display: none;">
67
    <div class="modal-dialog modal-lg" style="width: 30%">
69
    <div class="modal-dialog modal-lg" style="width: 30%">
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/serials-toolbar.inc (+1 lines)
Lines 119-124 Link Here
119
            <div class="modal-body">
119
            <div class="modal-body">
120
                [% IF (mana_id) %]
120
                [% IF (mana_id) %]
121
                    <div class="alert">
121
                    <div class="alert">
122
<h1>[% (mana_id) %]</h1>
122
                        <p>Your subscription is already linked with a Mana subscription model. Share it if you have made modifications, otherwise it will do nothing.</p>
123
                        <p>Your subscription is already linked with a Mana subscription model. Share it if you have made modifications, otherwise it will do nothing.</p>
123
                    </div>
124
                    </div>
124
                [% END %]
125
                [% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/web_services.pref (+6 lines)
Lines 60-65 Web services: Link Here
60
            - pref: AutoShareWithMana
60
            - pref: AutoShareWithMana
61
              multiple:
61
              multiple:
62
                subscription: Subscriptions
62
                subscription: Subscriptions
63
    ManaToken:
64
         -
65
             - "Security token used to authenticate on mana:"
66
             - pref: ManaToken
67
               class: Text
68
             - <br> You need a security token to authenticate on Mana, in order to confirm you are human. If you don't have one, please fill in the following form and confirm you e-mail address. <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>
63
    Reporting:
69
    Reporting:
64
        -
70
        -
65
            - Only return
71
            - Only return
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt (-6 / +2 lines)
Lines 467-479 canned reports and writing custom SQL reports.</p> Link Here
467
            </select>
467
            </select>
468
        </div>
468
        </div>
469
<div style="display:inline-block">
469
<div style="display:inline-block">
470
    [% IF (manamsg == 'success') %]
470
    [% IF manamsg %]
471
     <div id="mana_search" class="dialog message">
471
     <div id="mana_search" class="dialog message">
472
        <p> Shared successfully! Thanks for your help.</p>
472
        <p> [% manamsg %] </p>
473
    </div>
474
    [% ELSIF (manamsg == 'fail') %]
475
     <div id="mana_search" class="dialog message">
476
        <p> An error occured while sharing, please try again later.</p>
477
    </div>
473
    </div>
478
    [% END %]
474
    [% END %]
479
475
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-detail.tt (-5 / +1 lines)
Lines 75-85 $(document).ready(function() { Link Here
75
    [% IF mana_code.defined %]
75
    [% IF mana_code.defined %]
76
        <div id="alert-community" class="dialog message">
76
        <div id="alert-community" class="dialog message">
77
            <p>
77
            <p>
78
                [% IF (mana_code == 201) %]
78
                [% mana_code %]
79
                    The export is done, thank you for your contribution.
80
                [% ELSIF (mana_code == 200) %]
81
                    The model already exists on Mana, thank you for your contribution.
82
                [% END %]
83
            </p>
79
            </p>
84
        </div>
80
        </div>
85
    [% END %]
81
    [% END %]
(-)a/reports/guided_reports.pl (-3 / +3 lines)
Lines 630-639 elsif ( $phase eq 'Save Report' ) { Link Here
630
630
631
elsif ($phase eq 'Share'){
631
elsif ($phase eq 'Share'){
632
    my $result = Koha::SharedContent::manaShareInfos($input, $borrowernumber, $input->param('reportid'), 'report');
632
    my $result = Koha::SharedContent::manaShareInfos($input, $borrowernumber, $input->param('reportid'), 'report');
633
    if ( $result and ($result->{code} eq "200" or $result->{code} eq "201") ) {
633
    if ( $result ) {
634
        print $input->redirect("/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved&manamsg=success");
634
        print $input->redirect("/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved&manamsg=".$result->{msg});
635
    }else{
635
    }else{
636
        print $input->redirect("/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved&manamsg=fail");
636
        print $input->redirect("/cgi-bin/koha/reports/guided_reports.pl?phase=Use%20saved&manamsg=noanswer");
637
    }
637
    }
638
}
638
}
639
elsif ($phase eq 'Run this report'){
639
elsif ($phase eq 'Run this report'){
(-)a/serials/subscription-add.pl (-1 / +1 lines)
Lines 402-408 sub redirect_add_subscription { Link Here
402
    );
402
    );
403
    if ( grep { $_ eq "subscription" } split(/,/, C4::Context->preference('AutoShareWithMana')) ){
403
    if ( grep { $_ eq "subscription" } split(/,/, C4::Context->preference('AutoShareWithMana')) ){
404
        my $result = Koha::SharedContent::manaShareInfos( $query, $loggedinuser, $subscriptionid, 'subscription');
404
        my $result = Koha::SharedContent::manaShareInfos( $query, $loggedinuser, $subscriptionid, 'subscription');
405
        $template->param( mana_code => $result->{code} );
405
        $template->param( mana_msg => $result->{msg} );
406
    }
406
    }
407
    my $additional_fields = Koha::AdditionalField->all( { tablename => 'subscription' } );
407
    my $additional_fields = Koha::AdditionalField->all( { tablename => 'subscription' } );
408
    insert_additional_fields( $additional_fields, $biblionumber, $subscriptionid );
408
    insert_additional_fields( $additional_fields, $biblionumber, $subscriptionid );
(-)a/serials/subscription-detail.pl (-1 / +1 lines)
Lines 101-107 if ($op eq 'del') { Link Here
101
}
101
}
102
elsif ( $op and $op eq "share" ) {
102
elsif ( $op and $op eq "share" ) {
103
    my $result = Koha::SharedContent::manaShareInfos($query, $loggedinuser, $subscriptionid, 'subscription');
103
    my $result = Koha::SharedContent::manaShareInfos($query, $loggedinuser, $subscriptionid, 'subscription');
104
    $template->param( mana_code => $result->{code} );
104
    $template->param( mana_code => $result->{msg} );
105
    $subs->{mana_id} = $result->{id};
105
    $subs->{mana_id} = $result->{id};
106
}
106
}
107
107
(-)a/svc/mana/getToken (+55 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2016 BibLibre Baptiste Wojtkowski
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
#
20
21
22
use Modern::Perl;
23
24
use Koha::SharedContent;
25
use C4::Auth qw(check_cookie_auth);
26
27
use CGI;
28
use JSON;
29
30
my $input = new CGI;
31
binmode STDOUT, ":encoding(UTF-8)";
32
print $input->header( -type => 'text/plain', -charset => 'UTF-8' );
33
34
my ( $auth_status, $sessionID ) =
35
  check_cookie_auth( $input->cookie('CGISESSID'),
36
    { serials => 'create_subscription' } );
37
38
if ( $auth_status ne "ok" ) {
39
    exit 0;
40
}
41
42
my $mana_ip = C4::Context->config('mana_config');
43
44
my $url = "$mana_ip/getsecuritytoken";
45
my $request = HTTP::Request->new( POST => $url );
46
47
my $content;
48
$content->{ firstname }= $input->param("firstname");
49
$content->{ lastname }= $input->param("lastname");
50
$content->{ email }= $input->param("email");
51
my $json = to_json( $content, { utf8 => 1 } );
52
$request->content($json);
53
my $result = Koha::SharedContent::manaRequest($request);
54
55
print(to_json($result));
(-)a/svc/mana/search (-1 / +2 lines)
Lines 73-77 foreach my $resource (@{ $result->{data} }){ Link Here
73
}
73
}
74
74
75
$template->param( $input->param('resource')."s" => $result->{data} );
75
$template->param( $input->param('resource')."s" => $result->{data} );
76
$template->param( statuscode => $result->{code} );
77
$template->param( msg => $result->{msg} );
76
78
77
output_with_http_headers $input, $cookie, $template->output, 'json';
79
output_with_http_headers $input, $cookie, $template->output, 'json';
78
- 

Return to bug 17047