1 #$Header: /home/cvs/cvsroot/freeside/rt/lib/RT/Attic/ObjectKeywords.pm,v 1.1 2002-08-12 06:17:07 ivan Exp $
3 package RT::ObjectKeywords;
10 RT::ObjectKeywords - note warning
14 This module should B<NEVER> be called directly by client code. its API is entirely through RT ticket or other objects which can have keywords assigned.
22 ok (require RT::TestHarness);
23 ok (require RT::ObjectKeywords);
30 use RT::ObjectKeyword;
32 @ISA = qw( RT::EasySearch );
37 $self->{'table'} = 'ObjectKeywords';
38 $self->{'primary_key'} = 'id';
39 return ($self->SUPER::_Init(@_));
46 return (new RT::ObjectKeyword($self->CurrentUser));
50 # {{{ sub LimitToKeywordSelect
52 =head2 LimitToKeywordSelect
54 Takes a B<RT::KeywordSelect> id or Nameas its single argument. limits the returned set of ObjectKeywords
55 to ObjectKeywords which apply to that ticket
60 sub LimitToKeywordSelect {
62 my $keywordselect = shift;
64 if ($keywordselect =~ /^\d+$/) {
66 $self->Limit(FIELD => 'KeywordSelect',
68 ENTRYAGGREGATOR => 'OR',
69 VALUE => "$keywordselect");
72 #We're limiting by name. time to be klever
74 my $ks = $self->NewAlias('KeywordSelects');
75 $self->Join(ALIAS1 => $ks, FIELD1 => 'id',
76 ALIAS2 => 'main', FIELD2 => 'KeywordSelect');
78 $self->Limit( ALIAS => "$ks",
80 VALUE => "$keywordselect",
82 ENTRYAGGREGATOR => "OR");
84 $self->Limit ( ALIAS => "$ks",
85 FIELD => 'ObjectType',
90 $self->Limit ( ALIAS => "$ks",
91 FIELD => 'ObjectField',
97 # TODO +++ we need to be able to limit the returned
98 # keywordselects to ones that apply only to this queue
99 # $self->Limit( ALIAS => "$ks",
100 # FIELD => 'ObjectValue',
101 # VALUE => $self->QueueObj->Id,
103 # ENTRYAGGREGATOR => "OR");
115 =head2 LimitToTicket TICKET_ID
117 Takes an B<RT::Ticket> id as its single argument. limits the returned set of ObjectKeywords
118 to ObjectKeywords which apply to that ticket
125 $self->Limit(FIELD => 'ObjectId',
127 ENTRYAGGREGATOR => 'OR',
130 $self->Limit(FIELD => 'ObjectType',
132 ENTRYAGGREGATOR => 'OR',
140 #wrap around _DoSearch so that we can build the hash of returned
145 # $RT::Logger->debug("Now in ".$self."->_DoSearch");
146 my $return = $self->SUPER::_DoSearch(@_);
147 # $RT::Logger->debug("In $self ->_DoSearch. return from SUPER::_DoSearch was $return\n");
154 #Build a hash of this ACL's entries.
158 while (my $entry = $self->Next) {
160 my $hashkey = $entry->Keyword;
161 $self->{'as_hash'}->{"$hashkey"} =1;
169 =head2 HasEntry KEYWORD_ID
171 Takes a keyword id and returns true if this ObjectKeywords object has an entry for that
172 keyword. Returns undef otherwise.
182 #if we haven't done the search yet, do it now.
185 # $RT::Logger->debug("Now in ".$self."->HasEntry\n");
188 if ($self->{'as_hash'}->{ $keyword } == 1) {
198 # {{{ sub RelativePaths
202 # Return a (reference to a) list of KeywordRelativePaths
211 # Here $key is a RT::ObjectKeyword
212 while (my $key=$self->Next()) {
213 push(@list, $key->KeywordRelativePath);
219 # {{{ sub RelativePathsAsString
221 =head2 RelativePathsAsString
223 # Returns the RT::ObjectKeywords->RelativePaths as a comma seperated string
227 sub RelativePathsAsString {
229 return(join(", ",@{$self->KeywordRelativePaths}));