%# A banker is a fellow who lends you his umbrella when the sun is shining %# and wants it back the minute it begins to rain. %# -- Mark Twain <& /Edit/Elements/104Header, Buttons => [ Add => "index.html?Action-Add=1", Save => ($Queue ? "javascript:document.getElementById('mainform').submit()" : ''), Delete => '', Copy => '', Search => '', ], Method => 'POST', &>

<& /Edit/Elements/Tab, Text => 'Queues' &>
<& /Edit/Elements/Tabs, Map => $ARGS{Map}, URL => '/Edit/Queues/Basic/' &>
<&|/l&>Queue Name: <% $QueueObj->Name %>
<& /Edit/Elements/Tabs, Name => 'Map2', Map => $ARGS{Map2}, URL => '../Basic/' &>
<& Top, Item => $QueueObj, List => $List, Categories => \%Categories, Users => $Users, Owner => $Owner &>

<%INIT> my %Categories; my $Queues = RT::Queues->new($session{'CurrentUser'}); $Queues->UnLimit; $Categories{$_}++ for @{ $Queues->Categories }; while (my $queue = $Queues->Next) { my $descr = $queue->Description; $Categories{$descr}++ if length $descr; } my $List = [ sort keys %Categories ]; $Queues->SetCategories( $List ); if ($Action eq 'Add') { # create a new Queue! $QueueObj = RT::Queue->new($session{'CurrentUser'}); $QueueObj->Load('(new)'); if (!$QueueObj->Id) { $QueueObj->Create( Name => '(new)', Description => $List->[0], Disabled => 0, ); } $Queue = $QueueObj->Id; $QueueObj->UpdateCompany; } elsif ($Action eq 'Delete' and $QueueObj->Id) { $QueueObj->SetDisabled(1); return $m->comp('/Edit/Queues/index.html'); } elsif ($Action eq 'Save' and $QueueObj->Id) { # update the current queue foreach my $method (grep /^Set/, keys %ARGS) { my $key = substr($method, 3); $QueueObj->$method($ARGS{$method}) unless $QueueObj->$key eq $ARGS{$method}; } foreach my $method (grep /^Attr/, keys %ARGS) { my $key = substr($method, 4); $QueueObj->SetAttribute($key => $ARGS{$method}); } } my $Owner = $RT::Nothing; my $Users = []; my $AdminCc; if ($QueueObj != $RT::Nothing) { $AdminCc = $QueueObj->AdminCc; $Owner = $AdminCc->UserMembersObj->First || $RT::Nothing; } <%ARGS> $Action => "Save" $Queue => undef $QueueObj => undef