--- loncom/interface/loncreateuser.pm 2001/03/02 20:31:34 1.4 +++ loncom/interface/loncreateuser.pm 2001/08/24 21:09:53 1.18 @@ -16,7 +16,9 @@ # # 2/14 Gerd Kortemeyer) # -# 2/14,2/17,2/19,2/20,2/21,2/22,2/23,3/2 Gerd Kortemeyer +# 2/14,2/17,2/19,2/20,2/21,2/22,2/23,3/2,3/17,3/24,04/12 Gerd Kortemeyer +# April Guy Albertelli +# 05/10 Gerd Kortemeyer # package Apache::loncreateuser; @@ -101,12 +103,16 @@ sub phase_two { + + ENDENHEAD my $uhome=&Apache::lonnet::homeserver($ccuname,$ccdomain); my %incdomains; my %inccourses; - $incdomains{$ENV{'user.domain'}}=1; + map { + $incdomains{$_}=1; + } values %Apache::lonnet::hostdom; map { if ($_=~/^user\.priv\.cm\.\/(\w+)\/(\w+)/) { $inccourses{$1.'_'.$2}=1; @@ -114,85 +120,14 @@ ENDENHEAD } %ENV; if ($uhome eq 'no_host') { $r->print(<New user $ccuname at $ccdomain +

New user $ccuname at $ccdomain

@@ -221,22 +172,22 @@ Generation:

-Group/Section:

-

Login Data

-Username:

-Domain:

-Note: login settings below will not take effect if the user already exists

- Kerberos authenticated with domain

Internally authenticated (with initial password ) +

+ +Local Authentication with argument + +

