Kaynağa Gözat

Ticket #1470 - Timeline.

AntonLV 8 yıl önce
ebeveyn
işleme
053ca72a9c

+ 1 - 1
inc/js/classes/BxDolCmts.js

@@ -438,7 +438,7 @@ BxDolCmts.prototype.showLiveUpdate = function(oData)
         onShow: function() {
             setTimeout(function() {
                 $('.bx-popup-chain.bx-popup-applied:visible:first').dolPopupHide();
-            }, 50000);
+            }, 5000);
         },
     	onHide: function() {
             $this.resumeLiveUpdates();

+ 2 - 2
modules/base/general/classes/BxBaseModGeneralFormEntry.php

@@ -107,10 +107,10 @@ class BxBaseModGeneralFormEntry extends BxTemplFormView
             $this->aInputs[$CNF['FIELD_LABELS']]['value'] = array_intersect($aLabels, $this->aInputs[$CNF['FIELD_LABELS']]['values']);
         }
 
-        if (isset($CNF['FIELD_ANONYMOUS']) && isset($this->aInputs[$CNF['FIELD_ANONYMOUS']]) && isset($aValues[$CNF['FIELD_AUTHOR']])) {
+        if (isset($CNF['FIELD_ANONYMOUS']) && isset($this->aInputs[$CNF['FIELD_ANONYMOUS']]) && isset($CNF['FIELD_AUTHOR']) && isset($aValues[$CNF['FIELD_AUTHOR']])) {
             $this->aInputs[$CNF['FIELD_ANONYMOUS']]['checked'] = $aValues[$CNF['FIELD_AUTHOR']] < 0;
         }
-        
+
         parent::initChecker ($aValues, $aSpecificValues);
     }
     

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

@@ -908,7 +908,12 @@ class BxBaseModGeneralModule extends BxDolModule
             return '';
 
         $CNF = &$this->_oConfig->CNF;
-        
+
+        $iUserId = $this->getUserId();
+        $iAuthorId = $aContentInfo[$CNF['FIELD_AUTHOR']];
+        if($iAuthorId < 0 && abs($iAuthorId) != $iUserId)
+            return '';
+
         //--- Views
         $oViews = isset($CNF['OBJECT_VIEWS']) ? BxDolView::getObjectInstance($CNF['OBJECT_VIEWS'], $aEvent['object_id']) : null;
 

+ 2 - 1
modules/boonex/timeline/classes/BxTimelineConfig.php

@@ -63,11 +63,12 @@ class BxTimelineConfig extends BxBaseModNotificationsConfig
             // database fields
             'FIELD_ID' => 'id',
             'FIELD_OWNER_ID' => 'owner_id',
-            'FIELD_OBJECT_ID' => 'object_id',
+            'FIELD_OBJECT_ID' => 'object_id', //Note. For 'Direct Timeline Posts' this field contains post's author profile ID.
             'FIELD_OBJECT_PRIVACY_VIEW' => 'object_privacy_view',
             'FIELD_ADDED' => 'date',
             'FIELD_TITLE' => 'title',
             'FIELD_TEXT' => 'description',
+            'FIELD_ANONYMOUS' => 'anonymous',
             'FIELD_CONTROLS' => 'controls',
             'FIELD_LOCATION_PREFIX' => 'location',
 

+ 32 - 0
modules/boonex/timeline/classes/BxTimelineFormPost.php

@@ -42,6 +42,38 @@ class BxTimelineFormPost extends BxBaseModGeneralFormEntry
     	));
     }
 
