Difference between revisions of "NewTicketsAlert"

From Request Tracker Wiki
Jump to navigation Jump to search
m (1 revision imported)
 
(Code formatting cleanup)
 
Line 3: Line 3:
Place this in '''Callbacks/NewTicketsAlert/Elements/MyRT/BeforeTable''' :
Place this in '''Callbacks/NewTicketsAlert/Elements/MyRT/BeforeTable''' :


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

Latest revision as of 12:24, 25 August 2017

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) {
   
   <&|/Widgets/TitleBox, title => $title &>
   
   % }
   <%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";
   }