ENDNUSER } else { - $r->print('

Existing user '.$ccuname.' at '.$ccdomain.'

'); + $r->print('

Existing user '.$ccuname.' at '.$ccdomain.'

'); + my $rolesdump=&Apache::lonnet::reply( "dump:$ccdomain:$ccuname:roles",$uhome); unless ($rolesdump eq 'con_lost') { @@ -253,23 +204,29 @@ ENDNUSER my ($trole,$tend,$tstart)=split(/_/,$role); my $bgcol='ffffff'; my $allows=0; - if ($area=~/^\/(\w+)\/(\d\w+)\/(\w+)/) { + if ($area=~/^\/(\w+)\/(\d\w+)/) { my %coursedata=&Apache::lonnet::coursedescription($1.'_'.$2); - $area='Course: '. - $coursedata{'description'}.'
Section/Group: '.$3; + my $carea='Course: '.$coursedata{'description'}; $inccourses{$1.'_'.$2}=1; - if (&Apache::lonnet::allowed('c'.$trole,$1.'_'.$2)) { + if (&Apache::lonnet::allowed('c'.$trole,$1.'/'.$2)) { $allows=1; } $bgcol=$1.'_'.$2; $bgcol=~s/[^8-9b-e]//g; $bgcol=substr($bgcol.$bgcol.$bgcol.'ffffff',0,6); + if ($area=~/^\/(\w+)\/(\d\w+)\/(\w+)/) { + $carea.='
Section/Group: '.$3; + } + $area=$carea; } else { - if ($1) { - $incdomains{$1}=1; + if ($area=~/^\/(\w+)\//) { if (&Apache::lonnet::allowed('c'.$trole,$1)) { $allows=1; } + } else { + if (&Apache::lonnet::allowed('c'.$trole,'/')) { + $allows=1; + } } } @@ -296,21 +253,70 @@ ENDNUSER $r->print(''); } } - $r->print('

Add Roles

System Level
'); - $r->print('
Domain Level
'); + $r->print('

Add Roles

'); +# +# Co-Author +# + + if (&Apache::lonnet::allowed('cca',$ENV{'user.domain'})) { + my $cuname=$ENV{'user.name'}; + my $cudom=$ENV{'user.domain'}; + $r->print(<Construction Space + + + + + + + + + +
ActivateRoleExtentStartEnd
Co-Author$cudom\_$cuname +Set Start Date +Set End Date
+ENDCOAUTH + } +# +# Domain level +# + $r->print('

Domain Level

'. + ''. + ''); map { my $thisdomain=$_; map { if (&Apache::lonnet::allowed('c'.$_,$thisdomain)) { - $r->print($_.' - '.$thisdomain.'
'); + my $plrole=&Apache::lonnet::plaintext($_); + $r->print(< + + + + + + +ENDDROW } - } ('dc','cc','li','dg','au'); + } ('dc','li','dg','au'); } sort keys %incdomains; - $r->print('
Course Level
'. + $r->print('
ActivateRoleExtentStartEnd
$plrole$thisdomain +Set Start Date +Set End Date
'); +# +# Course level +# + $r->print('

Course Level

'. ''. ''); map { my $thiscourse=$_; + my $protectedcourse=$_; + $thiscourse=~s:_:/:g; my %coursedata=&Apache::lonnet::coursedescription($thiscourse); my $area=$coursedata{'description'}; my $bgcol=$thiscourse; @@ -319,26 +325,29 @@ ENDNUSER map { if (&Apache::lonnet::allowed('c'.$_,$thiscourse)) { my $plrole=&Apache::lonnet::plaintext($_); - $r->print(<print(" - + - - - + +"javascript:pjump('date_end','End Date $plrole',document.cu.end_$protectedcourse\_$_.value,'end_$protectedcourse\_$_','cu.pres','dateset')">Set End Date ENDROW - } - } ('st','ta','ep','ad','in'); + } ('st','ta','ep','ad','in','cc'); } sort keys %inccourses; $r->print('
ActivateRoleExtentGroup/SectionStartEnd
$plrole $area +"); + if ($_ ne 'cc') { + $r->print(""); + } else { $r->print(" "); } + $r->print(< Set Start Date +"javascript:pjump('date_start','Start Date $plrole',document.cu.start_$protectedcourse\_$_.value,'start_$protectedcourse\_$_','cu.pres','dateset')">Set Start Date Set End Date
'); - $r->print(''); + $r->print(''); $r->print(''); } @@ -355,6 +364,7 @@ sub phase_three {

Create User, Change User Privileges

ENDTHREEHEAD + $r->print('

'.$ENV{'form.cuname'}.' at '.$ENV{'form.cdomain'}.'

'); if ($ENV{'form.makeuser'}) { $r->print('

Creating User

'); if (($ENV{'form.cuname'})&&($ENV{'form.cuname'}!~/\W/)&& @@ -367,17 +377,20 @@ ENDTHREEHEAD } elsif ($ENV{'form.login'} eq 'int') { $amode='internal'; $genpwd=$ENV{'form.intpwd'}; - } + } elsif ($ENV{'form.login'} eq 'loc') { + $amode='localauth'; + $genpwd=$ENV{'form.locarg'}; + if (!$genpwd) { $genpwd=" "; } + } if (($amode) && ($genpwd)) { - &dropstudent($ENV{'form.cdomain'},$ENV{'form.cuname'}, - $ENV{'request.course.id'},$ENV{'form.csec'}); - $r->print(&Apache::lonnet::modifystudent( + $r->print('Generating user: '.&Apache::lonnet::modifyuser( $ENV{'form.cdomain'},$ENV{'form.cuname'}, $ENV{'form.cstid'},$amode,$genpwd, $ENV{'form.cfirst'},$ENV{'form.cmiddle'}, - $ENV{'form.clast'},$ENV{'form.cgen'}, - $ENV{'form.csec'},$ENV{'form.enddate'}, - $ENV{'form.startdate'})); + $ENV{'form.clast'},$ENV{'form.cgen'})); + $r->print('
Home server: '.&Apache::lonnet::homeserver + ($ENV{'form.cuname'},$ENV{'form.cdomain'})); + } else { $r->print('Invalid login mode or password'); } @@ -385,23 +398,70 @@ ENDTHREEHEAD $r->print('Invalid username or domain'); } } - $r->print('

'.$ENV{'form.cuname'}.' at '.$ENV{'form.cdomain'}.'

'); my $now=time; -# sub assignrole { -# my ($udom,$uname,$url,$role,$end,$start)=@_; + $r->print('

Modifying Roles

'); map { if (($_=~/^form\.rev\:([^\_]+)\_([^\_]+)$/) && ($ENV{$_})) { $r->print('Revoking '.$2.' in '.$1.': '. &Apache::lonnet::assignrole($ENV{'form.cdomain'},$ENV{'form.cuname'}, $1,$2,$now).'
'); + if ($2 eq 'st') { + $1=~/^\/(\w+)\/(\w+)/; + my $cid=$1.'_'.$2; + $r->print('Drop from classlist: '. + &Apache::lonnet::critical('put:'.$ENV{'course.'.$cid.'.domain'}.':'. + $ENV{'course.'.$cid.'.num'}.':classlist:'. + &Apache::lonnet::escape($ENV{'form.cuname'}.':'. + $ENV{'form.cdomain'}).'='. + &Apache::lonnet::escape($now.':'), + $ENV{'course.'.$cid.'.home'}).'
'); + } } } keys %ENV; - $r->print(''); map { if (($_=~/^form\.act\_([^\_]+)\_([^\_]+)\_([^\_]+)$/) && ($ENV{$_})) { - $r->print('a:'.$_.': '.$1.' '.$2.' '.$3.'
'); - } + my $url='/'.$1.'/'.$2; + if ($ENV{'form.sec_'.$1.'_'.$2.'_'.$3}) { + $url.='/'.$ENV{'form.sec_'.$1.'_'.$2.'_'.$3}; + } + my $start=$now; + if ($ENV{'form.start_'.$1.'_'.$2.'_'.$3}) { + $start=$ENV{'form.start_'.$1.'_'.$2.'_'.$3}; + } + my $end=0; + if ($ENV{'form.end_'.$1.'_'.$2.'_'.$3}) { + $end=$ENV{'form.end_'.$1.'_'.$2.'_'.$3}; + } + $r->print('Assigning: '.$3.' in '.$url.': '. + &Apache::lonnet::assignrole($ENV{'form.cdomain'},$ENV{'form.cuname'}, + $url,$3,$end,$start).'
'); + if ($3 eq 'st') { + $url=~/^\/(\w+)\/(\w+)/; + my $cid=$1.'_'.$2; + $r->print('Add to classlist: '. + &Apache::lonnet::critical('put:'.$ENV{'course.'.$cid.'.domain'}.':'. + $ENV{'course.'.$cid.'.num'}.':classlist:'. + &Apache::lonnet::escape($ENV{'form.cuname'}.':'. + $ENV{'form.cdomain'}).'='. + &Apache::lonnet::escape($end.':'.$start), + $ENV{'course.'.$cid.'.home'}).'
'); + } + } elsif (($_=~/^form\.act\_([^\_]+)\_([^\_]+)$/) && ($ENV{$_})) { + my $url='/'.$1.'/'; + my $start=$now; + if ($ENV{'form.start_'.$1.'_'.$2}) { + $start=$ENV{'form.start_'.$1.'_'.$2}; + } + my $end=0; + if ($ENV{'form.end_'.$1.'_'.$2}) { + $end=$ENV{'form.end_'.$1.'_'.$2}; + } + $r->print('Assigning: '.$2.' in '.$url.': '. + &Apache::lonnet::assignrole($ENV{'form.cdomain'},$ENV{'form.cuname'}, + $url,$2,$end,$start).'
'); + } } keys %ENV; + $r->print(''); } # ================================================================ Main Handler @@ -431,7 +491,7 @@ sub handler { } } else { $ENV{'user.error.msg'}= - "/adm/createcourse:mau:0:0:Cannot modify user data"; + "/adm/createuser:mau:0:0:Cannot modify user data"; return HTTP_NOT_ACCEPTABLE; } return OK;