--- loncom/interface/loncreateuser.pm 2006/11/21 21:38:44 1.134 +++ loncom/interface/loncreateuser.pm 2007/03/12 17:06:59 1.148 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Create a user # -# $Id: loncreateuser.pm,v 1.134 2006/11/21 21:38:44 raeburn Exp $ +# $Id: loncreateuser.pm,v 1.148 2007/03/12 17:06:59 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -66,7 +66,7 @@ use Apache::loncommon; use Apache::lonlocal; use Apache::longroup; use lib '/home/httpd/lib/perl/'; -use LONCAPA; +use LONCAPA qw(:DEFAULT :match); my $loginscript; # piece of javascript used in two separate instances my $generalrule; @@ -99,8 +99,8 @@ sub initialize_authen_forms { sub my_custom_roles { my %returnhash=(); my %rolehash=&Apache::lonnet::dump('roles'); - foreach (keys %rolehash) { - if ($_=~/^rolesdef\_(\w+)$/) { + foreach my $key (keys %rolehash) { + if ($key=~/^rolesdef\_(\w+)$/) { $returnhash{$1}=$1; } } @@ -135,7 +135,6 @@ sub portfolio_quota { sub print_username_entry_form { my ($r) = @_; my $defdom=$env{'request.role.domain'}; - my @domains = &Apache::loncommon::get_domains(); my $domform = &Apache::loncommon::select_dom_form($defdom,'ccdomain'); my $selscript=&Apache::loncommon::studentbrowser_javascript(); my $start_page = @@ -216,11 +215,8 @@ END # =================================================================== Phase two sub print_user_modification_page { my $r=shift; - my $ccuname=$env{'form.ccuname'}; - my $ccdomain=$env{'form.ccdomain'}; - - $ccuname=~s/\W//g; - $ccdomain=~s/\W//g; + my $ccuname =&LONCAPA::clean_username($env{'form.ccuname'}); + my $ccdomain=&LONCAPA::clean_domain($env{'form.ccdomain'}); unless (($ccuname) && ($ccdomain)) { &print_username_entry_form($r); @@ -238,9 +234,9 @@ sub print_user_modification_page { ); $loginscript = &Apache::loncommon::authform_header(%param); $authformkrb = &Apache::loncommon::authform_kerberos(%param); - - $ccuname=~s/\W//g; - $ccdomain=~s/\W//g; + + $ccuname =&LONCAPA::clean_username($ccuname); + $ccdomain=&LONCAPA::clean_domain($ccdomain); my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition(); my $dc_setcourse_code = ''; my $nondc_setsection_code = ''; @@ -254,7 +250,7 @@ sub print_user_modification_page { $groupslist = '"'.$groupslist.'"'; } - if ($env{'request.role'} =~ m-^dc\./(\w+)/$-) { + if ($env{'request.role'} =~ m-^dc\./($match_domain)/$-) { my $dcdom = $1; $loaditem{'onload'} = "document.cu.coursedesc.value='';"; my @rolevals = ('st','ta','ep','in','cc'); @@ -361,36 +357,6 @@ sub print_user_modification_page { } return -1; } - - function setType() { - var crstype = document.cu.crstype.options[document.cu.crstype.selectedIndex].value; - rolevals = new Array("$rolevalslist"); - if (crstype == 'Group') { - if (document.cu.currsec.options[0].text == "$pickcrsfirst") { - document.cu.currsec.options[0].text = "$pickgrpfirst"; - } - grprolenames = new Array("$grprolenameslist"); - for (var i=0; i ENDFORMINFO my $uhome=&Apache::lonnet::homeserver($ccuname,$ccdomain); - my %incdomains; my %inccourses; - foreach (values(%Apache::lonnet::hostdom)) { - $incdomains{$_}=1; - } - foreach (keys(%env)) { - if ($_=~/^user\.priv\.cm\.\/(\w+)\/(\w+)/) { + foreach my $key (keys(%env)) { + if ($key=~/^user\.priv\.cm\.\/($match_domain)\/($match_username)/) { $inccourses{$1.'_'.$2}=1; } } @@ -576,27 +538,24 @@ ENDCHANGEUSER ['firstname','middlename','lastname','generation', 'portfolioquota'],$ccdomain,$ccuname); my %rolesdump=&Apache::lonnet::dump('roles',$ccdomain,$ccuname); - $r->print(< - - - - - -END - foreach ('firstname','middlename','lastname','generation') { + $r->print(' +
'. + &Apache::loncommon::start_data_table(). + &Apache::loncommon::start_data_table_header_row(). +''. + &Apache::loncommon::end_data_table_header_row(). + &Apache::loncommon::start_data_table_row()); + foreach my $item ('firstname','middlename','lastname','generation') { if (&Apache::lonnet::allowed('mau',$ccdomain)) { - $r->print(<<"END"); - + $r->print(<<"END"); + END } else { - $r->print(''); + $r->print(''); } } - $r->print(< -
$lt{'fn'}$lt{'mn'}$lt{'ln'}$lt{'gen'}
'.$lt{'fn'}.''.$lt{'mn'}.''.$lt{'ln'}.''.$lt{'gen'}.''.$userenv{$_}.''.$userenv{$item}.'
-END + $r->print(&Apache::loncommon::end_data_table_row(). + &Apache::loncommon::end_data_table()); # Build up table of user roles to allow revocation of a role. my ($tmp) = keys(%rolesdump); unless ($tmp =~ /^(con_lost|error)/i) { @@ -625,13 +584,12 @@ END split(/_/,$role); # Is this a custom role? Get role owner and title. my ($croleudom,$croleuname,$croletitle)= - ($role_code=~/^cr\/(\w+)\/(\w+)\/(\w+)$/); - my $bgcol='ffffff'; + ($role_code=~m{^cr/($match_domain)/($match_username)/(\w+)$}); my $allowed=0; my $delallowed=0; my $sortkey=$role_code; my $class='Unknown'; - if ($area =~ /^\/(\w+)\/(\d\w+)/ ) { + if ($area =~ m{^/($match_domain)/($match_courseid)} ) { $class='Course'; my ($coursedom,$coursedir) = ($1,$2); $sortkey.="\0$coursedom"; @@ -667,10 +625,7 @@ END } } # Compute the background color based on $area - $bgcol=$1.'_'.$2; - $bgcol=~s/[^7-9a-e]//g; - $bgcol=substr($bgcol.$bgcol.$bgcol.'ffffff',2,6); - if ($area=~/^\/(\w+)\/(\d\w+)\/(\w+)/) { + if ($area=~m{^/($match_domain)/($match_courseid)/(\w+)}) { $carea.='
Section: '.$3; $sortkey.="\0$3"; } @@ -678,7 +633,7 @@ END } else { $sortkey.="\0".$area; # Determine if current user is able to revoke privileges - if ($area=~ /^\/(\w+)\//) { + if ($area=~m{^/($match_domain)/}) { if ((&Apache::lonnet::allowed('c'.$role_code,$1)) || (&Apache::lonnet::allowed('c'.$role_code,$ccdomain))) { $allowed=1; @@ -702,16 +657,15 @@ END } } if (($role_code eq 'ca') || ($role_code eq 'aa')) { - $area=~/\/(\w+)\/(\w+)/; + $area=~m{/($match_domain)/($match_username)}; if (&authorpriv($2,$1)) { $allowed=1; } else { $allowed=0; } } - $bgcol='77FF77'; my $row = ''; - $row.=''; + $row.= ''; my $active=1; $active=0 if (($role_end_time) && ($now>$role_end_time)); if (($active) && ($allowed)) { @@ -748,7 +702,7 @@ END : ' ' ). ''.($role_end_time ?localtime($role_end_time) : ' ' ) - ."\n"; + .""; $sortrole{$sortkey}=$envkey; $roletext{$envkey}=$row; $roleclass{$envkey}=$class; @@ -761,30 +715,35 @@ END $output{$type} = ''; foreach my $which (sort {uc($a) cmp uc($b)} (keys(%sortrole))) { if ( ($roleclass{$sortrole{$which}} =~ /^\Q$type\E/ ) && ($rolepriv{$sortrole{$which}}) ) { - $output{$type}.=$roletext{$sortrole{$which}}; + $output{$type}.= + &Apache::loncommon::start_data_table_row(). + $roletext{$sortrole{$which}}. + &Apache::loncommon::end_data_table_row(); } } unless($output{$type} eq '') { - $output{$type} = "". - "".&mt($type)."". + $output{$type} = ''. + "".&mt($type)."". $output{$type}; $rolesdisplay = 1; } } if ($rolesdisplay == 1) { - $r->print(<print('
-

