Alexander Nazarov (nfokz) wrote in changelog,
Alexander Nazarov
nfokz
changelog

[ljcom] r11152: LJSUP-9901: Add ability to put entry fro...

Committer: anazarov
LJSUP-9901: Add ability to put entry from community to owner and maintainers
U   trunk/bin/upgrading/en_LJ.dat
U   trunk/cgi-bin/LJ/Pay/Payment/PayItem/SelfPromo.pm
U   trunk/cgi-bin/LJ/Pay/SelfPromo.pm
Modified: trunk/bin/upgrading/en_LJ.dat
===================================================================
--- trunk/bin/upgrading/en_LJ.dat	2011-11-07 08:15:27 UTC (rev 11151)
+++ trunk/bin/upgrading/en_LJ.dat	2011-11-07 08:54:40 UTC (rev 11152)
@@ -6778,6 +6778,25 @@
 selfpromo.notification.deactivate.admin2.subject|staleness=1
 selfpromo.notification.deactivate.admin2.subject=Entry promotion discontinued
 
+selfpromo.notification.deactivate.admin3.body|staleness=1
+selfpromo.notification.deactivate.admin3.body<<
+Dear [[poster]],
+
+Promotion of your entry at [[entry_url]] has been discontinued due to a Terms of Use violation. Your entry stayed promoted for [[duration_hours]] [[?duration_hours|hour|hours|hours]] [[duration_min]] [[?duration_min|minute|minutes|minutes]].
+
+If you want to promote another entry, you can purchase promotion at the promotion page (http://www.livejournal.com/shop/selfpromo.bml).
+
+If you think it was removed in error, please contact our Support team (http://www.livejournal.com/support/) and let us know.
+
+Thank you for using the service!
+
+LiveJournal Team
+http://www.livejournal.com
+.
+
+selfpromo.notification.deactivate.admin3.subject|staleness=1
+selfpromo.notification.deactivate.admin3.subject=Entry promotion discontinued
+
 selfpromo.notification.deactivate.buyout.body<<
 Dear [[poster]],
 
@@ -6811,6 +6830,23 @@
 selfpromo.notification.deactivate.buyout2.subject|staleness=1
 selfpromo.notification.deactivate.buyout2.subject=Entry promotion discontinued
 
+selfpromo.notification.deactivate.buyout3.body|staleness=1
+selfpromo.notification.deactivate.buyout3.body<<
+Dear [[poster]],
+
+Promotion of your entry at [[entry_url]] has been discontinued because someone else bought it out. Your entry stayed promoted for [[duration_hours]] [[?duration_hours|hour|hours|hours]] [[duration_min]] [[?duration_min|minute|minutes|minutes]].
+
+If you want to promote an entry again, you can purchase promotion at the promotion page (http://www.livejournal.com/shop/selfpromo.bml).
+
+Thank you for using the service!
+
+LiveJournal Team
+http://www.livejournal.com
+.
+
+selfpromo.notification.deactivate.buyout3.subject|staleness=1
+selfpromo.notification.deactivate.buyout3.subject=Entry promotion discontinued
+
 selfpromo.notification.deactivate.deleted.body|staleness=1
 selfpromo.notification.deactivate.deleted.body<<
 Dear [[poster]],

Modified: trunk/cgi-bin/LJ/Pay/Payment/PayItem/SelfPromo.pm
===================================================================
--- trunk/cgi-bin/LJ/Pay/Payment/PayItem/SelfPromo.pm	2011-11-07 08:15:27 UTC (rev 11151)
+++ trunk/cgi-bin/LJ/Pay/Payment/PayItem/SelfPromo.pm	2011-11-07 08:54:40 UTC (rev 11152)
@@ -86,7 +86,7 @@
     # if there's an entry being promoted, deactivate it, and
     # then handle any refund if need be
     #
-    # note that it also stays valid for admin cancellations because they
+    # note that it also stays valid for admin or poster cancellations because they
     # also only cancel the current promotion
     my $entry_promoted;
     if ( $entry_promoted = LJ::Pay::SelfPromo->current_entry ) {
@@ -130,9 +130,22 @@
                 $refund_to, 'deactivate',
                 'reason'        => $reason_map->{$type},
                 'entry_url'     => $entry_url,
+                'entry'         => $promo->entry,
                 'refund_amount' => $refund,
                 'duration'      => time - $promo->started,
             );
+
+            unless ( LJ::u_equals($promo->poster, $refund_to) ) {
+                LJ::Pay::SelfPromo->send_notification(
+                    $promo->poster, 'deactivate',
+                    'reason'        => $reason_map->{$type},
+                    'entry_url'     => $entry_url,
+                    'entry'         => $promo->entry,
+                    'refund_amount' => $refund,
+                    'duration'      => time - $promo->started,
+                    'notify_poster' => 1,
+                );
+            }
         }
     }
 

Modified: trunk/cgi-bin/LJ/Pay/SelfPromo.pm
===================================================================
--- trunk/cgi-bin/LJ/Pay/SelfPromo.pm	2011-11-07 08:15:27 UTC (rev 11151)
+++ trunk/cgi-bin/LJ/Pay/SelfPromo.pm	2011-11-07 08:54:40 UTC (rev 11152)
@@ -363,6 +363,24 @@
         unless $promo->journalid == $entry->journalid
             && $promo->jitemid == $entry->jitemid;
 
+    unless ( LJ::u_equals($poster, $promoter) ) {
+        my $remote = LJ::get_remote();
+
+        # Poster cancels promo, need to pay refund to promoter
+        unless  ( LJ::u_equals($remote, $promoter) ) {
+            # Notifications will be sent via shop
+            return $class->poster_cancel_promo($entry)
+        } else {
+            $class->send_notification(
+                $poster, 'deactivate',
+                'reason'    => 'withdraw',
+                'entry_url' => $entry->url,
+                'duration'  => $promo->exptime - $promo->started,
+                'notify_poster' => 1,
+            );
+        }
+    }
+
     $class->send_notification(
         $promoter, 'deactivate',
         'reason'    => 'withdraw',
@@ -370,21 +388,6 @@
         'duration'  => $promo->exptime - $promo->started,
     );
 
-    unless ( LJ::u_equals($poster, $promoter) ) {
-        $class->send_notification(
-            $poster, 'deactivate',
-            'reason'    => 'withdraw',
-            'entry_url' => $entry->url,
-            'duration'  => $promo->exptime - $promo->started,
-        );
-
-        my $remote = LJ::get_remote();
-
-        # Poster cancels promo, need to pay refund to promoter
-        return $class->poster_cancel_promo($entry)
-            unless LJ::u_equals($remote, $promoter);
-    }
-
     $class->deactivate_promo(
         $promo->promoid, $promoter,
         'reason'    => 'withdraw',
@@ -441,6 +444,7 @@
                 'reason'    => 'deleted',
                 'entry_url' => $entry->url,
                 'duration'  => time - $promo->started,
+                'notify_poster' => 1,
             );
         }
     }
