[Rt-commit] r10001 - in rtir/branches/2.3-EXPERIMENTAL: html/RTIR
ruz at bestpractical.com
ruz at bestpractical.com
Tue Dec 18 21:21:36 EST 2007
Author: ruz
Date: Tue Dec 18 21:21:32 2007
New Revision: 10001
Modified:
rtir/branches/2.3-EXPERIMENTAL/html/RTIR/Create.html
rtir/branches/2.3-EXPERIMENTAL/lib/RT/IR.pm
Log:
* select default constituency using user's rights
Modified: rtir/branches/2.3-EXPERIMENTAL/html/RTIR/Create.html
==============================================================================
--- rtir/branches/2.3-EXPERIMENTAL/html/RTIR/Create.html (original)
+++ rtir/branches/2.3-EXPERIMENTAL/html/RTIR/Create.html Tue Dec 18 21:21:32 2007
@@ -150,6 +150,7 @@
% if ( !$Incident || RT->Config->Get('_RTIR_Constituency_Propagation') eq 'no' ) {
% my $default;
% $default = $IncidentObj->FirstCustomFieldValue('_RTIR_Constituency') if $Incident;
+% $default ||= RT::IR::DefaultConstituency( $QueueObj );
% $default ||= scalar RT->Config->Get('_RTIR_Constituency_default');
<& /RTIR/Elements/EditRTIRField,
QueueObj => $QueueObj,
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 Tue Dec 18 21:21:32 2007
@@ -214,6 +214,23 @@
}
}
+sub DefaultConstituency {
+ my $queue = shift;
+ my $name = $queue->Name;
+
+ my @values;
+
+ my $queues = RT::Queues->new( $queue->CurrentUser );
+ $queues->Limit( FIELD => 'Name', OPERATOR => 'STARTSWITH', VALUE => "$name - " );
+ while ( my $pqueue = $queues->Next ) {
+ next unless $pqueue->CurrentUserHasRight( "ShowTicket" );
+ push @values, substr $pqueue->__Value('Name'), length("$name - ");
+ }
+ my $default = RT->Config->Get('_RTIR_Constituency_default');
+ return $default if grep lc $_ eq lc $default, @values;
+ return shift @values;
+}
+
# IPs processing hooks
# in order too implement searches by IP ranges we
More information about the Rt-commit
mailing list