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

[livejournal] r17869: LJSUP-7526. incorrect removing community...

Committer: gprochaev
LJSUP-7526. incorrect removing community from category

U   trunk/cgi-bin/LJ/Browse.pm
U   trunk/htdocs/admin/browse/remove_community.bml
Modified: trunk/cgi-bin/LJ/Browse.pm
===================================================================
--- trunk/cgi-bin/LJ/Browse.pm	2010-12-07 05:46:51 UTC (rev 17868)
+++ trunk/cgi-bin/LJ/Browse.pm	2010-12-07 07:49:30 UTC (rev 17869)
@@ -1044,13 +1044,14 @@
         or die "unable to contact global db master to create category";
 
     foreach my $uid (@uids) {
-        $dbh->do("DELETE FROM categoryjournals WHERE catid=? AND journalid IN (?)", undef,
-                 $self->catid, @uids);
+        $dbh->do("DELETE FROM categoryjournals WHERE catid = ? AND journalid = ?", undef,
+                 $self->catid, $uid);
         die $dbh->errstr if $dbh->err;
 
         LJ::Browse->remove_community( comm  => LJ::want_user($uid),
                                       mod_u => LJ::get_remote(),
-                                      catid => $self->catid, );
+                                      catid => $self->catid,
+                                    );
     }
 
     $self->clear_journals_memcache;

Modified: trunk/htdocs/admin/browse/remove_community.bml
===================================================================
--- trunk/htdocs/admin/browse/remove_community.bml	2010-12-07 05:46:51 UTC (rev 17868)
+++ trunk/htdocs/admin/browse/remove_community.bml	2010-12-07 07:49:30 UTC (rev 17869)
@@ -100,43 +100,46 @@
     my @caturls = map { { text => $_->{pretty_name}, value => $_->url_path } } @categories;
     @caturls = sort { $a cmp $b } @caturls;
 
-    $ret .= "<p>Remove from Category:<br />";
-    $ret .= LJ::html_select({
-                name => 'caturl',
-                selected => $caturl },
-                { text => 'Select Category',
-                value => '' },
-                @caturls
-            );
-    $ret .= "</p>\n";
+    if ($vertical) {
 
+        $ret .= "<p>Remove from Category:<br />";
+        $ret .= LJ::html_select({
+                    name => 'caturl',
+                    selected => $caturl },
+                    { text => 'Select Category',
+                    value => '' },
+                    @caturls
+                );
+        $ret .= "\n";
+        $ret .= LJ::html_submit('select', 'Select Category') . "</p>";
+    }
+
     # Selected a category OR tried a remove and got an error
-    if ( LJ::did_post() && ($POST{'select'} || ($POST{'remove'} && @errors)) ) {
+    if ( LJ::did_post() && $POST{'select'} ) {
         # Has a valid category been chosen
         my $category = LJ::Browse->load_by_url("/browse" . $caturl, $vertical);
         push @errors, "Invalid category" unless $category;
 
-        my @comms = $category->communities;
-        if (@comms) {
-            $ret .= "<p>the following journals:<br />";
-        } else {
-            $ret .= "<p>No communities in category.</p>\n";
+        if ($category) {
+            my @comms = $category->communities;
+            if (@comms) {
+                $ret .= "<p>the following journals:<br />";
+            } else {
+                $ret .= "<p>No communities in category.</p>\n";
+            }
+            foreach my $c (@comms) {
+                my $name = 'journal-' . $c->userid;
+                $ret .= LJ::html_check( {
+                            name => $name,
+                            value => $c->user,
+                            selected => $POST{$name} ? 1 : 0,
+                        } );
+                $ret .= " <lable for='$name'>" . $c->user . "</label><br />";
+            }
+            $ret .= "</p>\n";
+
+            $ret .= "<br/>" . LJ::html_submit('remove', 'Remove Communities');
         }
-        foreach my $c (@comms) {
-            my $name = 'journal-' . $c->userid;
-            $ret .= LJ::html_check( {
-                        name => $name,
-                        value => $c->user,
-                        selected => $POST{$name} ? 1 : 0,
-                    } );
-            $ret .= " <lable for='$name'>" . $c->user . "</label><br />";
-        }
-        $ret .= "</p>\n";
-
-        $ret .= "<p>" . LJ::html_submit('remove', 'Remove Communities') . " " .
-                LJ::html_submit('select', 'Select Category') . "</p>";
-    } else {
-        $ret .= "<p>" . LJ::html_submit('select', 'Select Category') . "</p>";
     }
 
     $ret .= "</form>";

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