import rt 2.0.14
[freeside.git] / rt / lib / RT / ObjectKeyword.pm
1 #$Header: /home/cvs/cvsroot/freeside/rt/lib/RT/Attic/ObjectKeyword.pm,v 1.1 2002-08-12 06:17:07 ivan Exp $
2 # Released under the terms of the GNU Public License
3
4 =head1 NAME
5
6   RT::ObjectKeyword -- a keyword tied to an object in the database
7
8 =head1 SYNOPSIS
9
10   use RT::ObjectKeyword;
11
12
13 =head1 DESCRIPTION
14
15 This module should never be called directly by client code. it's an internal module which
16 should only be accessed through exported APIs in Ticket, Queue and other similar objects.
17
18
19 =begin testing
20
21 ok (require RT::TestHarness);
22 ok (require RT::ObjectKeyword);
23
24 =end testing
25
26 =head1 METHODS
27
28 =cut
29
30 package RT::ObjectKeyword;
31
32 use strict;
33 use vars qw(@ISA);
34 use RT::Record;
35
36 @ISA = qw(RT::Record);
37
38 sub _Init {
39     my $self = shift;
40     $self->{'table'} = "ObjectKeywords";
41     $self->SUPER::_Init(@_);
42 }
43
44 sub _Accessible {
45     my $self = shift;
46     
47     my %cols = (
48                 Keyword       => 'read/write', #link to the B<RT::Keyword>
49                 KeywordSelect => 'read/write', #link to the B<RT::KeywordSelect>
50                 ObjectType    => 'read/write', #currently only C<Ticket>
51                 ObjectId      => 'read/write', #link to the object specified in I<ObjectType>
52                );
53     return ($self->SUPER::_Accessible( @_, %cols));
54 }
55
56
57
58 # TODO - post 2.0. add in _Set and _Value, so we can ACL them.  protected at another API level
59
60
61 =head1 NAME
62
63  RT::ObjectKeyword - Manipulate an RT::ObjectKeyword record
64
65 =head1 SYNOPSIS
66
67   use RT::ObjectKeyword;
68
69   my $keyword = RT::ObjectKeyword->new($CurrentUser);
70   $keyword->Create;
71
72 =head1 DESCRIPTION
73
74 An B<RT::ObjectKeyword> object associates an B<RT::Keyword> with another
75 object (currently only B<RT::Ticket>.
76
77 This module should B<NEVER> be called directly by client code. its API is entirely through RT ticket or other objects which can have keywords assigned.
78
79
80 =head1 METHODS
81
82 =over 4
83
84 =item new CURRENT_USER
85
86 Takes a single argument, an RT::CurrentUser object.  Instantiates a new
87 (uncreated) RT::ObjectKeyword object.
88
89 =cut
90
91 # {{{ sub Create
92
93 =item Create KEY => VALUE, ...
94
95 Takes a list of key/value pairs and creates a the object.  Returns the id of
96 the newly created record, or false if there was an error.
97
98 Keys are:
99
100 Keyword - link to the B<RT::Keyword>
101 ObjectType - currently only C<Ticket>
102 ObjectId - link to the object specified in I<ObjectType>
103
104 =cut
105
106
107 sub Create {
108     my $self = shift;
109     my %args = (Keyword => undef,
110                 KeywordSelect => undef,
111                 ObjectType => undef,
112                 ObjectId => undef,
113                 @_);
114     
115     #TODO post 2.0 ACL check
116     
117     return ($self->SUPER::Create( Keyword => $args{'Keyword'}, 
118                                   KeywordSelect => $args{'KeywordSelect'},
119                                   ObjectType => $args{'ObjectType'}, 
120                                   ObjectId => $args{'ObjectId'}))
121 }
122 # }}}
123
124 # {{{ sub KeywordObj
125
126 =item KeywordObj 
127
128 Returns an B<RT::Keyword> object of the Keyword associated with this ObjectKeyword.
129
130 =cut
131
132 sub KeywordObj {
133     my $self = shift;
134     my $keyword = new RT::Keyword($self->CurrentUser);
135     $keyword->Load($self->Keyword);
136     return ($keyword);
137 }
138 # }}}
139
140 # {{{ sub KeywordSelectObj
141
142 =item KeywordSelectObj 
143
144 Returns an B<RT::KeywordSelect> object of the KeywordSelect associated with this ObjectKeyword.
145
146 =cut
147
148 sub KeywordSelectObj {
149     my $self = shift;
150     my $keyword_sel = new RT::KeywordSelect($self->CurrentUser);
151     $keyword_sel->Load($self->KeywordSelect);
152     return ($keyword_sel);
153 }
154 # }}}
155
156 # {{{ sub KeywordRelativePath
157
158 =item KeywordRelativePath
159
160 Returns a string of the Keyword's path relative to this ObjectKeyword's KeywordSelect
161
162
163
164 =cut
165
166 sub KeywordRelativePath {
167     my $self = shift;
168     return($self->KeywordObj->RelativePath(
169               $self->KeywordSelectObj->KeywordObj->Path));
170     
171 }
172 # }}}
173
174 =back
175
176 =head1 AUTHOR
177
178 Ivan Kohler <ivan-rt@420.am>
179
180 =head1 BUGS
181
182 Yes.
183
184 =head1 SEE ALSO
185
186 L<RT::ObjectKeywords>, L<RT::Keyword>, L<RT::Keywords>, L<RT::Ticket>,
187 L<RT::Record>
188
189 =cut
190
191 1;
192