madeon (madeon) wrote in changelog,
madeon
madeon
changelog

[livejournal] r21340: LJSUP-10102: User don't receive notifica...

Committer: sbelyaev
LJSUP-10102: User don't receive notification when user is removed from community
U   trunk/cgi-bin/LJ/DelayedEntry/Scheduler.pm
U   trunk/htdocs/community/members.bml
Modified: trunk/cgi-bin/LJ/DelayedEntry/Scheduler.pm
===================================================================
--- trunk/cgi-bin/LJ/DelayedEntry/Scheduler.pm	2012-03-11 12:22:55 UTC (rev 21339)
+++ trunk/cgi-bin/LJ/DelayedEntry/Scheduler.pm	2012-03-11 14:22:44 UTC (rev 21340)
@@ -87,7 +87,45 @@
     });
 }
 
+sub __notify_user {
+    my ($poster, $journal) = @_;
+    my $email = $poster->email_raw;
 
+    my $lang = $poster->prop('browselang') || $LJ::DEFAULT_LANG;
+    my $html = LJ::Lang::get_text($lang, 'community.members.delayed.remove.email_html', undef, {
+                         sitenameshort   => $LJ::SITENAMESHORT,
+                         user            => $poster->user,
+                         usercname       => $journal->user,
+                         sitename        => $LJ::SITENAME,
+                         siteroot        => $LJ::SITEROOT,
+                    });
+
+    my $plain = LJ::Lang::get_text($lang, 'community.members.delayed.remove.email_plain', undef, {
+                         sitenameshort   => $LJ::SITENAMESHORT,
+                         user            => $poster->user,
+                         usercname       => $journal->user,
+                         sitename        => $LJ::SITENAME,
+                         siteroot        => $LJ::SITEROOT,
+                    });
+
+    my $text = $poster->{opt_htmlemail} eq 'Y' ? $html : $plain;
+
+    my $subject = LJ::Lang::get_text($lang, 'community.members.delayed.remove.email_subject', undef,
+                    { mailusercname => $journal->user }
+                    );
+
+    LJ::send_mail({
+        'to'        => $email,
+        'from'      => $LJ::ADMIN_EMAIL,
+        'fromname'  => $LJ::SITENAME,
+        'charset'   => 'utf-8',
+        'subject'   => $subject,
+        'body'      => $text,
+        { subject => $subject },
+    });
+}
+
+
 sub on_pulse {
     my ($clusterid, $dbh, $verbose) = @_;
     __assert($dbh);
@@ -101,6 +139,22 @@
     eval {
         while ( my $entries = __load_delayed_entries($dbh) ) {
             foreach my $entry (@$entries) {
+                if (!LJ::DelayedEntry::can_post_to($entry->journal,
+                                                   $entry->poster)) {
+                    
+                    if ($verbose) {
+                        print "The entry with subject " . $entry->subject;
+                        print "\ndelayed id = " . $entry->delayedid . 
+                        print " and post date " . $entry->posttime;
+                        print " is deleted becouse USER CANNOT POST\n";
+                    }
+
+                    __notify_user(  $entry->poster,
+                                    $entry->journal);
+                    $entry->delete();
+                    next;
+                }
+
                 my $post_status = $entry->convert();
 
                 # do we need to send error
@@ -121,7 +175,6 @@
                 }
 
                 if ( $post_status->{delete_entry} ) {
-
                     if ($verbose) {
                         print "The entry with subject " . $entry->subject;
                         print "\ndelayed id = " . $entry->delayedid . 

Modified: trunk/htdocs/community/members.bml
===================================================================
--- trunk/htdocs/community/members.bml	2012-03-11 12:22:55 UTC (rev 21339)
+++ trunk/htdocs/community/members.bml	2012-03-11 14:22:44 UTC (rev 21340)
@@ -414,51 +414,6 @@
             $sendmail->($delmaintu, $html, $plain, $subject);
         }
 
-        # get all the users who were removed
-        my $changedusers = LJ::load_userids(keys %{$delete{'post'}});
-        # delete members
-        if (%{$delete{'post'}}) {
-            # TAG:FR:bml_comm_members:del_members
-            for my $uid (keys %{$delete{'post'}}) {
-                my $delu = $changedusers->{$uid};
-
-                next unless $delu;
-                next unless LJ::DelayedEntry::entries_exists($c, $delu);
-                next if  LJ::DelayedEntry::can_post_to($c, $delu);
-
-                my $mailusername = $delu->{user};
-                my $mailusercname = $c->{name};
-                my $mailclink = LJ::journal_base($c, ['community']);
-            
-                my $lang = $delu->prop('browselang') || $LJ::DEFAULT_LANG;
-                my $html = LJ::Lang::get_text($lang, 'community.members.delayed.remove.email_html', undef, {
-                                     sitenameshort   => $LJ::SITENAMESHORT,
-                                     user            => $mailusername,
-                                     usercname       => $mailusercname,
-                                     mailclink       => "href='$mailclink'",
-                                     remote          => $remote->{user},
-                                     sitename        => $LJ::SITENAME,
-                                     siteroot        => $LJ::SITEROOT,
-                                });
-
-                my $plain = LJ::Lang::get_text($lang, 'community.members.delayed.remove.email_plain', undef, {
-                                    sitenameshort   => $LJ::SITENAMESHORT,
-                                    user            => $mailusername,
-                                    usercname       => $mailusercname,
-                                    mailclink       => $mailclink,
-                                    remote          => $remote->{user},
-                                    sitename        => $LJ::SITENAME,
-                                    siteroot        => $LJ::SITEROOT,
-                                });
-
-                my $subject = LJ::Lang::get_text($lang, 'community.members.delayed.remove.email_subject', undef,
-                                { mailusercname => $mailusercname }
-                                );
-
-                $sendmail->($delu, $html, $plain, $subject); 
-            } 
-        }
-
         # delete other rel edges
         LJ::clear_rel_multi(
                             (map { [$cid, $_, 'A'] } keys %{$delete{admin}      || {}}),

Tags: bml, 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