summaryrefslogtreecommitdiff
path: root/IkiWiki
diff options
context:
space:
mode:
authorJoey Hess <joey@kodama.kitenet.net>2008-09-25 16:49:30 -0400
committerJoey Hess <joey@kodama.kitenet.net>2008-09-25 16:49:30 -0400
commite1ba137317f3b35bdfa90b37659d9005e4c253f2 (patch)
treecd1f2cc67bc340fc05873858d87fc59b7c2e7a3a /IkiWiki
parent093e8154408d9a7517a0df1768f44ad581c70be2 (diff)
attachment: Add admin() pagespec to test if the uploading user is a wiki admin.
Diffstat (limited to 'IkiWiki')
-rw-r--r--IkiWiki/Plugin/attachment.pm20
1 files changed, 20 insertions, 0 deletions
diff --git a/IkiWiki/Plugin/attachment.pm b/IkiWiki/Plugin/attachment.pm
index 999fa4a86..f1a9b1939 100644
--- a/IkiWiki/Plugin/attachment.pm
+++ b/IkiWiki/Plugin/attachment.pm
@@ -311,6 +311,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;