');
}
$r->print(&Apache::loncommon::end_page());
return OK;
}
-sub roles_from_env {
- my ($roleshash,$update) = @_;
- my $count = 0;
- if (ref($roleshash) eq 'HASH') {
- foreach my $envkey (keys(%env)) {
- if ($envkey =~ m{^user\.role\.(\w+)[./]}) {
- next if ($1 eq 'gr');
- $roleshash->{$envkey} = $env{$envkey};
- my ($start,$end) = split(/\./,$env{$envkey});
- unless ($end && $end<$update) {
- $count ++;
- }
- }
+sub is_active_author {
+ if ($env{'user.role.au./'.$env{'user.domain'}.'/'} =~ /^(\d*)\.(\d*)$/) {
+ if ((!$1 || $1 < time) &&
+ (!$2 || $2 > time)) {
+ return 1;
}
}
- return $count;
+ return;
+}
+
+sub reqauthor_check {
+ my $queued = $env{'environment.requestauthorqueued'};
+ my %reqauthor = &Apache::lonnet::get('requestauthor',['author_status','author'],
+ $env{'user.domain'},$env{'user.name'});
+ my $reqstatus = $reqauthor{'author_status'};
+ if (($reqstatus eq '' && $queued ne '') ||
+ ($env{'environment.requestauthorqueued'} !~ /^\Q$reqstatus\E/)) {
+ if (ref($reqauthor{'author'}) eq 'HASH') {
+ $queued = $reqstatus.':'.$reqauthor{'author'}{'timestamp'};
+ } else {
+ undef($queued);
+ }
+ &Apache::lonnet::appenv({'environment.requestauthorqueued' => $queued});
+ }
+ return $queued;
}
sub gather_roles {
- my ($update,$refresh,$now,$reinit,$nochoose,$roles_in_env,$roletext,$sortrole,$roleclass,$futureroles,
- $timezones,$loncaparev) = @_;
+ my ($update,$refresh,$now,$reinit,$nochoose,$roletext,$sortrole,$roleclass,$futureroles,$timezones,$loncaparev) = @_;
my ($countactive,$countfuture,$inrole,$possiblerole) = (0,0,0,'');
my $advanced = $env{'user.adv'};
my $tryagain = $env{'form.tryagain'};
my @ids = &Apache::lonnet::current_machine_ids();
- if (ref($roles_in_env) eq 'HASH') {
- my %adhocdesc;
- foreach my $envkey (sort(keys(%{$roles_in_env}))) {
- my $button = 1;
- my $switchserver='';
- my $switchwarning;
- my ($role_text,$role_text_end,$sortkey,$role,$where,$trolecode,$tstart,
- $tend,$tremark,$tstatus,$tpstart,$tpend);
+ foreach my $envkey (sort(keys(%env))) {
+ my $button = 1;
+ my $switchserver='';
+ my $switchwarning;
+ my ($role_text,$role_text_end,$sortkey);
+ if ($envkey=~/^user\.role\./) {
+ my ($role,$where,$trolecode,$tstart,$tend,$tremark,$tstatus,$tpstart,$tpend);
&Apache::lonnet::role_status($envkey,$update,$refresh,$now,\$role,\$where,
\$trolecode,\$tstatus,\$tstart,\$tend);
next if (!defined($role) || $role eq '' || $role =~ /^gr/);
@@ -1232,7 +1184,7 @@ sub gather_roles {
if (($tstatus eq 'is')
|| ($tstatus eq 'selected')
|| ($tstatus eq 'future')
- || ($env{'form.display'} eq 'showall')) {
+ || ($env{'form.showall'})) {
my $timezone = &role_timezone($where,$timezones);
if ($tstart) {
$tpstart=&Apache::lonlocal::locallocaltime($tstart,$timezone);
@@ -1264,10 +1216,8 @@ sub gather_roles {
my $trole;
if ($role =~ /^cr\//) {
my ($rdummy,$rdomain,$rauthor,$rrole)=split(/\//,$role);
- unless ($rauthor eq $rdomain.'-domainconfig') {
- if ($tremark) { $tremark.=' '; }
- $tremark.=&mt('Custom role defined by [_1].',$rauthor.':'.$rdomain);
- }
+ if ($tremark) { $tremark.=' '; }
+ $tremark.=&mt('Customrole defined by [_1].',$rauthor.':'.$rdomain);
}
$trole=Apache::lonnet::plaintext($role);
my $ttype;
@@ -1285,7 +1235,7 @@ sub gather_roles {
}
#next if ($home eq 'no_host');
$home = &Apache::lonnet::hostname($home);
- $ttype='Authoring Space';
+ $ttype='Construction Space';
$twhere=&mt('User').': '.$trest.' '.&mt('Domain').
': '.$tdom.' '.
' '.&mt('Server').': '.$home;
@@ -1304,7 +1254,7 @@ sub gather_roles {
}
#next if ($home eq 'no_host');
$home = &Apache::lonnet::hostname($home);
- $ttype='Authoring Space';
+ $ttype='Construction Space';
$twhere=&mt('Domain').': '.$tdom.' '.&mt('Server').
': '.$home;
$env{'course.'.$tdom.'_'.$trest.'.description'}='ca';
@@ -1313,32 +1263,7 @@ sub gather_roles {
} elsif ($trest) {
my $tcourseid=$tdom.'_'.$trest;
$ttype = &Apache::loncommon::course_type($tcourseid);
- if ($role !~ /^cr/) {
- $trole = &Apache::lonnet::plaintext($role,$ttype,$tcourseid);
- } elsif ($role =~ m{^\Qcr/$tdom/$tdom\E\-domainconfig/(\w+)$}) {
- my $rolename = $1;
- my $desc;
- if (ref($adhocdesc{$tdom}) eq 'HASH') {
- $desc = $adhocdesc{$tdom}{$rolename};
- } else {
- my %domdef = &Apache::lonnet::get_domain_defaults($tdom);
- if (ref($domdef{'adhocroles'}) eq 'HASH') {
- 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};
- }
- }
- }
- }
- if ($desc ne '') {
- $trole = $desc;
- } else {
- $trole = &mt('Helpdesk[_1]',' '.$rolename);
- }
- } else {
- $trole = (split(/\//,$role,4))[-1];
- }
+ $trole = &Apache::lonnet::plaintext($role,$ttype,$tcourseid);
if ($env{'course.'.$tcourseid.'.description'}) {
my $home=$env{'course.'.$tcourseid.'.home'};
$twhere=$env{'course.'.$tcourseid.'.description'};
@@ -1352,7 +1277,7 @@ sub gather_roles {
my $required = $env{'course.'.$tcourseid.'.internal.releaserequired'};
if ($required ne '') {
($switchserver,$switchwarning) =
- &Apache::loncommon::check_release_required($loncaparev,$tcourseid,$trolecode,$required);
+ &check_release_required($loncaparev,$tcourseid,$trolecode,$required);
if ($switchserver || $switchwarning) {
$button = 0;
}
@@ -1375,7 +1300,7 @@ sub gather_roles {
my $required = $newhash{'internal.releaserequired'};
if ($required ne '') {
($switchserver,$switchwarning) =
- &Apache::loncommon::check_release_required($loncaparev,$tcourseid,$trolecode,$required);
+ &check_release_required($loncaparev,$tcourseid,$trolecode,$required);
if ($switchserver || $switchwarning) {
$button = 0;
}
@@ -1476,7 +1401,7 @@ sub roletable_headers {
my $doheaders;
if ((ref($sortrole) eq 'HASH') && (ref($roleclass) eq 'HASH')) {
$r->print(' '
- .&Apache::loncommon::start_data_table('LC_textsize_mobile')
+ .&Apache::loncommon::start_data_table()
.&Apache::loncommon::start_data_table_header_row()
);
if (!$nochoose) { $r->print('
'); }
@@ -1502,12 +1427,12 @@ sub roletable_headers {
}
sub roletypes {
- my @types = ('Domain','Authoring Space','Course','Community','Unavailable','System');
+ my @types = ('Domain','Construction Space','Course','Community','Unavailable','System');
return @types;
}
sub print_rolerows {
- my ($r,$doheaders,$roleclass,$sortrole,$dcroles,$roletext,$update,$then) = @_;
+ my ($r,$doheaders,$roleclass,$sortrole,$dcroles,$roletext) = @_;
if ((ref($roleclass) eq 'HASH') && (ref($sortrole) eq 'HASH')) {
my @types = &roletypes();
foreach my $type (@types) {
@@ -1525,14 +1450,12 @@ sub print_rolerows {
&Apache::loncommon::end_data_table_row();
}
}
- if ($sortrole->{$which} =~ m{^user\.role\.dc\./($match_domain)/}) {
+ if ($sortrole->{$which} =~ m-dc\./($match_domain)/-) {
if (ref($dcroles) eq 'HASH') {
if ($dcroles->{$1}) {
$output .= &adhoc_roles_row($1,'');
}
}
- } elsif ($sortrole->{$which} =~ m{^user\.role\.(dh|da)\./($match_domain)/}) {
- $output .= &adhoc_customroles_row($1,$2,'',$update,$then);
}
}
}
@@ -1553,57 +1476,52 @@ sub print_rolerows {
}
sub findcourse_advice {
- my ($r,$cattype,$elapsed) = @_;
+ my ($r) = @_;
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'})) {
- $r->print('
'.&mt('If you were expecting to see an active role listed for a particular course in the [_1] domain, it may be missing for one of the following reasons:',$domdesc).'
+ $r->print(&mt('If you were expecting to see an active role listed for a particular course in the [_1] domain, it may be missing for one of the following reasons:',$domdesc).'
'.&mt('The course has yet to be created.').'
'.&mt('Automatic enrollment of registered students has not been enabled for the course.').'
'.&mt('You are in a section of course for which automatic enrollment in the corresponding LON-CAPA course is not active.').'
'.&mt('The start date for automated enrollment has yet to be reached.').'
'.&mt('You registered for the course recently and there is a time lag between the time you register, and the time this information becomes available for the update of LON-CAPA course rosters.').'
-
'.&mt('Automated enrollment added you to the course in the time since you last logged-in.').' '.&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.').'
-
');
+ ');
} 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.').'
');
- 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.').
- ' '.
- &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.').'
'.&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());
+ $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());
return;
}
sub requestcourse_advice {
- my ($r,$cattype,$inrole,$elapsed) = @_;
+ my ($r) = @_;
my $domdesc = &Apache::lonnet::domain($env{'user.domain'},'description');
my $esc_dom = &HTML::Entities::encode($env{'user.domain'},'"<>&');
- my (%can_request,%request_doms,$output);
+ my (%can_request,%request_doms);
&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}}));
- $output .=
+ $r->print(
'
'
.&mt('[_1]'.$typename->{$type}.'[_2] in domain: [_3]',
'',
'',
''.$domstr.'')
- .'
'.&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):').
- '
'.
- $output.
- '
'.
- &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').'
');
+ }
+ $r->print('
'.&mt('Use the [_1]request form[_2] to submit a request for creation of a new course or community.','','').'');
}
- &findcourse_advice($r,$cattype,$elapsed);
}
return;
}
@@ -1665,7 +1566,7 @@ sub privileges_info {
my (undef,$tdom,$trest,$tsec)=split(m{/},$where);
if ($trest) {
if ($env{'course.'.$tdom.'_'.$trest.'.description'} eq 'ca') {
- $ttype='Authoring Space';
+ $ttype='Construction Space';
$twhere='User: '.$trest.', Domain: '.$tdom;
} else {
$ttype= &Apache::loncommon::course_type($tdom.'_'.$trest);
@@ -1706,13 +1607,10 @@ sub privileges_info {
}
sub build_roletext {
- my ($trolecode,$tdom,$trest,$tstatus,$tryagain,$advanced,$tremark,$tbg,$trole,$twhere,
- $tpstart,$tpend,$nochoose,$button,$switchserver,$reinit,$switchwarning) = @_;
- my ($roletext,$roletext_end,$poss_adhoc);
- if ($trolecode =~ m/^d(c|h|a)\./) {
- $poss_adhoc = 1;
- }
- my $rowspan=($poss_adhoc) ? ''
+ my ($trolecode,$tdom,$trest,$tstatus,$tryagain,$advanced,$tremark,$tbg,$trole,$twhere,$tpstart,$tpend,$nochoose,$button,$switchserver,$reinit,$switchwarning) = @_;
+ my ($roletext,$roletext_end);
+ my $is_dc=($trolecode =~ m/^dc\./);
+ my $rowspan=($is_dc) ? ''
: ' rowspan="2" ';
unless ($nochoose) {
@@ -1773,7 +1671,7 @@ sub build_roletext {
.'