Bugzilla – Attachment 148211 Details for
Bug 32426
Make userid generation pluggable
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 32426: [DO NOT PUSH] Introduce example plugin
Bug-32426-DO-NOT-PUSH-Introduce-example-plugin.patch (text/plain), 3.09 KB, created by
Martin Renvoize (ashimema)
on 2023-03-15 13:43:31 UTC
(
hide
)
Description:
Bug 32426: [DO NOT PUSH] Introduce example plugin
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2023-03-15 13:43:31 UTC
Size:
3.09 KB
patch
obsolete
>From 56e393b57091b3bbf8cfc5271e028d753f4b2c2d Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Thu, 15 Dec 2022 16:10:55 +0100 >Subject: [PATCH] Bug 32426: [DO NOT PUSH] Introduce example plugin > >RM: Do not push this patch! > >A very simple plugin; it just returns the borrowers.email field, assuming >that you made this field mandatory. >It should check uniqueness, provide an alternative; for simplicity >that is not included here. > >Test plan: >NOTE: Some unit tests may fail when applying this patch/installing this >plugin. That's no problem; this example plugin just serves as POC. > >Install the plugin. You could just run: >* perl -MKoha::Plugin::Example::Userid_email -e"Koha::Plugin::Example::Userid_email->new->install" > >Run t/db_dependent/Koha/Patron_generate_userid.t. This should pass. > >Enter a new patron via OPAC self registration; try existing and new email address. >Toggle PatronSelfRegistrationVerifyByEmail. Try again (existing, new). >Go to staff memberentry page. >Add new patron with new email address. (Leave userid empty.) >Verify the newly generated userid after saving. >Try to add another patron with the same email. You should see an alert. >Edit an existing patron. Try new and existing email address. >When editing, clear userid and save. Check result. > >Uninstall the plugin. >* perl -MKoha::Plugin::Example::Userid_email -e"Koha::Plugin::Example::Userid_email->new->uninstall" > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > Koha/Plugin/Example/Userid_email.pm | 55 +++++++++++++++++++++++++++++ > 1 file changed, 55 insertions(+) > create mode 100644 Koha/Plugin/Example/Userid_email.pm > >diff --git a/Koha/Plugin/Example/Userid_email.pm b/Koha/Plugin/Example/Userid_email.pm >new file mode 100644 >index 0000000000..62d683adeb >--- /dev/null >+++ b/Koha/Plugin/Example/Userid_email.pm >@@ -0,0 +1,55 @@ >+package Koha::Plugin::Example::Userid_email; >+ >+# Limited test implementation of patron_generate_userid, returning borrowers.email. >+ >+use Modern::Perl; >+use parent qw/Koha::Plugins::Base/; >+use C4::Context; >+ >+our $VERSION = 1.00; >+our $metadata = { version => $VERSION }; >+ >+=pod >+ >+=head1 METHODS >+ >+=head2 new >+ >+=cut >+ >+sub new { >+ my ( $class, $args ) = @_; >+ $args //= {}; >+ return $class->SUPER::new({ %$args, metadata => $metadata }); >+} >+ >+=head2 install >+ >+=cut >+ >+sub install { >+ my ( $self ) = shift; >+ C4::Context->dbh->do( "INSERT IGNORE INTO plugin_methods (plugin_class, plugin_method) VALUES (?,?)", undef, __PACKAGE__, 'patron_generate_userid' ); >+} >+ >+=head2 uninstall >+ >+=cut >+ >+sub uninstall { >+ my ( $self ) = shift; >+ C4::Context->dbh->do( "DELETE FROM plugin_data WHERE plugin_class=?", undef, __PACKAGE__ ); >+ C4::Context->dbh->do( "DELETE FROM plugin_methods WHERE plugin_class=?", undef, __PACKAGE__ ); >+} >+ >+=head2 patron_generate_userid >+ >+=cut >+ >+sub patron_generate_userid { >+#TODO This c/should be extended with verification (uniqueness), etc. >+ my ($self, $params) = @_; >+ return $params->{patron}->email; >+} >+ >+1; >-- >2.39.2
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 32426
:
146947
|
146948
|
146949
|
146950
|
146951
|
146952
|
146953
|
146954
|
147252
|
147253
|
147254
|
147255
|
147704
|
147705
|
147706
|
147707
|
147708
|
147709
|
147710
|
147711
|
147712
|
148203
|
148204
|
148205
|
148206
|
148207
|
148208
|
148209
|
148210
| 148211 |
148782
|
148793