AntonLV 5 tahun lalu
induk
melakukan
ebcd87e828

+ 27 - 55
modules/boonex/timeline/classes/BxTimelineMenuItemActions.php

@@ -33,6 +33,8 @@ class BxTimelineMenuItemActions extends BxTemplMenuCustom
 
 
     protected $_sTmplNameItem;
     protected $_sTmplNameItem;
 
 
+    protected $_aItem2CheckFunc;
+
     public function __construct($aObject, $oTemplate = false)
     public function __construct($aObject, $oTemplate = false)
     {
     {
         $this->_sModule = 'bx_timeline';
         $this->_sModule = 'bx_timeline';
@@ -48,6 +50,25 @@ class BxTimelineMenuItemActions extends BxTemplMenuCustom
         $this->_bShowCountersEmpty = false;
         $this->_bShowCountersEmpty = false;
         $this->_bShowCountersIcons = true;
         $this->_bShowCountersIcons = true;
         $this->_sTmplNameItem = 'menu_custom_item_hor.html';
         $this->_sTmplNameItem = 'menu_custom_item_hor.html';
+
+        $this->_aItem2CheckFunc = array(
+            'item-view' => 'isAllowedViewCounter',
+            'item-comment' => 'isAllowedComment',
+            'item-vote' => 'isAllowedVote',
+            'item-reaction' => 'isAllowedReaction',
+            'item-score' => 'isAllowedScore',
+            'item-report' => 'isAllowedReport',
+            'item-mute' => 'isAllowedMute',
+            'item-more' => 'isAllowedMore',
+            'item-pin' => 'isAllowedPin',
+            'item-unpin' => 'isAllowedUnpin',
+            'item-stick' => 'isAllowedStick',
+            'item-unstick' => 'isAllowedUnstick',
+            'item-promote' => 'isAllowedPromote',
+            'item-unpromote' => 'isAllowedUnpromote',
+            'item-edit' => 'isAllowedEdit',
+            'item-delete' => 'isAllowedDelete'
+        );
     }
     }
 
 
     public function setEvent($aEvent, $aBrowseParams = array())
     public function setEvent($aEvent, $aBrowseParams = array())
@@ -296,80 +317,31 @@ class BxTimelineMenuItemActions extends BxTemplMenuCustom
         $sCheckFuncName = '';
         $sCheckFuncName = '';
         $aCheckFuncParams = array($this->_aEvent);
         $aCheckFuncParams = array($this->_aEvent);
         switch ($a['name']) {
         switch ($a['name']) {
-            case 'item-view':
-                $sCheckFuncName = 'isAllowedViewCounter';
-                break;
-
             case 'item-comment':
             case 'item-comment':
                 if($this->_sView == BX_TIMELINE_VIEW_ITEM)
                 if($this->_sView == BX_TIMELINE_VIEW_ITEM)
                     return false;
                     return false;
 
 
-                $sCheckFuncName = 'isAllowedComment';
-                break;
-
-            case 'item-vote':
-                $sCheckFuncName = 'isAllowedVote';
-                break;
-            
-            case 'item-reaction':
-                $sCheckFuncName = 'isAllowedReaction';
-                break;
-
-            case 'item-score':
-                $sCheckFuncName = 'isAllowedScore';
-                break;
-
-            case 'item-report':
-                $sCheckFuncName = 'isAllowedReport';
-                break;
-
-            case 'item-mute':
-                $sCheckFuncName = 'isAllowedMute';
+                $sCheckFuncName = $this->_aItem2CheckFunc[$a['name']];
                 break;
                 break;
 
 
-            case 'item-more':
-            	$sCheckFuncName = 'isAllowedMore';
-            	break;
-
             case 'item-pin':
             case 'item-pin':
                 if($this->_sType != BX_BASE_MOD_NTFS_TYPE_OWNER)
                 if($this->_sType != BX_BASE_MOD_NTFS_TYPE_OWNER)
                     return false;
                     return false;
 
 
-                $sCheckFuncName = 'isAllowedPin';
+                $sCheckFuncName = $this->_aItem2CheckFunc[$a['name']];
                 break;
                 break;
 
 
             case 'item-unpin':
             case 'item-unpin':
                 if($this->_sType != BX_BASE_MOD_NTFS_TYPE_OWNER)
                 if($this->_sType != BX_BASE_MOD_NTFS_TYPE_OWNER)
                     return false;
                     return false;
 
 
-                $sCheckFuncName = 'isAllowedUnpin';
-                break;
-
-            case 'item-stick':
-                $sCheckFuncName = 'isAllowedStick';
-                break;
-
-            case 'item-unstick':
-                $sCheckFuncName = 'isAllowedUnstick';
-                break;
-
-            case 'item-promote':
-                $sCheckFuncName = 'isAllowedPromote';
-                break;
-
-            case 'item-unpromote':
-                $sCheckFuncName = 'isAllowedUnpromote';
-                break;
-
-            case 'item-edit':
-                $sCheckFuncName = 'isAllowedEdit';
-                break;
-
-            case 'item-delete':
-                $sCheckFuncName = 'isAllowedDelete';
+                $sCheckFuncName = $this->_aItem2CheckFunc[$a['name']];
                 break;
                 break;
         }
         }
 
 
