madeon (madeon) wrote in changelog,
madeon
madeon
changelog

[livejournal] r22234: LJSUP-12562: Not delete Repost if Delete...

Committer: sbelyaev
LJSUP-12562: Not delete Repost if Deleted original entry
U   trunk/cgi-bin/LJ/Entry/Repost.pm
U   trunk/cgi-bin/LJ/Entry.pm
U   trunk/cgi-bin/LJ/S2/DayPage.pm
U   trunk/cgi-bin/LJ/S2/FriendsPage.pm
U   trunk/cgi-bin/LJ/S2/MonthPage.pm
U   trunk/cgi-bin/LJ/S2/RecentPage.pm
U   trunk/cgi-bin/LJ/S2.pm
U   trunk/cgi-bin/ljviews.pl
Modified: trunk/cgi-bin/LJ/Entry/Repost.pm
===================================================================
--- trunk/cgi-bin/LJ/Entry/Repost.pm	2012-06-14 08:45:57 UTC (rev 22233)
+++ trunk/cgi-bin/LJ/Entry/Repost.pm	2012-06-14 09:16:39 UTC (rev 22234)
@@ -434,17 +434,45 @@
             my $journal = int($org_journalid) ? LJ::want_user($org_journalid) : undef;
             
             my $fake_entry = LJ::Entry->new( $journal, jitemid => $org_jitemid);
-             
-            my $event = LJ::Lang::ml( 'entry.reference.journal.delete',
-                                      'datetime'     => $entry_obj->eventtime_mysql, 
-                                      'url'          => $fake_entry->url);
-            
-            ${$opts->{'event'}} = $event;
+
+            my $subject = LJ::Lang::ml( 'entry.reference.journal.delete.subject' );   
+            my $event   = LJ::Lang::ml( 'entry.reference.journal.delete',
+                                        'datetime'     => $entry_obj->eventtime_mysql, 
+                                        'url'          => $fake_entry->url);
+
+            if ($opts->{'removed'}) {
+                ${$opts->{'removed'}} = 1;
+            }
+           
+            if ($opts->{'repost_obj'}) {
+                ${$opts->{'repost_obj'}} = $fake_entry;
+            }
+ 
+            if ($opts->{'subject_repost'}) {
+                ${$opts->{'subject_repost'}} = $subject;
+            }
+
+            if ($opts->{'subject'}) {
+                ${$opts->{'subject'}}  = $subject;
+            }
+ 
+            if ($opts->{'event_raw'}) {
+                ${$opts->{'event_raw'}} = $event;
+            }
+
+            if ($opts->{'event'}) {
+                ${$opts->{'event'}} = $event;
+            }
+
             return 1;    
         }
         return 0;
     }
 
+    if ($opts->{'removed'}) {
+        ${$opts->{'removed'}} = 0;
+    }
+
     if ($opts->{'anum'}) {
         ${$opts->{'anum'}} = $original_entry_obj->anum;
     }

Modified: trunk/cgi-bin/LJ/Entry.pm
===================================================================
--- trunk/cgi-bin/LJ/Entry.pm	2012-06-14 08:45:57 UTC (rev 22233)
+++ trunk/cgi-bin/LJ/Entry.pm	2012-06-14 09:16:39 UTC (rev 22234)
@@ -2565,8 +2565,6 @@
     LJ::MemCache::delete([$jid, "log2:$jid:$jitemid"]);
     LJ::MemCache::decr([$jid, "log2ct:$jid"]) if $dc > 0;
 
-    LJ::Entry::Repost->delete_all_reposts_records($jid, $jitemid);
-
     if ( $jitemid == $u->get_sticky_entry_id() ){
         $u->remove_sticky_entry_id();
     }

Modified: trunk/cgi-bin/LJ/S2/DayPage.pm
===================================================================
--- trunk/cgi-bin/LJ/S2/DayPage.pm	2012-06-14 08:45:57 UTC (rev 22233)
+++ trunk/cgi-bin/LJ/S2/DayPage.pm	2012-06-14 09:16:39 UTC (rev 22234)
@@ -138,6 +138,7 @@
         }
 
         my $repost_entry_obj;
