Андрей (andy) wrote in changelog,
Андрей
andy
changelog

[livejournal] r19309: LJSUP-9110 (support tags system cleanup)

Committer: ailyin
LJSUP-9110 (support tags system cleanup)
U   trunk/cgi-bin/LJ/Support/Request/Tag.pm
U   trunk/cgi-bin/supportlib.pl
U   trunk/htdocs/support/manage_tags.bml
Modified: trunk/cgi-bin/LJ/Support/Request/Tag.pm
===================================================================
--- trunk/cgi-bin/LJ/Support/Request/Tag.pm	2011-06-17 01:49:18 UTC (rev 19308)
+++ trunk/cgi-bin/LJ/Support/Request/Tag.pm	2011-06-17 02:13:16 UTC (rev 19309)
@@ -59,7 +59,9 @@
 sub get_requests_tags {
     my @spids = @_;
 
-    @spids = map { $_+0 } @spids;
+    return {} unless @spids;
+
+    @spids = map { int $_ } @spids;
     my $spids = join ',', @spids;
 
     my $dbr = LJ::get_db_reader();
@@ -111,20 +113,30 @@
 
     my $dbh = LJ::get_db_writer();
 
-    @tags_remove = map { $_+0 } @tags_remove;
-    my $tags_remove = join(',', map { $_+0 } @tags_remove);
-    $dbh->do(
-        "DELETE FROM supporttagmap WHERE spid=? AND sptagid IN ($tags_remove)",
-        undef, $spid
-    );
+    if (@tags_remove) {
+        @tags_remove = map { int $_ } @tags_remove;
+        my $tags_remove = join( ',', map { int $_ } @tags_remove );
+        $dbh->do(
+            qq{
+                DELETE FROM supporttagmap
+                WHERE spid=? AND sptagid IN ($tags_remove)
+            },
+            undef, $spid
+        );
+    }
 
-    @tags_add = map { $_+0 } @tags_add;
-    my @tags_add_exprs = map { "($spid,$_)" } @tags_add;
-    my $tags_add_exprs = join ',', @tags_add_exprs;
+    if (@tags_add) {
+        @tags_add = map { int $_ } @tags_add;
+        my @tags_add_exprs = map { "($spid,$_)" } @tags_add;
+        my $tags_add_exprs = join ',', @tags_add_exprs;
 
-    $dbh->do(
-        "INSERT INTO supporttagmap (spid, sptagid) VALUES $tags_add_exprs"
-    );
+        $dbh->do(
+            qq{
+                INSERT INTO supporttagmap (spid, sptagid)
+                VALUES $tags_add_exprs
+            }
+        );
+    }
 
     return { added => \@tags_add, removed => \@tags_remove };
 }

Modified: trunk/cgi-bin/supportlib.pl
===================================================================
--- trunk/cgi-bin/supportlib.pl	2011-06-17 01:49:18 UTC (rev 19308)
+++ trunk/cgi-bin/supportlib.pl	2011-06-17 02:13:16 UTC (rev 19309)
@@ -12,6 +12,7 @@
 use lib "$ENV{LJHOME}/cgi-bin";
 require "sysban.pl";
 use LJ::TimeUtil;
+use LJ::Support::Request::Tag;
 
 # Constants
 my $SECONDS_IN_DAY  = 3600 * 24;

Modified: trunk/htdocs/support/manage_tags.bml
===================================================================
--- trunk/htdocs/support/manage_tags.bml	2011-06-17 01:49:18 UTC (rev 19308)
+++ trunk/htdocs/support/manage_tags.bml	2011-06-17 02:13:16 UTC (rev 19309)
@@ -13,8 +13,11 @@
     my $remote = LJ::get_remote();
     return "<?needlogin?>" unless $remote;
 
-    return $ML{'.error.unauthorized'} unless
-        LJ::check_priv($remote, 'supportviewinternal');
+    unless (   LJ::check_priv( $remote, 'supportviewinternal' )
+            || LJ::check_priv( $remote, 'supporthelp' ) )
+    {
+        return LJ::Lang::ml('.error.unauthorized');
+    }
 
     my $cats = LJ::Support::load_cats();
 

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