--- loncom/auth/lonroles.pm 2010/09/03 19:20:51 1.240.2.16 +++ loncom/auth/lonroles.pm 2010/03/22 20:11:08 1.246 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # User Roles Screen # -# $Id: lonroles.pm,v 1.240.2.16 2010/09/03 19:20:51 raeburn Exp $ +# $Id: lonroles.pm,v 1.246 2010/03/22 20:11:08 droeschl Exp $ # # Copyright Michigan State University Board of Trustees # @@ -57,8 +57,7 @@ course they should act on, etc. Both in handler determines via C's C<&allowed> function that a certain action is not allowed, C is used as error handler. This allows the user to select another role which may have permission to do -what they were trying to do. C can also be accessed via the -B button in the Remote Control. +what they were trying to do. =begin latex @@ -138,7 +137,6 @@ use Apache::lonannounce; use Apache::lonlocal; use Apache::lonpageflip(); use Apache::lonnavdisplay(); -use Apache::lonmainmenu(); use Apache::loncoursequeueadmin; use GDBM_File; use LONCAPA qw(:DEFAULT :match); @@ -146,19 +144,11 @@ use HTML::Entities; sub redirect_user { - my ($r,$title,$url,$msg,$launch_nav) = @_; + my ($r,$title,$url,$msg) = @_; $msg = $title if (! defined($msg)); &Apache::loncommon::content_type($r,'text/html'); &Apache::loncommon::no_cache($r); $r->send_http_header; - my $swinfo=&Apache::lonmenu::rawconfig(); - my $navwindow; - if ($launch_nav eq 'on') { - $navwindow.=&Apache::lonnavdisplay::launch_win('now',undef,undef, - ($url =~ m-^/adm/whatsnew-)); - } else { - $navwindow.=&Apache::lonnavmaps::close(); - } # Breadcrumbs my $brcrum = [{'href' => $url, @@ -166,7 +156,6 @@ sub redirect_user { my $start_page = &Apache::loncommon::start_page('Switching Role',undef, {'redirect' => [1,$url], 'bread_crumbs' => $brcrum,}); - &Apache::lonhtmlcommon::clear_breadcrumbs(); my $end_page = &Apache::loncommon::end_page(); # Note to style police: @@ -174,12 +163,6 @@ sub redirect_user { $url=~s/ /\%20/g; $r->print(< -// - -$navwindow

$msg

$end_page ENDREDIR @@ -227,7 +210,6 @@ sub handler { my %dcroles = (); my $numdc = &check_fordc(\%dcroles,$then); &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}); - my $custommenu = &Apache::loncommon::needs_gci_custom(); # ================================================================== Roles Init if ($env{'form.selectrole'}) { @@ -322,9 +304,7 @@ sub handler { } } } - if (($env{'form.cm'}) && ($env{'form.orgurl'})) { - $r->internal_redirect($env{'form.orgurl'}); - } + foreach $envkey (keys %env) { next if ($envkey!~/^user\.role\./); my ($where,$trolecode,$role,$tstatus,$tend,$tstart); @@ -451,16 +431,8 @@ ENDENTERKEY if (($cnum) && ($role ne 'ca') && ($role ne 'aa')) { my $msg; - if (&Apache::lonnet::allowed('adv') eq 'F') { $tadv=1; } - &Apache::lonnet::appenv({'request.role.adv'=>$tadv}); my ($furl,$ferr)= &Apache::lonuserstate::readmap($cdom.'/'.$cnum); - if ($custommenu) { - unless (($ferr) || ($env{'form.switchrole'})) { - &Apache::lonnet::put('nohist_crslastlogin',{$env{'user.name'}.':'.$env{'user.domain'}.':'.$csec.':'.$role => $now}, - $cdom,$cnum); - } - } if (($env{'form.orgurl'}) && ($env{'form.orgurl'}!~/^\/adm\/flip/)) { my $dest=$env{'form.orgurl'}; @@ -472,6 +444,8 @@ ENDENTERKEY } $dest .= 'symb='.$env{'form.symb'}; } + if (&Apache::lonnet::allowed('adv') eq 'F') { $tadv=1; } + &Apache::lonnet::appenv({'request.role.adv'=>$tadv}); if (($ferr) && ($tadv)) { &error_page($r,$ferr,$dest); } else { @@ -490,6 +464,8 @@ ENDENTERKEY .'

'.&mt('Please try again.').'

' .'

'.$ferr.'