+    function initChecker($aValues = array (), $aSpecificValues = array())
+    {
+        $CNF = &$this->_oModule->_oConfig->CNF;
+
+        if(isset($CNF['FIELD_ANONYMOUS']) && isset($this->aInputs[$CNF['FIELD_ANONYMOUS']]) && isset($aValues[$CNF['FIELD_OBJECT_ID']]))
+            $this->aInputs[$CNF['FIELD_ANONYMOUS']]['checked'] = $aValues[$CNF['FIELD_OBJECT_ID']] < 0;
+
+        parent::initChecker ($aValues, $aSpecificValues);
+    }
+
+    public function insert($aValsToAdd = array(), $isIgnore = false)
+    {
+        $CNF = &$this->_oModule->_oConfig->CNF;
+
+        $aValsToAdd[$CNF['FIELD_OBJECT_ID']] *= isset($CNF['FIELD_ANONYMOUS']) && isset($this->aInputs[$CNF['FIELD_ANONYMOUS']]) && $this->getCleanValue($CNF['FIELD_ANONYMOUS']) ? -1 : 1;
+
+        return parent::insert ($aValsToAdd, $isIgnore);
+    }
+
+    function update($iContentId, $aValsToAdd = array(), &$aTrackTextFieldsChanges = null)
+    {
+        $CNF = &$this->_oModule->_oConfig->CNF;
+
+        if (isset($CNF['FIELD_ANONYMOUS']) && isset($this->aInputs[$CNF['FIELD_ANONYMOUS']])) {
+            $aContentInfo = $this->_oModule->_oDb->getContentInfoById($iContentId);
+
+            $aValsToAdd[$CNF['FIELD_OBJECT_ID']] = ($this->getCleanValue($CNF['FIELD_ANONYMOUS']) ? -1 : 1) * abs($aContentInfo[$CNF['FIELD_OBJECT_ID']]);
+        }
+
+        return parent::update($iContentId, $aValsToAdd, $aTrackTextFieldsChanges);
+    }
+
     public function addHtmlEditor($iViewMode, &$aInput)
     {
         $CNF = &$this->_oModule->_oConfig->CNF;

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

@@ -2041,6 +2041,22 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
     }
 
     //--- Check permissions methods ---//
+    public function isModerator()
+    {
+        $sModule = $this->getName();
+        $iUserId = (int)$this->getUserId();
+
+        $aCheckResult = checkActionModule($iUserId, 'edit', $sModule);
+        if($aCheckResult[CHECK_ACTION_RESULT] === CHECK_ACTION_RESULT_ALLOWED)
+            return true;
+
+        $aCheckResult = checkActionModule($iUserId, 'delete', $sModule);
+        if($aCheckResult[CHECK_ACTION_RESULT] === CHECK_ACTION_RESULT_ALLOWED)
+            return true;
+
+        return false;
+    }
+
     public function isAllowedPost($bPerform = false)
     {
         if(isAdmin())
@@ -2085,7 +2101,7 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
 
         $iUserId = (int)$this->getUserId();
         $iOwnerId = (int)$aEvent['owner_id'];
-        $iObjectId = (int)$aEvent['object_id'];
+        $iObjectId = abs((int)$aEvent['object_id']);
         if($iObjectId == $iUserId && $this->_oConfig->isAllowEdit())
            return true;
 
@@ -2108,7 +2124,7 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
 
         $iUserId = (int)$this->getUserId();
         $iOwnerId = (int)$aEvent['owner_id'];
-        $iObjectId = (int)$aEvent['object_id'];
+        $iObjectId = abs((int)$aEvent['object_id']);
         if((($iOwnerId == $iUserId && $this->_oConfig->isAllowDelete()) || ($this->_oConfig->isCommon($aEvent['type'], $aEvent['action']) && $iObjectId == $iUserId)))
            return true;
 
@@ -2556,6 +2572,16 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
         return array($sSystem, $iObjectId, $iCount);
     }
 
+    public function getUserInfo($iUserId = 0)
+    {
+        $iLoggedId = $this->getUserId();
+        $iUserId = (int)$iUserId;
+        if($iUserId < 0  && (abs($iUserId) == $iLoggedId || $this->isModerator()))
+            $iUserId *= -1;
+
+        return parent::getUserInfo($iUserId);
+    }
+
     /**
      * Protected Methods 
      */

+ 19 - 10
modules/boonex/timeline/classes/BxTimelineTemplate.php

