import rt 2.0.14
[freeside.git] / rt / lib / RT / Groups.pm
1 #$Header: /home/cvs/cvsroot/freeside/rt/lib/RT/Groups.pm,v 1.1 2002-08-12 06:17:07 ivan Exp $
2
3 =head1 NAME
4
5   RT::Groups - a collection of RT::Group objects
6
7 =head1 SYNOPSIS
8
9   use RT::Groups;
10   my $groups = $RT::Groups->new($CurrentUser);
11   $groups->LimitToReal();
12   while (my $group = $groups->Next()) {
13      print $group->Id ." is a group id\n";
14   }
15
16 =head1 DESCRIPTION
17
18
19 =head1 METHODS
20
21
22 =begin testing
23
24 ok (require RT::TestHarness);
25 ok (require RT::Groups);
26
27 =end testing
28
29 =cut
30
31 package RT::Groups;
32 use RT::EasySearch;
33 use RT::Groups;
34
35 @ISA= qw(RT::EasySearch);
36
37 # {{{ sub _Init
38
39 sub _Init { 
40   my $self = shift;
41   $self->{'table'} = "Groups";
42   $self->{'primary_key'} = "id";
43
44   $self->OrderBy( ALIAS => 'main',
45                   FIELD => 'Name',
46                   ORDER => 'ASC');
47
48
49   return ( $self->SUPER::_Init(@_));
50 }
51 # }}}
52
53 # {{{ LimitToReal
54
55 =head2 LimitToReal
56
57 Make this groups object return only "real" groups, which can be
58 granted rights and have members assigned to them
59
60 =cut
61
62 sub LimitToReal {
63     my $self = shift;
64
65     return ($self->Limit( FIELD => 'Pseudo',
66                           VALUE => '0',
67                           OPERATOR => '='));
68
69 }
70 # }}}
71
72 # {{{ sub LimitToPseudo
73
74 =head2 LimitToPseudo
75
76 Make this groups object return only "pseudo" groups, which can be
77 granted rights but whose membership lists are determined dynamically.
78
79 =cut
80   
81   sub LimitToPseudo {
82     my $self = shift;
83
84     return ($self->Limit( FIELD => 'Pseudo',
85                           VALUE => '1',
86                           OPERATOR => '='));
87
88 }
89 # }}}
90
91 # {{{ sub NewItem 
92 sub NewItem  {
93   my $self = shift;
94   return (RT::Group->new($self->CurrentUser));
95 }
96 # }}}
97
98
99 1;
100