]> scripts.mit.edu Git - www/ikiwiki.git/blobdiff - IkiWiki/Plugin/po.pm
po: use the new canrename hook to prevent translation renames in the CGI
[www/ikiwiki.git] / IkiWiki / Plugin / po.pm
index 5670f3608ef3a5bb8424fffb4c6c3898f72a868f..2dad3b60b898c5e1a3a8b3fb838413fda21b2dfa 100644 (file)
@@ -40,6 +40,7 @@ sub import {
        hook(type => "delete", id => "po", call => \&mydelete);
        hook(type => "change", id => "po", call => \&change);
        hook(type => "canremove", id => "po", call => \&canremove);
+       hook(type => "canrename", id => "po", call => \&canrename);
        hook(type => "editcontent", id => "po", call => \&editcontent);
 
        $origsubs{'bestlink'}=\&IkiWiki::bestlink;
@@ -417,6 +418,16 @@ sub canremove ($$$) {
        return undef;
 }
 
+sub canrename ($$$) {
+       my ($page, $cgi, $session) = (shift, shift, shift);
+
+       if (istranslation($page)) {
+               return gettext("Can not rename a translation. Renaming the master page,".
+                              "though, renames its translations as well.");
+       }
+       return undef;
+}
+
 # As we're previewing or saving a page, the content may have
 # changed, so tell the next filter() invocation it must not be lazy.
 sub editcontent () {