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

[livejournal] r17898: LJSUP-7455. Add ability to add/remove su...

Committer: gprochaev
LJSUP-7455. Add ability to add/remove sub-category, sub-sub-category

U   trunk/bin/upgrading/en.dat
U   trunk/cgi-bin/LJ/Browse.pm
U   trunk/cgi-bin/LJ/Vertical.pm
U   trunk/htdocs/admin/browse/add_category.bml
U   trunk/htdocs/admin/browse/add_community.bml
U   trunk/htdocs/admin/browse/edit_community.bml
U   trunk/htdocs/admin/browse/remove_category.bml
U   trunk/htdocs/admin/browse/remove_community.bml
Modified: trunk/bin/upgrading/en.dat
===================================================================
--- trunk/bin/upgrading/en.dat	2010-12-10 07:32:48 UTC (rev 17897)
+++ trunk/bin/upgrading/en.dat	2010-12-10 08:26:09 UTC (rev 17898)
@@ -4570,6 +4570,8 @@
 vertical.nav.explore.technology|staleness=1
 vertical.nav.explore.technology=Technology
 
+vertical.admin.add_category.btn=Add Category
+
 vgift..anon=
 
 vgift..fromuser=

Modified: trunk/cgi-bin/LJ/Browse.pm
===================================================================
--- trunk/cgi-bin/LJ/Browse.pm	2010-12-10 07:32:48 UTC (rev 17897)
+++ trunk/cgi-bin/LJ/Browse.pm	2010-12-10 08:26:09 UTC (rev 17898)
@@ -127,6 +127,7 @@
     }
 
     $self = $class->new( catid => $catid );
+    $self->clear_memcache;
     return $self;
 }
 
@@ -535,6 +536,7 @@
 
     LJ::MemCache::delete($self->memkey_catid);
     LJ::MemCache::delete($self->memkey_caturi($uri));
+    LJ::MemCache::delete($self->memkey_catall(vertical => $self->vertical ? $self->vertical : undef));
 
     return;
 }
@@ -1079,6 +1081,61 @@
     return 1;
 }
 
+## Return "path" for selected category
+## catobj -> par_catobj -> par_par_catobj -> etc... (array)
+## Param: arrayref to save "path"
+sub get_parent_path {
+    my $c = shift;
+    my $cat_path = shift;
+
+    my $parent = $c->parent;
+
+    push @$cat_path, $c;
+
+    return 0 unless $parent;
+
+    return $parent->get_parent_path ($cat_path);
+}
+
+sub build_select_tree {
+    my ($class, $parent, $cats_ref, $selected_cat, $text, $i, $n) = @_;
+
+    $i ||= 0;
+
+    return $text unless $cats_ref;
+
+    my @categories = @$cats_ref;
+    @categories = grep { ($_->parent == $parent) } grep { $_ } @categories;
+
+    return $text unless scalar @categories;
+
+    my @path_ = ();
+    $selected_cat->get_parent_path (\@path_) if $selected_cat;
+    my %path = map { $_->catid => 1 } @path_;
+    my @sel_cat = grep { $path{$_->catid} } @categories;
+
+    my @caturls = map { { text => $_->{pretty_name}, value => $_->catid } } @categories;
+    @caturls = sort { $a->{text} cmp $b->{text} } @caturls;
+
+    $text .= "<tr><td>Category</td>";
+    $text .= "<td>" . LJ::html_select({
+                name => "catid$i\_$n", style => "width:100%;",
+                selected => $sel_cat[0] ? $sel_cat[0]->catid : '' },
+                { text => LJ::Lang::ml('vertical.admin.add_category.btn'),
+                value => '' },
+                @caturls
+    ) . "</td>";
+    $text .= "<td>" . LJ::html_submit('select_c', 'Select Category') . "</td>";
+    $text .= "</tr>";
+
+    if ($sel_cat[0]) {
+        my @children = $sel_cat[0]->children;
+        $text = $class->build_select_tree($sel_cat[0], \@children, $selected_cat, $text, ++$i, $n);
+    }
+
+    return $text;
+}
+
 # get the typemap for categoryprop
 sub typemap {
     my $self = shift;

Modified: trunk/cgi-bin/LJ/Vertical.pm
===================================================================
--- trunk/cgi-bin/LJ/Vertical.pm	2010-12-10 07:32:48 UTC (rev 17897)
+++ trunk/cgi-bin/LJ/Vertical.pm	2010-12-10 08:26:09 UTC (rev 17898)
@@ -453,7 +453,7 @@
     my $v = $class->new( vert_id => shift );
     $v->preload_rows;
 
-    return $v;
+    return $v->vert_id ? $v : undef;
 }
 
 # returns a vertical object of the vertical with the given name,

