[!
use strict;
use PVE::pvecfg;
use PVE::I18N;
use PVE::ConfigServer;
use PVE::HTMLForm;
use PVE::HTMLUtils;
!]
[-
use strict;
sub html_table_line {
my ($v1, $v2, $v3, $v4) = @_;
$v1 = " " if !$v1;
$v2 = " " if !$v2;
$v3 = " " if !$v3;
$v4 = " " if !$v4;
my $html = '
';
$html .= "$v1 | $v2 | ";
$html .= " | $v3 | $v4 |
\n";
return $html;
}
my $out = '';
my $form = PVE::HTMLForm->new (\%fdat);
my $conn = PVE::ConfigClient::connect ();
my $mailto;
if ($form->action eq 'save') {
eval {
check_write_mode ($udat{AM});
# verify email list
$fdat{email} =~ s/[,;]/ /g;
my @alist = split (/\s+/, $fdat{email});
foreach my $email (@alist) {
PVE::HTMLUtils::check_field (__("Administrator EMail"), $email, 'EMAIL');
}
$fdat{email} = join (',', @alist);
if ($fdat{newpwd1}) {
die __("Passwords does not match") . "\n" if $fdat{newpwd1} ne $fdat{newpwd2};
die __("Password is too short") . "\n" if $fdat{newpwd1} && length ($fdat{newpwd1}) < 5;
}
$mailto = $conn->get_config_data ('dotforward')->result;
if ($mailto ne $fdat{email}) {
$conn->set_config_data ('dotforward', $fdat{email});
}
if ($fdat{newpwd1}) {
$conn->modify_user ('root', undef, $fdat{newpwd1});
}
};
$udat{popup_error} = $@ if $@;
}
# always reread
$mailto = $conn->get_config_data ('dotforward')->result;
$out .= $form->create_header();
my $html = '';
$html .= html_table_line (__("Administrator EMail") . ':',
$form->create_element('email', 'text',
$fdat{email} || $mailto));
$html .= html_table_line (__("Password") . ':',
$form->create_element ('newpwd1', 'password', $fdat{newpwd1}));
$html .= html_table_line (__("Confirm Password") . ':',
$form->create_element ('newpwd2', 'password', $fdat{newpwd2}));
$html .= "
";
$html .= $form->create_cmdbutton ('save');
$out .= PVE::HTMLUtils::create_statusframe (undef, __("Administrator Options"), undef, $html);
$out .= $form->create_footer();
print OUT $out;
-]