$lt{'rer'}

- - -END +

'.$lt{'rer'}.'

'. +&Apache::loncommon::start_data_table("LC_createuser"). +&Apache::loncommon::start_data_table_header_row(). +''. +&Apache::loncommon::end_data_table_header_row()); foreach my $type ('Construction Space','Course','Group','Domain','System','Unknown') { if ($output{$type}) { $r->print($output{$type}."\n"); } } - $r->print('
$lt{'rev'}$lt{'ren'}$lt{'del'}$lt{'rol'}$lt{'e -xt'}$lt{'sta'}$lt{'end'}'.$lt{'rev'}.''.$lt{'ren'}.''.$lt{'del'}. +''.$lt{'rol'}.''.$lt{'ext'}. +''.$lt{'sta'}.''.$lt{'end'}.'
'); + $r->print(&Apache::loncommon::end_data_table()); } } # End of unless my $currentauth=&Apache::lonnet::queryauthenticate($ccuname,$ccdomain); @@ -923,34 +882,38 @@ ENDNOPRIV 'ssd' => "Set Start Date", 'sed' => "Set End Date" ); - $r->print(<$lt{'cs'} - - - - - - - -'. + ''. + ''."\n". + &Apache::loncommon::end_data_table_header_row()."\n". + &Apache::loncommon::start_data_table_row()."\n". + ' + + + + - - - - - -'."\n". + &Apache::loncommon::end_data_table_row()."\n". + &Apache::loncommon::start_data_table_row()."\n". +' + + + - + - -
$lt{'act'}$lt{'rol'}$lt{'ext'}$lt{'sta'}$lt{'end'}
$lt{'cau'}$cudom\_$cuname -$lt{'ssd'} + $r->print('

'.$lt{'cs'}.'

'."\n". + &Apache::loncommon::start_data_table()."\n". + &Apache::loncommon::start_data_table_header_row()."\n". + '
'.$lt{'act'}.''.$lt{'rol'}.''.$lt{'ext'}.''.$lt{'sta'}.''.$lt{'end'}.' + + '.$lt{'cau'}.''.$cudom.'_'.$cuname.' + '.$lt{'ssd'}.' $lt{'sed'}
$lt{'caa'}$cudom\_$cuname +"javascript:pjump('."'date_end','End Date Co-Author',document.cu.end_$cudom\_$cuname\_ca.value,'end_$cudom\_$cuname\_ca','cu.pres','dateset'".')">'.$lt{'sed'}.''.$lt{'caa'}.''.$cudom.'_'.$cuname.' $lt{'ssd'} +"javascript:pjump('."'date_start','Start Date Assistant Co-Author',document.cu.start_$cudom\_$cuname\_aa.value,'start_$cudom\_$cuname\_aa','cu.pres','dateset'".')">'.$lt{'ssd'}.' $lt{'sed'}
-ENDCOAUTH +"javascript:pjump('."'date_end','End Date Assistant Co-Author',document.cu.end_$cudom\_$cuname\_aa.value,'end_$cudom\_$cuname\_aa','cu.pres','dateset'".')">'.$lt{'sed'}.''."\n". + &Apache::loncommon::end_data_table_row()."\n". + &Apache::loncommon::end_data_table()); } # # Domain level @@ -958,35 +921,37 @@ ENDCOAUTH my $num_domain_level = 0; my $domaintext = '

'.&mt('Domain Level').'

'. - ''. - ''; - foreach ( sort( keys(%incdomains))) { - my $thisdomain=$_; - foreach ('dc','li','dg','au','sc') { - if (&Apache::lonnet::allowed('c'.$_,$thisdomain)) { - my $plrole=&Apache::lonnet::plaintext($_); + &Apache::loncommon::start_data_table(). + &Apache::loncommon::start_data_table_header_row(). + ''. + ''. + &Apache::loncommon::end_data_table_header_row(); + foreach my $thisdomain (sort(&Apache::lonnet::all_domains())) { + foreach my $role ('dc','li','dg','au','sc') { + if (&Apache::lonnet::allowed('c'.$role,$thisdomain)) { + my $plrole=&Apache::lonnet::plaintext($role); my %lt=&Apache::lonlocal::texthash( 'ssd' => "Set Start Date", 'sed' => "Set End Date" ); $num_domain_level ++; - $domaintext .= <<"ENDDROW"; - - - - - + + + - + - -ENDDROW +"javascript:pjump('."'date_end','End Date $plrole',document.cu.end_$thisdomain\_$role.value,'end_$thisdomain\_$role','cu.pres','dateset'".')">'.$lt{'sed'}.''. +&Apache::loncommon::end_data_table_row(); } } } - $domaintext.='
'.&mt('Activate').''.&mt('Role').''.&mt('Extent').''.&mt('Start').''.&mt('End').'
'.&mt('Activate').''.&mt('Role').''. + &mt('Extent').''.&mt('Start').''.&mt('End').'
$plrole$thisdomain + $domaintext .= +&Apache::loncommon::start_data_table_row(). +''.$plrole.''.$thisdomain.' $lt{'ssd'} +"javascript:pjump('."'date_start','Start Date $plrole',document.cu.start_$thisdomain\_$role.value,'start_$thisdomain\_$role','cu.pres','dateset'".')">'.$lt{'ssd'}.' $lt{'sed'}
'; + $domaintext.= &Apache::loncommon::end_data_table(); if ($num_domain_level > 0) { $r->print($domaintext); } @@ -994,7 +959,7 @@ ENDDROW # Course and group levels # - if ($env{'request.role'} =~ m-^dc\./(\w+)/$-) { + if ($env{'request.role'} =~ m{^dc\./($match_domain)/$}) { $r->print(&course_level_dc($1,'Course')); $r->print('
'."\n"); } else { @@ -1026,7 +991,8 @@ sub update_user_data { $r->print($error.&mt('No login name specified').'.'.$end); return; } - if ( $env{'form.ccuname'} =~/\W/) { + if ( $env{'form.ccuname'} ne + &LONCAPA::clean_username($env{'form.ccuname'}) ) { $r->print($error.&mt('Invalid login name').'. '. &mt('Only letters, numbers, and underscores are valid').'.'. $end); @@ -1036,9 +1002,10 @@ sub update_user_data { $r->print($error.&mt('No domain specified').'.'.$end); return; } - if ( $env{'form.ccdomain'} =~/\W/) { + if ( $env{'form.ccdomain'} ne + &LONCAPA::clean_domain($env{'form.ccdomain'}) ) { $r->print($error.&mt ('Invalid domain name').'. '. - &mt('Only letters, numbers, and underscores are valid').'.'. + &mt('Only letters, numbers, periods, dashes, and underscores are valid').'.'. $end); return; } @@ -1097,8 +1064,8 @@ ENDNEWUSERHEAD if (lc($desiredhost) eq 'default') { $desiredhost = undef; } else { - my %home_servers = &Apache::loncommon::get_library_servers - ($env{'form.ccdomain'}); + my %home_servers = + &Apache::lonnet::get_servers($env{'form.ccdomain'},'library'); if (! exists($home_servers{$desiredhost})) { $r->print($error.&mt('Invalid home server specified')); return; @@ -1115,7 +1082,7 @@ ENDNEWUSERHEAD my $home = &Apache::lonnet::homeserver($env{'form.ccuname'}, $env{'form.ccdomain'}); $r->print('
'.&mt('Home server').': '.$home.' '. - $Apache::lonnet::libserv{$home}); + &Apache::lonnet::hostname($home)); } elsif (($env{'form.login'} ne 'nochange') && ($env{'form.login'} ne '' )) { # Modify user privileges @@ -1154,9 +1121,9 @@ ENDMODIFYUSERHEAD %userenv = (); } # Check to see if we need to change user information - foreach ('firstname','middlename','lastname','generation') { + foreach my $item ('firstname','middlename','lastname','generation') { # Strip leading and trailing whitespace - $env{'form.c'.$_} =~ s/(\s+$|^\s+)//g; + $env{'form.c'.$item} =~ s/(\s+$|^\s+)//g; } my ($quotachanged,$namechanged,$oldportfolioquota); my %changeHash; @@ -1172,7 +1139,8 @@ ENDMODIFYUSERHEAD } } } else { - $oldportfolioquota = &default_quota($env{'form.ccdomain'}); + $oldportfolioquota = + &Apache::loncommon::default_quota($env{'form.ccdomain'}); } if (&Apache::lonnet::allowed('mau',$env{'form.ccdomain'}) && ($env{'form.cfirstname'} ne $userenv{'firstname'} || @@ -1261,17 +1229,17 @@ END ## my $now=time; $r->print('

