--- loncom/auth/lonroles.pm 2010/01/02 18:49:20 1.231.4.6 +++ loncom/auth/lonroles.pm 2010/01/23 21:13:04 1.231.4.12 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # User Roles Screen # -# $Id: lonroles.pm,v 1.231.4.6 2010/01/02 18:49:20 raeburn Exp $ +# $Id: lonroles.pm,v 1.231.4.12 2010/01/23 21:13:04 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -243,12 +243,12 @@ sub handler { # 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)$-)) { +# Is this an ad-hoc Coordinator role? + if (my ($ccrole,$domain,$coursenum) = + ($envkey =~ m-^form\.(cc|co)\./($match_domain)/($match_courseid)$-)) { if ($dcroles{$domain}) { &Apache::lonnet::check_adhoc_privs($domain,$coursenum, - $then,$refresh,$now,'cc'); + $then,$refresh,$now,$ccrole); } last; } @@ -479,8 +479,8 @@ ENDENTERKEY $courseid = substr($courseid, 1); } $courseid =~ s/\//_/; - if ($role eq 'cc' && $env{'course.' . $courseid . - '.course.helper.not.run'}) { + 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 } elsif ($env{'request.course.id'}) { @@ -692,13 +692,14 @@ ENDHEADER $refresh = $now; &Apache::lonnet::appenv({'user.refresh.time' => $refresh}); if ($env{'user.adv'}) { - $r->print( - '

'); + $r->print(' />'.&mt('Show all roles').'' + .' ' + .'

'); } else { if ($countactive > 0) { - &queued_selfenrollment($r); + $r->print(&Apache::loncoursequeueadmin::queued_selfenrollment()); my $domdesc = &Apache::lonnet::domain($env{'user.domain'},'description'); my $esc_dom = &HTML::Entities::encode($env{'user.domain'},'"<>&'); @@ -963,7 +964,7 @@ sub gather_roles { } elsif ($trest) { my $tcourseid=$tdom.'_'.$trest; $ttype = &Apache::loncommon::course_type($tcourseid); - $trole = &Apache::lonnet::plaintext($role,$ttype); + $trole = &Apache::lonnet::plaintext($role,$ttype,$tcourseid); if ($env{'course.'.$tcourseid.'.description'}) { $twhere=$env{'course.'.$tcourseid.'.description'}; $sortkey=$role."\0".$tdom."\0".$twhere."\0".$envkey; @@ -982,7 +983,7 @@ sub gather_roles { &Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$trest,$tdom). ''; $ttype = $newhash{'type'}; - $trole = &Apache::lonnet::plaintext($role,$ttype); + $trole = &Apache::lonnet::plaintext($role,$ttype,$tcourseid); } else { $twhere=&mt('Currently not available'); $env{'course.'.$tcourseid.'.description'}=$twhere; @@ -1098,7 +1099,7 @@ sub roletable_headers { } sub roletypes { - my @types = ('Domain','Construction Space','Course','Unavailable','System'); + my @types = ('Domain','Construction Space','Course','Community','Unavailable','System'); return @types; } @@ -1162,8 +1163,8 @@ sub findcourse_advice { } $r->print('

'.&mt('Self-Enrollment').'

'. '

'.&mt('The [_1]Course/Community Catalog[_2] provides information about all [_3] classes for which LON-CAPA courses have been created, as well as any communities in the domain.','','',$domdesc).'
'); - $r->print(&mt('You can search for courses and communities which permit self-enrollment, if you would like to enroll in one.').'

'); - &queued_selfenrollment($r); + $r->print(&mt('You can search for courses and communities which permit self-enrollment, if you would like to enroll in one.').'

