This commit was generated by cvs2svn to compensate for changes in r4407,
[freeside.git] / rt / lib / RT / Interface / Web.pm
index 8d66239..5097f54 100644 (file)
@@ -68,7 +68,6 @@ sub NewApacheHandler {
         default_escape_flags => 'h',
         allow_globals        => [qw(%session)],
         data_dir => "$RT::MasonDataDir",
-        autoflush => 1,
         @_
     );
 
@@ -99,8 +98,7 @@ sub NewCGIHandler {
         ],
         data_dir => "$RT::MasonDataDir",
         default_escape_flags => 'h',
-        allow_globals        => [qw(%session)],
-        autoflush => 1,
+        allow_globals        => [qw(%session)]
     );
   
 
@@ -139,60 +137,6 @@ sub EscapeUTF8  {
 
 # }}}
 
-# {{{ 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;
@@ -216,13 +160,10 @@ sub loc {
         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];
-    }
 }
 
 # }}}
@@ -248,7 +189,7 @@ sub loc_fuzzy {
         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));
     }
 }
@@ -424,8 +365,7 @@ sub ProcessUpdateMessage {
     );
 
     #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() )
@@ -493,8 +433,7 @@ sub MakeMIMEEntity {
         Cc                  => undef,
         Body                => undef,
         AttachmentFieldName => undef,
-#        map Encode::encode_utf8($_), @_,
-        @_,
+        map Encode::encode_utf8($_), @_,
     );
 
     #Make the update content have no 'weird' newlines in it
@@ -510,7 +449,6 @@ sub MakeMIMEEntity {
             Subject => $args{'Subject'} || "",
             From    => $args{'From'},
             Cc      => $args{'Cc'},
-            Charset => 'utf8',
             Data    => [ $args{'Body'} ]
         );
     }
@@ -525,14 +463,7 @@ sub MakeMIMEEntity {
 
     #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);
@@ -550,7 +481,7 @@ sub MakeMIMEEntity {
 
     $Message->attach(
         Path     => $temp_file,
-        Filename => Encode::decode_utf8($filename),
+        Filename => $filename,
         Type     => $uploadinfo->{'Content-Type'},
     );
     close($fh);
@@ -663,13 +594,13 @@ sub ProcessSearchQuery {
 
     # }}}
     # {{{ 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'},
         );
+
     }
 
     # }}}
@@ -849,13 +780,17 @@ sub ProcessACLChanges {
 
             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;
             }
@@ -878,14 +813,17 @@ sub ProcessACLChanges {
             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;
             }
@@ -1015,17 +953,6 @@ sub ProcessCustomFieldUpdates {
         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);
 }
 
@@ -1123,11 +1050,8 @@ sub ProcessTicketCustomFieldUpdates {
 
     # 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} } ) {
@@ -1150,10 +1074,10 @@ sub ProcessTicketCustomFieldUpdates {
                 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
@@ -1163,7 +1087,7 @@ sub ProcessTicketCustomFieldUpdates {
                 }
                 elsif ( $arg =~ /-DeleteValues$/ ) {
                     foreach my $value (@values) {
-                        next unless length($value);
+                        next unless ($value);
                         my ( $val, $msg ) = $Ticket->DeleteCustomFieldValue(
                             Field => $cf,
                             Value => $value
@@ -1176,7 +1100,7 @@ sub ProcessTicketCustomFieldUpdates {
 
                     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;