'.&mt('Modifying Roles').'

'); - foreach (keys (%env)) { - next if (! $env{$_}); + foreach my $key (keys (%env)) { + next if (! $env{$key}); # Revoke roles - if ($_=~/^form\.rev/) { - if ($_=~/^form\.rev\:([^\_]+)\_([^\_\.]+)$/) { + if ($key=~/^form\.rev/) { + if ($key=~/^form\.rev\:([^\_]+)\_([^\_\.]+)$/) { # Revoke standard role $r->print(&mt('Revoking').' '.$2.' in '.$1.': '. &Apache::lonnet::revokerole($env{'form.ccdomain'}, $env{'form.ccuname'},$1,$2).'
'); if ($2 eq 'st') { - $1=~/^\/(\w+)\/(\w+)/; + $1=~m{^/($match_domain)/($match_courseid)}; my $cid=$1.'_'.$2; $r->print(&mt('Drop from classlist').': '. &Apache::lonnet::critical('put:'. @@ -1283,22 +1251,22 @@ END $env{'course.'.$cid.'.home'}).'
'); } } - if ($_=~/^form\.rev\:([^\_]+)\_cr\.cr\/(\w+)\/(\w+)\/(\w+)$/) { + if ($key=~m{^form\.rev\:([^_]+)_cr\.cr/($match_domain)/($match_username)/(\w+)$}) { # Revoke custom role $r->print(&mt('Revoking custom role:'). - ' '.$4.' by '.$3.'@'.$2.' in '.$1.': '. + ' '.$4.' by '.$3.':'.$2.' in '.$1.': '. &Apache::lonnet::revokecustomrole($env{'form.ccdomain'}, $env{'form.ccuname'},$1,$2,$3,$4). '
'); } - } elsif ($_=~/^form\.del/) { - if ($_=~/^form\.del\:([^\_]+)\_([^\_\.]+)$/) { + } elsif ($key=~/^form\.del/) { + if ($key=~/^form\.del\:([^\_]+)\_([^\_\.]+)$/) { # Delete standard role $r->print(&mt('Deleting').' '.$2.' in '.$1.': '. &Apache::lonnet::assignrole($env{'form.ccdomain'}, $env{'form.ccuname'},$1,$2,$now,0,1).'
'); if ($2 eq 'st') { - $1=~/^\/(\w+)\/(\w+)/; + $1=~m{^/($match_domain)/($match_courseid)}; my $cid=$1.'_'.$2; $r->print(&mt('Drop from classlist').': '. &Apache::lonnet::critical('put:'. @@ -1310,7 +1278,7 @@ END $env{'course.'.$cid.'.home'}).'
'); } } - if ($_=~/^form\.del\:([^\_]+)\_cr\.cr\/(\w+)\/(\w+)\/(\w+)$/) { + 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]@[_3] in [_4]', @@ -1319,17 +1287,17 @@ END $env{'form.ccuname'},$url,$rdom,$rnam,$rolename,$now, 0,1).'

