журнал (shhh) wrote in changelog,
журнал
shhh
changelog

[livejournal] r23243: LJSUP-14157: Add 'limit social capital' ...

Committer: nnikulochkina
LJSUP-14157: Add 'limit social capital' param to paid repost settings
U   trunk/cgi-bin/LJ/Widget/EntryForm.pm
U   trunk/cgi-bin/ljprotocol.pl
U   trunk/cgi-bin/weblib.pl
U   trunk/htdocs/editjournal.bml
U   trunk/htdocs/update.bml
Modified: trunk/cgi-bin/LJ/Widget/EntryForm.pm
===================================================================
--- trunk/cgi-bin/LJ/Widget/EntryForm.pm	2012-11-01 14:40:41 UTC (rev 23242)
+++ trunk/cgi-bin/LJ/Widget/EntryForm.pm	2012-11-01 14:40:54 UTC (rev 23243)
@@ -890,6 +890,7 @@
             return '' unless LJ::is_enabled("paid_repost");
             
             my ($paid_repost_on, $budget) = ($opts->{paid_repost_on}, $opts->{current_repost_budget});
+            my $limit_sc = $opts->{repost_limit_sc};
 
             my $out = '';
 
@@ -938,7 +939,10 @@
             $out .= qq{<label for="repost_budget" class="b-updatepage-paidrepost-label">$label</label>};
             $out .= qq{<span class="b-updatepage-paidrepost-budget">$field</span>};
             $out .= qq{</span>};
-            
+
+            my $limit_sc_text = LJ::Lang::ml('talk.post.paidrepost.limit_sc');    
+            $out .= qq{$limit_sc_text <input type="text" name="repost_limit_sc" value="$limit_sc">};
+
             return $out;
         },         
         'sticky' => sub {

Modified: trunk/cgi-bin/ljprotocol.pl
===================================================================
--- trunk/cgi-bin/ljprotocol.pl	2012-11-01 14:40:41 UTC (rev 23242)
+++ trunk/cgi-bin/ljprotocol.pl	2012-11-01 14:40:54 UTC (rev 23243)
@@ -2448,13 +2448,10 @@
     if (LJ::is_enabled("paid_repost")) {
         my $error;
 
-        if ($req->{'repost_budget'} && $req->{'repost_budget'} =~ /\D/) {
-            return fail($err,224);
-        }
-
         $repost_offer = LJ::Pay::Repost::Offer->from_create_entry(
             \$event, 
             {repost_budget => $req->{'repost_budget'},
+             limit_sc      => $req->{'repost_limit_sc'},
              journalid     => $ownerid,
              userid        => $posterid}, 
             \$error
@@ -2463,8 +2460,6 @@
         return fail($err,222) if $repost_offer && ! $flags->{noauth};
        
         return fail($err,160,$error) if $error;
-
-        return fail($err,223) if $req->{'paid_repost_on'} && ! $repost_offer->{'budget'};
     }
 
     # convert RTE lj-embeds to normal lj-embeds
@@ -2839,24 +2834,6 @@
         }
     }    
     
-    if ($repost_offer) {
-        my $error = '';
-        
-        $repost_offer->{jitemid} = $jitemid;
-
-        my $offer_id = LJ::Pay::Repost::Offer->create(
-            \$error,
-            %$repost_offer,
-        );
-
-        unless ( $offer_id ) {
-            LJ::delete_entry($uowner, $jitemid, undef, $anum); # roll-back
-            return fail($err,160,$error);
-        } else {
-            $req->{props}->{repost_offer} = $offer_id;
-        }
-    }
-
     # Entry tags
     if ($req->{props} && defined $req->{props}->{taglist}) {
         # slightly misnamed, the taglist is/was normally a string, but now can also be an arrayref.
@@ -2930,6 +2907,23 @@
                           \%logprops) if %logprops;
     }
 
+    # Paid Repost Offer
+    if ($repost_offer) {
+        my $error = '';
+        
+        $repost_offer->{jitemid} = $jitemid;
+
+        my $offer_id = LJ::Pay::Repost::Offer->create(
+            \$error,
+            %$repost_offer,
+        );
+
+        unless ( $offer_id ) {
+            LJ::delete_entry($uowner, $jitemid, undef, $anum); # roll-back
+            return fail($err,160,$error);
+        }
+    }
+
     $dbh->do("UPDATE userusage SET timeupdate=NOW(), lastitemid=$jitemid ".
              "WHERE userid=$ownerid") unless $flags->{'notimeupdate'};
     LJ::MemCache::set([$ownerid, "tu:$ownerid"], pack("N", time()), 30*60);
