]>
Commit | Line | Data |
---|---|---|
af59614d MKG |
1 | # BEGIN BPS TAGGED BLOCK {{{ |
2 | # | |
3 | # COPYRIGHT: | |
4 | # | |
320f0092 | 5 | # This software is Copyright (c) 1996-2014 Best Practical Solutions, LLC |
af59614d MKG |
6 | # <sales@bestpractical.com> |
7 | # | |
8 | # (Except where explicitly superseded by other copyright notices) | |
9 | # | |
10 | # | |
11 | # LICENSE: | |
12 | # | |
13 | # This work is made available to you under the terms of Version 2 of | |
14 | # the GNU General Public License. A copy of that license should have | |
15 | # been provided with this software, but in any event can be snarfed | |
16 | # from www.gnu.org. | |
17 | # | |
18 | # This work is distributed in the hope that it will be useful, but | |
19 | # WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
21 | # General Public License for more details. | |
22 | # | |
23 | # You should have received a copy of the GNU General Public License | |
24 | # along with this program; if not, write to the Free Software | |
25 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | |
26 | # 02110-1301 or visit their web page on the internet at | |
27 | # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html. | |
28 | # | |
29 | # | |
30 | # CONTRIBUTION SUBMISSION POLICY: | |
31 | # | |
32 | # (The following paragraph is not intended to limit the rights granted | |
33 | # to you to modify and distribute this software under the terms of | |
34 | # the GNU General Public License and is only of importance to you if | |
35 | # you choose to contribute your changes and enhancements to the | |
36 | # community by submitting them to Best Practical Solutions, LLC.) | |
37 | # | |
38 | # By intentionally submitting any modifications, corrections or | |
39 | # derivatives to this work, or any other work intended for use with | |
40 | # Request Tracker, to Best Practical Solutions, LLC, you confirm that | |
41 | # you are the copyright holder for those contributions and you grant | |
42 | # Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable, | |
43 | # royalty-free, perpetual, license to use, copy, create derivative | |
44 | # works based on those contributions, and sublicense and distribute | |
45 | # those contributions and any derivatives thereof. | |
46 | # | |
47 | # END BPS TAGGED BLOCK }}} | |
48 | ||
49 | use strict; | |
50 | use warnings; | |
51 | ||
52 | package RT::ObjectScrip; | |
53 | use base 'RT::Record::AddAndSort'; | |
54 | ||
55 | use RT::Scrip; | |
56 | use RT::ObjectScrips; | |
c33a4027 | 57 | use Scalar::Util 'blessed'; |
af59614d MKG |
58 | |
59 | =head1 NAME | |
60 | ||
61 | RT::ObjectScrip - record representing addition of a scrip to a queue | |
62 | ||
63 | =head1 DESCRIPTION | |
64 | ||
65 | This record is created if you want to add a scrip to a queue or globally. | |
66 | ||
67 | Inherits methods from L<RT::Record::AddAndSort>. | |
68 | ||
69 | For most operations it's better to use methods in L<RT::Scrip>. | |
70 | ||
71 | =head1 METHODS | |
72 | ||
73 | =head2 Table | |
74 | ||
75 | Returns table name for records of this class. | |
76 | ||
77 | =cut | |
78 | ||
79 | sub Table {'ObjectScrips'} | |
80 | ||
81 | =head2 ObjectCollectionClass | |
82 | ||
83 | Returns class name of collection of records scrips can be added to. | |
84 | Now it's only L<RT::Queue>, so 'RT::Queues' is returned. | |
85 | ||
86 | =cut | |
87 | ||
88 | sub ObjectCollectionClass {'RT::Queues'} | |
89 | ||
90 | =head2 ScripObj | |
91 | ||
92 | Returns the Scrip Object which has the id returned by Scrip | |
93 | ||
94 | =cut | |
95 | ||
96 | sub ScripObj { | |
97 | my $self = shift; | |
98 | my $id = shift || $self->Scrip; | |
99 | my $obj = RT::Scrip->new( $self->CurrentUser ); | |
100 | $obj->Load( $id ); | |
101 | return $obj; | |
102 | } | |
103 | ||
104 | =head2 Neighbors | |
105 | ||
106 | Stage splits scrips into neighborhoods. See L<RT::Record::AddAndSort/Neighbors and Siblings>. | |
107 | ||
108 | =cut | |
109 | ||
110 | sub Neighbors { | |
111 | my $self = shift; | |
112 | my %args = @_; | |
113 | ||
114 | my $res = $self->CollectionClass->new( $self->CurrentUser ); | |
115 | $res->Limit( FIELD => 'Stage', VALUE => $args{'Stage'} || $self->Stage ); | |
116 | return $res; | |
117 | } | |
118 | ||
119 | =head2 id | |
120 | ||
121 | Returns the current value of id. | |
122 | (In the database, id is stored as int(11).) | |
123 | ||
124 | ||
125 | =cut | |
126 | ||
127 | ||
128 | =head2 Scrip | |
129 | ||
130 | Returns the current value of Scrip. | |
131 | (In the database, Scrip is stored as int(11).) | |
132 | ||
c33a4027 | 133 | =head2 FriendlyStage |
af59614d | 134 | |
c33a4027 MKG |
135 | Returns a localized human-readable version of the stage. |
136 | ||
137 | =cut | |
138 | ||
139 | sub FriendlyStage { | |
140 | my $self = shift; | |
141 | my $scrip_class = blessed($self->ScripObj); | |
142 | return $scrip_class->FriendlyStage($self->Stage); | |
143 | } | |
af59614d MKG |
144 | |
145 | =head2 SetScrip VALUE | |
146 | ||
147 | ||
148 | Set Scrip to VALUE. | |
149 | Returns (1, 'Status message') on success and (0, 'Error Message') on failure. | |
150 | (In the database, Scrip will be stored as a int(11).) | |
151 | ||
152 | =head2 Stage | |
153 | ||
154 | Returns the current value of Stage. | |
155 | (In the database, Stage is stored as varchar(32).) | |
156 | ||
157 | =head2 SetStage VALUE | |
158 | ||
159 | Set Stage to VALUE. | |
160 | Returns (1, 'Status message') on success and (0, 'Error Message') on failure. | |
161 | (In the database, Stage will be stored as a varchar(32).) | |
162 | ||
163 | =head2 ObjectId | |
164 | ||
165 | Returns the current value of ObjectId. | |
166 | (In the database, ObjectId is stored as int(11).) | |
167 | ||
168 | ||
169 | ||
170 | =head2 SetObjectId VALUE | |
171 | ||
172 | ||
173 | Set ObjectId to VALUE. | |
174 | Returns (1, 'Status message') on success and (0, 'Error Message') on failure. | |
175 | (In the database, ObjectId will be stored as a int(11).) | |
176 | ||
177 | ||
178 | =cut | |
179 | ||
180 | ||
181 | =head2 SortOrder | |
182 | ||
183 | Returns the current value of SortOrder. | |
184 | (In the database, SortOrder is stored as int(11).) | |
185 | ||
186 | ||
187 | ||
188 | =head2 SetSortOrder VALUE | |
189 | ||
190 | ||
191 | Set SortOrder to VALUE. | |
192 | Returns (1, 'Status message') on success and (0, 'Error Message') on failure. | |
193 | (In the database, SortOrder will be stored as a int(11).) | |
194 | ||
195 | ||
196 | =cut | |
197 | ||
198 | ||
199 | =head2 Creator | |
200 | ||
201 | Returns the current value of Creator. | |
202 | (In the database, Creator is stored as int(11).) | |
203 | ||
204 | ||
205 | =cut | |
206 | ||
207 | ||
208 | =head2 Created | |
209 | ||
210 | Returns the current value of Created. | |
211 | (In the database, Created is stored as datetime.) | |
212 | ||
213 | ||
214 | =cut | |
215 | ||
216 | ||
217 | =head2 LastUpdatedBy | |
218 | ||
219 | Returns the current value of LastUpdatedBy. | |
220 | (In the database, LastUpdatedBy is stored as int(11).) | |
221 | ||
222 | ||
223 | =cut | |
224 | ||
225 | ||
226 | =head2 LastUpdated | |
227 | ||
228 | Returns the current value of LastUpdated. | |
229 | (In the database, LastUpdated is stored as datetime.) | |
230 | ||
231 | ||
232 | =cut | |
233 | ||
234 | ||
235 | ||
236 | sub _CoreAccessible { | |
237 | { | |
238 | ||
239 | id => | |
240 | {read => 1, sql_type => 4, length => 11, is_blob => 0, is_numeric => 1, type => 'int(11)', default => ''}, | |
241 | Scrip => | |
242 | {read => 1, write => 1, sql_type => 4, length => 11, is_blob => 0, is_numeric => 1, type => 'int(11)', default => ''}, | |
243 | Stage => | |
244 | {read => 1, write => 1, sql_type => 12, length => 32, is_blob => 0, is_numeric => 0, type => 'varchar(32)', default => 'TransactionCreate'}, | |
245 | ObjectId => | |
246 | {read => 1, write => 1, sql_type => 4, length => 11, is_blob => 0, is_numeric => 1, type => 'int(11)', default => ''}, | |
247 | SortOrder => | |
248 | {read => 1, write => 1, sql_type => 4, length => 11, is_blob => 0, is_numeric => 1, type => 'int(11)', default => '0'}, | |
249 | Creator => | |
250 | {read => 1, auto => 1, sql_type => 4, length => 11, is_blob => 0, is_numeric => 1, type => 'int(11)', default => '0'}, | |
251 | Created => | |
252 | {read => 1, auto => 1, sql_type => 11, length => 0, is_blob => 0, is_numeric => 0, type => 'datetime', default => ''}, | |
253 | LastUpdatedBy => | |
254 | {read => 1, auto => 1, sql_type => 4, length => 11, is_blob => 0, is_numeric => 1, type => 'int(11)', default => '0'}, | |
255 | LastUpdated => | |
256 | {read => 1, auto => 1, sql_type => 11, length => 0, is_blob => 0, is_numeric => 0, type => 'datetime', default => ''}, | |
257 | ||
258 | } | |
259 | }; | |
260 | ||
261 | RT::Base->_ImportOverlays(); | |
262 | ||
263 | 1; |