[Koha-patches] [PATCH] Allows superlibrians to delete any and all messages, reguardless of branchcode.

Kyle M Hall kyle.m.hall at gmail.com
Tue Sep 29 14:32:19 CEST 2009


From: PTFS <koha-dev at ptfs.com>

---
 C4/Auth.pm          |    2 +-
 C4/Members.pm       |   15 ++++++++++++++-
 circ/circulation.pl |    4 ++--
 3 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/C4/Auth.pm b/C4/Auth.pm
index afe5fbf..4578caa 100644
--- a/C4/Auth.pm
+++ b/C4/Auth.pm
@@ -157,7 +157,7 @@ sub get_template_and_user {
         }
 
         $borrowernumber = getborrowernumber($user);
-        my ( $borr ) = GetMemberDetails( $borrowernumber );
+        my ( $borr ) = C4::Members::GetMemberDetails( $borrowernumber );
         my @bordat;
         $bordat[0] = $borr;
         $template->param( "USER_INFO" => \@bordat );
diff --git a/C4/Members.pm b/C4/Members.pm
index 93aa9d3..8b1746f 100644
--- a/C4/Members.pm
+++ b/C4/Members.pm
@@ -2098,8 +2098,20 @@ Returns all messages for the given borrowernumber
 =cut
 
 sub GetMessages {
-    my ( $borrowernumber, $type, $branchcode ) = @_;
+    my ( $borrowernumber, $type ) = @_;
+
+    ## Check to see if the logged in librarian has superlibrarian privileges
+    my $query = new CGI;
+    my $sessionID = $query->cookie("CGISESSID") ;
+    my $session = C4::Auth::get_session($sessionID);
+    my $librarian_borrowernumber = $session->param('number');    
+    my $librarian = GetMember( $librarian_borrowernumber ) if ( $librarian_borrowernumber );
+    my $is_super = C4::Auth::haspermission( $librarian->{'userid'}, { 'superlibrarian' => 1 } ) if ( $librarian );
+    $is_super = $is_super->{'superlibrarian'} if ( $is_super );
+    
+    my $branchcode = $session->param('branch');
 
+    ## If no type is passed, get messages of all types.
     if ( ! $type ) {
       $type = '%';
     }
@@ -2121,6 +2133,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 d3dd236..59b7cd6 100755
--- a/circ/circulation.pl
+++ b/circ/circulation.pl
@@ -643,8 +643,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' ),
+    bor_messages_loop		=> GetMessages( $borrowernumber, 'B' ),
     all_messages_del		=> C4::Context->preference('AllowAllMessageDeletion'),
     findborrower                => $findborrower,
     borrower                    => $borrower,
-- 
1.5.6.5




More information about the Koha-patches mailing list