--- loncom/auth/lonroles.pm 2014/03/25 09:41:16 1.301
+++ loncom/auth/lonroles.pm 2014/05/22 14:32:48 1.307
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# User Roles Screen
#
-# $Id: lonroles.pm,v 1.301 2014/03/25 09:41:16 raeburn Exp $
+# $Id: lonroles.pm,v 1.307 2014/05/22 14:32:48 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -128,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;
@@ -202,6 +202,14 @@ sub handler {
my $r = shift;
+ # Check for critical messages and redirect if present.
+ my ($redirect,$url) = &Apache::loncommon::critical_redirect(300);
+ 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'};
@@ -247,7 +255,7 @@ sub handler {
my $envkey;
my %dcroles = ();
my $numdc = &check_fordc(\%dcroles,$update,$then);
- my $loncaparev = $Apache::lonnet::perlvar{'lonVersion'};
+ my $loncaparev = $r->dir_config('lonVersion');
# ================================================================== Roles Init
if ($env{'form.selectrole'}) {
@@ -746,7 +754,12 @@ ENDENTERKEY
my $swinfo=&Apache::lonmenu::rawconfig();
my $start_page=&Apache::loncommon::start_page($pagetitle,undef,{bread_crumbs=>$brcrum});
- my $funcs = &get_roles_functions($showcount);
+ 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);
$standby=~s/\n/\\n/g;
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.').'
';
@@ -889,7 +902,7 @@ ENDHEADER
\%sortrole,\%roleclass,\%futureroles,\%timezones,$loncaparev);
$refresh = $now;
&Apache::lonnet::appenv({'user.refresh.time' => $refresh});
- unless ($env{'user.adv'}) {
+ if ((($cattype eq 'std') || ($cattype eq 'domonly')) && (!$env{'user.adv'})) {
if ($countactive > 0) {
my $domdesc = &Apache::lonnet::domain($env{'user.domain'},'description');
my $esc_dom = &HTML::Entities::encode($env{'user.domain'},'"<>&');
@@ -913,13 +926,7 @@ ENDHEADER
# No active roles
if ($countactive==0) {
- 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);
- &requestcourse_advice($r);
+ &requestcourse_advice($r,$cattype,$inrole);
$r->print('');
if ($countfuture) {
$r->print(&mt('The following [quant,_1,role,roles] will become active in the future:',$countfuture));
@@ -1407,7 +1414,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'})) {
@@ -1422,37 +1429,36 @@ sub findcourse_advice {
} 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.').'
');
}
- $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.').'
'.
- &Apache::loncoursequeueadmin::queued_selfenrollment());
+ if (($cattype eq 'std') || ($cattype eq 'domonly')) {
+ $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.').'
'.
+ &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.'')
- .'
'
- );
+ .'';
foreach my $dom (@{$request_doms{$type}}) {
unless (grep(/^\Q$dom\E/,@reqdoms)) {
push(@reqdoms,$dom);
@@ -1475,9 +1481,26 @@ sub requestcourse_advice {
}
if (@reqdoms == 1 || @showtypes > 0) {
$requrl .= '&state=crstype&action=new';
- }
- $r->print('
'.&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):').
+ '
'.
+ &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;
}
@@ -1750,7 +1773,7 @@ sub check_release_required {
my $otherserver;
if (($major eq '' && $minor eq '') ||
(($reqdmajor > $major) || (($reqdmajor == $major) && ($reqdminor > $minor)))) {
- my ($userdomserver) = &Apache::lonnet::choose_server($env{'user.domain'},undef,$required);
+ my ($userdomserver) = &Apache::lonnet::choose_server($env{'user.domain'},undef,$required,1);
my $switchlcrev =
&Apache::lonnet::get_server_loncaparev($env{'user.domain'},
$userdomserver);
@@ -1759,7 +1782,7 @@ sub check_release_required {
(($reqdmajor == $swmajor) && ($reqdminor > $swminor))) {
my $cdom = $env{'course.'.$tcourseid.'.domain'};
if ($cdom ne $env{'user.domain'}) {
- my ($coursedomserver,$coursehostname) = &Apache::lonnet::choose_server($cdom);
+ my ($coursedomserver,$coursehostname) = &Apache::lonnet::choose_server($cdom,undef,$required,1);
my $serverhomeID = &Apache::lonnet::get_server_homeID($coursehostname);
my $serverhomedom = &Apache::lonnet::host_domain($serverhomeID);
my %defdomdefaults = &Apache::lonnet::get_domain_defaults($serverhomedom);
@@ -2704,7 +2727,7 @@ sub is_active_course {
}
sub get_roles_functions {
- my ($rolescount) = @_;
+ my ($rolescount,$cattype) = @_;
my @links;
push(@links,["javascript:rolesView('doupdate');",'start-here-22x22',&mt('Check for changes')]);
if ($env{'environment.canrequest.author'}) {
@@ -2730,7 +2753,7 @@ sub get_roles_functions {
push(@links,["javascript:rolesView('showall');",'edit-undo-22x22',&mt('Include expired')]);
}
}
- if (&Apache::loncommon::designparm('login.coursecatalog',$env{'user.domain'})) {
+ unless ($cattype eq 'none') {
push(@links,['/adm/coursecatalog','ccat-22x22',&mt('Course catalog')]);
}
my $funcs = &Apache::lonhtmlcommon::start_funclist();