%# BEGIN LICENSE BLOCK %# %# Copyright (c) 1996-2002 Jesse Vincent %# %# (Except where explictly superceded by other copyright notices) %# %# This work is made available to you under the terms of Version 2 of %# the GNU General Public License. A copy of that license should have %# been provided with this software, but in any event can be snarfed %# from www.gnu.org %# %# This work is distributed in the hope that it will be useful, but %# WITHOUT ANY WARRANTY; without even the implied warranty of %# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU %# General Public License for more details. %# %# %# Unless otherwise specified, all modifications, corrections or %# extensions to this work which alter its source code become the %# property of Best Practical Solutions, LLC when submitted for %# inclusion in the work. %# %# %# END LICENSE BLOCK <& /RTFM/Admin/Elements/ClassTabs, id => $ClassObj->id, Title => loc('Admin/Class/CustomFields') &> <& /Elements/ListActions, actions => \@results &> <& /Elements/TitleBoxStart, title => $title &>
% while (my $cf = $CustomFields->Next) { % my $class_cf = RT::FM::ClassCustomField->new($session{'CurrentUser'}); % $class_cf->LoadByCols(Class => $ClassObj->Id, CustomField => $cf->Id); % }
Id) { CHECKED % } > <%loc($cf->Type)%> <%$cf->Name%>
<%$cf->Description%>
<& /Elements/TitleBoxEnd &> <& /Elements/Submit &>
<%INIT> my $ClassObj = new RT::FM::Class( $session{'CurrentUser'} ); my ( $title, @results ); $ClassObj->Load($ARGS{'id'}) || $m->comp("/RTFM/Elements/Error", Why => "Couldn't load class '$id'"); my $ClassCFs = $ClassObj->CustomFields; my $CustomFields = RT::FM::CustomFieldCollection->new( $session{'CurrentUser'} ); $CustomFields->UnLimit; $title = loc( 'Edit Custom Fields for Class [_1]', $ClassObj->Name ); if ($ARGS{'UpdateCFs'} ) { while (my $cf = $CustomFields->Next) { # Go through and delete all the custom field relationships that this class # no longer has if ($ClassCFs->HasEntry($cf->Id)) { unless (defined $ARGS{"Class-".$ClassObj->Id."-CF-".$cf->Id} ) { my ($val, $msg) = $cf->RemoveFromClass($ClassObj->Id); push (@results, $msg); } } else { # if the class doesn't have the custom field yet if ($ARGS{"Class-".$ClassObj->Id."-CF-".$cf->Id} ) { my ($val, $msg) = $cf->AddToClass($ClassObj->Id); push (@results, $msg); } } if (defined $ARGS{"Class-".$ClassObj->Id."-CF-".$cf->Id} ) { my ($val, $msg) = $cf->SetSortOrderForClass(Class => $ClassObj->Id, SortOrder => $ARGS{"Class-".$ClassObj->Id."-CF-".$cf->Id."-SortOrder"}); } } } # We've made changes. refresh the object $ClassCFs = $ClassObj->CustomFields; <%ARGS> $id => undef $result => undef