* #12968: added captcha to infomail form.
authorivankartolo <ivankartolo@735d13b6-9817-0410-8766-e36946ffe9aa>
Tue, 1 Mar 2011 00:09:48 +0000 (00:09 +0000)
committerivankartolo <ivankartolo@735d13b6-9817-0410-8766-e36946ffe9aa>
Tue, 1 Mar 2011 00:09:48 +0000 (00:09 +0000)
* added README file

git-svn-id: https://svn.typo3.org/TYPO3v4/Extensions/direct_mail_subscription/trunk@44426 735d13b6-9817-0410-8766-e36946ffe9aa

ChangeLog
README.txt [new file with mode: 0644]
fe_adminLib.inc

index 54f68cb..033bc41 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2011-03-01 Ivan Kartolo <ivan.kartolo@dkd.de>
+       * #12968: added captcha to infomail form.
+       * Added README file
+       
 2011-02-22 Ivan Kartolo <ivan.kartolo@dkd.de>
        * locallang file in xml-format
        * optimizing localized gender: localized gender can be overwrite per TS
diff --git a/README.txt b/README.txt
new file mode 100644 (file)
index 0000000..0ebf276
--- /dev/null
@@ -0,0 +1,5 @@
+Upon upgrading, please notes these changes:
+       - fe_adminLib.inc is now local. please check the path to this script in your TypoScript.
+       - new subpart in template ###TEMPLATE_INFOMAIL_NORECORD###
+       - added support for captcha. Please check the standard TypoScript in ext_typoscript_setup.txt
+       -
\ No newline at end of file
index 15b2183..7b09465 100644 (file)
@@ -730,26 +730,7 @@ class user_feAdmin {
                                $this->markerArray['###EVAL_ERROR_FIELD_'.$theField.'###'] = is_array($this->failureMsg[$theField]) ? implode('<br />',$this->failureMsg[$theField]) : '';
                        }
                        
-                       /* CAPTCHA */
-                       if (t3lib_extMgm::isLoaded('captcha')){
-                               session_start();
-                               $captchaStr = $_SESSION['tx_captcha_string'];
-                               $_SESSION['tx_captcha_string'] = '';
-                               
-                               if ($captchaStr && $this->dataArr['captcha'] !== $captchaStr) { 
-                                       $theField = 'captcha';
-                                       $tempArr[] = $theField;
-                                       $this->failureMsg[$theField][] = $this->getFailure($theField, 'captcha', 'Wrong captcha!');
-//                                     $this->markerArray['###EVAL_ERROR_FIELD_'.$theField.'###'] = is_array($this->failureMsg[$theField]) ? implode('<br />',$this->failureMsg[$theField]) : '';
-                                       
-//                                     $templateCodeCaptcha = $this->cObj->getSubpart($this->templateCode, '###TEMPLATE_CAPTCHA###');
-//                                     $this->markerArray['###CAPTCHA_IMG###'] = '<img src="'.t3lib_extMgm::siteRelPath('captcha').'captcha/captcha.php" alt="" />';
-//                                     $this->markerArray['###CAPTCHA###'] = $this->cObj->substituteMarkerArray($templateCodeCaptcha, $this->markerArray);
-                                       $errorMsg = is_array($this->failureMsg[$theField]) ? implode('<br />',$this->failureMsg[$theField]) : '';
-                                       $this->markerArray['###CAPTCHA###'] = $this->getCaptcha($errorMsg);
-                                       
-                               }
-                       } 
+                       $this->checkCaptcha();
                        
                        
                }
@@ -757,6 +738,33 @@ class user_feAdmin {
        }
 
        /**
+        * check captcha
+        * 
+        * @return      bool    @captcha:TRUE if captcha not loaded or captcha is correct, FALSE on wrong captcha
+        */
+       function checkCaptcha() {
+               /* CAPTCHA */
+               $captcha = TRUE;
+               
+               if (t3lib_extMgm::isLoaded('captcha') && isset($this->dataArr['captcha'])){
+                       session_start();
+                       $captchaStr = $_SESSION['tx_captcha_string'];
+                       $_SESSION['tx_captcha_string'] = '';
+
+                       if ($captchaStr && $this->dataArr['captcha'] !== $captchaStr) {
+                               $captcha = FALSE;
+                               $theField = 'captcha';
+                               $tempArr[] = $theField;
+                               $this->failureMsg[$theField][] = $this->getFailure($theField, 'captcha', 'Wrong captcha!');
+                               $errorMsg = is_array($this->failureMsg[$theField]) ? implode('<br />',$this->failureMsg[$theField]) : '';
+                               $this->markerArray['###CAPTCHA###'] = $this->getCaptcha($errorMsg);
+                       }
+               }
+               return $captcha;
+       }
+       
+       
+       /**
         * Preforms user processing of input array - triggered right after the function call to evalValues() IF TypoScript property "evalFunc" was set.
         *
         * @param       string          Key pointing to the property in TypoScript holding the configuration for this processing (here: "evalFunc.*"). Well: at least its safe to say that "parentObj" in this array passed to the function is a reference back to this object.
@@ -1223,6 +1231,11 @@ class user_feAdmin       {
                $templateCode = $this->cObj->getSubpart($this->templateCode, $key);
                $this->setCObjects($templateCode,is_array($r)?$r:array());
                
+               /* CAPTCHA */
+               if (!$this->markerArray['###CAPTCHA###']) {
+                       $this->markerArray['###CAPTCHA###'] = $this->getCaptcha();
+               }
+               
                $markerArray = is_array($r) ? $this->cObj->fillInMarkerArray($this->markerArray, $r, '', TRUE, 'FIELD_', $this->recInMarkersHSC) : $this->markerArray;
                
                
@@ -1392,7 +1405,14 @@ class user_feAdmin       {
        function sendInfoMail() {
                if ($this->conf['infomail'] && $this->conf['email.']['field'])  {
                        $fetch = t3lib_div::_GP('fetch');
-                       if ($fetch)     {
+                       
+                       //check the failureMsg array, since evalValues is called
+                       $captcha = TRUE;
+                       if (is_array($this->failureMsg['captcha'])) {
+                               $captcha = FALSE;
+                       }
+                        
+                       if ($fetch && $captcha) {
                                        // Getting infomail config.
                                $key= trim(t3lib_div::_GP('key'));
                                if (is_array($this->conf['infomail.'][$key.'.']))               {