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

(-)a/Koha/REST/V1/Suggestions.pm (+24 lines)
Lines 177-180 sub delete { Link Here
177
    };
177
    };
178
}
178
}
179
179
180
=head3 list_managers
181
182
Return the list of possible suggestions' managers
183
184
=cut
185
186
sub list_managers {
187
    my $c = shift->openapi->valid_input or return;
188
189
    return try {
190
191
        my $patrons_rs = Koha::Patrons->search->filter_by_have_subpermission('suggestions.suggestions_manage');
192
        my $patrons    = $c->objects->search( $patrons_rs );
193
194
        return $c->render(
195
            status  => 200,
196
            openapi => $patrons
197
        );
198
    }
199
    catch {
200
        $c->unhandled_exception($_);
201
    };
202
}
203
180
1;
204
1;
(-)a/api/v1/swagger/paths.yaml (+2 lines)
Lines 141-143 Link Here
141
  $ref: paths/suggestions.yaml#/~1suggestions
141
  $ref: paths/suggestions.yaml#/~1suggestions
142
"/suggestions/{suggestion_id}":
142
"/suggestions/{suggestion_id}":
143
  $ref: paths/suggestions.yaml#/~1suggestions~1{suggestion_id}
143
  $ref: paths/suggestions.yaml#/~1suggestions~1{suggestion_id}
144
/suggestions/managers:
145
  $ref: paths/suggestions.yaml#/~1suggestions~1managers
(-)a/api/v1/swagger/paths/suggestions.yaml (+44 lines)
Lines 214-216 Link Here
214
    x-koha-authorization:
214
    x-koha-authorization:
215
      permissions:
215
      permissions:
216
        suggestions: suggestions_manage
216
        suggestions: suggestions_manage
217
/suggestions/managers:
218
  get:
219
    x-mojo-to: Suggestions#list_managers
220
    operationId: listSuggestionsManagers
221
    description: This resource returns a list of patron allowed to be a manager for suggestions
222
    summary: List possibe managers for suggestions
223
    tags:
224
      - suggestions
225
    parameters:
226
      - $ref: ../parameters.yaml#/match
227
      - $ref: ../parameters.yaml#/order_by
228
      - $ref: ../parameters.yaml#/page
229
      - $ref: ../parameters.yaml#/per_page
230
      - $ref: ../parameters.yaml#/q_param
231
      - $ref: ../parameters.yaml#/q_body
232
      - $ref: ../parameters.yaml#/q_header
233
    produces:
234
      - application/json
235
    responses:
236
      "200":
237
        description: A list of suggestions' managers
238
        schema:
239
          type: array
240
          items:
241
            $ref: ../definitions.yaml#/patron
242
      "403":
243
        description: Access forbidden
244
        schema:
245
          $ref: ../definitions.yaml#/error
246
      "500":
247
        description: |
248
          Internal server error. Possible `error_code` attribute values:
249
250
          * `internal_server_error`
251
        schema:
252
          $ref: ../definitions.yaml#/error
253
      "503":
254
        description: Under maintenance
255
        schema:
256
          $ref: ../definitions.yaml#/error
257
    x-koha-authorization:
258
      permissions:
259
        suggestions: suggestions_manage
260
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/search.tt (-1 / +6 lines)
Lines 164-170 Link Here
164
            };
164
            };
