| Revision 2 (by moose, 2006/07/10 13:21:14) |
initial import
|
#!/usr/bin/perl
use strict;
use warnings;
use CGI::Carp qw/fatalsToBrowser/;
use SVNAdmin;
#use CGI::Pretty qw/:all -no_xhtml -oldstyle_urls -no_undef_params *table *TR *Tr *td *div *span *label *ul *li/;
use CGI qw/:all -no_xhtml -oldstyle_urls -no_undef_params *table *TR *Tr *td *div *span *label *ul *li/;
our $action = $q->param('action');
if(defined $action && $action eq 'Change') {
$user->set_email($q->param('email'));
# CHECK:
# if passwd1: passwd1 must equal passwd
# maybe add an "old password" field to weed out issues with people leaving themselves logged in...
# print http_header();
# for($q->param()) {
# print br().$_ . " => " . $q->param($_);
# }
print http_redirect(uri('user.pl'))."\n";
exit(0);
}
print
http_header() .
start_page(-style => 'style.css', -title => 'SVN User') .
start_menu() .
end_menu() .
start_content() .
detail() .
end_content() .
end_page();
exit(0);
sub detail {
my $dat = '';
if($action eq 'edit') {
$dat .=
start_div({-class => 'ui_box'}) .
start_form(-method=>'GET', -action => uri('user.pl'), -enctype => 'application/x-www-form-urlencoded') .
start_table({-class => 'ui_box_table'}) .
start_Tr({-class => 'ui_box_table_row'}) .
th({-class => 'ui_box_table_header', -colspan => 2}, 'Modify Settings') .
end_Tr();
for(sort keys %{$user->{profile}}) {
$dat .=
start_Tr({-class => 'ui_box_table_row'}) .
start_td({-class => 'ui_box_label'}) . label({-for => $_}, ucfirst($_)) . end_td() .
start_td({-class => 'ui_box_table_cell1'}) . textfield({-size => 50, -maxlength => 100, -id => $_, -name => $_, -value => $user->{profile}{$_}}) . end_td() .
end_Tr();
}
my ($passwd1, $passwd2);
$dat .=
start_Tr({-class => 'ui_box_table_row'}) .
start_td({-class => 'ui_box_label'}) . label({-for => 'passwd1'}, 'Password') . end_td() .
start_td({-class => 'ui_box_table_cell1 center'}) . password_field({-align => 'center', -size => 50, -maxlength => 100, -id => 'passwd1', -name => 'passwd1', -value => $passwd1}) . end_td() .
end_Tr() .
start_Tr({-class => 'ui_box_table_row'}) .
start_td({-class => 'ui_box_label'}) . label({-for => 'passwd2'}, '') . end_td() .
start_td({-class => 'ui_box_table_cell1 center'}) . password_field({-align => 'center', -size => 50, -maxlength => 100, -id => 'passwd2', -name => 'passwd2', -value => $passwd2}) . end_td() .
end_Tr() .
start_Tr({-class => 'ui_box_table_row'}) .
start_td({-class => 'ui_box_submit', colspan=>2}) .
submit(-name => 'action', -value => 'Cancel') . ' ' .
submit(-name => 'action', -value => 'Change') .
end_td() .
end_Tr() .
end_table() .
end_form() .
end_div();
}
else {
$dat .=
start_div({-class => 'ui_box'}) .
user_info() .
end_div() .
start_div({-class => 'ui_edit_link'}) .
a({-href => uri('user.pl?action=edit')}, "edit") .
end_div();
}
return $dat;
}
sub user_info {
my $dat =
start_table({-class => 'ui_box_table'}) .
start_Tr({-class => 'ui_box_table_row'}) .
th({-class => 'ui_box_table_cell1'}, 'Name:') . td({-class => 'ui_box_table_cell2'}, $username) .
end_Tr();
for(keys %{$user->{profile}}) {
$dat .=
start_Tr({-class => 'ui_box_table_row'}) .
th({-class => 'ui_box_table_cell1'}, ucfirst($_).":") . td({-class => 'ui_box_table_cell2'}, $user->{profile}{$_}) .
end_Tr();
}
$dat .=
end_table();
return $dat;
}