@@ -925,6 +925,9 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
         $sJsObject = $this->_oConfig->getJsObject('view');
         $sStylePrefix = $this->_oConfig->getPrefix('style');
 
+        $iUserId = $oModule->getUserId();
+        $bModerator = $oModule->isModerator();
+
         $aEvents = array_reverse($aEvents);
         $iEvents = count($aEvents);
 
@@ -935,7 +938,13 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
                 continue;
 
             $iEventId = $aEvent['id'];
-            $iEventAuthorId = $this->_oConfig->isSystem($aEvent['type'], $aEvent['action']) ? $aEvent['owner_id'] : $aEvent['object_id'];
+            $iEventAuthorId = $this->_oConfig->isSystem($aEvent['type'], $aEvent['action']) ? (int)$aEvent['owner_id'] : (int)$aEvent['object_id'];
+            if($iEventAuthorId < 0) {
+                if(abs($iEventAuthorId) == $iUserId)
+                    continue;
+                else if($bModerator)
+                    $iEventAuthorId *= -1;
+            }
 
             $oAuthor = $oModule->getObjectUser($iEventAuthorId);
             $sAuthorName = $oAuthor->getDisplayName();
@@ -1217,7 +1226,7 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
         $aTmplVarsOwners = array();
         foreach($aOwnerIds as $iOwnerId) {
             $iOwnerId = (int)$iOwnerId;
-            if($iOwnerId == 0 || $iOwnerId == (int)$aEvent['object_owner_id'])
+            if($iOwnerId == 0 || $iOwnerId == (int)abs($aEvent['object_owner_id']))
                 continue;
 
             list($sToName, $sToUrl, $sToThumb, $sToUnit, $sToUnitWoInfo) = $oModule->getUserInfo($iOwnerId);
@@ -1556,17 +1565,17 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
     protected function _getSystemData(&$aEvent, $aBrowseParams = array())
     {
         $mixedResult = $this->_oConfig->getSystemData($aEvent, $aBrowseParams);
-		if($mixedResult === false) {
-    		$sMethod = 'display' . bx_gen_method_name($aEvent['type'] . '_' . $aEvent['action']);
-    		if(method_exists($this, $sMethod))
-    		    $mixedResult = $this->$sMethod($aEvent);
-		}
-		
-		if($mixedResult === false)
+        if($mixedResult === false) {
+            $sMethod = 'display' . bx_gen_method_name($aEvent['type'] . '_' . $aEvent['action']);
+            if(method_exists($this, $sMethod))
+                $mixedResult = $this->$sMethod($aEvent);
+        }
+
+        if($mixedResult === false)
             return '';
 
         $this->_preparetDataActions($aEvent, $mixedResult);
-		return $mixedResult;
+        return $mixedResult;
     }
 
     protected function _getCommonData(&$aEvent, $aBrowseParams = array())

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

@@ -167,7 +167,7 @@ CREATE TABLE IF NOT EXISTS `bx_timeline_comments` (
   `cmt_parent_id` int(11) NOT NULL DEFAULT '0',
   `cmt_vparent_id` int(11) NOT NULL DEFAULT '0',
   `cmt_object_id` int(11) NOT NULL DEFAULT '0',
-  `cmt_author_id` int(10) NOT NULL DEFAULT '0',
+  `cmt_author_id` int(11) NOT NULL DEFAULT '0',
   `cmt_level` int(11) NOT NULL DEFAULT '0',
   `cmt_text` text NOT NULL,
   `cmt_time` int(11) unsigned NOT NULL DEFAULT '0',
@@ -333,6 +333,7 @@ INSERT INTO `sys_form_inputs` (`object`, `module`, `name`, `value`, `values`, `c
 ('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, '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, 'anonymous', '', '', 0, 'switcher', '_sys_form_input_sys_anonymous', '_sys_form_input_anonymous', '', 0, 0, 0, '', '', '', '', '', '', '', '', 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),
 ('bx_timeline_post', @sName, 'location', '', '', 0, 'location', '_sys_form_input_sys_location', '', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0),