Henry Lyne (henrylyne) wrote in changelog,
Henry Lyne
henrylyne
changelog

[livejournal] r15612: Don't allow duplicate submissions to dir...

Committer: henrylyne
Don't allow duplicate submissions to directory moderation.
Provide full URL for navigation links.

U   trunk/cgi-bin/LJ/Browse.pm
Modified: trunk/cgi-bin/LJ/Browse.pm
===================================================================
--- trunk/cgi-bin/LJ/Browse.pm	2009-08-18 18:48:17 UTC (rev 15611)
+++ trunk/cgi-bin/LJ/Browse.pm	2009-08-18 19:05:30 UTC (rev 15612)
@@ -313,7 +313,7 @@
     return @cats;
 }
 
-# TODO Not yet tested
+# Top level categories to appear in navigation
 sub load_for_nav {
     my $class = shift;
 
@@ -334,7 +334,7 @@
         push @$LJ::CACHED_CATEGORIES_FOR_NAV, {
             id => $c->catid,
             pretty_name => $c->display_name,
-            url => $c->url_path,
+            url => $c->url,
         };
     }
 
@@ -924,6 +924,8 @@
     my $cat = LJ::Browse->load_by_url("/browse" . $caturl) if (defined $caturl);
     die "invalid category" unless $cat;
 
+    return if ($class->_is_community_in_pending($c->userid, $cat->catid));
+
     my $dbh = LJ::get_db_writer()
         or die "unable to contact global db master to create category";
 
@@ -1117,5 +1119,26 @@
     return $class->get_communities(@_, @status);
 }
 
+# is a community already in a category in the moderation table
+sub _is_community_in_pending {
+    my $class = shift;
+    my ($jid, $catid) = @_;
 
+    die "missing argument" unless ($jid && $catid);
+
+    my $dbh = LJ::get_db_writer()
+        or die "unable to contact global db master to create category";
+
+    my $sth = $dbh->prepare("SELECT pendid FROM categoryjournals_pending " .
+                    "WHERE status IN ('P','A') AND jid=? AND catid=?");
+    $sth->execute($jid, $catid);
+    die $dbh->errstr if $dbh->err;
+
+    while (my $row = $sth->fetchrow_hashref) {
+        return 1 if $row;
+    }
+
+    return 0;
+}
+
 1;

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