version 1.218, 2007/12/21 16:23:54
|
version 1.219, 2007/12/21 17:27:57
|
Line 1397 sub modify_login_block {
|
Line 1397 sub modify_login_block {
|
|
|
sub personal_data_display { |
sub personal_data_display { |
my ($ccuname,$ccdomain,$newuser,$context,$inst_results) = @_; |
my ($ccuname,$ccdomain,$newuser,$context,$inst_results) = @_; |
my ($output,$showforceid,%userenv,%domconfig); |
my ($output,$showforceid,%userenv,%canmodify); |
|
my @userinfo = ('firstname','middlename','lastname','generation', |
|
'permanentemail','id'); |
if (!$newuser) { |
if (!$newuser) { |
# Get the users information |
# Get the users information |
%userenv = &Apache::lonnet::get('environment', |
%userenv = &Apache::lonnet::get('environment', |
['firstname','middlename','lastname','generation', |
['firstname','middlename','lastname','generation', |
'permanentemail','id'],$ccdomain,$ccuname); |
'permanentemail','id'],$ccdomain,$ccuname); |
%domconfig = |
%canmodify = |
&Apache::lonnet::get_dom('configuration',['usermodification'], |
&Apache::lonuserutils::can_modify_userinfo($context,$ccdomain, |
$ccdomain); |
\@userinfo); |
} |
} |
my %lt=&Apache::lonlocal::texthash( |
my %lt=&Apache::lonlocal::texthash( |
'pd' => "Personal Data", |
'pd' => "Personal Data", |
Line 1417 sub personal_data_display {
|
Line 1419 sub personal_data_display {
|
'id' => "ID/Student Number", |
'id' => "ID/Student Number", |
'lg' => "Login Data" |
'lg' => "Login Data" |
); |
); |
my @userinfo = ('firstname','middlename','lastname','generation', |
|
'permanentemail','id'); |
|
my %textboxsize = ( |
my %textboxsize = ( |
firstname => '15', |
firstname => '15', |
middlename => '15', |
middlename => '15', |
Line 1447 sub personal_data_display {
|
Line 1447 sub personal_data_display {
|
$output .= '<input type="text" name="c'.$item.'" size="'.$textboxsize{$item}.'" value="" />'; |
$output .= '<input type="text" name="c'.$item.'" size="'.$textboxsize{$item}.'" value="" />'; |
} |
} |
} else { |
} else { |
my $canmodify = 0; |
if ($canmodify{$item}) { |
if (&Apache::lonnet::allowed('mau',$ccdomain)) { |
|
$canmodify = 1; |
|
} else { |
|
if (ref($domconfig{'usermodification'}) eq 'HASH') { |
|
if (ref($domconfig{'usermodification'}{$context}) eq 'HASH') { |
|
foreach my $key (keys(%{$domconfig{'usermodification'}{$context}})) { |
|
if (ref($domconfig{'usermodification'}{$context}{$key}) eq 'HASH') { |
|
if ($domconfig{'usermodification'}{$context}{$key}{$item}) { |
|
$canmodify = 1; |
|
last; |
|
} |
|
} |
|
} |
|
} |
|
} elsif ($context eq 'course') { |
|
$canmodify = 1; |
|
} |
|
} |
|
if ($canmodify) { |
|
$output .= '<input type="text" name="c'.$item.'" size="'.$textboxsize{$item}.'" value="'.$userenv{$item}.'" />'; |
$output .= '<input type="text" name="c'.$item.'" size="'.$textboxsize{$item}.'" value="'.$userenv{$item}.'" />'; |
} else { |
} else { |
$output .= $userenv{$item}; |
$output .= $userenv{$item}; |
} |
} |
if ($item eq 'id') { |
if ($item eq 'id') { |
$showforceid = $canmodify; |
$showforceid = $canmodify{$item}; |
} |
} |
} |
} |
$output .= &Apache::lonhtmlcommon::row_closure(1); |
$output .= &Apache::lonhtmlcommon::row_closure(1); |
} |
} |
Line 1495 sub update_user_data {
|
Line 1476 sub update_user_data {
|
my $end = '</span><br /><br />'; |
my $end = '</span><br /><br />'; |
my $rtnlink = '<a href="javascript:backPage(document.userupdate,'. |
my $rtnlink = '<a href="javascript:backPage(document.userupdate,'. |
"'$env{'form.prevphase'}','modify')".'" />'. |
"'$env{'form.prevphase'}','modify')".'" />'. |
&mt('Return to previous page').'</a>'.&Apache::loncommon::end_page(); |
&mt('Return to previous page').'</a>'. |
|
&Apache::loncommon::end_page(); |
|
my $now = time; |
my $title; |
my $title; |
if (exists($env{'form.makeuser'})) { |
if (exists($env{'form.makeuser'})) { |
$title='Set Privileges for New User'; |
$title='Set Privileges for New User'; |
Line 1520 sub update_user_data {
|
Line 1503 sub update_user_data {
|
} |
} |
&Apache::lonhtmlcommon::add_breadcrumb |
&Apache::lonhtmlcommon::add_breadcrumb |
({href=>"javascript:backPage(document.userupdate,'$env{'form.prevphase'}','modify')", |
({href=>"javascript:backPage(document.userupdate,'$env{'form.prevphase'}','modify')", |
text=>"Set user role", |
text=>$breadcrumb_text{'modify'}, |
faq=>282,bug=>'Instructor Interface',}, |
faq=>282,bug=>'Instructor Interface',}, |
{href=>"/adm/createuser", |
{href=>"/adm/createuser", |
text=>"Result", |
text=>"Result", |
faq=>282,bug=>'Instructor Interface',}); |
faq=>282,bug=>'Instructor Interface',}); |
$r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management')); |
$r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management')); |
|
|
my %disallowed; |
my %disallowed; |
$r->print(&update_result_form($uhome)); |
$r->print(&update_result_form($uhome)); |
# Check Inputs |
# Check Inputs |
Line 1552 sub update_user_data {
|
Line 1534 sub update_user_data {
|
$end.$rtnlink); |
$end.$rtnlink); |
return; |
return; |
} |
} |
|
if ($uhome eq 'no_host') { |
|
$newuser = 1; |
|
} |
if (! exists($env{'form.makeuser'})) { |
if (! exists($env{'form.makeuser'})) { |
# Modifying an existing user, so check the validity of the name |
# Modifying an existing user, so check the validity of the name |
if ($uhome eq 'no_host') { |
if ($uhome eq 'no_host') { |
Line 1589 sub update_user_data {
|
Line 1574 sub update_user_data {
|
return; |
return; |
} |
} |
|
|
|
|
$r->print('<h3>'.&mt('User [_1] in domain [_2]', |
$r->print('<h3>'.&mt('User [_1] in domain [_2]', |
$env{'form.ccuname'}, $env{'form.ccdomain'}).'</h3>'); |
$env{'form.ccuname'}, $env{'form.ccdomain'}).'</h3>'); |
my (%alerts,%rulematch,%inst_results,%curr_rules); |
my (%alerts,%rulematch,%inst_results,%curr_rules); |
Line 1616 sub update_user_data {
|
Line 1600 sub update_user_data {
|
my %checkhash; |
my %checkhash; |
my %checks = ('id' => 1); |
my %checks = ('id' => 1); |
%{$checkhash{$env{'form.ccuname'}.':'.$env{'form.ccdomain'}}} = ( |
%{$checkhash{$env{'form.ccuname'}.':'.$env{'form.ccdomain'}}} = ( |
'newuser' => 1, |
'newuser' => $newuser, |
'id' => $env{'form.cid'}, |
'id' => $env{'form.cid'}, |
); |
); |
if ($env{'form.cid'} ne '') { |
if ($env{'form.cid'} ne '') { |
Line 1650 sub update_user_data {
|
Line 1634 sub update_user_data {
|
$env{'form.cgeneration'},undef,$desiredhost, |
$env{'form.cgeneration'},undef,$desiredhost, |
$env{'form.cpermanentemail'}); |
$env{'form.cpermanentemail'}); |
$r->print(&mt('Generating user').': '.$result); |
$r->print(&mt('Generating user').': '.$result); |
my $home = &Apache::lonnet::homeserver($env{'form.ccuname'}, |
$uhome = &Apache::lonnet::homeserver($env{'form.ccuname'}, |
$env{'form.ccdomain'}); |
$env{'form.ccdomain'}); |
$r->print('<br />'.&mt('Home server').': '.$home.' '. |
$r->print('<br />'.&mt('Home server').': '.$uhome.' '. |
&Apache::lonnet::hostname($home)); |
&Apache::lonnet::hostname($uhome)); |
} elsif (($env{'form.login'} ne 'nochange') && |
} elsif (($env{'form.login'} ne 'nochange') && |
($env{'form.login'} ne '' )) { |
($env{'form.login'} ne '' )) { |
# Modify user privileges |
# Modify user privileges |
Line 1764 sub update_user_data {
|
Line 1748 sub update_user_data {
|
push(@longroles,&Apache::lonnet::plaintext($role)); |
push(@longroles,&Apache::lonnet::plaintext($role)); |
} |
} |
} |
} |
foreach my $item ('firstname','middlename','lastname','generation','permanentemail','id') { |
my @userinfo = ('firstname','middlename','lastname','generation','permanentemail','id'); |
my $canmodify = 0; |
my %canmodify = &Apache::lonuserutils::can_modify_userinfo($context,$env{'form.ccdomain'},\@userinfo,\@userroles); |
if (&Apache::lonnet::allowed('mau',$env{'form.ccdomain'})) { |
foreach my $item (@userinfo) { |
$canmodify = 1; |
|
} else { |
|
if ($context eq 'course' || $context eq 'author') { |
|
if (ref($domconfig{'usermodification'}) eq 'HASH') { |
|
if (ref($domconfig{'usermodification'}{$context}) eq 'HASH') { |
|
foreach my $role (@userroles) { |
|
if (ref($domconfig{'usermodification'}{$context}{$role}) eq 'HASH') { |
|
if ($domconfig{'usermodification'}{$context}{$role}{$item}) { |
|
$canmodify = 1; |
|
last; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} elsif ($context eq 'course') { |
|
if (grep(/^st$/,@userroles)) { |
|
$canmodify = 1; |
|
} |
|
} |
|
} |
|
# Strip leading and trailing whitespace |
# Strip leading and trailing whitespace |
$env{'form.c'.$item} =~ s/(\s+$|^\s+)//g; |
$env{'form.c'.$item} =~ s/(\s+$|^\s+)//g; |
if (!$canmodify) { |
if (!$canmodify{$item}) { |
if (defined($env{'form.c'.$item})) { |
if (defined($env{'form.c'.$item})) { |
if ($env{'form.c'.$item} ne $userenv{$item}) { |
if ($env{'form.c'.$item} ne $userenv{$item}) { |
push(@mod_disallowed,$item); |
push(@mod_disallowed,$item); |