'); } - } elsif ($_=~/^form\.ren/) { + } elsif ($key=~/^form\.ren/) { my $udom = $env{'form.ccdomain'}; my $uname = $env{'form.ccuname'}; # Re-enable standard role - if ($_=~/^form\.ren\:([^\_]+)\_([^\_\.]+)$/) { + if ($key=~/^form\.ren\:([^\_]+)\_([^\_\.]+)$/) { my $url = $1; my $role = $2; my $logmsg; my $output; if ($role eq 'st') { - if ($url =~ m-^/(\w+)/(\w+)/?(\w*)$-) { + if ($url =~ m-^/($match_domain)/($match_courseid)/?(\w*)$-) { my $result = &Apache::loncommon::commit_studentrole(\$logmsg,$udom,$uname,$url,$role,$now,0,$1,$2,$3); if (($result =~ /^error/) || ($result eq 'not_in_class') || ($result eq 'unknown_course')) { $output = "Error: $result\n"; @@ -1349,7 +1317,7 @@ END $r->print($output); } # Re-enable custom role - if ($_=~/^form\.ren\:([^\_]+)\_cr\.cr\/(\w+)\/(\w+)\/(\w+)$/) { + if ($key=~m{^form\.ren\:([^_]+)_cr\.cr/($match_domain)/($match_username)/(\w+)$}) { my ($url,$rdom,$rnam,$rolename) = ($1,$2,$3,$4); my $result = &Apache::lonnet::assigncustomrole( $env{'form.ccdomain'}, $env{'form.ccuname'}, @@ -1357,10 +1325,10 @@ END $r->print(&mt('Re-enabling custom role [_1] by [_2]@[_3] in [_4] : [_5]', $rolename,$rnam,$rdom,$url,$result).'
'); } - } elsif ($_=~/^form\.act/) { + } elsif ($key=~/^form\.act/) { my $udom = $env{'form.ccdomain'}; my $uname = $env{'form.ccuname'}; - if ($_=~/^form\.act\_([^\_]+)\_([^\_]+)\_cr_cr_([^\_]+)_(\w+)_([^\_]+)$/) { + if ($key=~/^form\.act\_($match_domain)\_($match_courseid)\_cr_cr_($match_domain)_($match_username)_([^\_]+)$/) { # Activate a custom role my ($one,$two,$three,$four,$five)=($1,$2,$3,$4,$5); my $url='/'.$one.'/'.$two; @@ -1391,7 +1359,7 @@ END $r->print(&Apache::loncommon::commit_customrole($udom,$uname,$securl,$three,$four,$five,$start,$end)); } } - } elsif ($_=~/^form\.act\_([^\_]+)\_(\w+)\_([^\_]+)$/) { + } elsif ($key=~/^form\.act\_($match_domain)\_($match_name)\_([^\_]+)$/) { # Activate roles for sections with 3 id numbers # set start, end times, and the url for the class my ($one,$two,$three)=($1,$2,$3); @@ -1430,7 +1398,7 @@ END $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$three,$start,$end,$one,$two,'')); } } - } elsif ($_=~/^form\.act\_([^\_]+)\_([^\_]+)$/) { + } elsif ($key=~/^form\.act\_([^\_]+)\_([^\_]+)$/) { # Activate roles for sections with two id numbers # set start, end times, and the url for the class my $start = ( $env{'form.start_'.$1.'_'.$2} ? @@ -1460,7 +1428,7 @@ END } } } else { - $r->print('

