<%doc> User Interface for Hosts <%args> $id => undef $user => $ui->get_current_user($r) $rr => undef $ipblock => undef $action => undef $zone => undef $submit => undef $add_ptr => undef $add_alias => undef $add_dhcp => undef $editattr => undef $editipblock => undef <%init> my $DEBUG = 0; print '%ARGS is

    ', Dumper(%ARGS), '

' if $DEBUG; my @rraddrs; my %rrs; my $edit; my $deleted_label; my $manager = $ui->get_permission_manager($r); if ( $id ) { $rr = RR->retrieve($id); $m->comp('/generic/error.mhtml', error=>"Could not retrieve RR id $id") unless $id; $rrs{$rr->id} = $rr; }elsif ( $rr ){ my @tmp; if ( ref($rr) eq 'ARRAY' ){ @tmp = @$rr; }else { push @tmp, $rr; $id = $rr; } foreach ( @tmp ){ $_ = RR->retrieve($_) unless ref($_); # Check if user can view this object unless ( $manager && $manager->can($user, "view", $_) ){ $m->comp('/generic/error.mhtml', error=>"You don't have permission to view this object"); } $rrs{$_->id} = $_; } } if ( $ipblock ) { $ipblock = Ipblock->objectify($ipblock); unless ( $manager && $manager->can($user, "view", $ipblock) ){ $m->comp('/generic/error.mhtml', error=>"You don't have permission to view this object"); } if (my @a_records = $ipblock->a_records()) { foreach my $arecord (@a_records) { $rrs{$arecord->rr->id} = $arecord->rr; } } } if ( $submit ){ if ( $rr && $action eq 'delete_confirm' ){ # Check if user can delete this object unless ( $manager && $manager->can($user, "delete", $rr) ){ $m->comp('/generic/error.mhtml', error=>"You don't have permission to delete this object"); } eval { Netdot::Model->do_transaction(sub{ my @ips = map { $_->ipblock } $rr->a_records(); $deleted_label = $rr->get_label(); delete $rrs{$rr->id}; $rr->delete(); undef $rr; $action = 'deleted'; }); }; if ( my $e = $@ ){ $m->comp('/generic/error.mhtml', error=>"$e"); } }elsif ($rr || $id || $ipblock || $action eq 'new') { # insert/update eval{ Netdot::Model->do_transaction(sub{ my $user_type = $user->getAttribute('USER_TYPE'); # For unprivileged users, we apply restrictions # on RR names if ( $user_type eq 'User' ){ foreach my $key ( %ARGS ){ if ( $key =~ /^RR__(?:NEW|\d+)__name$/ ){ RR->validate_name($ARGS{$key}); last; } } } my %ret = $ui->form_to_db(%ARGS); print 'form_to_db returned:

    ', Dumper(%ret), '

' if $DEBUG; if ( exists $ret{RR} ) { my $newid = (keys %{$ret{RR}{id}})[0]; defined $newid || die "Could not get record ID"; if ( $ret{RR}{id}{$newid}{action} eq 'INSERTED' ){ if(! $id){ $id = $newid; } if(! $rr){ $rr = $newid; } if (defined $ipblock) { RRADDR->insert({rr=>$newid, ipblock=>$ipblock}); } } # Add new RR to %rrs hash # Also, if RR was just updated, this re-reads it from the DB # to avoid the old values from showing up my $newrr = RR->retrieve($newid); $rrs{$newrr->id} = $newrr if ( defined $newrr && $id == $newid ); } }) }; if ( my $e = $@ ){ if ($e =~ /Error while inserting RRCNAME: Some values are duplicated./ ){ my $name = $ARGS{'RR__NEW__name'}; $e = "Alias ". $name . " already exists in the database."; } $m->comp('/generic/error.mhtml', error=>"$e"); } else { $submit = 0; $action = ""; } } } <%perl> print ''; if ( $rr && $action eq 'delete' ){ print '
'; print '
Delete Records
'; print '
'; print '

'; print 'Are you sure you want to delete the records below?'; print '

'; print '

'; print ''; print ''; print ' '; print ''; print '

