[LON-CAPA-cvs] cvs: loncom /interface loncommon.pm

albertel lon-capa-cvs@mail.lon-capa.org
Thu, 30 Nov 2006 22:29:07 -0000


albertel		Thu Nov 30 17:29:07 2006 EDT

  Modified files:              
    /loncom/interface	loncommon.pm 
  Log:
  - switch to ue herlper re
  
  
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.478 loncom/interface/loncommon.pm:1.479
--- loncom/interface/loncommon.pm:1.478	Wed Nov 29 17:02:47 2006
+++ loncom/interface/loncommon.pm	Thu Nov 30 17:29:03 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.478 2006/11/29 22:02:47 www Exp $
+# $Id: loncommon.pm,v 1.479 2006/11/30 22:29:03 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -65,7 +65,7 @@
 use Apache::loncoursedata();
 use Apache::lontexconvert();
 use Apache::lonclonecourse();
-use LONCAPA;
+use LONCAPA qw(:DEFAULT :match);
 
 my $readit;
 
@@ -157,7 +157,7 @@
     opendir(DIR,$designdir);
     while ($filename=readdir(DIR)) {
 	if ($filename!~/\.tab$/) { next; }
-	my ($domain)=($filename=~/^(\w+)\./);
+	my ($domain)=($filename=~/^($match_domain)\./);
 	{
 	    my $designfile = $designdir.'/'.$filename;
 	    if ( open (my $fh,"<$designfile") ) {
@@ -2810,8 +2810,8 @@
     my %courses;
     my $now=time;
     foreach my $key (keys(%env)) {
-	if ( $key=~m{^user\.role\.(\w+)\./(\w+)/(\w+)/?(\w*)$} ||
-             $key=~m{^user\.role\.(cr/\w+/\w+/\w+)\./(\w+)/(\w+)}) {
+	if ( $key=~m{^user\.role\.(\w+)\./($match_domain)/($match_username)/?(\w*)$} ||
+             $key=~m{^user\.role\.(cr/$match_domain/$match_username/\w+)\./($match_domain)/($match_username)}) {
 	    my ($role,$domain,$id,$sec) = ($1,$2,$3,$4);
 	    next if ($role eq 'ca' || $role eq 'aa');
 	    next if (%roles && !exists($roles{$role}));
@@ -3118,7 +3118,7 @@
  # role and realm
     my ($role,$realm) = split(/\./,$env{'request.role'},2);
     if ($role  eq 'ca') {
-        my ($rdom,$rname) = ($realm =~ m-^/(\w+)/(\w+)$-);
+        my ($rdom,$rname) = ($realm =~ m{^/($match_domain)/($match_username)$});
         $realm = &plainname($rname,$rdom).':'.$rdom;
     } 
 # realm
@@ -3624,8 +3624,6 @@
 table.LC_whatsnew tr.LC_empty_row td {
   padding: 4ex
 }
-
-
 table.LC_whatsnew {
 }
 
@@ -6015,7 +6013,7 @@
 #
 # Check if created correctly
 #
-    ($$crsudom,$$crsunum)=($$courseid=~/^\/(\w+)\/(\w+)$/);
+    ($$crsudom,$$crsunum)= &LONCAPA::split_courseid($$courseid);
     my $crsuhome=&Apache::lonnet::homeserver($$crsunum,$$crsudom);
     $outcome .= &mt('Created on').': '.$crsuhome.'<br>';
 #
@@ -6024,7 +6022,7 @@
     my $cloneid='';
     if (($args->{'clonecourse'}) && ($args->{'clonedomain'})) {
 	$cloneid='/'.$args->{'clonedomain'}.'/'.$args->{'clonecourse'};
-        my ($clonecrsudom,$clonecrsunum)=($cloneid=~/^\/(\w+)\/(\w+)$/);
+        my ($clonecrsudom,$clonecrsunum)= &LONCAPA::split_courseid($cloneid);
 	my $clonehome=&Apache::lonnet::homeserver($clonecrsunum,$clonecrsudom);
 	if ($clonehome eq 'no_host') {
 	    $outcome .=