#!/usr/local/bin/perl # edit_user.cgi # Display a form for editing a user, or creating a new user require './cluster-useradmin-lib.pl'; use Time::Local; &ReadParse(); &foreign_require("useradmin", "user-lib.pl"); @hosts = &list_useradmin_hosts(); @servers = &list_servers(); if ($in{'host'} ne '') { ($host) = grep { $_->{'id'} == $in{'host'} } @hosts; local ($u) = grep { $_->{'user'} eq $in{'user'} } @{$host->{'users'}}; %uinfo = %$u; } else { foreach $h (@hosts) { local ($u) = grep { $_->{'user'} eq $in{'user'} } @{$h->{'users'}}; if ($u) { $host = $h; %uinfo = %$u; last; } } } ($serv) = grep { $_->{'id'} == $host->{'id'} } @servers; $desc = &text('uedit_host', $serv->{'desc'} ? $serv->{'desc'} : $serv->{'host'}); &ui_print_header(undef, $text{'uedit_title'}, ""); # build list of used shells foreach $h (@hosts) { foreach $u (@{$h->{'users'}}) { push(@shlist, $u->{'shell'}) if ($u->{'shell'}); } } open(SHELLS, ") { s/\r|\n//g; s/#.*$//; push(@shlist, $_) if (/\S/); } close(SHELLS); print "
\n";
print &ui_hr();
print &ui_subheading($text{'uedit_hosts'});
if ($config{'table_mode'}) {
# Show as table
print &ui_columns_start([ $text{'index_thost'},
$text{'index_tdesc'},
$text{'index_ttype'} ]);
foreach $h (@hosts) {
local ($s) = grep { $_->{'id'} == $h->{'id'} } @servers;
next if (!$s);
local ($type) = grep { $_->[0] eq $s->{'type'} }
@servers::server_types;
local ($link) = $config{'conf_host_links'} ?
&ui_link("edit_host.cgi?id=$h->{'id'}",($s->{'host'} || &get_system_hostname())) :
($s->{'host'} || &get_system_hostname());
print &ui_columns_row([
$link,
$s->{'desc'},
$type->[1],
]);
}
print &ui_columns_end();
}
else {
# Show as icons
&icons_table(\@links, \@titles, \@icons);
print "
";
}
&ui_print_footer("", $text{'index_return'});
# date_input(day, month, year, prefix)
sub date_input
{
print "";
print "/";
print "/";
print &date_chooser_button("$_[3]d", "$_[3]m", "$_[3]y");
}