Bugzilla – Attachment 137865 Details for
Bug 25498
Allow to change owner of public or shared list
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 25498: Transfer ownership shared list on OPAC
Bug-25498-Transfer-ownership-shared-list-on-OPAC.patch (text/plain), 7.48 KB, created by
Marcel de Rooy
on 2022-07-19 12:21:45 UTC
(
hide
)
Description:
Bug 25498: Transfer ownership shared list on OPAC
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2022-07-19 12:21:45 UTC
Size:
7.48 KB
patch
obsolete
>From c149313e16cd18d001674eebec43fce35b15c202 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Mon, 13 Jun 2022 09:40:07 +0000 >Subject: [PATCH] Bug 25498: Transfer ownership shared list on OPAC >Content-Type: text/plain; charset=utf-8 > >Test plan: >Pick or create a shared list. Login as owner. >Transfer to one of the other members. >Verify that you do no longer have Transfer, but see Remove share. >Login as the other member. Transfer it back. > >Bonus: Working with two tabs, you can open the Transfer form and >in the meantime delete the list, the patron or remove the share. >Or change permissions. Submit after that and check the error message. > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Signed-off-by: Owen Leonard <oleonard@myacpl.org> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > Koha/Virtualshelfshare.pm | 22 ++++++++++++- > .../bootstrap/en/modules/opac-shelves.tt | 31 ++++++++++++++++++ > opac/opac-shelves.pl | 32 ++++++++++++++++++- > 3 files changed, 83 insertions(+), 2 deletions(-) > >diff --git a/Koha/Virtualshelfshare.pm b/Koha/Virtualshelfshare.pm >index 64e13bd542..16bd017351 100644 >--- a/Koha/Virtualshelfshare.pm >+++ b/Koha/Virtualshelfshare.pm >@@ -23,6 +23,7 @@ use DateTime::Duration; > use Koha::Database; > use Koha::DateUtils qw( dt_from_string ); > use Koha::Exceptions; >+use Koha::Patron; > > use base qw(Koha::Object); > >@@ -38,7 +39,7 @@ Koha::Virtualshelfshare - Koha Virtualshelfshare Object class > > =cut > >-=head3 type >+=head3 accept > > =cut > >@@ -66,6 +67,10 @@ sub accept { > } > } > >+=head3 has_expired >+ >+=cut >+ > sub has_expired { > my ($self) = @_; > my $dt_sharedate = dt_from_string( $self->sharedate, 'sql' ); >@@ -76,6 +81,21 @@ sub has_expired { > return $has_expired == 1 ? 1 : 0 > } > >+=head3 patron >+ >+ Returns related Koha::Patron object for this share. >+ >+=cut >+ >+sub patron { >+ my $self = shift; >+ return Koha::Patron->_new_from_dbic( $self->{_result}->borrowernumber ); >+} >+ >+=head3 _type >+ >+=cut >+ > sub _type { > return 'Virtualshelfshare'; > } >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 3bbd59ada0..fdf8036b3e 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt >@@ -182,8 +182,15 @@ > <span>You do not have permission to delete this list.</span> > [% CASE 'unauthorized_on_add_biblio' %] > <span>You do not have permission to add a record to this list.</span> >+ [% CASE 'unauthorized_transfer' %] >+ <span>You do not have permission to transfer ownership of this list.</span> > [% CASE 'no_biblio_removed' %] > <span>No record was removed.</span> >+ [% CASE 'new_owner_not_found' %] >+ <span>The new owner could not be found anymore.</span> >+ [% CASE 'new_owner_has_no_share' %] >+ <span>The new owner has no share for this list.</span> >+ > [% CASE 'Koha::Exceptions::Virtualshelf::DuplicateObject' %] > <span>An error occurred when creating the list. The name [% shelfname | html %] already exists.</span> > [% CASE 'DBIx::Class::Exception' %] >@@ -635,6 +642,30 @@ > </fieldset> > </form> > >+ [% ELSIF op == 'transfer' %] >+ <h1>Transfer ownership of shared list '[% shelf.shelfname | html %]'</h1> >+ <br/> >+ <form action="/cgi-bin/koha/opac-shelves.pl" id="transferform" method="post"> >+ <fieldset> >+ <input type="hidden" name="op" value="transfer" /> >+ <input type="hidden" name="public" value="0" /> >+ <input type="hidden" name="shelfnumber" value="[% shelf.shelfnumber | html %]" /> >+ <div> >+ <label for="find_patron">New owner: </label> >+ <select name="new_owner" id="new_owner"> >+ [% FOREACH sharee IN shared_users %] >+ <option value="[% sharee.borrowernumber | html %]" selected="">[% sharee.email | html %]</option> >+ [% END %] >+ </select> >+ </div> >+ <br/> >+ <fieldset class="action"> >+ <input type="submit" value="Transfer" class="submit" /> >+ <a href="/cgi-bin/koha/opac-shelves.pl?op=list&public=0" class="cancel">Cancel</a> >+ </fieldset> >+ </fieldset> >+ </form> >+ > [% ELSIF op == 'list' %] > <h1>Lists</h1> > <div class="toptabs ui-tabs ui-widget ui-widget-content ui-corner-all"> >diff --git a/opac/opac-shelves.pl b/opac/opac-shelves.pl >index 5bd342f514..cce27b9f05 100755 >--- a/opac/opac-shelves.pl >+++ b/opac/opac-shelves.pl >@@ -38,9 +38,11 @@ use Koha::Biblios; > use Koha::Biblioitems; > use Koha::CirculationRules; > use Koha::CsvProfiles; >+use Koha::DateUtils qw/dt_from_string/; > use Koha::Items; > use Koha::ItemTypes; > use Koha::Patrons; >+use Koha::Virtualshelfshares; > use Koha::Virtualshelves; > use Koha::RecordProcessor; > >@@ -257,7 +259,35 @@ if ( $op eq 'add_form' ) { > } > $op = 'view'; > } elsif( $op eq 'transfer' ) { >- $op = 'list'; # TODO >+ $shelfnumber = $query->param('shelfnumber'); >+ $shelf = Koha::Virtualshelves->find($shelfnumber) if $shelfnumber; >+ my $new_owner = $query->param('new_owner'); # borrowernumber or undef >+ >+ $op = 'list'; >+ if( !$shelf ) { >+ push @messages, { type => 'error', code => 'does_not_exist' }; >+ } elsif( $shelf->public or !$shelf->is_shared or !$shelf->can_be_managed($loggedinuser) ) { >+ push @messages, { type => 'error', code => 'unauthorized_transfer' }; >+ } elsif( !$new_owner ) { >+ my $patrons = []; >+ my $shares = $shelf->get_shares->search({ borrowernumber => { '!=' => undef } }); >+ while( my $share = $shares->next ) { >+ push @$patrons, { email => $share->patron->notice_email_address, borrowernumber => $share->get_column('borrowernumber') }; >+ } >+ $template->param( shared_users => $patrons ); >+ $op = 'transfer'; >+ } elsif( !Koha::Patrons->find($new_owner) ) { >+ push @messages, { type => 'error', code => 'new_owner_not_found' }; >+ } elsif( !$shelf->get_shares->search({ borrowernumber => $new_owner })->count ) { >+ push @messages, { type => 'error', code => 'new_owner_has_no_share' }; >+ } else { >+ # Remove from virtualshelfshares new_owner, add loggedinuser >+ $shelf->_result->result_source->schema->txn_do( sub { >+ $shelf->get_shares->search({ borrowernumber => $new_owner })->delete; >+ Koha::Virtualshelfshare->new({ shelfnumber => $shelfnumber, borrowernumber => $loggedinuser, sharedate => dt_from_string })->store; >+ $shelf->owner($new_owner)->store; >+ }); >+ } > } > > # PART 2: After a possible action, view one list or show a number of lists >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 25498
:
135889
|
135921
|
136008
|
136009
|
136010
|
136011
|
136033
|
136034
|
136035
|
136036
|
136166
|
136167
|
136168
|
136169
|
136220
|
136221
|
137862
|
137863
|
137864
| 137865 |
137866
|
137867
|
137871
|
137908