Lines 28-33
require Exporter;
Link Here
|
28 |
use C4::Context; |
28 |
use C4::Context; |
29 |
use C4::Templates; # to get the template |
29 |
use C4::Templates; # to get the template |
30 |
use C4::Branch; # GetBranches |
30 |
use C4::Branch; # GetBranches |
|
|
31 |
use C4::Printer qw(GetPrinterDetails); |
31 |
use C4::VirtualShelves; |
32 |
use C4::VirtualShelves; |
32 |
use POSIX qw/strftime/; |
33 |
use POSIX qw/strftime/; |
33 |
use List::MoreUtils qw/ any /; |
34 |
use List::MoreUtils qw/ any /; |
Lines 46-52
BEGIN {
Link Here
|
46 |
$debug = $ENV{DEBUG}; |
47 |
$debug = $ENV{DEBUG}; |
47 |
@ISA = qw(Exporter); |
48 |
@ISA = qw(Exporter); |
48 |
@EXPORT = qw(&checkauth &get_template_and_user &haspermission &get_user_subpermissions); |
49 |
@EXPORT = qw(&checkauth &get_template_and_user &haspermission &get_user_subpermissions); |
49 |
@EXPORT_OK = qw(&check_api_auth &get_session &check_cookie_auth &checkpw &get_all_subpermissions &get_user_subpermissions); |
50 |
@EXPORT_OK = qw(&check_api_auth &get_session &check_cookie_auth &checkpw |
|
|
51 |
&get_all_subpermissions &get_user_subpermissions &get_user_printer); |
50 |
%EXPORT_TAGS = ( EditPermissions => [qw(get_all_subpermissions get_user_subpermissions)] ); |
52 |
%EXPORT_TAGS = ( EditPermissions => [qw(get_all_subpermissions get_user_subpermissions)] ); |
51 |
$ldap = C4::Context->config('useldapserver') || 0; |
53 |
$ldap = C4::Context->config('useldapserver') || 0; |
52 |
$cas = C4::Context->preference('casAuthentication'); |
54 |
$cas = C4::Context->preference('casAuthentication'); |
Lines 310-315
sub get_template_and_user {
Link Here
|
310 |
$template->param(dateformat_iso => 1); |
312 |
$template->param(dateformat_iso => 1); |
311 |
} |
313 |
} |
312 |
|
314 |
|
|
|
315 |
my $userenv = C4::Context->userenv; |
316 |
my $userenv_branch = $userenv ? $userenv->{"branch"} : undef; |
317 |
|
313 |
# these template parameters are set the same regardless of $in->{'type'} |
318 |
# these template parameters are set the same regardless of $in->{'type'} |
314 |
$template->param( |
319 |
$template->param( |
315 |
"BiblioDefaultView".C4::Context->preference("BiblioDefaultView") => 1, |
320 |
"BiblioDefaultView".C4::Context->preference("BiblioDefaultView") => 1, |
Lines 317-325
sub get_template_and_user {
Link Here
|
317 |
GoogleJackets => C4::Context->preference("GoogleJackets"), |
322 |
GoogleJackets => C4::Context->preference("GoogleJackets"), |
318 |
OpenLibraryCovers => C4::Context->preference("OpenLibraryCovers"), |
323 |
OpenLibraryCovers => C4::Context->preference("OpenLibraryCovers"), |
319 |
KohaAdminEmailAddress => "" . C4::Context->preference("KohaAdminEmailAddress"), |
324 |
KohaAdminEmailAddress => "" . C4::Context->preference("KohaAdminEmailAddress"), |
320 |
LoginBranchcode => (C4::Context->userenv?C4::Context->userenv->{"branch"}:"insecure"), |
325 |
LoginBranchcode => ($userenv?$userenv_branch:"insecure"), |
321 |
LoginFirstname => (C4::Context->userenv?C4::Context->userenv->{"firstname"}:"Bel"), |
326 |
LoginFirstname => ($userenv?$userenv->{"firstname"}:"Bel"), |
322 |
LoginSurname => C4::Context->userenv?C4::Context->userenv->{"surname"}:"Inconnu", |
327 |
LoginSurname => $userenv?$userenv->{"surname"}:"Inconnu", |
323 |
TagsEnabled => C4::Context->preference("TagsEnabled"), |
328 |
TagsEnabled => C4::Context->preference("TagsEnabled"), |
324 |
hide_marc => C4::Context->preference("hide_marc"), |
329 |
hide_marc => C4::Context->preference("hide_marc"), |
325 |
item_level_itypes => C4::Context->preference('item-level_itypes'), |
330 |
item_level_itypes => C4::Context->preference('item-level_itypes'), |
Lines 347-353
sub get_template_and_user {
Link Here
|
347 |
IntranetNav => C4::Context->preference("IntranetNav"), |
352 |
IntranetNav => C4::Context->preference("IntranetNav"), |
348 |
IntranetmainUserblock => C4::Context->preference("IntranetmainUserblock"), |
353 |
IntranetmainUserblock => C4::Context->preference("IntranetmainUserblock"), |
349 |
LibraryName => C4::Context->preference("LibraryName"), |
354 |
LibraryName => C4::Context->preference("LibraryName"), |
350 |
LoginBranchname => (C4::Context->userenv?C4::Context->userenv->{"branchname"}:"insecure"), |
355 |
LoginBranchname => ($userenv?$userenv->{"branchname"}:"insecure"), |
351 |
advancedMARCEditor => C4::Context->preference("advancedMARCEditor"), |
356 |
advancedMARCEditor => C4::Context->preference("advancedMARCEditor"), |
352 |
canreservefromotherbranches => C4::Context->preference('canreservefromotherbranches'), |
357 |
canreservefromotherbranches => C4::Context->preference('canreservefromotherbranches'), |
353 |
intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"), |
358 |
intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"), |
Lines 367-372
sub get_template_and_user {
Link Here
|
367 |
AllowMultipleCovers => C4::Context->preference('AllowMultipleCovers'), |
372 |
AllowMultipleCovers => C4::Context->preference('AllowMultipleCovers'), |
368 |
EnableBorrowerFiles => C4::Context->preference('EnableBorrowerFiles'), |
373 |
EnableBorrowerFiles => C4::Context->preference('EnableBorrowerFiles'), |
369 |
); |
374 |
); |
|
|
375 |
if ( C4::Context->preference('UsePrintQueues') ) { |
376 |
my $printer = get_user_printer(); |
377 |
my $printer_rec = $printer ? GetPrinterDetails($printer) : {}; |
378 |
$template->param( |
379 |
UsePrintQueues => 1, |
380 |
PrinterName => $printer_rec->{printername}, |
381 |
); |
382 |
} |
370 |
} |
383 |
} |
371 |
else { |
384 |
else { |
372 |
warn "template type should be OPAC, here it is=[" . $in->{'type'} . "]" unless ( $in->{'type'} eq 'opac' ); |
385 |
warn "template type should be OPAC, here it is=[" . $in->{'type'} . "]" unless ( $in->{'type'} eq 'opac' ); |
Lines 385-392
sub get_template_and_user {
Link Here
|
385 |
my $opac_name = ''; |
398 |
my $opac_name = ''; |
386 |
if (($opac_search_limit =~ /branch:(\w+)/ && $opac_limit_override) || $in->{'query'}->param('limit') =~ /branch:(\w+)/){ |
399 |
if (($opac_search_limit =~ /branch:(\w+)/ && $opac_limit_override) || $in->{'query'}->param('limit') =~ /branch:(\w+)/){ |
387 |
$opac_name = $1; # opac_search_limit is a branch, so we use it. |
400 |
$opac_name = $1; # opac_search_limit is a branch, so we use it. |
388 |
} elsif (C4::Context->preference("SearchMyLibraryFirst") && C4::Context->userenv && C4::Context->userenv->{'branch'}) { |
401 |
} elsif (C4::Context->preference("SearchMyLibraryFirst") && $userenv_branch) { |
389 |
$opac_name = C4::Context->userenv->{'branch'}; |
402 |
$opac_name = $userenv_branch |
390 |
} |
403 |
} |
391 |
$template->param( |
404 |
$template->param( |
392 |
opaccolorstylesheet => C4::Context->preference("opaccolorstylesheet"), |
405 |
opaccolorstylesheet => C4::Context->preference("opaccolorstylesheet"), |
Lines 397-403
sub get_template_and_user {
Link Here
|
397 |
CalendarFirstDayOfWeek => (C4::Context->preference("CalendarFirstDayOfWeek") eq "Sunday")?0:1, |
410 |
CalendarFirstDayOfWeek => (C4::Context->preference("CalendarFirstDayOfWeek") eq "Sunday")?0:1, |
398 |
LibraryName => "" . C4::Context->preference("LibraryName"), |
411 |
LibraryName => "" . C4::Context->preference("LibraryName"), |
399 |
LibraryNameTitle => "" . $LibraryNameTitle, |
412 |
LibraryNameTitle => "" . $LibraryNameTitle, |
400 |
LoginBranchname => C4::Context->userenv?C4::Context->userenv->{"branchname"}:"", |
413 |
LoginBranchname => $userenv?$userenv->{"branchname"}:"", |
401 |
OPACAmazonEnabled => C4::Context->preference("OPACAmazonEnabled"), |
414 |
OPACAmazonEnabled => C4::Context->preference("OPACAmazonEnabled"), |
402 |
OPACAmazonSimilarItems => C4::Context->preference("OPACAmazonSimilarItems"), |
415 |
OPACAmazonSimilarItems => C4::Context->preference("OPACAmazonSimilarItems"), |
403 |
OPACAmazonCoverImages => C4::Context->preference("OPACAmazonCoverImages"), |
416 |
OPACAmazonCoverImages => C4::Context->preference("OPACAmazonCoverImages"), |
Lines 431-437
sub get_template_and_user {
Link Here
|
431 |
RequestOnOpac => C4::Context->preference("RequestOnOpac"), |
444 |
RequestOnOpac => C4::Context->preference("RequestOnOpac"), |
432 |
'Version' => C4::Context->preference('Version'), |
445 |
'Version' => C4::Context->preference('Version'), |
433 |
hidelostitems => C4::Context->preference("hidelostitems"), |
446 |
hidelostitems => C4::Context->preference("hidelostitems"), |
434 |
mylibraryfirst => (C4::Context->preference("SearchMyLibraryFirst") && C4::Context->userenv) ? C4::Context->userenv->{'branch'} : '', |
447 |
mylibraryfirst => (C4::Context->preference("SearchMyLibraryFirst") && $userenv) ? $userenv_branch : '', |
435 |
opaclayoutstylesheet => "" . C4::Context->preference("opaclayoutstylesheet"), |
448 |
opaclayoutstylesheet => "" . C4::Context->preference("opaclayoutstylesheet"), |
436 |
opacbookbag => "" . C4::Context->preference("opacbookbag"), |
449 |
opacbookbag => "" . C4::Context->preference("opacbookbag"), |
437 |
opaccredits => "" . C4::Context->preference("opaccredits"), |
450 |
opaccredits => "" . C4::Context->preference("opaccredits"), |
Lines 1651-1658
sub getborrowernumber {
Link Here
|
1651 |
return 0; |
1664 |
return 0; |
1652 |
} |
1665 |
} |
1653 |
|
1666 |
|
|
|
1667 |
=head2 get_user_printer |
1668 |
|
1669 |
$printer = get_user_printer(); |
1670 |
|
1671 |
Returns printer queue that is to be used for the logged in user |
1672 |
|
1673 |
=cut |
1674 |
|
1675 |
sub get_user_printer { |
1676 |
my $userenv = C4::Context->userenv or return; |
1677 |
if (my $printer = $userenv->{branchprinter}) { |
1678 |
return $printer; |
1679 |
} |
1680 |
my $branchname = $userenv->{branch} or return; |
1681 |
my $branch = GetBranchDetail($branchname) or return; |
1682 |
return $branch->{branchprinter}; |
1683 |
} |
1654 |
|
1684 |
|
1655 |
END { } # module clean-up code here (global destructor) |
|
|
1656 |
1; |
1685 |
1; |
1657 |
__END__ |
1686 |
__END__ |
1658 |
|
1687 |
|