--- loncom/auth/lonroles.pm 2016/08/04 18:53:26 1.269.2.24
+++ loncom/auth/lonroles.pm 2016/10/23 18:30:32 1.269.2.27
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# User Roles Screen
#
-# $Id: lonroles.pm,v 1.269.2.24 2016/08/04 18:53:26 raeburn Exp $
+# $Id: lonroles.pm,v 1.269.2.27 2016/10/23 18:30:32 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -260,7 +260,8 @@ sub handler {
my $envkey;
my %dcroles = ();
- my $numdc = &check_fordc(\%dcroles,$update,$then);
+ my %dhroles = ();
+ my ($numdc,$numdh,$numadhoc) = &check_for_adhoc(\%dcroles,\%dhroles,$update,$then);
my $loncaparev = $r->dir_config('lonVersion');
# ================================================================== Roles Init
@@ -269,8 +270,15 @@ 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 role trying to enter a course
+ if ($env{'form.newrole'} =~ m{^cr/($match_domain)/\1\-domainconfig/\w+\./\1/$match_courseid$}) {
+ if ($dhroles{$1}) {
+ $custom_adhoc = 1;
+ }
+ }
}
if ($env{'request.course.id'}) {
# Check if user is CC trying to select a course role
@@ -301,8 +309,26 @@ sub handler {
"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)$}) {
+ my $cdom = $1;
+ my $rolename = $2;
+ my $cnum = $3;
+ if ($custom_adhoc) {
+ my %adhocroles = &Apache::lonnet::userenvironment($env{'user.domain'},$env{'user.name'},
+ 'adhocroles.'.$cdom);
+ if (keys(%adhocroles)) {
+ my @adhoc = split(',',$adhocroles{'adhocroles.'.$cdom});
+ if (grep(/^\Q$rolename\E$/,@adhoc)) {
+ if (&Apache::lonnet::check_adhoc_privs($cdom,$cnum,$update,$refresh,$now,
+ "cr/$cdom/$cdom".'-domainconfig/'.$rolename)) {
+ &Apache::lonnet::appenv({"environment.internal.$cdom.$cnum.cr/$cdom/$cdom".'-domainconfig/'."$rolename.adhoc" => time});
+ }
+ }
+ }
+ }
+ } elsif ($numdc > 0) {
# 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) =
@@ -710,6 +736,12 @@ 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 'sc') {
my $redirect_url = '/adm/grades?command=scantronupload';
&redirect_user($r,&mt('Loading Data Upload Page'),
@@ -746,13 +778,19 @@ ENDENTERKEY
my $showcount = &roles_from_env(\%roles_in_env,$update);
my $swinfo=&Apache::lonmenu::rawconfig();
- my $start_page=&Apache::loncommon::start_page($pagetitle,undef,{bread_crumbs=>$brcrum});
my %domdefs=&Apache::lonnet::get_domain_defaults($env{'user.domain'});
my $cattype = 'std';
if ($domdefs{'catauth'}) {
$cattype = $domdefs{'catauth'};
}
my $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,{bread_crumbs=>$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.').'
';
@@ -951,7 +989,7 @@ ENDHEADER
}
# ----------------------------------------------------------------------- Table
- if ($numdc > 0) {
+ if (($numdc > 0) || (($numdh > 0) && ($numadhoc > 0))) {
$r->print(&coursepick_jscript());
$r->print(&Apache::loncommon::coursebrowser_javascript().
&Apache::loncommon::authorbrowser_javascript());
@@ -984,9 +1022,12 @@ ENDHEADER
$roletext{'user.role.'.$role}->[1].
&Apache::loncommon::end_data_table_row();
}
- if ($role =~ m{dc\./($match_domain)/}
+ if ($role =~ m{^dc\./($match_domain)/$}
&& $dcroles{$1}) {
$output .= &adhoc_roles_row($1,'recent');
+ } elsif ($role =~ m{^dh\./($match_domain)/$}
+ && ($env{'environment.adhocroles.'.$1} ne '')) {
+ $output .= &adhoc_customroles_row($1,'recent');
}
} elsif ($numdc > 0) {
unless ($role =~/^error\:/) {
@@ -1328,7 +1369,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('