From 3316f9cc737c091ff79270f75fc30dd349616b12 Mon Sep 17 00:00:00 2001 From: intrigeri Date: Thu, 1 Jan 2009 16:48:43 +0100 Subject: rename: implemented new canrename hook Signed-off-by: intrigeri --- IkiWiki/Plugin/rename.pm | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'IkiWiki/Plugin/rename.pm') diff --git a/IkiWiki/Plugin/rename.pm b/IkiWiki/Plugin/rename.pm index 25ddd2d65..740ca8ac4 100644 --- a/IkiWiki/Plugin/rename.pm +++ b/IkiWiki/Plugin/rename.pm @@ -87,6 +87,26 @@ sub check_canrename ($$$$$$) { IkiWiki::Plugin::attachment::check_canattach($session, $dest, $srcfile); } } + + my $canrename; + IkiWiki::run_hooks(canrename => sub { + return if defined $canrename; + my $ret=shift->($src, $q, $session); + if (defined $ret) { + if ($ret eq "") { + $canrename=1; + } + elsif (ref $ret eq 'CODE') { + $ret->(); + $canrename=0; + } + elsif (defined $ret) { + error($ret); + $canrename=0; + } + } + }); + return $canrename; } sub rename_form ($$$) { -- cgit v1.2.3