فهرست منبع

Merge branch 'master' of https://github.com/unaio/una

AntonLV 3 سال پیش
والد
کامیت
9f69de2d5c

+ 12 - 6
modules/base/general/classes/BxBaseModGeneralFormEntry.php

@@ -425,8 +425,12 @@ class BxBaseModGeneralFormEntry extends BxTemplFormView
         if (CHECK_ACTION_RESULT_ALLOWED === $this->_oModule->checkAllowedSetThumb() && isset($CNF['FIELD_THUMB'])) {
             $aThumb = isset($_POST[$CNF['FIELD_THUMB']]) ? bx_process_input ($_POST[$CNF['FIELD_THUMB']], BX_DATA_INT) : false;
             $aValsToAdd[$CNF['FIELD_THUMB']] = 0;
-            if (!empty($aThumb) && is_array($aThumb) && ($iFileThumb = array_pop($aThumb)))
-                $aValsToAdd[$CNF['FIELD_THUMB']] = $iFileThumb;
+            if (!empty($aThumb)){
+                if(is_array($aThumb) && ($iFileThumb = array_pop($aThumb)))
+                   $aValsToAdd[$CNF['FIELD_THUMB']] = $iFileThumb;
+               else
+                   $aValsToAdd[$CNF['FIELD_THUMB']] = $aThumb;
+            }
         }
 
         if(!empty($CNF['OBJECT_METATAGS']))
@@ -540,10 +544,12 @@ class BxBaseModGeneralFormEntry extends BxTemplFormView
         if(CHECK_ACTION_RESULT_ALLOWED === $this->_oModule->checkAllowedSetThumb($iContentId) && isset($CNF['FIELD_THUMB'])) {
             $aThumb = bx_process_input (bx_get($CNF['FIELD_THUMB']), BX_DATA_INT);
             $aValsToAdd[$CNF['FIELD_THUMB']] = 0;
-            if (!is_array($aThumb))
-                $aThumb =[$aThumb];
-            if (!empty($aThumb) && is_array($aThumb) && ($iFileThumb = array_pop($aThumb)))
-                $aValsToAdd[$CNF['FIELD_THUMB']] = $iFileThumb;
+            if (!empty($aThumb)){
+                if(is_array($aThumb) && ($iFileThumb = array_pop($aThumb)))
+                   $aValsToAdd[$CNF['FIELD_THUMB']] = $iFileThumb;
+               else
+                   $aValsToAdd[$CNF['FIELD_THUMB']] = $aThumb;
+            }
         }
 
         if(!empty($CNF['OBJECT_METATAGS']))

+ 18 - 9
template/scripts/BxBaseCmts.php

@@ -1338,17 +1338,19 @@ class BxBaseCmts extends BxDolCmts
         return bx_is_api() ? ['form' => $oForm, 'res' => 0] : ['form' => $oForm->getCode($bDynamic), 'form_id' => $oForm->id];
     }
 
-    protected function _getFormEdit($iCmtId, $aDp = [])
+   protected function _getFormEdit($iCmtId, $aDp = [])
     {
         $bDynamic = isset($aDp['dynamic_mode']) && (bool)$aDp['dynamic_mode'];
 
         $aCmt = $this->getCommentSimple($iCmtId);
         if(!$aCmt)
-            return array('msg' => _t('_No such comment'));
+            return bx_is_api() ? bx_api_get_msg(_t('_No such comment')) : array('msg' => _t('_No such comment'));
 
         $iCmtAuthorId = $this->_getAuthorId();
-        if(!$this->isEditAllowed($aCmt))
-            return array('msg' => $aCmt['cmt_author_id'] == $iCmtAuthorId ? strip_tags($this->msgErrEditAllowed()) : _t('_Access denied'));
+        if(!$this->isEditAllowed($aCmt)){
+            $sMsg = $aCmt['cmt_author_id'] == $iCmtAuthorId ? strip_tags($this->msgErrEditAllowed()) : _t('_Access denied');
+            return bx_is_api() ? bx_api_get_msg($sMsg) : array('msg' => $sMsg);
+        }
 
         $oForm = $this->_getForm(BX_CMT_ACTION_EDIT, $aCmt['cmt_id']);
 
@@ -1373,14 +1375,21 @@ class BxBaseCmts extends BxDolCmts
                 if($this->_sMetatagsObj && ($oMetatags = BxDolMetatags::getObjectInstance($this->_sMetatagsObj)) !== false)
                     $oMetatags->metaAdd($iCmtUniqId, $sCmtText);
 
-                if(($mixedResult = $this->onEditAfter($iCmtId, $aDp)) !== false)
-                    return $mixedResult;
-            }
+                if(($mixedResult = $this->onEditAfter($iCmtId, $aDp)) !== false){
+                    if (bx_is_api()){
+                        $this->_unsetFormObject(BX_CMT_ACTION_POST);
+                        return ['form' => $this->_getForm(BX_CMT_ACTION_POST, $iCmtParentId), 'res' => $iCmtId];
+                    }
+                    else{
+                        return $mixedResult;
+                    }
+                }
 
