import rt 2.0.14
[freeside.git] / rt / lib / RT / Templates.pm
1 # $Header: /home/cvs/cvsroot/freeside/rt/lib/RT/Templates.pm,v 1.1 2002-08-12 06:17:07 ivan Exp $
2
3 =head1 NAME
4
5   RT::Templates - a collection of RT Template objects
6
7 =head1 SYNOPSIS
8
9   use RT::Templates;
10
11 =head1 DESCRIPTION
12
13
14 =head1 METHODS
15
16 =begin testing
17
18 ok (require RT::TestHarness);
19 ok (require RT::Templates);
20
21 =end testing
22
23 =cut
24
25 package RT::Templates;
26 use RT::EasySearch;
27 @ISA= qw(RT::EasySearch);
28
29
30 # {{{ sub _Init
31
32 =head2 _Init
33
34   Returns RT::Templates specific init info like table and primary key names
35
36 =cut
37
38 sub _Init {
39     
40     my $self = shift;
41     $self->{'table'} = "Templates";
42     $self->{'primary_key'} = "id";
43     return ($self->SUPER::_Init(@_));
44 }
45 # }}}
46
47 # {{{ LimitToNotInQueue
48
49 =head2 LimitToNotInQueue
50
51 Takes a queue id # and limits the returned set of templates to those which 
52 aren't that queue's templates.
53
54 =cut
55
56 sub LimitToNotInQueue {
57     my $self = shift;
58     my $queue_id = shift;
59     $self->Limit(FIELD => 'Queue',
60                  VALUE => "$queue_id",
61                  OPERATOR => '!='
62                 );
63 }
64 # }}}
65
66 # {{{ LimitToGlobal
67
68 =head2 LimitToGlobal
69
70 Takes no arguments. Limits the returned set to "Global" templates
71 which can be used with any queue.
72
73 =cut
74
75 sub LimitToGlobal {
76     my $self = shift;
77     my $queue_id = shift;
78     $self->Limit(FIELD => 'Queue',
79                  VALUE => "0",
80                  OPERATOR => '='
81                 );
82 }
83 # }}}
84
85 # {{{ LimitToQueue
86
87 =head2 LimitToQueue
88
89 Takes a queue id # and limits the returned set of templates to that queue's
90 templates
91
92 =cut
93
94 sub LimitToQueue {
95     my $self = shift;
96     my $queue_id = shift;
97     $self->Limit(FIELD => 'Queue',
98                  VALUE => "$queue_id",
99                  OPERATOR => '='
100                 );
101 }
102 # }}}
103
104 # {{{ sub NewItem 
105
106 =head2 NewItem
107
108 Returns a new empty Template object
109
110 =cut
111
112 sub NewItem  {
113   my $self = shift;
114
115   use RT::Template;
116   my $item = new RT::Template($self->CurrentUser);
117   return($item);
118 }
119 # }}}
120
121 1;
122