--- loncom/auth/lonroles.pm 2009/06/29 12:43:45 1.228
+++ loncom/auth/lonroles.pm 2014/05/22 18:51:01 1.269.2.20
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# User Roles Screen
#
-# $Id: lonroles.pm,v 1.228 2009/06/29 12:43:45 bisitz Exp $
+# $Id: lonroles.pm,v 1.269.2.20 2014/05/22 18:51:01 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 $msg ');
+ if ($switchwarning) {
+ $r->print($switchwarning.' '
- .&mt('This is LON-CAPA [_1]',$r->dir_config('lonVersion'))
- .' '
+ .&mt('This LON-CAPA server is version [_1]',$r->dir_config('lonVersion'))
+ .' '.&mt('The [_1]Course Catalog[_2] provides information about all [_3] classes for which LON-CAPA courses have been created.','','',$domdesc).' '.&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).' '.
+ &mt('You have rights to request the creation of courses and/or communities in the following domain(s):').
+ '
');
+ if (&Apache::loncommon::show_course()) {
+ $r->print(&mt('Display courses'));
+ } else {
+ $r->print(&mt('Display roles'));
+ }
+ $r->print('');
+ } elsif ($switchserver) {
+ $r->print(&mt('This course requires a newer version of LON-CAPA than is installed on this server.').
+ '
'.
+ ''.
+ &mt('Switch Server').
+ '');
+ }
+ $r->print('
'.&mt('As this is not the case, most functionality in the system will be unavailable.').'
';
+ 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(<'.
- &mt('As your session file for the course has expired, you will need to re-select the course.').'
');
+ &mt('As your session file for the course or community has expired, you will need to re-select it.').'');
} else {
$r->print(
''.
- &mt('You need to choose another user role or enter a specific course for this function').'
');
+ &mt('You need to choose another user role or enter a specific course or community for this function.').
+ '');
}
}
}
-# -------------------------------------------------------- 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('Select a Course to Enter')."
\n");
}
+ if ($env{'form.destinationurl'}) {
+ $r->print('');
+ if ($env{'form.destsymb'} ne '') {
+ $r->print('');
+ }
+ }
+
my $doheaders = &roletable_headers($r,\%roleclass,\%sortrole,$nochoose);
if ($env{'environment.recentroles'}) {
my %recent_roles =
&Apache::lonhtmlcommon::get_recent('roles',$env{'environment.recentrolesn'});
my $output='';
- foreach (sort(keys(%recent_roles))) {
- if (ref($roletext{'user.role.'.$_}) eq 'ARRAY') {
+ foreach my $role (sort(keys(%recent_roles))) {
+ if (ref($roletext{'user.role.'.$role}) eq 'ARRAY') {
$output.= &Apache::loncommon::start_data_table_row().
- $roletext{'user.role.'.$_}->[0].
- &Apache::loncommon::end_data_table_row().
- &Apache::loncommon::continue_data_table_row().
- $roletext{'user.role.'.$_}->[1].
+ $roletext{'user.role.'.$role}->[0].
&Apache::loncommon::end_data_table_row();
- if ($_ =~ m-dc\./($match_domain)/-
+ if ($roletext{'user.role.'.$role}->[1] ne '') {
+ $output .= &Apache::loncommon::continue_data_table_row().
+ $roletext{'user.role.'.$role}->[1].
+ &Apache::loncommon::end_data_table_row();
+ }
+ if ($role =~ m{dc\./($match_domain)/}
&& $dcroles{$1}) {
$output .= &adhoc_roles_row($1,'recent');
}
} elsif ($numdc > 0) {
- unless ($_ =~/^error\:/) {
- $output.=&display_cc_role('user.role.'.$_);
+ unless ($role =~/^error\:/) {
+ my ($roletext,$role_text_end) = &display_cc_role('user.role.'.$role);
+ if ($roletext) {
+ $output.= &Apache::loncommon::start_data_table_row().
+ $roletext.
+ &Apache::loncommon::end_data_table_row();
+ if ($role_text_end) {
+ $output .= &Apache::loncommon::continue_data_table_row().
+ $role_text_end.
+ &Apache::loncommon::end_data_table_row();
+ }
+ }
}
- }
+ }
}
if ($output) {
$r->print(&Apache::loncommon::start_data_table_empty_row()
@@ -791,12 +1028,6 @@ ENDHEADER
$doheaders ++;
}
}
-
- if ($numdc > 0) {
- $r->print(&coursepick_jscript());
- $r->print(&Apache::loncommon::coursebrowser_javascript().
- &Apache::loncommon::authorbrowser_javascript());
- }
&print_rolerows($r,$doheaders,\%roleclass,\%sortrole,\%dcroles,\%roletext);
if ($countactive > 1) {
my $tremark='';
@@ -832,45 +1063,64 @@ ENDHEADER
$r->print(''.&mt('Current Privileges').'
');
$r->print(&privileges_info());
}
- $r->print(&Apache::lonnet::getannounce());
+ my $announcements = &Apache::lonnet::getannounce();
+ $r->print(
+ '
'.
+ ''.&mt('Announcements').'
'.
+ $announcements
+ ) unless (!$announcements);
if ($advanced) {
my $esc_dom = &HTML::Entities::encode($env{'user.domain'},'"<>&');
- $r->print('
'
- .''.&mt('Logout').' '
+ $r->print('
'
+ .''.&mt('Logout').' '
.''
- .&mt('Course Catalog')
+ .&mt('Course/Community Catalog')
.'
'; }
- $tremark.=&mt('Defined by [_1] at [_2].',$rauthor,$rdomain);
+ $tremark.=&mt('Custom role defined by [_1].',$rauthor.':'.$rdomain);
}
$trole=Apache::lonnet::plaintext($role);
my $ttype;
@@ -915,15 +1172,14 @@ sub gather_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();
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('User').': '.$trest.'
'.&mt('Domain').
': '.$tdom.'
'.
' '.&mt('Server').': '.$home;
@@ -935,15 +1191,14 @@ sub gather_roles {
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';
@@ -952,26 +1207,49 @@ sub gather_roles {
} elsif ($trest) {
my $tcourseid=$tdom.'_'.$trest;
$ttype = &Apache::loncommon::course_type($tcourseid);
- $trole = &Apache::lonnet::plaintext($role,$ttype);
+ $trole = &Apache::lonnet::plaintext($role,$ttype,$tcourseid);
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) =
+ &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);
+ $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) =
+ &check_release_required($loncaparev,$tcourseid,$trolecode,$required);
+ if ($switchserver || $switchwarning) {
+ $button = 0;
+ }
+ }
+ }
} else {
$twhere=&mt('Currently not available');
$env{'course.'.$tcourseid.'.description'}=$twhere;
@@ -995,7 +1273,7 @@ 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);
$roletext->{$envkey}=[$role_text,$role_text_end];
if (!$sortkey) {$sortkey=$twhere."\0".$envkey;}
$sortrole->{$sortkey}=$envkey;
@@ -1015,9 +1293,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);
@@ -1030,7 +1314,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};
@@ -1087,7 +1371,7 @@ sub roletable_headers {
}
sub roletypes {
- my @types = ('Domain','Construction Space','Course','Unavailable','System');
+ my @types = ('Domain','Authoring Space','Course','Community','Unavailable','System');
return @types;
}
@@ -1103,10 +1387,12 @@ 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 (ref($dcroles) eq 'HASH') {
@@ -1134,7 +1420,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'})) {
@@ -1149,51 +1435,78 @@ 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('
');
- $r->print(&mt('You can search the course catalog for courses which permit self-enrollment, if you would like to enroll in a course.').''.&mt('Self-Enrollment').'
'.
+ '
');
+ $r->print(&mt('You can search for courses and communities which permit self-enrollment, if you would like to enroll in one.').'
'.
- &Apache::loncommon::start_data_table().
- &Apache::loncommon::start_data_table_header_row().
- ''.&mt('Date requested').' '.&mt('Course title').' '.
- ''.&mt('User role').' '.&mt('Section').' '.
- &Apache::loncommon::end_data_table_header_row());
- my @sorted = sort { $a <=> $b } (keys(%reqs_by_date));
- foreach my $item (@sorted) {
- if (ref($reqs_by_date{$item}) eq 'ARRAY') {
- foreach my $crs (@{$reqs_by_date{$item}}) {
- my %courseinfo = &Apache::lonnet::coursedescription($crs);
- my $usec = $selfenrollrequests{$crs}{'section'};
- if ($usec eq '') {
- $usec = &mt('No section');
- }
- $r->print(&Apache::loncommon::start_data_table_row().
- ''.&Apache::lonlocal::locallocaltime($item).' '.
- ''.$courseinfo{'description'}.' '.
- ''.$rolename.' '.$usec.' '.
- &Apache::loncommon::end_data_table_row());
+sub requestcourse_advice {
+ 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,$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')) {
+ 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}}));
+ $output .=
+ ''.&mt('Request creation of a course or community').'
'.
+ ''.
+ $output.
+ '
'.
+ &mt('Use the [_1]request form[_2] to submit a request for creation of a new course or community.',
+ '','').
+ '