version 1.271, 2012/08/14 17:35:04
|
version 1.273, 2012/08/15 16:56:52
|
Line 225 sub handler {
|
Line 225 sub handler {
|
$updateresult .= &update_session_roles(); |
$updateresult .= &update_session_roles(); |
&Apache::lonnet::appenv({'user.update.time' => $now}); |
&Apache::lonnet::appenv({'user.update.time' => $now}); |
$update = $now; |
$update = $now; |
&reqauthor_check(); |
&Apache::loncoursequeueadmin::reqauthor_check(); |
} |
} |
|
|
# -------------------------------------------------- Check for author requests |
# -------------------------------------------------- Check for author requests |
|
|
my $reqauthor; |
my $reqauthor; |
if ($env{'form.requestauthor'}) { |
if ($env{'form.requestauthor'}) { |
if ($env{'environment.canrequest.author'}) { |
$reqauthor = &Apache::loncoursequeueadmin::process_reqauthor(\$update); |
unless (&is_active_author()) { |
|
my $queued = &reqauthor_check(); |
|
my $skipreq; |
|
if ($queued =~ /^approval:\d+$/) { |
|
my ($status,$timestamp) = split(/:/,$env{'environment.requestauthorqueued'}); |
|
if ($status eq 'approval') { |
|
$reqauthor = '<span class="LC_info">'. |
|
&mt('A request for authoring space submitted on [_1] is awaiting approval', |
|
&Apache::lonlocal::locallocaltime($timestamp)). |
|
'</span>'; |
|
} |
|
$skipreq = 1; |
|
} elsif ($queued =~ /^approved:\d+$/) { |
|
my %roleshash = &Apache::lonnet::get_my_roles($env{'user.name'},$env{'user.domain'},'userroles', |
|
['active'],['au'],[$env{'user.domain'}]); |
|
if (keys(%roleshash) > 0) { |
|
$skipreq = 1; |
|
} |
|
} |
|
unless ($skipreq) { |
|
my (@inststatuses,%domconfig); |
|
%domconfig = |
|
&Apache::lonnet::get_dom('configuration', |
|
['requestauthor'],$env{'user.domain'}); |
|
my $val = &Apache::loncoursequeueadmin::get_processtype('requestauthor',$env{'user.name'}, |
|
$env{'user.domain'},$env{'user.adv'}, |
|
$env{'user.domain'},undef, |
|
\@inststatuses,\%domconfig); |
|
if ($val eq 'automatic') { |
|
my $start = $now-1; |
|
if (&Apache::lonnet::assignrole($env{'user.domain'},$env{'user.name'},'/'.$env{'user.domain'}.'/', |
|
'au',undef,$start,undef,undef,'requestauthor') eq 'ok') { |
|
$reqauthor = '<span class="LC_info">'. |
|
&mt('Access to authoring space has been activated').'</span><br />'; |
|
&update_session_roles(); |
|
&Apache::lonnet::appenv({'user.update.time' => $now}); |
|
$update = $now; |
|
} else { |
|
$reqauthor = '<span class="LC_info">'. |
|
&mt('An error occurred while activating your access to authoring space'); |
|
} |
|
} elsif ($val eq 'approval') { |
|
my $domconfiguser = &Apache::lonnet::get_domainconfiguser($env{'user.domain'}); |
|
if (&Apache::lonnet::put('requestauthorqueue',{ $env{'user.name'}.'_'.$val => $now }, |
|
$env{'user.domain'},$domconfiguser) eq 'ok') { |
|
my %userrequest = ( |
|
author => { |
|
timestamp => $now, |
|
status => $val, |
|
}, |
|
author_status => $val, |
|
); |
|
my $req_notifylist; |
|
if (ref($domconfig{'requestauthor'}) eq 'HASH') { |
|
if (ref($domconfig{'requestauthor'}{'notify'}) eq 'HASH') { |
|
my $req_notifylist = $domconfig{'requestauthor'}{'notify'}{'approval'}; |
|
if ($req_notifylist) { |
|
my $fullname = &Apache::loncommon::plainname($env{'user.name'}, |
|
$env{'user.domain'}); |
|
my $sender = $env{'user.name'}.':'.$env{'user.domain'}; |
|
my $domdesc = &Apache::lonnet::domain($env{'user.domain'},'description'); |
|
&Apache::loncoursequeueadmin::send_selfserve_notification($req_notifylist, |
|
"$fullname ($env{'user.name'}:$env{'user.domain'})",undef,$domdesc, |
|
$now,'authorreq',$sender); |
|
} |
|
} |
|
} |
|
my $userresult = |
|
&Apache::lonnet::put('requestauthor',\%userrequest,$env{'user.domain'},$env{'user.name'}); |
|
$reqauthor = '<span class="LC_info">'. |
|
&mt('Your request for authoring space has been submitted for approval.'). |
|
'</span>'; |
|
&Apache::lonnet::appenv({'environment.requestauthorqueued' => $val.':'.$now}); |
|
} else { |
|
$reqauthor = '<span class="LC_info">'. |
|
&mt('An error occurred saving your request for authoring space.'). |
|
'</span>'; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
} |
|
|
my $envkey; |
my $envkey; |
Line 882 ENDHEADER
|
Line 799 ENDHEADER
|
my ($requestauthor,$requestcrs); |
my ($requestauthor,$requestcrs); |
unless ($reqauthor) { |
unless ($reqauthor) { |
if ($env{'environment.canrequest.author'}) { |
if ($env{'environment.canrequest.author'}) { |
unless (&is_active_author()) { |
unless (&Apache::loncoursequeueadmin::is_active_author()) { |
my ($status,$timestamp) = split(/:/,$env{'environment.requestauthorqueued'}); |
my ($status,$timestamp) = split(/:/,$env{'environment.requestauthorqueued'}); |
if ($status eq 'approval') { |
if ($status eq 'approval') { |
$requestauthor = &mt('A request for authoring space submitted on [_1] is awaiting approval',&Apache::lonlocal::locallocaltime($timestamp)); |
$requestauthor = &mt('A request for authoring space submitted on [_1] is awaiting approval',&Apache::lonlocal::locallocaltime($timestamp)); |
Line 1132 ENDHEADER
|
Line 1049 ENDHEADER
|
return OK; |
return OK; |
} |
} |
|
|
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 $queued; |
|
} |
|
|
|
sub gather_roles { |
sub gather_roles { |
my ($update,$refresh,$now,$reinit,$nochoose,$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 ($countactive,$countfuture,$inrole,$possiblerole) = (0,0,0,''); |