[LON-CAPA-cvs] cvs: loncom /auth lonacc.pm lonlogin.pm lonroles.pm

raeburn lon-capa-cvs@mail.lon-capa.org
Thu, 11 Nov 2004 22:18:23 -0000


raeburn		Thu Nov 11 17:18:23 2004 EDT

  Modified files:              
    /loncom/auth	lonacc.pm lonlogin.pm lonroles.pm 
  Log:
  DC can select a CC role in his/her domain, and receive CC privileges on the fly.  Work in progress. Access is not quite set right for pages.
  
  
Index: loncom/auth/lonacc.pm
diff -u loncom/auth/lonacc.pm:1.51 loncom/auth/lonacc.pm:1.52
--- loncom/auth/lonacc.pm:1.51	Fri Apr 23 19:01:36 2004
+++ loncom/auth/lonacc.pm	Thu Nov 11 17:18:23 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Cookie Based Access Handler
 #
-# $Id: lonacc.pm,v 1.51 2004/04/23 23:01:36 albertel Exp $
+# $Id: lonacc.pm,v 1.52 2004/11/11 22:18:23 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -118,7 +118,11 @@
                 }
                 if ($ENV{'form.symb'}) {
 		    $symb=&Apache::lonnet::symbclean($ENV{'form.symb'});
-                    if (&Apache::lonnet::symbverify($symb,$requrl)) {
+                    if ($requrl =~ m|^/adm/wrapper/|) {
+                        my ($map,$mid,$murl)=&Apache::lonnet::decode_symb($symb);
+                        &Apache::lonnet::symblist($map,$murl => $mid,
+                                               'last_known' => $murl);
+                    } elsif (&Apache::lonnet::symbverify($symb,$requrl)) {
                       my ($map,$mid,$murl)=&Apache::lonnet::decode_symb($symb);
                       &Apache::lonnet::symblist($map,$murl => $mid,
                                                'last_known' => $murl);
Index: loncom/auth/lonlogin.pm
diff -u loncom/auth/lonlogin.pm:1.59 loncom/auth/lonlogin.pm:1.60
--- loncom/auth/lonlogin.pm:1.59	Tue Nov  2 18:20:17 2004
+++ loncom/auth/lonlogin.pm	Thu Nov 11 17:18:23 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Login Screen
 #
-# $Id: lonlogin.pm,v 1.59 2004/11/02 23:20:17 albertel Exp $
+# $Id: lonlogin.pm,v 1.60 2004/11/11 22:18:23 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -263,8 +263,8 @@
 		  'help' => 'Help',
 		  'serv' => 'Server',
                   'servadm' => 'Server Administration',
-                  'sysadm' => 'System Administration');
-
+                  'sysadm' => 'System Administration',
+                  'helpdesk' => 'Contact Helpdesk');
 
 # ---------------------------------------------------------- Serve rest of page
     $r->print(<<ENDSCRIPT);
@@ -447,6 +447,7 @@
     </form>
 ENDLOGIN
     if ($fullgraph) {
+        my $contactblock = &contactdisplay(\%lt,$sysadm,$servadm,$version);
 	$r->print(<<ENDDOCUMENT);
    </td>
 
@@ -499,13 +500,7 @@
       </tr>
      </table>
      <br />
-    <small>
-     <b>&nbsp;&nbsp;&nbsp;$lt{'sysadm'}:</b><br />
-     <tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$sysadm</tt><br />
-     <b>&nbsp;&nbsp;&nbsp;$lt{'servadm'}:</b><br />
-     <tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$servadm</tt><br />&nbsp;<br />
-     &nbsp;&nbsp;&nbsp;$version
-    </small>
+    $contactblock
    </td>
 
    <!-- Row 5 Column 2 -->
@@ -544,7 +539,31 @@
 }
     $r->print('</body></html>');
     return OK;
-} 
+}
+
+sub contactdisplay {
+    my ($lt,$sysadm,$servadm,$version) = @_;
+    my $contactblock;
+    my $showsysadm = 1;
+    my $showservadm = 1;
+    my $showhelpdesk = 1;
+    if ($showsysadm) {
+        $contactblock .= '<b>&nbsp;&nbsp;&nbsp;'.$$lt{'sysadm'}.':</b><br />'.
+                         '<tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.$sysadm.'</tt><br />';
+    }
+    if ($showservadm) {
+        $contactblock .= '<b>&nbsp;&nbsp;&nbsp;'.$$lt{'servadm'}.':</b><br />'.
+                         '<tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.$servadm.'</tt><br />&nbsp;<br />';
+    }
+    if ($showhelpdesk) {
+        $contactblock .= '<b>&nbsp;&nbsp;&nbsp;<a href="/adm/helpdesk">'.$$lt{'helpdesk'}.'</a></b><br />';
+    }
+    $contactblock .= <<"ENDBLOCK";
+     &nbsp;&nbsp;&nbsp;$version
+ENDBLOCK
+    return $contactblock;
+}
+ 
 
 1;
 __END__
