--- loncom/interface/loncreateuser.pm 2010/08/20 04:19:38 1.295.2.35 +++ loncom/interface/loncreateuser.pm 2022/11/23 02:55:37 1.465 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Create a user # -# $Id: loncreateuser.pm,v 1.295.2.35 2010/08/20 04:19:38 raeburn Exp $ +# $Id: loncreateuser.pm,v 1.465 2022/11/23 02:55:37 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -71,6 +71,7 @@ use Apache::longroup; use Apache::lonuserutils; use Apache::loncoursequeueadmin; use LONCAPA qw(:DEFAULT :match); +use HTML::Entities; my $loginscript; # piece of javascript used in two separate instances my $authformnop; @@ -78,6 +79,7 @@ my $authformkrb; my $authformint; my $authformfsys; my $authformloc; +my $authformlti; sub initialize_authen_forms { my ($dom,$formname,$curr_authtype,$mode) = @_; @@ -88,7 +90,7 @@ sub initialize_authen_forms { domain => $dom, ); my %abv_auth = &auth_abbrev(); - if ($curr_authtype =~ /^(krb4|krb5|internal|localauth|unix):(.*)$/) { + if ($curr_authtype =~ /^(krb4|krb5|internal|localauth|unix|lti):(.*)$/) { my $long_auth = $1; my $curr_autharg = $2; my %abv_auth = &auth_abbrev(); @@ -107,111 +109,131 @@ sub initialize_authen_forms { $authformint = &Apache::loncommon::authform_internal(%param); $authformfsys = &Apache::loncommon::authform_filesystem(%param); $authformloc = &Apache::loncommon::authform_local(%param); + $authformlti = &Apache::loncommon::authform_lti(%param); } 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', + lti => 'lti', ); 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; } @@ -223,7 +245,9 @@ 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)", 'portfolio' => "Personal User Portfolio", + 'timezone' => "Can set Time Zone", 'avai' => "Available", 'cusa' => "availability", 'chse' => "Change setting", @@ -232,12 +256,18 @@ 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', + 'lti' => 'Can request creation of LTI courses', + 'requestauthor' => 'Can request author space', ); + $isadv = &Apache::lonnet::is_advanced_user($ccdomain,$ccuname); 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','requestcourses.lti'); + @usertools = ('official','unofficial','community','textbook','placement','lti'); @options =('norequest','approval','autolimit','validate'); %validations = &Apache::lonnet::auto_courserequest_checks($ccdomain); %reqtitles = &courserequest_titles(); @@ -245,21 +275,37 @@ sub build_tools_display { $colspan = ' colspan="2"'; %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'); - @usertools = ('aboutme','blog','portfolio'); + 'tools.aboutme','tools.portfolio','tools.blog', + 'tools.webdav','tools.timezone'); + @usertools = ('aboutme','blog','webdav','portfolio','timezone'); } foreach my $item (@usertools) { my ($custom_access,$curr_access,$cust_on,$cust_off,$tool_on,$tool_off, $currdisp,$custdisp,$custradio); $cust_off = 'checked="checked" '; $tool_on = 'checked="checked" '; - $curr_access = + $curr_access = &Apache::lonnet::usertools_access($ccuname,$ccdomain,$item,undef, - $context); - if ($userenv{$context.'.'.$item} ne '') { + $context,\%userenv,'', + {'is_adv' => $isadv}); + 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 = ''; } @@ -269,6 +315,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 = @@ -290,15 +342,28 @@ 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); - 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'; @@ -336,35 +401,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'}.':