mark: A photo of Mark kneeling on top of the Taal Volcano in the Philippines. It was a long hike. (Default)
Mark Smith ([staff profile] mark) wrote in [site community profile] changelog2009-04-29 06:23 am

[dw-free] Finishing up payment system

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

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

Add 'buy a paid account' link to the profile page.

Patch by [personal profile] janinedog.

Files modified:
  • bin/upgrading/en.dat
  • cgi-bin/DW/Logic/ProfilePage.pm
  • cgi-bin/DW/Logic/UserLinkBar.pm
  • htdocs/img/silk/profile/buy_account.png
--------------------------------------------------------------------------------
diff -r c5a0b5cd0417 -r efe0c2bfca94 bin/upgrading/en.dat
--- a/bin/upgrading/en.dat	Wed Apr 29 06:18:18 2009 +0000
+++ b/bin/upgrading/en.dat	Wed Apr 29 06:23:44 2009 +0000
@@ -3433,6 +3433,18 @@ userlinkbar.addtrust.title.other=Grant a
 
 userlinkbar.addtrust.title.loggedout=You must be logged in to grant access to this user
 
+userlinkbar.buyaccount.comm=Gift Paid Account
+
+userlinkbar.buyaccount.other=Gift Paid Account
+
+userlinkbar.buyaccount.self=Upgrade Account
+
+userlinkbar.buyaccount.title.comm=Purchase paid time as a gift for this community
+
+userlinkbar.buyaccount.title.other=Purchase paid time as a gift for this user
+
+userlinkbar.buyaccount.title.self=Purchase paid time for yourself
+
 userlinkbar.joincomm=Join
 
 userlinkbar.joincomm.title.cantjoin=You cannot join this community
diff -r c5a0b5cd0417 -r efe0c2bfca94 cgi-bin/DW/Logic/ProfilePage.pm
--- a/cgi-bin/DW/Logic/ProfilePage.pm	Wed Apr 29 06:18:18 2009 +0000
+++ b/cgi-bin/DW/Logic/ProfilePage.pm	Wed Apr 29 06:23:44 2009 +0000
@@ -58,7 +58,7 @@ sub action_links {
     my $remote = $self->{remote};
     
     my $user_link_bar = $u->user_link_bar( $remote, class_prefix => "profile" );
-    my @ret = $user_link_bar->get_links( "manage_membership", "trust", "watch", "post", "track", "message" );
+    my @ret = $user_link_bar->get_links( "manage_membership", "trust", "watch", "post", "track", "message", "buyaccount" );
 }
 
 
diff -r c5a0b5cd0417 -r efe0c2bfca94 cgi-bin/DW/Logic/UserLinkBar.pm
--- a/cgi-bin/DW/Logic/UserLinkBar.pm	Wed Apr 29 06:18:18 2009 +0000
+++ b/cgi-bin/DW/Logic/UserLinkBar.pm	Wed Apr 29 06:23:44 2009 +0000
@@ -432,6 +432,44 @@ sub memories {
     return $self->fix_link( $link );
 }
 
+=head2 C<< $obj->buyaccount >>
+
+Returns a hashref with the appropriate icon/link/text for buying this user a paid account.
+
+=cut
+
+sub buyaccount {
+    my $self = $_[0];
+
+    my $u = $self->{u};
+    my $remote = $self->{remote};
+    my $user = $u->user;
+
+    # if payments are enabled:
+    # show link on personal journals and communities that aren't seed accounts
+    # as long as they have less than a year's worth of paid time
+    if (
+        ( LJ::is_enabled( 'payments' ) ) &&
+        ( $u->is_personal || $u->is_community ) &&
+        ( DW::Pay::get_account_type( $u ) ne 'seed' ) &&
+        ( ( DW::Pay::get_account_expiration_time( $u ) - time() ) < 86400*30 )
+    ) {
+        my $remote_is_u = $remote && $remote->equals( $u ) ? 1 : 0;
+        my $type = $remote_is_u ? 'self' : 'other';
+        $type = 'comm' if $u->is_community;
+
+        my $link = {
+            url => $remote_is_u ? "shop/account?for=self" : "shop/account?for=gift&user=$user",
+            image => 'buy_account.png',
+            text_ml => "userlinkbar.buyaccount.$type",
+            title_ml => "userlinkbar.buyaccount.title.$type",
+            class => 'buyaccount',
+        };
+
+        return $self->fix_link( $link );
+    }
+}
+
 =head1 BUGS
 
 =head1 AUTHORS
diff -r c5a0b5cd0417 -r efe0c2bfca94 htdocs/img/silk/profile/buy_account.png
Binary file htdocs/img/silk/profile/buy_account.png has changed
--------------------------------------------------------------------------------

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