-            return array('msg' => _t('_cmt_err_cannot_perform_action'));
+            }
+            return bx_is_api() ? bx_api_get_msg(_t('_cmt_err_cannot_perform_action')) : array('msg' => _t('_cmt_err_cannot_perform_action'));
         }
 
-        return array('form' => $oForm->getCode($bDynamic), 'form_id' => $oForm->id);
+        return bx_is_api() ? ['form' => $oForm, 'res' => 0] :  array('form' => $oForm->getCode($bDynamic), 'form_id' => $oForm->id);
     }
 
     protected function _getForm($sAction, $iId)

+ 24 - 0
template/scripts/BxBaseCmtsServices.php

@@ -456,6 +456,30 @@ class BxBaseCmtsServices extends BxDol
         if(is_string($aParams))
             $aParams = json_decode($aParams, true);
         
+        if (isset($aParams['action']) && isset($aParams['id']) && $aParams['action'] == 'remove'){
+            $iCmtId = $aParams['id'];
+            $oCmts = BxDolCmts::getObjectInstance($aParams['module'], $aParams['object_id']);
+            $oCmts->remove($iCmtId);
+            return 'Ok';
+        }
+        
+        if (isset($aParams['action']) && isset($aParams['id']) && $aParams['action'] == 'edit'){
+            $iCmtId = $aParams['id'];
+            $oCmts = BxDolCmts::getObjectInstance($aParams['module'], $aParams['object_id']);
+            $oForm = $oCmts->getFormEdit($iCmtId);
+            $aForm = $oForm['form']->getCodeAPI();
+            $aForm['inputs']['cmt_text']['numLines'] = 1;
+            $aForm['inputs']['cmt_text']['autoheight'] = true;
+            $aForm['inputs']['cmt_submit'] = $aForm['inputs']['cmt_controls'][0];
+            unset($aForm['inputs']['cmt_controls']);
+            
+            $aForm['inputs']['cmt_submit']['icon'] = 'contact';
+            $aForm['inputs']['cmt_submit']['variant'] = 'text';
+            $aForm['inputs']['cmt_submit']['icon_only'] = true;
+            $aRv['form'] = ['id' => 'cmt_form', 'type' => 'form', 'name' => 'comment', 'data' => $aForm, 'request' => ['immutable' => true]];
+            return $aRv;
+        }
+        
         $aParams['parent_id'] = !isset($aParams['parent_id']) ? 0 : $aParams['parent_id'];
         $aParams['start_from'] = !isset($aParams['start_from']) ? 0 : $aParams['start_from'];
         $aParams['order_way'] = !isset($aParams['order_way']) ? 'asc' : $aParams['order_way'];

+ 3 - 2
template/scripts/BxBasePage.php

@@ -465,9 +465,10 @@ class BxBasePage extends BxDolPage
         }
 
         if (isLogged()) {
-            if(($oMenuAddContent = BxDolMenu::getObjectInstance('sys_add_content')) !== false)
+            /* temporatery commented
+                if(($oMenuAddContent = BxDolMenu::getObjectInstance('sys_add_content')) !== false)
                 $a['menu_add'] = $oMenuAddContent->getCodeAPI();
-
+            */
             $o = BxDolProfile::getInstance();
             $a['user'] = [
                 'id' => $o->id(),