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

raeburn lon-capa-cvs-allow@mail.lon-capa.org
Fri, 09 May 2008 17:55:29 -0000


raeburn		Fri May  9 13:55:29 2008 EDT

  Modified files:              
    /loncom/interface	lonuserutils.pm 
  Log:
  - Moving code used to generate role filter for "User Lists Display" to subroutine: &role_filter(). 
  
  
Index: loncom/interface/lonuserutils.pm
diff -u loncom/interface/lonuserutils.pm:1.52 loncom/interface/lonuserutils.pm:1.53
--- loncom/interface/lonuserutils.pm:1.52	Wed Apr 30 19:16:19 2008
+++ loncom/interface/lonuserutils.pm	Fri May  9 13:55:25 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Utility functions for managing LON-CAPA user accounts
 #
-# $Id: lonuserutils.pm,v 1.52 2008/04/30 23:16:19 raeburn Exp $
+# $Id: lonuserutils.pm,v 1.53 2008/05/09 17:55:25 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1252,34 +1252,11 @@
     if ($env{'form.showrole'} eq 'Any') {
        $roleselected = ' selected="selected" '; 
     }
-    my ($role_select,$cnum,$cdom);
-    if ($context eq 'domain') {
-        $role_select = &domain_roles_select();
-        $r->print('<label>'.&mt('Role Type: [_1]',$role_select).'</label>');
-    } else {
-        $role_select = '<select name="showrole">'."\n".
-                       '<option value="Any" '.$roleselected.'>'.
-                       &mt('Any role').'</option>';
-        my @poss_roles = &curr_role_permissions($context);
-        foreach my $role (@poss_roles) {
-            $roleselected = '';
-            if ($role eq $env{'form.showrole'}) {
-                $roleselected = ' selected="selected" ';
-            }
-            my $plrole;
-            if ($role eq 'cr') {
-                $plrole = &mt('Custom role');
-            } else {
-                $plrole=&Apache::lonnet::plaintext($role);
-            }
-            $role_select .= '<option value="'.$role.'"'.$roleselected.'>'.$plrole.'</option>';
-        }
-        $role_select .= '</select>';
-        $r->print('<label>'.&mt('Role: [_1]',$role_select).'</label>');
-        if ($context eq 'course') {
-            ($cnum,$cdom) = &get_course_identity();
-            $r->print(&section_group_filter($cnum,$cdom));
-        }
+    my ($cnum,$cdom);
+    $r->print(&role_filter($context));
+    if ($context eq 'course') {
+        ($cnum,$cdom) = &get_course_identity();
+        $r->print(&section_group_filter($cnum,$cdom));
     }
     if (!(($context eq 'domain') && ($env{'form.roletype'} eq 'course'))) {
         $r->print('&nbsp;'.&list_submit_button(&mt('Update Display')).
@@ -1451,6 +1428,41 @@
               $env{'form.phase'}.'" /></form>');
 }
 
+sub role_filter {
+    my ($context) = @_;
+    my $output;
+    my $roleselected = '';
+    if ($env{'form.showrole'} eq 'Any') {
+       $roleselected = ' selected="selected" ';
+    }
+    my ($role_select);
+    if ($context eq 'domain') {
+        $role_select = &domain_roles_select();
+        $output = '<label>'.&mt('Role Type: [_1]',$role_select).'</label>';
+    } else {
+        $role_select = '<select name="showrole">'."\n".
+                       '<option value="Any" '.$roleselected.'>'.
+                       &mt('Any role').'</option>';
+        my @poss_roles = &curr_role_permissions($context);
+        foreach my $role (@poss_roles) {
+            $roleselected = '';
+            if ($role eq $env{'form.showrole'}) {
+                $roleselected = ' selected="selected" ';
+            }
+            my $plrole;
+            if ($role eq 'cr') {
+                $plrole = &mt('Custom role');
+            } else {
+                $plrole=&Apache::lonnet::plaintext($role);
+            }
+            $role_select .= '<option value="'.$role.'"'.$roleselected.'>'.$plrole.'</option>';
+        }
+        $role_select .= '</select>';
+        $output = '<label>'.&mt('Role: [_1]',$role_select).'</label>';
+    }
+    return $output;
+}
+
 sub section_group_filter {
     my ($cnum,$cdom) = @_;
     my @filters;