This commit was generated by cvs2svn to compensate for changes in r2523,
[freeside.git] / rt / lib / RT / Queues.pm
1 #$Header: /home/cvs/cvsroot/freeside/rt/lib/RT/Queues.pm,v 1.1 2002-08-12 06:17:07 ivan Exp $
2
3 =head1 NAME
4
5   RT::Queues - a collection of RT::Queue objects
6
7 =head1 SYNOPSIS
8
9   use RT::Queues;
10
11 =head1 DESCRIPTION
12
13
14 =head1 METHODS
15
16
17 =begin testing
18
19 ok (require RT::TestHarness);
20 ok (require RT::Queues);
21
22 =end testing
23
24 =cut
25
26 package RT::Queues;
27 use RT::EasySearch;
28 @ISA= qw(RT::EasySearch);
29
30
31 # {{{ sub _Init
32 sub _Init { 
33   my $self = shift;
34   $self->{'table'} = "Queues";
35   $self->{'primary_key'} = "id";
36
37   # By default, order by name
38   $self->OrderBy( ALIAS => 'main',
39                   FIELD => 'Name',
40                   ORDER => 'ASC');
41
42   return ($self->SUPER::_Init(@_));
43 }
44 # }}}
45
46 # {{{ sub _DoSearch 
47
48 =head2 _DoSearch
49
50   A subclass of DBIx::SearchBuilder::_DoSearch that makes sure that _Disabled rows never get seen unless
51 we're explicitly trying to see them.
52
53 =cut
54
55 sub _DoSearch {
56     my $self = shift;
57     
58     #unless we really want to find disabled rows, make sure we\'re only finding enabled ones.
59     unless($self->{'find_disabled_rows'}) {
60         $self->LimitToEnabled();
61     }
62     
63     return($self->SUPER::_DoSearch(@_));
64     
65 }
66
67 # }}}
68   
69
70 # {{{ sub Limit 
71 sub Limit  {
72   my $self = shift;
73   my %args = ( ENTRYAGGREGATOR => 'AND',
74                @_);
75   $self->SUPER::Limit(%args);
76 }
77 # }}}
78
79 # {{{ sub NewItem 
80 sub NewItem  {
81   my $self = shift;
82   my $item;
83
84   use RT::Queue;
85   $item = new RT::Queue($self->CurrentUser);
86   return($item);
87 }
88 # }}}
89
90 # {{{ sub Next 
91
92 =head2 Next
93
94 Returns the next queue that this user can see.
95
96 =cut
97   
98 sub Next {
99     my $self = shift;
100     
101     
102     my $Queue = $self->SUPER::Next();
103     if ((defined($Queue)) and (ref($Queue))) {
104
105         if ($Queue->CurrentUserHasRight('SeeQueue')) {
106             return($Queue);
107         }
108         
109         #If the user doesn't have the right to show this queue
110         else {  
111             return($self->Next());
112         }
113     }
114     #if there never was any queue
115     else {
116         return(undef);
117     }   
118     
119 }
120 # }}}
121
122 1;
123