Index: loncom/auth/lonroles.pm
diff -u loncom/auth/lonroles.pm:1.105 loncom/auth/lonroles.pm:1.106
--- loncom/auth/lonroles.pm:1.105	Tue Nov  9 15:04:48 2004
+++ loncom/auth/lonroles.pm	Thu Nov 11 17:18:23 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # User Roles Screen
 #
-# $Id: lonroles.pm,v 1.105 2004/11/09 20:04:48 raeburn Exp $
+# $Id: lonroles.pm,v 1.106 2004/11/11 22:18:23 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -120,6 +120,33 @@
 				"request.role"        => 'cm',
                                 "request.role.adv"    => $ENV{'user.adv'},
 				"request.role.domain" => $ENV{'user.domain'});
+
+# Check to see if the user is a DC trying to enter a course                            
+# course selection page
+        my $dcflag = 0;
+        if ($ENV{'form.dccourse'}) {
+            my $dcdom = $ENV{'form.dcdomain'};
+            my $pickedcourse = $ENV{'form.dccourse'};
+            if ($dcdom && $pickedcourse) {
+                unless ($ENV{'user.role.cc./'.$dcdom.'/'.$pickedcourse}) {
+                    if ($ENV{'user.role.dc./'.$dcdom.'/'}) {
+                        &set_privileges($dcdom,$pickedcourse);
+                        my $msg=&mt('Entering course ...');
+                        my ($furl,$ferr)=&Apache::lonuserstate::readmap($dcdom.'/'.$pickedcourse);
+                        my $formaction = '/adm/roles/';
+                        my $courseid = $dcdom.'_'.$pickedcourse;
+                        &Apache::lonhtmlcommon::store_recent('cc_pickby_dc_'.$dcdom,
+                            $courseid,$formaction);
+                        # Send the user to the course they selected
+                        &redirect_user($r,&mt('Entering Course'),
+                                $furl,$msg,
+                                $ENV{'environment.remotenavmap'});
+                        return OK;
+                    }
+                }
+            }
+        }
+
         foreach $envkey (keys %ENV) {
             next if ($envkey!~/^user\.role\./);
             my ($where,$trolecode,$role,$tstatus,$tend,$tstart);
@@ -675,7 +702,7 @@
              foreach my $which (sort {uc($a) cmp uc($b)} (keys(%sortrole))) {
                 my $skiprole = 0;
                 foreach my $dcdom (keys %dcroles) {
-                    if ($sortrole{$which} =~ m-(dc|cc)\./$dcdom/-) {
+                    if ($sortrole{$which} =~ m-(dc)\./$dcdom/-) {
                         $skiprole = 1;
                         last;
                     }
@@ -706,7 +733,7 @@
 		    $r->print("<tr bgcolor='#BBffBB'>".
 			      "<td align='center' colspan='7'>".&mt($type)."</td>");
 	        }
-	        $r->print($output);	    
+	        $r->print($output);	
 	    }
         }
     }
@@ -1009,6 +1036,35 @@
     return 'nohist_recent_'.&Apache::lonnet::escape($area);
 }
 
+sub set_privileges {
+    my ($dcdom,$pickedcourse) = @_;
+    my $area = '/'.$dcdom.'/'.$pickedcourse;
+    my $role = 'cc';
+    my $spec = $role.'.'.$area;
+    my $userroles = &Apache::lonnet::set_arearole($role,$area,'','',$dcdom,$ENV{'user.name'});
+    my %ccrole = ();
+    &Apache::lonnet::standard_roleprivs(\%ccrole,$role,$dcdom,$spec,$pickedcourse,$area);
+    $userroles .= &Apache::lonnet::set_userprivs(\$userroles,\%ccrole);                        my @newprivs = split/\n/,$userroles;
+    my %newccroles = ();
+    foreach (@newprivs) {
+        my ($key,$val) = split/=/,$_;
+        $newccroles{$key} = $val;
+    }
+    &Apache::lonnet::appenv(%newccroles);
+    &Apache::lonnet::log($ENV{'user.domain'},
+                         $ENV{'user.name'},
+                         $ENV{'user.home'},
+                        "Role ".$role);
+                                                                                           
+    &Apache::lonnet::appenv(
+                          'request.role'        => $role,
+                          'request.role.domain' => $dcdom,
+                          'request.course.sec'  => '');
+    my $tadv=0;
+    if (&Apache::lonnet::allowed('adv') eq 'F') { $tadv=1; }
+    &Apache::lonnet::appenv('request.role.adv'    => $tadv);
+}
+
 1;
 __END__