version 1.30, 2012/08/14 15:45:06
|
version 1.31, 2012/08/15 14:37:13
|
Line 70 described at http://www.lon-capa.org.
|
Line 70 described at http://www.lon-capa.org.
|
|
|
=item process_official_reqs() |
=item process_official_reqs() |
|
|
|
=item is_active_author() |
|
|
|
=item author_prompt() |
|
|
|
=item reqauthor_check() |
|
|
|
=item process_reqauthor() |
|
|
=back |
=back |
|
|
=cut |
=cut |
Line 101 sub send_selfserve_notification {
|
Line 109 sub send_selfserve_notification {
|
} elsif ($context eq 'domainmanagers') { |
} elsif ($context eq 'domainmanagers') { |
$rawsubj = 'Course/Community requests reviewed'; |
$rawsubj = 'Course/Community requests reviewed'; |
push(@rawmsg,{ |
push(@rawmsg,{ |
mt => 'Course/Community creation requests in the following domain: [_1] have been reviewed.', |
mt => 'Course/Community creation requests in the following domain: "[_1]" have been reviewed.', |
args => ["\n$contextdesc"], |
args => ["\n$contextdesc"], |
}); |
}); |
if (ref($textstr) eq 'ARRAY') { |
if (ref($textstr) eq 'ARRAY') { |
Line 110 sub send_selfserve_notification {
|
Line 118 sub send_selfserve_notification {
|
} elsif ($context eq 'authormanagers') { |
} elsif ($context eq 'authormanagers') { |
$rawsubj = 'Authoring space requests reviewed'; |
$rawsubj = 'Authoring space requests reviewed'; |
push(@rawmsg,{ |
push(@rawmsg,{ |
mt => 'Authoring requests in the following domain: [_1] have been reviewed.', |
mt => 'Authoring requests in the following domain: "[_1]" have been reviewed.', |
args => ["\n$contextdesc"], |
args => ["\n$contextdesc"], |
}); |
}); |
if (ref($textstr) eq 'ARRAY') { |
if (ref($textstr) eq 'ARRAY') { |
Line 170 sub send_selfserve_notification {
|
Line 178 sub send_selfserve_notification {
|
}, |
}, |
{ |
{ |
mt =>'[_1]As Domain Coordinator, use: [_2]Main Menu -> Course and community creation -> Approve or reject requests[_3]to display a list of pending requests, which you can either approve or reject.', |
mt =>'[_1]As Domain Coordinator, use: [_2]Main Menu -> Course and community creation -> Approve or reject requests[_3]to display a list of pending requests, which you can either approve or reject.', |
args => ["\n","\n\n ","\n\n"], |
args => ["\n","\n\n","\n\n"], |
}); |
}); |
} elsif ($context eq 'selfenrollreq') { |
} elsif ($context eq 'selfenrollreq') { |
$rawsubj = 'Self-enrollment request'; |
$rawsubj = 'Self-enrollment request'; |
if ($crstype eq 'community') { |
if ($crstype eq 'community') { |
$msgtxt = 'Enrollment in the following community: [_1] was requested by [_2] on [_3].' |
$msgtxt = 'Enrollment in the following community: [_1]was requested by [_2] on [_3].' |
} else { |
} else { |
$msgtxt = 'Enrollment in the following course: [_1] was requested by [_2] on [_3].' |
$msgtxt = 'Enrollment in the following course: [_1]was requested by [_2] on [_3].' |
} |
} |
push(@rawmsg,{ |
push(@rawmsg,{ |
mt => $msgtxt, |
mt => $msgtxt, |
Line 196 sub send_selfserve_notification {
|
Line 204 sub send_selfserve_notification {
|
}); |
}); |
} elsif ($context eq 'authorreq') { |
} elsif ($context eq 'authorreq') { |
$rawsubj = 'Authoring space request to review'; |
$rawsubj = 'Authoring space request to review'; |
$msgtxt = 'Assignment of an author role in the [_1] domain[_2] was requested by [_3] on [_4].'; |
$msgtxt = 'Assignment of an author role in the [_1] domain[_2]was requested by [_3] on [_4].'; |
push(@rawmsg,{ |
push(@rawmsg,{ |
mt => $msgtxt, |
mt => $msgtxt, |
args => [$contextdesc,"\n",$textstr,$timestamp], |
args => [$contextdesc,"\n",$textstr,$timestamp], |
Line 1781 sub process_official_reqs {
|
Line 1789 sub process_official_reqs {
|
} |
} |
} |
} |
return $output; |
return $output; |
|
} |
|
|
|
sub is_active_author { |
|
if ($env{'user.role.au./'.$env{'user.domain'}.'/'} =~ /^(\d*)\.(\d*)$/) { |
|
if ((!$1 || $1 < time) && |
|
(!$2 || $2 > time)) { |
|
return 1; |
|
} |
|
} |
|
} |
|
|
|
sub author_prompt { |
|
my ($is_active_author,$offer_author); |
|
if ($env{'environment.canrequest.author'}) { |
|
unless (&is_active_author()) { |
|
if ($env{'environment.canrequest.author'}) { |
|
unless (&reqauthor_check() =~ /^approval:\d+$/) { |
|
$offer_author = 1; |
|
} |
|
} |
|
} |
|
} |
|
return $offer_author; |
|
} |
|
|
|
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 process_reqauthor { |
|
my ($dispositionref,$updateref) = @_; |
|
if (&is_active_author()) { |
|
return '<span class="LC_warning">'. |
|
&mt('An authoring space has already been assigned to you.').'<br />'. |
|
&mt('Please select the Author role from your [_1]roles page[_2].','<a href="/adm/roles">', |
|
'</a>').'</span>'; |
|
} |
|
unless ($env{'environment.canrequest.author'}) { |
|
return '<span class="LC_warning">'. |
|
&mt('You do not currently have rights to request an authoring space.').'<br />'. |
|
&mt('Please contact the [_1]helpdesk[_2].','<a href="/adm/helpdesk">', |
|
'</a>').'</span>'; |
|
} |
|
my $queued = &reqauthor_check(); |
|
if ($queued =~ /^approval:(\d+)$/) { |
|
my $timestamp = $1; |
|
return '<span class="LC_info">'. |
|
&mt('A request for authoring space submitted on [_1] is awaiting approval', |
|
&Apache::lonlocal::locallocaltime($timestamp)). |
|
'</span>'; |
|
} elsif ($queued =~ /^approved:(\d+)$/) { |
|
my $timestamp = $1; |
|
my %roleshash = &Apache::lonnet::get_my_roles($env{'user.name'},$env{'user.domain'},'userroles', |
|
['active'],['au'],[$env{'user.domain'}]); |
|
if (keys(%roleshash) > 0) { |
|
return '<span class="LC_info">'. |
|
&mt('A request for authoring space submitted on [_1] has been approved.', |
|
&Apache::lonlocal::locallocaltime($timestamp)). |
|
'</span>'; |
|
} |
|
} |
|
my ($output,@inststatuses,%domconfig); |
|
%domconfig = &Apache::lonnet::get_dom('configuration',['requestauthor'], |
|
$env{'user.domain'}); |
|
my $val = &get_processtype('requestauthor',$env{'user.name'},$env{'user.domain'}, |
|
$env{'user.adv'},$env{'user.domain'},undef, |
|
\@inststatuses,\%domconfig); |
|
my $now = time; |
|
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') { |
|
$output = '<span class="LC_info">'. |
|
&mt('Access to authoring space has been activated').'</span><br />'; |
|
&Apache::lonroles::update_session_roles(); |
|
&Apache::lonnet::appenv({'user.update.time' => $now}); |
|
if (ref($updateref)) { |
|
$$updateref = $now; |
|
} |
|
if (ref($dispositionref)) { |
|
$$dispositionref = 'created'; |
|
} |
|
} else { |
|
$output = '<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'); |
|
&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'}); |
|
$output = '<span class="LC_info">'. |
|
&mt('Your request for authoring space has been submitted for approval.'). |
|
'</span>'; |
|
&Apache::lonnet::appenv({'environment.requestauthorqueued' => $val.':'.$now}); |
|
} else { |
|
$output = '<span class="LC_info">'. |
|
&mt('An error occurred saving your request for authoring space.'). |
|
'</span>'; |
|
} |
|
} |
|
return $output; |
} |
} |
|
|
1; |
1; |