Lines 1-23
Link Here
|
1 |
#!/usr/bin/perl |
1 |
#!/usr/bin/perl |
2 |
|
2 |
|
3 |
# script to find a basket user |
|
|
4 |
|
5 |
# Copyright 2012 BibLibre SARL |
6 |
# |
7 |
# This file is part of Koha. |
3 |
# This file is part of Koha. |
8 |
# |
4 |
# |
9 |
# Koha is free software; you can redistribute it and/or modify it under the |
5 |
# Copyright 2014 BibLibre |
10 |
# terms of the GNU General Public License as published by the Free Software |
|
|
11 |
# Foundation; either version 2 of the License, or (at your option) any later |
12 |
# version. |
13 |
# |
6 |
# |
14 |
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY |
7 |
# Koha is free software; you can redistribute it and/or modify it |
15 |
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
8 |
# under the terms of the GNU General Public License as published by |
16 |
# A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
9 |
# the Free Software Foundation; either version 3 of the License, or |
|
|
10 |
# (at your option) any later version. |
17 |
# |
11 |
# |
18 |
# You should have received a copy of the GNU General Public License along |
12 |
# Koha is distributed in the hope that it will be useful, but |
19 |
# with Koha; if not, write to the Free Software Foundation, Inc., |
13 |
# WITHOUT ANY WARRANTY; without even the implied warranty of |
20 |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
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>. |
21 |
|
19 |
|
22 |
use Modern::Perl; |
20 |
use Modern::Perl; |
23 |
|
21 |
|
Lines 31-37
my $input = new CGI;
Link Here
|
31 |
my $dbh = C4::Context->dbh; |
29 |
my $dbh = C4::Context->dbh; |
32 |
|
30 |
|
33 |
my ( $template, $loggedinuser, $cookie, $staff_flags ) = get_template_and_user( |
31 |
my ( $template, $loggedinuser, $cookie, $staff_flags ) = get_template_and_user( |
34 |
{ template_name => "acqui/aqbasketuser_search.tt", |
32 |
{ template_name => "acqui/add_user_search.tt", |
35 |
query => $input, |
33 |
query => $input, |
36 |
type => "intranet", |
34 |
type => "intranet", |
37 |
authnotrequired => 0, |
35 |
authnotrequired => 0, |
Lines 42-59
my ( $template, $loggedinuser, $cookie, $staff_flags ) = get_template_and_user(
Link Here
|
42 |
my $q = $input->param('q') || ''; |
40 |
my $q = $input->param('q') || ''; |
43 |
my $op = $input->param('op') || ''; |
41 |
my $op = $input->param('op') || ''; |
44 |
|
42 |
|
|
|
43 |
my $referer = $input->referer(); |
44 |
|
45 |
# If this script is called by acqui/basket.pl |
46 |
# the patrons to return should be superlibrarian or have the order_manage |
47 |
# acquisition flag. |
48 |
my $search_patrons_with_acq_perm_only = |
49 |
( $referer =~ m|acqui/basket.pl| ) |
50 |
? 1 : 0; |
51 |
|
45 |
if( $op eq "do_search" ) { |
52 |
if( $op eq "do_search" ) { |
46 |
my $results = C4::Members::Search( $q, "surname"); |
53 |
my $results = C4::Members::Search( $q, "surname"); |
47 |
|
54 |
|
48 |
my @users_loop; |
55 |
my @users_loop; |
49 |
my $nresults = 0; |
56 |
my $nresults = 0; |
50 |
foreach my $res (@$results) { |
57 |
foreach my $res (@$results) { |
51 |
my $perms = haspermission( $res->{userid} ); |
58 |
my $should_be_returned = 1; |
52 |
my $subperms = get_user_subpermissions( $res->{userid} ); |
59 |
|
|
|
60 |
if ( $search_patrons_with_acq_perm_only ) { |
61 |
$should_be_returned = 0; |
62 |
my $perms = haspermission( $res->{userid} ); |
63 |
my $subperms = get_user_subpermissions( $res->{userid} ); |
53 |
|
64 |
|
54 |
if( $perms->{superlibrarian} == 1 |
65 |
if( $perms->{superlibrarian} == 1 |
55 |
|| $perms->{acquisition} == 1 |
66 |
|| $perms->{acquisition} == 1 |
56 |
|| $subperms->{acquisition}->{'order_manage'} ) { |
67 |
|| $subperms->{acquisition}->{'order_manage'} ) { |
|
|
68 |
$should_be_returned = 1; |
69 |
} |
70 |
} |
71 |
if ( $should_be_returned ) { |
57 |
my %row = ( |
72 |
my %row = ( |
58 |
borrowernumber => $res->{borrowernumber}, |
73 |
borrowernumber => $res->{borrowernumber}, |
59 |
cardnumber => $res->{cardnumber}, |
74 |
cardnumber => $res->{cardnumber}, |
Lines 74-77
if( $op eq "do_search" ) {
Link Here
|
74 |
); |
89 |
); |
75 |
} |
90 |
} |
76 |
|
91 |
|
|
|
92 |
$template->param( |
93 |
patrons_with_acq_perm_only => $search_patrons_with_acq_perm_only, |
94 |
); |
77 |
output_html_with_http_headers( $input, $cookie, $template->output ); |
95 |
output_html_with_http_headers( $input, $cookie, $template->output ); |