Changeset 14070

Show
Ignore:
Timestamp:
07/23/08 23:30:03 (5 years ago)
Author:
janine
Message:

LJSUP-2512

Allow individual entries to be suspended/unsuspended without suspending/unsuspending an entire account.
* The entry poster can still view the entry, and can edit it to request an unsuspension.

Location:
trunk
Files:
27 modified

Legend:

Unmodified
Added
Removed
  • trunk/bin/upgrading/en.dat

    r14025 r14070  
    4646 
    4747btn.search=Search 
     48 
     49cleanhtml.suspend_msg=This is a suspended entry. 
     50 
     51cleanhtml.suspend_msg_with_supportid=This is a suspended entry. <a [[aopts]]>An unsuspension request</a> has been opened, and your entry will be reviewed soon. 
    4852 
    4953contentflag.viewingconcepts=You are about to view content that may not be appropriate for minors. 
     
    14821486entryform.save=Save Entry 
    14831487 
     1488entryform.saveandrequestunsuspend=Save Entry & Request Unsuspension 
     1489 
    14841490entryform.security=Security: 
    14851491 
     
    21732179talk.error.suspended.title=Suspended 
    21742180 
     2181talk.error.suspendedentry=This entry is suspended. You can visit the journal <a [[aopts]]>here</a>. 
     2182 
     2183talk.error.suspendedentryreply=This entry is suspended. You cannot reply to it. You can visit the journal <a [[aopts]]>here</a>. 
     2184 
    21752185talk.frozen=Replies frozen 
    21762186 
  • trunk/bin/upgrading/proplists.dat

    r13958 r14070  
    13021302  sortorder: 99 
    13031303 
     1304logproplist.statusvis: 
     1305  datatype: char 
     1306  des: 'V' or undef for visible, 'S' for suspended 
     1307  prettyname: Visibility Status of an Entry 
     1308  sortorder: 99 
     1309 
    13041310logproplist.syn_id: 
    13051311  datatype: char 
     
    13261332  sortorder: 99 
    13271333 
     1334logproplist.unsuspend_supportid: 
     1335  datatype: num 
     1336  des: The support request ID of the unsuspension request submitted by a user whose entry was suspended. Undef or 0 if no request is currently open. 
     1337  prettyname: Support Request ID for Unsuspension Request 
     1338  sortorder: 99 
     1339 
    13281340logproplist.used_rte: 
    13291341  datatype: bool 
  • trunk/cgi-bin/Apache/LiveJournal.pm

    r13819 r14070  
    13871387 
    13881388        $generate_iejunk = 1; 
     1389 
     1390    } elsif ($opts->{'suspendedentry'}) { 
     1391        $status = "403 Entry suspended"; 
     1392        $html = "<h1>Suspended Entry</h1>" . 
     1393                "<p>The entry at this URL is suspended.  You cannot reply to it.</p>"; 
     1394 
     1395        $generate_iejunk = 1; 
    13891396    } 
    13901397 
  • trunk/cgi-bin/LJ/Comment.pm

    r13866 r14070  
    903903    return 0 if $u->underage; 
    904904    return 0 unless $u->get_cap("edit_comments"); 
     905 
     906    # entry cannot be suspended 
     907    return 0 if $self->entry->is_suspended; 
    905908 
    906909    # user must be the poster of the comment 
  • trunk/cgi-bin/LJ/Console/Command/Suspend.pm

    r13095 r14070  
    77sub cmd { "suspend" } 
    88 
    9 sub desc { "Suspend an account." } 
     9sub desc { "Suspend an account or entry." } 
    1010 
    1111sub args_desc { [ 
    12                  'username or email address' => "The username of the account to suspend, or an email address to suspend all accounts at that address.", 
    13                  'reason' => "Why you're suspending the account.", 
     12                 'username or email address or entry url' => "The username of the account to suspend, or an email address to suspend all accounts at that address, or an entry URL to suspend a single entry within an account", 
     13                 'reason' => "Why you're suspending the account or entry.", 
    1414                 ] } 
    1515 
    16 sub usage { '<username or email address> <reason>' } 
     16sub usage { '<username or email address or entry url> <reason>' } 
    1717 
    1818sub can_execute { 
     
    2626    return $self->error("This command takes two arguments. Consult the reference.") 
    2727        unless $user && $reason && scalar(@args) == 0; 
     28 
     29    my $remote = LJ::get_remote(); 
     30    my $entry = LJ::Entry->new_from_url($user); 
     31    if ($entry) { 
     32        my $poster = $entry->poster; 
     33        my $journal = $entry->journal; 
     34 
     35        return $self->error("Invalid entry.") 
     36            unless $entry->valid; 
     37 
     38        return $self->error("Journal and/or poster is purged; cannot suspend entry.") 
     39            if $poster->is_expunged || $journal->is_expunged; 
     40 
     41        return $self->error("Entry is already suspended.") 
     42            if $entry->is_suspended; 
     43 
     44        $entry->set_prop( statusvis => "S" ); 
     45 
     46        $reason = "entry: " . $entry->url . "; reason: $reason"; 
     47        LJ::statushistory_add($journal, $remote, "suspend", $reason); 
     48        LJ::statushistory_add($poster, $remote, "suspend", $reason) 
     49            unless $journal->equals($poster); 
     50 
     51        return $self->print("Entry " . $entry->url . " suspended."); 
     52    } 
    2853 
    2954    my @users; 
     
    76101        $u->{statusvis} = 'S'; 
    77102 
    78         my $remote = LJ::get_remote(); 
    79103        LJ::statushistory_add($u, $remote, "suspend", $reason); 
    80104 
     
    89113        } 
    90114 
    91         $self->info("User '$username' suspended."); 
     115        $self->print("User '$username' suspended."); 
    92116    } 
    93117 
  • trunk/cgi-bin/LJ/Console/Command/Unsuspend.pm

    r12444 r14070  
    77sub cmd { "unsuspend" } 
    88 
    9 sub desc { "Unsuspend an account." } 
     9sub desc { "Unsuspend an account or entry." } 
    1010 
    1111sub args_desc { [ 
    12                  'username or email address' => "The username of the account to unsuspend, or an email address to unsuspend all accounts at that address.", 
    13                  'reason' => "Why you're unsuspending the account.", 
     12                 'username or email address or entry url' => "The username of the account to unsuspend, or an email address to unsuspend all accounts at that address, or an entry URL to unsuspend a single entry within an account", 
     13                 'reason' => "Why you're unsuspending the account or entry", 
    1414                 ] } 
    1515 
    16 sub usage { '<username or email address> <reason>' } 
     16sub usage { '<username or email address or entry url> <reason>' } 
    1717 
    1818sub can_execute { 
     
    2626    return $self->error("This command takes two arguments. Consult the reference.") 
    2727        unless $user && $reason && scalar(@args) == 0; 
     28 
     29    my $remote = LJ::get_remote(); 
     30    my $entry = LJ::Entry->new_from_url($user); 
     31    if ($entry) { 
     32        my $poster = $entry->poster; 
     33        my $journal = $entry->journal; 
     34 
     35        return $self->error("Invalid entry.") 
     36            unless $entry->valid; 
     37 
     38        return $self->error("Journal and/or poster is purged; cannot unsuspend entry.") 
     39            if $poster->is_expunged || $journal->is_expunged; 
     40 
     41        return $self->error("Entry is not currently suspended.") 
     42            if $entry->is_visible; 
     43 
     44        $entry->set_prop( statusvis => "V" ); 
     45        $entry->set_prop( unsuspend_supportid => 0 ) 
     46            if $entry->prop("unsuspend_supportid"); 
     47 
     48        $reason = "entry: " . $entry->url . "; reason: $reason"; 
     49        LJ::statushistory_add($journal, $remote, "unsuspend", $reason); 
     50        LJ::statushistory_add($poster, $remote, "unsuspend", $reason) 
     51            unless $journal->equals($poster); 
     52 
     53        return $self->print("Entry " . $entry->url . " unsuspended."); 
     54    } 
    2855 
    2956    my @users; 
     
    7299        $u->{statusvis} = 'V'; 
    73100 
    74         my $remote = LJ::get_remote(); 
    75101        LJ::statushistory_add($u, $remote, "unsuspend", $reason); 
    76102        eval { $u->fb_push }; 
    77103        warn "Error running fb_push: $@\n" if $@ && $LJ::IS_DEV_SERVER; 
    78104 
    79         $self->info("User '$username' unsuspended."); 
     105        $self->print("User '$username' unsuspended."); 
    80106    } 
    81107 
  • trunk/cgi-bin/LJ/Entry.pm

    r13952 r14070  
    769769    } 
    770770 
     771    my $remote = LJ::get_remote(); 
     772    my $suspend_msg = $self->should_show_suspend_msg_to($remote) ? 1 : 0; 
     773    $opts->{suspend_msg} = $suspend_msg; 
     774    $opts->{unsuspend_supportid} = $suspend_msg ? $self->prop("unsuspend_supportid") : 0; 
     775 
    771776    $self->_load_text unless $self->{_loaded_text}; 
    772777    my $event = $self->{event}; 
     
    843848        # can't see anything by suspended users 
    844849        return 0 if $self->poster->{statusvis} eq 'S'; 
     850 
     851        # can't see suspended entries 
     852        return 0 if $self->is_suspended_for($remote); 
    845853    } 
    846854 
     
    11621170 
    11631171    return ""; 
     1172} 
     1173 
     1174sub statusvis { 
     1175    my $self = shift; 
     1176 
     1177    return $self->prop("statusvis") eq "S" ? "S" : "V"; 
     1178} 
     1179 
     1180sub is_visible { 
     1181    my $self = shift; 
     1182 
     1183    return $self->statusvis eq "V" ? 1 : 0; 
     1184} 
     1185 
     1186sub is_suspended { 
     1187    my $self = shift; 
     1188 
     1189    return $self->statusvis eq "S" ? 1 : 0; 
     1190} 
     1191 
     1192# same as is_suspended, except that it returns 0 if the given user can see the suspended entry 
     1193sub is_suspended_for { 
     1194    my $self = shift; 
     1195    my $u = shift; 
     1196 
     1197    return 0 unless $self->is_suspended; 
     1198    return 0 if LJ::check_priv($u, 'canview', 'suspended'); 
     1199    return 0 if LJ::isu($u) && $u->equals($self->poster); 
     1200    return 1; 
     1201} 
     1202 
     1203sub should_show_suspend_msg_to { 
     1204    my $self = shift; 
     1205    my $u = shift; 
     1206 
     1207    return $self->is_suspended && !$self->is_suspended_for($u) ? 1 : 0; 
    11641208} 
    11651209 
  • trunk/cgi-bin/LJ/S2/DayPage.pm

    r13993 r14070  
    116116            map { $item->{$_} } qw(posterid itemid security allowmask alldatepart anum); 
    117117 
     118        my $ditemid = $itemid*256 + $anum; 
     119        my $entry_obj = LJ::Entry->new($u, ditemid => $ditemid); 
     120 
    118121        my $replycount = $logprops{$itemid}->{'replycount'}; 
    119122        my $subject = $logtext->{$itemid}->[0]; 
     
    125128        } 
    126129 
    127         # don't show posts from suspended users 
     130        # don't show posts from suspended users or suspended posts 
    128131        next ENTRY if $apu{$posterid} && $apu{$posterid}->{'statusvis'} eq 'S' && ! $viewsome; 
     132        next ENTRY if $entry_obj && $entry_obj->is_suspended_for($remote); 
    129133 
    130134        if ($LJ::UNICODE && $logprops{$itemid}->{'unknown8bit'}) { 
     
    134138        LJ::CleanHTML::clean_subject(\$subject) if $subject; 
    135139 
    136         my $ditemid = $itemid*256 + $anum; 
    137  
     140        my $suspend_msg = $entry_obj && $entry_obj->should_show_suspend_msg_to($remote) ? 1 : 0; 
    138141        LJ::CleanHTML::clean_event(\$text, { 'preformatted' => $logprops{$itemid}->{'opt_preformatted'}, 
    139142                                             'cuturl' => LJ::item_link($u, $itemid, $anum), 
    140                                              'ljcut_disable' => $remote->{'opt_ljcut_disable_lastn'}, }); 
     143                                             'ljcut_disable' => $remote->{'opt_ljcut_disable_lastn'}, 
     144                                             'suspend_msg' => $suspend_msg, 
     145                                             'unsuspend_supportid' => $suspend_msg ? $entry_obj->prop("unsuspend_supportid") : 0, }); 
    141146        LJ::expand_embedded($u, $ditemid, $remote, \$text); 
    142147 
    143         my $entry_obj = LJ::Entry->new($u, ditemid => $ditemid); 
    144148        $text = LJ::ContentFlag->transform_post(post => $text, journal => $u, 
    145149                                                remote => $remote, entry => $entry_obj); 
  • trunk/cgi-bin/LJ/S2/EntryPage.pm

    r13799 r14070  
    2929    my ($entry, $s2entry) = EntryPage_entry($u, $remote, $opts); 
    3030    return if $opts->{'suspendeduser'}; 
     31    return if $opts->{'suspendedentry'}; 
    3132    return if $opts->{'handler_return'}; 
    3233    return if $opts->{'redir'}; 
     
    414415    } 
    415416 
     417    if ($entry && $entry->is_suspended_for($remote)) { 
     418        $opts->{'suspendedentry'} = 1; 
     419        return; 
     420    } 
     421 
    416422    my $replycount = $entry->prop("replycount"); 
    417423    my $nc = ""; 
  • trunk/cgi-bin/LJ/S2/FriendsPage.pm

    r13546 r14070  
    210210 
    211211        my $ditemid = $itemid * 256 + $item->{'anum'}; 
     212        my $entry_obj = LJ::Entry->new($friends{$friendid}, ditemid => $ditemid); 
    212213 
    213214        my $stylemine = ""; 
     
    215216                                      $remote->{'userid'} != $friendid; 
    216217 
     218        my $suspend_msg = $entry_obj && $entry_obj->should_show_suspend_msg_to($remote) ? 1 : 0; 
    217219        LJ::CleanHTML::clean_event(\$text, { 'preformatted' => $logprops{$datakey}->{'opt_preformatted'}, 
    218220                                             'cuturl' => LJ::item_link($friends{$friendid}, $itemid, $item->{'anum'}, $stylemine), 
    219221                                             'maximgwidth' => $maximgwidth, 
    220222                                             'maximgheight' => $maximgheight, 
    221                                              'ljcut_disable' => $remote->{'opt_ljcut_disable_friends'}, }); 
     223                                             'ljcut_disable' => $remote->{'opt_ljcut_disable_friends'}, 
     224                                             'suspend_msg' => $suspend_msg, 
     225                                             'unsuspend_supportid' => $suspend_msg ? $entry_obj->prop("unsuspend_supportid") : 0, }); 
    222226        LJ::expand_embedded($friends{$friendid}, $ditemid, $remote, \$text); 
    223227 
    224         my $entry_obj = LJ::Entry->new($friends{$friendid}, ditemid => $ditemid); 
    225228        $text = LJ::ContentFlag->transform_post(post => $text, journal => $friends{$friendid}, 
    226229                                                remote => $remote, entry => $entry_obj); 
     
    232235        my $po = $posters{$posterid} || $friends{$posterid}; 
    233236 
    234         # don't allow posts from suspended users 
    235         if ($po->{'statusvis'} eq 'S') { 
     237        # don't allow posts from suspended users or suspended posts 
     238        if ($po->{'statusvis'} eq 'S' || ($entry_obj && $entry_obj->is_suspended_for($remote))) { 
    236239            $hiddenentries++; # Remember how many we've skipped for later 
    237240            next ENTRY; 
  • trunk/cgi-bin/LJ/S2/MonthPage.pm

    r13614 r14070  
    105105        my $day = $item->{'day'}; 
    106106 
    107         # don't show posts from suspended users 
     107        my $ditemid = $itemid*256 + $anum; 
     108        my $entry_obj = LJ::Entry->new($u, ditemid => $ditemid); 
     109 
     110        # don't show posts from suspended users or suspended posts 
    108111        next unless $pu{$posterid}; 
    109112        next ENTRY if $pu{$posterid}->{'statusvis'} eq 'S' && !$viewsome; 
     113        next ENTRY if $entry_obj && $entry_obj->is_suspended_for($remote); 
    110114 
    111115        if ($LJ::UNICODE && $logprops{$itemid}->{'unknown8bit'}) { 
     
    120124        } 
    121125 
    122         my $ditemid = $itemid*256 + $anum; 
    123126        my $nc = ""; 
    124127        $nc .= "nc=$replycount" if $replycount && $remote && $remote->{'opt_nctalklinks'}; 
  • trunk/cgi-bin/LJ/S2/RecentPage.pm

    r13546 r14070  
    137137            map { $item->{$_} } qw(posterid itemid security allowmask alldatepart); 
    138138 
     139        my $ditemid = $itemid * 256 + $item->{'anum'}; 
     140        my $entry_obj = LJ::Entry->new($u, ditemid => $ditemid); 
     141 
    139142        my $replycount = $logprops{$itemid}->{'replycount'}; 
    140143        my $subject = $logtext->{$itemid}->[0]; 
     
    148151        $itemnum++; 
    149152 
    150         # don't show posts from suspended users unless the user doing the viewing says to (and is allowed) 
     153        # don't show posts from suspended users or suspended posts unless the user doing the viewing says to (and is allowed) 
    151154        next ENTRY if $apu{$posterid} && $apu{$posterid}->{'statusvis'} eq 'S' && !$viewsome; 
     155        next ENTRY if $entry_obj && $entry_obj->is_suspended_for($remote); 
    152156 
    153157        if ($LJ::UNICODE && $logprops{$itemid}->{'unknown8bit'}) { 
     
    165169        LJ::CleanHTML::clean_subject(\$subject) if $subject; 
    166170 
    167         my $ditemid = $itemid * 256 + $item->{'anum'}; 
     171        my $suspend_msg = $entry_obj && $entry_obj->should_show_suspend_msg_to($remote) ? 1 : 0; 
    168172        LJ::CleanHTML::clean_event(\$text, { 'preformatted' => $logprops{$itemid}->{'opt_preformatted'}, 
    169173                                              'cuturl' => LJ::item_link($u, $itemid, $item->{'anum'}), 
    170                                               'ljcut_disable' => $remote->{"opt_ljcut_disable_lastn"}, }); 
     174                                              'ljcut_disable' => $remote->{"opt_ljcut_disable_lastn"}, 
     175                                              'suspend_msg' => $suspend_msg, 
     176                                              'unsuspend_supportid' => $suspend_msg ? $entry_obj->prop("unsuspend_supportid") : 0, }); 
    171177        LJ::expand_embedded($u, $ditemid, $remote, \$text); 
    172178 
    173         my $entry_obj = LJ::Entry->new($u, ditemid => $ditemid); 
    174179        $text = LJ::ContentFlag->transform_post(post => $text, journal => $u, 
    175180                                                remote => $remote, entry => $entry_obj); 
  • trunk/cgi-bin/LJ/S2/ReplyPage.pm

    r13142 r14070  
    2121    my ($entry, $s2entry) = EntryPage_entry($u, $remote, $opts); 
    2222    return if $opts->{'suspendeduser'}; 
     23 
     24    # reply page of suspended entry cannot be accessed by anyone, even entry poster 
     25    if ($entry && $entry->is_suspended) { 
     26        $opts->{suspendedentry} = 1; 
     27        return; 
     28    } 
     29 
    2330    return if $opts->{'handler_return'}; 
    2431    return if $opts->{'redir'}; 
     
    111118            $opts->{status} = "403 Forbidden"; 
    112119            return "<p>This thread has been frozen; no more replies are allowed.</p>"; 
     120        } 
     121        if ($entry->is_suspended) { 
     122            $opts->{status} = "403 Forbidden"; 
     123            return "<p>This entry has been suspended; you cannot reply to it.</p>"; 
    113124        } 
    114125 
  • trunk/cgi-bin/LJ/User.pm

    r14041 r14070  
    79357935        return $error->("Journal has been deleted.  If you are <b>$user</b>, you have a period of 30 days to decide to undelete your journal.", "404 Not Found") if ($u->is_deleted); 
    79367936        return $error->("This journal has been suspended.", "403 Forbidden") if ($u->is_suspended); 
     7937 
     7938        my $entry = $opts->{ljentry}; 
     7939        return $error->("This entry has been suspended. You can visit the journal <a href='" . $u->journal_base . "/'>here</a>.", "403 Forbidden") 
     7940            if $entry && $entry->is_suspended_for($remote); 
    79377941    } 
    79387942    return $error->("This journal has been deleted and purged.", "410 Gone") if ($u->is_expunged); 
  • trunk/cgi-bin/LJ/Vertical.pm

    r13685 r14070  
    104104    return 0 unless $entry->security eq "public"; 
    105105 
    106     # poster and journal must be visible 
     106    # poster, journal, and entry must be visible 
    107107    return 0 unless $poster->is_visible; 
    108108    return 0 unless $journal->is_visible; 
     109    return 0 unless $entry->is_visible; 
    109110 
    110111    my $hook_rv = LJ::run_hook("entry_should_be_in_verticals", $entry); 
  • trunk/cgi-bin/cleanhtml.pl

    r13722 r14070  
    135135        (exists $opts->{'blocked_link_substitute'}) ? $opts->{'blocked_link_substitute'} : 
    136136        ($LJ::BLOCKED_LINK_SUBSTITUTE) ? $LJ::BLOCKED_LINK_SUBSTITUTE : '#'; 
    137          
     137    my $suspend_msg = $opts->{'suspend_msg'} || 0; 
     138    my $unsuspend_supportid = $opts->{'unsuspend_supportid'} || 0; 
     139 
    138140    my @canonical_urls; # extracted links 
    139141    my %action = (); 
     
    10121014    $$data = $newdata; 
    10131015    $$data .= $extra_text if $extra_text; # invalid markup error 
     1016 
     1017    if ($suspend_msg) { 
     1018        my $msg = qq{<div style="color: #000; font: 12px Verdana, Arial, Sans-Serif; background-color: #ffeeee; background-repeat: repeat-x; border: 1px solid #ff9999; padding: 8px; margin: 5px auto; width: auto; text-align: left; background-image: url('$LJ::IMGPREFIX/message-error.gif');">}; 
     1019 
     1020        if ($unsuspend_supportid) { 
     1021            $msg .= LJ::Lang::ml('cleanhtml.suspend_msg_with_supportid', { aopts => "href='$LJ::SITEROOT/support/see_request.bml?id=$unsuspend_supportid'" }); 
     1022        } else { 
     1023            $msg .= LJ::Lang::ml('cleanhtml.suspend_msg', { aopts => "href='$LJ::SITEROOT/abuse/report.bml'" }); 
     1024        } 
     1025 
     1026        $msg .= "</div>"; 
     1027 
     1028        $$data = $msg . $$data; 
     1029    } 
    10141030 
    10151031    return 0; 
     
    12581274    my $wordlength = defined $opts->{'wordlength'} ? $opts->{'wordlength'} : 40; 
    12591275 
    1260     # fast path:  no markup or URLs to linkify 
    1261     if ($$ref !~ /\<|\>|http/ && ! $opts->{preformatted}) { 
     1276    # fast path:  no markup or URLs to linkify, and no suspend message needed 
     1277    if ($$ref !~ /\<|\>|http/ && ! $opts->{preformatted} && !$opts->{suspend_msg}) { 
    12621278        $$ref =~ s/\S{$wordlength,}/break_word($&,$wordlength)/eg if $wordlength; 
    12631279        $$ref =~ s/\r?\n/<br \/>/g; 
     
    12901306        'transform_embed_nocheck' => $opts->{'transform_embed_nocheck'} ? 1 : 0, 
    12911307        'transform_embed_wmode' => $opts->{'transform_embed_wmode'}, 
     1308        'suspend_msg' => $opts->{'suspend_msg'} ? 1 : 0, 
     1309        'unsuspend_supportid' => $opts->{'unsuspend_supportid'}, 
    12921310    }); 
    12931311} 
  • trunk/cgi-bin/ljfeed.pl

    r14037 r14070  
    172172        my $itemid  = $it->{'itemid'}; 
    173173        my $ditemid = $itemid*256 + $it->{'anum'}; 
     174        my $entry_obj = LJ::Entry->new($u, ditemid => $ditemid); 
    174175 
    175176        next ENTRY if $posteru{$it->{'posterid'}} && $posteru{$it->{'posterid'}}->{'statusvis'} eq 'S'; 
     177        next ENTRY if $entry_obj && $entry_obj->is_suspended_for($remote); 
    176178 
    177179        if ($LJ::UNICODE && $logprops{$itemid}->{'unknown8bit'}) { 
     
    262264        }; 
    263265        push @cleanitems, $cleanitem; 
    264         push @entries,    LJ::Entry->new($u, ditemid => $ditemid); 
     266        push @entries,    $entry_obj; 
    265267    } 
    266268 
  • trunk/cgi-bin/ljviews.pl

    r13849 r14070  
    12621262            map { $item->{$_} } qw(posterid itemid security alldatepart); 
    12631263 
     1264        my $ditemid = $itemid * 256 + $item->{'anum'}; 
     1265        my $entry_obj = LJ::Entry->new($u, ditemid => $ditemid); 
     1266 
    12641267        my $pu = $posteru{$posterid}; 
    12651268        next ENTRY if $pu && $pu->{'statusvis'} eq 'S' && !$viewsome; 
     1269        next ENTRY if $entry_obj && $entry_obj->is_suspended_for($remote); 
    12661270 
    12671271        my $replycount = $logprops{$itemid}->{'replycount'}; 
     
    13111315        } 
    13121316 
    1313         my $ditemid = $itemid * 256 + $item->{'anum'}; 
    13141317        my $itemargs = "journal=$user&amp;itemid=$ditemid"; 
    13151318        $lastn_event{'itemargs'} = $itemargs; 
    13161319 
     1320        my $suspend_msg = $entry_obj && $entry_obj->should_show_suspend_msg_to($remote) ? 1 : 0; 
    13171321        LJ::CleanHTML::clean_event(\$event, { 'preformatted' => $logprops{$itemid}->{'opt_preformatted'}, 
    13181322                                               'cuturl' => LJ::item_link($u, $itemid, $item->{'anum'}), 
    1319                                                'ljcut_disable' => $remote->{'opt_ljcut_disable_lastn'}, }); 
     1323                                               'ljcut_disable' => $remote->{'opt_ljcut_disable_lastn'}, 
     1324                                               'suspend_msg' => $suspend_msg, 
     1325                                               'unsuspend_supportid' => $suspend_msg ? $entry_obj->prop("unsuspend_supportid") : 0, }); 
    13201326        LJ::expand_embedded($u, $ditemid, $remote, \$event); 
    13211327 
    1322         my $entry_obj = LJ::Entry->new($u, ditemid => $ditemid); 
    13231328        $event = LJ::ContentFlag->transform_post(post => $event, journal => $u, 
    13241329                                                 remote => $remote, entry => $entry_obj); 
     
    17231728            map { $item->{$_} } qw(ownerid posterid itemid security alldatepart); 
    17241729 
     1730        my $ditemid = $itemid * 256 + $item->{'anum'}; 
     1731        my $entry_obj = LJ::Entry->new($friends{$friendid}, ditemid => $ditemid); 
     1732 
    17251733        my $pu = $friends{$posterid} || $aposter{$posterid}; 
    17261734        next ENTRY if $pu && $pu->{'statusvis'} eq 'S'; 
     1735        next ENTRY if $entry_obj && $entry_obj->is_suspended_for($remote); 
    17271736 
    17281737        # counting excludes skipped entries 
     
    17811790        } 
    17821791 
    1783         my $ditemid = $itemid * 256 + $item->{'anum'}; 
    17841792        my $itemargs = "journal=$friend&amp;itemid=$ditemid"; 
    17851793        $friends_event{'itemargs'} = $itemargs; 
     
    17891797                                      $remote->{'userid'} != $friendid; 
    17901798 
     1799        my $suspend_msg = $entry_obj && $entry_obj->should_show_suspend_msg_to($remote) ? 1 : 0; 
    17911800        LJ::CleanHTML::clean_event(\$event, { 'preformatted' => $logprops{$datakey}->{'opt_preformatted'}, 
    17921801                                              'cuturl' => LJ::item_link($friends{$friendid}, $itemid, $item->{'anum'}, $stylemine), 
    17931802                                              'maximgwidth' => $maximgwidth, 
    17941803                                              'maximgheight' => $maximgheight, 
    1795                                               'ljcut_disable' => $remote->{'opt_ljcut_disable_friends'}, }); 
     1804                                              'ljcut_disable' => $remote->{'opt_ljcut_disable_friends'}, 
     1805                                              'suspend_msg' => $suspend_msg, 
     1806                                              'unsuspend_supportid' => $suspend_msg ? $entry_obj->prop("unsuspend_supportid") : 0, }); 
    17961807        LJ::expand_embedded($friends{$friendid}, $ditemid, $remote, \$event); 
    17971808 
    1798         my $entry_obj = LJ::Entry->new($friends{$friendid}, ditemid => $ditemid); 
    17991809        $event = LJ::ContentFlag->transform_post(post => $event, journal => $friends{$friendid}, 
    18001810                                                 remote => $remote, entry => $entry_obj); 
     
    24692479            map { $item->{$_} } qw(itemid posterid security alldatepart anum); 
    24702480 
     2481        my $ditemid = $itemid*256 + $anum; 
     2482        my $entry_obj = LJ::Entry->new($u, ditemid => $ditemid); 
     2483 
    24712484        next ENTRY if $posteru{$posterid} && $posteru{$posterid}->{'statusvis'} eq 'S' && !$viewsome; 
     2485        next ENTRY if $entry_obj && $entry_obj->is_suspended_for($remote); 
    24722486 
    24732487        my $replycount = $logprops{$itemid}->{'replycount'}; 
     
    24972511        } 
    24982512 
    2499         my $ditemid = $itemid*256 + $anum; 
    25002513        my $itemargs = "journal=$user&amp;itemid=$ditemid"; 
    25012514        $day_event{'itemargs'} = $itemargs; 
    25022515 
     2516        my $suspend_msg = $entry_obj && $entry_obj->should_show_suspend_msg_to($remote) ? 1 : 0; 
    25032517        LJ::CleanHTML::clean_event(\$event, { 'preformatted' => $logprops{$itemid}->{'opt_preformatted'}, 
    25042518                                              'cuturl' => LJ::item_link($u, $itemid, $anum), 
    2505                                               'ljcut_disable' => $remote->{'opt_ljcut_disable_lastn'}, }); 
     2519                                              'ljcut_disable' => $remote->{'opt_ljcut_disable_lastn'}, 
     2520                                              'suspend_msg' => $suspend_msg, 
     2521                                              'unsuspend_supportid' => $suspend_msg ? $entry_obj->prop("unsuspend_supportid") : 0, }); 
    25062522        LJ::expand_embedded($u, $ditemid, $remote, \$event); 
    25072523 
    2508         my $entry_obj = LJ::Entry->new($u, ditemid => $ditemid); 
    25092524        $event = LJ::ContentFlag->transform_post(post => $event, journal => $u, 
    25102525                                                 remote => $remote, entry => $entry_obj); 
  • trunk/cgi-bin/supportlib.pl

    r13671 r14070  
    534534 
    535535    $dbh->do("LOCK TABLES support WRITE, duplock WRITE"); 
    536     $sth = $dbh->prepare("SELECT dupid FROM duplock WHERE realm='support' AND reid=0 AND userid=$qrequserid AND digest='$md5'"); 
    537     $sth->execute; 
    538     ($dup_id) = $sth->fetchrow_array; 
    539     if ($dup_id) { 
    540         $dbh->do("UNLOCK TABLES"); 
    541         return $dup_id; 
     536 
     537    unless ($o->{ignore_dup_check}) { 
     538        $sth = $dbh->prepare("SELECT dupid FROM duplock WHERE realm='support' AND reid=0 AND userid=$qrequserid AND digest='$md5'"); 
     539        $sth->execute; 
     540        ($dup_id) = $sth->fetchrow_array; 
     541        if ($dup_id) { 
     542            $dbh->do("UNLOCK TABLES"); 
     543            return $dup_id; 
     544        } 
    542545    } 
    543546 
     
    556559    $spid = $dbh->{'mysql_insertid'}; 
    557560 
    558     $dbh->do("INSERT INTO duplock (realm, reid, userid, digest, dupid, instime) VALUES ('support', 0, $qrequserid, '$md5', $spid, NOW())"); 
     561    $dbh->do("INSERT INTO duplock (realm, reid, userid, digest, dupid, instime) VALUES ('support', 0, $qrequserid, '$md5', $spid, NOW())") 
     562        unless $o->{ignore_dup_check}; 
    559563    $dbh->do("UNLOCK TABLES"); 
    560564 
  • trunk/cgi-bin/weblib.pl

    r14040 r14070  
    16411641                                    { 'onclick' => $onclick, 'disabled' => $opts->{'disabled_save'}, 
    16421642                                      'tabindex' => $tabindex->() }) . "&nbsp;\n"; 
     1643 
     1644            if ($opts->{suspended} && !$opts->{unsuspend_supportid}) { 
     1645                $out .= LJ::html_submit('action:saveunsuspend', BML::ml('entryform.saveandrequestunsuspend'), 
     1646                                        { 'onclick' => $onclick, 'disabled' => $opts->{'disabled_save'}, 
     1647                                          'tabindex' => $tabindex->() }) . "&nbsp;\n"; 
     1648            } 
     1649 
    16431650            $out .= LJ::html_submit('action:delete', BML::ml('entryform.delete'), { 
    16441651                'disabled' => $opts->{'disabled_delete'}, 
  • trunk/htdocs/editjournal.bml

    r14038 r14070  
    133133            my $anum = $ditemid % 256; 
    134134            my $itemid = $ditemid >> 8; 
     135            my $entry_obj = LJ::Entry->new($u, ditemid => $ditemid); 
    135136 
    136137            # do getevents request 
     
    182183 
    183184            # they clicked the save or delete button 
    184             if (!$spellcheck_html && ($POST{'action:save'} || $POST{'action:delete'} || $POST{'action:deletespam'})) { 
     185            if (!$spellcheck_html && ($POST{'action:save'} || $POST{'action:saveunsuspend'} || $POST{'action:delete'} || $POST{'action:deletespam'})) { 
    185186                return LJ::bad_input($ML{'error.invalidform'}) unless LJ::check_form_auth(); 
    186187 
     
    233234                } else { 
    234235                    $result .= "<?p $ML{'.success.edited'} p?>"; 
     236 
     237                    # open a request about the unsuspension if one doesn't already exist 
     238                    if ($POST{'action:saveunsuspend'} && !$entry_obj->prop("unsuspend_supportid") && $LJ::UNSUSPENSION_REQUEST_SPCATID) { 
     239                        my %req; 
     240                        $req{reqtype} = "user"; 
     241                        $req{requserid} = $remote->id; 
     242                        $req{uniq} = LJ::UniqCookie->current_uniq; 
     243                        $req{spcatid} = $LJ::UNSUSPENSION_REQUEST_SPCATID; 
     244                        $req{ignore_dup_check} = 1; # can't have dup checking in case a particular entry gets re-suspended after unsuspension 
     245                        $req{subject} = "Unsuspension Request from " . $remote->user; 
     246                        $req{body} = "The suspended entry at " . $entry_obj->url . " has been edited and the poster requests unsuspension."; 
     247 
     248                        my @errors; 
     249                        my $spid = LJ::Support::file_request(\@errors, \%req); 
     250 
     251                        if ($spid) { 
     252                            $entry_obj->set_prop( unsuspend_supportid => $spid ); 
     253                            my $url = "$LJ::SITEROOT/support/see_request.bml?id=$spid"; 
     254                            $result .= "<?p " . BML::ml('.success.editedunsuspend', { url => "<a href='$url'>$url</a>" }) . " p?>"; 
     255                        } 
     256                    } 
    235257                } 
    236258 
     
    297319            $event = LJ::eurl($event); 
    298320 
     321            my $suspend_msg = $entry_obj && $entry_obj->should_show_suspend_msg_to($remote) ? 1 : 0; 
    299322            my $entry = { 
    300323                'mode' => "edit", 
     
    314337                'disabled_delete' => $disabled_delete, 
    315338                'disabled_spamdelete' => $disabled_spamdelete, 
     339                'suspended' => $suspend_msg, 
     340                'unsuspend_supportid' => $suspend_msg ? $entry_obj->prop("unsuspend_supportid") : 0, 
    316341            }; 
    317342            for (my $i = 1; $i <= $res{'prop_count'}; $i++) { 
  • trunk/htdocs/editjournal.bml.text

    r13999 r14070  
    2020.success.edited=Journal entry was edited. 
    2121 
     22.success.editedunsuspend=Additionally, an unsuspension request has been opened at [[url]], and your entry will be reviewed soon. 
     23 
    2224.success.fromhere=From here you can: 
    2325 
  • trunk/htdocs/talkpost.bml

    r13621 r14070  
    152152    } 
    153153 
    154     # check suspended 
     154    # check suspended user 
    155155    return "<?h1 $ML{'talk.error.suspended.title'} h1?><?p $ML{'talk.error.suspended'} p?>" 
    156156        if $u->is_suspended || $up->is_suspended || 
     
    160160    return "<?h1 $ML{'talk.error.deleted.title'} h1?><?p $ML{'talk.error.deleted'} p?>" 
    161161        if ($u->is_deleted); 
     162 
     163    # check suspended entry 
     164    # reply page of suspended entry cannot be accessed by anyone, even entry poster 
     165    return "<?h1 $ML{'talk.error.suspended.title'} h1?><?p " . BML::ml('talk.error.suspendedentryreply', { aopts => "href='" . $u->journal_base . "/'" }) . " p?>" 
     166        if $entry && $entry->is_suspended; 
    162167 
    163168    # checked screened post 
     
    184189    my $preformatted = $FORM{'replyto'} eq "" ? $props->{'opt_preformatted'} : $parpost->{'opt_preformatted'}; 
    185190 
    186     LJ::CleanHTML::clean_event(\$event, $preformatted); 
     191    my $suspend_msg = $entry && $entry->should_show_suspend_msg_to($remote) ? 1 : 0; 
     192    LJ::CleanHTML::clean_event(\$event, { 'preformatted' => $preformatted, 
     193                                          'suspend_msg' => $suspend_msg, 
     194                                          'unsuspend_supportid' => $suspend_msg ? $entry->prop("unsuspend_supportid") : 0, }); 
    187195    LJ::expand_embedded($u, $ditemid, $remote, \$event); 
    188196    BML::ebml(\$event); 
  • trunk/htdocs/talkpost.bml.text

    r12954 r14070  
    1717 
    1818.error.noreply_screened=This comment is screened and you have no permissions to see it or reply to it. 
     19 
     20.error.noreply_suspended=This entry is suspended.  You cannot reply to it. 
    1921 
    2022.label.picturetouse2=<a [[aopts]]>Picture</a> to use: 
  • trunk/htdocs/talkpost_do.bml

    r12974 r14070  
    193193        if $parent->{state} eq 'F'; 
    194194 
     195    # no replying to suspended entries, even by entry poster 
     196    my $entry = LJ::Entry->new($journalu, jitemid => $item->{jitemid}); 
     197    return LJ::bad_input($ML{'/talkpost.bml.error.noreply_suspended'}) 
     198        if $entry && $entry->is_suspended; 
     199 
    195200    ## insertion or editing 
    196201    my $wasscreened = ($parent->{state} eq 'S'); 
  • trunk/htdocs/talkread.bml

    r14032 r14070  
    150150 # check for deleted/suspended/security 
    151151 unless ($viewsome) { 
    152      # check suspended 
     152     # check suspended user 
    153153     return "<?h1 $ML{'talk.error.suspended.title'} h1?><?p $ML{'talk.error.suspended'} p?>" 
    154154         if ($u->is_suspended || $up->is_suspended); 
     
    157157     return "<?h1 $ML{'talk.error.deleted.title'} h1?><?p $ML{'talk.error.deleted'} p?>" 
    158158         if ($u->is_deleted); 
     159 
     160     # check suspended entry 
     161     return "<?h1 $ML{'talk.error.suspended.title'} h1?><?p " . BML::ml('talk.error.suspendedentry', { aopts => "href='" . $u->journal_base . "/'" }) . " p?>" 
     162         if $entry && $entry->is_suspended_for($remote); 
    159163 } 
    160164 
     
    211215 my $event = $item->{'event'}; 
    212216 
    213  LJ::CleanHTML::clean_event(\$event, $props->{'opt_preformatted'}); 
     217 my $suspend_msg = $entry && $entry->should_show_suspend_msg_to($remote) ? 1 : 0; 
     218 LJ::CleanHTML::clean_event(\$event, { 'preformatted' => $props->{'opt_preformatted'}, 
     219                                       'suspend_msg' => $suspend_msg, 
     220                                       'unsuspend_supportid' => $suspend_msg ? $entry->prop("unsuspend_supportid") : 0, }); 
    214221 LJ::expand_embedded($u, $ditemid, $remote, \$event); 
    215222 BML::ebml(\$event); 
  • trunk/htdocs/view/index.bml

    r13621 r14070  
    172172 { 
    173173     my ($itemid, $anum, $day, $eventtime, $posterid, $replycount, $security, $allowmask) = @$it; 
     174 
     175     my $entry = LJ::Entry->new($u, jitemid => $itemid); 
    174176     next if $u{$posterid}->is_suspended && !$viewsome; 
     177     next if $entry && $entry->is_suspended_for($remote); 
    175178 
    176179     my $subject = $lt->{$itemid}->[0];