default_escape_flags => 'h',
allow_globals => [qw(%session)],
data_dir => "$RT::MasonDataDir",
- autoflush => 1,
@_
);
],
data_dir => "$RT::MasonDataDir",
default_escape_flags => 'h',
- allow_globals => [qw(%session)],
- autoflush => 1,
+ allow_globals => [qw(%session)]
);
# }}}
-# {{{ WebCanonicalizeInfo
-
-=head2 WebCanonicalizeInfo();
-
-Different web servers set different environmental varibles. This
-function must return something suitable for REMOTE_USER. By default,
-just downcase $ENV{'REMOTE_USER'}
-
-=cut
-
-sub WebCanonicalizeInfo {
- my $user;
-
- if ( defined $ENV{'REMOTE_USER'} ) {
- $user = lc ( $ENV{'REMOTE_USER'} ) if( length($ENV{'REMOTE_USER'}) );
- }
-
- return $user;
-}
-
-# }}}
-
-# {{{ WebExternalAutoInfo
-
-=head2 WebExternalAutoInfo($user);
-
-Returns a hash of user attributes, used when WebExternalAuto is set.
-
-=cut
-
-sub WebExternalAutoInfo {
- my $user = shift;
-
- my %user_info;
-
- $user_info{'Privileged'} = 1;
-
- if ($^O !~ /^(?:riscos|MacOS|MSWin32|dos|os2)$/) {
- # 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;
- }
- elsif ($^O eq 'MSWin32' and eval 'use Net::AdminMisc; 1') {
- # Populate fields with information from NT domain controller
- }
-
- # and return the wad of stuff
- return {%user_info};
-}
-
-# }}}
-
package HTML::Mason::Commands;
use strict;
UNIVERSAL::can($session{'CurrentUser'}, 'loc')){
return($session{'CurrentUser'}->loc(@_));
}
- elsif ( my $u = eval { RT::CurrentUser->new($RT::SystemUser->Id) } ) {
+ else {
+ my $u = RT::CurrentUser->new($RT::SystemUser);
return ($u->loc(@_));
}
- else {
- # pathetic case -- SystemUser is gone.
- return $_[0];
- }
}
# }}}
return($session{'CurrentUser'}->loc_fuzzy($msg));
}
else {
- my $u = RT::CurrentUser->new($RT::SystemUser->Id);
+ my $u = RT::CurrentUser->new($RT::SystemUser);
return ($u->loc_fuzzy($msg));
}
}
);
#Make the update content have no 'weird' newlines in it
- if ( $args{ARGSRef}->{'UpdateContent'} ||
- $args{ARGSRef}->{'UpdateAttachments'}) {
+ if ( $args{ARGSRef}->{'UpdateContent'} ) {
if (
$args{ARGSRef}->{'UpdateSubject'} eq $args{'TicketObj'}->Subject() )
Cc => undef,
Body => undef,
AttachmentFieldName => undef,
-# map Encode::encode_utf8($_), @_,
- @_,
+ map Encode::encode_utf8($_), @_,
);
#Make the update content have no 'weird' newlines in it
Subject => $args{'Subject'} || "",
From => $args{'From'},
Cc => $args{'Cc'},
- Charset => 'utf8',
Data => [ $args{'Body'} ]
);
}
#foreach my $filehandle (@filenames) {
- my ( $fh, $temp_file );
- for ( 1 .. 10 ) {
- # on NFS and NTFS, it is possible that tempfile() conflicts
- # with other processes, causing a race condition. we try to
- # accommodate this by pausing and retrying.
- last if ($fh, $temp_file) = eval { tempfile() };
- sleep 1;
- }
+ my ( $fh, $temp_file ) = tempfile();
binmode $fh; #thank you, windows
my ($buffer);
$Message->attach(
Path => $temp_file,
- Filename => Encode::decode_utf8($filename),
+ Filename => $filename,
Type => $uploadinfo->{'Content-Type'},
);
close($fh);
# }}}
# {{{ Limit requestor email
- if ( $args{ARGS}->{'ValueOfWatcherRole'} ne '' ) {
- $session{'tickets'}->LimitWatcher(
- TYPE => $args{ARGS}->{'WatcherRole'},
- VALUE => $args{ARGS}->{'ValueOfWatcherRole'},
- OPERATOR => $args{ARGS}->{'WatcherRoleOp'},
+ if ( $args{ARGS}->{'ValueOfRequestor'} ne '' ) {
+ my $alias = $session{'tickets'}->LimitRequestor(
+ VALUE => $args{ARGS}->{'ValueOfRequestor'},
+ OPERATOR => $args{ARGS}->{'RequestorOp'},
);
+
}
# }}}
my $obj;
- if ($object_type eq 'RT::System') {
- $obj = $RT::System;
- } elsif ($RT::ACE::OBJECT_TYPES{$object_type}) {
- $obj = $object_type->new($session{'CurrentUser'});
+ if ($object_type eq 'RT::Queue') {
+ $obj = RT::Queue->new($session{'CurrentUser'});
+ $obj->Load($object_id);
+ } elsif ($object_type eq 'RT::Group') {
+ $obj = RT::Group->new($session{'CurrentUser'});
$obj->Load($object_id);
+
+ } elsif ($object_type eq 'RT::System') {
+ $obj = $RT::System;
} else {
- push (@results, loc("System Error"). ': '.
+ push (@results, loc("System Error").
loc("Rights could not be granted for [_1]", $object_type));
next;
}
next unless ($right);
my $obj;
- if ($object_type eq 'RT::System') {
- $obj = $RT::System;
- } elsif ($RT::ACE::OBJECT_TYPES{$object_type}) {
- $obj = $object_type->new($session{'CurrentUser'});
+ if ($object_type eq 'RT::Queue') {
+ $obj = RT::Queue->new($session{'CurrentUser'});
$obj->Load($object_id);
+ } elsif ($object_type eq 'RT::Group') {
+ $obj = RT::Group->new($session{'CurrentUser'});
+ $obj->Load($object_id);
+
+ } elsif ($object_type eq 'RT::System') {
+ $obj = $RT::System;
} else {
- die;
- push (@results, loc("System Error"). ': '.
+ push (@results, loc("System Error").
loc("Rights could not be revoked for [_1]", $object_type));
next;
}
my ( $err, $msg ) = $Object->DeleteValue($id);
push ( @results, $msg );
}
-
- my $vals = $Object->Values();
- while (my $cfv = $vals->Next()) {
- if (my $so = $ARGSRef->{ 'CustomField-' . $Object->Id . '-SortOrder' . $cfv->Id }) {
- if ($cfv->SortOrder != $so) {
- my ( $err, $msg ) = $cfv->SetSortOrder($so);
- push ( @results, $msg );
- }
- }
- }
-
return (@results);
}
# For each of those tickets
foreach my $tick ( keys %custom_fields_to_mod ) {
- my $Ticket = $args{'TicketObj'};
- if (!$Ticket or $Ticket->id != $tick) {
- $Ticket = RT::Ticket->new( $session{'CurrentUser'} );
- $Ticket->Load($tick);
- }
+ my $Ticket = RT::Ticket->new( $session{'CurrentUser'} );
+ $Ticket->Load($tick);
# For each custom field
foreach my $cf ( keys %{ $custom_fields_to_mod{$tick} } ) {
my @values =
( ref( $ARGSRef->{$arg} ) eq 'ARRAY' )
? @{ $ARGSRef->{$arg} }
- : split /\n/, $ARGSRef->{$arg} ;
+ : ( $ARGSRef->{$arg} );
if ( ( $arg =~ /-AddValue$/ ) || ( $arg =~ /-Value$/ ) ) {
foreach my $value (@values) {
- next unless length($value);
+ next unless ($value);
my ( $val, $msg ) = $Ticket->AddCustomFieldValue(
Field => $cf,
Value => $value
}
elsif ( $arg =~ /-DeleteValues$/ ) {
foreach my $value (@values) {
- next unless length($value);
+ next unless ($value);
my ( $val, $msg ) = $Ticket->DeleteCustomFieldValue(
Field => $cf,
Value => $value
my %values_hash;
foreach my $value (@values) {
- next unless length($value);
+ next unless ($value);
# build up a hash of values that the new set has
$values_hash{$value} = 1;