Index: Kernel/Modules/AgentTicketWatchView.pm
===================================================================
--- Kernel/Modules/AgentTicketWatchView.pm	(revision 14)
+++ Kernel/Modules/AgentTicketWatchView.pm	(revision 15)
@@ -118,6 +118,48 @@
                 Permission   => 'ro',
             },
         };
+    # cmeier 20090819: add some filter 
+        $Filters{New} = {
+            Name   => 'New message',
+            Prio   => 1006,
+            Search => {
+                Result     => 'ARRAY',
+                Limit      => 1000,
+                OrderBy    => $OrderBy,
+                SortBy     => $SortByS,
+                WatchUserIDs => [ $Self->{UserID} ],
+                UserID     => 1,
+                Permission => 'ro',
+            },
+        };
+        $Filters{Reminder} = {
+            Name   => 'Pending',
+            Prio   => 1007,
+            Search => {
+                Result     => 'ARRAY',
+                Limit      => 1000,
+                StateType  => [ 'pending reminder', 'pending auto' ],
+                OrderBy    => $OrderBy,
+                SortBy     => $SortByS,
+                WatchUserIDs => [ $Self->{UserID} ],
+                UserID     => 1,
+                Permission => 'ro',
+            },
+        };
+        $Filters{ReminderReached} = {
+            Name   => 'Reminder Reached',
+            Prio   => 1008,
+            Search => {
+                Result     => 'ARRAY',
+                Limit      => 1000,
+                StateType  => [ 'pending reminder', 'pending auto' ],
+                OrderBy    => $OrderBy,
+                SortBy     => $SortByS,
+                WatchUserIDs => [ $Self->{UserID} ],
+                UserID     => 1,
+                Permission => 'ro',
+            },
+        };
     }
 
     # check if filter is valid
@@ -133,29 +175,67 @@
 
     my %NavBarFilter;
     for my $Filter ( keys %Filters ) {
-        my @ViewableTickets = $Self->{TicketObject}->TicketSearch(
+    	# cmeier 20090819: rename for-internal variable ViewableTickets to ViewableTicketsFilter
+        my @ViewableTicketsFilter = $Self->{TicketObject}->TicketSearch(
             %{ $Filters{$Filter}->{Search} },
             Result => 'ARRAY',
             Limit  => 1000,
         );
 
+        # cmeier 20090819: change handling for filter "new" to get new message from all watched tickets not only from locked tickets
         if ( $Filter eq 'New' ) {
             my @ViewableTicketsTmp;
-            my %LockedData = $Self->{TicketObject}->GetLockedCount( UserID => $Self->{UserID} );
+            
+            
+#            my %LockedData = $Self->{TicketObject}->GetLockedCount( UserID => $Self->{UserID} );
+#
+#            # check what tickets are new
+#            for my $TicketID (@ViewableTickets) {
+#                my $Message = '';
+#                if ( $LockedData{NewTicketIDs}->{$TicketID} ) {
+#                    $Message = 'New message!';
+#                    push( @ViewableTicketsTmp, $TicketID );
+#                }
+#            }
+#            @ViewableTickets = @ViewableTicketsTmp;
 
-            # check what tickets are new
-            for my $TicketID (@ViewableTickets) {
-                my $Message = '';
-                if ( $LockedData{NewTicketIDs}->{$TicketID} ) {
-                    $Message = 'New message!';
-                    push( @ViewableTicketsTmp, $TicketID );
-                }
+            
+            foreach my $TicketID (@ViewableTicketsFilter)
+            {
+				my $Message = '';
+				
+				# put all tickets to ToDo where last sender type is customer / system or ! UserID
+				# show just unseen tickets as new
+				if ($Self->{ConfigObject}->Get('Ticket::NewMessageMode') eq 'ArticleSeen')
+				{
+				    my @Index = $Self->{TicketObject}->ArticleIndex(TicketID => $TicketID);
+				    if (@Index)
+				    {
+				        my %Article = $Self->{TicketObject}->ArticleGet(ArticleID => $Index[$#Index]);
+				        my %Flag = $Self->{TicketObject}->ArticleFlagGet(
+				            ArticleID => $Article{ArticleID},
+				            UserID => $Self->{UserID},
+				        );
+				        if (!$Flag{seen})
+				        {
+				            $Message = 'New message!';
+				            push( @ViewableTicketsTmp, $TicketID );
+				        }
+				    }
+				}
             }
-            @ViewableTickets = @ViewableTicketsTmp;
+            @ViewableTicketsFilter = @ViewableTicketsTmp;
+            
+            if ($Self->{Filter} eq $Filter)
+            {
+            	@ViewableTickets = @ViewableTicketsTmp;
+            }
+            
+            
         }
         elsif ( $Filter eq 'ReminderReached' ) {
             my @ViewableTicketsTmp;
-            for my $TicketID (@ViewableTickets) {
+            for my $TicketID (@ViewableTicketsFilter) {
                 my @Index = $Self->{TicketObject}->ArticleIndex( TicketID => $TicketID );
                 if (@Index) {
                     my %Article = $Self->{TicketObject}->ArticleGet( ArticleID => $Index[-1] );
@@ -164,11 +244,18 @@
                     }
                 }
             }
-            @ViewableTickets = @ViewableTicketsTmp;
+            # cmeier 20090918: copy filtered ids to main-id-array
+#            @ViewableTickets = @ViewableTicketsTmp;
+			@ViewableTicketsFilter = @ViewableTicketsTmp;
+            
+            if ($Self->{Filter} eq $Filter)
+            {
+            	@ViewableTickets = @ViewableTicketsTmp;
+            }
         }
 
         $NavBarFilter{ $Filters{$Filter}->{Prio} } = {
-            Count  => scalar @ViewableTickets,
+            Count  => scalar @ViewableTicketsFilter,
             Filter => $Filter,
             %{ $Filters{$Filter} },
         };
