[LON-CAPA-cvs] cvs: loncom /auth roles.tab rolesplain.tab /lonnet/perl lonnet.pm

www lon-capa-cvs@mail.lon-capa.org
Mon, 31 Mar 2003 20:31:39 -0000


www		Mon Mar 31 15:31:39 2003 EDT

  Modified files:              
    /loncom/auth	roles.tab rolesplain.tab 
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  Routines to complete delete a role, using lond's rolesdel command.
  New privilege "dro" for doing so.
  
  
Index: loncom/auth/roles.tab
diff -u loncom/auth/roles.tab:1.18 loncom/auth/roles.tab:1.19
--- loncom/auth/roles.tab:1.18	Tue Mar 19 14:37:06 2002
+++ loncom/auth/roles.tab	Mon Mar 31 15:31:39 2003
@@ -1,6 +1,6 @@
-su:s csu&U:sma:mau:cdc&U
+su:s csu&U:sma:mau:cdc&U:dro
 dc:s bre:sma
-dc:d cli&UIK:cau&U:cdg&UIK:mau:ccc&U:cin&UIK:cta&UIK:cep&UIK:ccr&UIK:cst&UIK:cad&UIK
+dc:d cli&UIK:cau&U:cdg&UIK:mau:ccc&U:cin&UIK:cta&UIK:cep&UIK:ccr&UIK:cst&UIK:cad&UIK:dro
 cc:s bre:sma:mcr
 cc:c cin&IK:cta&IK:cep&IK:ccr&IK:cst&IK:are:cre:ere:vgr:gan:srm:opa:mgr:rin:pch
 in:s sma
Index: loncom/auth/rolesplain.tab
diff -u loncom/auth/rolesplain.tab:1.5 loncom/auth/rolesplain.tab:1.6
--- loncom/auth/rolesplain.tab:1.5	Thu Apr 12 19:44:40 2001
+++ loncom/auth/rolesplain.tab	Mon Mar 31 15:31:39 2003
@@ -37,6 +37,7 @@
 cau:Grant/revoke role of Author
 cdg:Grant/revoke role of Domain Guest
 cca:Grant/revoke role of Co-Author
+dro:Delete a role
 mcr:Create a Course Custom Role
 mau:Modify authentication mechanism and data for a user
 bre:Browse resources
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.356 loncom/lonnet/perl/lonnet.pm:1.357
--- loncom/lonnet/perl/lonnet.pm:1.356	Fri Mar 28 16:20:16 2003
+++ loncom/lonnet/perl/lonnet.pm	Mon Mar 31 15:31:39 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.356 2003/03/28 21:20:16 albertel Exp $
+# $Id: lonnet.pm,v 1.357 2003/03/31 20:31:39 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2550,7 +2550,7 @@
 # ----------------------------------------------------------------- Assign Role
 
 sub assignrole {
-    my ($udom,$uname,$url,$role,$end,$start)=@_;
+    my ($udom,$uname,$url,$role,$end,$start,$deleteflag)=@_;
     my $mrole;
     if ($role =~ /^cr\//) {
 	unless (&allowed('ccr',$url)) {
@@ -2581,7 +2581,20 @@
            $command.='_0_'.$start;
         }
     }
+# actually delete
+    if ($deleteflag) {
+	if (&allowed('dro',$udom)) {
+# modify command to delete the role
+           $command="encrypt:rolesdel:$ENV{'user.domain'}:$ENV{'user.name'}:".
+                "$udom:$uname:$url".'_'."$mrole";
+# set start and finish to negative values for userrolelog
+           $start=-1;
+           $end=-1;
+        }
+    }
+# send command
     my $answer=&reply($command,&homeserver($uname,$udom));
+# log new user role if status is ok
     if ($answer eq 'ok') {
 	&userrolelog($mrole,$uname,$udom,$url,$start,$end);
     }
@@ -2859,25 +2872,26 @@
 # ---------------------------------------------------------- Assign Custom Role
 
 sub assigncustomrole {
-    my ($udom,$uname,$url,$rdom,$rnam,$rolename,$end,$start)=@_;
+    my ($udom,$uname,$url,$rdom,$rnam,$rolename,$end,$start,$deleteflag)=@_;
     return &assignrole($udom,$uname,$url,'cr/'.$rdom.'/'.$rnam.'/'.$rolename,
-                       $end,$start);
+                       $end,$start,$deleteflag);
 }
 
 # ----------------------------------------------------------------- Revoke Role
 
 sub revokerole {
-    my ($udom,$uname,$url,$role)=@_;
+    my ($udom,$uname,$url,$role,$deleteflag)=@_;
     my $now=time;
-    return &assignrole($udom,$uname,$url,$role,$now);
+    return &assignrole($udom,$uname,$url,$role,$now,$deleteflag);
 }
 
 # ---------------------------------------------------------- Revoke Custom Role
 
 sub revokecustomrole {
-    my ($udom,$uname,$url,$rdom,$rnam,$rolename)=@_;
+    my ($udom,$uname,$url,$rdom,$rnam,$rolename,$deleteflag)=@_;
     my $now=time;
-    return &assigncustomrole($udom,$uname,$url,$rdom,$rnam,$rolename,$now);
+    return &assigncustomrole($udom,$uname,$url,$rdom,$rnam,$rolename,$now,
+           $deleteflag);
 }
 
 # ------------------------------------------------------------ Directory lister