--- loncom/auth/lonroles.pm 2005/06/05 07:57:28 1.121 +++ loncom/auth/lonroles.pm 2005/11/11 18:47:09 1.134 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # User Roles Screen # -# $Id: lonroles.pm,v 1.121 2005/06/05 07:57:28 albertel Exp $ +# $Id: lonroles.pm,v 1.134 2005/11/11 18:47:09 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -50,7 +50,8 @@ sub redirect_user { my $swinfo=&Apache::lonmenu::rawconfig(); my $navwindow; if ($launch_nav eq 'on') { - $navwindow.=&Apache::lonnavmaps::launch_win('now'); + $navwindow.=&Apache::lonnavmaps::launch_win('now',undef,undef, + ($url eq '/adm/whatsnew')); } else { $navwindow.=&Apache::lonnavmaps::close(); } @@ -88,6 +89,9 @@ sub handler { # ================================================================== Roles Init if ($env{'form.selectrole'}) { + if ($env{'form.newrole'}) { + $env{'form.'.$env{'form.newrole'}}=1; + } if ($env{'request.course.id'}) { my %temp=('logout_'.$env{'request.course.id'} => time); &Apache::lonnet::put('email_status',\%temp); @@ -227,7 +231,7 @@ ENDENTERKEY my $tadv=0; my $msg=&mt('Entering course ...'); - if (($cnum) && ($role ne 'ca')) { + if (($cnum) && ($role ne 'ca') && ($role ne 'aa')) { my ($furl,$ferr)= &Apache::lonuserstate::readmap($cdom.'/'.$cnum); if (($env{'form.orgurl'}) && @@ -243,7 +247,7 @@ ENDENTERKEY "request.course.id" => $cdom.'_'.$cnum); $furl='/adm/roles?tryagain=1'; $msg= - '

'. + '

'. &mt('Could not initialize course at this time.'). '

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

'.$ferr; } @@ -260,17 +264,24 @@ ENDENTERKEY if ($role eq 'cc' && $env{'course.' . $courseid . '.course.helper.not.run'}) { $furl = "/adm/helper/course.initialization.helper"; + # Send the user to the course they selected + } elsif (($env{'request.course.fn'}) + && ($role eq 'cc' && ($env{'environment.course_init_display'} ne 'firstres'))) { + $msg = &mt('Entering course ....'); + &redirect_user($r,&mt('New in course'), + '/adm/whatsnew',$msg, + $env{'environment.remotenavmap'}); + return OK; } - # Send the user to the course they selected - &redirect_user($r,&mt('Entering Course'), + &redirect_user($r,&mt('Entering Course'), $furl,$msg, $env{'environment.remotenavmap'}); - return OK; + return OK; } } # # Send the user to the construction space they selected - if ($role =~ /^(au|ca)$/) { + if ($role =~ /^(au|ca|aa)$/) { my $redirect_url = '/priv/'; if ($role eq 'au') { $redirect_url.=$env{'user.name'}; @@ -304,6 +315,7 @@ ENDENTERKEY my $swinfo=&Apache::lonmenu::rawconfig(); my $bodytag=&Apache::loncommon::bodytag('User Roles'); + my $standby=&mt('Role selected. Please stand by.'); my $helptag='
'.&Apache::loncommon::help_open_menu('','General Intro','General_Intro','User Roles',1,undef,undef,undef,undef,,&mt("Click here for help")).'
'; $r->print(< @@ -315,6 +327,20 @@ $helptag
ENDHEADER @@ -336,7 +362,7 @@ ENDHEADER # --------------------------------------------------------------- Error Header? if ($error) { $r->print("

LON-CAPA Access Control

