--- loncom/interface/loncreateuser.pm 2013/03/01 04:55:34 1.375
+++ loncom/interface/loncreateuser.pm 2014/01/22 18:01:43 1.387
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Create a user
#
-# $Id: loncreateuser.pm,v 1.375 2013/03/01 04:55:34 raeburn Exp $
+# $Id: loncreateuser.pm,v 1.387 2014/01/22 18:01:43 bisitz Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -122,66 +122,42 @@ sub auth_abbrev {
# ====================================================
-sub portfolio_quota {
+sub user_quotas {
my ($ccuname,$ccdomain) = @_;
my %lt = &Apache::lonlocal::texthash(
'usrt' => "User Tools",
- 'disk' => "Disk space allocated to user's portfolio files",
'cuqu' => "Current quota",
'cust' => "Custom quota",
'defa' => "Default",
'chqu' => "Change quota",
);
- my ($currquota,$quotatype,$inststatus,$defquota) =
- &Apache::loncommon::get_user_quota($ccuname,$ccdomain);
- my ($usertypes,$order) = &Apache::lonnet::retrieve_inst_usertypes($ccdomain);
- my ($longinsttype,$showquota,$custom_on,$custom_off,$defaultinfo);
- if ($inststatus ne '') {
- if ($usertypes->{$inststatus} ne '') {
- $longinsttype = $usertypes->{$inststatus};
- }
- }
- $custom_on = ' ';
- $custom_off = ' checked="checked" ';
+
my $quota_javascript = <<"END_SCRIPT";
END_SCRIPT
- if ($quotatype eq 'custom') {
- $custom_on = $custom_off;
- $custom_off = ' ';
- $showquota = $currquota;
- if ($longinsttype eq '') {
- $defaultinfo = &mt('For this user, the default quota would be [_1]'
- .' Mb.',$defquota);
- } else {
- $defaultinfo = &mt("For this user, the default quota would be [_1]".
- " Mb, as determined by the user's institutional".
- " affiliation ([_2]).",$defquota,$longinsttype);
- }
- } else {
- if ($longinsttype eq '') {
- $defaultinfo = &mt('For this user, the default quota is [_1]'
- .' Mb.',$defquota);
- } else {
- $defaultinfo = &mt("For this user, the default quota of [_1]".
- " Mb, is determined by the user's institutional".
- " affiliation ([_2]).",$defquota,$longinsttype);
- }
- }
-
+ my $longinsttype;
+ my ($usertypes,$order) = &Apache::lonnet::retrieve_inst_usertypes($ccdomain);
my $output = $quota_javascript."\n".
'
'.$lt{'usrt'}.'
'."\n".
&Apache::loncommon::start_data_table();
@@ -189,29 +165,71 @@ END_SCRIPT
if (&Apache::lonnet::allowed('mut',$ccdomain)) {
$output .= &build_tools_display($ccuname,$ccdomain,'tools');
}
- if (&Apache::lonnet::allowed('mpq',$ccdomain)) {
- $output .= ''."\n".
- ' '.$lt{'disk'}.' | '."\n".
- '
'."\n".
- &Apache::loncommon::start_data_table_row()."\n".
- ' '.$lt{'cuqu'}.': '.
- $currquota.' Mb. '.
- $defaultinfo.' | '."\n".
- &Apache::loncommon::end_data_table_row()."\n".
- &Apache::loncommon::start_data_table_row()."\n".
- ' '.$lt{'chqu'}.
- ': '.
- ' '.
- ' Mb | '."\n".
- &Apache::loncommon::end_data_table_row()."\n";
- }
+
+ my %titles = &Apache::lonlocal::texthash (
+ portfolio => "Disk space allocated to user's portfolio files",
+ author => "Disk space allocated to user's Authoring Space (if role assigned)",
+ );
+ foreach my $name ('portfolio','author') {
+ my ($currquota,$quotatype,$inststatus,$defquota) =
+ &Apache::loncommon::get_user_quota($ccuname,$ccdomain,$name);
+ if ($longinsttype eq '') {
+ if ($inststatus ne '') {
+ if ($usertypes->{$inststatus} ne '') {
+ $longinsttype = $usertypes->{$inststatus};
+ }
+ }
+ }
+ my ($showquota,$custom_on,$custom_off,$defaultinfo);
+ $custom_on = ' ';
+ $custom_off = ' checked="checked" ';
+ if ($quotatype eq 'custom') {
+ $custom_on = $custom_off;
+ $custom_off = ' ';
+ $showquota = $currquota;
+ if ($longinsttype eq '') {
+ $defaultinfo = &mt('For this user, the default quota would be [_1]'
+ .' MB.',$defquota);
+ } else {
+ $defaultinfo = &mt("For this user, the default quota would be [_1]".
+ " MB, as determined by the user's institutional".
+ " affiliation ([_2]).",$defquota,$longinsttype);
+ }
+ } else {
+ if ($longinsttype eq '') {
+ $defaultinfo = &mt('For this user, the default quota is [_1]'
+ .' MB.',$defquota);
+ } else {
+ $defaultinfo = &mt("For this user, the default quota of [_1]".
+ " MB, is determined by the user's institutional".
+ " affiliation ([_2]).",$defquota,$longinsttype);
+ }
+ }
+
+ if (&Apache::lonnet::allowed('mpq',$ccdomain)) {
+ $output .= ''."\n".
+ ' '.$titles{$name}.' | '."\n".
+ '
'."\n".
+ &Apache::loncommon::start_data_table_row()."\n".
+ ' '.$lt{'cuqu'}.': '.
+ $currquota.' MB. '.
+ $defaultinfo.' | '."\n".
+ &Apache::loncommon::end_data_table_row()."\n".
+ &Apache::loncommon::start_data_table_row()."\n".
+ ' '.$lt{'chqu'}.
+ ': '.
+ ' '.
+ ' MB | '."\n".
+ &Apache::loncommon::end_data_table_row()."\n";
+ }
+ }
$output .= &Apache::loncommon::end_data_table();
return $output;
}
@@ -223,7 +241,7 @@ sub build_tools_display {
my %lt = &Apache::lonlocal::texthash (
'blog' => "Personal User Blog",
'aboutme' => "Personal Information Page",
- 'webdav' => "WebDAV access to authoring spaces (if SSL and author/co-author)",
+ 'webdav' => "WebDAV access to Authoring Spaces (if SSL and author/co-author)",
'portfolio' => "Personal User Portfolio",
'avai' => "Available",
'cusa' => "availability",
@@ -233,13 +251,14 @@ sub build_tools_display {
'official' => 'Can request creation of official courses',
'unofficial' => 'Can request creation of unofficial courses',
'community' => 'Can request creation of communities',
+ 'textbook' => 'Can request creation of textbook courses',
'requestauthor' => 'Can request author space',
);
if ($context eq 'requestcourses') {
%userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname,
'requestcourses.official','requestcourses.unofficial',
- 'requestcourses.community');
- @usertools = ('official','unofficial','community');
+ 'requestcourses.community','requestcourses.textbook');
+ @usertools = ('official','unofficial','community','textbook');
@options =('norequest','approval','autolimit','validate');
%validations = &Apache::lonnet::auto_courserequest_checks($ccdomain);
%reqtitles = &courserequest_titles();
@@ -428,12 +447,13 @@ sub coursereq_externaluser {
'official' => 'Can request creation of official courses',
'unofficial' => 'Can request creation of unofficial courses',
'community' => 'Can request creation of communities',
+ 'textbook' => 'Can request creation of textbook courses',
);
%userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname,
'reqcrsotherdom.official','reqcrsotherdom.unofficial',
- 'reqcrsotherdom.community');
- @usertools = ('official','unofficial','community');
+ 'reqcrsotherdom.community','reqcrsotherdom.textbook');
+ @usertools = ('official','unofficial','community','textbook');
@options = ('approval','validate','autolimit');
%validations = &Apache::lonnet::auto_courserequest_checks($cdom);
my $optregex = join('|',@options);
@@ -513,6 +533,7 @@ sub courserequest_titles {
official => 'Official',
unofficial => 'Unofficial',
community => 'Communities',
+ textbook => 'Textbook',
norequest => 'Not allowed',
approval => 'Approval by Dom. Coord.',
validate => 'With validation',
@@ -550,6 +571,15 @@ sub requestauthor_display {
return %titles;
}
+sub requestchange_display {
+ my %titles = &Apache::lonlocal::texthash (
+ approval => "availability set to 'on' (approval required)",
+ automatic => "availability set to 'on' (automatic approval)",
+ norequest => "availability set to 'off'",
+ );
+ return %titles;
+}
+
sub curr_requestauthor {
my ($uname,$udom,$isadv,$inststatuses,$domconfig) = @_;
return unless ((ref($inststatuses) eq 'ARRAY') && (ref($domconfig) eq 'HASH'));
@@ -970,7 +1000,7 @@ ENDSCRIPT
$r->print('');
}
}
- $r->print('';
return $outcome;
}
sub quota_admin {
- my ($setquota,$changeHash) = @_;
+ my ($setquota,$changeHash,$name) = @_;
my $quotachanged;
if (&Apache::lonnet::allowed('mpq',$env{'form.ccdomain'})) {
# Current user has quota modification privileges
if (ref($changeHash) eq 'HASH') {
$quotachanged = 1;
- $changeHash->{'portfolioquota'} = $setquota;
+ $changeHash->{$name.'quota'} = $setquota;
}
}
return $quotachanged;
@@ -4073,7 +4253,7 @@ sub custom_role_editor {
$r->print('
');
$r->print(<
+');
+ $result =
+ &Apache::lonnet::assigncustomrole(
+ $env{'user.domain'},$env{'user.name'},
+ $url,
+ $env{'user.domain'},$env{'user.name'},
+ $rolename,undef,undef,undef,$context);
+ if ($result ne 'ok') {
+ $errmsg = ': '.$result;
+ }
+ $message .=
+ '
'
+ .&Apache::lonhtmlcommon::confirm_success(
+ &mt('Assigning Role to Self').$errmsg, ($result eq 'ok' ? 0 : 1));
+ }
+ $r->print(
+ &Apache::loncommon::confirmwrapper($message)
+ .'
'
+ .&Apache::lonhtmlcommon::actionbox([
+ ''
+ .&mt('Create or edit another custom role')
+ .''])
+ .''
+ );
}
# ================================================================ Main Handler
@@ -4453,7 +4656,7 @@ sub handler {
(&Apache::lonnet::allowed('cau',$env{'request.role.domain'}))) {
push(@{$brcrum},
{href => '/adm/createuser?action=processauthorreq',
- text => 'Authoring space requests',
+ text => 'Authoring Space requests',
help => 'Domain_Role_Approvals'});
$bread_crumbs_component = 'Authoring requests';
if ($env{'form.state'} eq 'done') {
@@ -4748,6 +4951,7 @@ function updateCols(caller) {
document.getElementById('showcolrole').disabled = 'disabled';
}
if (context == 'domain') {
+ var quotausageshow = 0;
if ((document.studentform.roletype.options[document.studentform.roletype.selectedIndex].value == 'course') ||
(document.studentform.roletype.options[document.studentform.roletype.selectedIndex].value == 'community')) {
document.getElementById('showcolstatus').checked = false;
@@ -4767,6 +4971,16 @@ function updateCols(caller) {
document.getElementById('showcolextent').checked = 'false';
document.getElementById('showextent').style.display='none';
document.getElementById('showcoltextextent').innerHTML = '';
+ if ((document.studentform.showrole.options[document.studentform.showrole.selectedIndex].value == 'au') ||
+ (document.studentform.showrole.options[document.studentform.showrole.selectedIndex].value == 'Any')) {
+ if (document.getElementById('showcolauthorusage')) {
+ document.getElementById('showcolauthorusage').disabled = '';
+ }
+ if (document.getElementById('showcolauthorquota')) {
+ document.getElementById('showcolauthorquota').disabled = '';
+ }
+ quotausageshow = 1;
+ }
} else {
document.getElementById('showextent').style.display='block';
document.getElementById('showextent').style.textAlign='left';
@@ -4785,6 +4999,16 @@ function updateCols(caller) {
}
}
}
+ if (quotausageshow == 0) {
+ if (document.getElementById('showcolauthorusage')) {
+ document.getElementById('showcolauthorusage').checked = false;
+ document.getElementById('showcolauthorusage').disabled = 'disabled';
+ }
+ if (document.getElementById('showcolauthorquota')) {
+ document.getElementById('showcolauthorquota').checked = false;
+ document.getElementById('showcolauthorquota').disabled = 'disabled';
+ }
+ }
}
}
return;
@@ -6025,7 +6249,7 @@ sub role_display_filter {
&mt('Context:').'