%# BEGIN LICENSE BLOCK %# %# Copyright (c) 2002-2003 Jesse Vincent %# %# This program is free software; you can redistribute it and/or modify %# it under the terms of version 2 of the GNU General Public License %# as published by the Free Software Foundation. %# %# A copy of that license should have arrived with this %# software, but in any event can be snarfed from www.gnu.org. %# %# This program 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. %# %# 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