[LON-CAPA-cvs] cvs: loncom /interface loncreateuser.pm
raeburn
raeburn at source.lon-capa.org
Tue Dec 17 01:41:45 EST 2013
raeburn Tue Dec 17 06:41:45 2013 EDT
Modified files:
/loncom/interface loncreateuser.pm
Log:
- Re-enable display of changes to user's settings for course/authoring requests
by a domain coordinator.
- Ability to set authring space request rights only available where user's domain
is domain being coordinated.
- Expand explanation of user setting changes for course/authoring requests.
-------------- next part --------------
Index: loncom/interface/loncreateuser.pm
diff -u loncom/interface/loncreateuser.pm:1.382 loncom/interface/loncreateuser.pm:1.383
--- loncom/interface/loncreateuser.pm:1.382 Mon Dec 9 21:33:32 2013
+++ loncom/interface/loncreateuser.pm Tue Dec 17 06:41:44 2013
@@ -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 @@
$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 @@
' </tr>'."\n".
&Apache::loncommon::start_data_table_row()."\n".
' <td>'.$lt{'cuqu'}.': '.
- $currquota.' Mb. '.
+ $currquota.' MB. '.
$defaultinfo.'</td>'."\n".
&Apache::loncommon::end_data_table_row()."\n".
&Apache::loncommon::start_data_table_row()."\n".
@@ -220,13 +220,13 @@
': <label>'.
'<input type="radio" name="custom_'.$name.'quota" id="custom_'.$name.'quota_off" '.
'value="0" '.$custom_off.' onchange="javascript:quota_changes('."'custom','$name'".');"'.
- ' />'.$lt{'defa'}.' ('.$defquota.' Mb).</label> '.
+ ' />'.$lt{'defa'}.' ('.$defquota.' MB).</label> '.
' <label><input type="radio" name="custom_'.$name.'quota" id="custom_'.$name.'quota_on" '.
'value="1" '.$custom_on.' onchange="javascript:quota_changes('."'custom','$name'".');"'.
' />'.$lt{'cust'}.':</label> '.
'<input type="text" name="'.$name.'quota" id="'.$name.'quota" size ="5" '.
'value="'.$showquota.'" onfocus="javascript:quota_changes('."'quota','$name'".');"'.
- ' /> Mb</span></td>'."\n".
+ ' /> MB</span></td>'."\n".
&Apache::loncommon::end_data_table_row()."\n";
}
}
@@ -568,6 +568,15 @@
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 @@
# Current user has quota or user tools modification privileges
$portfolioform = '<br />'.&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 = '<br />'.&domainrole_req($ccuname,$ccdomain);
}
&initialize_authen_forms($ccdomain,$formname);
@@ -1392,7 +1402,8 @@
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 @@
$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 @@
}
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 @@
}
}
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 @@
$r->print('<th><span class="LC_nobreak"><b>'.$lt{'chto'}.'</b></span></th>');
$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("<td>$lt{$item}</td>\n");
- $r->print('<td>'.$userenv->{$item}.' </td>');
+ $r->print("<td>".$userenv->{$item}."</td>\n");
$r->print("<td>$value </td>\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("<td>$lt{$item}</td>\n");
- $r->print("<td>$oldsetting->{$item} $oldsettingtext->{$item}</td>\n");
- my $value = $newsetting->{$item}.' '.$newsettingtext->{$item};
- if ($changedhash->{$item}) {
- $value = '<span class="LC_cusr_emph">'.$value.'</span>';
+ 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("<td>$lt{$item}</td>\n");
+ $r->print("<td>".$oldsetting->{$item});
+ if ($oldsettingtext->{$item}) {
+ if ($oldsetting->{$item}) {
+ $r->print(' -- ');
+ }
+ $r->print($oldsettingtext->{$item});
+ }
+ $r->print("</td>\n");
+ $r->print("<td>".$newsetting->{$item});
+ if ($newsettingtext->{$item}) {
+ if ($newsetting->{$item}) {
+ $r->print(' -- ');
+ }
+ $r->print($newsettingtext->{$item});
+ }
+ $r->print("</td>\n");
+ $r->print(&Apache::loncommon::end_data_table_row()."\n");
}
- $r->print("<td>$value </td>\n");
}
} elsif ($entry eq 'tools') {
foreach my $item (@{$usertools}) {
- $r->print("<td>$lt{$item}</td>\n");
- $r->print("<td>$oldsetting->{$item} $oldsettingtext->{$item}</td>\n");
- my $value = $newsetting->{$item}.' '.$newsettingtext->{$item};
- if ($changedhash->{$item}) {
- $value = '<span class="LC_cusr_emph">'.$value.'</span>';
+ if ($newsetting->{$item} ne $oldsetting->{$item}) {
+ $r->print(&Apache::loncommon::start_data_table_row()."\n");
+ $r->print("<td>$lt{$item}</td>\n");
+ $r->print("<td>".$oldsetting->{$item}.' '.$oldsettingtext->{$item}."</td>\n");
+ $r->print("<td>".$newsetting->{$item}.' '.$newsettingtext->{$item}."</td>\n");
+ $r->print(&Apache::loncommon::end_data_table_row()."\n");
}
- $r->print("<td>$value </td>\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("<td>$lt{$name.$entry}</td>\n");
- $r->print("<td>$oldsetting->{$entry}->{$name} $oldsettingtext->{$entry}->{$name} </td>\n");
- my $value = $newsetting->{$entry}->{$name}.' '.$newsettingtext->{$entry}->{$name};
- if ($changedhash->{$entry}) {
- $value = '<span class="LC_cusr_emph">'.$value.'</span>';
+ if ($newsetting->{$entry}->{$name} ne $oldsetting->{$entry}->{$name}) {
+ $r->print(&Apache::loncommon::start_data_table_row()."\n");
+ $r->print("<td>$lt{$name.$entry}</td>\n");
+ $r->print("<td>".$oldsettingtext->{$entry}->{$name}."</td>\n");
+ $r->print("<td>".$newsettingtext->{$entry}->{$name}."</td>\n");
+ $r->print(&Apache::loncommon::end_data_table_row()."\n");
}
- $r->print("<td>$value </td>\n");
}
}
} else {
- $r->print("<td>$lt{$entry}</td>\n");
- $r->print("<td>$oldsetting->{$entry} $oldsettingtext->{$entry} </td>\n");
- my $value = $newsetting->{$entry}.' '.$newsettingtext->{$entry};
- if ($changedhash->{$entry}) {
- $value = '<span class="LC_cusr_emph">'.$value.'</span>';
+ if ($newsetting->{$entry} ne $oldsetting->{$entry}) {
+ $r->print(&Apache::loncommon::start_data_table_row()."\n");
+ $r->print("<td>$lt{$entry}</td>\n");
+ $r->print("<td>".$oldsetting->{$entry}.' '.$oldsettingtext->{$entry}."</td>\n");
+ $r->print("<td>".$newsetting->{$entry}.' '.$newsettingtext->{$entry}."</td>\n");
+ $r->print(&Apache::loncommon::end_data_table_row()."\n");
}
- $r->print("<td>$value </td>\n");
}
- $r->print(&Apache::loncommon::end_data_table_row());
}
}
$r->print(&Apache::loncommon::end_data_table().'<br />');
@@ -3258,20 +3290,20 @@
(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('|', at 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 @@
$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 @@
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 @@
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 @@
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 @@
}
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 @@
$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 @@
$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 @@
$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 @@
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 @@
$outcome .= '<input type="hidden" name="forcenewuser" value="1" />'."\n";
}
$outcome .= '<input type="hidden" name="phase" value="" />'."\n".
- '<input type ="hidden" name="currstate" value="" />'."\n".
- '<input type ="hidden" name="action" value="'.$env{'form.action'}.'" />'."\n".
+ '<input type="hidden" name="currstate" value="" />'."\n".
+ '<input type="hidden" name="action" value="'.$env{'form.action'}.'" />'."\n".
'</form>';
return $outcome;
}
More information about the LON-CAPA-cvs
mailing list