--- loncom/auth/lonroles.pm 2021/11/03 01:04:02 1.353
+++ loncom/auth/lonroles.pm 2025/02/23 05:16:01 1.376
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# User Roles Screen
#
-# $Id: lonroles.pm,v 1.353 2021/11/03 01:04:02 raeburn Exp $
+# $Id: lonroles.pm,v 1.376 2025/02/23 05:16:01 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -149,43 +149,69 @@ my $registered_cleanup;
my $rosterupdates;
sub start_loading_course {
- my ($r,$title) = @_;
+ my ($r,$title,$only_body) = @_;
&Apache::loncommon::content_type($r,'text/html');
&Apache::loncommon::no_cache($r);
$r->send_http_header;
- my $swinfo=&Apache::lonmenu::rawconfig();
- # Breadcrumbs
- my $brcrum = [{'href' => '',
- 'text' => $title},];
- my $start_page = &Apache::loncommon::start_page($title,undef,
- {'bread_crumbs' => $brcrum,});
- $r->print(<print(&Apache::loncommon::start_page($title,undef,{'only_body' => 1,
+ 'add_progressbar' => 1}));
+ } else {
+ my $swinfo=&Apache::lonmenu::rawconfig();
+ # Breadcrumbs
+ my $brcrum = [{'href' => '',
+ 'text' => $title},];
+ my $start_page = &Apache::loncommon::start_page($title,undef,
+ {'bread_crumbs' => $brcrum,
+ 'bread_crumbs_nomenu' => 1,
+ 'links_disabled' => 1});
+ $r->print(<
//
ENDREDIR
+ }
+ $r->print('
'."\n");
return;
}
sub finish_loading_course {
- my ($r,$msg,$url) = @_;
-#FIXME add continue link, and add jquery to enable menu links when page is loaded
- my $link;
+ my ($r,$msg,$url,$only_body) = @_;
+ my $link = '
'.
+ ''.
&Apache::loncommon::end_page());
}
} else {
+ &set_supplemental_access($cnum,$cdom);
if (($env{'request.lti.login'}) &&
($env{'request.lti.rosterid'} || $env{'request.lti.passbackid'})) {
&process_lti($r,$cdom,$cnum);
}
+ if ($env{'request.deeplink.login'}) {
+ &set_deeplink_target($cnum,$cdom);
+ }
# Check to see if the user is a CC entering a course
# for the first time
if ((($role eq 'cc') || ($role eq 'co'))
@@ -848,7 +1022,7 @@ ENDCLOSE
$msg = '
';
- &finish_loading_course($r,$msg,$furl);
+ &finish_loading_course($r,$msg,$furl,$only_body);
}
}
$r->rflush();
@@ -1005,6 +1179,12 @@ ENDCLOSE
$redirect_url .= $where;
}
$redirect_url .= '/';
+ if ($env{'form.orgurl'} =~ /^\Q$redirect_url\E/) {
+ my ($path) = ($env{'form.orgurl'} =~ m{^(.+)/[^/]+$});
+ if (($path ne '') && (-e $Apache::lonnet::perlvar{'lonDocRoot'}.$path)) {
+ $redirect_url = $env{'form.orgurl'};
+ }
+ }
&redirect_user($r,&mt('Entering Authoring Space'),
$redirect_url);
return OK;
@@ -1057,6 +1237,10 @@ ENDCLOSE
$recent = &mt('Recent Courses');
$standby = &mt('Course selected. Please stand by.');
}
+ if (($norolelist) && ((split(/:/,$env{'user.error.msg'}))[2])) {
+ $crumbtext = 'Access Denied';
+ $pagetitle = 'Unauthorized';
+ }
my $brcrum =[{href=>"/adm/roles",text=>$crumbtext}];
my %roles_in_env;
@@ -1093,14 +1277,18 @@ ENDCLOSE
$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 ($crumbsright,$crumbs_style);
+ unless (($norolelist) && ((split(/:/,$env{'user.error.msg'}))[2])) {
+ $funcs = &get_roles_functions($showcount,$cattype,$domdefs{'userapprovals'});
+ if ($env{'browser.mobile'}) {
+ $crumbsright = $funcs;
+ undef($funcs);
+ $crumbs_style = 'overflow: visible;';
+ }
}
$start_page=&Apache::loncommon::start_page($pagetitle,undef,{bread_crumbs=>$brcrum,
- bread_crumbs_component=>$crumbsright});
+ bread_crumbs_component=>$crumbsright,
+ bread_crumbs_style=>$crumbs_style,});
}
&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.').' ';
@@ -1131,7 +1319,11 @@ function enterrole (thisform,rolecode,bu
}
function rolesView (caller) {
- if ((caller == 'showall') || (caller == 'noshowall')) {
+ if (caller == 'approvals') {
+ document.rolechoice.approvals.value = 'show';
+ } else if (caller == 'noapprovals') {
+ document.rolechoice.approvals.value = 'hide';
+ } else if ((caller == 'showall') || (caller == 'noshowall')) {
document.rolechoice.display.value = caller;
} else {
if ((caller == 'doupdate') || (caller == 'requestauthor') ||
@@ -1204,9 +1396,18 @@ ENDHEADER
}
}
if ($nochoose) {
- $r->print("
".&mt('Sorry ...')."
\n".
- &mt('This action is currently not authorized.').''.
- &Apache::loncommon::end_page());
+ $r->print("
+
".&mt('Sorry ...')."
\n".
+ &mt('This action is currently not authorized.').'');
+ if ($error && $norolelist) {
+ $r->print('
'.
+ &mt('As your session was launched from a web page external to LON-CAPA some course content may be unavailable, including the resource you were trying to access.').
+ '
'.
+ '
'.
+ &mt('You may need to login to LON-CAPA directly, or re-launch from a different external system.').
+ '
'.
+ &mt('The [_1] you selected is not available for access with a [_2] role from your current IP address: [_3].',
+ lc($blocked_type),$blocked_role,$clientip).
+ '
');
+ }
}
$r->rflush();
@@ -1624,9 +1844,9 @@ sub gather_roles {
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};
}
}
+ $desc = $adhocdesc{$tdom}{$rolename};
}
}
if ($desc ne '') {
@@ -1782,7 +2002,7 @@ sub roletable_headers {
.&Apache::loncommon::start_data_table('LC_textsize_mobile')
.&Apache::loncommon::start_data_table_header_row()
);
- if (!$nochoose) { $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.').'
');
if ($elapsed > 600) {
- $r->print('
'.&mt('You may also have been assigned to a course in the time since you last logged-in, or checked for changes').
+ $r->print('
'.&mt('You may also have been assigned to a course in the time since you last logged-in, or checked for changes.').
' '.
&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.').'
');
}
@@ -2068,7 +2288,7 @@ sub build_roletext {
$trolecode."','".$buttonname.'\');" />';
}
}
- if (($trolecode !~ m/^(dc|ca|au|aa)\./) && (!$skipcal)) {
+ if (($trolecode !~ m/^(ca|aa)\./) && ($trest ne '') && (!$skipcal)) {
$tremark.=&Apache::lonannounce::showday(time,1,
&Apache::lonannounce::readcalendar($tdom.'_'.$trest));
}
@@ -2527,6 +2747,22 @@ sub update_session_roles {
}
} else {
$newrole{$rolekey} = $status_in_db;
+ if ($role eq 'au') {
+ my %userenv =
+ &Apache::lonnet::userenvironment($env{'user.domain'},
+ $env{'user.name'},'authoreditors');
+ if ($userenv{'authoreditors'}) {
+ $userenv{'editors'} = $userenv{'authoreditors'};
+ } else {
+ my %domdef = &Apache::lonnet::get_domain_defaults($env{'user.domain'});
+ if ($domdef{'editors'} ne '') {
+ $userenv{'editors'} = $domdef{'editors'};
+ } else {
+ $userenv{'editors'} = 'edit,xml';
+ }
+ }
+ &Apache::lonnet::appenv(\%userenv);
+ }
}
}
}
@@ -3208,7 +3444,7 @@ sub is_active_course {
}
sub get_roles_functions {
- my ($rolescount,$cattype) = @_;
+ my ($rolescount,$cattype,$userapprovals) = @_;
my @links;
push(@links,["javascript:rolesView('doupdate');",'start-here-22x22',&mt('Check for changes')]);
if ($env{'environment.canrequest.author'}) {
@@ -3237,6 +3473,13 @@ sub get_roles_functions {
unless ($cattype eq 'none') {
push(@links,['/adm/coursecatalog','ccat-22x22',&mt('Course catalog')]);
}
+ if ($userapprovals) {
+ if ($env{'form.approvals'} eq 'show') {
+ push(@links,["javascript:rolesView('noapprovals');",'list-add-22x22',&mt('Hide pending')]);
+ } else {
+ push(@links,["javascript:rolesView('approvals');",'list-add-22x22',&mt('Show pending')]);
+ }
+ }
my $funcs;
if ($env{'browser.mobile'}) {
my @functions;
@@ -3254,7 +3497,7 @@ sub get_roles_functions {
foreach my $link (@links) {
$funcs .= &Apache::lonhtmlcommon::add_item_funclist(
''.
- ''.
+ ''.
$link->[2].'');
}
$funcs .= &Apache::lonhtmlcommon::end_funclist();
@@ -3340,15 +3583,23 @@ sub get_queued {
unless ($output) {
if ($env{'environment.canrequest.author'} || $env{'environment.canrequest.official'} ||
$env{'environment.canrequest.unofficial'} || $env{'environment.canrequest.community'}) {
- $output = &mt('No requests for courses, communities or authoring currently queued');
+ $output = ''.
+ &mt('No requests for courses, communities or authoring currently queued').
+ '';
} else {
- $output = &mt('No enrollment requests currently queued awaiting approval');
+ $output = ''.
+ &mt('No enrollment requests currently queued awaiting approval').
+ '';
}
}
return ' ';
}
+sub get_approvals {
+ return &Apache::loncoursequeueadmin::display_queued_requests('othdomaction',$env{'user.domain'},'','user');
+}
+
sub process_lti {
my ($r,$cdom,$cnum) = @_;
my %lti = &Apache::lonnet::get_domain_lti($cdom,'provider');
@@ -3424,6 +3675,44 @@ sub ltienroll {
&LONCAPA::ltiutils::batchaddroster($item);
}
}
+ $rosterupdates = [];
+ }
+ return OK;
+}
+
+sub set_deeplink_target {
+ my ($cnum,$cdom) = @_;
+ if (($cnum ne '') && ($cdom ne '')) {
+ my $deeplink_symb = &Apache::loncommon::deeplink_login_symb($cnum,$cdom);
+ if ($deeplink_symb ne '') {
+ my $deeplink;
+ if ($deeplink_symb =~ /\.(page|sequence)$/) {
+ my $mapname = &Apache::lonnet::deversion((&Apache::lonnet::decode_symb($deeplink_symb))[2]);
+ my $navmap = Apache::lonnavmaps::navmap->new();
+ if (ref($navmap)) {
+ $deeplink = $navmap->get_mapparam(undef,$mapname,'0.deeplink');
+ }
+ } elsif ($deeplink_symb ne '') {
+ $deeplink = &Apache::lonnet::EXT('resource.0.deeplink',$deeplink_symb);
+ }
+ if ($deeplink ne '') {
+ my ($state,$others,$listed,$scope,$protect,$display,$target) = split(/,/,$deeplink);
+ if ($target ne '') {
+ &Apache::lonnet::appenv({'request.deeplink.target' => $target});
+ } elsif (exists($env{'request.deeplink.target'})) {
+ &Apache::lonnet::delenv('request.deeplink.target');
+ }
+ }
+ }
+ }
+ return;
+}
+
+sub set_supplemental_access {
+ my ($cnum,$cdom) = @_;
+ my ($supplemental,$refs_updated) = &Apache::loncommon::get_supplemental($cnum,$cdom);
+ unless ($refs_updated) {
+ &Apache::loncommon::set_supp_httprefs($cnum,$cdom,$supplemental);
}
}