sunnyman's (sunnyman) wrote in changelog,
sunnyman's
sunnyman
changelog

[ljcom] r12427: LJSUP-12403: Console commands with comme...

Committer: vtroitsky
LJSUP-12403: Console commands with commercial promo.Refactoring.
U   trunk/cgi-bin/LJ/Console/Command/SelfPromo.pm
Modified: trunk/cgi-bin/LJ/Console/Command/SelfPromo.pm
===================================================================
--- trunk/cgi-bin/LJ/Console/Command/SelfPromo.pm	2012-08-06 15:23:33 UTC (rev 12426)
+++ trunk/cgi-bin/LJ/Console/Command/SelfPromo.pm	2012-08-06 16:11:51 UTC (rev 12427)
@@ -186,11 +186,10 @@
                     }
                 }
             }
-            # TODO: Set ban scope!
-            $u->set_prop( 'selfpromo_banned' => 1 );
-            LJ::statushistory_add( $u, $admin, 'selfpromo', 'admin banned user. Reason: '. $reason );
 
-            $self->info( $u->display_name . " banned successfully from $promo_class promo" . ($promo_class eq 'all' ? 's' : '') . '.' );
+            $object->ban_for_promos($reason, $admin, @promo_classes);
+
+            $self->info( $object->name . " banned successfully from $promo_class promo" . ($promo_class eq 'all' ? 's' : '') . '.' );
             return 1;
         }
 
@@ -211,34 +210,18 @@
                     }
                 }
             }
-            # TODO: Set ban scope!
-            $entry->set_prop( 'selfpromo_banned' => 1 );
-            LJ::statushistory_add( $entry->journal, $admin, 'selfpromo', 'admin banned entry: '. $entry->url .'. Reason: '. $reason );
 
-            $self->info( $entry->url . " banned successfully from $promo_class promo" . ($promo_class eq 'all' ? 's' : '') . '.' );
+            $object->ban_for_promos($reason, $admin, @promo_classes);
+
+            $self->info( $object->name . " banned successfully from $promo_class promo" . ($promo_class eq 'all' ? 's' : '') . '.' );
             return 1;
         }
-
         return 1;
     }
 
     if ( $cmd eq 'unban' ) {
-        if ( $object->type ne PROMO_OBJECT_TYPE_ENTRY() ) {
-            my $user = $object->object;
-            # TODO: Clean ban scope only!
-            $user->clear_prop('selfpromo_banned');
-            LJ::statushistory_add( $user, $admin, 'selfpromo', 'admin unbanned user. Reason: '. $reason );
-            $self->info( $user->display_name . " unbanned successfully from $promo_class promo" . ($promo_class eq 'all' ? 's' : '') . '.' );
-            return 1;
-        } else {  # entry
-            my $entry = $object->object;
-            # TODO: Clean ban scope only!
-            $entry->set_prop( 'selfpromo_banned' => undef );
-            LJ::statushistory_add( $object->journal, $admin, 'selfpromo', 'admin unbanned entry: '. $object->url .'. Reason: '. $reason );
-            $self->info( $object->url . " unbanned successfully from $promo_class promo" . ($promo_class eq 'all' ? 's' : '') . '.' );
-            return 1;
-        }
-
+        $object->unban_for_promos($reason, $admin, @promo_classes);
+        $self->info( $object->name . " unbanned successfully from $promo_class promo" . ($promo_class eq 'all' ? 's' : '') . '.' );
         return 1;
     }
 }

Tags: ljcom, pm, sunnyman, vtroitsky
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