]> sipb.mit.edu Git - ikiwiki.git/commitdiff
rename: implemented new canrename hook
authorintrigeri <intrigeri@boum.org>
Thu, 1 Jan 2009 15:48:43 +0000 (16:48 +0100)
committerintrigeri <intrigeri@boum.org>
Thu, 1 Jan 2009 15:52:34 +0000 (16:52 +0100)
Signed-off-by: intrigeri <intrigeri@boum.org>
IkiWiki/Plugin/rename.pm
doc/plugins/write.mdwn

index 25ddd2d65870fea21fda94930fa90031ec9e4342..740ca8ac443f72ba05336599da5a331d1157f55e 100644 (file)
@@ -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 ($$$) {
index e20cce763e4b2d98fd11a2b0fbac1e4a3ab3498a..a927b16293f549a0ec94be8177229c4f54f8a22a 100644 (file)
@@ -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);