1
0
Эх сурвалжийг харах

#4558 - Build-in API support (contact form & cmts bug fix)

romanlesnikov 1 жил өмнө
parent
commit
06ae5cff35

+ 13 - 5
modules/boonex/contact/classes/BxContactModule.php

@@ -124,11 +124,19 @@ class BxContactModule extends BxDolModule
             }
         }
 
-        if (bx_is_api())
-            return [
-                bx_api_get_block('form', $oForm->getCodeAPI(), ['ext' => ['request' => ['url' => '/api.php?r=bx_contact/get_block_form', 'immutable' => true]]]),
-                bx_api_get_msg($sResult, ['id' => 2])
-            ];
+        if (bx_is_api()){
+            if ($oForm->isSubmittedAndValid()){
+                return [
+                    bx_api_get_msg($sResult, ['ext' => ['msg_type' => 'result']])
+                ];
+            }
+            else{
+                return [
+                    bx_api_get_block('form', $oForm->getCodeAPI(), ['ext' => ['request' => ['url' => '/api.php?r=bx_contact/get_block_form', 'immutable' => true]]]),
+
+                ];
+            }
+        }
 
         return ['content' => ($sResult ?  MsgBox($sResult) : '') . $oForm->getCode()];
     }

+ 2 - 2
template/scripts/BxBaseCmtsServices.php

@@ -634,8 +634,8 @@ class BxBaseCmtsServices extends BxDol
                 $bIsList = true;
                 $aForm['inputs']['cmt_parent_id']['value'] = 0;
             }
-            
-            $aRv['form'] = ['id' => 'cmt_form', 'type' => 'form', 'name' => 'comment', 'data' => $aForm, 'request' => ['immutable' => true]];
+            if (bx_get_logged_profile_id())           
+                $aRv['form'] = ['id' => 'cmt_form', 'type' => 'form', 'name' => 'comment', 'data' => $aForm, 'request' => ['immutable' => true]];
 
             // default view (form + list)
             if (!$oForm['form']->isSubmitted()){