[Jaws-commits] r12418 - branches/0.8/html/gadgets/Chatbox

afz at jaws-project.com afz at jaws-project.com
Mon Jan 16 09:33:16 UTC 2012


Author: afz
Date: 2012-01-16 09:33:15 +0000 (Mon, 16 Jan 2012)
New Revision: 12418

Modified:
   branches/0.8/html/gadgets/Chatbox/HTML.php
   branches/0.8/html/gadgets/Chatbox/LayoutHTML.php
Log:
[Chatbox]: compatible using captcha with new changes in Policy gadget

Modified: branches/0.8/html/gadgets/Chatbox/HTML.php
===================================================================
--- branches/0.8/html/gadgets/Chatbox/HTML.php	2012-01-16 09:12:27 UTC (rev 12417)
+++ branches/0.8/html/gadgets/Chatbox/HTML.php	2012-01-16 09:33:15 UTC (rev 12418)
@@ -43,7 +43,7 @@
     {
         require_once JAWS_PATH . 'include/Jaws/Header.php';
         $request =& Jaws_Request::getInstance();
-        $post    = $request->get(array('message', 'name', 'captcha', 'captchaKey', 'email', 'url'), 'post');
+        $post  = $request->get(array('message', 'name', 'email', 'url'), 'post');
         $model = $GLOBALS['app']->LoadGadget('Chatbox', 'Model');
 
         if ($GLOBALS['app']->Session->Logged()) {
@@ -57,17 +57,11 @@
             Jaws_Header::Referrer();
         }
 
-        if (!$GLOBALS['app']->Session->Logged()) {
-            $GLOBALS['app']->Registry->LoadFile('Policy');
-            $_captcha = $GLOBALS['app']->Registry->Get('/gadgets/Policy/captcha');
-            if ($_captcha != 'DISABLED') {
-                require_once JAWS_PATH . 'gadgets/Policy/captchas/' . $_captcha . '.php';
-                $captcha = new $_captcha();
-                if (!$captcha->Check()) {
-                    $GLOBALS['app']->Session->PushSimpleResponse(_t('GLOBAL_CAPTCHA_ERROR_DOES_NOT_MATCH'), 'Chatbox');
-                    Jaws_Header::Referrer();
-                }
-            }
+        $mPolicy = $GLOBALS['app']->LoadGadget('Policy', 'Model');
+        $resCheck = $mPolicy->CheckCaptcha();
+        if (Jaws_Error::IsError($resCheck)) {
+            $GLOBALS['app']->Session->PushSimpleResponse($resCheck->getMessage(), 'Chatbox');
+            Jaws_Header::Referrer();
         }
 
         $res = $model->NewEntry($post['name'], $post['message'],

Modified: branches/0.8/html/gadgets/Chatbox/LayoutHTML.php
===================================================================
--- branches/0.8/html/gadgets/Chatbox/LayoutHTML.php	2012-01-16 09:12:27 UTC (rev 12417)
+++ branches/0.8/html/gadgets/Chatbox/LayoutHTML.php	2012-01-16 09:33:15 UTC (rev 12418)
@@ -50,22 +50,18 @@
                 $tpl->SetVariable('email', _t('GLOBAL_EMAIL'));
                 $tpl->SetVariable('emailvalue', isset($email) ? $xss->filter($email) : '');
                 $tpl->ParseBlock('chatbox/fieldset/info-box');
+            }
 
-                $GLOBALS['app']->Registry->LoadFile('Policy');
-                $_captcha = $GLOBALS['app']->Registry->Get('/gadgets/Policy/captcha');
-                if ($_captcha != 'DISABLED') {
-                    require_once JAWS_PATH . 'gadgets/Policy/captchas/' . $_captcha . '.php';
-                    $captcha = new $_captcha();
-                    $captchaRes = $captcha->Get();
-                    $tpl->SetBlock('chatbox/fieldset/captcha');
-                    $tpl->SetVariable('lbl_captcha', _t('GLOBAL_CAPTCHA_CODE'));
-                    $tpl->SetVariable('captcha', $captchaRes['captcha']->Get());
-                    if (!empty($captchaRes['entry'])) {
-                        $tpl->SetVariable('captchavalue', $captchaRes['entry']->Get());
-                    }
-                    $tpl->SetVariable('captcha_msg', _t('GLOBAL_CAPTCHA_CODE_DESC'));
-                    $tpl->ParseBlock('chatbox/fieldset/captcha');
+            $mPolicy = $GLOBALS['app']->LoadGadget('Policy', 'Model');
+            if ($mPolicy->LoadCaptcha($captcha, $entry, $description)) {
+                $tpl->SetBlock('chatbox/fieldset/captcha');
+                $tpl->SetVariable('lbl_captcha', _t('GLOBAL_CAPTCHA_CODE'));
+                $tpl->SetVariable('captcha', $captcha);
+                if (!empty($entry)) {
+                    $tpl->SetVariable('captchavalue', $entry);
                 }
+                $tpl->SetVariable('captcha_msg', $description);
+                $tpl->ParseBlock('chatbox/fieldset/captcha');
             }
 
             $tpl->ParseBlock('chatbox/fieldset');



More information about the Jaws-commits mailing list