[rt-users] Custom Display.html and Select Status woes

Seth Cohn, EFN General Manager gm at efn.org
Tue Jan 7 16:18:34 EST 2003


I'm making Display show a EditBasics and EditPeople box, which involved
stealing much from ModifyAll.html and adding back in Display.html parts to
properly work with Create.html. Most of our initial responses require
changing Subject, Status, Queue, or Owner/Requestor/etc, so it makes sense
to include 2 boxes on the plain Display page to speed up responding.

A few bugs:

1) I'm getting a Duplicate submission message even though it submits fine.
Any suggestions to fix this?

2) The EditBasic conflicts with the OpenTicket addon for 'new' tickets,
when Editbasic's status default to new, and then it processes the page:
the status goes Open because of the transaction, then goes back to New
because of processing the 'new' selection.  Patching EditBasics to not
allow a default 'new' selection status but change that to 'open' would fix
the problem.

But I can't figure out what to replace this in EditBasic to do that.

my $SelectStatus = $m->scomp("/Elements/SelectStatus", Name =>
'Status', Default=>$TicketObj->Status);

Help?

My new Display.html is enclosed (not diffed, since it's a mix of Display
and ModifyAll)

-------------- next part --------------
<& /Elements/Header, Title => "Ticket #".$Ticket->Id ." ".$Ticket->Subject &>

<& /Ticket/Elements/Tabs, Ticket => $Ticket , current_tab =>
"Ticket/Display.html?id=".$Ticket->Id &>

<& /Elements/ListActions, actions => \@results &>

<& /Ticket/Elements/ShowSummary,  Ticket => $Ticket &>

<FORM METHOD=POST ACTION="Display.html" ENCTYPE="multipart/form-data">
<INPUT TYPE=HIDDEN NAME=id VALUE="<%$Ticket->Id%>">

<& /Ticket/Elements/ShowHistory , Ticket => $Ticket, ShowHeaders =>
$ARGS{'ShowHeaders'}, URIFile => 'History.html' &>


<& /Elements/TitleBoxStart, title => 'Ticket #'.$Ticket->Id,   color=>
"#993333", width => "100%" &>
<& Elements/EditBasics, TicketObj => $Ticket &>
<& /Elements/TitleBoxEnd &>

<BR>

<& /Elements/TitleBoxStart, title => 'People',width => "100%", color=> "#333399
" &>
<& Elements/EditPeople, Ticket => $Ticket, UserField => $UserField, UserString
=> $UserString, UserOp => $UserOp &>
<& /Elements/TitleBoxEnd &>

<BR>

<& /Elements/Submit, Label => 'Save Changes', Caption => "If you've updated any
thing above, be sure to", color => "#333399" &>


</form>

<%INIT>


  my ($linkid, $message, $tid, $Ticket, @Actions);
  my (@wresults, @results, @okresults, @dresults, @lresults);

        my $CanRespond = 0;
        my $CanComment = 0;


$Ticket = new RT::Ticket($session{'CurrentUser'});

unless ($id) {
    Abort('No ticket specified');
}

if ($ARGS{'id'} eq 'new') {
    # {{{ Create a new ticket

    my $Queue = new RT::Queue($session{'CurrentUser'});
    unless ($Queue->Load($ARGS{'Queue'})) {
        Abort('Queue not found');
    }

    unless ($Queue->CurrentUserHasRight('CreateTicket')) {
        Abort('You have no permission to create tickets in that queue.');
    }

    my $due = new RT::Date($session{'CurrentUser'});
    $due->Set(Format => 'unknown', Value => $ARGS{'Due'});
    my $starts = new RT::Date($session{'CurrentUser'});
    $starts->Set(Format => 'unknown', Value => $ARGS{'Starts'});


    my @Requestors = split(/,/,$ARGS{'Requestors'});
    my @Cc = split(/,/,$ARGS{'Cc'});
    my @AdminCc = split(/,/,$ARGS{'AdminCc'});

    my $MIMEObj = MakeMIMEEntity( Subject => $ARGS{'Subject'},
                                  From => $ARGS{'From'},
                                  Cc => $ARGS{'Cc'},
                                  Body => $ARGS{'Content'},
                                  AttachmentFieldName => 'Attach');

                                
    my %create_args = (
                       Queue=>$ARGS{Queue},
                       Owner=>$ARGS{ValueOfOwner},
                       InitialPriority=> $ARGS{InitialPriority},
                       FinalPriority=> $ARGS{FinalPriority},
                       TimeLeft => $ARGS{TimeLeft},
                       TimeWorked => $ARGS{TimeWorked},
                       Requestor=> \@Requestors,
                       Cc => \@Cc,
                       AdminCc => \@AdminCc,
                       Subject=>$ARGS{Subject},
                       Status=>$ARGS{Status},
                       Due => $due->ISO,
                       Starts => $starts->ISO,
                       MIMEObj => $MIMEObj
                      );


    # we need to get any KeywordSelect-<integer> fields into %create_args..
    grep { $_ =~ /^KeywordSelect-/ && {$create_args{$_} = $ARGS{$_}}} %ARGS;

    my ($id, $Trans, $ErrMsg)= $Ticket->Create(%create_args);
    unless ($id && $Trans) {
        Abort($ErrMsg);
    }
    my @linktypes = qw( DependsOn MemberOf RefersTo );

    foreach my $linktype (@linktypes) {
      foreach my $luri (split (/ /,$ARGS{"new-$linktype"})) {
        $luri =~ s/\s*$//; # Strip trailing whitespace
        my ($val, $msg) = $Ticket->AddLink( Target => $luri,
                                            Type => $linktype);
        push @Actions, $msg;
      }

      foreach my $luri (split (/ /,$ARGS{"$linktype-new"})) {
        my ($val, $msg) = $Ticket->AddLink( Base => $luri,
                                            Type => $linktype);
        
        push @Actions, $msg;
      }
    }
    # don't try to change queue to the current queue
    delete $ARGS{'Queue'};

    push(@Actions, $ErrMsg);
    unless ($Ticket->CurrentUserHasRight('ShowTicket')) {
      Abort("No permission to view newly created ticket #".$Ticket->id.".");
    }
    # }}}
}

