[livejournal] r18344: LJSUP-7871. Add function for manually fo...

Committer: gprochaev
LJSUP-7871. Add function for manually forcing a community owner poll

U   trunk/cgi-bin/LJ/Poll.pm
Modified: trunk/cgi-bin/LJ/Poll.pm
===================================================================
--- trunk/cgi-bin/LJ/Poll.pm	2011-02-17 10:28:10 UTC (rev 18343)
+++ trunk/cgi-bin/LJ/Poll.pm	2011-02-17 11:45:11 UTC (rev 18344)
@@ -824,6 +824,13 @@
         $winner =~ s/<lj user='(.*?)'>/$1/;
         $winner = LJ::load_user($winner);
         if ($winner && $winner->can_manage($is_super) && $winner->is_visible) {
+            ## Poll can be created by console command, and community may have supermaintainer already.
+            ## Clean all existing SM first.
+            my $s_maints = LJ::load_rel_user($is_super, 'S');
+            foreach my $user_id (@$s_maints) {
+                LJ::clear_rel($is_super, $user_id, 'S');
+            }
+
             LJ::set_rel($is_super, $winner->{userid}, 'S');
             $self->close_poll;