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

+ 1 - 1
modules/base/notifications/classes/BxBaseModNotificationsConfig.php

@@ -149,7 +149,7 @@ class BxBaseModNotificationsConfig extends BxBaseModGeneralConfig
 
     public function getPrivacyViewDefault($sType)
     {
-        return isset($this->_aPrivacyViewDefault[$sType]) ? $this->_aPrivacyViewDefault[$sType] : BX_DOL_PG_ALL;
+        return isset($this->_aPrivacyViewDefault[$sType]) ? (int)$this->_aPrivacyViewDefault[$sType] : (int)BX_DOL_PG_ALL;
     }
 }
 

+ 0 - 2
modules/boonex/russian/data/langs/bx_timeline/ru.xml

@@ -26,8 +26,6 @@
 	<string name="_bx_timeline_form_post_display_add_profile"><![CDATA[Написать сообщение в профиль]]></string>
 	<string name="_bx_timeline_form_post_display_edit"><![CDATA[Изменить сообщение]]></string>
 	<string name="_bx_timeline_form_post_input_sys_owner_id"><![CDATA[ID владельца]]></string>
-	<string name="_bx_timeline_form_post_input_owner_id"><![CDATA[Контекст]]></string>
-	<string name="_bx_timeline_form_post_input_owner_id_err"><![CDATA[Поле Контекст является обязательным. Пожалуйста, выберите значение.]]></string>
 	<string name="_bx_timeline_form_post_input_owner_id_own"><![CDATA[Собственный профиль]]></string>
     <string name="_bx_timeline_form_post_input_owner_id_following_group"><![CDATA[Отслеживаемые {0}]]></string>
 	<string name="_bx_timeline_form_post_input_sys_action"><![CDATA[Действие]]></string>

+ 16 - 0
modules/boonex/timeline/classes/BxTimelineConfig.php

@@ -13,6 +13,8 @@ bx_import('BxDolPrivacy');
 
 class BxTimelineConfig extends BxBaseModNotificationsConfig
 {
+    protected $_aTypeToFormDisplay;
+
     protected $_bAllowEdit;
     protected $_bAllowDelete;
     protected $_bShowAll;
@@ -82,6 +84,12 @@ class BxTimelineConfig extends BxBaseModNotificationsConfig
             ),
         );
 
+        $this->_aTypeToFormDisplay = array(
+            BX_BASE_MOD_NTFS_TYPE_OWNER => 'form_display_post_add_profile',
+            BX_BASE_MOD_NTFS_TYPE_PUBLIC => 'form_display_post_add_public',
+            BX_TIMELINE_TYPE_OWNER_AND_CONNECTIONS => 'form_display_post_add'
+        );
+
         $this->_aPrefixes = array(
         	'style' => 'bx-tl',
         	'language' => '_bx_timeline',
@@ -245,6 +253,14 @@ class BxTimelineConfig extends BxBaseModNotificationsConfig
         return $this->_bShowAll;
     }
 