165
            patrons_table = $("#memberresultst").kohaTable({
165
            patrons_table = $("#memberresultst").kohaTable({
166
                "ajax": {
166
                "ajax": {
167
                    "url": '/api/v1/patrons'
167
                    [% SWITCH filter %]
168
                    [% CASE 'suggestions_managers' %]
169
                        "url": '/api/v1/suggestions/managers'
170
                    [% CASE %]
171
                        "url": '/api/v1/patrons'
172
                    [% END %]
168
                },
173
                },
169
                "order": [[ 1, "asc" ]],
174
                "order": [[ 1, "asc" ]],
170
                "iDeferLoading": 0,
175
                "iDeferLoading": 0,
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt (-2 / +2 lines)
Lines 1218-1224 Link Here
1218
        var tab = '';
1218
        var tab = '';
1219
        function editManagerPopup(selected_tab) {
1219
        function editManagerPopup(selected_tab) {
1220
            tab = selected_tab;
1220
            tab = selected_tab;
1221
            window.open("/cgi-bin/koha/suggestion/add_user_search.pl?selection_type=select&callback=select_manager&permissions=suggestions.suggestions_manage",
1221
            window.open("/cgi-bin/koha/members/search.pl?columns=cardnumber,name,branch,category,action&selection_type=select&callback=select_manager&filter=suggestions_managers",
1222
                'PatronPopup',
1222
                'PatronPopup',
1223
                'width=740,height=450,location=yes,toolbar=no,'
1223
                'width=740,height=450,location=yes,toolbar=no,'
1224
                + 'scrollbars=yes,resize=yes'
1224
                + 'scrollbars=yes,resize=yes'
Lines 1255-1261 Link Here
1255
        }
1255
        }
1256
1256
1257
        function editSuggesterPopup() {
1257
        function editSuggesterPopup() {
1258
            window.open("/cgi-bin/koha/suggestion/add_user_search.pl?selection_type=select&callback=select_suggester",
1258
            window.open("/cgi-bin/koha/members/search.pl?columns=cardnumber,name,branch,category,action&selection_type=select&callback=select_suggester",
1259
                'PatronPopup',
1259
                'PatronPopup',
1260
                'width=740,height=450,location=yes,toolbar=no,'
1260
                'width=740,height=450,location=yes,toolbar=no,'
1261
                + 'scrollbars=yes,resize=yes'
1261
                + 'scrollbars=yes,resize=yes'
(-)a/members/search.pl (-4 / +9 lines)
Lines 34-44 my ( $template, $loggedinuser, $cookie, $staff_flags ) = get_template_and_user( Link Here
34
my $referer = $input->referer();
34
my $referer = $input->referer();
35
35
36
my @columns = split ',', $input->param('columns');
36
my @columns = split ',', $input->param('columns');
37
my $callback = $input->param('callback');
38
my $selection_type = $input->param('selection_type') || 'select';
39
my $filter = $input->param('filter');
37
40
38
$template->param(
41
$template->param(
39
    view => ( $input->request_method() eq "GET" ) ? "show_form" : "show_results",
42
    view           => ( $input->request_method() eq "GET" ) ? "show_form" : "show_results",
40
    columns => \@columns,
43
    callback       => $callback,
41
    selection_type => 'select',
44
    columns        => \@columns,
42
    alphabet        => ( C4::Context->preference('alphabet') || join ' ', 'A' .. 'Z' ),
45
    filter         => $filter,
46
    selection_type => $selection_type,
47
    alphabet       => ( C4::Context->preference('alphabet') || join ' ', 'A' .. 'Z' ),
43
);
48
);
44
output_html_with_http_headers( $input, $cookie, $template->output );
49
output_html_with_http_headers( $input, $cookie, $template->output );
(-)a/suggestion/add_user_search.pl (-65 lines)
Lines 1-64 Link Here
1
#!/usr/bin/perl
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18
use Modern::Perl;
19
20
use CGI qw ( -utf8 );
21
use C4::Auth qw( get_template_and_user );
22
use C4::Output qw( output_html_with_http_headers );
23
use C4::Members;
24
25
use Koha::Patron::Categories;
26
27
my $input = CGI->new;
28
29
my $dbh = C4::Context->dbh;
30
31
my ( $template, $loggedinuser, $cookie, $staff_flags ) = get_template_and_user(
32
    {   template_name   => "common/patron_search.tt",
33
        query           => $input,
34
        type            => "intranet",
35
        authnotrequired => 0,
36
        flagsrequired   => { suggestions => 'suggestions_manage' },
37
    }
38
);
39
40
my $q = $input->param('q') || '';
41
my $op = $input->param('op') || '';
42
my $selection_type = $input->param('selection_type') || 'add';
43
44
my $referer = $input->referer();
45
46
# The patrons to return should be superlibrarian or have the suggestions_manage flag
47
my $permissions = $input->param('permissions');
48
my $search_patrons_with_suggestion_perm_only =
49
    ( $permissions && $permissions eq 'suggestions.suggestions_manage' )
50
        ? 1 : 0;
51
52
my $patron_categories = Koha::Patron::Categories->search_with_library_limits({}, {order_by => ['description']});;
53
$template->param(
54
    patrons_with_suggestion_perm_only => $search_patrons_with_suggestion_perm_only,
55
    view => ( $input->request_method() eq "GET" ) ? "show_form" : "show_results",
56
    callback => scalar $input->param('callback'),
57
    columns => ['cardnumber', 'name', 'branch', 'category', 'action'],
58
    json_template => 'acqui/tables/members_results.tt',
59
    selection_type => $selection_type,
60
    alphabet        => ( C4::Context->preference('alphabet') || join ' ', 'A' .. 'Z' ),
61
    categories      => $patron_categories,
62
    aaSorting       => 1,
63
);
64
output_html_with_http_headers( $input, $cookie, $template->output );
65
- 

Return to bug 30055