wisest owl (wisest_owl) wrote in changelog,
wisest owl
wisest_owl
changelog

[livejournal] r17999: LJSUP-7667. Improve Remove Verticals BML...

Committer: gprochaev
LJSUP-7667. Improve Remove Verticals BML page.

U   trunk/htdocs/admin/browse/remove_verticals.bml
Modified: trunk/htdocs/admin/browse/remove_verticals.bml
===================================================================
--- trunk/htdocs/admin/browse/remove_verticals.bml	2010-12-22 11:51:57 UTC (rev 17998)
+++ trunk/htdocs/admin/browse/remove_verticals.bml	2010-12-23 04:35:20 UTC (rev 17999)
@@ -22,6 +22,24 @@
         return "<?h1 $ML{'Error'} h1?><?p $ML{'error.invalidform'} p?>"
             unless LJ::check_form_auth();
 
+        my @keys = keys %POST;
+        foreach (@keys) {
+            next unless $_ =~ /delete_vert_(\d+)/;
+            my $vert = LJ::Vertical->load_by_id ($1);
+            my $vert_name = $vert->name;
+            my $vert_id = $vert->vert_id;
+            my @cats = LJ::Browse->load_all ($vert);
+            foreach my $cat (@cats) {
+                my @comms = $cat->communities ();
+                $cat->remove_communities (@comms) if @comms;
+                $cat->delete;
+            }
+            $vert->delete_and_purge();
+
+            $ret .= "Vertical '".$vert_name."' (#$vert_id) has been deleted.<br/><br/>";
+        }
+
+=head
         if ($POST{'to_delete'}) {
             ## Delete vertical, categories and communities.
             my $vert = LJ::Vertical->load_by_id ($POST{'vert_id'});
@@ -81,6 +99,7 @@
             $ret .= "<p><a href='/admin/browse/'>Back to main page</a></p>";
             return $ret;
         }
+=cut
     }
 
     my @verticals = LJ::Vertical->load_all();
@@ -89,13 +108,14 @@
     $ret .= LJ::form_auth();
 
     $ret .= "<table style='border-collapse:collapse;'>";
-    $ret .= "<tr><th style='border:1px solid #000;padding:5px;'>Vertical name</td><th style='border:1px solid #000;padding:5px;'>Vertical Url</td><th style='border:1px solid #000;padding:5px;'></td></tr>";
+    $ret .= "<tr><th style='border:1px solid #000; padding:5px;'>&nbsp;</th><th style='border:1px solid #000;padding:5px;'>Vertical name</td><th style='border:1px solid #000;padding:5px;'>Vertical Url</th></tr>";
     foreach my $vert (@verticals) {
         my $vert_name = $vert->{name};
         my $vert_url  = $vert->{url};
         my $vert_id   = $vert->{vert_id};
-        $ret .= "<tr><td style='border:1px solid #000;padding:5px;'>$vert_name</td><td style='border:1px solid #000;padding:5px;'>$vert_url</td><td style='border:1px solid #000;padding:5px;'><input type='submit' name='delete_vert_$vert_id' value='Delete'></tr>";
+        $ret .= "<tr><td style='border:1px solid #000; padding:5px;'><input type='checkbox' name='delete_vert_$vert_id' value='1'></td><td style='border:1px solid #000;padding:5px;'>$vert_name</td><td style='border:1px solid #000;padding:5px;'>$vert_url</td></tr>";
     }
+    $ret .= "<tr><td colspan='3'><input type='submit' name='delete' value='Delete'></td></tr>";
     $ret .= "</table>";
 
     $ret .= "</form>";

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