<%once>;
my $widget = 'profile';
</%once>
<%args>
$id => undef
</%args>
<%init>;

if ($ARGS{id} or $ARGS{site_id}) {
    $m->comp('edit.html', widget => $widget,
                          id     => $id,
                          %ARGS);
} else {
    # Get a list of sites that we have EDIT access to
    my $sites = $c->get('__SITES__');

    unless ($sites) {
        $sites = Bric::Biz::Site->list({ active => 1 });
        $c->set('__SITES__', $sites);
    }

    $sites = [grep { chk_authz($_, EDIT, 1) } @$sites];

    # If there is only one site, skip the site chooser screen
    if (@$sites == 1) {
        $ARGS{site_id} = $sites->[0]->get_id;
        $m->comp('edit.html', widget => $widget,
                              id     => $id,
                              %ARGS);
    } else {
        $m->comp('new.html', widget => $widget,
                             id     => $id,
                             sites  => $sites);
    }
}
</%init>
<%doc>
###############################################################################

=head1 NAME

/admin/profile/category/dhandler - Interface for managing categories.

=head1 VERSION

$LastChangedRevision$

=head1 DATE

$LastChangedDate$

=head1 DESCRIPTION

This element handles the display for editing categories.

=cut

</%doc>