+        my $removed;
         my $lite_journalu =  $userlite_journal;
 
         my $content =  { 'original_post_obj' => \$entry_obj,
@@ -150,18 +151,20 @@
                          'event_raw'         => \$text,
                          'subject'           => \$subject,
                          'reply_count'       => \$replycount,
-                         'userlite'          => \$lite_journalu, };
+                         'userlite'          => \$lite_journalu,
+                         'removed'           => \$removed, };
 
         if (LJ::Entry::Repost->substitute_content( $entry_obj, $content )) {
+            next ENTRY if $removed && !LJ::u_equals($user, $remote);
             next ENTRY unless $entry_obj->visible_to($remote, { 'viewall'  => $viewall,
                                                                 'viewsome' => $viewsome});
 
             $logprops{$itemid} = $entry_obj->props;
 
             $lite_journalu = UserLite($entry_obj->journal);
-
             $apu_lite{$entry_obj->journalid} = $lite_journalu;
             $apu{$entry_obj->journalid} = $entry_obj->journal;
+
             if (!$apu_lite{$posterid} || !$apu{$posterid}) {
                 $apu_lite{$posterid} = UserLite($entry_obj->poster);
                 $apu{$posterid} = $entry_obj->poster; 
@@ -222,7 +225,7 @@
         my $nc = "";
         $nc .= "nc=$replycount" if $replycount && $remote && $remote->{'opt_nctalklinks'};
 
-        my $permalink = $entry_obj->permalink_url;
+        my $permalink = $removed ? '' : $entry_obj->permalink_url;
         my $readurl   = $entry_obj->comments_url;
         my $posturl   = $entry_obj->reply_url;
 
@@ -236,8 +239,8 @@
             'screened' => ($logprops{$itemid}->{'hasscreened'} && $remote &&
                            ($remote->{'user'} eq $u->{'user'} || $remote->can_manage($u))) ? 1 : 0,
         });
-        $comments->{show_postlink} = $entry_obj->posting_comments_allowed;
-        $comments->{show_readlink} = $entry_obj->comments_shown && ($replycount || $comments->{'screened'});
+        $comments->{show_postlink} = $removed ? 0 : $entry_obj->posting_comments_allowed;
+        $comments->{show_readlink} = $removed ? 0 : ($entry_obj->comments_shown && ($replycount || $comments->{'screened'}));
 
         my $userlite_poster = $userlite_journal;
         $pu = $u;

Modified: trunk/cgi-bin/LJ/S2/FriendsPage.pm
===================================================================
--- trunk/cgi-bin/LJ/S2/FriendsPage.pm	2012-06-14 08:45:57 UTC (rev 22233)
+++ trunk/cgi-bin/LJ/S2/FriendsPage.pm	2012-06-14 09:16:39 UTC (rev 22234)
@@ -266,6 +266,7 @@
         my $ditemid = $itemid * 256 + $item->{'anum'};
         my $entry_obj = LJ::Entry->new($friends{$friendid}, ditemid => $ditemid);
         my $repost_entry_obj;
+        my $removed;
         
         my $content =  { 'original_post_obj' => \$entry_obj,
                          'repost_obj'        => \$repost_entry_obj,
@@ -277,9 +278,11 @@
                          'allowmask'         => \$allowmask,
                          'event_raw'         => \$text,
                          'subject'           => \$subject,
+                         'removed'           => \$removed,
                          'reply_count'       => \$replycount, };
 
         if (LJ::Entry::Repost->substitute_content( $entry_obj, $content )) {
+            next ENTRY if $removed;
             next ENTRY unless $entry_obj->visible_to($remote);
 
             $friend   = $entry_obj->journal;
@@ -428,6 +431,7 @@
             'screened'    => ($logprops{$datakey}->{'hasscreened'} && $remote &&
                                ($remote->{'user'} eq $fr->{'user'} || $remote->can_manage($fr))) ? 1 : 0,
         });
+
         $comments->{show_postlink} = $eobj->posting_comments_allowed;
         $comments->{show_readlink} = $eobj->comments_shown && ($replycount || $comments->{'screened'});
 

