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

raeburn raeburn at source.lon-capa.org
Fri Aug 12 15:49:57 EDT 2016


raeburn		Fri Aug 12 19:49:57 2016 EDT

  Modified files:              (Branch: version_2_11_X)
    /loncom/interface	domainprefs.pm 
  Log:
  - For 2.11
    - Backport 1.269, 1.270
  
  
-------------- next part --------------
Index: loncom/interface/domainprefs.pm
diff -u loncom/interface/domainprefs.pm:1.160.6.68 loncom/interface/domainprefs.pm:1.160.6.69
--- loncom/interface/domainprefs.pm:1.160.6.68	Sun Aug  7 00:28:39 2016
+++ loncom/interface/domainprefs.pm	Fri Aug 12 19:49:56 2016
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set domain-wide configuration settings
 #
-# $Id: domainprefs.pm,v 1.160.6.68 2016/08/07 00:28:39 raeburn Exp $
+# $Id: domainprefs.pm,v 1.160.6.69 2016/08/12 19:49:56 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -4542,7 +4542,8 @@
 
 sub captcha_choice {
     my ($context,$settings,$itemcount) = @_;
-    my ($keyentry,$currpub,$currpriv,%checked,$rowname,$pubtext,$privtext);
+    my ($keyentry,$currpub,$currpriv,%checked,$rowname,$pubtext,$privtext,
+        $vertext,$currver); 
     my %lt = &captcha_phrases();
     $keyentry = 'hidden';
     if ($context eq 'cancreate') {
@@ -4560,6 +4561,11 @@
             $pubtext = $lt{'pub'};
             $privtext = $lt{'priv'};
             $keyentry = 'text';
+            $vertext = $lt{'ver'};
+            $currver = $settings->{'recaptchaversion'};
+            if ($currver ne '2') {
+                $currver = 1;
+            }
         }
         if (ref($settings->{'recaptchakeys'}) eq 'HASH') {
             $currpub = $settings->{'recaptchakeys'}{'public'};
@@ -4593,7 +4599,11 @@
                $currpub.'" size="40" /></span><br />'."\n".
                '<span class="LC_nobreak"><span id="'.$context.'_recaptchaprivtxt">'.$privtext.'</span> '."\n".
                '<input type="'.$keyentry.'" id="'.$context.'_recaptchapriv" name="'.$context.'_recaptchapriv" value="'.
-               $currpriv.'" size="40" /></span></td></tr></table>'."\n".
+               $currpriv.'" size="40" /></span><br />'.
+               '<span class="LC_nobreak"><span id="'.$context.'_recaptchavertxt">'.$vertext.'</span> '."\n".
+               '<input type="'.$keyentry.'" id="'.$context.'_recaptchaversion" name="'.$context.'_recaptchaversion" value="'.
+               $currver.'" size="3" /></span><br />'.
+               '</td></tr></table>'."\n".
                '</td></tr>';
     return $output;
 }
@@ -6380,6 +6390,13 @@
                         $chgtxt .= '</ul>';
                         $resulttext .= '<li>'.$chgtxt.'</li>';
                     }
+                } elsif ($item eq 'recaptchaversion') {
+                    if (ref($loginhash{'login'}) eq 'HASH') {
+                        if ($loginhash{'login'}{'captcha'} eq 'recaptcha') {
+                            $resulttext .= '<li>'.&mt('ReCAPTCHA for helpdesk form set to version [_1]',$loginhash{'login'}{'recaptchaversion'}).
+                                           '</li>';
+                        }
+                    }
                 } else {
                     $resulttext .= '<li>'.&mt("$title{$item} set to $offon[$env{'form.'.$item}]").'</li>';
                 }
