kohabug 2159 Improving "Lists" button list refreshes after adding/changing lists...
authorChris Nighswonger <chris.nighswonger@liblime.com>
Thu, 26 Jun 2008 04:18:07 +0000 (23:18 -0500)
committerJoshua Ferraro <jmf@liblime.com>
Tue, 22 Jul 2008 20:48:13 +0000 (15:48 -0500)
Adding code to refresh "Lists" button lists display in OPAC masthead.inc

Adding javascript to force refresh of parent window to update "Lists" button menu

Adding query limits and ability to specify row count and offset in queries related to Virtualshelves.
Also added the ability to return total record counts for specified virtualshelves.

Adding C4::VirtualShelves::GetRecentShelves which returns a list of the most recently modified shelves for
a given set of parameters. This allows the user to be offered active private and open lists to add books
to in drop down menus while also allowing drop down menus to be limited to a reasonable length.
This also limits the shelves stored in the user's session to a fixed number. A further enhancement might
be to add a syspref to enable a staff member to define the limit. Currently it is hardcoded at 10 per
list type (private/public-open).

Adding pagination to list/shelf related screens

Moving refresh shelves code into C4::VirtualShelves::RefreshShelvesSummary and tidying up a bit

Correcting several inconsistancies in the shelves templates as well as handling shelf management on
the intranet side correctly.

Correcting "Add To:" drop-down list to show only lists the patron has permission to add to

Correcting a few C4::VirtualShelves::GetShelvesSummary API calls

Modifications for template consistancy

Breaking up a 1367 char line of javascript in opac-results.tmpl

Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
13 files changed:
C4/Auth.pm
C4/Context.pm
C4/VirtualShelves.pm
C4/VirtualShelves/Page.pm
koha-tmpl/intranet-tmpl/prog/en/includes/virtualshelves-toolbar.inc
koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tmpl
koha-tmpl/opac-tmpl/prog/en/includes/masthead.inc
koha-tmpl/opac-tmpl/prog/en/modules/opac-addbybiblionumber.tmpl
koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tmpl
koha-tmpl/opac-tmpl/prog/en/modules/opac-shelves.tmpl
opac/opac-addbybiblionumber.pl
opac/opac-search.pl
virtualshelves/addbybiblionumber.pl

index 8ccaf61..98c151e 100755 (executable)
@@ -31,7 +31,7 @@ use C4::Output;    # to get the template
 use C4::Members;
 use C4::Koha;
 use C4::Branch; # GetBranches
-use C4::VirtualShelves 3.02 qw(GetShelvesSummary);
+use C4::VirtualShelves;
 
 # use utf8;
 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $debug $ldap);