Modified: trunk/cgi-bin/LJ/S2/MonthPage.pm
===================================================================
--- trunk/cgi-bin/LJ/S2/MonthPage.pm	2012-06-14 08:45:57 UTC (rev 22233)
+++ trunk/cgi-bin/LJ/S2/MonthPage.pm	2012-06-14 09:16:39 UTC (rev 22234)
@@ -28,7 +28,6 @@
     my $user = $u->{'user'};
     my $journalbase = LJ::journal_base($user, $opts->{'vhost'});
 
-
     my ($year, $month);
     if ($opts->{'pathextra'} =~ m!^/(\d\d\d\d)/(\d\d)\b!) {
         ($year, $month) = ($1, $2);
@@ -114,6 +113,7 @@
         $entry_obj->handle_prefetched_props($logprops{$itemid}); 
 
         my $repost_entry_obj;
+        my $removed;
         my $lite_journalu = $userlite_journal;
 
         my $content =  { 'original_post_obj' => \$entry_obj,
@@ -125,9 +125,11 @@
                          'security'          => \$security,
                          'allowmask'         => \$allowmask,
                          'subject_repost'    => \$subject,
+                         'removed'           => \$removed,
                          'reply_count'       => \$replycount, };
 
         if (LJ::Entry::Repost->substitute_content( $entry_obj, $content )) {
+            next ENTRY if $removed; 
             next ENTRY unless $entry_obj->visible_to($remote);
 
             $pu{$posterid} = $entry_obj->poster;

Modified: trunk/cgi-bin/LJ/S2/RecentPage.pm
===================================================================
--- trunk/cgi-bin/LJ/S2/RecentPage.pm	2012-06-14 08:45:57 UTC (rev 22233)
+++ trunk/cgi-bin/LJ/S2/RecentPage.pm	2012-06-14 09:16:39 UTC (rev 22234)
@@ -162,7 +162,8 @@
         my $ditemid   = $itemid * 256 + $item->{'anum'};
         my $entry_obj = LJ::Entry->new($u, ditemid => $ditemid);
        
-        my $repost_entry_obj; 
+        my $repost_entry_obj;
+        my $removed; 
 
         next ENTRY unless $entry_obj->visible_to($remote, { 'viewall'  => $viewall, 
                                                             'viewsome' => $viewsome});
@@ -183,9 +184,11 @@
                          'event_raw'         => \$text,
                          'subject'           => \$subject,
                          'reply_count'       => \$replycount,
+                         'removed'           => \$removed,
                          'userlite'          => \$lite_journalu, };
 
-        if (LJ::Entry::Repost->substitute_content( $entry_obj, $content )) {        
+        if (LJ::Entry::Repost->substitute_content( $entry_obj, $content )) {
+            next ENTRY if $removed && !LJ::u_equals($u, $remote);
             next ENTRY unless $entry_obj->visible_to($remote, { 'viewall'  => $viewall,
                                                                 'viewsome' => $viewsome});
 
@@ -266,7 +269,7 @@
             $text .= LJ::S2::get_tags_text($opts->{ctx}, \@taglist);
         }
 
-        my $permalink = $entry_obj->permalink_url;
+        my $permalink = $removed ? '' : $entry_obj->permalink_url;
         my $readurl   = $entry_obj->comments_url;
         my $posturl   = $entry_obj->reply_url;
 
@@ -283,6 +286,9 @@
             'show_readlink' => $entry_obj->comments_shown && ($replycount || $has_screened),
             'show_postlink' => $entry_obj->posting_comments_allowed,
         });
+    
+        $comments->{show_postlink} = $removed ? 0 : $comments->{show_postlink};
+        $comments->{show_readlink} = $removed ? 0 : $comments->{show_readlink};
 
         my $userlite_poster = $lite_journalu;
         my $pu = $journalu;

