<%doc> Zone UI % % <%attr> title => 'Zone' section => 'Management' % % <%args> $id $user => $ui->get_current_user($r) $view => undef $edit => undef $submit => undef $bulk_import_data => undef $import_overwrite => undef % % <%init> my $DEBUG = 0; print '%ARGS is

    ', Dumper(%ARGS), '

' if $DEBUG; my $o = Zone->retrieve($id); unless ( $o ){ $m->comp('/generic/error.mhtml', error=>"Cannot retrieve zone id $id"); } # Check if user can view this object my $manager = $ui->get_permission_manager($r); unless ( $manager && $manager->can($user, "view", $o) ){ $m->comp('/generic/error.mhtml', error=>"You don't have permission to view zone ".$o->name); } if ( $submit ){ if ($edit eq 'bulk_import'){ unless ( $bulk_import_data ){ $m->comp('/generic/error.mhtml', error=>"Empty import data"); } # Do this atomically eval { Netdot::Model->do_transaction(sub{ $o->import_records(text=>$bulk_import_data, overwrite=>$import_overwrite) }); }; if ( my $e = $@ ){ $m->comp('/generic/error.mhtml', error=>$e); }else{ $submit = 0; # So we display zone below } } } % if ( !$submit ){
%###########################################################################
Zone <% $o->name %>
[refresh] % if ( $manager && $manager->can($user, 'access_admin_section', 'zone.html:buttons') ){ [new] % } % if ( $manager && $manager->can($user, 'edit', $o) ){ [edit] % } % if ( $manager && $manager->can($user, 'delete', $o) ){ [delete] % } [text]
<& /generic/form.mhtml, table=>"Zone", id=>$id, edit=>0 &>
%########################################################################### % my @headers; % my @rows; % my $count = $o->get_record_count();
Record Count
% my $total = 0; % foreach my $rtype ( sort keys %$count ){ % $total += $count->{$rtype}; % push @headers, uc($rtype); % push @rows, $count->{$rtype}; % } % push @headers, 'TOTAL'; % push @rows, $total; % $m->comp('/generic/attribute_table.mhtml', width=>"4", field_headers=>\@headers, data=>\@rows);
%########################################################################### %# This zone's records % if ( my $at = RR->search(name=>'@', zone=>$id)->first ){ % if ( my @a_records = $at->arecords ){
Address Records
<& /generic/sortresults.mhtml, object=>\@a_records &>
% } % if ( my @nslist = $at->ns_records ){
Name Servers (NS)
<& /generic/sortresults.mhtml, object=>\@nslist &>
% } % if ( my @mxlist = $at->mx_records ){
Mail Exchangers (MX)
<& /generic/sortresults.mhtml, object=>\@mxlist &>
% } % if ( my @loc = $at->loc_records ){
Location (LOC)
<& /generic/sortresults.mhtml, object=>\@loc &>
% } % } % # Check if user can access this section % if ( $manager && $manager->can($user, "access_section", 'zone.html:subnets') ){ %########################################################################### % my @sz = $o->subnets;
IP Blocks
% if ( $edit eq 'ipblocks' ){
% }else{
% if ( $manager && $manager->can($user, 'access_admin_section', 'zone.html:buttons') ){ [edit] [add] % }
% } <& /generic/sortresults.mhtml, object=>\@sz, withedit=>($edit eq 'ipblocks')? 1 : 0 &>
% }
Records
% if ( $manager && $manager->can($user, 'edit', $o) ){ [add] [import] % } % if ( $view eq 'records' ){ % if ( $edit ne 'records' ){ % if ( $manager && $manager->can($user, 'edit', $o) ){ [edit] % } % } % }else{ [view] % }
<%perl> if ( $view eq 'records' || $edit eq 'records' ){ my $records = $o->get_hosts(); print '
'; $m->comp('/management/hostlist.mhtml', records=>$records, withedit=>($edit eq 'records')? 1 : 0, return_args=>"?id=$id", dot_arpa=>$o->is_dot_arpa); print '
'; print '
'; }
Pending Changes
% if ( $view eq 'pending_changes' ){ % }else{ [view] % }
% if ( $view eq 'pending_changes' ){ % my @pending_changes = HostAudit->search_where( % { zone => $o, % pending => 1 }, % { order_by => 'tstamp DESC' }); <& /generic/sortresults.mhtml, object=>\@pending_changes, withedit=>0 &> % }
Recent Changes
% if ( $view eq 'recent_changes' ){ % }else{ [view] % }
% if ( $view eq 'recent_changes' ){ % my @audit_records = HostAudit->search_where( % { zone => $o }, % { order_by => 'tstamp DESC', % limit_dialect => 'LimitXY', % limit => '50' }); <& /generic/sortresults.mhtml, object=>\@audit_records, withedit=>0 &> % }
% if ( $view eq 'bulk_import' ){

; Copy zone data here (BIND format)

Overwrite existing records of same name

% } % }