Add page which shows users in your circle who might appreciate some 
paid time; link under the Shop menu.

        Patch by denise. 

diffs (163 lines):

diff -r a041e9c1d2fd -r 21c7e961f007 bin/upgrading/en.dat
--- a/bin/upgrading/en.dat      Sat Jul 11 05:16:12 2009 +0000
+++ b/bin/upgrading/en.dat      Sat Jul 11 05:26:19 2009 +0000
@@ -2207,6 +2207,8 @@ menunav.read.tags=Tags
 
 menunav.shop=Shop
 
+menunav.shop.gifts=Circle Gifts
+
 menunav.shop.paidtime=Buy a Paid Account
 
 menunav.shop.history=Payment History
diff -r a041e9c1d2fd -r 21c7e961f007 cgi-bin/DW/Logic/MenuNav.pm
--- a/cgi-bin/DW/Logic/MenuNav.pm       Sat Jul 11 05:16:12 2009 +0000
+++ b/cgi-bin/DW/Logic/MenuNav.pm       Sat Jul 11 05:26:19 2009 +0000
@@ -223,11 +223,16 @@ sub get_menu_navigation {
                     text => "menunav.shop.paidtime",
                     display => LJ::is_enabled( 'payments' ) ? 1 : 0,
                 },
-               {
-                   url => "$LJ::SITEROOT/shop/history.bml",
-                   text => "menunav.shop.history",
-                   display => LJ::is_enabled( 'payments' ) && $loggedin ? 1 : 
0,
-               },
+                       {
+                    url => "$LJ::SITEROOT/shop/history.bml",
+                    text => "menunav.shop.history",
+                    display => LJ::is_enabled( 'payments' ) && $loggedin ? 1 : 
0,
+                       },
+                       {
+                    url => "$LJ::SITEROOT/shop/gifts.bml",
+                    text => "menunav.shop.gifts",
+                    display => LJ::is_enabled( 'payments' ) && $loggedin ? 1 : 
0,
+                },
             ],
         },
     );
diff -r a041e9c1d2fd -r 21c7e961f007 htdocs/shop/gifts.bml
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/htdocs/shop/gifts.bml     Sat Jul 11 05:26:19 2009 +0000
@@ -0,0 +1,101 @@
+<?_c
+#!/usr/bin/perl
+#
+# /shop/gifts.bml
+#
+# Provides a list of users in your Circle who might want a paid account.
+#
+# 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'.
+#
+_c?><?page
+body<=
+<?_code
+{
+    use strict;
+    use vars qw/ %GET %POST $title /;
+
+
+    # translated/custom page title can go here
+    $title = BML::ml( '.title', { 'sitename' => $LJ::SITENAMESHORT } );
+
+    # for pages that require authentication
+    my $remote = LJ::get_remote();
+    return "<?needlogin?>" unless $remote;
+
+    my ( $ret, @free, @expiring );
+
+    my $circle = LJ::load_userids( $remote->circle_userids );
+
+    foreach my $target ( values %$circle ) {
+
+        if ( $target->is_person || $target->is_community ) {
+            my $paidstatus = DW::Pay::get_paid_status( $target );
+
+            # account is free if it has no paidstatus, if it's not permanent,
+            # and if the expiration date is greater than 0 (this prevents
+            # the problem where previously paid but expired accounts
+            # wouldn't show, since get_paid_status only returns undef if
+            # the account has never been paid, not if it's not currently
+            # paid...):
+            push @free, $target unless $paidstatus &&  
$paidstatus->{expiresin} > 0 || $paidstatus->{permanent};
+
+            # account is expiring soon if the expiration time is
+            # within the next month:
+            push @expiring, $target if $paidstatus &&  
$paidstatus->{expiresin} < 2592000  && $paidstatus->{expiresin} > 0;
+        }
+    }
+
+
+    # now that we have the lists, sort them alphabetically by display name: 
+    @free = sort { $a->display_name cmp $b->display_name } @free;
+    @expiring = sort { $a->display_name cmp $b->display_name } @expiring;
+
+    # and we've got our lists. the only thing left is to format them
+    # for human display, so we:
+
+    # build a list of expiring-soon users in the circle, formatted with
+    # the display username and a buy-a-gift link:
+    my $freeusers;
+    foreach my $person ( @free ) {
+        $freeusers .= "<li>" . $person->ljuser_display . ": " . 
$person->name_html . " [<a href='$LJ::SITEROOT/shop/account?for=gift&user=" . 
$person->user . "'>" . BML::ml( '.buy' ) . "</a>]</li>\n";
+    }
+
+    # build a list of expiring-soon users in the circle, formatted with
+    # the display username and a buy-a-gift link:
+    my $expusers;
+    foreach my $person ( @expiring ) {
+        $expusers .= "<li>" . $person->ljuser_display . ": " . 
$person->name_html . " [<a href='$LJ::SITEROOT/shop/account?for=gift&user=" . 
$person->user . "'>" . BML::ml( '.buy' ) . "</a>]</li>\n";
+    }
+
+    # and, now we build the page.
+    $ret .= "<p>" . BML::ml( '.about', { 'sitename' => $LJ::SITENAMESHORT } ) 
. "</p>";
+
+    if ( $freeusers ) {
+        $ret .= "<h2>" . BML::ml( '.free.header' ) . "</h2>\n";
+        $ret .= "<p>" . BML::ml( '.free.about', { 'aopts' => 
"href='$LJ::SITEROOT/support/faqbrowse.bml?faqid=153'" } ) . "</p>";
+        $ret .= "<ul> " . $freeusers . "</ul>";
+    }
+
+    if ( $expusers ) {
+        $ret .= "<h2>" . BML::ml( '.paid.header' ) . "</h2>\n";
+        $ret .= "<p>" . BML::ml( '.paid.about' ) . "</p>";
+        $ret .= "<ul> " . $expusers . "</ul>";
+    }
+
+    unless ( $freeusers || $expusers ) {
+        $ret .= "<p>" . BML::ml( '.none.text', { 'sitename' => 
$LJ::SITENAMESHORT, 'aopts' => "href='$LJ::SITEROOT/shop/'" } ) . "</p>";
+    }
+
+    return $ret;
+}
+_code?>
+<=body
+title=><?_code return $title; _code?>
+page?>
diff -r a041e9c1d2fd -r 21c7e961f007 htdocs/shop/gifts.bml.text
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/htdocs/shop/gifts.bml.text        Sat Jul 11 05:26:19 2009 +0000
@@ -0,0 +1,17 @@
+;; -*- coding: utf-8 -*-
+
+.about=Are you looking for a gift for a birthday or a holiday? Is one of the 
people in your Circle such a compelling writer that you want to find a way to 
say a quick "thank you for being so awesome"? Give the gift of a paid 
[[sitename]] account!
+
+.buy=Buy gift
+
+.free.about=These are the people in your Circle who have free accounts and 
might appreciate the chance to try out some of our <a [[aopts]]>paid 
features</a>: 
+
+.free.header=Free Accounts
+
+.none.text=None of the people in your Circle have free accounts or have paid 
accounts that are expiring within the next month! You can still buy someone a 
gift in the <a [[aopts]]>[[sitename]] Shop</a>.
+
+.paid.about=These are the people in your Circle who have paid accounts that 
are expiring within the next month:
+
+.paid.header=Expiring Soon
+
+.title=Give the Gift of [[sitename]]
_______________________________________________
dw-changelog mailing list
[email protected]
http://lists.dwscoalition.org/mailman/listinfo/dw-changelog

Reply via email to