[rt-users] see others tickets

Richard Pijnenburg Richard at widexs.nl
Thu Nov 4 04:37:42 EDT 2010


Wouldn't it be easier if you could create a group per customer and let all the users in that group see the tickets from each other?
Of course there are different approaches possible to the same issue :-)


Met vriendelijke groet / With kind regards,

Richard Pijnenburg 

-----Original Message-----
From: rt-users-bounces at lists.bestpractical.com [mailto:rt-users-bounces at lists.bestpractical.com] On Behalf Of Václav Ovsík
Sent: Thursday, November 04, 2010 9:23 AM
To: rt-users at lists.bestpractical.com
Subject: Re: [rt-users] see others tickets

On Thu, Nov 04, 2010 at 12:22:11AM +0100, Josef wrote:
> 
>  Thank you very much,
>     I have copied these files into my
> /usr/share/request-tracker3.6/html/SelfService/, but I'm having this

			^^^^^^^^
I forgot to mention files from the tarball should be extracted into
installation directory of RT 3.8.8. So you should end with:

local/html/SelfService
local/html/SelfService/QueueTickets.html
local/html/SelfService/Elements
local/html/SelfService/Elements/Tickets
local/html/SelfService/Elements/Tabs

in the directory where you install RT version 3.8.8.

The reasons for creating this SelfService extension was, that we don't
want to give customers full UI. We only want the customer can view
tickets for his company. We have groups of users with permissions to
view corresponding queues.

This code should replace old extension GroupService that exist in the
past for RT 2.x after we move to latest RT.

I wrote the code using loc(), so full localisation is possible and I did
it for Czech language. Menu option "Queue tickets" is not shown in the
case the user has no permission to view tickets in any queue.

Can someone review the changes to include this into share/html upstream?




 * SelfService/Elements/Tabs
   modification of original file

--- share/html/SelfService/Elements/Tabs	2010-05-10 15:36:53.000000000 +0200
+++ local/html/SelfService/Elements/Tabs	2010-07-01 15:07:01.000000000 +0200
@@ -58,14 +58,21 @@
 my $queues = RT::Queues->new($session{'CurrentUser'});
 $queues->UnLimit;
 
-my $queue_count = 0;
-my $queue_id = 1;
+my $queue_create_count = 0;
+my $queue_create_id = 1;
+my $queue_show_count = 0;
+my $queue_show_id = 1;
 
 while (my $queue = $queues->Next) {
-  next unless $queue->CurrentUserHasRight('CreateTicket');
-  $queue_id = $queue->id;
-  $queue_count++;
-  last if ($queue_count > 1);
+	if ( $queue->CurrentUserHasRight('CreateTicket') ) {
+		$queue_create_id = $queue->id;
+		$queue_create_count++;
+	}
+	if ( $queue->CurrentUserHasRight('ShowTicket') ) {
+		$queue_show_id = $queue->id;
+		$queue_show_count++;
+	}
+	last if $queue_create_count > 1 && $queue_show_count > 1;
 }
 
 if ($Title) {
@@ -83,13 +90,19 @@
                        },
            };
 
-if ($queue_count > 1) {
+if ($queue_show_count) {
+	$tabs->{B2} = { title => loc('Queue tickets'),
+		       path => 'SelfService/QueueTickets.html'
+		       };
+}
+
+if ($queue_create_count > 1) {
         $tabs->{C} = { title => loc('New ticket'),
                        path => 'SelfService/CreateTicketInQueue.html'
                        };
 } else {
         $tabs->{C} = { title => loc('New ticket'),
-                       path => 'SelfService/Create.html?Queue=' . $queue_id
+                       path => 'SelfService/Create.html?Queue=' . $queue_create_id
                        };
 }
 



 * SelfService/Elements/Tickets
   is modification of SelfService/Elements/MyRequests

--- share/html/SelfService/Elements/MyRequests	2010-05-10 15:36:53.000000000 +0200
+++ local/html/SelfService/Elements/Tickets	2010-07-08 12:13:04.000000000 +0200
@@ -45,41 +45,65 @@
 %# those contributions and any derivatives thereof.
 %# 
 %# END BPS TAGGED BLOCK }}}
+<%once>
+#my $Format = RT->Config->Get('DefaultSelfServiceSearchResultFormat');
+my $Format = qq{
+   '<B><A HREF="__WebPath__/SelfService/Display.html?id=__id__">__id__</a></B>/TITLE:#',
+   QueueName,
+   '<B><A HREF="__WebPath__/SelfService/Display.html?id=__id__">__Subject__</a></B>/TITLE:Subject',
+   Status,
+   Requestors,
+   OwnerName};
+</%once>
 <&| /Widgets/TitleBox, title =>  $title &>
 <& /Elements/CollectionList, Title   => $title,
 			 Format  => $Format, 
 			 Query   => $Query, 
-			 Order   => @Order, 
-			 OrderBy => @OrderBy,
+			 Order   => [@Order],
+			 OrderBy => [@OrderBy],
 			 BaseURL => $BaseURL,
-			 GenericQueryArgs => $GenericQueryArgs,
-			 AllowSorting => $AllowSorting,
-			 Class   => 'RT::Tickets',
-             Rows    => $Rows,
-			 Page    => $Page &>
+			 AllowSorting	=> $AllowSorting,
+			 Class		=> 'RT::Tickets',
+			 Rows		=> $Rows,
+			 Page		=> $Page,
+			 queue		=> [@queue],
+			 status		=> [@status],
+			 PassArguments	=> [qw(Page Order OrderBy queue status)],
+&>
+
 </&>
 
 <%INIT>
 my $id = $session{'CurrentUser'}->id;
+
+ at queue = grep($_, @queue);
+
+unless ( @queue ) {
+    my $queues = RT::Queues->new($session{'CurrentUser'});
+    $queues->UnLimit;
+    while (my $queue = $queues->Next) {
+	push @queue, $queue->id
+		if $queue->CurrentUserHasRight('ShowTicket');
+    }
+}
+
 my $Query = "( "
-    . join( ' OR ', map "$_.id = $id", @roles )
+    . join( ' OR ', map "Queue.id = $_", @queue )
     . ")";
 if ( @status ) {
     $Query .= " AND ( "
         . join( ' OR ', map "Status = '$_'", @status )
         . " )";
 }
-my $Format = RT->Config->Get('DefaultSelfServiceSearchResultFormat');
 
 </%INIT>
 <%ARGS>
 $friendly_status => loc('open')
-$title => loc("My [_1] tickets", $friendly_status)
- at roles => ('Watcher')
+$title => loc("All [_1] tickets", $friendly_status)
 @status => RT::Queue->ActiveStatusArray()
+ at queue => undef
 $BaseURL => undef
 $Page => 1
-$GenericQueryArgs => undef
 $AllowSorting => 1
 @Order => ('ASC')
 @OrderBy => ('Created')



 * SelfService/QueueTickets.html
   is a new component


Regards
-- 
Zito



More information about the rt-users mailing list