View | Details | Raw Unified | Return to bug 32426
Collapse All | Expand All

(-)a/Koha/Plugin/Example/Userid_email.pm (-1 / +55 lines)
Line 0 Link Here
0
- 
1
package Koha::Plugin::Example::Userid_email;
2
3
# Limited test implementation of patron_generate_userid, returning borrowers.email.
4
5
use Modern::Perl;
6
use parent qw/Koha::Plugins::Base/;
7
use C4::Context;
8
9
our $VERSION = 1.00;
10
our $metadata = { version => $VERSION };
11
12
=pod
13
14
=head1 METHODS
15
16
=head2 new
17
18
=cut
19
20
sub new {
21
    my ( $class, $args ) = @_;
22
    $args //= {};
23
    return $class->SUPER::new({ %$args, metadata => $metadata });
24
}
25
26
=head2 install
27
28
=cut
29
30
sub install {
31
    my ( $self ) = shift;
32
    C4::Context->dbh->do( "INSERT IGNORE INTO plugin_methods (plugin_class, plugin_method) VALUES (?,?)", undef, __PACKAGE__, 'patron_generate_userid' );
33
}
34
35
=head2 uninstall
36
37
=cut
38
39
sub uninstall {
40
    my ( $self ) = shift;
41
    C4::Context->dbh->do( "DELETE FROM plugin_data WHERE plugin_class=?", undef, __PACKAGE__ );
42
    C4::Context->dbh->do( "DELETE FROM plugin_methods WHERE plugin_class=?", undef, __PACKAGE__ );
43
}
44
45
=head2 patron_generate_userid
46
47
=cut
48
49
sub patron_generate_userid {
50
#TODO This c/should be extended with verification (uniqueness), etc.
51
    my ($self, $params) = @_;
52
    return $params->{patron}->email;
53
}
54
55
1;

Return to bug 32426