--- loncom/interface/loncreateuser.pm 2012/10/02 18:08:12 1.366 +++ loncom/interface/loncreateuser.pm 2012/11/30 15:09:17 1.367 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Create a user # -# $Id: loncreateuser.pm,v 1.366 2012/10/02 18:08:12 bisitz Exp $ +# $Id: loncreateuser.pm,v 1.367 2012/11/30 15:09:17 goltermann Exp $ # # Copyright Michigan State University Board of Trustees # @@ -2432,13 +2432,14 @@ sub update_user_data { # If they are creating a new user but have not specified login # information this will be caught below. } else { - $r->print($error.&mt('Invalid login mode or password').$end.$rtnlink); - return; + $r->print($error.&mt('Invalid login mode or password').$end.$rtnlink); + return; } $r->print('

'.&mt('User [_1] in domain [_2]', - $env{'form.ccuname'}, $env{'form.ccdomain'}).'

'); - $r->print('

'.&mt('Please be patient').'

'); + $env{'form.ccuname'}.' ('.&Apache::loncommon::plainname($env{'form.ccuname'}, + $env{'form.ccdomain'}).')', $env{'form.ccdomain'}).''); + my %prog_state = &Apache::lonhtmlcommon::Create_PrgWin($r,2); my (%alerts,%rulematch,%inst_results,%curr_rules); my @userinfo = ('firstname','middlename','lastname','generation','permanentemail','id'); @@ -2499,6 +2500,7 @@ sub update_user_data { } } } + &Apache::lonhtmlcommon::Increment_PrgWin($r, \%prog_state); # Call modifyuser my $result = &Apache::lonnet::modifyuser ($env{'form.ccdomain'},$env{'form.ccuname'},$env{'form.cid'}, @@ -2588,9 +2590,8 @@ sub update_user_data { $r->print($error.&mt('You do not have the authority to modify this users authentification information').'.'.$end); } } - $r->rflush(); # Finish display of header before time consuming actions start - + &Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state); ## my (@userroles,%userupdate,$cnum,$cdom,%namechanged); if ($context eq 'course') { @@ -2902,7 +2903,8 @@ sub update_user_data { $changeHash{'tools.'.$key}; } else { $newenvhash{'environment.availabletools.'.$key} = - &Apache::lonnet::usertools_access($env{'user.name'},$env{'user.domain'}, $key,'reload','tools'); + &Apache::lonnet::usertools_access($env{'user.name'},$env{'user.domain'}, + $key,'reload','tools'); } } } @@ -3005,6 +3007,7 @@ sub update_user_data { .&Apache::lonuserutils::print_namespacing_alerts($env{'form.ccdomain'},\%alerts,\%curr_rules) .''); } + &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state); if ($env{'form.action'} eq 'singlestudent') { &enroll_single_student($r,$uhome,$amode,$genpwd,$now,$newuser,$context,$crstype); $r->print('

'); @@ -3036,10 +3039,9 @@ sub update_user_data { if ($env{'form.popup'}) { $r->print('

'.&mt('Close window').'

'); } else { - $r->print('

' - .&mt('Modify this user: [_1]',''.$env{'form.ccuname'}.':'.$env{'form.ccdomain'}.' ('.$userinfo.')').'' - .(' 'x5).'' - .&mt('Create/Modify Another User').'

'); + $r->print('
'.&Apache::lonhtmlcommon::actionbox(['' + .&mt('Modify this user: [_1]',''.$env{'form.ccuname'}.':'.$env{'form.ccdomain'}.' ('.$userinfo.')').'', + ''.&mt('Create/Modify Another User').''])); } } } @@ -3084,70 +3086,36 @@ sub display_userinfo { my $title = $lt{'ui'}; if ($changed) { $title = $lt{'uic'}; - } - $r->print('

'.$title.'

'. - &Apache::loncommon::start_data_table(). - &Apache::loncommon::start_data_table_header_row()); - if ($changed) { + $r->print('

'.$title.'

