[LON-CAPA-cvs] cvs: loncom /interface loncreateuser.pm
www
lon-capa-cvs@mail.lon-capa.org
Thu, 17 Jul 2003 19:40:39 -0000
www Thu Jul 17 15:40:39 2003 EDT
Modified files:
/loncom/interface loncreateuser.pm
Log:
More work on Bug #795
Index: loncom/interface/loncreateuser.pm
diff -u loncom/interface/loncreateuser.pm:1.58 loncom/interface/loncreateuser.pm:1.59
--- loncom/interface/loncreateuser.pm:1.58 Thu Jul 17 14:14:41 2003
+++ loncom/interface/loncreateuser.pm Thu Jul 17 15:40:39 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Create a user
#
-# $Id: loncreateuser.pm,v 1.58 2003/07/17 18:14:41 www 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.58 2003/07/17 18:14:41 www Exp $
+# $Id: loncreateuser.pm,v 1.59 2003/07/17 19:40:39 www Exp $
###
package Apache::loncreateuser;
@@ -83,6 +83,18 @@
}
+# ======================================================= 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 @@
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");
<html>
<head>
@@ -127,7 +142,7 @@
<form action="/adm/createuser" method="post" name="docustom">
<input type="hidden" name="phase" value="selected_custom_edit">
<h2>Edit Custom Role Privileges</h2>
-Name of Role: <input type="text" size="15" name="rolename" /><br />
+Name of Role: $choice <input type="text" size="15" name="newrolename" /><br />
<input name="customeditor" type="submit" value="Custom Role Editor" />
</body>
</html>
@@ -845,6 +860,10 @@
my $r=shift;
my $rolename=$ENV{'form.rolename'};
+ if ($rolename eq 'make new role') {
+ $rolename=$ENV{'form.newrolename'};
+ }
+
$rolename=~s/\W//gs;
unless ($rolename) {
@@ -853,8 +872,17 @@
}
$r->print(&Apache::loncommon::bodytag(
- 'Create Users, Change User Privileges'));
- $r->print('Not yet implemented.');
+ 'Create Users, Change User Privileges').'<h2>');
+ 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.'"</h2>');
+ $r->print('Not yet implemented.');
}
# ================================================================ Main Handler