NewTicketsAlert

From Request Tracker Wiki
Revision as of 15:15, 6 April 2016 by Admin (talk | contribs) (1 revision imported)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This callback adds a conspicuous message on the top of the "My RT" page which displays a list of new tickets assigned to the current user. It also adds a count of the user's new tickets in the page title, ie. "My RT (2)".

Place this in Callbacks/NewTicketsAlert/Elements/MyRT/BeforeTable :

% if ($count > 0) {
 <div class="results">
 <script type="text/javascript">document.title += " (<%$count%>)"</script>
 <&|/Widgets/TitleBox, title => $title &>
 <ul>
 % while (my $ticket = $tickets->Next) {
 <li><a href="/Ticket/Display.html?id=<%$ticket->Id%>">#<%$ticket->Id%>: <%$ticket->Subject%></a></li>
 % }
 </ul>
 </&>
 </div>
 % }
 <%INIT>
 my $tickets = RT::Tickets->new( $session{'CurrentUser'} );
 $tickets->LimitOwner( VALUE => $session{'CurrentUser'}->Id );
 $tickets->LimitStatus( VALUE => 'new' );
 my $count = $tickets->CountAll();
 my $title;
 if ($count == 1) {
   $title = "You have a new ticket";
 } else {
   $title = "You have ${count} new tickets";
 }
 </%INIT>