From 3ce9301cca58f6e5b7c3f514536be3baa5689b96 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Wed, 15 May 2013 11:04:07 -0400 Subject: [PATCH] Bug 10277 - Add C4::Context->IsSuperLibrarian() The method of checking the logged in user for superlibrarian privileges is obtuse ( $userenv && $userenv->{flags} % 2 != 1 ) to say the least. The codebase is littered with these lines, with no explanation given. It would be much better if we had one subroutine that returned a boolean value to tell us if the logged in user is a superlibrarian or not. --- C4/Context.pm | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-) diff --git a/C4/Context.pm b/C4/Context.pm index 7709f7e..db0d498 100644 --- a/C4/Context.pm +++ b/C4/Context.pm @@ -1228,6 +1228,20 @@ sub tz { } +=head2 IsSuperLibrarian + + C4::Context->IsSuperlibrarian(); + +=cut + +sub IsSuperLibrarian { + if ( C4::Context->userenv ) { + return C4::Context->userenv->{flags} % 2 == 1; + } + else { + confess("C4::Context->userenv not defined!"); + } +} 1; __END__ -- 1.7.2.5