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

(-)a/C4/Auth.pm (-22 / +22 lines)
Lines 164-182 sub get_template_and_user { Link Here
164
        $template->param( loggedinusername => $user );
164
        $template->param( loggedinusername => $user );
165
        $template->param( sessionID        => $sessionID );
165
        $template->param( sessionID        => $sessionID );
166
166
167
		my ($total, $pubshelves, $barshelves) = C4::Context->get_shelves_userenv();
167
        my ($total, $pubshelves, $barshelves) = C4::Context->get_shelves_userenv();
168
		if (defined($pubshelves)) {
168
        if (defined($pubshelves)) {
169
        	$template->param( 	pubshelves     	=> scalar (@$pubshelves),
169
            $template->param( pubshelves     => scalar @{$pubshelves},
170
        						pubshelvesloop 	=> $pubshelves,
170
                              pubshelvesloop => $pubshelves,
171
							);
171
            );
172
			$template->param(	pubtotal		=> $total->{'pubtotal'}, ) if ($total->{'pubtotal'} > scalar (@$pubshelves));
172
            $template->param( pubtotal   => $total->{'pubtotal'}, ) if ($total->{'pubtotal'} > scalar @{$pubshelves});
173
		}
173
        }
174
		if (defined($barshelves)) {
174
        if (defined($barshelves)) {
175
        	$template->param(	barshelves     	=> scalar (@$barshelves),
175
            $template->param( barshelves      => scalar @{$barshelves},
176
        						barshelvesloop 	=> $barshelves,
176
                              barshelvesloop  => $barshelves,
177
							);
177
            );
178
			$template->param(	bartotal		=> $total->{'bartotal'}, ) if ($total->{'bartotal'} > scalar (@$barshelves));
178
            $template->param( bartotal  => $total->{'bartotal'}, ) if ($total->{'bartotal'} > scalar @{$barshelves});
179
		}
179
        }
180
180
181
        $borrowernumber = getborrowernumber($user) if defined($user);
181
        $borrowernumber = getborrowernumber($user) if defined($user);
182
182
Lines 297-307 sub get_template_and_user { Link Here
297
        $template->param( sessionID        => $sessionID );
297
        $template->param( sessionID        => $sessionID );
298
        
298
        
299
        my ($total, $pubshelves) = C4::Context->get_shelves_userenv();  # an anonymous user has no 'barshelves'...
299
        my ($total, $pubshelves) = C4::Context->get_shelves_userenv();  # an anonymous user has no 'barshelves'...
300
        if (defined(($pubshelves))) {
300
        if (defined $pubshelves) {
301
            $template->param(   pubshelves      => scalar (@$pubshelves),
301
            $template->param(   pubshelves      => scalar @{$pubshelves},
302
                                pubshelvesloop  => $pubshelves,
302
                                pubshelvesloop  => $pubshelves,
303
                            );
303
                            );
304
            $template->param(   pubtotal        => $total->{'pubtotal'}, ) if ($total->{'pubtotal'} > scalar (@$pubshelves));
304
            $template->param(   pubtotal        => $total->{'pubtotal'}, ) if ($total->{'pubtotal'} > scalar @{$pubshelves});
305
        }
305
        }
306
306
307
    }
307
    }
Lines 852-863 sub checkauth { Link Here
852
				$total->{'bartotal'} = $totshelves;
852
				$total->{'bartotal'} = $totshelves;
853
				($pubshelves, $totshelves) = C4::VirtualShelves::GetRecentShelves(2, $row_count, undef);
853
				($pubshelves, $totshelves) = C4::VirtualShelves::GetRecentShelves(2, $row_count, undef);
854
				$total->{'pubtotal'} = $totshelves;
854
				$total->{'pubtotal'} = $totshelves;
855
				$session->param('barshelves', $barshelves->[0]);
855
				$session->param('barshelves', $barshelves);
856
				$session->param('pubshelves', $pubshelves->[0]);
856
				$session->param('pubshelves', $pubshelves);
857
				$session->param('totshelves', $total);
857
				$session->param('totshelves', $total);
858
858
859
				C4::Context::set_shelves_userenv('bar',$barshelves->[0]);
859
				C4::Context::set_shelves_userenv('bar',$barshelves);
860
				C4::Context::set_shelves_userenv('pub',$pubshelves->[0]);
860
				C4::Context::set_shelves_userenv('pub',$pubshelves);
861
				C4::Context::set_shelves_userenv('tot',$total);
861
				C4::Context::set_shelves_userenv('tot',$total);
862
			}
862
			}
863
        	else {
863
        	else {
Lines 877-885 sub checkauth { Link Here
877
			my ($total, $totshelves, $pubshelves);
877
			my ($total, $totshelves, $pubshelves);
878
			($pubshelves, $totshelves) = C4::VirtualShelves::GetRecentShelves(2, $row_count, undef);
878
			($pubshelves, $totshelves) = C4::VirtualShelves::GetRecentShelves(2, $row_count, undef);
879
			$total->{'pubtotal'} = $totshelves;
879
			$total->{'pubtotal'} = $totshelves;
880
			$session->param('pubshelves', $pubshelves->[0]);
880
			$session->param('pubshelves', $pubshelves);
881
			$session->param('totshelves', $total);
881
			$session->param('totshelves', $total);
882
			C4::Context::set_shelves_userenv('pub',$pubshelves->[0]);
882
			C4::Context::set_shelves_userenv('pub',$pubshelves);
883
			C4::Context::set_shelves_userenv('tot',$total);
883
			C4::Context::set_shelves_userenv('tot',$total);
884
884
885
			# setting a couple of other session vars...
885
			# setting a couple of other session vars...
(-)a/C4/VirtualShelves.pm (-19 / +25 lines)
Lines 186-194 sub GetShelvesSummary ($$$$) { Link Here
186
186
187
=head2 GetRecentShelves
187
=head2 GetRecentShelves
188
188
189
	($shelflist) = GetRecentShelves(1, $limit, $owner)
189
	($shelflist, $total) = GetRecentShelves(1, $limit, $owner)
190
190
191
This function returns a references to an array of hashrefs containing specified shelves sorted
191
This function returns a reference to an array of hashrefs containing specified shelves sorted
192
by the date the shelf was last modified in descending order limited to the number of records
192
by the date the shelf was last modified in descending order limited to the number of records
193
specified by C<$row_count>. If calling with C<$mincategory> other than 1, use undef as C<$owner>.
193
specified by C<$row_count>. If calling with C<$mincategory> other than 1, use undef as C<$owner>.
194
194
Lines 197-215 the submitted parameters. Link Here
197
197
198
=cut
198
=cut
199
199
200
sub GetRecentShelves ($$$) {
200
sub GetRecentShelves {
201
	my ($mincategory, $row_count, $owner) = @_;
201
    my ($mincategory, $row_count, $owner) = @_;
202
    my (@shelflist);
202
    my $total = _shelf_count($owner, $mincategory);
203
	my $total = _shelf_count($owner, $mincategory);
203
    my @params;
204
	my @params = ($owner, $mincategory, 0, $row_count);	 #FIXME: offset is hardcoded here, but could be passed in for enhancements
204
    my $selection;
205
	shift @params if (not defined $owner);
205
    if (defined $owner) {
206
	my $query = "SELECT * FROM virtualshelves";
206
        @params = ($owner, $mincategory, $row_count);
207
	$query .= ((defined $owner) ? " WHERE owner = ? AND category = ?" : " WHERE category >= ? ");
207
        $selection = ' WHERE owner = ? AND category = ?';
208
	$query .= " ORDER BY lastmodified DESC LIMIT ?, ?";
208
    } else {
209
	my $sth = $dbh->prepare($query);
209
        @params = ( $mincategory, $row_count);
210
	$sth->execute(@params);
210
        $selection = ' WHERE category >= ? ';
211
	@shelflist = $sth->fetchall_arrayref({});
211
    }
212
	return ( \@shelflist, $total );
212
    my $query = 'SELECT * FROM virtualshelves';
213
    $query .= $selection;
214
    $query .= ' ORDER BY lastmodified DESC LIMIT ?';
215
    my $sth = $dbh->prepare($query);
216
    $sth->execute(@params);
217
    my $shelflist = $sth->fetchall_arrayref({});
218
    return ( $shelflist, $total );
213
}
219
}
214
220
215
=head2 GetAllShelves
221
=head2 GetAllShelves
Lines 563-575 sub RefreshShelvesSummary ($$$) { Link Here
563
	$total->{'pubtotal'} = $totshelves;
569
	$total->{'pubtotal'} = $totshelves;
564
570
565
	# Update the current session with the latest shelves...
571
	# Update the current session with the latest shelves...
566
	$session->param('barshelves', $barshelves->[0]);
572
	$session->param('barshelves', $barshelves);
567
	$session->param('pubshelves', $pubshelves->[0]);
573
	$session->param('pubshelves', $pubshelves);
568
	$session->param('totshelves', $total);
574
	$session->param('totshelves', $total);
569
575
570
	# likewise the userenv...
576
	# likewise the userenv...
571
	C4::Context->set_shelves_userenv('bar',$barshelves->[0]);
577
	C4::Context->set_shelves_userenv('bar',$barshelves);
572
	C4::Context->set_shelves_userenv('pub',$pubshelves->[0]);
578
	C4::Context->set_shelves_userenv('pub',$pubshelves);
573
	C4::Context::set_shelves_userenv('tot',$total);
579
	C4::Context::set_shelves_userenv('tot',$total);
574
580
575
	return ($total, $pubshelves, $barshelves);
581
	return ($total, $pubshelves, $barshelves);
(-)a/C4/VirtualShelves/Page.pm (-6 / +6 lines)
Lines 393-410 sub shelfpage ($$$$$) { Link Here
393
393
394
    if ( defined $barshelves ) {
394
    if ( defined $barshelves ) {
395
        $template->param(
395
        $template->param(
396
            barshelves     => scalar( @{ $barshelves->[0] } ),
396
            barshelves     => scalar( @{ $barshelves } ),
397
            barshelvesloop => $barshelves->[0],
397
            barshelvesloop => $barshelves,
398
        );
398
        );
399
        $template->param( bartotal => $total->{'bartotal'}, ) if ( $total->{'bartotal'} > scalar( @{ $barshelves->[0] } ) );
399
        $template->param( bartotal => $total->{'bartotal'}, ) if ( $total->{'bartotal'} > scalar( @{ $barshelves } ) );
400
    }
400
    }
401
401
402
    if ( defined $pubshelves ) {
402
    if ( defined $pubshelves ) {
403
        $template->param(
403
        $template->param(
404
            pubshelves     => scalar( @{ $pubshelves->[0] } ),
404
            pubshelves     => scalar( @{ $pubshelves } ),
405
            pubshelvesloop => $pubshelves->[0],
405
            pubshelvesloop => $pubshelves,
406
        );
406
        );
407
        $template->param( pubtotal => $total->{'pubtotal'}, ) if ( $total->{'pubtotal'} > scalar( @{ $pubshelves->[0] } ) );
407
        $template->param( pubtotal => $total->{'pubtotal'}, ) if ( $total->{'pubtotal'} > scalar( @{ $pubshelves } ) );
408
    }
408
    }
409
409
410
    output_html_with_http_headers $query, $cookie, $template->output;
410
    output_html_with_http_headers $query, $cookie, $template->output;
(-)a/catalogue/search.pl (-9 / +6 lines)
Lines 673-689 my $row_count = 10; # FIXME:This probably should be a syspref Link Here
673
my ($pubshelves, $total) = GetRecentShelves(2, $row_count, undef);
673
my ($pubshelves, $total) = GetRecentShelves(2, $row_count, undef);
674
my ($barshelves, $total) = GetRecentShelves(1, $row_count, $borrowernumber);
674
my ($barshelves, $total) = GetRecentShelves(1, $row_count, $borrowernumber);
675
675
676
my @pubshelves = @{$pubshelves};
676
if (@{$pubshelves}) {
677
my @barshelves = @{$barshelves};
677
        $template->param( addpubshelves     => scalar @{$pubshelves});
678
678
        $template->param( addpubshelvesloop => $pubshelves);
679
if (@pubshelves) {
680
        $template->param( addpubshelves     => scalar (@pubshelves));
681
        $template->param( addpubshelvesloop => @pubshelves);
682
}
679
}
683
680
684
if (@barshelves) {
681
if (@{$barshelves}) {
685
        $template->param( addbarshelves     => scalar (@barshelves));
682
        $template->param( addbarshelves     => scalar @{$barshelves});
686
        $template->param( addbarshelvesloop => @barshelves);
683
        $template->param( addbarshelvesloop => $barshelves);
687
}
684
}
688
685
689
686
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tmpl (-1 / +1 lines)
Lines 65-72 $(".addtocart").show(); Link Here
65
        param1 += "<option id=\"s<!-- TMPL_VAR NAME="shelfnumber" -->\" value=\"addtolist\"><!-- TMPL_VAR NAME="shelfname" ESCAPE="html"--><\/option>";<!-- /TMPL_LOOP -->
65
        param1 += "<option id=\"s<!-- TMPL_VAR NAME="shelfnumber" -->\" value=\"addtolist\"><!-- TMPL_VAR NAME="shelfname" ESCAPE="html"--><\/option>";<!-- /TMPL_LOOP -->
66
        param1 += "<\/optgroup>";<!-- /TMPL_IF -->
66
        param1 += "<\/optgroup>";<!-- /TMPL_IF -->
67
        <!-- TMPL_IF NAME="addpubshelves" -->param1 += "<optgroup label=\""+_("Public Lists:")+"\">"<!-- TMPL_LOOP NAME="addpubshelvesloop" -->+"<option id=\"s<!-- TMPL_VAR NAME="shelfnumber" -->\" value=\"addtolist\"><!-- TMPL_VAR NAME="shelfname" ESCAPE="html"--><\/option>"<!-- /TMPL_LOOP -->
67
        <!-- TMPL_IF NAME="addpubshelves" -->param1 += "<optgroup label=\""+_("Public Lists:")+"\">"<!-- TMPL_LOOP NAME="addpubshelvesloop" -->+"<option id=\"s<!-- TMPL_VAR NAME="shelfnumber" -->\" value=\"addtolist\"><!-- TMPL_VAR NAME="shelfname" ESCAPE="html"--><\/option>"<!-- /TMPL_LOOP -->
68
        <!-- /TMPL_IF -->
68
        param1 +="<\/optgroup><option value=\"newlist\">"+_("[ New List ]")+"<\/option>"
69
        param1 +="<\/optgroup><option value=\"newlist\">"+_("[ New List ]")+"<\/option>"
69
<!-- /TMPL_IF -->
70
        <!-- /TMPL_IF -->
70
        <!-- /TMPL_IF -->
71
        param1 += "<\/select> <input id=\"cartsubmit\" type=\"submit\" class=\"submit\" value=\""+_("Save")+"\" />";
71
        param1 += "<\/select> <input id=\"cartsubmit\" type=\"submit\" class=\"submit\" value=\""+_("Save")+"\" />";
72
 $('#sortsubmit').hide();
72
 $('#sortsubmit').hide();
(-)a/virtualshelves/addbybiblionumber.pl (-3 / +2 lines)
Lines 160-172 else { # this shelf doesn't already exist. Link Here
160
    #grab each type of shelf, open (type 3) should not be limited by user.
160
    #grab each type of shelf, open (type 3) should not be limited by user.
161
    foreach my $shelftype (1,2,3) {
161
    foreach my $shelftype (1,2,3) {
162
	    my ($shelflist) = GetRecentShelves($shelftype, $limit, $shelftype == 3 ? undef : $loggedinuser);
162
	    my ($shelflist) = GetRecentShelves($shelftype, $limit, $shelftype == 3 ? undef : $loggedinuser);
163
	    for my $shelf (@{ $shelflist->[0] }) {
163
	    for my $shelf (@{ $shelflist }) {
164
		    push(@shelvesloop, $shelf->{shelfnumber});
164
		    push(@shelvesloop, $shelf->{shelfnumber});
165
		    $shelvesloop{$shelf->{shelfnumber}} = $shelf->{shelfname};
165
		    $shelvesloop{$shelf->{shelfnumber}} = $shelf->{shelfname};
166
	    }
166
	    }
167
    }
167
    }
168
168
169
    if(@shelvesloop gt 0){
169
    if( @shelvesloop ){
170
        my $CGIvirtualshelves = CGI::scrolling_list
170
        my $CGIvirtualshelves = CGI::scrolling_list
171
          (
171
          (
172
           -name     => 'shelfnumber',
172
           -name     => 'shelfnumber',
173
- 

Return to bug 5529