version 1.148, 2007/03/12 17:06:59
|
version 1.149, 2007/05/29 17:48:44
|
Line 122 sub portfolio_quota {
|
Line 122 sub portfolio_quota {
|
my ($ccuname,$ccdomain) = @_; |
my ($ccuname,$ccdomain) = @_; |
my %lt = &Apache::lonlocal::texthash( |
my %lt = &Apache::lonlocal::texthash( |
'disk' => "Disk space allocated to user's portfolio files", |
'disk' => "Disk space allocated to user's portfolio files", |
|
'cuqu' => "Current quota", |
|
'cust' => "Custom quota", |
|
'defa' => "Default", |
|
'chqu' => "Change quota", |
); |
); |
my $output = '<h3>'.$lt{'disk'}.'</h3>'. |
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"; |
|
<script type="text/javascript"> |
|
function quota_changes(caller) { |
|
if (caller == "custom") { |
|
if (document.cu.customquota[0].checked) { |
|
document.cu.portfolioquota.value = ""; |
|
} |
|
} |
|
if (caller == "quota") { |
|
document.cu.customquota[1].checked = true; |
|
} |
|
} |
|
</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 $output = $quota_javascript. |
|
'<h3>'.$lt{'disk'}.'</h3>'. |
|
$lt{'cuqu'}.': '.$currquota.' Mb. '. |
|
$defaultinfo.'<br /><span class="LC_nobreak">'.$lt{'chqu'}. |
|
': <label>'. |
|
'<input type="radio" name="customquota" value="0" '. |
|
$custom_off.' onchange="javascript:quota_changes('."'custom'".')" |
|
/>'.$lt{'defa'}.' ('.$defquota.' Mb).</label> '. |
|
' <label><input type="radio" name="customquota" value="1" '. |
|
$custom_on.' onchange="javascript:quota_changes('."'custom'".')" />'. |
|
$lt{'cust'}.':</label> '. |
'<input type="text" name="portfolioquota" size ="5" value="'. |
'<input type="text" name="portfolioquota" size ="5" value="'. |
&Apache::loncommon::get_user_quota($ccuname,$ccdomain). |
$showquota.'" onfocus="javascript:quota_changes('."'quota'".')" '. |
'" /> Mb'; |
'/> Mb'; |
return $output; |
return $output; |
} |
} |
|
|
Line 234 sub print_user_modification_page {
|
Line 295 sub print_user_modification_page {
|
); |
); |
$loginscript = &Apache::loncommon::authform_header(%param); |
$loginscript = &Apache::loncommon::authform_header(%param); |
$authformkrb = &Apache::loncommon::authform_kerberos(%param); |
$authformkrb = &Apache::loncommon::authform_kerberos(%param); |
|
|
$ccuname =&LONCAPA::clean_username($ccuname); |
$ccuname =&LONCAPA::clean_username($ccuname); |
$ccdomain=&LONCAPA::clean_domain($ccdomain); |
$ccdomain=&LONCAPA::clean_domain($ccdomain); |
my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition(); |
my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition(); |
Line 1115 ENDMODIFYUSERHEAD
|
Line 1176 ENDMODIFYUSERHEAD
|
# Check for need to change |
# Check for need to change |
my %userenv = &Apache::lonnet::get |
my %userenv = &Apache::lonnet::get |
('environment',['firstname','middlename','lastname','generation', |
('environment',['firstname','middlename','lastname','generation', |
'portfolioquota'],$env{'form.ccdomain'},$env{'form.ccuname'}); |
'portfolioquota','inststatus'],$env{'form.ccdomain'}, |
|
$env{'form.ccuname'}); |
my ($tmp) = keys(%userenv); |
my ($tmp) = keys(%userenv); |
if ($tmp =~ /^(con_lost|error)/i) { |
if ($tmp =~ /^(con_lost|error)/i) { |
%userenv = (); |
%userenv = (); |
Line 1125 ENDMODIFYUSERHEAD
|
Line 1187 ENDMODIFYUSERHEAD
|
# Strip leading and trailing whitespace |
# Strip leading and trailing whitespace |
$env{'form.c'.$item} =~ s/(\s+$|^\s+)//g; |
$env{'form.c'.$item} =~ s/(\s+$|^\s+)//g; |
} |
} |
my ($quotachanged,$namechanged,$oldportfolioquota); |
my ($quotachanged,$namechanged,$oldportfolioquota,$newportfolioquota, |
|
$inststatus,$isdefault,$defquotatext); |
|
my ($defquota,$settingstatus) = |
|
&Apache::loncommon::default_quota($env{'form.ccdomain'},$inststatus); |
my %changeHash; |
my %changeHash; |
if (exists($userenv{'portfolioquota'})) { |
if ($userenv{'portfolioquota'} ne '') { |
$oldportfolioquota = $userenv{'portfolioquota'}; |
$oldportfolioquota = $userenv{'portfolioquota'}; |
if (exists($env{'form.portfolioquota'})) { |
if ($env{'form.customquota'} == 1) { |
if ($env{'form.portfolioquota'} ne $userenv{'portfolioquota'}) { |
if ($env{'form.portfolioquota'} eq '') { |
if (&Apache::lonnet::allowed('mpq',$env{'form.ccdomain'})) { |
$newportfolioquota = 0; |
# Current user has quota modification privileges |
} else { |
$quotachanged = 1; |
$newportfolioquota = $env{'form.portfolioquota'}; |
$changeHash{'portfolioquota'} = $env{'form.portfolioquota'}; |
$newportfolioquota =~ s/[^\d\.]//g; |
} |
|
} |
} |
|
if ($newportfolioquota != $userenv{'portfolioquota'}) { |
|
$quotachanged = "a_admin($newportfolioquota,\%changeHash); |
|
} |
|
} else { |
|
$quotachanged = "a_admin('',\%changeHash); |
|
$newportfolioquota = $defquota; |
|
$isdefault = 1; |
} |
} |
} else { |
} else { |
$oldportfolioquota = |
$oldportfolioquota = $defquota; |
&Apache::loncommon::default_quota($env{'form.ccdomain'}); |
if ($env{'form.customquota'} == 1) { |
|
if ($env{'form.portfolioquota'} eq '') { |
|
$newportfolioquota = 0; |
|
} else { |
|
$newportfolioquota = $env{'form.portfolioquota'}; |
|
$newportfolioquota =~ s/[^\d\.]//g; |
|
} |
|
$quotachanged = "a_admin($newportfolioquota,\%changeHash); |
|
} else { |
|
$newportfolioquota = $defquota; |
|
$isdefault = 1; |
|
} |
|
} |
|
if ($isdefault) { |
|
if ($settingstatus eq '') { |
|
$defquotatext = &mt('(default)'); |
|
} else { |
|
my ($usertypes,$order) = |
|
&Apache::lonnet::retrieve_inst_usertypes($env{'form.ccdomain'}); |
|
if ($usertypes->{$settingstatus} eq '') { |
|
$defquotatext = &mt('(default)'); |
|
} else { |
|
$defquotatext = &mt('(default for [_1])',$usertypes->{$settingstatus}); |
|
} |
|
} |
} |
} |
if (&Apache::lonnet::allowed('mau',$env{'form.ccdomain'}) && |
if (&Apache::lonnet::allowed('mau',$env{'form.ccdomain'}) && |
($env{'form.cfirstname'} ne $userenv{'firstname'} || |
($env{'form.cfirstname'} ne $userenv{'firstname'} || |
Line 1184 ENDMODIFYUSERHEAD
|
Line 1279 ENDMODIFYUSERHEAD
|
<td>$userenv{'middlename'} </td> |
<td>$userenv{'middlename'} </td> |
<td>$userenv{'lastname'} </td> |
<td>$userenv{'lastname'} </td> |
<td>$userenv{'generation'} </td> |
<td>$userenv{'generation'} </td> |
<td>$oldportfolioquota</td> |
<td>$oldportfolioquota Mb</td> |
</tr> |
</tr> |
<tr><td>$lt{'chto'}</td> |
<tr><td>$lt{'chto'}</td> |
<td>$env{'form.cfirstname'} </td> |
<td>$env{'form.cfirstname'} </td> |
<td>$env{'form.cmiddlename'} </td> |
<td>$env{'form.cmiddlename'} </td> |
<td>$env{'form.clastname'} </td> |
<td>$env{'form.clastname'} </td> |
<td>$env{'form.cgeneration'} </td> |
<td>$env{'form.cgeneration'} </td> |
<td>$env{'form.portfolioquota'} Mb</td></tr> |
<td>$newportfolioquota Mb $defquotatext </td></tr> |
</table> |
</table> |
END |
END |
|
if (($env{'form.ccdomain'} eq $env{'user.domain'}) && |
|
($env{'form.ccuname'} eq $env{'user.name'})) { |
|
my %newenvhash; |
|
foreach my $key (keys(%changeHash)) { |
|
$newenvhash{'environment.'.$key} = $changeHash{$key}; |
|
} |
|
&Apache::lonnet::appenv(%newenvhash); |
|
} |
} else { # error occurred |
} else { # error occurred |
$r->print("<h2>".&mt('Unable to successfully change environment for')." ". |
$r->print("<h2>".&mt('Unable to successfully change environment for')." ". |
$env{'form.ccuname'}." ".&mt('in domain')." ". |
$env{'form.ccuname'}." ".&mt('in domain')." ". |
Line 1220 END
|
Line 1323 END
|
<h4>$lt{'gen'}: $userenv{'generation'}</h4> |
<h4>$lt{'gen'}: $userenv{'generation'}</h4> |
END |
END |
if ($putresult eq 'ok') { |
if ($putresult eq 'ok') { |
if ($oldportfolioquota ne $env{'form.portfolioquota'}) { |
if ($oldportfolioquota != $newportfolioquota) { |
$r->print('<h4>'.$lt{'disk'}.': '.$env{'form.portfolioquota'}.' Mb</h4>'); |
$r->print('<h4>'.$lt{'disk'}.': '.$newportfolioquota.' Mb '. |
|
$defquotatext.'</h4>'); |
|
&Apache::lonnet::appenv('environment.portfolioquota' => $changeHash{'portfolioquota'}); |
} |
} |
} |
} |
} |
} |
Line 1446 END
|
Line 1551 END
|
$r->print(&Apache::loncommon::end_page()); |
$r->print(&Apache::loncommon::end_page()); |
} |
} |
|
|
|
sub quota_admin { |
|
my ($setquota,$changeHash) = @_; |
|
my $quotachanged; |
|
if (&Apache::lonnet::allowed('mpq',$env{'form.ccdomain'})) { |
|
# Current user has quota modification privileges |
|
$quotachanged = 1; |
|
$changeHash->{'portfolioquota'} = $setquota; |
|
} |
|
return $quotachanged; |
|
} |
|
|
sub build_roles { |
sub build_roles { |
my ($sectionstr,$sections,$role) = @_; |
my ($sectionstr,$sections,$role) = @_; |
my $num_sections = 0; |
my $num_sections = 0; |