Skip to content

Commit

Permalink
Add upgrade method to plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyle M Hall authored and kylemhall committed May 28, 2018
1 parent 985c25f commit 8771a78
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Koha/Plugin/Com/ByWaterSolutions/KitchenSink.pm
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ sub configure {
enable_opac_payments => $self->retrieve_data('enable_opac_payments'),
foo => $self->retrieve_data('foo'),
bar => $self->retrieve_data('bar'),
last_upgraded => $self->retrieve_data('last_upgraded'),
);

$self->output_html( $template->output() );
Expand Down Expand Up @@ -304,6 +305,16 @@ sub install() {
" );
}

## This is the 'upgrade' method. It will be triggered when a newer version of a
## plugin is installed over an existing older version of a plugin
sub upgrade {
my ( $self, $args ) = @_;

$self->store_data( last_upgraded => dt_from_string()->datetime(' ') );

return 1;
}

## This method will be run just before the plugin files are deleted
## when a plugin is uninstalled. It is good practice to clean up
## after ourselves!
Expand Down
12 changes: 12 additions & 0 deletions Koha/Plugin/Com/ByWaterSolutions/KitchenSink/configure.tt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[% USE KohaDates %]
[% INCLUDE 'doc-head-open.inc' %]
<title>Koha: Kitchen Sink Plugin: Configuration</title>
[% INCLUDE 'doc-head-close.inc' %]
Expand Down Expand Up @@ -63,4 +64,15 @@
<input type="submit" value="Save configuration" />
</form>

<hr/>

<p>
<h5>Upgrade status</h5>
[% IF last_upgraded %]
Plugin was last upgraded on this system on [% last_upgraded | $KohaDates with_hours => 1 %]
[% ELSE %]
Plugin has never been upgraded.
[% END %]
</p>

[% INCLUDE 'intranet-bottom.inc' %]

0 comments on commit 8771a78

Please sign in to comment.