[Rt-commit] rtir branch, 2.5-trunk, updated. 170995a6efe3fd1c71bb478d519a2e80c804e3b5
Ruslan Zakirov
ruz at bestpractical.com
Wed Sep 16 01:32:57 EDT 2009
The branch, 2.5-trunk has been updated
via 170995a6efe3fd1c71bb478d519a2e80c804e3b5 (commit)
from 46806a3899346de1b3b1b7ce7f16f74dcde3d479 (commit)
Summary of changes:
html/RTIR/Create.html | 19 ++++++++++---------
html/RTIR/Edit.html | 3 ++-
html/RTIR/Elements/MergeWith | 3 ++-
html/RTIR/Incident/Create.html | 11 +++++++++--
html/RTIR/Incident/Display.html | 5 +++--
lib/RT/IR.pm | 2 +-
6 files changed, 27 insertions(+), 16 deletions(-)
- Log -----------------------------------------------------------------
commit 170995a6efe3fd1c71bb478d519a2e80c804e3b5
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date: Wed Sep 16 09:32:30 2009 +0400
don't show Constituency when it's disabled
diff --git a/html/RTIR/Create.html b/html/RTIR/Create.html
index 9e3ecf4..8354cbf 100644
--- a/html/RTIR/Create.html
+++ b/html/RTIR/Create.html
@@ -148,6 +148,7 @@
<&|/l&>(Sends a carbon-copy of this update to a comma-delimited list of administrative email addresses. These people <b>will</b> receive future updates.)</&>
</font></i></td>
</tr>
+% if ( $constituency_cf ) {
<tr>
<td class="labeltop"><&|/l&>Constituency</&>:</td>
<td class="value" colspan="2">
@@ -162,14 +163,13 @@
Default => $default &>
% } else {
% #TODO: hacks, we need way to define CF value on Create, but don't allow user to change it
-% my $cf = RT::CustomField->new( $RT::SystemUser );
-% $cf->LoadByNameAndQueue( Name => 'Constituency', Queue => $Queue );
- <input type="hidden" class="hidden" name="Object-RT::Ticket--CustomField-<% $cf->id %>-Values-Magic" value="1" />
- <input type="hidden" class="hidden" name="Object-RT::Ticket--CustomField-<% $cf->id %>-Values" value="<% $IncidentObj->FirstCustomFieldValue('Constituency') %>" />
+ <input type="hidden" class="hidden" name="<% $constituency_field %>-Magic" value="1" />
+ <input type="hidden" class="hidden" name="<% $constituency_field %>" value="<% $IncidentObj->FirstCustomFieldValue('Constituency') %>" />
<& /RTIR/Elements/ShowRTIRField, Ticket => $IncidentObj, Name => 'Constituency' &>
% }
</td>
</tr>
+% }
<tr>
<td colspan="3">
<& /RTIR/Elements/EditCustomFields,
@@ -276,10 +276,11 @@ $name ||= $Type;
my (@results, $checks_failure, $skip_create);
$skip_create = !$ARGS{'Create'};
-my $constituency_cf = RT::CustomField->new( $RT::SystemUser );
-$constituency_cf->LoadByNameAndQueue( Name => 'Constituency', Queue => $Queue );
-my $constituency_field =
- 'Object-RT::Ticket--CustomField-' . $constituency_cf->id .'-Values';
+my $constituency_cf = RT::IR->CustomFields( 'Constituency', Queue => $Queue );
+my $constituency_field;
+$constituency_field =
+ 'Object-RT::Ticket--CustomField-' . $constituency_cf->id .'-Values'
+ if $constituency_cf;
my $IncidentObj;
if ( $Incident ) {
@@ -293,7 +294,7 @@ if ( $Incident ) {
push @results, loc('Ticket #[_1] is not an Incident', $Incident );
($checks_failure, $IncidentObj, $Incident) = (1, undef, undef);
}
- elsif ( !$skip_create
+ elsif ( !$skip_create && $constituency_field
&& RT->Config->Get('_RTIR_Constituency_Propagation') eq 'reject'
&& lc $ARGS{$constituency_field} ne lc $IncidentObj->FirstCustomFieldValue('Constituency') )
{
diff --git a/html/RTIR/Edit.html b/html/RTIR/Edit.html
index 74915ac..94ae82f 100644
--- a/html/RTIR/Edit.html
+++ b/html/RTIR/Edit.html
@@ -79,7 +79,7 @@
<td class="label"><&|/l&>Time Worked</&>:</td>
<td class="value"><input name="TimeWorked" value="<%$Ticket->TimeWorked|h%>" size="5" /></td>
</tr>
-% if ( $constituency_propagation ne 'reject' || !$has_parent ) {
+% if ( $constituency_cf && ($constituency_propagation ne 'reject' || !$has_parent) ) {
<tr>
<td class="labeltop"><&|/l&>Constituency</&>:</td>
<td class="value">
@@ -156,6 +156,7 @@ $CanRespond = 1 if ( $Ticket->CurrentUserHasRight('ReplyToTicket') or
$CanComment = 1 if ( $Ticket->CurrentUserHasRight('CommentOnTicket') or
$Ticket->CurrentUserHasRight('ModifyTicket') );
+my $constituency_cf = RT::IR->CustomFields( Constituency => Ticket => $Ticket );
my $constituency_propagation = RT->Config->Get('_RTIR_Constituency_Propagation');
my $has_parent = 0;
if ( $constituency_propagation eq 'reject' ) {
diff --git a/html/RTIR/Elements/MergeWith b/html/RTIR/Elements/MergeWith
index 2309066..8848fe2 100644
--- a/html/RTIR/Elements/MergeWith
+++ b/html/RTIR/Elements/MergeWith
@@ -22,7 +22,8 @@ unless ( $BaseQuery ) {
push @parts, "id != $id";
push @parts, $m->comp('/RTIR/Elements/BaseQuery', Queue => $Queue) if $Queue;
push @parts, "CF.{Constituency} = '". $Ticket->FirstCustomFieldValue('Constituency') ."'"
- if RT->Config->Get('_RTIR_Constituency_Propagation') eq 'reject';
+ if RT->Config->Get('_RTIR_Constituency_Propagation') eq 'reject'
+ && RT::IR->CustomFields(Constituency => Queue => $Queue);
$BaseQuery = join ' AND ', map "( $_ )", grep $_, @parts;
}
diff --git a/html/RTIR/Incident/Create.html b/html/RTIR/Incident/Create.html
index e01b958..288a162 100644
--- a/html/RTIR/Incident/Create.html
+++ b/html/RTIR/Incident/Create.html
@@ -261,8 +261,15 @@ if ( $CreateIncident ) {
$checks_failure = 1;
}
- if ( $ChildObj && RT->Config->Get('_RTIR_Constituency_Propagation') eq 'reject' ) {
- unless ( lc $ARGS{ $ARGS{'Constituency'} }
+ if ( $ChildObj
+ and RT->Config->Get('_RTIR_Constituency_Propagation') eq 'reject'
+ and my $constituency_cf = RT::IR->CustomFields(
+ 'Constituency', Queue => 'Incidents'
+ )
+ ) {
+ my $constituency_field =
+ 'Object-RT::Ticket--CustomField-' . $constituency_cf->id .'-Values';
+ unless ( lc $ARGS{ $constituency_field }
eq lc $ChildObj->FirstCustomFieldValue('Constituency') )
{
push @results, loc( "New incident and its child #[_1] must have the same constituency", $ChildObj->id );
diff --git a/html/RTIR/Incident/Display.html b/html/RTIR/Incident/Display.html
index 2874a48..bf94ed4 100644
--- a/html/RTIR/Incident/Display.html
+++ b/html/RTIR/Incident/Display.html
@@ -167,8 +167,9 @@ my $DoLinks = sub {
if ( RT->Config->Get('_RTIR_Constituency_Propagation') eq 'reject' ) {
return loc("Couldn't link tickets with different constituencies")
- unless lc $child->FirstCustomFieldValue('Constituency')
- eq lc $parent->FirstCustomFieldValue('Constituency');
+ if lc $child->FirstCustomFieldValue('Constituency')
+ ne lc $parent->FirstCustomFieldValue('Constituency')
+ && RT::IR->CustomFields('Constituency');
}
my %args = ();
diff --git a/lib/RT/IR.pm b/lib/RT/IR.pm
index 99a3067..6e76300 100644
--- a/lib/RT/IR.pm
+++ b/lib/RT/IR.pm
@@ -274,7 +274,7 @@ sub CustomFields {
}
}
- return @list;
+ return wantarray? @list : $list[0];
} }
sub DefaultConstituency {
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list