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 348-354
sub get_template_and_user {
Link Here
|
348 |
IntranetNav => C4::Context->preference("IntranetNav"), |
353 |
IntranetNav => C4::Context->preference("IntranetNav"), |
349 |
IntranetmainUserblock => C4::Context->preference("IntranetmainUserblock"), |
354 |
IntranetmainUserblock => C4::Context->preference("IntranetmainUserblock"), |
350 |
LibraryName => C4::Context->preference("LibraryName"), |
355 |
LibraryName => C4::Context->preference("LibraryName"), |
351 |
LoginBranchname => (C4::Context->userenv?C4::Context->userenv->{"branchname"}:"insecure"), |
356 |
LoginBranchname => ($userenv?$userenv->{"branchname"}:"insecure"), |
352 |
advancedMARCEditor => C4::Context->preference("advancedMARCEditor"), |
357 |
advancedMARCEditor => C4::Context->preference("advancedMARCEditor"), |
353 |
canreservefromotherbranches => C4::Context->preference('canreservefromotherbranches'), |
358 |
canreservefromotherbranches => C4::Context->preference('canreservefromotherbranches'), |
354 |
intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"), |
359 |
intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"), |
Lines 368-373
sub get_template_and_user {
Link Here
|
368 |
AllowMultipleCovers => C4::Context->preference('AllowMultipleCovers'), |
373 |
AllowMultipleCovers => C4::Context->preference('AllowMultipleCovers'), |
369 |
EnableBorrowerFiles => C4::Context->preference('EnableBorrowerFiles'), |
374 |
EnableBorrowerFiles => C4::Context->preference('EnableBorrowerFiles'), |
370 |
); |
375 |
); |
|
|
376 |
if ( C4::Context->preference('UsePrintQueues') ) { |
377 |
my $printer = get_user_printer(); |
378 |
my $printer_rec = $printer ? GetPrinterDetails($printer) : {}; |
379 |
$template->param( |
380 |
UsePrintQueues => 1, |
381 |
PrinterName => $printer_rec->{printername}, |
382 |
); |
383 |
} |
371 |
} |
384 |
} |
372 |
else { |
385 |
else { |
373 |
warn "template type should be OPAC, here it is=[" . $in->{'type'} . "]" unless ( $in->{'type'} eq 'opac' ); |
386 |
warn "template type should be OPAC, here it is=[" . $in->{'type'} . "]" unless ( $in->{'type'} eq 'opac' ); |
Lines 386-393
sub get_template_and_user {
Link Here
|
386 |
my $opac_name = ''; |
399 |
my $opac_name = ''; |
387 |
if (($opac_search_limit =~ /branch:(\w+)/ && $opac_limit_override) || $in->{'query'}->param('limit') =~ /branch:(\w+)/){ |
400 |
if (($opac_search_limit =~ /branch:(\w+)/ && $opac_limit_override) || $in->{'query'}->param('limit') =~ /branch:(\w+)/){ |
388 |
$opac_name = $1; # opac_search_limit is a branch, so we use it. |
401 |
$opac_name = $1; # opac_search_limit is a branch, so we use it. |
389 |
} elsif (C4::Context->preference("SearchMyLibraryFirst") && C4::Context->userenv && C4::Context->userenv->{'branch'}) { |
402 |
} elsif (C4::Context->preference("SearchMyLibraryFirst") && $userenv_branch) { |
390 |
$opac_name = C4::Context->userenv->{'branch'}; |
403 |
$opac_name = $userenv_branch |
391 |
} |
404 |
} |
392 |
my $checkstyle = C4::Context->preference("opaccolorstylesheet"); |
405 |
my $checkstyle = C4::Context->preference("opaccolorstylesheet"); |
393 |
if ($checkstyle =~ /http/) |
406 |
if ($checkstyle =~ /http/) |
Lines 407-413
sub get_template_and_user {
Link Here
|
407 |
CalendarFirstDayOfWeek => (C4::Context->preference("CalendarFirstDayOfWeek") eq "Sunday")?0:1, |
420 |
CalendarFirstDayOfWeek => (C4::Context->preference("CalendarFirstDayOfWeek") eq "Sunday")?0:1, |
408 |
LibraryName => "" . C4::Context->preference("LibraryName"), |
421 |
LibraryName => "" . C4::Context->preference("LibraryName"), |
409 |
LibraryNameTitle => "" . $LibraryNameTitle, |
422 |
LibraryNameTitle => "" . $LibraryNameTitle, |
410 |
LoginBranchname => C4::Context->userenv?C4::Context->userenv->{"branchname"}:"", |
423 |
LoginBranchname => $userenv?$userenv->{"branchname"}:"", |
411 |
OPACAmazonEnabled => C4::Context->preference("OPACAmazonEnabled"), |
424 |
OPACAmazonEnabled => C4::Context->preference("OPACAmazonEnabled"), |
412 |
OPACAmazonSimilarItems => C4::Context->preference("OPACAmazonSimilarItems"), |
425 |
OPACAmazonSimilarItems => C4::Context->preference("OPACAmazonSimilarItems"), |
413 |
OPACAmazonCoverImages => C4::Context->preference("OPACAmazonCoverImages"), |
426 |
OPACAmazonCoverImages => C4::Context->preference("OPACAmazonCoverImages"), |
Lines 441-447
sub get_template_and_user {
Link Here
|
441 |
RequestOnOpac => C4::Context->preference("RequestOnOpac"), |
454 |
RequestOnOpac => C4::Context->preference("RequestOnOpac"), |
442 |
'Version' => C4::Context->preference('Version'), |
455 |
'Version' => C4::Context->preference('Version'), |
443 |
hidelostitems => C4::Context->preference("hidelostitems"), |
456 |
hidelostitems => C4::Context->preference("hidelostitems"), |
444 |
mylibraryfirst => (C4::Context->preference("SearchMyLibraryFirst") && C4::Context->userenv) ? C4::Context->userenv->{'branch'} : '', |
457 |
mylibraryfirst => (C4::Context->preference("SearchMyLibraryFirst") && $userenv) ? $userenv_branch : '', |
445 |
opaclayoutstylesheet => "" . C4::Context->preference("opaclayoutstylesheet"), |
458 |
opaclayoutstylesheet => "" . C4::Context->preference("opaclayoutstylesheet"), |
446 |
opacstylesheet => "" . C4::Context->preference("opacstylesheet"), |
459 |
opacstylesheet => "" . C4::Context->preference("opacstylesheet"), |
447 |
opacbookbag => "" . C4::Context->preference("opacbookbag"), |
460 |
opacbookbag => "" . C4::Context->preference("opacbookbag"), |
Lines 1671-1678
sub getborrowernumber {
Link Here
|
1671 |
return 0; |
1684 |
return 0; |
1672 |
} |
1685 |
} |
1673 |
|
1686 |
|
|
|
1687 |
=head2 get_user_printer |
1688 |
|
1689 |
$printer = get_user_printer(); |
1690 |
|
1691 |
Returns printer queue that is to be used for the logged in user |
1692 |
|
1693 |
=cut |
1694 |
|
1695 |
sub get_user_printer { |
1696 |
my $userenv = C4::Context->userenv or return; |
1697 |
if (my $printer = $userenv->{branchprinter}) { |
1698 |
return $printer; |
1699 |
} |
1700 |
my $branchname = $userenv->{branch} or return; |
1701 |
my $branch = GetBranchDetail($branchname) or return; |
1702 |
return $branch->{branchprinter}; |
1703 |
} |
1674 |
|
1704 |
|
1675 |
END { } # module clean-up code here (global destructor) |
|
|
1676 |
1; |
1705 |
1; |
1677 |
__END__ |
1706 |
__END__ |
1678 |
|
1707 |
|