@@ -, +, @@ --- Koha/Objects.pm | 11 + Koha/Virtualshelf.pm | 16 +- Koha/Virtualshelves.pm | 24 +- .../virtualshelves/tables/shelves_results.tt | 2 + .../opac-tmpl/bootstrap/en/includes/masthead.inc | 14 +- .../opac-tmpl/bootstrap/en/includes/usermenu.inc | 2 +- .../opac-tmpl/bootstrap/en/modules/opac-detail.tt | 4 +- .../bootstrap/en/modules/opac-downloadshelf.tt | 16 +- .../bootstrap/en/modules/opac-sendshelfform.tt | 6 +- .../bootstrap/en/modules/opac-shareshelf.tt | 6 +- .../bootstrap/en/modules/opac-shelves-rss.tt | 6 +- .../opac-tmpl/bootstrap/en/modules/opac-shelves.tt | 638 +++++++++------------ opac/opac-downloadshelf.pl | 18 +- opac/opac-shelves.pl | 314 +++++++++- t/db_dependent/Virtualshelves.t | 76 ++- 15 files changed, 719 insertions(+), 434 deletions(-) --- a/Koha/Objects.pm +++ a/Koha/Objects.pm @@ -126,6 +126,17 @@ sub count { return $self->_resultset()->count($params); } +=head3 Koha::Objects->pager(); + +my $pager = Koha::Objects->pager; + +=cut + +sub pager { + my ( $self ) = @_; + return $self->_resultset->pager; +} + =head3 Koha::Objects->next(); my $object = Koha::Objects->next(); --- a/Koha/Virtualshelf.pm +++ a/Koha/Virtualshelf.pm @@ -101,12 +101,14 @@ sub is_shelfname_valid { sub get_shares { my ( $self ) = @_; - return $self->{_result}->virtualshelfshares; + my $shares = $self->{_result}->virtualshelfshares; + return $shares; } sub get_contents { my ( $self ) = @_; - return $self->{_result}->virtualshelfcontents; + my $contents = $self->{_result}->virtualshelfcontents; + return $contents; } sub share { @@ -132,6 +134,16 @@ sub is_shared { )->count; } +sub is_shared_with { + my ( $self, $borrowernumber ) = @_; + return unless $borrowernumber; + return $self->get_shares->search( + { + borrowernumber => $borrowernumber, + } + )->count; +} + sub remove_share { my ( $self, $borrowernumber ) = @_; my $shelves = Koha::Virtualshelfshares->search( --- a/Koha/Virtualshelves.pm +++ a/Koha/Virtualshelves.pm @@ -41,24 +41,23 @@ Koha::Virtualshelf - Koha Virtualshelf Object class sub get_private_shelves { my ( $self, $params ) = @_; - my $limit = $params->{limit}; - my $offset = $params->{offset} || 0; - my $borrowernumber = $params->{borrowernumber}; + my $page = $params->{page}; + my $rows = $params->{rows}; + my $borrowernumber = $params->{borrowernumber} || 0; $self->search( { - 'virtualshelfshares.borrowernumber' => $borrowernumber, category => 1, -or => { - 'virtualshelfshares.owner' => $borrowernumber, - 'virtualshelves.borrowernumber' => $borrowernumber, + 'virtualshelfshares.borrowernumber' => $borrowernumber, + 'me.owner' => $borrowernumber, } }, { - join => ['borrowers', 'virtualshelfcontents', 'virtualshelfshares' ], + join => [ 'virtualshelfshares' ], group_by => 'shelfnumber', order_by => 'shelfname', - limit => "$limit,$offset", + ( ( $page and $rows ) ? ( page => $page, rows => $rows ) : () ), } ); } @@ -66,18 +65,17 @@ sub get_private_shelves { sub get_public_shelves { my ( $self, $params ) = @_; - my $limit = $params->{limit}; - my $offset = $params->{offset} || 0; + my $page = $params->{page}; + my $rows = $params->{rows}; $self->search( { - category => 1, + category => 2, }, { - join => [ 'virtualshelfcontents' ], group_by => 'shelfnumber', order_by => 'shelfname', - limit => "$limit,$offset", + ( ( $page and $rows ) ? ( page => $page, rows => $rows ) : () ), } ); } --- a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/tables/shelves_results.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/tables/shelves_results.tt @@ -36,6 +36,7 @@ [%~ action_block = action_block _ '' ~%] [%~ action_block = action_block _ '' ~%] [%~ action_block = action_block _ '' ~%] + [%~ action_block = action_block _ '' ~%] [%~ action_block = action_block _ '' ~%] [%~ action_block = action_block _ '' ~%] [%~ END ~%] @@ -46,6 +47,7 @@ [%~ action_block = action_block _ '' ~%] [%~ action_block = action_block _ '' ~%] [%~ action_block = action_block _ '' ~%] + [%~ action_block = action_block _ '' ~%] [%~ action_block = action_block _ '' ~%] [%~ action_block = action_block _ '' ~%] [%~ END ~%] --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc +++ a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc @@ -38,26 +38,26 @@ Lists
@@ -47,7 +47,7 @@

Your download should begin automatically.

[% ELSE %] -

Download list [% shelfname %]

+

Download list [% shelf.shelfname %]

+ - Cancel + Cancel
[% IF ( modal ) %] --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-sendshelfform.tt +++ a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-sendshelfform.tt @@ -15,7 +15,7 @@

The list was sent to: [% email %]

-

Back to lists

+

Back to lists

[% END %] [% IF ( error ) %]
@@ -27,7 +27,7 @@

You do not have permission to send this list.

-

Back to lists

+

Back to lists

[% ELSE %]

Sending your list

@@ -42,7 +42,7 @@
- Cancel + Cancel
--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shareshelf.tt +++ a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shareshelf.tt @@ -41,7 +41,7 @@ [% IF errcode==6 %]
Sorry, but you did not enter a valid email address.
[% END %] [% IF errcode==7 %]
Sorry, but we could not accept this key. The invitation may have expired. Contact the patron who sent you the invitation.
[% END %] [% IF errcode==8 %]
As owner of a list you cannot accept an invitation for sharing it.
[% END %] -

Return to your lists

+

Return to your lists

[% ELSIF op=='invite' %]
@@ -59,7 +59,7 @@
- Cancel + Cancel
@@ -75,7 +75,7 @@ [% IF approvedaddress %]

You will receive an email notification if someone accepts your share within two weeks.

[% END %] -

Return to your lists

+

Return to your lists

[% ELSIF op=='accept' %] --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves-rss.tt +++ a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves-rss.tt @@ -3,9 +3,9 @@ - [% shelfname %] - [% OPACBaseURL %]/cgi-bin/koha/opac-shelves.pl?rss=1&viewshelf=[% shelfnumber %] - RSS feed for public list [% shelfname | html %] + [% shelf.shelfname %] + [% OPACBaseURL %]/cgi-bin/koha/opac-shelves.pl?rss=1&viewshelf=[% shelf.shelfnumber %] + RSS feed for public list [% shelf.shelfname | html %] [% FOREACH i IN itemsloop %] --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt +++ a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt @@ -1,9 +1,11 @@ [% USE Koha %] -[% SET TagsShowEnabled = ( ( Koha.Preference( 'TagsEnabled' ) == 1 ) && TagsShowOnList ) %] -[% SET TagsInputEnabled = ( ( Koha.Preference( 'opacuserlogin' ) == 1 ) && ( Koha.Preference( 'TagsEnabled' ) == 1 ) && TagsInputOnList ) %] +[% SET PRIVATE = 1 %] +[% SET PUBLIC = 2 %] +[% SET TagsShowEnabled = ( ( Koha.Preference( 'TagsEnabled' ) == 1 ) && Koha.Preference('TagsShowOnList') ) %] +[% SET TagsInputEnabled = ( ( Koha.Preference( 'opacuserlogin' ) == 1 ) && ( Koha.Preference( 'TagsEnabled' ) == 1 ) && Koha.Preference('TagsInputOnList') ) %] [% INCLUDE 'doc-head-open.inc' %] -[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog › [% IF ( viewshelf ) %]Contents of [% shelfname |html %][% ELSE %]Your lists[% END %][% INCLUDE 'doc-head-close.inc' %] +[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog › [% IF op == 'view' %]Contents of [% shelf.shelfname |html %][% ELSE %]Your lists[% END %][% INCLUDE 'doc-head-close.inc' %] [% BLOCK cssinclude %][% END %] [% IF ( loggedinusername ) %][% INCLUDE 'bodytag.inc' bodyid='opac-userlists' bodyclass='scrollto' %][% ELSE %][% INCLUDE 'bodytag.inc' bodyid='opac-lists' bodyclass='scrollto' %][% END %] @@ -12,35 +14,28 @@
  •  anyone else to add entries. (The owner of a list is always allowed to add entries, but needs permission to remove.)
  •  anyone to remove his own contributed entries.
  •  anyone to remove other contributed entries.
  • [% END %] -[% BLOCK remove_share %] - [%# Use: add parameter shelfnumber and add end form tag %] -
    - - - -[% END %] [% INCLUDE 'masthead.inc' %]
    @@ -50,42 +45,36 @@
  • [% FOREACH USER_INF IN USER_INFO %][% USER_INF.title %] [% USER_INF.firstname %] [% USER_INF.surname %][% END %]
  • [% END %] - [% IF ( category1 ) %] - [% IF ( viewshelf || edit ) %] -
  • Your lists
  • - [% ELSE %] -
  • Your lists
  • - [% END %] - [% ELSIF ( category2 ) %] - [% IF ( viewshelf || edit ) %] -
  • Public lists
  • - [% ELSE %] -
  • Public lists
  • - [% END %] - [% ELSIF ( showprivateshelves ) %] - [% IF ( viewshelf || edit ) %] -
  • Your lists
  • + [% IF op != 'list' %] +
  • Lists
  • + [% ELSE %] +
  • Lists
  • + [% END %] + + [% IF shelf and shelf.category == PRIVATE %] + [% IF op == 'view' OR op == 'edit_form' %] +
  • Your lists
  • [% ELSE %] -
  • Your lists
  • +
  • Your lists
  • [% END %] - [% ELSIF ( showpublicshelves ) %] - [% IF ( viewshelf || edit || shelves ) %] -
  • Public lists
  • + [% ELSIF shelf AND shelf.category == PUBLIC %] + [% IF op == 'view' %] +
  • Public lists
  • [% ELSE %] -
  • Public lists
  • +
  • Public lists
  • [% END %] [% END %] - [% IF ( viewshelf ) %] -
  • Contents of [% shelfname | html %]
  • + [% IF op == 'view' %] +
  • Contents of [% shelf.shelfname | html %]
  • [% END %] - [% IF ( shelves ) %] + [% IF op == 'add_form' %]
  • Create new list
  • [% END %] - [% IF ( edit ) %] -
  • Edit list [% shelfname | html %]
  • + [% IF op == 'edit_form' %] +
  • Edit list [% shelf.shelfname | html %]
  • [% END %] @@ -107,52 +96,65 @@ [% END %]
    - [% IF ( paramsloop ) %] - [% FOREACH paramsloo IN paramsloop %] - [% IF ( paramsloo.status ) %]
    [% paramsloo.string %]
    [% END %] - [% IF ( paramsloo.nobarcode ) %]
    ERROR: No barcode given.
    [% END %] - [% IF ( paramsloo.noshelfnumber ) %]
    ERROR: No shelfnumber given.
    [% END %] - [% IF ( paramsloo.need_confirm ) %] -
    - The list [% paramsloo.need_confirm %] is not empty. -
    It has [% paramsloo.count %] [% IF paramsloo.count == 1 %]entry[% ELSE %]entries[% END %]. -
    Use the "Confirm" button below to confirm deletion. -
    - [% END %] - [% IF ( paramsloo.nopermission ) %] -
    ERROR: You do not have adequate permission for that action on list [% paramsloo.nopermission |html%].
    - [% END %] - [% IF ( paramsloo.failgetitem ) %] -
    ERROR: No item found with barcode [% paramsloo.failgetitem %].
    - [% END %] - [% IF ( paramsloo.duplicatebiblio ) %] -
    A record matching barcode [% paramsloo.duplicatebiblio %] has already been added.
    - [% END %] - [% IF ( paramsloo.delete_ok ) %] -
    List [% paramsloo.delete_ok |html %] Deleted.
    - [% END %] - [% IF ( paramsloo.delete_fail ) %] -
    ERROR: Database error. Delete (list number [% paramsloo.delete_fail |html %]) failed.
    - [% END %] - [% IF ( paramsloo.unrecognized ) %] -
    ERROR: List number [% paramsloo.unrecognized %] unrecognized.
    - [% END %] - [% IF ( paramsloo.modifyfailure) %] -
    ERROR: Shelf could not be renamed to [% paramsloo.modifyfailure %]. This name may not be unique for this type of list. Please check.
    - [% END %] - [% IF ( paramsloo.nothingdeleted) %] -
    Warning: You could not delete any selected items from this shelf.
    - [% END %] - [% IF ( paramsloo.somedeleted) %] -
    Warning: You could not delete all selected items from this shelf.
    - [% END %] - [% END # / FOREACH paramsloop %] - [% END # / IF paramsloop %] + [% FOR m IN messages %] + [% SWITCH m.type %] + [% CASE 'message' %] +