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

(-)a/C4/VirtualShelves.pm (-12 / +7 lines)
Lines 71-77 bibs to and from virtual shelves. Link Here
71
71
72
=head2 GetShelves
72
=head2 GetShelves
73
73
74
  ($shelflist, $totshelves) = &GetShelves($category, $row_count, $offset, $owner);
74
  $shelflist = &GetShelves($category, $row_count, $offset, $owner);
75
  ($shelfnumber, $shelfhash) = each %{$shelflist};
75
  ($shelfnumber, $shelfhash) = each %{$shelflist};
76
76
77
Returns the number of shelves specified by C<$row_count> and C<$offset> as well as the total
77
Returns the number of shelves specified by C<$row_count> and C<$offset> as well as the total
Lines 90-107 and the values (C<$shelfhash>, above) are themselves references-to-hash, with th Link Here
90
90
91
A string. The name of the shelf.
91
A string. The name of the shelf.
92
92
93
=item C<$shelfhash-E<gt>{count}>
94
95
The number of virtuals on that virtualshelves.
96
97
=back
93
=back
98
94
99
=cut
95
=cut
100
96
101
sub GetShelves {
97
sub GetShelves {
102
    my ($category, $row_count, $offset, $owner) = @_;
98
    my ($category, $row_count, $offset, $owner) = @_;
103
    my @params;
99
    $offset ||= 0;
104
    my $total = _shelf_count($owner, $category);
100
    my @params = ( $offset, $row_count );
105
    my $dbh = C4::Context->dbh;
101
    my $dbh = C4::Context->dbh;
106
    my $query = qq{
102
    my $query = qq{
107
        SELECT vs.shelfnumber, vs.shelfname,vs.owner,
103
        SELECT vs.shelfnumber, vs.shelfname,vs.owner,
Lines 115-125 sub GetShelves { Link Here
115
            LEFT JOIN virtualshelfshares sh ON sh.shelfnumber=vs.shelfnumber
111
            LEFT JOIN virtualshelfshares sh ON sh.shelfnumber=vs.shelfnumber
116
            AND sh.borrowernumber=?
112
            AND sh.borrowernumber=?
117
        WHERE category=1 AND (vs.owner=? OR sh.borrowernumber=?) };
113
        WHERE category=1 AND (vs.owner=? OR sh.borrowernumber=?) };
118
        @params= ($owner, $owner, $owner, $offset||0, $row_count);
114
        push @params, ($owner) x 3;
119
    }
115
    }
120
    else {
116
    else {
121
        $query.= 'WHERE category=2 ';
117
        $query.= 'WHERE category=2 ';
122
        @params= ($offset||0, $row_count);
123
    }
118
    }
124
    $query.= qq{
119
    $query.= qq{
125
        GROUP BY vs.shelfnumber
120
        GROUP BY vs.shelfnumber
Lines 139-145 sub GetShelves { Link Here
139
        $shelflist{$shelfnumber}->{'surname'}   = $surname;
134
        $shelflist{$shelfnumber}->{'surname'}   = $surname;
140
        $shelflist{$shelfnumber}->{'firstname'} = $firstname;
135
        $shelflist{$shelfnumber}->{'firstname'} = $firstname;
141
    }
136
    }
142
    return ( \%shelflist, $total );
137
    return \%shelflist;
143
}
138
}
144
139
145
=head2 GetAllShelves
140
=head2 GetAllShelves
Lines 751-759 WHERE borrowernumber=? AND shelfnumber=? Link Here
751
    return 1;
746
    return 1;
752
}
747
}
753
748
754
# internal subs
755
749
756
sub _shelf_count {
750
sub GetShelfCount {
757
    my ($owner, $category) = @_;
751
    my ($owner, $category) = @_;
758
    my @params;
752
    my @params;
759
    # Find out how many shelves total meet the submitted criteria...
753
    # Find out how many shelves total meet the submitted criteria...
Lines 777-782 sub _shelf_count { Link Here
777
    return $total;
771
    return $total;
778
}
772
}
779
773
774
# internal subs
780
sub _CheckShelfName {
775
sub _CheckShelfName {
781
    my ($name, $cat, $owner, $number)= @_;
776
    my ($name, $cat, $owner, $number)= @_;
782
777
(-)a/C4/VirtualShelves/Page.pm (-3 / +4 lines)
Lines 90-96 sub shelfpage { Link Here
90
    $shelvesoffset = ( $shelfoff - 1 ) * $shelflimit;    # Sets the offset to begin retrieving shelves at (offset)
90
    $shelvesoffset = ( $shelfoff - 1 ) * $shelflimit;    # Sets the offset to begin retrieving shelves at (offset)
91
                                                # getting the Shelves list
91
                                                # getting the Shelves list
92
    my $category = ( ( $displaymode eq 'privateshelves' ) ? 1 : 2 );
92
    my $category = ( ( $displaymode eq 'privateshelves' ) ? 1 : 2 );
93
    my ( $shelflist, $totshelves ) = GetShelves( $category, $shelveslimit, $shelvesoffset, $loggedinuser );
93
    my $shelflist = GetShelves( $category, $shelveslimit, $shelvesoffset, $loggedinuser );
94
    my $totshelves = C4::VirtualShelves::GetShelfCount( $loggedinuser, $category );
94
95
95
    #Get a list of private shelves for possible deletion. Only do this when we've defaulted to public shelves
96
    #Get a list of private shelves for possible deletion. Only do this when we've defaulted to public shelves
96
    my ( $privshelflist, $privtotshelves );
97
    my ( $privshelflist, $privtotshelves );
Lines 429-435 sub shelfpage { Link Here
429
    my $numberCanManage = 0;
430
    my $numberCanManage = 0;
430
431
431
    # rebuild shelflist in case a shelf has been added
432
    # rebuild shelflist in case a shelf has been added
432
    ( $shelflist, $totshelves ) = GetShelves( $category, $shelveslimit, $shelvesoffset, $loggedinuser ) unless $delflag;
433
    $shelflist = GetShelves( $category, $shelveslimit, $shelvesoffset, $loggedinuser ) unless $delflag;
434
    $totshelves = C4::VirtualShelves::GetShelfCount( $loggedinuser, $category ) unless $delflag;
433
    foreach my $element ( sort { lc( $shelflist->{$a}->{'shelfname'} ) cmp lc( $shelflist->{$b}->{'shelfname'} ) } keys %$shelflist ) {
435
    foreach my $element ( sort { lc( $shelflist->{$a}->{'shelfname'} ) cmp lc( $shelflist->{$b}->{'shelfname'} ) } keys %$shelflist ) {
434
        my %line;
436
        my %line;
435
        $shelflist->{$element}->{shelf} = $element;
437
        $shelflist->{$element}->{shelf} = $element;
436
- 

Return to bug 13418