Add account level display under accounts tab.

        Patch by denise. 

diffs (95 lines):

diff -r fb6cfdde33c8 -r 904246a1deb8 bin/upgrading/en.dat
--- a/bin/upgrading/en.dat      Sat Jul 11 15:28:56 2009 +0000
+++ b/bin/upgrading/en.dat      Sat Jul 11 16:33:59 2009 +0000
@@ -2573,6 +2573,14 @@ setting.display.accountstatus.option.rea
 
 setting.display.accountstatus.option.suspended=Suspended
 
+setting.display.accounttype.label=Account Type
+
+setting.display.accounttype.addmore=Extend Account
+
+setting.display.accounttype.upgrade=Upgrade
+
+setting.display.accounttype.status=[[status]], expiring [[exptime]]
+
 setting.display.banusers.label=Ban and Unban Users
 
 setting.display.banusers.option.comm=Ban and unban users from commenting in my 
community
diff -r fb6cfdde33c8 -r 904246a1deb8 cgi-bin/DW/Setting/Display/AccountLevel.pm
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/cgi-bin/DW/Setting/Display/AccountLevel.pm        Sat Jul 11 16:33:59 
2009 +0000
@@ -0,0 +1,61 @@
+#!/usr/bin/perl
+#
+# DW::Setting::Display::AccountLevel - shows user's current account 
+# level and a link to the shop.
+#
+# Authors:
+#      Denise Paolucci <[email protected]>
+#
+# Copyright (c) 2009 by Dreamwidth Studios, LLC.
+#
+# This program is free software; you may redistribute it and/or modify it under
+# the same terms as Perl itself. For a copy of the license, please reference
+# 'perldoc perlartistic' or 'perldoc perlgpl'.
+
+package DW::Setting::Display::AccountLevel;
+use base 'LJ::Setting';
+use strict;
+use warnings;
+
+sub should_render {
+    my ( $class, $u ) = @_;
+
+    return $u && $u->is_person && LJ::is_enabled( 'payments' ) ? 1 : 0;
+}
+
+sub label {
+    my $class = shift;
+
+    return $class->ml( 'setting.display.accounttype.label' );
+}
+
+sub actionlink {
+    my ( $class, $u ) = @_;
+
+    my $paidstatus = DW::Pay::get_paid_status( $u );
+
+    if ( $paidstatus && $paidstatus->{permanent} ) {
+        return "";
+    } elsif ( $paidstatus && DW::Pay::get_account_type( $u->userid ) eq 
"premium" ) {
+         # tell premium paid users to just add more time, not upgrade
+         return "<a href='$LJ::SITEROOT/shop/?for=gift&user=" . $u->user . 
"'>" . $class->ml( 'setting.display.accounttype.addmore' ) . "</a>";
+    } else {
+        return "<a href='$LJ::SITEROOT/shop/?for=gift&user=" . $u->user . "'>" 
. $class->ml( 'setting.display.accounttype.upgrade' ) . "</a>";
+    }
+}
+
+sub option {
+    my ( $class, $u, $errs, $args ) = @_;
+
+    my $paidstatus = DW::Pay::get_paid_status( $u );
+    my $paidtype = "<strong>" . $paidstatus ? DW::Pay::type_name( 
$paidstatus->{typeid} ) : "" . "</strong>";
+    my $expiretime = LJ::mysql_time( $paidstatus->{expiretime} );
+
+    if ( $paidstatus && $paidstatus->{expiresin} > 0 && ! 
$paidstatus->{permanent} ) {
+        return BML::ml( 'setting.display.accounttype.status', { status => 
$paidtype, exptime => $expiretime } );
+    } else {
+        return $paidtype;
+    }
+}
+
+1;
diff -r fb6cfdde33c8 -r 904246a1deb8 htdocs/manage/settings/index.bml
--- a/htdocs/manage/settings/index.bml  Sat Jul 11 15:28:56 2009 +0000
+++ b/htdocs/manage/settings/index.bml  Sat Jul 11 16:33:59 2009 +0000
@@ -40,7 +40,7 @@ body<=
             form => 0,
             desc => $ML{'.cat.account.desc'},
             settings => [qw(
-                LJ::Setting::Display::AccountLevel
+                DW::Setting::Display::AccountLevel
                 LJ::Setting::Display::AccountStatus
                 LJ::Setting::Display::Email
                 LJ::Setting::Display::Password
_______________________________________________
dw-changelog mailing list
[email protected]
http://lists.dwscoalition.org/mailman/listinfo/dw-changelog

Reply via email to