madeon (madeon) wrote in changelog,
madeon
madeon
changelog

[livejournal] r20372: LJSUP-10093: Member of moderated communi...

Committer: sbelyaev
LJSUP-10093: Member of moderated community with access to post without moderation can't create delayed post
U   trunk/cgi-bin/LJ/DelayedEntry.pm
Modified: trunk/cgi-bin/LJ/DelayedEntry.pm
===================================================================
--- trunk/cgi-bin/LJ/DelayedEntry.pm	2011-10-18 14:25:32 UTC (rev 20371)
+++ trunk/cgi-bin/LJ/DelayedEntry.pm	2011-10-18 22:06:01 UTC (rev 20372)
@@ -76,6 +76,10 @@
     $journal->do("INSERT INTO delayedblob2 ".
                 "VALUES ($journalid, $delayedid, $data_ser)");
 
+    my $memcache_key = "delayed_entry::$journalid::$delayedid";
+    my $timelife = $rposttime - $rlogtime;
+    LJ::MemCache::set($memcache_key, $data_ser, $timelife);
+
     $self->{journal} = $opts->{journal};    
     $self->{posttime} = $opts->{posttime};
     $self->{posttime} = $dbh->selectrow_array("SELECT NOW()");
@@ -1210,7 +1214,33 @@
     }
     return { 'delete_entry' => (!$fail || $err < 500), 
              'res' => $res };
+}
 
+sub can_post_to {
+    my ($uowner, $poster) = @_;
+    
+    #if (__delayed_entry_can_see($uowner, $poster)) {
+    #    return 1;
+    #}
+    
+    my $uownerid = $uowner->userid;
+    my $posterid = $poster->userid;
+
+    my $can_manage = $poster->can_manage($uowner) || 0;
+    my $moderated = $uowner->prop('moderated');
+    my $need_moderated = ( $moderated =~ /^[1A]$/ ) ? 1 : 0;
+    my $can_post = ($uowner->{'journaltype'} eq 'C' && !$need_moderated) || $can_manage;
+   
+    if ($can_post) {
+        return 1;
+    }
+
+    # don't moderate admins, moderators & pre-approved users
+    my $dbh = LJ::get_db_writer();
+    my $relcount = $dbh->selectrow_array("SELECT COUNT(*) FROM reluser ".
+                                         "WHERE userid=$uownerid AND targetid=$posterid ".
+                                         "AND type IN ('A','M','N')");
+    return $relcount ? 1 : 0;
 }
 
 sub __delayed_entry_can_see {

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