+        if(empty($sCheckFuncName) && isset($this->_aItem2CheckFunc[$a['name']]))
+            $sCheckFuncName = $this->_aItem2CheckFunc[$a['name']];
+
         if(!$sCheckFuncName || !method_exists($this->_oModule, $sCheckFuncName))
         if(!$sCheckFuncName || !method_exists($this->_oModule, $sCheckFuncName))
             return true;
             return true;
 
 

+ 5 - 0
modules/boonex/timeline/classes/BxTimelineMenuItemCounters.php

@@ -22,6 +22,11 @@ class BxTimelineMenuItemCounters extends BxTimelineMenuItemActions
 
 
         $this->_sMode = self::$_sModeCounters;
         $this->_sMode = self::$_sModeCounters;
         $this->_bShowCounters = true;
         $this->_bShowCounters = true;
+
+        $this->_aItem2CheckFunc = array_merge($this->_aItem2CheckFunc, array(
+            'item-vote' => 'isAllowedVoteView',
+            'item-reaction' => 'isAllowedReactionView',
+        ));
     }
     }
 
 
     protected function _getMenuItemItemComment($aItem)
     protected function _getMenuItemItemComment($aItem)

+ 39 - 1
modules/boonex/timeline/classes/BxTimelineModule.php

@@ -3321,7 +3321,7 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
         $oVote = $this->getVoteObject($sSystem, $iObjectId);
         $oVote = $this->getVoteObject($sSystem, $iObjectId);
 
 
         if(!$oVote->isAllowedVote($bPerform))
         if(!$oVote->isAllowedVote($bPerform))
-        	return false;
+            return false;
 
 
         $bResult = true;
         $bResult = true;
         if(!empty($aEvent['owner_id']) && ($oProfileOwner = BxDolProfile::getInstance($aEvent['owner_id'])) !== false)
         if(!empty($aEvent['owner_id']) && ($oProfileOwner = BxDolProfile::getInstance($aEvent['owner_id'])) !== false)
@@ -3329,6 +3329,25 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
 
 
         return $bResult;
         return $bResult;
     }
     }
+    
+    public function isAllowedVoteView($aEvent, $bPerform = false)
+    {
+        $mixedVotes = $this->getVotesData($aEvent['votes']);
+        if($mixedVotes === false)
+            return false;
+
+        list($sSystem, $iObjectId) = $mixedVotes;
+        $oVote = $this->getVoteObject($sSystem, $iObjectId);
+
+        if(!$oVote->isAllowedVoteView($bPerform))
+            return false;
+
+        $bResult = true;
+        if(!empty($aEvent['owner_id']) && ($oProfileOwner = BxDolProfile::getInstance($aEvent['owner_id'])) !== false)
+            bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_vote_view', $oProfileOwner->id(), (int)$this->getUserId(), array('result' => &$bResult));
+
+        return $bResult;
+    }
 
 
     public function isAllowedReaction($aEvent, $bPerform = false)
     public function isAllowedReaction($aEvent, $bPerform = false)
     {
     {
@@ -3349,6 +3368,25 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
         return $bResult;
         return $bResult;
     }
     }
 
 
+    public function isAllowedReactionView($aEvent, $bPerform = false)
+    {
+        $mixedReactions = $this->getReactionsData($aEvent['reactions']);
+        if($mixedReactions === false)
+            return false;
+
+        list($sSystem, $iObjectId) = $mixedReactions;
+        $oReaction = $this->getReactionObject($sSystem, $iObjectId);
+
+        if(!$oReaction->isAllowedVoteView($bPerform))
+            return false;
+
+        $bResult = true;
+        if(!empty($aEvent['owner_id']) && ($oProfileOwner = BxDolProfile::getInstance($aEvent['owner_id'])) !== false)
+            bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_reaction_view', $oProfileOwner->id(), (int)$this->getUserId(), array('result' => &$bResult));
+
+        return $bResult;
+    }
+
     public function isAllowedScore($aEvent, $bPerform = false)
     public function isAllowedScore($aEvent, $bPerform = false)
     {
     {
         $mixedScores = $this->getScoresData($aEvent['scores']);
         $mixedScores = $this->getScoresData($aEvent['scores']);