[LON-CAPA-cvs] cvs: loncom /interface lonuserutils.pm
raeburn
raeburn@source.lon-capa.org
Tue, 19 Jan 2010 18:02:20 -0000
raeburn Tue Jan 19 18:02:20 2010 EDT
Modified files:
/loncom/interface lonuserutils.pm
Log:
- Disallow non-word characters in section names.
Index: loncom/interface/lonuserutils.pm
diff -u loncom/interface/lonuserutils.pm:1.112 loncom/interface/lonuserutils.pm:1.113
--- loncom/interface/lonuserutils.pm:1.112 Thu Jan 14 18:15:31 2010
+++ loncom/interface/lonuserutils.pm Tue Jan 19 18:02:20 2010
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Utility functions for managing LON-CAPA user accounts
#
-# $Id: lonuserutils.pm,v 1.112 2010/01/14 18:15:31 bisitz Exp $
+# $Id: lonuserutils.pm,v 1.113 2010/01/19 18:02:20 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -4833,11 +4833,13 @@
plch => 'Please choose a different section name.',
mnot => 'may not be used as a section name, as it is the name of a course group.',
secn => 'Section names and group names must be distinct. Please choose a different section name.',
+ nonw => 'Section names may only contain letters or numbers.',
);
$setsection_js .= <<"ENDSECCODE";
function setSections(formname,crstype) {
var re1 = /^currsec_/;
+ var re2 =/\\W/;
var groups = new Array($groupslist);
for (var i=0;i<formname.elements.length;i++) {
var str = formname.elements[i].name;
@@ -4881,9 +4883,22 @@
}
var newsecs = formname.elements[i+1].value;
var numsplit;
+ var validsecs = new Array();
+ var badsecs = new Array();
if (newsecs != null && newsecs != "") {
numsplit = newsecs.split(/,/g);
- numsec = numsec + numsplit.length;
+ for (var i=0; i<numsplit.length; i++) {
+ if (re2.test(numsplit[i]) == true) {
+ badsecs.push(numsplit[i]);
+ } else {
+ validsecs.push(numsplit[i]);
+ }
+ }
+ if (badsecs.length > 0) {
+ alert("$alerts{'nonw'}\\n$alerts{'plch'}");
+ return;
+ }
+ numsec = numsec + validsecs.length;
}
if ((role == 'st') && (numsec > 1)) {