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

raeburn raeburn at source.lon-capa.org
Mon May 5 17:40:53 EDT 2014


raeburn		Mon May  5 21:40:53 2014 EDT

  Modified files:              (Branch: version_2_11_X)
    /loncom/interface	domainprefs.pm 
  Log:
  - For 2.11
    - Backport 1.240
  
  
Index: loncom/interface/domainprefs.pm
diff -u loncom/interface/domainprefs.pm:1.160.6.43 loncom/interface/domainprefs.pm:1.160.6.44
--- loncom/interface/domainprefs.pm:1.160.6.43	Sun May  4 22:19:29 2014
+++ loncom/interface/domainprefs.pm	Mon May  5 21:40:52 2014
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set domain-wide configuration settings
 #
-# $Id: domainprefs.pm,v 1.160.6.43 2014/05/04 22:19:29 raeburn Exp $
+# $Id: domainprefs.pm,v 1.160.6.44 2014/05/05 21:40:52 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -4063,6 +4063,43 @@
                 $$rowtotal ++;
             }
         }
+        my @fields = ('lastname','firstname','middlename','permanentemail','id','inststatus');
+        my %fieldtitles = &Apache::loncommon::personal_data_fieldtitles();
+        $fieldtitles{'inststatus'} = &mt('Institutional status');
+        my $rem;
+        my $numperrow = 2;
+        my $css_class = $$rowtotal%2?' class="LC_odd_row"':'';
+        $datatable .= '<tr'.$css_class.'>'.
+                     '<td class="LC_left_item">'.&mt('Shibboleth (SSO) Data').'</td>'.
+                     '<td class="LC_left_item">'."\n".
+                     '<table><tr><td>'."\n";
+        for (my $i=0; $i<@fields; $i++) {
+            $rem = $i%($numperrow);
+            if ($rem == 0) {
+                if ($i > 0) {
+                    $datatable .= '</tr>';
+                }
+                $datatable .= '<tr>';
+            }
+            my $currval;
+            if (ref($createsettings->{'shibenv'}) eq 'HASH') {
+                $currval = $createsettings->{'shibenv'}{$fields[$i]};
+            }
+            $datatable .= '<td class="LC_left_item">'.
+                          '<span class="LC_nobreak">'.
+                          '<input type="text" name="shibenv_'.$fields[$i].'" '.
+                          'value="'.$currval.'" size="10" /> '.
+                          $fieldtitles{$fields[$i]}.'</span></td>';
+        }
+        my $colsleft = $numperrow - $rem;
+        if ($colsleft > 1 ) {
+            $datatable .= '<td colspan="'.$colsleft.'" class="LC_left_item">'.
+                         ' </td>';
+        } elsif ($colsleft == 1) {
+            $datatable .= '<td class="LC_left_item"> </td>';
+        }
+        $datatable .= '</tr></table></td></tr>';
+        $$rowtotal ++;
     } elsif ($position eq 'middle') {
         my %domconf = &Apache::lonnet::get_dom('configuration',['usermodification'],$dom);
         my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
@@ -4073,7 +4110,7 @@
             foreach my $status (@{$types}) {
                 $datatable .= &modifiable_userdata_row('selfcreate',$status,$domconf{'usermodification'},
                                                        $numinrow,$$rowtotal,$usertypes);
-            $$rowtotal ++;
+                $$rowtotal ++;
             }
         }
     } else {
@@ -4119,8 +4156,8 @@
         $additional .= '</div>'."\n";
 
         ($datatable,$itemcount) = &radiobutton_prefs(\%radiohash,\@toggles,\%defaultchecked,
-                                                     \%choices,$itemcount,$onclick,$additional);
-        $$rowtotal += $itemcount;
+                                                     \%choices,$$rowtotal,$onclick,$additional);
+        $$rowtotal ++;
         $datatable .= &print_requestmail($dom,'selfcreation',$createsettings,$rowtotal);
         $$rowtotal ++;
         my ($infofields,$infotitles) = &Apache::loncommon::emailusername_info();