'.&mt('ERROR').': '.&mt('Unknown command').' '.$_.'


'); + $r->print('

'.&mt('ERROR').': '.&mt('Unknown command').' '.$key.'


'); } foreach my $key (sort(keys(%disallowed))) { if (($key eq 'none') || ($key eq 'all')) { @@ -1549,8 +1517,8 @@ sub custom_role_editor { my %full=(); my %courselevel=(); my %courselevelcurrent=(); - foreach (split(/\:/,$Apache::lonnet::pr{'cr:c'})) { - my ($priv,$restrict)=split(/\&/,$_); + foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:c'})) { + my ($priv,$restrict)=split(/\&/,$item); unless ($restrict) { $restrict='F'; } $courselevel{$priv}=$restrict; if ($coursepriv=~/\:$priv/) { @@ -1560,8 +1528,8 @@ sub custom_role_editor { } my %domainlevel=(); my %domainlevelcurrent=(); - foreach (split(/\:/,$Apache::lonnet::pr{'cr:d'})) { - my ($priv,$restrict)=split(/\&/,$_); + foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:d'})) { + my ($priv,$restrict)=split(/\&/,$item); unless ($restrict) { $restrict='F'; } $domainlevel{$priv}=$restrict; if ($dompriv=~/\:$priv/) { @@ -1571,8 +1539,8 @@ sub custom_role_editor { } my %systemlevel=(); my %systemlevelcurrent=(); - foreach (split(/\:/,$Apache::lonnet::pr{'cr:s'})) { - my ($priv,$restrict)=split(/\&/,$_); + foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:s'})) { + my ($priv,$restrict)=split(/\&/,$item); unless ($restrict) { $restrict='F'; } $systemlevel{$priv}=$restrict; if ($syspriv=~/\:$priv/) { @@ -1590,13 +1558,16 @@ sub custom_role_editor {
- - - ENDCCF + $r->print(&Apache::loncommon::start_data_table(). + &Apache::loncommon::start_data_table_header_row(). +''. + &Apache::loncommon::end_data_table_header_row()); foreach my $priv (sort keys %full) { my $privtext = &Apache::lonnet::plaintext($priv); - $r->print(''); + ''. + &Apache::loncommon::end_data_table_row()); } - $r->print( - '
$lt{'prv'}$lt{'crl'}$lt{'dml'}$lt{'ssl'}
'.$lt{'prv'}.''.$lt{'crl'}.''.$lt{'dml'}. +''.$lt{'ssl'}.'
'.$privtext.''. + $r->print(&Apache::loncommon::start_data_table_row(). + ''.$privtext.''. ($courselevel{$priv}?'':' '). ''. @@ -1605,10 +1576,11 @@ ENDCCF ''. ($systemlevel{$priv}?'':' '). - '
'. + $r->print(&Apache::loncommon::end_data_table(). + ''. &Apache::loncommon::end_page()); } @@ -1642,27 +1614,27 @@ sub set_custom_role { my $domrole=''; my $courole=''; - foreach (split(/\:/,$Apache::lonnet::pr{'cr:c'})) { - my ($priv,$restrict)=split(/\&/,$_); + foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:c'})) { + my ($priv,$restrict)=split(/\&/,$item); unless ($restrict) { $restrict=''; } if ($env{'form.'.$priv.':c'}) { - $courole.=':'.$_; + $courole.=':'.$item; } } - foreach (split(/\:/,$Apache::lonnet::pr{'cr:d'})) { - my ($priv,$restrict)=split(/\&/,$_); + foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:d'})) { + my ($priv,$restrict)=split(/\&/,$item); unless ($restrict) { $restrict=''; } if ($env{'form.'.$priv.':d'}) { - $domrole.=':'.$_; + $domrole.=':'.$item; } } - foreach (split(/\:/,$Apache::lonnet::pr{'cr:s'})) { - my ($priv,$restrict)=split(/\&/,$_); + foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:s'})) { + my ($priv,$restrict)=split(/\&/,$item); unless ($restrict) { $restrict=''; } if ($env{'form.'.$priv.':s'}) { - $sysrole.=':'.$_; + $sysrole.=':'.$item; } } $r->print('
Defining Role: '. @@ -1741,17 +1713,13 @@ sub course_level_table { 'end' => "End" ); - foreach (sort( keys(%inccourses))) { - my $thiscourse=$_; - my $protectedcourse=$_; + foreach my $protectedcourse (sort( keys(%inccourses))) { + my $thiscourse=$protectedcourse; $thiscourse=~s:_:/:g; my %coursedata=&Apache::lonnet::coursedescription($thiscourse); my $area=$coursedata{'description'}; my $type=$coursedata{'type'}; - if (!defined($area)) { $area=&mt('Unavailable course').': '.$_; } - my $bgcol=$thiscourse; - $bgcol=~s/[^7-9a-e]//g; - $bgcol=substr($bgcol.$bgcol.$bgcol.'ffffff',2,6); + if (!defined($area)) { $area=&mt('Unavailable course').': '.$protectedcourse; } my ($domain,$cnum)=split(/\//,$thiscourse); my %sections_count; if (defined($env{'request.course.id'})) { @@ -1760,57 +1728,54 @@ sub course_level_table { &Apache::loncommon::get_sections($domain,$cnum); } } - foreach ('st','ta','ep','in','cc') { - if (&Apache::lonnet::allowed('c'.$_,$thiscourse)) { - my $plrole=&Apache::lonnet::plaintext($_); - $table .= < - - - -ENDEXTENT - if ($_ ne 'cc') { + foreach my $role ('st','ta','ep','in','cc') { + if (&Apache::lonnet::allowed('c'.$role,$thiscourse)) { + my $plrole=&Apache::lonnet::plaintext($role); + $table .= &Apache::loncommon::start_data_table_row(). +' + +'."\n"; + if ($role ne 'cc') { if (%sections_count) { - my $currsec = &course_sections(\%sections_count,$protectedcourse.'_'.$_); + my $currsec = &course_sections(\%sections_count,$protectedcourse.'_'.$role); $table .= - ' +'. +&Apache::loncommon::end_data_table_header_row(). +&Apache::loncommon::start_data_table_row(). +$table. +&Apache::loncommon::end_data_table_row(). +&Apache::loncommon::end_data_table(); return $result; } @@ -1863,9 +1833,9 @@ sub course_sections { $output = ''; @@ -1882,7 +1852,6 @@ sub course_level_dc { ('cu','dccourse','dcdomain','coursedesc',undef,undef,'Course').''; my $cb_jscript = &Apache::loncommon::coursebrowser_javascript($dcdom,'currsec','cu'); my %lt=&Apache::lonlocal::texthash( - 'typ' => "Type", 'rol' => "Role", 'grs' => "Section", 'exs' => "Existing sections", @@ -1893,23 +1862,22 @@ sub course_level_dc { 'sed' => "Set End Date" ); my $header = '

'.&mt('Course Level').'

'. - '
$plrole$area
Domain: $domain
'.$plrole.''.$area.'
Domain: '.$domain.'
'. - ''; } else { $table .= ''; + 'name="sec_'.$protectedcourse.'_'.$role.'">'; } } else { $table .= ''; } $table .= < + - + +"javascript:pjump('date_end','End Date $plrole',document.cu.end_$protectedcourse\_$role.value,'end_$protectedcourse\_$role','cu.pres','dateset')">$lt{'sed'} ENDTIMEENTRY - $table.= "\n"; + $table.= &Apache::loncommon::end_data_table_row(); } } - foreach (sort keys %customroles) { + foreach my $cust (sort keys %customroles) { if (&Apache::lonnet::allowed('ccr',$thiscourse)) { - my $plrole=$_; + my $plrole=$cust; my $customrole=$protectedcourse.'_cr_cr_'.$env{'user.domain'}. '_'.$env{'user.name'}.'_'.$plrole; - $table .= < - - - -END + $table .= &Apache::loncommon::start_data_table_row(). +' + +'."\n"; if (%sections_count) { my $currsec = &course_sections(\%sections_count,$customrole); $table.= @@ -1833,20 +1798,25 @@ END "javascript:pjump('date_start','Start Date $plrole',document.cu.start_$customrole.value,'start_$customrole','cu.pres','dateset')">$lt{'ssd'} +"javascript:pjump('date_end','End Date $plrole',document.cu.end_$customrole.value,'end_$customrole','cu.pres','dateset')">$lt{'sed'} ENDENTRY + $table .= &Apache::loncommon::end_data_table_row(); } } } return '' if ($table eq ''); # return nothing if there is nothing # in the table - my $result = <$lt{'crl'} -
'.$lt{'exs'}.'
'. + '
'. + ' + '. ''. ''. + ''. ''. + 'name="sec_'.$protectedcourse.'_'.$role.'">'. '
'.$lt{'exs'}.'
'. $currsec.'
   '.$lt{'new'}.'
'. - '
  $lt{'ssd'} +"javascript:pjump('date_start','Start Date $plrole',document.cu.start_$protectedcourse\_$role.value,'start_$protectedcourse\_$role','cu.pres','dateset')">$lt{'ssd'} $lt{'sed'}
$plrole$area'.$plrole.''.$area.' $lt{'sed'}
- -$table -
$lt{'act'}$lt{'rol'}$lt{'ext'}$lt{'grs'}$lt{'sta'}$lt{'end'}
-ENDTABLE + my $result = ' +

'.$lt{'crl'}.'

'. +&Apache::loncommon::start_data_table(). +&Apache::loncommon::start_data_table_header_row(). +'
'.$lt{'act'}.''.$lt{'rol'}.''.$lt{'ext'}.''.$lt{'grs'}.''.$lt{'sta'}.''.$lt{'end'}.'
'; - my $otheritems = ''. + &Apache::loncommon::end_data_table_header_row(); + my $otheritems = &Apache::loncommon::start_data_table_row()."\n". ''."\n". ' ENDTIMEENTRY - $otheritems .= "
'.$lt{'typ'}.''.$courseform.''.$lt{'rol'}.''.$lt{'grs'}.''.$lt{'sta'}.''.$lt{'end'}.'
'."\n". + &Apache::loncommon::start_data_table(). + &Apache::loncommon::start_data_table_header_row(). + ''.$courseform.''.$lt{'rol'}.''.$lt{'grs'}.''.$lt{'sta'}.''.$lt{'end'}.''. @@ -1929,7 +1897,8 @@ sub course_level_dc { $lt{'sed'}
\n"; + $otheritems .= &Apache::loncommon::end_data_table_row(). + &Apache::loncommon::end_data_table()."\n"; return $cb_jscript.$header.$hiddenitems.$otheritems; }