]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - IkiWiki/Plugin/attachment.pm
Merge branch 'tova'
[git.ikiwiki.info.git] / IkiWiki / Plugin / attachment.pm
index 999fa4a8609c1b9f48702b3f6132e6d44a87cf71..8379928418fd997922a574bc59f68c79415251d4 100644 (file)
@@ -181,8 +181,7 @@ sub formbuilder (@) { #{{{
                        }
                }
 
-               $filename=IkiWiki::linkpage(
-                       IkiWiki::possibly_foolish_untaint(
+               $filename=linkpage(IkiWiki::possibly_foolish_untaint(
                                attachment_location($form->field('page')).
                                IkiWiki::basename($filename)));
                if (IkiWiki::file_pruned($filename, $config{srcdir})) {
@@ -271,7 +270,7 @@ sub attachment_list ($) { #{{{
 
        my @ret;
        foreach my $f (values %pagesources) {
-               if (! defined IkiWiki::pagetype($f) &&
+               if (! defined pagetype($f) &&
                    $f=~m/^\Q$loc\E[^\/]+$/ &&
                    -e "$config{srcdir}/$f") {
                        push @ret, {
@@ -311,6 +310,26 @@ sub match_user ($$;@) { #{{{
        }
 } #}}}
 
+sub match_admin ($$;@) { #{{{
+       shift;
+       shift;
+       my %params=@_;
+       
+       if (! exists $params{user}) {
+               return IkiWiki::FailReason->new("no user specified");
+       }
+
+       if (defined $params{user} && IkiWiki::is_admin($params{user})) {
+               return IkiWiki::SuccessReason->new("user is an admin");
+       }
+       elsif (! defined $params{user}) {
+               return IkiWiki::FailReason->new("not logged in");
+       }
+       else {
+               return IkiWiki::FailReason->new("user is not an admin");
+       }
+} #}}}
+
 sub match_ip ($$;@) { #{{{
        shift;
        my $ip=shift;