3 # Delete an existing view and all its zones
5 require './bind8-lib.pl';
7 $parent = &get_config_parent();
8 $conf = $parent->{'members'};
9 $vconf = $conf->[$in{'index'}];
10 $access{'views'} || &error($text{'view_ecannot'});
12 if (!$in{'confirm'}) {
13 # Ask the user if he is sure ..
14 &ui_print_header(undef, $text{'vdelete_title'}, "");
16 # Build input for moving zones to another view
17 @zones = &find("zone", $vconf->{'members'});
19 @moveopts = ( [ 0, $text{'vdelete_delete'} ],
20 [ 1, $text{'vdelete_root'} ] );
21 @views = &find("view", $conf);
23 push(@moveopts, [ 2, $text{'vdelete_move'}." ".
24 &ui_select("newview", undef,
25 [ map { [ $_->{'index'}, $_->{'value'} ] }
26 grep { $_->{'index'} != $in{'index'} }
29 $movefield = "<b>$text{'vdelete_newview'}</b> ".
30 &ui_radio("mode", 1, \@moveopts);
34 print &ui_confirmation_form("delete_view.cgi",
35 &text(@zones ? 'vdelete_mesg' : 'vdelete_mesg2',
36 "<tt>$vconf->{'value'}</tt>"),
37 [ [ 'index', $in{'index'} ] ],
38 [ [ 'confirm', $text{'view_delete'} ] ],
41 &ui_print_footer("", $text{'index_return'});
45 # deal with the zones in this view
46 @zones = &find("zone", $vconf->{'members'});
47 if ($in{'mode'} == 1) {
49 $dest = &get_config_parent(&add_to_file());
52 # Adding to some other view
53 $dest = $conf->[$in{'newview'}];
55 &lock_file(&make_chroot($dest->{'file'}));
57 local $type = &find_value("type", $z->{'members'});
58 next if (!$type || $type eq 'hint');
59 if ($in{'mode'} == 0) {
60 # Delete the records file, and perhaps journal
61 local $f = &find_value("file", $z->{'members'});
63 &delete_records_file($f->{'value'});
67 # Move to another view or the top level.
70 &save_directive($dest, undef, [ $z ], $in{'mode'} == 2 ? 1 : 0);
74 # remove the view directive
75 &lock_file(&make_chroot($vconf->{'file'}));
76 &save_directive($parent, [ $vconf ], [ ]);
79 &webmin_log("delete", "view", $vconf->{'value'}, \%in);