@@ -3461,20 +3455,6 @@
     if (LJ::is_enabled("paid_repost") && $req->{'event'} =~ /\S/) {
         my $error;
 
-        if(!$curprops{$itemid}->{repost_offer} &&
-           $req->{paid_repost_on} &&
-           !$req->{repost_budget}) {
-            return fail($err,223);
-        }
-
-        if ($req->{repost_budget} && $req->{repost_budget} =~ /\D/){
-            return fail($err,224);
-        }
-
-        if ($req->{add_repost_budget} && $req->{add_repost_budget} =~ /\D/){
-            return fail($err,224);
-        }
-
         ($repost_offer, $repost_offer_action) = LJ::Pay::Repost::Offer->from_edit_entry(
             \$req->{event},
             {
@@ -3483,14 +3463,21 @@
                 journalid   => $ownerid,
                 jitemid     => $itemid,
                 budget      => $req->{repost_budget},
+                limit_sc    => $req->{repost_limit_sc},
                 revoke      => !$req->{paid_repost_on},
             },
             \$error,
         );
         
-        # cannot create or edit repost offer via api
-        return fail($err,222) if $repost_offer && $repost_offer_action =~ /create|edit/ && ! $flags->{noauth};;
+        
+        unless ($flags->{noauth}) {
+            # cannot create or edit repost offer via api
+            return fail($err,222) if $repost_offer && $repost_offer_action =~ /create|edit/;
 
+            # do not revoke repost offer via api
+            undef $repost_offer if $repost_offer && $repost_offer_action =~ /revoke/;
+        }
+  
         return fail($err,160,$error) if $error;
     }
     
@@ -3650,12 +3637,12 @@
 
             my $offer_id = LJ::Pay::Repost::Offer->create(\$error, %$repost_offer) or 
                 fail(\$warning,160,$error);
-            
-            $req->{props}->{repost_offer} = $offer_id if $offer_id;
-            
+                        
         } elsif($repost_offer_action eq 'edit') {
-            $repost_offer->add_budget(\$error, $repost_offer->{add_budget}) or 
-                fail(\$warning,160,$error);
+            $repost_offer->edit(\$error, 
+                                add_budget => $repost_offer->{add_budget},
+                                limit_sc   => $repost_offer->{limit_sc},
+                                ) or fail(\$warning,160,$error);
        
         } elsif($repost_offer_action eq 'revoke') {
             

Modified: trunk/cgi-bin/weblib.pl
===================================================================
--- trunk/cgi-bin/weblib.pl	2012-11-01 14:40:41 UTC (rev 23242)
+++ trunk/cgi-bin/weblib.pl	2012-11-01 14:40:54 UTC (rev 23243)
@@ -1158,7 +1158,7 @@
                 prop_opt_preformatted prop_opt_nocomments prop_opt_lockcomments
                 prop_current_location prop_current_coords
                 prop_taglist prop_qotdid prop_give_features 
-                repost_budget paid_repost_on)) {
+                repost_budget paid_repost_on repost_limit_sc)) {
         $req->{$_} = $POST->{$_};
     }
 

Modified: trunk/htdocs/editjournal.bml
===================================================================
--- trunk/htdocs/editjournal.bml	2012-11-01 14:40:41 UTC (rev 23242)
+++ trunk/htdocs/editjournal.bml	2012-11-01 14:40:54 UTC (rev 23243)
@@ -635,6 +635,7 @@
                 if($offer && $offer->is_active) {
                     $entry->{'current_repost_budget'} = $offer->budget;
                     $entry->{'paid_repost_on'} = 1 unless defined $entry->{'paid_repost_on'};
+                    $entry->{'repost_limit_sc'} = $offer->limit_sc;
                 }
             }
             

Modified: trunk/htdocs/update.bml
===================================================================
--- trunk/htdocs/update.bml	2012-11-01 14:40:41 UTC (rev 23242)
+++ trunk/htdocs/update.bml	2012-11-01 14:40:54 UTC (rev 23243)
@@ -350,6 +350,7 @@
             'albums_id'             => $POST{'albums_id'} || $GET{'albums_id'},
             'photos_id'             => $POST{'photos_id'} || $GET{'photos_id'},
             'repost_budget'         => $POST{'repost_budget'},
+            'repost_limit_sc'       => $POST{'repost_limit_sc'},
         };
 
         if ($remote) {
@@ -535,7 +536,8 @@
                     'custom_time' => $custom_time,
                     'tz'          => $timezone,
                     'posttype'    => $type,
-                    'repost_budget' => $POST{'repost_budget'},
+                    'repost_budget'   => $POST{'repost_budget'},
+                    'repost_limit_sc' => $POST{'repost_limit_sc'},
                     );
 
         $flags->{'use_custom_time'} = 1; 

Tags: bml, livejournal, nikulochkina, nnikulochkina, pl, 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