1 package Koha::Plugin::Test;
3 ## It's good practice to use Modern::Perl
6 use Koha::Exceptions::Exception;
7 use Koha::Plugins::Tab;
9 use Mojo::JSON qw(decode_json);
11 ## Required for all plugins
12 use base qw(Koha::Plugins::Base);
16 name => 'Test Plugin',
17 author => 'Kyle M Hall',
18 description => 'Test plugin',
19 date_authored => '2013-01-14',
20 date_updated => '2013-01-14',
21 minimum_version => '3.11',
22 maximum_version => undef,
24 my_example_tag => 'find_me',
27 ## This is the minimum code required for a plugin's 'new' method
28 ## More can be added, but none should be removed
30 my ( $class, $args ) = @_;
31 $args->{'metadata'} = $metadata;
32 my $self = $class->SUPER::new($args);
37 my ( $self, $args ) = @_;
38 return "Koha::Plugin::Test::report";
42 my ( $self, $args ) = @_;
43 return "Koha::Plugin::Test::tool";
47 my ( $self, $args ) = @_;
48 return "Koha::Plugin::Test::to_marc";
51 sub intranet_catalog_biblio_enhancements_toolbar_button {
52 my ( $self, $args ) = @_;
53 return "Koha::Plugin::Test::intranet_catalog_biblio_enhancements_toolbar_button";
56 sub intranet_catalog_biblio_enhancements {
57 my ( $self, $args ) = @_;
58 return "Koha::Plugin::Test::intranet_catalog_biblio_enhancements";
61 sub opac_online_payment {
62 my ( $self, $args ) = @_;
63 return "Koha::Plugin::Test::opac_online_payment";
66 sub opac_online_payment_begin {
67 my ( $self, $args ) = @_;
68 return "Koha::Plugin::Test::opac_online_payment_begin";
71 sub opac_online_payment_end {
72 my ( $self, $args ) = @_;
73 return "Koha::Plugin::Test::opac_online_payment_end";
77 my ( $self, $args ) = @_;
78 return "Koha::Plugin::Test::opac_head";
82 my ( $self, $args ) = @_;
83 return "Koha::Plugin::Test::opac_js";
87 my ( $self, $args ) = @_;
88 return "Koha::Plugin::Test::intranet_head";
92 my ( $self, $args ) = @_;
93 return "Koha::Plugin::Test::intranet_js";
97 my ( $self, $args ) = @_;
98 return "Koha::Plugin::Test::configure";;
102 my ( $self, $args ) = @_;
103 return "Koha::Plugin::Test::install";
107 my ( $self, $args ) = @_;
108 return "Koha::Plugin::Test::upgrade";
112 my ( $self, $args ) = @_;
113 return "Koha::Plugin::Test::uninstall";
118 $self->output( '¡Hola output!', 'json' );
121 sub test_output_html {
123 $self->output_html( '¡Hola output_html!' );
130 sub after_biblio_action {
131 my ( $self, $params ) = @_;
132 my $action = $params->{action} // '';
133 my $biblio = $params->{biblio};
134 my $biblio_id = $params->{biblio_id};
136 if ( $action ne 'delete' ) {
137 Koha::Exceptions::Exception->throw("after_biblio_action called with action: $action, ref: " . ref($biblio) );
140 Koha::Exceptions::Exception->throw("after_biblio_action called with action: $action") if $biblio_id;
144 sub after_item_action {
145 my ( $self, $params ) = @_;
146 my $action = $params->{action} // '';
147 my $item = $params->{item};
148 my $item_id = $params->{item_id};
150 if ( $action ne 'delete' ) {
151 Koha::Exceptions::Exception->throw("after_item_action called with action: $action, ref: " . ref($item) );
154 Koha::Exceptions::Exception->throw("after_item_action called with action: $action" ) if $item_id;
158 sub after_circ_action {
159 my ( $self, $params ) = @_;
161 my $action = $params->{action};
162 my $payload = $params->{payload};
164 my $renewal_library_id = $payload->{renewal_library_id};
165 my $charge = $payload->{charge};
166 my $item_id = $payload->{item_id};
167 my $item_type = $payload->{item_type};
168 my $shelving_location = $payload->{shelving_location};
169 my $patron_id = $payload->{patron_id};
170 my $collection_code = $payload->{collection_code};
171 my $date_due = $payload->{date_due};
173 Koha::Exceptions::Exception->throw("after_circ_action called with action: $action, ref: " . ref($date_due));
177 my ( $self, $args ) = @_;
183 "x-mojo-to": "Test::Controller#bother",
184 "operationId": "BotherPatron",
191 "description": "A bothered patron",
196 "description": "If the patron has been bothered",
203 "description": "An error occurred",
208 "description": "An explanation for the error",
215 "x-koha-authorization": {
222 "/public/patrons/bother": {
224 "x-mojo-to": "Test::Controller#bother",
225 "operationId": "PubliclyBotherPatron",
232 "description": "A bothered patron",
237 "description": "If the patron has been bothered",
244 "description": "Authentication required",
249 "description": "An explanation for the error",
261 return decode_json($spec);
265 my ( $self, $args ) = @_;
267 my $password = $args->{'password'};
268 if ( $password && $password =~ m/^\d{4}$/ ) {
269 return { error => 0 };
274 msg => "PIN should be four digits"
279 sub intranet_catalog_biblio_tab {
282 Koha::Plugins::Tab->new(
285 content => 'This is content for tab 1'
290 Koha::Plugins::Tab->new(
293 content => 'This is content for tab 2'