Bugzilla – Attachment 20038 Details for
Bug 10389
Share a list (part 2: accept the invitation)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 10389: Remove an accepted share
Bug-10389-Remove-an-accepted-share.patch (text/plain), 7.06 KB, created by
Marcel de Rooy
on 2013-08-01 13:07:00 UTC
(
hide
)
Description:
Bug 10389: Remove an accepted share
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2013-08-01 13:07:00 UTC
Size:
7.06 KB
patch
obsolete
>From 8fa15d59a1e4b48e7f0af1bb43587123859ddcde Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Thu, 1 Aug 2013 13:56:21 +0200 >Subject: [PATCH] Bug 10389: Remove an accepted share >Content-Type: text/plain; charset=utf-8 > >If a user accepted a share, this patch allows him to remove it again. >A new routine is added to VirtualShelves.pm. >The Remove Share button is visible on OPAC when viewing Your lists or >a particular shared list. > >Test plan: >User 1 creates private list P3, sends a share. >User 1 creates private list P4, adds one item, sends a share. >User 2 accepts the share for P3. >User 2 checks the shelves display, and removes share P3. >User 2 accepts the share for P4. >User 2 views shelf P4 with one item and confirms Remove share on that form. >User 2 checks shelves display again. > >Run the adjusted test unit too. Did all 96 tests pass? > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > C4/VirtualShelves.pm | 24 +++++++++++++++++++- > C4/VirtualShelves/Page.pm | 13 +++++++++- > .../opac-tmpl/prog/en/modules/opac-shelves.tt | 18 +++++++++++++++ > t/db_dependent/VirtualShelves.t | 13 ++++++++++- > 4 files changed, 64 insertions(+), 4 deletions(-) > >diff --git a/C4/VirtualShelves.pm b/C4/VirtualShelves.pm >index 4531564..f8afc58 100644 >--- a/C4/VirtualShelves.pm >+++ b/C4/VirtualShelves.pm >@@ -44,7 +44,8 @@ BEGIN { > &ModShelf > &ShelfPossibleAction > &DelFromShelf &DelShelf >- &GetBibliosShelves &AddShare &AcceptShare &IsSharedList >+ &GetBibliosShelves >+ &AddShare &AcceptShare &RemoveShare &IsSharedList > ); > @EXPORT_OK = qw( > &GetAllShelves &ShelvesMax >@@ -740,6 +741,27 @@ sub IsSharedList { > return defined($rv); > } > >+=head2 RemoveShare >+ >+ RemoveShare( $user, $shelfnumber ); >+ >+RemoveShare removes a share for specific shelf and borrower. >+Returns true if a record could be deleted. >+ >+=cut >+ >+sub RemoveShare { >+ my ($user, $shelfnumber)= @_; >+ my $dbh = C4::Context->dbh; >+ my $sql=" >+DELETE FROM virtualshelfshares >+WHERE borrowernumber=? AND shelfnumber=? >+ "; >+ my $n= $dbh->do($sql,undef,($user, $shelfnumber)); >+ return if !defined($n) || !$n || $n eq '0E0'; #nothing removed >+ return 1; >+} >+ > # internal subs > > sub _shelf_count { >diff --git a/C4/VirtualShelves/Page.pm b/C4/VirtualShelves/Page.pm >index b2bd238..efaf69b 100644 >--- a/C4/VirtualShelves/Page.pm >+++ b/C4/VirtualShelves/Page.pm >@@ -360,13 +360,22 @@ sub shelfpage { > > #Deleting a shelf (asking for confirmation if it has entries) > foreach ( $query->param() ) { >- /DEL-(\d+)/ or next; >+ /(DEL|REMSHR)-(\d+)/ or next; > $delflag = 1; >- my $number = $1; >+ my $number = $2; > unless ( defined $shelflist->{$number} || defined $privshelflist->{$number} ) { > push( @paramsloop, { unrecognized => $number } ); > last; > } >+ #remove a share >+ if(/REMSHR/) { >+ RemoveShare($loggedinuser, $number); >+ delete $shelflist->{$number} if exists $shelflist->{$number}; >+ delete $privshelflist->{$number} if exists $privshelflist->{$number}; >+ $stay=0; >+ next; >+ } >+ # > unless ( ShelfPossibleAction( $loggedinuser, $number, 'manage' ) ) { > push( @paramsloop, { nopermission => $shelfnumber } ); > last; >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 b429717..4c77b9f 100644 >--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-shelves.tt >+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-shelves.tt >@@ -8,6 +8,7 @@ > //<![CDATA[ > var MSG_REMOVE_FROM_LIST = _("Are you sure you want to remove these items from the list?"); > var MSG_CONFIRM_DELETE_LIST = _("Are you sure you want to delete this list?"); >+var MSG_CONFIRM_REMOVE_SHARE = _("Are you sure you want to remove this share?"); > > [% IF ( opacuserlogin ) %][% IF ( RequestOnOpac ) %] > function holdSelections() { >@@ -225,6 +226,15 @@ $(document).ready(function() { > </li> > [% END %] > >+[%# When using the next block, add the parameter for shelfnumber and add a tag to end the form %] >+[% BLOCK remove_share %] >+ <form action="opac-shelves.pl" method="post"> >+ <input type="hidden" name="shelves" value="1" /> >+ <input type="hidden" name="display" value="privateshelves" /> >+ <input type="hidden" name="shelfoff" value="[% shelfoff %]" /> >+ <input type="submit" class="removeshare" onclick="return confirmDelete(MSG_CONFIRM_REMOVE_SHARE);" value="Remove share" /> >+[% 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' %] >@@ -357,6 +367,10 @@ $(document).ready(function() { > <input type="submit" class="Share" value="Share" /> > </form> > [% END %] >+ [% ELSIF showprivateshelves %] >+ [% INCLUDE remove_share %] >+ <input type="hidden" name="REMSHR-[% shelfnumber %]" value="1" /> >+ </form> > [% END %] > > >@@ -645,6 +659,10 @@ $(document).ready(function() { > <input type="submit" class="Share" value="Share" /> > </form> > [% END %] >+ [% ELSIF shelveslooppri.shares %] >+ [% INCLUDE remove_share %] >+ <input type="hidden" name="REMSHR-[% shelveslooppri.shelf %]" value="1" /> >+ </form> > [% END %] > </td> > </tr> >diff --git a/t/db_dependent/VirtualShelves.t b/t/db_dependent/VirtualShelves.t >index 27bfd34..42f451a 100755 >--- a/t/db_dependent/VirtualShelves.t >+++ b/t/db_dependent/VirtualShelves.t >@@ -5,7 +5,7 @@ > # Larger modifications by Jonathan Druart and Marcel de Rooy > > use Modern::Perl; >-use Test::More tests => 95; >+use Test::More tests => 96; > use MARC::Record; > > use C4::Biblio qw( AddBiblio DelBiblio ); >@@ -229,6 +229,17 @@ for my $i (0..9) { > is(IsSharedList($sh),$n? 1: '', "Checked IsSharedList for shelf $sh"); > } > >+#----------------------- TEST RemoveShare -------------------------------------# >+ >+my $remshr_test="select borrowernumber, shelfnumber from virtualshelfshares where borrowernumber is not null"; >+my @remshr_shelf= $dbh->selectrow_array($remshr_test); >+if(@remshr_shelf) { >+ is(RemoveShare(@remshr_shelf),1,'Removed a shelf share'); >+} >+else { >+ ok(1,'Skipped RemoveShare test'); >+} >+ > #----------------TEST DelShelf & DelFromShelf functions------------------------# > > for my $i (0..9){ >-- >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 10389
:
19602
|
20033
|
20034
|
20038