@@ -8601,7 +8618,8 @@
                 if (ref($domconfig{'usercreation'}{$key}) eq 'HASH') {
                     foreach my $item (keys(%{$domconfig{'usercreation'}{$key}})) {
                         if (($item eq 'selfcreate') || ($item eq 'statustocreate') ||
-                            ($item eq 'captcha') || ($item eq 'recaptchakeys')) {
+                            ($item eq 'captcha') || ($item eq 'recaptchakeys') ||
+                            ($item eq 'recaptchaversion')) {
                             $save_usercreate{$key}{$item} = $domconfig{'usercreation'}{$key}{$item};
                         } else {
                             $curr_usercreation{$key}{$item} = $domconfig{'usercreation'}{$key}{$item};
@@ -8825,6 +8843,7 @@
                     foreach my $item (keys(%{$domconfig{'usercreation'}{$key}})) {
                         if (($item eq 'selfcreate') || ($item eq 'statustocreate') ||
                             ($item eq 'captcha') || ($item eq 'recaptchakeys') || 
+                            ($item eq 'recaptchaversion') ||
                             ($item eq 'emailusername') || ($item eq 'notify') ||
                             ($item eq 'selfcreateprocessing') || ($item eq 'shibenv')) {
                             $curr_usercreation{$key}{$item} = $domconfig{'usercreation'}{$key}{$item};
@@ -9154,6 +9173,7 @@
 #
     $save_usercreate{'cancreate'}{'captcha'} = $savecaptcha{'captcha'};
     $save_usercreate{'cancreate'}{'recaptchakeys'} = $savecaptcha{'recaptchakeys'};
+    $save_usercreate{'cancreate'}{'recaptchaversion'} = $savecaptcha{'recaptchaversion'};
     $save_usercreate{'cancreate'}{'selfcreate'} = $cancreate{'selfcreate'};
     if (ref($cancreate{'notify'}) eq 'HASH') {
         $save_usercreate{'cancreate'}{'notify'} = $cancreate{'notify'};
@@ -9315,6 +9335,10 @@
                             $chgtext .= '<li>'.&mt('Private key set to [_1]',$pubkey).'</li>';
                         }
                         $chgtext .= '</ul>';
+                    } elsif ($type eq 'recaptchaversion') {
+                        if ($savecaptcha{'captcha'} eq 'recaptcha') {
+                            $chgtext .= &mt('ReCAPTCHA set to version [_1]',$savecaptcha{$type});
+                        }
                     } elsif ($type eq 'emailusername') {
                         if (ref($cancreate{'emailusername'}) eq 'HASH') {
                             if (ref($types) eq 'ARRAY') {
@@ -9435,7 +9459,7 @@
             $changes->{'captcha'} = 1;
         }
     }
-    my ($newpub,$newpriv,$currpub,$currpriv);
+    my ($newpub,$newpriv,$currpub,$currpriv,$newversion,$currversion);
     if ($newsettings->{'captcha'} eq 'recaptcha') {
         $newpub = $env{'form.'.$container.'_recaptchapub'};
         $newpriv = $env{'form.'.$container.'_recaptchapriv'};
@@ -9445,6 +9469,12 @@
                                              public  => $newpub,
                                              private => $newpriv,
                                           };
+        $newversion = $env{'form.'.$container.'_recaptchaversion'};
+        $newversion =~ s/\D//g;
+        if ($newversion ne '2') {
+            $newversion = 1;
+        }
+        $newsettings->{'recaptchaversion'} = $newversion;
     }
     if (ref($current->{'recaptchakeys'}) eq 'HASH') {
         $currpub = $current->{'recaptchakeys'}{'public'};
@@ -9456,6 +9486,23 @@
                                               }
         }
     }
+    if ($current->{'captcha'} eq 'recaptcha') {
+        $currversion = $current->{'recaptchaversion'};
+        if ($currversion ne '2') {
+            $currversion = 1;
+        }
+    }
+    if ($currversion ne $newversion) {
+        if ($container eq 'cancreate') {
+            if (ref($changes->{'cancreate'}) eq 'ARRAY') {
+                push(@{$changes->{'cancreate'}},'recaptchaversion');
+            } elsif (!defined($changes->{'cancreate'})) {
+                $changes->{'cancreate'} = ['recaptchaversion'];
+            }
+        } else {
+            $changes->{'recaptchaversion'} = 1;
+        }
+    }
     if (($newpub ne $currpub) || ($newpriv ne $currpriv)) {
         if ($container eq 'cancreate') {
             if (ref($changes->{'cancreate'}) eq 'ARRAY') {
@@ -12136,6 +12183,8 @@
     var pubitem;
     var privtext;
     var pubtext;
+    var versionitem;
+    var versiontext;
     if (document.getElementById(context+'_recaptchapub')) {
         pubitem = document.getElementById(context+'_recaptchapub');
     } else {
@@ -12156,6 +12205,16 @@
     } else {
         return;
     }
+    if (document.getElementById(context+'_recaptchaversion')) {
+        versionitem = document.getElementById(context+'_recaptchaversion');
+    } else {
+        return;
+    }
+    if (document.getElementById(context+'_recaptchavertxt')) {
+        versiontext = document.getElementById(context+'_recaptchavertxt');
+    } else {
+        return;
+    }
     if (caller.checked) {
         if (caller.value == 'recaptcha') {
             pubitem.type = 'text';
@@ -12164,11 +12223,16 @@
             privitem.size = '40';
             pubtext.innerHTML = "$lt{'pub'}";
             privtext.innerHTML = "$lt{'priv'}";
+            versionitem.type = 'text';
+            versionitem.size = '3';
+            versiontext.innerHTML = "$lt{'ver'}";
         } else {
             pubitem.type = 'hidden';
             privitem.type = 'hidden';
+            versionitem.type = 'hidden';
             pubtext.innerHTML = '';
             privtext.innerHTML = '';
+            versiontext.innerHTML = '';
         }
     }
     return;
@@ -12234,6 +12298,7 @@
                  original  => 'original (CAPTCHA)',
                  recaptcha => 'successor (ReCAPTCHA)',
                  notused   => 'unused',
+                 ver => 'ReCAPTCHA version (1 or 2)',
     );
 }
 


More information about the LON-CAPA-cvs mailing list