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 344-350
sub get_template_and_user {
Link Here
|
344 |
IntranetNav => C4::Context->preference("IntranetNav"), |
349 |
IntranetNav => C4::Context->preference("IntranetNav"), |
345 |
IntranetmainUserblock => C4::Context->preference("IntranetmainUserblock"), |
350 |
IntranetmainUserblock => C4::Context->preference("IntranetmainUserblock"), |
346 |
LibraryName => C4::Context->preference("LibraryName"), |
351 |
LibraryName => C4::Context->preference("LibraryName"), |
347 |
LoginBranchname => (C4::Context->userenv?C4::Context->userenv->{"branchname"}:"insecure"), |
352 |
LoginBranchname => ($userenv?$userenv->{"branchname"}:"insecure"), |
348 |
advancedMARCEditor => C4::Context->preference("advancedMARCEditor"), |
353 |
advancedMARCEditor => C4::Context->preference("advancedMARCEditor"), |
349 |
canreservefromotherbranches => C4::Context->preference('canreservefromotherbranches'), |
354 |
canreservefromotherbranches => C4::Context->preference('canreservefromotherbranches'), |
350 |
intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"), |
355 |
intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"), |
Lines 364-369
sub get_template_and_user {
Link Here
|
364 |
AllowMultipleCovers => C4::Context->preference('AllowMultipleCovers'), |
369 |
AllowMultipleCovers => C4::Context->preference('AllowMultipleCovers'), |
365 |
EnableBorrowerFiles => C4::Context->preference('EnableBorrowerFiles'), |
370 |
EnableBorrowerFiles => C4::Context->preference('EnableBorrowerFiles'), |
366 |
); |
371 |
); |
|
|
372 |
if ( C4::Context->preference('UsePrintQueues') ) { |
373 |
my $printer = get_user_printer(); |
374 |
my $printer_rec = $printer ? GetPrinterDetails($printer) : {}; |
375 |
$template->param( |
376 |
UsePrintQueues => 1, |
377 |
PrinterName => $printer_rec->{printername}, |
378 |
); |
379 |
} |
367 |
} |
380 |
} |
368 |
else { |
381 |
else { |
369 |
warn "template type should be OPAC, here it is=[" . $in->{'type'} . "]" unless ( $in->{'type'} eq 'opac' ); |
382 |
warn "template type should be OPAC, here it is=[" . $in->{'type'} . "]" unless ( $in->{'type'} eq 'opac' ); |
Lines 382-389
sub get_template_and_user {
Link Here
|
382 |
my $opac_name = ''; |
395 |
my $opac_name = ''; |
383 |
if (($opac_search_limit =~ /branch:(\w+)/ && $opac_limit_override) || $in->{'query'}->param('limit') =~ /branch:(\w+)/){ |
396 |
if (($opac_search_limit =~ /branch:(\w+)/ && $opac_limit_override) || $in->{'query'}->param('limit') =~ /branch:(\w+)/){ |
384 |
$opac_name = $1; # opac_search_limit is a branch, so we use it. |
397 |
$opac_name = $1; # opac_search_limit is a branch, so we use it. |
385 |
} elsif (C4::Context->preference("SearchMyLibraryFirst") && C4::Context->userenv && C4::Context->userenv->{'branch'}) { |
398 |
} elsif (C4::Context->preference("SearchMyLibraryFirst") && $userenv_branch) { |
386 |
$opac_name = C4::Context->userenv->{'branch'}; |
399 |
$opac_name = $userenv_branch |
387 |
} |
400 |
} |
388 |
$template->param( |
401 |
$template->param( |
389 |
opaccolorstylesheet => C4::Context->preference("opaccolorstylesheet"), |
402 |
opaccolorstylesheet => C4::Context->preference("opaccolorstylesheet"), |
Lines 393-399
sub get_template_and_user {
Link Here
|
393 |
CalendarFirstDayOfWeek => (C4::Context->preference("CalendarFirstDayOfWeek") eq "Sunday")?0:1, |
406 |
CalendarFirstDayOfWeek => (C4::Context->preference("CalendarFirstDayOfWeek") eq "Sunday")?0:1, |
394 |
LibraryName => "" . C4::Context->preference("LibraryName"), |
407 |
LibraryName => "" . C4::Context->preference("LibraryName"), |
395 |
LibraryNameTitle => "" . $LibraryNameTitle, |
408 |
LibraryNameTitle => "" . $LibraryNameTitle, |
396 |
LoginBranchname => C4::Context->userenv?C4::Context->userenv->{"branchname"}:"", |
409 |
LoginBranchname => $userenv?$userenv->{"branchname"}:"", |
397 |
OPACAmazonCoverImages => C4::Context->preference("OPACAmazonCoverImages"), |
410 |
OPACAmazonCoverImages => C4::Context->preference("OPACAmazonCoverImages"), |
398 |
OPACFRBRizeEditions => C4::Context->preference("OPACFRBRizeEditions"), |
411 |
OPACFRBRizeEditions => C4::Context->preference("OPACFRBRizeEditions"), |
399 |
OpacHighlightedWords => C4::Context->preference("OpacHighlightedWords"), |
412 |
OpacHighlightedWords => C4::Context->preference("OpacHighlightedWords"), |
Lines 424-430
sub get_template_and_user {
Link Here
|
424 |
RequestOnOpac => C4::Context->preference("RequestOnOpac"), |
437 |
RequestOnOpac => C4::Context->preference("RequestOnOpac"), |
425 |
'Version' => C4::Context->preference('Version'), |
438 |
'Version' => C4::Context->preference('Version'), |
426 |
hidelostitems => C4::Context->preference("hidelostitems"), |
439 |
hidelostitems => C4::Context->preference("hidelostitems"), |
427 |
mylibraryfirst => (C4::Context->preference("SearchMyLibraryFirst") && C4::Context->userenv) ? C4::Context->userenv->{'branch'} : '', |
440 |
mylibraryfirst => (C4::Context->preference("SearchMyLibraryFirst") && $userenv) ? $userenv_branch : '', |
428 |
opaclayoutstylesheet => "" . C4::Context->preference("opaclayoutstylesheet"), |
441 |
opaclayoutstylesheet => "" . C4::Context->preference("opaclayoutstylesheet"), |
429 |
opacbookbag => "" . C4::Context->preference("opacbookbag"), |
442 |
opacbookbag => "" . C4::Context->preference("opacbookbag"), |
430 |
opaccredits => "" . C4::Context->preference("opaccredits"), |
443 |
opaccredits => "" . C4::Context->preference("opaccredits"), |
Lines 1644-1651
sub getborrowernumber {
Link Here
|
1644 |
return 0; |
1657 |
return 0; |
1645 |
} |
1658 |
} |
1646 |
|
1659 |
|
|
|
1660 |
=head2 get_user_printer |
1661 |
|
1662 |
$printer = get_user_printer(); |
1663 |
|
1664 |
Returns printer queue that is to be used for the logged in user |
1665 |
|
1666 |
=cut |
1667 |
|
1668 |
sub get_user_printer { |
1669 |
my $userenv = C4::Context->userenv or return; |
1670 |
if (my $printer = $userenv->{branchprinter}) { |
1671 |
return $printer; |
1672 |
} |
1673 |
my $branchname = $userenv->{branch} or return; |
1674 |
my $branch = GetBranchDetail($branchname) or return; |
1675 |
return $branch->{branchprinter}; |
1676 |
} |
1647 |
|
1677 |
|
1648 |
END { } # module clean-up code here (global destructor) |
|
|
1649 |
1; |
1678 |
1; |
1650 |
__END__ |
1679 |
__END__ |
1651 |
|
1680 |
|