Modified: trunk/cgi-bin/LJ/S2.pm
===================================================================
--- trunk/cgi-bin/LJ/S2.pm	2012-06-14 08:45:57 UTC (rev 22233)
+++ trunk/cgi-bin/LJ/S2.pm	2012-06-14 09:16:39 UTC (rev 22234)
@@ -4004,14 +4004,29 @@
     if ($this->{'real_itemid'}) {
         if ($key eq 'delete_repost') {
             return $null_link unless $remote;
-            return $null_link unless LJ::u_equals($remote, $real_user);
 
-            my $link = LJ::S2::Link($entry->url,
-                            $ctx->[S2::PROPS]->{"text_delete_repost"},
-                            LJ::S2::Image("$LJ::IMGPREFIX/btn_delete_repost.gif", 24, 24));
-            $link->{'_raw'} = LJ::Entry::Repost->render_delete_js( $entry->url );
-            return $link;
+            unless (LJ::u_equals($remote, $real_user)) {
+                my $link = $entry->prop('repost_link');
+                my ($journalid, $jitemid) = split(/:/, $link);
+            
+                my $reposted_entry = LJ::Entry->new(int($journalid), 
+                                                    jitemid => int($jitemid));
+
+                my $link = LJ::S2::Link($reposted_entry->url,
+                                $ctx->[S2::PROPS]->{"text_delete_repost"},
+                                LJ::S2::Image("$LJ::IMGPREFIX/btn_delete_repost.gif", 24, 24));
+
+                $link->{'_raw'} = LJ::Entry::Repost->render_delete_js( $reposted_entry->url );
+                return $link;
+            } else {
+                my $link = LJ::S2::Link($entry->url,
+                                $ctx->[S2::PROPS]->{"text_delete_repost"},
+                                LJ::S2::Image("$LJ::IMGPREFIX/btn_delete_repost.gif", 24, 24));
+                $link->{'_raw'} = LJ::Entry::Repost->render_delete_js( $entry->url );
+                return $link;
+            }
         }
+        return $null_link unless LJ::u_equals($remote, $real_user);
     }
 
     if ($key eq "edit_entry") {

Modified: trunk/cgi-bin/ljviews.pl
===================================================================
--- trunk/cgi-bin/ljviews.pl	2012-06-14 08:45:57 UTC (rev 22233)
+++ trunk/cgi-bin/ljviews.pl	2012-06-14 09:16:39 UTC (rev 22234)
@@ -1290,6 +1290,8 @@
 
         my $username = $user;
         my $repost_entry_obj;
+        my $removed;
+
         my $content =  { 'original_post_obj' => \$entry_obj,
                          'repost_obj'        => \$repost_entry_obj,
                          'ditemid'           => \$ditemid,
@@ -1298,10 +1300,14 @@
                          'security'          => \$security,
                          'event_raw'         => \$event,
                          'subject'           => \$subject,
+                         'removed'           => \$removed,
                          'reply_count'       => \$replycount };
 
         if (LJ::Entry::Repost->substitute_content( $entry_obj, $content )) {
-            next ENTRY unless $entry_obj->visible_to($remote, {'viewall' => $viewall, 'viewsome' => $viewsome});
+            next ENTRY if $removed && !LJ::u_equals($user, $remote);
+            next ENTRY unless $entry_obj->visible_to($remote, {'viewall'  => $viewall, 
+                                                               'viewsome' => $viewsome});
+
             $username = $entry_obj->poster->username;
             $posteru{$posterid} = $entry_obj->poster;
             $logprops{$itemid} = $entry_obj->props;
@@ -2734,6 +2740,7 @@
         my $event = $logtext->{$itemid}->[1];
 
         my $repost_entry_obj;
+        my $removed;
         my $content =  { 'original_post_obj' => \$entry_obj,
                          'repost_obj'        => \$repost_entry_obj,
                          'ditemid'           => \$ditemid,
@@ -2742,9 +2749,11 @@
                          'security'          => \$security,
                          'event_raw'         => \$event,
                          'subject'           => \$subject,
+                         'removed'           => \$removed,
                          'reply_count'       => \$replycount };
 
-        if (LJ::Entry::Repost->substitute_content( $entry_obj, $content )) {
+        if (LJ::Entry::Repost->substitute_conten( $entry_obj, $content )) {
+            next ENTRY if $removed;
             $username = $entry_obj->poster->user;
             $logprops{$itemid} = $entry_obj->props;
         }

Tags: livejournal, madeon, pl, pm, sbelyaev
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