[Rt-devel] [PATCH] Search criteria UpdatedBy
Bradley Bell
bradleyb at u.washington.edu
Tue Sep 12 19:28:14 EDT 2006
Roy El-Hames wrote:
> Hi there;
> (rt-3.6.1 , mysql, apache2 mod_perl)
> I have a search criteria where it looks for any tickets updated by a
> particular user, I got it working for all kind of transactions and I
> wonder if anyone can help me put the final tweak to get it to return
> ticket where the User just Commented/Corresponded ..I have the following
> function in Tickets_Overlay.pm:
> [snip]
> Any help will be appreciated,
> Regards;
> Roy
Thanks for the code, I was just trying to do the same thing. I haven't
figured out how to do that final tweak yet, either.
But anyway, here is a patch that completes this mod, bringing the search
into the UI and all.
I'm thinking CommentBy/CorrespondBy should/would be separate criteria,
though they could be built into the same limit function.
-brad
-------------- next part --------------
--- share/html/Search/Elements/PickBasics 2006-06-19 15:44:04.000000000 -0700
+++ local/html/Search/Elements/PickBasics 2006-09-12 15:50:28.000000000 -0700
@@ -101,6 +101,7 @@
<option value="Owner"><&|/l&>Owner</&></option>
<option value="Creator"><&|/l&>Creator</&></option>
<option value="LastUpdatedBy"><&|/l&>LastUpdatedBy</&></option>
+<option value="UpdatedBy"><&|/l&>UpdatedBy</&></option>
</select>
</td><td>
<& /Elements/SelectBoolean, Name => "ActorOp",
--- lib/RT/Tickets_Overlay.pm.dist 2006-09-12 16:19:35.000000000 -0700
+++ lib/RT/Tickets_Overlay.pm 2006-09-12 16:22:08.000000000 -0700
@@ -141,6 +141,7 @@
CustomField => [ 'CUSTOMFIELD', ],
CF => [ 'CUSTOMFIELD', ],
Updated => [ 'TRANSDATE', ],
+ UpdatedBy => [ 'TRANSUSER', ],
RequestorGroup => [ 'MEMBERSHIPFIELD' => 'Requestor', ],
CCGroup => [ 'MEMBERSHIPFIELD' => 'Cc', ],
AdminCCGroup => [ 'MEMBERSHIPFIELD' => 'AdminCc', ],
@@ -156,6 +157,7 @@
STRING => \&_StringLimit,
TRANSFIELD => \&_TransLimit,
TRANSDATE => \&_TransDateLimit,
+ TRANSUSER => \&_TransUserLimit,
WATCHERFIELD => \&_WatcherLimit,
MEMBERSHIPFIELD => \&_WatcherMembershipLimit,
LINKFIELD => \&_LinkFieldLimit,
@@ -186,6 +188,10 @@
},
TRANSFIELD => 'AND',
TRANSDATE => 'AND',
+ TRANSUSER => {
+ '=' => 'OR',
+ '!=' => 'AND'
+ },
LINK => 'OR',
LINKFIELD => 'AND',
TARGET => 'AND',
@@ -626,6 +632,54 @@
$sb->_CloseParen;
}
+=head2 _TransUserLimit
+
+Handle fields limiting based on Transaction User.
+
+Meta Data:
+ None
+
+=cut
+
+# This routine should really be factored into translimit.
+sub _TransUserLimit {
+ my ($self, $field, $op, $value, @rest ) = @_;
+ #$RT::Logger->error("the field = $field and op is $op and value is $value and rest is @rest");
+ $self->{_sql_transalias} = $self->NewAlias('Transactions')
+ unless defined $self->{_sql_transalias};
+ $self->{_sql_Usersalias} = $self->NewAlias('Users')
+ unless defined $self->{_sql_Usersalias};
+ $self->_OpenParen;
+ #Search for the right field
+ $self->_SQLLimit(
+ ALIAS => $self->{_sql_Usersalias},
+ FIELD => 'Name', ### for the Updated by in particular may change later
+ OPERATOR => $op,
+ VALUE => $value,
+ CASESENSITIVE => 0,
+ @rest
+ );
+ $self->_SQLJoin(
+ ALIAS1 => $self->{_sql_Usersalias},
+ FIELD1 => 'Id',
+ ALIAS2 => $self->{_sql_transalias},
+ FIELD2 => 'Creator'
+ );
+ $self->_SQLJoin(
+ ALIAS1 => 'main',
+ FIELD1 => 'Id',
+ ALIAS2 => $self->{_sql_transalias},
+ FIELD2 => 'ObjectId'
+ );
+ $self->SUPER::Limit(
+ ALIAS => $self->{_sql_transalias},
+ FIELD => 'ObjectType',
+ VALUE => 'RT::Ticket',
+ ENTRYAGGREGATOR => 'AND'
+ );
+ $self->_CloseParen;
+}
+
=head2 _TransLimit
Limit based on the Content of a transaction or the ContentType.
More information about the Rt-devel
mailing list