+    public function getPostFormDisplay($sType)
+    {
+        if(empty($sType) || !array_key_exists($sType, $this->_aTypeToFormDisplay))
+            $sType = BX_TIMELINE_TYPE_DEFAULT;
+
+        return $this->_aTypeToFormDisplay[$sType];
+    }
+
     public function getUploaders($sType)
     {
         $aResult = array();

+ 12 - 33
modules/boonex/timeline/classes/BxTimelineFormPost.php

@@ -32,35 +32,6 @@ class BxTimelineFormPost extends BxBaseModGeneralFormEntry
 		$this->aFormAttrs['action'] = BX_DOL_URL_ROOT . $this->_oModule->_oConfig->getBaseUri() . 'post/';
         
 		$this->aInputs['owner_id']['value'] = $iOwnerId;
-        if(!$this->_bPublicMode && !$this->_bProfileMode) {
-            $this->aInputs['owner_id']['values'] = array(
-                array ('key' => $iUserId, 'value' => _t('_bx_timeline_form_post_input_owner_id_own')),
-            );
-            
-            $oProfileQuery = BxDolProfileQuery::getInstance();
-
-            $sConnections = $this->_oModule->_oConfig->getObject('conn_subscriptions');
-            $aConnections = BxDolConnection::getObjectInstance($sConnections)->getConnectedContent($iUserId);
-
-            $aCnnGroups = array();
-            foreach($aConnections as $iId) {
-                $aProfileInfo = $oProfileQuery->getInfoById($iId);
-                if(empty($aProfileInfo) || !is_array($aProfileInfo))
-                    continue;
-
-                $aCnnGroups[$aProfileInfo['type']][] = $aProfileInfo['id'];
-            }
-
-            $oProfile = BxDolProfile::getInstance();
-            foreach($aCnnGroups as $sCnnGroup => $aCnnGroup) {
-                $this->aInputs['owner_id']['values'][] = array('type' => 'group_header', 'value' => _t('_bx_timeline_form_post_input_owner_id_following_group', _t('_' . $sCnnGroup)));
-                foreach($aCnnGroup as $iId)
-                    $this->aInputs['owner_id']['values'][] = array('key' => $iId, 'value' => $oProfile->getDisplayName($iId));
-                $this->aInputs['owner_id']['values'][] = array('type' => 'group_end');
-            }
-        }
-        else
-            $this->aInputs['owner_id']['type'] = 'hidden';
 
         if(isset($this->aInputs['text'])) {
             if(empty($this->aInputs['text']['attrs']) || !is_array($this->aInputs['text']['attrs']))
@@ -74,10 +45,18 @@ class BxTimelineFormPost extends BxBaseModGeneralFormEntry
                 'title' => _t('_bx_timeline_form_post_input_object_privacy_view')
             )));
 
-            if($this->_bPublicMode || ($this->_bProfileMode && $iOwnerId != $iUserId))
-                foreach($this->aInputs['object_privacy_view']['values'] as $iKey => $aValue)
-                    if($aValue['key'] !== BX_DOL_PG_ALL)
-                        unset($this->aInputs['object_privacy_view']['values'][$iKey]);
+            if($this->_bPublicMode || $this->_bProfileMode)
+                foreach($this->aInputs['object_privacy_view']['values'] as $iKey => $aValue) {
+                    //--- Show 'Public' privacy group only in Public and Profile (for Not Owner) post forms. 
+                    if(($this->_bPublicMode || ($this->_bProfileMode && $iOwnerId != $iUserId)) && isset($aValue['key']) && $aValue['key'] == BX_DOL_PG_ALL)
+                        continue;
+
+                    //--- Show a default privacy groups Profile (for Owner) post form. 
+                    if($this->_bProfileMode && $iOwnerId == $iUserId && isset($aValue['key']) && (int)$aValue['key'] >= 0)
+                        continue;
+
+                    unset($this->aInputs['object_privacy_view']['values'][$iKey]);
+                }
         }
 
         if(isset($this->aInputs['link']))

+ 28 - 11
modules/boonex/timeline/classes/BxTimelineModule.php

@@ -279,8 +279,12 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
     public function actionGetPostForm()
     {
         $this->_iOwnerId = bx_process_input(bx_get('owner_id'), BX_DATA_INT);
+        $sType = bx_process_input(bx_get('type'));
 
-        echoJson($this->getFormPost());
+        echoJson($this->getFormPost(array(
+            'type' => $sType,
+            'form_display' => $this->_oConfig->getPostFormDisplay($sType)
+        )));
     }
 
     public function actionGetEditForm($iId)
@@ -617,8 +621,10 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
         if(!$iProfileId)
             return array();
 
+        $sType = BX_BASE_MOD_NTFS_TYPE_OWNER;
         return $this->_getBlockPost($iProfileId, array(
-        	'form_display' => 'form_display_post_add_profile'
+        	'type' => $sType,
+        	'form_display' => $this->_oConfig->getPostFormDisplay($sType)
         ));
     }
 
@@ -653,9 +659,11 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
 		if(empty($oProfile))
 			return array();
 
