summaryrefslogtreecommitdiff
path: root/rt/lib/RT/Interface
diff options
context:
space:
mode:
authorivan <ivan>2008-03-02 04:11:51 +0000
committerivan <ivan>2008-03-02 04:11:51 +0000
commit8103c1fc1b2c27a6855feadf26f91b980a54bc52 (patch)
tree631dd45606c37c00d9026e14ecc3ee3700b4b51c /rt/lib/RT/Interface
parent9c68254528b6f2c7d8c1921b452fa56064783782 (diff)
import rt 3.6.6
Diffstat (limited to 'rt/lib/RT/Interface')
-rw-r--r--rt/lib/RT/Interface/CLI.pm8
-rwxr-xr-xrt/lib/RT/Interface/Email.pm119
-rwxr-xr-xrt/lib/RT/Interface/Email/Auth/GnuPG.pm6
-rw-r--r--rt/lib/RT/Interface/Email/Auth/MailFrom.pm6
-rw-r--r--rt/lib/RT/Interface/Email/Filter/SpamAssassin.pm6
-rw-r--r--rt/lib/RT/Interface/REST.pm36
-rw-r--r--rt/lib/RT/Interface/Web.pm253
-rw-r--r--rt/lib/RT/Interface/Web/Handler.pm23
-rwxr-xr-xrt/lib/RT/Interface/Web/QueryBuilder.pm6
-rwxr-xr-xrt/lib/RT/Interface/Web/QueryBuilder/Tree.pm6
-rwxr-xr-xrt/lib/RT/Interface/Web/Standalone.pm47
11 files changed, 359 insertions, 157 deletions
diff --git a/rt/lib/RT/Interface/CLI.pm b/rt/lib/RT/Interface/CLI.pm
index 31650392f..c2b545468 100644
--- a/rt/lib/RT/Interface/CLI.pm
+++ b/rt/lib/RT/Interface/CLI.pm
@@ -2,7 +2,7 @@
#
# COPYRIGHT:
#
-# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC
+# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC
# <jesse@bestpractical.com>
#
# (Except where explicitly superseded by other copyright notices)
@@ -22,7 +22,9 @@
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301 or visit their web page on the internet at
+# http://www.gnu.org/copyleft/gpl.html.
#
#
# CONTRIBUTION SUBMISSION POLICY:
@@ -55,7 +57,7 @@ BEGIN {
use vars qw ($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
# set the version for version checking
- $VERSION = do { my @r = (q$Revision: 1.1.1.5 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; # must be all one line, for MakeMaker
+ $VERSION = do { my @r = (q$Revision: 1.1.1.6 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; # must be all one line, for MakeMaker
@ISA = qw(Exporter);
diff --git a/rt/lib/RT/Interface/Email.pm b/rt/lib/RT/Interface/Email.pm
index de125f560..dfbd4aeea 100755
--- a/rt/lib/RT/Interface/Email.pm
+++ b/rt/lib/RT/Interface/Email.pm
@@ -1,38 +1,40 @@
# BEGIN BPS TAGGED BLOCK {{{
-#
+#
# COPYRIGHT:
-#
-# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC
+#
+# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC
# <jesse@bestpractical.com>
-#
+#
# (Except where explicitly superseded by other copyright notices)
-#
-#
+#
+#
# LICENSE:
-#
+#
# This work is made available to you under the terms of Version 2 of
# the GNU General Public License. A copy of that license should have
# been provided with this software, but in any event can be snarfed
# from www.gnu.org.
-#
+#
# This work is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
-#
+#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-#
-#
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301 or visit their web page on the internet at
+# http://www.gnu.org/copyleft/gpl.html.
+#
+#
# CONTRIBUTION SUBMISSION POLICY:
-#
+#
# (The following paragraph is not intended to limit the rights granted
# to you to modify and distribute this software under the terms of
# the GNU General Public License and is only of importance to you if
# you choose to contribute your changes and enhancements to the
# community by submitting them to Best Practical Solutions, LLC.)
-#
+#
# By intentionally submitting any modifications, corrections or
# derivatives to this work, or any other work intended for use with
# Request Tracker, to Best Practical Solutions, LLC, you confirm that
@@ -41,7 +43,7 @@
# royalty-free, perpetual, license to use, copy, create derivative
# works based on those contributions, and sublicense and distribute
# those contributions and any derivatives thereof.
-#
+#
# END BPS TAGGED BLOCK }}}
package RT::Interface::Email;
@@ -219,7 +221,7 @@ Returns the same array with any IsRTAddress()es weeded out.
=cut
sub CullRTAddresses {
- return ( grep { IsRTAddress($_) } @_ );
+ return grep !IsRTAddress($_), @_;
}
# }}}
@@ -242,14 +244,16 @@ sub MailError {
level => $args{'LogLevel'},
message => $args{'Explanation'}
);
+ # the colons are necessary to make ->build include non-standard headers
my $entity = MIME::Entity->build(
Type => "multipart/mixed",
From => $args{'From'},
Bcc => $args{'Bcc'},
To => $args{'To'},
Subject => $args{'Subject'},
- Precedence => 'bulk',
- 'X-RT-Loop-Prevention' => $RT::rtname,
+ 'Precedence:' => 'bulk',
+ 'X-RT-Loop-Prevention:' => $RT::rtname,
+ 'In-Reply-To:' => $args{'MIMEObj'} ? $args{'MIMEObj'}->head->get('Message-Id') : undef
);
$entity->attach( Data => $args{'Explanation'} . "\n" );
@@ -297,7 +301,6 @@ sub CreateUser {
unless ($Val) {
# Deal with the race condition of two account creations at once
- #
if ($Username) {
$NewUser->LoadByName($Username);
}
@@ -393,12 +396,15 @@ sub ParseSenderAddressFromHead {
my $head = shift;
#Figure out who's sending this message.
- my $From = $head->get('Reply-To')
- || $head->get('From')
- || $head->get('Sender');
- return ( ParseAddressFromHeader($From) );
-}
+ foreach my $header ('Reply-To', 'From', 'Sender') {
+ my $From = $head->get($header);
+ my ($addr, $name) = ParseAddressFromHeader($From);
+ # only return if the address is not empty
+ return ($addr, $name) if $addr;
+ }
+ return (undef, undef);
+}
# }}}
# {{{ ParseErrorsToAdddressFromHead
@@ -442,11 +448,12 @@ Takes an address from $head->get('Line') and returns a tuple: user@host, friendl
sub ParseAddressFromHeader {
my $Addr = shift;
+ # Some broken mailers send: ""Vincent, Jesse"" <jesse@fsck.com>. Hate
+ $Addr =~ s/\"\"(.*?)\"\"/\"$1\"/g;
my @Addresses = Mail::Address->parse($Addr);
- my $AddrObj = $Addresses[0];
-
- unless ( ref($AddrObj) ) {
+ my ($AddrObj) = grep ref $_, @Addresses;
+ unless ( $AddrObj ) {
return ( undef, undef );
}
@@ -568,6 +575,22 @@ sub Gateway {
#Pull apart the subject line
my $Subject = $head->get('Subject') || '';
chomp $Subject;
+
+ # {{{ Lets check for mail loops of various sorts.
+ my ($should_store_machine_generated_message, $IsALoop, $result);
+ ( $should_store_machine_generated_message, $ErrorsTo, $result, $IsALoop ) =
+ _HandleMachineGeneratedMail(
+ Message => $Message,
+ ErrorsTo => $ErrorsTo,
+ Subject => $Subject,
+ MessageId => $MessageId
+ );
+
+ # Do not pass loop messages to MailPlugins, to make sure the loop
+ # is broken, unless $RT::StoreLoops is set.
+ if ($IsALoop && !$should_store_machine_generated_message) {
+ return ( 0, $result, undef );
+ }
$args{'ticket'} ||= ParseTicketId($Subject);
@@ -643,6 +666,10 @@ sub Gateway {
$skip_action{$action}++ if $AuthStat == -2;
}
+ # strip actions we should skip
+ @actions = grep !$skip_action{$_}, @actions if $AuthStat == -2;
+ last unless @actions;
+
last if $AuthStat == -1;
}
# {{{ If authentication fails and no new user was created, get out.
@@ -679,22 +706,11 @@ sub Gateway {
);
}
- # {{{ Lets check for mail loops of various sorts.
- my ($continue, $result);
- ( $continue, $ErrorsTo, $result ) = _HandleMachineGeneratedMail(
- Message => $Message,
- ErrorsTo => $ErrorsTo,
- Subject => $Subject,
- MessageId => $MessageId
- );
- unless ($continue) {
+ unless ($should_store_machine_generated_message) {
return ( 0, $result, undef );
}
- # strip actions we should skip
- @actions = grep !$skip_action{$_}, @actions;
-
# if plugin's updated SystemTicket then update arguments
$args{'ticket'} = $SystemTicket->Id if $SystemTicket && $SystemTicket->Id;
@@ -724,7 +740,7 @@ sub Gateway {
if ( $id == 0 ) {
MailError(
To => $ErrorsTo,
- Subject => "Ticket creation failed",
+ Subject => "Ticket creation failed: $Subject",
Explanation => $ErrStr,
MIMEObj => $Message
);
@@ -736,20 +752,23 @@ sub Gateway {
@actions = grep !/^(comment|correspond)$/, @actions;
$args{'ticket'} = $id;
- } else {
+ } elsif ( $args{'ticket'} ) {
$Ticket->Load( $args{'ticket'} );
unless ( $Ticket->Id ) {
my $error = "Could not find a ticket with id " . $args{'ticket'};
MailError(
To => $ErrorsTo,
- Subject => "Message not recorded",
+ Subject => "Message not recorded: $Subject",
Explanation => $error,
MIMEObj => $Message
);
return ( 0, $error );
}
+ $args{'ticket'} = $Ticket->id;
+ } else {
+ return ( 1, "Success", $Ticket );
}
# }}}
@@ -764,7 +783,7 @@ sub Gateway {
#Warn the sender that we couldn't actually submit the comment.
MailError(
To => $ErrorsTo,
- Subject => "Message not recorded",
+ Subject => "Message not recorded: $Subject",
Explanation => $msg,
MIMEObj => $Message
);
@@ -856,6 +875,7 @@ EOT
);
# Also notify the requestor that his request has been dropped.
+ if ($args{'Requestor'} ne $RT::OwnerEmail) {
MailError(
To => $args{'Requestor'},
Subject => "Could not load a valid user",
@@ -867,6 +887,7 @@ EOT
MIMEObj => $args{'Message'},
LogLevel => 'error'
);
+ }
}
=head2 _HandleMachineGeneratedMail
@@ -877,7 +898,8 @@ Takes named params:
Subject
Checks the message to see if it's a bounce, if it looks like a loop, if it's autogenerated, etc.
-Returns a triple of ("Should we continue (boolean)", "New value for $ErrorsTo", "Status message");
+Returns a triple of ("Should we continue (boolean)", "New value for $ErrorsTo", "Status message",
+"This message appears to be a loop (boolean)" );
=cut
@@ -905,7 +927,7 @@ sub _HandleMachineGeneratedMail {
# Warn someone if it's a loop, before we drop it on the ground
if ($IsALoop) {
- $RT::Logger->crit("RT Recieved mail (".$args{MessageId}.") from itself.");
+ $RT::Logger->crit("RT Received mail (".$args{MessageId}.") from itself.");
#Should we mail it to RTOwner?
if ($RT::LoopsToRTOwner) {
@@ -918,7 +940,7 @@ sub _HandleMachineGeneratedMail {
}
#Do we actually want to store it?
- return ( 0, $ErrorsTo, "Message Bounced" ) unless ($RT::StoreLoops);
+ return ( 0, $ErrorsTo, "Message Bounced", $IsALoop ) unless ($RT::StoreLoops);
}
# Squelch replies if necessary
@@ -942,7 +964,7 @@ sub _HandleMachineGeneratedMail {
$head->add( 'RT-Squelch-Replies-To', $Sender );
$head->add( 'RT-DetectedAutoGenerated', 'true' );
}
- return ( 1, $ErrorsTo, "Handled machine detection" );
+ return ( 1, $ErrorsTo, "Handled machine detection", $IsALoop );
}
=head2 IsCorrectAction
@@ -953,7 +975,8 @@ Returns a list of valid actions we've found for this message
sub IsCorrectAction {
my $action = shift;
- my @actions = split /-/, $action;
+ my @actions = grep $_, split /-/, $action;
+ return ( 0, '(no value)' ) unless @actions;
foreach (@actions) {
return ( 0, $_ ) unless /^(?:comment|correspond|take|resolve)$/;
}
diff --git a/rt/lib/RT/Interface/Email/Auth/GnuPG.pm b/rt/lib/RT/Interface/Email/Auth/GnuPG.pm
index 2dfada755..115080722 100755
--- a/rt/lib/RT/Interface/Email/Auth/GnuPG.pm
+++ b/rt/lib/RT/Interface/Email/Auth/GnuPG.pm
@@ -2,7 +2,7 @@
#
# COPYRIGHT:
#
-# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC
+# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC
# <jesse@bestpractical.com>
#
# (Except where explicitly superseded by other copyright notices)
@@ -22,7 +22,9 @@
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301 or visit their web page on the internet at
+# http://www.gnu.org/copyleft/gpl.html.
#
#
# CONTRIBUTION SUBMISSION POLICY:
diff --git a/rt/lib/RT/Interface/Email/Auth/MailFrom.pm b/rt/lib/RT/Interface/Email/Auth/MailFrom.pm
index 5143764e1..32009c372 100644
--- a/rt/lib/RT/Interface/Email/Auth/MailFrom.pm
+++ b/rt/lib/RT/Interface/Email/Auth/MailFrom.pm
@@ -2,7 +2,7 @@
#
# COPYRIGHT:
#
-# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC
+# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC
# <jesse@bestpractical.com>
#
# (Except where explicitly superseded by other copyright notices)
@@ -22,7 +22,9 @@
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301 or visit their web page on the internet at
+# http://www.gnu.org/copyleft/gpl.html.
#
#
# CONTRIBUTION SUBMISSION POLICY:
diff --git a/rt/lib/RT/Interface/Email/Filter/SpamAssassin.pm b/rt/lib/RT/Interface/Email/Filter/SpamAssassin.pm
index c552d76e6..2f8b61cdb 100644
--- a/rt/lib/RT/Interface/Email/Filter/SpamAssassin.pm
+++ b/rt/lib/RT/Interface/Email/Filter/SpamAssassin.pm
@@ -2,7 +2,7 @@
#
# COPYRIGHT:
#
-# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC
+# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC
# <jesse@bestpractical.com>
#
# (Except where explicitly superseded by other copyright notices)
@@ -22,7 +22,9 @@
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301 or visit their web page on the internet at
+# http://www.gnu.org/copyleft/gpl.html.
#
#
# CONTRIBUTION SUBMISSION POLICY:
diff --git a/rt/lib/RT/Interface/REST.pm b/rt/lib/RT/Interface/REST.pm
index 4eeb468c4..bb2bf24bb 100644
--- a/rt/lib/RT/Interface/REST.pm
+++ b/rt/lib/RT/Interface/REST.pm
@@ -2,7 +2,7 @@
#
# COPYRIGHT:
#
-# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC
+# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC
# <jesse@bestpractical.com>
#
# (Except where explicitly superseded by other copyright notices)
@@ -22,7 +22,9 @@
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301 or visit their web page on the internet at
+# http://www.gnu.org/copyleft/gpl.html.
#
#
# CONTRIBUTION SUBMISSION POLICY:
@@ -54,25 +56,37 @@ BEGIN {
use Exporter ();
use vars qw($VERSION @ISA @EXPORT);
- $VERSION = do { my @r = (q$Revision: 1.1.1.5 $ =~ /\d+/g); sprintf "%d."."%02d"x$#r, @r };
+ $VERSION = do { my @r = (q$Revision: 1.1.1.6 $ =~ /\d+/g); sprintf "%d."."%02d"x$#r, @r };
@ISA = qw(Exporter);
@EXPORT = qw(expand_list form_parse form_compose vpush vsplit);
}
-my $field = '[a-zA-Z][a-zA-Z0-9_-]*';
+my $field = '(?i:[a-z][a-z0-9_-]*|C(?:ustom)?F(?:ield)?-(?:[a-z0-9_ -]|\s)+)';
+# WARN: this code is duplicated in bin/rt.in,
+# change both functions at once
sub expand_list {
my ($list) = @_;
- my ($elt, @elts, %elts);
- foreach $elt (split /,/, $list) {
- if ($elt =~ /^(\d+)-(\d+)$/) { push @elts, ($1..$2) }
- else { push @elts, $elt }
+ my @elts;
+ foreach (split /,/, $list) {
+ push @elts, /^(\d+)-(\d+)$/? ($1..$2): $_;
}
- @elts{@elts}=();
- return sort {$a<=>$b} keys %elts;
+ return map $_->[0], # schwartzian transform
+ sort {
+ defined $a->[1] && defined $b->[1]?
+ # both numbers
+ $a->[1] <=> $b->[1]
+ :!defined $a->[1] && !defined $b->[1]?
+ # both letters
+ $a->[2] cmp $b->[2]
+ # mix, number must be first
+ :defined $a->[1]? -1: 1
+ }
+ map [ $_, (defined( /^(\d+)$/ )? $1: undef), lc($_) ],
+ @elts;
}
# Returns a reference to an array of parsed forms.
@@ -108,7 +122,7 @@ sub form_parse {
}
$c .= "\n";
}
- elsif ($state <= 1 && $line =~ /^($field):(?:\s+(.*))?$/) {
+ elsif ($state <= 1 && $line =~ /^($field):(?:\s+(.*))?$/i) {
# Read a field: value specification.
my $f = $1;
my @v = ($2 || ());
diff --git a/rt/lib/RT/Interface/Web.pm b/rt/lib/RT/Interface/Web.pm
index 8bc840ba4..bc63f7cb5 100644
--- a/rt/lib/RT/Interface/Web.pm
+++ b/rt/lib/RT/Interface/Web.pm
@@ -2,7 +2,7 @@
#
# COPYRIGHT:
#
-# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC
+# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC
# <jesse@bestpractical.com>
#
# (Except where explicitly superseded by other copyright notices)
@@ -22,7 +22,9 @@
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301 or visit their web page on the internet at
+# http://www.gnu.org/copyleft/gpl.html.
#
#
# CONTRIBUTION SUBMISSION POLICY:
@@ -62,10 +64,13 @@ use_ok(RT::Interface::Web);
=cut
-package RT::Interface::Web;
use strict;
+use warnings;
-
+package RT::Interface::Web;
+use HTTP::Date;
+use RT::SavedSearches;
+use URI;
# {{{ EscapeUTF8
@@ -127,7 +132,7 @@ sub WebCanonicalizeInfo {
my $user;
if ( defined $ENV{'REMOTE_USER'} ) {
- $user = lc ( $ENV{'REMOTE_USER'} ) if( length($ENV{'REMOTE_USER'}) );
+ $user = lc ( $ENV{'REMOTE_USER'} ) if( length($ENV{'REMOTE_USER'}) );
}
return $user;
@@ -151,14 +156,14 @@ sub WebExternalAutoInfo {
$user_info{'Privileged'} = 1;
if ($^O !~ /^(?:riscos|MacOS|MSWin32|dos|os2)$/) {
- # Populate fields with information from Unix /etc/passwd
+ # Populate fields with information from Unix /etc/passwd
- my ($comments, $realname) = (getpwnam($user))[5, 6];
- $user_info{'Comments'} = $comments if defined $comments;
- $user_info{'RealName'} = $realname if defined $realname;
+ my ($comments, $realname) = (getpwnam($user))[5, 6];
+ $user_info{'Comments'} = $comments if defined $comments;
+ $user_info{'RealName'} = $realname if defined $realname;
}
elsif ($^O eq 'MSWin32' and eval 'use Net::AdminMisc; 1') {
- # Populate fields with information from NT domain controller
+ # Populate fields with information from NT domain controller
}
# and return the wad of stuff
@@ -168,8 +173,62 @@ sub WebExternalAutoInfo {
# }}}
+
+=head2 Redirect URL
+
+This routine ells the current user's browser to redirect to URL.
+Additionally, it unties the user's currently active session, helping to avoid
+A bug in Apache::Session 1.81 and earlier which clobbers sessions if we try to use
+a cached DBI statement handle twice at the same time.
+
+=cut
+
+
+sub Redirect {
+ my $redir_to = shift;
+ untie $HTML::Mason::Commands::session;
+ my $uri = URI->new($redir_to);
+ my $server_uri = URI->new($RT::WebURL);
+
+ # If the user is coming in via a non-canonical
+ # hostname, don't redirect them to the canonical host,
+ # it will just upset them (and invalidate their credentials)
+ if ($uri->host eq $server_uri->host &&
+ $uri->port eq $server_uri->port) {
+ $uri->host($ENV{'HTTP_HOST'});
+ $uri->port($ENV{'SERVER_PORT'});
+ }
+
+ $HTML::Mason::Commands::m->redirect($uri->canonical);
+ $HTML::Mason::Commands::m->abort;
+}
+
+
+=head2 StaticFileHeaders
+
+Send the browser a few headers to try to get it to (somewhat agressively)
+cache RT's static Javascript and CSS files.
+
+This routine could really use _accurate_ heuristics. (XXX TODO)
+
+=cut
+
+sub StaticFileHeaders {
+ # make cache public
+ $HTML::Mason::Commands::r->headers_out->{'Cache-Control'} = 'max-age=259200, public';
+
+ # Expire things in a month.
+ $HTML::Mason::Commands::r->headers_out->{'Expires'} = HTTP::Date::time2str( time() + 2592000 );
+
+ # if we set 'Last-Modified' then browser request a comp using 'If-Modified-Since'
+ # request, but we don't handle it and generate full reply again
+ # Last modified at server start time
+ #$HTML::Mason::Commands::r->headers_out->{'Last-Modified'} = HTTP::Date::time2str($^T);
+
+}
+
+
package HTML::Mason::Commands;
-use strict;
use vars qw/$r $m %session/;
@@ -194,8 +253,8 @@ sub loc {
return ($u->loc(@_));
}
else {
- # pathetic case -- SystemUser is gone.
- return $_[0];
+ # pathetic case -- SystemUser is gone.
+ return $_[0];
}
}
@@ -277,15 +336,12 @@ sub CreateTicket {
my $starts = new RT::Date( $session{'CurrentUser'} );
$starts->Set( Format => 'unknown', Value => $ARGS{'Starts'} );
- my @Requestors = split ( /\s*,\s*/, $ARGS{'Requestors'} );
- my @Cc = split ( /\s*,\s*/, $ARGS{'Cc'} );
- my @AdminCc = split ( /\s*,\s*/, $ARGS{'AdminCc'} );
-
my $MIMEObj = MakeMIMEEntity(
Subject => $ARGS{'Subject'},
From => $ARGS{'From'},
Cc => $ARGS{'Cc'},
Body => $ARGS{'Content'},
+ Type => $ARGS{'ContentType'},
);
if ( $ARGS{'Attachments'} ) {
@@ -311,23 +367,39 @@ sub CreateTicket {
TimeLeft => $ARGS{'TimeLeft'},
TimeEstimated => $ARGS{'TimeEstimated'},
TimeWorked => $ARGS{'TimeWorked'},
- Requestor => \@Requestors,
- Cc => \@Cc,
- AdminCc => \@AdminCc,
Subject => $ARGS{'Subject'},
Status => $ARGS{'Status'},
Due => $due->ISO,
Starts => $starts->ISO,
MIMEObj => $MIMEObj
);
+
+ my @temp_squelch;
+ foreach my $type (qw(Requestors Cc AdminCc)) {
+ my @tmp = map { $_->format } grep { $_->address} Mail::Address->parse( $ARGS{ $type } );
+
+ $create_args{ $type } = [
+ grep $_, map {
+ my $user = RT::User->new( $RT::SystemUser );
+ $user->LoadOrCreateByEmail( $_ );
+ # convert to ids to avoid work later
+ $user->id;
+ } @tmp
+ ];
+ $RT::Logger->debug(
+ "$type got ".join(',',@{$create_args{ $type }}) );
+
+ }
+ # XXX: workaround for name conflict :(
+ $create_args{'Requestor'} = delete $create_args{'Requestors'};
+
foreach my $arg (keys %ARGS) {
- my $cfid = $1;
+ next if $arg =~ /-(?:Magic|Category)$/;
- next if ($arg =~ /-Magic$/);
- #Object-RT::Ticket--CustomField-3-Values
if ($arg =~ /^Object-RT::Transaction--CustomField-/) {
$create_args{$arg} = $ARGS{$arg};
}
+ # Object-RT::Ticket--CustomField-3-Values
elsif ($arg =~ /^Object-RT::Ticket--CustomField-(\d+)(.*?)$/) {
my $cfid = $1;
my $cf = RT::CustomField->new( $session{'CurrentUser'});
@@ -358,42 +430,42 @@ sub CreateTicket {
my (@dependson, @dependedonby, @parents, @children, @refersto, @referredtoby);
foreach my $luri ( split ( / /, $ARGS{"new-DependsOn"} ) ) {
- $luri =~ s/\s*$//; # Strip trailing whitespace
- push @dependson, $luri;
+ $luri =~ s/\s*$//; # Strip trailing whitespace
+ push @dependson, $luri;
}
$create_args{'DependsOn'} = \@dependson;
foreach my $luri ( split ( / /, $ARGS{"DependsOn-new"} ) ) {
- push @dependedonby, $luri;
+ push @dependedonby, $luri;
}
$create_args{'DependedOnBy'} = \@dependedonby;
foreach my $luri ( split ( / /, $ARGS{"new-MemberOf"} ) ) {
- $luri =~ s/\s*$//; # Strip trailing whitespace
- push @parents, $luri;
+ $luri =~ s/\s*$//; # Strip trailing whitespace
+ push @parents, $luri;
}
$create_args{'Parents'} = \@parents;
foreach my $luri ( split ( / /, $ARGS{"MemberOf-new"} ) ) {
- push @children, $luri;
+ push @children, $luri;
}
$create_args{'Children'} = \@children;
foreach my $luri ( split ( / /, $ARGS{"new-RefersTo"} ) ) {
- $luri =~ s/\s*$//; # Strip trailing whitespace
- push @refersto, $luri;
+ $luri =~ s/\s*$//; # Strip trailing whitespace
+ push @refersto, $luri;
}
$create_args{'RefersTo'} = \@refersto;
foreach my $luri ( split ( / /, $ARGS{"RefersTo-new"} ) ) {
- push @referredtoby, $luri;
+ push @referredtoby, $luri;
}
$create_args{'ReferredToBy'} = \@referredtoby;
# }}}
my ( $id, $Trans, $ErrMsg ) = $Ticket->Create(%create_args);
- unless ( $id && $Trans ) {
+ unless ( $id ) {
Abort($ErrMsg);
}
@@ -467,6 +539,7 @@ sub ProcessUpdateMessage {
my $Message = MakeMIMEEntity(
Subject => $args{ARGSRef}->{'UpdateSubject'},
Body => $args{ARGSRef}->{'UpdateContent'},
+ Type => $args{ARGSRef}->{'UpdateContentType'},
);
$Message->head->add( 'Message-ID' =>
@@ -544,6 +617,8 @@ sub ProcessUpdateMessage {
Takes a paramhash Subject, Body and AttachmentFieldName.
+Also takes Form, Cc and Type as optional paramhash keys.
+
Returns a MIME::Entity.
=cut
@@ -557,13 +632,14 @@ sub MakeMIMEEntity {
Cc => undef,
Body => undef,
AttachmentFieldName => undef,
+ Type => undef,
# map Encode::encode_utf8($_), @_,
@_,
);
#Make the update content have no 'weird' newlines in it
- $args{'Body'} =~ s/\r\n/\n/gs;
+ $args{'Body'} =~ s/\r\n/\n/gs if $args{'Body'};
my $Message;
{
# MIME::Head is not happy in utf-8 domain. This only happens
@@ -574,7 +650,8 @@ sub MakeMIMEEntity {
Subject => $args{'Subject'} || "",
From => $args{'From'},
Cc => $args{'Cc'},
- Charset => 'utf8',
+ Type => $args{'Type'} || 'text/plain',
+ 'Charset:' => 'utf8',
Data => [ $args{'Body'} ]
);
}
@@ -902,7 +979,7 @@ sub ProcessACLChanges {
if ($object_type eq 'RT::System') {
$obj = $RT::System;
- } elsif ($RT::ACE::OBJECT_TYPES{$object_type}) {
+ } elsif ($RT::ACE::OBJECT_TYPES{$object_type}) {
$obj = $object_type->new($session{'CurrentUser'});
$obj->Load($object_id);
} else {
@@ -931,7 +1008,7 @@ sub ProcessACLChanges {
if ($object_type eq 'RT::System') {
$obj = $RT::System;
- } elsif ($RT::ACE::OBJECT_TYPES{$object_type}) {
+ } elsif ($RT::ACE::OBJECT_TYPES{$object_type}) {
$obj = $object_type->new($session{'CurrentUser'});
$obj->Load($object_id);
} else {
@@ -973,9 +1050,9 @@ sub UpdateRecordObject {
my $Object = $args{'Object'};
my @results = $Object->Update(AttributesRef => $args{'AttributesRef'},
- ARGSRef => $args{'ARGSRef'},
+ ARGSRef => $args{'ARGSRef'},
AttributePrefix => $args{'AttributePrefix'}
- );
+ );
return (@results);
}
@@ -1073,6 +1150,7 @@ sub ProcessTicketBasics {
Queue
);
+
if ( $ARGSRef->{'Queue'} and ( $ARGSRef->{'Queue'} !~ /^(\d+)$/ ) ) {
my $tempqueue = RT::Queue->new($RT::SystemUser);
$tempqueue->Load( $ARGSRef->{'Queue'} );
@@ -1123,11 +1201,11 @@ sub ProcessTicketCustomFieldUpdates {
my %custom_fields_to_mod;
foreach my $arg ( keys %$ARGSRef ) {
if ( $arg =~ /^Ticket-(\d+-.*)/) {
- $ARGSRef->{"Object-RT::Ticket-$1"} = delete $ARGSRef->{$arg};
- }
+ $ARGSRef->{"Object-RT::Ticket-$1"} = delete $ARGSRef->{$arg};
+ }
elsif ( $arg =~ /^CustomField-(\d+-.*)/) {
- $ARGSRef->{"Object-RT::Ticket--$1"} = delete $ARGSRef->{$arg};
- }
+ $ARGSRef->{"Object-RT::Ticket--$1"} = delete $ARGSRef->{$arg};
+ }
}
return ProcessObjectCustomFieldUpdates(%args, ARGSRef => $ARGSRef);
@@ -1187,6 +1265,8 @@ sub _ProcessObjectCustomFieldUpdates {
my @results;
foreach my $arg ( keys %{ $args{'ARGS'} } ) {
+
+ next if $arg =~ /Category$/;
# since http won't pass in a form element with a null value, we need
# to fake it
@@ -1206,7 +1286,7 @@ sub _ProcessObjectCustomFieldUpdates {
@values = @{ $args{'ARGS'}->{$arg} };
} elsif ( $cf_type =~ /text/i ) { # Both Text and Wikitext
@values = ($args{'ARGS'}->{$arg});
- } else {
+ } elsif ( defined( $args{'ARGS'}->{ $arg } ) ) {
@values = split /\n/, $args{'ARGS'}->{ $arg };
}
@@ -1302,8 +1382,8 @@ sub _ProcessObjectCustomFieldUpdates {
}
}
else {
- push ( @results, loc("User asked for an unknown update type"
- ." for custom field [_1] for [_2] object #[_3]",
+ push ( @results,
+ loc("User asked for an unknown update type for custom field [_1] for [_2] object #[_3]",
$cf->Name, ref $args{'Object'}, $args{'Object'}->id )
);
}
@@ -1330,27 +1410,30 @@ sub ProcessTicketWatchers {
my $Ticket = $args{'TicketObj'};
my $ARGSRef = $args{'ARGSRef'};
- # {{{ Munge watchers
+ # Munge watchers
foreach my $key ( keys %$ARGSRef ) {
- # {{{ Delete deletable watchers
- if ( ( $key =~ /^Ticket-DeleteWatcher-Type-(.*)-Principal-(\d+)$/ ) ) {
- my ( $code, $msg ) =
- $Ticket->DeleteWatcher(PrincipalId => $2,
- Type => $1);
+ # Delete deletable watchers
+ if ( ( $key =~ /^Ticket-DeleteWatcher-Type-(.*)-Principal-(\d+)$/ ) )
+ {
+ my ( $code, $msg ) = $Ticket->DeleteWatcher(
+ PrincipalId => $2,
+ Type => $1
+ );
push @results, $msg;
}
# Delete watchers in the simple style demanded by the bulk manipulator
- elsif ( $key =~ /^Delete(Requestor|Cc|AdminCc)$/ ) {
- my ( $code, $msg ) = $Ticket->DeleteWatcher( Email => $ARGSRef->{$key}, Type => $1 );
+ elsif ( $key =~ /^Delete(Requestor|Cc|AdminCc)$/ ) {
+ my ( $code, $msg ) = $Ticket->DeleteWatcher(
+ Email => $ARGSRef->{$key},
+ Type => $1
+ );
push @results, $msg;
}
- # }}}
-
- # Add new wathchers by email address
+ # Add new wathchers by email address
elsif ( ( $ARGSRef->{$key} =~ /^(AdminCc|Cc|Requestor)$/ )
and ( $key =~ /^WatcherTypeEmail(\d*)$/ ) )
{
@@ -1373,18 +1456,21 @@ sub ProcessTicketWatchers {
}
# Add new watchers by owner
- elsif ( ( $ARGSRef->{$key} =~ /^(AdminCc|Cc|Requestor)$/ )
- and ( $key =~ /^Ticket-AddWatcher-Principal-(\d*)$/ ) ) {
+ elsif ( $key =~ /^Ticket-AddWatcher-Principal-(\d*)$/ ) {
+ my $principal_id = $1;
+ my $form = $ARGSRef->{$key};
+ foreach my $value ( ref($form) ? @{$form} : ($form) ) {
+ next unless $value =~ /^(?:AdminCc|Cc|Requestor)$/i;
- #They're in this order because otherwise $1 gets clobbered :/
- my ( $code, $msg ) =
- $Ticket->AddWatcher( Type => $ARGSRef->{$key}, PrincipalId => $1 );
- push @results, $msg;
+ my ( $code, $msg ) = $Ticket->AddWatcher(
+ Type => $value,
+ PrincipalId => $principal_id
+ );
+ push @results, $msg;
+ }
}
- }
-
- # }}}
+ }
return (@results);
}
@@ -1426,7 +1512,7 @@ sub ProcessTicketDates {
my $DateObj = RT::Date->new( $session{'CurrentUser'} );
#If it's something other than just whitespace
- if ( $ARGSRef->{ $field . '_Date' } ne '' ) {
+ if ( $ARGSRef->{ $field . '_Date' } && ($ARGSRef->{ $field . '_Date' } ne '') ) {
$DateObj->Set(
Format => 'unknown',
Value => $ARGSRef->{ $field . '_Date' }
@@ -1466,7 +1552,7 @@ sub ProcessTicketLinks {
my (@results) = ProcessRecordLinks(RecordObj => $Ticket,
- ARGSRef => $ARGSRef);
+ ARGSRef => $ARGSRef);
#Merge if we need to
if ( $ARGSRef->{ $Ticket->Id . "-MergeInto" } ) {
@@ -1562,6 +1648,37 @@ sub _UploadedFile {
};
}
+=head2 _load_container_object ( $type, $id );
+
+Instantiate container object for saving searches.
+
+=cut
+
+sub _load_container_object {
+ my ($obj_type, $obj_id) = @_;
+ return RT::SavedSearch->new($session{'CurrentUser'})->_load_privacy_object($obj_type, $obj_id);
+}
+
+=head2 _parse_saved_search ( $arg );
+
+Given a serialization string for saved search, and returns the
+container object and the search id.
+
+=cut
+
+sub _parse_saved_search {
+ my $spec = shift;
+ return unless $spec;
+ if ($spec !~ /^(.*?)-(\d+)-SavedSearch-(\d+)$/ ) {
+ return;
+ }
+ my $obj_type = $1;
+ my $obj_id = $2;
+ my $search_id = $3;
+
+ return (_load_container_object ($obj_type, $obj_id), $search_id);
+}
+
eval "require RT::Interface::Web_Vendor";
die $@ if ($@ && $@ !~ qr{^Can't locate RT/Interface/Web_Vendor.pm});
eval "require RT::Interface::Web_Local";
diff --git a/rt/lib/RT/Interface/Web/Handler.pm b/rt/lib/RT/Interface/Web/Handler.pm
index e41490f8f..1e871ec59 100644
--- a/rt/lib/RT/Interface/Web/Handler.pm
+++ b/rt/lib/RT/Interface/Web/Handler.pm
@@ -2,7 +2,7 @@
#
# COPYRIGHT:
#
-# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC
+# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC
# <jesse@bestpractical.com>
#
# (Except where explicitly superseded by other copyright notices)
@@ -22,7 +22,9 @@
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301 or visit their web page on the internet at
+# http://www.gnu.org/copyleft/gpl.html.
#
#
# CONTRIBUTION SUBMISSION POLICY:
@@ -43,7 +45,6 @@
# those contributions and any derivatives thereof.
#
# END BPS TAGGED BLOCK }}}
-
package RT::Interface::Web::Handler;
use CGI qw/-private_tempfiles/;
@@ -54,7 +55,6 @@ use Time::ParseDate;
use Time::HiRes;
use HTML::Entities;
use HTML::Scrubber;
-use Text::Quoted;
use RT::Interface::Web::Handler;
use File::Path qw( rmtree );
use File::Glob qw( bsd_glob );
@@ -88,16 +88,6 @@ sub new {
$class->InitSessionDir;
if ( $mod_perl::VERSION && $mod_perl::VERSION >= 1.9908 ) {
-# require Apache::RequestUtil;
-# no warnings 'redefine';
-# my $sub = *Apache::request{CODE};
-# *Apache::request = sub {
-# my $r;
-# eval { $r = $sub->('Apache'); };
-#
-# # warn $@ if $@;
-# return $r;
-# };
goto &NewApacheHandler;
}
elsif ($CGI::MOD_PERL) {
@@ -117,12 +107,11 @@ sub InitSessionDir {
# Clean up our umask to protect session files
umask(0077);
- if ($CGI::MOD_PERL and $CGI::MOD_PERL < 1.9908 ) {
+ if ($CGI::MOD_PERL) { local $@; eval {
chown( Apache->server->uid, Apache->server->gid,
$RT::MasonSessionDir )
- if Apache->server->can('uid');
- }
+ }}
# Die if WebSessionDir doesn't exist or we can't write to it
stat($RT::MasonSessionDir);
diff --git a/rt/lib/RT/Interface/Web/QueryBuilder.pm b/rt/lib/RT/Interface/Web/QueryBuilder.pm
index b7526b30a..56c5b038c 100755
--- a/rt/lib/RT/Interface/Web/QueryBuilder.pm
+++ b/rt/lib/RT/Interface/Web/QueryBuilder.pm
@@ -2,7 +2,7 @@
#
# COPYRIGHT:
#
-# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC
+# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC
# <jesse@bestpractical.com>
#
# (Except where explicitly superseded by other copyright notices)
@@ -22,7 +22,9 @@
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301 or visit their web page on the internet at
+# http://www.gnu.org/copyleft/gpl.html.
#
#
# CONTRIBUTION SUBMISSION POLICY:
diff --git a/rt/lib/RT/Interface/Web/QueryBuilder/Tree.pm b/rt/lib/RT/Interface/Web/QueryBuilder/Tree.pm
index 67b728339..467627313 100755
--- a/rt/lib/RT/Interface/Web/QueryBuilder/Tree.pm
+++ b/rt/lib/RT/Interface/Web/QueryBuilder/Tree.pm
@@ -2,7 +2,7 @@
#
# COPYRIGHT:
#
-# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC
+# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC
# <jesse@bestpractical.com>
#
# (Except where explicitly superseded by other copyright notices)
@@ -22,7 +22,9 @@
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301 or visit their web page on the internet at
+# http://www.gnu.org/copyleft/gpl.html.
#
#
# CONTRIBUTION SUBMISSION POLICY:
diff --git a/rt/lib/RT/Interface/Web/Standalone.pm b/rt/lib/RT/Interface/Web/Standalone.pm
index bc2423e6d..319e317b8 100755
--- a/rt/lib/RT/Interface/Web/Standalone.pm
+++ b/rt/lib/RT/Interface/Web/Standalone.pm
@@ -1,3 +1,50 @@
+# BEGIN BPS TAGGED BLOCK {{{
+#
+# COPYRIGHT:
+#
+# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC
+# <jesse@bestpractical.com>
+#
+# (Except where explicitly superseded by other copyright notices)
+#
+#
+# LICENSE:
+#
+# This work is made available to you under the terms of Version 2 of
+# the GNU General Public License. A copy of that license should have
+# been provided with this software, but in any event can be snarfed
+# from www.gnu.org.
+#
+# This work is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301 or visit their web page on the internet at
+# http://www.gnu.org/copyleft/gpl.html.
+#
+#
+# CONTRIBUTION SUBMISSION POLICY:
+#
+# (The following paragraph is not intended to limit the rights granted
+# to you to modify and distribute this software under the terms of
+# the GNU General Public License and is only of importance to you if
+# you choose to contribute your changes and enhancements to the
+# community by submitting them to Best Practical Solutions, LLC.)
+#
+# By intentionally submitting any modifications, corrections or
+# derivatives to this work, or any other work intended for use with
+# Request Tracker, to Best Practical Solutions, LLC, you confirm that
+# you are the copyright holder for those contributions and you grant
+# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
+# royalty-free, perpetual, license to use, copy, create derivative
+# works based on those contributions, and sublicense and distribute
+# those contributions and any derivatives thereof.
+#
+# END BPS TAGGED BLOCK }}}
package RT::Interface::Web::Standalone;
use strict;