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

(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/members-toolbar.inc (-1 / +1 lines)
Lines 61-67 Link Here
61
                [% END %]
61
                [% END %]
62
62
63
                [% IF CAN_user_borrowers_edit_borrowers %]
63
                [% IF CAN_user_borrowers_edit_borrowers %]
64
                    <li><a id="apikeys" href="/cgi-bin/koha/members/apikeys.pl?patron_id=[% borrowernumber %]">Manage API keys</a></li>
64
                    <li><a id="apikeys" href="/cgi-bin/koha/members/apikeys.pl?patron_id=[% patron.borrowernumber %]">Manage API keys</a></li>
65
                [% ELSE %]
65
                [% ELSE %]
66
                    <li class="disabled"><a data-toggle="tooltip" data-placement="left" title="You are not authorized to manage API keys" id="apikeys" href="#">Manage API keys</a></li>
66
                    <li class="disabled"><a data-toggle="tooltip" data-placement="left" title="You are not authorized to manage API keys" id="apikeys" href="#">Manage API keys</a></li>
67
                [% END %]
67
                [% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/apikeys.tt (-7 / +9 lines)
Lines 27-33 Link Here
27
                    <input type="hidden" name="patron_id" value="[% patron.id %]" />
27
                    <input type="hidden" name="patron_id" value="[% patron.id %]" />
28
                    <input type="hidden" name="op" value="generate" />
28
                    <input type="hidden" name="op" value="generate" />
29
                    <fieldset class="brief">
29
                    <fieldset class="brief">
30
                        <legend>Generate new key</legend>
30
                        <legend>Generate new client id/secret pair</legend>
31
                        <ol>
31
                        <ol>
32
                            <li>
32
                            <li>
33
                                <label for="description">Description: </label>
33
                                <label for="description">Description: </label>
Lines 42-54 Link Here
42
                <div id="keys">
42
                <div id="keys">
43
                    [% IF api_keys && api_keys.size > 0 %]
43
                    [% IF api_keys && api_keys.size > 0 %]
44
                        <p>
44
                        <p>
45
                            <button class="btn btn-default btn-xs toggle_element" type="submit" id="show-api-form" data-element="#add-api-key"><i class="fa fa-plus"></i> Generate a new key</button>
45
                            <button class="btn btn-default btn-xs toggle_element" type="submit" id="show-api-form" data-element="#add-api-key"><i class="fa fa-plus"></i> Generate a new client id/key pair</button>
46
                        </p>
46
                        </p>
47
                        <table>
47
                        <table>
48
                            <thead>
48
                            <thead>
49
                                <tr>
49
                                <tr>
50
                                    <th>Description</th>
50
                                    <th>Description</th>
51
                                    <th>Key</th>
51
                                    <th>Client ID</th>
52
                                    <th>Secret</th>
52
                                    <th>Active</th>
53
                                    <th>Active</th>
53
                                    <th>Actions</th>
54
                                    <th>Actions</th>
54
                                </tr>
55
                                </tr>
Lines 57-74 Link Here
57
                                [% FOREACH key IN api_keys %]
58
                                [% FOREACH key IN api_keys %]
58
                                    <tr>
59
                                    <tr>
59
                                        <td>[% key.description %]</td>
60
                                        <td>[% key.description %]</td>
60
                                        <td>[% key.value %]</td>
61
                                        <td>[% key.client_id %]</td>
62
                                        <td>[% key.secret %]</td>
61
                                        <td>[% IF key.active %]Yes[% ELSE %]No[% END %]</td>
63
                                        <td>[% IF key.active %]Yes[% ELSE %]No[% END %]</td>
62
                                        <td>
64
                                        <td>
63
                                            <form action="/cgi-bin/koha/members/apikeys.pl" method="post">
65
                                            <form action="/cgi-bin/koha/members/apikeys.pl" method="post">
64
                                                <input type="hidden" name="patron_id" value="[% patron.id %]" />
66
                                                <input type="hidden" name="patron_id" value="[% patron.id %]" />
65
                                                <input type="hidden" name="key" value="[% key.value %]" />
67
                                                <input type="hidden" name="key" value="[% key.id %]" />
66
                                                <input type="hidden" name="op" value="delete" />
68
                                                <input type="hidden" name="op" value="delete" />
67
                                                <button class="btn btn-default btn-xs delete" type="submit"><i class="fa fa-trash"></i> Delete</button>
69
                                                <button class="btn btn-default btn-xs delete" type="submit"><i class="fa fa-trash"></i> Delete</button>
68
                                            </form>
70
                                            </form>
69
                                            <form action="/cgi-bin/koha/members/apikeys.pl" method="post">
71
                                            <form action="/cgi-bin/koha/members/apikeys.pl" method="post">
70
                                                <input type="hidden" name="patron_id" value="[% patron.id %]" />
72
                                                <input type="hidden" name="patron_id" value="[% patron.id %]" />
71
                                                <input type="hidden" name="key" value="[% key.value %]" />
73
                                                <input type="hidden" name="key" value="[% key.id %]" />
72
                                                [% IF key.active %]
74
                                                [% IF key.active %]
73
                                                    <input type="hidden" name="op" value="revoke" />
75
                                                    <input type="hidden" name="op" value="revoke" />
74
                                                    <button class="btn btn-default btn-xs" type="submit"><i class="fa fa-remove"></i> Revoke</button>
76
                                                    <button class="btn btn-default btn-xs" type="submit"><i class="fa fa-remove"></i> Revoke</button>
Lines 83-89 Link Here
83
                            </tbody>
85
                            </tbody>
84
                        </table>
86
                        </table>
85
                    [% ELSE %]
87
                    [% ELSE %]
86
                        <div class="dialog message">No keys defined for the current patron. <a href="#" class="toggle_element" data-element="#add-api-key" id="show-api-form"><i class="fa fa-plus"></i> Generate a new key</div>
88
                        <div class="dialog message">No keys defined for the current patron. <a href="#" class="toggle_element" data-element="#add-api-key" id="show-api-form"><i class="fa fa-plus"></i> Generate a new client id/secret pair</div>
87
                    [% END %]
89
                    [% END %]
88
                </div>
90
                </div>
89
            </div>
91
            </div>
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-apikeys.tt (-5 / +7 lines)
Lines 33-39 Link Here
33
                    </p>
33
                    </p>
34
                    <form id="add-api-key" action="/cgi-bin/koha/opac-apikeys.pl" method="post">
34
                    <form id="add-api-key" action="/cgi-bin/koha/opac-apikeys.pl" method="post">
35
                        <fieldset>
35
                        <fieldset>
36
                            <legend>Generate new key</legend>
36
                            <legend>Generate new client id/secret pair</legend>
37
                            <input type="hidden" name="patron_id" value="[% patron.id %]" />
37
                            <input type="hidden" name="patron_id" value="[% patron.id %]" />
38
                            <input type="hidden" name="op" value="generate" />
38
                            <input type="hidden" name="op" value="generate" />
39
                            <label for="description">Description: </label>
39
                            <label for="description">Description: </label>
Lines 48-54 Link Here
48
                            <thead>
48
                            <thead>
49
                                <tr>
49
                                <tr>
50
                                    <th>Description</th>
50
                                    <th>Description</th>
51
                                    <th>Key</th>
51
                                    <th>Client ID</th>
52
                                    <th>Secret</th>
52
                                    <th>Active</th>
53
                                    <th>Active</th>
53
                                    <th>Actions</th>
54
                                    <th>Actions</th>
54
                                </tr>
55
                                </tr>
Lines 57-72 Link Here
57
                                [% FOREACH key IN api_keys %]
58
                                [% FOREACH key IN api_keys %]
58
                                    <tr>
59
                                    <tr>
59
                                        <td>[% key.description %]</td>
60
                                        <td>[% key.description %]</td>
60
                                        <td>[% key.value %]</td>
61
                                        <td>[% key.client_id %]</td>
62
                                        <td>[% key.secret %]</td>
61
                                        <td>[% IF key.active %]Yes[% ELSE %]No[% END %]</td>
63
                                        <td>[% IF key.active %]Yes[% ELSE %]No[% END %]</td>
62
                                        <td>
64
                                        <td>
63
                                            <form action="/cgi-bin/koha/opac-apikeys.pl" method="post" class="form-inline">
65
                                            <form action="/cgi-bin/koha/opac-apikeys.pl" method="post" class="form-inline">
64
                                                <input type="hidden" name="key" value="[% key.value %]" />
66
                                                <input type="hidden" name="key" value="[% key.id %]" />
65
                                                <input type="hidden" name="op" value="delete" />
67
                                                <input type="hidden" name="op" value="delete" />
66
                                                <button class="btn btn-link btn-xs delete-key" type="submit"><i class="fa fa-trash"></i> Delete</button>
68
                                                <button class="btn btn-link btn-xs delete-key" type="submit"><i class="fa fa-trash"></i> Delete</button>
67
                                            </form>
69
                                            </form>
68
                                            <form action="/cgi-bin/koha/opac-apikeys.pl" method="post" class="form-inline">
70
                                            <form action="/cgi-bin/koha/opac-apikeys.pl" method="post" class="form-inline">
69
                                                <input type="hidden" name="key" value="[% key.value %]" />
71
                                                <input type="hidden" name="key" value="[% key.id %]" />
70
                                                [% IF key.active %]
72
                                                [% IF key.active %]
71
                                                    <input type="hidden" name="op" value="revoke" />
73
                                                    <input type="hidden" name="op" value="revoke" />
72
                                                    <button class="btn btn-link btn-xs" type="submit"><i class="fa fa-remove"></i> Revoke</button>
74
                                                    <button class="btn btn-link btn-xs" type="submit"><i class="fa fa-remove"></i> Revoke</button>
(-)a/members/apikeys.pl (-6 / +6 lines)
Lines 67-74 if ($op) { Link Here
67
    }
67
    }
68
68
69
    if ( $op eq 'delete' ) {
69
    if ( $op eq 'delete' ) {
70
        my $api_key = $cgi->param('key');
70
        my $api_key_id = $cgi->param('key');
71
        my $key = Koha::ApiKeys->find({ patron_id => $patron_id, value => $api_key });
71
        my $key = Koha::ApiKeys->find({ patron_id => $patron_id, id => $api_key_id });
72
        if ($key) {
72
        if ($key) {
73
            $key->delete;
73
            $key->delete;
74
        }
74
        }
Lines 77-84 if ($op) { Link Here
77
    }
77
    }
78
78
79
    if ( $op eq 'revoke' ) {
79
    if ( $op eq 'revoke' ) {
80
        my $api_key = $cgi->param('key');
80
        my $api_key_id = $cgi->param('key');
81
        my $key = Koha::ApiKeys->find({ patron_id => $patron_id, value => $api_key });
81
        my $key = Koha::ApiKeys->find({ patron_id => $patron_id, id => $api_key_id });
82
        if ($key) {
82
        if ($key) {
83
            $key->active(0);
83
            $key->active(0);
84
            $key->store;
84
            $key->store;
Lines 88-95 if ($op) { Link Here
88
    }
88
    }
89
89
90
    if ( $op eq 'activate' ) {
90
    if ( $op eq 'activate' ) {
91
        my $api_key = $cgi->param('key');
91
        my $api_key_id = $cgi->param('key');
92
        my $key = Koha::ApiKeys->find({ patron_id => $patron_id, value => $api_key });
92
        my $key = Koha::ApiKeys->find({ patron_id => $patron_id, id => $api_key_id });
93
        if ($key) {
93
        if ($key) {
94
            $key->active(1);
94
            $key->active(1);
95
            $key->store;
95
            $key->store;
(-)a/opac/opac-apikeys.pl (-8 / +6 lines)
Lines 47-53 if ( not defined $patron Link Here
47
    exit;
47
    exit;
48
}
48
}
49
49
50
51
my $op = $cgi->param('op');
50
my $op = $cgi->param('op');
52
51
53
if ($op) {
52
if ($op) {
Lines 63-70 if ($op) { Link Here
63
    }
62
    }
64
63
65
    if ($op eq 'delete') {
64
    if ($op eq 'delete') {
66
        my $key = $cgi->param('key');
65
        my $key_id  = $cgi->param('key');
67
        my $api_key = Koha::ApiKeys->find({ patron_id => $patron_id, value => $key});
66
        my $api_key = Koha::ApiKeys->find({ patron_id => $patron_id, id => $key_id });
68
        if ($api_key) {
67
        if ($api_key) {
69
            $api_key->delete;
68
            $api_key->delete;
70
        }
69
        }
Lines 73-80 if ($op) { Link Here
73
    }
72
    }
74
73
75
    if ($op eq 'revoke') {
74
    if ($op eq 'revoke') {
76
        my $key = $cgi->param('key');
75
        my $key_id  = $cgi->param('key');
77
        my $api_key = Koha::ApiKeys->find({ patron_id => $patron_id, value => $key });
76
        my $api_key = Koha::ApiKeys->find({ patron_id => $patron_id, id => $key_id });
78
        if ($api_key) {
77
        if ($api_key) {
79
            $api_key->active(0);
78
            $api_key->active(0);
80
            $api_key->store;
79
            $api_key->store;
Lines 84-91 if ($op) { Link Here
84
    }
83
    }
85
84
86
    if ($op eq 'activate') {
85
    if ($op eq 'activate') {
87
        my $key = $cgi->param('key');
86
        my $key_id  = $cgi->param('key');
88
        my $api_key = Koha::ApiKeys->find({ patron_id => $patron_id, value => $key });
87
        my $api_key = Koha::ApiKeys->find({ patron_id => $patron_id, id => $key_id });
89
        if ($api_key) {
88
        if ($api_key) {
90
            $api_key->active(1);
89
            $api_key->active(1);
91
            $api_key->store;
90
            $api_key->store;
92
- 

Return to bug 20568