diff options
author | Ivan Kohler <ivan@freeside.biz> | 2012-06-07 00:56:06 -0700 |
---|---|---|
committer | Ivan Kohler <ivan@freeside.biz> | 2012-06-07 00:56:06 -0700 |
commit | 43a06151e47d2c59b833cbd8c26d97865ee850b6 (patch) | |
tree | 42c51d94e7fa265461b508d061562be204ccc2c1 /rt/share/html/REST | |
parent | 6587f6ba7d047ddc1686c080090afe7d53365bd4 (diff) |
starting to work...
Diffstat (limited to 'rt/share/html/REST')
27 files changed, 108 insertions, 92 deletions
diff --git a/rt/share/html/REST/1.0/Forms/attachment/default b/rt/share/html/REST/1.0/Forms/attachment/default index b53f6fdc9..3f9bd1b63 100644 --- a/rt/share/html/REST/1.0/Forms/attachment/default +++ b/rt/share/html/REST/1.0/Forms/attachment/default @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC %# <sales@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) @@ -54,7 +54,7 @@ $args => undef <%INIT> my @data; my ($c, $o, $k, $e) = ("", [], {}, ""); -my $attachment = new RT::Attachment $session{CurrentUser}; +my $attachment = RT::Attachment->new($session{CurrentUser}); $attachment->Load($id); unless ( $attachment->Id ) { diff --git a/rt/share/html/REST/1.0/Forms/group/customfields b/rt/share/html/REST/1.0/Forms/group/customfields index b7b679274..70b50cceb 100644 --- a/rt/share/html/REST/1.0/Forms/group/customfields +++ b/rt/share/html/REST/1.0/Forms/group/customfields @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC %# <sales@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) @@ -55,7 +55,7 @@ $changes => {} <%perl> my @comments; my ($c, $o, $k, $e) = ("", [], {}, 0); -my $group = new RT::Group $session{CurrentUser}; +my $group = RT::Group->new($session{CurrentUser}); $group->Load($id); if (!$group->Id) { diff --git a/rt/share/html/REST/1.0/Forms/group/default b/rt/share/html/REST/1.0/Forms/group/default index 22ecf5840..7686f2176 100644 --- a/rt/share/html/REST/1.0/Forms/group/default +++ b/rt/share/html/REST/1.0/Forms/group/default @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC %# <sales@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) @@ -57,7 +57,7 @@ $changes => {} my @comments; my ($c, $o, $k, $e) = ("", [], {}, 0); my %data = %$changes; -my $group = new RT::Group $session{CurrentUser}; +my $group = RT::Group->new($session{CurrentUser}); my @fields = qw(Name Description); my %fields = map { lc $_ => $_ } @fields; diff --git a/rt/share/html/REST/1.0/Forms/group/ns b/rt/share/html/REST/1.0/Forms/group/ns index ec85faeb7..2e15040c4 100644 --- a/rt/share/html/REST/1.0/Forms/group/ns +++ b/rt/share/html/REST/1.0/Forms/group/ns @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC %# <sales@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) @@ -53,7 +53,7 @@ $id <%perl> use RT::Groups; -my $groups = new RT::Groups $session{CurrentUser}; +my $groups = RT::Groups->new($session{CurrentUser}); $groups->Limit(FIELD => 'Name', OPERATOR => '=', VALUE => $id); if ($groups->Count == 0) { return (0, "No group named $id exists."); diff --git a/rt/share/html/REST/1.0/Forms/queue/customfields b/rt/share/html/REST/1.0/Forms/queue/customfields index 87f925c34..18b1222d2 100644 --- a/rt/share/html/REST/1.0/Forms/queue/customfields +++ b/rt/share/html/REST/1.0/Forms/queue/customfields @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC %# <sales@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) @@ -55,7 +55,7 @@ $changes => {} <%perl> my @comments; my ($c, $o, $k, $e) = ("", [], {}, 0); -my $queue = new RT::Queue $session{CurrentUser}; +my $queue = RT::Queue->new($session{CurrentUser}); $queue->Load($id); if (!$queue->Id) { diff --git a/rt/share/html/REST/1.0/Forms/queue/default b/rt/share/html/REST/1.0/Forms/queue/default index d42fef9c3..e6d50f311 100755 --- a/rt/share/html/REST/1.0/Forms/queue/default +++ b/rt/share/html/REST/1.0/Forms/queue/default @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC %# <sales@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) @@ -57,7 +57,7 @@ $changes => {} my @comments; my ($c, $o, $k, $e) = ("", [], {}, 0); my %data = %$changes; -my $queue = new RT::Queue $session{CurrentUser}; +my $queue = RT::Queue->new($session{CurrentUser}); my @fields = qw(Name Description CorrespondAddress CommentAddress InitialPriority FinalPriority DefaultDueIn); my %fields = map { lc $_ => $_ } @fields; diff --git a/rt/share/html/REST/1.0/Forms/queue/ns b/rt/share/html/REST/1.0/Forms/queue/ns index a46431b16..255af4c0b 100755 --- a/rt/share/html/REST/1.0/Forms/queue/ns +++ b/rt/share/html/REST/1.0/Forms/queue/ns @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC %# <sales@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) @@ -53,7 +53,7 @@ $id <%perl> use RT::Queues; -my $queues = new RT::Queues $session{CurrentUser}; +my $queues = RT::Queues->new($session{CurrentUser}); $queues->Limit(FIELD => 'Name', OPERATOR => '=', VALUE => $id); if ($queues->Count == 0) { return (0, "No queue named $id exists."); diff --git a/rt/share/html/REST/1.0/Forms/queue/ticketcustomfields b/rt/share/html/REST/1.0/Forms/queue/ticketcustomfields index 61ca19da8..abbfa8ea8 100644 --- a/rt/share/html/REST/1.0/Forms/queue/ticketcustomfields +++ b/rt/share/html/REST/1.0/Forms/queue/ticketcustomfields @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC %# <sales@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) @@ -55,7 +55,7 @@ $changes => {} <%perl> my @comments; my ($c, $o, $k, $e) = ("", [], {}, 0); -my $queue = new RT::Queue $session{CurrentUser}; +my $queue = RT::Queue->new($session{CurrentUser}); $queue->Load($id); if (!$queue->Id) { @@ -71,7 +71,7 @@ if (%$changes) { my @data; push @data, [ id => "queue/" . $queue->Id ]; -my $qcfs = RT::CustomFields->new($session{CurrentUser}); +my $qcfs = RT::CustomFields->new($session{CurrentUser});; $qcfs->LimitToGlobalOrQueue($id); while ( my $qcf = $qcfs->Next() ) { if ( $format eq "l" ) { diff --git a/rt/share/html/REST/1.0/Forms/ticket/attachments b/rt/share/html/REST/1.0/Forms/ticket/attachments index ac141615d..43b8ed85a 100755 --- a/rt/share/html/REST/1.0/Forms/ticket/attachments +++ b/rt/share/html/REST/1.0/Forms/ticket/attachments @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC %# <sales@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) @@ -54,7 +54,7 @@ $args => undef <%INIT> my @data; my ($c, $o, $k, $e) = ("", [], {}, ""); -my $ticket = new RT::Ticket $session{CurrentUser}; +my $ticket = RT::Ticket->new($session{CurrentUser}); $ticket->Load($id); unless ($ticket->Id) { @@ -76,7 +76,7 @@ if ($aid) { unless ($aid =~ /^\d+$/) { return [ "# Invalid attachment id: $aid", [], {}, 1 ]; } - my $attachment = new RT::Attachment $session{CurrentUser}; + my $attachment = RT::Attachment->new($session{CurrentUser}); $attachment->Load($aid); unless ($attachment->Id eq $aid) { return [ "# Invalid attachment id: $aid", [], {}, 1 ]; @@ -118,7 +118,8 @@ else { my $size = length($a->Content || ''); if ($size > 1024) { $size = int($size/102.4)/10 . "k" } else { $size .= "b" } - push @attachments, $a->Id.": ".($a->Filename || '(Unnamed)')." (".$a->ContentType . " / ".$size.")"; + my $name = (defined $a->Filename and length $a->Filename) ? $a->Filename : "(Unnamed)"; + push @attachments, $a->Id.": $name (".$a->ContentType . " / $size)"; } } diff --git a/rt/share/html/REST/1.0/Forms/ticket/comment b/rt/share/html/REST/1.0/Forms/ticket/comment index c8d548adb..35b543d9c 100755 --- a/rt/share/html/REST/1.0/Forms/ticket/comment +++ b/rt/share/html/REST/1.0/Forms/ticket/comment @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC %# <sales@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) @@ -60,7 +60,7 @@ use File::Temp qw(tempfile); $RT::Logger->debug("Got ticket id=$id for comment"); $RT::Logger->debug("Got args @{[keys(%changes)]}."); -my $ticket = new RT::Ticket $session{CurrentUser}; +my $ticket = RT::Ticket->new($session{CurrentUser}); my ($c, $o, $k, $e) = ("", [], {}, 0); # http://.../REST/1.0/ticket/1/comment diff --git a/rt/share/html/REST/1.0/Forms/ticket/default b/rt/share/html/REST/1.0/Forms/ticket/default index 76635c85a..9ae803d89 100755 --- a/rt/share/html/REST/1.0/Forms/ticket/default +++ b/rt/share/html/REST/1.0/Forms/ticket/default @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC %# <sales@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) @@ -62,7 +62,7 @@ my $cf_spec = RT::Interface::REST->custom_field_spec(1); my @comments; my ($c, $o, $k, $e) = ("", [], {}, 0); my %data = %$changes; -my $ticket = new RT::Ticket $session{CurrentUser}; +my $ticket = RT::Ticket->new($session{CurrentUser}); my @dates = qw(Created Starts Started Due Resolved Told LastUpdated); my @people = qw(Requestors Cc AdminCc); my @create = qw(Queue Requestor Subject Cc AdminCc Owner Status Priority @@ -81,20 +81,27 @@ if ($id ne 'new') { if (!$ticket->Id) { return [ "# Ticket $id does not exist.", [], {}, 1 ]; } - elsif (!$ticket->CurrentUserHasRight('ShowTicket') || - (%data && !$ticket->CurrentUserHasRight('ModifyTicket'))) - { - my $act = %data ? "modify" : "display"; - return [ "# You are not allowed to $act ticket $id.", [], {}, 1 ]; + elsif ( %data ) { + if ( $data{status} && $data{status} eq 'deleted' && ! grep { $_ ne 'id' && $_ ne 'status' } keys %data ) { + if ( !$ticket->CurrentUserHasRight('DeleteTicket') ) { + return [ "# You are not allowed to delete ticket $id.", [], {}, 1 ]; + } + } + elsif ( !$ticket->CurrentUserHasRight('ModifyTicket') ) { + return [ "# You are not allowed to modify ticket $id.", [], {}, 1 ]; + } + } + elsif (!$ticket->CurrentUserHasRight('ShowTicket')) { + return [ "# You are not allowed to display ticket $id.", [], {}, 1 ]; } } else { if (!keys(%data)) { # GET ticket/new: Return a suitable default form. # We get defaults from queue/1 (XXX: What if it isn't there?). - my $due = new RT::Date $session{CurrentUser}; - my $queue = new RT::Queue $session{CurrentUser}; - my $starts = new RT::Date $session{CurrentUser}; + my $due = RT::Date->new($session{CurrentUser}); + my $queue = RT::Queue->new($session{CurrentUser}); + my $starts = RT::Date->new($session{CurrentUser}); $queue->Load(1); $due->SetToNow; $due->AddDays($queue->DefaultDueIn) if $queue->DefaultDueIn; @@ -132,7 +139,7 @@ else { foreach my $k (keys %data) { # flexibly parse any dates if ($dates{lc $k}) { - my $time = new RT::Date $session{CurrentUser}; + my $time = RT::Date->new($session{CurrentUser}); $time->Set(Format => 'unknown', Value => $data{$k}); $data{$k} = $time->ISO; } @@ -142,7 +149,7 @@ else { } # Set custom field elsif ($k =~ /^$cf_spec/) { - my $cf = RT::CustomField->new( $RT::SystemUser ); + my $cf = RT::CustomField->new( RT->SystemUser ); my $cfk = $1 || $2; unless($cf->LoadByName( Name => $cfk )) { push @comments, "# Invalid custom field name ($cfk)"; @@ -205,14 +212,14 @@ if (!keys(%data)) { push @data, [ $key => [ $ticket->$key->MemberEmailAddresses ] ]; } - $time = new RT::Date ($session{CurrentUser}); + $time = RT::Date->new ($session{CurrentUser}); foreach $key (@dates) { next unless (!%$fields || (exists $fields->{lc $key})); $time->Set(Format => 'sql', Value => $ticket->$key); push @data, [ $key => $time->AsString ]; } - $time = new RT::Date ($session{CurrentUser}); + $time = RT::Date->new ($session{CurrentUser}); foreach $key (qw(TimeEstimated TimeWorked TimeLeft)) { next unless (!%$fields || (exists $fields->{lc $key})); $val = $ticket->$key || 0; @@ -280,7 +287,7 @@ else { $key = $simple{$key}; $set = "Set$key"; - next if (($val eq $ticket->$key)|| ($ticket->$key =~ /^\d+$/ && $val == $ticket->$key)); + next if (($val eq ($ticket->$key||''))|| ($ticket->$key =~ /^\d+$/ && $val =~ /^\d+$/ && $val == $ticket->$key)); ($n, $s) = $ticket->$set("$val"); } elsif (exists $dates{$key}) { @@ -295,7 +302,7 @@ else { $set = "Set$key"; - my $time = new RT::Date $session{CurrentUser}; + my $time = RT::Date->new($session{CurrentUser}); $time->Set(Format => 'sql', Value => $ticket->$key); next if ($val =~ /^not set$/i || $val eq $time->AsString); @@ -341,7 +348,7 @@ else { } # Set custom field elsif ($key =~ /^$cf_spec/) { - my $cf = RT::CustomField->new( $RT::SystemUser ); + my $cf = RT::CustomField->new( RT->SystemUser ); $key = $1 || $2; if (not $cf->LoadByName( Name => $key )) { $n = 0; diff --git a/rt/share/html/REST/1.0/Forms/ticket/history b/rt/share/html/REST/1.0/Forms/ticket/history index c2aa35a8e..8b6e01722 100755 --- a/rt/share/html/REST/1.0/Forms/ticket/history +++ b/rt/share/html/REST/1.0/Forms/ticket/history @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC %# <sales@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) @@ -54,7 +54,7 @@ $format => undef $fields => undef </%ARGS> <%INIT> -my $ticket = new RT::Ticket $session{CurrentUser}; +my $ticket = RT::Ticket->new($session{CurrentUser}); my ($c, $o, $k, $e) = ("", [], {}, ""); $ticket->Load($id); @@ -100,7 +100,7 @@ if ($type) { if ($tid) { my @data; - my $t = new RT::Transaction $session{CurrentUser}; + my $t = RT::Transaction->new($session{CurrentUser}); # this paragraph limits the transaction ID query to transactions on this ticket. # Otherwise you can query any transaction from any ticket, which makes no sense. @@ -137,7 +137,7 @@ if ($tid) { if (!%$fields || exists $fields->{lc 'Content'}) { - my $creator = new RT::User $session{CurrentUser}; + my $creator = RT::User->new($session{CurrentUser}); $creator->Load($t->Creator); push @data, [ Creator => $creator->Name ]; } @@ -151,7 +151,8 @@ if ($tid) { my $size = length($a->Content||''); if ($size > 1024) { $size = int($size/102.4)/10 . "k" } else { $size .= "b" } - $attachlist .= "\n" . $a->Id.": ".($a->Filename || "untitled")." (".$size.")"; + my $name = (defined $a->Filename and length $a->Filename) ? $a->Filename : "untitled"; + $attachlist .= "\n" . $a->Id.": $name ($size)"; } push @data, [Attachments => $attachlist]; diff --git a/rt/share/html/REST/1.0/Forms/ticket/links b/rt/share/html/REST/1.0/Forms/ticket/links index fb9ee8fe1..e2e1830fe 100755 --- a/rt/share/html/REST/1.0/Forms/ticket/links +++ b/rt/share/html/REST/1.0/Forms/ticket/links @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC %# <sales@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) @@ -54,7 +54,7 @@ $changes => undef </%ARGS> <%INIT> my @data; -my $ticket = new RT::Ticket $session{CurrentUser}; +my $ticket = RT::Ticket->new($session{CurrentUser}); $ticket->Load($id); if (!$ticket->Id) { @@ -96,8 +96,8 @@ if ($changes) { my %new; foreach my $nkey (@{vsplit($val)}) { if ($nkey =~ /^\d+$/) { - my $uri = new RT::URI $session{CurrentUser}; - my $tick = new RT::Ticket $session{CurrentUser}; + my $uri = RT::URI->new($session{CurrentUser}); + my $tick = RT::Ticket->new($session{CurrentUser}); $tick->Load($nkey); if ($tick->Id) { $nkey = $uri->FromObject($tick); diff --git a/rt/share/html/REST/1.0/Forms/ticket/merge b/rt/share/html/REST/1.0/Forms/ticket/merge index 360ddd702..a751dc558 100755 --- a/rt/share/html/REST/1.0/Forms/ticket/merge +++ b/rt/share/html/REST/1.0/Forms/ticket/merge @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC %# <sales@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) @@ -56,8 +56,8 @@ use RT::Interface::REST; my $into = $args; -my $ticket = new RT::Ticket $session{CurrentUser}; -my $ticket_into = new RT::Ticket $session{CurrentUser}; +my $ticket = RT::Ticket->new($session{CurrentUser}); +my $ticket_into = RT::Ticket->new($session{CurrentUser}); my ($c, $o, $k, $e) = ("", [], {}, 0); # http://.../REST/1.0/ticket/1/merge/6 (merges ticket 1 into ticket 6) diff --git a/rt/share/html/REST/1.0/Forms/ticket/take b/rt/share/html/REST/1.0/Forms/ticket/take index d0bf13e3a..503ba55f0 100755 --- a/rt/share/html/REST/1.0/Forms/ticket/take +++ b/rt/share/html/REST/1.0/Forms/ticket/take @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC %# <sales@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) @@ -54,7 +54,7 @@ $id <%INIT> use RT::Interface::REST; -my $ticket = new RT::Ticket $session{CurrentUser}; +my $ticket = RT::Ticket->new($session{CurrentUser}); my ($c, $o, $k, $e) = ("", [], {}, 0); # http://.../REST/1.0/ticket/1/take diff --git a/rt/share/html/REST/1.0/Forms/transaction/default b/rt/share/html/REST/1.0/Forms/transaction/default index 46488d23a..1ffa2b2a5 100644 --- a/rt/share/html/REST/1.0/Forms/transaction/default +++ b/rt/share/html/REST/1.0/Forms/transaction/default @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC %# <sales@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) @@ -54,7 +54,7 @@ $format => undef $fields => undef </%ARGS> <%INIT> -my $trans = new RT::Transactions $session{CurrentUser}; +my $trans = RT::Transactions->new($session{CurrentUser}); my ($c, $o, $k, $e) = ("", [], {} , ""); chomp $args; @@ -65,7 +65,7 @@ $trans->Limit(FIELD => 'Id', OPERATOR => '=', VALUE => $tid); if ($tid) { my @data; - my $t = new RT::Transaction $session{CurrentUser}; + my $t = RT::Transaction->new($session{CurrentUser}); $t->Load($tid); if ($format eq "l") { push @data, [ id => $t->Id ]; @@ -89,7 +89,7 @@ if ($tid) { if (!%$fields || exists $fields->{lc 'Content'}); if (!%$fields || exists $fields->{lc 'Content'}) { - my $creator = new RT::User $session{CurrentUser}; + my $creator = RT::User->new($session{CurrentUser}); $creator->Load($t->Creator); push @data, [ Creator => $creator->Name ]; } @@ -107,7 +107,8 @@ if ($tid) { else { $size .= "b"; } - $attachlist .= "\n" . $a->Id.": ".($a->Filename || "untitled")." (".$size.")"; + my $name = (defined $a->Filename and length $a->Filename) ? $a->Filename : "untitled"; + $attachlist .= "\n" . $a->Id.": $name ($size)"; } push @data, [Attachments => $attachlist]; } diff --git a/rt/share/html/REST/1.0/Forms/user/default b/rt/share/html/REST/1.0/Forms/user/default index 908eab208..a5786bab3 100755 --- a/rt/share/html/REST/1.0/Forms/user/default +++ b/rt/share/html/REST/1.0/Forms/user/default @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC %# <sales@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) @@ -56,7 +56,7 @@ $changes => {} my @comments; my ($c, $o, $k, $e) = ("", [], {}, 0); my %data = %$changes; -my $user = new RT::User $session{CurrentUser}; +my $user = RT::User->new($session{CurrentUser}); my @fields = qw(RealName NickName Gecos Organization Address1 Address2 City State Zip Country HomePhone WorkPhone MobilePhone PagerPhone FreeformContactInfo Comments Signature Lang EmailEncoding diff --git a/rt/share/html/REST/1.0/Forms/user/ns b/rt/share/html/REST/1.0/Forms/user/ns index 16c8902eb..0aca5de4d 100755 --- a/rt/share/html/REST/1.0/Forms/user/ns +++ b/rt/share/html/REST/1.0/Forms/user/ns @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC %# <sales@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) @@ -56,7 +56,7 @@ use RT::Users; my $field = "Name"; $field = "EmailAddress" if $id =~ /\@/; -my $users = new RT::Users $session{CurrentUser}; +my $users = RT::Users->new($session{CurrentUser}); $users->Limit(FIELD => $field, OPERATOR => '=', VALUE => $id); if ($users->Count == 0) { return (0, "No user named $id exists."); diff --git a/rt/share/html/REST/1.0/NoAuth/mail-gateway b/rt/share/html/REST/1.0/NoAuth/mail-gateway index a34536861..27c2ac6c1 100755 --- a/rt/share/html/REST/1.0/NoAuth/mail-gateway +++ b/rt/share/html/REST/1.0/NoAuth/mail-gateway @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC %# <sales@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) diff --git a/rt/share/html/REST/1.0/autohandler b/rt/share/html/REST/1.0/autohandler index 6bc219789..ccca11235 100755 --- a/rt/share/html/REST/1.0/autohandler +++ b/rt/share/html/REST/1.0/autohandler @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC %# <sales@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) diff --git a/rt/share/html/REST/1.0/dhandler b/rt/share/html/REST/1.0/dhandler index a7400ddbd..a6fc89724 100755 --- a/rt/share/html/REST/1.0/dhandler +++ b/rt/share/html/REST/1.0/dhandler @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC %# <sales@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) diff --git a/rt/share/html/REST/1.0/logout b/rt/share/html/REST/1.0/logout index 2e59b1dca..660c12337 100755 --- a/rt/share/html/REST/1.0/logout +++ b/rt/share/html/REST/1.0/logout @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC %# <sales@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) diff --git a/rt/share/html/REST/1.0/search/dhandler b/rt/share/html/REST/1.0/search/dhandler index 70b799946..e1ddb9b13 100755 --- a/rt/share/html/REST/1.0/search/dhandler +++ b/rt/share/html/REST/1.0/search/dhandler @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC %# <sales@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) diff --git a/rt/share/html/REST/1.0/search/ticket b/rt/share/html/REST/1.0/search/ticket index bd03caf9f..16c6c6a0d 100755 --- a/rt/share/html/REST/1.0/search/ticket +++ b/rt/share/html/REST/1.0/search/ticket @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC %# <sales@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) @@ -57,7 +57,7 @@ $fields => undef use RT::Interface::REST; my $output = ""; my $status = "200 Ok"; -my $tickets = new RT::Tickets $session{CurrentUser}; +my $tickets = RT::Tickets->new($session{CurrentUser}); # Parse and validate any field specifications. my $field = RT::Interface::REST->field_spec; @@ -88,24 +88,29 @@ my ($n, $s); eval { ($n, $s) = $tickets->FromSQL($query); }; -my $sortstring = ""; + if ($orderby) { - $sortstring = 'FIELD => '; + my %args; + my $order = substr($orderby, 0, 1); if ($order eq '+' || $order eq '-') { - $sortstring .= 'substr($orderby, 1)'; - if ($order eq '+') { - $sortstring .= ", ORDER => 'ASC'"; - } elsif ($order eq '-') { - $sortstring .= ", ORDER => 'DESC'"; - } - } else { - $sortstring .= '$orderby'; + # remove the +/- sorting sigil + substr($orderby, 0, 1, ''); + + if ($order eq '+') { + $args{ORDER} = 'ASC'; + } + elsif ($order eq '-') { + $args{ORDER} = 'DESC'; + } } - my $foo = 'FIELD => '; - $foo .= '$orderby'; - $tickets->OrderBy(eval $sortstring); + + $tickets->OrderBy( + FIELD => $orderby, + %args, + ); } + if ($@ || $n == 0) { $s ||= $@; $status = "400 Bad request"; @@ -132,10 +137,11 @@ while (my $ticket = $tickets->Next) { } # Cut off the annoying ticket/ before the id; $key_values->{'id'} = $id; - $output .= join("\t", map {$key_values->{$_}} @$order)."\n"; - + $output .= join("\t", map { ref $key_values->{$_} eq 'ARRAY' ? +join( ', ', @{$key_values->{$_}} ) : $key_values->{$_} } @$order)."\n"; + - } else { + } else { $output .= $ticket->Id . ": ". $ticket->Subject . "\n"; } } diff --git a/rt/share/html/REST/1.0/ticket/comment b/rt/share/html/REST/1.0/ticket/comment index c0a3c4747..768a4688b 100755 --- a/rt/share/html/REST/1.0/ticket/comment +++ b/rt/share/html/REST/1.0/ticket/comment @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC %# <sales@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) @@ -56,7 +56,7 @@ use LWP::MediaTypes; use RT::Interface::REST; use File::Temp qw(tempfile); -my $ticket = new RT::Ticket $session{CurrentUser}; +my $ticket = RT::Ticket->new($session{CurrentUser}); my $object = $r->path_info; my $status = "200 Ok"; my $output; diff --git a/rt/share/html/REST/1.0/ticket/link b/rt/share/html/REST/1.0/ticket/link index 4f4ff25a9..aa80b0de4 100755 --- a/rt/share/html/REST/1.0/ticket/link +++ b/rt/share/html/REST/1.0/ticket/link @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC %# <sales@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) @@ -58,7 +58,7 @@ use RT::Interface::REST; my $output; my $status = "200 Ok"; -my $ticket = new RT::Ticket $session{CurrentUser}; +my $ticket = RT::Ticket->new($session{CurrentUser}); my $object = $r->path_info; my @fields = qw(DependsOn DependedOnBy RefersTo ReferredToBy HasMember MemberOf); diff --git a/rt/share/html/REST/1.0/ticket/merge b/rt/share/html/REST/1.0/ticket/merge index fe8fdad55..c7507a40b 100755 --- a/rt/share/html/REST/1.0/ticket/merge +++ b/rt/share/html/REST/1.0/ticket/merge @@ -2,7 +2,7 @@ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC %# <sales@bestpractical.com> %# %# (Except where explicitly superseded by other copyright notices) @@ -56,7 +56,7 @@ use RT::Interface::REST; my $output; my $status = "200 Ok"; -my $ticket = new RT::Ticket $session{CurrentUser}; +my $ticket = RT::Ticket->new($session{CurrentUser}); my $object = $r->path_info; # http://.../REST/1.0/ticket/merge/1 |