'; print '
'; print '

'; } print '

'; my (@field_headers, @cell_data); print '
DNS Records
'; print '
'; if ($action eq 'new') { if ($ipblock) { print ''; } print ''; print ''; print ''; } elsif ($ipblock) { print '[new]'; } elsif (!($id || $rr || $ipblock)) { print '[add]'; }else{ print ' ' } print '
'; #close containderheadright print '
'; my %comphash = (field_headers=>\@field_headers, data=>\@cell_data, headercolwidth=>"15%", datacolwidth=>"85%"); if ($action eq 'new') { print '
'; print '
New Record
'; print '
'; $ui->add_to_fields(edit=>1, table=>'RR', fields=>['name'], field_headers=>\@field_headers, cell_data=>\@cell_data); my %ffargs = (table=>'RR', column=>'zone', edit=>1, linkPage=>'zone.html'); if ( defined $zone ){ $zone = Zone->objectify($zone); }elsif ( $ipblock ){ $ipblock = Ipblock->objectify($ipblock); $zone = $ipblock->forward_zone(); } # Make sure that user does not add a record to a zone for which # they don't have permissions my @select_list; if ( $zone ){ @select_list = ( $zone ); $ffargs{default} = $zone->id; } foreach my $z ( sort { $a->name cmp $b->name } Zone->retrieve_all ){ next if $z->is_dot_arpa; next unless $z->active; next if $zone && ($z->id == $zone->id); if ( $manager && $manager->can($user, 'edit', $z) ){ push @select_list, $z; } } # The list needs to have at least one item, otherwise # the form_field function will display all zones scalar @select_list or push(@select_list, undef); $ffargs{defaults} = \@select_list; unless ( $manager && $manager->can($user, 'access_section', 'new_zone_button') ){ $ffargs{new_button} = 0; } my %tmp = $ui->form_field(%ffargs); push( @field_headers, $tmp{label} ); push( @cell_data, $tmp{value} ); $m->comp('/generic/attribute_table.mhtml', %comphash); (@field_headers, @cell_data) = ((),()); print '
'; #close containerbody of 'new' print '
'; #close container of 'new' }elsif ( $action eq 'deleted' ){ print '

'; print 'Record '.$deleted_label.' has been deleted'; print '

'; print '
'; print '

