--- loncom/auth/lonroles.pm 2007/04/17 15:44:58 1.177 +++ loncom/auth/lonroles.pm 2008/01/26 21:12:32 1.182 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # User Roles Screen # -# $Id: lonroles.pm,v 1.177 2007/04/17 15:44:58 www Exp $ +# $Id: lonroles.pm,v 1.182 2008/01/26 21:12:32 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -122,13 +122,35 @@ sub handler { "request.role.adv" => $env{'user.adv'}, "request.role.domain" => $env{'user.domain'}); -# Check if user is a DC trying to enter a course and needs privs to be created +# Check if user is a DC trying to enter a course or author space and needs privs to be created if ($numdc > 0) { foreach my $envkey (keys %env) { +# Is this an ad-hoc CC-role? if (my ($domain,$coursenum) = ($envkey =~ m-^form\.cc\./($match_domain)/($match_courseid)$-)) { if ($dcroles{$domain}) { - &check_privs($domain,$coursenum,$then,$now); + &check_privs($domain,$coursenum,$then,$now,'cc'); + } + last; + } +# Is this a recent ad-hoc CA-role? + if (my ($domain,$coursenum) = + ($envkey =~ m-^form\.ca\./($match_domain)/($match_courseid)$-)) { + if ($dcroles{$domain}) { + &check_privs($domain,$coursenum,$then,$now,'ca'); + } + last; + } +# Is this a new ad-hoc CA-role? + if (my ($domain) = + ($envkey =~ m-^form\.adhocca\./($match_domain)$-)) { + if ($dcroles{$domain}) { + my $user=$env{'form.adhoccauname.'.$domain}; + if (!$user) { $user=$env{'form.adhoccaunamerecent.'.$domain} }; + if (($user) && ($user=~/$match_username/)) { + &check_privs($domain,$user,$then,$now,'ca'); + $env{'form.ca./'.$domain.'/'.$user}=1; + } } last; } @@ -201,7 +223,7 @@ sub handler { } $r->print(< +
@@ -224,7 +246,7 @@ ENDENTEREDKEY my $end_page=&Apache::loncommon::end_page(); $r->print(< + @@ -365,11 +387,15 @@ ENDENTERKEY my $start_page=&Apache::loncommon::start_page('User Roles'); my $standby=&mt('Role selected. Please stand by.'); $standby=~s/\n/\\n/g; + my $noscript=''.&mt('Use of LON-CAPA requires Javascript to be enabled in your web browser.').'
'.&mt('As this is not the case, most functionality in the system will ba unavailable.').'

'; $r->print(< -'); + $r->print(''); $r->print(&Apache::loncommon::end_page()); return OK; } # More than one possible role # ----------------------------------------------------------------------- Table - unless (($advanced) || ($nochoose)) { + unless ((!&Apache::lonmenu::show_course()) || ($nochoose)) { $r->print("

".&mt('Select a Course to Enter')."

\n"); } $r->print('
'); @@ -672,7 +691,8 @@ ENDHEADER $output.=$roletext{'user.role.'.$_}; if ($_ =~ m-dc\./($match_domain)/- && $dcroles{$1}) { - $output .= &allcourses_row($1,'recent'); + $output .= &allcourses_row($1,'recent'). + &allcoauthors_row($1,'recent'); } } elsif ($numdc > 0) { unless ($_ =~/^error\:/) { @@ -700,7 +720,8 @@ ENDHEADER $output.=$roletext{$sortrole{$which}}; if ($sortrole{$which} =~ m-dc\./($match_domain)/-) { if ($dcroles{$1}) { - $output .= &allcourses_row($1,''); + $output .= &allcourses_row($1,''). + &allcoauthors_row($1,''); } } } @@ -885,16 +906,16 @@ sub build_roletext { } sub check_privs { - my ($cdom,$cnum,$then,$now) = @_; - my $cckey = 'user.role.cc./'.$cdom.'/'.$cnum; + my ($cdom,$cnum,$then,$now,$checkrole) = @_; + my $cckey = 'user.role.'.$checkrole.'./'.$cdom.'/'.$cnum; if ($env{$cckey}) { my ($role,$where,$trolecode,$tstart,$tend,$tremark,$tstatus,$tpstart,$tpend,$tfont); &role_status($cckey,$then,$now,\$role,\$where,\$trolecode,\$tstatus,\$tstart,\$tend); unless (($tstatus eq 'is') || ($tstatus eq 'will_not')) { - &set_privileges($cdom,$cnum); + &set_privileges($cdom,$cnum,$checkrole); } } else { - &set_privileges($cdom,$cnum); + &set_privileges($cdom,$cnum,$checkrole); } } @@ -934,7 +955,7 @@ sub courselink { sub coursepick_jscript { my $verify_script = <<"END"; - -END - return $process_pick; -} - sub display_cc_role { my $rolekey = shift; my $roletext; @@ -1034,6 +1029,19 @@ sub allcourses_row { my $ccrole = &Apache::lonnet::plaintext('cc'); $output.= ''. &mt('[_1]: [_2] from domain [_3]',$ccrole,$selectlink,$dcdom). + '
'."\n"; + return $output; +} + +sub allcoauthors_row { + my ($dcdom,$rowtype) = @_; + my $output = ''. + ' '."\n"; return $output; } @@ -1044,9 +1052,9 @@ sub recent_filename { } sub set_privileges { - my ($dcdom,$pickedcourse) = @_; +# role can be cc or ca + my ($dcdom,$pickedcourse,$role) = @_; my $area = '/'.$dcdom.'/'.$pickedcourse; - my $role = 'cc'; my $spec = $role.'.'.$area; my %userroles = &Apache::lonnet::set_arearole($role,$area,'','', $env{'user.domain'}, 500 Internal Server Error

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at root@localhost to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.

'; + my $carole = &Apache::lonnet::plaintext('ca'); + my $inputlink=''; + my $gobutton=''; + $output.= ''. + &mt('[_1]: [_2] in domain [_3] [_4]',$carole,$inputlink,$dcdom,$gobutton). '