import of rt 3.0.4
[freeside.git] / rt / lib / RT / Templates_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::Templates - a collection of RT Template objects
27
28 =head1 SYNOPSIS
29
30   use RT::Templates;
31
32 =head1 DESCRIPTION
33
34
35 =head1 METHODS
36
37 =begin testing
38
39 ok (require RT::Templates);
40
41 =end testing
42
43 =cut
44
45 use strict;
46 no warnings qw(redefine);
47
48
49 # {{{ sub _Init
50
51 =head2 _Init
52
53   Returns RT::Templates specific init info like table and primary key names
54
55 =cut
56
57 sub _Init {
58     
59     my $self = shift;
60     $self->{'table'} = "Templates";
61     $self->{'primary_key'} = "id";
62     return ($self->SUPER::_Init(@_));
63 }
64 # }}}
65
66 # {{{ LimitToNotInQueue
67
68 =head2 LimitToNotInQueue
69
70 Takes a queue id # and limits the returned set of templates to those which 
71 aren't that queue's templates.
72
73 =cut
74
75 sub LimitToNotInQueue {
76     my $self = shift;
77     my $queue_id = shift;
78     $self->Limit(FIELD => 'Queue',
79                  VALUE => "$queue_id",
80                  OPERATOR => '!='
81                 );
82 }
83 # }}}
84
85 # {{{ LimitToGlobal
86
87 =head2 LimitToGlobal
88
89 Takes no arguments. Limits the returned set to "Global" templates
90 which can be used with any queue.
91
92 =cut
93
94 sub LimitToGlobal {
95     my $self = shift;
96     my $queue_id = shift;
97     $self->Limit(FIELD => 'Queue',
98                  VALUE => "0",
99                  OPERATOR => '='
100                 );
101 }
102 # }}}
103
104 # {{{ LimitToQueue
105
106 =head2 LimitToQueue
107
108 Takes a queue id # and limits the returned set of templates to that queue's
109 templates
110
111 =cut
112
113 sub LimitToQueue {
114     my $self = shift;
115     my $queue_id = shift;
116     $self->Limit(FIELD => 'Queue',
117                  VALUE => "$queue_id",
118                  OPERATOR => '='
119                 );
120 }
121 # }}}
122
123 # {{{ sub NewItem 
124
125 =head2 NewItem
126
127 Returns a new empty Template object
128
129 =cut
130
131 sub NewItem  {
132   my $self = shift;
133
134   use RT::Template;
135   my $item = new RT::Template($self->CurrentUser);
136   return($item);
137 }
138 # }}}
139
140 1;
141