[LON-CAPA-cvs] cvs: loncom(version_2_11_X) /interface loncommon.pm

raeburn raeburn at source.lon-capa.org
Sun Nov 13 09:38:32 EST 2016


raeburn		Sun Nov 13 14:38:32 2016 EDT

  Modified files:              (Branch: version_2_11_X)
    /loncom/interface	loncommon.pm 
  Log:
  - For 2.11 
    - Backport 1.1259, 1.1260
  
  
-------------- next part --------------
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.1075.2.116 loncom/interface/loncommon.pm:1.1075.2.117
--- loncom/interface/loncommon.pm:1.1075.2.116	Sun Oct 30 18:04:58 2016
+++ loncom/interface/loncommon.pm	Sun Nov 13 14:38:30 2016
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.1075.2.116 2016/10/30 18:04:58 raeburn Exp $
+# $Id: loncommon.pm,v 1.1075.2.117 2016/11/13 14:38:30 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2845,13 +2845,16 @@
               @_,
               );
     my ($check4,$check5,$krbcheck,$krbarg,$krbver,$result,$authtype,
-        $autharg,$jscall);
+        $autharg,$jscall,$disabled);
     my ($authnum,%can_assign) = &get_assignable_auth($in{'domain'});
     if ($in{'kerb_def_auth'} eq 'krb5') {
        $check5 = ' checked="checked"';
     } else {
        $check4 = ' checked="checked"';
     }
+    if ($in{'readonly'}) {
+        $disabled = ' disabled="disabled"';
+    }
     $krbarg = $in{'kerb_def_dom'};
     if (defined($in{'curr_authtype'})) {
         if ($in{'curr_authtype'} eq 'krb') {
@@ -2896,7 +2899,7 @@
         if (defined($in{'mode'})) {
             if ($in{'mode'} eq 'modifycourse') {
                 if ($authnum == 1) {
-                    $authtype = '<input type="radio" name="login" value="krb" />';
+                    $authtype = '<input type="radio" name="login" value="krb"'.$disabled.' />';
                 }
             }
         }
@@ -2905,7 +2908,7 @@
     if ($authtype eq '') {
         $authtype = '<input type="radio" name="login" value="krb" '.
                     'onclick="'.$jscall.'" onchange="'.$jscall.'"'.
-                    $krbcheck.' />';
+                    $krbcheck.$disabled.' />';
     }
     if (($can_assign{'krb4'} && $can_assign{'krb5'}) ||
         ($can_assign{'krb4'} && !$can_assign{'krb5'} &&
@@ -2918,9 +2921,9 @@
          '<label>'.$authtype,
          '</label><input type="text" size="10" name="krbarg" '.
              'value="'.$krbarg.'" '.
-             'onchange="'.$jscall.'" />',
-         '<label><input type="radio" name="krbver" value="4" '.$check4.' />',
-         '</label><label><input type="radio" name="krbver" value="5" '.$check5.' />',
+             'onchange="'.$jscall.'"'.$disabled.' />',
+         '<label><input type="radio" name="krbver" value="4" '.$check4.$disabled.' />',
+         '</label><label><input type="radio" name="krbver" value="5" '.$check5.$disabled.' />',
 	 '</label>');
     } elsif ($can_assign{'krb4'}) {
         $result .= &mt
@@ -2929,7 +2932,7 @@
          '<label>'.$authtype,
          '</label><input type="text" size="10" name="krbarg" '.
              'value="'.$krbarg.'" '.
-             'onchange="'.$jscall.'" />',
+             'onchange="'.$jscall.'"'.$disabled.' />',
          '<label><input type="hidden" name="krbver" value="4" />',
          '</label>');
     } elsif ($can_assign{'krb5'}) {
@@ -2939,7 +2942,7 @@
          '<label>'.$authtype,
          '</label><input type="text" size="10" name="krbarg" '.
              'value="'.$krbarg.'" '.
-             'onchange="'.$jscall.'" />',
+             'onchange="'.$jscall.'"'.$disabled.' />',
          '<label><input type="hidden" name="krbver" value="5" />',
          '</label>');
     }
@@ -2952,8 +2955,11 @@
                 kerb_def_dom => 'MSU.EDU',
                 @_,
                 );
-    my ($intcheck,$intarg,$result,$authtype,$autharg,$jscall);
+    my ($intcheck,$intarg,$result,$authtype,$autharg,$jscall,$disabled);
     my ($authnum,%can_assign) = &get_assignable_auth($in{'domain'});
