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.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • 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