]> sipb.mit.edu Git - ikiwiki.git/commitdiff
attachment: Add admin() pagespec to test if the uploading user is a wiki admin.
authorJoey Hess <joey@kodama.kitenet.net>
Thu, 25 Sep 2008 20:49:30 +0000 (16:49 -0400)
committerJoey Hess <joey@kodama.kitenet.net>
Thu, 25 Sep 2008 20:49:30 +0000 (16:49 -0400)
IkiWiki/Plugin/attachment.pm
debian/changelog
doc/ikiwiki/pagespec/attachment.mdwn

index 999fa4a8609c1b9f48702b3f6132e6d44a87cf71..f1a9b19394701ea82558513ecc423b451ba2ddc4 100644 (file)
@@ -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;
index ff119a314287759154c59d1bafe5bbf57717ef52..002591083a5d19b6301c1c7a9c8facc9879cb6ef 100644 (file)
@@ -3,6 +3,8 @@ ikiwiki (2.66) UNRELEASED; urgency=low
   * recentchanges: Fix redirects to non-page files. 
   * aggregate: Avoid uninitialized value warnings for pages with no recorded
     ctime.
+  * attachment: Add admin() pagespec to test if the uploading user is a wiki
+    admin.
 
  -- Joey Hess <joeyh@debian.org>  Thu, 25 Sep 2008 13:45:55 -0400
 
index 6b86c510b41cfe74b2aad7e0a38a5d259e7e9085..234fcdf02ef18a7223c1c21529962425bed3d44c 100644 (file)
@@ -41,6 +41,10 @@ additional tests:
   Tests whether the attachment is being uploaded by a user with the
   specified username. If openid is enabled, an openid can also be put here.
 
+* adminuser()
+
+  Tests whether the attachment is being uploded by one of the wiki admins.
+
 * ip(address)
 
   Tests whether the attacment is being uploaded from the specified IP