hide the notify-tickets widget if there are no tickets, or if the user turns it off...
authorMark Wells <mark@freeside.biz>
Wed, 23 Nov 2016 23:00:20 +0000 (15:00 -0800)
committerMark Wells <mark@freeside.biz>
Wed, 23 Nov 2016 23:14:12 +0000 (15:14 -0800)
httemplate/elements/notify-tickets.html
httemplate/pref/pref-process.html
httemplate/pref/pref.html

index e661737..16a04f4 100644 (file)
 use Class::Load 'load_class';
 
 my $enabled = $FS::TicketSystem::system eq 'RT_Internal';
+$enabled = 0 if $FS::CurrentUser::CurrentUser->option('hide_notify_tickets');
 my $UnrepliedTickets;
 if ($enabled) {
   my $class = 'RT::Search::UnrepliedTickets';
   load_class($class);
   my $session = FS::TicketSystem->session;
   my $CurrentUser = $session->{CurrentUser};
+  # if there are no tickets the current user could see, always hide it
+  my $AnyTickets = RT::Tickets->new($CurrentUser);
+  foreach my $status (qw(resolved rejected deleted)) {
+    $AnyTickets->LimitStatus( OPERATOR => '!=', VALUE => $status );
+  }
+  $enabled = 0 if $AnyTickets->Count == 0;
+
   $UnrepliedTickets = RT::Tickets->new($CurrentUser);
   my $search = $class->new(TicketsObj => $UnrepliedTickets);
   $search->Prepare;
index f5b5bb6..0134e6a 100644 (file)
@@ -56,6 +56,7 @@ unless ( $error ) { # if ($access_user) {
                       enable_mask_clipboard_hack dashboard_customers
                       customer_view_emails
                       printtofit
+                      hide_notify_tickets
                       email_address
                       snom-ip snom-username snom-password
                       vonage-fromnumber vonage-username vonage-password
index a6b5ba7..f6ad36a 100644 (file)
@@ -150,7 +150,14 @@ Interface
   </TR>
 
   <TR>
-    <TH ALIGN="right">How many recently-modified customers displayed on dashboard</TH>
+    <TH ALIGN="right"><% emt('Hide notification of new ticket activity') %></TH>
+    <TD ALIGN="left">
+      <INPUT TYPE="checkbox" NAME="hide_notify_tickets" VALUE="1" <% $curuser->option('hide_notify_tickets') ? 'CHECKED' : '' %>>
+    </TD>
+  </TR>
+
+  <TR>
+    <TH ALIGN="right"><% emt("How many recently-modified customers displayed on dashboard") %></TH>
     <TD ALIGN="left" COLSPAN=2>
       <INPUT TYPE="text" NAME="dashboard_customers" VALUE="<% $curuser->option('dashboard_customers') %>"></TD>
     </TD>