--- loncom/interface/loncreateuser.pm 2003/12/11 14:58:00 1.73 +++ loncom/interface/loncreateuser.pm 2004/07/03 20:45:23 1.84 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Create a user # -# $Id: loncreateuser.pm,v 1.73 2003/12/11 14:58:00 sakharuk Exp $ +# $Id: loncreateuser.pm,v 1.84 2004/07/03 20:45:23 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -123,8 +123,7 @@ sub print_username_entry_form { my $defdom=$ENV{'request.role.domain'}; my @domains = &Apache::loncommon::get_domains(); my $domform = &Apache::loncommon::select_dom_form($defdom,'ccdomain'); - my $bodytag =&Apache::loncommon::bodytag( - 'Create Users, Change User Privileges'); + my $bodytag =&Apache::loncommon::bodytag('Create Users, Change User Privileges').&Apache::loncommon::help_open_menu('',undef,undef,'',282,'Instructor Interface'); my $selscript=&Apache::loncommon::studentbrowser_javascript(); my $sellink=&Apache::loncommon::selectstudent_link ('crtuser','ccuname','ccdomain'); @@ -140,6 +139,8 @@ sub print_username_entry_form { 'nr' => "Name of Role", 'cre' => "Custom Role Editor" ); + my $helpsiur=&Apache::loncommon::help_open_topic('Course_Change_Privileges'); + my $helpecpr=&Apache::loncommon::help_open_topic('Course_Editing_Custom_Roles'); $r->print(<<"ENDDOCUMENT"); @@ -149,7 +150,7 @@ $selscript $bodytag
-

$lt{siur}

+

$lt{siur}$helpsiur

-

$lt{'ecrp'}

+

$lt{'ecrp'}$helpecpr

