[Rt-commit] r5838 - in rt/branches/3.7-EXPERIMENTAL: .
ruz at bestpractical.com
ruz at bestpractical.com
Thu Aug 31 22:13:48 EDT 2006
Author: ruz
Date: Thu Aug 31 22:13:47 2006
New Revision: 5838
Modified:
rt/branches/3.7-EXPERIMENTAL/ (props changed)
rt/branches/3.7-EXPERIMENTAL/lib/RT/Tickets_Overlay.pm
Log:
r3675 at cubic-pc: cubic | 2006-08-31 21:52:50 +0400
* make link type an optional argument in searches by links
** support for LinkedTo and LinkedFrom keywords
* initial work in direction to make link direction optional too
** doesn't work yet
Modified: rt/branches/3.7-EXPERIMENTAL/lib/RT/Tickets_Overlay.pm
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/lib/RT/Tickets_Overlay.pm (original)
+++ rt/branches/3.7-EXPERIMENTAL/lib/RT/Tickets_Overlay.pm Thu Aug 31 22:13:47 2006
@@ -329,27 +329,18 @@
my ( $sb, $field, $op, $value, @rest ) = @_;
my $meta = $FIELD_METADATA{$field};
- die "Incorrect Metadata for $field"
- unless defined $meta->[1] && defined $meta->[2];
-
die "Invalid Operator $op for $field" unless $op =~ /^(=|!=|IS|IS NOT)$/io;
- my $direction = $meta->[1];
-
- my $matchfield;
- my $linkfield;
+ my $direction = $meta->[1] || '';
+ my ($matchfield, $linkfield) = ('', '');
if ( $direction eq 'To' ) {
- $matchfield = "Target";
- $linkfield = "Base";
-
+ ($matchfield, $linkfield) = ("Target", "Base");
}
elsif ( $direction eq 'From' ) {
- $linkfield = "Target";
- $matchfield = "Base";
-
+ ($matchfield, $linkfield) = ("Base", "Target");
}
- else {
- die "Invalid link direction '$meta->[1]' for $field\n";
+ elsif ( $direction ) {
+ die "Invalid link direction '$direction' for $field\n";
}
my ($is_local, $is_null) = (1, 0);
@@ -357,7 +348,7 @@
$is_null = 1;
$op = ($op =~ /^(=|IS)$/)? 'IS': 'IS NOT';
}
- elsif ( $value =~ /\D/o ) {
+ elsif ( $value =~ /\D/ ) {
$is_local = 0;
}
$matchfield = "Local$matchfield" if $is_local;
@@ -374,7 +365,7 @@
# AND(main.id = Links_1.LocalTarget))
# WHERE Links_1.LocalBase IS NULL;
- if ($is_null) {
+ if ( $is_null ) {
my $linkalias = $sb->Join(
TYPE => 'LEFT',
ALIAS1 => 'main',
@@ -387,7 +378,7 @@
FIELD => 'Type',
OPERATOR => '=',
VALUE => $meta->[2],
- );
+ ) if $meta->[2];
$sb->_SQLLimit(
@rest,
ALIAS => $linkalias,
@@ -410,7 +401,7 @@
FIELD => 'Type',
OPERATOR => '=',
VALUE => $meta->[2],
- );
+ ) if $meta->[2];
$sb->SUPER::Limit(
LEFTJOIN => $linkalias,
FIELD => $matchfield,
@@ -435,7 +426,7 @@
FIELD => 'Type',
OPERATOR => '=',
VALUE => $meta->[2],
- );
+ ) if $meta->[2];
$sb->_SQLLimit(
ALIAS => $linkalias,
FIELD => 'Local' . $linkfield,
More information about the Rt-commit
mailing list