--- loncom/interface/loncreateuser.pm 2013/12/09 21:33:32 1.382 +++ loncom/interface/loncreateuser.pm 2013/12/17 06:41:44 1.383 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Create a user # -# $Id: loncreateuser.pm,v 1.382 2013/12/09 21:33:32 raeburn Exp $ +# $Id: loncreateuser.pm,v 1.383 2013/12/17 06:41:44 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -189,19 +189,19 @@ END_SCRIPT $showquota = $currquota; if ($longinsttype eq '') { $defaultinfo = &mt('For this user, the default quota would be [_1]' - .' Mb.',$defquota); + .' MB.',$defquota); } else { $defaultinfo = &mt("For this user, the default quota would be [_1]". - " Mb, as determined by the user's institutional". + " 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); + .' MB.',$defquota); } else { $defaultinfo = &mt("For this user, the default quota of [_1]". - " Mb, is determined by the user's institutional". + " MB, is determined by the user's institutional". " affiliation ([_2]).",$defquota,$longinsttype); } } @@ -212,7 +212,7 @@ END_SCRIPT ' '."\n". &Apache::loncommon::start_data_table_row()."\n". ' '.$lt{'cuqu'}.': '. - $currquota.' Mb.  '. + $currquota.' MB.  '. $defaultinfo.''."\n". &Apache::loncommon::end_data_table_row()."\n". &Apache::loncommon::start_data_table_row()."\n". @@ -220,13 +220,13 @@ END_SCRIPT ':  '. + ' />'.$lt{'defa'}.' ('.$defquota.' MB). '. '  '. ' Mb'."\n". + ' /> MB'."\n". &Apache::loncommon::end_data_table_row()."\n"; } } @@ -568,6 +568,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')); @@ -1225,7 +1234,8 @@ ENDFORMINFO # Current user has quota or user tools modification privileges $portfolioform = '
'.&user_quotas($ccuname,$ccdomain); } - if (&Apache::lonnet::allowed('cau',$env{'request.role.domain'})) { + if ((&Apache::lonnet::allowed('cau',$env{'request.role.domain'})) && + ($ccdomain eq $env{'request.role.domain'})) { $domroleform = '
'.&domainrole_req($ccuname,$ccdomain); } &initialize_authen_forms($ccdomain,$formname); @@ -1392,7 +1402,8 @@ ENDCHANGEUSER my ($isadv,$isauthor) = &Apache::lonnet::is_advanced_user($ccuname,$ccdomain); if ((!$isauthor) && - (&Apache::lonnet::allowed('cau',$env{'request.role.domain'}))) { + (&Apache::lonnet::allowed('cau',$env{'request.role.domain'})) + && ($env{'request.role.domain'} eq $ccdomain)) { $user_text{'requestauthor'} = &domainrole_req($ccuname,$ccdomain); } $user_text{'auth'} = &user_authentication($ccuname,$ccdomain,$formname); @@ -2597,7 +2608,8 @@ sub update_user_data { $newcustom{$item} = $env{'form.crsreq_'.$item}; if ($env{'form.crsreq_'.$item} eq 'autolimit') { $newcustom{$item} .= '='; - unless ($env{'form.crsreq_'.$item.'_limit'} =~ /\D/) { + $env{'form.crsreq_'.$item.'_limit'} =~ s/\D+//g; + if ($env{'form.crsreq_'.$item.'_limit'}) { $newcustom{$item} .= $env{'form.crsreq_'.$item.'_limit'}; } } @@ -2923,9 +2935,13 @@ sub update_user_data { } if ($oldisdefault{$name}) { $oldsettingstext{'quota'}{$name} = &get_defaultquota_text($oldsettingstatus{$name}); + } else { + $oldsettingstext{'quota'}{$name} = &mt('custom quota: [_1] MB',$oldquota{$name}); } if ($newisdefault{$name}) { $newsettingstext{'quota'}{$name} = &get_defaultquota_text($newsettingstatus{$name}); + } else { + $newsettingstext{'quota'}{$name} = &mt('custom quota: [_1] MB',$newquota{$name}); } } &tool_changes('tools',\@usertools,\%oldsettings,\%oldsettingstext,\%userenv, @@ -2945,8 +2961,8 @@ sub update_user_data { } } foreach my $name ('portfolio','author') { - $oldsettings{'quota'}{$name} = $oldquota{$name}.' Mb'; - $newsettings{'quota'}{$name} = $newquota{$name}.' Mb'; + $oldsettings{'quota'}{$name} = $oldquota{$name}.' MB'; + $newsettings{'quota'}{$name} = $newquota{$name}.' MB'; } if ((keys(%namechanged) > 0) || (keys(%changed) > 0)) { my ($chgresult,$namechgresult); @@ -3178,67 +3194,83 @@ sub display_userinfo { $r->print(''.$lt{'chto'}.''); $r->print(&Apache::loncommon::end_data_table_header_row()); my @userinfo = ('firstname','middlename','lastname','generation','permanentemail','id'); - foreach my $item (@userinfo) { my $value = $env{'form.c'.$item}; #show changes only: - unless($value eq $userenv->{$item}){ + unless ($value eq $userenv->{$item}){ $r->print(&Apache::loncommon::start_data_table_row()); - $r->print("$lt{$item}\n"); - $r->print(''.$userenv->{$item}.' '); + $r->print("".$userenv->{$item}."\n"); $r->print("$value \n"); - $r->print(&Apache::loncommon::end_data_table_row()); } } foreach my $entry (@{$order}) { - if ($canshow->{$entry} && ($newsetting->{$entry} ne $newsetting->{$entry})) { - $r->print(&Apache::loncommon::start_data_table_row()); - if (($entry eq 'requestcourses') || ($entry eq 'reqcrsotherdom')) { - foreach my $item (@{$requestcourses}) { - $r->print("$lt{$item}\n"); - $r->print("$oldsetting->{$item} $oldsettingtext->{$item}\n"); - my $value = $newsetting->{$item}.' '.$newsettingtext->{$item}; - if ($changedhash->{$item}) { - $value = ''.$value.''; + if ($canshow->{$entry}) { + if (($entry eq 'requestcourses') || ($entry eq 'reqcrsotherdom') || ($entry eq 'requestauthor')) { + my @items; + if ($entry eq 'requestauthor') { + @items = ($entry); + } else { + @items = @{$requestcourses}; + } + foreach my $item (@items) { + if (($newsetting->{$item} ne $oldsetting->{$item}) || + ($newsettingtext->{$item} ne $oldsettingtext->{$item})) { + $r->print(&Apache::loncommon::start_data_table_row()."\n"); + $r->print("$lt{$item}\n"); + $r->print("".$oldsetting->{$item}); + if ($oldsettingtext->{$item}) { + if ($oldsetting->{$item}) { + $r->print(' -- '); + } + $r->print($oldsettingtext->{$item}); + } + $r->print("\n"); + $r->print("".$newsetting->{$item}); + if ($newsettingtext->{$item}) { + if ($newsetting->{$item}) { + $r->print(' -- '); + } + $r->print($newsettingtext->{$item}); + } + $r->print("\n"); + $r->print(&Apache::loncommon::end_data_table_row()."\n"); } - $r->print("$value \n"); } } elsif ($entry eq 'tools') { foreach my $item (@{$usertools}) { - $r->print("$lt{$item}\n"); - $r->print("$oldsetting->{$item} $oldsettingtext->{$item}\n"); - my $value = $newsetting->{$item}.' '.$newsettingtext->{$item}; - if ($changedhash->{$item}) { - $value = ''.$value.''; + if ($newsetting->{$item} ne $oldsetting->{$item}) { + $r->print(&Apache::loncommon::start_data_table_row()."\n"); + $r->print("$lt{$item}\n"); + $r->print("".$oldsetting->{$item}.' '.$oldsettingtext->{$item}."\n"); + $r->print("".$newsetting->{$item}.' '.$newsettingtext->{$item}."\n"); + $r->print(&Apache::loncommon::end_data_table_row()."\n"); } - $r->print("$value \n"); } } elsif ($entry eq 'quota') { if ((ref($oldsetting->{$entry}) eq 'HASH') && (ref($oldsettingtext->{$entry}) eq 'HASH') && (ref($newsetting->{$entry}) eq 'HASH') && (ref($newsettingtext->{$entry}) eq 'HASH')) { foreach my $name ('portfolio','author') { - $r->print("$lt{$name.$entry}\n"); - $r->print("$oldsetting->{$entry}->{$name} $oldsettingtext->{$entry}->{$name} \n"); - my $value = $newsetting->{$entry}->{$name}.' '.$newsettingtext->{$entry}->{$name}; - if ($changedhash->{$entry}) { - $value = ''.$value.''; + if ($newsetting->{$entry}->{$name} ne $oldsetting->{$entry}->{$name}) { + $r->print(&Apache::loncommon::start_data_table_row()."\n"); + $r->print("$lt{$name.$entry}\n"); + $r->print("".$oldsettingtext->{$entry}->{$name}."\n"); + $r->print("".$newsettingtext->{$entry}->{$name}."\n"); + $r->print(&Apache::loncommon::end_data_table_row()."\n"); } - $r->print("$value \n"); } } } else { - $r->print("$lt{$entry}\n"); - $r->print("$oldsetting->{$entry} $oldsettingtext->{$entry} \n"); - my $value = $newsetting->{$entry}.' '.$newsettingtext->{$entry}; - if ($changedhash->{$entry}) { - $value = ''.$value.''; + if ($newsetting->{$entry} ne $oldsetting->{$entry}) { + $r->print(&Apache::loncommon::start_data_table_row()."\n"); + $r->print("$lt{$entry}\n"); + $r->print("".$oldsetting->{$entry}.' '.$oldsettingtext->{$entry}."\n"); + $r->print("".$newsetting->{$entry}.' '.$newsettingtext->{$entry}."\n"); + $r->print(&Apache::loncommon::end_data_table_row()."\n"); } - $r->print("$value \n"); } - $r->print(&Apache::loncommon::end_data_table_row()); } } $r->print(&Apache::loncommon::end_data_table().'
'); @@ -3258,20 +3290,20 @@ sub tool_changes { (ref($newaccess) eq 'HASH') && (ref($newaccesstext) eq 'HASH'))) { return; } + my %reqdisplay = &requestchange_display(); if ($context eq 'reqcrsotherdom') { my @options = ('approval','validate','autolimit'); my $optregex = join('|',@options); - my %reqdisplay = &courserequest_display(); my $cdom = $env{'request.role.domain'}; foreach my $tool (@{$usertools}) { - $oldaccesstext->{$tool} = &mt('No'); + $oldaccesstext->{$tool} = &mt("availability set to 'off'"); $newaccesstext->{$tool} = $oldaccesstext->{$tool}; $changeHash->{$context.'.'.$tool} = $userenv->{$context.'.'.$tool}; - my $newop; + my ($newop,$limit); if ($env{'form.'.$context.'_'.$tool}) { $newop = $env{'form.'.$context.'_'.$tool}; if ($newop eq 'autolimit') { - my $limit = $env{'form.'.$context.'_'.$tool.'_limit'}; + $limit = $env{'form.'.$context.'_'.$tool.'_limit'}; $limit =~ s/\D+//g; $newop .= '='.$limit; } @@ -3281,7 +3313,15 @@ sub tool_changes { $changed->{$tool}=&tool_admin($tool,$cdom.':'.$newop, $changeHash,$context); if ($changed->{$tool}) { - $newaccesstext->{$tool} = &mt('Yes'); + if ($newop =~ /^autolimit/) { + if ($limit) { + $newaccesstext->{$tool} = &mt('available with automatic approval, up to limit of [quant,_1,request] per user',$limit); + } else { + $newaccesstext->{$tool} = &mt('available with automatic approval (unlimited)'); + } + } else { + $newaccesstext->{$tool} = $reqdisplay{$newop}; + } } else { $newaccesstext->{$tool} = $oldaccesstext->{$tool}; } @@ -3292,8 +3332,17 @@ sub tool_changes { my $changedoms; foreach my $req (@curr) { if ($req =~ /^\Q$cdom\E\:($optregex\=?\d*)$/) { - $oldaccesstext->{$tool} = &mt('Yes'); my $oldop = $1; + if ($oldop =~ /^autolimit=(\d*)/) { + my $limit = $1; + if ($limit) { + $oldaccesstext->{$tool} = &mt('available with automatic approval, up to limit of [quant,_1,request] per user',$limit); + } else { + $oldaccesstext->{$tool} = &mt('available with automatic approval (unlimited)'); + } + } else { + $oldaccesstext->{$tool} = $reqdisplay{$oldop}; + } if ($oldop ne $newop) { $changedoms = 1; foreach my $item (@curr) { @@ -3327,15 +3376,15 @@ sub tool_changes { my $limit = $env{'form.'.$context.'_'.$tool.'_limit'}; $limit =~ s/\D+//g; if ($limit) { - $newaccesstext->{$tool} = &mt('Yes, up to limit of [quant,_1,request] per user.',$limit); + $newaccesstext->{$tool} = &mt('available with automatic approval, up to limit of [quant,_1,request] per user',$limit); } else { - $newaccesstext->{$tool} = &mt('Yes, processed automatically'); + $newaccesstext->{$tool} = &mt('available with automatic approval (unlimited)'); } } else { $newaccesstext->{$tool} = $reqdisplay{$env{'form.'.$context.'_'.$tool}}; } } else { - $newaccesstext->{$tool} = &mt('No'); + $newaccesstext->{$tool} = &mt("availability set to 'off'"); } } } @@ -3344,12 +3393,14 @@ sub tool_changes { return; } foreach my $tool (@{$usertools}) { - my ($newval,$envkey); + my ($newval,$limit,$envkey); $envkey = $context.'.'.$tool; if ($context eq 'requestcourses') { $newval = $env{'form.crsreq_'.$tool}; if ($newval eq 'autolimit') { - $newval .= '='.$env{'form.crsreq_'.$tool.'_limit'}; + $limit = $env{'form.crsreq_'.$tool.'_limit'}; + $limit =~ s/\D+//g; + $newval .= '='.$limit; } } elsif ($context eq 'requestauthor') { $newval = $env{'form.'.$context}; @@ -3359,10 +3410,25 @@ sub tool_changes { } if ($userenv->{$envkey} ne '') { $oldaccess->{$tool} = &mt('custom'); - if ($userenv->{$envkey}) { - $oldaccesstext->{$tool} = &mt("availability set to 'on'"); + if (($context eq 'requestcourses') || ($context eq 'requestauthor')) { + if ($userenv->{$envkey} =~ /^autolimit=(\d*)$/) { + my $currlimit = $1; + if ($currlimit eq '') { + $oldaccesstext->{$tool} = &mt('available with automatic approval (unlimited)'); + } else { + $oldaccesstext->{$tool} = &mt('available with automatic approval, up to limit of [quant,_1,request] per user',$currlimit); + } + } elsif ($userenv->{$envkey}) { + $oldaccesstext->{$tool} = $reqdisplay{$userenv->{$envkey}}; + } else { + $oldaccesstext->{$tool} = &mt("availability set to 'off'"); + } } else { - $oldaccesstext->{$tool} = &mt("availability set to 'off'"); + if ($userenv->{$envkey}) { + $oldaccesstext->{$tool} = &mt("availability set to 'on'"); + } else { + $oldaccesstext->{$tool} = &mt("availability set to 'off'"); + } } $changeHash->{$envkey} = $userenv->{$envkey}; if ($env{'form.custom'.$tool} == 1) { @@ -3371,17 +3437,45 @@ sub tool_changes { $context); if ($changed->{$tool}) { $newaccess->{$tool} = &mt('custom'); - if ($newval) { - $newaccesstext->{$tool} = &mt("availability set to 'on'"); + if (($context eq 'requestcourses') || ($context eq 'requestauthor')) { + if ($newval =~ /^autolimit/) { + if ($limit) { + $newaccesstext->{$tool} = &mt('available with automatic approval, up to limit of [quant,_1,request] per user',$limit); + } else { + $newaccesstext->{$tool} = &mt('available with automatic approval (unlimited)'); + } + } elsif ($newval) { + $newaccesstext->{$tool} = $reqdisplay{$newval}; + } else { + $newaccesstext->{$tool} = &mt("availability set to 'off'"); + } } else { - $newaccesstext->{$tool} = &mt("availability set to 'off'"); + if ($newval) { + $newaccesstext->{$tool} = &mt("availability set to 'on'"); + } else { + $newaccesstext->{$tool} = &mt("availability set to 'off'"); + } } } else { $newaccess->{$tool} = $oldaccess->{$tool}; - if ($userenv->{$context.'.'.$tool}) { - $newaccesstext->{$tool} = &mt("availability set to 'on'"); + if (($context eq 'requestcourses') || ($context eq 'requestauthor')) { + if ($newval =~ /^autolimit/) { + if ($limit) { + $newaccesstext->{$tool} = &mt('available with automatic approval, up to limit of [quant,_1,request] per user',$limit); + } else { + $newaccesstext->{$tool} = &mt('available with automatic approval (unlimited)'); + } + } elsif ($newval) { + $newaccesstext->{$tool} = $reqdisplay{$newval}; + } else { + $newaccesstext->{$tool} = &mt("availability set to 'off'"); + } } else { - $newaccesstext->{$tool} = &mt("availability set to 'off'"); + if ($userenv->{$context.'.'.$tool}) { + $newaccesstext->{$tool} = &mt("availability set to 'on'"); + } else { + $newaccesstext->{$tool} = &mt("availability set to 'off'"); + } } } } else { @@ -3394,10 +3488,24 @@ sub tool_changes { $newaccess->{$tool} = &mt('default'); } else { $newaccess->{$tool} = $oldaccess->{$tool}; - if ($userenv->{$context.'.'.$tool}) { - $newaccesstext->{$tool} = &mt("availability set to 'on'"); + if (($context eq 'requestcourses') || ($context eq 'requestauthor')) { + if ($newval =~ /^autolimit/) { + if ($limit) { + $newaccesstext->{$tool} = &mt('available with automatic approval, up to limit of [quant,_1,request] per user',$limit); + } else { + $newaccesstext->{$tool} = &mt('available with automatic approval (unlimited)'); + } + } elsif ($newval) { + $newaccesstext->{$tool} = $reqdisplay{$newval}; + } else { + $newaccesstext->{$tool} = &mt("availability set to 'off'"); + } } else { - $newaccesstext->{$tool} = &mt("availability set to 'off'"); + if ($userenv->{$context.'.'.$tool}) { + $newaccesstext->{$tool} = &mt("availability set to 'on'"); + } else { + $newaccesstext->{$tool} = &mt("availability set to 'off'"); + } } } } @@ -3408,10 +3516,24 @@ sub tool_changes { $context); if ($changed->{$tool}) { $newaccess->{$tool} = &mt('custom'); - if ($newval) { - $newaccesstext->{$tool} = &mt("availability set to 'on'"); + if (($context eq 'requestcourses') || ($context eq 'requestauthor')) { + if ($newval =~ /^autolimit/) { + if ($limit) { + $newaccesstext->{$tool} = &mt('available with automatic approval, up to limit of [quant,_1,request] per user',$limit); + } else { + $newaccesstext->{$tool} = &mt('available with automatic approval (unlimited)'); + } + } elsif ($newval) { + $newaccesstext->{$tool} = $reqdisplay{$newval}; + } else { + $newaccesstext->{$tool} = &mt("availability set to 'off'"); + } } else { - $newaccesstext->{$tool} = &mt("availability set to 'off'"); + if ($newval) { + $newaccesstext->{$tool} = &mt("availability set to 'on'"); + } else { + $newaccesstext->{$tool} = &mt("availability set to 'off'"); + } } } else { $newaccess->{$tool} = $oldaccess->{$tool}; @@ -3834,14 +3956,14 @@ sub get_defaultquota_text { my ($settingstatus) = @_; my $defquotatext; if ($settingstatus eq '') { - $defquotatext = &mt('(default)'); + $defquotatext = &mt('default'); } else { my ($usertypes,$order) = &Apache::lonnet::retrieve_inst_usertypes($env{'form.ccdomain'}); if ($usertypes->{$settingstatus} eq '') { - $defquotatext = &mt('(default)'); + $defquotatext = &mt('default'); } else { - $defquotatext = &mt('(default for [_1])',$usertypes->{$settingstatus}); + $defquotatext = &mt('default for [_1]',$usertypes->{$settingstatus}); } } return $defquotatext; @@ -3866,8 +3988,8 @@ sub update_result_form { $outcome .= ''."\n"; } $outcome .= ''."\n". - ''."\n". - ''."\n". + ''."\n". + ''."\n". ''; return $outcome; }