import rt 2.0.14
[freeside.git] / rt / lib / RT / Keywords.pm
1 #$Header: /home/cvs/cvsroot/freeside/rt/lib/RT/Attic/Keywords.pm,v 1.1 2002-08-12 06:17:07 ivan Exp $
2
3 =head1 NAME
4
5   RT::Keywords - a collection of RT::Keyword objects
6
7 =head1 SYNOPSIS
8
9   use RT::Keywords;
10   my $keywords = RT::Keywords->new($user);
11   $keywords->LimitToParent(0);
12   while my ($keyword = $keywords->Next()) {
13      print $keyword->Name ."\n";
14   }
15
16
17 =head1 DESCRIPTION
18
19
20 =head1 METHODS
21
22 =begin testing
23
24 ok (require RT::TestHarness);
25 ok (require RT::Keywords);
26
27 =end testing
28
29 =cut
30
31 package RT::Keywords;
32
33 use strict;
34 use vars qw( @ISA );
35 use RT::EasySearch;
36 use RT::Keyword;
37
38 @ISA = qw( RT::EasySearch );
39
40
41 # {{{ sub _Init
42
43 sub _Init {
44     my $self = shift;
45     $self->{'table'} = 'Keywords';
46     $self->{'primary_key'} = 'id';
47
48     # By default, order by name
49     $self->OrderBy( ALIAS => 'main',
50                     FIELD => 'Name',
51                     ORDER => 'ASC');
52
53     return ($self->SUPER::_Init(@_));
54 }
55 # }}}
56
57 # {{{ sub _DoSearch 
58
59 =head2 _DoSearch
60
61   A subclass of DBIx::SearchBuilder::_DoSearch that makes sure that _Disabled rows never get seen unless
62 we're explicitly trying to see them.
63
64 =cut
65
66 sub _DoSearch {
67     my $self = shift;
68     
69     #unless we really want to find disabled rows, make sure we\'re only finding enabled ones.
70     unless($self->{'find_disabled_rows'}) {
71         $self->LimitToEnabled();
72     }
73     
74     return($self->SUPER::_DoSearch(@_));
75     
76 }
77
78 # }}}
79
80 # {{{ sub NewItem 
81 sub NewItem {
82     my $self = shift;
83     return (RT::Keyword->new($self->CurrentUser));
84 }
85 # }}}
86
87 # {{{ sub LimitToParent
88
89 =head2 LimitToParent
90
91 Takes a parent id and limits the returned keywords to children of that parent.
92
93 =cut
94
95 sub LimitToParent {
96     my $self = shift;
97     my $parent = shift;
98     $self->Limit( FIELD => 'Parent',
99                   VALUE => $parent,
100                   OPERATOR => '=',
101                   ENTRYAGGREGATOR => 'OR' );
102 }       
103 # }}}
104
105 1;
106