--- loncom/interface/loncreateuser.pm 2006/05/18 01:08:51 1.117
+++ 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.117 2006/05/18 01:08:51 raeburn Exp $
+# $Id: loncreateuser.pm,v 1.135 2006/11/22 16:06:28 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -65,6 +65,8 @@ use Apache::lonnet;
use Apache::loncommon;
use Apache::lonlocal;
use Apache::longroup;
+use lib '/home/httpd/lib/perl/';
+use LONCAPA;
my $loginscript; # piece of javascript used in two separate instances
my $generalrule;
@@ -97,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;
}
}
@@ -114,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 {
@@ -140,7 +156,7 @@ sub print_username_entry_form {
'nr' => "Name of Role",
'cre' => "Custom Role Editor"
);
- my $help = &Apache::loncommon::help_open_menu('',undef,undef,'',282,'Instructor Interface');
+ my $help = &Apache::loncommon::help_open_menu(undef,undef,282,'Instructor Interface');
my $helpsiur=&Apache::loncommon::help_open_topic('Course_Change_Privileges');
my $helpecpr=&Apache::loncommon::help_open_topic('Course_Editing_Custom_Roles');
$r->print(<<"ENDDOCUMENT");
@@ -193,81 +209,6 @@ sub user_modification_js {
$nondc_setsection_code
- function setSections() {
- var re1 = /^currsec_/;
- var groups = new Array($groupslist);
- for (var i=0;i 0) {
- if (document.cu.elements[i+1].value != "" && document.cu.elements[i+1].value != null) {
- sections = sections + "," + document.cu.elements[i+1].value;
- }
- }
- else {
- sections = document.cu.elements[i+1].value;
- }
- var newseclist = document.cu.elements[i+1].value;
- var newsecs = new Array();
- if (newseclist != null && newseclist != "") {
- newsecs = newseclist.split(/,/g);
- numsec = numsec + newsecs.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 {
- for (var j=0; j
END
}
@@ -302,7 +243,8 @@ sub print_user_modification_page {
$ccdomain=~s/\W//g;
my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition();
my $dc_setcourse_code = '';
- my $nondc_setsection_code = '';
+ my $nondc_setsection_code = '';
+
my %loaditem;
my $groupslist;
@@ -314,7 +256,18 @@ sub print_user_modification_page {
if ($env{'request.role'} =~ m-^dc\./(\w+)/$-) {
my $dcdom = $1;
- $loaditem{'onload'} = "document.cu.coursedesc.value=''";
+ $loaditem{'onload'} = "document.cu.coursedesc.value='';";
+ my @rolevals = ('st','ta','ep','in','cc');
+ my (@crsroles,@grproles);
+ for (my $i=0; $i<@rolevals; $i++) {
+ $crsroles[$i]=&Apache::lonnet::plaintext($rolevals[$i],'Course');
+ $grproles[$i]=&Apache::lonnet::plaintext($rolevals[$i],'Group');
+ }
+ my $rolevalslist = join('","',@rolevals);
+ my $crsrolenameslist = join('","',@crsroles);
+ my $grprolenameslist = join('","',@grproles);
+ my $pickcrsfirst = '<--'.&mt('Pick course first');
+ my $pickgrpfirst = '<--'.&mt('Pick group first');
$dc_setcourse_code = <<"ENDSCRIPT";
function setCourse() {
var course = document.cu.dccourse.value;
@@ -374,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+4].name = "sec"+coursename
- document.cu.elements[numcourse+4].value = section
- document.cu.elements[numcourse+5].name = "start"+coursename
- document.cu.elements[numcourse+6].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();
@@ -399,6 +361,36 @@ sub print_user_modification_page {
}
return -1;
}
+
+ function setType() {
+ var crstype = document.cu.crstype.options[document.cu.crstype.selectedIndex].value;
+ rolevals = new Array("$rolevalslist");
+ if (crstype == 'Group') {
+ if (document.cu.currsec.options[0].text == "$pickcrsfirst") {
+ document.cu.currsec.options[0].text = "$pickgrpfirst";
+ }
+ grprolenames = new Array("$grprolenameslist");
+ for (var i=0; i 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) {
@@ -634,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);
@@ -644,10 +641,12 @@ END
' '.&mt('Domain').': '.$coursedom.(' 'x8).
&Apache::loncommon::syllabuswrapper('Syllabus',$coursedir,$coursedom);
$sortkey.="\0".$coursedata{'description'};
+ $class=$coursedata{'type'};
} else {
$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))) {
@@ -735,7 +734,7 @@ END
}
my $plaintext='';
unless ($croletitle) {
- $plaintext=&Apache::lonnet::plaintext($role_code);
+ $plaintext=&Apache::lonnet::plaintext($role_code,$class)
} else {
$plaintext=
"Customrole '$croletitle' defined by $croleuname\@$croleudom";
@@ -755,7 +754,7 @@ END
} # end of foreach (table building loop)
my $rolesdisplay = 0;
my %output = ();
- foreach my $type ('Construction Space','Course','Domain','System','Unknown') {
+ foreach my $type ('Construction Space','Course','Group','Domain','System','Unknown') {
$output{$type} = '';
foreach my $which (sort {uc($a) cmp uc($b)} (keys(%sortrole))) {
if ( ($roleclass{$sortrole{$which}} =~ /^\Q$type\E/ ) && ($rolepriv{$sortrole{$which}}) ) {
@@ -777,7 +776,7 @@ END
$lt{'rev'}
$lt{'ren'}
$lt{'del'}
$lt{'rol'}
$lt{'e
xt'}
$lt{'sta'}
$lt{'end'}
END
- foreach my $type ('Construction Space','Course','Domain','System','Unknown') {
+ foreach my $type ('Construction Space','Course','Group','Domain','System','Unknown') {
if ($output{$type}) {
$r->print($output{$type}."\n");
}
@@ -800,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",
@@ -823,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",
@@ -832,9 +831,6 @@ ENDBADAUTH
);
$r->print(<
-
$lt{'err'}:
$lt{'uuas'} ($currentauth). $lt{'adcs'}.
@@ -865,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",
@@ -883,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
@@ -907,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);
}
#
-# Course level
+# Course and group levels
#
if ($env{'request.role'} =~ m-^dc\./(\w+)/$-) {
- $r->print(&course_level_dc($1));
+ $r->print(&course_level_dc($1,'Course'));
$r->print(''."\n");
} else {
$r->print(&course_level_table(%inccourses));
@@ -1131,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'};
@@ -1164,6 +1201,7 @@ ENDMODIFYUSERHEAD
'mddl' => "middle",
'lst' => "last",
'gen' => "generation",
+ 'disk' => "disk space allocated to portfolio files",
'prvs' => "Previous",
'chto' => "Changed To"
);
@@ -1174,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
@@ -1193,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");