'. + &Apache::loncommon::start_data_table(). + &Apache::loncommon::start_data_table_header_row()); $r->print(" \n"); - } - my @userinfo = ('firstname','middlename','lastname','generation','permanentemail','id'); - foreach my $item (@userinfo) { - $r->print("$lt{$item}\n"); - } - foreach my $entry (@{$order}) { - if ($canshow->{$entry}) { - if (($entry eq 'requestcourses') || ($entry eq 'reqcrsotherdom')) { - foreach my $item (@{$requestcourses}) { - $r->print("$lt{$item}\n"); - } - } elsif ($entry eq 'tools') { - foreach my $item (@{$usertools}) { - $r->print("$lt{$item}\n"); - } - } else { - $r->print("$lt{$entry}\n"); - } - } - } - $r->print(&Apache::loncommon::end_data_table_header_row(). - &Apache::loncommon::start_data_table_row()); - if ($changed) { - $r->print(''.$lt{'prvs'}.''."\n"); - } - foreach my $item (@userinfo) { - $r->print(''.$userenv->{$item}.' '."\n"); - } - foreach my $entry (@{$order}) { - if ($canshow->{$entry}) { - if (($entry eq 'requestcourses') || ($entry eq 'reqcrsotherdom')) { - foreach my $item (@{$requestcourses}) { - $r->print("$oldsetting->{$item} $oldsettingtext->{$item}\n"); - } - } elsif ($entry eq 'tools') { - foreach my $item (@{$usertools}) { - $r->print("$oldsetting->{$item} $oldsettingtext->{$item}\n"); - } - } else { - $r->print("$oldsetting->{$entry} $oldsettingtext->{$entry} \n"); - } - } - } - $r->print(&Apache::loncommon::end_data_table_row()); - if ($changed) { - $r->print(&Apache::loncommon::start_data_table_row(). - ''.$lt{'chto'}.''."\n"); + $r->print(''.$lt{'prvs'}.''); + $r->print(''.$lt{'chto'}.''); + $r->print(&Apache::loncommon::end_data_table_header_row()); + my @userinfo = ('firstname','middlename','lastname','generation','permanentemail','id'); + + foreach my $item (@userinfo) { my $value = $env{'form.c'.$item}; - if ($namechangedhash->{$item}) { - $value = ''.$value.''; + #show changes only: + unless($value eq $userenv->{$item}){ + $r->print(&Apache::loncommon::start_data_table_row()); + + $r->print("$lt{$item}\n"); + $r->print(''.$userenv->{$item}.' '); + $r->print("$value \n"); + + $r->print(&Apache::loncommon::end_data_table_row()); } - $r->print("$value \n"); } foreach my $entry (@{$order}) { - if ($canshow->{$entry}) { + if ($canshow->{$entry} && ($newsetting->{$entry} ne $newsetting->{$entry})) { + $r->print(&Apache::loncommon::start_data_table_row()); if (($entry eq 'requestcourses') || ($entry eq 'reqcrsotherdom')) { foreach my $item (@{$requestcourses}) { + $r->print("$lt{$item}\n"); + $r->print("$oldsetting->{$item} $oldsettingtext->{$item}\n"); my $value = $newsetting->{$item}.' '.$newsettingtext->{$item}; if ($changedhash->{$item}) { $value = ''.$value.''; @@ -3156,6 +3124,8 @@ sub display_userinfo { } } elsif ($entry eq 'tools') { foreach my $item (@{$usertools}) { + $r->print("$lt{$item}\n"); + $r->print("$oldsetting->{$item} $oldsettingtext->{$item}\n"); my $value = $newsetting->{$item}.' '.$newsettingtext->{$item}; if ($changedhash->{$item}) { $value = ''.$value.''; @@ -3163,17 +3133,19 @@ sub display_userinfo { $r->print("$value \n"); } } else { + $r->print("$lt{$entry}\n"); + $r->print("$oldsetting->{$entry} $oldsettingtext->{$entry} \n"); my $value = $newsetting->{$entry}.' '.$newsettingtext->{$entry}; if ($changedhash->{$entry}) { $value = ''.$value.''; } $r->print("$value \n"); } + $r->print(&Apache::loncommon::end_data_table_row()); } } - $r->print(&Apache::loncommon::end_data_table_row()); + $r->print(&Apache::loncommon::end_data_table().'
'); } - $r->print(&Apache::loncommon::end_data_table().'
'); return; } @@ -3370,14 +3342,15 @@ sub update_roles { &Apache::lonnet::revokerole($env{'form.ccdomain'}, $env{'form.ccuname'}, $scope,$role,'','',$context); - $r->print(&mt('Revoking [_1] in [_2]: [_3]', - $role,$scope,''.$result.'').'
'); + $r->print(&Apache::lonhtmlcommon::confirm_success( + &mt('Revoking [_1] in [_2]', &Apache::lonnet::plaintext($role), '"'.&cid_to_cname($scope).'"
'), + $result ne "ok")); if ($role eq 'st') { my $result = &Apache::lonuserutils::classlist_drop($scope, $env{'form.ccuname'},$env{'form.ccdomain'}, $now); - $r->print($result); + $r->print(&Apache::lonhtmlcommon::confirm_success($result)); } if (!grep(/^\Q$role\E$/,@rolechanges)) { push(@rolechanges,$role); @@ -3385,11 +3358,10 @@ sub update_roles { } if ($key=~m{^form\.rev\:([^_]+)_cr\.cr/($match_domain)/($match_username)/(\w+)$}s) { # Revoke custom role - $r->print(&mt('Revoking custom role:'). - ' '.$4.' by '.$3.':'.$2.' in '.$1.': '. - &Apache::lonnet::revokecustomrole($env{'form.ccdomain'}, - $env{'form.ccuname'},$1,$2,$3,$4,'','',$context). - '
'); + $r->print(&Apache::lonhtmlcommon::confirm_success( + &mt('Revoking custom role [_1] by [_2]:[_3] in [_4]',$4,$3,$2,'"'.&cid_to_cname($1).'"
'), + &Apache::lonnet::revokecustomrole($env{'form.ccdomain'},$env{'form.ccuname'},$1,$2,$3,$4,'','',$context) ne 'ok')); + if (!grep(/^cr$/,@rolechanges)) { push(@rolechanges,'cr'); } @@ -3403,8 +3375,10 @@ sub update_roles { $env{'form.ccuname'}, $scope,$role,$now,0,1,'', $context); - $r->print(&mt('Deleting [_1] in [_2]: [_3]',$role,$scope, - ''.$result.'').'
'); + $r->print(&Apache::lonhtmlcommon::confirm_success( + &mt('Deleting [_1] in [_2]', + &Apache::lonnet::plaintext($role),'"'.&cid_to_cname($scope).'"
'),$result ne 'ok')); + if ($role eq 'st') { my $result = &Apache::lonuserutils::classlist_drop($scope, @@ -3419,11 +3393,12 @@ sub update_roles { if ($key=~m{^form\.del\:([^_]+)_cr\.cr/($match_domain)/($match_username)/(\w+)$}) { my ($url,$rdom,$rnam,$rolename) = ($1,$2,$3,$4); # Delete custom role - $r->print(&mt('Deleting custom role [_1] by [_2] in [_3]', - $rolename,$rnam.':'.$rdom,$url).': '. + $r->print(&confirm_success(&mt('Deleting custom role [_1] by [_2] in [_3]', + $rolename,$rnam.':'.$rdom,'"'.&cid_to_cname($1).'"').'
')); &Apache::lonnet::assigncustomrole($env{'form.ccdomain'}, $env{'form.ccuname'},$url,$rdom,$rnam,$rolename,$now, - 0,1,$context).'

