]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - IkiWiki/Plugin/remove.pm
skeleton plugin: added the canrename and canremove hooks
[git.ikiwiki.info.git] / IkiWiki / Plugin / remove.pm
index 7815016625a3c84b4e8dc212d9fb86f728adf31d..2e3614cca7dde3bfcffab25ffefe82591e4eafaa 100644 (file)
@@ -3,7 +3,7 @@ package IkiWiki::Plugin::remove;
 
 use warnings;
 use strict;
 
 use warnings;
 use strict;
-use IkiWiki 2.00;
+use IkiWiki 3.00;
 
 sub import {
        hook(type => "getsetup", id => "remove", call => \&getsetup);
 
 sub import {
        hook(type => "getsetup", id => "remove", call => \&getsetup);
@@ -54,6 +54,26 @@ sub check_canremove ($$$) {
                        error("renaming of attachments is not allowed");
                }
        }
                        error("renaming of attachments is not allowed");
                }
        }
+
+       my $canremove;
+       IkiWiki::run_hooks(canremove => sub {
+               return if defined $canremove;
+               my $ret=shift->($page, $q, $session);
+               if (defined $ret) {
+                       if ($ret eq "") {
+                               $canremove=1;
+                       }
+                       elsif (ref $ret eq 'CODE') {
+                               $ret->();
+                               $canremove=0;
+                       }
+                       elsif (defined $ret) {
+                               error($ret);
+                               $canremove=0;
+                       }
+               }
+       });
+       return $canremove;
 }
 
 sub formbuilder_setup (@) {
 }
 
 sub formbuilder_setup (@) {