--- loncom/auth/lonroles.pm 2010/12/05 17:22:18 1.240.2.22
+++ loncom/auth/lonroles.pm 2018/01/09 15:44:43 1.336
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# User Roles Screen
#
-# $Id: lonroles.pm,v 1.240.2.22 2010/12/05 17:22:18 raeburn Exp $
+# $Id: lonroles.pm,v 1.336 2018/01/09 15:44:43 raeburn 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
@@ -129,7 +128,7 @@ package Apache::lonroles;
use strict;
use Apache::lonnet;
use Apache::lonuserstate();
-use Apache::Constants qw(:common);
+use Apache::Constants qw(:common REDIRECT);
use Apache::File();
use Apache::lonmenu;
use Apache::loncommon;
@@ -139,25 +138,20 @@ use Apache::lonlocal;
use Apache::lonpageflip();
use Apache::lonnavdisplay();
use Apache::loncoursequeueadmin;
+use Apache::longroup;
+use Apache::lonrss;
+use Apache::lonplacementtest;
use GDBM_File;
use LONCAPA qw(:DEFAULT :match);
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,
@@ -165,7 +159,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:
@@ -173,12 +166,6 @@ sub redirect_user {
$url=~s/ /\%20/g;
$r->print(<
-//
-
-$navwindow
$msg
$end_page
ENDREDIR
@@ -216,17 +203,62 @@ sub handler {
my $r = shift;
+ # Check for critical messages and redirect if present.
+ my ($redirect,$url) = &Apache::loncommon::critical_redirect(300,'roles');
+ if ($redirect) {
+ &Apache::loncommon::content_type($r,'text/html');
+ $r->header_out(Location => $url);
+ return REDIRECT;
+ }
+
my $now=time;
my $then=$env{'user.login.time'};
my $refresh=$env{'user.refresh.time'};
+ my $update=$env{'user.update.time'};
if (!$refresh) {
$refresh = $then;
}
+ if (!$update) {
+ $update = $then;
+ }
+
+ &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'});
+
+# -------------------------------------------------- Check if setting hot list
+ my $hotlist;
+ if ($env{'form.action'} eq 'verify_and_change_rolespref') {
+ $hotlist = &Apache::lonpreferences::verify_and_change_rolespref($r);
+ }
+
+# -------------------------------------------------------- Check for new roles
+ my $updateresult;
+ if ($env{'form.state'} eq 'doupdate') {
+ my $show_course=&Apache::loncommon::show_course();
+ my $checkingtxt;
+ if ($show_course) {
+ $checkingtxt = &mt('Checking for new courses ...');
+ } else {
+ $checkingtxt = &mt('Checking for new roles ...');
+ }
+ $updateresult = $checkingtxt;
+ $updateresult .= &update_session_roles();
+ &Apache::lonnet::appenv({'user.update.time' => $now});
+ $update = $now;
+ &Apache::loncoursequeueadmin::reqauthor_check();
+ }
+
+# -------------------------------------------------- Check for author requests
+ my $reqauthor;
+ if ($env{'form.state'} eq 'requestauthor') {
+ $reqauthor = &Apache::loncoursequeueadmin::process_reqauthor(\$update);
+ }
+
my $envkey;
my %dcroles = ();
- my $numdc = &check_fordc(\%dcroles,$then);
- &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'});
- my $custommenu = &Apache::loncommon::needs_gci_custom();
+ my %helpdeskroles = ();
+ my ($numdc,$numhelpdesk,$numadhoc) =
+ &check_for_adhoc(\%dcroles,\%helpdeskroles,$update,$then);
+ my $loncaparev = $r->dir_config('lonVersion');
# ================================================================== Roles Init
if ($env{'form.selectrole'}) {
@@ -234,105 +266,189 @@ sub handler {
my $locknum=&Apache::lonnet::get_locks();
if ($locknum) { return 409; }
+ my $custom_adhoc;
if ($env{'form.newrole'}) {
$env{'form.'.$env{'form.newrole'}}=1;
+# Check if this is a Domain Helpdesk or Domain Helpdesk Assistant role trying to enter a course
+ if ($env{'form.newrole'} =~ m{^cr/($match_domain)/\1\-domainconfig/\w+\./\1/$match_courseid$}) {
+ if ($helpdeskroles{$1}) {
+ $custom_adhoc = 1;
+ }
+ }
}
if ($env{'request.course.id'}) {
# Check if user is CC trying to select a course role
if ($env{'form.switchrole'}) {
- if (!defined($env{'user.role.'.$env{'form.switchrole'}})) {
- &adhoc_course_role($refresh,$then);
+ my $switch_is_active;
+ if (defined($env{'user.role.'.$env{'form.switchrole'}})) {
+ my ($start,$end) = split(/\./,$env{'user.role.'.$env{'form.switchrole'}});
+ if (!$end || $end > $now) {
+ if (!$start || $start < $update) {
+ $switch_is_active = 1;
+ }
+ }
+ }
+ unless ($switch_is_active) {
+ &adhoc_course_role($refresh,$update,$then);
}
}
my %temp=('logout_'.$env{'request.course.id'} => time);
&Apache::lonnet::put('email_status',\%temp);
&Apache::lonnet::delenv('user.state.'.$env{'request.course.id'});
}
- &Apache::lonnet::appenv({"request.course.id" => '',
- "request.course.fn" => '',
- "request.course.uri" => '',
- "request.course.sec" => '',
- "request.role" => 'cm',
- "request.role.adv" => $env{'user.adv'},
- "request.role.domain" => $env{'user.domain'}});
-# 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 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,$ccrole);
+ &Apache::lonnet::appenv({"request.course.id" => '',
+ "request.course.fn" => '',
+ "request.course.uri" => '',
+ "request.course.sec" => '',
+ "request.course.tied" => '',
+ "request.course.timechecked" => '',
+ "request.role" => 'cm',
+ "request.role.adv" => $env{'user.adv'},
+ "request.role.domain" => $env{'user.domain'}});
+# Check if Domain Helpdesk role trying to enter a course needs privs to be created
+ if ($env{'form.newrole'} =~ m{^cr/($match_domain)/\1\-domainconfig/(\w+)\./\1/($match_courseid)(?:/(\w+)|$)}) {
+ my $cdom = $1;
+ my $rolename = $2;
+ my $cnum = $3;
+ my $sec = $4;
+ if ($custom_adhoc) {
+ my ($possroles,$description) = &Apache::lonnet::get_my_adhocroles($cdom.'_'.$cnum,1);
+ if (ref($possroles) eq 'ARRAY') {
+ if (grep(/^\Q$rolename\E$/,@{$possroles})) {
+ if (&Apache::lonnet::check_adhoc_privs($cdom,$cnum,$update,$refresh,$now,
+ "cr/$cdom/$cdom".'-domainconfig/'.$rolename,undef,$sec)) {
+ &Apache::lonnet::appenv({"environment.internal.$cdom.$cnum.cr/$cdom/$cdom".'-domainconfig/'."$rolename.adhoc" => time});
+ }
}
- last;
}
-# Is this an ad-hoc CA-role?
- if (my ($domain,$user) =
- ($envkey =~ m-^form\.ca\./($match_domain)/($match_username)$-)) {
- if (($domain eq $env{'user.domain'}) && ($user eq $env{'user.name'})) {
- delete($env{$envkey});
- $env{'form.au./'.$domain.'/'} = 1;
- my ($server_status,$home) = &check_author_homeserver($user,$domain);
- if ($server_status eq 'switchserver') {
- my $trolecode = 'au./'.$domain.'/';
- my $switchserver = '/adm/switchserver?otherserver='.$home.'&role='.$trolecode;
- $r->internal_redirect($switchserver);
+ }
+ } elsif (($numdc > 0) || ($numhelpdesk > 0)) {
+# Check if user is a DC trying to enter a course or author space and needs privs to be created
+# Check if user is a DH or DA trying to enter a course and needs privs to be created
+ foreach my $envkey (keys(%env)) {
+# Is this an ad-hoc Coordinator role?
+ if ($numdc) {
+ if (my ($ccrole,$domain,$coursenum) =
+ ($envkey =~ m-^form\.(cc|co)\./($match_domain)/($match_courseid)$-)) {
+ if ($dcroles{$domain}) {
+ if (&Apache::lonnet::check_adhoc_privs($domain,$coursenum,
+ $update,$refresh,$now,$ccrole)) {
+ &Apache::lonnet::appenv({"environment.internal.$domain.$coursenum.$ccrole.adhoc" => time});
+ }
}
last;
}
- if (my ($castart,$caend) = ($env{'user.role.ca./'.$domain.'/'.$user} =~ /^(\d*)\.(\d*)$/)) {
- if (((($castart) && ($castart < $now)) || !$castart) &&
- ((!$caend) || (($caend) && ($caend > $now)))) {
+# Is this an ad-hoc CA-role?
+ if (my ($domain,$user) =
+ ($envkey =~ m-^form\.ca\./($match_domain)/($match_username)$-)) {
+ if (($domain eq $env{'user.domain'}) && ($user eq $env{'user.name'})) {
+ delete($env{$envkey});
+ $env{'form.au./'.$domain.'/'} = 1;
my ($server_status,$home) = &check_author_homeserver($user,$domain);
if ($server_status eq 'switchserver') {
- my $trolecode = 'ca./'.$domain.'/'.$user;
- my $switchserver = '/adm/switchserver?otherserver='.$home.'&role='.$trolecode;
+ my $trolecode = 'au./'.$domain.'/';
+ my $switchserver = '/adm/switchserver?otherserver='.$home.'&role='.$trolecode;
$r->internal_redirect($switchserver);
+ return OK;
}
last;
}
- }
- # Check if author blocked ca-access
- my %blocked=&Apache::lonnet::get('environment',['domcoord.author'],$domain,$user);
- if ($blocked{'domcoord.author'} eq 'blocked') {
- delete($env{$envkey});
- $env{'user.error.msg'}=':::1:User '.$user.' in domain '.$domain.' blocked domain coordinator access';
+ if (my ($castart,$caend) = ($env{'user.role.ca./'.$domain.'/'.$user} =~ /^(\d*)\.(\d*)$/)) {
+ if (((($castart) && ($castart < $now)) || !$castart) &&
+ ((!$caend) || (($caend) && ($caend > $now)))) {
+ my ($server_status,$home) = &check_author_homeserver($user,$domain);
+ if ($server_status eq 'switchserver') {
+ my $trolecode = 'ca./'.$domain.'/'.$user;
+ my $switchserver = '/adm/switchserver?otherserver='.$home.'&role='.$trolecode;
+ $r->internal_redirect($switchserver);
+ return OK;
+ }
+ last;
+ }
+ }
+ # Check if author blocked ca-access
+ my %blocked=&Apache::lonnet::get('environment',['domcoord.author'],$domain,$user);
+ if ($blocked{'domcoord.author'} eq 'blocked') {
+ delete($env{$envkey});
+ $env{'user.error.msg'}=':::1:User '.$user.' in domain '.$domain.' blocked domain coordinator access';
+ last;
+ }
+ if ($dcroles{$domain}) {
+ my ($server_status,$home) = &check_author_homeserver($user,$domain);
+ if (($server_status eq 'ok') || ($server_status eq 'switchserver')) {
+ &Apache::lonnet::check_adhoc_privs($domain,$user,$update,
+ $refresh,$now,'ca');
+ if ($server_status eq 'switchserver') {
+ my $trolecode = 'ca./'.$domain.'/'.$user;
+ my $switchserver = '/adm/switchserver?'
+ .'otherserver='.$home.'&role='.$trolecode;
+ $r->internal_redirect($switchserver);
+ return OK;
+ }
+ } else {
+ delete($env{$envkey});
+ }
+ } else {
+ delete($env{$envkey});
+ }
last;
}
- if ($dcroles{$domain}) {
- my ($server_status,$home) = &check_author_homeserver($user,$domain);
- if (($server_status eq 'ok') || ($server_status eq 'switchserver')) {
- &Apache::lonnet::check_adhoc_privs($domain,$user,$then,
- $refresh,$now,'ca');
- if ($server_status eq 'switchserver') {
- my $trolecode = 'ca./'.$domain.'/'.$user;
- my $switchserver = '/adm/switchserver?'
- .'otherserver='.$home.'&role='.$trolecode;
- $r->internal_redirect($switchserver);
+ }
+ if ($numhelpdesk) {
+# Is this an ad hoc custom role in a course/community?
+ if (my ($domain,$rolename,$coursenum,$sec) = ($envkey =~ m{^form\.cr/($match_domain)/\1\-domainconfig/(\w+)\./\1/($match_courseid)(?:/(\w+)|$)})) {
+ if ($helpdeskroles{$domain}) {
+ my ($possroles,$description) = &Apache::lonnet::get_my_adhocroles($domain.'_'.$coursenum,1);
+ if (ref($possroles) eq 'ARRAY') {
+ if (grep(/^\Q$rolename\E$/,@{$possroles})) {
+ if (&Apache::lonnet::check_adhoc_privs($domain,$coursenum,$update,$refresh,$now,
+ "cr/$domain/$domain".'-domainconfig/'.$rolename,
+ undef,$sec)) {
+ &Apache::lonnet::appenv({"environment.internal.$domain.$coursenum.cr/$domain/$domain".
+ '-domainconfig/'."$rolename.adhoc" => time});
+ }
+ } else {
+ delete($env{$envkey});
+ }
+ } else {
+ delete($env{$envkey});
}
} else {
delete($env{$envkey});
}
- } else {
- delete($env{$envkey});
+ last;
}
- last;
}
}
}
- if (($env{'form.cm'}) && ($env{'form.orgurl'})) {
- $r->internal_redirect($env{'form.orgurl'});
- }
- foreach $envkey (keys %env) {
+ foreach $envkey (keys(%env)) {
next if ($envkey!~/^user\.role\./);
my ($where,$trolecode,$role,$tstatus,$tend,$tstart);
- &Apache::lonnet::role_status($envkey,$then,$refresh,$now,\$role,\$where,
+ &Apache::lonnet::role_status($envkey,$update,$refresh,$now,\$role,\$where,
\$trolecode,\$tstatus,\$tstart,\$tend);
if ($env{'form.'.$trolecode}) {
if ($tstatus eq 'is') {
$where=~s/^\///;
my ($cdom,$cnum,$csec)=split(/\//,$where);
+ if (($cnum) && ($role ne 'ca') && ($role ne 'aa')) {
+ my $home = $env{'course.'.$cdom.'_'.$cnum.'.home'};
+ my @ids = &Apache::lonnet::current_machine_ids();
+ unless ($loncaparev eq '' && $home && grep(/^\Q$home\E$/,@ids)) {
+ my %curr_reqd_hash = &Apache::lonnet::userenvironment($cdom,$cnum,'internal.releaserequired');
+ if ($curr_reqd_hash{'internal.releaserequired'} ne '') {
+ my ($switchserver,$switchwarning) =
+ &Apache::loncommon::check_release_required($loncaparev,$cdom.'_'.$cnum,$trolecode,
+ $curr_reqd_hash{'internal.releaserequired'});
+ if ($switchwarning ne '' || $switchserver ne '') {
+ &Apache::loncommon::content_type($r,'text/html');
+ &Apache::loncommon::no_cache($r);
+ $r->send_http_header;
+ $r->print(&Apache::loncommon::check_release_result($switchwarning,$switchserver));
+ return OK;
+ }
+ }
+ }
+ }
# check for course groups
my %coursegroups = &Apache::lonnet::get_active_groups(
$env{'user.domain'},$env{'user.name'},$cdom, $cnum);
@@ -440,7 +556,7 @@ ENDENTERKEY
$env{'user.name'},
$env{'user.home'},
"Role ".$trolecode);
-
+
&Apache::lonnet::appenv(
{'request.role' => $trolecode,
'request.role.domain' => $cdom,
@@ -449,31 +565,84 @@ ENDENTERKEY
my $tadv=0;
if (($cnum) && ($role ne 'ca') && ($role ne 'aa')) {
+ if ($role =~ m{^\Qcr/$cdom/$cdom\E\-domainconfig/(\w+)$}) {
+ my $rolename = $1;
+ my %domdef = &Apache::lonnet::get_domain_defaults($cdom);
+ if (ref($domdef{'adhocroles'}) eq 'HASH') {
+ if (ref($domdef{'adhocroles'}{$rolename}) eq 'HASH') {
+ &Apache::lonnet::appenv({'request.role.desc' => $domdef{'adhocroles'}{$rolename}{'desc'}});
+ }
+ }
+ }
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);
+ unless ($ferr) {
+ &Apache::lonnet::appenv({'request.course.timechecked'=>$now});
+ unless (($env{'form.switchrole'}) ||
+ ($env{"environment.internal.$cdom.$cnum.$role.adhoc"})) {
+ &Apache::lonnet::put('nohist_crslastlogin',
+ {$env{'user.name'}.':'.$env{'user.domain'}.
+ ':'.$csec.':'.$role => $now},$cdom,$cnum);
+ }
+ if (($env{"environment.internal.$cdom.$cnum.$role.adhoc"}) &&
+ (&Apache::lonnet::allowed('vxc',$cdom.'_'.$cnum))) {
+ my $owner = $env{'course.'.$cdom.'_'.$cnum.'.internal.courseowner'};
+ my @coowners = split(/,/,$env{'course.'.$env{'request.course.id'}.'.internal.co-owners'});
+ my %auaccess;
+ foreach my $user ($owner,@coowners) {
+ my ($cpname,$cpdom) = split(/:/,$user);
+ my %auroles = &Apache::lonnet::get_my_roles($cpname,$cpdom,'userroles',undef,['au','ca','aa'],[$cdom]);
+ foreach my $key (keys(%auroles)) {
+ my ($auname,$audom,$aurole) = split(/:/,$key);
+ if ($aurole eq 'au') {
+ $auaccess{$cpname} = 1;
+ } else {
+ $auaccess{$auname} = 1;
+ }
+ }
+ }
+ &Apache::lonnet::appenv({'request.course.adhocsrcaccess' => join(',',sort(keys(%auaccess))) });
+ }
+ my ($feeds,$syllabus_time);
+ &Apache::lonrss::advertisefeeds($cnum,$cdom,undef,\$feeds);
+ &Apache::lonnet::appenv({'request.course.feeds' => $feeds});
+ &Apache::lonnet::get_numsuppfiles($cnum,$cdom,1);
+ unless ($env{'course.'.$cdom.'_'.$cnum.'.updatedsyllabus'}) {
+ unless (($env{'course.'.$cdom.'_'.$cnum.'.externalsyllabus'}) ||
+ ($env{'course.'.$cdom.'_'.$cnum.'.uploadedsyllabus'})) {
+ my %syllabus=&Apache::lonnet::dump('syllabus',$cdom,$cnum);
+ $syllabus_time = $syllabus{'uploaded.lastmodified'};
+ if ($syllabus_time) {
+ &Apache::lonnet::appenv({'request.course.syllabustime' => $syllabus_time});
+ }
+ }
}
}
if (($env{'form.orgurl'}) &&
- ($env{'form.orgurl'}!~/^\/adm\/flip/)) {
+ ($env{'form.orgurl'}!~/^\/adm\/flip/) &&
+ ($env{'form.orgurl'} ne '/adm/roles')) {
my $dest=$env{'form.orgurl'};
if ($env{'form.symb'}) {
if ($dest =~ /\?/) {
$dest .= '&';
} else {
- $dest .= '?'
+ $dest .= '?';
}
$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 {
+ if ($dest =~ m{^/adm/coursedocs\?folderpath}) {
+ if ($env{'request.course.id'} eq $cdom.'_'.$cnum) {
+ my $chome = &Apache::lonnet::homeserver($cnum,$cdom);
+ &Apache::loncommon::update_content_constraints($cdom,$cnum,$chome,
+ $cdom.'_'.$cnum);
+ }
+ }
$r->internal_redirect($dest);
}
return OK;
@@ -489,32 +658,89 @@ 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);
} else {
# Check to see if the user is a CC entering a course
# for the first time
- my (undef, undef, $role, $courseid) = split(/\./, $envkey);
- if (substr($courseid, 0, 1) eq '/') {
- $courseid = substr($courseid, 1);
- }
- $courseid =~ s/\//_/;
- if (($cdom !~ /^\w+citest$/) && (($role eq 'cc') || ($role eq 'co'))
- && ($env{'course.' . $courseid .'.course.helper.not.run'})) {
+ if ((($role eq 'cc') || ($role eq 'co'))
+ && ($env{'course.'.$cdom.'_'.$cnum.'.course.helper.not.run'})) {
$furl = "/adm/helper/course.initialization.helper";
# Send the user to the course they selected
} elsif ($env{'request.course.id'}) {
- if ($env{'form.destinationurl'}) {
- my $dest = $env{'form.destinationurl'};
- if ($env{'form.destsymb'} ne '') {
- my $esc_symb = &HTML::Entities::encode($env{'form.destsymb'},'"<>&');
- $dest .= '?symb='.$esc_symb;
+ if ((&Apache::loncommon::course_type() eq 'Placement') &&
+ (!$env{'request.role.adv'})) {
+ my ($score,$incomplete) =
+ &Apache::lonplacementtest::check_completion(undef,undef,1);
+ if (($incomplete) && ($incomplete < 100)) {
+ &redirect_user($r, &mt('Entering [_1]',
+ $env{'course.'.$cdom.'_'.$cnum.'.description'}),
+ '/adm/placement', $msg);
+ return OK;
+ }
+ }
+ my ($dest,$destsymb,$checkenc);
+ $dest = $env{'form.destinationurl'};
+ $destsymb = $env{'form.destsymb'};
+ if ($dest ne '') {
+ if ($env{'form.switchrole'}) {
+ if ($destsymb ne '') {
+ if ($destsymb !~ m{^/enc/}) {
+ unless ($env{'request.role.adv'}) {
+ $checkenc = 1;
+ }
+ }
+ }
+ if (($dest =~ m{^\Q/public/$cdom/$cnum/syllabus\E.*(\?|\&)usehttp=1}) ||
+ ($dest =~ m{^\Q/adm/wrapper/ext/\E(?!https:)})) {
+ if ($ENV{'SERVER_PORT'} == 443) {
+ my $hostname = $r->hostname();
+ if ($hostname ne '') {
+ $dest = 'http://'.$hostname.$dest;
+ }
+ }
+ }
+ if ($dest =~ m{^/enc/}) {
+ if ($env{'request.role.adv'}) {
+ $dest = &Apache::lonenc::unencrypted($dest);
+ if ($destsymb eq '') {
+ ($destsymb) = ($dest =~ /(?:\?|\&)symb=([^\&]*)/);
+ $destsymb = &unescape($destsymb);
+ }
+ }
+ } else {
+ if ($destsymb eq '') {
+ ($destsymb) = ($dest =~ /(?:\?|\&)symb=([^\&]+)/);
+ $destsymb = &unescape($destsymb);
+ }
+ unless ($env{'request.role.adv'}) {
+ $checkenc = 1;
+ }
+ }
+ if (($checkenc) && ($destsymb ne '')) {
+ my ($encstate,$unencsymb,$res);
+ $unencsymb = &Apache::lonnet::symbclean($destsymb);
+ (undef,undef,$res) = &Apache::lonnet::decode_symb($unencsymb);
+ &Apache::lonnet::symbverify($unencsymb,$res,\$encstate);
+ if ($encstate) {
+ if (($dest ne '') && ($dest !~ m{^/enc/})) {
+ $dest=&Apache::lonenc::encrypted($dest);
+ }
+ }
+ }
+ }
+ unless (($dest =~ m{^/enc/}) || ($dest =~ /(\?|\&)symb=.+___\d+___.+/)) {
+ if (($destsymb ne '') && ($destsymb !~ m{^/enc/})) {
+ my $esc_symb = &escape($destsymb);
+ $dest .= (($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.'.$cdom.'_'.$cnum.'.description'}),
+ $dest, $msg);
return OK;
}
if (&Apache::lonnet::allowed('whn',
@@ -523,31 +749,40 @@ ENDENTERKEY
$env{'request.course.id'}.'/'
.$env{'request.course.sec'})
) {
- my $startpage = &courseloadpage($courseid);
- unless (($startpage eq 'firstres') || ($cdom =~ /^\w+citest$/)) {
+ my $startpage = &courseloadpage($env{'request.course.id'});
+ 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'});
+ $env{'course.'.$env{'request.course.id'}.'.description'});
+ &redirect_user($r, &mt('New in course'),
+ '/adm/whatsnew?refpage=start', $msg);
return OK;
}
}
}
-# Are we allowed to look at the first resource?
- if ($furl !~ m|^/adm/|) {
-# Guess not ...
- $furl=&Apache::lonpageflip::first_accessible_resource();
- }
- if (($cdom =~ /^\w+citest$/) && ($custommenu)) {
- $furl = '/adm/navmaps';
+ # Are we allowed to look at the first resource?
+ my $access;
+ if ($furl =~ m{^(/adm/wrapper|)/ext/}) {
+ # If it's an external resource,
+ # strip off the symb argument and possible query
+ my ($exturl,$symb) = ($furl =~ m{^(.+)(?:\?|\&)symb=(.+)$});
+ # Unencode $symb
+ $symb = &unescape($symb);
+ # Then check for permission
+ $access = &Apache::lonnet::allowed('bre',$exturl,$symb);
+ # For other resources just check for permission
+ } else {
+ $access = &Apache::lonnet::allowed('bre',$furl);
+ }
+ if (!$access) {
+ $furl = &Apache::lonpageflip::first_accessible_resource();
+ } elsif ($access eq 'B') {
+ $furl = '/adm/navmaps?showOnlyHomework=1';
}
$msg = &mt('Entering [_1] ...',
- $env{'course.'.$courseid.'.description'});
- &redirect_user($r,&mt('Entering [_1]',
- $env{'course.'.$courseid.'.description'}),
- $furl,$msg,
- $env{'environment.remotenavmap'});
+ $env{'course.'.$cdom.'_'.$cnum.'.description'});
+ &redirect_user($r, &mt('Entering [_1]',
+ $env{'course.'.$cdom.'_'.$cnum.'.description'}),
+ $furl, $msg);
}
return OK;
}
@@ -557,13 +792,12 @@ ENDENTERKEY
if ($role =~ /^(au|ca|aa)$/) {
my $redirect_url = '/priv/';
if ($role eq 'au') {
- $redirect_url.=$env{'user.name'};
+ $redirect_url.=$env{'user.domain'}.'/'.$env{'user.name'};
} else {
- $where =~ /\/(.*)$/;
- $redirect_url .= $1;
+ $redirect_url .= $where;
}
$redirect_url .= '/';
- &redirect_user($r,&mt('Entering Construction Space'),
+ &redirect_user($r,&mt('Entering Authoring Space'),
$redirect_url);
return OK;
}
@@ -573,6 +807,18 @@ ENDENTERKEY
$redirect_url);
return OK;
}
+ if ($role eq 'dh') {
+ my $redirect_url = '/adm/menu/';
+ &redirect_user($r,&mt('Loading Domain Helpdesk Menu'),
+ $redirect_url);
+ return OK;
+ }
+ if ($role eq 'da') {
+ my $redirect_url = '/adm/menu/';
+ &redirect_user($r,&mt('Loading Domain Helpdesk Assistant Menu'),
+ $redirect_url);
+ return OK;
+ }
if ($role eq 'sc') {
my $redirect_url = '/adm/grades?command=scantronupload';
&redirect_user($r,&mt('Loading Data Upload Page'),
@@ -584,6 +830,7 @@ ENDENTERKEY
}
}
+
# =============================================================== No Roles Init
&Apache::loncommon::content_type($r,'text/html');
@@ -591,43 +838,68 @@ ENDENTERKEY
$r->send_http_header;
return OK if $r->header_only;
- my ($crumbtext,$pagetitle,$recent,$show_course);
- $show_course=&Apache::loncommon::show_course();
- 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');
- $r->print(<<"ENDCUSTOM");
-$start_page
-
-ENDCUSTOM
- } else {
- $crumbtext = 'User Roles';
- $pagetitle = 'My Roles';
- $recent = &mt('Recent Roles');
- my $standby=&mt('Role selected. Please stand by.');
- if ($show_course) {
- $crumbtext = 'Courses';
- $pagetitle = 'My Courses';
- $recent = &mt('Recent Courses');
- $standby = &mt('Course selected. Please stand by.');
- }
- my $brcrum = [{ href => '/adm/roles',
- text => $crumbtext,},
- ];
- my $args;
- if ($numdc) {
- $args = {bread_crumbs => $brcrum};
+ my $crumbtext = 'User Roles';
+ my $pagetitle = 'My Roles';
+ my $recent = &mt('Recent Roles');
+ my $standby = &mt('Role selected. Please stand by.');
+ my $show_course=&Apache::loncommon::show_course();
+ if ($show_course) {
+ $crumbtext = 'Courses';
+ $pagetitle = 'My Courses';
+ $recent = &mt('Recent Courses');
+ $standby = &mt('Course selected. Please stand by.');
+ }
+ my $brcrum =[{href=>"/adm/roles",text=>$crumbtext}];
+
+ my %roles_in_env;
+ my $showcount = &roles_from_env(\%roles_in_env,$update);
+
+ my $swinfo=&Apache::lonmenu::rawconfig();
+ my %domdefs=&Apache::lonnet::get_domain_defaults($env{'user.domain'});
+ my $cattype = 'std';
+ if ($domdefs{'catauth'}) {
+ $cattype = $domdefs{'catauth'};
+ }
+ my $placementonly;
+ if ($showcount == 1) {
+ if ($env{'request.course.id'}) {
+ if ($env{'course.'.$env{'request.course.id'}.'.type'} eq 'Placement') {
+ $placementonly = 1;
+ }
} else {
- $args = {bread_crumbs => $brcrum,
- bread_crumbs_menulink => '_nomenu'};
+ foreach my $rolecode (keys(%roles_in_env)) {
+ my ($cid) = ($rolecode =~ m{^\Quser.role.st./\E($match_domain/$match_courseid)(?:/|$)});
+ if ($cid) {
+ my %coursedescription =
+ &Apache::lonnet::coursedescription($cid,{'one_time' => '1'});
+ if ($coursedescription{'type'} eq 'Placement') {
+ $placementonly = 1;
+ }
+ last;
+ }
+ }
+ }
+ }
+ my ($start_page,$funcs);
+ if ($placementonly) {
+ $start_page=&Apache::loncommon::start_page($pagetitle,undef,
+ {bread_crumbs=>$brcrum,crstype=>'Placement'});
+ } else {
+ $funcs = &get_roles_functions($showcount,$cattype);
+ my $crumbsright;
+ if ($env{'browser.mobile'}) {
+ $crumbsright = $funcs;
+ undef($funcs);
}
- my $start_page=&Apache::loncommon::start_page($pagetitle,undef,$args);
- my $swinfo=&Apache::lonmenu::rawconfig();
- $standby=~s/\n/\\n/g;
- $r->print(<$brcrum,
+ bread_crumbs_component=>$crumbsright});
+ }
+ &js_escape(\$standby);
+ 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.').' ';
+
+ $r->print(<
$noscript
@@ -647,12 +919,25 @@ function enterrole (thisform,rolecode,bu
thisform.submit();
} else {
alert('$standby');
- }
+ }
+}
+
+function rolesView (caller) {
+ if ((caller == 'showall') || (caller == 'noshowall')) {
+ document.rolechoice.display.value = caller;
+ } else {
+ if ((caller == 'doupdate') || (caller == 'requestauthor') ||
+ (caller == 'queued')) {
+ document.rolechoice.state.value = caller;
+ }
+ }
+ document.rolechoice.selectrole.value='';
+ document.rolechoice.submit();
}
+
// ]]>
ENDHEADER
- }
# ------------------------------------------ Get Error Message from Environment
@@ -710,123 +995,93 @@ ENDHEADER
}
}
}
-# -------------------------------------------------------- Choice or no choice?
if ($nochoose) {
$r->print("
".&mt('Sorry ...')."
\n".
&mt('This action is currently not authorized.').''.
&Apache::loncommon::end_page());
return OK;
} else {
+ if ($updateresult || $reqauthor || $hotlist) {
+ my $showresult = '
'.&mt('Currently not assigned as a GCI contributor').'
');
- }
- } else {
- $r->print('
'.&mt('Currently no active roles, courses or communities').'
');
- }
- }
- unless ($env{'user.domain'} =~ /^\w+citest$/) {
- &findcourse_advice($r);
- &requestcourse_advice($r);
- }
+ &requestcourse_advice($r,$cattype,$inrole);
$r->print('');
if ($countfuture) {
- if ($show_course) {
- if ($env{'user.domain'} =~ /^\w+citest$/) {
- $r->print(&mt('The following [quant,_1,Concept Test] will be available in the future:',$countfuture));
- } else {
- $r->print(&mt('The following [quant,_1,course] will become active in the future:',$countfuture));
- }
- } else {
- $r->print(&mt('The following [quant,_1,role,roles] will become active in the future:',$countfuture));
- }
+ $r->print(&mt('The following [quant,_1,role,roles] will become active in the future:',$countfuture));
my $doheaders = &roletable_headers($r,\%roleclass,\%sortrole,
$nochoose);
&print_rolerows($r,$doheaders,\%roleclass,\%sortrole,\%dcroles,
- \%roletext);
+ \%roletext,$update,$then);
my $tremark='';
my $tbg;
if ($env{'request.role'} eq 'cm') {
@@ -848,30 +1103,28 @@ ENDHEADER
}
$r->print(&Apache::loncommon::end_page());
return OK;
- } elsif ($countactive==1) { # Is there only one choice?
- my $needs_switchserver;
- if ($env{'user.author'}) {
- $needs_switchserver = &check_needs_switchserver($possiblerole);
- }
- if ((!$needs_switchserver) && ($env{'request.role'} eq 'cm')) {
- $r->print('
\n".
- &mt('Construction Space access is only available from '.
- 'the home server of the corresponding Author.').' '.
- &mt("Click the 'Switch Server' link to go there.").' ');
- }
+ } elsif (($placementonly) && ($env{'request.role'} eq 'cm')) {
+ $r->print('
');
+ .'');
}
$r->print(&Apache::loncommon::end_page());
return OK;
}
-sub ci_info_page {
- my %longname = (
- GCI => 'Geoscience Concept Inventory',
- SLCI => 'Science Literacy Concept Inventory',
- );
- my $inventory = uc($env{'user.domain'});
- my %features = (
- review => 'Review and comment on existing $inventory questions',
- submit => "Submit $inventory questions of your own",
- managetest => 'Create an online test for your students',
- tutorial => 'View tutorials on creating online tests',
- );
- my $tabs = &Apache::loncommon::ci_tabs($env{'user.domain'});
- my %info = (
- GCI => '
For more information about writing and reviewing Concept Inventory questions please refer to the GCI Workbook.
',
- );
- my $output = <<"END";
-
-
-
Welcome to the $longname{$inventory} WebCenter
-
-Use the tabs to navigate the WebCenter and...
-
-END
- if (ref($tabs) eq 'ARRAY') {
- foreach my $tab (@{$tabs}) {
- if ($features{$tab}) {
- $output .= '
'.$features{$tab}.'
'."\n";
+sub roles_from_env {
+ my ($roleshash,$update) = @_;
+ my $count = 0;
+ if (ref($roleshash) eq 'HASH') {
+ foreach my $envkey (keys(%env)) {
+ if ($envkey =~ m{^user\.role\.(\w+)[./]}) {
+ next if ($1 eq 'gr');
+ $roleshash->{$envkey} = $env{$envkey};
+ my ($start,$end) = split(/\./,$env{$envkey});
+ unless ($end && $end<$update) {
+ $count ++;
+ }
}
}
}
- $output .= <<"END";
-
-
-$info{$inventory}
-
-END
-
+ return $count;
}
sub gather_roles {
- my ($then,$refresh,$now,$reinit,$nochoose,$roletext,$sortrole,$roleclass,$futureroles,$timezones) = @_;
+ my ($update,$refresh,$now,$reinit,$nochoose,$roles_in_env,$roletext,$sortrole,$roleclass,$futureroles,
+ $timezones,$loncaparev) = @_;
my ($countactive,$countfuture,$inrole,$possiblerole) = (0,0,0,'');
my $advanced = $env{'user.adv'};
my $tryagain = $env{'form.tryagain'};
- foreach my $envkey (sort(keys(%env))) {
- my $button = 1;
- my $switchserver='';
- my ($role_text,$role_text_end,$sortkey);
- if ($envkey=~/^user\.role\./) {
- my ($role,$where,$trolecode,$tstart,$tend,$tremark,$tstatus,$tpstart,$tpend);
- &Apache::lonnet::role_status($envkey,$then,$refresh,$now,\$role,\$where,
+ my @ids = &Apache::lonnet::current_machine_ids();
+ my (%willtrust,%trustchecked);
+ if (ref($roles_in_env) eq 'HASH') {
+ my %adhocdesc;
+ foreach my $envkey (sort(keys(%{$roles_in_env}))) {
+ my $button = 1;
+ my $switchserver='';
+ my $switchwarning;
+ my ($role_text,$role_text_end,$sortkey,$role,$where,$trolecode,$tstart,
+ $tend,$tremark,$tstatus,$tpstart,$tpend);
+ &Apache::lonnet::role_status($envkey,$update,$refresh,$now,\$role,\$where,
\$trolecode,\$tstatus,\$tstart,\$tend);
next if (!defined($role) || $role eq '' || $role =~ /^gr/);
- my $timezone = &role_timezone($where,$timezones);
$tremark='';
$tpstart=' ';
$tpend=' ';
- if ($tstart) {
- $tpstart=&Apache::lonlocal::locallocaltime($tstart,$timezone);
- }
- if ($tend) {
- $tpend=&Apache::lonlocal::locallocaltime($tend,$timezone);
- }
if ($env{'request.role'} eq $trolecode) {
$tstatus='selected';
}
@@ -1043,7 +1282,14 @@ sub gather_roles {
if (($tstatus eq 'is')
|| ($tstatus eq 'selected')
|| ($tstatus eq 'future')
- || ($env{'form.showall'})) {
+ || ($env{'form.display'} eq 'showall')) {
+ my $timezone = &role_timezone($where,$timezones);
+ if ($tstart) {
+ $tpstart=&Apache::lonlocal::locallocaltime($tstart,$timezone);
+ }
+ if ($tend) {
+ $tpend=&Apache::lonlocal::locallocaltime($tend,$timezone);
+ }
if ($tstatus eq 'is') {
$tbg='LC_roles_is';
$possiblerole=$trolecode;
@@ -1068,47 +1314,63 @@ sub gather_roles {
my $trole;
if ($role =~ /^cr\//) {
my ($rdummy,$rdomain,$rauthor,$rrole)=split(/\//,$role);
- if ($tremark) { $tremark.=' '; }
- $tremark.=&mt('Defined by [_1] at [_2].',$rauthor,$rdomain);
+ unless ($rauthor eq $rdomain.'-domainconfig') {
+ if ($tremark) { $tremark.=' '; }
+ $tremark.=&mt('Custom role defined by [_1].',$rauthor.':'.$rdomain);
+ }
}
$trole=Apache::lonnet::plaintext($role);
my $ttype;
my $twhere;
+ my $skipcal;
my ($tdom,$trest,$tsection)=
split(/\//,Apache::lonnet::declutter($where));
# First, Co-Authorship roles
if (($role eq 'ca') || ($role eq 'aa')) {
my $home = &Apache::lonnet::homeserver($trest,$tdom);
my $allowed=0;
- my @ids=&Apache::lonnet::current_machine_ids();
+ my $prohibited;
foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } }
if (!$allowed) {
$button=0;
- $switchserver='otherserver='.$home.'&role='.$trolecode;
+ unless ($trustchecked{$tdom}) {
+ if ((&Apache::lonnet::will_trust('othcoau',$tdom,$env{'user.domain'})) &&
+ (&Apache::lonnet::will_trust('coremau',$env{'user.domain'},$tdom))) {
+ $willtrust{$tdom} = 1;
+ $trustchecked{$tdom} = 1;
+ }
+ }
+ if ($willtrust{$tdom}) {
+ $switchserver='otherserver='.$home.'&role='.$trolecode;
+ } else {
+ $prohibited = 1;
+ $tremark .= &mt('Session switch required but prohibited.');
+ }
}
#next if ($home eq 'no_host');
$home = &Apache::lonnet::hostname($home);
- $ttype='Construction Space';
+ $ttype='Authoring Space';
$twhere=&mt('User').': '.$trest.' '.&mt('Domain').
': '.$tdom.' '.
' '.&mt('Server').': '.$home;
$env{'course.'.$tdom.'_'.$trest.'.description'}='ca';
- $tremark.=&Apache::lonhtmlcommon::authorbombs('/res/'.$tdom.'/'.$trest.'/');
+ unless ($prohibited) {
+ $tremark.=&Apache::lonhtmlcommon::authorbombs('/res/'.$tdom.'/'.$trest.'/');
+ }
$sortkey=$role."$trest:$tdom";
} elsif ($role eq 'au') {
# Authors
my $home = &Apache::lonnet::homeserver
($env{'user.name'},$env{'user.domain'});
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='otherserver='.$home.'&role='.$trolecode;
+ $switchserver='otherserver='.$home.'&role='.$trolecode;
}
#next if ($home eq 'no_host');
$home = &Apache::lonnet::hostname($home);
- $ttype='Construction Space';
+ $ttype='Authoring Space';
$twhere=&mt('Domain').': '.$tdom.' '.&mt('Server').
': '.$home;
$env{'course.'.$tdom.'_'.$trest.'.description'}='ca';
@@ -1117,33 +1379,85 @@ sub gather_roles {
} elsif ($trest) {
my $tcourseid=$tdom.'_'.$trest;
$ttype = &Apache::loncommon::course_type($tcourseid);
- $trole = &Apache::lonnet::plaintext($role,$ttype,$tcourseid);
+ if ($role !~ /^cr/) {
+ $trole = &Apache::lonnet::plaintext($role,$ttype,$tcourseid);
+ } elsif ($role =~ m{^\Qcr/$tdom/$tdom\E\-domainconfig/(\w+)$}) {
+ my $rolename = $1;
+ my $desc;
+ if (ref($adhocdesc{$tdom}) eq 'HASH') {
+ $desc = $adhocdesc{$tdom}{$rolename};
+ } else {
+ my %domdef = &Apache::lonnet::get_domain_defaults($tdom);
+ if (ref($domdef{'adhocroles'}) eq 'HASH') {
+ foreach my $rolename (sort(keys(%{$domdef{'adhocroles'}}))) {
+ if (ref($domdef{'adhocroles'}{$rolename}) eq 'HASH') {
+ $adhocdesc{$tdom}{$rolename} = $domdef{'adhocroles'}{$rolename}{'desc'};
+ $desc = $adhocdesc{$tdom}{$rolename};
+ }
+ }
+ }
+ }
+ if ($desc ne '') {
+ $trole = $desc;
+ } else {
+ $trole = &mt('Helpdesk[_1]',' '.$rolename);
+ }
+ } else {
+ $trole = (split(/\//,$role,4))[-1];
+ }
if ($env{'course.'.$tcourseid.'.description'}) {
+ my $home=$env{'course.'.$tcourseid.'.home'};
$twhere=$env{'course.'.$tcourseid.'.description'};
$sortkey=$role."\0".$tdom."\0".$twhere."\0".$envkey;
+ $twhere = &HTML::Entities::encode($twhere,'"<>&');
unless ($twhere eq &mt('Currently not available')) {
$twhere.=' '.
&Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$trest,$tdom).
'';
+ unless ($home && grep(/^\Q$home\E$/,@ids) && $loncaparev eq '') {
+ my $required = $env{'course.'.$tcourseid.'.internal.releaserequired'};
+ if ($required ne '') {
+ ($switchserver,$switchwarning) =
+ &Apache::loncommon::check_release_required($loncaparev,$tcourseid,$trolecode,$required);
+ if ($switchserver || $switchwarning) {
+ $button = 0;
+ }
+ }
+ }
}
} else {
my %newhash=&Apache::lonnet::coursedescription($tcourseid);
if (%newhash) {
$sortkey=$role."\0".$tdom."\0".$newhash{'description'}.
"\0".$envkey;
- $twhere=$newhash{'description'}.
- ' '.
- &Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$trest,$tdom).
- '';
+ $twhere=&HTML::Entities::encode($newhash{'description'},'"<>&').
+ ' '.
+ &Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$trest,$tdom).
+ '';
$ttype = $newhash{'type'};
$trole = &Apache::lonnet::plaintext($role,$ttype,$tcourseid);
+ my $home = $newhash{'home'};
+ unless ($home && grep(/^\Q$home\E$/,@ids) && $loncaparev eq '') {
+ my $required = $newhash{'internal.releaserequired'};
+ if ($required ne '') {
+ ($switchserver,$switchwarning) =
+ &Apache::loncommon::check_release_required($loncaparev,$tcourseid,$trolecode,$required);
+ if ($switchserver || $switchwarning) {
+ $button = 0;
+ }
+ }
+ }
} else {
$twhere=&mt('Currently not available');
$env{'course.'.$tcourseid.'.description'}=$twhere;
$sortkey=$role."\0".$tdom."\0".$twhere."\0".$envkey;
$ttype = 'Unavailable';
+ $skipcal = 1;
}
}
+ if ($ttype eq 'Placement') {
+ $ttype = 'Placement Test';
+ }
if ($tsection) {
$twhere.=' '.&mt('Section').': '.$tsection;
}
@@ -1160,7 +1474,8 @@ sub gather_roles {
($role_text,$role_text_end) =
&build_roletext($trolecode,$tdom,$trest,$tstatus,$tryagain,
$advanced,$tremark,$tbg,$trole,$twhere,$tpstart,
- $tpend,$nochoose,$button,$switchserver,$reinit);
+ $tpend,$nochoose,$button,$switchserver,$reinit,
+ $switchwarning,$skipcal);
$roletext->{$envkey}=[$role_text,$role_text_end];
if (!$sortkey) {$sortkey=$twhere."\0".$envkey;}
$sortrole->{$sortkey}=$envkey;
@@ -1180,9 +1495,15 @@ sub role_timezone {
my $cnum = $2;
if ($cdom && $cnum) {
if (!exists($timezones->{$cdom.'_'.$cnum})) {
- my %timehash =
- &Apache::lonnet::get('environment',['timezone'],$cdom,$cnum);
- if ($timehash{'timezone'} eq '') {
+ my $tz;
+ if ($env{'course.'.$cdom.'_'.$cnum.'.description'}) {
+ $tz = $env{'course.'.$cdom.'_'.$cnum.'.timezone'};
+ } else {
+ my %timehash =
+ &Apache::lonnet::get('environment',['timezone'],$cdom,$cnum);
+ $tz = $timehash{'timezone'};
+ }
+ if ($tz eq '') {
if (!exists($timezones->{$cdom})) {
my %domdefaults =
&Apache::lonnet::get_domain_defaults($cdom);
@@ -1195,7 +1516,7 @@ sub role_timezone {
$timezones->{$cdom.'_'.$cnum} = $timezones->{$cdom};
} else {
$timezones->{$cdom.'_'.$cnum} =
- &Apache::lonlocal::gettimezone($timehash{'timezone'});
+ &Apache::lonlocal::gettimezone($tz);
}
}
$timezone = $timezones->{$cdom.'_'.$cnum};
@@ -1226,7 +1547,7 @@ sub roletable_headers {
my $doheaders;
if ((ref($sortrole) eq 'HASH') && (ref($roleclass) eq 'HASH')) {
$r->print(' '
- .&Apache::loncommon::start_data_table()
+ .&Apache::loncommon::start_data_table('LC_textsize_mobile')
.&Apache::loncommon::start_data_table_header_row()
);
if (!$nochoose) { $r->print('
'); }
@@ -1252,12 +1573,12 @@ sub roletable_headers {
}
sub roletypes {
- my @types = ('Domain','Construction Space','Course','Community','Unavailable','System');
+ my @types = ('Domain','Authoring Space','Course','Placement Test','Community','Unavailable','System');
return @types;
}
sub print_rolerows {
- my ($r,$doheaders,$roleclass,$sortrole,$dcroles,$roletext) = @_;
+ my ($r,$doheaders,$roleclass,$sortrole,$dcroles,$roletext,$update,$then) = @_;
if ((ref($roleclass) eq 'HASH') && (ref($sortrole) eq 'HASH')) {
my @types = &roletypes();
foreach my $type (@types) {
@@ -1268,17 +1589,21 @@ sub print_rolerows {
if (ref($roletext->{$sortrole->{$which}}) eq 'ARRAY') {
$output.= &Apache::loncommon::start_data_table_row().
$roletext->{$sortrole->{$which}}->[0].
- &Apache::loncommon::end_data_table_row().
- &Apache::loncommon::continue_data_table_row().
- $roletext->{$sortrole->{$which}}->[1].
&Apache::loncommon::end_data_table_row();
+ if ($roletext->{$sortrole->{$which}}->[1] ne '') {
+ $output .= &Apache::loncommon::continue_data_table_row().
+ $roletext->{$sortrole->{$which}}->[1].
+ &Apache::loncommon::end_data_table_row();
+ }
}
- if ($sortrole->{$which} =~ m-dc\./($match_domain)/-) {
+ if ($sortrole->{$which} =~ m{^user\.role\.dc\./($match_domain)/}) {
if (ref($dcroles) eq 'HASH') {
if ($dcroles->{$1}) {
$output .= &adhoc_roles_row($1,'');
}
}
+ } elsif ($sortrole->{$which} =~ m{^user\.role\.(dh|da)\./($match_domain)/}) {
+ $output .= &adhoc_customroles_row($1,$2,'',$update,$then);
}
}
}
@@ -1299,7 +1624,7 @@ sub print_rolerows {
}
sub findcourse_advice {
- my ($r) = @_;
+ my ($r,$cattype) = @_;
my $domdesc = &Apache::lonnet::domain($env{'user.domain'},'description');
my $esc_dom = &HTML::Entities::encode($env{'user.domain'},'"<>&');
if (&Apache::lonnet::auto_run(undef,$env{'user.domain'})) {
@@ -1310,46 +1635,41 @@ sub findcourse_advice {
'.&mt('You are in a section of course for which automatic enrollment in the corresponding LON-CAPA course is not active.').'
'.&mt('The start date for automated enrollment has yet to be reached.').'
'.&mt('You registered for the course recently and there is a time lag between the time you register, and the time this information becomes available for the update of LON-CAPA course rosters.').'
+
'.&mt('Automated enrollment added you to the course in the time since you last logged in.').' '.&mt('If that is the case you can use the "Check for changes" link in the gray Functions bar to update the list of your available course roles.').'
');
} else {
$r->print(&mt('If you were expecting to see an active role listed for a particular course, that course may not have been created yet.').' ');
}
- my $queued = &Apache::loncoursequeueadmin::queued_selfenrollment();
- if ($queued) {
- $r->print($queued);
- } else {
- $r->print(&mt('You have no request for contributor access pending approval by the GCI WebCenter team.').'
'.
- '
'.&mt('This may mean that action was taken on your request in the time since your most recent log-in.[_1]View [_2]Message[_3] to see if this is the case.',' ','','').'
'.
- '
'.&mt('If you logout and log-in again you may find you now have access to the Geoscience Concept Inventory, as a contributor.').'
'.&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.').'
'.
+ &Apache::loncoursequeueadmin::queued_selfenrollment());
}
return;
}
sub requestcourse_advice {
- my ($r) = @_;
+ my ($r,$cattype,$inrole) = @_;
my $domdesc = &Apache::lonnet::domain($env{'user.domain'},'description');
my $esc_dom = &HTML::Entities::encode($env{'user.domain'},'"<>&');
- my (%can_request,%request_doms);
+ my (%can_request,%request_doms,$output);
&Apache::lonnet::check_can_request($env{'user.domain'},\%can_request,\%request_doms);
if (keys(%request_doms) > 0) {
my ($types,$typename) = &Apache::loncommon::course_types();
if ((ref($types) eq 'ARRAY') && (ref($typename) eq 'HASH')) {
- $r->print('
'.&mt('Request creation of a course or community').'
'.
- '
'.&mt('You have rights to request the creation of courses and/or communities in the following domain(s):').'
');
my (@reqdoms,@reqtypes);
foreach my $type (sort(keys(%request_doms))) {
push(@reqtypes,$type);
if (ref($request_doms{$type}) eq 'ARRAY') {
my $domstr = join(', ',map { &Apache::lonnet::domain($_) } sort(@{$request_doms{$type}}));
- $r->print(
+ $output .=
'
'
.&mt('[_1]'.$typename->{$type}.'[_2] in domain: [_3]',
'',
'',
''.$domstr.'')
- .'
'.&mt('Use the [_1]request form[_2] to submit a request for creation of a new course or community.','','').'');
+ }
+ if ($output) {
+ $r->print('
'.&mt('Request creation of a course or community').'
'.
+ '
'.
+ &mt('You have rights to request the creation of courses and/or communities in the following domain(s):').
+ '
'.
+ $output.
+ '
'.
+ &mt('Use the [_1]request form[_2] to submit a request for creation of a new course or community.',
+ '','').
+ '');
+ }
}
+ } elsif (!$env{'user.adv'}) {
+ if ($inrole) {
+ $r->print('
'.&mt('Currently no additional roles, courses or communities').'
');
+ } else {
+ $r->print('
'.&mt('Currently no active roles, courses or communities').'
');
+ }
+ &findcourse_advice($r,$cattype);
}
return;
}
@@ -1394,7 +1731,7 @@ sub privileges_info {
my (undef,$tdom,$trest,$tsec)=split(m{/},$where);
if ($trest) {
if ($env{'course.'.$tdom.'_'.$trest.'.description'} eq 'ca') {
- $ttype='Construction Space';
+ $ttype='Authoring Space';
$twhere='User: '.$trest.', Domain: '.$tdom;
} else {
$ttype= &Apache::loncommon::course_type($tdom.'_'.$trest);
@@ -1435,10 +1772,13 @@ sub privileges_info {
}
sub build_roletext {
- my ($trolecode,$tdom,$trest,$tstatus,$tryagain,$advanced,$tremark,$tbg,$trole,$twhere,$tpstart,$tpend,$nochoose,$button,$switchserver,$reinit) = @_;
- my ($roletext,$roletext_end);
- my $is_dc=($trolecode =~ m/^dc\./);
- my $rowspan=($is_dc) ? ''
+ my ($trolecode,$tdom,$trest,$tstatus,$tryagain,$advanced,$tremark,$tbg,$trole,$twhere,
+ $tpstart,$tpend,$nochoose,$button,$switchserver,$reinit,$switchwarning,$skipcal) = @_;
+ my ($roletext,$roletext_end,$poss_adhoc);
+ if ($trolecode =~ m/^d(c|h|a)\./) {
+ $poss_adhoc = 1;
+ }
+ my $rowspan=($poss_adhoc) ? ''
: ' rowspan="2" ';
unless ($nochoose) {
@@ -1453,6 +1793,13 @@ sub build_roletext {
} else {
$roletext.=('