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

(-)a/C4/VirtualShelves.pm (-87 / +87 lines)
Lines 36-53 use constant SHELVES_POPUP_MAX => 40; #addbybiblio popup Link Here
36
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
36
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
37
37
38
BEGIN {
38
BEGIN {
39
	# set the version for version checking
39
    # set the version for version checking
40
	$VERSION = 3.02;
40
    $VERSION = 3.02;
41
	require Exporter;
41
    require Exporter;
42
	@ISA    = qw(Exporter);
42
    @ISA    = qw(Exporter);
43
	@EXPORT = qw(
43
    @EXPORT = qw(
44
            &GetShelves &GetShelfContents &GetShelf
44
            &GetShelves &GetShelfContents &GetShelf
45
            &AddToShelf &AddShelf
45
            &AddToShelf &AddShelf
46
            &ModShelf
46
            &ModShelf
47
            &ShelfPossibleAction
47
            &ShelfPossibleAction
48
            &DelFromShelf &DelShelf
48
            &DelFromShelf &DelShelf
49
            &GetBibliosShelves
49
            &GetBibliosShelves
50
	);
50
    );
51
        @EXPORT_OK = qw(
51
        @EXPORT_OK = qw(
52
            &GetAllShelves &ShelvesMax
52
            &GetAllShelves &ShelvesMax
53
        );
53
        );
Lines 116-122 sub GetShelves { Link Here
116
        $query.= qq{
116
        $query.= qq{
117
            LEFT JOIN virtualshelfshares sh ON sh.shelfnumber=vs.shelfnumber
117
            LEFT JOIN virtualshelfshares sh ON sh.shelfnumber=vs.shelfnumber
118
            AND sh.borrowernumber=?
118
            AND sh.borrowernumber=?
119
	    WHERE category=1 AND (vs.owner=? OR sh.borrowernumber=?) };
119
        WHERE category=1 AND (vs.owner=? OR sh.borrowernumber=?) };
120
        @params= ($owner, $owner, $owner, $offset||0, $row_count);
120
        @params= ($owner, $owner, $owner, $offset||0, $row_count);
121
    }
121
    }
122
    else {
122
    else {
Lines 164-174 sub GetAllShelves { Link Here
164
        $query.= qq{
164
        $query.= qq{
165
            LEFT JOIN virtualshelfshares sh ON sh.shelfnumber=vs.shelfnumber
165
            LEFT JOIN virtualshelfshares sh ON sh.shelfnumber=vs.shelfnumber
166
            AND sh.borrowernumber=?
166
            AND sh.borrowernumber=?
167
	    WHERE category=1 AND (vs.owner=? OR sh.borrowernumber=?) };
167
        WHERE category=1 AND (vs.owner=? OR sh.borrowernumber=?) };
168
        @params = ($owner, $owner, $owner);
168
        @params = ($owner, $owner, $owner);
169
    }
169
    }
170
    else {
170
    else {
171
	$query.='WHERE category=2 ';
171
    $query.='WHERE category=2 ';
172
        @params = ();
172
        @params = ();
173
    }
173
    }
174
    $query.='AND (allow_add=1 OR owner=?) ' if $adding_allowed;
174
    $query.='AND (allow_add=1 OR owner=?) ' if $adding_allowed;
Lines 261-301 from C4::Circulation. Link Here
261
sub GetShelfContents ($;$$$) {
261
sub GetShelfContents ($;$$$) {
262
    my ($shelfnumber, $row_count, $offset, $sortfield) = @_;
262
    my ($shelfnumber, $row_count, $offset, $sortfield) = @_;
263
    my $dbh=C4::Context->dbh();
263
    my $dbh=C4::Context->dbh();
264
	my $sth1 = $dbh->prepare("SELECT count(*) FROM virtualshelfcontents WHERE shelfnumber = ?");
264
    my $sth1 = $dbh->prepare("SELECT count(*) FROM virtualshelfcontents WHERE shelfnumber = ?");
265
	$sth1->execute($shelfnumber);
265
    $sth1->execute($shelfnumber);
266
	my $total = $sth1->fetchrow;
266
    my $total = $sth1->fetchrow;
267
	if(!$sortfield) {
267
    if(!$sortfield) {
268
		my $sth2 = $dbh->prepare('SELECT sortfield FROM virtualshelves WHERE shelfnumber=?');
268
        my $sth2 = $dbh->prepare('SELECT sortfield FROM virtualshelves WHERE shelfnumber=?');
269
		$sth2->execute($shelfnumber);
269
        $sth2->execute($shelfnumber);
270
		($sortfield) = $sth2->fetchrow_array;
270
        ($sortfield) = $sth2->fetchrow_array;
271
	}
271
    }
272
    my $query =
272
    my $query =
273
       " SELECT vc.biblionumber, vc.shelfnumber, vc.dateadded, itemtypes.*,
273
       " SELECT vc.biblionumber, vc.shelfnumber, vc.dateadded, itemtypes.*,
274
            biblio.*, biblioitems.itemtype, biblioitems.publicationyear as year, biblioitems.publishercode, biblioitems.place, biblioitems.size, biblioitems.pages
274
            biblio.*, biblioitems.itemtype, biblioitems.publicationyear as year, biblioitems.publishercode, biblioitems.place, biblioitems.size, biblioitems.pages
275
         FROM   virtualshelfcontents vc
275
         FROM   virtualshelfcontents vc
276
		 LEFT JOIN biblio      ON      vc.biblionumber =      biblio.biblionumber
276
         LEFT JOIN biblio      ON      vc.biblionumber =      biblio.biblionumber
277
		 LEFT JOIN biblioitems ON  biblio.biblionumber = biblioitems.biblionumber
277
         LEFT JOIN biblioitems ON  biblio.biblionumber = biblioitems.biblionumber
278
		 LEFT JOIN itemtypes   ON biblioitems.itemtype = itemtypes.itemtype
278
         LEFT JOIN itemtypes   ON biblioitems.itemtype = itemtypes.itemtype
279
         WHERE  vc.shelfnumber=? ";
279
         WHERE  vc.shelfnumber=? ";
280
	my @params = ($shelfnumber);
280
    my @params = ($shelfnumber);
281
	if($sortfield) {
281
    if($sortfield) {
282
		$query .= " ORDER BY " . $sortfield;
282
        $query .= " ORDER BY " . $sortfield;
283
		$query .= " DESC " if ($sortfield eq 'copyrightdate');
283
        $query .= " DESC " if ($sortfield eq 'copyrightdate');
284
	}
284
    }
285
    if($row_count){
285
    if($row_count){
286
	   $query .= " LIMIT ?, ? ";
286
       $query .= " LIMIT ?, ? ";
287
	   push (@params, ($offset ? $offset : 0));
287
       push (@params, ($offset ? $offset : 0));
288
	   push (@params, $row_count);
288
       push (@params, $row_count);
289
    }
289
    }
290
    my $sth3 = $dbh->prepare($query);
290
    my $sth3 = $dbh->prepare($query);
291
	$sth3->execute(@params);
291
    $sth3->execute(@params);
292
	return ($sth3->fetchall_arrayref({}), $total);
292
    return ($sth3->fetchall_arrayref({}), $total);
293
	# Like the perldoc says,
293
    # Like the perldoc says,
294
	# returns reference-to-array, where each element is reference-to-hash of the row:
294
    # returns reference-to-array, where each element is reference-to-hash of the row:
295
	#   like [ $sth->fetchrow_hashref(), $sth->fetchrow_hashref() ... ] 
295
    #   like [ $sth->fetchrow_hashref(), $sth->fetchrow_hashref() ... ] 
296
	# Suitable for use in TMPL_LOOP.
296
    # Suitable for use in TMPL_LOOP.
297
	# See http://search.cpan.org/~timb/DBI-1.601/DBI.pm#fetchall_arrayref
297
    # See http://search.cpan.org/~timb/DBI-1.601/DBI.pm#fetchall_arrayref
298
	# or newer, for your version of DBI.
298
    # or newer, for your version of DBI.
299
}
299
}
300
300
301
=head2 AddShelf
301
=head2 AddShelf
Lines 326-338 sub AddShelf { Link Here
326
326
327
    my $sth = $dbh->prepare($query);
327
    my $sth = $dbh->prepare($query);
328
    $sth->execute(
328
    $sth->execute(
329
	$hashref->{shelfname},
329
    $hashref->{shelfname},
330
	$owner,
330
    $owner,
331
	$hashref->{category},
331
    $hashref->{category},
332
	$hashref->{sortfield},
332
    $hashref->{sortfield},
333
	$hashref->{allow_add}||0,
333
    $hashref->{allow_add}||0,
334
	$hashref->{allow_delete_own}||1,
334
    $hashref->{allow_delete_own}||1,
335
	$hashref->{allow_delete_other}||0 );
335
    $hashref->{allow_delete_other}||0 );
336
    my $shelfnumber = $dbh->{'mysql_insertid'};
336
    my $shelfnumber = $dbh->{'mysql_insertid'};
337
    return $shelfnumber;
337
    return $shelfnumber;
338
}
338
}
Lines 358-374 sub AddToShelf { Link Here
358
358
359
    $sth->execute( $shelfnumber, $biblionumber );
359
    $sth->execute( $shelfnumber, $biblionumber );
360
    ($sth->rows) and return undef;	# already on shelf
360
    ($sth->rows) and return undef;	# already on shelf
361
	$query = qq(
361
    $query = qq(
362
		INSERT INTO virtualshelfcontents
362
        INSERT INTO virtualshelfcontents
363
			(shelfnumber, biblionumber, flags, borrowernumber)
363
            (shelfnumber, biblionumber, flags, borrowernumber)
364
		VALUES (?, ?, 0, ?));
364
        VALUES (?, ?, 0, ?));
365
	$sth = $dbh->prepare($query);
365
    $sth = $dbh->prepare($query);
366
	$sth->execute( $shelfnumber, $biblionumber, $borrowernumber);
366
    $sth->execute( $shelfnumber, $biblionumber, $borrowernumber);
367
	$query = qq(UPDATE virtualshelves
367
    $query = qq(UPDATE virtualshelves
368
				SET lastmodified = CURRENT_TIMESTAMP
368
                SET lastmodified = CURRENT_TIMESTAMP
369
				WHERE shelfnumber = ?);
369
                WHERE shelfnumber = ?);
370
	$sth = $dbh->prepare($query);
370
    $sth = $dbh->prepare($query);
371
	$sth->execute( $shelfnumber );
371
    $sth->execute( $shelfnumber );
372
}
372
}
373
373
374
=head2 ModShelf
374
=head2 ModShelf
Lines 403-412 sub ModShelf { Link Here
403
    #if name or category changes, the name should be tested
403
    #if name or category changes, the name should be tested
404
    if($hashref->{shelfname} || $hashref->{category}) {
404
    if($hashref->{shelfname} || $hashref->{category}) {
405
        unless(_CheckShelfName(
405
        unless(_CheckShelfName(
406
	    $hashref->{shelfname}||$oldrecord->{shelfname},
406
        $hashref->{shelfname}||$oldrecord->{shelfname},
407
	    $hashref->{category}||$oldrecord->{category},
407
        $hashref->{category}||$oldrecord->{category},
408
	    $oldrecord->{owner}, $shelfnumber )) {
408
        $oldrecord->{owner}, $shelfnumber )) {
409
		return 0; #name check failed
409
        return 0; #name check failed
410
        }
410
        }
411
    }
411
    }
412
412
Lines 414-426 sub ModShelf { Link Here
414
    $query= "UPDATE virtualshelves SET shelfname=?, category=?, sortfield=?, allow_add=?, allow_delete_own=?, allow_delete_other=? WHERE shelfnumber=?";
414
    $query= "UPDATE virtualshelves SET shelfname=?, category=?, sortfield=?, allow_add=?, allow_delete_own=?, allow_delete_other=? WHERE shelfnumber=?";
415
    $sth = $dbh->prepare($query);
415
    $sth = $dbh->prepare($query);
416
    $sth->execute(
416
    $sth->execute(
417
	$hashref->{shelfname}||$oldrecord->{shelfname},
417
    $hashref->{shelfname}||$oldrecord->{shelfname},
418
	$hashref->{category}||$oldrecord->{category},
418
    $hashref->{category}||$oldrecord->{category},
419
	$hashref->{sortfield}||$oldrecord->{sortfield},
419
    $hashref->{sortfield}||$oldrecord->{sortfield},
420
	$hashref->{allow_add}||$oldrecord->{allow_add},
420
    $hashref->{allow_add}||$oldrecord->{allow_add},
421
	$hashref->{allow_delete_own}||$oldrecord->{allow_delete_own},
421
    $hashref->{allow_delete_own}||$oldrecord->{allow_delete_own},
422
	$hashref->{allow_delete_other}||$oldrecord->{allow_delete_other},
422
    $hashref->{allow_delete_other}||$oldrecord->{allow_delete_other},
423
	$shelfnumber );
423
    $shelfnumber );
424
    return $@? 0: 1;
424
    return $@? 0: 1;
425
}
425
}
426
426
Lines 471-493 sub ShelfPossibleAction { Link Here
471
471
472
    return 0 unless $shelf && ($shelf->{category}==2 || $shelf->{owner}==$user || $shelf->{borrowernumber}==$user);
472
    return 0 unless $shelf && ($shelf->{category}==2 || $shelf->{owner}==$user || $shelf->{borrowernumber}==$user);
473
    if($action eq 'view') {
473
    if($action eq 'view') {
474
	#already handled in the above condition
474
    #already handled in the above condition
475
	return 1;
475
    return 1;
476
    }
476
    }
477
    elsif($action eq 'add') {
477
    elsif($action eq 'add') {
478
	return 0 if $user<=0; #should be logged in
478
    return 0 if $user<=0; #should be logged in
479
	return 1 if $shelf->{allow_add}==1 || $shelf->{owner}==$user;
479
    return 1 if $shelf->{allow_add}==1 || $shelf->{owner}==$user;
480
	#owner may always add
480
    #owner may always add
481
    }
481
    }
482
    elsif($action eq 'delete') {
482
    elsif($action eq 'delete') {
483
        #this answer is just diplomatic: it says that you may be able to delete
483
        #this answer is just diplomatic: it says that you may be able to delete
484
        #some items from that shelf
484
        #some items from that shelf
485
        #it does not answer the question about a specific biblio
485
        #it does not answer the question about a specific biblio
486
        #DelFromShelf checks the situation per biblio
486
        #DelFromShelf checks the situation per biblio
487
	return 1 if $user>0 && ($shelf->{allow_delete_own}==1 || $shelf->{allow_delete_other}==1);
487
    return 1 if $user>0 && ($shelf->{allow_delete_own}==1 || $shelf->{allow_delete_other}==1);
488
    }
488
    }
489
    elsif($action eq 'manage') {
489
    elsif($action eq 'manage') {
490
	return 1 if $user && $shelf->{owner}==$user;
490
    return 1 if $user && $shelf->{owner}==$user;
491
    }
491
    }
492
    return 0;
492
    return 0;
493
}
493
}
Lines 515-525 sub DelFromShelf { Link Here
515
        $query = qq(DELETE FROM virtualshelfcontents
515
        $query = qq(DELETE FROM virtualshelfcontents
516
            WHERE shelfnumber=? AND biblionumber=? AND borrowernumber=?);
516
            WHERE shelfnumber=? AND biblionumber=? AND borrowernumber=?);
517
        $sth= $dbh->prepare($query);
517
        $sth= $dbh->prepare($query);
518
	foreach my $biblionumber (@$bibref) {
518
    foreach my $biblionumber (@$bibref) {
519
            $sth->execute($shelfnumber, $biblionumber, $user);
519
            $sth->execute($shelfnumber, $biblionumber, $user);
520
	    $r= $sth->rows; #Expect -1, 0 or 1 (-1 means Don't know; count as 1)
520
        $r= $sth->rows; #Expect -1, 0 or 1 (-1 means Don't know; count as 1)
521
	    $t+= ($r==-1)? 1: $r;
521
        $t+= ($r==-1)? 1: $r;
522
	}
522
    }
523
    }
