import of rt 3.0.9
[freeside.git] / rt / lib / RT / Attachments_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::Attachments - a collection of RT::Attachment objects
27
28 =head1 SYNOPSIS
29
30   use RT::Attachments;
31
32 =head1 DESCRIPTION
33
34 This module should never be called directly by client code. it's an internal module which
35 should only be accessed through exported APIs in Ticket, Queue and other similar objects.
36
37
38 =head1 METHODS
39
40
41 =begin testing
42
43 ok (require RT::Attachments);
44
45 =end testing
46
47 =cut
48
49 use strict;
50 no warnings qw(redefine);
51
52 # {{{ sub _Init  
53 sub _Init   {
54   my $self = shift;
55  
56   $self->{'table'} = "Attachments";
57   $self->{'primary_key'} = "id";
58   return ( $self->SUPER::_Init(@_));
59 }
60 # }}}
61
62
63 # {{{ sub ContentType
64
65 =head2 ContentType (VALUE => 'text/plain', ENTRYAGGREGATOR => 'OR', OPERATOR => '=' ) 
66
67 Limit result set to attachments of ContentType 'TYPE'...
68
69 =cut
70
71
72 sub ContentType  {
73   my $self = shift;
74   my %args = ( VALUE => 'text/plain',
75                OPERATOR => '=',
76                ENTRYAGGREGATOR => 'OR',
77                @_);
78
79   $self->Limit ( FIELD => 'ContentType',
80                  VALUE => $args{'VALUE'},
81                  OPERATOR => $args{'OPERATOR'},
82                  ENTRYAGGREGATOR => $args{'ENTRYAGGREGATOR'});
83 }
84 # }}}
85
86 # {{{ sub ChildrenOf 
87
88 =head2 ChildrenOf ID
89
90 Limit result set to children of Attachment ID
91
92 =cut
93
94
95 sub ChildrenOf  {
96   my $self = shift;
97   my $attachment = shift;
98   $self->Limit ( FIELD => 'Parent',
99                  VALUE => $attachment);
100 }
101 # }}}
102
103 # {{{ sub NewItem 
104 sub NewItem  {
105   my $self = shift;
106
107   use RT::Attachment;
108   my $item = new RT::Attachment($self->CurrentUser);
109   return($item);
110 }
111 # }}}
112   1;
113
114
115
116