--- loncom/interface/loncreateuser.pm 2003/07/17 18:10:53 1.57 +++ loncom/interface/loncreateuser.pm 2003/07/17 19:40:39 1.59 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Create a user # -# $Id: loncreateuser.pm,v 1.57 2003/07/17 18:10:53 matthew Exp $ +# $Id: loncreateuser.pm,v 1.59 2003/07/17 19:40:39 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -46,7 +46,7 @@ # 05/10,10/16 Gerd Kortemeyer # 02/11/02 Matthew Hall # -# $Id: loncreateuser.pm,v 1.57 2003/07/17 18:10:53 matthew Exp $ +# $Id: loncreateuser.pm,v 1.59 2003/07/17 19:40:39 www Exp $ ### package Apache::loncreateuser; @@ -83,6 +83,18 @@ BEGIN { } +# ======================================================= Existing Custom Roles + +sub my_custom_roles { + my %returnhash=(); + my %rolehash=&Apache::lonnet::dump('roles'); + foreach (keys %rolehash) { + if ($_=~/^rolesdef\_(\w+)$/) { + $returnhash{$_}=$_; + } + } + return %returnhash; +} # ==================================================== Figure out author access @@ -107,6 +119,9 @@ sub print_username_entry_form { my $selscript=&Apache::loncommon::studentbrowser_javascript(); my $sellink=&Apache::loncommon::selectstudent_link ('crtuser','ccuname','ccdomain'); + my %existingroles=&my_custom_roles(); + my $choice=&Apache::loncommon::select_form('make new role','rolename', + ('make new role' => 'Generate new role ...',%existingroles)); $r->print(<<"ENDDOCUMENT"); @@ -116,15 +131,19 @@ $selscript $bodytag
-

+

Set Individual User Roles

-
Username: $sellink
Domain:$domform
-

- + +
+
+ +

Edit Custom Role Privileges

+Name of Role: $choice
+ ENDDOCUMENT @@ -136,6 +155,14 @@ sub print_user_modification_page { my $ccuname=$ENV{'form.ccuname'}; my $ccdomain=$ENV{'form.ccdomain'}; + $ccuname=~s/\W//gs; + $ccdomain=~s/\W//gs; + + unless (($ccuname) && ($ccdomain)) { + &print_username_entry_form($r); + return; + } + my $defdom=$ENV{'request.role.domain'}; my ($krbdef,$krbdefdom) = @@ -827,6 +854,37 @@ END $r->print(''); } +# ========================================================== Custom Role Editor + +sub custom_role_editor { + my $r=shift; + my $rolename=$ENV{'form.rolename'}; + + if ($rolename eq 'make new role') { + $rolename=$ENV{'form.newrolename'}; + } + + $rolename=~s/\W//gs; + + unless ($rolename) { + &print_username_entry_form($r); + return; + } + + $r->print(&Apache::loncommon::bodytag( + 'Create Users, Change User Privileges').'

'); + my ($rdummy,$roledef)= + &Apache::lonnet::get('roles',["rolesdef_$rolename"]); + if (($rdummy ne 'con_lost') && ($roledef ne '')) { + $r->print('Existing Role "'); + } else { + $r->print('New Role "'); + $roledef=''; + } + $r->print($rolename.'"

'); + $r->print('Not yet implemented.'); +} + # ================================================================ Main Handler sub handler { my $r = shift; @@ -852,6 +910,8 @@ sub handler { &print_user_modification_page($r); } elsif ($ENV{'form.phase'} eq 'update_user_data') { &update_user_data($r); + } elsif ($ENV{'form.phase'} eq 'selected_custom_edit') { + &custom_role_editor($r); } } else { $ENV{'user.error.msg'}=