import of rt 3.0.9
[freeside.git] / rt / lib / RT / CustomFields_Overlay.pm
1 # BEGIN LICENSE BLOCK
2
3 # Copyright (c) 1996-2003 Jesse Vincent <jesse@bestpractical.com>
4
5 # (Except where explictly superceded by other copyright notices)
6
7 # This work is made available to you under the terms of Version 2 of
8 # the GNU General Public License. A copy of that license should have
9 # been provided with this software, but in any event can be snarfed
10 # from www.gnu.org.
11
12 # This work is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 # General Public License for more details.
16
17 # Unless otherwise specified, all modifications, corrections or
18 # extensions to this work which alter its source code become the
19 # property of Best Practical Solutions, LLC when submitted for
20 # inclusion in the work.
21
22
23 # END LICENSE BLOCK
24 =head1 NAME
25
26   RT::CustomFields - a collection of RT CustomField objects
27
28 =head1 SYNOPSIS
29
30   use RT::CustomFields;
31
32 =head1 DESCRIPTION
33
34 =head1 METHODS
35
36
37 =begin testing
38
39 ok (require RT::CustomFields);
40
41 =end testing
42
43 =cut
44
45 use strict;
46 no warnings qw(redefine);
47
48
49 # {{{ sub LimitToGlobalOrQueue 
50
51 =item LimitToGlobalOrQueue QUEUEID
52
53 Limits the set of custom fields found to global custom fields or those tied to the queue with ID QUEUEID 
54
55 =cut
56
57 sub LimitToGlobalOrQueue {
58     my $self = shift;
59     my $queue = shift;
60     $self->LimitToQueue($queue);
61     $self->LimitToGlobal();
62 }
63
64 # }}}
65
66 # {{{ sub LimitToQueue 
67
68 =head2 LimitToQueue QUEUEID
69
70 Takes a queue id (numerical) as its only argument. Makes sure that 
71 Scopes it pulls out apply to this queue (or another that you've selected with
72 another call to this method
73
74 =cut
75
76 sub LimitToQueue  {
77    my $self = shift;
78   my $queue = shift;
79  
80   $self->Limit (ENTRYAGGREGATOR => 'OR',
81                 FIELD => 'Queue',
82                 VALUE => "$queue")
83       if defined $queue;
84   
85 }
86 # }}}
87
88 # {{{ sub LimitToGlobal
89
90 =head2 LimitToGlobal
91
92 Makes sure that 
93 Scopes it pulls out apply to all queues (or another that you've selected with
94 another call to this method or LimitToQueue
95
96 =cut
97
98
99 sub LimitToGlobal  {
100    my $self = shift;
101  
102   $self->Limit (ENTRYAGGREGATOR => 'OR',
103                 FIELD => 'Queue',
104                 VALUE => 0);
105   
106 }
107 # }}}
108
109
110 # {{{ sub _DoSearch 
111
112 =head2 _DoSearch
113
114   A subclass of DBIx::SearchBuilder::_DoSearch that makes sure that _Disabled ro
115 ws never get seen unless
116 we're explicitly trying to see them.
117
118 =cut
119
120 sub _DoSearch {
121     my $self = shift;
122     
123     #unless we really want to find disabled rows, make sure we\'re only finding enabled ones.
124     unless($self->{'find_disabled_rows'}) {
125         $self->LimitToEnabled();
126     }
127     
128     return($self->SUPER::_DoSearch(@_));
129     
130 }
131
132 # }}}
133   
134 1;
135