@@ -8318,7 +8355,7 @@
                         if (($item eq 'selfcreate') || ($item eq 'statustocreate') ||
                             ($item eq 'captcha') || ($item eq 'recaptchakeys') || 
                             ($item eq 'emailusername') || ($item eq 'notify') ||
-                            ($item eq 'selfcreateprocessing')) {
+                            ($item eq 'selfcreateprocessing') || ($item eq 'shibenv')) {
                             $curr_usercreation{$key}{$item} = $domconfig{'usercreation'}{$key}{$item};
                         } else {
                             $save_usercreate{$key}{$item} = $domconfig{'usercreation'}{$key}{$item};
@@ -8350,6 +8387,7 @@
     %{$cancreate{'emailusername'}} = ();
     @{$cancreate{'statustocreate'}} = ();
     %{$cancreate{'selfcreateprocessing'}} = ();
+    %{$cancreate{'shibenv'}} = ();
     my %selfcreatetypes = (
                              sso   => 'users authenticated by institutional single sign on',
                              login => 'users authenticated by institutional log-in',
@@ -8467,6 +8505,7 @@
     }
     my @fields = ('lastname','firstname','middlename','generation',
                   'permanentemail','id');
+    my @shibfields = (@fields,'inststatus');
     my %fieldtitles = &Apache::loncommon::personal_data_fieldtitles();
 #
 # Where usernames may created for institutional log-in and/or institutional single sign on:
@@ -8511,6 +8550,27 @@
                 }
             }
         }
+        foreach my $field (@shibfields) {
+            if ($env{'form.shibenv_'.$field} ne '') {
+                $cancreate{'shibenv'}{$field} = $env{'form.shibenv_'.$field};
+            }
+        }
+        if (ref($curr_usercreation{'cancreate'}) eq 'HASH') {
+            if (ref($curr_usercreation{'cancreate'}{'shibenv'}) eq 'HASH') {
+                foreach my $field (@shibfields) {
+                    if ($env{'form.shibenv_'.$field} ne $curr_usercreation{'cancreate'}{'shibenv'}{$field}) {
+                        push(@{$changes{'cancreate'}},'shibenv');
+                    }
+                }
+            } else {
+                foreach my $field (@shibfields) {
+                    if ($env{'form.shibenv_'.$field}) {
+                        push(@{$changes{'cancreate'}},'shibenv');
+                        last;
+                    }
+                }
+            }
+        }
     }
     foreach my $item (@contexts) {
         if (ref($curr_usercreation{'cancreate'}{$item}) eq 'ARRAY') {
@@ -8633,6 +8693,9 @@
     if (ref($cancreate{'statustocreate'}) eq 'ARRAY') {
         $save_usercreate{'cancreate'}{'statustocreate'} = $cancreate{'statustocreate'};
     }
+    if (ref($cancreate{'shibenv'}) eq 'HASH') {
+        $save_usercreate{'cancreate'}{'shibenv'} = $cancreate{'shibenv'};
+    }
     $save_usercreate{'cancreate'}{'emailusername'} = $cancreate{'emailusername'};
     $save_usercreate{'emailrule'} = \@email_rule;
 
@@ -8675,6 +8738,22 @@
                                 }
                             }
                         }
+                    } elsif ($type eq 'shibenv') {
+                        if (keys(%{$cancreate{$type}}) == 0) {
+                            $chgtext .= &mt('Shibboleth-autheticated user does not use environment variables to set user information'); 
+                        } else {
+                            $chgtext .= &mt('Shibboleth-autheticated user information set from environment variables, as follows:').
+                                        '<ul>';
+                            foreach my $field (@shibfields) {
+                                next if ($cancreate{$type}{$field} eq '');
+                                if ($field eq 'inststatus') {
+                                    $chgtext .= '<li>'.&mt('Institutional status').' -- '.$cancreate{$type}{$field}.'</li>';
+                                } else {
+                                    $chgtext .= '<li>'.$fieldtitles{$field}.' -- '.$cancreate{$type}{$field}.'</li>';
+                                }
+                            }
+                            $chgtext .= '</ul>';
+                        }  
                     } elsif ($type eq 'statustocreate') {
                         if ((ref($cancreate{'selfcreate'}) eq 'ARRAY') &&
                             (ref($cancreate{'statustocreate'}) eq 'ARRAY')) {




More information about the LON-CAPA-cvs mailing list