3 %# Copyright (c) 1996-2003 Jesse Vincent <jesse@bestpractical.com>
5 %# (Except where explictly superceded by other copyright notices)
7 %# This work is made available to you under the terms of Version 2 of
8 %# the GNU General Public License. A copy of that license should have
9 %# been provided with this software, but in any event can be snarfed
12 %# This work is distributed in the hope that it will be useful, but
13 %# WITHOUT ANY WARRANTY; without even the implied warranty of
14 %# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 %# General Public License for more details.
17 %# Unless otherwise specified, all modifications, corrections or
18 %# extensions to this work which alter its source code become the
19 %# property of Best Practical Solutions, LLC when submitted for
20 %# inclusion in the work.
24 %# REST/1.0/ticket/merge
31 use RT::Interface::REST;
34 my $status = "200 Ok";
35 my $ticket = new RT::Ticket $session{CurrentUser};
36 my $object = $r->path_info;
38 # http://.../REST/1.0/ticket/merge/1
41 if ($id && $object && $id != $object) {
42 $output = "Different ids in URL (`$object') and submitted form (`$id').\n";
43 $status = "400 Bad Request";
47 unless ($id =~ /^\d+$/ && $into =~ /^\d+$/) {
48 my $bad = ($id !~ /^\d+$/) ? $id : $into;
49 $output = $r->path_info. "\n";
50 $output .= "Invalid ticket id: `$bad'.\n";
51 $status = "400 Bad Request";
56 unless ($ticket->Id) {
57 $output = "Couldn't load ticket id: `$id'.\n";
58 $status = "404 Ticket not found";
61 unless ($ticket->CurrentUserHasRight('ModifyTicket')) {
62 $output = "You are not allowed to modify ticket $id.\n";
63 $status = "403 Permission denied";
67 my ($n, $s) = $ticket->MergeInto($into);
70 $status = "500 Error";
76 RT/<% $RT::VERSION %> <% $status %>