Bugzilla – Attachment 13288 Details for
Bug 7805
Exposing the new list permissions in opac and staff
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
PATCH] [3.8.x] 7805 Exposing the new list permissions in opac and staff
patch.txt (text/plain), 15.23 KB, created by
Marcel de Rooy
on 2012-11-07 16:00:59 UTC
(
hide
)
Description:
PATCH] [3.8.x] 7805 Exposing the new list permissions in opac and staff
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2012-11-07 16:00:59 UTC
Size:
15.23 KB
patch
obsolete
>From a5cbaa47dff7ac13730a347bc6a2ab6be6b49e7f Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Thu, 22 Mar 2012 11:59:01 +0100 >Subject: [PATCH] 7805 Exposing the new list permissions in opac and staff >Content-Type: text/plain; charset="utf-8" > >This report builds on 7310. >Had to correct some lines in ModShelf and AddShelf as well in order to save 0 values correctly for the permission columns. >--- > C4/VirtualShelves.pm | 41 ++++++++++---------- > C4/VirtualShelves/Page.pm | 21 ++++++++-- > .../prog/en/modules/virtualshelves/shelves.tt | 39 ++++++++++++++++++- > .../opac-tmpl/prog/en/modules/opac-shelves.tt | 30 ++++++++++++++ > 4 files changed, 104 insertions(+), 27 deletions(-) > >diff --git a/C4/VirtualShelves.pm b/C4/VirtualShelves.pm >index 1a594f8..fa32f4b 100644 >--- a/C4/VirtualShelves.pm >+++ b/C4/VirtualShelves.pm >@@ -215,19 +215,17 @@ sub GetSomeShelfNames { > > =head2 GetShelf > >- (shelfnumber,shelfname,owner,category,sortfield) = &GetShelf($shelfnumber); >+ (shelfnumber,shelfname,owner,category,sortfield,allow_add,allow_delete_own,allow_delete_other) = &GetShelf($shelfnumber); > >-Looks up information about the contents of virtual virtualshelves number >-C<$shelfnumber> >- >-Returns the database's information on 'virtualshelves' table. >+Returns the above-mentioned fields for passed virtual shelf number. > > =cut > > sub GetShelf ($) { > my ($shelfnumber) = @_; > my $query = qq( >- SELECT shelfnumber, shelfname, owner, category, sortfield >+ SELECT shelfnumber, shelfname, owner, category, sortfield, >+ allow_add, allow_delete_own, allow_delete_other > FROM virtualshelves > WHERE shelfnumber=? > ); >@@ -311,7 +309,7 @@ sub AddShelf { > > #initialize missing hash values to silence warnings > foreach('shelfname','category', 'sortfield', 'allow_add', 'allow_delete_own', 'allow_delete_other' ) { >- $hashref->{$_}= exists $hashref->{$_}? $hashref->{$_}||'': ''; >+ $hashref->{$_}= undef unless exists $hashref->{$_}; > } > > return -1 unless _CheckShelfName($hashref->{shelfname}, $hashref->{category}, $owner, 0); >@@ -326,9 +324,9 @@ sub AddShelf { > $owner, > $hashref->{category}, > $hashref->{sortfield}, >- $hashref->{allow_add}||0, >- $hashref->{allow_delete_own}||1, >- $hashref->{allow_delete_other}||0 ); >+ $hashref->{allow_add}//0, >+ $hashref->{allow_delete_own}//1, >+ $hashref->{allow_delete_other}//0 ); > my $shelfnumber = $dbh->{'mysql_insertid'}; > return $shelfnumber; > } >@@ -393,16 +391,17 @@ sub ModShelf { > > #initialize missing hash values to silence warnings > foreach('shelfname','category', 'sortfield', 'allow_add', 'allow_delete_own', 'allow_delete_other' ) { >- $hashref->{$_}= exists $hashref->{$_}? $hashref->{$_}||'': ''; >+ $hashref->{$_}= undef unless exists $hashref->{$_}; > } > > #if name or category changes, the name should be tested > if($hashref->{shelfname} || $hashref->{category}) { > unless(_CheckShelfName( >- $hashref->{shelfname}||$oldrecord->{shelfname}, >- $hashref->{category}||$oldrecord->{category}, >- $oldrecord->{owner}, $shelfnumber )) { >- return 0; #name check failed >+ $hashref->{shelfname}//$oldrecord->{shelfname}, >+ $hashref->{category}//$oldrecord->{category}, >+ $oldrecord->{owner}, >+ $shelfnumber )) { >+ return 0; #name check failed > } > } > >@@ -410,12 +409,12 @@ sub ModShelf { > $query= "UPDATE virtualshelves SET shelfname=?, category=?, sortfield=?, allow_add=?, allow_delete_own=?, allow_delete_other=? WHERE shelfnumber=?"; > $sth = $dbh->prepare($query); > $sth->execute( >- $hashref->{shelfname}||$oldrecord->{shelfname}, >- $hashref->{category}||$oldrecord->{category}, >- $hashref->{sortfield}||$oldrecord->{sortfield}, >- $hashref->{allow_add}||$oldrecord->{allow_add}, >- $hashref->{allow_delete_own}||$oldrecord->{allow_delete_own}, >- $hashref->{allow_delete_other}||$oldrecord->{allow_delete_other}, >+ $hashref->{shelfname}//$oldrecord->{shelfname}, >+ $hashref->{category}//$oldrecord->{category}, >+ $hashref->{sortfield}//$oldrecord->{sortfield}, >+ $hashref->{allow_add}//$oldrecord->{allow_add}, >+ $hashref->{allow_delete_own}//$oldrecord->{allow_delete_own}, >+ $hashref->{allow_delete_other}//$oldrecord->{allow_delete_other}, > $shelfnumber ); > return $@? 0: 1; > } >diff --git a/C4/VirtualShelves/Page.pm b/C4/VirtualShelves/Page.pm >index fddcfa4..a30c443 100644 >--- a/C4/VirtualShelves/Page.pm >+++ b/C4/VirtualShelves/Page.pm >@@ -185,8 +185,11 @@ sub shelfpage { > last SWITCH; > } > my $shelf = { >- 'shelfname' => $query->param('shelfname'), >- 'sortfield' => $query->param('sortfield'), >+ shelfname => $query->param('shelfname'), >+ sortfield => $query->param('sortfield'), >+ allow_add => $query->param('allow_add'), >+ allow_delete_own => $query->param('allow_delete_own'), >+ allow_delete_other => $query->param('allow_delete_other'), > }; > if($query->param('category')) { #optional > $shelf->{category}= $query->param('category'); >@@ -207,7 +210,7 @@ sub shelfpage { > } > #Editing a shelf > elsif ( $op eq 'modif' ) { >- my ( $shelfnumber2, $shelfname, $owner, $category, $sortfield ) = GetShelf($shelfnumber); >+ my ( $shelfnumber2, $shelfname, $owner, $category, $sortfield, $allow_add, $allow_delete_own, $allow_delete_other) = GetShelf($shelfnumber); > my $member = GetMember( 'borrowernumber' => $owner ); > my $ownername = defined($member) ? $member->{firstname} . " " . $member->{surname} : ''; > $edit = 1; >@@ -222,6 +225,9 @@ sub shelfpage { > "category$category" => 1, > category => $category, > "sort_$sortfield" => 1, >+ allow_add => $allow_add, >+ allow_delete_own => $allow_delete_own, >+ allow_delete_other => $allow_delete_other, > ); > } > last SWITCH; >@@ -322,7 +328,11 @@ sub shelfpage { > my $shelfnumber = AddShelf( { > shelfname => $newshelf, > sortfield => $query->param('sortfield'), >- category => $query->param('category') }, >+ category => $query->param('category'), >+ allow_add => $query->param('allow_add'), >+ allow_delete_own => $query->param('allow_delete_own'), >+ allow_delete_other => $query->param('allow_delete_other'), >+ }, > $query->param('owner') ); > $stay = 1; > if ( $shelfnumber == -1 ) { #shelf already exists. >@@ -454,6 +464,9 @@ sub shelfpage { > $edit > ) { > $template->param( seflag => 1 ); >+ #This hack is just another argument for refactoring this script one day >+ #At this point you are adding or editing a list; if you add, then you add a private list (by default) with permissions as below; if you edit, do not pass these permissions, they must come from the database >+ $template->param( allow_add => 0, allow_delete_own => 1, allow_delete_other => 0) unless $shelfnumber; > } > > #Next call updates the shelves for the Lists button. >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt >index 650be11..0a9521d 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt >@@ -115,6 +115,32 @@ function placeHold () { > [% INCLUDE 'header.inc' %] > [% INCLUDE 'cat-search.inc' %] > >+[% BLOCK list_permissions %] >+ <li> >+ <label for="permissions">Permissions: </label> >+ <select name="allow_add" id="allow_add"> >+ [% IF allow_add %]<option value="0">Do not allow</option>[% ELSE %]<option value="0" selected="selected">Do not allow</option>[% END %] >+ [% IF allow_add %]<option value="1" selected="selected">Allow</option>[% ELSE %]<option value="1">Allow</option>[% END %] >+ </select> >+ <span>anyone else to add entries.</span> >+ </li> >+ <li> >+ <label> </label> >+ <select name="allow_delete_own" id="allow_delete_own"> >+ [% IF allow_delete_own %]<option value="0">Do not allow</option>[% ELSE %]<option value="0" selected="selected">Do not allow</option>[% END %] >+ [% IF allow_delete_own %]<option value="1" selected="selected">Allow</option>[% ELSE %]<option value="1">Allow</option>[% END %] >+ </select> >+ <span>anyone to remove his own contributed entries.</span> >+ </li> >+ <li> >+ <label> </label> >+ <select name="allow_delete_other" id="allow_delete_other"> >+ [% IF allow_delete_other %]<option value="0">Do not allow</option>[% ELSE %]<option value="0" selected="selected">Do not allow</option>[% END %] >+ [% IF allow_delete_other %]<option value="1" selected="selected">Allow</option>[% ELSE %]<option value="1">Allow</option>[% END %] >+ </select> >+ <span>anyone to remove other contributed entries.</span> >+ </li> >+[% END %] > <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/virtualshelves/shelves.pl">Lists</a> [% IF ( category1 ) %] › [% IF ( viewshelf || edit ) %] <a href="/cgi-bin/koha/virtualshelves/shelves.pl?display=privateshelves">Your lists</a> [% ELSE %] Your lists [% END %] [% ELSIF ( category2 ) %] › [% IF ( viewshelf ) %] <a href="/cgi-bin/koha/virtualshelves/shelves.pl?display=publicshelves">Public lists</a> [% ELSE %] Public lists [% END %] [% ELSIF ( showprivateshelves ) %] › [% IF ( viewshelf || edit ) %] <a href="/cgi-bin/koha/virtualshelves/shelves.pl?display=privateshelves">Your lists</a> [% ELSE %] Your lists [% END %] [% ELSIF ( showpublicshelves ) %] › [% IF ( viewshelf || edit ) %] <a href="/cgi-bin/koha/virtualshelves/shelves.pl?display=publicshelves">Public lists</a> [% ELSE %] Public lists [% END %] [% END %] > > [% IF ( viewshelf ) %]› Contents of <i>[% shelfname | html %]</i>[% END %][% IF ( shelves ) %] › Create new list[% END %][% IF ( edit ) %] › Edit list <i>[% shelfname | html %]</i>[% END %]</div> >@@ -153,6 +179,9 @@ function placeHold () { > [% IF ( paramsloo.somedeleted) %] > <div class="dialog message">Warning: You could not delete all selected items from this shelf.</div> > [% END %] >+ [% IF ( paramsloo.modifyfailure) %] >+ <div class="dialog message">ERROR: List could not be modified.</div> >+ [% END %] > </div> > </div> > [% END %] >@@ -275,7 +304,9 @@ function placeHold () { > <select name="category" id="category"> > <option value="1">Private</option> > <option value="2">Public</option> >- </select></li></ol> >+ </select></li> >+ [% INCLUDE list_permissions %] >+ </ol> > [% END %] > > [% IF ( edit ) %] >@@ -304,7 +335,9 @@ function placeHold () { > [% ELSE %] > <option value="2">Public</option> > [% END %] >- </select></li></ol> >+ </select></li> >+ [% INCLUDE list_permissions %] >+ </ol> > [% END %] > > </fieldset> >@@ -317,6 +350,8 @@ function placeHold () { > <div class="help"><ul> > <li>A <b>Private</b> list is managed by you and can be seen only by you.</li> > <li> A <b>Public</b> list can be seen by everybody, but managed only by you.</li> >+ <br/> >+ <li>The owner of a list is always allowed to add entries, but needs permission to remove.</li> > </ul> > </div> > </div> >diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-shelves.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-shelves.tt >index b6a2954..716f2e1 100644 >--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-shelves.tt >+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-shelves.tt >@@ -170,6 +170,34 @@ $(function() { > </script> > </head> > [% IF ( loggedinusername ) %]<body id="opac-userlists">[% ELSE %]<body id="opac-lists">[% END %] >+ >+[% BLOCK list_permissions %] >+ <li> >+ <label for="permissions">Permissions: </label> >+ <select name="allow_add" id="allow_add"> >+ [% IF allow_add %]<option value="0">Do not allow</option>[% ELSE %]<option value="0" selected="selected">Do not allow</option>[% END %] >+ [% IF allow_add %]<option value="1" selected="selected">Allow</option>[% ELSE %]<option value="1">Allow</option>[% END %] >+ </select> >+ <span>anyone else to add entries. (The owner of a list is always allowed to add entries, but needs permission to remove.)</span> >+ </li> >+ <li> >+ <label> </label> >+ <select name="allow_delete_own" id="allow_delete_own"> >+ [% IF allow_delete_own %]<option value="0">Do not allow</option>[% ELSE %]<option value="0" selected="selected">Do not allow</option>[% END %] >+ [% IF allow_delete_own %]<option value="1" selected="selected">Allow</option>[% ELSE %]<option value="1">Allow</option>[% END %] >+ </select> >+ <span>anyone to remove his own contributed entries.</span> >+ </li> >+ <li> >+ <label> </label> >+ <select name="allow_delete_other" id="allow_delete_other"> >+ [% IF allow_delete_other %]<option value="0">Do not allow</option>[% ELSE %]<option value="0" selected="selected">Do not allow</option>[% END %] >+ [% IF allow_delete_other %]<option value="1" selected="selected">Allow</option>[% ELSE %]<option value="1">Allow</option>[% END %] >+ </select> >+ <span>anyone to remove other contributed entries.</span> >+ </li> >+[% END %] >+ > [% IF ( OpacNav ) %]<div id="doc3" class="yui-t1">[% ELSIF ( loggedinusername ) %]<div id="doc3" class="yui-t1">[% ELSE %]<div id="doc3" class="yui-t7">[% END %] > <div id="bd"> > [% INCLUDE 'masthead.inc' %] >@@ -445,6 +473,7 @@ $(function() { > </select> > [% END %] > </li> >+ [% INCLUDE list_permissions %] > </ol> > </fieldset> > <fieldset class="action"><input type="submit" value="Save" class="submit" /> [% IF ( showprivateshelves ) %]<a class="cancel" href="/cgi-bin/koha/opac-shelves.pl?shelfnumber=[% shelfnumber %]&display=privateshelves">Cancel</a>[% ELSE %]<a class="cancel" href="/cgi-bin/koha/opac-shelves.pl?shelfnumber=[% shelfnumber %]">Cancel</a>[% END %]</fieldset> >@@ -633,6 +662,7 @@ $(function() { > [% END %] > </select> > </li> >+ [% INCLUDE list_permissions %] > </ol> > </fieldset> > <fieldset class="action"> >-- >1.7.7.6 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 7805
:
8529
|
9387
|
9805
|
10274
|
11417
| 13288 |
13289