--- loncom/interface/loncreateuser.pm 2013/03/01 04:55:34 1.375 +++ loncom/interface/loncreateuser.pm 2017/03/26 22:19:24 1.437 @@ -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.437 2017/03/26 22:19:24 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -122,96 +122,114 @@ 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(); - if (&Apache::lonnet::allowed('mut',$ccdomain)) { + if ((&Apache::lonnet::allowed('mut',$ccdomain)) || + (&Apache::lonnet::allowed('udp',$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". + ' '. + &mt('Current quota: [_1] MB',$currquota).'  '. + $defaultinfo.''."\n". + &Apache::loncommon::end_data_table_row()."\n". + &Apache::loncommon::start_data_table_row()."\n". + ' '.$lt{'chqu'}. + ':  '. + '  '. + ' '.&mt('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,16 @@ 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', + 'placement' => 'Can request creation of placement tests', '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', + 'requestcourses.placement'); + @usertools = ('official','unofficial','community','textbook','placement'); @options =('norequest','approval','autolimit','validate'); %validations = &Apache::lonnet::auto_courserequest_checks($ccdomain); %reqtitles = &courserequest_titles(); @@ -247,7 +268,7 @@ sub build_tools_display { $colspan = ' colspan="2"'; %domconfig = &Apache::lonnet::get_dom('configuration',['requestcourses'],$ccdomain); - $isadv = &Apache::lonnet::is_advanced_user($ccuname,$ccdomain); + $isadv = &Apache::lonnet::is_advanced_user($ccdomain,$ccuname); } elsif ($context eq 'requestauthor') { %userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname, 'requestauthor'); @@ -314,6 +335,7 @@ sub build_tools_display { ' '.$lt{$item}.''."\n". ' '."\n". &Apache::loncommon::start_data_table_row()."\n"; + if (($context eq 'requestcourses') || ($context eq 'requestauthor')) { my ($curroption,$currlimit); my $envkey = $context.'.'.$item; @@ -408,7 +430,9 @@ sub build_tools_display { } $output .= ' '.$custom_access.(' 'x4). $lt{'avai'}.': '.$currdisp.''."\n". - &Apache::loncommon::end_data_table_row()."\n". + &Apache::loncommon::end_data_table_row()."\n"; + unless (&Apache::lonnet::allowed('udp',$ccdomain)) { + $output .= &Apache::loncommon::start_data_table_row()."\n". ' '. $lt{'chse'}.':