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

www lon-capa-cvs@mail.lon-capa.org
Sat, 19 Jul 2003 00:51:05 -0000


www		Fri Jul 18 20:51:05 2003 EDT

  Modified files:              
    /loncom/interface	loncreateuser.pm 
  Log:
  Work on Bug #795: can now define and re-define a custom role, and can assign
  role to self. Still needs work to assign and revoke custom roles for other
  users.
  
  
Index: loncom/interface/loncreateuser.pm
diff -u loncom/interface/loncreateuser.pm:1.62 loncom/interface/loncreateuser.pm:1.63
--- loncom/interface/loncreateuser.pm:1.62	Fri Jul 18 16:53:06 2003
+++ loncom/interface/loncreateuser.pm	Fri Jul 18 20:51:05 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Create a user
 #
-# $Id: loncreateuser.pm,v 1.62 2003/07/18 20:53:06 www Exp $
+# $Id: loncreateuser.pm,v 1.63 2003/07/19 00:51:05 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -842,7 +842,7 @@
 	$rolename=$ENV{'form.newrolename'};
     }
 
-    $rolename=~s/\W//gs;
+    $rolename=~s/[^A-Za-z0-9]//gs;
 
     unless ($rolename) {
 	&print_username_entry_form($r);
@@ -931,7 +931,7 @@
 
     my $rolename=$ENV{'form.rolename'};
 
-    $rolename=~s/\W//gs;
+    $rolename=~s/[^A-Za-z0-9]//gs;
 
     unless ($rolename) {
 	&print_username_entry_form($r);
@@ -978,8 +978,19 @@
 	    $sysrole.=':'.$_;
 	}
     }
-    $r->print('Defining Role: '.
+    $r->print('<br />Defining Role: '.
 	   &Apache::lonnet::definerole($rolename,$sysrole,$domrole,$courole));
+    if ($ENV{'request.course.id'}) {
+        my $url='/'.$ENV{'request.course.id'};
+        $url=~s/\_/\//g;
+	$r->print('<br />Assigning Role to Self: '.
+	      &Apache::lonnet::assigncustomrole($ENV{'user.domain'},
+						$ENV{'user.name'},
+						$url,
+						$ENV{'user.domain'},
+						$ENV{'user.name'},
+						$rolename));
+    }
     $r->print('</body></html>');
 }