AutoRedirectToSelfService

From Request Tracker Wiki
Jump to navigation Jump to search

I created a custom form for my Help Desk, but I needed a way to redirect users to the form without publishing a new web site for RT. Since most users don't need to know about all the tickets in the queue, and can't own tickets, I found a way to redirect them to the Self Service page and added some features to make our lives easier.

In /usr/local/rt3/local/html/index.html add this code to redirect to Self Service if the user can not own a ticket:

73 %# Redirect to !SelfService if the user can not own tickets
74 % my $urefresh = $session{'home_refresh_interval'};
75 % if ( ! $session{'CurrentUser'}->HasRight(Right=>'OwnTicket', Object=>$RT::System) ) {
76 %               $urefresh = '0; URL=' . $RT::WebPath . '/SelfService/index.html';
77 %       }
78
79 %#<& /Elements/Header, Title=>loc("RT at a glance"), Refresh => $session{'home_refresh_interval'} &>
80 <& /Elements/Header, Title=>loc("RT at a glance"), Refresh => $urefresh &>

In /usr/local/rt3/local/html/SelfService/index.html add this code to list the queues and number of tickets in each queue:

48 <TABLE BORDER=0 WIDTH=100%>
49 <TR VALIGN=TOP>
50 <TD WIDTH=70% class="boxcontainer">
51 <& /SelfService/Elements/MyRequests &>
52 <BR>
53 <TD class="boxcontainer">
54 <& /Elements/Quicksearch &>
55 <BR>
56 </TABLE>

My custom Help Desk form is /usr/local/rt3/local/html/SelfService/Create.html and I have this code in there to set the priority of the ticket based on a Drop-Down:

65 <TR>
66 <TD CLASS=label>Priority:</TD>
67 <TD><SELECT NAME="InitialPriority">
68         <OPTION VALUE="10">Low - Minor Annoyance
69         <OPTION VALUE="30">Medium - Affects Daily Work
70         <OPTION VALUE="70">High - Major Disruption
71         <OPTION VALUE="90">Critical - Class Is Halted
72         </SELECT>
73 </TR>

In /usr/local/rt3/local/html/SelfService/Display.html I have this code to set the due date of a ticket based on the priority:

109 # Set the due date for helpdesk que based on initial priority
110 if ($ARGS{'InitialPriority'} and !$ARGS{'Due'}) {
111   my $priority_due = RT::Date->new($session{'CurrentUser'});
112   $priority_due->SetToNow();
113   $priority_due->AddDays( 10 - ( $ARGS{'InitialPriority'} ) / 10 );
114   $ARGS{'Due'} = $priority_due->ISO();
115 }


Comment by RichardF, 23 Aug 07:

In RT v3.6.4, I found that passing anything other than an integer as the Refresh parameter to the Header element didn't result in a redirect being created. Also, to ensure that "semi-privileged" users could not directly access other privileged URLS (eg /User/Prefs.html), I found it easier to simply modify the main autohandler to redirect users who don't have the OwnTicket privilege to the SelfService interface (in the same way that unprivileged users are redirected).

To achieve this, I copied /html/autohandler to /local/html/autohandler, and made the following change to the local copy:

  273 if ( (not $session{'CurrentUser'}->Privileged) ||
->274      (!$session{'CurrentUser'}->HasRight(Right=>'OwnTicket', Object=>$RT::System))
  275    ){