X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fmisc%2Fxmlhttp-ticket-update.html;h=8735eecab47e9de23fcf9895b20ba46a3a49c238;hb=4c4bf4f91c1bb61c85b1e73d0eddad20708fd89c;hp=bd58b95c69c84d22699cc955d9fc89485631a32c;hpb=a863f6dc3cb00b50c497f836af7255d8999be455;p=freeside.git

diff --git a/httemplate/misc/xmlhttp-ticket-update.html b/httemplate/misc/xmlhttp-ticket-update.html
index bd58b95c6..8735eecab 100644
--- a/httemplate/misc/xmlhttp-ticket-update.html
+++ b/httemplate/misc/xmlhttp-ticket-update.html
@@ -8,14 +8,18 @@ my $username = $cgi->param('username');
 
 my $ticket = FS::TicketSystem->get_ticket_object( \%session, ticket_id=>$id );
 
-#hmm, this should happen in a single transaction and either commit or rollback,
-# but in reality failures "Don't Happen" so its not like a ticket gets
-# half changed
+#hmm, this should happen in a single transaction and either commit or rollback
 
 my $return;
 if ( $ticket ) {
 
-  my($orv, $omsg) = $ticket->SetOwner( $username, 'Steal' );
+  my $curowner = $ticket->OwnerObj->Name;
+  my($orv, $omsg);
+  if (( $curowner eq $FS::CurrentUser::CurrentUser->username ) or ( $curowner eq 'nobody' )) {
+    ($orv, $omsg) = $ticket->SetOwner( $username );
+  } else {
+    ($orv, $omsg) = $ticket->SetOwner( $username, 'Steal' );
+  }
   $orv = 1 if ! $orv && $omsg =~ /already own/i;
 
   if ( $orv ) {