-		return $this->_getBlockPost($oProfile->id(), array(
-		    'type' => BX_BASE_MOD_NTFS_TYPE_OWNER,
-			'form_display' => 'form_display_post_add_profile'
+        $iProfileId = $oProfile->id();
+        $sType = BX_BASE_MOD_NTFS_TYPE_OWNER;
+		return $this->_getBlockPost($iProfileId, array(
+		    'type' => $sType,
+			'form_display' => $this->_oConfig->getPostFormDisplay($sType)
 		));
     }
 
@@ -679,9 +687,10 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
     public function serviceGetBlockPostHome()
     {
         $iProfileId = 0;
+        $sType = BX_BASE_MOD_NTFS_TYPE_PUBLIC;
         return $this->_getBlockPost($iProfileId, array(
-        	'type' => BX_BASE_MOD_NTFS_TYPE_PUBLIC,
-            'form_display' => 'form_display_post_add_public'
+        	'type' => $sType,
+            'form_display' => $this->_oConfig->getPostFormDisplay($sType)
         ));
     }
 
@@ -708,9 +717,10 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
             return '';
 
         $iProfileId = $this->getProfileId();
+        $sType = BX_TIMELINE_TYPE_OWNER_AND_CONNECTIONS;
 		return $this->_getBlockPost($iProfileId, array(
-		    'type' => BX_TIMELINE_TYPE_OWNER_AND_CONNECTIONS,
-			'form_display' => 'form_display_post_add'
+		    'type' => $sType,
+			'form_display' => $this->_oConfig->getPostFormDisplay($sType)
 		));
     }
 
@@ -1524,10 +1534,16 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
             if($bText)
             	$aContent['text'] = $sText;
 
-            //--- Process Privacy ---//
+            //--- Process Context and Privacy ---//
+            $iOwnerId = (int)$oForm->getCleanValue('owner_id');
             $iObjectPrivacyView = (int)$oForm->getCleanValue('object_privacy_view');
+            $iObjectPrivacyViewDefault = $this->_oConfig->getPrivacyViewDefault('object');
             if(empty($iObjectPrivacyView))
-                $iObjectPrivacyView = $this->_oConfig->getPrivacyViewDefault('object');
+                $iObjectPrivacyView = $iObjectPrivacyViewDefault;
+            else if($iObjectPrivacyView < 0) {
+                $iOwnerId = abs($iObjectPrivacyView);
+                $iObjectPrivacyView = $iObjectPrivacyViewDefault;
+            }
 
             //--- Process Link ---//
             $aLinkIds = $oForm->getCleanValue('link');
