%# 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 => ($RT::Foundry ? '' : "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->OrderBy(FIELD => 'Name'); $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 if $QueueObj->can('UpdateCompany'); $m->redirect("?Queue=$Queue"); } elsif ($Action eq 'Delete' and $QueueObj->Id) { $QueueObj->SetDisabled(1); $m->redirect('/Edit/Queues/'); } elsif ($Action eq 'Save' and $r->method eq 'POST') { # 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}); } $m->redirect("?Queue=$Queue"); } my $Owner = $RT::Nothing; my $Users = []; my $AdminCc; if ($QueueObj != $RT::Nothing) { $AdminCc = $QueueObj->AdminCc; if (!$AdminCc->Id) { # try to patch bug caused by b0rked Queue::Create $QueueObj->_CreateQueueGroups; $AdminCc = $QueueObj->AdminCc; } $Owner = $AdminCc->UserMembersObj->First || $RT::Nothing; } <%ARGS> $Action => "Save" $Queue => undef $QueueObj => undef