From: Chris Nighswonger <[EMAIL PROTECTED]>

Edit functions here are limited to renaming and changing the type. No one can 
view
a list except the list owner unless it is public.

Signed-off-by: Galen Charlton <[EMAIL PROTECTED]>
---
 C4/VirtualShelves.pm                               |    5 ++++-
 C4/VirtualShelves/Page.pm                          |    6 ++++--
 .../prog/en/modules/virtualshelves/shelves.tmpl    |    2 +-
 3 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/C4/VirtualShelves.pm b/C4/VirtualShelves.pm
index c4a5754..e5c8adc 100644
--- a/C4/VirtualShelves.pm
+++ b/C4/VirtualShelves.pm
@@ -26,6 +26,7 @@ use Carp;
 use C4::Context;
 use C4::Circulation;
 use C4::Debug;
+use C4::Members;
 
 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
 
@@ -413,9 +414,11 @@ sub ShelfPossibleAction {
     my $sth = $dbh->prepare($query);
     $sth->execute($shelfnumber);
     my ( $owner, $category ) = $sth->fetchrow;
-    return 1 if ( $category >= 3);                                             
        # open list
+       my $borrower = GetMemberDetails($user);
+       return 1 if ( $category >= 3);                                          
        # open list
     return 1 if (($category >= 2) and
                                defined($action) and $action eq 'view');        
# public list, anybody can view
+    return 1 if (($category >= 2) and defined($user) and 
$borrower->{authflags}->{superlibrarian});    # public list, superlibrarian can 
edit/delete
     return 1 if (defined($user)  and $owner  eq $user );       # user owns 
this list.  Check last.
     return 0;
 }
diff --git a/C4/VirtualShelves/Page.pm b/C4/VirtualShelves/Page.pm
index 17d9c55..af85ed5 100755
--- a/C4/VirtualShelves/Page.pm
+++ b/C4/VirtualShelves/Page.pm
@@ -125,18 +125,20 @@ SWITCH: {
                                'category'              => 
$query->param('category'),
                                'sortfield'             => 
$query->param('sortfield'),
                        };
-                       $shelf->{'owner'} = $loggedinuser if $type eq 
'intranet';       #we only overwrite the list owner if &ModShelf was called 
from the staff client
 
                        ModShelf( $shelfnumber, $shelf );
-                       $shelflist = GetShelves( $loggedinuser, 2 );    # 
refresh after mods
+                       $shelflist = GetShelves( $loggedinuser, 2 );    # 
refresh after mods; this also retrieves all public shelves
                
                } elsif ( $op eq 'modif' ) {
                        my ( $shelfnumber2, $shelfname, $owner, $category, 
$sortfield ) =GetShelf( $shelfnumber );
+                       my $member = GetMember($owner,'borrowernumber');
+                       my $ownername = defined($member) ? $member->{firstname} 
. " " . $member->{surname} : '';
                        $template->param(
                                edit                => 1,
                                shelfnumber         => $shelfnumber2,
                                shelfname           => $shelfname,
                                owner               => $owner,
+                               ownername                       => $ownername,
                                "category$category"     => 1,
                                category                        => $category,
                                "sort_$sortfield"   => 1,
diff --git 
a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tmpl 
b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tmpl
index 6fa5541..03180cc 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tmpl
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tmpl
@@ -224,7 +224,7 @@ $(document).ready(function(){
                <legend>Edit List <i><!-- TMPL_VAR name="shelfname" 
--></i></legend>
                <ol>
                <li><label for="shelfname">Name: </label><input type="text" 
id="shelfname" name="shelfname" size="25" value='<!-- TMPL_VAR name="shelfname" 
ESCAPE="HTML" -->' /></li>
-               <li><label for="owner">Owner: </label><input type="hidden" 
id="owner" name="owner" value="<!-- TMPL_VAR NAME="loggedinuser" -->" /><!-- 
TMPL_VAR NAME="loggedinusername" --></li>
+               <li><label for="owner">Owner: </label><input type="hidden" 
id="owner" name="owner" value="<!-- TMPL_IF NAME="owner" --><!-- TMPL_VAR 
NAME="ownername" --><!-- TMPL_ELSE --><!-- TMPL_VAR NAME="loggedinusername" 
--><!-- /TMPL_IF -->" /><!-- TMPL_IF NAME="owner" --><!-- TMPL_VAR 
NAME="ownername" --><!-- TMPL_ELSE --><!-- TMPL_VAR NAME="loggedinusername" 
--><!-- /TMPL_IF --></li>
                <li><label for="category">Category: </label>
                        <select id="category" name="category">
                        <!-- TMPL_IF name="category1" -->
-- 
1.5.5.GIT

_______________________________________________
Koha-patches mailing list
[email protected]
http://lists.koha.org/mailman/listinfo/koha-patches

Reply via email to