From e7d5cc279160d34d8f9d745ecaf598eefa7f89d8 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 10 Aug 2015 16:53:06 +0100 Subject: [PATCH] Bug 14544: Make the OPAC side independent of Page.pm Bug 14544: Fix redirect on editing a list If you edit a list from the list view, after saving the form, you are not redirected to the list view (but on the edit form). Bug 14544: Cosmetic: › should be a class divider --- 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(-) diff --git a/Koha/Objects.pm b/Koha/Objects.pm index 8ef6390..8f7af79 100644 --- a/Koha/Objects.pm +++ b/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(); diff --git a/Koha/Virtualshelf.pm b/Koha/Virtualshelf.pm index e256316..f8f90a6 100644 --- a/Koha/Virtualshelf.pm +++ b/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( diff --git a/Koha/Virtualshelves.pm b/Koha/Virtualshelves.pm index 98f9d40..2cbd41c 100644 --- a/Koha/Virtualshelves.pm +++ b/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 ) : () ) } ); } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/tables/shelves_results.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/tables/shelves_results.tt index 08d75a6..0304dbe 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/tables/shelves_results.tt +++ b/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 ~%] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc index 1ccd2be..a2b5cd7 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead.inc +++ b/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 ) %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-sendshelfform.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-sendshelfform.tt index 3b38535..52b6671 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-sendshelfform.tt +++ b/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
diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shareshelf.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shareshelf.tt index 6421138..ac5a19b 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shareshelf.tt +++ b/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' %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves-rss.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves-rss.tt index f25f3ed..2525d80 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves-rss.tt +++ b/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 %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt index d7363f3..d3a0a07 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt +++ b/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' %] +