523
    }
524
    if($del_oth) {
524
    if($del_oth) {
525
        #includes a check if borrowernumber is null (deleted patron)
525
        #includes a check if borrowernumber is null (deleted patron)
Lines 527-537 sub DelFromShelf { Link Here
527
            WHERE shelfnumber=? AND biblionumber=? AND
527
            WHERE shelfnumber=? AND biblionumber=? AND
528
            (borrowernumber IS NULL OR borrowernumber<>?)/;
528
            (borrowernumber IS NULL OR borrowernumber<>?)/;
529
        $sth= $dbh->prepare($query);
529
        $sth= $dbh->prepare($query);
530
	foreach my $biblionumber (@$bibref) {
530
    foreach my $biblionumber (@$bibref) {
531
            $sth->execute($shelfnumber, $biblionumber, $user);
531
            $sth->execute($shelfnumber, $biblionumber, $user);
532
	    $r= $sth->rows;
532
        $r= $sth->rows;
533
	    $t+= ($r==-1)? 1: $r;
533
        $t+= ($r==-1)? 1: $r;
534
	}
534
    }
535
    }
535
    }
536
    return $t;
536
    return $t;
537
}
537
}
Lines 639-649 sub _shelf_count { Link Here
639
        $query.= qq{
639
        $query.= qq{
640
            LEFT JOIN virtualshelfshares sh ON sh.shelfnumber=vs.shelfnumber
640
            LEFT JOIN virtualshelfshares sh ON sh.shelfnumber=vs.shelfnumber
641
            AND sh.borrowernumber=?
641
            AND sh.borrowernumber=?
642
	    WHERE category=1 AND (vs.owner=? OR sh.borrowernumber=?) };
642
        WHERE category=1 AND (vs.owner=? OR sh.borrowernumber=?) };
643
        @params= ($owner, $owner, $owner);
643
        @params= ($owner, $owner, $owner);
644
    }
644
    }
645
    else {
645
    else {
646
	$query.='WHERE category=2';
646
    $query.='WHERE category=2';
647
        @params= ();
647
        @params= ();
648
    }
648
    }
649
    my $sth = $dbh->prepare($query);
649
    my $sth = $dbh->prepare($query);
Lines 657-665 sub _biblionumber_sth { #only used in obsolete sub below Link Here
657
    my $query = 'select biblionumber from virtualshelfcontents where shelfnumber = ?';
657
    my $query = 'select biblionumber from virtualshelfcontents where shelfnumber = ?';
658
    my $dbh = C4::Context->dbh;
658
    my $dbh = C4::Context->dbh;
659
    my $sth = $dbh->prepare($query)
659
    my $sth = $dbh->prepare($query)
660
	or die $dbh->errstr;
660
    or die $dbh->errstr;
661
    $sth->execute( $shelf )
661
    $sth->execute( $shelf )
662
	or die $sth->errstr;
662
    or die $sth->errstr;
663
    $sth;
663
    $sth;
664
}
664
}
665
665
Lines 667-674 sub each_biblionumbers (&$) { #OBSOLETE Link Here
667
    my ($code,$shelf) = @_;
667
    my ($code,$shelf) = @_;
668
    my $ref =  _biblionumber_sth($shelf)->fetchall_arrayref;
668
    my $ref =  _biblionumber_sth($shelf)->fetchall_arrayref;
669
    map {
669
    map {
670
	$_=$$_[0];
670
    $_=$$_[0];
671
	$code->();
671
    $code->();
672
    } @$ref;
672
    } @$ref;
673
}
673
}
674
674
Lines 678-684 sub _CheckShelfName { Link Here
678
    my $query = qq(
678
    my $query = qq(
679
        SELECT DISTINCT shelfnumber
679
        SELECT DISTINCT shelfnumber
680
        FROM   virtualshelves
680
        FROM   virtualshelves
681
	LEFT JOIN virtualshelfshares sh USING (shelfnumber)
681
    LEFT JOIN virtualshelfshares sh USING (shelfnumber)
682
        WHERE  shelfname=? AND shelfnumber<>?);
682
        WHERE  shelfname=? AND shelfnumber<>?);
683
    if($cat==1) {
683
    if($cat==1) {
684
        $query.= ' AND (sh.borrowernumber=? OR owner=?) AND category=1';
684
        $query.= ' AND (sh.borrowernumber=? OR owner=?) AND category=1';
(-)a/C4/VirtualShelves/Page.pm (-7 / +7 lines)
Lines 61-68 sub shelfpage { Link Here
61
    $query            or die "No query";
61
    $query            or die "No query";
62
    $template         or die "No template";
62
    $template         or die "No template";
63
    $template->param(
63
    $template->param(
64
	loggedinuser => $loggedinuser,
64
    loggedinuser => $loggedinuser,
65
	OpacAllowPublicListCreation => C4::Context->preference('OpacAllowPublicListCreation'),
65
    OpacAllowPublicListCreation => C4::Context->preference('OpacAllowPublicListCreation'),
66
    );
66
    );
67
    my $edit;
67
    my $edit;
68
    my $shelves;
68
    my $shelves;
Lines 178-184 sub shelfpage { Link Here
178
178
179
  SWITCH: {
179
  SWITCH: {
180
        if ($op) {
180
        if ($op) {
181
	    #Saving modified shelf
181
        #Saving modified shelf
182
            if ( $op eq 'modifsave' ) {
182
            if ( $op eq 'modifsave' ) {
183
                unless ($okmanage) {
183
                unless ($okmanage) {
184
                        push @paramsloop, { nopermission => $shelfnumber };
184
                        push @paramsloop, { nopermission => $shelfnumber };
Lines 205-212 sub shelfpage { Link Here
205
                }
205
                }
206
                exit;
206
                exit;
207
            }
207
            }
208
	    #Editing a shelf
208
        #Editing a shelf
209
            elsif ( $op eq 'modif' ) {
209
        elsif ( $op eq 'modif' ) {
210
                my ( $shelfnumber2, $shelfname, $owner, $category, $sortfield ) = GetShelf($shelfnumber);
210
                my ( $shelfnumber2, $shelfname, $owner, $category, $sortfield ) = GetShelf($shelfnumber);
211
                my $member = GetMember( 'borrowernumber' => $owner );
211
                my $member = GetMember( 'borrowernumber' => $owner );
212
                my $ownername = defined($member) ? $member->{firstname} . " " . $member->{surname} : '';
212
                my $ownername = defined($member) ? $member->{firstname} . " " . $member->{surname} : '';
Lines 315-321 sub shelfpage { Link Here
315
        if ( $query->param('shelves') ) {
315
        if ( $query->param('shelves') ) {
316
            my $stay = 1;
316
            my $stay = 1;
317
317
318
	    #Add a shelf
318
        #Add a shelf
319
            if ( my $newshelf = $query->param('addshelf') ) {
319
            if ( my $newshelf = $query->param('addshelf') ) {
320
320
321
                # note: a user can always add a new shelf
321
                # note: a user can always add a new shelf
Lines 335-341 sub shelfpage { Link Here
335
                }
335
                }
336
            }
336
            }
337
337
338
	    #Deleting a shelf (asking for confirmation if it has entries)
338
        #Deleting a shelf (asking for confirmation if it has entries)
339
            foreach ( $query->param() ) {
339
            foreach ( $query->param() ) {
340
                /DEL-(\d+)/ or next;
340
                /DEL-(\d+)/ or next;
341
                $delflag = 1;
341
                $delflag = 1;
(-)a/opac/opac-addbybiblionumber.pl (-35 / +35 lines)
Lines 88-114 sub AddBibliosToShelf { Link Here
88
88
89
sub HandleNewVirtualShelf {
89
sub HandleNewVirtualShelf {
90
    if($authorized= ShelfPossibleAction($loggedinuser, undef, $category==1? 'new_private': 'new_public')) {
90
    if($authorized= ShelfPossibleAction($loggedinuser, undef, $category==1? 'new_private': 'new_public')) {
91
	$shelfnumber = AddShelf( {
91
    $shelfnumber = AddShelf( {
92
            shelfname => $newvirtualshelf,
92
            shelfname => $newvirtualshelf,
93
            category => $category }, $loggedinuser);
93
            category => $category }, $loggedinuser);
94
	if($shelfnumber == -1) {
94
    if($shelfnumber == -1) {
95
	    $authorized=0;
95
        $authorized=0;
96
	    $errcode=1;
96
        $errcode=1;
97
	    return;
97
        return;
98
	}
98
    }
99
	AddBibliosToShelf($shelfnumber, @biblionumber);
99
    AddBibliosToShelf($shelfnumber, @biblionumber);
100
	#Reload the page where you came from
100
    #Reload the page where you came from
101
	print $query->header;
101
    print $query->header;
102
	print "<html><meta http-equiv=\"refresh\" content=\"0\" /><body onload=\"window.opener.location.reload(true);self.close();\"></body></html>";
102
    print "<html><meta http-equiv=\"refresh\" content=\"0\" /><body onload=\"window.opener.location.reload(true);self.close();\"></body></html>";
103
    }
103
    }
104
}
104
}
105
105
106
sub HandleShelfNumber {
106
sub HandleShelfNumber {
107
    if($authorized= ShelfPossibleAction($loggedinuser, $shelfnumber, 'add')) {
107
    if($authorized= ShelfPossibleAction($loggedinuser, $shelfnumber, 'add')) {
108
	AddBibliosToShelf($shelfnumber,@biblionumber);
108
    AddBibliosToShelf($shelfnumber,@biblionumber);
109
	#Close this page and return
109
    #Close this page and return
110
	print $query->header;
110
    print $query->header;
111
	print "<html><meta http-equiv=\"refresh\" content=\"0\" /><body onload=\"self.close();\"></body></html>";
111
    print "<html><meta http-equiv=\"refresh\" content=\"0\" /><body onload=\"self.close();\"></body></html>";
112
    }
112
    }
113
}
113
}
114
114
Lines 117-126 sub HandleSelectedShelf { Link Here
117
        #adding to specific shelf
117
        #adding to specific shelf
118
        my ($singleshelf, $singleshelfname, $singlecategory)= GetShelf($query->param('selectedshelf'));
118
        my ($singleshelf, $singleshelfname, $singlecategory)= GetShelf($query->param('selectedshelf'));
119
        $template->param(
119
        $template->param(
120
	    singleshelf               => 1,
120
        singleshelf               => 1,
121
	    shelfnumber               => $singleshelf,
121
        shelfnumber               => $singleshelf,
122
	    shelfname                 => $singleshelfname,
122
        shelfname                 => $singleshelfname,
123
	    "category$singlecategory" => 1
123
        "category$singlecategory" => 1
124
        );
124
        );
125
    }
125
    }
126
}
126
}
Lines 130-170 sub HandleSelect { Link Here
130
    my $privateshelves = GetAllShelves(1,$loggedinuser,1);
130
    my $privateshelves = GetAllShelves(1,$loggedinuser,1);
131
    if(@{$privateshelves}){
131
    if(@{$privateshelves}){
132
        $template->param (
132
        $template->param (
133
	    privatevirtualshelves          => $privateshelves,
133
        privatevirtualshelves          => $privateshelves,
134
	    existingshelves => 1
134
        existingshelves => 1
135
	);
135
    );
136
    }
136
    }
137
    my $publicshelves = GetAllShelves(2,$loggedinuser,1);
137
    my $publicshelves = GetAllShelves(2,$loggedinuser,1);
138
    if(@{$publicshelves}){
138
    if(@{$publicshelves}){
139
        $template->param (
139
        $template->param (
140
	    publicvirtualshelves          => $publicshelves,
140
        publicvirtualshelves          => $publicshelves,
141
	    existingshelves => 1
141
        existingshelves => 1
142
	);
142
    );
143
    }
143
    }
144
}
144
}
145
145
146
sub LoadBib {
146
sub LoadBib {
147
    for my $bib (@biblionumber) {
147
    for my $bib (@biblionumber) {
148
        my $data = GetBiblioData( $bib );
148
        my $data = GetBiblioData( $bib );
149
	push(@biblios,
149
    push(@biblios,
150
		{ biblionumber => $bib,
150
        { biblionumber => $bib,
151
		  title        => $data->{'title'},
151
          title        => $data->{'title'},
152
		  author       => $data->{'author'},
152
          author       => $data->{'author'},
153
	} );
153
    } );
154
    }
154
    }
155
    $template->param(
155
    $template->param(
156
        multiple => (scalar(@biblios) > 1),
156
        multiple => (scalar(@biblios) > 1),
157
	total    => scalar @biblios,
157
    total    => scalar @biblios,
158
	biblios  => \@biblios,
158
    biblios  => \@biblios,
159
    );
159
    );
160
}
160
}
161
161
162
sub ShowTemplate {
162
sub ShowTemplate {
163
    $template->param (
163
    $template->param (
164
	newshelf => $newshelf||0,
164
    newshelf => $newshelf||0,
165
	authorized	=> $authorized,
165
    authorized	=> $authorized,
166
	errcode		=> $errcode,
166
    errcode		=> $errcode,
167
	OpacAllowPublicListCreation => C4::Context->preference('OpacAllowPublicListCreation'),
167
    OpacAllowPublicListCreation => C4::Context->preference('OpacAllowPublicListCreation'),
168
    );
168
    );
169
    output_html_with_http_headers $query, $cookie, $template->output;
169
    output_html_with_http_headers $query, $cookie, $template->output;
170
}
170
}
(-)a/virtualshelves/addbybiblionumber.pl (-26 / +25 lines)
Lines 136-144 sub HandleNewVirtualShelf { Link Here
136
        sortfield => $sortfield,
136
        sortfield => $sortfield,
137
        category => $category }, $loggedinuser);
137
        category => $category }, $loggedinuser);
138
    if($shelfnumber == -1) {
138
    if($shelfnumber == -1) {
139
	    $authorized=0;
139
        $authorized=0;
140
	    $errcode=1; #add failed
140
        $errcode=1; #add failed
141
	    return;
141
        return;
142
    }
142
    }
143
    AddBibliosToShelf($shelfnumber, @biblionumber);
143
    AddBibliosToShelf($shelfnumber, @biblionumber);
144
    #Reload the page where you came from
144
    #Reload the page where you came from
Lines 148-160 sub HandleNewVirtualShelf { Link Here
148
148
149
sub HandleShelfNumber {
149
sub HandleShelfNumber {
150
    if($authorized= ShelfPossibleAction($loggedinuser, $shelfnumber, 'add')) {
150
    if($authorized= ShelfPossibleAction($loggedinuser, $shelfnumber, 'add')) {
151
	AddBibliosToShelf($shelfnumber, @biblionumber);
151
    AddBibliosToShelf($shelfnumber, @biblionumber);
152
	#Close this page and return
152
    #Close this page and return
153
	print $query->header;
153
    print $query->header;
154
	print "<html><meta http-equiv=\"refresh\" content=\"0\" /><body onload=\"self.close();\"></body></html>";
154
    print "<html><meta http-equiv=\"refresh\" content=\"0\" /><body onload=\"self.close();\"></body></html>";
155
    }
155
    }
156
    else {
156
    else {
157
	$errcode=2; #no perm
157
    $errcode=2; #no perm
158
    }
158
    }
159
}
159
}
160
160
Lines 163-176 sub HandleSelectedShelf { Link Here
163
        #confirm adding to specific shelf
163
        #confirm adding to specific shelf
164
        my ($singleshelf, $singleshelfname, $singlecategory)= GetShelf($shelfnumber);
164
        my ($singleshelf, $singleshelfname, $singlecategory)= GetShelf($shelfnumber);
165
        $template->param(
165
        $template->param(
166
	    singleshelf               => 1,
166
        singleshelf               => 1,
167
	    shelfnumber               => $singleshelf,
167
        shelfnumber               => $singleshelf,
168
	    shelfname                 => $singleshelfname,
168
        shelfname                 => $singleshelfname,
169
	    "category$singlecategory" => 1
169
        "category$singlecategory" => 1
170
        );
170
        );
171
    }
171
    }
172
    else {
172
    else {
173
	$errcode=2; #no perm
173
    $errcode=2; #no perm
174
    }
174
    }
175
}
175
}
176
176
Lines 178-185 sub HandleSelect { Link Here
178
    my $privateshelves = GetAllShelves(1,$loggedinuser,1);
178
    my $privateshelves = GetAllShelves(1,$loggedinuser,1);
179
    my $publicshelves = GetAllShelves(2,$loggedinuser,1);
179
    my $publicshelves = GetAllShelves(2,$loggedinuser,1);
180
    $template->param(
180
    $template->param(
181
	privatevirtualshelves => $privateshelves,
181
    privatevirtualshelves => $privateshelves,
182
	publicvirtualshelves  => $publicshelves,
182
    publicvirtualshelves  => $publicshelves,
183
    );
183
    );
184
}
184
}
185
185
Lines 187-210 sub LoadBib { Link Here
187
    my @biblios;
187
    my @biblios;
188
    for my $bib (@biblionumber) {
188
    for my $bib (@biblionumber) {
189
        my $data = GetBiblioData($bib);
189
        my $data = GetBiblioData($bib);
190
	push(@biblios,
190
    push(@biblios,
191
		{ biblionumber => $bib,
191
        { biblionumber => $bib,
192
		  title        => $data->{'title'},
192
          title        => $data->{'title'},
193
		  author       => $data->{'author'},
193
          author       => $data->{'author'},
194
	} );
194
    } );
195
    }
195
    }
196
    $template->param(
196
    $template->param(
197
        multiple => (scalar(@biblios) > 1),
197
        multiple => (scalar(@biblios) > 1),
198
	total    => scalar @biblios,
198
    total    => scalar @biblios,
199
	biblios  => \@biblios,
199
    biblios  => \@biblios,
200
    );
200
    );
201
}
201
}
202
202
203
sub ShowTemplate {
203
sub ShowTemplate {
204
    $template->param (
204
    $template->param (
205
	newshelf => $newshelf||0,
205
    newshelf => $newshelf||0,
206
	authorized	=> $authorized,
206
    authorized	=> $authorized,
207
	errcode		=> $errcode,
207
    errcode		=> $errcode,
208
    );
208
    );
209
    output_html_with_http_headers $query, $cookie, $template->output;
209
    output_html_with_http_headers $query, $cookie, $template->output;
210
}
210
}
211
- 

Return to bug 7675