');
}
if (($ENV{'REDIRECT_QUERY_STRING'}) && ($fn)) {
$fn.='?'.$ENV{'REDIRECT_QUERY_STRING'};
}
- my $display = ($env{'form.display'} =~ /^(showall)$/);
$r->print('');
if ($countfuture) {
$r->print(&mt('The following [quant,_1,role,roles] will become active in the future:',$countfuture));
@@ -1083,38 +1049,46 @@ ENDHEADER
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;
+}
+
+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 $count;
+ 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') {
- 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/);
@@ -1128,7 +1102,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);
@@ -1161,7 +1135,7 @@ sub gather_roles {
if ($role =~ /^cr\//) {
my ($rdummy,$rdomain,$rauthor,$rrole)=split(/\//,$role);
if ($tremark) { $tremark.=' '; }
- $tremark.=&mt('Custom role defined by [_1].',$rauthor.':'.$rdomain);
+ $tremark.=&mt('Customrole defined by [_1].',$rauthor.':'.$rdomain);
}
$trole=Apache::lonnet::plaintext($role);
my $ttype;
@@ -1179,7 +1153,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;
@@ -1198,7 +1172,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';
@@ -1371,7 +1345,7 @@ 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;
}
@@ -1420,7 +1394,7 @@ sub print_rolerows {
}
sub findcourse_advice {
- my ($r,$cattype) = @_;
+ 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'})) {
@@ -1435,36 +1409,37 @@ 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.').' ');
}
- 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.').'
'.&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) = @_;
+ 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.'')
- .'
';
if (&Apache::loncommon::show_course()) {
$msg .= &mt('Your role in the current course has expired.');
} else {
$msg .= &mt('Your current role has expired.');
}
- $msg .= ' '.&mt('However you can continue to use this role until you logout, click the "Re-Select" button, or your session has been idle for more than 24 hours.').'';
- }
- &Apache::lonnet::set_userprivs(\%userroles,\%allroles,\%allgroups,\%groups_roles);
- my ($curr_is_adv,$curr_role_adv,$curr_author,$curr_role_author);
- $curr_author = $env{'user.author'};
- if (($env{'request.role'} =~/^au/) || ($env{'request.role'} =~/^ca/) ||
- ($env{'request.role'} =~/^aa/)) {
- $curr_role_author=1;
- }
- $curr_is_adv = $env{'user.adv'};
- $curr_role_adv = $env{'request.role.adv'};
- if (keys(%userroles) > 0) {
- foreach my $role (@changed_roles) {
- unless(grep(/^\Q$role\E$/,@rolecodes)) {
- push(@rolecodes,$role);
- }
- }
- unless(grep(/^\Qcm\E$/,@rolecodes)) {
- push(@rolecodes,'cm');
- }
- &Apache::lonnet::appenv(\%userroles,\@rolecodes);
- }
- my %newenv;
- if (&Apache::lonnet::is_advanced_user($env{'user.domain'},$env{'user.name'})) {
- unless ($curr_is_adv) {
- $newenv{'user.adv'} = 1;
- }
- } elsif ($curr_is_adv && !$curr_role_adv) {
- &Apache::lonnet::delenv('user.adv');
- }
- my %authorroleshash =
- &Apache::lonnet::get_my_roles('','','userroles',['active'],['au','ca','aa']);
- if (keys(%authorroleshash)) {
- unless ($curr_author) {
- $newenv{'user.author'} = 1;
- }
- } elsif ($curr_author && !$curr_role_author) {
- &Apache::lonnet::delenv('user.author');
- }
- if ($env{'request.course.id'}) {
- my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
- my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
- my (@activecrsgroups,$crsgroupschanged);
- if ($env{'request.course.groups'}) {
- @activecrsgroups = split(/:/,$env{'request.course.groups'});
- foreach my $item (keys(%deletedroles)) {
- if ($item =~ m{^gr\./\Q$cdom\E/\Q$cnum\E/(\w+)$}) {
- if (grep(/^\Q$1\E$/,@activecrsgroups)) {
- $crsgroupschanged = 1;
- last;
- }
- }
- }
- }
- unless ($crsgroupschanged) {
- foreach my $item (keys(%newgroup)) {
- if ($item =~ m{^gr\./\Q$cdom\E/\Q$cnum\E/(\w+)$}) {
- if ($newgroup{$item} eq 'active') {
- $crsgroupschanged = 1;
- last;
- }
- }
- }
- }
- if ((ref($changed_groups{$env{'request.course.id'}}) eq 'HASH') ||
- (ref($groupchange{"/$cdom/$cnum"}) eq 'HASH') ||
- ($crsgroupschanged)) {
- my %grouproles = &Apache::lonnet::get_my_roles('','','userroles',
- ['active'],['gr'],[$cdom],1);
- my @activegroups;
- foreach my $item (keys(%grouproles)) {
- next unless($item =~ /^\Q$cnum\E:\Q$cdom\E/);
- my $group;
- my ($crsn,$crsd,$role,$remainder) = split(/:/,$item,4);
- if ($remainder =~ /:/) {
- (my $other,$group) = ($remainder =~ /^([\w:]+):([^:]+)$/);
- } else {
- $group = $remainder;
- }
- if ($group ne '') {
- push(@activegroups,$group);
- }
- }
- $newenv{'request.course.groups'} = join(':',@activegroups);
- }
- }
- if (keys(%newenv)) {
- &Apache::lonnet::appenv(\%newenv);
+ $msg .= ' '.&mt('However you can continue to use this role until you logout, click the "Re-Select" button, or your session has been idle for more than 24 hours.').'
';
}
if (!@changed_roles || !(keys(%changed_groups))) {
my ($rolesmsg,$groupsmsg);
@@ -2435,43 +2313,11 @@ sub update_session_roles {
if (@changed_roles > 0) {
if (keys(%newgroup) > 0) {
my $groupmsg;
- my (%curr_groups,%groupdescs,$currcrs);
foreach my $item (sort(keys(%newgroup))) {
if (&is_active_course($item,$refresh,$update,\%roleshash)) {
- if ($item =~ m{^gr\./($match_domain/$match_courseid)/(\w+)$}) {
- my ($cdom,$cnum) = split(/\//,$1);
- my $group = $2;
- if ($currcrs ne $cdom.'_'.$cnum) {
- if ($currcrs) {
- $groupmsg .= '
';
- }
- if ($env{'environment.canrequest.author'}) {
- unless (&Apache::loncoursequeueadmin::is_active_author()) {
- my $requestauthor;
- my ($status,$timestamp) = split(/:/,$env{'environment.requestauthorqueued'});
- if (($status eq 'approval') || ($status eq 'approved')) {
- $output .= '
'.&mt('Author role request').' ';
- if ($status eq 'approval') {
- $output .= &mt('A request for Authoring Space submitted on [_1] is awaiting approval',
- &Apache::lonlocal::locallocaltime($timestamp));
- } elsif ($status eq 'approved') {
- my %roleshash =
- &Apache::lonnet::get_my_roles($env{'user.name'},$env{'user.domain'},'userroles',
- ['active'],['au'],[$env{'user.domain'}]);
- if (keys(%roleshash)) {
- $output .= ''.
- &mt('Your request for an author role has been approved.').' '.
- &mt('Use the "Check for changes" link to update your list of roles.').
- '';
- }
- }
- $output .= '