From b9a8342843dcf4b4234eb418c2135c2c9d3b2561 Mon Sep 17 00:00:00 2001 From: doxulting Date: Wed, 23 Mar 2005 09:25:20 +0000 Subject: [PATCH] New param for the template in order to show only allowed links to user (In parameters screen only right now) --- C4/Auth.pm | 64 +++++++++++++++++++++++++++++++++++++++++++- C4/Auth_with_ldap.pm | 64 +++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 126 insertions(+), 2 deletions(-) diff --git a/C4/Auth.pm b/C4/Auth.pm index 18925d0d35..86fec56d08 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -121,11 +121,73 @@ sub get_template_and_user { $template->param(sessionID => $sessionID); $borrowernumber = getborrowernumber($user); - my ($borr, $flags) = getpatroninformation(undef, $borrowernumber); + my ($borr, $alternativeflags) = getpatroninformation(undef, $borrowernumber); my @bordat; $bordat[0] = $borr; $template->param(USER_INFO => \@bordat, ); + + # We are going to use the $flags returned by checkauth + # to create the template's parameters that will indicate + # which menus the user can access. + if ($flags->{superlibrarian} == 1) + { + $template->param(CAN_user_circulate => 1); + $template->param(CAN_user_catalogue => 1); + $template->param(CAN_user_parameters => 1); + $template->param(CAN_user_borrowers => 1); + $template->param(CAN_user_permission => 1); + $template->param(CAN_user_reserveforothers => 1); + $template->param(CAN_user_borrow => 1); + $template->param(CAN_user_reserveforself => 1); + $template->param(CAN_user_editcatalogue => 1); + $template->param(CAN_user_updatecharge => 1); + $template->param(CAN_user_acquisition => 1); + $template->param(CAN_user_management => 1); + $template->param(CAN_user_tools => 1); } + + if ($flags->{circulate} == 1) { + $template->param(CAN_user_circulate => 1); } + + if ($flags->{catalogue} == 1) { + $template->param(CAN_user_catalogue => 1); } + + if ($flags->{parameters} == 1) { + $template->param(CAN_user_parameters => 1); + $template->param(CAN_user_management => 1); + $template->param(CAN_user_tools => 1); } + + if ($flags->{borrowers} == 1) { + $template->param(CAN_user_borrowers => 1); } + + if ($flags->{permissions} == 1) { + $template->param(CAN_user_permission => 1); } + + if ($flags->{reserveforothers} == 1) { + $template->param(CAN_user_reserveforothers => 1); } + + if ($flags->{borrow} == 1) { + $template->param(CAN_user_borrow => 1); } + + if ($flags->{reserveforself} == 1) { + $template->param(CAN_user_reserveforself => 1); } + + if ($flags->{editcatalogue} == 1) { + $template->param(CAN_user_editcatalogue => 1); } + + if ($flags->{updatecharges} == 1) { + $template->param(CAN_user_updatecharge => 1); } + + if ($flags->{acquisition} == 1) { + $template->param(CAN_user_acquisition => 1); } + + if ($flags->{management} == 1) { + $template->param(CAN_user_management => 1); + $template->param(CAN_user_tools => 1); } + + if ($flags->{tools} == 1) { + $template->param(CAN_user_tools => 1); } + } $template->param( LibraryName => C4::Context->preference("LibraryName"), diff --git a/C4/Auth_with_ldap.pm b/C4/Auth_with_ldap.pm index aaa5376039..685494ac5a 100644 --- a/C4/Auth_with_ldap.pm +++ b/C4/Auth_with_ldap.pm @@ -132,11 +132,73 @@ sub get_template_and_user { $template->param(sessionID => $sessionID); $borrowernumber = getborrowernumber($user); - my ($borr, $flags) = getpatroninformation(undef, $borrowernumber); + my ($borr, $alternativeflags) = getpatroninformation(undef, $borrowernumber); my @bordat; $bordat[0] = $borr; $template->param(USER_INFO => \@bordat, ); + + # We are going to use the $flags returned by checkauth + # to create the template's parameters that will indicate + # which menus the user can access. + if ($flags->{superlibrarian} == 1) + { + $template->param(CAN_user_circulate => 1); + $template->param(CAN_user_catalogue => 1); + $template->param(CAN_user_parameters => 1); + $template->param(CAN_user_borrowers => 1); + $template->param(CAN_user_permission => 1); + $template->param(CAN_user_reserveforothers => 1); + $template->param(CAN_user_borrow => 1); + $template->param(CAN_user_reserveforself => 1); + $template->param(CAN_user_editcatalogue => 1); + $template->param(CAN_user_updatecharge => 1); + $template->param(CAN_user_acquisition => 1); + $template->param(CAN_user_management => 1); + $template->param(CAN_user_tools => 1); } + + if ($flags->{circulate} == 1) { + $template->param(CAN_user_circulate => 1); } + + if ($flags->{catalogue} == 1) { + $template->param(CAN_user_catalogue => 1); } + + if ($flags->{parameters} == 1) { + $template->param(CAN_user_parameters => 1); + $template->param(CAN_user_management => 1); + $template->param(CAN_user_tools => 1); } + + if ($flags->{borrowers} == 1) { + $template->param(CAN_user_borrowers => 1); } + + if ($flags->{permissions} == 1) { + $template->param(CAN_user_permission => 1); } + + if ($flags->{reserveforothers} == 1) { + $template->param(CAN_user_reserveforothers => 1); } + + if ($flags->{borrow} == 1) { + $template->param(CAN_user_borrow => 1); } + + if ($flags->{reserveforself} == 1) { + $template->param(CAN_user_reserveforself => 1); } + + if ($flags->{editcatalogue} == 1) { + $template->param(CAN_user_editcatalogue => 1); } + + if ($flags->{updatecharges} == 1) { + $template->param(CAN_user_updatecharge => 1); } + + if ($flags->{acquisition} == 1) { + $template->param(CAN_user_acquisition => 1); } + + if ($flags->{management} == 1) { + $template->param(CAN_user_management => 1); + $template->param(CAN_user_tools => 1); } + + if ($flags->{tools} == 1) { + $template->param(CAN_user_tools => 1); } + } $template->param( LibraryName => C4::Context->preference("LibraryName"), -- 2.39.5