--- loncom/auth/lonroles.pm 2017/01/21 19:58:05 1.324
+++ loncom/auth/lonroles.pm 2017/08/08 20:10:55 1.333
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# User Roles Screen
#
-# $Id: lonroles.pm,v 1.324 2017/01/21 19:58:05 raeburn Exp $
+# $Id: lonroles.pm,v 1.333 2017/08/08 20:10:55 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -204,7 +204,7 @@ sub handler {
my $r = shift;
# Check for critical messages and redirect if present.
- my ($redirect,$url) = &Apache::loncommon::critical_redirect(300);
+ my ($redirect,$url) = &Apache::loncommon::critical_redirect(300,'roles');
if ($redirect) {
&Apache::loncommon::content_type($r,'text/html');
$r->header_out(Location => $url);
@@ -255,8 +255,9 @@ sub handler {
my $envkey;
my %dcroles = ();
- my %dhroles = ();
- my ($numdc,$numdh,$numadhoc) = &check_for_adhoc(\%dcroles,\%dhroles,$update,$then);
+ my %helpdeskroles = ();
+ my ($numdc,$numhelpdesk,$numadhoc) =
+ &check_for_adhoc(\%dcroles,\%helpdeskroles,$update,$then);
my $loncaparev = $r->dir_config('lonVersion');
# ================================================================== Roles Init
@@ -268,9 +269,9 @@ sub handler {
my $custom_adhoc;
if ($env{'form.newrole'}) {
$env{'form.'.$env{'form.newrole'}}=1;
-# Check if this is a Domain Helpdesk role trying to enter a course
+# 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 ($dhroles{$1}) {
+ if ($helpdeskroles{$1}) {
$custom_adhoc = 1;
}
}
@@ -321,9 +322,9 @@ sub handler {
}
}
}
- } elsif (($numdc > 0) || ($numdh > 0)) {
+ } 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 trying to enter a course 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) {
@@ -393,10 +394,10 @@ sub handler {
last;
}
}
- if ($numdh) {
+ 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 ($dhroles{$domain}) {
+ 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})) {
@@ -673,6 +674,15 @@ ENDENTERKEY
}
}
}
+ 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);
@@ -705,7 +715,7 @@ ENDENTERKEY
unless (($dest =~ m{^/enc/}) || ($dest =~ /(\?|\&)symb=.+___\d+___.+/)) {
if (($destsymb ne '') && ($destsymb !~ m{^/enc/})) {
my $esc_symb = &escape($destsymb);
- $dest .= '?symb='.$esc_symb;
+ $dest .= (($dest =~/\?/)? '&':'?').'symb='.$esc_symb;
}
}
&redirect_user($r, &mt('Entering [_1]',
@@ -783,6 +793,12 @@ ENDENTERKEY
$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'),
@@ -1080,10 +1096,12 @@ ENDHEADER
}
# ----------------------------------------------------------------------- Table
- if (($numdc > 0) || (($numdh > 0) && ($numadhoc > 0))) {
- $r->print(&coursepick_jscript());
- $r->print(&Apache::loncommon::coursebrowser_javascript().
- &Apache::loncommon::authorbrowser_javascript());
+ if (($numdc > 0) || (($numhelpdesk > 0) && ($numadhoc > 0))) {
+ $r->print(&coursepick_jscript().
+ &Apache::loncommon::coursebrowser_javascript());
+ }
+ if ($numdc > 0) {
+ $r->print(&Apache::loncommon::authorbrowser_javascript());
}
unless ((!&Apache::loncommon::show_course()) || ($nochoose) || ($countactive==1)) {
@@ -1116,7 +1134,7 @@ ENDHEADER
if ($role =~ m{^dc\./($match_domain)/$}
&& $dcroles{$1}) {
$output .= &adhoc_roles_row($1,'recent');
- } elsif ($role =~ m{^(dh)\./($match_domain)/$}) {
+ } elsif ($role =~ m{^(dh|da)\./($match_domain)/$}) {
$output .= &adhoc_customroles_row($1,$2,'recent',$update,$then);
}
} elsif ($numdc > 0) {
@@ -1222,6 +1240,7 @@ sub gather_roles {
my $advanced = $env{'user.adv'};
my $tryagain = $env{'form.tryagain'};
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}))) {
@@ -1290,10 +1309,23 @@ sub gather_roles {
if (($role eq 'ca') || ($role eq 'aa')) {
my $home = &Apache::lonnet::homeserver($trest,$tdom);
my $allowed=0;
+ 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);
@@ -1302,7 +1334,9 @@ sub gather_roles {
': '.$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
@@ -1548,7 +1582,7 @@ sub print_rolerows {
$output .= &adhoc_roles_row($1,'');
}
}
- } elsif ($sortrole->{$which} =~ m{^user\.role\.(dh)\./($match_domain)/}) {
+ } elsif ($sortrole->{$which} =~ m{^user\.role\.(dh|da)\./($match_domain)/}) {
$output .= &adhoc_customroles_row($1,$2,'',$update,$then);
}
}
@@ -1719,9 +1753,11 @@ sub privileges_info {
sub build_roletext {
my ($trolecode,$tdom,$trest,$tstatus,$tryagain,$advanced,$tremark,$tbg,$trole,$twhere,
$tpstart,$tpend,$nochoose,$button,$switchserver,$reinit,$switchwarning,$skipcal) = @_;
- my ($roletext,$roletext_end);
- my $is_dc=($trolecode =~ m/^dc\./);
- my $rowspan=($is_dc) ? ''
+ my ($roletext,$roletext_end,$poss_adhoc);
+ if ($trolecode =~ m/^d(c|h|a)\./) {
+ $poss_adhoc = 1;
+ }
+ my $rowspan=($poss_adhoc) ? ''
: ' rowspan="2" ';
unless ($nochoose) {
@@ -1782,7 +1818,7 @@ sub build_roletext {
.'