import rt 2.0.14
[freeside.git] / rt / lib / RT / Attachments.pm
1 #$Header: /home/cvs/cvsroot/freeside/rt/lib/RT/Attachments.pm,v 1.1 2002-08-12 06:17:07 ivan Exp $
2
3 =head1 NAME
4
5   RT::Attachments - a collection of RT::Attachment objects
6
7 =head1 SYNOPSIS
8
9   use RT::Attachments;
10
11 =head1 DESCRIPTION
12
13 This module should never be called directly by client code. it's an internal module which
14 should only be accessed through exported APIs in Ticket, Queue and other similar objects.
15
16
17 =head1 METHODS
18
19
20 =begin testing
21
22 ok (require RT::TestHarness);
23 ok (require RT::Attachments);
24
25 =end testing
26
27 =cut
28
29 package RT::Attachments;
30
31 use RT::EasySearch;
32
33 @ISA= qw(RT::EasySearch);
34
35 # {{{ sub _Init  
36 sub _Init   {
37   my $self = shift;
38  
39   $self->{'table'} = "Attachments";
40   $self->{'primary_key'} = "id";
41   return ( $self->SUPER::_Init(@_));
42 }
43 # }}}
44
45
46 # {{{ sub ContentType
47
48 =head2 ContentType (VALUE => 'text/plain', ENTRYAGGREGATOR => 'OR', OPERATOR => '=' ) 
49
50 Limit result set to attachments of ContentType 'TYPE'...
51
52 =cut
53
54
55 sub ContentType  {
56   my $self = shift;
57   my %args = ( VALUE => 'text/plain',
58                OPERATOR => '=',
59                ENTRYAGGREGATOR => 'OR',
60                @_);
61
62   $self->Limit ( FIELD => 'ContentType',
63                  VALUE => $args{'VALUE'},
64                  OPERATOR => $args{'OPERATOR'},
65                  ENTRYAGGREGATOR => $args{'ENTRYAGGREGATOR'});
66 }
67 # }}}
68
69 # {{{ sub ChildrenOf 
70
71 =head2 ChildrenOf ID
72
73 Limit result set to children of Attachment ID
74
75 =cut
76
77
78 sub ChildrenOf  {
79   my $self = shift;
80   my $attachment = shift;
81   $self->Limit ( FIELD => 'Parent',
82                  VALUE => $attachment);
83 }
84 # }}}
85
86 # {{{ sub NewItem 
87 sub NewItem  {
88   my $self = shift;
89
90   use RT::Attachment;
91   my $item = new RT::Attachment($self->CurrentUser);
92   return($item);
93 }
94 # }}}
95   1;
96
97
98
99