X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fmisc%2Fxmlhttp-ticket-update.html;h=8735eecab47e9de23fcf9895b20ba46a3a49c238;hb=4c4bf4f91c1bb61c85b1e73d0eddad20708fd89c;hp=46ed5bbad248012e8614631bf8a5a35207f05e9a;hpb=11e14b5e8d431d0414a9a07fc340a106102032ef;p=freeside.git diff --git a/httemplate/misc/xmlhttp-ticket-update.html b/httemplate/misc/xmlhttp-ticket-update.html index 46ed5bbad..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 ) { @@ -50,7 +54,7 @@ if ( $ticket ) { 'sched_label' => FS::sched_avail::pretty_time($sh*60+$sm). '-'. FS::sched_avail::pretty_time($eh*60+$em). ': '. - $cust_main[0]->_FreesideURILabel, + encode_entities($cust_main[0]->_FreesideURILabel), }; } else { $return = { 'error' => $smsg };