+    if ($in{'readonly'}) {
+        $disabled = ' disabled="disabled"';
+    }
     if (defined($in{'curr_authtype'})) {
         if ($in{'curr_authtype'} eq 'int') {
             if ($can_assign{'int'}) {
@@ -2982,7 +2988,7 @@
         if (defined($in{'mode'})) {
             if ($in{'mode'} eq 'modifycourse') {
                 if ($authnum == 1) {
-                    $authtype = '<input type="radio" name="login" value="int" />';
+                    $authtype = '<input type="radio" name="login" value="int"'.$disabled.' />';
                 }
             }
         }
@@ -2990,14 +2996,14 @@
     $jscall = "javascript:changed_radio('int',$in{'formname'});";
     if ($authtype eq '') {
         $authtype = '<input type="radio" name="login" value="int" '.$intcheck.
-                    ' onchange="'.$jscall.'" onclick="'.$jscall.'" />';
+                    ' onchange="'.$jscall.'" onclick="'.$jscall.'"'.$disabled.' />';
     }
     $autharg = '<input type="password" size="10" name="intarg" value="'.
-               $intarg.'" onchange="'.$jscall.'" />';
+               $intarg.'" onchange="'.$jscall.'"'.$disabled.' />';
     $result = &mt
         ('[_1] Internally authenticated (with initial password [_2])',
          '<label>'.$authtype,'</label>'.$autharg);
-    $result.="<label><input type=\"checkbox\" name=\"visible\" onclick='if (this.checked) { this.form.intarg.type=\"text\" } else { this.form.intarg.type=\"password\" }' />".&mt('Visible input').'</label>';
+    $result.='<label><input type="checkbox" name="visible" onclick="if (this.checked) { this.form.intarg.type='."'text'".' } else { this.form.intarg.type='."'password'".' }"'.$disabled.' />".&mt('Visible input').'</label>';
     return $result;
 }
 
@@ -3007,8 +3013,11 @@
               kerb_def_dom => 'MSU.EDU',
               @_,
               );
-    my ($loccheck,$locarg,$result,$authtype,$autharg,$jscall);
+    my ($loccheck,$locarg,$result,$authtype,$autharg,$jscall,$disabled);
     my ($authnum,%can_assign) = &get_assignable_auth($in{'domain'});
+    if ($in{'readonly'}) {
+        $disabled = ' disabled="disabled"';
+    }
     if (defined($in{'curr_authtype'})) {
         if ($in{'curr_authtype'} eq 'loc') {
             if ($can_assign{'loc'}) {
@@ -3037,7 +3046,7 @@
         if (defined($in{'mode'})) {
             if ($in{'mode'} eq 'modifycourse') {
                 if ($authnum == 1) {
-                    $authtype = '<input type="radio" name="login" value="loc" />';
+                    $authtype = '<input type="radio" name="login" value="loc"'.$disabled.' />';
                 }
             }
         }
@@ -3046,10 +3055,10 @@
     if ($authtype eq '') {
         $authtype = '<input type="radio" name="login" value="loc" '.
                     $loccheck.' onchange="'.$jscall.'" onclick="'.
-                    $jscall.'" />';
+                    $jscall.'"'.$disabled.' />';
     }
     $autharg = '<input type="text" size="10" name="locarg" value="'.
-               $locarg.'" onchange="'.$jscall.'" />';
+               $locarg.'" onchange="'.$jscall.'"'.$disabled.' />';
     $result = &mt('[_1] Local Authentication with argument [_2]',
                   '<label>'.$authtype,'</label>'.$autharg);
     return $result;
@@ -3061,8 +3070,11 @@
               kerb_def_dom => 'MSU.EDU',
               @_,
               );
-    my ($fsyscheck,$result,$authtype,$autharg,$jscall);
+    my ($fsyscheck,$result,$authtype,$autharg,$jscall,$disabled);
     my ($authnum,%can_assign) = &get_assignable_auth($in{'domain'});
+    if ($in{'readonly'}) {
+        $disabled = ' disabled="disabled"';
+    }
     if (defined($in{'curr_authtype'})) {
         if ($in{'curr_authtype'} eq 'fsys') {
             if ($can_assign{'fsys'}) {
@@ -3088,7 +3100,7 @@
         if (defined($in{'mode'})) {
             if ($in{'mode'} eq 'modifycourse') {
                 if ($authnum == 1) {
-                    $authtype = '<input type="radio" name="login" value="fsys" />';
+                    $authtype = '<input type="radio" name="login" value="fsys"'.$disabled.' />';
                 }
             }
         }
@@ -3097,16 +3109,16 @@
     if ($authtype eq '') {
         $authtype = '<input type="radio" name="login" value="fsys" '.
                     $fsyscheck.' onchange="'.$jscall.'" onclick="'.
-                    $jscall.'" />';
+                    $jscall.'"'.$disabled.' />';
     }
     $autharg = '<input type="text" size="10" name="fsysarg" value=""'.
-               ' onchange="'.$jscall.'" />';
+               ' onchange="'.$jscall.'"'.$disabled.' />';
     $result = &mt
         ('[_1] Filesystem Authenticated (with initial password [_2])',
          '<label><input type="radio" name="login" value="fsys" '.
-         $fsyscheck.'onchange="'.$jscall.'" onclick="'.$jscall.'" />',
+         $fsyscheck.'onchange="'.$jscall.'" onclick="'.$jscall.'"'.$disabled.' />',
          '</label><input type="password" size="10" name="fsysarg" value="" '.
-                  'onchange="'.$jscall.'" />');
+                  'onchange="'.$jscall.'"'.$disabled.' />');
     return $result;
 }
 
@@ -3128,7 +3140,7 @@
             my $context;
             if ($env{'request.role'} =~ /^au/) {
                 $context = 'author';
-            } elsif ($env{'request.role'} =~ /^dc/) {
+            } elsif ($env{'request.role'} =~ /^(dc|dh)/) {
                 $context = 'domain';
             } elsif ($env{'request.course.id'}) {
                 $context = 'course';
@@ -14204,12 +14216,15 @@
 
 type    - scalar contains course type (Course or Community).
 
+disabled - scalar (optional) contains disabled="disabled" if input elements are
+           to be readonly (e.g., Domain Helpdesk role viewing course settings).
+
 Returns: $output (markup to be displayed) 
 
 =cut
 
 sub assign_categories_table {
-    my ($cathash,$currcat,$type) = @_;
+    my ($cathash,$currcat,$type,$disabled) = @_;
     my $output;
     if (ref($cathash) eq 'HASH') {
         my (@cats, at trails,%allitems,%idx, at jsarray, at path,$maxdepth);
@@ -14245,11 +14260,11 @@
                     }
                     $table .= '<tr '.$css_class.'><td><span class="LC_nobreak">'.
                               '<input type="checkbox" name="usecategory" value="'.
-                              $item.'"'.$checked.' />'.$parent_title.'</span>'.
+                              $item.'"'.$checked.$disabled.' />'.$parent_title.'</span>'.
                               '<input type="hidden" name="catname" value="'.$parent.'" /></td>';
                     my $depth = 1;
                     push(@path,$parent);
-                    $table .= &assign_category_rows($itemcount,\@cats,$depth,$parent,\@path,\@currcategories);
+                    $table .= &assign_category_rows($itemcount,\@cats,$depth,$parent,\@path,\@currcategories,$disabled);
                     pop(@path);
                     $table .= '</tr><tr><td colspan="'.$maxdepth.'" class="LC_row_separator"></td></tr>';
                     $itemcount ++;
@@ -14288,12 +14303,15 @@
 
 currcategories - reference to array of current categories assigned to the course
 
+disabled - scalar (optional) contains disabled="disabled" if input elements are
+           to be readonly (e.g., Domain Helpdesk role viewing course settings).
+
 Returns: $output (markup to be displayed).
 
 =cut
 
 sub assign_category_rows {
-    my ($itemcount,$cats,$depth,$parent,$path,$currcategories) = @_;
+    my ($itemcount,$cats,$depth,$parent,$path,$currcategories,$disabled) = @_;
     my ($text,$name,$item,$chgstr);
     if (ref($cats) eq 'ARRAY') {
         my $maxdepth = scalar(@{$cats});
@@ -14316,12 +14334,12 @@
                     }
                     $text .= '<tr><td><span class="LC_nobreak"><label>'.
                              '<input type="checkbox" name="usecategory" value="'.
-                             $item.'"'.$checked.' />'.$name.'</label></span>'.
+                             $item.'"'.$checked.$disabled.' />'.$name.'</label></span>'.
                              '<input type="hidden" name="catname" value="'.$name.'" />'.
                              '</td><td>';
                     if (ref($path) eq 'ARRAY') {
                         push(@{$path},$name);
-                        $text .= &assign_category_rows($itemcount,$cats,$deeper,$name,$path,$currcategories);
+                        $text .= &assign_category_rows($itemcount,$cats,$deeper,$name,$path,$currcategories,$disabled);
                         pop(@{$path});
                     }
                     $text .= '</td></tr>';


More information about the LON-CAPA-cvs mailing list