%# 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 <& /Admin/Elements/Header, Title => loc('Edit Custom Fields for [_1]', $Queue->Name) &> <& /Admin/Elements/QueueTabs, id => $Queue->id &> <& /Elements/ListActions, actions => \@results &> <& /Elements/TitleBoxStart, title => loc('Edit Custom Fields for [_1]', $Queue->Name) &>
  • <&|/l&>Create a new Custom Field

    % while (my $CustomFieldObj = $CustomFields->Next) {
  • <%$CustomFieldObj->id%>/<% loc($CustomFieldObj->Type) %>/<%$CustomFieldObj->Name%>: <%$CustomFieldObj->Description%>
    %} <& /Elements/TitleBoxEnd &> <%INIT> my $Queue = new RT::Queue($session{'CurrentUser'}); $Queue->Load($id); if ($CustomField and $Move) { my $SourceObj = RT::CustomField->new($session{'CurrentUser'}); $SourceObj->Load($CustomField) || Abort(loc('No CustomField')); my $target_order = $SourceObj->SortOrder + $Move; my $CustomFields = $Queue->CustomFields; my $TargetObj; while (my $CustomFieldObj = $CustomFields->Next) { $TargetObj = $CustomFieldObj if $CustomFieldObj->SortOrder == $target_order; } if ($TargetObj) { # swap their sort order $SourceObj->SetSortOrder($target_order); $TargetObj->SetSortOrder($target_order - $Move); } } my $CustomFields = $Queue->CustomFields; # now process the 'copy queue' action. my @results; if ($Source and $Source ne $id) { my $SourceQueue = new RT::Queue($session{'CurrentUser'}); $SourceQueue->Load($Source); my $SourceCustomFields = $SourceQueue->CustomFields; # delete old fields foreach my $CustomFieldObj ( @{$CustomFields->ItemsArrayRef} ) { $CustomFieldObj->Delete; } # add new fields while (my $SourceCustomFieldObj = $SourceCustomFields->Next) { my $CustomFieldObj = RT::CustomField->new($session{'CurrentUser'}); my ($val, $msg) = $CustomFieldObj->Create( id => $SourceCustomFieldObj->id, Queue => $id, Name => $SourceCustomFieldObj->Name, Type => $SourceCustomFieldObj->Type, Description => $SourceCustomFieldObj->Description, ); Abort(loc("Could not create CustomField") . ": $msg") unless ($val); push @results, $msg; $CustomFieldObj->SetSortOrder($SourceCustomFieldObj->SortOrder); # add new values my $values = $SourceCustomFieldObj->Values(); while (my $v = $values->Next) { my ( $addval, $addmsg ) = $CustomFieldObj->AddValue( Name => $v->Name, Description => $v->Description, SortOrder => $v->SortOrder ); # push ( @results, $addmsg ); } } } <%ARGS> $id => undef $Move => undef $Source => undef $CustomField => undef