--- loncom/interface/loncreateuser.pm 2006/06/27 17:48:53 1.123
+++ loncom/interface/loncreateuser.pm 2006/11/22 16:06:28 1.135
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Create a user
#
-# $Id: loncreateuser.pm,v 1.123 2006/06/27 17:48:53 albertel Exp $
+# $Id: loncreateuser.pm,v 1.135 2006/11/22 16:06:28 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -99,8 +99,8 @@ sub initialize_authen_forms {
sub my_custom_roles {
my %returnhash=();
my %rolehash=&Apache::lonnet::dump('roles');
- foreach (keys %rolehash) {
- if ($_=~/^rolesdef\_(\w+)$/) {
+ foreach my $key (keys %rolehash) {
+ if ($key=~/^rolesdef\_(\w+)$/) {
$returnhash{$1}=$1;
}
}
@@ -116,6 +116,20 @@ sub authorpriv {
return 1;
}
+# ====================================================
+
+sub portfolio_quota {
+ my ($ccuname,$ccdomain) = @_;
+ my %lt = &Apache::lonlocal::texthash(
+ 'disk' => "Disk space allocated to user's portfolio files",
+ );
+ my $output = '
'.$lt{'disk'}.'
'.
+ ' Mb';
+ return $output;
+}
+
# =================================================================== Phase one
sub print_username_entry_form {
@@ -313,18 +327,27 @@ sub print_user_modification_page {
alert("Section designations do not apply to Course Coordinator roles.\\nA course coordinator role will be added with access to all sections.");
section = "";
}
+ var coursename = "_$dcdom"+"_"+course+"_"+userrole
var numcourse = getIndex(document.cu.dccourse);
if (numcourse == "-1") {
alert("There was a problem with your course selection");
return
}
- else {
- var coursename = "_$dcdom"+"_"+course+"_"+userrole
- document.cu.elements[numcourse].name = "act"+coursename
- document.cu.elements[numcourse+5].name = "sec"+coursename
- document.cu.elements[numcourse+5].value = section
- document.cu.elements[numcourse+7].name = "start"+coursename
- document.cu.elements[numcourse+8].name = "end"+coursename
+ else {
+ document.cu.elements[numcourse].name = "act"+coursename;
+ var numnewsec = getIndex(document.cu.newsec);
+ if (numnewsec != "-1") {
+ document.cu.elements[numnewsec].name = "sec"+coursename;
+ document.cu.elements[numnewsec].value = section;
+ }
+ var numstart = getIndex(document.cu.start);
+ if (numstart != "-1") {
+ document.cu.elements[numstart].name = "start"+coursename;
+ }
+ var numend = getIndex(document.cu.end);
+ if (numend != "-1") {
+ document.cu.elements[numend].name = "end"+coursename
+ }
}
}
document.cu.submit();
@@ -378,7 +401,6 @@ ENDSCRIPT
var str = document.cu.elements[i].name;
var checkcurr = str.match(re1);
if (checkcurr != null) {
- var re2 = /^currsec_[a-zA-Z0-9]+_[a-zA-Z0-9]+_(\\w+)\$/;
if (document.cu.elements[i-1].checked == true) {
var re2 = /^currsec_[a-zA-Z0-9]+_[a-zA-Z0-9]+_(\\w+)\$/;
match = re2.exec(str);
@@ -415,15 +437,17 @@ ENDSCRIPT
sections = document.cu.elements[i+1].value;
}
var newsecs = document.cu.elements[i+1].value;
+ var numsplit;
if (newsecs != null && newsecs != "") {
- var numsplit = newsecs.split(/,/g);
+ numsplit = newsecs.split(/,/g);
numsec = numsec + numsplit.length;
}
+
if ((role == 'st') && (numsec > 1)) {
alert("In each course, each user may only have one student role at a time. You had selected "+numsec+" sections.\\nPlease modify your selections so they include no more than one section.")
return;
}
- else {
+ else if (numsplit != null) {
for (var j=0; j "Home Server",
'lg' => "Login Data"
);
+ my $portfolioform;
+ if (&Apache::lonnet::allowed('mpq',$env{'request.role.domain'})) {
+ # Current user has quota modification privileges
+ $portfolioform = &portfolio_quota($ccuname,$ccdomain);
+ }
my $genhelp=&Apache::loncommon::help_open_topic('Generation');
&initialize_authen_forms();
$r->print(<
-
'.
+ &Apache::loncommon::end_data_table_header_row().
+ &Apache::loncommon::start_data_table_row());
+ foreach my $item ('firstname','middlename','lastname','generation') {
if (&Apache::lonnet::allowed('mau',$ccdomain)) {
- $r->print(<<"END");
-
+ $r->print(<<"END");
+
END
} else {
- $r->print('
'.$userenv{$_}.'
');
+ $r->print('
'.$userenv{$item}.'
');
}
}
- $r->print(<
-
-END
+ $r->print(&Apache::loncommon::end_data_table_row().
+ &Apache::loncommon::end_data_table());
# Build up table of user roles to allow revocation of a role.
my ($tmp) = keys(%rolesdump);
unless ($tmp =~ /^(con_lost|error)/i) {
@@ -603,7 +631,7 @@ END
if ($area =~ /^\/(\w+)\/(\d\w+)/ ) {
$class='Course';
my ($coursedom,$coursedir) = ($1,$2);
- $sortkey.="\0$1";
+ $sortkey.="\0$coursedom";
# $1.'_'.$2 is the course id (eg. 103_12345abcef103l3).
my %coursedata=
&Apache::lonnet::coursedescription($1.'_'.$2);
@@ -618,6 +646,7 @@ END
$carea=&mt('Unavailable course').': '.$area;
$sortkey.="\0".&mt('Unavailable course').': '.$area;
}
+ $sortkey.="\0$coursedir";
$inccourses{$1.'_'.$2}=1;
if ((&Apache::lonnet::allowed('c'.$role_code,$1.'/'.$2)) ||
(&Apache::lonnet::allowed('c'.$role_code,$ccdomain))) {
@@ -770,7 +799,7 @@ END
$currentauth=~/^internal:/ or
$currentauth=~/^localauth:/
) { # bad authentication scheme
- if (&Apache::lonnet::allowed('mau',$env{'request.role.domain'})) {
+ if (&Apache::lonnet::allowed('mau',$ccdomain)) {
&initialize_authen_forms();
my %lt=&Apache::lonlocal::texthash(
'err' => "ERROR",
@@ -793,7 +822,7 @@ $lt{'uuas'} ($currentauth). $lt{'sldb'}.
$authformloc
ENDBADAUTH
} else {
- # This user is not allowed to modify the users
+ # This user is not allowed to modify the user's
# authentication scheme, so just notify them of the problem
my %lt=&Apache::lonlocal::texthash(
'err' => "ERROR",
@@ -802,9 +831,6 @@ ENDBADAUTH
);
$r->print(<
-
$lt{'err'}:
$lt{'uuas'} ($currentauth). $lt{'adcs'}.
@@ -835,7 +861,7 @@ ENDBADAUTH
"
$authformint
$authformfsys
";
}
$authformcurrent.=' (will override current values) ';
- if (&Apache::lonnet::allowed('mau',$env{'request.role.domain'})) {
+ if (&Apache::lonnet::allowed('mau',$ccdomain)) {
# Current user has login modification privileges
my %lt=&Apache::lonlocal::texthash(
'ccld' => "Change Current Login Data",
@@ -853,6 +879,23 @@ $loginscript
$lt{'enld'}
$authform_other
ENDOTHERAUTHS
+ } else {
+ if (&Apache::lonnet::allowed('mau',$env{'request.role.domain'})) {
+ my %lt=&Apache::lonlocal::texthash(
+ 'ccld' => "Change Current Login Data",
+ 'yodo' => "You do not have privileges to modify the authentication configuration for this user.",
+ 'ifch' => "If a change is required, contact a domain coordinator for the domain",
+ );
+ $r->print(<
+
$lt{'ccld'}
+$lt{'yodo'} $lt{'ifch'}: $ccdomain
+ENDNOPRIV
+ }
+ }
+ if (&Apache::lonnet::allowed('mpq',$env{'request.role.domain'})) {
+ # Current user has quota modification privileges
+ $r->print(&portfolio_quota($ccuname,$ccdomain));
}
} ## End of "check for bad authentication type" logic
} ## End of new user/old user logic
@@ -877,34 +920,38 @@ ENDOTHERAUTHS
'ssd' => "Set Start Date",
'sed' => "Set End Date"
);
- $r->print(<$lt{'cs'}
-
+"javascript:pjump('."'date_end','End Date Co-Author',document.cu.end_$cudom\_$cuname\_ca.value,'end_$cudom\_$cuname\_ca','cu.pres','dateset'".')">'.$lt{'sed'}.'
+"javascript:pjump('."'date_start','Start Date Assistant Co-Author',document.cu.start_$cudom\_$cuname\_aa.value,'start_$cudom\_$cuname\_aa','cu.pres','dateset'".')">'.$lt{'ssd'}.'
+"javascript:pjump('."'date_start','Start Date $plrole',document.cu.start_$thisdomain\_$role.value,'start_$thisdomain\_$role','cu.pres','dateset'".')">'.$lt{'ssd'}.'
-ENDDROW
+"javascript:pjump('."'date_end','End Date $plrole',document.cu.end_$thisdomain\_$role.value,'end_$thisdomain\_$role','cu.pres','dateset'".')">'.$lt{'sed'}.''.
+&Apache::loncommon::end_data_table_row();
}
}
}
- $domaintext.='
';
+ $domaintext.= &Apache::loncommon::end_data_table();
if ($num_domain_level > 0) {
$r->print($domaintext);
}
@@ -1101,24 +1150,42 @@ ENDMODIFYUSERHEAD
if (! $env{'form.makeuser'} ) {
# Check for need to change
my %userenv = &Apache::lonnet::get
- ('environment',['firstname','middlename','lastname','generation'],
- $env{'form.ccdomain'},$env{'form.ccuname'});
+ ('environment',['firstname','middlename','lastname','generation',
+ 'portfolioquota'],$env{'form.ccdomain'},$env{'form.ccuname'});
my ($tmp) = keys(%userenv);
if ($tmp =~ /^(con_lost|error)/i) {
%userenv = ();
}
# Check to see if we need to change user information
- foreach ('firstname','middlename','lastname','generation') {
+ foreach my $item ('firstname','middlename','lastname','generation') {
# Strip leading and trailing whitespace
- $env{'form.c'.$_} =~ s/(\s+$|^\s+)//g;
+ $env{'form.c'.$item} =~ s/(\s+$|^\s+)//g;
+ }
+ my ($quotachanged,$namechanged,$oldportfolioquota);
+ my %changeHash;
+ if (exists($userenv{'portfolioquota'})) {
+ $oldportfolioquota = $userenv{'portfolioquota'};
+ if (exists($env{'form.portfolioquota'})) {
+ if ($env{'form.portfolioquota'} ne $userenv{'portfolioquota'}) {
+ if (&Apache::lonnet::allowed('mpq',$env{'form.ccdomain'})) {
+ # Current user has quota modification privileges
+ $quotachanged = 1;
+ $changeHash{'portfolioquota'} = $env{'form.portfolioquota'};
+ }
+ }
+ }
+ } else {
+ $oldportfolioquota = &default_quota($env{'form.ccdomain'});
}
if (&Apache::lonnet::allowed('mau',$env{'form.ccdomain'}) &&
($env{'form.cfirstname'} ne $userenv{'firstname'} ||
$env{'form.cmiddlename'} ne $userenv{'middlename'} ||
$env{'form.clastname'} ne $userenv{'lastname'} ||
$env{'form.cgeneration'} ne $userenv{'generation'} )) {
+ $namechanged = 1;
+ }
+ if ($namechanged) {
# Make the change
- my %changeHash;
$changeHash{'firstname'} = $env{'form.cfirstname'};
$changeHash{'middlename'} = $env{'form.cmiddlename'};
$changeHash{'lastname'} = $env{'form.clastname'};
@@ -1134,6 +1201,7 @@ ENDMODIFYUSERHEAD
'mddl' => "middle",
'lst' => "last",
'gen' => "generation",
+ 'disk' => "disk space allocated to portfolio files",
'prvs' => "Previous",
'chto' => "Changed To"
);
@@ -1144,17 +1212,21 @@ ENDMODIFYUSERHEAD
$lt{'frst'}
$lt{'mddl'}
$lt{'lst'}
-
$lt{'gen'}
+
$lt{'gen'}
+
$lt{'disk'}
$lt{'prvs'}
$userenv{'firstname'}
$userenv{'middlename'}
$userenv{'lastname'}
-
$userenv{'generation'}
+
$userenv{'generation'}
+
$oldportfolioquota
+
$lt{'chto'}
$env{'form.cfirstname'}
$env{'form.cmiddlename'}
$env{'form.clastname'}
-
$env{'form.cgeneration'}
+
$env{'form.cgeneration'}
+
$env{'form.portfolioquota'} Mb
END
} else { # error occurred
@@ -1163,28 +1235,40 @@ END
$env{'form.ccdomain'}."");
}
} else { # End of if ($env ... ) logic
+ my $putresult;
+ if ($quotachanged) {
+ $putresult = &Apache::lonnet::put
+ ('environment',\%changeHash,
+ $env{'form.ccdomain'},$env{'form.ccuname'});
+ }
# They did not want to change the users name but we can
# still tell them what the name is
my %lt=&Apache::lonlocal::texthash(
'usr' => "User",
'id' => "in domain",
- 'gen' => "Generation"
+ 'gen' => "Generation",
+ 'disk' => "Disk space allocated to user's portfolio files",
);
- $r->print(<<"END");
+ $r->print(<<"END");