1 # BEGIN BPS TAGGED BLOCK {{{
5 # This software is Copyright (c) 1996-2015 Best Practical Solutions, LLC
6 # <sales@bestpractical.com>
8 # (Except where explicitly superseded by other copyright notices)
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
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.
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.
30 # CONTRIBUTION SUBMISSION POLICY:
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.)
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.
47 # END BPS TAGGED BLOCK }}}
52 package RT::ObjectCustomField;
53 use base 'RT::Record::AddAndSort';
56 use RT::ObjectCustomFields;
58 sub Table {'ObjectCustomFields'}
60 sub ObjectCollectionClass {
63 return $args{'CustomField'}->CollectionClassFromLookupType;
66 # XXX: Where is ACL check when we create a record?
70 Returns the CustomField Object which has the id returned by CustomField
76 my $id = shift || $self->CustomField;
78 # To find out the proper context object to load the CF with, we need
79 # data from the CF -- namely, the record class. Go find that as the
81 my $system_CF = RT::CustomField->new( RT->SystemUser );
82 $system_CF->Load( $id );
83 my $class = $system_CF->RecordClassFromLookupType;
85 my $obj = $class->new( $self->CurrentUser );
86 $obj->Load( $self->ObjectId );
88 my $CF = RT::CustomField->new( $self->CurrentUser );
89 $CF->SetContextObject( $obj );
98 my $res = $self->CollectionClass->new( $self->CurrentUser );
99 $res->LimitToLookupType(
100 ($args{'CustomField'} || $self->CustomFieldObj)->LookupType
107 Returns the current value of id.
108 (In the database, id is stored as int(11).)
116 Returns the current value of CustomField.
117 (In the database, CustomField is stored as int(11).)
121 =head2 SetCustomField VALUE
124 Set CustomField to VALUE.
125 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
126 (In the database, CustomField will be stored as a int(11).)
134 Returns the current value of ObjectId.
135 (In the database, ObjectId is stored as int(11).)
139 =head2 SetObjectId VALUE
142 Set ObjectId to VALUE.
143 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
144 (In the database, ObjectId will be stored as a int(11).)
152 Returns the current value of SortOrder.
153 (In the database, SortOrder is stored as int(11).)
157 =head2 SetSortOrder VALUE
160 Set SortOrder to VALUE.
161 Returns (1, 'Status message') on success and (0, 'Error Message') on failure.
162 (In the database, SortOrder will be stored as a int(11).)
170 Returns the current value of Creator.
171 (In the database, Creator is stored as int(11).)
179 Returns the current value of Created.
180 (In the database, Created is stored as datetime.)
188 Returns the current value of LastUpdatedBy.
189 (In the database, LastUpdatedBy is stored as int(11).)
197 Returns the current value of LastUpdated.
198 (In the database, LastUpdated is stored as datetime.)
205 sub _CoreAccessible {
209 {read => 1, sql_type => 4, length => 11, is_blob => 0, is_numeric => 1, type => 'int(11)', default => ''},
211 {read => 1, write => 1, sql_type => 4, length => 11, is_blob => 0, is_numeric => 1, type => 'int(11)', default => ''},
213 {read => 1, write => 1, sql_type => 4, length => 11, is_blob => 0, is_numeric => 1, type => 'int(11)', default => ''},
215 {read => 1, write => 1, sql_type => 4, length => 11, is_blob => 0, is_numeric => 1, type => 'int(11)', default => '0'},
217 {read => 1, auto => 1, sql_type => 4, length => 11, is_blob => 0, is_numeric => 1, type => 'int(11)', default => '0'},
219 {read => 1, auto => 1, sql_type => 11, length => 0, is_blob => 0, is_numeric => 0, type => 'datetime', default => ''},
221 {read => 1, auto => 1, sql_type => 4, length => 11, is_blob => 0, is_numeric => 1, type => 'int(11)', default => '0'},
223 {read => 1, auto => 1, sql_type => 11, length => 0, is_blob => 0, is_numeric => 0, type => 'datetime', default => ''},
228 sub FindDependencies {
230 my ($walker, $deps) = @_;
232 $self->SUPER::FindDependencies($walker, $deps);
234 $deps->Add( out => $self->CustomFieldObj );
236 if ($self->ObjectId) {
237 my $class = $self->CustomFieldObj->RecordClassFromLookupType;
238 my $obj = $class->new( $self->CurrentUser );
239 $obj->Load( $self->ObjectId );
240 $deps->Add( out => $obj );
247 my %store = $self->SUPER::Serialize(@_);
249 if ($store{ObjectId}) {
250 my $class = $self->CustomFieldObj->RecordClassFromLookupType;
251 my $obj = $class->new( RT->SystemUser );
252 $obj->Load( $store{ObjectId} );
253 $store{ObjectId} = \($obj->UID);
259 RT::Base->_ImportOverlays();