$lt{'nr'}: $choice
@@ -246,7 +247,7 @@ ENDFORMINFO ''."\n". &Apache::loncommon::home_server_option_list($ccdomain); - my %lt=&Apache::lonlocal::texthash( + my %lt=&Apache::lonlocal::texthash( 'cnu' => "Create New User", 'nu' => "New User", 'id' => "in domain", @@ -259,6 +260,7 @@ ENDFORMINFO 'hs' => "Home Server", 'lg' => "Login Data" ); + my $genhelp=&Apache::loncommon::help_open_topic('Generation'); $r->print(<$lt{'cnu'} @@ -277,11 +279,11 @@ $loginscript - +
$lt{usr}: $sellink
@@ -159,7 +160,7 @@ $lt{'dom'}:$domform
$lt{'ln'}
$lt{'gen'}
$lt{'gen'}$genhelp
$lt{'idsn'}

-${'hs'}: +$lt{'hs'}:

$lt{'lg'}

$generalrule

@@ -291,7 +293,7 @@ ${'hs'}: '; + } else { + $row.=' '; + } + $row.=''; if ($delallowed) { $row.= ''; } else { @@ -463,8 +489,24 @@ END ''.($role_end_time ?localtime($role_end_time) : ' ' ) ."\n"; - $r->print($row); + $sortrole{$sortkey}=$envkey; + $roletext{$envkey}=$row; + $roleclass{$envkey}=$class; + #$r->print($row); } # end of foreach (table building loop) + foreach my $type ('Construction Space','Course','Domain','System','Unknown') { + my $output; + foreach my $which (sort {uc($a) cmp uc($b)} (keys(%sortrole))) { + if ($roleclass{$sortrole{$which}} =~ /^\Q$type\E/) { + $output.=$roletext{$sortrole{$which}}; + } + } + if (defined($output)) { + $r->print("". + "".&mt($type).""); + } + $r->print($output); + } $r->print(''); } # End of unless my $currentauth=&Apache::lonnet::queryauthenticate($ccuname,$ccdomain); @@ -581,23 +623,23 @@ ENDOTHERAUTHS 'rol' => "Role", 'ext' => "Extent", 'sta' => "Start", - 'end' => "End". + 'end' => "End", 'cau' => "Co-Author", 'ssd' => "Set Start Date", 'sed' => "Set End Date" ); $r->print(<$lt{'cs'} - +
${'act'}${'rol'}${'ext'}
- + - - @@ -756,10 +798,10 @@ ENDNEWUSERHEAD $ENV{'form.cmiddle'},$ENV{'form.clast'},$ENV{'form.cgen'}, undef,$desiredhost ); - $r->print('Generating user: '.$result); + $r->print(&mt('Generating user').': '.$result); my $home = &Apache::lonnet::homeserver($ENV{'form.ccuname'}, $ENV{'form.ccdomain'}); - $r->print('
'&mt('Home server').': '.$home.' '. + $r->print('
'.&mt('Home server').': '.$home.' '. $Apache::lonnet::libserv{$home}); } elsif (($ENV{'form.login'} ne 'nochange') && ($ENV{'form.login'} ne '' )) { @@ -862,7 +904,7 @@ END 'gen' => "Generation" ); $r->print(<<"END"); -

$lt{'usr'} "$ENV{'form.ccuname'}" ${'id'} "$ENV{'form.ccdomain'}"

+

$lt{'usr'} "$ENV{'form.ccuname'}" $lt{'id'} "$ENV{'form.ccdomain'}"

$userenv{'firstname'} $userenv{'middlename'} $userenv{'lastname'}

$lt{'gen'}: $userenv{'generation'}

END @@ -919,12 +961,34 @@ END $ENV{'course.'.$cid.'.home'}).'
'); } } + } elsif ($_=~/^form\.ren/) { + if ($_=~/^form\.ren\:([^\_]+)\_([^\_]+)$/) { + my $result=&Apache::lonnet::assignrole($ENV{'form.ccdomain'}, + $ENV{'form.ccuname'},$1,$2,0,$now); + $r->print(&mt('Re-Enabling [_1] in [_2]: [_3]', + $2,$1,$result).'
'); + if ($2 eq 'st') { + $1=~/^\/(\w+)\/(\w+)/; + my $cid=$1.'_'.$2; + $r->print(&mt('Add to classlist').': '. + &Apache::lonnet::critical( + 'put:'.$ENV{'course.'.$cid.'.domain'}.':'. + $ENV{'course.'.$cid.'.num'}.':classlist:'. + &Apache::lonnet::escape( + $ENV{'form.ccuname'}.':'. + $ENV{'form.ccdomain'} ).'='. + &Apache::lonnet::escape(':'.$now), + $ENV{'course.'.$cid.'.home'}) + .'
'); + } + } } elsif ($_=~/^form\.act/) { - if -($_=~/^form\.act\_([^\_]+)\_([^\_]+)\_cr_cr_([^\_]+)_(\w+)_([^\_]+)$/) { + if ($_=~/^form\.act\_([^\_]+)\_([^\_]+)\_cr_cr_([^\_]+)_(\w+)_([^\_]+)$/) { # Activate a custom role - my $url='/'.$1.'/'.$2; - my $full=$1.'_'.$2.'_cr_cr_'.$3.'_'.$4.'_'.$5; + my ($one,$two,$three,$four,$five)=($1,$2,$3,$4,$5); + my $url='/'.$one.'/'.$two; + my $full=$one.'_'.$two.'_cr_cr_'.$three.'_'.$four.'_'.$five; + $ENV{'form.sec_'.$full}=~s/\W//g; if ($ENV{'form.sec_'.$full}) { $url.='/'.$ENV{'form.sec_'.$full}; } @@ -936,38 +1000,39 @@ END $ENV{'form.end_'.$full} : 0 ); - $r->print(&mt('Assigning custom role').' "'.$5.'" by '.$4.'@'.$3.' in '.$url. + $r->print(&mt('Assigning custom role').' "'.$five.'" by '.$four.'@'.$three.' in '.$url. ($start?', '.&mt('starting').' '.localtime($start):''). ($end?', ending '.localtime($end):'').': '. &Apache::lonnet::assigncustomrole( - $ENV{'form.ccdomain'},$ENV{'form.ccuname'},$url,$3,$4,$5,$end,$start). + $ENV{'form.ccdomain'},$ENV{'form.ccuname'},$url,$three,$four,$five,$end,$start). '
'); } elsif ($_=~/^form\.act\_([^\_]+)\_([^\_]+)\_([^\_]+)$/) { # Activate roles for sections with 3 id numbers # set start, end times, and the url for the class - - my $start = ( $ENV{'form.start_'.$1.'_'.$2.'_'.$3} ? - $ENV{'form.start_'.$1.'_'.$2.'_'.$3} : + my ($one,$two,$three)=($1,$2,$3); + my $start = ( $ENV{'form.start_'.$one.'_'.$two.'_'.$three} ? + $ENV{'form.start_'.$one.'_'.$two.'_'.$three} : $now ); - my $end = ( $ENV{'form.end_'.$1.'_'.$2.'_'.$3} ? - $ENV{'form.end_'.$1.'_'.$2.'_'.$3} : + my $end = ( $ENV{'form.end_'.$one.'_'.$two.'_'.$three} ? + $ENV{'form.end_'.$one.'_'.$two.'_'.$three} : 0 ); - my $url='/'.$1.'/'.$2; - if ($ENV{'form.sec_'.$1.'_'.$2.'_'.$3}) { - $url.='/'.$ENV{'form.sec_'.$1.'_'.$2.'_'.$3}; + my $url='/'.$one.'/'.$two; + $ENV{'form.sec_'.$one.'_'.$two.'_'.$three}=~s/\W//g; + if ($ENV{'form.sec_'.$one.'_'.$two.'_'.$three}) { + $url.='/'.$ENV{'form.sec_'.$one.'_'.$two.'_'.$three}; } # Assign the role and report it - $r->print(&mt('Assigning').' '.$3.' in '.$url. + $r->print(&mt('Assigning').' '.$three.' in '.$url. ($start?', '.&mt('starting').' '.localtime($start):''). ($end?', '.&mt('ending').' '.localtime($end):'').': '. &Apache::lonnet::assignrole( $ENV{'form.ccdomain'},$ENV{'form.ccuname'}, - $url,$3,$end,$start). + $url,$three,$end,$start). '
'); # Handle students differently - if ($3 eq 'st') { + if ($three eq 'st') { $url=~/^\/(\w+)\/(\w+)/; - my $cid=$1.'_'.$2; + my $cid=$one.'_'.$two; $r->print(&mt('Add to classlist').': '. &Apache::lonnet::critical( 'put:'.$ENV{'course.'.$cid.'.domain'}.':'. @@ -1002,6 +1067,8 @@ END } } } # End of foreach (keys(%ENV)) +# Flush the course logs so reverse user roles immediately updated + &Apache::lonnet::flushcourselogs(); $r->print(''); } @@ -1229,6 +1296,7 @@ sub course_level_table { my $bgcol=$thiscourse; $bgcol=~s/[^7-9a-e]//g; $bgcol=substr($bgcol.$bgcol.$bgcol.'ffffff',2,6); + my ($domain)=split(/\//,$thiscourse); foreach ('st','ta','ep','ad','in','cc') { if (&Apache::lonnet::allowed('c'.$_,$thiscourse)) { my $plrole=&Apache::lonnet::plaintext($_); @@ -1236,7 +1304,7 @@ sub course_level_table { - + ENDEXTENT if ($_ ne 'cc') { $table .= <
$lt{'act'}$lt{'rol'}$lt{'ext'} $lt{'sta'}$lt{'end'}
$lt{'cau'} $cudom\_$cuname + $lt{'ssd'} + $lt{'sed'}
$plrole$area$area
Domain: $domain