import of rt 3.0.9
[freeside.git] / rt / lib / RT / Queues_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::Queues - a collection of RT::Queue objects
27
28 =head1 SYNOPSIS
29
30   use RT::Queues;
31
32 =head1 DESCRIPTION
33
34
35 =head1 METHODS
36
37
38 =begin testing
39
40 ok (require RT::Queues);
41
42 =end testing
43
44 =cut
45
46 use strict;
47 no warnings qw(redefine);
48
49 # {{{ sub _Init
50 sub _Init { 
51   my $self = shift;
52   $self->{'table'} = "Queues";
53   $self->{'primary_key'} = "id";
54
55   # By default, order by name
56   $self->OrderBy( ALIAS => 'main',
57                   FIELD => 'Name',
58                   ORDER => 'ASC');
59
60   return ($self->SUPER::_Init(@_));
61 }
62 # }}}
63
64 # {{{ sub _DoSearch 
65
66 =head2 _DoSearch
67
68   A subclass of DBIx::SearchBuilder::_DoSearch that makes sure that _Disabled rows never get seen unless
69 we're explicitly trying to see them.
70
71 =cut
72
73 sub _DoSearch {
74     my $self = shift;
75     
76     #unless we really want to find disabled rows, make sure we\'re only finding enabled ones.
77     unless($self->{'find_disabled_rows'}) {
78         $self->LimitToEnabled();
79     }
80     
81     return($self->SUPER::_DoSearch(@_));
82     
83 }
84
85 # }}}
86   
87
88 # {{{ sub Limit 
89 sub Limit  {
90   my $self = shift;
91   my %args = ( ENTRYAGGREGATOR => 'AND',
92                @_);
93   $self->SUPER::Limit(%args);
94 }
95 # }}}
96
97 # {{{ sub Next 
98
99 =head2 Next
100
101 Returns the next queue that this user can see.
102
103 =cut
104   
105 sub Next {
106     my $self = shift;
107     
108     
109     my $Queue = $self->SUPER::Next();
110     if ((defined($Queue)) and (ref($Queue))) {
111
112         if ($Queue->CurrentUserHasRight('SeeQueue')) {
113             return($Queue);
114         }
115         
116         #If the user doesn't have the right to show this queue
117         else {  
118             return($self->Next());
119         }
120     }
121     #if there never was any queue
122     else {
123         return(undef);
124     }   
125     
126 }
127 # }}}
128
129 1;
130