"); - $r->print("
Access  : ".
+        $r->print("
Access  : ".
                   Apache::lonnet::plaintext($priv)."\n");
         $r->print("Resource: ".&Apache::lonenc::check_encrypt($fn)."\n");
         $r->print("Action  : $msg\n

"); @@ -354,7 +380,7 @@ ENDHEADER } else { if ($env{'user.error.msg'}) { $r->print( - '

'. + '

'. &mt('You need to choose another user role or enter a specific course for this function').'

'); } } @@ -380,7 +406,7 @@ ENDHEADER ($env{'user.name'},$env{'user.domain'})}. "
\n"); $r->print(&mt( - "Author and Co-Author roles may not be available on servers other than your home server.")); + "Author and Co-Author roles are not available on servers other than their respective home servers.")); } if (($ENV{'REDIRECT_QUERY_STRING'}) && ($fn)) { $fn.='?'.$ENV{'REDIRECT_QUERY_STRING'}; @@ -388,6 +414,7 @@ ENDHEADER $r->print('
'); $r->print(''); $r->print(''); + $r->print(''); } if ($env{'user.adv'}) { $r->print( @@ -453,7 +480,8 @@ ENDHEADER my $trole; if ($role =~ /^cr\//) { my ($rdummy,$rdomain,$rauthor,$rrole)=split(/\//,$role); - $tremark.='
'.&mt('Defined by ').$rauthor. + if ($tremark) { $tremark.='
'; } + $tremark.=&mt('Defined by ').$rauthor. &mt(' at ').$rdomain.'.'; $trole=$rrole; } else { @@ -464,18 +492,14 @@ ENDHEADER my ($tdom,$trest,$tsection)= split(/\//,Apache::lonnet::declutter($where)); # First, Co-Authorship roles - if ($role eq 'ca') { + if (($role eq 'ca') || ($role eq 'aa')) { my $home = &Apache::lonnet::homeserver($trest,$tdom); my $allowed=0; my @ids=&Apache::lonnet::current_machine_ids(); foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } } if (!$allowed) { $button=0; - $switchserver=&Apache::lonnet::escape('http://'. - $Apache::lonnet::hostname{$home}. - '/adm/login?domain='.$env{'user.domain'}. - '&username='.$env{'user.name'}. - '&firsturl=/priv/'.$trest.'/'); + $switchserver='otherserver='.$home.'&role='.$trolecode; } #next if ($home eq 'no_host'); $home = $Apache::lonnet::hostname{$home}; @@ -585,10 +609,9 @@ ENDHEADER $r->print('
'); unless ($nochoose) { $r->print(''); } $r->print(''."\n"); + ''."\n"); my $doheaders=-1; - foreach my $type ('Construction Space','Course','Domain','System') { + foreach my $type ('Domain','Construction Space','Course','System') { my $haverole=0; foreach my $which (sort {uc($a) cmp uc($b)} (keys(%sortrole))) { if ($roleclass{$sortrole{$which}} =~ /^\Q$type\E/) { @@ -605,6 +628,9 @@ ENDHEADER foreach (sort(keys(%recent_roles))) { if (defined($roletext{'user.role.'.$_})) { $output.=$roletext{'user.role.'.$_}; + if ($_ =~ m-dc\./(\w+)/- && $dcroles{$1}) { + $output .= &allcourses_row($1); + } } elsif ($numdc > 0) { unless ($_ =~/^error\:/) { $output.=&display_cc_role('user.role.'.$_); @@ -612,8 +638,8 @@ ENDHEADER } } if ($output) { - $r->print(""); + $r->print(""); $r->print($output); $r->print(""); $doheaders ++; @@ -624,7 +650,7 @@ ENDHEADER $r->print(&coursepick_jscript()); $r->print(&Apache::loncommon::coursebrowser_javascript()); } - foreach my $type ('Construction Space','Course','Domain','System') { + foreach my $type ('Construction Space','Domain','Course','System') { my $output; foreach my $which (sort {uc($a) cmp uc($b)} (keys(%sortrole))) { if ($roleclass{$sortrole{$which}} =~ /^\Q$type\E/) { @@ -638,8 +664,8 @@ ENDHEADER } if ($output) { if ($doheaders > 0) { - $r->print("". - ""); + $r->print("". + ""); } $r->print($output); } @@ -655,13 +681,13 @@ ENDHEADER } unless ($nochoose) { if ($env{'request.role'} ne 'cm') { - $r->print(''); } else { $r->print(''); } } - $r->print(''."\n"); @@ -671,7 +697,7 @@ ENDHEADER } # ------------------------------------------------------------ Privileges Info if (($advanced) && (($env{'user.error.msg'}) || ($error))) { - $r->print('

Current Privileges

'); + $r->print('

Current Privileges

'); foreach $envkey (sort keys %env) { if ($envkey=~/^user\.priv\.$env{'request.role'}\./) { @@ -761,40 +787,50 @@ sub role_status { sub build_roletext { my ($trolecode,$tdom,$trest,$tstatus,$tryagain,$advanced,$tremark,$tbg,$tfont,$trole,$ttype,$twhere,$tpstart,$tpend,$nochoose,$button,$switchserver) = @_; my $roletext=''; + my $is_dc=($trolecode =~ m/^dc\./); + my $rowspan=($is_dc) ? '' + : ' rowspan="2" '; + unless ($nochoose) { + my $buttonname=$trolecode; + $buttonname=~s/\W//g; if (!$button) { if ($switchserver) { - $roletext.=''; } else { $roletext.=(''); } } elsif ($tstatus eq 'is') { - $roletext.=(''); + $roletext.=''; } elsif ($tryagain) { $roletext.= - ''; + ''; } elsif ($advanced) { $roletext.= - ''; + ''; } else { - $roletext.=''; + $roletext.=' '; } } $tremark.=&Apache::lonannounce::showday(time,1, &Apache::lonannounce::readcalendar($tdom.'_'.$trest)); - $roletext.=''."\n"; + ''; + if (!$is_dc) { + $roletext.=''."\n"; + } return $roletext; } @@ -891,7 +927,7 @@ function process_pick(dom) { if (pickedCourse != '') { if (numbutton != -1) { var courseTarget = "cc./"+pickedDomain+"/"+pickedCourse - opener.document.rolechoice.elements[numbutton+1].name = courseTarget + opener.document.rolechoice.elements[numbutton].name = courseTarget opener.document.rolechoice.submit() } } @@ -948,18 +984,13 @@ sub allcourses_row { my $ccrole = Apache::lonnet::plaintext('cc'); my $selectlink = &courselink($dcdom); my $output = ''. - ''. - ''. - ''."\n"; + ''. + ''. + ''."\n"; return $output; }
 '.&mt('User Role').''.&mt('Extent'). - ''.&mt('Start').''.&mt('End').''. - &mt('Remarks and Calendar Announcements').'
'.&mt('Start').''.&mt('End').'
". - &mt('Recent Roles')."
". + &mt('Recent Roles')."
".&mt($type)."
".&mt($type)."
 '.&mt('No role specified'). + $r->print(''.&mt('No role specified'). ''.$tremark. ' 
'.&mt('Switch Server').'  '.$trole. ''.$twhere. ''.$tpstart. ''.$tpend. - ''.$tremark. - ' 
'.$tremark. + ' 
'. - ''. - $ccrole.''.&mt('All courses').': '. - $selectlink.''. - '
'.&mt('Domain').':'.$dcdom.'
'. - '
'. - &mt('Course Coordinator access to all courses in domain'). - ': '.$dcdom.'
'. + ''.$ccrole.''. + ' '.$selectlink.''. + ' from '.&mt('Domain').' '.$dcdom. + '