Просмотр исходного кода

Ticket #2745 - Check default privacy group if user didn't specify the group manually.

AntonLV 6 лет назад
Родитель
Сommit
e15a302f99
1 измененных файлов с 23 добавлено и 11 удалено
  1. 23 11
      template/scripts/BxBaseFormView.php

+ 23 - 11
template/scripts/BxBaseFormView.php

@@ -550,17 +550,29 @@ BLAH;
         if(empty($mixedInput) || !is_array($mixedInput))
             return false;
 
-        if(!empty($mixedInput['privacy']) && !empty($this->_iAuthorId)) {
-            $mixedResult = checkActionModule($this->_iAuthorId, 'set form fields privacy', 'system');
-            if($mixedResult[CHECK_ACTION_RESULT] === CHECK_ACTION_RESULT_ALLOWED) {
-                $aInputPrivacy = BxDolFormQuery::getInputPrivacy($mixedInput['id'], $this->_iAuthorId);
-                if(!empty($aInputPrivacy) && is_array($aInputPrivacy)) {
-                    $oPrivacy = BxDolPrivacy::getObjectInstance($this->_sPrivacyObjectView);            
-                    if($oPrivacy && !$oPrivacy->check($aInputPrivacy['id']))
-                        return false;
-                }
-            }
-        }
+        if(!empty($mixedInput['privacy']) && !empty($this->_iAuthorId) && !$this->_isInputVisibleByPrivacy($mixedInput))
+            return false;
+
+        return true;
+    }
+
+    protected function _isInputVisibleByPrivacy($aInput)
+    {
+        $mixedResult = checkActionModule($this->_iAuthorId, 'set form fields privacy', 'system');
+        if($mixedResult[CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED)
+            return true;            
+
+        $aInputPrivacy = BxDolFormQuery::getInputPrivacy($aInput['id'], $this->_iAuthorId);
+        if(empty($aInputPrivacy) || !is_array($aInputPrivacy))
+            if(BxDolFormQuery::setInputPrivacy($aInput['id'], $this->_iAuthorId, BxDolPrivacy::getFieldName($this->_sPrivacyObjectView), $this->_sPrivacyGroupDefault))
+                $aInputPrivacy = BxDolFormQuery::getInputPrivacy($aInput['id'], $this->_iAuthorId);
+
+        if((empty($aInputPrivacy) || !is_array($aInputPrivacy)) && $this->_sPrivacyGroupDefault != BX_DOL_PG_ALL)
+            return false;
+
+        $oPrivacy = BxDolPrivacy::getObjectInstance($this->_sPrivacyObjectView);            
+        if($oPrivacy && !$oPrivacy->check($aInputPrivacy['id']))
+            return false;
 
         return true;
     }