[LON-CAPA-cvs] cvs: loncom /interface loncreateuser.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Thu, 23 Nov 2006 01:41:37 -0000
albertel Wed Nov 22 20:41:37 2006 EDT
Modified files:
/loncom/interface loncreateuser.pm
Log:
- switch to using the helper re
Index: loncom/interface/loncreateuser.pm
diff -u loncom/interface/loncreateuser.pm:1.138 loncom/interface/loncreateuser.pm:1.139
--- loncom/interface/loncreateuser.pm:1.138 Wed Nov 22 19:53:19 2006
+++ loncom/interface/loncreateuser.pm Wed Nov 22 20:41:37 2006
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Create a user
#
-# $Id: loncreateuser.pm,v 1.138 2006/11/23 00:53:19 albertel Exp $
+# $Id: loncreateuser.pm,v 1.139 2006/11/23 01:41:37 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -66,7 +66,7 @@
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;
@@ -251,7 +251,7 @@
$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');
@@ -490,7 +490,7 @@
$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;
}
}
@@ -619,12 +619,12 @@
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";
@@ -660,7 +660,7 @@
}
}
# Compute the background color based on $area
- if ($area=~/^\/(\w+)\/(\d\w+)\/(\w+)/) {
+ if ($area=~m{^/($match_domain)/($match_username)/(\w+)}) {
$carea.='<br />Section: '.$3;
$sortkey.="\0$3";
}
@@ -668,7 +668,7 @@
} 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;
@@ -692,7 +692,7 @@
}
}
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 {
@@ -994,7 +994,7 @@
# 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('<hr /><input type="button" value="'.&mt('Modify User').'" onClick="setCourse()">'."\n");
} else {
@@ -1273,7 +1273,7 @@
&Apache::lonnet::revokerole($env{'form.ccdomain'},
$env{'form.ccuname'},$1,$2).'</b><br />');
if ($2 eq 'st') {
- $1=~/^\/(\w+)\/(\w+)/;
+ $1=~m{^/($match_domain)/($match_username)};
my $cid=$1.'_'.$2;
$r->print(&mt('Drop from classlist').': <b>'.
&Apache::lonnet::critical('put:'.
@@ -1285,10 +1285,10 @@
$env{'course.'.$cid.'.home'}).'</b><br />');
}
}
- if ($key=~/^form\.rev\:([^\_]+)\_cr\.cr\/(\w+)\/(\w+)\/(\w+)$/) {
+ if ($key=~m{^form\.rev\:([^_]+)_cr\.cr/($match_domain)/($match_username)/(\w+)$}) {
# Revoke custom role
$r->print(&mt('Revoking custom role:').
- ' '.$4.' by '.$3.'@'.$2.' in '.$1.': <b>'.
+ ' '.$4.' by '.$3.':'.$2.' in '.$1.': <b>'.
&Apache::lonnet::revokecustomrole($env{'form.ccdomain'},
$env{'form.ccuname'},$1,$2,$3,$4).
'</b><br />');
@@ -1300,7 +1300,7 @@
&Apache::lonnet::assignrole($env{'form.ccdomain'},
$env{'form.ccuname'},$1,$2,$now,0,1).'<br />');
if ($2 eq 'st') {
- $1=~/^\/(\w+)\/(\w+)/;
+ $1=~m{^/($match_domain)/($match_username)};
my $cid=$1.'_'.$2;
$r->print(&mt('Drop from classlist').': <b>'.
&Apache::lonnet::critical('put:'.
@@ -1312,7 +1312,7 @@
$env{'course.'.$cid.'.home'}).'</b><br />');
}
}
- if ($key=~/^form\.del\:([^\_]+)\_cr\.cr\/(\w+)\/(\w+)\/(\w+)$/) {
+ if ($key=~m{^form\.del\:([^_]+)_cr\.cr/($match_domain)/($match_username)/(\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]',
@@ -1331,7 +1331,7 @@
my $logmsg;
my $output;
if ($role eq 'st') {
- if ($url =~ m-^/(\w+)/(\w+)/?(\w*)$-) {
+ if ($url =~ m-^/($match_domain)/($match_username)/?(\w*)$-) {
my $result = &Apache::loncommon::commit_studentrole(\$logmsg,$udom,$uname,$url,$role,$now,0,$1,$2,$3);
if (($result =~ /^error/) || ($result eq 'not_in_class') || ($result eq 'unknown_course')) {
$output = "Error: $result\n";
@@ -1351,7 +1351,7 @@
$r->print($output);
}
# Re-enable custom role
- if ($key=~/^form\.ren\:([^\_]+)\_cr\.cr\/(\w+)\/(\w+)\/(\w+)$/) {
+ if ($key=~m{^form\.ren\:([^_]+)_cr\.cr/($match_domain)/($match_username)/(\w+)$}) {
my ($url,$rdom,$rnam,$rolename) = ($1,$2,$3,$4);
my $result = &Apache::lonnet::assigncustomrole(
$env{'form.ccdomain'}, $env{'form.ccuname'},
@@ -1362,7 +1362,7 @@
} elsif ($key=~/^form\.act/) {
my $udom = $env{'form.ccdomain'};
my $uname = $env{'form.ccuname'};
- if ($key=~/^form\.act\_([^\_]+)\_([^\_]+)\_cr_cr_([^\_]+)_(\w+)_([^\_]+)$/) {
+ if ($key=~/^form\.act\_($match_domain)\_($match_username)\_cr_cr_($match_domain)_($match_username)_([^\_]+)$/) {
# Activate a custom role
my ($one,$two,$three,$four,$five)=($1,$2,$3,$4,$5);
my $url='/'.$one.'/'.$two;
@@ -1393,7 +1393,7 @@
$r->print(&Apache::loncommon::commit_customrole($udom,$uname,$securl,$three,$four,$five,$start,$end));
}
}
- } elsif ($key=~/^form\.act\_([^\_]+)\_(\w+)\_([^\_]+)$/) {
+ } elsif ($key=~/^form\.act\_($match_domain)\_($match_username)\_([^\_]+)$/) {
# Activate roles for sections with 3 id numbers
# set start, end times, and the url for the class
my ($one,$two,$three)=($1,$2,$3);