@@ -1554,6 +1570,7 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
                 $iDate = time();
 
             $iId = $oForm->insert(array(
+                'owner_id' => $iOwnerId,
                 'object_id' => $iUserId,
                 'object_privacy_view' => $iObjectPrivacyView,
                 'content' => serialize($aContent),

+ 41 - 0
modules/boonex/timeline/classes/BxTimelinePrivacy.php

@@ -11,10 +11,51 @@
 
 class BxTimelinePrivacy extends BxBaseModNotificationsPrivacy
 {
+    protected $_oModule;
+
 	public function __construct ($aOptions, $oTemplate = false)
     {
         parent::__construct ($aOptions, $oTemplate);
+
+        $this->_oModule = BxDolModule::getInstance('bx_timeline');
+    }
+
+    public function addSpaces($aValues, $iOwnerId, $aParams)
+    {
+        if (!$this->_aObject['spaces'])
+            return $aValues;
+
+        if (!($oProfile = BxDolProfile::getInstance($iOwnerId)))
+            return $aValues;
+
+        if (!($aModules = BxDolModuleQuery::getInstance()->getModules()))
+            return $aValues;
+            
+        $oProfileQuery = BxDolProfileQuery::getInstance();
+
+        $sConnections = $this->_oModule->_oConfig->getObject('conn_subscriptions');
+        $aConnections = BxDolConnection::getObjectInstance($sConnections)->getConnectedContent($iOwnerId);
+
+        $aCnnGroups = array();
+        foreach($aConnections as $iId) {
+            $aProfileInfo = $oProfileQuery->getInfoById($iId);
+            if(empty($aProfileInfo) || !is_array($aProfileInfo))
+                continue;
+
+            $aCnnGroups[$aProfileInfo['type']][] = $aProfileInfo['id'];
+        }
+
+        $oProfile = BxDolProfile::getInstance();
+        foreach($aCnnGroups as $sCnnGroup => $aCnnGroup) {
+            $aValues[] = array('type' => 'group_header', 'value' => _t('_bx_timeline_form_post_input_owner_id_following_group', _t('_' . $sCnnGroup)));
+            foreach($aCnnGroup as $iId)
+                $aValues[] = array('key' => -$iId, 'value' => $oProfile->getDisplayName($iId));
+            $aValues[] = array('type' => 'group_end');
+        }
+
+        return $aValues;
     }
+    
 }
 
 /** @} */

+ 7 - 1
modules/boonex/timeline/classes/BxTimelineResponse.php

@@ -32,10 +32,16 @@ class BxTimelineResponse extends BxBaseModNotificationsResponse
         $aHandler = $this->_oModule->_oConfig->getHandlers($oAlert->sUnit . '_' . $oAlert->sAction);
         switch($aHandler['type']) {
             case BX_BASE_MOD_NTFS_HANDLER_TYPE_INSERT:
+                $iOwnerId = $oAlert->iSender;
+                if($iObjectPrivacyView < 0) {
+                    $iOwnerId = abs($iObjectPrivacyView);
+                    $iObjectPrivacyView = $this->_oModule->_oConfig->getPrivacyViewDefault('object');
+                }
+
                 $sContent = !empty($oAlert->aExtras) && is_array($oAlert->aExtras) ? serialize(bx_process_input($oAlert->aExtras)) : '';
 
                 $iId = $this->_oModule->_oDb->insertEvent(array(
-                    'owner_id' => $oAlert->iSender,
+                    'owner_id' => $iOwnerId,
                     'type' => $oAlert->sUnit,
                     'action' => $oAlert->sAction,
                     'object_id' => $oAlert->iObject,

+ 23 - 7
modules/boonex/timeline/classes/BxTimelineTemplate.php

@@ -343,8 +343,10 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
             $bNext = true;
         }
 
-        $iEvents = count($aEvents);
         $sContent = '';
+        $sContent .= $this->getSizer($aParams);
+
+        $iEvents = count($aEvents);
         if($bViewTimeline && $iEvents <= 0)
         	$sContent .= $this->getDividerToday();
 
@@ -418,6 +420,16 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
         ));
     }
 
+    public function getSizer($aParams)
+    {
+        if($aParams['view'] != BX_TIMELINE_VIEW_OUTLINE)
+            return '';
+
+        return $this->parseHtmlByName('sizer_' . $aParams['view'] . '.html', array(
+        	'style_prefix' => $this->_oConfig->getPrefix('style')
+        ));
+    }
+
     public function getBack($aParams)
     {
         $iYearSel = (int)$aParams['timeline'];
@@ -899,13 +911,17 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
         $bPinned = (int)$aEvent['pinned'] > 0;
         $bPromoted = (int)$aEvent['promoted'] > 0;
 
-        $sClass = 'bx-tl-view-sizer';
+        $sClass = $sStylePrefix . '-view-sizer';
         if($bViewOutline) {
-            $sClass = 'bx-tl-grid-sizer';
-            if($bPinned)
-            	$sClass .= '-pnd';
-            if($bPromoted)
-            	$sClass .= '-pmd';
+            $sClass = $sStylePrefix . '-grid-item-sizer';
+            if($bPinned || $bPromoted) {
+                $sClass .= ' ' . $sStylePrefix . '-gis';
+
+                if($bPinned)
+            	    $sClass .= '-pnd';
+                if($bPromoted)
+                	$sClass .= '-pmd';
+            }
         }
         if(!empty($aBrowseParams['blink']) && in_array($aEvent['id'], $aBrowseParams['blink']))
 			$sClass .= ' ' . $sStylePrefix . '-blink';

+ 0 - 2
modules/boonex/timeline/install/langs/en.xml

@@ -26,8 +26,6 @@
 	<string name="_bx_timeline_form_post_display_add_profile"><![CDATA[Write Profile Post]]></string>
 	<string name="_bx_timeline_form_post_display_edit"><![CDATA[Edit Post]]></string>
 	<string name="_bx_timeline_form_post_input_sys_owner_id"><![CDATA[Owner ID]]></string>
-	<string name="_bx_timeline_form_post_input_owner_id"><![CDATA[Context]]></string>
-	<string name="_bx_timeline_form_post_input_owner_id_err"><![CDATA[The Context field is essential. Please select some value.]]></string>
 	<string name="_bx_timeline_form_post_input_owner_id_own"><![CDATA[Your profile]]></string>
 	<string name="_bx_timeline_form_post_input_owner_id_following_group"><![CDATA[Following {0}]]></string>
 	<string name="_bx_timeline_form_post_input_sys_action"><![CDATA[Action]]></string>

+ 1 - 1
modules/boonex/timeline/install/sql/install.sql

@@ -299,7 +299,7 @@ INSERT INTO `sys_form_displays` (`display_name`, `module`, `object`, `title`, `v
 INSERT INTO `sys_form_inputs` (`object`, `module`, `name`, `value`, `values`, `checked`, `type`, `caption_system`, `caption`, `info`, `required`, `collapsed`, `html`, `attrs`, `attrs_tr`, `attrs_wrapper`, `checker_func`, `checker_params`, `checker_error`, `db_pass`, `db_params`, `editable`, `deletable`) VALUES
 ('bx_timeline_post', @sName, 'type', 'post', '', 0, 'hidden', '_bx_timeline_form_post_input_sys_type', '', '', 0, 0, 0, '', '', '', '', '', '', 'Xss', '', 0, 0),
 ('bx_timeline_post', @sName, 'action', '', '', 0, 'hidden', '_bx_timeline_form_post_input_sys_action', '', '', 0, 0, 0, '', '', '', '', '', '', 'Xss', '', 0, 0),
-('bx_timeline_post', @sName, 'owner_id', '0', '', 0, 'select', '_bx_timeline_form_post_input_sys_owner_id', '_bx_timeline_form_post_input_owner_id', '', 0, 0, 0, '', '', '', '', '', '', 'Int', '', 1, 0),
+('bx_timeline_post', @sName, 'owner_id', '0', '', 0, 'hidden', '_bx_timeline_form_post_input_sys_owner_id', '', '', 0, 0, 0, '', '', '', '', '', '', 'Int', '', 1, 0),
 ('bx_timeline_post', @sName, 'text', '', '', 0, 'textarea', '_bx_timeline_form_post_input_sys_text', '_bx_timeline_form_post_input_text', '', 0, 0, 3, 'a:1:{s:12:"autocomplete";s:3:"off";}', '', '', '', '', '', 'XssHtml', '', 1, 0),
 ('bx_timeline_post', @sName, 'date', '', '', 0, 'datetime', '_bx_timeline_form_post_input_sys_date', '_bx_timeline_form_post_input_date', '_bx_timeline_form_post_input_date_info', 0, 0, 0, '', '', '', '', '', '', 'DateTimeUtc', '', 1, 0),
 ('bx_timeline_post', @sName, 'object_privacy_view', '', '', 0, 'custom', '_bx_timeline_form_post_input_sys_object_privacy_view', '_bx_timeline_form_post_input_object_privacy_view', '', 1, 0, 0, '', '', '', '', '', '', '', '', 1, 0),

+ 1 - 1
modules/boonex/timeline/template/type_repost.html

@@ -1,5 +1,5 @@
 <bx_if:show_title>
-	<div class="__style_prefix__-title bx-def-margin-sec-bottom bx-def-font-large">__title__</div>
+	<div class="__style_prefix__-title bx-def-margin-sec-bottom bx-def-margin-leftright bx-def-font-large">__title__</div>
 </bx_if:show_title>
 <bx_if:show_content>
 	<div class="__style_prefix__-content __style_prefix__-reposted bx-def-margin-sec-bottom">