'); + 0,1,$context); + if (!grep(/^cr$/,@rolechanges)) { push(@rolechanges,'cr'); } @@ -3447,18 +3422,16 @@ sub update_roles { $output = "Error: $result\n"; } } else { - $output = &mt('Assigning').' '.$role.' in '.$url. - &mt('starting').' '.localtime($now). - ':
'.$logmsg.'
'. - &mt('Add to classlist').': ok
'; + $output = &Apache::lonhtmlcommon::confirm_success(&mt('Assigning [_1] in [_2] starting [_3]',&Apache::lonnet::plaintext($role), + '"'.&cid_to_cname($url).'"',&Apache::lonlocal::locallocaltime($now))).'
'.$logmsg.'
'; } } } else { my $result=&Apache::lonnet::assignrole($env{'form.ccdomain'}, $env{'form.ccuname'},$url,$role,0,$now,'','', $context); - $output = &mt('Re-enabling [_1] in [_2]: [_3]', - $role,$url,''.$result.'').'
'; + $output = &Apache::lonhtmlcommon::confirm_success(&mt('Re-enabling [_1] in [_2]', + &Apache::lonnet::plaintext($role),'"'.&cid_to_cname($url).'"').'
',$result ne "ok"); } $r->print($output); if (!grep(/^\Q$role\E$/,@rolechanges)) { @@ -3471,8 +3444,8 @@ sub update_roles { my $result = &Apache::lonnet::assigncustomrole( $env{'form.ccdomain'}, $env{'form.ccuname'}, $url,$rdom,$rnam,$rolename,0,$now,undef,$context); - $r->print(&mt('Re-enabling custom role [_1] by [_2] in [_3]: [_4]', - $rolename,$rnam.':'.$rdom,$url,''.$result.'').'
'); + $r->print(&Apache::lonhtmlcommon::confirm_success(&mt('Re-enabling custom role [_1] by [_2] in [_3]', + $rolename,$rnam.':'.$rdom,'"'.&cid_to_cname($1).'"').'
'),$result ne "ok"); if (!grep(/^cr$/,@rolechanges)) { push(@rolechanges,'cr'); } @@ -3692,7 +3665,7 @@ sub get_defaultquota_text { sub update_result_form { my ($uhome) = @_; my $outcome = - '
'."\n"; + ''."\n"; foreach my $item ('srchby','srchin','srchtype','srchterm','srchdomain','ccuname','ccdomain') { $outcome .= ''."\n"; } @@ -6972,7 +6945,12 @@ sub get_selfenroll_titles { #--------------------------------- functions for &phase_two and &phase_three #--------------------------end of functions for &phase_two and &phase_three - +sub cid_to_cname(){ + my $courseid = shift; + $courseid =~ s/^\///; + $courseid =~ s/\//_/; + return $env{'course.'.$courseid.'.description'}; +} 1; __END__