[Rt-commit] r7646 - in rtir/branches/2.3-EXPERIMENTAL: . docs t
jesse at bestpractical.com
jesse at bestpractical.com
Mon Apr 23 15:44:46 EDT 2007
Author: jesse
Date: Mon Apr 23 15:44:42 2007
New Revision: 7646
Modified:
rtir/branches/2.3-EXPERIMENTAL/ (props changed)
rtir/branches/2.3-EXPERIMENTAL/docs/Constituencies.pod
rtir/branches/2.3-EXPERIMENTAL/lib/RT/IR.pm
rtir/branches/2.3-EXPERIMENTAL/t/014-custom-field-constituency.t
Log:
r55976 at pinglin: jesse | 2007-04-23 15:42:02 -0400
* Added support for displaying the correct corresopndaddress or commentaddress based on a ticket's constituency.
Modified: rtir/branches/2.3-EXPERIMENTAL/docs/Constituencies.pod
==============================================================================
--- rtir/branches/2.3-EXPERIMENTAL/docs/Constituencies.pod (original)
+++ rtir/branches/2.3-EXPERIMENTAL/docs/Constituencies.pod Mon Apr 23 15:44:42 2007
@@ -49,14 +49,34 @@
=head2 ACLs
-To implement requirement D.3.5.2 we've associated one group with each value of
-the constituency field. Name of a group should match 'DutyTeam <constituency>'.
-When people define or change value of a ticket we add a group to the ticket's
-AdminCc role, so all people in the group inherit rights granted to AdminCc role.
-You can control list of rights through the web interface. Open page RT ->
-Configuration -> Queues -> select a RTIR queue -> Group Rights, change
-rights of the AdminCc role to control access of the constituency groups.
-You can also control access of other groups to the queue.
+RTIR allows you to grant additional rights to tickets based on their
+constituency by means of "pseudo" queues.
+
+For example, assume you have two constituencies "EDUNET" and "GOVNET".
+Your RTIR instance consists of four queues: Incident Reports,
+Incidents, Investigations and Blocks. To grant the user "Edward"
+the right to work with EDUNET Incident Reports, you'll need to
+create a new queue, "Incident Reports - EDUNET". Make "Edward" an
+AdminCc of the new queue, either directly or as a member of a group
+like "DutyTeam - EDUNET".
+
+You should grant that user or group the rights you want them to
+have to tickets in the "Incident Reports" queue. It is important
+that you NOT grant the user or group "queue-wide" rights sunch as
+"See Queue" or "Create Ticket" in the pseudo-queue as the system
+will apply those rights to the pseudo-queue "Incident Reports -
+EUDNET" and NOT to the "Incident Reports" queue.
+
+=head2 Outgoing mail: "CorrespondAddress" and "CommentAddress"
+
+If you create queues as described in the ACL section, their
+correspondence and comment addresses will override the original
+queue's where possible.
+
+
+
+It is important to note that these additional rights do NOT also add new mailing rules.
+
=head2 Presetting constituency according to mail traffic
Modified: rtir/branches/2.3-EXPERIMENTAL/lib/RT/IR.pm
==============================================================================
--- rtir/branches/2.3-EXPERIMENTAL/lib/RT/IR.pm (original)
+++ rtir/branches/2.3-EXPERIMENTAL/lib/RT/IR.pm Mon Apr 23 15:44:42 2007
@@ -338,12 +338,25 @@
# if (0) {
{
+ require RT::Record;
+ wrap 'RT::Record::_AddCustomFieldValue', pre => sub {
+ return unless( UNIVERSAL::isa($_[0] => 'RT::Ticket'));
+ $RT::IR::ConstituencyCache->{$_[0]->id} = undef;
+
+ };
+
require RT::Ticket;
wrap 'RT::Ticket::ACLEquivalenceObjects', pre => sub {
my $self = shift;
- return if ( $self->CurrentUser->id == $RT::SystemUser->id );
- my $queue = $self->QueueObj;
+ my $queue = RT::Queue->new($RT::SystemUser);
+ $queue->Load($self->__Value('Queue'));
+
+ # We do this, rather than fall through to the orignal sub, as that interacts poorly with our overloaded QueueObj below
+ if ( $self->CurrentUser->id == $RT::SystemUser->id ) {
+ $_[-1] = [$queue];
+ return;
+ }
if ( UNIVERSAL::isa( $self, 'RT::Ticket' ) ) {
if (not defined $RT::IR::ConstituencyCache->{ $self->id }) {
my $systicket = RT::Ticket->new($RT::SystemUser);
@@ -357,7 +370,7 @@
return unless ( $new_queue->id );
$self->{_constituency_queue} = $new_queue;
}
- $_[-1] = ($queue, $self->{_constituency_queue});
+ $_[-1] = [$queue, $self->{_constituency_queue}];
} else {
use YAML;
$RT::Logger->crit( "$self is not a ticket object like I expected"
@@ -365,6 +378,49 @@
}
};
}
+
+
+{
+ wrap 'RT::Ticket::QueueObj', pre => sub {
+ my $queue = RT::Queue->new($_[0]->CurrentUser);
+ $queue->Load($_[0]->__Value('Queue'));
+ $queue->{'_for_ticket'} = $_[0]->id;
+ $_[-1] = $queue;
+ return;
+ };
+
+ {
+ package RT::Queue;
+
+ sub CorrespondAddress { GetQueueAttribute(shift, 'CorrespondAddress') }
+ sub CommentAddress { GetQueueAttribute(shift, 'CommentAddress') }
+
+ sub GetQueueAttribute {
+ my $queue = shift;
+ my $attr = shift;
+
+ if ( ( my $id = $queue->{'_for_ticket'} ) ) {
+ my $const = $RT::IR::ConstituencyCache->{$id};
+ unless ($const) {
+ my $ticket = RT::Ticket->new($RT::SystemUser);
+ $ticket->Load($id);
+ $const = $ticket->FirstCustomFieldValue('_RTIR_Constituency');
+ }
+ if ($const) {
+ my $new_queue = RT::Queue->new($RT::SystemUser);
+ $new_queue->LoadByCols(
+ Name => $queue->Name . " - " . $const );
+ if ( $new_queue->id ) {
+ return $new_queue->_Value($attr);
+ }
+ }
+ }
+ return $queue->_Value($attr);
+ }
+}
+}
+
+
#
eval "require RT::IR_Vendor";
die $@ if ($@ && $@ !~ qr{^Can't locate RT/IR_Vendor.pm});
Modified: rtir/branches/2.3-EXPERIMENTAL/t/014-custom-field-constituency.t
==============================================================================
--- rtir/branches/2.3-EXPERIMENTAL/t/014-custom-field-constituency.t (original)
+++ rtir/branches/2.3-EXPERIMENTAL/t/014-custom-field-constituency.t Mon Apr 23 15:44:42 2007
@@ -233,15 +233,14 @@
is( $ticket->FirstCustomFieldValue('_RTIR_Constituency'), 'GOVNET', 'correct value' );
}
-diag "Grant govhandler the right to see tickets in Incident Reports - GOVNET"
- if $ENV{'TEST_VERBOSE'};
-diag "Grant eduhandler the right to see tickets in Incident Reports - EDUNET"
- if $ENV{'TEST_VERBOSE'};
-diag "Create an incident report with a default constituency of EDUNET"
- if $ENV{'TEST_VERBOSE'};
+diag "Grant govhandler the right to see tickets in Incident Reports - GOVNET" if $ENV{'TEST_VERBOSE'};
+diag "Grant eduhandler the right to see tickets in Incident Reports - EDUNET" if $ENV{'TEST_VERBOSE'};
+diag "Create an incident report with a default constituency of EDUNET" if $ENV{'TEST_VERBOSE'};
+diag "autoreply comes from the EDUNET queue address" if $ENV{'TEST_VERBOSE'};
diag "govhandler can't see the incident report" if $ENV{'TEST_VERBOSE'};
diag "eduhandler can see the incident report" if $ENV{'TEST_VERBOSE'};
diag "move the incident report from EDUNET to GOVNET" if $ENV{'TEST_VERBOSE'};
diag "govhandler can see the incident report" if $ENV{'TEST_VERBOSE'};
diag "eduhandler can't see the incident report" if $ENV{'TEST_VERBOSE'};
-
+diag "govhandler replies to the incident report" if $ENV{'TEST_VERBOSE'};
+diag "reply comes from the GOVNET queue address" if $ENV{'TEST_VERBOSE'};
More information about the Rt-commit
mailing list