madeon (madeon) wrote in changelog,
madeon
madeon
changelog

[livejournal] r21315: LJSV-2014: Ability to rename support tag...

Committer: sbelyaev
LJSV-2014: Ability to rename support tags
U   trunk/cgi-bin/LJ/Support/Request/Tag.pm
U   trunk/htdocs/support/manage_tags.bml
Modified: trunk/cgi-bin/LJ/Support/Request/Tag.pm
===================================================================
--- trunk/cgi-bin/LJ/Support/Request/Tag.pm	2012-03-07 09:01:14 UTC (rev 21314)
+++ trunk/cgi-bin/LJ/Support/Request/Tag.pm	2012-03-07 09:21:49 UTC (rev 21315)
@@ -122,10 +122,12 @@
 sub __rename_tag_everywhere {
     my ($opts) = @_;
 
+    #
     # Tag information
+    #
+
     my $sptagid     = $opts->{'sptagid'};
     my $spcatid     = $opts->{'spcatid'};
-
     # The new name for tag 
     my $new_name    = $opts->{'new_name'};
 
@@ -137,19 +139,22 @@
     # Get curret name 
     my $old_name = LJ::Support::Request::Tag::tag_id_to_name($sptagid);
 
+    #
     # Receive all categories where rename will be done
-    my $source
-        = $dbh->selectall_hashref( "SELECT sptagid, spcatid FROM supporttag " .
-                                   "WHERE name=?",
-                                   'spcatid',
-                                   undef,
-                                   $old_name );
+    #
+    my $source  = $dbh->selectall_hashref( "SELECT sptagid, spcatid " .
+                                           "FROM supporttag " .
+                                           "WHERE name=?",
+                                           'spcatid',
+                                           undef,
+                                           $old_name );
 
-
     my @old_spcatids = keys %$source;
     my $old_spcatids_str = join(',', @old_spcatids);
 
+    #
     # Receive all tags with new name
+    #
     my $destination
         = $dbh->selectall_hashref( "SELECT sptagid, spcatid FROM supporttag " .
                                    "WHERE name=? AND spcatid IN ($old_spcatids_str)",
@@ -167,34 +172,42 @@
                   $old_name );
 
     } elsif ($allowmerge) {
-
+        #
         # update all in 'supporttag'
+        #
         foreach my $spcatid (keys %$source) {
-            # if no need to merge
+            #
+            # if no needs to merge
+            #
             if (!$destination->{$spcatid}) {
                 next;
             }
 
-            # get dest. by category
+            #
+            # Get a destination id
+            #
             my $destination_hash  = $destination->{$spcatid};
-
-            # get dest. tag id 
             my $destination_id    = $destination_hash->{'sptagid'};
 
+            #
             # remove from source hash
+            #
             my $source_hash       = delete $source->{$spcatid};
-
-            # get src. id
             my $source_id         = $source_hash->{'sptagid'};
 
+            warn LJ::D($destination_hash);
+            warn LJ::D($source_hash);
+
+            #
             # get current spid
+            #
             my $current_spids = $dbh->selectcol_arrayref( 'SELECT spid ' .
                                                           'FROM supporttagmap ' .
                                                           'WHERE sptagid = ?',
                                                           undef,
                                                           $source_id);
 
-            # get current tag id 
+            # get current tag id
             my $spids = $dbh->selectcol_arrayref( 'SELECT spid ' .
                                                   'FROM supporttagmap ' .
                                                   'WHERE sptagid = ?',
@@ -206,9 +219,7 @@
 
             foreach my $current_spid (@$current_spids) {
                 foreach my $spid (@$spids) {
-                    if ($spid == $current_spid) {
-                        next;
-                    }
+
                     eval {
                         $dbh->do( 'INSERT INTO supporttagmap (spid, sptagid) ' .
                                   'VALUES (?, ?) ',
@@ -221,7 +232,6 @@
         }
 
         foreach my $spcatid (keys %$source) {
-
             my $source_hash = delete $source->{$spcatid};
             my $source_id   = $source_hash->{'sptagid'};
 
@@ -234,7 +244,6 @@
         }
     } else {
         foreach my $spcatid (keys %$source) {
-
             if (exists $destination->{$spcatid}) {
                 next;
             }

Modified: trunk/htdocs/support/manage_tags.bml
===================================================================
--- trunk/htdocs/support/manage_tags.bml	2012-03-07 09:01:14 UTC (rev 21314)
+++ trunk/htdocs/support/manage_tags.bml	2012-03-07 09:21:49 UTC (rev 21315)
@@ -74,6 +74,22 @@
         my $allowmerge  = $FORM{'allowmerge'};
         my $new_name    = $FORM{'new_name'};
 
+        my $cats = LJ::Support::load_cats();
+        my $name = LJ::Support::Request::Tag::tag_id_to_name($sptagid);
+
+        my $u_lj_support = LJ::load_user('lj_support');
+
+        my $cat     = $cats->{$spcatid};
+        my $cat_key = $cat->{'catkey'} || '';
+        my $userid  = $u_lj_support ? $u_lj_support->userid : 0;
+        
+        my $target_cat = $everywhere ? 'board' : $cat_key;
+        LJ::statushistory_add( $userid,
+                               $remote->userid,
+                               "support_tag",
+                               "\"$name\" has been renamed to \"$new_name\". Target: $target_cat");
+
+
         LJ::Support::Request::Tag::rename_tag( {'sptagid'    => $sptagid,
                                                 'spcatid'    => $spcatid,
                                                 'new_name'   => $new_name,

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