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

raeburn raeburn at source.lon-capa.org
Tue Nov 8 19:32:48 EST 2016


raeburn		Wed Nov  9 00:32:48 2016 EDT

  Modified files:              
    /loncom/interface	lonuserutils.pm 
  Log:
  - Viewing of class roster and enrollment type is available to roles with 'vcl'
    priv (via Automated Enrollment), but without ability to switch auto to 
    manual, and vice versa, or to lock against changes (via disabled attribute).
  
  
Index: loncom/interface/lonuserutils.pm
diff -u loncom/interface/lonuserutils.pm:1.177 loncom/interface/lonuserutils.pm:1.178
--- loncom/interface/lonuserutils.pm:1.177	Fri Oct 14 23:26:21 2016
+++ loncom/interface/lonuserutils.pm	Wed Nov  9 00:32:45 2016
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Utility functions for managing LON-CAPA user accounts
 #
-# $Id: lonuserutils.pm,v 1.177 2016/10/14 23:26:21 raeburn Exp $
+# $Id: lonuserutils.pm,v 1.178 2016/11/09 00:32:45 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2993,6 +2993,12 @@
             } (keys(%$userlist));
     }
     my $rowcount = 0;
+    my $disabled;
+    if ($mode eq 'autoenroll') {
+        unless ($permission->{'cusr'}) {
+            $disabled = ' disabled="disabled"';
+        }
+    }
     foreach my $user (@sorted_users) {
         my %in;
         my $sdata = $userlist->{$user};
@@ -3029,16 +3035,16 @@
             if ($mode eq 'autoenroll') {
                 my $cellentry;
                 if ($in{'type'} eq 'auto') {
-                    $cellentry = '<b>'.&mt('auto').'</b> <label><input type="checkbox" name="chgauto" value="'.$in{'username'}.':'.$in{'domain'}.'" /> '.&mt('Change').'</label>';
+                    $cellentry = '<b>'.&mt('auto').'</b> <label><input type="checkbox" name="chgauto" value="'.$in{'username'}.':'.$in{'domain'}.'"'.$disabled.' /> '.&mt('Change').'</label>';
                     $autocount ++;
                 } else {
-                    $cellentry = '<table border="0" cellspacing="0"><tr><td rowspan="2"><b>'.&mt('manual').'</b></td><td><span class="LC_nobreak"><label><input type="checkbox" name="chgmanual" value="'.$in{'username'}.':'.$in{'domain'}.'" /> '.&mt('Change').'</label></span></td></tr><tr><td><span class="LC_nobreak">';
+                    $cellentry = '<table border="0" cellspacing="0"><tr><td rowspan="2"><b>'.&mt('manual').'</b></td><td><span class="LC_nobreak"><label><input type="checkbox" name="chgmanual" value="'.$in{'username'}.':'.$in{'domain'}.'"'.$disabled.' /> '.&mt('Change').'</label></span></td></tr><tr><td><span class="LC_nobreak">';
                     $manualcount ++;
                     if ($in{'lockedtype'}) {
-                        $cellentry .= '<label><input type="checkbox" name="unlockchg" value="'.$in{'username'}.':'.$in{'domain'}.'" /> '.&mt('Unlock').'</label>';
+                        $cellentry .= '<label><input type="checkbox" name="unlockchg" value="'.$in{'username'}.':'.$in{'domain'}.'"'.$disabled.' /> '.&mt('Unlock').'</label>';
                         $unlockcount ++;
                     } else {
-                        $cellentry .= '<label><input type="checkbox" name="lockchg" value="'.$in{'username'}.':'.$in{'domain'}.'" /> '.&mt('Lock').'</label>';
+                        $cellentry .= '<label><input type="checkbox" name="lockchg" value="'.$in{'username'}.':'.$in{'domain'}.'"'.$disabled.' /> '.&mt('Lock').'</label>';
                         $lockcount ++;
                     }
                     $cellentry .= '</span></td></tr></table>';
@@ -5416,13 +5422,13 @@
 }
 
 sub course_sections {
-    my ($sections_count,$role,$current_sec) = @_;
+    my ($sections_count,$role,$current_sec,$disabled) = @_;
     my $output = '';
     my @sections = (sort {$a <=> $b} keys(%{$sections_count}));
     my $numsec = scalar(@sections);
     my $is_selected = ' selected="selected"';
     if ($numsec <= 1) {
-        $output = '<select name="currsec_'.$role.'" >'."\n".
+        $output = '<select name="currsec_'.$role.'"'.$disabled.'>'."\n".
                   '  <option value="">'.&mt('Select').'</option>'."\n";
         if ($current_sec eq 'none') {
             $output .=       
@@ -5445,7 +5451,7 @@
         my $multiple = 4;
         if (scalar(@sections) < 4) { $multiple = scalar(@sections); }
         if ($role eq 'st') {
-            $output .= '>'."\n".
+            $output .= $disabled.'>'."\n".
                        '  <option value="">'.&mt('Select').'</option>'."\n";
             if ($current_sec eq 'none') {
                 $output .= 
@@ -5455,7 +5461,7 @@
                        '  <option value="">'.&mt('No section')."</option>\n";
             }
         } else {
-            $output .= 'multiple="multiple" size="'.$multiple.'">'."\n";
+            $output .= 'multiple="multiple" size="'.$multiple.'"'.$disabled.'>'."\n";
         }
         foreach my $sec (@sections) {
             if ($current_sec eq $sec) {
@@ -5672,6 +5678,9 @@
     my $cancreate = 1;
     if (&Apache::lonnet::allowed('mau',$dom)) {
         return $cancreate;
+    } elsif ($context eq 'domain') {
+        $cancreate = 0;
+        return $cancreate;
     }
     if (ref($domconf{'usercreation'}) eq 'HASH') {
         if (ref($domconf{'usercreation'}{'cancreate'}) eq 'HASH') {
@@ -5894,7 +5903,9 @@
         if (&Apache::lonnet::allowed('vac',$env{'request.role.domain'})) {
             $permission{'activity'} = 1;
         }
-        $permission{'view'} = $permission{'cusr'};
+        if (&Apache::lonnet::allowed('vur',$env{'request.role.domain'})) {
+            $permission{'view'} = 1;
+        }
     }
     my $allowed = 0;
     foreach my $perm (values(%permission)) {




More information about the LON-CAPA-cvs mailing list