'; } + if (&Apache::lonnet::allowed('adv') eq 'F') { $tadv=1; } + &Apache::lonnet::appenv({'request.role.adv'=>$tadv}); if (($ferr) && ($tadv)) { &error_page($r,$ferr,$furl); @@ -501,7 +477,7 @@ ENDENTERKEY $courseid = substr($courseid, 1); } $courseid =~ s/\//_/; - if (($cdom ne 'gcitest') && (($role eq 'cc') || ($role eq 'co')) + if ((($role eq 'cc') || ($role eq 'co')) && ($env{'course.' . $courseid .'.course.helper.not.run'})) { $furl = "/adm/helper/course.initialization.helper"; # Send the user to the course they selected @@ -512,10 +488,9 @@ ENDENTERKEY my $esc_symb = &HTML::Entities::encode($env{'form.destsymb'},'"<>&'); $dest .= '?symb='.$esc_symb; } - &redirect_user($r,&mt('Entering [_1]', - $env{'course.'.$courseid.'.description'}), - $dest,$msg, - $env{'environment.remotenavmap'}); + &redirect_user($r, &mt('Entering [_1]', + $env{'course.'.$courseid.'.description'}), + $dest, $msg); return OK; } if (&Apache::lonnet::allowed('whn', @@ -525,12 +500,11 @@ ENDENTERKEY .$env{'request.course.sec'}) ) { my $startpage = &courseloadpage($courseid); - unless (($startpage eq 'firstres') || ($cdom eq 'gcitest')) { + unless ($startpage eq 'firstres') { $msg = &mt('Entering [_1] ...', $env{'course.'.$courseid.'.description'}); - &redirect_user($r,&mt('New in course'), - '/adm/whatsnew?refpage=start',$msg, - $env{'environment.remotenavmap'}); + &redirect_user($r, &mt('New in course'), + '/adm/whatsnew?refpage=start', $msg); return OK; } } @@ -540,15 +514,11 @@ ENDENTERKEY # Guess not ... $furl=&Apache::lonpageflip::first_accessible_resource(); } - if (($cdom eq 'gcitest') && ($custommenu)) { - $furl = '/adm/navmaps'; - } $msg = &mt('Entering [_1] ...', $env{'course.'.$courseid.'.description'}); - &redirect_user($r,&mt('Entering [_1]', - $env{'course.'.$courseid.'.description'}), - $furl,$msg, - $env{'environment.remotenavmap'}); + &redirect_user($r, &mt('Entering [_1]', + $env{'course.'.$courseid.'.description'}), + $furl, $msg); } return OK; } @@ -585,6 +555,7 @@ ENDENTERKEY } } + # =============================================================== No Roles Init &Apache::loncommon::content_type($r,'text/html'); @@ -592,34 +563,23 @@ ENDENTERKEY $r->send_http_header; return OK if $r->header_only; - my ($crumbtext,$pagetitle,$recent,$show_course); + my $crumbtext = 'User Roles'; + my $pagetitle = 'My Roles'; + my $recent = &mt('Recent Roles'); + my $show_course=&Apache::loncommon::show_course(); + if ($show_course) { + $crumbtext = 'Courses'; + $pagetitle = 'My Courses'; + $recent = &mt('Recent Courses'); + } + my $brcrum =[{href=>"/adm/roles",text=>$crumbtext}]; + my $swinfo=&Apache::lonmenu::rawconfig(); + my $start_page=&Apache::loncommon::start_page($pagetitle,undef,{bread_crumbs=>$brcrum}); + 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 be unavailable.').'

'; - if ($custommenu) { - my $start_page = &Apache::loncommon::start_page('Main Menu',undef, - {'bread_crumbs' => 1}); - $r->print(<<"ENDCUSTOM"); -$start_page -
- -ENDCUSTOM - } else { - $crumbtext = 'User Roles'; - $pagetitle = 'My Roles'; - $recent = &mt('Recent Roles'); - $show_course=&Apache::loncommon::show_course(); - if ($show_course) { - $crumbtext = 'Courses'; - $pagetitle = 'My Courses'; - $recent = &mt('Recent Courses'); - } - my $brcrum =[{href=>"/adm/roles",text=>$crumbtext}]; - my $swinfo=&Apache::lonmenu::rawconfig(); - my $start_page=&Apache::loncommon::start_page($pagetitle,undef,{bread_crumbs=>$brcrum}); - my $standby=&mt('Role selected. Please stand by.'); - $standby=~s/\n/\\n/g; - $r->print(<print(<