This commit was generated by cvs2svn to compensate for changes in r2523,
[freeside.git] / rt / lib / RT / KeywordSelects.pm
1 #$Header: /home/cvs/cvsroot/freeside/rt/lib/RT/Attic/KeywordSelects.pm,v 1.1 2002-08-12 06:17:07 ivan Exp $
2
3
4
5 =begin testing
6
7 ok (require RT::TestHarness);
8 ok (require RT::Scrip);
9
10 =end testing
11
12 =cut
13
14
15 package RT::KeywordSelects;
16
17 use strict;
18 use vars qw( @ISA );
19 use RT::EasySearch;
20 use RT::KeywordSelect;
21
22 @ISA = qw( RT::EasySearch );
23
24 # {{{ _Init
25 sub _Init {
26   my $self = shift;
27   $self->{'table'} = 'KeywordSelects';
28   $self->{'primary_key'} = 'id';
29   return ($self->SUPER::_Init(@_));
30 }
31 # }}}
32
33 # {{{ sub _DoSearch 
34
35 =head2 _DoSearch
36
37   A subclass of DBIx::SearchBuilder::_DoSearch that makes sure that _Disabled rows never get seen unless
38 we're explicitly trying to see them.
39
40 =cut
41
42 sub _DoSearch {
43     my $self = shift;
44     
45     #unless we really want to find disabled rows, make sure we\'re only finding enabled ones.
46     unless($self->{'find_disabled_rows'}) {
47         $self->LimitToEnabled();
48     }
49     
50     return($self->SUPER::_DoSearch(@_));
51     
52 }
53
54 # }}}
55
56 # {{{ sub LimitToQueue
57 =head2 LimitToQueue 
58
59 Takes a queue id. Limits the returned set to KeywordSelects for that queue.
60 Repeated calls will be OR'd together.
61
62 =cut
63
64 sub LimitToQueue {
65     my $self = shift;
66     my $queue = shift;
67
68     $self->Limit( FIELD => 'ObjectValue',
69                   VALUE => $queue,
70                   OPERATOR => '=',
71                   ENTRYAGGREGATOR => 'OR'
72                 );
73
74     $self->Limit( FIELD => 'ObjectType',
75                   VALUE => 'Ticket',
76                   OPERATOR => '=');
77
78     $self->Limit( FIELD => 'ObjectField',
79                   VALUE => 'Queue',
80                   OPERATOR => '=');
81
82     
83 }
84 # }}}
85
86 # {{{ sub LimitToGlobals
87
88 =head2 LimitToGlobals
89
90 Limits the returned set to KeywordSelects for all queues.
91 Repeated calls will be OR'd together.
92
93 =cut
94
95 sub LimitToGlobals {
96     my $self = shift;
97
98     $self->Limit( FIELD => 'ObjectType',
99                   VALUE => 'Ticket',
100                   OPERATOR => '=');
101
102     $self->Limit( FIELD => 'ObjectField',
103                   VALUE => 'Queue',
104                   OPERATOR => '=');
105
106     $self->Limit( FIELD => 'ObjectValue',
107                   VALUE => '0',
108                   OPERATOR => '=',
109                   ENTRYAGGREGATOR => 'OR'
110                 );
111     
112 }
113 # }}}
114
115 # {{{ sub IncludeGlobals
116 =head2 IncludeGlobals
117
118 Include KeywordSelects which apply globally in the set of returned results
119
120 =cut
121
122
123 sub IncludeGlobals {
124     my $self = shift;
125     $self->Limit( FIELD => 'ObjectValue',
126                   VALUE => '0',
127                   OPERATOR => '=',
128                   ENTRYAGGREGATOR => 'OR'
129                 );
130     
131
132 }
133 # }}}
134
135 # {{{ sub NewItem
136 sub NewItem {
137     my $self = shift;
138     #my $Handle = shift;
139     return (new RT::KeywordSelect($self->CurrentUser));
140 }
141 # }}}
142 1;
143