AntonLV 8 лет назад
Родитель
Сommit
eec467719a

+ 7 - 6
modules/base/general/classes/BxBaseModGeneralModule.php

@@ -28,13 +28,14 @@ class BxBaseModGeneralModule extends BxDolModule
         $this->_aSearchableNamesExcept = array(
             'allow_view_to'
         );
-        
+
         $this->_aFormParams = array(
-        	'display' => false, 
-        	'dynamic_mode' => false, 
-        	'ajax_mode' => false, 
-        	'absolute_action_url' => false,
-        	'context_id' => 0
+            'display' => false, 
+            'dynamic_mode' => false, 
+            'ajax_mode' => false, 
+            'absolute_action_url' => false,
+            'visibility_autoselect' => false,
+            'context_id' => 0,
         );
     }
 

+ 52 - 36
modules/boonex/timeline/classes/BxTimelineFormPost.php

@@ -18,22 +18,61 @@ class BxTimelineFormPost extends BxBaseModGeneralFormEntry
     protected $_bPublicMode;
     protected $_bProfileMode;
 
+    protected $_bVisibilityAutoselect;
+
     public function __construct($aInfo, $oTemplate = false)
     {
         $this->MODULE = 'bx_timeline';
 
         parent::__construct($aInfo, $oTemplate);
 
-        $iUserId = $this->_oModule->getUserId();
-        $iOwnerId = $this->_oModule->getOwnerId();
-
         $this->_bAccountMode = isset($this->aParams['display']) && $this->aParams['display'] == $this->_oModule->_oConfig->getObject('form_display_post_add');
         $this->_bPublicMode = isset($this->aParams['display']) && $this->aParams['display'] == $this->_oModule->_oConfig->getObject('form_display_post_add_public');
         $this->_bProfileMode = isset($this->aParams['display']) && $this->aParams['display'] == $this->_oModule->_oConfig->getObject('form_display_post_add_profile');
 
-		$this->aFormAttrs['action'] = BX_DOL_URL_ROOT . $this->_oModule->_oConfig->getBaseUri() . 'post/';
-        
-		$this->aInputs['owner_id']['value'] = $iOwnerId;
+        $this->_bVisibilityAutoselect = true;
+    }
+
+    public function getCode($bDynamicMode = false)
+    {
+    	$sResult = parent::getCode($bDynamicMode);
+
+    	return $this->_oModule->_oTemplate->parseHtmlByContent($sResult, array(
+    		'attachments_menu' => $this->_oModule->getAttachmentsMenuObject()->getCode()
+    	));
+    }
+
+    public function addHtmlEditor($iViewMode, &$aInput)
+    {
+        $CNF = &$this->_oModule->_oConfig->CNF;
+
+        $oEditor = BxDolEditor::getObjectInstance(false, $this->oTemplate);
+        if (!$oEditor)
+            return false;
+
+            
+        if(in_array($this->aParams['display'], array($this->_oModule->_oConfig->getObject('form_display_post_add'), $this->_oModule->_oConfig->getObject('form_display_post_add_public'))))
+            $oEditor->setCustomConf("
+                placeholderText: '" . _t('_bx_timeline_txt_some_text_here') . "',
+                initOnClick: false,
+            ");
+
+        if(!$this->_oModule->_oConfig->isEditorToolbar())
+        	$oEditor->setCustomToolbarButtons('');
+
+        $this->_sCodeAdd .= $oEditor->attachEditor ('#' . $this->aFormAttrs['id'] . ' [name='.$aInput['name'].']', $iViewMode, $this->_bDynamicMode);
+
+        return true;
+    }
+
+    public function init()
+    {
+        $iUserId = $this->_oModule->getUserId();
+        $iOwnerId = $this->_oModule->getOwnerId();
+
+        $this->aFormAttrs['action'] = BX_DOL_URL_ROOT . $this->_oModule->_oConfig->getBaseUri() . 'post/';
+
+        $this->aInputs['owner_id']['value'] = $iOwnerId;
 
         if(isset($this->aInputs['text'])) {
             if(empty($this->aInputs['text']['attrs']) || !is_array($this->aInputs['text']['attrs']))
@@ -66,7 +105,7 @@ class BxTimelineFormPost extends BxBaseModGeneralFormEntry
             $this->aInputs['photo']['ghost_template'] = $oFormNested;
         }
 
-	    if(isset($this->aInputs['video'])) {
+        if(isset($this->aInputs['video'])) {
             $aFormNested = array(
                 'params' =>array(
                     'nested_form_template' => 'uploader_nfw.html'
@@ -91,36 +130,9 @@ class BxTimelineFormPost extends BxBaseModGeneralFormEntry
             $this->aInputs[$this->_oModule->_oConfig->CNF['FIELD_LOCATION_PREFIX']]['manual_input'] = false;
     }
 
-    public function getCode($bDynamicMode = false)
+    public function setVisibilityAutoselect($bVisibilityAutoselect)
     {
-    	$sResult = parent::getCode($bDynamicMode);
-
-    	return $this->_oModule->_oTemplate->parseHtmlByContent($sResult, array(
-    		'attachments_menu' => $this->_oModule->getAttachmentsMenuObject()->getCode()
-    	));
-    }
-
-    public function addHtmlEditor($iViewMode, &$aInput)
-    {
-        $CNF = &$this->_oModule->_oConfig->CNF;
-
-        $oEditor = BxDolEditor::getObjectInstance(false, $this->oTemplate);
-        if (!$oEditor)
-            return false;
-
-            
-        if(in_array($this->aParams['display'], array($this->_oModule->_oConfig->getObject('form_display_post_add'), $this->_oModule->_oConfig->getObject('form_display_post_add_public'))))
-            $oEditor->setCustomConf("
-                placeholderText: '" . _t('_bx_timeline_txt_some_text_here') . "',
-                initOnClick: false,
-            ");
-
-        if(!$this->_oModule->_oConfig->isEditorToolbar())
-        	$oEditor->setCustomToolbarButtons('');
-
-        $this->_sCodeAdd .= $oEditor->attachEditor ('#' . $this->aFormAttrs['id'] . ' [name='.$aInput['name'].']', $iViewMode, $this->_bDynamicMode);
-
-        return true;
+        $this->_bVisibilityAutoselect = $bVisibilityAutoselect;
     }
 
     protected function _updateFieldObjectPrivacyView($aInput)
@@ -132,6 +144,10 @@ class BxTimelineFormPost extends BxBaseModGeneralFormEntry
             'title' => _t('_bx_timeline_form_post_input_object_privacy_view')
         )));
 
+        //--- Show field as is when 'Autoselect' is disabled.
+        if(!$this->_bVisibilityAutoselect)
+            return $aInput;
+
         //--- Show default privacy groups and followed contexts on Account (Profile + Connections) post form.
         if($this->_bAccountMode)
             return $aInput;

+ 14 - 8
modules/boonex/timeline/classes/BxTimelineModule.php

@@ -543,13 +543,7 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
                 $aParams['form_display'] = 'form_display_post_add_profile';
         }
 
-        $oForm = $this->getFormPostObject($aParams);
-	
-        $sParamsKey = 'ajax_mode';
-        if(isset($aParams[$sParamsKey]) && is_bool($aParams[$sParamsKey]))
-        	$oForm->setAjaxMode((bool)$aParams[$sParamsKey]);
-
-    	return $oForm;
+    	return $this->getFormPostObject($aParams);
     }
     
     /**
@@ -1934,7 +1928,19 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
     {
     	$sFormObject = !empty($aParams['form_object']) ? $aParams['form_object'] : 'form_post';
         $sFormDisplay = !empty($aParams['form_display']) ? $aParams['form_display'] : 'form_display_post_add';
-        return BxDolForm::getObjectInstance($this->_oConfig->getObject($sFormObject), $this->_oConfig->getObject($sFormDisplay), $this->_oTemplate);
+
+        $oForm = BxDolForm::getObjectInstance($this->_oConfig->getObject($sFormObject), $this->_oConfig->getObject($sFormDisplay), $this->_oTemplate);        
+
+        $sParamsKey = 'ajax_mode';
+        if(isset($aParams[$sParamsKey]) && is_bool($aParams[$sParamsKey]))
+            $oForm->setAjaxMode((bool)$aParams[$sParamsKey]);
+
+        $sParamsKey = 'visibility_autoselect';
+        if(isset($aParams[$sParamsKey]) && is_bool($aParams[$sParamsKey]))
+            $oForm->setVisibilityAutoselect((bool)$aParams[$sParamsKey]);
+
+        $oForm->init();
+        return $oForm;
     }
 
     public function getCmtsObject($sSystem, $iId)