--- loncom/interface/loncreateuser.pm 2007/03/12 17:06:59 1.148
+++ loncom/interface/loncreateuser.pm 2007/07/20 23:57:06 1.159
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Create a user
#
-# $Id: loncreateuser.pm,v 1.148 2007/03/12 17:06:59 albertel Exp $
+# $Id: loncreateuser.pm,v 1.159 2007/07/20 23:57:06 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -65,7 +65,6 @@ use Apache::lonnet;
use Apache::loncommon;
use Apache::lonlocal;
use Apache::longroup;
-use lib '/home/httpd/lib/perl/';
use LONCAPA qw(:DEFAULT :match);
my $loginscript; # piece of javascript used in two separate instances
@@ -122,11 +121,72 @@ sub portfolio_quota {
my ($ccuname,$ccdomain) = @_;
my %lt = &Apache::lonlocal::texthash(
'disk' => "Disk space allocated to user's portfolio files",
+ 'cuqu' => "Current quota",
+ 'cust' => "Custom quota",
+ 'defa' => "Default",
+ 'chqu' => "Change quota",
);
- my $output = '
'.$lt{'disk'}.'
'.
+ 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 $output = $quota_javascript.
+ ''.$lt{'disk'}.'
'.
+ $lt{'cuqu'}.': '.$currquota.' Mb. '.
+ $defaultinfo.'
'.$lt{'chqu'}.
+ ': '.
+ ' '.
' Mb';
+ $showquota.'" onfocus="javascript:quota_changes('."'quota'".')" '.
+ '/> Mb';
return $output;
}
@@ -161,10 +221,10 @@ sub print_username_entry_form {
$r->print(<<"ENDDOCUMENT");
$start_page
'.
&Apache::loncommon::end_page());
}
-
+# --------------------------------------------------------
+sub make_script_template {
+ my ($role) = @_;
+ my %full_c=();
+ my %full_d=();
+ my %full_s=();
+ my $return_script;
+ foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:c'})) {
+ my ($priv,$restrict)=split(/\&/,$item);
+ $full_c{$priv}=1;
+ }
+ foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:d'})) {
+ my ($priv,$restrict)=split(/\&/,$item);
+ $full_d{$priv}=1;
+ }
+ foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:s'})) {
+ my ($priv,$restrict)=split(/\&/,$item);
+ $full_s{$priv}=1;
+ }
+ $return_script .= 'function set_'.$role.'() {'."\n";
+ my @temp = split(/:/,$Apache::lonnet::pr{$role.':c'});
+ my %role_c;
+ foreach my $priv (@temp) {
+ my ($priv_item, $dummy) = split(/\&/,$priv);
+ $role_c{$priv_item} = 1;
+ }
+ foreach my $priv_item (keys(%full_c)) {
+ my ($priv, $dummy) = split(/\&/,$priv_item);
+ if (exists($role_c{$priv})) {
+ $return_script .= "document.form1.$priv"."_c.checked = true;\n";
+ } else {
+ $return_script .= "document.form1.$priv"."_c.checked = false;\n";
+ }
+ }
+ my %role_d;
+ @temp = split(/:/,$Apache::lonnet::pr{$role.':d'});
+ foreach my $priv(@temp) {
+ my ($priv_item, $dummy) = split(/\&/,$priv);
+ $role_d{$priv_item} = 1;
+ }
+ foreach my $priv_item (keys(%full_d)) {
+ my ($priv, $dummy) = split(/\&/,$priv_item);
+ if (exists($role_d{$priv})) {
+ $return_script .= "document.form1.$priv"."_d.checked = true;\n";
+ } else {
+ $return_script .= "document.form1.$priv"."_d.checked = false;\n";
+ }
+ }
+ my %role_s;
+ @temp = split(/:/,$Apache::lonnet::pr{$role.':s'});
+ foreach my $priv(@temp) {
+ my ($priv_item, $dummy) = split(/\&/,$priv);
+ $role_s{$priv_item} = 1;
+ }
+ foreach my $priv_item (keys(%full_s)) {
+ my ($priv, $dummy) = split(/\&/,$priv_item);
+ if (exists($role_s{$priv})) {
+ $return_script .= "document.form1.$priv"."_s.checked = true;\n";
+ } else {
+ $return_script .= "document.form1.$priv"."_s.checked = false;\n";
+ }
+ }
+ $return_script .= '}'."\n";
+ return ($return_script);
+}
+# ----------------------------------------------------------
+sub make_button_code {
+ my ($role) = @_;
+ my $label = &Apache::lonnet::plaintext($role);
+ my $button_code = '';
+ return ($button_code);
+}
# ---------------------------------------------------------- Call to definerole
sub set_custom_role {
my ($r) = @_;
@@ -1592,7 +1791,7 @@ sub set_custom_role {
$rolename=~s/[^A-Za-z0-9]//gs;
- unless ($rolename) {
+ if (!$rolename) {
&print_username_entry_form($r);
return;
}
@@ -1616,24 +1815,24 @@ sub set_custom_role {
foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:c'})) {
my ($priv,$restrict)=split(/\&/,$item);
- unless ($restrict) { $restrict=''; }
- if ($env{'form.'.$priv.':c'}) {
+ if (!$restrict) { $restrict=''; }
+ if ($env{'form.'.$priv.'_c'}) {
$courole.=':'.$item;
}
}
foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:d'})) {
my ($priv,$restrict)=split(/\&/,$item);
- unless ($restrict) { $restrict=''; }
- if ($env{'form.'.$priv.':d'}) {
+ if (!$restrict) { $restrict=''; }
+ if ($env{'form.'.$priv.'_d'}) {
$domrole.=':'.$item;
}
}
foreach my $item (split(/\:/,$Apache::lonnet::pr{'cr:s'})) {
my ($priv,$restrict)=split(/\&/,$item);
- unless ($restrict) { $restrict=''; }
- if ($env{'form.'.$priv.':s'}) {
+ if (!$restrict) { $restrict=''; }
+ if ($env{'form.'.$priv.'_s'}) {
$sysrole.=':'.$item;
}
}
@@ -1672,7 +1871,7 @@ sub handler {
(&Apache::lonnet::allowed('mau',$env{'request.role.domain'}))) {
&Apache::loncommon::content_type($r,'text/html');
$r->send_http_header;
- unless ($env{'form.phase'}) {
+ if (!$env{'form.phase'}) {
&print_username_entry_form($r);
}
if ($env{'form.phase'} eq 'get_user_info') {
@@ -1732,7 +1931,7 @@ sub course_level_table {
if (&Apache::lonnet::allowed('c'.$role,$thiscourse)) {
my $plrole=&Apache::lonnet::plaintext($role);
$table .= &Apache::loncommon::start_data_table_row().
-' |
+' |
'.$plrole.' |
'.$area.' Domain: '.$domain.' | '."\n";
if ($role ne 'cc') {
@@ -1745,22 +1944,22 @@ sub course_level_table {
$currsec.''.
' | '.
' '.$lt{'new'}.' '.
- ' | '.
+ ''.
''.
+ 'name="sec_'.$protectedcourse.'_'.$role.'" />'.
'';
} else {
$table .= ' | ';
+ 'name="sec_'.$protectedcourse.'_'.$role.'" />';
}
} else {
$table .= '  | ';
}
$table .= <
+
$lt{'ssd'} |
-
+ |
$lt{'sed'} |
ENDTIMEENTRY
@@ -1773,7 +1972,7 @@ ENDTIMEENTRY
my $customrole=$protectedcourse.'_cr_cr_'.$env{'user.domain'}.
'_'.$env{'user.name'}.'_'.$plrole;
$table .= &Apache::loncommon::start_data_table_row().
-' |
+' |
'.$plrole.' |
'.$area.' | '."\n";
if (%sections_count) {
@@ -1786,17 +1985,17 @@ ENDTIMEENTRY
' '.$lt{'new'}.' '.
' | '.
''.
+ 'name="sec_'.$customrole.'" />'.
'';
} else {
$table .= ' | ';
+ 'name="sec_'.$customrole.'" />';
}
$table .= <
+
$lt{'ssd'} |
-
+ |
$lt{'sed'} |
ENDENTRY
@@ -1813,9 +2012,7 @@ ENDENTRY
''.$lt{'act'}.' | '.$lt{'rol'}.' | '.$lt{'ext'}.' |
'.$lt{'grs'}.' | '.$lt{'sta'}.' | '.$lt{'end'}.' | '.
&Apache::loncommon::end_data_table_header_row().
-&Apache::loncommon::start_data_table_row().
$table.
-&Apache::loncommon::end_data_table_row().
&Apache::loncommon::end_data_table();
return $result;
}
@@ -1890,10 +2087,10 @@ sub course_level_dc {
''.
'';
$otheritems .= <
+
$lt{'ssd'} |
-
+ |
$lt{'sed'} |
ENDTIMEENTRY