Lines 26-31
use CGI::Session;
Link Here
|
26 |
|
26 |
|
27 |
require Exporter; |
27 |
require Exporter; |
28 |
use C4::Context; |
28 |
use C4::Context; |
|
|
29 |
use C4::Koha; |
29 |
use C4::Templates; # to get the template |
30 |
use C4::Templates; # to get the template |
30 |
use C4::Branch; # GetBranches |
31 |
use C4::Branch; # GetBranches |
31 |
use C4::VirtualShelves; |
32 |
use C4::VirtualShelves; |
Lines 45-51
BEGIN {
Link Here
|
45 |
$debug = $ENV{DEBUG}; |
46 |
$debug = $ENV{DEBUG}; |
46 |
@ISA = qw(Exporter); |
47 |
@ISA = qw(Exporter); |
47 |
@EXPORT = qw(&checkauth &get_template_and_user &haspermission &get_user_subpermissions); |
48 |
@EXPORT = qw(&checkauth &get_template_and_user &haspermission &get_user_subpermissions); |
48 |
@EXPORT_OK = qw(&check_api_auth &get_session &check_cookie_auth &checkpw &get_all_subpermissions &get_user_subpermissions); |
49 |
@EXPORT_OK = qw(&check_api_auth &get_session &check_cookie_auth &checkpw |
|
|
50 |
&get_all_subpermissions &get_user_subpermissions &get_user_printer); |
49 |
%EXPORT_TAGS = ( EditPermissions => [qw(get_all_subpermissions get_user_subpermissions)] ); |
51 |
%EXPORT_TAGS = ( EditPermissions => [qw(get_all_subpermissions get_user_subpermissions)] ); |
50 |
$ldap = C4::Context->config('useldapserver') || 0; |
52 |
$ldap = C4::Context->config('useldapserver') || 0; |
51 |
$cas = C4::Context->preference('casAuthentication'); |
53 |
$cas = C4::Context->preference('casAuthentication'); |
Lines 309-314
sub get_template_and_user {
Link Here
|
309 |
$template->param(dateformat_iso => 1); |
311 |
$template->param(dateformat_iso => 1); |
310 |
} |
312 |
} |
311 |
|
313 |
|
|
|
314 |
my $userenv = C4::Context->userenv; |
315 |
my $userenv_branch = $userenv ? $userenv->{"branch"} : undef; |
316 |
|
312 |
# these template parameters are set the same regardless of $in->{'type'} |
317 |
# these template parameters are set the same regardless of $in->{'type'} |
313 |
$template->param( |
318 |
$template->param( |
314 |
"BiblioDefaultView".C4::Context->preference("BiblioDefaultView") => 1, |
319 |
"BiblioDefaultView".C4::Context->preference("BiblioDefaultView") => 1, |
Lines 316-324
sub get_template_and_user {
Link Here
|
316 |
GoogleJackets => C4::Context->preference("GoogleJackets"), |
321 |
GoogleJackets => C4::Context->preference("GoogleJackets"), |
317 |
OpenLibraryCovers => C4::Context->preference("OpenLibraryCovers"), |
322 |
OpenLibraryCovers => C4::Context->preference("OpenLibraryCovers"), |
318 |
KohaAdminEmailAddress => "" . C4::Context->preference("KohaAdminEmailAddress"), |
323 |
KohaAdminEmailAddress => "" . C4::Context->preference("KohaAdminEmailAddress"), |
319 |
LoginBranchcode => (C4::Context->userenv?C4::Context->userenv->{"branch"}:"insecure"), |
324 |
LoginBranchcode => ($userenv?$userenv_branch:"insecure"), |
320 |
LoginFirstname => (C4::Context->userenv?C4::Context->userenv->{"firstname"}:"Bel"), |
325 |
LoginFirstname => ($userenv?$userenv->{"firstname"}:"Bel"), |
321 |
LoginSurname => C4::Context->userenv?C4::Context->userenv->{"surname"}:"Inconnu", |
326 |
LoginSurname => $userenv?$userenv->{"surname"}:"Inconnu", |
322 |
TagsEnabled => C4::Context->preference("TagsEnabled"), |
327 |
TagsEnabled => C4::Context->preference("TagsEnabled"), |
323 |
hide_marc => C4::Context->preference("hide_marc"), |
328 |
hide_marc => C4::Context->preference("hide_marc"), |
324 |
item_level_itypes => C4::Context->preference('item-level_itypes'), |
329 |
item_level_itypes => C4::Context->preference('item-level_itypes'), |
Lines 345-351
sub get_template_and_user {
Link Here
|
345 |
IntranetNav => C4::Context->preference("IntranetNav"), |
350 |
IntranetNav => C4::Context->preference("IntranetNav"), |
346 |
IntranetmainUserblock => C4::Context->preference("IntranetmainUserblock"), |
351 |
IntranetmainUserblock => C4::Context->preference("IntranetmainUserblock"), |
347 |
LibraryName => C4::Context->preference("LibraryName"), |
352 |
LibraryName => C4::Context->preference("LibraryName"), |
348 |
LoginBranchname => (C4::Context->userenv?C4::Context->userenv->{"branchname"}:"insecure"), |
353 |
LoginBranchname => ($userenv?$userenv->{"branchname"}:"insecure"), |
349 |
advancedMARCEditor => C4::Context->preference("advancedMARCEditor"), |
354 |
advancedMARCEditor => C4::Context->preference("advancedMARCEditor"), |
350 |
canreservefromotherbranches => C4::Context->preference('canreservefromotherbranches'), |
355 |
canreservefromotherbranches => C4::Context->preference('canreservefromotherbranches'), |
351 |
intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"), |
356 |
intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"), |
Lines 364-369
sub get_template_and_user {
Link Here
|
364 |
OPACLocalCoverImages => C4::Context->preference('OPACLocalCoverImages'), |
369 |
OPACLocalCoverImages => C4::Context->preference('OPACLocalCoverImages'), |
365 |
AllowMultipleCovers => C4::Context->preference('AllowMultipleCovers'), |
370 |
AllowMultipleCovers => C4::Context->preference('AllowMultipleCovers'), |
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 |
my $checkstyle = C4::Context->preference("opaccolorstylesheet"); |
401 |
my $checkstyle = C4::Context->preference("opaccolorstylesheet"); |
389 |
if ($checkstyle =~ /http/) |
402 |
if ($checkstyle =~ /http/) |
Lines 402-408
sub get_template_and_user {
Link Here
|
402 |
CalendarFirstDayOfWeek => (C4::Context->preference("CalendarFirstDayOfWeek") eq "Sunday")?0:1, |
415 |
CalendarFirstDayOfWeek => (C4::Context->preference("CalendarFirstDayOfWeek") eq "Sunday")?0:1, |
403 |
LibraryName => "" . C4::Context->preference("LibraryName"), |
416 |
LibraryName => "" . C4::Context->preference("LibraryName"), |
404 |
LibraryNameTitle => "" . $LibraryNameTitle, |
417 |
LibraryNameTitle => "" . $LibraryNameTitle, |
405 |
LoginBranchname => C4::Context->userenv?C4::Context->userenv->{"branchname"}:"", |
418 |
LoginBranchname => $userenv?$userenv->{"branchname"}:"", |
406 |
OPACAmazonEnabled => C4::Context->preference("OPACAmazonEnabled"), |
419 |
OPACAmazonEnabled => C4::Context->preference("OPACAmazonEnabled"), |
407 |
OPACAmazonSimilarItems => C4::Context->preference("OPACAmazonSimilarItems"), |
420 |
OPACAmazonSimilarItems => C4::Context->preference("OPACAmazonSimilarItems"), |
408 |
OPACAmazonCoverImages => C4::Context->preference("OPACAmazonCoverImages"), |
421 |
OPACAmazonCoverImages => C4::Context->preference("OPACAmazonCoverImages"), |
Lines 435-441
sub get_template_and_user {
Link Here
|
435 |
RequestOnOpac => C4::Context->preference("RequestOnOpac"), |
448 |
RequestOnOpac => C4::Context->preference("RequestOnOpac"), |
436 |
'Version' => C4::Context->preference('Version'), |
449 |
'Version' => C4::Context->preference('Version'), |
437 |
hidelostitems => C4::Context->preference("hidelostitems"), |
450 |
hidelostitems => C4::Context->preference("hidelostitems"), |
438 |
mylibraryfirst => (C4::Context->preference("SearchMyLibraryFirst") && C4::Context->userenv) ? C4::Context->userenv->{'branch'} : '', |
451 |
mylibraryfirst => (C4::Context->preference("SearchMyLibraryFirst") && $userenv) ? $userenv_branch : '', |
439 |
opaclayoutstylesheet => "" . C4::Context->preference("opaclayoutstylesheet"), |
452 |
opaclayoutstylesheet => "" . C4::Context->preference("opaclayoutstylesheet"), |
440 |
opacstylesheet => "" . C4::Context->preference("opacstylesheet"), |
453 |
opacstylesheet => "" . C4::Context->preference("opacstylesheet"), |
441 |
opacbookbag => "" . C4::Context->preference("opacbookbag"), |
454 |
opacbookbag => "" . C4::Context->preference("opacbookbag"), |
Lines 1664-1671
sub getborrowernumber {
Link Here
|
1664 |
return 0; |
1677 |
return 0; |
1665 |
} |
1678 |
} |
1666 |
|
1679 |
|
|
|
1680 |
=head2 get_user_printer |
1681 |
|
1682 |
$printer = get_user_printer(); |
1683 |
|
1684 |
Returns printer queue that is to be used for the logged in user |
1685 |
|
1686 |
=cut |
1687 |
|
1688 |
sub get_user_printer { |
1689 |
my $userenv = C4::Context->userenv or return; |
1690 |
if (my $printer = $userenv->{branchprinter}) { |
1691 |
return $printer; |
1692 |
} |
1693 |
my $branchname = $userenv->{branch} or return; |
1694 |
my $branch = GetBranchDetail($branchname) or return; |
1695 |
return $branch->{branchprinter}; |
1696 |
} |
1667 |
|
1697 |
|
1668 |
END { } # module clean-up code here (global destructor) |
|
|
1669 |
1; |
1698 |
1; |
1670 |
__END__ |
1699 |
__END__ |
1671 |
|
1700 |
|