root/DeleteAndRebuild/trunk/DeleteAndRebuild.pl

Revision 282, 0.7 kB (checked in by ogawa, 22 months ago)

Just a little bit fix to avoid removing entry archives when there's no individual entry archive template.

  • Property svn:keywords set to Id
Line 
1# DeleteAndRebuild
2#
3# $Id$
4
5package MT::Plugin::DeleteAndRebuild;
6use strict;
7use MT 3.3;
8use base qw(MT::Plugin);
9our $VERSION = '0.01';
10
11my $plugin = __PACKAGE__->new({
12    name => 'DeleteAndRebuild',
13    description => 'A plugin for rebuilding archives related to deleted entry.',
14    author_name => 'Hirotaka Ogawa',
15    author_link => 'http://profile.typekey.com/ogawa/',
16    version => $VERSION,
17    callbacks => { 'CMSPostDelete.entry' => \&handler }
18});
19MT->add_plugin($plugin);
20
21sub handler {
22    my ($eh, $app, $obj) = @_;
23    $app->rebuild_entry(Entry => $obj, BuildDependencies => 1);
24    $app->publisher->remove_entry_archive_file(Entry => $obj, ArchiveType => 'Individual')
25        if $app->config('DeleteFilesAtRebuild');
26}
Note: See TracBrowser for help on using the browser.