View | Details | Raw Unified | Return to bug 10389
Collapse All | Expand All

(-)a/C4/VirtualShelves.pm (-1 / +23 lines)
Lines 44-50 BEGIN { Link Here
44
            &ModShelf
44
            &ModShelf
45
            &ShelfPossibleAction
45
            &ShelfPossibleAction
46
            &DelFromShelf &DelShelf
46
            &DelFromShelf &DelShelf
47
            &GetBibliosShelves &AddShare &AcceptShare &IsSharedList
47
            &GetBibliosShelves
48
            &AddShare &AcceptShare &RemoveShare &IsSharedList
48
    );
49
    );
49
        @EXPORT_OK = qw(
50
        @EXPORT_OK = qw(
50
            &GetAllShelves &ShelvesMax
51
            &GetAllShelves &ShelvesMax
Lines 740-745 sub IsSharedList { Link Here
740
    return defined($rv);
741
    return defined($rv);
741
}
742
}
742
743
744
=head2 RemoveShare
745
746
     RemoveShare( $user, $shelfnumber );
747
748
RemoveShare removes a share for specific shelf and borrower.
749
Returns true if a record could be deleted.
750
751
=cut
752
753
sub RemoveShare {
754
    my ($user, $shelfnumber)= @_;
755
    my $dbh = C4::Context->dbh;
756
    my $sql="
757
DELETE FROM virtualshelfshares
758
WHERE borrowernumber=? AND shelfnumber=?
759
    ";
760
    my $n= $dbh->do($sql,undef,($user, $shelfnumber));
761
    return if !defined($n) || !$n || $n eq '0E0'; #nothing removed
762
    return 1;
763
}
764
743
# internal subs
765
# internal subs
744
766
745
sub _shelf_count {
767
sub _shelf_count {
(-)a/C4/VirtualShelves/Page.pm (-2 / +11 lines)
Lines 360-372 sub shelfpage { Link Here
360
360
361
        #Deleting a shelf (asking for confirmation if it has entries)
361
        #Deleting a shelf (asking for confirmation if it has entries)
362
            foreach ( $query->param() ) {
362
            foreach ( $query->param() ) {
363
                /DEL-(\d+)/ or next;
363
                /(DEL|REMSHR)-(\d+)/ or next;
364
                $delflag = 1;
364
                $delflag = 1;
365
                my $number = $1;
365
                my $number = $2;
366
                unless ( defined $shelflist->{$number} || defined $privshelflist->{$number} ) {
366
                unless ( defined $shelflist->{$number} || defined $privshelflist->{$number} ) {
367
                    push( @paramsloop, { unrecognized => $number } );
367
                    push( @paramsloop, { unrecognized => $number } );
368
                    last;
368
                    last;
369
                }
369
                }
370
                #remove a share
371
                if(/REMSHR/) {
372
                    RemoveShare($loggedinuser, $number);
373
                    delete $shelflist->{$number} if exists $shelflist->{$number};
374
                    delete $privshelflist->{$number} if exists $privshelflist->{$number};
375
                    $stay=0;
376
                    next;
377
                }
378
                #
370
                unless ( ShelfPossibleAction( $loggedinuser, $number, 'manage' ) ) {
379
                unless ( ShelfPossibleAction( $loggedinuser, $number, 'manage' ) ) {
371
                    push( @paramsloop, { nopermission => $shelfnumber } );
380
                    push( @paramsloop, { nopermission => $shelfnumber } );
372
                    last;
381
                    last;
(-)a/koha-tmpl/opac-tmpl/prog/en/modules/opac-shelves.tt (+18 lines)
Lines 8-13 Link Here
8
//<![CDATA[
8
//<![CDATA[
9
var MSG_REMOVE_FROM_LIST = _("Are you sure you want to remove these items from the list?");
9
var MSG_REMOVE_FROM_LIST = _("Are you sure you want to remove these items from the list?");
10
var MSG_CONFIRM_DELETE_LIST = _("Are you sure you want to delete this list?");
10
var MSG_CONFIRM_DELETE_LIST = _("Are you sure you want to delete this list?");
11
var MSG_CONFIRM_REMOVE_SHARE = _("Are you sure you want to remove this share?");
11
12
12
[% IF ( opacuserlogin ) %][% IF ( RequestOnOpac ) %]
13
[% IF ( opacuserlogin ) %][% IF ( RequestOnOpac ) %]
13
function holdSelections() {
14
function holdSelections() {
Lines 225-230 $(document).ready(function() { Link Here
225
    </li>
226
    </li>
226
[% END %]
227
[% END %]
227
228
229
[%# When using the next block, add the parameter for shelfnumber and add a tag to end the form %]
230
[% BLOCK remove_share %]
231
    <form action="opac-shelves.pl" method="post">
232
        <input type="hidden" name="shelves" value="1" />
233
        <input type="hidden" name="display" value="privateshelves" />
234
        <input type="hidden" name="shelfoff" value="[% shelfoff %]" />
235
        <input type="submit" class="removeshare" onclick="return confirmDelete(MSG_CONFIRM_REMOVE_SHARE);" value="Remove share" />
236
[% END %]
237
228
[% IF ( OpacNav ) %]<div id="doc3" class="yui-t1">[% ELSIF ( loggedinusername ) %]<div id="doc3" class="yui-t1">[% ELSE %]<div id="doc3" class="yui-t7">[% END %]
238
[% IF ( OpacNav ) %]<div id="doc3" class="yui-t1">[% ELSIF ( loggedinusername ) %]<div id="doc3" class="yui-t1">[% ELSE %]<div id="doc3" class="yui-t7">[% END %]
229
    <div id="bd">
239
    <div id="bd">
230
      [% INCLUDE 'masthead.inc' %]
240
      [% INCLUDE 'masthead.inc' %]
Lines 357-362 $(document).ready(function() { Link Here
357
                            <input type="submit" class="Share" value="Share" />
367
                            <input type="submit" class="Share" value="Share" />
358
                        </form>
368
                        </form>
359
                    [% END %]
369
                    [% END %]
370
                [% ELSIF showprivateshelves %]
371
                    [% INCLUDE remove_share %]
372
                    <input type="hidden" name="REMSHR-[% shelfnumber %]" value="1" />
373
                    </form>
360
                [% END %]
374
                [% END %]
361
375
362
376
Lines 645-650 $(document).ready(function() { Link Here
645
                                  <input type="submit" class="Share" value="Share" />
659
                                  <input type="submit" class="Share" value="Share" />
646
                                </form>
660
                                </form>
647
                              [% END %]
661
                              [% END %]
662
                            [% ELSIF shelveslooppri.shares %]
663
                                [% INCLUDE remove_share %]
664
                                <input type="hidden" name="REMSHR-[% shelveslooppri.shelf %]" value="1" />
665
                                </form>
648
                            [% END %]&nbsp;
666
                            [% END %]&nbsp;
649
                            </td>
667
                            </td>
650
                          </tr>
668
                          </tr>
(-)a/t/db_dependent/VirtualShelves.t (-2 / +12 lines)
Lines 5-11 Link Here
5
# Larger modifications by Jonathan Druart and Marcel de Rooy
5
# Larger modifications by Jonathan Druart and Marcel de Rooy
6
6
7
use Modern::Perl;
7
use Modern::Perl;
8
use Test::More tests => 95;
8
use Test::More tests => 96;
9
use MARC::Record;
9
use MARC::Record;
10
10
11
use C4::Biblio qw( AddBiblio DelBiblio );
11
use C4::Biblio qw( AddBiblio DelBiblio );
Lines 229-234 for my $i (0..9) { Link Here
229
    is(IsSharedList($sh),$n? 1: '', "Checked IsSharedList for shelf $sh");
229
    is(IsSharedList($sh),$n? 1: '', "Checked IsSharedList for shelf $sh");
230
}
230
}
231
231
232
#----------------------- TEST RemoveShare -------------------------------------#
233
234
my $remshr_test="select borrowernumber, shelfnumber from virtualshelfshares where borrowernumber is not null";
235
my @remshr_shelf= $dbh->selectrow_array($remshr_test);
236
if(@remshr_shelf) {
237
    is(RemoveShare(@remshr_shelf),1,'Removed a shelf share');
238
}
239
else {
240
    ok(1,'Skipped RemoveShare test');
241
}
242
232
#----------------TEST DelShelf & DelFromShelf functions------------------------#
243
#----------------TEST DelShelf & DelFromShelf functions------------------------#
233
244
234
for my $i (0..9){
245
for my $i (0..9){
235
- 

Return to bug 10389