[rt-devel] [fsck.com #438] rt --limit-keyword=[!]<keyword_select>/<keyword>
Byron Ellacott
bje at apnic.net
Mon Feb 25 21:12:45 EST 2002
Attached is a patch to enable limiting by keyword in the CLI.
Works by applying the limit to the most recently specified queue limit,
eg:
rt --summary --limit-queue=myqueue --limit-keyword=select/keyword
--
bje
-------------- next part --------------
Index: rt
===================================================================
RCS file: /usr/local/cvs/fsck/rt2/bin/rt,v
retrieving revision 1.1.1.1
diff -c -4 -r1.1.1.1 rt
*** rt 2002/01/10 05:51:48 1.1.1.1
--- rt 2002/02/26 02:06:24
***************
*** 53,60 ****
--- 53,61 ----
@limit_memberof,
@limit_hasmember,
@limit_refersto,
@limit_referredtoby,
+ @limit_keyword,
@limit_due,
@limit_starts,
@limit_started,
***************
*** 112,119 ****
--- 113,121 ----
"limit-body=s", \@limit_body,
"limit-created=s" => \@limit_created,
"limit-due=s" => \@limit_due,
"limit-last-updated=s" => \@limit_lastupdated,
+ "limit-keyword=s" => \@limit_keyword,
"limit-member-of=s" => \@limit_memberof,
"limit-has-member=s" => \@limit_hasmember,
"limit-depended-on-by=s" => \@limit_dependedonby,
***************
*** 189,196 ****
--- 191,199 ----
starts is less than ends
--limit-requestor=[!]<userid>|<email>
--limit-subject=[!]<text>
--limit-body=[!]<text>
+ --limit-keyword=[!]<select>/<keyword>
Links
--limit-member-of=<ticketid>
--limit-has-member=<ticketid>
***************
*** 382,389 ****
--- 385,393 ----
my $Tickets = new RT::Tickets($CurrentUser);
# {{{ Limit our search
my $value; #to use when iterating through restrictions
+ my $queue_id; #to use when limiting by keyword
# {{{ limit on id
foreach $value (@id) {
***************
*** 441,450 ****
--- 445,486 ----
}
$RT::Logger->debug ("Limiting queue to $op ".$queue_obj->Name);
$Tickets->LimitQueue(VALUE => $queue_obj->Name,
OPERATOR => $op);
+ $queue_id=$queue_obj->id;
}
}
+
+ # {{{ limit on keyword
+ foreach $value (@limit_keyword) {
+ if ($value =~ /^(\W?)(.*?)\/(.*)$/i) {
+ my $op = $1;
+ my $select = $2;
+ my $keyword = $3;
+
+ $op = ParseBooleanOp($op);
+
+ # load the keyword select
+ my $keyselect = RT::KeywordSelect->new($RT::SystemUser);
+ unless ($keyselect->LoadByName(Name=>$select, Queue=>$queue_id)) {
+ $RT::Logger->debug("KeywordSelect '$select' not found");
+ print STDERR "KeywordSelect '$select' not fount\n";
+ exit(-1);
+ }
+
+ # load the keyword
+ my $k = RT::Keyword->new($RT::SystemUser);
+ unless ($k->LoadByNameAndParentId($keyword, $keyselect->Keyword)) {
+ $RT::Logger->debug("Keyword '$keyword' not found");
+ print STDERR "Keyword '$keyword' not found\n";
+ exit(-1);
+ }
+ $Tickets->LimitKeyword(OPERATOR => $op,
+ KEYWORDSELECT => $keyselect->id,
+ KEYWORD => $k->id);
+ $RT::Logger->debug ("Limiting keyword to $op ".$k->Path);
+ }
+ }
# }}}
# {{{ limit on owner
foreach $value (@limit_owner) {
if ($value =~ /^(\W?)(.*?)$/i) {
More information about the Rt-devel
mailing list