[Koha-patches] [PATCH] Bug # 3472 - Allows superlibrians to delete any and all messages, reguardless of branchcode.
Michael Hafen
mdhafen at tech.washk12.org
Mon Sep 28 18:17:58 CEST 2009
Perhaps you could get $loggedinuser from the session rather than passing
it through the function call? I know it can be a pain what with all the
module circular dependencies. Have you tried it anyway?
On Mon, 2009-09-28 at 08:48 -0400, Kyle M Hall wrote:
> ---
> C4/Members.pm | 11 +++++++++--
> circ/circulation.pl | 4 ++--
> 2 files changed, 11 insertions(+), 4 deletions(-)
>
> diff --git a/C4/Members.pm b/C4/Members.pm
> index 9ce2001..e9a8392 100644
> --- a/C4/Members.pm
> +++ b/C4/Members.pm
> @@ -2090,11 +2090,13 @@ sub AddMessage {
>
> =over 4
>
> -GetMessages( $borrowernumber, $type );
> +GetMessages( $borrowernumber, $type, $loggedinuser );
>
> $type is message type, B for borrower, or L for Librarian.
> Empty type returns all messages of any type.
>
> +$loggedinuser is the borrowernumber for the currently logged in librarian, if any.
> +
> Returns all messages for the given borrowernumber
>
> =back
> @@ -2102,7 +2104,11 @@ Returns all messages for the given borrowernumber
> =cut
>
> sub GetMessages {
> - my ( $borrowernumber, $type, $branchcode ) = @_;
> + my ( $borrowernumber, $type, $branchcode, $loggedinuser, ) = @_;
> +
> + my $librarian = GetMember( $loggedinuser ) if ( $loggedinuser );
> + my $is_super = C4::Auth::haspermission( $librarian->{'userid'}, { 'superlibrarian' => 1 } ) if ( $librarian );
> + $is_super = $is_super->{'superlibrarian'} if ( $is_super );
>
> if ( ! $type ) {
> $type = '%';
> @@ -2125,6 +2131,7 @@ sub GetMessages {
> my @results;
>
> while ( my $data = $sth->fetchrow_hashref ) {
> + $data->{'can_delete'} = 1 if ( $is_super );
> push @results, $data;
> }
> return \@results;
> diff --git a/circ/circulation.pl b/circ/circulation.pl
> index ca4b995..10cd975 100755
> --- a/circ/circulation.pl
> +++ b/circ/circulation.pl
> @@ -655,8 +655,8 @@ if ( C4::Context->preference("memberofinstitution") ) {
>
> $template->param(
> issued_itemtypes_count_loop => \@issued_itemtypes_count_loop,
> - lib_messages_loop => GetMessages( $borrowernumber, 'L', $branch ),
> - bor_messages_loop => GetMessages( $borrowernumber, 'B', $branch ),
> + lib_messages_loop => GetMessages( $borrowernumber, 'L', $branch, $loggedinuser ),
> + bor_messages_loop => GetMessages( $borrowernumber, 'B', $branch, $loggedinuser ),
> all_messages_del => C4::Context->preference('AllowAllMessageDeletion'),
> findborrower => $findborrower,
> borrower => $borrower,
--
Michael Hafen
Systems Analyst and Programmer
Washington County School District
Utah, USA
for Koha checkout
http://development.washk12.org/gitweb/
or
git://development.washk12.org/koha
More information about the Koha-patches
mailing list