[LON-CAPA-cvs] cvs: loncom /interface loncommon.pm lonpickstudent.pm

albertel lon-capa-cvs@mail.lon-capa.org
Mon, 09 Jan 2006 20:38:52 -0000


albertel		Mon Jan  9 15:38:52 2006 EDT

  Modified files:              
    /loncom/interface	loncommon.pm lonpickstudent.pm 
  Log:
  -making section srm work a bit more universally 
  
  
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.301 loncom/interface/loncommon.pm:1.302
--- loncom/interface/loncommon.pm:1.301	Thu Dec 15 17:10:49 2005
+++ loncom/interface/loncommon.pm	Mon Jan  9 15:38:52 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.301 2005/12/15 22:10:49 albertel Exp $
+# $Id: loncommon.pm,v 1.302 2006/01/09 20:38:52 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -331,7 +331,10 @@
 sub studentbrowser_javascript {
    unless (
             (($env{'request.course.id'}) && 
-             (&Apache::lonnet::allowed('srm',$env{'request.course.id'})))
+             (&Apache::lonnet::allowed('srm',$env{'request.course.id'})
+	      || &Apache::lonnet::allowed('srm',$env{'request.course.id'}.
+					  '/'.$env{'request.course.sec'})
+	      ))
          || ($env{'request.role'}=~/^(au|dc|su)/)
           ) { return ''; }  
    return (<<'ENDSTDBRW');
@@ -362,7 +365,9 @@
 sub selectstudent_link {
    my ($form,$unameele,$udomele)=@_;
    if ($env{'request.course.id'}) {  
-       unless (&Apache::lonnet::allowed('srm',$env{'request.course.id'})) {
+       if (!&Apache::lonnet::allowed('srm',$env{'request.course.id'})
+	   && !&Apache::lonnet::allowed('srm',$env{'request.course.id'}.
+					'/'.$env{'request.course.sec'})) {
 	   return '';
        }
        return "<a href='".'javascript:openstdbrowser("'.$form.'","'.$unameele.
Index: loncom/interface/lonpickstudent.pm
diff -u loncom/interface/lonpickstudent.pm:1.9 loncom/interface/lonpickstudent.pm:1.10
--- loncom/interface/lonpickstudent.pm:1.9	Thu Apr  7 02:56:23 2005
+++ loncom/interface/lonpickstudent.pm	Mon Jan  9 15:38:52 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Pick a student from the classlist
 #
-# $Id: lonpickstudent.pm,v 1.9 2005/04/07 06:56:23 albertel Exp $
+# $Id: lonpickstudent.pm,v 1.10 2006/01/09 20:38:52 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -57,10 +57,16 @@
         ($ENV{'QUERY_STRING'},['filter','form','unameelement','udomelement',
 			       'roles']);
 # Allowed?
+    my $allowed;
+    my $scope = $env{'request.course.id'};
+    if (!($allowed = &Apache::lonnet::allowed('srm',$scope))) {
+	$scope .= '/'.$env{'request.course.sec'};
+	$allowed = &Apache::lonnet::allowed('srm',$scope);
+	if ($allowed) { $allowed = 'section';	}
+    }
 
     unless (($env{'form.roles'}) ||
-            (($env{'request.course.id'}) && 
-             (&Apache::lonnet::allowed('srm',$env{'request.course.id'})))) {
+            (($env{'request.course.id'}) && ($allowed))) {
 	$r->print('<body>No context.</body>');
         return OK;
     }
@@ -91,8 +97,7 @@
 ENDSCRIPT
     
   $r->print('<form>');
-  if ((&Apache::lonnet::allowed('srm',$env{'request.course.id'})) &&
-      (!$env{'form.roles'})) {
+  if ($allowed && (!$env{'form.roles'})) {
 # -------------------------------------------------------- Get course personnel
     $r->print('<h3>'.$env{'course.'.$env{'request.course.id'}.'.description'}.
               '</h3>');
@@ -120,6 +125,9 @@
         # the following undefs are for 'domain', and 'username' respectively.
 	my (undef,undef,$end,$start,$id,$section,$fullname,$status)=
             @{$classlist->{$_}};
+	if ($allowed eq 'section' && $section ne $env{'request.course.sec'}) {
+	    next;
+	}
         if ($_=~/^(\w+)\:(\w+)$/) {
 	    my ($uname,$udom)=($1,$2);
 	    if (($uname=~/^$filter/) ||