@@ -470,6 +474,7 @@
                 'entry'     => $entry,
                 'entry_url' => $entry->url,
                 'duration'  => time - $promo->started,
+                'notify_poster' => 1,
             );
         }
     }
@@ -492,6 +497,7 @@
                 'entry'     => $entry,
                 'entry_url' => $entry->url,
                 'duration'  => time - $promo->started,
+                'notify_poster' => 1,
             );
         }
     }
@@ -736,19 +742,27 @@
             'refund_amount'  => $opts{'refund_amount'},
             'entry_url'      => $opts{'entry_url'},
             'duration_hours' => int( $opts{'duration'} / 3600 ),
-            'duration_min'   => int( ( $opts{'duration'} % 3600 ) / 600 ) * 10,
+            'duration_min'   => int( ( $opts{'duration'} % 3600 ) / 60 ),
             'poster'         => $poster->display_name,
         );
 
         if ( $reason eq 'admin' ) {
-            $ml_var = 'selfpromo.notification.deactivate.admin2';
-            unless ( $opts{'refund_amount'} > 0 ) {
-                $ml_var .= '.norefund';
+            if ( $opts{'notify_poster'} ) {
+                $ml_var = 'selfpromo.notification.deactivate.admin3';
+            } else {
+                $ml_var = 'selfpromo.notification.deactivate.admin2';
+                unless ( $opts{'refund_amount'} > 0 ) {
+                    $ml_var .= '.norefund';
+                }
             }
         }
 
         if ( $reason eq 'buyout' ) {
-            $ml_var = 'selfpromo.notification.deactivate.buyout2';
+            if ( $opts{'notify_poster'} ) {
+                $ml_var = 'selfpromo.notification.deactivate.buyout3';
+            } else {
+                $ml_var = 'selfpromo.notification.deactivate.buyout2';
+            }
         }
 
         if ( $reason eq 'deleted' ) {
@@ -770,9 +784,13 @@
         }
 
         if ( $reason eq 'poster' ) {
-            $ml_var = 'selfpromo.notification.deactivate.poster';
-            $ml_params{'promoter'} = $ml_params{'poster'};
-            $ml_params{'poster'}   = $entry? $entry->poster->display_name : '';
+            if ( $opts{'notify_poster'} ) {
+                $ml_var = 'selfpromo.notification.deactivate.withdraw';
+            } else {
+                $ml_var = 'selfpromo.notification.deactivate.poster';
+                $ml_params{'promoter'} = $ml_params{'poster'};
+                $ml_params{'poster'}   = $entry ? $entry->poster->display_name : '';
+            }
         }
     }
 

Tags: anazarov, dat, ljcom, nfokz, pm
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments