[LON-CAPA-cvs] cvs: loncom /auth lonroles.pm /interface domainprefs.pm loncommon.pm loncoursequeueadmin.pm loncreateuser.pm lonrequestcourse.pm /lonnet/perl lonnet.pm
raeburn
raeburn at source.lon-capa.org
Tue Aug 14 11:45:35 EDT 2012
raeburn Tue Aug 14 15:45:35 2012 EDT
Modified files:
/loncom/interface domainprefs.pm loncommon.pm
loncoursequeueadmin.pm loncreateuser.pm
lonrequestcourse.pm
/loncom/auth lonroles.pm
/loncom/lonnet/perl lonnet.pm
Log:
- Add ability for users to request creation of an author role in their
domain, if they do not already have an active author role.
- Domain defaults can be assigned based on institutional status.
- Defaults can be overridden for individual users by the DC.
- Requests can either be processed automatically or queued for DC
approval.
- Notification message can be sent to DCs when queued for approval
- Notification message sent to requester if approved/rejected.
-------------- next part --------------
Index: loncom/interface/domainprefs.pm
diff -u loncom/interface/domainprefs.pm:1.162 loncom/interface/domainprefs.pm:1.163
--- loncom/interface/domainprefs.pm:1.162 Fri Jun 1 11:39:24 2012
+++ loncom/interface/domainprefs.pm Tue Aug 14 15:45:06 2012
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: domainprefs.pm,v 1.162 2012/06/01 11:39:24 raeburn Exp $
+# $Id: domainprefs.pm,v 1.163 2012/08/14 15:45:06 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -86,8 +86,8 @@
$dom is the domain, $settings is a reference to a hash of current settings for
the current context, $rowtotal is a reference to the scalar used to record the
-number of rows displayed on the page, and $action is the context (either quotas
-or requestcourses).
+number of rows displayed on the page, and $action is the context (quotas,
+requestcourses or requestauthor).
The print_quotas routine was orginally created to display/store information
about default quota sizes for portfolio spaces for the different types of
@@ -211,11 +211,13 @@
'directorysrch','usercreation','usermodification',
'contacts','defaults','scantron','coursecategories',
'serverstatuses','requestcourses','helpsettings',
- 'coursedefaults','usersessions','loadbalancing'],$dom);
+ 'coursedefaults','usersessions','loadbalancing',
+ 'requestauthor'],$dom);
my @prefs_order = ('rolecolors','login','defaults','quotas','autoenroll',
'autoupdate','autocreate','directorysrch','contacts',
'usercreation','usermodification','scantron',
- 'requestcourses','coursecategories','serverstatuses','helpsettings',
+ 'requestcourses','requestauthor','coursecategories',
+ 'serverstatuses','helpsettings',
'coursedefaults','usersessions');
if (keys(%servers) > 1) {
push(@prefs_order,'loadbalancing');
@@ -323,6 +325,14 @@
{col1 => 'Setting',
col2 => 'Value'}],
},
+ 'requestauthor' =>
+ {text => 'Request authoring space',
+ help => 'Domain_Configuration_Request_Author',
+ header => [{col1 => 'User affiliation',
+ col2 => 'Availability/Processing of requests',},
+ {col1 => 'Setting',
+ col2 => 'Value'}],
+ },
'coursecategories' =>
{ text => 'Cataloging of courses/communities',
help => 'Domain_Configuration_Cataloging_Courses',
@@ -487,6 +497,8 @@
$output = &modify_serverstatuses($dom,%domconfig);
} elsif ($action eq 'requestcourses') {
$output = &modify_quotas($dom,$action,%domconfig);
+ } elsif ($action eq 'requestauthor') {
+ $output = &modify_quotas($dom,$action,%domconfig);
} elsif ($action eq 'helpsettings') {
$output = &modify_helpsettings($r,$dom,$confname,%domconfig);
} elsif ($action eq 'coursedefaults') {
@@ -549,6 +561,8 @@
$colspan = ' colspan="2"';
} elsif ($action eq 'requestcourses') {
$output .= &print_quotas($dom,$settings,\$rowtotal,$action);
+ } elsif ($action eq 'requestauthor') {
+ $output .= &print_quotas($dom,$settings,\$rowtotal,$action);
} elsif ($action eq 'helpsettings') {
$output .= &print_helpsettings('top',$dom,$confname,$settings,\$rowtotal);
} elsif ($action eq 'usersessions') {
@@ -615,7 +629,9 @@
} elsif ($action eq 'login') {
$output .= &print_login('bottom',$dom,$confname,$phase,$settings,\$rowtotal);
} elsif ($action eq 'requestcourses') {
- $output .= &print_courserequestmail($dom,$settings,\$rowtotal);
+ $output .= &print_requestmail($dom,$action,$settings,\$rowtotal);
+ } elsif ($action eq 'requestauthor') {
+ $output .= &print_requestmail($dom,$action,$settings,\$rowtotal);
} elsif ($action eq 'helpsettings') {
$output .= &print_helpsettings('bottom',$dom,$confname,$settings,\$rowtotal);
} elsif ($action eq 'usersessions') {
@@ -1376,6 +1392,10 @@
@options =('norequest','approval','validate','autolimit');
%validations = &Apache::lonnet::auto_courserequest_checks($dom);
%titles = &courserequest_titles();
+ } elsif ($context eq 'requestauthor') {
+ @usertools = ('author');
+ @options = ('norequest','approval','automatic');
+ %titles = &authorrequest_titles();
} else {
@usertools = ('aboutme','blog','webdav','portfolio');
%titles = &tool_titles();
@@ -1383,7 +1403,8 @@
if (ref($types) eq 'ARRAY') {
foreach my $type (@{$types}) {
my $currdefquota;
- unless ($context eq 'requestcourses') {
+ unless (($context eq 'requestcourses') ||
+ ($context eq 'requestauthor')) {
if (ref($settings) eq 'HASH') {
if (ref($settings->{defaultquota}) eq 'HASH') {
$currdefquota = $settings->{defaultquota}->{$type};
@@ -1453,6 +1474,28 @@
$cell{$item} .= $titles{'unlimited'};
}
}
+ } elsif ($context eq 'requestauthor') {
+ my $curroption;
+ if (ref($settings) eq 'HASH') {
+ $curroption = $settings->{$type};
+ }
+ if (!$curroption) {
+ $curroption = 'norequest';
+ }
+ foreach my $option (@options) {
+ my $val = $option;
+ if ($option eq 'norequest') {
+ $val = 0;
+ }
+ my $checked = '';
+ if ($option eq $curroption) {
+ $checked = ' checked="checked"';
+ }
+ $datatable .= '<span class="LC_nobreak"><label>'.
+ '<input type="radio" name="authorreq_'.$type.
+ '" value="'.$val.'"'.$checked.' />'.
+ $titles{$option}.'</label></span> ';
+ }
} else {
my $checked = 'checked="checked" ';
if (ref($settings) eq 'HASH') {
@@ -1478,7 +1521,8 @@
$datatable .= '</tr></table>';
}
$datatable .= '</td>';
- unless ($context eq 'requestcourses') {
+ unless (($context eq 'requestcourses') ||
+ ($context eq 'requestauthor')) {
$datatable .=
'<td class="LC_right_item"><span class="LC_nobreak">'.
'<input type="text" name="quota_'.$type.
@@ -1489,7 +1533,7 @@
}
}
}
- unless ($context eq 'requestcourses') {
+ unless (($context eq 'requestcourses') || ($context eq 'requestauthor')) {
$defaultquota = '20';
if (ref($settings) eq 'HASH') {
if (ref($settings->{'defaultquota'}) eq 'HASH') {
@@ -1559,6 +1603,30 @@
$defcell{$item} .= $titles{'unlimited'};
}
}
+ } elsif ($context eq 'requestauthor') {
+ my $curroption;
+ if (ref($settings) eq 'HASH') {
+ if (ref($settings->{'requestauthor'}) eq 'HASH') {
+ $curroption = $settings->{'requestauthor'};
+ }
+ }
+ if (!$curroption) {
+ $curroption = 'norequest';
+ }
+ foreach my $option (@options) {
+ my $val = $option;
+ if ($option eq 'norequest') {
+ $val = 0;
+ }
+ my $checked = '';
+ if ($option eq $curroption) {
+ $checked = ' checked="checked"';
+ }
+ $datatable .= '<span class="LC_nobreak"><label>'.
+ '<input type="radio" name="authorreq_default"'.
+ ' value="'.$val.'"'.$checked.' />'.
+ $titles{$option}.'</label></span> ';
+ }
} else {
my $checked = 'checked="checked" ';
if (ref($settings) eq 'HASH') {
@@ -1584,7 +1652,7 @@
$datatable .= '</tr></table>';
}
$datatable .= '</td>';
- unless ($context eq 'requestcourses') {
+ unless (($context eq 'requestcourses') || ($context eq 'requestauthor')) {
$datatable .= '<td class="LC_right_item"><span class="LC_nobreak">'.
'<input type="text" name="defaultquota" value="'.
$defaultquota.'" size="5" /> Mb</span></td>';
@@ -1662,6 +1730,33 @@
$advcell{$item} .= $titles{'unlimited'};
}
}
+ } elsif ($context eq 'requestauthor') {
+ my $curroption;
+ if (ref($settings) eq 'HASH') {
+ $curroption = $settings->{'_LC_adv'};
+ }
+ my $checked = '';
+ if ($curroption eq '') {
+ $checked = ' checked="checked"';
+ }
+ $datatable .= '<span class="LC_nobreak"><label>'.
+ '<input type="radio" name="authorreq__LC_adv"'.
+ ' value=""'.$checked.' />'.
+ &mt('No override set').'</label></span> ';
+ foreach my $option (@options) {
+ my $val = $option;
+ if ($option eq 'norequest') {
+ $val = 0;
+ }
+ my $checked = '';
+ if ($val eq $curroption) {
+ $checked = ' checked="checked"';
+ }
+ $datatable .= '<span class="LC_nobreak"><label>'.
+ '<input type="radio" name="crsreq_'.$item.
+ '__LC_adv" value="'.$val.'"'.$checked.' />'.
+ $titles{$option}.'</label></span> ';
+ }
} else {
my $checked = 'checked="checked" ';
if (ref($settings) eq 'HASH') {
@@ -1691,8 +1786,8 @@
return $datatable;
}
-sub print_courserequestmail {
- my ($dom,$settings,$rowtotal) = @_;
+sub print_requestmail {
+ my ($dom,$action,$settings,$rowtotal) = @_;
my ($now,$datatable,%dompersonnel, at domcoord, at currapproval,$rows);
$now = time;
$rows = 0;
@@ -1723,9 +1818,14 @@
my $numinrow = 4;
my $numdc = @domcoord;
my $css_class = 'class="LC_odd_row"';
- $datatable = '<tr'.$css_class.'>'.
- ' <td>'.&mt('Receive notification of course requests requiring approval.').
- ' </td>'.
+ my $text;
+ if ($action eq 'requestcourses') {
+ $text = &mt('Receive notification of course requests requiring approval');
+ } else {
+ $text = &mt('Receive notification of authoring space requests requiring approval')
+ }
+ $datatable = '<tr '.$css_class.'>'.
+ ' <td>'.$text.'</td>'.
' <td class="LC_left_item">';
if (@domcoord > 0) {
$datatable .= '<table>';
@@ -3028,6 +3128,15 @@
return %titles;
}
+sub authorrequest_titles {
+ my %titles = &Apache::lonlocal::texthash (
+ norequest => 'Not allowed',
+ approval => 'Approval by Dom. Coord.',
+ automatic => 'Automatic approval',
+ );
+ return %titles;
+}
+
sub courserequest_conditions {
my %conditions = &Apache::lonlocal::texthash (
approval => '(Processing of request subject to approval by Domain Coordinator).',
@@ -5211,7 +5320,7 @@
%limithash,$toolregexp,%conditions,$resulttext,%changes);
if ($action eq 'quotas') {
$context = 'tools';
- } else {
+ } else {
$context = $action;
}
if ($context eq 'requestcourses') {
@@ -5221,6 +5330,9 @@
%titles = &courserequest_titles();
$toolregexp = join('|', at usertools);
%conditions = &courserequest_conditions();
+ } elsif ($context eq 'requestauthor') {
+ @usertools = ('author');
+ %titles = &authorrequest_titles();
} else {
@usertools = ('aboutme','blog','webdav','portfolio');
%titles = &tool_titles();
@@ -5238,6 +5350,10 @@
$confhash{$item}{$type} = $env{$key};
}
}
+ } elsif ($context eq 'requestauthor') {
+ if ($key =~ /^\Qform.authorreq_\E(.+)$/) {
+ $confhash{$1} = $env{$key};
+ }
} else {
if ($key =~ /^form\.quota_(.+)$/) {
$confhash{'defaultquota'}{$1} = $env{$key};
@@ -5247,7 +5363,7 @@
}
}
}
- if ($context eq 'requestcourses') {
+ if (($context eq 'requestcourses') || ($context eq 'requestauthor')) {
my @approvalnotify = &Apache::loncommon::get_env_multiple('form.reqapprovalnotify');
@approvalnotify = sort(@approvalnotify);
$confhash{'notify'}{'approval'} = join(',', at approvalnotify);
@@ -5283,6 +5399,11 @@
$confhash{$item}{$type} .= $limithash{$item}{$type};
}
}
+ } elsif ($context eq 'requestauthor') {
+ $unset = '0';
+ if ($type eq '_LC_adv') {
+ $unset = '';
+ }
} else {
if (grep(/^\Q$type\E$/,@{$toolshash{$item}})) {
$confhash{$item}{$type} = 1;
@@ -5291,7 +5412,11 @@
}
}
if (ref($domconfig{$action}) eq 'HASH') {
- if (ref($domconfig{$action}{$item}) eq 'HASH') {
+ if ($action eq 'requestauthor') {
+ if ($domconfig{$action}{$type} ne $confhash{$type}) {
+ $changes{$type} = 1;
+ }
+ } elsif (ref($domconfig{$action}{$item}) eq 'HASH') {
if ($domconfig{$action}{$item}{$type} ne $confhash{$item}{$type}) {
$changes{$item}{$type} = 1;
}
@@ -5311,6 +5436,10 @@
if ($confhash{$item}{$type} ne $unset) {
$changes{$item}{$type} = 1;
}
+ } elsif ($context eq 'requestauthor') {
+ if ($confhash{$type} ne $unset) {
+ $changes{$type} = 1;
+ }
} else {
if (!$confhash{$item}{$type}) {
$changes{$item}{$type} = 1;
@@ -5319,7 +5448,7 @@
}
}
}
- unless ($context eq 'requestcourses') {
+ unless (($context eq 'requestcourses') || ($context eq 'requestauthor')) {
if (ref($domconfig{'quotas'}) eq 'HASH') {
if (ref($domconfig{'quotas'}{'defaultquota'}) eq 'HASH') {
foreach my $key (keys(%{$domconfig{'quotas'}{'defaultquota'}})) {
@@ -5362,10 +5491,14 @@
}
}
- foreach my $key (keys(%confhash)) {
- $domdefaults{$key} = $confhash{$key};
+ if ($context eq 'requestauthor') {
+ $domdefaults{'requestauthor'} = \%confhash;
+ } else {
+ foreach my $key (keys(%confhash)) {
+ $domdefaults{$key} = $confhash{$key};
+ }
}
-
+
my %quotahash = (
$action => { %confhash }
);
@@ -5377,7 +5510,8 @@
&Apache::lonnet::do_cache_new('domdefaults',$dom,\%domdefaults,$cachetime);
$resulttext = &mt('Changes made:').'<ul>';
- unless ($context eq 'requestcourses') {
+ unless (($context eq 'requestcourses') ||
+ ($context eq 'requestauthor')) {
if (ref($changes{'defaultquota'}) eq 'HASH') {
$resulttext .= '<li>'.&mt('Portfolio default quotas').'<ul>';
foreach my $type (@{$types},'default') {
@@ -5394,12 +5528,25 @@
}
my %newenv;
foreach my $item (@usertools) {
- if (ref($changes{$item}) eq 'HASH') {
+ my (%haschgs,%inconf);
+ if ($context eq 'requestauthor') {
+ %haschgs = %changes;
+ %inconf = %confhash;
+ } else {
+ if (ref($changes{$item}) eq 'HASH') {
+ %haschgs = %{$changes{$item}};
+ }
+ if (ref($confhash{$item}) eq 'HASH') {
+ %inconf = %{$confhash{$item}};
+ }
+ }
+ if (keys(%haschgs) > 0) {
my $newacc =
&Apache::lonnet::usertools_access($env{'user.name'},
$env{'user.domain'},
$item,'reload',$context);
- if ($context eq 'requestcourses') {
+ if (($context eq 'requestcourses') ||
+ ($context eq 'requestauthor')) {
if ($env{'environment.canrequest.'.$item} ne $newacc) {
$newenv{'environment.canrequest.'.$item} = $newacc;
}
@@ -5408,26 +5555,28 @@
$newenv{'environment.availabletools.'.$item} = $newacc;
}
}
- $resulttext .= '<li>'.$titles{$item}.'<ul>';
+ unless ($context eq 'requestauthor') {
+ $resulttext .= '<li>'.$titles{$item}.'<ul>';
+ }
foreach my $type (@{$types},'default','_LC_adv') {
- if ($changes{$item}{$type}) {
+ if ($haschgs{$type}) {
my $typetitle = $usertypes->{$type};
if ($type eq 'default') {
$typetitle = $othertitle;
} elsif ($type eq '_LC_adv') {
$typetitle = 'LON-CAPA Advanced Users';
}
- if ($confhash{$item}{$type}) {
+ if ($inconf{$type}) {
if ($context eq 'requestcourses') {
my $cond;
- if ($confhash{$item}{$type} =~ /^autolimit=(\d*)$/) {
+ if ($inconf{$type} =~ /^autolimit=(\d*)$/) {
if ($1 eq '') {
$cond = &mt('(Automatic processing of any request).');
} else {
$cond = &mt('(Automatic processing of requests up to limit of [quant,_1,request] per user).',$1);
}
} else {
- $cond = $conditions{$confhash{$item}{$type}};
+ $cond = $conditions{$inconf{$type}};
}
$resulttext .= '<li>'.&mt('Set to be available to [_1].',$typetitle).' '.$cond.'</li>';
} else {
@@ -5435,7 +5584,7 @@
}
} else {
if ($type eq '_LC_adv') {
- if ($confhash{$item}{$type} eq '0') {
+ if ($inconf{$type} eq '0') {
$resulttext .= '<li>'.&mt('Set to be unavailable to [_1]',$typetitle).'</li>';
} else {
$resulttext .= '<li>'.&mt('No override set for [_1]',$typetitle).'</li>';
@@ -5446,17 +5595,19 @@
}
}
}
- $resulttext .= '</ul></li>';
+ unless ($context eq 'requestauthor') {
+ $resulttext .= '</ul></li>';
+ }
}
}
- if ($action eq 'requestcourses') {
+ if (($action eq 'requestcourses') || ($action eq 'requestauthor')) {
if (ref($changes{'notify'}) eq 'HASH') {
if ($changes{'notify'}{'approval'}) {
if (ref($confhash{'notify'}) eq 'HASH') {
if ($confhash{'notify'}{'approval'}) {
$resulttext .= '<li>'.&mt('Notification of requests requiring approval will be sent to: ').$confhash{'notify'}{'approval'}.'</li>';
} else {
- $resulttext .= '<li>'.&mt('No Domain Coordinators will receive notification of course requests requiring approval.').'</li>';
+ $resulttext .= '<li>'.&mt('No Domain Coordinators will receive notification of requests requiring approval.').'</li>';
}
}
}
@@ -5469,6 +5620,8 @@
} else {
if ($context eq 'requestcourses') {
$resulttext = &mt('No changes made to rights to request creation of courses.');
+ } elsif ($context eq 'requestauthor') {
+ $resulttext = &mt('No changes made to rights to request author space.');
} else {
$resulttext = &mt('No changes made to availability of personal information pages, blogs, portfolios or default quotas');
}
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.1091 loncom/interface/loncommon.pm:1.1092
--- loncom/interface/loncommon.pm:1.1091 Tue Aug 14 10:22:25 2012
+++ loncom/interface/loncommon.pm Tue Aug 14 15:45:06 2012
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.1091 2012/08/14 10:22:25 foxr Exp $
+# $Id: loncommon.pm,v 1.1092 2012/08/14 15:45:06 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -13872,6 +13872,20 @@
\%userenv,\%domdef,\%is_adv);
}
+ $userenv{'canrequest.author'} =
+ &Apache::lonnet::usertools_access($username,$domain,'requestauthor',
+ 'reload','requestauthor',
+ \%userenv,\%domdef,\%is_adv);
+ my %reqauthor = &Apache::lonnet::get('requestauthor',['author_status','author'],
+ $domain,$username);
+ my $reqstatus = $reqauthor{'author_status'};
+ if ($reqstatus eq 'approval' || $reqstatus eq 'approved') {
+ if (ref($reqauthor{'author'}) eq 'HASH') {
+ $userenv{'requestauthorqueued'} = $reqstatus.':'.
+ $reqauthor{'author'}{'timestamp'};
+ }
+ }
+
$env{'user.environment'} = "$lonids/$cookie.id";
if (tie(my %disk_env,'GDBM_File',"$lonids/$cookie.id",
Index: loncom/interface/loncoursequeueadmin.pm
diff -u loncom/interface/loncoursequeueadmin.pm:1.29 loncom/interface/loncoursequeueadmin.pm:1.30
--- loncom/interface/loncoursequeueadmin.pm:1.29 Wed Nov 30 12:31:00 2011
+++ loncom/interface/loncoursequeueadmin.pm Tue Aug 14 15:45:06 2012
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Utilities to administer domain course requests and course self-enroll requests
#
-# $Id: loncoursequeueadmin.pm,v 1.29 2011/11/30 12:31:00 goltermann Exp $
+# $Id: loncoursequeueadmin.pm,v 1.30 2012/08/14 15:45:06 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -96,13 +96,22 @@
$rawsubj = 'Self-enrollment requests processed';
push(@rawmsg,{
mt => 'Enrollment requests in the following course: [_1] have been processed.',
- args => ["\n $contextdesc"],
+ args => ["\n$contextdesc"],
});
} elsif ($context eq 'domainmanagers') {
$rawsubj = 'Course/Community requests reviewed';
push(@rawmsg,{
mt => 'Course/Community creation requests in the following domain: [_1] have been reviewed.',
- args => ["\n $contextdesc"],
+ args => ["\n$contextdesc"],
+ });
+ if (ref($textstr) eq 'ARRAY') {
+ push(@rawmsg,@{$textstr});
+ }
+ } elsif ($context eq 'authormanagers') {
+ $rawsubj = 'Authoring space requests reviewed';
+ push(@rawmsg,{
+ mt => 'Authoring requests in the following domain: [_1] have been reviewed.',
+ args => ["\n$contextdesc"],
});
if (ref($textstr) eq 'ARRAY') {
push(@rawmsg,@{$textstr});
@@ -185,7 +194,28 @@
mt => $directions,
args => [" \n\n","\n"],
});
+ } elsif ($context eq 'authorreq') {
+ $rawsubj = 'Authoring space request to review';
+ $msgtxt = 'Assignment of an author role in the [_1] domain[_2] was requested by [_3] on [_4].';
+ push(@rawmsg,{
+ mt => $msgtxt,
+ args => [$contextdesc,"\n",$textstr,$timestamp],
+ },
+ {
+ mt =>'[_1]As Domain Coordinator, use: [_2]Main Menu -> Create users or modify the roles and privileges of users -> Authoring space reqests[_3]to display a list of pending requests, which you can either approve or reject.',
+ args => ["\n","\n\n ","\n\n"],
+ });
+ } elsif ($context eq 'requestauthor') {
+ $rawsubj = 'Authoring space request';
+ $msgtxt = 'Your request for an authoring space requested on [_1]has been reviewed by a Domain Coordinator.';
+ push(@rawmsg,{
+ mt => $msgtxt,
+ args => [$timestamp."\n"],
+ });
+ if (ref($textstr) eq 'ARRAY') {
+ push(@rawmsg,@{$textstr});
+ }
}
my @to_notify = split(/,/,$notifylist);
my $numsent = 0;
@@ -250,6 +280,13 @@
if ($rejectedlist) {
$message .= "\n\n".&Apache::lonlocal::mt_user($sender_lh,'Rejected course requests:')."\n".$rejectedlist;
}
+ } elsif ($context eq 'authormanagers') {
+ if ($approvedlist) {
+ $message .= "\n\n".&Apache::lonlocal::mt_user($sender_lh,'Approved author role requests:')."\n".$approvedlist;
+ }
+ if ($rejectedlist) {
+ $message .= "\n\n".&Apache::lonlocal::mt_user($sender_lh,'Rejected author role requests:')."\n".$rejectedlist;
+ }
}
$status .= &Apache::lonmsg::user_normal_msg($ccname,$ccdom,$subject,$message,undef,undef,undef,1,\%sentmessage,undef,undef,undef,1,$recipid).',';
}
@@ -265,6 +302,11 @@
$namespace = 'selfenrollrequests';
%requesthash = &Apache::lonnet::dump($namespace,$dom,$cnum);
$nextelement = '<input type="hidden" name="state" value="done" />';
+ } elsif ($context eq 'requestauthor') {
+ $formaction = '/adm/createuser';
+ $namespace = 'requestauthorqueue';
+ %requesthash = &Apache::lonnet::dump_dom($namespace,$dom);
+ $nextelement = '<input type="hidden" name="state" value="done" />';
} else {
$formaction = '/adm/createcourse';
$namespace = 'courserequestqueue';
@@ -287,6 +329,9 @@
if ($context eq 'course') {
($timestamp, my $usec) = split(/:/,$requesthash{$item});
$entry = $item.':'.$usec;
+ } elsif ($context eq 'requestauthor') {
+ $timestamp = $requesthash{$item};
+ ($entry) = ($item =~ /^($match_username)_approval$/);
} else {
$timestamp = $requesthash{$item}{'timestamp'};
if (ref($requesthash{$item}) eq 'HASH') {
@@ -316,8 +361,10 @@
$output .= '<h3>'.&mt('Requests for official courses queued pending validation').'</h3>'.
'<p>'.&mt('Requests are validated against institutional data to confirm that the requestor is an instructor of record.').'<br />'.
&mt('Validation is attempted when the request is submitted.').' '.&mt('If unvalidated, the request will be held in a queue.').' '.&mt('Validation of pending requests is automatically repeated daily.').'</p>';
+ } elsif ($context eq 'requestauthor') {
+ $output .= '<h3>'.&mt('Requests for authoring space queued pending approval by a Domain Coordinator').'</h3>';
} else {
- $output .= '<h3>'.&mt('Course/Community requests queued pending approval by a Domain Coordinator').'</h3>';
+ $output .= '<h3>'.&mt('Course/Community requests queued pending approval by a Domain Coordinator').'</h3>';
}
$output .= &build_queue_display($dom,$context,\%queue_by_date).
'<input type="hidden" name="queue" value="approval" />';
@@ -327,6 +374,8 @@
$output .= &mt('There are currently no enrollment requests awaiting approval.');
} elsif ($context eq 'pending') {
$output .= &mt('There are currently no requests for official courses awaiting validation.');
+ } elsif ($context eq 'requestauthor') {
+ $output .= &mt('There are currently no requests for authoring space awaiting approval.');
} elsif ($context eq 'domain') {
$output .= &mt('There are currently no course or community requests awaiting approval.');
}
@@ -367,6 +416,8 @@
if ($context eq 'course') {
$output .= '<th>'.&mt('Section').'</th>'.
'<th>'.&mt('Date requested').'</th>';
+ } elsif ($context eq 'requestauthor') {
+ $output .= '<th>'.&mt('Date requested').'</th>';
} elsif ($context eq 'pending' || $context eq 'stillpending') {
$output .= '<th>'.&mt('Institutional code').'</th>'.
'<th>'.&mt('Date requested').'</th>'.
@@ -401,6 +452,14 @@
$namelink = &Apache::loncommon::aboutmewrapper(
&Apache::loncommon::plainname($puname,$pudom),
$puname,$pudom);
+ } elsif ($context eq 'requestauthor') {
+ if (&Apache::lonnet::homeserver($request,$dom) ne 'no_host') {
+ $approve = $count.':'.$request;
+ $reject = $request;
+ $namelink = &Apache::loncommon::aboutmewrapper(
+ &Apache::loncommon::plainname($request,$dom),
+ $request,$dom);
+ }
} else {
my ($cnum,$ownername,$ownerdom,$type,$cdesc);
my $queue = 'approval';
@@ -424,9 +483,10 @@
}
unless ($context eq 'pending') {
$row = '<td><span class="LC_nobreak"><label>'.
- '<input type="radio" value="'.$approve.'" name="'.$count.'radioreq" />'.&mt('Approve').'</label></span>'.
- '<span class="LC_nobreak"><label>'.
- '<input type="radio" value="'.$reject.'" name="'.$count.'radioreq" />'.&mt('Reject').'</label></span>'.
+ '<input type="radio" value="'.$approve.'" name="'.$count.'radioreq" />'.&mt('Approve').'</label>'.
+ '<label>'.(' 'x2).
+ '<input type="radio" value="'.$reject.'" name="'.$count.'radioreq" />'.&mt('Reject').'</label>'.
+ '<label>'.(' 'x2).
'<input type="radio" value="'."later:".$reject.'" name="'.$count.'radioreq" checked />'.&mt('Decide Later').
'</label></span><br /></td>';
}
@@ -434,6 +494,8 @@
if ($context eq 'course') {
$row .= '<td>'.$showsec.'</td>'."\n".
'<td>'.$showtime.'</td>'."\n";
+ } elsif ($context eq 'requestauthor') {
+ $row .= '<td>'.$showtime.'</td>'."\n";
} else {
if ($context eq 'pending' || $context eq 'stillpending') {
$row .= '<td>'.$instcode.'</td>'."\n";
@@ -461,8 +523,9 @@
$sender,$approvedmsg,$rejectedmsg,$beneficiary,
@existing, at missingreq, at invalidusers, at limitexceeded, at completed,
@processing_errors, at warn_approves, at warn_rejects, at approvals, at warn_dels,
- @rejections, at rejectionerrors, at nopermissions,%courseroles,
- %communityroles,%domdefs,%approvalmsg,%rejectionmsg,$crstype,$queue,$firsturl);
+ @rejections, at rejectionerrors, at nopermissions,%courseroles, at toremove,
+ %communityroles,%domdefs,%approvalmsg,%rejectionmsg,$crstype,$queue,
+ $firsturl);
my $count=0;
while (my @course = &Apache::loncommon::get_env_multiple('form.'.$count.'radioreq')) {
if (@course[0] =~ /^\d+:.*/) {
@@ -474,7 +537,6 @@
}
$count+=1;
}
-
$now = time;
$sender = $env{'user.name'}.':'.$env{'user.domain'};
@@ -501,6 +563,29 @@
$rejectedmsg = [{
mt => 'Your request for enrollment has not been approved.',
}];
+ } elsif ($context eq 'requestauthor') {
+ $namespace = 'requestauthorqueue';
+ $beneficiary = 'requestauthor';
+ %requesthash = &Apache::lonnet::dump_dom($namespace,$cdom);
+ my %domdefs = &Apache::lonnet::get_domain_defaults($cdom);
+ if (ref($domdefs{'requestauthor'}) eq 'HASH') {
+ if (ref($domdefs{'requestauthor'}{'notify'}) eq 'HASH') {
+ $notifylist = $domdefs{'requestauthor'}{'notify'}{'approval'};
+ }
+ }
+ my $domconfiguser = &Apache::lonnet::get_domainconfiguser($cdom);
+ $firsturl = &course_portal_url($domconfiguser,$cdom);
+ $approvedmsg = [{
+ mt => 'Your request for authoring space has been approved.',
+ },
+ {
+ mt => 'Visit [_1] to log-in and select your author role',
+ args => [$firsturl],
+ }];
+ $rejectedmsg = [{
+ mt => 'Your request for authoring space has not been approved.',
+ }];
+ $domdesc = &Apache::lonnet::domain($cdom);
} else {
$domdesc = &Apache::lonnet::domain($cdom);
$namespace = 'courserequestqueue';
@@ -551,7 +636,6 @@
foreach my $role (@roles) {
$communityroles{$role}=&Apache::lonnet::plaintext($role,'Community');
}
-
}
foreach my $item (sort {$a <=> $b} @approvals) {
if ($context eq 'course') {
@@ -613,6 +697,50 @@
} else {
push(@invalidusers,$uname.':'.$udom);
}
+ } elsif ($context eq 'requestauthor') {
+ my ($num,$uname) = split(/:/,$item);
+ my $uhome = &Apache::lonnet::homeserver($uname,$cdom);
+ if ($uhome ne 'no_host') {
+ my ($user_is_adv,$user_is_author) = &Apache::lonnet::is_advanced_user($cdom,$uname);
+ if ($user_is_author) {
+ push(@existing,$uname);
+ } elsif (&Apache::lonnet::usertools_access($uname,$cdom,'requestauthor',
+ undef,'requestauthor')) {
+ if (&Apache::lonnet::allowed('cau',$cdom)) {
+ if (&Apache::lonnet::assignrole($cdom,$uname,'/'.$cdom.'/','au',undef,time,undef,undef,'requestauthor') eq 'ok') {
+ push(@completed,$uname);
+ unless (&Apache::lonnet::del_dom($namespace,[$uname.'_approval'],$cdom) eq 'ok') {
+ push(@warn_dels,$uname);
+ }
+ &send_selfserve_notification($uname.':'.$cdom,
+ $approvedmsg,undef,undef,$now,
+ $beneficiary,$sender);
+ my %userrequest = (
+ author => {
+ timestamp => $now,
+ adjudicator => $env{'user.name'}.':'.$env{'user.domain'},
+ status => 'approved',
+ },
+ author_status => 'approved',
+ );
+ my $userresult =
+ &Apache::lonnet::put('requestauthor',\%userrequest,$cdom,$uname);
+ if ($userresult ne 'ok') {
+ push(@warn_approves,$item);
+ }
+ } else {
+ push(@processing_errors,$uname);
+ }
+ } else {
+ push(@nopermissions,$uname);
+ }
+ } else {
+ push(@nopermissions,$uname);
+ }
+ } else {
+ push(@invalidusers,$uname.':'.$cdom);
+ }
+ push(@toremove,(@invalidusers, at nopermissions));
} else {
my ($num,$cnum) = split(':',$item);
if (ref($requesthash{$cnum.'_'.$queue}) eq 'HASH') {
@@ -717,26 +845,40 @@
my @changes = (@completed, at rejections);
if ($context eq 'domain') {
@changes = map {$_.'_'.$queue} (@changes);
+ } elsif ($context eq 'requestauthor') {
+ @changes = map {$_.'_approval'} (@changes);
}
if (@rejections) {
foreach my $item (@rejections) {
- if ($context eq 'course') {
- my $user = $item;
+ if (($context eq 'course') || ($context eq 'requestauthor')) {
+ my ($user,$uname,$udom,%userrequest,$key);
+ if ($context eq 'requestauthor') {
+ $uname = $item;
+ $udom = $cdom;
+ $user = $uname.':'.$udom;
+ $key = 'author';
+ } else {
+ $user = $item;
+ ($uname,$udom) = split(/:/,$user);
+ $key = $cdom.'_'.$cnum;
+ }
&send_selfserve_notification($user,$rejectedmsg,$cid,$coursedesc,
$now,$beneficiary,$sender,undef,undef,
$crstype);
- my ($uname,$udom) = split(/:/,$user);
- my %userrequest = (
- $cdom.'_'.$cnum => {
+ %userrequest = (
+ $key => {
timestamp => $now,
adjudicator => $env{'user.name'}.':'.$env{'user.domain'},
- status => 'rejected',
+ status => 'rejection',
}
);
+ if ($context eq 'requestauthor') {
+ $userrequest{'author_status'} = 'rejection';
+ }
my $userresult =
- &Apache::lonnet::put($namespace,\%userrequest,$udom,$uname);
+ &Apache::lonnet::put('requestauthor',\%userrequest,$udom,$uname);
if ($userresult ne 'ok') {
- push(@warn_rejects,$user);
+ push(@warn_rejects,$item);
}
} else {
my $cnum = $item;
@@ -799,6 +941,21 @@
}
}
}
+ if (@toremove) {
+ foreach my $item (@toremove) {
+ my %userrequest = (
+ author => {
+ timestamp => $now,
+ adjudicator => $env{'user.name'}.':'.$env{'user.domain'},
+ status => 'deleted',
+ },
+ author_status => 'deleted',
+ );
+ &Apache::lonnet::put('requestauthor',\%userrequest,$cdom,$item);
+ }
+ @toremove = map {$_.'_approval'} (@toremove);
+ my $delresult = &Apache::lonnet::del_dom($namespace,\@toremove,$cdom);
+ }
if (@changes) {
my $delresult;
if ($context eq 'course') {
@@ -840,6 +997,34 @@
$now,'coursemanagers',$sender,
$approvedlist,$rejectedlist,$crstype);
}
+ } elsif ($context eq 'requestauthor') {
+ $chgmsg = "'Action was taken on the following authoring space requests by [_1].',$namelink";
+ if (@completed) {
+ $approvedlist = join("\n", at completed);
+ $output .= '<p>'.&mt('The following requests were approved:').'<ul>';
+ foreach my $uname (@completed) {
+ my $userlink =
+ &Apache::loncommon::aboutmewrapper(&Apache::loncommon::plainname($uname,$cdom),$uname,$cdom);
+ $output .= '<li>'.$userlink.'</li>';
+
+ }
+ $output .= '</ul></p>';
+ }
+ if (@rejections) {
+ $rejectedlist = join("\n", at rejections);
+ $output .= '<p>'.&mt('The following requests were rejected:').'<ul>';
+ foreach my $uname (@rejections) {
+ my $userlink =
+ &Apache::loncommon::aboutmewrapper(&Apache::loncommon::plainname($uname,$cdom),$uname,$cdom);
+ $output .= '<li>'.$userlink.'</li>';
+ }
+ $output .= '</ul></p>';
+ }
+ if ($notifylist ne '') {
+ &send_selfserve_notification($notifylist,$chgmsg,undef,$domdesc,
+ $now,'authormanagers',$sender,
+ $approvedlist,$rejectedlist);
+ }
} else {
$chgmsg = "'Action was taken on the following course and community requests by [_1].',$namelink";
if (@completed) {
@@ -887,6 +1072,14 @@
$output .= '<li>'.$user.'</li>';
}
$output .= '</ul></p>';
+ } elsif ($context eq 'requestauthor') {
+ $output .= '<p>'.&mt('Authoring space requests from the following users were deleted because one already exists:').'<ul>';
+ foreach my $uname (@existing) {
+ my $userlink =
+ &Apache::loncommon::aboutmewrapper(&Apache::loncommon::plainname($uname,$cdom),$uname,$cdom);
+ $output .= '<li>'.$userlink.'</li>';
+ }
+ $output .= '</ul></p>';
} else {
$output .= '<p>'.&mt('The following course/community creation requests were deleted because the course or community has already been created:').'<ul>';
foreach my $cnum (@existing) {
@@ -909,13 +1102,20 @@
$output .= '<li>'.$user.'</li>';
}
$output .= '</ul></p>';
+ } elsif ($context eq 'requestauthor') {
+ $output .= '<p>'.&mt('The following requests were ignored because the request is no longer in the queue:').'<ul>';
+ foreach my $uname (@missingreq) {
+ my $userlink =
+ &Apache::loncommon::aboutmewrapper(&Apache::loncommon::plainname($uname,$cdom),$uname,$cdom);
+ $output .= '<li>'.$userlink.'</li>';
+ }
+ $output .= '</ul></p>';
} else {
$output .= '<p>'.&mt('The following course/community creation requests were ignored because the request is no longer in the queue:').'<ul>';
foreach my $cnum (@missingreq) {
$output .= '<li>'.$cnum.'</li>';
}
$output .= '</ul></p>';
-
}
}
if (@invalidusers) {
@@ -925,6 +1125,14 @@
$output .= '<li>'.$user.'</li>';
}
$output .= '</ul></p>';
+ } elsif ($context eq 'requestauthor') {
+ $output .= '<p>'.&mt('The following authoring space requests were deleted because the requestor does not have a LON-CAPA account:').'<ul>';
+ foreach my $uname (@invalidusers) {
+ my $userlink =
+ &Apache::loncommon::aboutmewrapper(&Apache::loncommon::plainname($uname,$cdom),$uname,$cdom);
+ $output .= '<li>'.$userlink.'</li>';
+ }
+ $output .= '</ul></p>';
}
}
if (@limitexceeded) {
@@ -937,17 +1145,27 @@
}
}
if (@nopermissions) {
- $output .= '<p>'.&mt('The following course/community creation requests could not be processed because the owner does not have rights to create this type of course:').'<ul>';
- foreach my $cnum (@nopermissions) {
- my $showcourse;
- if (ref($requesthash{$cnum.'_'.$queue})) {
- $showcourse = $requesthash{$cnum.'_'.$queue}{'description'};
- } else {
- $showcourse = $cnum;
+ if ($context eq 'course') {
+ $output .= '<p>'.&mt('The following course/community creation requests could not be processed because the owner does not have rights to create this type of course:').'<ul>';
+ foreach my $cnum (@nopermissions) {
+ my $showcourse;
+ if (ref($requesthash{$cnum.'_'.$queue})) {
+ $showcourse = $requesthash{$cnum.'_'.$queue}{'description'};
+ } else {
+ $showcourse = $cnum;
+ }
+ $output .= '<li>'.$showcourse.'</li>';
}
- $output .= '<li>'.$showcourse.'</li>';
+ $output .= '</ul></p>';
+ } elsif ($context eq 'requestauthor') {
+ $output .= '<p>'.&mt('The following requests could not be processed because the requestor does not have rights to request an authoring space:').'<ul>';
+ foreach my $uname (@nopermissions) {
+ my $userlink =
+ &Apache::loncommon::aboutmewrapper(&Apache::loncommon::plainname($uname,$cdom),$uname,$cdom);
+ $output .= '<li>'.$userlink.'</li>';
+ }
+ $output .= '</ul></p>';
}
- $output .= '</ul></p>';
}
if (@processing_errors) {
if ($context eq 'course') {
@@ -956,6 +1174,14 @@
$output .= '<li>'.$user.'</li>';
}
$output .= '</ul></p>';
+ } elsif ($context eq 'requestauthor') {
+ $output .= '<p>'.&mt('The following requests could not be processed because an error occurred:').'<ul>';
+ foreach my $uname (@processing_errors) {
+ my $userlink =
+ &Apache::loncommon::aboutmewrapper(&Apache::loncommon::plainname($uname,$cdom),$uname,$cdom);
+ $output .= '<li>'.$userlink.'</li>';
+ }
+ $output .= '</ul></p>';
} else {
$output .= '<p>'.&mt('The following course/community creation requests could not be processed because an error occurred:').'<ul>';
foreach my $cnum (@processing_errors) {
@@ -990,6 +1216,14 @@
$output .= '<li>'.$user.'</li>';
}
$output .= '</ul></p>';
+ } elsif ($context eq 'requestauthor') {
+ $output .= '<p>'.&mt("For the following users, an error occurred when updating the user's own author request record:").'<ul>';
+ foreach my $uname (@warn_approves, at warn_rejects) {
+ my $userlink =
+ &Apache::loncommon::aboutmewrapper(&Apache::loncommon::plainname($uname,$cdom),$uname,$cdom);
+ $output .= '<li>'.$userlink.'</li>';
+ }
+ $output .= '</ul></p>';
} else {
$output .= '<p>'.&mt("For the following course/community requests an error occurred when updating the requestor's own requests record:").'<ul>';
foreach my $cnum (@warn_approves, at warn_rejects) {
@@ -1005,17 +1239,27 @@
}
}
if (@warn_dels) {
- $output .= '<p>'.&mt("For the following course/community requests an error occurred when removing requests for the following from the pending queue:").'<ul>';
- foreach my $cnum (@warn_dels) {
- my $showcourse;
- if (ref($requesthash{$cnum.'_'.$queue})) {
- $showcourse = $requesthash{$cnum.'_'.$queue}{'description'};
- } else {
- $showcourse = $cnum;
+ if ($context eq 'requestauthor') {
+ $output .= '<p>'.&mt("For the following requests an error occurred when removing the request from the queue:").'<ul>';
+ foreach my $uname (@warn_dels) {
+ my $userlink =
+ &Apache::loncommon::aboutmewrapper(&Apache::loncommon::plainname($uname,$cdom),$uname,$cdom);
+ $output .= '<li>'.$userlink.'</li>';
}
- $output .= '<li>'.$showcourse.'</li>';
+ $output .= '</ul></p>';
+ } else {
+ $output .= '<p>'.&mt("For the following course/community requests an error occurred when removing requests for the following from the pending queue:").'<ul>';
+ foreach my $cnum (@warn_dels) {
+ my $showcourse;
+ if (ref($requesthash{$cnum.'_'.$queue})) {
+ $showcourse = $requesthash{$cnum.'_'.$queue}{'description'};
+ } else {
+ $showcourse = $cnum;
+ }
+ $output .= '<li>'.$showcourse.'</li>';
+ }
+ $output .= '</ul></p>';
}
- $output .= '</ul></p>';
}
return $output;
}
@@ -1186,70 +1430,82 @@
}
sub get_processtype {
- my ($uname,$udom,$isadv,$dom,$crstype,$inststatuses,$domconfig) = @_;
+ my ($context,$uname,$udom,$isadv,$dom,$crstype,$inststatuses,$domconfig) = @_;
return unless ((ref($inststatuses) eq 'ARRAY') && (ref($domconfig) eq 'HASH'));
if ($uname eq '' || $udom eq '') {
$uname = $env{'user.name'};
$udom = $env{'user.domain'};
$isadv = $env{'user.adv'};
}
- my (%userenv,%settings,$val);
- my @options = ('autolimit','validate','approval');
- if ($dom eq $udom) {
+ my (%userenv,%settings,$val, at options,$envkey);
+ if ($context eq 'course') {
+ @options = ('autolimit','validate','approval');
+ $envkey = 'requestcourses.'.$crstype;
+ if (ref($domconfig->{'requestcourses'}) eq 'HASH') {
+ if (ref($domconfig->{'requestcourses'}->{$crstype}) eq 'HASH') {
+ %settings = %{$domconfig->{'requestcourses'}->{$crstype}};
+ }
+ }
+ } else {
+ @options = ('automatic','approval');
+ $envkey = 'requestauthor';
+ if (ref($domconfig->{'requestauthor'}) eq 'HASH') {
+ %settings = %{$domconfig->{'requestauthor'}};
+ }
+ }
+ if (($dom eq $udom) || ($context eq 'requestauthor')) {
%userenv =
- &Apache::lonnet::userenvironment($udom,$uname,'requestcourses.'.$crstype,'inststatus');
- if ($userenv{'requestcourses.'.$crstype}) {
- $val = $userenv{'requestcourses.'.$crstype};
+ &Apache::lonnet::userenvironment($udom,$uname,$envkey,'inststatus');
+ if ($userenv{$envkey}) {
+ $val = $userenv{$envkey};
@{$inststatuses} = ('_custom_');
} else {
- my ($task,%alltasks);
- if (ref($domconfig->{'requestcourses'}) eq 'HASH') {
- %settings = %{$domconfig->{'requestcourses'}};
- if (ref($settings{$crstype}) eq 'HASH') {
- if (($isadv) && ($settings{$crstype}{'_LC_adv'} ne '')) {
- $val = $settings{$crstype}{'_LC_adv'};
- @{$inststatuses} = ('_LC_adv_');
- } else {
- if ($userenv{'inststatus'} ne '') {
- @{$inststatuses} = split(',',$userenv{'inststatus'});
- } else {
- @{$inststatuses} = ('default');
- }
- foreach my $status (@{$inststatuses}) {
- if (exists($settings{$crstype}{$status})) {
- my $value = $settings{$crstype}{$status};
- next unless ($value);
- unless (exists($alltasks{$value})) {
- if (ref($alltasks{$value}) eq 'ARRAY') {
- unless(grep(/^\Q$status\E$/,@{$alltasks{$value}})) {
- push(@{$alltasks{$value}},$status);
- }
- } else {
- @{$alltasks{$value}} = ($status);
- }
+ my %alltasks;
+ if (($isadv) && ($settings{'_LC_adv'} ne '')) {
+ $val = $settings{$crstype}{'_LC_adv'};
+ @{$inststatuses} = ('_LC_adv_');
+ } else {
+ if ($userenv{'inststatus'} ne '') {
+ @{$inststatuses} = split(',',$userenv{'inststatus'});
+ } else {
+ @{$inststatuses} = ('default');
+ }
+ foreach my $status (@{$inststatuses}) {
+ if (exists($settings{$status})) {
+ my $value = $settings{$status};
+ next unless ($value);
+ unless (exists($alltasks{$value})) {
+ if (ref($alltasks{$value}) eq 'ARRAY') {
+ unless(grep(/^\Q$status\E$/,@{$alltasks{$value}})) {
+ push(@{$alltasks{$value}},$status);
}
+ } else {
+ @{$alltasks{$value}} = ($status);
}
}
- my $maxlimit = 0;
-
- foreach my $key (sort(keys(%alltasks))) {
- if ($key =~ /^autolimit=(\d*)$/) {
- if ($1 eq '') {
- $val ='autolimit=';
- last;
- } elsif ($1 > $maxlimit) {
- $maxlimit = $1;
- }
+ }
+ }
+ my $maxlimit = 0;
+ if ($context eq 'course') {
+ foreach my $key (sort(keys(%alltasks))) {
+ if ($key =~ /^autolimit=(\d*)$/) {
+ if ($1 eq '') {
+ $val ='autolimit=';
+ last;
+ } elsif ($1 > $maxlimit) {
+ $maxlimit = $1;
}
}
- if ($maxlimit) {
- $val = 'autolimit='.$maxlimit;
- } else {
- foreach my $option (@options) {
- if ($alltasks{$option}) {
- $val = $option;
- last;
- }
+ }
+ }
+ if (($context eq 'requestauthor') || (!$val)) {
+ if ($context eq 'course' && $maxlimit) {
+ $val = 'autolimit='.$maxlimit;
+ } else {
+ foreach my $option (@options) {
+ if ($alltasks{$option}) {
+ $val = $option;
+ last;
}
}
}
Index: loncom/interface/loncreateuser.pm
diff -u loncom/interface/loncreateuser.pm:1.361 loncom/interface/loncreateuser.pm:1.362
--- loncom/interface/loncreateuser.pm:1.361 Fri Jun 1 11:39:24 2012
+++ loncom/interface/loncreateuser.pm Tue Aug 14 15:45:06 2012
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Create a user
#
-# $Id: loncreateuser.pm,v 1.361 2012/06/01 11:39:24 raeburn Exp $
+# $Id: loncreateuser.pm,v 1.362 2012/08/14 15:45:06 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -233,6 +233,7 @@
'official' => 'Can request creation of official courses',
'unofficial' => 'Can request creation of unofficial courses',
'community' => 'Can request creation of communities',
+ 'requestauthor' => 'Can request author space',
);
if ($context eq 'requestcourses') {
%userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname,
@@ -247,6 +248,16 @@
%domconfig =
&Apache::lonnet::get_dom('configuration',['requestcourses'],$ccdomain);
$isadv = &Apache::lonnet::is_advanced_user($ccuname,$ccdomain);
+ } elsif ($context eq 'requestauthor') {
+ %userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname,
+ 'requestauthor');
+ @usertools = ('requestauthor');
+ @options =('norequest','approval','automatic');
+ %reqtitles = &requestauthor_titles();
+ %reqdisplay = &requestauthor_display();
+ $colspan = ' colspan="2"';
+ %domconfig =
+ &Apache::lonnet::get_dom('configuration',['requestauthor'],$ccdomain);
} else {
%userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname,
'tools.aboutme','tools.portfolio','tools.blog',
@@ -261,7 +272,12 @@
$curr_access =
&Apache::lonnet::usertools_access($ccuname,$ccdomain,$item,undef,
$context);
- if ($userenv{$context.'.'.$item} ne '') {
+ if ($context eq 'requestauthor') {
+ if ($userenv{$context} ne '') {
+ $cust_on = ' checked="checked" ';
+ $cust_off = '';
+ }
+ } elsif ($userenv{$context.'.'.$item} ne '') {
$cust_on = ' checked="checked" ';
$cust_off = '';
}
@@ -271,6 +287,12 @@
} else {
$custom_access = &mt('Currently from custom setting.');
}
+ } elsif ($context eq 'requestauthor') {
+ if ($userenv{$context} eq '') {
+ $custom_access = &mt('Currently from default setting.');
+ } else {
+ $custom_access = &mt('Currently from custom setting.');
+ }
} else {
if ($userenv{$context.'.'.$item} eq '') {
$custom_access =
@@ -292,15 +314,27 @@
' <td'.$colspan.'>'.$lt{$item}.'</td>'."\n".
' </tr>'."\n".
&Apache::loncommon::start_data_table_row()."\n";
- if ($context eq 'requestcourses') {
+ if (($context eq 'requestcourses') || ($context eq 'requestauthor')) {
my ($curroption,$currlimit);
- if ($userenv{$context.'.'.$item} ne '') {
- $curroption = $userenv{$context.'.'.$item};
+ my $envkey = $context.'.'.$item;
+ if ($context eq 'requestauthor') {
+ $envkey = $context;
+ }
+ if ($userenv{$envkey} ne '') {
+ $curroption = $userenv{$envkey};
} else {
my (@inststatuses);
- $curroption =
- &Apache::loncoursequeueadmin::get_processtype($ccuname,$ccdomain,$isadv,$ccdomain,
- $item,\@inststatuses,\%domconfig);
+ if ($context eq 'requestcourses') {
+ $curroption =
+ &Apache::loncoursequeueadmin::get_processtype('course',$ccuname,$ccdomain,
+ $isadv,$ccdomain,$item,
+ \@inststatuses,\%domconfig);
+ } else {
+ $curroption =
+ &Apache::loncoursequeueadmin::get_processtype('requestauthor',$ccuname,$ccdomain,
+ $isadv,$ccdomain,undef,
+ \@inststatuses,\%domconfig);
+ }
}
if (!$curroption) {
$curroption = 'norequest';
@@ -338,28 +372,36 @@
$checked = ' checked="checked"';
}
}
+ my $name = 'crsreq_'.$item;
+ if ($context eq 'requestauthor') {
+ $name = $item;
+ }
$custdisp .= '<tr><td><span class="LC_nobreak"><label>'.
- '<input type="radio" name="crsreq_'.$item.
- '" value="'.$val.'"'.$checked.' />'.
+ '<input type="radio" name="'.$name.'" '.
+ 'value="'.$val.'"'.$checked.' />'.
$reqtitles{$option}.'</label> ';
if ($option eq 'autolimit') {
- $custdisp .= '<input type="text" name="crsreq_'.
- $item.'_limit" size="1" '.
+ $custdisp .= '<input type="text" name="'.$name.
+ '_limit" size="1" '.
'value="'.$currlimit.'" /></span><br />'.
$reqtitles{'unlimited'};
- } else {
- $custdisp .= '</span>';
- }
- $custdisp .= '</td></tr>';
+ } else {
+ $custdisp .= '</span>';
+ }
+ $custdisp .= '</td></tr>';
}
$custdisp .= '</table>';
$custradio = '</span></td><td>'.&mt('Custom setting').'<br />'.$custdisp;
} else {
$currdisp = ($curr_access?&mt('Yes'):&mt('No'));
+ my $name = $context.'_'.$item;
+ if ($context eq 'requestauthor') {
+ $name = $context;
+ }
$custdisp = '<span class="LC_nobreak"><label>'.
- '<input type="radio" name="'.$context.'_'.$item.'"'.
+ '<input type="radio" name="'.$name.'"'.
' value="1" '.$tool_on.'/>'.&mt('On').'</label> <label>'.
- '<input type="radio" name="'.$context.'_'.$item.'" value="0" '.
+ '<input type="radio" name="'.$name.'" value="0" '.
$tool_off.'/>'.&mt('Off').'</label></span>';
$custradio = (' 'x2).'--'.$lt{'cusa'}.': '.$custdisp.
'</span>';
@@ -455,6 +497,17 @@
return $output;
}
+sub domainrole_req {
+ my ($ccuname,$ccdomain) = @_;
+ return '<br /><h3>'.
+ &mt('User Can Request Assignment of Domain Roles?').
+ '</h3>'."\n".
+ &Apache::loncommon::start_data_table().
+ &build_tools_display($ccuname,$ccdomain,
+ 'requestauthor').
+ &Apache::loncommon::end_data_table();
+}
+
sub courserequest_titles {
my %titles = &Apache::lonlocal::texthash (
official => 'Official',
@@ -478,6 +531,80 @@
return %titles;
}
+sub requestauthor_titles {
+ my %titles = &Apache::lonlocal::texthash (
+ norequest => 'Not allowed',
+ approval => 'Approval by Dom. Coord.',
+ automatic => 'Automatic approval',
+ );
+ return %titles;
+
+}
+
+sub requestauthor_display {
+ my %titles = &Apache::lonlocal::texthash (
+ approval => 'Yes, need approval',
+ automatic => 'Yes, automatic approval',
+ norequest => 'No',
+ );
+ return %titles;
+}
+
+sub curr_requestauthor {
+ my ($uname,$udom,$isadv,$inststatuses,$domconfig) = @_;
+ return unless ((ref($inststatuses) eq 'ARRAY') && (ref($domconfig) eq 'HASH'));
+ if ($uname eq '' || $udom eq '') {
+ $uname = $env{'user.name'};
+ $udom = $env{'user.domain'};
+ $isadv = $env{'user.adv'};
+ }
+ my (%userenv,%settings,$val);
+ my @options = ('automatic','approval');
+ %userenv =
+ &Apache::lonnet::userenvironment($udom,$uname,'requestauthor','inststatus');
+ if ($userenv{'requestauthor'}) {
+ $val = $userenv{'requestauthor'};
+ @{$inststatuses} = ('_custom_');
+ } else {
+ my %alltasks;
+ if (ref($domconfig->{'requestauthor'}) eq 'HASH') {
+ %settings = %{$domconfig->{'requestauthor'}};
+ if (($isadv) && ($settings{'_LC_adv'} ne '')) {
+ $val = $settings{'_LC_adv'};
+ @{$inststatuses} = ('_LC_adv_');
+ } else {
+ if ($userenv{'inststatus'} ne '') {
+ @{$inststatuses} = split(',',$userenv{'inststatus'});
+ } else {
+ @{$inststatuses} = ('default');
+ }
+ foreach my $status (@{$inststatuses}) {
+ if (exists($settings{$status})) {
+ my $value = $settings{$status};
+ next unless ($value);
+ unless (exists($alltasks{$value})) {
+ if (ref($alltasks{$value}) eq 'ARRAY') {
+ unless(grep(/^\Q$status\E$/,@{$alltasks{$value}})) {
+ push(@{$alltasks{$value}},$status);
+ }
+ } else {
+ @{$alltasks{$value}} = ($status);
+ }
+ }
+ }
+ }
+ foreach my $option (@options) {
+ if ($alltasks{$option}) {
+ $val = $option;
+ last;
+ }
+ }
+ }
+ }
+ }
+ return $val;
+}
+
# =================================================================== Phase one
sub print_username_entry_form {
@@ -939,7 +1066,7 @@
&Apache::lonnet::inst_userrules($ccdomain,'username');
$usertype =
&Apache::lonuserutils::check_usertype($ccdomain,$ccuname,$rules,
- \%curr_rules,\%got_rules);
+ \%curr_rules,\%got_rules);
my $cancreate =
&Apache::lonuserutils::can_create_user($ccdomain,$context,
$usertype);
@@ -951,7 +1078,9 @@
);
my $response;
if ($env{'form.origform'} eq 'crtusername') {
- $response = '<span class="LC_warning">'.&mt('No match found for the username [_1] in LON-CAPA domain: [_2]','<b>'.$ccuname.'</b>',$ccdomain).
+ $response = '<span class="LC_warning">'.
+ &mt('No match found for the username [_1] in LON-CAPA domain: [_2]',
+ '<b>'.$ccuname.'</b>',$ccdomain).
'</span><br />';
}
$response .= '<p class="LC_warning">'
@@ -1068,12 +1197,15 @@
}
}
if ($newuser) {
- my $portfolioform;
+ my ($portfolioform,$domroleform);
if ((&Apache::lonnet::allowed('mpq',$env{'request.role.domain'})) ||
(&Apache::lonnet::allowed('mut',$env{'request.role.domain'}))) {
# Current user has quota or user tools modification privileges
$portfolioform = '<br />'.&portfolio_quota($ccuname,$ccdomain);
}
+ if (&Apache::lonnet::allowed('cau',$env{'request.role.domain'})) {
+ $domroleform = '<br />'.&domainrole_req($ccuname,$ccdomain);
+ }
&initialize_authen_forms($ccdomain,$formname);
my %lt=&Apache::lonlocal::texthash(
'cnu' => 'Create New User',
@@ -1119,7 +1251,8 @@
$r->print($home_server_pick);
}
if (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'})) {
- $r->print('<br /><h3>'.&mt('User Can Request Creation of Courses/Communities in this Domain?').'</h3>'.
+ $r->print('<br /><h3>'.
+ &mt('User Can Request Creation of Courses/Communities in this Domain?').'</h3>'.
&Apache::loncommon::start_data_table().
&build_tools_display($ccuname,$ccdomain,
'requestcourses').
@@ -1183,7 +1316,7 @@
} else {
$r->print(&Apache::lonuserutils::set_login($ccdomain,$authformkrb,$authformint,$authformloc));
}
- $r->print($portfolioform);
+ $r->print($portfolioform.$domroleform);
if ($env{'form.action'} eq 'singlestudent') {
$r->print(&date_sections_select($context,$newuser,$formname,
$permission));
@@ -1217,10 +1350,10 @@
$inst_results{$ccuname.':'.$ccdomain});
$r->print($personal_table);
if ($showforceid) {
- $r->print(&Apache::lonuserutils::forceid_change($context));
+ $r->print('<table>'.&Apache::lonuserutils::forceid_change($context).'</table>');
}
if (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'})) {
- $r->print('<h3>'.&mt('User Can Request Creation of Courses/Communities in this Domain?').'</h3>'.
+ $r->print('<br /><h3>'.&mt('User Can Request Creation of Courses/Communities in this Domain?').'</h3>'.
&Apache::loncommon::start_data_table());
if ($env{'request.role.domain'} eq $ccdomain) {
$r->print(&build_tools_display($ccuname,$ccdomain,'requestcourses'));
@@ -1231,12 +1364,19 @@
$r->print(&Apache::loncommon::end_data_table());
}
$r->print('</div>');
- my $user_auth_text = &user_authentication($ccuname,$ccdomain,$formname);
- my ($user_quota_text,$user_tools_text,$user_reqcrs_text);
+ my @order = ('auth','quota','tools','requestauthor');
+ my %user_text;
+ my ($isadv,$isauthor) =
+ &Apache::lonnet::is_advanced_user($ccuname,$ccdomain);
+ if ((!$isauthor) &&
+ (&Apache::lonnet::allowed('cau',$env{'request.role.domain'}))) {
+ $user_text{'requestauthor'} = &domainrole_req($ccuname,$ccdomain);
+ }
+ $user_text{'auth'} = &user_authentication($ccuname,$ccdomain,$formname);
if ((&Apache::lonnet::allowed('mpq',$ccdomain)) ||
(&Apache::lonnet::allowed('mut',$ccdomain))) {
# Current user has quota modification privileges
- $user_quota_text = &portfolio_quota($ccuname,$ccdomain);
+ $user_text{'quota'} = &portfolio_quota($ccuname,$ccdomain);
}
if (!&Apache::lonnet::allowed('mpq',$ccdomain)) {
if (&Apache::lonnet::allowed('mpq',$env{'request.role.domain'})) {
@@ -1248,7 +1388,7 @@
'youd' => "You do not have privileges to modify the portfolio quota for this user.",
'ichr' => "If a change is required, contact a domain coordinator for the domain",
);
- $user_quota_text = <<ENDNOPORTPRIV;
+ $user_text{'quota'} = <<ENDNOPORTPRIV;
<h3>$lt{'dska'}</h3>
$lt{'youd'} $lt{'ichr'}: $ccdomain
ENDNOPORTPRIV
@@ -1261,43 +1401,31 @@
'yodo' => "You do not have privileges to modify Portfolio, Blog, WebDAV, or Personal Information Page settings for this user.",
'ifch' => "If a change is required, contact a domain coordinator for the domain",
);
- $user_tools_text = <<ENDNOTOOLSPRIV;
+ $user_text{'tools'} = <<ENDNOTOOLSPRIV;
<h3>$lt{'utav'}</h3>
$lt{'yodo'} $lt{'ifch'}: $ccdomain
ENDNOTOOLSPRIV
}
}
- if ($user_auth_text ne '') {
- $r->print('<div class="LC_left_float">'.$user_auth_text);
- if ($user_quota_text ne '') {
- $r->print($user_quota_text);
- }
- if ($user_tools_text ne '') {
- $r->print($user_tools_text);
- }
- if ($env{'form.action'} eq 'singlestudent') {
- $r->print(&date_sections_select($context,$newuser,$formname));
- }
- } elsif ($user_quota_text ne '') {
- $r->print('<div class="LC_left_float">'.$user_quota_text);
- if ($user_tools_text ne '') {
- $r->print($user_tools_text);
- }
- if ($env{'form.action'} eq 'singlestudent') {
- $r->print(&date_sections_select($context,$newuser,$formname));
- }
- } elsif ($user_tools_text ne '') {
- $r->print('<div class="LC_left_float">'.$user_tools_text);
- if ($env{'form.action'} eq 'singlestudent') {
- $r->print(&date_sections_select($context,$newuser,$formname));
- }
- } else {
- if ($env{'form.action'} eq 'singlestudent') {
- $r->print('<div class="LC_left_float">'.
- &date_sections_select($context,$newuser,$formname));
+ my $gotdiv = 0;
+ foreach my $item (@order) {
+ if ($user_text{$item} ne '') {
+ unless ($gotdiv) {
+ $r->print('<div class="LC_left_float">');
+ $gotdiv = 1;
+ }
+ $r->print('<br />'.$user_text{$item});
}
}
- $r->print('</div><div class="LC_clear_float_footer"></div>');
+ if ($env{'form.action'} eq 'singlestudent') {
+ unless ($gotdiv) {
+ $r->print('<div class="LC_left_float">');
+ }
+ $r->print(&date_sections_select($context,$newuser,$formname));
+ }
+ if ($gotdiv) {
+ $r->print('</div><div class="LC_clear_float_footer"></div>');
+ }
if ($env{'form.action'} ne 'singlestudent') {
&display_existing_roles($r,$ccuname,$ccdomain,\%inccourses,$context,
$roledom,$crstype);
@@ -2316,6 +2444,7 @@
my @userinfo = ('firstname','middlename','lastname','generation','permanentemail','id');
my @usertools = ('aboutme','blog','webdav','portfolio');
my @requestcourses = ('official','unofficial','community');
+ my @requestauthor = ('requestauthor');
my ($othertitle,$usertypes,$types) =
&Apache::loncommon::sorted_inst_types($env{'form.ccdomain'});
my %canmodify_status =
@@ -2412,6 +2541,12 @@
\%changeHash,'requestcourses');
}
}
+ if ($env{'form.customrequestauthor'} == 1) {
+ $newcustom{'requestauthor'} = $env{'form.requestauthor'};
+ $changed{'requestauthor'} = &tool_admin('requestauthor',
+ $newcustom{'requestauthor'},
+ \%changeHash,'requestauthor');
+ }
}
if ($canmodify_status{'inststatus'}) {
if (exists($env{'form.inststatus'})) {
@@ -2470,7 +2605,8 @@
'tools.blog','tools.webdav','tools.portfolio',
'requestcourses.official','requestcourses.unofficial',
'requestcourses.community','reqcrsotherdom.official',
- 'reqcrsotherdom.unofficial','reqcrsotherdom.community'],
+ 'reqcrsotherdom.unofficial','reqcrsotherdom.community',
+ 'requestauthor'],
$env{'form.ccdomain'},$env{'form.ccuname'});
my ($tmp) = keys(%userenv);
if ($tmp =~ /^(con_lost|error)/i) {
@@ -2598,7 +2734,7 @@
$olddefquota,$oldsettingstatus,$newdefquota,$newsettingstatus);
@disporder = ('inststatus');
if ($env{'request.role.domain'} eq $env{'form.ccdomain'}) {
- push(@disporder,'requestcourses');
+ push(@disporder,'requestcourses','requestauthor');
} else {
push(@disporder,'reqcrsotherdom');
}
@@ -2622,6 +2758,9 @@
if (&Apache::lonnet::allowed('mau',$env{'form.ccdomain'})) {
$canshow{'inststatus'} = 1;
}
+ if (&Apache::lonnet::allowed('cau',$env{'form.ccdomain'})) {
+ $canshow{'requestauthor'} = 1;
+ }
my (%changeHash,%changed);
if ($oldinststatus eq '') {
$oldsettings{'inststatus'} = $othertitle;
@@ -2711,6 +2850,7 @@
if ($env{'form.ccdomain'} eq $env{'request.role.domain'}) {
&tool_changes('requestcourses',\@requestcourses,\%oldsettings,\%oldsettingstext,
\%userenv,\%changeHash,\%changed,\%newsettings,\%newsettingstext);
+ &tool_changes('requestauthor',\@requestauthor,\%oldsettings,\%oldsettingstext,\%userenv,\%changeHash,\%changed,\%newsettings,\%newsettingstext);
} else {
&tool_changes('reqcrsotherdom',\@requestcourses,\%oldsettings,\%oldsettingstext,
\%userenv,\%changeHash,\%changed,\%newsettings,\%newsettingstext);
@@ -2738,13 +2878,22 @@
|| ($key eq 'community')) {
$newenvhash{'environment.requestcourses.'.$key} =
$changeHash{'requestcourses.'.$key};
- if ($changeHash{'requestcourses.'.$key} ne '') {
+ if ($changeHash{'requestcourses.'.$key}) {
$newenvhash{'environment.canrequest.'.$key} = 1;
} else {
$newenvhash{'environment.canrequest.'.$key} =
&Apache::lonnet::usertools_access($env{'user.name'},$env{'user.domain'},
$key,'reload','requestcourses');
}
+ } elsif ($key eq 'requestauthor') {
+ $newenvhash{'environment.'.$key} = $changeHash{$key};
+ if ($changeHash{$key}) {
+ $newenvhash{'environment.canrequest.author'} = 1;
+ } else {
+ $newenvhash{'environment.canrequest.author'} =
+ &Apache::lonnet::usertools_access($env{'user.name'},$env{'user.domain'},
+ $key,'reload','requestauthor');
+ }
} elsif ($key ne 'quota') {
$newenvhash{'environment.tools.'.$key} =
$changeHash{'tools.'.$key};
@@ -2786,7 +2935,7 @@
((keys(%changed) > 0) && $chgresult eq 'ok')) {
# Tell the user we changed the name
&display_userinfo($r,1,\@disporder,\%canshow,\@requestcourses,
- \@usertools,\%userenv,\%changed,\%namechanged,
+ \@usertools,\@requestauthor,\%userenv,\%changed,\%namechanged,
\%oldsettings, \%oldsettingstext,\%newsettings,
\%newsettingstext);
if ($env{'form.cid'} ne $userenv{'id'}) {
@@ -2819,7 +2968,7 @@
# or ability to request creation of courses,
# but we can still tell them what the name and quota and availabilities are
&display_userinfo($r,undef,\@disporder,\%canshow,\@requestcourses,
- \@usertools,\%userenv,\%changed,\%namechanged,\%oldsettings,
+ \@usertools,\@requestauthor,\%userenv,\%changed,\%namechanged,\%oldsettings,
\%oldsettingstext,\%newsettings,\%newsettingstext);
}
if (@mod_disallowed) {
@@ -2896,12 +3045,13 @@
}
sub display_userinfo {
- my ($r,$changed,$order,$canshow,$requestcourses,$usertools,$userenv,
- $changedhash,$namechangedhash,$oldsetting,$oldsettingtext,
+ my ($r,$changed,$order,$canshow,$requestcourses,$usertools,$requestauthor,
+ $userenv,$changedhash,$namechangedhash,$oldsetting,$oldsettingtext,
$newsetting,$newsettingtext) = @_;
return unless (ref($order) eq 'ARRAY' &&
ref($canshow) eq 'HASH' &&
ref($requestcourses) eq 'ARRAY' &&
+ ref($requestauthor) eq 'ARRAY' &&
ref($usertools) eq 'ARRAY' &&
ref($userenv) eq 'HASH' &&
ref($changedhash) eq 'HASH' &&
@@ -2926,6 +3076,7 @@
'official' => 'Can Request Official Courses',
'unofficial' => 'Can Request Unofficial Courses',
'community' => 'Can Request Communities',
+ 'requestauthor' => 'Can Request Author Role',
'inststatus' => "Affiliation",
'prvs' => 'Previous Value:',
'chto' => 'Changed To:'
@@ -3121,25 +3272,29 @@
return;
}
foreach my $tool (@{$usertools}) {
- my $newval;
+ my ($newval,$envkey);
+ $envkey = $context.'.'.$tool;
if ($context eq 'requestcourses') {
$newval = $env{'form.crsreq_'.$tool};
if ($newval eq 'autolimit') {
$newval .= '='.$env{'form.crsreq_'.$tool.'_limit'};
}
+ } elsif ($context eq 'requestauthor') {
+ $newval = $env{'form.'.$context};
+ $envkey = $context;
} else {
$newval = $env{'form.'.$context.'_'.$tool};
}
- if ($userenv->{$context.'.'.$tool} ne '') {
+ if ($userenv->{$envkey} ne '') {
$oldaccess->{$tool} = &mt('custom');
- if ($userenv->{$context.'.'.$tool}) {
+ if ($userenv->{$envkey}) {
$oldaccesstext->{$tool} = &mt("availability set to 'on'");
} else {
$oldaccesstext->{$tool} = &mt("availability set to 'off'");
}
- $changeHash->{$context.'.'.$tool} = $userenv->{$context.'.'.$tool};
+ $changeHash->{$envkey} = $userenv->{$envkey};
if ($env{'form.custom'.$tool} == 1) {
- if ($newval ne $userenv->{$context.'.'.$tool}) {
+ if ($newval ne $userenv->{$envkey}) {
$changed->{$tool} = &tool_admin($tool,$newval,$changeHash,
$context);
if ($changed->{$tool}) {
@@ -3583,6 +3738,10 @@
if (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'})) {
$canchange = 1;
}
+ } elsif ($context eq 'requestauthor') {
+ if (&Apache::lonnet::allowed('cau',$env{'request.role.domain'})) {
+ $canchange = 1;
+ }
} elsif (&Apache::lonnet::allowed('mut',$env{'form.ccdomain'})) {
# Current user has quota modification privileges
$canchange = 1;
@@ -3591,7 +3750,11 @@
if ($canchange) {
if (ref($changeHash) eq 'HASH') {
$toolchanged = 1;
- $changeHash->{$context.'.'.$tool} = $settool;
+ if ($tool eq 'requestauthor') {
+ $changeHash->{$context} = $settool;
+ } else {
+ $changeHash->{$context.'.'.$tool} = $settool;
+ }
}
}
return $toolchanged;
@@ -4160,6 +4323,32 @@
} else {
&custom_role_editor($r,$brcrum);
}
+ } elsif (($env{'form.action'} eq 'processauthorreq') &&
+ ($permission->{'cusr'}) &&
+ (&Apache::lonnet::allowed('cau',$env{'request.role.domain'}))) {
+ push(@{$brcrum},
+ {href => '/adm/createuser?action=processauthorreq',
+ text => 'Authoring space requests',
+ help => 'Domain_Role_Approvals'});
+ $bread_crumbs_component = 'Authoring requests';
+ if ($env{'form.state'} eq 'done') {
+ push(@{$brcrum},
+ {href => '/adm/createuser?action=authorreqqueue',
+ text => 'Result',
+ help => 'Domain_Role_Approvals'});
+ $bread_crumbs_component = 'Authoring request result';
+ }
+ $args = { bread_crumbs => $brcrum,
+ bread_crumbs_component => $bread_crumbs_component};
+ $r->print(&header(undef,$args));
+ if (!exists($env{'form.state'})) {
+ $r->print(&Apache::loncoursequeueadmin::display_queued_requests('requestauthor',
+ $env{'request.role.domain'}));
+ } elsif ($env{'form.state'} eq 'done') {
+ $r->print('<h3>'.&mt('Authoring request processing').'</h3>'."\n");
+ $r->print(&Apache::loncoursequeueadmin::update_request_queue('requestauthor',
+ $env{'request.role.domain'}));
+ }
} elsif (($env{'form.action'} eq 'listusers') &&
($permission->{'view'} || $permission->{'cusr'})) {
if ($env{'form.phase'} eq 'bulkchange') {
@@ -4462,6 +4651,14 @@
permission => $permission->{'custom'},
linktitle => 'Configure a custom role.',
},
+ {
+ linktext => 'Authoring Space Requests',
+ icon => 'selfenrl-queue.png',
+ #help => 'Domain_Role_Approvals',
+ url => '/adm/createuser?action=processauthorreq',
+ permission => $permission->{'cusr'},
+ linktitle => 'Approve or reject author role requests',
+ },
);
}elsif ($context eq 'course'){
Index: loncom/interface/lonrequestcourse.pm
diff -u loncom/interface/lonrequestcourse.pm:1.63 loncom/interface/lonrequestcourse.pm:1.64
--- loncom/interface/lonrequestcourse.pm:1.63 Sun Mar 6 21:17:15 2011
+++ loncom/interface/lonrequestcourse.pm Tue Aug 14 15:45:06 2012
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Request a course
#
-# $Id: lonrequestcourse.pm,v 1.63 2011/03/06 21:17:15 raeburn Exp $
+# $Id: lonrequestcourse.pm,v 1.64 2012/08/14 15:45:06 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -3333,8 +3333,9 @@
};
my (@inststatuses,$storeresult,$creationresult);
my $val =
- &Apache::loncoursequeueadmin::get_processtype($env{'user.name'},$env{'user.domain'},
- $env{'user.adv'},$dom,$crstype,\@inststatuses,\%domconfig);
+ &Apache::loncoursequeueadmin::get_processtype('course',$env{'user.name'},
+ $env{'user.domain'},$env{'user.adv'},
+ $dom,$crstype,\@inststatuses,\%domconfig);
if ($val eq '') {
if ($crstype eq 'official') {
$output = &mt('You are not permitted to request creation of official courses.');
Index: loncom/auth/lonroles.pm
diff -u loncom/auth/lonroles.pm:1.269 loncom/auth/lonroles.pm:1.270
--- loncom/auth/lonroles.pm:1.269 Sat Jul 21 21:09:03 2012
+++ loncom/auth/lonroles.pm Tue Aug 14 15:45:25 2012
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# User Roles Screen
#
-# $Id: lonroles.pm,v 1.269 2012/07/21 21:09:03 raeburn Exp $
+# $Id: lonroles.pm,v 1.270 2012/08/14 15:45:25 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -225,6 +225,95 @@
$updateresult .= &update_session_roles();
&Apache::lonnet::appenv({'user.update.time' => $now});
$update = $now;
+ &reqauthor_check();
+ }
+
+# -------------------------------------------------- Check for author requests
+
+ my $reqauthor;
+ if ($env{'form.requestauthor'}) {
+ if ($env{'environment.canrequest.author'}) {
+ 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') {
+ if (&Apache::lonnet::assignrole($env{'user.domain'},$env{'user.name'},'/'.$env{'user.domain'}.'/',
+ 'au',undef,$now,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;
@@ -684,6 +773,12 @@
thisform.submit();
}
+function setToRequestAuthor(thisform) {
+ thisform.requestauthor.value='1';
+ thisform.selectrole.value='';
+ thisform.submit();
+}
+
// ]]>
</script>
ENDHEADER
@@ -750,7 +845,12 @@
&Apache::loncommon::end_page());
return OK;
} else {
- $r->print($updateresult);
+ if ($updateresult || $reqauthor) {
+ $r->print('<div>'.
+ $updateresult.
+ $reqauthor.
+ '</div>');
+ }
if (($ENV{'REDIRECT_QUERY_STRING'}) && ($fn)) {
$fn.='?'.$ENV{'REDIRECT_QUERY_STRING'};
}
@@ -778,6 +878,42 @@
'<input type="button" name="update" value="'.
$updatebutton.'" onclick="javascript:setToUpdate(this.form)" />';
}
+ my ($requestauthor,$requestcrs);
+ unless ($reqauthor) {
+ if ($env{'environment.canrequest.author'}) {
+ unless (&is_active_author()) {
+ my ($status,$timestamp) = split(/:/,$env{'environment.requestauthorqueued'});
+ if ($status eq 'approval') {
+ $requestauthor = &mt('A request for authoring space submitted on [_1] is awaiting approval',&Apache::lonlocal::locallocaltime($timestamp));
+ } elsif (($status eq 'approved') && ($do_update)) {
+ my %roleshash = &Apache::lonnet::get_my_roles($env{'user.name'},$env{'user.domain'},'userroles',
+ ['active'],['au'],[$env{'user.domain'}]);
+ if (keys(%roleshash)) {
+ $requestauthor = &mt('Your request for an author role has been approved.').'<br />';
+ if ($show_course) {
+ $requestauthor .= &mt('Use the "Check for new courses" button to update your list of roles.');
+ } else {
+ $requestauthor .= &mt('Use the "Check for new roles" button to update your list of roles.');
+ }
+ $requestauthor = '<span class="LC_info">'.$requestauthor.'</span>';
+ }
+ }
+ unless ($requestauthor) {
+ $requestauthor =
+ '<input type="hidden" name="requestauthor" value="" />'.
+ '<input type="button" name="reqauthor" value="'.
+ &mt('Request author space').'" '.
+ 'onclick="javascript:setToRequestAuthor(this.form)" />';
+ }
+ }
+ }
+ }
+ my $do_update;
+ unless (($env{'form.source'} eq 'login') || ($env{'form.doupdate'})) {
+ $do_update = '<input type="hidden" name="doupdate" value="" />'.
+ '<input type="button" name="update" value="'.
+ $updatebutton.'" onclick="javascript:setToUpdate(this.form)" />';
+ }
if ($env{'user.adv'}) {
my $showall = '<label><input type="checkbox" name="showall"';
if ($env{'form.showall'}) {
@@ -785,18 +921,37 @@
}
$showall .= ' />'.&mt('Show all roles').'</label> '.
'<input type="submit" value="'.&mt('Update display').'" />';
- if ($do_update) {
+ if ($do_update || $requestauthor) {
$r->print('<div class="LC_left_float"><fieldset>'.
'<legend>'. &mt('Display').'</legend>'.
- $showall.'</fieldset></div>'.
- '<div class="LC_left_float"><fieldset><legend>'.
- &mt('Changes?').'</legend>'.
- $do_update.'</fieldset></div><br clear="all" />');
+ $showall.'</fieldset></div>');
+ if ($do_update) {
+ $r->print('<div class="LC_left_float">'.
+ '<fieldset><legend>'.&mt('Changes?').'</legend>'.
+ $do_update.'</fieldset></div>');
+ }
+ if ($requestauthor) {
+ $r->print('<div class="LC_left_float">'.
+ '<fieldset><legend>'.&mt('Add author role').'</legend>'.
+ $requestauthor.'</fieldset>');
+ }
+ $r->print('</div><br clear="all" />');
} else {
$r->print($showall);
}
} else {
- $r->print('<p>'.$do_update.'</p>');
+ if ($do_update && $requestauthor) {
+ $r->print('<div class="LC_left_float">'.
+ '<fieldset><legend>'.&mt('Changes?').'</legend>'.
+ $do_update.'</fieldset></div>'.
+ '<div class="LC_left_float">'.
+ '<fieldset><legend>'.&mt('Add author role').'</legend>'.
+ $requestauthor.'</fieldset></div><br clear="all" />');
+ } elsif ($do_update) {
+ $r->print('<p>'.$do_update.'</p>');
+ } elsif ($requestauthor) {
+ $r->print('<p>'.$requestauthor.'</p>');
+ }
if ($countactive > 0) {
$r->print(&Apache::loncoursequeueadmin::queued_selfenrollment());
my $domdesc = &Apache::lonnet::domain($env{'user.domain'},'description');
@@ -976,6 +1131,33 @@
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 {
my ($update,$refresh,$now,$reinit,$nochoose,$roletext,$sortrole,$roleclass,$futureroles,$timezones,$loncaparev) = @_;
my ($countactive,$countfuture,$inrole,$possiblerole) = (0,0,0,'');
@@ -2204,7 +2386,7 @@
}
$msg .= '</ul>';
} else {
- $msg = ' <span class="LC_cusr_emph">'.$rolesmsg.'</span><br /><br />';
+ $msg = ' <span class="LC_cusr_emph">'.$rolesmsg.'</span><br />';
}
return $msg;
}
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.1182 loncom/lonnet/perl/lonnet.pm:1.1183
--- loncom/lonnet/perl/lonnet.pm:1.1182 Fri Aug 3 10:55:53 2012
+++ loncom/lonnet/perl/lonnet.pm Tue Aug 14 15:45:34 2012
@@ -1,7 +1,7 @@
# The LearningOnline Network
# TCP networking package
#
-# $Id: lonnet.pm,v 1.1182 2012/08/03 10:55:53 foxr Exp $
+# $Id: lonnet.pm,v 1.1183 2012/08/14 15:45:34 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1939,7 +1939,8 @@
my %domconfig =
&Apache::lonnet::get_dom('configuration',['defaults','quotas',
'requestcourses','inststatus',
- 'coursedefaults','usersessions'],$domain);
+ 'coursedefaults','usersessions',
+ 'requestauthor'],$domain);
if (ref($domconfig{'defaults'}) eq 'HASH') {
$domdefaults{'lang_def'} = $domconfig{'defaults'}{'lang_def'};
$domdefaults{'auth_def'} = $domconfig{'defaults'}{'auth_def'};
@@ -1970,6 +1971,9 @@
$domdefaults{$item} = $domconfig{'requestcourses'}{$item};
}
}
+ if (ref($domconfig{'requestauthor'}) eq 'HASH') {
+ $domdefaults{'requestauthor'} = $domconfig{'requestauthor'};
+ }
if (ref($domconfig{'inststatus'}) eq 'HASH') {
foreach my $item ('inststatustypes','inststatusorder') {
$domdefaults{$item} = $domconfig{'inststatus'}{$item};
@@ -5680,6 +5684,10 @@
unofficial => 1,
community => 1,
);
+ } elsif ($context eq 'requestauthor') {
+ %tools = (
+ requestauthor => 1,
+ );
} else {
%tools = (
aboutme => 1,
@@ -5699,25 +5707,32 @@
if ($action ne 'reload') {
if ($context eq 'requestcourses') {
return $env{'environment.canrequest.'.$tool};
+ } elsif ($context eq 'requestauthor') {
+ return $env{'environment.canrequest.author'};
} else {
return $env{'environment.availabletools.'.$tool};
}
}
}
- my ($toolstatus,$inststatus);
+ my ($toolstatus,$inststatus,$envkey);
+ if ($context eq 'requestauthor') {
+ $envkey = $context;
+ } else {
+ $envkey = $context.'.'.$tool;
+ }
if (($udom eq $env{'user.domain'}) && ($uname eq $env{'user.name'}) &&
($action ne 'reload')) {
- $toolstatus = $env{'environment.'.$context.'.'.$tool};
+ $toolstatus = $env{'environment.'.$envkey};
$inststatus = $env{'environment.inststatus'};
} else {
if (ref($userenvref) eq 'HASH') {
- $toolstatus = $userenvref->{$context.'.'.$tool};
+ $toolstatus = $userenvref->{$envkey};
$inststatus = $userenvref->{'inststatus'};
} else {
- my %userenv = &userenvironment($udom,$uname,$context.'.'.$tool,'inststatus');
- $toolstatus = $userenv{$context.'.'.$tool};
+ my %userenv = &userenvironment($udom,$uname,$envkey,'inststatus');
+ $toolstatus = $userenv{$envkey};
$inststatus = $userenv{'inststatus'};
}
}
@@ -7504,6 +7519,41 @@
}
}
}
+ } elsif ($context eq 'requestauthor') {
+ if (($udom eq $env{'user.domain'}) && ($uname eq $env{'user.name'}) &&
+ ($url eq '/'.$udom.'/') && ($role eq 'au')) {
+ if ($env{'environment.requestauthor'} eq 'automatic') {
+ $refused = '';
+ } else {
+ my %domdefaults = &get_domain_defaults($udom);
+ if (ref($domdefaults{'requestauthor'}) eq 'HASH') {
+ my $checkbystatus;
+ if ($env{'user.adv'}) {
+ my $disposition = $domdefaults{'requestauthor'}{'_LC_adv'};
+ if ($disposition eq 'automatic') {
+ $refused = '';
+ } elsif ($disposition eq '') {
+ $checkbystatus = 1;
+ }
+ } else {
+ $checkbystatus = 1;
+ }
+ if ($checkbystatus) {
+ if ($env{'environment.inststatus'}) {
+ my @inststatuses = split(/,/,$env{'environment.inststatus'});
+ foreach my $type (@inststatuses) {
+ if (($type ne '') &&
+ ($domdefaults{'requestauthor'}{$type} eq 'automatic')) {
+ $refused = '';
+ }
+ }
+ } elsif ($domdefaults{'requestauthor'}{'default'} eq 'automatic') {
+ $refused = '';
+ }
+ }
+ }
+ }
+ }
}
if ($refused) {
&logthis('Refused assignrole: '.$udom.' '.$uname.' '.$url.
More information about the LON-CAPA-cvs
mailing list