#!/usr/local/bin/perl
# edit_record.cgi
# Edit an existing record of some type

require './bind8-lib.pl';
&ReadParse();
$conf = &get_config();
if ($in{'view'} ne '') {
	$view = $conf->[$in{'view'}];
	$conf = $view->{'members'};
	}
$zconf = $conf->[$in{'index'}];
$dom = $conf->[$in{'index'}]->{'value'};
%access = &get_module_acl();
&can_edit_zone(\%access, $conf->[$in{'index'}], $view) ||
	&error($text{'recs_ecannot'});
$type = &find("type", $zconf->{'members'})->{'value'};
$file = &find("file", $zconf->{'members'})->{'value'};
@recs = &read_zone_file($file, $dom);
$rec = $recs[$in{'num'}];
&can_edit_type($rec->{'type'}, \%access) ||
	&error($text{'recs_ecannottype'});

$desc = &text('edit_header', &ip6int_to_net(&arpa_to_ip($dom)));
&ui_print_header($desc, &text('edit_title', $text{"edit_".$rec->{'type'}} || $rec->{'type'}), "");

&record_input($in{'index'}, $in{'view'}, $in{'type'}, $file,
	      $zconf->{'value'}, $in{'num'}, $rec);
&ui_print_footer("", $text{'index_return'},
	"edit_$type.cgi?index=$in{'index'}&view=$in{'view'}",
	$text{'recs_return'},
	"edit_recs.cgi?index=$in{'index'}&type=$in{'type'}",
	$text{'edit_return'});