else {
    $Ticket = LoadTicket($ARGS{'id'});
    unless ($Ticket->CurrentUserHasRight('ShowTicket')) {
        Abort("No permission to view ticket");
    }

$CanRespond = 1 if ( $Ticket->CurrentUserHasRight('ReplyToTicket') or
                     $Ticket->CurrentUserHasRight('ModifyTicket') );

$CanComment = 1 if ( $Ticket->CurrentUserHasRight('CommentOnTicket') or
                     $Ticket->CurrentUserHasRight('ModifyTicket') );



if (defined $ARGS{'Action'}) {
  if ($ARGS{'Action'} =~ /^(Steal|Kill|Take|SetTold)$/) {
    my $action = $1;
    my ($res, $msg)=$Ticket->$action();
    push(@Actions, $msg);
  }
}
    $ARGS{'UpdateContent'} =~ s/\r\n/\n/g;

    if ($ARGS{'UpdateContent'} &&
        $ARGS{'UpdateContent'} ne '' &&
        $ARGS{'UpdateContent'} ne  "-- \n" .
                                $session{'CurrentUser'}->UserObj->Signature
       ) {
            ProcessUpdateMessage(ARGSRef=>\%ARGS,
                                 Actions=>\@Actions,
                                 TicketObj=>$Ticket);
        }
#Process status updates
my @BasicActions = ProcessTicketBasics(ARGSRef => \%ARGS, TicketObj=>$Ticket);

push (@Actions, @BasicActions);
}

unless ($OnlySearchForPeople) {
    @wresults = ProcessTicketWatchers( TicketObj => $Ticket, ARGSRef => \%ARGS)
;
    @results = ProcessTicketBasics( TicketObj => $Ticket, ARGSRef => \%ARGS);
    @okresults = ProcessTicketObjectKeywords(TicketObj => $Ticket, ARGSRef => \
%ARGS);

    @dresults = ProcessTicketDates( TicketObj => $Ticket, ARGSRef => \%ARGS);
    @lresults = ProcessTicketLinks( TicketObj => $Ticket, ARGSRef => \%ARGS);

    $ARGS{'UpdateContent'} =~ s/\r\n/\n/g;

    if ($ARGS{'UpdateContent'} &&
        $ARGS{'UpdateContent'} ne '' &&
        $ARGS{'UpdateContent'} ne  "-- \n" .
                                $session{'CurrentUser'}->UserObj->Signature
       ) {
         ProcessUpdateMessage(TicketObj => $Ticket,
                              ARGSRef=>\%ARGS,
                              Actions=>\@results);
        }
}
push @results, @wresults;
push @results, @dresults;
push @results, @lresults;
push @results, @okresults;

# If they've gone and moved the ticket to somewhere they can't see, etc...
# TODO: display the results, even if we can't display the ticket.

unless ($Ticket->CurrentUserHasRight('ShowTicket')) {
   Abort("No permission to view ticket");
}


</%INIT>



<%ARGS>
$id => undef
$Create => undef
$ShowHeaders => undef
$Collapsed => undef
$OnlySearchForPeople => undef
$UserField => undef
$UserOp => undef
$UserString => undef
</%ARGS>







More information about the rt-users mailing list