@@ -, +, @@ --- Koha/Plugin/Test_Newsletter.pm | 55 ++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 Koha/Plugin/Test_Newsletter.pm --- a/Koha/Plugin/Test_Newsletter.pm +++ a/Koha/Plugin/Test_Newsletter.pm @@ -0,0 +1,55 @@ +package Koha::Plugin::Test_Newsletter; + +#Implements patron_consent_type plugin. + +use Modern::Perl; +use C4::Context; + +use parent qw/Koha::Plugins::Base/; + +use constant CONSENT_TYPE => 'NEWSLETTER'; + +our $VERSION = 1.00; +our $metadata = { version => $VERSION }; + +my $consent_info = { + title => { + 'en' => q|Newsletter|, + }, + description => { + 'en' => + q|We would be happy to regularly send you a newsletter by email about our library services and activities.|, + }, +}; + +sub new { + my ( $class, $params ) = @_; + $params->{metadata} = $metadata; + $params->{metadata}->{name} = $class; + return $class->SUPER::new($params); +} + +sub install { + my ($self) = shift; + C4::Context->dbh->do( + "INSERT IGNORE INTO plugin_methods (plugin_class, plugin_method) VALUES (?,?)", + undef, + ref $self, + 'patron_consent_type' + ); + return 1; +} + +sub uninstall { + my ($self) = @_; + C4::Context->dbh->do( "DELETE FROM plugin_data WHERE plugin_class LIKE ?", undef, ref $self ); + C4::Context->dbh->do( "DELETE FROM plugin_methods WHERE plugin_class LIKE ?", undef, ref $self ); + return 1; +} + +sub patron_consent_type { + my ($self) = @_; + return [ CONSENT_TYPE, $consent_info ]; +} + +1; --