[Jaws-commits] r12416 - branches/0.8/html/gadgets/Blog

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


Author: afz
Date: 2012-01-16 09:07:36 +0000 (Mon, 16 Jan 2012)
New Revision: 12416

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

Modified: branches/0.8/html/gadgets/Blog/HTML.php
===================================================================
--- branches/0.8/html/gadgets/Blog/HTML.php	2012-01-16 09:05:17 UTC (rev 12415)
+++ branches/0.8/html/gadgets/Blog/HTML.php	2012-01-16 09:07:36 UTC (rev 12416)
@@ -959,22 +959,18 @@
             $tpl->SetVariable('url',  _t('GLOBAL_URL'));
             $tpl->SetVariable('url_value', $visitorUrl);
             $tpl->ParseBlock('commentform/unregistered');
+        }
 
-            $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('commentform/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('commentform/captcha');
+        $mPolicy = $GLOBALS['app']->LoadGadget('Policy', 'Model');
+        if ($mPolicy->LoadCaptcha($captcha, $entry, $description)) {
+            $tpl->SetBlock('commentform/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('commentform/captcha');
         }
 
         if (!is_null($post['title'])) {
@@ -1118,7 +1114,7 @@
         $request =& Jaws_Request::getInstance();
         $names = array(
             'name', 'email', 'url', 'title', 'comments', 'createtime',
-            'ip_address', 'parent_id', 'parent', 'captcha', 'captchaKey', 'url2'
+            'ip_address', 'parent_id', 'parent', 'url2'
         );
         $post = $request->get($names, 'post');
         $id  = (int)$post['parent_id'];
@@ -1168,18 +1164,12 @@
             Jaws_Header::Location($url);
         }
 
-        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'), 'Blog');
-                    $GLOBALS['app']->Session->PushSimpleResponse($post, 'Blog_Comment');
-                    Jaws_Header::Location($url);
-                }
-            }
+        $mPolicy = $GLOBALS['app']->LoadGadget('Policy', 'Model');
+        $resCheck = $mPolicy->CheckCaptcha();
+        if (Jaws_Error::IsError($resCheck)) {
+            $GLOBALS['app']->Session->PushSimpleResponse($resCheck->getMessage(), 'Blog');
+            $GLOBALS['app']->Session->PushSimpleResponse($post, 'Blog_Comment');
+            Jaws_Header::Location($url);
         }
 
         $result = $model->NewComment($post['name'], $post['title'], $post['url'],



More information about the Jaws-commits mailing list