--- loncom/interface/loncreateuser.pm 2009/11/28 21:33:53 1.329 +++ loncom/interface/loncreateuser.pm 2017/08/11 00:24:53 1.446 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Create a user # -# $Id: loncreateuser.pm,v 1.329 2009/11/28 21:33:53 raeburn Exp $ +# $Id: loncreateuser.pm,v 1.446 2017/08/11 00:24:53 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -111,107 +111,125 @@ sub initialize_authen_forms { sub auth_abbrev { my %abv_auth = ( - krb5 => 'krb', - krb4 => 'krb', - internal => 'int', - localuth => 'loc', - unix => 'fsys', + krb5 => 'krb', + krb4 => 'krb', + internal => 'int', + localauth => 'loc', + unix => 'fsys', ); return %abv_auth; } # ==================================================== -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; } @@ -219,10 +237,11 @@ END_SCRIPT sub build_tools_display { my ($ccuname,$ccdomain,$context) = @_; my (@usertools,%userenv,$output,@options,%validations,%reqtitles,%reqdisplay, - $colspan); + $colspan,$isadv,%domconfig); 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)", 'portfolio' => "Personal User Portfolio", 'avai' => "Available", 'cusa' => "availability", @@ -232,21 +251,39 @@ 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(); %reqdisplay = &courserequest_display(); $colspan = ' colspan="2"'; + %domconfig = + &Apache::lonnet::get_dom('configuration',['requestcourses'],$ccdomain); + $isadv = &Apache::lonnet::is_advanced_user($ccdomain,$ccuname); + } 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'); - @usertools = ('aboutme','blog','portfolio'); + 'tools.aboutme','tools.portfolio','tools.blog', + 'tools.webdav'); + @usertools = ('aboutme','blog','webdav','portfolio'); } foreach my $item (@usertools) { my ($custom_access,$curr_access,$cust_on,$cust_off,$tool_on,$tool_off, @@ -256,7 +293,12 @@ sub build_tools_display { $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 = ''; } @@ -266,6 +308,12 @@ sub build_tools_display { } 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 = @@ -287,9 +335,29 @@ sub build_tools_display { ' '.$lt{$item}.''."\n". ' '."\n". &Apache::loncommon::start_data_table_row()."\n"; - if ($context eq 'requestcourses') { + + if (($context eq 'requestcourses') || ($context eq 'requestauthor')) { my ($curroption,$currlimit); - $curroption = $userenv{$context.'.'.$item}; + my $envkey = $context.'.'.$item; + if ($context eq 'requestauthor') { + $envkey = $context; + } + if ($userenv{$envkey} ne '') { + $curroption = $userenv{$envkey}; + } else { + my (@inststatuses); + 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'; } @@ -326,35 +394,45 @@ sub build_tools_display { $checked = ' checked="checked"'; } } + my $name = 'crsreq_'.$item; + if ($context eq 'requestauthor') { + $name = $item; + } $custdisp .= ' '; if ($option eq 'autolimit') { - $custdisp .= '
'. $reqtitles{'unlimited'}; - } else { - $custdisp .= ''; - } - $custdisp .= ''; + } else { + $custdisp .= ''; + } + $custdisp .= ''; } $custdisp .= ''; $custradio = ''.&mt('Custom setting').'
'.$custdisp; } else { $currdisp = ($curr_access?&mt('Yes'):&mt('No')); + my $name = $context.'_'.$item; + if ($context eq 'requestauthor') { + $name = $context; + } $custdisp = '  '; $custradio = (' 'x2).'--'.$lt{'cusa'}.': '.$custdisp. ''; } $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'}.':