'; }
<%perl> foreach my $o ( values %rrs ) { if ($action eq 'edit' && $rr->id == $o->id) { $edit = 1; } else { $edit = 0; } print ''; print '

'; print '
'.$o->get_label.'
'; print '
'; if ( $edit ) { print ''; print ''; } else { print '[refresh] '; if ( $manager && $manager->can($user, 'edit', $o) ){ print '[edit] '; } if ( $manager && $manager->can($user, "delete", $o) ){ print '[delete]'; } } print '
'; $ui->add_to_fields(edit=>$edit, o=>$o, fields=>['name', 'zone', 'active', 'info'], field_headers=>\@field_headers, cell_data=>\@cell_data, linkpages=>['', 'zone.html', '', '']); $ui->add_to_fields(edit=>0, o=>$o, fields=>['created', 'modified'], field_headers=>\@field_headers, cell_data=>\@cell_data); $ui->add_to_fields(edit=>$edit, o=>$o, fields=>['expiration'], field_headers=>\@field_headers, cell_data=>\@cell_data); if ( $manager && $manager->can($user, "access_section", 'host.html:auto_update') ){ if ( my $device = ($o->devices)[0] ){ push @field_headers, 'Device:'; push @cell_data, ''.$device->get_label.''; } $ui->add_to_fields(edit=>$edit, o=>$o, fields=>['auto_update'], field_headers=>\@field_headers, cell_data=>\@cell_data, ); } $m->comp('/generic/attribute_table.mhtml', %comphash, width=>2); (@field_headers, @cell_data) = ((),()); my @arecs = $o->a_records(); my @ips; ##################################################################################################### #RRADDR if ( $o->name eq '@' || $o->name eq $o->zone->name || (!$o->cnames && !$o->ptr_records) ){ print '
'; print '
Address '.$ui->table_descr_link('RRADDR', '(A/AAAA)'). '
'; print '
'; if ( $manager && $manager->can($user, "access_section", 'host.html:add_rraddr') ){ push( @field_headers, ("IP:", "TTL") ); push( @cell_data, "" ); push( @cell_data, "" ); my $newrraddr = $m->scomp('/generic/attribute_table.mhtml', %comphash, width=>2); (@field_headers, @cell_data) = ((),()); $newrraddr =~ s/\n//g; $newrraddr =~ s///g; $newrraddr =~ s/'/\\'/g; print '
'; print ' '; if ( !$edit ){ if ( $manager && $manager->can($user, 'edit', $o) ){ print '
[add]
'; } } }else{ print ' '; } print '
'; #close containerheadright #display/edit rraddr print '
'; foreach my $arecord (sort { $a->ipblock->address_numeric <=> $b->ipblock->address_numeric } @arecs) { my $ipblock = $arecord->ipblock; if ( int($ipblock) == 0 ){ # This record should not exist then $arecord->delete; next; } push @ips, $ipblock; push( @field_headers, "IP:"); push( @cell_data, "".$ipblock->address.""); $ui->add_to_fields(o=>$arecord, edit=>$edit, fields=>['ttl'], field_headers=>\@field_headers, cell_data=>\@cell_data, linkpages=>[''], with_delete=>1); $m->comp('/generic/attribute_table.mhtml', %comphash, width=>2); (@field_headers, @cell_data) = ((),()); } print '
'; print '
'; ################################################################ # DHCP host scopes # Do not show client id options unless the subnet has DHCP enabled foreach my $ipblock ( @ips ){ my $gscope; # global scope if ( $ipblock->parent && $ipblock->parent->dhcp_scopes ) { # Subnet is in DHCP $gscope = $ipblock->parent->dhcp_scopes->first->get_global; $m->comp('/generic/error.mhtml', error=>"Could not determine global scope for IP ". $ipblock->get_label) unless $gscope; }else{ next; } print '
'; print '
DHCP for '.$ipblock->address.'
'; print '
'; my $scope; if ( ($scope = $ipblock->dhcp_scopes->first) && ( $scope->physaddr() || $scope->duid ) ){ print ' '; }else{ if ( $add_dhcp ){ print ''; print ''; }else{ # Let user add a scope print ' '; if ( !$edit ){ if ( $manager && $manager->can($user, 'edit', $o) ){ print '[add]'; } } } } print '
'; print '
'; if ( $scope ){ my $t_width; if ( my $phys = $scope->physaddr() ){ # Show the MAC address push @field_headers, ('Ethernet: '); push( @cell_data, ''.$phys->address.'' ); if ( $edit ){ push @field_headers, 'Delete'; push @cell_data, ''; } $t_width = 2; }elsif ( $ipblock->version == 6 ){ push @field_headers, ('DUID: '); if ( $edit ){ push @cell_data, ''; }else{ push( @cell_data, $scope->duid ); } if ( $edit ){ push @field_headers, 'Delete'; push @cell_data, ''; } $t_width = 2; } $m->comp('/generic/attribute_table.mhtml', %comphash, width=>$t_width); (@field_headers, @cell_data) = ((),()); }else{ if ( $add_dhcp == $ipblock->id ){ # User wants to add a scope with this ip print ''; print ''; print ''; print ''; if ( $ipblock->version == 4 || ($ipblock->version == 6 && Netdot->config->get('DHCPD_ALLOW_ETHERNET_FOR_IPV6_HOST_DECL')) ){ push @field_headers, ('Ethernet: '); push( @cell_data, '' ); }elsif ( $ipblock->version == 6 ){ push @field_headers, ('DUID: '); push( @cell_data, '' ); } $m->comp('/generic/attribute_table.mhtml', %comphash, width=>1); (@field_headers, @cell_data) = ((),()); } } print '
'; } ##################################################################################################### #RRHINFO print '
'; print '
Hardware Information '. $ui->table_descr_link('RRHINFO', '(HINFO)').'
'; print '
'; my $cpu_defaults = $ui->config->get('DEFAULT_HINFO_CPU_VALUES'); my $os_defaults = $ui->config->get('DEFAULT_HINFO_OS_VALUES'); my $defaults = [ $cpu_defaults, $os_defaults ]; if ( !$o->hinfo_records ){ #new rrhinfo $ui->add_to_fields(table=>'RRHINFO', edit=>1, fields=>['cpu', 'os', 'ttl'], field_headers=>\@field_headers, cell_data=>\@cell_data, defaults =>$defaults, linkpages=>['view.html','view.html','']); my $newhinfo = $m->scomp('/generic/attribute_table.mhtml', %comphash, width=>2); (@field_headers, @cell_data) = ((),()); $newhinfo =~ s/\n//g; $newhinfo =~ s///g; $newhinfo =~ s/'/\\'/g; print '
'; print ' '; if ( !$edit ){ if ( $manager && $manager->can($user, 'edit', $o) ){ print '
[add]
'; } } }else{ print ' '; } print '
'; #close containerheadright #display/edit print '
'; if (my @hinfos = $o->hinfo_records()) { foreach my $hinfo (@hinfos) { $ui->add_to_fields(o=>$hinfo, edit=>$edit, fields=>['cpu', 'os', 'ttl'], field_headers=>\@field_headers, cell_data=>\@cell_data, defaults =>$defaults, linkpages=>['view.html','view.html',''], with_delete=>1 ); $m->comp('/generic/attribute_table.mhtml', %comphash, width=>2); (@field_headers, @cell_data) = ((),()); } } print '
'; print '
'; ##################################################################################################### #RRTXT print '
'; print '
Text Records '.$ui->table_descr_link('RRTXT', '(TXT)'). '
'; print '
'; #new rrtxt $ui->add_to_fields(table=>'RRTXT', edit=>1, fields=>['txtdata', 'ttl'], field_headers=>\@field_headers, cell_data=>\@cell_data, linkpages=>['view.html','']); my $newtxt = $m->scomp('/generic/attribute_table.mhtml', %comphash, width=>2); (@field_headers, @cell_data) = ((),()); $newtxt =~ s/\n//g; $newtxt =~ s///g; $newtxt =~ s/'/\\'/g; print '
'; print ' '; if ( !$edit ){ if ( $manager && $manager->can($user, 'edit', $o) ){ print '
[add]
'; } } print '
'; #close containerheadright #display/edit print '
'; if (my @txts = $o->txt_records()) { foreach my $txt (@txts) { $ui->add_to_fields(o=>$txt, edit=>$edit, fields=>['txtdata', 'ttl'], field_headers=>\@field_headers, cell_data=>\@cell_data, linkpages=>['view.html',''], with_delete=>1); $m->comp('/generic/attribute_table.mhtml', %comphash, width=>2); (@field_headers, @cell_data) = ((),()); } } print '
'; print '
'; ##################################################################################################### #RRMX print '
'; print '
Mail Exchangers '.$ui->table_descr_link('RRMX', '(MX)'). '
'; print '
'; #new rrmx $ui->add_to_fields(table=>'RRMX', edit=>1, fields=>['preference', 'exchange', 'ttl'], field_headers=>\@field_headers, cell_data=>\@cell_data, linkpages=>['', 'view.html','']); my $newmx = $m->scomp('/generic/attribute_table.mhtml', %comphash); (@field_headers, @cell_data) = ((),()); $newmx =~ s/\n//g; $newmx =~ s///g; $newmx =~ s/'/\\'/g; print '
'; print ' '; if ( !$edit ){ if ( $manager && $manager->can($user, 'edit', $o) ){ print '
[add]
'; } } print '
'; #close containerheadright #display/edit print '
'; if (my @mxs = sort { $a->preference <=> $b->preference } $o->mx_records()) { foreach my $mx (@mxs) { $ui->add_to_fields(o=>$mx, edit=>$edit, fields=>['preference', 'exchange', 'ttl'], field_headers=>\@field_headers, cell_data=>\@cell_data, linkpages=>['','view.html',''], with_delete=>1); $m->comp('/generic/attribute_table.mhtml', %comphash, width=>2); (@field_headers, @cell_data) = ((),()); } } print '
'; print '
'; ##################################################################################################### #RRMX pointing to $o if ( my @mxs = RRMX->search(exchange=>$o->get_label) ){ print '
'; print '
MX records pointing to '.$o->get_label.'
'; # display only print '
'; foreach my $mx ( sort { $a->rr->name cmp $b->rr->name } @mxs ) { $ui->add_to_fields(o=>$mx, edit=>0, fields=>['rr'], field_headers=>\@field_headers, cell_data=>\@cell_data, linkpages=>['host.html']); $m->comp('/generic/attribute_table.mhtml', %comphash, width=>1); (@field_headers, @cell_data) = ((),()); } print '
'; } ##################################################################################################### #RRCNAME for somewhere pointing to $o print '
'; print '
Aliases of '.$o->get_label.' '. $ui->table_descr_link('RRCNAME', '(CNAME)').'
'; print '
'; if ( $add_alias ){ print ''; print ''; }else{ print ' '; if ( !$edit ){ if ( $manager && $manager->can($user, 'edit', $o) ){ print '[add]'; } } } print '
'; #close containerheadright #new rrcname if ( $add_alias ){ push( @field_headers, ("Name", "TTL") ); print ''; print ''; print ''; print ''; push( @cell_data, '' ); push( @cell_data, '' ); $m->comp('/generic/attribute_table.mhtml', %comphash, width=>2); (@field_headers, @cell_data) = ((),()); } #display/edit print '
'; if ( my @cnames = RRCNAME->search(cname=>$o->get_label) ){ foreach my $cname ( sort { $a->rr->name cmp $b->rr->name } @cnames ) { $ui->add_to_fields(o=>$cname, edit=>0, fields=>['rr'], field_headers=>\@field_headers, cell_data=>\@cell_data, linkpages=>['host.html']); $ui->add_to_fields(o=>$cname, edit=>$edit, fields=>['ttl'], field_headers=>\@field_headers, cell_data=>\@cell_data, with_delete=>1); $m->comp('/generic/attribute_table.mhtml', %comphash, width=>2); (@field_headers, @cell_data) = ((),()); } } print '
'; } ##################################################################################################### #RRCNAME for aliases of $o ($o pointing to somewhere) # cannot have an A/AAAA record at the same time # the $o is unique in the cname table if ( !$o->a_records && !$o->ptr_records && !$o->ns_records ) { print '
'; print '
'.$o->get_label.' is an alias of '. $ui->table_descr_link('RRCNAME', '(CNAME)').'
'; print '
'; my @cnames = $o->cnames(); if ( !@cnames ){ #new rrcname (only add if there isn't one) $ui->add_to_fields(table=>'RRCNAME', edit=>1, fields=>['cname', 'ttl'], field_headers=>\@field_headers, cell_data=>\@cell_data, linkpages=>['view.html','']); my $newcname = $m->scomp('/generic/attribute_table.mhtml', %comphash); (@field_headers, @cell_data) = ((),()); $newcname =~ s/\n//g; $newcname =~ s///g; $newcname =~ s/'/\\'/g; print '
'; print ' '; if ( !$edit ){ if ( $manager && $manager->can($user, 'edit', $o) ){ print '
[add]
'; } } }else{ print ' '; } print '
'; #close containerheadright #display/edit print '
'; if ( @cnames ) { my $cname = $cnames[0]; # shouldn't be more than one, right? # Deal with cname field # The trick here is that the cname is a varchar field, so it could or # could not be referencing a record which exists in Netdot. # We let the user edit the text, but when not editing, we'll try # to find an existing RR and provide a hyperlink if found. if ( $edit ){ # Edit cname field $ui->add_to_fields(o=>$cname, edit=>1, fields=>['cname'], field_headers=>\@field_headers, cell_data=>\@cell_data); $m->comp('/generic/attribute_table.mhtml', %comphash); (@field_headers, @cell_data) = ((),()); }else{ if ( my $cnamerr = RR->search(name=>$cname->cname)->first ){ push @field_headers, "Canonical Name:"; push @cell_data, "".$cnamerr->get_label.""; }else{ push @field_headers, "Canonical Name:"; push @cell_data, $cname->cname; } } # Add TTL $ui->add_to_fields(o=>$cname, edit=>$edit, fields=>['ttl'], field_headers=>\@field_headers, cell_data=>\@cell_data); $m->comp('/generic/attribute_table.mhtml', %comphash); (@field_headers, @cell_data) = ((),()); } if (!$o->a_records()) { print '
'; } print '
'; } ##################################################################################################### # Restrict access to the following records # Unpriviledged users can only work on these records if they have permissions on the whole zone ##################################################################################################### if ( !$o->cnames && ($manager && ($manager->can($user, "edit", $o->zone) || $manager->can($user, "access_section", 'host.html:extra_records')) )){ ##################################################################################################### #RRPTR foreach my $arecord ( @arecs ) { next if int($arecord->ipblock) == 0; my $ipblock = $arecord->ipblock; # We can assume there is only one per IP my $ptr = $ipblock->ptr_records->first; print '
'; print '
Reverse for '.$ipblock->get_label.' '. $ui->table_descr_link('RRPTR', '(PTR)').'
'; print '
'; print ' '; if ( !$ptr ){ if ( !$edit ){ if ( $manager && $manager->can($user, 'edit', $o) ){ print '[add]'; } } } print '
'; #close containerheadright print '
'; if ( $add_ptr == $ipblock->id ){ # new rrptr my $rzone; if ( ($ipblock->parent != 0) && $ipblock->parent->reverse_zone ){ $rzone = $ipblock->parent->reverse_zone; } push( @field_headers, ("Name", "Zone", "Domain Name", "TTL") ); print ''; print ''; if ( $rzone ){ my $name = RRPTR->get_name(ipblock=>$ipblock, zone=>$rzone); push( @cell_data, '' ); }else{ push( @cell_data, '' ); } my $zone_select = '
"; push( @cell_data, $zone_select ); push( @cell_data, '' ); push( @cell_data, '' ); $m->comp('/generic/attribute_table.mhtml', %comphash); (@field_headers, @cell_data) = ((),()); print ''; print ''; } # display/edit if ( $ptr ) { $ui->add_to_fields(o=>$ptr, edit=>0, fields=>['rr', 'ptrdname', 'ttl'], field_headers=>\@field_headers, cell_data=>\@cell_data, linkpages=>['host.html', '', ''], with_delete=>1); $m->comp('/generic/attribute_table.mhtml', %comphash); (@field_headers, @cell_data) = ((),()); } print '
'; } ##################################################################################################### #RRNS if ( $o->name eq '@' || $o->name eq $o->zone->name || (!$o->a_records && !$o->ptr_records) ){ print '
'; print '
Name Servers '.$ui->table_descr_link('RRNS', '(NS)').'
'; print '
'; #new rrns $ui->add_to_fields(table=>'RRNS', edit=>1, fields=>['nsdname', 'ttl'], field_headers=>\@field_headers, cell_data=>\@cell_data, linkpages=>['view.html','']); my $newns = $m->scomp('/generic/attribute_table.mhtml', %comphash); (@field_headers, @cell_data) = ((),()); $newns =~ s/\n//g; $newns =~ s///g; $newns =~ s/'/\\'/g; print '
'; print ' '; if ( !$edit ){ if ( $manager && $manager->can($user, 'access_section', 'add_ns_records') && $manager->can($user, 'edit', $o) ){ print '
[add]
'; } } print '
'; #close containerheadright #display/edit print '
'; if (my @nss = $o->ns_records()) { my $ns_edit = $edit; unless ( $manager && $manager->can($user, 'access_section', 'edit_ns_records') && $manager->can($user, 'edit', $o) ){ # Do not allow edits unless they have permissions $ns_edit = 0; } foreach my $ns (@nss) { $ui->add_to_fields(o=>$ns, edit=>$ns_edit, fields=>['nsdname', 'ttl'], field_headers=>\@field_headers, cell_data=>\@cell_data, linkpages=>['view.html',''], with_delete=>1); $m->comp('/generic/attribute_table.mhtml', %comphash); (@field_headers, @cell_data) = ((),()); } } print '
'; print '
'; } ##################################################################################################### #RRDS if ( !$o->a_records && !$o->ptr_records ){ print '
'; print '
Delegation Signers '. $ui->table_descr_link('RRDS', '(DS)').'
'; print '
'; my @field_names = ('key_tag', 'algorithm', 'digest_type', 'digest', 'ttl'); #new rrds $ui->add_to_fields(table=>'RRDS', edit=>1, fields=>\@field_names, field_headers=>\@field_headers, cell_data=>\@cell_data, ); my $newds = $m->scomp('/generic/attribute_table.mhtml', %comphash); (@field_headers, @cell_data) = ((),()); $newds =~ s/\n//g; $newds =~ s///g; $newds =~ s/'/\\'/g; print '
'; print ' '; if ( !$edit ){ if ( $manager && $manager->can($user, 'access_section', 'add_ds_records') && $manager->can($user, 'edit', $o) ){ print '
[add]
'; } } print '
'; #close containerheadright #display/edit print '
'; if (my @dss = $o->ds_records()) { my $ds_edit = $edit; unless ( $manager && $manager->can($user, 'access_section', 'edit_ns_records') && $manager->can($user, 'edit', $o) ){ # Do not allow edits unless they have permissions $ds_edit = 0; } foreach my $ds (@dss) { $ui->add_to_fields(o=>$ds, edit=>$ds_edit, fields=>\@field_names, field_headers=>\@field_headers, cell_data=>\@cell_data, with_delete=>1); $m->comp('/generic/attribute_table.mhtml', %comphash); (@field_headers, @cell_data) = ((),()); } } print '
'; print '
'; } ##################################################################################################### #RRNAPTR if ( !$o->a_records && !$o->ptr_records && !$o->ns_records ){ print '
'; print '
Name Authority Pointer '. $ui->table_descr_link('RRNAPTR', '(NAPTR)').'
'; print '
'; #new rrnaptr $ui->add_to_fields(table=>'RRNAPTR', edit=>1, fields=>['order_field', 'preference', 'flags', 'services', 'regexpr', 'replacement', 'ttl'], field_headers=>\@field_headers, cell_data=>\@cell_data, linkpages=>['view.html','']); my $newnaptr = $m->scomp('/generic/attribute_table.mhtml', %comphash); (@field_headers, @cell_data) = ((),()); $newnaptr =~ s/\n//g; $newnaptr =~ s///g; $newnaptr =~ s/'/\\'/g; print '
'; print ' '; if ( !$edit ){ if ( $manager && $manager->can($user, 'edit', $o) ){ print '
[add]
'; } } print '
'; #close containerheadright #display/edit print '
'; if (my @naptrs = $o->naptr_records()) { foreach my $naptr (@naptrs) { $ui->add_to_fields(o=>$naptr, edit=>$edit, fields=>['order_field', 'preference', 'flags', 'services', 'regexpr', 'replacement', 'ttl'], field_headers=>\@field_headers, cell_data=>\@cell_data, linkpages=>['view.html','view.html',''], with_delete=>1); $m->comp('/generic/attribute_table.mhtml', %comphash); (@field_headers, @cell_data) = ((),()); } } print '
'; print '
'; } ##################################################################################################### #RRPTR (when the name is the PTR record's name) if ( !$o->a_records && !$o->ns_records ){ print '
'; print '
Pointer Records '. $ui->table_descr_link('RRPTR', '(PTR)').'
'; print '
'; #new rrptr push( @field_headers, "IP:"); push( @cell_data, ""); $ui->add_to_fields(table=>'RRPTR', edit=>1, fields=>['ptrdname', 'ttl'], field_headers=>\@field_headers, cell_data=>\@cell_data, linkpages=>['']); my $newptr = $m->scomp('/generic/attribute_table.mhtml', %comphash); (@field_headers, @cell_data) = ((),()); $newptr =~ s/\n//g; $newptr =~ s///g; $newptr =~ s/'/\\'/g; print '
'; print ' '; if ( !$edit ){ if ( $manager && $manager->can($user, 'edit', $o) ){ print '
[add]
'; } } print '
'; #close containerheadright #display/edit print '
'; if (my @ptrs = $o->ptr_records()) { foreach my $ptr (@ptrs) { push( @field_headers, "IP:"); if ($edit) { push( @cell_data, "" ); } else { push( @cell_data, "". $ptr->ipblock->address.""); } $ui->add_to_fields(o=>$ptr, edit=>$edit, fields=>['ptrdname', 'ttl'], field_headers=>\@field_headers, cell_data=>\@cell_data, linkpages=>['', ''], with_delete=>1); $m->comp('/generic/attribute_table.mhtml', %comphash); (@field_headers, @cell_data) = ((),()); } } print '
'; print '
'; } ##################################################################################################### #RRLOC if ( !$o->ptr_records && !$o->ns_records ){ print '
'; print '
Location Records '. $ui->table_descr_link('RRLOC', '(LOC)').'
'; print '
'; #new $ui->add_to_fields(table=>'RRLOC', edit=>1, fields=>['latitude', 'longitude', 'altitude', 'size', 'horiz_pre', 'vert_pre', 'ttl'], field_headers=>\@field_headers, cell_data=>\@cell_data, linkpages=>['view.html', 'view.html', 'view.html', 'view.html', 'view.html', 'view.html', ''], ); my $newloc = $m->scomp('/generic/attribute_table.mhtml', %comphash); (@field_headers, @cell_data) = ((),()); $newloc =~ s/\n//g; $newloc =~ s///g; $newloc =~ s/'/\\'/g; print '
'; print ' '; if ( !$edit ){ if ( $manager && $manager->can($user, 'edit', $o) ){ print '
[add]
'; } } print '
'; #close containerheadright #display/edit print '
'; if (my @locs = $o->loc_records()) { foreach my $loc (@locs) { $ui->add_to_fields(o=>$loc, edit=>$edit, fields=>['latitude', 'longitude', 'altitude', 'size', 'horiz_pre', 'vert_pre', 'ttl'], field_headers=>\@field_headers, cell_data=>\@cell_data, linkpages=>['view.html', 'view.html', 'view.html', 'view.html', 'view.html', 'view.html', ''], with_delete=>1 ); $m->comp('/generic/attribute_table.mhtml', %comphash); (@field_headers, @cell_data) = ((),()); } } print '
'; print '
'; } ##################################################################################################### #RRSRV # Only show this part if owner name follows valid format if ( $o->name =~ /^_.+\._.+/ ){ print '
'; print '
Service Records '. $ui->table_descr_link('RRSRV', '(SRV)').'
'; print '
'; #new rrsrv $ui->add_to_fields(table=>'RRSRV', edit=>1, fields=>['priority', 'weight', 'port', 'target', 'ttl'], field_headers=>\@field_headers, cell_data=>\@cell_data, linkpages=>['view.html','view.html','view.html','view.html','']); my $newsrv = $m->scomp('/generic/attribute_table.mhtml', %comphash); (@field_headers, @cell_data) = ((),()); $newsrv =~ s/\n//g; $newsrv =~ s///g; $newsrv =~ s/'/\\'/g; print '
'; print ' '; if ( !$edit ){ if ( $manager && $manager->can($user, 'edit', $o) ){ print '
[add]
'; } } print '
'; #close containerheadright #display/edit print '
'; if (my @srvs = $o->srv_records()) { foreach my $srv (@srvs) { $ui->add_to_fields(o=>$srv, edit=>$edit, fields=>['priority', 'weight', 'port', 'target', 'ttl'], field_headers=>\@field_headers, cell_data=>\@cell_data, with_delete=>1); $m->comp('/generic/attribute_table.mhtml', %comphash); (@field_headers, @cell_data) = ((),()); } } print '
'; print '
'; } } # close restrict if print '
'; #close container print '
'; } print ''; #close outer containerbody print ''; print ''; #close outer container