From: intrigeri Date: Thu, 1 Jan 2009 15:48:43 +0000 (+0100) Subject: rename: implemented new canrename hook X-Git-Tag: 3.15~299 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=3316f9cc737c091ff79270f75fc30dd349616b12;p=ikiwiki.git rename: implemented new canrename hook Signed-off-by: intrigeri --- 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 ($$$) { diff --git a/doc/plugins/write.mdwn b/doc/plugins/write.mdwn index e20cce763..a927b1629 100644 --- a/doc/plugins/write.mdwn +++ b/doc/plugins/write.mdwn @@ -329,6 +329,14 @@ This hook can be used to implement arbitrary access methods to control when a page can be removed using the web interface (commits from revision control bypass it). It works exactly like the `canedit` hook. +### canrename + + hook(type => "canrename", id => "foo", call => \&canrename); + +This hook can be used to implement arbitrary access methods to control when +a page can be renamed using the web interface (commits from revision control +bypass it). It works exactly like the `canedit` hook. + ### editcontent hook(type => "editcontent", id => "foo", call => \&editcontent);