'. + &Apache::loncoursequeueadmin::queued_selfenrollment()); return; } @@ -1220,49 +1221,6 @@ sub requestcourse_advice { return; } -sub queued_selfenrollment { - my ($r) = @_; - my %selfenrollrequests = &Apache::lonnet::dump('selfenrollrequests'); - my %reqs_by_date; - foreach my $item (keys(%selfenrollrequests)) { - if (ref($selfenrollrequests{$item}) eq 'HASH') { - if ($selfenrollrequests{$item}{'status'} eq 'request') { - if ($selfenrollrequests{$item}{'timestamp'}) { - push(@{$reqs_by_date{$selfenrollrequests{$item}{'timestamp'}}},$item); - } - } - } - } - if (keys(%reqs_by_date)) { - my $rolename = &Apache::lonnet::plaintext('st'); - $r->print(''.&mt('Enrollment requests pending Course Coordinator approval').'
'. - &Apache::loncommon::start_data_table(). - &Apache::loncommon::start_data_table_header_row(). - ''.&mt('Date requested').''.&mt('Course title').''. - ''.&mt('User role').''.&mt('Section').''. - &Apache::loncommon::end_data_table_header_row()); - my @sorted = sort { $a <=> $b } (keys(%reqs_by_date)); - foreach my $item (@sorted) { - if (ref($reqs_by_date{$item}) eq 'ARRAY') { - foreach my $crs (@{$reqs_by_date{$item}}) { - my %courseinfo = &Apache::lonnet::coursedescription($crs); - my $usec = $selfenrollrequests{$crs}{'section'}; - if ($usec eq '') { - $usec = &mt('No section'); - } - $r->print(&Apache::loncommon::start_data_table_row(). - ''.&Apache::lonlocal::locallocaltime($item).''. - ''.$courseinfo{'description'}.''. - ''.$rolename.''.$usec.''. - &Apache::loncommon::end_data_table_row()); - } - } - } - $r->print(&Apache::loncommon::end_data_table()); - } - return; -} - sub privileges_info { my ($which) = @_; my $output; @@ -1442,10 +1400,11 @@ sub check_fordc { sub adhoc_course_role { my ($refresh,$then) = @_; - my ($cdom,$cnum); + my ($cdom,$cnum,$crstype); $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; - if (&check_forcc($cdom,$cnum,$refresh,$then)) { + $crstype = &Apache::loncommon::course_type(); + if (&check_forcc($cdom,$cnum,$refresh,$then,$crstype)) { my $setprivs; if (!defined($env{'user.role.'.$env{'form.switchrole'}})) { $setprivs = 1; @@ -1495,11 +1454,16 @@ sub adhoc_course_role { } sub check_forcc { - my ($cdom,$cnum,$refresh,$then) = @_; - my $is_cc; + my ($cdom,$cnum,$refresh,$then,$crstype) = @_; + my ($is_cc,$ccrole); + if ($crstype eq 'Community') { + $ccrole = 'co'; + } else { + $ccrole = 'cc'; + } if ($cdom ne '' && $cnum ne '') { if (&Apache::lonnet::is_course($cdom,$cnum)) { - my $envkey = 'user.role.cc./'.$cdom.'/'.$cnum; + my $envkey = 'user.role.'.$ccrole.'./'.$cdom.'/'.$cnum; if (defined($env{$envkey})) { $is_cc = 1; my ($tstart,$tend)=split(/\./,$env{$envkey}); @@ -1516,7 +1480,7 @@ sub courselink { my $courseform=&Apache::loncommon::selectcourse_link ('rolechoice','dccourse'.$rowtype.'_'.$dcdom, 'dcdomain'.$rowtype.'_'.$dcdom,'coursedesc'.$rowtype.'_'. - $dcdom,$dcdom,undef); + $dcdom,$dcdom,undef,'Course/Community'); my $hiddenitems = ''. ''. ''. @@ -1579,9 +1543,10 @@ sub display_cc_role { my $advanced = $env{'user.adv'}; my $tryagain = $env{'form.tryagain'}; unless ($rolekey =~/^error\:/) { - if ($rolekey =~ m-^user\.role.cc\./($match_domain)/($match_courseid)$-) { - my $tcourseid = $1.'_'.$2; - my $trolecode = 'cc./'.$1.'/'.$2; + if ($rolekey =~ m-^user\.role.(cc|co)\./($match_domain)/($match_courseid)$-) { + my $ccrole = $1; + my $tcourseid = $2.'_'.$3; + my $trolecode = $1.'./'.$2.'/'.$3; my $twhere; my $ttype; my $tbg='LC_roles_is'; @@ -1596,7 +1561,7 @@ sub display_cc_role { $twhere=&mt('Currently not available'); $env{'course.'.$tcourseid.'.description'}=$twhere; } - my $trole = &Apache::lonnet::plaintext('cc',$ttype); + my $trole = &Apache::lonnet::plaintext($ccrole,$ttype,$tcourseid); $twhere.="
".&mt('Domain').":".$1; ($roletext,$roletext_end) = &build_roletext($trolecode,$1,$2,'is',$tryagain,$advanced,'',$tbg,$trole,$twhere,'','','',1,''); } @@ -1612,7 +1577,7 @@ sub adhoc_roles_row { ,'','',$dcdom) .' '; my $selectcclink = &courselink($dcdom,$rowtype); - my $ccrole = &Apache::lonnet::plaintext('cc'); + my $ccrole = &Apache::lonnet::plaintext('co',undef,undef,1); my $carole = &Apache::lonnet::plaintext('ca'); my $selectcalink = &coauthorlink($dcdom,$rowtype); $output.=$ccrole.': '.$selectcclink