### Eclipse Workspace Patch 1.0
#P scmbugg
Index: src/lib/product/Daemon/Bugzilla.pm.in
===================================================================
RCS file: /projects/scmbug/cvsroot/system/src/lib/product/Daemon/Bugzilla.pm.in,v
retrieving revision 1.48
diff -u -r1.48 Bugzilla.pm.in
--- src/lib/product/Daemon/Bugzilla.pm.in	11 Nov 2007 20:41:07 -0000	1.48
+++ src/lib/product/Daemon/Bugzilla.pm.in	24 Dec 2007 08:19:08 -0000
@@ -498,11 +498,75 @@
     my $self = shift;
     my ( $bugid, $username, $status, $resolution, $resolution_data ) = ( @_ );
 
-    return ( 1, "Changing bug resolution is not yet implemented in this version of Bugzilla.\n");
-}
+    if ( $self->is_version_latest() ) {
 
+        my $assigned_to = undef;
+        my $dup_id = undef;
 
+        $status = uc $status;
+        if($status eq "RESOLVED") {
+            $resolution = uc $resolution;
+        } else {
+            $resolution = undef;
+        }
 
+        if(defined $resolution_data) {
+            if($status eq "ASSIGNED") {
+                $assigned_to = $resolution_data;
+                $status = undef;
+            } elsif($status eq "DUPLICATE") {
+                $dup_id = $resolution_data;
+                $status = undef;
+            }
+        }
+
+        my $mail = 'From: ' . $username . "\n";
+        $mail .= "Subject: Scmbug integration\n\n";
+        $mail .= '@bug_id = ' . $bugid . "\n";
+        if(defined $status){
+            $mail .= '@bug_status = ' . $status . "\n";
+        }
+        if(defined $resolution){
+            $mail .= '@resolution = ' . $resolution . "\n";
+        }
+        if(defined $assigned_to){
+            $mail .= '@assigned_to = ' . $assigned_to . "\n";
+        }
+        if(defined $dup_id){
+            $mail .= '@dup_id = ' . $dup_id . "\n";
+        }
+        # We could add an comment to the bug here...
+
+
+        my $operations;
+        my $incomplete_data;
+        
+        ($operations, $incomplete_data) = Bugzilla::Bug::GetBugActivity($bugid, undef);
+        my $ops_before = @$operations;
+
+        # email_in.pl reads from STDIN.
+        open(EMAIL, "|-", $self->installation_directory()."/email_in.pl");
+        print EMAIL $mail;
+        close EMAIL;
+        
+        ($operations, $incomplete_data) = Bugzilla::Bug::GetBugActivity($bugid, undef);
+        my $ops_after = @$operations;
+
+        if($ops_before < $ops_after){
+            # workaround for bug in email_in.pl
+            if((defined $status) && $status eq "REOPENED") {
+                my $dbh = Bugzilla->dbh;
+                $dbh->do('UPDATE bugs SET bug_status = ? WHERE bug_id = ?', undef,
+                         "REOPENED", $bugid);
+            }
+            return 0;
+        } else {
+            return ( 1, "Changing bug resolution wasn't successful. Nothing changed.\n");
+        }
+        
+    }
+    return ( 1, "Changing bug resolution is not yet implemented in this version of Bugzilla.\n");
+}
 
 
 
@@ -933,6 +997,7 @@
 # RETURNS:
 # - 0 on success
 # - 1 if the product name does not exist
+# - 2 if the tag name does not exist
 sub integration_delete_tag {
     my $self = shift;
     my ( $product_name, $tag_name ) = ( @_ );
@@ -947,6 +1012,11 @@
 
 	my $version = new Bugzilla::Version( { product => $product,
 					       name => $tag_name } );
+        if ( !defined ( $version ) ) {
+            # The tag name does not exist
+            return 2;
+        }
+
 	$version->remove_from_db;
     } else {
 	my $sql;
