[LON-CAPA-cvs] cvs: loncom /interface loncreateuser.pm /lonnet/perl lonnet.pm
www
lon-capa-cvs@mail.lon-capa.org
Fri, 18 Jul 2003 19:50:28 -0000
This is a MIME encoded message
--www1058557828
Content-Type: text/plain
www Fri Jul 18 15:50:28 2003 EDT
Modified files:
/loncom/interface loncreateuser.pm
/loncom/lonnet/perl lonnet.pm
Log:
Work on bug #795
--www1058557828
Content-Type: text/plain
Content-Disposition: attachment; filename="www-20030718155028.txt"
Index: loncom/interface/loncreateuser.pm
diff -u loncom/interface/loncreateuser.pm:1.60 loncom/interface/loncreateuser.pm:1.61
--- loncom/interface/loncreateuser.pm:1.60 Fri Jul 18 09:45:14 2003
+++ loncom/interface/loncreateuser.pm Fri Jul 18 15:50:28 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Create a user
#
-# $Id: loncreateuser.pm,v 1.60 2003/07/18 13:45:14 www Exp $
+# $Id: loncreateuser.pm,v 1.61 2003/07/18 19:50:28 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -25,28 +25,6 @@
#
# http://www.lon-capa.org/
#
-# (Create a course
-# (My Desk
-#
-# (Internal Server Error Handler
-#
-# (Login Screen
-# 5/21/99,5/22,5/25,5/26,5/31,6/2,6/10,7/12,7/14,
-# 1/14/00,5/29,5/30,6/1,6/29,7/1,11/9 Gerd Kortemeyer)
-#
-# YEAR=2001
-# 3/1/1 Gerd Kortemeyer)
-#
-# 3/1 Gerd Kortemeyer)
-#
-# 2/14 Gerd Kortemeyer)
-#
-# 2/14,2/17,2/19,2/20,2/21,2/22,2/23,3/2,3/17,3/24,04/12 Gerd Kortemeyer
-# April Guy Albertelli
-# 05/10,10/16 Gerd Kortemeyer
-# 02/11/02 Matthew Hall
-#
-# $Id: loncreateuser.pm,v 1.60 2003/07/18 13:45:14 www Exp $
###
package Apache::loncreateuser;
@@ -90,7 +68,7 @@
my %rolehash=&Apache::lonnet::dump('roles');
foreach (keys %rolehash) {
if ($_=~/^rolesdef\_(\w+)$/) {
- $returnhash{$_}=$_;
+ $returnhash{$1}=$1;
}
}
return %returnhash;
@@ -873,11 +851,17 @@
$r->print(&Apache::loncommon::bodytag(
'Create Users, Change User Privileges').'<h2>');
+ my $syspriv='';
+ my $dompriv='';
+ my $coursepriv='';
my ($rdummy,$roledef)=
&Apache::lonnet::get('roles',["rolesdef_$rolename"]);
# ------------------------------------------------------- Does this role exist?
if (($rdummy ne 'con_lost') && ($roledef ne '')) {
$r->print('Existing Role "');
+# ------------------------------------------------- Get current role privileges
+ ($syspriv,$dompriv,$coursepriv)=split(/\_/,$roledef);
+ $r->print($syspriv.' '.$dompriv.' '.$coursepriv);
} else {
$r->print('New Role "');
$roledef='';
@@ -886,26 +870,118 @@
# ------------------------------------------------------- What can be assigned?
my %full=();
my %courselevel=();
+ my %courselevelcurrent=();
foreach (split(/\:/,$Apache::lonnet::pr{'cr:c'})) {
my ($priv,$restrict)=split(/\&/,$_);
unless ($restrict) { $restrict='F'; }
$courselevel{$priv}=$restrict;
+ if ($coursepriv=~/\:$priv/) {
+ $courselevelcurrent{$priv}=1;
+ }
$full{$priv}=1;
}
my %domainlevel=();
+ my %domainlevelcurrent=();
foreach (split(/\:/,$Apache::lonnet::pr{'cr:d'})) {
my ($priv,$restrict)=split(/\&/,$_);
unless ($restrict) { $restrict='F'; }
$domainlevel{$priv}=$restrict;
+ if ($dompriv=~/\:$priv/) {
+ $domainlevelcurrent{$priv}=1;
+ }
$full{$priv}=1;
}
- $r->print('<table border="2"><tr><th>Privilege</th><th>Course Level</th><th>Domain Level</th></tr>');
+ my %systemlevel=();
+ my %systemlevelcurrent=();
+ foreach (split(/\:/,$Apache::lonnet::pr{'cr:s'})) {
+ my ($priv,$restrict)=split(/\&/,$_);
+ unless ($restrict) { $restrict='F'; }
+ $systemlevel{$priv}=$restrict;
+ if ($syspriv=~/\:$priv/) {
+ $systemlevelcurrent{$priv}=1;
+ }
+ $full{$priv}=1;
+ }
+ $r->print(<<ENDCCF);
+<form method="post">
+<input type="hidden" name="phase" value="set_custom_roles" />
+<input type="hidden" name="rolename" value="$rolename" />
+<table border="2">
+<tr><th>Privilege</th><th>Course Level</th><th>Domain Level</th>
+<th>System Level</th></tr>
+ENDCCF
foreach (sort keys %full) {
$r->print('<tr><td>'.&Apache::lonnet::plaintext($_).'</td><td>'.
- $courselevel{$_}.'</td><td>'.$domainlevel{$_}.'</td></tr>');
+ ($courselevel{$_}?'<input type="checkbox" name="'.$_.':c" '.
+ ($courselevelcurrent{$_}?'checked="1"':'').' />':' ').
+ '</td><td>'.
+ ($domainlevel{$_}?'<input type="checkbox" name="'.$_.':d" '.
+ ($domainlevelcurrent{$_}?'checked="1"':'').' />':' ').
+ '</td><td>'.
+ ($systemlevel{$_}?'<input type="checkbox" name="'.$_.':s" '.
+ ($systemlevelcurrent{$_}?'checked="1"':'').' />':' ').
+ '</td></tr>');
}
- $r->print('</table>');
- $r->print('Not yet implemented.');
+ $r->print(
+ '<table><input type="submit" value="Define Role" /></form></body></html>');
+}
+
+# ---------------------------------------------------------- Call to definerole
+sub set_custom_role {
+ my $r=shift;
+
+ my $rolename=$ENV{'form.rolename'};
+
+ $rolename=~s/\W//gs;
+
+ unless ($rolename) {
+ &print_username_entry_form($r);
+ return;
+ }
+
+ $r->print(&Apache::loncommon::bodytag(
+ 'Create Users, Change User Privileges').'<h2>');
+ my ($rdummy,$roledef)=
+ &Apache::lonnet::get('roles',["rolesdef_$rolename"]);
+# ------------------------------------------------------- Does this role exist?
+ if (($rdummy ne 'con_lost') && ($roledef ne '')) {
+ $r->print('Existing Role "');
+ } else {
+ $r->print('New Role "');
+ $roledef='';
+ }
+ $r->print($rolename.'"</h2>');
+# ------------------------------------------------------- What can be assigned?
+ my $sysrole='';
+ my $domrole='';
+ my $courole='';
+
+ foreach (split(/\:/,$Apache::lonnet::pr{'cr:c'})) {
+ my ($priv,$restrict)=split(/\&/,$_);
+ unless ($restrict) { $restrict=''; }
+ if ($ENV{'form.'.$priv.':c'}) {
+ $courole.=':'.$_;
+ }
+ }
+
+ foreach (split(/\:/,$Apache::lonnet::pr{'cr:d'})) {
+ my ($priv,$restrict)=split(/\&/,$_);
+ unless ($restrict) { $restrict=''; }
+ if ($ENV{'form.'.$priv.':d'}) {
+ $domrole.=':'.$_;
+ }
+ }
+
+ foreach (split(/\:/,$Apache::lonnet::pr{'cr:s'})) {
+ my ($priv,$restrict)=split(/\&/,$_);
+ unless ($restrict) { $restrict=''; }
+ if ($ENV{'form.'.$priv.':s'}) {
+ $sysrole.=':'.$_;
+ }
+ }
+ $r->print('Defining Role: '.
+ &Apache::lonnet::definerole($rolename,$sysrole,$domrole,$courole));
+ $r->print('</body></html>');
}
# ================================================================ Main Handler
@@ -935,6 +1011,8 @@
&update_user_data($r);
} elsif ($ENV{'form.phase'} eq 'selected_custom_edit') {
&custom_role_editor($r);
+ } elsif ($ENV{'form.phase'} eq 'set_custom_roles') {
+ &set_custom_role($r);
}
} else {
$ENV{'user.error.msg'}=
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.391 loncom/lonnet/perl/lonnet.pm:1.392
--- loncom/lonnet/perl/lonnet.pm:1.391 Wed Jul 16 16:13:17 2003
+++ loncom/lonnet/perl/lonnet.pm Fri Jul 18 15:50:28 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network
# TCP networking package
#
-# $Id: lonnet.pm,v 1.391 2003/07/16 20:13:17 matthew Exp $
+# $Id: lonnet.pm,v 1.392 2003/07/18 19:50:28 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1936,14 +1936,14 @@
my ($tdummy,$tdomain,$trest)=split(/\//,$area);
if ($trole =~ /^cr\//) {
my ($rdummy,$rdomain,$rauthor,$rrole)=split(/\//,$trole);
- my $homsvr=homeserver($rauthor,$rdomain);
+ my $homsvr=homeserver($rauthor,$rdomain);
if ($hostname{$homsvr} ne '') {
- my $roledef=
- reply("get:$rdomain:$rauthor:roles:rolesdef_$rrole",
- $homsvr);
- if (($roledef ne 'con_lost') && ($roledef ne '')) {
+ my ($rdummy,$roledef)=
+ &get('roles',["rolesdef_$rrole"],$rdomain,$rauthor);
+
+ if (($rdummy ne 'con_lost') && ($roledef ne '')) {
my ($syspriv,$dompriv,$coursepriv)=
- split(/\_/,unescape($roledef));
+ split(/\_/,$roledef);
if (defined($syspriv)) {
$allroles{'cm./'}.=':'.$syspriv;
$allroles{$spec.'./'}.=':'.$syspriv;
@@ -2521,7 +2521,7 @@
sub definerole {
if (allowed('mcr','/')) {
my ($rolename,$sysrole,$domrole,$courole)=@_;
- foreach (split('/',$sysrole)) {
+ foreach (split(':',$sysrole)) {
my ($crole,$cqual)=split(/\&/,$_);
if ($pr{'cr:s'}!~/$crole/) { return "refused:s:$crole"; }
if ($pr{'cr:s'}=~/$crole\&/) {
@@ -2530,7 +2530,7 @@
}
}
}
- foreach (split('/',$domrole)) {
+ foreach (split(':',$domrole)) {
my ($crole,$cqual)=split(/\&/,$_);
if ($pr{'cr:d'}!~/$crole/) { return "refused:d:$crole"; }
if ($pr{'cr:d'}=~/$crole\&/) {
@@ -2539,7 +2539,7 @@
}
}
}
- foreach (split('/',$courole)) {
+ foreach (split(':',$courole)) {
my ($crole,$cqual)=split(/\&/,$_);
if ($pr{'cr:c'}!~/$crole/) { return "refused:c:$crole"; }
if ($pr{'cr:c'}=~/$crole\&/) {
--www1058557828--