Modified: trunk/htdocs/admin/browse/add_category.bml
===================================================================
--- trunk/htdocs/admin/browse/add_category.bml	2010-12-10 07:32:48 UTC (rev 17897)
+++ trunk/htdocs/admin/browse/add_category.bml	2010-12-10 08:26:09 UTC (rev 17898)
@@ -20,15 +20,19 @@
     my $parentcaturl;
     my $newcat;
     my $newcaturl;
-    my $vert_url;
+    my $vert_id;
 
+    my @ids = sort { $b cmp $a } grep { $_ =~ /^catid\d+\_0$/ } keys %POST;
+    my $cat_id = $POST{$ids[0]};
+    my $category = $cat_id ? LJ::Browse->load_by_id ($cat_id) : undef;
+
     if (LJ::did_post() and $POST{'add'}) {
         $parentcaturl = $POST{'parentcaturl'};
         $newcat = $POST{'newcat'};
         $newcaturl = $POST{'newcaturl'};
-        $vert_url = $POST{'vert_url_add'};
+        $vert_id = $POST{'vert_id_add'} + 0;
 
-        my $vertical = LJ::Vertical->load_by_url("/vertical" . $vert_url);
+        my $vertical = LJ::Vertical->load_by_id($vert_id);
 
         push @errors, "Invalid form submission" unless LJ::check_form_auth();
         {
@@ -78,38 +82,39 @@
     $ret .= "<p>";
 
     my $vertical = undef;
-    if (LJ::did_post() && $POST{'select'}) {
-        $vert_url = $POST{'vert_url'};
-        $vertical = LJ::Vertical->load_by_url("/vertical" . $vert_url);
+    if (LJ::did_post()) {
+        $vert_id = $POST{'vert_id'} + 0;
+        $vertical = LJ::Vertical->load_by_id($vert_id);
     }
 
+    $ret .= "<table>";
     my @verticals = LJ::Vertical->load_all();
-    @verticals = map { { text => $_->{name}, value => $_->{url} } } @verticals;
+    if (!$LJ::DISABLED{'verticals_menu'}) {
+        $ret .= "<tr><td valign='top'><!-- -->Vertical</td>";
+        @verticals = map { { text => $_->{name}, value => $_->{vert_id} } } @verticals;
 
-    $ret .= "<p>".LJ::html_select({
-                name => 'vert_url',
-                selected => $vert_url,
-                },
-                { text => 'Community Directory',
-                value => '',},
-                @verticals
-            );
-    $ret .= "&nbsp;\n";
+        $ret .= "<td>".LJ::html_select({
+                    name => "vert_id", style => "",
+                    selected => $vertical ? $vertical->vert_id : 0,
+                    },
+                    { text => 'Community Directory',
+                    value => '',},
+                    @verticals
+                );
+        $ret .= "</td><td>\n";
 
-    $ret .= LJ::html_submit('select', 'Select Vertical') . "</p>";
+        $ret .= LJ::html_submit('select', 'Select Vertical') . "</td></tr>";
+    }
 
+    my @children = $category ? $category->children : ();
     # Get the full list of categories
     my @categories = LJ::Browse->load_all($vertical);
-    my @caturls = map { { text => $_->{pretty_name}, value => $_->url_path } } @categories;
 
-    $ret .= "<p>";
-    $ret .= LJ::html_select({
-                name => 'parentcaturl',
-                selected => $parentcaturl },
-                { text => 'Select Category',
-                value => '' },
-                @caturls
-            );
+    $ret .= LJ::Browse->build_select_tree (0, \@categories, $category, undef, undef, 0);
+    if ($category) {
+        $ret .= "<tr><td colspan='2'>New category will be add in '".$category->display_name."'</td></tr>";
+    }
+    $ret .= "</table>\n";
     $ret .= "</p>\n";
 
     $ret .= "<h2>New Category Details</h2>";
@@ -135,7 +140,8 @@
 
     $ret .= "<p>" . LJ::html_submit('add', 'Add') . "</p>";
 
-    $ret .= LJ::html_hidden("vert_url_add", $vertical ? $vertical->uri : '');
+    $ret .= LJ::html_hidden("vert_id_add", $vertical ? $vertical->vert_id : '');
+    $ret .= LJ::html_hidden("parentcaturl", $category->url_path) if $category;
     $ret .= "</form>";
     $ret .= "<p><a href='/admin/browse/'>Back to main page</a></p>";
 

Modified: trunk/htdocs/admin/browse/add_community.bml
===================================================================
--- trunk/htdocs/admin/browse/add_community.bml	2010-12-10 07:32:48 UTC (rev 17897)
+++ trunk/htdocs/admin/browse/add_community.bml	2010-12-10 08:26:09 UTC (rev 17898)
@@ -18,20 +18,27 @@
     my $ret = "";
 
     my $caturl = $POST{'caturl'};
-    my $vert_url = $POST{'vert_url'};
+    my $vert_id = $POST{'vert_id'};
     my $journal = $POST{'journal'};
     my $tags = $POST{'tags'};
 
+    my @ids = sort { $b cmp $a } grep { $_ =~ /^catid\d+\_0$/ } keys %POST;
+    my $cat_id = $POST{$ids[0]};
+    my $category = $cat_id ? LJ::Browse->load_by_id ($cat_id) : undef;
+
     my $vertical = undef;
-    if (LJ::did_post() && $vert_url) {
-        $vertical = LJ::Vertical->load_by_url ("/vertical" . $vert_url);
+    if (LJ::did_post() && $vert_id) {
+        $vertical = LJ::Vertical->load_by_id ($vert_id);
     }
 
     if (LJ::did_post() and $POST{'add'}) {
+        my @ids = sort { $b cmp $a } grep { $_ =~ /^catid\d+\_0$/ && $POST{$_} } keys %POST;
+        my $cat_id = $POST{$ids[0]};
+
         push @errors, "Invalid form submission" unless LJ::check_form_auth();
         {
             # Check for required data
-            unless ($caturl) {
+            unless ($cat_id) {
                 push @errors, "Please select a category";
                 next;
             }
@@ -41,7 +48,7 @@
             }
 
             # Has a valid category been chosen
-            my $category = LJ::Browse->load_by_url("/browse" . $caturl, $vertical);
+            my $category = LJ::Browse->load_by_id($cat_id);
             push @errors, "Invalid category" unless $category;
 
             # Extract usernames and get userids
@@ -65,53 +72,54 @@
     $ret .= "<form method='POST'>\n";
     $ret .= LJ::form_auth();
 
+    $ret .= "<p>";
+    $ret .= "<table>";
     my @verticals = LJ::Vertical->load_all();
-    @verticals = map { { text => $_->{name}, value => $_->{url} } } @verticals;
+    if (!$LJ::DISABLED{'verticals_menu'}) {
+        $ret .= "<tr><td valign='top'><!-- -->Vertical</td>";
+        @verticals = map { { text => $_->{name}, value => $_->{vert_id} } } @verticals;
 
-    $ret .= "<p>".LJ::html_select({
-                name => 'vert_url',
-                selected => $vert_url,
-                },
-                { text => 'Community Directory',
-                value => '',},
-                @verticals
-            );
-    $ret .= "&nbsp;\n";
+        $ret .= "<td>".LJ::html_select({
+                    name => "vert_id", style => "",
+                    selected => $vertical ? $vertical->vert_id : 0,
+                    },
+                    { text => 'Community Directory',
+                    value => '',},
+                    @verticals
+                );
+        $ret .= "</td><td>\n";
 
-    $ret .= LJ::html_submit('select', 'Select Vertical') . "</p>";
+        $ret .= LJ::html_submit('select', 'Select Vertical') . "</td></tr>";
+    }
 
+    my @children = $category ? $category->children : ();
     # Get the full list of categories
     my @categories = LJ::Browse->load_all($vertical);
-    # Don't include the top level categories and get the unique URI for each
-    @categories = grep { $_->{parentcatid} } @categories unless $vertical;
-    my @caturls = map { { text => $_->{pretty_name}, value => $_->url_path } } @categories;
-    @caturls = sort { $a cmp $b } @caturls;
 
-    $ret .= "<p>Add to Category:<br />";
-    $ret .= LJ::html_select({
-                name => 'caturl',
-                selected => $caturl },
-                { text => 'Select Category',
-                value => '' },
-                @caturls
-            );
+    $ret .= LJ::Browse->build_select_tree (0, \@categories, $category, undef, undef, 0);
+    if ($category) {
+        $ret .= "<tr><td colspan='2'>New community will be add in '".$category->display_name."'</td></tr>";
+    }
+    $ret .= "</table>\n";
     $ret .= "</p>\n";
 
-    $ret .= "<p>the following journal:<br />";
-    $ret .= LJ::html_text( {
-                name => 'journal',
-                size => 40,
-                }
-            );
+    if ($category) {
+        $ret .= "<p>the following journal:<br />";
+        $ret .= LJ::html_text( {
+                    name => 'journal',
+                    size => 40,
+                    }
+                );
 
-    $ret .= "<p>with tags:<br />";
-    $ret .= LJ::html_text( {
-                name => 'tags',
-                size => 60,
-                }
-            );
+        $ret .= "<p>with tags:<br />";
+        $ret .= LJ::html_text( {
+                    name => 'tags',
+                    size => 60,
+                    }
+                );
 
-    $ret .= "<p>" . LJ::html_submit('add', 'Add') . "</p>";
+        $ret .= "<p>" . LJ::html_submit('add', 'Add') . "</p>";
+    }
 
     $ret .= "</form>";
     $ret .= "<p><a href='/admin/browse/'>Back to main page</a></p>";

Modified: trunk/htdocs/admin/browse/edit_community.bml
===================================================================
--- trunk/htdocs/admin/browse/edit_community.bml	2010-12-10 07:32:48 UTC (rev 17897)
+++ trunk/htdocs/admin/browse/edit_community.bml	2010-12-10 08:26:09 UTC (rev 17898)
@@ -9,62 +9,8 @@
 
     return "This page is not available." unless LJ::is_enabled("browse");
 
-    my $ret;
+    my $ret = '';
 
-sub get_parent_path {
-    my $cat_path = shift;
-    my $c = shift;
-
-    return undef unless $c;
-
-    my $parent = $c->parent;
-
-    push @$cat_path, $c;
-
-    return 0 unless $parent;
-
-    return get_parent_path ($cat_path, $c->parent);
-}
-
-sub _build_tree {
-    my ($parent, $cats_ref, $selected_cat, $text, $i, $n) = @_;
-
-    $i ||= 0;
-
-    return $text unless $cats_ref;
-
-    my @categories = @$cats_ref;
-    @categories = grep { ($_->parent == $parent) } grep { $_ } @categories;
-
-    return $text unless scalar @categories;
-
-    my @path_ = ();
-    get_parent_path (\@path_, $selected_cat);
-    my %path = map { $_->catid => 1 } @path_;
-    my @sel_cat = grep { $path{$_->catid} } @categories;
-
-    my @caturls = map { { text => $_->{pretty_name}, value => $_->catid } } @categories;
-    @caturls = sort { $a->{text} cmp $b->{text} } @caturls;
-
-    $text .= "<tr><td>Category</td>";
-    $text .= "<td>" . LJ::html_select({
-                name => "catid$i\_$n", style => "width:100%;",
-                selected => $sel_cat[0] ? $sel_cat[0]->catid : '' },
-                { text => $ML{'.add'},
-                value => '' },
-                @caturls
-    ) . "</td>";
-    $text .= "<td>" . LJ::html_submit('select_c', 'Select Category') . "</td>";
-    $text .= "</tr>";
-
-    if ($sel_cat[0]) {
-        my @children = $sel_cat[0]->children;
-        $text = _build_tree($sel_cat[0], \@children, $selected_cat, $text, ++$i, $n);
-    }
-
-    return $text;
-}
-
     # get remote
     my $remote = LJ::get_remote();
     unless ($remote) {
@@ -134,7 +80,7 @@
         # Get the full list of categories
         my @categories = LJ::Browse->load_all($vert_[$j]);
 
-        $ret .= _build_tree (0, \@categories, $cat_[$j], undef, undef, $i);
+        $ret .= LJ::Browse->build_select_tree (0, \@categories, $cat_[$j], undef, undef, $i);
         if ($cat_[$j]) {
             $ret .= "<tr><td valign='top'>Communities from category:</td><tr><td colspan='3'>";
             if ($cat_[$j]->communities) {

Modified: trunk/htdocs/admin/browse/remove_category.bml
===================================================================
--- trunk/htdocs/admin/browse/remove_category.bml	2010-12-10 07:32:48 UTC (rev 17897)
+++ trunk/htdocs/admin/browse/remove_category.bml	2010-12-10 08:26:09 UTC (rev 17898)
@@ -18,26 +18,31 @@
     my $ret = "";
 
     my $caturl;
-    my $vert_url = $POST{'vert_url'};
+    my $vert_id = $POST{'vert_id'};
 
+    my @ids = sort { $b cmp $a } grep { $_ =~ /^catid\d+\_0$/ } keys %POST;
+    my $cat_id = $POST{$ids[0]};
+    my $category = $cat_id ? LJ::Browse->load_by_id ($cat_id) : undef;
+
     my $vertical = undef;
-    if (LJ::did_post() && $POST{'vert_url'}) {
-        $vertical = LJ::Vertical->load_by_url("/vertical" . $vert_url);
+    if (LJ::did_post() && $POST{'vert_id'}) {
+        $vertical = LJ::Vertical->load_by_id($vert_id);
     }
 
     if (LJ::did_post() and $POST{'remove'}) {
-        $caturl = $POST{'caturl'};
+        my @ids = sort { $b cmp $a } grep { $_ =~ /^catid\d+\_0$/ && $POST{$_} } keys %POST;
+        my $cat_id = $POST{$ids[0]};
 
         push @errors, "Invalid form submission" unless LJ::check_form_auth();
         {
             # Check for required data
-            unless ($caturl) {
+            unless ($cat_id) {
                 push @errors, "Please select a category to remove";
                 next;
             }
 
             # Has a valid category been chosen
-            my $category = LJ::Browse->load_by_url("/browse" . $caturl, $vertical);
+            my $category = LJ::Browse->load_by_id($cat_id);
             push @errors, "Invalid category" unless $category;
 
             my @children = $category->children;
@@ -64,37 +69,37 @@
     my @verticals = LJ::Vertical->load_all();
     @verticals = map { { text => $_->{name}, value => $_->{url} } } @verticals;
 
-    $ret .= "<p>".LJ::html_select({
-                name => 'vert_url',
-                selected => $vert_url,
-                },
-                { text => 'Community Directory',
-                value => '',},
-                @verticals
-            );
-    $ret .= "&nbsp;\n";
+    $ret .= "<p>";
+    $ret .= "<table>";
+    my @verticals = LJ::Vertical->load_all();
+    if (!$LJ::DISABLED{'verticals_menu'}) {
+        $ret .= "<tr><td valign='top'><!-- -->Vertical</td>";
+        @verticals = map { { text => $_->{name}, value => $_->{vert_id} } } @verticals;
 
-    $ret .= LJ::html_submit('selectv', 'Select Vertical') . "</p>";
+        $ret .= "<td>".LJ::html_select({
+                    name => "vert_id", style => "",
+                    selected => $vertical ? $vertical->vert_id : 0,
+                    },
+                    { text => 'Community Directory',
+                    value => '',},
+                    @verticals
+                );
+        $ret .= "</td><td>\n";
 
+        $ret .= LJ::html_submit('select', 'Select Vertical') . "</td></tr>";
+    }
+
+    my @children = $category ? $category->children : ();
     # Get the full list of categories
     my @categories = LJ::Browse->load_all($vertical);
-    # Get the unique URI for each
-    #@categories = grep { $_->parent } @categories unless $vertical;
-    my @caturls = map { { text => $_->{pretty_name}, value => $_->url_path } } @categories;
-    @caturls = sort { $a cmp $b } @caturls;
 
-    $ret .= "<p>Remove Category:<br />";
-    $ret .= LJ::html_select({
-                name => 'caturl',
-                selected => $caturl },
-                { text => 'Select Category',
-                value => '' },
-                @caturls
-            );
+    $ret .= LJ::Browse->build_select_tree (0, \@categories, $category, undef, undef, 0);
+    if ($category) {
+        $ret .= "<tr><td colspan='2'>Selected category: ".$category->display_name."</td></tr>";
+    }
+    $ret .= "</table>\n";
     $ret .= "</p>\n";
 
-    $ret .= "</table></p>\n";
-
     $ret .= "<p>" . LJ::html_submit('remove', 'Remove') . "</p>";
 
     $ret .= "</form>";

Modified: trunk/htdocs/admin/browse/remove_community.bml
===================================================================
--- trunk/htdocs/admin/browse/remove_community.bml	2010-12-10 07:32:48 UTC (rev 17897)
+++ trunk/htdocs/admin/browse/remove_community.bml	2010-12-10 08:26:09 UTC (rev 17898)
@@ -24,19 +24,26 @@
     my $ret = "";
 
     my $caturl = $POST{'caturl'};
-    my $vert_url = $POST{'vert_url'};
+    my $vert_id = $POST{'vert_id'};
     my $journals = $POST{'journals'};
 
+    my @ids = sort { $b cmp $a } grep { $_ =~ /^catid\d+\_0$/ } keys %POST;
+    my $cat_id = $POST{$ids[0]};
+    my $category = $cat_id ? LJ::Browse->load_by_id ($cat_id) : undef;
+
     my $vertical = undef;
-    if (LJ::did_post() && $POST{'vert_url'}) {
-        $vertical = LJ::Vertical->load_by_url("/vertical" . $vert_url);
+    if (LJ::did_post() && $POST{'vert_id'}) {
+        $vertical = LJ::Vertical->load_by_id($vert_id);
     }
 
     if (LJ::did_post() and $POST{'remove'}) {
+        my @ids = sort { $b cmp $a } grep { $_ =~ /^catid\d+\_0$/ && $POST{$_} } keys %POST;
+        my $cat_id = $POST{$ids[0]};
+
         push @errors, "Invalid form submission" unless LJ::check_form_auth();
         {
             # Check for required data
-            unless ($caturl) {
+            unless ($cat_id) {
                 push @errors, "Please select a category";
                 next;
             }
@@ -46,7 +53,7 @@
             }
 
             # Has a valid category been chosen
-            my $category = LJ::Browse->load_by_url("/browse" . $caturl, $vertical);
+            my $category = LJ::Browse->load_by_id($cat_id);
             push @errors, "Invalid category" unless $category;
 
             # Extract usernames and get userids
@@ -78,43 +85,38 @@
     $ret .= "<form method='POST'>\n";
     $ret .= LJ::form_auth();
 
+    $ret .= "<p>";
+    $ret .= "<table>";
     my @verticals = LJ::Vertical->load_all();
-    @verticals = map { { text => $_->{name}, value => $_->{url} } } @verticals;
+    if (!$LJ::DISABLED{'verticals_menu'}) {
+        $ret .= "<tr><td valign='top'><!-- -->Vertical</td>";
+        @verticals = map { { text => $_->{name}, value => $_->{vert_id} } } @verticals;
 
-    $ret .= "<p>".LJ::html_select({
-                name => 'vert_url',
-                selected => $vert_url,
-                },
-                { text => 'Community Directory',
-                value => '',},
-                @verticals
-            );
-    $ret .= "&nbsp;\n";
+        $ret .= "<td>".LJ::html_select({
+                    name => "vert_id", style => "",
+                    selected => $vertical ? $vertical->vert_id : 0,
+                    },
+                    { text => 'Community Directory',
+                    value => '',},
+                    @verticals
+                );
+        $ret .= "</td><td>\n";
 
-    $ret .= LJ::html_submit('selectv', 'Select Vertical') . "</p>";
+        $ret .= LJ::html_submit('select', 'Select Vertical') . "</td></tr>";
+    }
 
+    my @children = $category ? $category->children : ();
     # Get the full list of categories
     my @categories = LJ::Browse->load_all($vertical);
-    # Don't include the top level categories and get the unique URI for each
-    @categories = grep { $_->parent } @categories unless $vertical;
-    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 .= "\n";
-    $ret .= LJ::html_submit('select', 'Select Category') . "</p>";
+    $ret .= LJ::Browse->build_select_tree (0, \@categories, $category, undef, undef, 0);
+    $ret .= "</table>\n";
+    $ret .= "</p>\n";
 
     # Selected a category OR tried a remove and got an error
-    if ( LJ::did_post() && $POST{'select'} ) {
+    if ( LJ::did_post() && $category ) {
         # Has a valid category been chosen
-        my $category = LJ::Browse->load_by_url("/browse" . $caturl, $vertical);
+        my $category = LJ::Browse->load_by_id($cat_id);
         push @errors, "Invalid category" unless $category;
 
         if ($category) {

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