[ljcom] r11494: LJSUP-11294: Change logic of cancellatio...
Committer: vtroitsky
LJSUP-11294: Change logic of cancellation of (community) entry promotion by authorU trunk/cgi-bin/LJ/Pay/SelfPromo.pm
Modified: trunk/cgi-bin/LJ/Pay/SelfPromo.pm
===================================================================
--- trunk/cgi-bin/LJ/Pay/SelfPromo.pm 2012-02-20 08:02:41 UTC (rev 11493)
+++ trunk/cgi-bin/LJ/Pay/SelfPromo.pm 2012-02-20 08:35:29 UTC (rev 11494)
@@ -446,13 +446,43 @@
my $remote = LJ::get_remote(); # TODO: To remove dependency from remote user !!!
- # Poster cancels promo, need to pay refund to promoter
- unless ( LJ::u_equals($remote, $promoter) ) {
+ # Owner cancels promo, need to pay refund to promoter
+ unless ( LJ::u_equals($remote, $promoter) ) {
# Req: $owner == $remote
# Notifications will be sent via shop
# TODO: ensure $owner == $remote , it's not obvious from conditions, it has to be concluded!
- return $class->owner_cancel_promo($object);
- } else {
+
+# return $class->owner_cancel_promo($object);
+
+ # send notifications to the promoter (owner cancelled)
+ $class->send_notification(
+ $promoter, 'deactivate',
+ 'reason' => 'owner',
+ 'object_url' => $object_url,
+ 'object' => $object,
+ 'owner' => $owner,
+ 'duration' => time - $promo->started,
+ );
+
+ # send notification to the owner itself (owner cancelled)
+ $class->send_notification(
+ $promo->owner, 'deactivate',
+ 'reason' => 'owner',
+ 'object_url' => $object_url,
+ 'object' => $object,
+ 'duration' => time - $promo->started,
+ 'notify_owner' => 1,
+ );
+
+ $class->deactivate_promo(
+ $promo->promoid, $promoter,
+ 'reason' => 'withdraw',
+ 'object' => $object,
+ 'object_url' => $object_url,
+ );
+ return 1;
+
+ } else {
$class->send_notification( # send notification to the owner of the promoted object
$owner, 'deactivate',
'reason' => 'withdraw',
@@ -461,9 +491,9 @@
'duration' => $promo->exptime - $promo->started,
# 'notify_poster' => 1,
'notify_owner' => 1,
- );
- }
- }
+ );
+ }
+ }
# Send notification to promoter
$class->send_notification(
@@ -474,14 +504,14 @@
'duration' => $promo->exptime - $promo->started,
);
- $class->deactivate_promo(
+ $class->deactivate_promo(
$promo->promoid, $promoter,
'reason' => 'withdraw',
# 'entry' => $entry,
# 'entry_url' => $entry->url,
'object' => $object,
'object_url' => $object_url,
- );
+ );
return 1;
}