@@ -145,14 +145,18 @@ sub get_template_and_user {
         $template->param( loggedinusername => $user );
         $template->param( sessionID        => $sessionID );
 
-               my ($pubshelves, $barshelves) = C4::Context->get_shelves_userenv();
+               my ($total, $pubshelves, $barshelves) = C4::Context->get_shelves_userenv();
                if (defined($pubshelves)) {
-               $template->param( pubshelves     => scalar (@$pubshelves));
-               $template->param( pubshelvesloop => $pubshelves);
+               $template->param(       pubshelves      => scalar (@$pubshelves),
+                                                       pubshelvesloop  => $pubshelves,
+                                                       );
+                       $template->param(       pubtotal                => $total->{'pubtotal'}, ) if ($total->{'pubtotal'} > scalar (@$pubshelves));
                }
                if (defined($barshelves)) {
-               $template->param( barshelves     => scalar (@$barshelves));
-               $template->param( barshelvesloop => $barshelves);
+               $template->param(       barshelves      => scalar (@$barshelves),
+                                                       barshelvesloop  => $barshelves,
+                                                       );
+                       $template->param(       bartotal                => $total->{'bartotal'}, ) if ($total->{'bartotal'} > scalar (@$barshelves));
                }
 
         $borrowernumber = getborrowernumber($user);
@@ -240,10 +244,12 @@ sub get_template_and_user {
 
         $template->param( sessionID        => $sessionID );
                
-               my ($pubshelves) = C4::Context->get_shelves_userenv();  # an anonymous user has no 'barshelves'...
+               my ($total, $pubshelves) = C4::Context->get_shelves_userenv();  # an anonymous user has no 'barshelves'...
                if (defined(($pubshelves))) {
-               $template->param( pubshelves     => scalar (@$pubshelves));
-               $template->param( pubshelvesloop => $pubshelves);
+               $template->param(       pubshelves      => scalar (@$pubshelves),
+                                                       pubshelvesloop  => $pubshelves,
+                                                       );
+                       $template->param(       pubtotal                => $total->{'pubtotal'}, ) if ($total->{'pubtotal'} > scalar (@$pubshelves));
                }
 
        }
@@ -519,6 +525,7 @@ sub checkauth {
             );
             C4::Context::set_shelves_userenv('bar',$session->param('barshelves'));
             C4::Context::set_shelves_userenv('pub',$session->param('pubshelves'));
+            C4::Context::set_shelves_userenv('tot',$session->param('totshelves'));
             $debug and printf STDERR "AUTH_SESSION: (%s)\t%s %s - %s\n", map {$session->param($_)} qw(cardnumber firstname surname branch) ;
             $ip       = $session->param('ip');
             $lasttime = $session->param('lasttime');
@@ -699,15 +706,22 @@ sub checkauth {
                                        $session->param('emailaddress'), $session->param('branchprinter')
                                );
 
-                               # Grab borrower's shelves and add to the session...
-                               $barshelves = GetShelvesSummary($borrowernumber,2,10);
-                               $session->param('barshelves', $barshelves);
-                               C4::Context::set_shelves_userenv('bar',$barshelves);
-
-                               # Grab the public shelves and add to the session...
-                               $pubshelves = GetShelvesSummary(0,2,10);
-                               $session->param('pubshelves', $pubshelves);
-                               C4::Context::set_shelves_userenv('pub',$pubshelves);
+                               # Grab borrower's shelves and public shelves and add them to the session
+                               # $row_count determines how many records are returned from the db query
+                               # and the number of lists to be displayed of each type in the 'Lists' button drop down
+                               my $row_count = 10; # FIXME:This probably should be a syspref
+                               my ($total, $totshelves, $barshelves, $pubshelves);
+                               ($barshelves, $totshelves) = GetRecentShelves(1, $row_count, $borrowernumber);
+                               $total->{'bartotal'} = $totshelves;
+                               ($pubshelves, $totshelves) = GetRecentShelves(2, $row_count, undef);
+                               $total->{'pubtotal'} = $totshelves;
+                               $session->param('barshelves', ${@$barshelves}[0]);
+                               $session->param('pubshelves', ${@$pubshelves}[0]);
+                               $session->param('totshelves', $total);
+                               
+                               C4::Context::set_shelves_userenv('bar',${@$barshelves}[0]);
+                               C4::Context::set_shelves_userenv('pub',${@$pubshelves}[0]);
+                               C4::Context::set_shelves_userenv('tot',$total);
                        }
                else {
                if ($userid) {
@@ -722,9 +736,14 @@ sub checkauth {
                        $debug and warn "Initiating an anonymous session...";
 
                        # Grab the public shelves and add to the session...
-                       $pubshelves = GetShelvesSummary(0,2,10);
-                       $session->param('pubshelves', $pubshelves);
-                       C4::Context::set_shelves_userenv('pub',$pubshelves);
+                       my $row_count = 20; # FIXME:This probably should be a syspref
+                       my ($total, $totshelves, $pubshelves);
+                       ($pubshelves, $totshelves) = GetRecentShelves(2, $row_count, undef);
+                       $total->{'pubtotal'} = $totshelves;
+                       $session->param('pubshelves', ${@$pubshelves}[0]);
+                       $session->param('pubtotal', $total->{'pubtotal'});
+                       C4::Context::set_shelves_userenv('pub',${@$pubshelves}[0]);
+                       C4::Context::set_shelves_userenv('tot',$total);
                        
                        # setting a couple of other session vars...
                        $session->param('ip',$session->remote_addr());
index 20e5794..efd344f 100644 (file)
@@ -913,6 +913,7 @@ sub set_shelves_userenv ($$) {
        my $activeuser = $context->{activeuser} or return undef;
        $context->{userenv}->{$activeuser}->{barshelves} = $shelves if $type eq 'bar';
        $context->{userenv}->{$activeuser}->{pubshelves} = $shelves if $type eq 'pub';
+       $context->{userenv}->{$activeuser}->{totshelves} = $shelves if $type eq 'tot';
 }
 
 sub get_shelves_userenv () {
@@ -921,9 +922,10 @@ sub get_shelves_userenv () {
                $debug and warn "get_shelves_userenv cannot retrieve context->{userenv}->{context->{activeuser}}";
                return undef;
        }
+       my $totshelves = $active->{totshelves} or undef;
        my $pubshelves = $active->{pubshelves} or undef;
-       my $barshelves = $active->{barshelves} or undef;#  die "get_shelves_userenv: activeenv has no ->{shelves}";
-       return $pubshelves, $barshelves;
+       my $barshelves = $active->{barshelves} or undef;
+       return ($totshelves, $pubshelves, $barshelves);
 }
 
 =item _new_userenv
index e5c8adc..fbb100d 100644 (file)
@@ -37,16 +37,21 @@ BEGIN {
        @ISA    = qw(Exporter);
        @EXPORT = qw(
         &GetShelves &GetShelfContents &GetShelf
+               &GetRecentShelves &GetShelvesSummary
 
         &AddToShelf &AddToShelfFromBiblio &AddShelf
 
+               &SetShelvesLimit
+               &RefreshShelvesSummary
+
         &ModShelf
         &ShelfPossibleAction
         &DelFromShelf &DelShelf
        );
-       @EXPORT_OK = qw(&GetShelvesSummary);
 }
 
+use C4::Auth qw(get_session);
+
 my $dbh = C4::Context->dbh;
 
 =head1 NAME
@@ -69,18 +74,15 @@ items to and from virtualshelves.
 
 =item GetShelves
 
-  $shelflist = &GetShelves($owner);
-  $shelflist = &GetShelves($owner, $mincategory);
-  $shelflist = &GetShelves($owner, $mincategory, $limit);
+  ($shelflist, $totshelves) = &GetShelves($mincategory, $row_count, $offset, $owner);
   ($shelfnumber, $shelfhash) = each %{$shelflist};
 
-Looks up the virtual virtualshelves, and returns a summary. C<$shelflist>
-is a reference-to-hash. The keys are the virtualshelves numbers
-(C<$shelfnumber>, above), and the values (C<$shelfhash>, above) are
-themselves references-to-hash, with the following keys:
-
-C<mincategory> : 2 if the list is for "Public", 3 for "Open".
-virtualshelves of the owner are always selected, whatever the category
+Returns the number of shelves specified by C<$row_count> and C<$offset> as well as the total
+number of shelves that meet the C<$owner> and C<$mincategory> criteria.  C<$mincategory>,
+C<$row_count>, and C<$offset> are required. C<$owner> must be supplied when C<$mincategory> == 1.
+When C<$mincategory> is 2 or 3, supply undef as argument for C<$owner>.
+C<$shelflist>is a reference-to-hash. The keys are the virtualshelves numbers (C<$shelfnumber>, above),
+and the values (C<$shelfhash>, above) are themselves references-to-hash, with the following keys:
 
 =over 4
 
@@ -96,32 +98,33 @@ The number of virtuals on that virtualshelves.
 
 =cut
 
-sub GetShelves {
-    my ($owner, $mincategory, $limit) = @_;
-       ($mincategory and $mincategory =~ /^\d+$/) or $mincategory = 2;
-       (      $limit and       $limit =~ /^\d+$/) or $limit = undef;
+sub GetShelves ($$$$) {
+    my ($mincategory, $row_count, $offset, $owner) = @_;
+       my @params = ($owner, $mincategory, ($offset ? $offset : 0), $row_count);
+       my @params1 = ($owner, $mincategory);
+       if ($mincategory > 1) {
+               shift @params;
+               shift @params1;
+       }
+       my $total = _shelf_count($owner, $mincategory);
+    # grab only the shelves meeting the row_count/offset spec...
     my $query = qq(
         SELECT virtualshelves.shelfnumber, virtualshelves.shelfname,owner,surname,firstname,virtualshelves.category,virtualshelves.sortfield,
                count(virtualshelfcontents.biblionumber) as count
         FROM   virtualshelves
             LEFT JOIN   virtualshelfcontents ON virtualshelves.shelfnumber = virtualshelfcontents.shelfnumber
-            LEFT JOIN   borrowers ON virtualshelves.owner = borrowers.borrowernumber
-        WHERE  owner=? OR category>=?
+            LEFT JOIN   borrowers ON virtualshelves.owner = borrowers.borrowernumber );
+    $query .= ($mincategory == 1) ? "WHERE  owner=? AND category=?" : "WHERE category>=?";
+       $query .= qq(
         GROUP BY virtualshelves.shelfnumber
-        ORDER BY virtualshelves.category, virtualshelves.shelfname, borrowers.firstname, borrowers.surname
-    );
-       $limit and $query .= " LIMIT $limit ";
-    my $sth = $dbh->prepare($query);
-    $sth->execute( $owner, $mincategory );
+        ORDER BY virtualshelves.category
+               DESC 
+               LIMIT ?, ?);
+    my $sth2 = $dbh->prepare($query);
+    $sth2->execute(@params);
     my %shelflist;
-    while (
-        my (
-            $shelfnumber, $shelfname, $owner, $surname,
-            $firstname,   $category,  $sortfield, $count
-        )
-        = $sth->fetchrow
-      )
-    {
+    while ( my ( $shelfnumber, $shelfname, $owner, $surname,
+               $firstname,   $category,  $sortfield, $count ) = $sth2->fetchrow ) {
         $shelflist{$shelfnumber}->{'shelfname'} = $shelfname;
         $shelflist{$shelfnumber}->{'count'}     = $count;
         $shelflist{$shelfnumber}->{'sortfield'} = $sortfield;
@@ -130,14 +133,31 @@ sub GetShelves {
         $shelflist{$shelfnumber}->{'surname'}   = $surname;
         $shelflist{$shelfnumber}->{'firstname'} = $firstname;
     }
-    return ( \%shelflist );
+    return ( \%shelflist, $total );
 }
 
-sub GetShelvesSummary {
-    my ($owner, $mincategory, $limit) = @_;
-       ($mincategory and $mincategory =~ /^\d+$/) or $mincategory = 2;
-       (      $limit and       $limit =~ /^\d+$/) or $limit = 10;
-    my $query = qq(
+=item GetShelvesSummary
+
+       ($shelves, $total) = GetShelvesSummary($mincategory, $row_count, $offset, $owner)
+
+Returns the number of shelves specified by C<$row_count> and C<$offset> as well as the total
+number of shelves that meet the C<$owner> and/or C<$mincategory> criteria. C<$mincategory>,
+C<$row_count>, and C<$offset> are required. C<$owner> must be supplied when C<$mincategory> == 1.
+When C<$mincategory> is 2 or 3, supply undef as argument for C<$owner>.
+
+=cut
+
+sub GetShelvesSummary ($$$$) {
+    my ($mincategory, $row_count, $offset, $owner) = @_;
+       my @params = ($owner, $mincategory, ($offset ? $offset : 0), $row_count);
+       my @params1 = ($owner, $mincategory);
+       if ($mincategory > 1) {
+               shift @params;
+               shift @params1;
+       }
+       my $total = _shelf_count($owner, $mincategory);
+    # grab only the shelves meeting the row_count/offset spec...
+       my $query = qq(
                SELECT
                        virtualshelves.shelfnumber,
                        virtualshelves.shelfname,
@@ -147,25 +167,17 @@ sub GetShelvesSummary {
                        count(virtualshelfcontents.biblionumber) AS count
                FROM   virtualshelves
                        LEFT JOIN  virtualshelfcontents ON virtualshelves.shelfnumber = virtualshelfcontents.shelfnumber
-                       LEFT JOIN             borrowers ON virtualshelves.owner = borrowers.borrowernumber
-               WHERE  owner=? OR category>=?
+                       LEFT JOIN             borrowers ON virtualshelves.owner = borrowers.borrowernumber );
+    $query .= ($mincategory == 1) ? "WHERE  owner=? AND category=?" : "WHERE category>=?";
+       $query .= qq(
                GROUP BY virtualshelves.shelfnumber
-               ORDER BY virtualshelves.category, borrowers.surname, borrowers.firstname, virtualshelves.shelfname
-               LIMIT ?
-       );
-       my $sth = $dbh->prepare($query);
-       $sth->execute($owner,$mincategory,$limit);
-
-    my $shelves = $sth->fetchall_arrayref({});
-    # add private flag to each shelf entry --
-    # need to do this because HTML::Template::Pro's EXPR
-    # support complains about a non-initialized 'category'
-    # if the user has no shelves -- the offending line in
-    # masthead.inc was <-- TMPL_IF EXPR="category == 1"...
-    foreach my $shelf (@{ $shelves }) {
-        $shelf->{'private'} = ($shelf->{'category'} == 1);
-    }
-    return $shelves;
+               ORDER BY virtualshelves.category
+               DESC 
+               LIMIT ?, ?);
+       my $sth2 = $dbh->prepare($query);
+       $sth2->execute(@params);
+    my $shelves = $sth2->fetchall_arrayref({});
+    return ($shelves, $total);
 
        # Probably NOT the final implementation since it is still bulky (repeated hash keys).
        # might like an array of rows of delimited values:
@@ -173,6 +185,34 @@ sub GetShelvesSummary {
        # 2|6|Josh Ferraro|51|en_fuego|106
 }
 
+=item GetRecentShelves
+
+       ($shelflist) = GetRecentShelves(1, $limit, $owner)
+
+This function returns a references to an array of hashrefs containing specified shelves sorted
+by the date the shelf was last modified in descending order limited to the number of records
+specified by C<$row_count>. If calling with C<$mincategory> other than 1, use undef as C<$owner>.
+
+This function is intended to return a dataset reflecting the most recently active shelves for
+the submitted parameters.
+
+=cut
+
+sub GetRecentShelves ($$$) {
+       my ($mincategory, $row_count, $owner) = @_;
+    my (@shelflist);
+       my $total = _shelf_count($owner, $mincategory);
+       my @params = ($owner, $mincategory, 0, $row_count);      #FIXME: offset is hardcoded here, but could be passed in for enhancements
+       shift @params if !$owner;
+       my $query = "SELECT * FROM virtualshelves";
+       $query .= ($owner ? " WHERE owner = ? AND category = ?" : " WHERE category >= ? ");
+       $query .= " ORDER BY lastmodified DESC LIMIT ?, ?";
+       my $sth = $dbh->prepare($query);
+       $sth->execute(@params);
+       @shelflist = $sth->fetchall_arrayref({});
+       return ( \@shelflist, $total );
+}
+
 =item GetShelf
 
   (shelfnumber,shelfname,owner,category,sortfield) = &GetShelf($shelfnumber);
@@ -184,7 +224,7 @@ Returns the database's information on 'virtualshelves' table.
 
 =cut
 
-sub GetShelf {
+sub GetShelf ($) {
     my ($shelfnumber) = @_;
     my $query = qq(
         SELECT shelfnumber, shelfname, owner, category, sortfield
@@ -214,13 +254,16 @@ from C4::Circulation.
 
 =cut
 
-sub GetShelfContents {
-    my ( $shelfnumber ,$sortfield) = @_;
+sub GetShelfContents ($$;$$) {
+    my ($shelfnumber, $row_count, $offset, $sortfield) = @_;
     my $dbh=C4::Context->dbh();
+       my $sth1 = $dbh->prepare("SELECT count(*) FROM virtualshelfcontents WHERE shelfnumber = ?");
+       $sth1->execute($shelfnumber);
+       my $total = $sth1->fetchrow;
        if(!$sortfield) {
-               my $sthsort = $dbh->prepare('SELECT sortfield FROM virtualshelves WHERE shelfnumber=?');
-               $sthsort->execute($shelfnumber);
-               ($sortfield) = $sthsort->fetchrow_array;
+               my $sth2 = $dbh->prepare('SELECT sortfield FROM virtualshelves WHERE shelfnumber=?');
+               $sth2->execute($shelfnumber);
+               ($sortfield) = $sth2->fetchrow_array;
        }
     my $query =
        " SELECT vc.biblionumber, vc.shelfnumber, vc.dateadded,
@@ -230,13 +273,18 @@ sub GetShelfContents {
                 LEFT JOIN biblioitems ON  biblio.biblionumber = biblioitems.biblionumber
                 LEFT JOIN itemtypes   ON biblioitems.itemtype = itemtypes.itemtype
          WHERE  vc.shelfnumber=? ";
+       my @params = ($shelfnumber);
        if($sortfield) {
-               $query .= " ORDER BY `$sortfield` ";
+               $query .= " ORDER BY ? ";
                $query .= " DESC " if ($sortfield eq 'copyrightdate');
+               push (@params, $sortfield);
        }
-    my $sth = $dbh->prepare($query);
-       $sth->execute($shelfnumber);
-       return $sth->fetchall_arrayref({});     
+       $query .= " LIMIT ?, ? ";
+       push (@params, ($offset ? $offset : 0));
+       push (@params, $row_count);
+    my $sth3 = $dbh->prepare($query);
+       $sth3->execute(@params);
+       return ($sth3->fetchall_arrayref({}), $total);
        # Like the perldoc says,
        # returns reference-to-array, where each element is reference-to-hash of the row:
        #   like [ $sth->fetchrow_hashref(), $sth->fetchrow_hashref() ... ] 
@@ -259,7 +307,7 @@ Returns a code to know what's happen.
 =cut
 
 sub AddShelf {
-    my ( $shelfname, $owner, $category ) = @_;
+    my ( $shelfname, $owner, $category, $sortfield ) = @_;
     my $query = qq(
         SELECT *
         FROM   virtualshelves
@@ -270,11 +318,11 @@ sub AddShelf {
     ( $sth->rows ) and return (-1);
     $query = qq(
         INSERT INTO virtualshelves
-            (shelfname,owner,category)
-        VALUES (?,?,?)
+            (shelfname,owner,category,sortfield)
+        VALUES (?,?,?,?)
     );
     $sth = $dbh->prepare($query);
-    $sth->execute( $shelfname, $owner, $category );
+    $sth->execute( $shelfname, $owner, $category, $sortfield );
     my $shelfnumber = $dbh->{'mysql_insertid'};
     return ($shelfnumber);
 }
@@ -309,6 +357,11 @@ sub AddToShelf {
        );
        $sth = $dbh->prepare($query);
        $sth->execute( $shelfnumber, $biblionumber );
+       $query = qq(UPDATE virtualshelves
+                               SET lastmodified = CURRENT_TIMESTAMP
+                               WHERE shelfnumber = ?);
+       $sth = $dbh->prepare($query);
+       $sth->execute( $shelfnumber );
 }
 
 =item AddToShelfFromBiblio
@@ -339,6 +392,11 @@ sub AddToShelfFromBiblio {
         );
         $sth = $dbh->prepare($query);
         $sth->execute( $shelfnumber, $biblionumber );
+               $query = qq(UPDATE virtualshelves
+                                       SET lastmodified = CURRENT_TIMESTAMP
+                                       WHERE shelfnumber = ?);
+               $sth = $dbh->prepare($query);
+               $sth->execute( $shelfnumber );
     }
 }
 
@@ -472,6 +530,57 @@ sub DelShelf {
        return $sth->execute(shift);
 }
 
+=item RefreshShelvesSummary
+
+       ($total, $pubshelves, $barshelves) = RefreshShelvesSummary($sessionID, $loggedinuser, $row_count);
+
+Updates the current session and userenv with the most recent shelves
+
+Returns the total number of shelves stored in the session/userenv along with two references each to an
+array of hashes, one containing the C<$loggedinuser>'s private shelves and one containing all public/open shelves.
+
+This function is used in conjunction with the 'Lists' button in masthead.inc.
+
+=cut
+
+sub RefreshShelvesSummary ($$$) {
+       
+       my ($sessionID, $loggedinuser, $row_count) = @_;
+       my $session = get_session($sessionID);
+       my ($total, $totshelves, $barshelves, $pubshelves);
+
+       ($barshelves, $totshelves) = GetRecentShelves(1, $row_count, $loggedinuser);
+       $total->{'bartotal'} = $totshelves;
+       ($pubshelves, $totshelves) = GetRecentShelves(2, $row_count, undef);
+       $total->{'pubtotal'} = $totshelves;
+
+       # Update the current session with the latest shelves...
+       $session->param('barshelves', ${@$barshelves}[0]);
+       $session->param('pubshelves', ${@$pubshelves}[0]);
+       $session->param('totshelves', $total);
+
+       # likewise the userenv...
+       C4::Context->set_shelves_userenv('bar',${@$barshelves}[0]);
+       C4::Context->set_shelves_userenv('pub',${@$pubshelves}[0]);
+       C4::Context::set_shelves_userenv('tot',$total);
+
+       return ($total, $pubshelves, $barshelves);
+}
+
+# internal subs
+
+sub _shelf_count ($$) {
+       my (@params) = @_;
+       # Find out how many shelves total meet the submitted criteria...
+       my $query = "SELECT count(*) FROM virtualshelves";
+       $query .= ($params[1] > 1) ? " WHERE category >= ?" : " WHERE  owner=? AND category=?";
+       shift @params if $params[1] > 1;
+       my $sth = $dbh->prepare($query);
+       $sth->execute(@params);
+       my $total = $sth->fetchrow;
+       return $total;
+}
+
 1;
 
 __END__
index af85ed5..7c28918 100755 (executable)
@@ -23,7 +23,7 @@ package C4::VirtualShelves::Page;
 use strict;
 use warnings;
 use CGI;
-use C4::VirtualShelves qw/:DEFAULT GetShelvesSummary/;
+use C4::VirtualShelves;
 use C4::Biblio;
 use C4::Items;
 use C4::Koha;
@@ -32,6 +32,7 @@ use C4::Members;
 use C4::Output;
 use C4::Dates qw/format_date/;
 use Exporter;
+use Data::Dumper;
 
 use vars qw($debug @EXPORT @ISA $VERSION);
 
@@ -58,11 +59,22 @@ sub shelfpage ($$$$$) {
        $template or die "No template";
        $template->param( { loggedinuser => $loggedinuser } );
        my @paramsloop;
+       my $totitems;
+       my $shelfoff = ($query->param('shelfoff') ? $query->param('shelfoff') : 1);
+       my $itemoff = ($query->param('itemoff') ? $query->param('itemoff') : 1);
+       my $displaymode = ($query->param('display') ? $query->param('display') : 'publicshelves');
+       my ($shelflimit, $shelfoffset, $shelveslimit, $shelvesoffset);
+       # FIXME: These limits should not be hardcoded...
+       $shelflimit = 20;       # Limits number of items returned for a given query
+       $shelfoffset = (($itemoff == 1) ? 0 : ($itemoff * 10));         # Sets the offset to begin retrieving items at
+       $shelveslimit = 20;     # Limits number of shelves returned for a given query (row_count)
+       $shelvesoffset = (($shelfoff == 1) ? 0 : ($shelfoff * 10));             # Sets the offset to begin retrieving shelves at (offset)
        # getting the Shelves list
-       my $shelflist = GetShelves( $loggedinuser, 2 );
+       my $category = (($displaymode eq 'privateshelves') ? 1 : 2);
+       my ($shelflist, $totshelves) = GetShelves( $category, $shelveslimit, $shelvesoffset, $loggedinuser );
        my $op = $query->param('op');
-    my $imgdir = getitemtypeimagesrc();
-    my $itemtypes = GetItemTypes();
+#    my $imgdir = getitemtypeimagesrc();
+#    my $itemtypes = GetItemTypes();
     
 # the format of this is unindented for ease of diff comparison to the old script
 # Note: do not mistake the assignment statements below for comparisons!
@@ -92,7 +104,7 @@ if ( $query->param('modifyshelfcontents') ) {
 
 my $showadd = 1;
 # set the default tab, etc. (for OPAC)
-my $shelf_type = $query->param('display');
+my $shelf_type = ($query->param('display') ? $query->param('display') : 'publicshelves');
 if (defined $shelf_type) {
        if ($shelf_type eq 'privateshelves')  {
                $template->param(showprivateshelves => 1);
@@ -102,6 +114,8 @@ if (defined $shelf_type) {
        } else {
                $debug and warn "Invalid 'display' param ($shelf_type)";
        }
+} elsif ($loggedinuser == -1) {
+       $template->param(showpublicshelves => 1);
 } else {
        $template->param(showprivateshelves => 1);
 }
@@ -109,10 +123,12 @@ if (defined $shelf_type) {
 my($okmanage, $okview);
 my $shelfnumber = $query->param('shelfnumber') || $query->param('viewshelf');
 if ($shelfnumber) {
-       $okmanage = &ShelfPossibleAction( $loggedinuser, $shelfnumber, 'manage' );
-       $okview   = &ShelfPossibleAction( $loggedinuser, $shelfnumber, 'view' );
+       $okmanage = ShelfPossibleAction( $loggedinuser, $shelfnumber, 'manage' );
+       $okview   = ShelfPossibleAction( $loggedinuser, $shelfnumber, 'view' );
 }
 
+my $delflag = 0;
+
 SWITCH: {
        if ( $op ) {
                unless ($okmanage) {
@@ -127,8 +143,7 @@ SWITCH: {
                        };
 
                        ModShelf( $shelfnumber, $shelf );
-                       $shelflist = GetShelves( $loggedinuser, 2 );    # refresh after mods; this also retrieves all public shelves
-               
+
                } elsif ( $op eq 'modif' ) {
                        my ( $shelfnumber2, $shelfname, $owner, $category, $sortfield ) =GetShelf( $shelfnumber );
                        my $member = GetMember($owner,'borrowernumber');
@@ -149,10 +164,13 @@ SWITCH: {
     if ($shelfnumber = $query->param('viewshelf') ) {
         #check that the user can view the shelf
                if ( ShelfPossibleAction( $loggedinuser, $shelfnumber, 'view' ) ) {
-                       my $items = GetShelfContents($shelfnumber);
+                       my $items;
+                       ($items, $totitems) = GetShelfContents($shelfnumber, $shelflimit, $shelfoffset);
                        for my $this_item (@$items) {
-                               $this_item->{imageurl} = $imgdir."/".$itemtypes->{ $this_item->{itemtype}  }->{'imageurl'};
-                               $this_item->{'description'} = $itemtypes->{ $this_item->{itemtype} }->{'description'};
+                               # the virtualshelfcontents table does not store these columns nor are they retrieved from the items
+                               # and itemtypes tables, so I'm commenting them out for now to quiet the log -crn
+                               #$this_item->{imageurl} = $imgdir."/".$itemtypes->{ $this_item->{itemtype}  }->{'imageurl'};
+                               #$this_item->{'description'} = $itemtypes->{ $this_item->{itemtype} }->{'description'};
                                $this_item->{'dateadded'} = format_date($this_item->{'dateadded'});
                        }
                        $showadd = 1;
@@ -160,13 +178,12 @@ SWITCH: {
                        foreach (grep {$i++ % 2} @$items) {     # every other item
                                $_->{toggle} = 1;
                        }
-                       # my $manageshelf = &ShelfPossibleAction( $loggedinuser, $shelfnumber, 'manage' );
-                       # ($manageshelf) and $showadd = 1;
+                       my $manageshelf = ShelfPossibleAction( $loggedinuser, $shelfnumber, 'manage' );
                        $template->param(
                                shelfname   => $shelflist->{$shelfnumber}->{'shelfname'},
                                shelfnumber => $shelfnumber,
                                viewshelf   => $shelfnumber,
-                               manageshelf => &ShelfPossibleAction( $loggedinuser, $shelfnumber, 'manage' ),
+                               manageshelf => $manageshelf,
                                itemsloop => $items,
                        );
                } else { push @paramsloop, {nopermission=>$shelfnumber} };
@@ -179,7 +196,8 @@ SWITCH: {
             my $shelfnumber = AddShelf(
                 $newshelf,
                 $query->param('owner'),
-                $query->param('category')
+                $query->param('category'),
+                $query->param('sortfield')
             );
                        $stay = 1;
             if ( $shelfnumber == -1 ) {    #shelf already exists.
@@ -193,6 +211,7 @@ SWITCH: {
         }
                foreach ($query->param()) {
                        /DEL-(\d+)/ or next;
+                       $delflag = 1;
                        my $number = $1;
                        unless (defined $shelflist->{$number}) {
                                push(@paramsloop, {unrecognized=>$number}); last;
@@ -200,7 +219,8 @@ SWITCH: {
                        unless (ShelfPossibleAction($loggedinuser, $number, 'manage')) {
                                push(@paramsloop, {nopermission=>$shelfnumber}); last;
                        }
-                       my $contents = GetShelfContents($number);
+                       my $contents;
+                       ($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});
@@ -225,13 +245,13 @@ SWITCH: {
 }
 
 (@paramsloop) and $template->param(paramsloop => \@paramsloop);
-# rebuild shelflist in case a shelf has been added
-# $shelflist = GetShelves( $loggedinuser, 2 );
 $showadd and $template->param(showadd => 1);
 my @shelvesloop;
 my @shelveslooppriv;
 my $numberCanManage = 0;
 
+# rebuild shelflist in case a shelf has been added
+($shelflist, $totshelves) = GetShelves( $category, $shelveslimit, $shelvesoffset, $loggedinuser ) unless $delflag;
 foreach my $element (sort { lc($shelflist->{$a}->{'shelfname'}) cmp lc($shelflist->{$b}->{'shelfname'}) } keys %$shelflist) {
        my %line;
        $shelflist->{$element}->{shelf} = $element;
@@ -239,7 +259,7 @@ foreach my $element (sort { lc($shelflist->{$a}->{'shelfname'}) cmp lc($shelflis
        my $owner    = $shelflist->{$element}->{ 'owner'  };
        my $canmanage = ShelfPossibleAction( $loggedinuser, $element, 'manage' );
        $shelflist->{$element}->{"viewcategory$category"} = 1;
-       $shelflist->{$element}->{canmanage} = $canmanage;
+       $shelflist->{$element}->{manageshelf} = $canmanage;
        if ($owner eq $loggedinuser or $canmanage) {
                $shelflist->{$element}->{'mine'} = 1;
        } 
@@ -254,7 +274,14 @@ foreach my $element (sort { lc($shelflist->{$a}->{'shelfname'}) cmp lc($shelflis
                push (@shelvesloop, $shelflist->{$element});
        }
 }
-
+my $url = $type eq 'opac' ? "/cgi-bin/koha/opac-shelves.pl" : "/cgi-bin/koha/virtualshelves/shelves.pl";
+$url .= "?display=" . $query->param('display') if $query->param('display');
+$url .= "?viewshelf=" . $query->param('viewshelf') if $query->param('viewshelf');
+if ($query->param('viewshelf')) {
+       $template->param( {pagination_bar => pagination_bar($url, (int($totitems/$shelflimit)) + (($totitems % $shelflimit) > 0 ? 1 : 0), $itemoff, "itemoff")} );
+} else {
+       $template->param( {pagination_bar => pagination_bar($url, (int($totshelves/$shelveslimit)) + (($totshelves % $shelveslimit) > 0 ? 1 : 0), $shelfoff, "shelfoff")} );
+}
 $template->param(
     shelveslooppriv => \@shelveslooppriv,
     shelvesloop     => \@shelvesloop,
@@ -272,13 +299,25 @@ if ($template->param( 'shelves' ) or
        $template->param( seflag => 1);
 }
 
-my $sessionID = $query->cookie("CGISESSID") ;
-my $session = get_session($sessionID);
-my $barshelves = GetShelvesSummary($loggedinuser, 2, 10);
-if (defined($barshelves)) {
-       $session->param('barshelves', $barshelves);
-       $template->param( barshelves     => scalar (@$barshelves));
-       $template->param( barshelvesloop => $barshelves);
+#FIXME:        This refresh really only needs to happen when there is a modification of some sort
+#              to the shelves, but the above code is so convoluted in its handling of the various
+#              options, it is easier to do this refresh every time C4::VirtualShelves::Page.pm is
+#              called
+
+my ($total, $pubshelves, $barshelves) = RefreshShelvesSummary($query->cookie("CGISESSID"),$loggedinuser,($loggedinuser == -1 ? 20 : 10));
+
+if (defined $barshelves) {
+       $template->param(       barshelves      => scalar (@{${@$barshelves}[0]}),
+                                               barshelvesloop  => ${@$barshelves}[0],
+                                       );
+       $template->param(       bartotal                => $total->{'bartotal'}, ) if ($total->{'bartotal'} > scalar (@{${@$barshelves}[0]}));
+}
+
+if (defined $pubshelves) {
+       $template->param(       pubshelves      => scalar (@{${@$pubshelves}[0]}),
+                                               pubshelvesloop  => ${@$pubshelves}[0],
+                                       );
+       $template->param(       pubtotal                => $total->{'pubtotal'}, ) if ($total->{'pubtotal'} > scalar (@{${@$pubshelves}[0]}));
 }
 
 output_html_with_http_headers $query, $cookie, $template->output;
index 803db7f..32b2de5 100644 (file)
@@ -29,7 +29,7 @@
 <ul class="toolbar">
        <li><a id="newshelf" href="/cgi-bin/koha/virtualshelves/shelves.pl?shelves=1">New List</a></li>
        <!-- TMPL_IF NAME="viewshelf" --><!-- TMPL_IF name="manageshelf" -->
-       <li><a id="editshelf" href="/cgi-bin/koha/virtualshelves/shelves.pl?op=modif&amp;shelf=<!-- TMPL_VAR NAME="shelfnumber" -->">Edit List</a></li>
+       <li><a id="editshelf" href="/cgi-bin/koha/virtualshelves/shelves.pl?shelfnumber=<!-- TMPL_VAR NAME="shelfnumber" -->&amp;op=modif">Edit List</a></li>
        <li id="deleteshelfc"><a id="deleteshelf" href="/cgi-bin/koha/virtualshelves/shelves.pl?shelves=1&amp;DEL-<!-- TMPL_VAR NAME="shelfnumber" -->=1">Delete List</a></li>
        <!-- /TMPL_IF --><!-- /TMPL_IF -->
 </ul>
index 03180cc..e24fffa 100644 (file)
@@ -76,7 +76,6 @@ $(document).ready(function(){
   <div id="yui-main">
    <div class="yui-g"><!-- TMPL_INCLUDE NAME="virtualshelves-toolbar.inc" -->
    </div>
-
 <!-- TMPL_IF NAME="paramsloop" -->
 <!-- TMPL_LOOP NAME="paramsloop" -->
 <div class="yui-ge">
@@ -114,10 +113,11 @@ $(document).ready(function(){
         <input type="hidden" name="modifyshelfcontents" value="1" />
  <fieldset>
   <legend>Contents of <i><!-- TMPL_VAR NAME="shelfname" --></i></legend>
-  <p><span class="checkall"></span><span class="clearall"></span></p>
+ <!--TMPL_IF NAME="manageshelf" --><p><span class="checkall"></span><span class="clearall"></span></p><!-- /TMPL_IF -->
+ <!-- TMPL_VAR name='pagination_bar'-->
     <table>
             <tr>
-                <th class="checkall">&nbsp;</th>
+                <!--TMPL_IF NAME="manageshelf" --><th class="checkall">&nbsp;</th><!-- /TMPL_IF -->
                 <!-- TMPL_UNLESS NAME="item-level_itypes" --><th>Item Type</th><!-- /TMPL_UNLESS -->
                 <th>Title</th>
                 <th>Author</th>
@@ -130,6 +130,7 @@ $(document).ready(function(){
                        <!-- TMPL_ELSE -->
                        <tr>
                        <!-- /TMPL_IF -->
+                       <!--TMPL_IF NAME="manageshelf" -->
                        <td>
                                <!-- TMPL_IF NAME="confirm" -->
                                <input type="hidden"   name="CONFIRM-<!-- TMPL_VAR NAME="confirm" -->" />
@@ -138,6 +139,7 @@ $(document).ready(function(){
                                <input type="checkbox" name="REM-<!-- TMPL_VAR NAME="biblionumber" -->" />
                                <!-- /TMPL_IF -->
                        </td>
+                       <!-- /TMPL_IF -->
                        <!-- TMPL_UNLESS NAME="item-level_itypes" --><td>
                 <img src="<!-- TMPL_VAR NAME="imageurl" -->" alt="<!-- TMPL_VAR NAME="description" -->" title="<!-- TMPL_VAR NAME="description" -->" /><!-- TMPL_VAR NAME="description" -->
                        <!-- /TMPL_UNLESS --></td>
@@ -210,11 +212,17 @@ $(document).ready(function(){
         <ol>
         <li><label for="addshelf">Name: </label><input id="addshelf" type="text" name="addshelf" size="25" /></li>
         <li><span class="label">Owner: </span><input type="hidden" name="owner" id="owner" value="<!-- TMPL_VAR name="loggedinuser" -->" /><!-- TMPL_VAR name="loggedinusername" --></li>
+               <li><label for="sortfield" >Sort this list by: </label>
+               <select name="sortfield">
+               <!-- TMPL_IF NAME="sort_title" --><option value="title" selected="selected">Title</option><!-- TMPL_ELSE --><option value="title">Title</option><!-- /TMPL_IF -->
+               <!-- TMPL_IF NAME="sort_author" --><option value="author" selected="selected">Author</option><!-- TMPL_ELSE --><option value="author">Author</option><!-- /TMPL_IF -->
+               <!-- TMPL_IF NAME="sort_copyrightdate" --><option value="copyrightdate" selected="selected">Copyrightdate</option><!-- TMPL_ELSE --><option value="copyrightdate">Copyrightdate</option><!-- /TMPL_IF -->
+               </select></li>
         <li><label for="category">Category: </label>
                        <select name="category" id="category">
                   <option value="1">Private</option>
                   <option value="2">Public</option>
-                  <option value="3">Free</option>
+                  <option value="3">Open</option>
                        </select></li></ol>
     <!-- /TMPL_IF -->
 
@@ -225,6 +233,12 @@ $(document).ready(function(){
                <ol>
                <li><label for="shelfname">Name: </label><input type="text" id="shelfname" name="shelfname" size="25" value='<!-- TMPL_VAR name="shelfname" ESCAPE="HTML" -->' /></li>
                <li><label for="owner">Owner: </label><input type="hidden" id="owner" name="owner" value="<!-- TMPL_IF NAME="owner" --><!-- TMPL_VAR NAME="ownername" --><!-- TMPL_ELSE --><!-- TMPL_VAR NAME="loggedinusername" --><!-- /TMPL_IF -->" /><!-- TMPL_IF NAME="owner" --><!-- TMPL_VAR NAME="ownername" --><!-- TMPL_ELSE --><!-- TMPL_VAR NAME="loggedinusername" --><!-- /TMPL_IF --></li>
+               <li><label for="sortfield" >Sort this list by: </label>
+               <select name="sortfield">
+               <!-- TMPL_IF NAME="sort_title" --><option value="title" selected="selected">Title</option><!-- TMPL_ELSE --><option value="title">Title</option><!-- /TMPL_IF -->
+               <!-- TMPL_IF NAME="sort_author" --><option value="author" selected="selected">Author</option><!-- TMPL_ELSE --><option value="author">Author</option><!-- /TMPL_IF -->
+               <!-- TMPL_IF NAME="sort_copyrightdate" --><option value="copyrightdate" selected="selected">Copyrightdate</option><!-- TMPL_ELSE --><option value="copyrightdate">Copyrightdate</option><!-- /TMPL_IF -->
+               </select></li>
                <li><label for="category">Category: </label>
                        <select id="category" name="category">
                        <!-- TMPL_IF name="category1" -->
@@ -253,49 +267,120 @@ $(document).ready(function(){
         <div class="help"><ul>
             <li>A <b>Private</b> List is managed by you and can be seen only by you.</li>
             <li> A <b>Public</b> List can be seen by everybody, but managed only by you.</li>
-            <li> A <b>Free</b> List can be seen and managed by everybody.</li>
+            <li> A <b>Open</b> List can be seen and managed by everybody.</li>
         </ul></div>
     </div>
 </div>
 <!-- /TMPL_IF --><!-- /seflag -->
 
 <!-- TMPL_UNLESS NAME="vseflag" -->
-<!-- TMPL_IF NAME="shelvesloopall" -->
-<h3>Lists</h3>
-<table>
-<tr><th>Name</th><th>Owner</th><th>Category</th><th>Items</th><th>&nbsp;</th></tr>
-<!-- TMPL_LOOP NAME="shelvesloopall" -->
-<!-- TMPL_IF NAME="toggle" --><tr class="highlight"><!-- TMPL_ELSE --><tr><!-- /TMPL_IF -->
-<td><a href="/cgi-bin/koha/virtualshelves/shelves.pl?viewshelf=<!-- TMPL_VAR NAME="shelf" -->"><!-- TMPL_VAR NAME="shelfname" --></a></td>
-<td><!-- TMPL_IF NAME="owner" --><!-- TMPL_VAR NAME="ownername" --><!-- TMPL_ELSE -->Koha Admin<!-- /TMPL_IF -->
-</td>
-<td>
-  <!-- TMPL_IF NAME="viewcategory1" -->Private<!-- /TMPL_IF -->
-  <!-- TMPL_IF NAME="viewcategory2" -->Public<!-- /TMPL_IF -->
-  <!-- TMPL_IF NAME="viewcategory3" -->Open<!-- /TMPL_IF -->
-</td>
-<td><!-- TMPL_VAR NAME="count" --></td>
-<td>
-       <form action="/cgi-bin/koha/virtualshelves/shelves.pl" method="get">
-               <input type="hidden" name="shelfnumber" value="<!-- TMPL_VAR NAME="shelf" -->" />
-               <input type="hidden" name="op" value="modif" />
-               <input type="submit" value="Edit" />
-       </form>
-       <form action="/cgi-bin/koha/virtualshelves/shelves.pl" method="post">
-               <input type="hidden" name="shelves" value="1" />
-               <input type="hidden" name="DEL-<!-- TMPL_VAR NAME="shelf" -->" value="1" />
-               <!-- TMPL_IF NAME="confirm" -->
-               <input type="hidden" name="CONFIRM-<!-- TMPL_VAR NAME="confirm" -->" value="1" />
-               <input type="submit" class="confirm" value="Confirm" />
+        <h2>Lists</h2>
+        <ul class="link-tabs">
+        <!-- TMPL_IF NAME="showprivateshelves" -->
+            <li id="privateshelves_tab" class="on"><a href="/cgi-bin/koha/virtualshelves/shelves.pl?display=privateshelves">Your Lists</a></li>
+        <!-- TMPL_ELSE -->
+            <li id="privateshelves_tab" class="off"><a href="/cgi-bin/koha/virtualshelves/shelves.pl?display=privateshelves">Your Lists</a></li>
+        <!-- /TMPL_IF -->
+        <!-- TMPL_IF NAME="showpublicshelves" -->
+            <li id="publicshelves_tab" class="on"><a href="/cgi-bin/koha/virtualshelves/shelves.pl?display=publicshelves">Public Lists</a></li>
+        <!-- TMPL_ELSE -->
+            <li id="publicshelves_tab" class="off"><a href="/cgi-bin/koha/virtualshelves/shelves.pl?display=publicshelves">Public Lists</a></li>
+        <!-- /TMPL_IF -->
+        </ul>
+        <!-- TMPL_IF NAME="showprivateshelves" -->
+               <div id="privateshelves" class="tab-container" style="display:block;">
                <!-- TMPL_ELSE -->
-               <input type="submit" onclick='return confirmDelete(_("Are you sure you want to remove this List?"));' value="Delete" />
+               <div id="privateshelves" class="tab-container" style="display:none;">
                <!-- /TMPL_IF -->
-       </form>
-</td>
-</tr>
-<!-- /TMPL_LOOP -->
-</table>
-<!-- /TMPL_IF -->
+            <!-- TMPL_IF NAME="shelveslooppriv" -->
+                       <!-- TMPL_VAR name='pagination_bar'-->
+                       <table>
+                       <tr><th>List Name</th><th>Contents</th><th>Sort by</th><th>Type</th><th>Options</th></tr>
+                <!-- TMPL_LOOP NAME="shelveslooppriv" -->
+                    <!-- TMPL_IF NAME="toggle" --><tr class="highlight"><!--TMPL_ELSE--><tr><!-- /TMPL_IF -->
+        <td><a href="shelves.pl?viewshelf=<!-- TMPL_VAR NAME="shelf" -->"><!-- TMPL_VAR NAME="shelfname" ESCAPE="html"  --></a></td>
+        <td><!-- TMPL_VAR NAME="count" --> item(s)</td>
+        <td><!-- TMPL_VAR NAME="sortfield" --></td>
+        <td><!-- TMPL_IF NAME="viewcategory1" -->Private<!-- /TMPL_IF -->
+                       <!-- TMPL_IF NAME="viewcategory2" -->Public<!-- /TMPL_IF -->
+                       <!-- TMPL_IF NAME="viewcategory3" -->Open<!-- /TMPL_IF -->
+               </td>
+        <td>
+            <!-- TMPL_IF NAME="mine" -->
+                               <form action="shelves.pl" method="get">
+                                       <input type="hidden" name="shelfnumber" value="<!-- TMPL_VAR NAME="shelf" -->" />
+                                       <input type="hidden" name="op" value="modif" />
+                                       <input type="submit" class="editshelf" value="Edit" />
+                               </form>
+                               <form action="shelves.pl" method="post">
+                                       <input type="hidden" name="shelves" value="1" />
+                                       <input type="hidden" name="DEL-<!-- TMPL_VAR NAME="shelf" -->" value="1" />
+                                       <!-- TMPL_IF NAME="confirm" -->
+                                       <input type="hidden" name="CONFIRM-<!-- TMPL_VAR NAME="confirm" -->" value="1" />
+                                       <input type="submit" class="confirm" value="Confirm" />
+                                       <!-- TMPL_ELSE -->
+                                       <input type="submit" class="deleteshelf" onclick="return confirmDelete(_('Are you sure you want to remove this List?'));" value="Delete" />
+                                       <!-- /TMPL_IF -->
+                               </form>
+                       <!-- TMPL_ELSE -->
+                               None
+                       <!-- /TMPL_IF -->
+               </td>
+               </tr>
+                <!-- /TMPL_LOOP -->
+            <!-- TMPL_ELSE -->
+            <tr><td colspan="4">No Private Lists.</td></tr>
+            <!-- /TMPL_IF --><!-- /shelveslooppriv -->
+        </table>
+               <a class="newshelf" href="/cgi-bin/koha/virtualshelves/shelves.pl?shelves=1">New List</a>
+               </div><!-- /privateshelves -->
+
+        <!-- TMPL_IF NAME="showpublicshelves" -->
+               <div id="publicshelves" class="tab-container" style="display:block;">
+               <!-- TMPL_ELSE -->
+               <div id="publicshelves" class="tab-container" style="display:none;">
+               <!-- /TMPL_IF -->
+        <!-- TMPL_IF NAME="shelvesloop" -->
+               <!-- TMPL_VAR name='pagination_bar'-->
+        <table>
+        <tr><th>List Name</th><th>Contents</th><th>Sort By</th><th>Type</th><th>Options</th></tr>
+            <!-- TMPL_LOOP NAME="shelvesloop" -->
+                <!-- TMPL_IF NAME="toggle" --><tr class="highlight"><!--TMPL_ELSE--><tr><!-- /TMPL_IF -->
+               <td><a href="shelves.pl?viewshelf=<!-- TMPL_VAR NAME="shelf" -->"><!-- TMPL_VAR NAME="shelfname" ESCAPE="html"  --></a></td>
+               <td><!-- TMPL_VAR NAME="count" --> item(s)</td>
+        <td><!-- TMPL_VAR NAME="sortfield" --></td>
+        <td><!-- TMPL_IF NAME="viewcategory1" -->Private<!-- /TMPL_IF -->
+                       <!-- TMPL_IF NAME="viewcategory2" -->Public<!-- /TMPL_IF -->
+                       <!-- TMPL_IF NAME="viewcategory3" -->Open<!-- /TMPL_IF -->
+               </td>
+        <td>
+            <!-- TMPL_IF NAME="manageshelf" -->
+                               <form action="shelves.pl" method="get">
+                                       <input type="hidden" name="shelfnumber" value="<!-- TMPL_VAR NAME="shelf" -->" />
+                                       <input type="hidden" name="op" value="modif" />
+                                       <input type="submit" class="editshelf" value="Edit" />
+                               </form>
+                               <form action="shelves.pl" method="post">
+                                       <input type="hidden" name="shelves" value="1" />
+                                       <input type="hidden" name="DEL-<!-- TMPL_VAR NAME="shelf" -->" value="1" />
+                                       <!-- TMPL_IF NAME="confirm" -->
+                                       <input type="hidden" name="CONFIRM-<!-- TMPL_VAR NAME="confirm" -->" value="1" />
+                                       <input type="submit" class="confirm" value="Confirm" />
+                                       <!-- TMPL_ELSE -->
+                                       <input type="submit" class="deleteshelf" onclick="return confirmDelete(_('Are you sure you want to remove this List?'));" value="Delete" />
+                                       <!-- /TMPL_IF -->
+                               </form>
+                       <!-- TMPL_ELSE -->
+                               None
+                       <!-- /TMPL_IF -->
+               </td>
+               </tr>
+            <!-- /TMPL_LOOP -->
+        </table>
+        <!-- TMPL_ELSE -->
+               <!-- TMPL_IF NAME="showpublicshelves" -->No Public Lists.<!-- /TMPL_IF -->
+        <!-- /TMPL_IF --><!-- /shelvesloop -->
+        </div><!-- /publicshelves -->
 <!-- /TMPL_UNLESS -->
 
 </div>
index 1eafec5..ddc0027 100755 (executable)
                <!-- TMPL_IF NAME="pubshelves" -->
                        <ul class="first-of-type">
                        <!-- TMPL_LOOP NAME="pubshelvesloop" -->
-                       <!-- TMPL_UNLESS NAME="private" --><li class="yuimenuitem"><a href="/cgi-bin/koha/opac-shelves.pl?viewshelf=<!-- TMPL_VAR NAME="shelfnumber" -->"><!-- TMPL_VAR NAME="shelfname"  ESCAPE="html" --></a></li><!-- /TMPL_UNLESS -->
+                       <li class="yuimenuitem"><a href="/cgi-bin/koha/opac-shelves.pl?viewshelf=<!-- TMPL_VAR NAME="shelfnumber" -->"><!-- TMPL_VAR NAME="shelfname"  ESCAPE="html" --></a></li>
                        <!-- /TMPL_LOOP -->
                        </ul>   
                <!-- TMPL_ELSE -->
                        No Public Lists
                <!-- /TMPL_IF -->
+               <!-- TMPL_IF NAME="pubtotal" -->
+                       <ul class="second-of-type">
+            <li class="yuimenuitem"><a class="yuimenuitemlabel" href="/cgi-bin/koha/opac-shelves.pl?display=publicshelves">View all <!--TMPL_VAR NAME="pubtotal" --> public lists</a></li>
+                       </ul>
+               <!-- /TMPL_IF -->
 <!-- TMPL_IF NAME="opacuserlogin" -->
 <!-- TMPL_IF NAME="loggedinusername" -->
 <h4>Your Lists</h4>
                <!-- TMPL_IF NAME="barshelves" -->
                        <ul class="first-of-type">
                        <!-- TMPL_LOOP NAME="barshelvesloop" -->
-                       <!-- TMPL_IF NAME="private" --><li class="yuimenuitem"><a href="/cgi-bin/koha/opac-shelves.pl?viewshelf=<!-- TMPL_VAR NAME="shelfnumber" -->"><!-- TMPL_VAR NAME="shelfname"  ESCAPE="html" --></a></li><!-- /TMPL_IF -->
+                       <li class="yuimenuitem"><a href="/cgi-bin/koha/opac-shelves.pl?viewshelf=<!-- TMPL_VAR NAME="shelfnumber" -->"><!-- TMPL_VAR NAME="shelfname"  ESCAPE="html" --></a></li>
                        <!-- /TMPL_LOOP -->
                        </ul>   
                <!-- TMPL_ELSE -->
                        No Private Lists
                <!-- /TMPL_IF -->
-
+               <!-- TMPL_IF NAME="bartotal" -->
                        <ul class="second-of-type">
-            <li class="yuimenuitem"><a class="yuimenuitemlabel" href="/cgi-bin/koha/opac-shelves.pl">Manage Lists</a></li>
+            <li class="yuimenuitem"><a class="yuimenuitemlabel" href="/cgi-bin/koha/opac-shelves.pl?display=privateshelves">View all <!--TMPL_VAR NAME="bartotal" --> of your lists</a></li>
+                       </ul>
+               <!-- /TMPL_IF -->
+               <ul class="second-of-type">
+        <li class="yuimenuitem"><a class="yuimenuitemlabel" href="/cgi-bin/koha/opac-shelves.pl">Manage Lists</a></li>
         </ul>
                <!-- TMPL_ELSE --><ul class="first-of-type"><li><a href="/cgi-bin/koha/opac-user.pl">Log in to Create Your Own Lists</a></li></ul><!-- /TMPL_IF -->
 <!-- /TMPL_IF -->
index 5b5a003..adbcf92 100644 (file)
@@ -9,58 +9,61 @@
 <div id="custom-doc" class="yui-t7">
 <div class="container">
 <!-- TMPL_IF NAME="authorized" -->
-<!-- TMPL_UNLESS NAME="newshelf" --><!-- TMPL_IF NAME="multiple"-->
-    <h1>Add <!-- TMPL_VAR NAME="total"--> items to <!-- TMPL_IF NAME="singleshelf" --><em><!-- TMPL_VAR NAME="shelfname" --></em>: <!-- TMPL_ELSE -->a list:<!-- /TMPL_IF --></h1>
-<!-- TMPL_ELSE -->
-       <h1>Add to <!-- TMPL_IF NAME="singleshelf" --><em><!-- TMPL_VAR NAME="shelfname" --></em><!-- TMPL_ELSE -->a list:<!-- /TMPL_IF --></h1>
-<!-- /TMPL_IF -->
-     <ul> <!-- TMPL_LOOP NAME="biblios"-->
-           <li> <span class="title"><!-- TMPL_VAR NAME="title"--></span> 
-            <!-- TMPL_IF NAME="author"--><span class="author"> <!-- TMPL_VAR NAME="author"--> </span><!-- /TMPL_IF -->
-            </li>
+       <!-- TMPL_UNLESS NAME="newshelf" -->
+               <!-- TMPL_IF NAME="multiple"-->
+               <h1>Add <!-- TMPL_VAR NAME="total"--> items to <!-- TMPL_IF NAME="singleshelf" --><em><!-- TMPL_VAR NAME="shelfname" --></em>: <!-- TMPL_ELSE -->a list:<!-- /TMPL_IF --></h1>
+               <!-- TMPL_ELSE -->
+                       <h1>Add to <!-- TMPL_IF NAME="singleshelf" --><em><!-- TMPL_VAR NAME="shelfname" --></em><!-- TMPL_ELSE -->a list:<!-- /TMPL_IF --></h1>
+               <!-- /TMPL_IF -->
+       <ul>
+               <!-- TMPL_LOOP NAME="biblios"-->
+               <li> <span class="title"><!-- TMPL_VAR NAME="title"--></span> 
+               <!-- TMPL_IF NAME="author"--><span class="author"> <!-- TMPL_VAR NAME="author"--> </span><!-- /TMPL_IF -->
+               </li>
         <!-- /TMPL_LOOP -->
-</ul>
-<!-- TMPL_IF NAME="CGIvirtualshelves"-->
-<form name="f1" action="/cgi-bin/koha/opac-addbybiblionumber.pl" method="post">
-    <fieldset class="rows"><legend>Select a List</legend>
-<ol><li>    <label for="shelfnumber">Add to list:</label> <!-- TMPL_VAR NAME="CGIvirtualshelves" --></li></ol>
- <!-- TMPL_LOOP NAME="biblios" --> <input type="hidden" name="biblionumber" value="<!-- TMPL_VAR NAME="biblionumber" -->" /><!-- /TMPL_LOOP -->
-    <input type="hidden" name="modifyshelfcontents" value="1" /></fieldset>
-    <fieldset class="action"><input type="submit" value="Save" class="submit" /> <a class="close cancel" href="#">Cancel</a></fieldset>
-</form>
-<p>...or...</p>
-<!-- TMPL_ELSE -->
-<!-- TMPL_IF NAME="singleshelf" -->
-<form name="f1" action="/cgi-bin/koha/opac-addbybiblionumber.pl" method="post">
-<!-- TMPL_LOOP NAME="biblios" --> <input type="hidden" name="biblionumber" value="<!-- TMPL_VAR NAME="biblionumber" -->"><!-- /TMPL_LOOP -->
-       <input type="hidden" name="shelfnumber" value="<!-- TMPL_VAR NAME="shelfnumber" -->" />
-    <input type="hidden" name="modifyshelfcontents" value="1" /></fieldset>
-    <fieldset class="action"><input type="submit" value="Save" class="submit" /> <a class="close cancel" href="#">Cancel</a></fieldset>
-</form>
-<!-- /TMPL_IF -->
-<!-- /TMPL_IF --><!-- /TMPL_UNLESS -->
-
-<!-- TMPL_UNLESS NAME="singleshelf" --><form name="f2" method="post" action="/cgi-bin/koha/opac-addbybiblionumber.pl">
-<fieldset class="rows">    <legend>Add to a New List:</legend>
-        <ol><li>
-            <label for="newvirtualshelf">
-                List Name:
-            </label>
-            <input type="text" name="newvirtualshelf" id="newvirtualshelf" size="40" />
-        </li>
-         <li><label for="category">Category:</label>
-            <select name="category" id="category">
-                <option value="1">Private</option>
-                <option value="2">Public</option>
-            </select></li></ol></fieldset>
- <!-- TMPL_LOOP NAME="biblios" --> <input type="hidden" name="biblionumber" value="<!-- TMPL_VAR NAME="biblionumber" -->" /><!-- /TMPL_LOOP -->
-    <fieldset class="action"><input type="submit" value="Save" class="submit" /> <a class="close cancel" href="#">Cancel</a></fieldset>
-</form><!-- /TMPL_UNLESS -->
+               </ul>
+               <!-- TMPL_IF NAME="CGIvirtualshelves"-->
+                       <form name="f1" action="/cgi-bin/koha/opac-addbybiblionumber.pl" method="post">
+               <fieldset class="rows"><legend>Select a List</legend>
+                       <ol><li>    <label for="shelfnumber">Add to list:</label> <!-- TMPL_VAR NAME="CGIvirtualshelves" --></li></ol>
+                       <!-- TMPL_LOOP NAME="biblios" --> <input type="hidden" name="biblionumber" value="<!-- TMPL_VAR NAME="biblionumber" -->" /><!-- /TMPL_LOOP -->
+               <input type="hidden" name="modifyshelfcontents" value="1" /></fieldset>
+               <fieldset class="action"><input type="submit" value="Save" class="submit" /> <a class="close cancel" href="#">Cancel</a></fieldset>
+                       </form>
+                       <p>...or...</p>
+               <!-- TMPL_ELSE -->
+                       <!-- TMPL_IF NAME="singleshelf" -->
+                               <form name="f1" action="/cgi-bin/koha/opac-addbybiblionumber.pl" method="post">
+                               <!-- TMPL_LOOP NAME="biblios" --> <input type="hidden" name="biblionumber" value="<!-- TMPL_VAR NAME="biblionumber" -->"><!-- /TMPL_LOOP -->
+                               <input type="hidden" name="shelfnumber" value="<!-- TMPL_VAR NAME="shelfnumber" -->" />
+                               <input type="hidden" name="modifyshelfcontents" value="1" /></fieldset>
+                               <fieldset class="action"><input type="submit" value="Save" class="submit" /> <a class="close cancel" href="#">Cancel</a></fieldset>
+                               </form>
+                       <!-- /TMPL_IF -->
+               <!-- /TMPL_IF -->
+       <!-- /TMPL_UNLESS -->
+       <!-- TMPL_UNLESS NAME="singleshelf" --><form name="f2" method="post" action="/cgi-bin/koha/opac-addbybiblionumber.pl">
+               <fieldset class="rows">    <legend>Add to a New List:</legend>
+               <ol><li>
+               <label for="newvirtualshelf">
+               List Name:
+               </label>
+               <input type="text" name="newvirtualshelf" id="newvirtualshelf" size="40" />
+               </li>
+               <li><label for="category">Category:</label>
+               <select name="category" id="category">
+               <option value="1">Private</option>
+               <option value="2">Public</option>
+               </select></li></ol></fieldset>
+               <!-- TMPL_LOOP NAME="biblios" --> <input type="hidden" name="biblionumber" value="<!-- TMPL_VAR NAME="biblionumber" -->" /><!-- /TMPL_LOOP -->
+               <fieldset class="action"><input type="submit" value="Save" class="submit" /> <a class="close cancel" href="#">Cancel</a></fieldset>
+               </form>
+       <!-- /TMPL_UNLESS -->
 <!-- TMPL_ELSE -->
-<p align="center">
-       This is not an open list.
-       Items cannot be added to it.
-</p>
+       <p align="center">
+               This is not an open list.
+               Items cannot be added to it.
+       </p>
 <!-- /TMPL_IF -->
 <p align="center">
     <a href="#" class="close">Close this window.</a>
index 196f115..0ec9d00 100644 (file)
 <script type="text/javascript">
 //<![CDATA[
 $(document).ready(function(){
+       var param1 = "<label for=\"addto\">Add to: </label><select name=\"addto\" id=\"addto\"><option value=\"\"></option>"<!-- TMPL_IF name="opacbookbag" -->+"<option value=\"addtocart\">Cart</option>"+<!-- /TMPL_IF --><!-- TMPL_IF NAME="virtualshelves" --><!-- TMPL_IF NAME="loggedinusername" -->"<optgroup label=\"Your Lists:\">"+<!-- TMPL_IF NAME="addbarshelves" --><!-- TMPL_LOOP NAME="addbarshelvesloop" -->"<option id=\"s<!-- TMPL_VAR NAME="shelfnumber" -->\" value=\"addtolist\"><!-- TMPL_VAR NAME="shelfname" ESCAPE="html"--></option>"+<!-- /TMPL_LOOP --><!-- /TMPL_IF -->"</optgroup>";
+       param1 += "<optgroup label=\"Public Lists:\">"+<!-- TMPL_IF NAME="addpubshelves" --><!-- TMPL_LOOP NAME="addpubshelvesloop" -->"<option id=\"s<!-- TMPL_VAR NAME="shelfnumber" -->\" value=\"addtolist\"><!-- TMPL_VAR NAME="shelfname" ESCAPE="html"--></option>"+<!-- /TMPL_LOOP --><!-- /TMPL_IF -->"</optgroup><option value=\"newlist\">[ New List ]</option>"+<!-- TMPL_ELSE -->"<optgroup label=\"Public Lists:\">"+<!-- TMPL_IF NAME="addpubshelves" --><!-- TMPL_LOOP NAME="addpubshelvesloop" -->"<option id=\"s<!-- TMPL_VAR NAME="shelfnumber" -->\" value=\"addtolist\"><!-- TMPL_VAR NAME="shelfname" ESCAPE="html"--></option>"+<!-- /TMPL_LOOP --><!-- /TMPL_IF -->"</optgroup>"+<!-- /TMPL_IF --><!-- /TMPL_IF -->"</select> <input type=\"submit\" class=\"submit\" value=\"Save\" />";
        $('#sortsubmit').hide();
     $('#sort_by').change(function() {
         $('#bookbag_form').submit();
     });
        $("span.clearall").html("<a id=\"CheckNone\" href=\"#\">Clear All</a>");
        $("span.checkall").html("<a id=\"CheckAll\" href=\"#\">Select All</a>");
-       $("span.addto").html("<label for=\"addto\">Add to: </label><select name=\"addto\" id=\"addto\"><option value=\"\"></option><!-- TMPL_IF name="opacbookbag" --><option value=\"addtocart\">Cart</option><!-- /TMPL_IF --><!-- TMPL_IF NAME="virtualshelves" --><!-- TMPL_IF NAME="loggedinusername" --><optgroup label=\"Your Lists:\"><!-- TMPL_IF NAME="barshelves" --><!-- TMPL_LOOP NAME="barshelvesloop" --><!-- TMPL_IF EXPR="category == 1" --><option id=\"s<!-- TMPL_VAR NAME="shelfnumber" -->\" value=\"addtolist\"><!-- TMPL_VAR NAME="shelfname" ESCAPE="html"--></option><!-- /TMPL_IF --><!-- /TMPL_LOOP --><!-- /TMPL_IF --></optgroup><optgroup label=\"Public Lists:\"><!-- TMPL_IF NAME="pubshelves" --><!-- TMPL_LOOP NAME="pubshelvesloop" --><option id=\"s<!-- TMPL_VAR NAME="shelfnumber" -->\" value=\"addtolist\"><!-- TMPL_VAR NAME="shelfname" ESCAPE="html"--></option><!-- /TMPL_LOOP --><!-- /TMPL_IF --></optgroup><option value=\"newlist\">[ New List ]</option><!-- TMPL_ELSE --><optgroup label=\"Public Lists:\"><!-- TMPL_IF NAME="pubshelves" --><!-- TMPL_LOOP NAME="pubshelvesloop" --><option id=\"s<!-- TMPL_VAR NAME="shelfnumber" -->\" value=\"addtolist\"><!-- TMPL_VAR NAME="shelfname" ESCAPE="html"--></option><!-- /TMPL_LOOP --><!-- /TMPL_IF --></optgroup><!-- /TMPL_IF --><!-- /TMPL_IF --></select> <input type=\"submit\" class=\"submit\" value=\"Save\" />");
+       $("span.addto").html(param1);
        $("#addto").change(function(){
                cartList();
        });
index 30603b4..6f1619f 100644 (file)
@@ -97,6 +97,7 @@ $.tablesorter.addParser({
     <!-- TMPL_IF NAME="manageshelf" --><form action="/cgi-bin/koha/opac-shelves.pl" method="post" name="myform" class="checkboxed">
         <input type="hidden" name="viewshelf" value="<!-- TMPL_VAR NAME="shelfnumber" -->" />
         <input type="hidden" name="modifyshelfcontents" value="1" /><!-- /TMPL_IF -->
+               <!-- TMPL_VAR name='pagination_bar'-->
 <table id="listcontents">
         <thead><tr>
             <!-- TMPL_IF NAME="manageshelf" --><th>&nbsp;</th><!-- /TMPL_IF -->
@@ -167,9 +168,15 @@ $.tablesorter.addParser({
             <!-- TMPL_IF NAME="sort_author" --><option value="author" selected="selected">Author</option><!-- TMPL_ELSE --><option value="author">Author</option><!-- /TMPL_IF -->
             <!-- TMPL_IF NAME="sort_copyrightdate" --><option value="copyrightdate" selected="selected">Copyrightdate</option><!-- TMPL_ELSE --><option value="copyrightdate">Copyrightdate</option><!-- /TMPL_IF -->
             </select></li>
+                       <li><label for="category">Category: </label>
+                               <select name="category" id="category">
+                                         <option value="1">Private</option>
+                                         <option value="2">Public</option>
+                               </select>
+                       </li>
             </ol>
             </fieldset>
-            <fieldset class="action"><input type="hidden" name="category" value="<!-- TMPL_VAR NAME="category" -->" /><input type="submit" value="Save" class="submit" /> <a class="cancel" href="/cgi-bin/koha/opac-shelves.pl?shelfnumber=<!-- TMPL_VAR NAME="shelfnumber" -->">Cancel</a></fieldset>
+            <fieldset class="action"><input type="submit" value="Save" class="submit" /> <a class="cancel" href="/cgi-bin/koha/opac-shelves.pl?shelfnumber=<!-- TMPL_VAR NAME="shelfnumber" -->">Cancel</a></fieldset>
         </form>
     <!-- /TMPL_IF -->
 
@@ -195,6 +202,7 @@ $.tablesorter.addParser({
         
                <!-- TMPL_IF NAME="loggedinusername" -->
             <!-- TMPL_IF NAME="shelveslooppriv" -->
+                       <!-- TMPL_VAR name='pagination_bar'-->
                        <table>
                        <tr><th>List Name</th><th>Contents</th><th>Sort by</th><th>Type</th><th>&nbsp;</th></tr>
                 <!-- TMPL_LOOP NAME="shelveslooppriv" -->
@@ -243,6 +251,7 @@ $.tablesorter.addParser({
                <div id="publicshelves" class="tab-container" style="display:none;">
                <!-- /TMPL_IF -->
         <!-- TMPL_IF NAME="shelvesloop" -->
+               <!-- TMPL_VAR name='pagination_bar'-->
         <table>
         <tr><th>List Name</th><th>Contents</th><th>Type</th></tr>
             <!-- TMPL_LOOP NAME="shelvesloop" -->
@@ -274,6 +283,12 @@ $.tablesorter.addParser({
                                <input id="addshelf" type="text" name="addshelf" size="60" />
                                <!-- /TMPL_IF -->
                                <input type="hidden" name="owner" id="owner" value="<!-- TMPL_VAR NAME="loggedinuser" -->" /></li>
+                               <li><label for="sortfield" >Sort this list by: </label>
+                               <select name="sortfield">
+                               <!-- TMPL_IF NAME="sort_title" --><option value="title" selected="selected">Title</option><!-- TMPL_ELSE --><option value="title">Title</option><!-- /TMPL_IF -->
+                               <!-- TMPL_IF NAME="sort_author" --><option value="author" selected="selected">Author</option><!-- TMPL_ELSE --><option value="author">Author</option><!-- /TMPL_IF -->
+                               <!-- TMPL_IF NAME="sort_copyrightdate" --><option value="copyrightdate" selected="selected">Copyrightdate</option><!-- TMPL_ELSE --><option value="copyrightdate">Copyrightdate</option><!-- /TMPL_IF -->
+                               </select></li>
                        <li><label for="category">Category:</label>
                    <select name="category" id="category">
                        <option value="1">Private</option>
index 194aa67..304c2b4 100755 (executable)
@@ -29,14 +29,15 @@ use C4::VirtualShelves;
 use C4::Auth;
 use C4::Output;
 use C4::Auth qw/get_session/;
+use C4::Debug;
 
-my $query        = new CGI;
-my @biblionumber = $query->param('biblionumber');
-my $selectedshelf = $query->param('selectedshelf');
-my $newshelf = $query->param('newshelf');
-my $shelfnumber  = $query->param('shelfnumber');
-my $newvirtualshelf = $query->param('newvirtualshelf');
-my $category     = $query->param('category');
+my $query              = new CGI;
+my @biblionumber       = $query->param('biblionumber');
+my $selectedshelf      = $query->param('selectedshelf');
+my $newshelf           = $query->param('newshelf');
+my $shelfnumber        = $query->param('shelfnumber');
+my $newvirtualshelf    = $query->param('newvirtualshelf');
+my $category           = $query->param('category');
 
 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
     {
@@ -47,7 +48,13 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
     }
 );
 
-$shelfnumber = AddShelf(  $newvirtualshelf, $loggedinuser, $category ) if $newvirtualshelf;
+if ($newvirtualshelf) {
+       $shelfnumber = AddShelf(  $newvirtualshelf, $loggedinuser, $category );
+       RefreshShelvesSummary($query->cookie("CGISESSID"),$loggedinuser,($loggedinuser == -1 ? 20 : 10));
+       print $query->header;
+       print "<html><body onload=\"window.opener.location.reload(true);self.close();\"></body></html>";
+       exit;
+}
 
 # verify user is authorized to perform the action on the shelf...
 my $authorized = 1;
@@ -64,10 +71,11 @@ if (scalar(@biblionumber) == 1) {
 }
 if ($shelfnumber && ($shelfnumber != -1)) {
        for my $bib (@biblionumber){
-               &AddToShelfFromBiblio($bib,$shelfnumber);
+               AddToShelfFromBiblio($bib,$shelfnumber);
        }
+       RefreshShelvesSummary($query->cookie("CGISESSID"),$loggedinuser,($loggedinuser == -1 ? 20 : 10));
        print $query->header;
-       print "<html><body onload=\"window.close();\"><div>Please close this window to continue.</div></body></html>";
+       print "<html><body onload=\"window.opener.location.reload(true);self.close();\"></body></html>";
        exit;
 }
 else {
@@ -82,13 +90,21 @@ else {
                        );
        } else {
        # offer choice of shelves
-    my ($shelflist) = GetShelves( $loggedinuser, 3 );
+       # first private shelves...
+       my $limit = 10;
+       my ($shelflist) = GetRecentShelves(1, $limit, $loggedinuser);
     my @shelvesloop;
     my %shelvesloop;
-    foreach my $element ( sort keys %$shelflist ) {
-        push( @shelvesloop, $element );
-               $shelvesloop{$element} = $shelflist->{$element}->{'shelfname'};
-
+    for my $shelf ( @{${@$shelflist}[0]} ) {
+        push( @shelvesloop, $shelf->{shelfnumber} );
+               $shelvesloop{$shelf->{shelfnumber}} = $shelf->{shelfname};
+       }
+       # then open shelves...
+       my ($shelflist) = GetRecentShelves(3, $limit, undef);
+    for my $shelf ( @{${@$shelflist}[0]} ) {
+        push( @shelvesloop, $shelf->{shelfnumber} );
+               $shelvesloop{$shelf->{shelfnumber}} = $shelf->{shelfname};
+       }
     my $CGIvirtualshelves;
     if ( @shelvesloop > 0 ) {
         $CGIvirtualshelves = CGI::scrolling_list (
@@ -105,7 +121,6 @@ else {
                CGIvirtualshelves       => $CGIvirtualshelves,
        );
     }
-    }
        }
 
        my @biblios;
index 3a177af..86b47d8 100755 (executable)
@@ -9,7 +9,7 @@ use strict;            # always use
 ## load Koha modules
 use C4::Context;
 use C4::Output;
-use C4::Auth;
+use C4::Auth qw(:DEFAULT get_session);
 use C4::Search;
 use C4::Biblio;  # GetBiblioData
 use C4::Koha;
@@ -603,4 +603,25 @@ if ( C4::Context->preference("kohaspsuggest") ) {
 # see bug 2078.
 my $content_type = $cgi->param('format') =~ /rss|atom/ ? "application/xml" :
                    "text/html";
+
+# Build drop-down list for 'Add To:' menu...
+my $session = get_session($cgi->cookie("CGISESSID"));
+my @addpubshelves;
+my $pubshelves = $session->param('pubshelves');
+my $barshelves = $session->param('barshelves');
+foreach my $shelf (@$pubshelves) {
+       next if ( ($shelf->{'owner'} != ($borrowernumber ? $borrowernumber : -1)) && ($shelf->{'category'} < 3) );
+       push (@addpubshelves, $shelf);
+}
+
+if (defined @addpubshelves) {
+       $template->param( addpubshelves     => scalar (@addpubshelves));
+       $template->param( addpubshelvesloop => \@addpubshelves);
+}
+
+if (defined $barshelves) {
+       $template->param( addbarshelves     => scalar (@$barshelves));
+       $template->param( addbarshelvesloop => $barshelves);
+}
+
 output_html_with_http_headers $cgi, $cookie, $template->output, $content_type;
index 456f51e..4862d02 100755 (executable)
@@ -71,6 +71,7 @@ my $biblionumber    = $query->param('biblionumber');
 my $shelfnumber     = $query->param('shelfnumber');
 my $newvirtualshelf = $query->param('newvirtualshelf');
 my $category        = $query->param('category');
+my $sortfield          = $query->param('sortfield');
 
 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
     {
@@ -82,10 +83,10 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
     }
 );
 
-$shelfnumber = AddShelf( $newvirtualshelf, $loggedinuser, $category )
+$shelfnumber = AddShelf( $newvirtualshelf, $loggedinuser, $category, $sortfield )
   if $newvirtualshelf;
 if ( $shelfnumber || ( $shelfnumber == -1 ) ) {    # the shelf already exist.
-    &AddToShelfFromBiblio( $biblionumber, $shelfnumber );
+    AddToShelfFromBiblio( $biblionumber, $shelfnumber );
     print
 "Content-Type: text/html\n\n<html><body onload=\"window.close()\"></body></html>";
     exit;
@@ -93,13 +94,20 @@ if ( $shelfnumber || ( $shelfnumber == -1 ) ) {    # the shelf already exist.
 else {    # this shelf doesn't already exist.
     my ( $bibliocount, @biblios ) = GetBiblio($biblionumber);
 
-    my ($shelflist) = GetShelves( $loggedinuser, 3 );
+       my $limit = 10;
+       my ($shelflist) = GetRecentShelves(1, $limit, $loggedinuser);
     my @shelvesloop;
     my %shelvesloop;
-    foreach my $element ( sort keys %$shelflist ) {
-        push( @shelvesloop, $element );
-        $shelvesloop{$element} = $shelflist->{$element}->{'shelfname'};
-    }
+    for my $shelf ( @{${@$shelflist}[0]} ) {
+        push( @shelvesloop, $shelf->{shelfnumber} );
+               $shelvesloop{$shelf->{shelfnumber}} = $shelf->{shelfname};
+       }
+       # then open shelves...
+       my ($shelflist) = GetRecentShelves(3, $limit, undef);
+    for my $shelf ( @{${@$shelflist}[0]} ) {
+        push( @shelvesloop, $shelf->{shelfnumber} );
+               $shelvesloop{$shelf->{shelfnumber}} = $shelf->{shelfname};
+       }
        if(@shelvesloop gt 0){
     my $CGIvirtualshelves = CGI::scrolling_list(
         -name     => 'shelfnumber',
@@ -122,56 +130,3 @@ else {    # this shelf doesn't already exist.
 
     output_html_with_http_headers $query, $cookie, $template->output;
 }
-
-# Revision 1.8  2007/04/24 13:54:29  hdl
-# functions that were in C4::Interface::CGI::Output are now in C4::Output.
-# So this implies quite a change for files.
-# Sorry about conflicts which will be caused.
-# directory Interface::CGI should now be dropped.
-# I noticed that many scripts (reports ones, but also some circ/stats.pl or opac-topissues) still use Date::Manip.
-#
-# Revision 1.7  2007/04/04 16:46:22  tipaul
-# HUGE COMMIT : code cleaning circulation.
-#
-# some stuff to do, i'll write a mail on koha-devel NOW !
-#
-# Revision 1.6  2007/03/09 14:32:26  tipaul
-# rel_3_0 moved to HEAD
-#
-# Revision 1.4.2.6  2006/12/18 16:35:17  toins
-# removing use HTML::Template from *.pl.
-#
-# Revision 1.4.2.5  2006/12/05 11:35:29  toins
-# Biblio.pm cleaned.
-# additionalauthors, bibliosubject, bibliosubtitle tables are now unused.
-# Some functions renamed according to the coding guidelines.
-#
-# Revision 1.4.2.4  2006/11/30 18:23:51  toins
-# theses scripts don't need to use C4::Search.
-#
-# Revision 1.4.2.3  2006/10/30 09:48:19  tipaul
-# samll bugfix to create a virtualshelf correctly
-#
-# Revision 1.4.2.2  2006/08/30 16:13:54  toins
-# correct an error in the "if condition".
-#
-# Revision 1.4.2.1  2006/08/30 15:59:14  toins
-# Code cleaned according to coding guide lines.
-#
-# Revision 1.4  2006/07/04 14:36:51  toins
-# Head & rel_2_2 merged
-#
-# Revision 1.3.2.4  2006/06/20 16:21:42  oleonard
-# Adding "tabindex=''" to CGI:scrolling_lists to prevent incorrect tabbing. See Bug 1098
-#
-# Revision 1.3.2.3  2006/02/05 21:59:21  kados
-# Adds script support for IntranetNav ... see mail to koha-devel for
-# details
-#
-# Revision 1.3.2.2  2006/02/05 21:45:25  kados
-# Adds support for intranetstylesheet system pref in Koha scripts
-#
-
-# Local Variables:
-# tab-width: 4
-# End: