import rt 2.0.14
[freeside.git] / rt / lib / RT / EasySearch.pm
1 #$Header: /home/cvs/cvsroot/freeside/rt/lib/RT/Attic/EasySearch.pm,v 1.1 2002-08-12 06:17:07 ivan Exp $
2
3 =head1 NAME
4
5   RT::EasySearch - a baseclass for RT collection objects
6
7 =head1 SYNOPSIS
8
9 =head1 DESCRIPTION
10
11
12 =head1 METHODS
13
14
15 =begin testing
16
17 ok (require RT::EasySearch);
18
19 =end testing
20
21
22 =cut
23
24 package RT::EasySearch;
25 use DBIx::SearchBuilder;
26 @ISA= qw(DBIx::SearchBuilder);
27
28 # {{{ sub _Init 
29 sub _Init  {
30     my $self = shift;
31     
32     $self->{'user'} = shift;
33     unless(defined($self->CurrentUser)) {
34         use Carp;
35         Carp::confess("$self was created without a CurrentUser");
36         $RT::Logger->err("$self was created without a CurrentUser\n"); 
37         return(0);
38     }
39     $self->SUPER::_Init( 'Handle' => $RT::Handle);
40 }
41 # }}}
42
43 # {{{ sub LimitToEnabled
44
45 =head2 LimitToEnabled
46
47 Only find items that haven\'t been disabled
48
49 =cut
50
51 sub LimitToEnabled {
52     my $self = shift;
53     
54     $self->Limit( FIELD => 'Disabled',
55                   VALUE => '0',
56                   OPERATOR => '=' );
57 }
58 # }}}
59
60 # {{{ sub LimitToDisabled
61
62 =head2 LimitToDeleted
63
64 Only find items that have been deleted.
65
66 =cut
67
68 sub LimitToDeleted {
69     my $self = shift;
70     
71     $self->{'find_disabled_rows'} = 1;
72     $self->Limit( FIELD => 'Disabled',
73                   OPERATOR => '=',
74                   VALUE => '1'
75                 );
76 }
77 # }}}
78
79
80 # {{{ sub Limit 
81
82 =head2 Limit PARAMHASH
83
84 This Limit sub calls SUPER::Limit, but defaults "CASESENSITIVE" to 1, thus
85 making sure that by default lots of things don't do extra work trying to 
86 match lower(colname) agaist lc($val);
87
88 =cut
89
90 sub Limit {
91         my $self = shift;
92         my %args = ( CASESENSITIVE => 1,
93                      @_ );
94
95    return $self->SUPER::Limit(%args);
96 }
97
98 # {{{ sub CurrentUser 
99
100 =head2 CurrentUser
101
102   Returns the current user as an RT::User object.
103
104 =cut
105
106 sub CurrentUser  {
107   my $self = shift;
108   return ($self->{'user'});
109 }
110 # }}}
111     
112
113 1;
114
115