[LON-CAPA-cvs] cvs: loncom /interface loncreateuser.pm
raeburn
lon-capa-cvs@mail.lon-capa.org
Tue, 09 May 2006 17:21:13 -0000
This is a MIME encoded message
--raeburn1147195273
Content-Type: text/plain
raeburn Tue May 9 13:21:13 2006 EDT
Modified files:
/loncom/interface loncreateuser.pm
Log:
Correct scoping of arrays used to store new sections in javascript. Custom roles
can now be deleted and re-enabled.
--raeburn1147195273
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20060509132113.txt"
Index: loncom/interface/loncreateuser.pm
diff -u loncom/interface/loncreateuser.pm:1.115 loncom/interface/loncreateuser.pm:1.116
--- loncom/interface/loncreateuser.pm:1.115 Tue May 9 11:09:27 2006
+++ loncom/interface/loncreateuser.pm Tue May 9 13:21:13 2006
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Create a user
#
-# $Id: loncreateuser.pm,v 1.115 2006/05/09 15:09:27 albertel Exp $
+# $Id: loncreateuser.pm,v 1.116 2006/05/09 17:21:13 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -235,25 +235,26 @@
else {
sections = document.cu.elements[i+1].value;
}
- var newsecs = document.cu.elements[i+1].value;
- if (newsecs != null && newsecs != "") {
- var numsplit = newsecs.split(/,/g);
- numsec = numsec + numsplit.length;
+ 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<numsplit.length; j++) {
- if ((numsplit[j] == 'all') ||
- (numsplit[j] == 'none')) {
- alert("'"+numsplit[j]+"' may not be used as the name for a section, as it is a reserved word.\\nPlease choose a different section name.");
+ for (var j=0; j<newsecs.length; j++) {
+ if ((newsecs[j] == 'all') ||
+ (newsecs[j] == 'none')) {
+ alert("'"+newsecs[j]+"' may not be used as the name for a section, as it is a reserved word.\\nPlease choose a different section name.");
return;
}
for (var k=0; k<groups.length; k++) {
- if (numsplit[j] == groups[k]) {
- alert("'"+numsplit[j]+"' may not be used as a section name, as it is the name of a course group.\\nSection names and group names must be distinct. Please choose a different section name.");
+ if (newsecs[j] == groups[k]) {
+ alert("'"+newsecs[j]+"' may not be used as a section name, as it is the name of a course group.\\nSection names and group names must be distinct. Please choose a different section name.");
return;
}
}
@@ -324,6 +325,7 @@
var userrole = document.cu.role.options[document.cu.role.selectedIndex].value
var section="";
var numsections = 0;
+ var newsecs = new Array();
for (var i=0; i<document.cu.currsec.length; i++) {
if (document.cu.currsec.options[i].selected == true ) {
if (document.cu.currsec.options[i].value != "" && document.cu.currsec.options[i].value != null) {
@@ -345,23 +347,23 @@
else {
section = section + "," + document.cu.newsec.value
}
- var numsplit = document.cu.newsec.value.split(/,/g);
- numsections = numsections + numsplit.length;
+ newsecs = document.cu.newsec.value.split(/,/g);
+ numsections = numsections + newsecs.length;
}
if ((userrole == 'st') && (numsections > 1)) {
alert("In each course, each user may only have one student role at a time. You had selected "+numsections+" sections.\\nPlease modify your selections so they include no more than one section.")
return;
}
- for (var j=0; j<numsplit.length; j++) {
- if ((numsplit[j] == 'all') || (numsplit[j] == 'none')) {
- alert("'"+numsplit[j]+"' may not be used as the name for a section, as it is a reserved word.\\nPlease choose a different section name.");
+ for (var j=0; j<newsecs.length; j++) {
+ if ((newsecs[j] == 'all') || (newsecs[j] == 'none')) {
+ alert("'"+newsecs[j]+"' may not be used as the name for a section, as it is a reserved word.\\nPlease choose a different section name.");
return;
}
if (document.cu.groups.value != '') {
var groups = document.cu.groups.value.split(/,/g);
for (var k=0; k<groups.length; k++) {
- if (numsplit[j] == groups[k]) {
- alert("'"+numsplit[j]+"' may not be used as the name for a section, as it is the name of a course group.\\nSection names and group names must be distinct. Please choose a different section name.");
+ if (newsecs[j] == groups[k]) {
+ alert("'"+newsecs[j]+"' may not be used as the name for a section, as it is the name of a course group.\\nSection names and group names must be distinct. Please choose a different section name.");
return;
}
}
@@ -1238,7 +1240,8 @@
'</b><br />');
}
} elsif ($_=~/^form\.del/) {
- if ($_=~/^form\.del\:([^\_]+)\_([^\_]+)$/) {
+ if ($_=~/^form\.del\:([^\_]+)\_([^\_\.]+)$/) {
+# Delete standard role
$r->print(&mt('Deleting').' '.$2.' in '.$1.': '.
&Apache::lonnet::assignrole($env{'form.ccdomain'},
$env{'form.ccuname'},$1,$2,$now,0,1).'<br />');
@@ -1254,11 +1257,21 @@
&Apache::lonnet::escape($now.':'),
$env{'course.'.$cid.'.home'}).'</b><br />');
}
- }
+ }
+ if ($_=~/^form\.del\:([^\_]+)\_cr\.cr\/(\w+)\/(\w+)\/(\w+)$/) {
+ my ($url,$rdom,$rnam,$rolename) = ($1,$2,$3,$4);
+# Delete custom role
+ $r->print(&mt('Deleting custom role [_1] by [_2]@[_3] in [_4]',
+ $rolename,$rnam,$rdom,$url).': <b>'.
+ &Apache::lonnet::assigncustomrole($env{'form.ccdomain'},
+ $env{'form.ccuname'},$url,$rdom,$rnam,$rolename,$now,
+ 0,1).'</b><br />');
+ }
} elsif ($_=~/^form\.ren/) {
my $udom = $env{'form.ccdomain'};
my $uname = $env{'form.ccuname'};
- if ($_=~/^form\.ren\:([^\_]+)\_([^\_]+)$/) {
+# Re-enable standard role
+ if ($_=~/^form\.ren\:([^\_]+)\_([^\_\.]+)$/) {
my $url = $1;
my $role = $2;
my $logmsg;
@@ -1278,11 +1291,20 @@
} else {
my $result=&Apache::lonnet::assignrole($env{'form.ccdomain'},
$env{'form.ccuname'},$url,$role,0,$now);
- $output = &mt('Re-Enabling [_1] in [_2]: [_3]',
+ $output = &mt('Re-enabling [_1] in [_2]: <b>[_3]</b>',
$role,$url,$result).'<br />';
}
$r->print($output);
}
+# Re-enable custom role
+ if ($_=~/^form\.ren\:([^\_]+)\_cr\.cr\/(\w+)\/(\w+)\/(\w+)$/) {
+ my ($url,$rdom,$rnam,$rolename) = ($1,$2,$3,$4);
+ my $result = &Apache::lonnet::assigncustomrole(
+ $env{'form.ccdomain'}, $env{'form.ccuname'},
+ $url,$rdom,$rnam,$rolename,0,$now);
+ $r->print(&mt('Re-enabling custom role [_1] by [_2]@[_3] in [_4] : <b>[_5]</b>',
+ $rolename,$rnam,$rdom,$url,$result).'<br />');
+ }
} elsif ($_=~/^form\.act/) {
my $udom = $env{'form.ccdomain'};
my $uname = $env{'form.ccuname'};
--raeburn1147195273--