From 25eb36f21fe952118327d2c84dfef5d38eee31a7 Mon Sep 17 00:00:00 2001 From: Allen Reinmeyer Date: Mon, 17 Nov 2008 15:10:27 -0600 Subject: [PATCH] Bug #2531 Cannot delete private shelf Added logic to create a list of private lists to check on deletion. Multiple pages have the ability to delete lists, both private and public. Default option of retrieving a user's lists is retrieving the public ones. Now private lists of the owner are retrieved as well and checked upon deletion request. This allows any method of deletion to delete the correct list without examining the myriad of options currently used to indicate display of privateshelves and expect all pages to know whether a shelf number comes from a private or public list. Since deletion occurs based on shelf number and the virtualshelves table has a primary key on shelf number, this will not cause unwanted deletion of shelves. UPDATE: added logic for conditional creation of shelves. Also note change in staff side as deletions worked except for viewing a populated shelf, then deleting. The confirm message showed, but the display was of public shelves, not private. Signed-off-by: Galen Charlton --- C4/VirtualShelves/Page.pm | 29 +++++++++++++++---- .../en/includes/virtualshelves-toolbar.inc | 2 +- .../en/modules/virtualshelves/shelves.tmpl | 5 ++-- .../prog/en/modules/opac-shelves.tmpl | 8 +++-- 4 files changed, 33 insertions(+), 11 deletions(-) diff --git a/C4/VirtualShelves/Page.pm b/C4/VirtualShelves/Page.pm index bcfd3af810..8e45029e31 100644 --- a/C4/VirtualShelves/Page.pm +++ b/C4/VirtualShelves/Page.pm @@ -72,6 +72,11 @@ sub shelfpage ($$$$$) { # getting the Shelves list my $category = (($displaymode eq 'privateshelves') ? 1 : 2); my ($shelflist, $totshelves) = GetShelves( $category, $shelveslimit, $shelvesoffset, $loggedinuser ); + #Get a list of private shelves for possible deletion. Only do this when we've defaulted to public shelves + my ($privshelflist, $privtotshelves); + if ($category == 2) { + ($privshelflist, $privtotshelves) = GetShelves( 1, $shelveslimit, $shelvesoffset, $loggedinuser ); + } my $op = $query->param('op'); # my $imgdir = getitemtypeimagesrc(); # my $itemtypes = GetItemTypes(); @@ -173,6 +178,7 @@ SWITCH: { #$this_item->{'description'} = $itemtypes->{ $this_item->{itemtype} }->{'description'}; $this_item->{'dateadded'} = format_date($this_item->{'dateadded'}); } + push @paramsloop, {display => 'privateshelves'} if $category == 1; $showadd = 1; my $i = 0; foreach (grep {$i++ % 2} @$items) { # every other item @@ -180,7 +186,7 @@ SWITCH: { } my $manageshelf = ShelfPossibleAction( $loggedinuser, $shelfnumber, 'manage' ); $template->param( - shelfname => $shelflist->{$shelfnumber}->{'shelfname'}, + shelfname => $shelflist->{$shelfnumber}->{'shelfname'} || $privshelflist->{$shelfnumber}->{'shelfname'}, shelfnumber => $shelfnumber, viewshelf => $shelfnumber, manageshelf => $manageshelf, @@ -213,7 +219,7 @@ SWITCH: { /DEL-(\d+)/ or next; $delflag = 1; my $number = $1; - unless (defined $shelflist->{$number}) { + unless (defined $shelflist->{$number} || defined $privshelflist->{$number}) { push(@paramsloop, {unrecognized=>$number}); last; } unless (ShelfPossibleAction($loggedinuser, $number, 'manage')) { @@ -223,17 +229,28 @@ SWITCH: { ($contents, $totshelves) = GetShelfContents($number, $shelveslimit, $shelvesoffset); if (my $count = scalar @$contents){ unless (scalar grep {/^CONFIRM-$number$/} $query->param()) { - push(@paramsloop, {need_confirm=>$shelflist->{$number}->{shelfname}, count=>$count}); - $shelflist->{$number}->{confirm} = $number; + if (defined $shelflist->{$number}) { + push(@paramsloop, {need_confirm=>$shelflist->{$number}->{shelfname}, count=>$count}); + $shelflist->{$number}->{confirm} = $number; + } else { + push(@paramsloop, {need_confirm=>$privshelflist->{$number}->{shelfname}, count=>$count}); + $privshelflist->{$number}->{confirm} = $number; + } $stay = 0; next; } } - my $name = $shelflist->{$number}->{'shelfname'}; + my $name; + if (defined $shelflist->{$number}) { + $name = $shelflist->{$number}->{'shelfname'}; + delete $shelflist->{$number}; + } else { + $name = $privshelflist->{$number}->{'shelfname'}; + delete $privshelflist->{$number}; + } unless (DelShelf($number)) { push(@paramsloop, {delete_fail=>$name}); last; } - delete $shelflist->{$number}; push(@paramsloop, {delete_ok=>$name}); # print $query->redirect($pages{$type}->{redirect}); exit; $stay = 0; diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/virtualshelves-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/virtualshelves-toolbar.inc index 32b2de5624..6910770d84 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/virtualshelves-toolbar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/virtualshelves-toolbar.inc @@ -30,7 +30,7 @@
  • New List
  • &op=modif">Edit List
  • -
  • =1">Delete List
  • +
  • display=privateshelves&shelves=1&DEL-=1">Delete List
  • 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 e9e9bfa743..aa86b9a678 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tmpl +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tmpl @@ -21,7 +21,7 @@ $(document).ready(function(){ function confirmDelete(message){ if (window.confirm(message)) { - location.href="/cgi-bin/koha/virtualshelves/shelves.pl?shelves=1&DEL-=1"; + location.href="/cgi-bin/koha/virtualshelves/shelves.pl?display=privateshelves&shelves=1&DEL-=1"; } else { return false; } @@ -299,7 +299,7 @@ $(document).ready(function(){ List NameContentsSort byTypeOptions - "> + display=privateshelves&viewshelf="> item(s) Private @@ -315,6 +315,7 @@ $(document).ready(function(){
    + " value="1" /> " value="1" /> diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-shelves.tmpl b/koha-tmpl/opac-tmpl/prog/en/modules/opac-shelves.tmpl index 87fba62f8c..00051706cf 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-shelves.tmpl +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-shelves.tmpl @@ -91,6 +91,9 @@ $.tablesorter.addParser({
    | &op=modif">Edit List + + + "/>
    @@ -207,7 +210,7 @@ $.tablesorter.addParser({ List NameContentsSort byType  - "> + "> item(s) Private @@ -218,13 +221,14 @@ $.tablesorter.addParser({
    " /> +
    - " value="1" /> + " value="1" /> " value="1" /> -- 2.39.5