fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([personal profile] fu) wrote in [site community profile] changelog2010-08-31 03:16 am

[dw-free] add siteadmin:invites priv

[commit: http://hg.dwscoalition.org/dw-free/rev/a7f858ce42d3]

http://bugs.dwscoalition.org/show_bug.cgi?id=2974

Allow trusted people to have a subset of invites functionality.

Patch by [personal profile] fu.

Files modified:
  • cgi-bin/LJ/User.pm
  • cgi-bin/ljlib.pl
  • htdocs/admin/invites/distribute.bml
  • htdocs/admin/invites/index.bml
  • htdocs/admin/invites/promo.bml
  • htdocs/admin/invites/requests.bml
--------------------------------------------------------------------------------
diff -r 909c7faa2251 -r a7f858ce42d3 cgi-bin/LJ/User.pm
--- a/cgi-bin/LJ/User.pm	Mon Aug 30 14:19:12 2010 -0500
+++ b/cgi-bin/LJ/User.pm	Tue Aug 31 11:16:42 2010 +0800
@@ -1978,6 +1978,15 @@ sub can_leave_comments {
     return $_[0]->get_cap( 'leave_comments' ) ? 1 : 0;
 }
 
+sub can_manage_invites_light {
+    my $u = $_[0];
+
+    return 1 if $u->has_priv( "payments" );
+    return 1 if $u->has_priv( "siteadmin", "invites" );
+
+    return 0;
+}
+
 sub can_map_domains {
     return $_[0]->get_cap( 'domainmap' ) ? 1 : 0;
 }
diff -r 909c7faa2251 -r a7f858ce42d3 cgi-bin/ljlib.pl
--- a/cgi-bin/ljlib.pl	Mon Aug 30 14:19:12 2010 -0500
+++ b/cgi-bin/ljlib.pl	Tue Aug 31 11:16:42 2010 +0800
@@ -2446,6 +2446,7 @@ sub list_valid_args {
         commentview    => "Access to /admin/recent_comments",
         emailqueue     => "Access to /tools/recent_email",
         entry_redirect => "Access to /misc/entry_redirect",
+        invites        => "Access to some invites functionality under /admin/invites",
         largefeedsize  => "Overrides synsuck_max_size for a feed",
         memcacheview   => "Access to /admin/memcache",
         mysqlstatus    => "Access to /admin/mysql_status",
diff -r 909c7faa2251 -r a7f858ce42d3 htdocs/admin/invites/distribute.bml
--- a/htdocs/admin/invites/distribute.bml	Mon Aug 30 14:19:12 2010 -0500
+++ b/htdocs/admin/invites/distribute.bml	Tue Aug 31 11:16:42 2010 +0800
@@ -20,7 +20,7 @@ body<=
     return LJ::error_noremote() unless $remote;
 
     return BML::redirect( $LJ::SITEROOT )
-        unless $remote->has_priv( 'payments' );
+        unless $remote->can_manage_invites_light;
 
     my $ret;
 
diff -r 909c7faa2251 -r a7f858ce42d3 htdocs/admin/invites/index.bml
--- a/htdocs/admin/invites/index.bml	Mon Aug 30 14:19:12 2010 -0500
+++ b/htdocs/admin/invites/index.bml	Tue Aug 31 11:16:42 2010 +0800
@@ -26,6 +26,7 @@ body<=
 
     my $haspayments = $remote->has_priv( "payments" );
     my $hasfinduser = $remote->has_priv ( "finduser", "codetrace" );
+    my $hasinvites  = $remote->can_manage_invites_light;
 
     my $ret;
 
@@ -33,16 +34,16 @@ body<=
         if $hasfinduser;
 
     $ret .= "<div class='itemhead'><a href='distribute'><?_ml .distribute.head _ml?></a></div><div class='itemdef'><?_ml .distribute.desc _ml?></div>"
-        if $haspayments;
+        if $hasinvites;
 
     $ret .= "<div class='itemhead'><a href='requests'><?_ml .requests.head _ml?></a></div><div class='itemdef'><?_ml .requests.desc _ml?></div>"
-        if $haspayments;
+        if $hasinvites;
 
     $ret .= "<div class='itemhead'><a href='review'><?_ml .review.head _ml?></a></div><div class='itemdef'><?_ml .review.desc _ml?></div>"
         if $haspayments;
 
     $ret .= "<div class='itemhead'><a href='promo?state=active'><?_ml .promo.head _ml?></a></div><div class='itemdef'><?_ml .promo.desc _ml?></div>"
-        if $haspayments;
+        if $hasinvites;
 
 
     return $ret;
diff -r 909c7faa2251 -r a7f858ce42d3 htdocs/admin/invites/promo.bml
--- a/htdocs/admin/invites/promo.bml	Mon Aug 30 14:19:12 2010 -0500
+++ b/htdocs/admin/invites/promo.bml	Tue Aug 31 11:16:42 2010 +0800
@@ -23,7 +23,7 @@ body<=
     return "<?needlogin?>" unless $remote;
 
     return "You are not authorized to view this page."
-        unless $remote->has_priv( "payments" );
+        unless $remote->can_manage_invites_light;
 
     my $ret = "";
 
diff -r 909c7faa2251 -r a7f858ce42d3 htdocs/admin/invites/requests.bml
--- a/htdocs/admin/invites/requests.bml	Mon Aug 30 14:19:12 2010 -0500
+++ b/htdocs/admin/invites/requests.bml	Tue Aug 31 11:16:42 2010 +0800
@@ -22,7 +22,7 @@ body<=
     return "<?needlogin?>" unless $remote;
 
     return "You are not authorized to view this page."
-        unless $remote->has_priv( "payments" );
+        unless $remote->can_manage_invites_light;
 
     my $ret;
 
@@ -99,7 +99,7 @@ body<=
         }
 
         my $reason = $outstanding->reason || "( no reason given )";
-        $ret .= "<td><a href='review?user=$u->{user}'>$reason</a></td>";
+        $ret .= $remote->has_priv( "payments" ) ? "<td><a href='review?user=$u->{user}'>$reason</a></td>" : "<td>$reason</td>";
         $ret .= "</tr>";
     }
 
--------------------------------------------------------------------------------

Post a comment in response:

This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org