@@ -, +, @@ --- Koha/Plugin/Example/Userid_email.pm | 55 +++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 Koha/Plugin/Example/Userid_email.pm --- a/Koha/Plugin/Example/Userid_email.pm +++ a/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; --