--- loncom/interface/loncreateuser.pm 2006/11/23 00:04:09 1.137
+++ loncom/interface/loncreateuser.pm 2006/12/01 21:00:35 1.140
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Create a user
#
-# $Id: loncreateuser.pm,v 1.137 2006/11/23 00:04:09 raeburn Exp $
+# $Id: loncreateuser.pm,v 1.140 2006/12/01 21:00:35 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -66,7 +66,7 @@ use Apache::loncommon;
use Apache::lonlocal;
use Apache::longroup;
use lib '/home/httpd/lib/perl/';
-use LONCAPA;
+use LONCAPA qw(:DEFAULT :match);
my $loginscript; # piece of javascript used in two separate instances
my $generalrule;
@@ -216,11 +216,8 @@ END
# =================================================================== Phase two
sub print_user_modification_page {
my $r=shift;
- my $ccuname=$env{'form.ccuname'};
- my $ccdomain=$env{'form.ccdomain'};
-
- $ccuname=~s/\W//g;
- $ccdomain=~s/\W//g;
+ my $ccuname =&LONCAPA::clean_username($env{'form.ccuname'});
+ my $ccdomain=&LONCAPA::clean_domain($env{'form.ccdomain'});
unless (($ccuname) && ($ccdomain)) {
&print_username_entry_form($r);
@@ -238,9 +235,9 @@ sub print_user_modification_page {
);
$loginscript = &Apache::loncommon::authform_header(%param);
$authformkrb = &Apache::loncommon::authform_kerberos(%param);
-
- $ccuname=~s/\W//g;
- $ccdomain=~s/\W//g;
+
+ $ccuname =&LONCAPA::clean_username($ccuname);
+ $ccdomain=&LONCAPA::clean_domain($ccdomain);
my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition();
my $dc_setcourse_code = '';
my $nondc_setsection_code = '';
@@ -254,7 +251,7 @@ sub print_user_modification_page {
$groupslist = '"'.$groupslist.'"';
}
- if ($env{'request.role'} =~ m-^dc\./(\w+)/$-) {
+ if ($env{'request.role'} =~ m-^dc\./($match_domain)/$-) {
my $dcdom = $1;
$loaditem{'onload'} = "document.cu.coursedesc.value='';";
my @rolevals = ('st','ta','ep','in','cc');
@@ -493,7 +490,7 @@ ENDFORMINFO
$incdomains{$item}=1;
}
foreach my $key (keys(%env)) {
- if ($key=~/^user\.priv\.cm\.\/(\w+)\/(\w+)/) {
+ if ($key=~/^user\.priv\.cm\.\/($match_domain)\/($match_username)/) {
$inccourses{$1.'_'.$2}=1;
}
}
@@ -622,12 +619,12 @@ END
split(/_/,$role);
# Is this a custom role? Get role owner and title.
my ($croleudom,$croleuname,$croletitle)=
- ($role_code=~/^cr\/(\w+)\/(\w+)\/(\w+)$/);
+ ($role_code=~m{^cr/($match_domain)/($match_username)/(\w+)$});
my $allowed=0;
my $delallowed=0;
my $sortkey=$role_code;
my $class='Unknown';
- if ($area =~ /^\/(\w+)\/(\d\w+)/ ) {
+ if ($area =~ m{^/($match_domain)/($match_username)} ) {
$class='Course';
my ($coursedom,$coursedir) = ($1,$2);
$sortkey.="\0$coursedom";
@@ -663,7 +660,7 @@ END
}
}
# Compute the background color based on $area
- if ($area=~/^\/(\w+)\/(\d\w+)\/(\w+)/) {
+ if ($area=~m{^/($match_domain)/($match_username)/(\w+)}) {
$carea.='
Section: '.$3;
$sortkey.="\0$3";
}
@@ -671,7 +668,7 @@ END
} else {
$sortkey.="\0".$area;
# Determine if current user is able to revoke privileges
- if ($area=~ /^\/(\w+)\//) {
+ if ($area=~m{^/($match_domain)/}) {
if ((&Apache::lonnet::allowed('c'.$role_code,$1)) ||
(&Apache::lonnet::allowed('c'.$role_code,$ccdomain))) {
$allowed=1;
@@ -695,7 +692,7 @@ END
}
}
if (($role_code eq 'ca') || ($role_code eq 'aa')) {
- $area=~/\/(\w+)\/(\w+)/;
+ $area=~m{/($match_domain)/($match_username)};
if (&authorpriv($2,$1)) {
$allowed=1;
} else {
@@ -997,7 +994,7 @@ ENDNOPRIV
# Course and group levels
#
- if ($env{'request.role'} =~ m-^dc\./(\w+)/$-) {
+ if ($env{'request.role'} =~ m{^dc\./($match_domain)/$}) {
$r->print(&course_level_dc($1,'Course'));
$r->print('