Procházet zdrojové kódy

Ticket #3743 - Timeline notes issues: Visibility for guests.

AntonLV před 4 roky
rodič
revize
e74e8a47ba

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

@@ -67,7 +67,8 @@ class BxTimelineMenuItemActions extends BxTemplMenuCustom
             'item-promote' => 'isAllowedPromote',
             'item-promote' => 'isAllowedPromote',
             'item-unpromote' => 'isAllowedUnpromote',
             'item-unpromote' => 'isAllowedUnpromote',
             'item-edit' => 'isAllowedEdit',
             'item-edit' => 'isAllowedEdit',
-            'item-delete' => 'isAllowedDelete'
+            'item-delete' => 'isAllowedDelete',
+            'item-notes' => 'isAllowedNotes',
         );
         );
     }
     }
 
 

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

@@ -3767,14 +3767,10 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
 
 
     public function isModeratorForProfile($iUserId)
     public function isModeratorForProfile($iUserId)
     {
     {
-        $sModule = $this->getName();
-
-        $aCheckResult = checkActionModule($iUserId, 'edit', $sModule);
-        if($aCheckResult[CHECK_ACTION_RESULT] === CHECK_ACTION_RESULT_ALLOWED)
+        if($this->checkAllowedEditAnyEntryForProfile(false, $iUserId) === CHECK_ACTION_RESULT_ALLOWED)
             return true;
             return true;
 
 
-        $aCheckResult = checkActionModule($iUserId, 'delete', $sModule);
-        if($aCheckResult[CHECK_ACTION_RESULT] === CHECK_ACTION_RESULT_ALLOWED)
+        if($this->checkAllowedDeleteAnyEntryForProfile(false, $iUserId) === CHECK_ACTION_RESULT_ALLOWED)
             return true;
             return true;
 
 
         return false;
         return false;
@@ -3841,9 +3837,9 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
 
 
         $aCheckResult = checkActionModule($iUserId, 'edit', $this->getName(), $bPerform);
         $aCheckResult = checkActionModule($iUserId, 'edit', $this->getName(), $bPerform);
         if(!empty($iOwnerId) && ($oProfileOwner = BxDolProfile::getInstance($iOwnerId)) !== false) {
         if(!empty($iOwnerId) && ($oProfileOwner = BxDolProfile::getInstance($iOwnerId)) !== false) {
-            if (BxDolService::call($oProfileOwner->getModule(), 'check_allowed_module_action_in_profile', array($oProfileOwner->getContentId(), $this->getName(), 'edit_any')) === CHECK_ACTION_RESULT_ALLOWED) {
+            if(BxDolService::call($oProfileOwner->getModule(), 'check_allowed_module_action_in_profile', array($oProfileOwner->getContentId(), $this->getName(), 'edit_any')) === CHECK_ACTION_RESULT_ALLOWED)
                 return true;
                 return true;
-            }
+
             bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_edit', $oProfileOwner->id(), $iUserId, array('check_result' => &$aCheckResult));
             bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_edit', $oProfileOwner->id(), $iUserId, array('check_result' => &$aCheckResult));
         }
         }
 
 
@@ -3866,9 +3862,9 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
 
 
         $aCheckResult = checkActionModule($iUserId, 'delete', $this->getName(), $bPerform);
         $aCheckResult = checkActionModule($iUserId, 'delete', $this->getName(), $bPerform);
         if(!empty($iOwnerId) && ($oProfileOwner = BxDolProfile::getInstance($iOwnerId)) !== false) {
         if(!empty($iOwnerId) && ($oProfileOwner = BxDolProfile::getInstance($iOwnerId)) !== false) {
-            if (BxDolService::call($oProfileOwner->getModule(), 'check_allowed_module_action_in_profile', array($oProfileOwner->getContentId(), $this->getName(), 'delete_any')) === CHECK_ACTION_RESULT_ALLOWED) {
+            if(BxDolService::call($oProfileOwner->getModule(), 'check_allowed_module_action_in_profile', array($oProfileOwner->getContentId(), $this->getName(), 'delete_any')) === CHECK_ACTION_RESULT_ALLOWED)
                 return true;
                 return true;
-            }
+
             bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_delete', $oProfileOwner->id(), $iUserId, array('check_result' => &$aCheckResult));
             bx_alert($oProfileOwner->getModule(), $this->_oConfig->getUri() . '_delete', $oProfileOwner->id(), $iUserId, array('check_result' => &$aCheckResult));
         }
         }
 
 
@@ -4129,7 +4125,7 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
     public function isAllowedUnstick($aEvent, $bPerform = false)
     public function isAllowedUnstick($aEvent, $bPerform = false)
     {
     {
     	if((int)$aEvent['sticked'] == 0)
     	if((int)$aEvent['sticked'] == 0)
-    		return false;
+            return false;
     
     
     	return $this->_isAllowedStick($aEvent, $bPerform);
     	return $this->_isAllowedStick($aEvent, $bPerform);
     }
     }
@@ -4137,7 +4133,7 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
     public function isAllowedPromote($aEvent, $bPerform = false)
     public function isAllowedPromote($aEvent, $bPerform = false)
     {
     {
     	if((int)$aEvent['promoted'] != 0)
     	if((int)$aEvent['promoted'] != 0)
-    		return false;
+            return false;
 
 
         return $this->_isAllowedPromote($aEvent, $bPerform);
         return $this->_isAllowedPromote($aEvent, $bPerform);
     }
     }
@@ -4145,11 +4141,16 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
     public function isAllowedUnpromote($aEvent, $bPerform = false)
     public function isAllowedUnpromote($aEvent, $bPerform = false)
     {
     {
     	if((int)$aEvent['promoted'] == 0)
     	if((int)$aEvent['promoted'] == 0)
-    		return false;
+            return false;
 
 
         return $this->_isAllowedPromote($aEvent, $bPerform);
         return $this->_isAllowedPromote($aEvent, $bPerform);
     }
     }
 
 
+    public function isAllowedNotes($aEvent, $bPerform = false)
+    {
+        return $this->isModerator();
+    }
+
     public function isAllowedMore($aEvent, $bPerform = false)
     public function isAllowedMore($aEvent, $bPerform = false)
     {
     {
     	$oMoreMenu = $this->getManageMenuObject();
     	$oMoreMenu = $this->getManageMenuObject();
@@ -4216,7 +4217,19 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
 
 
     	$aCheck = checkActionModule($iProfileId, 'edit', $this->getName(), $isPerformAction);
     	$aCheck = checkActionModule($iProfileId, 'edit', $this->getName(), $isPerformAction);
     	if($aCheck[CHECK_ACTION_RESULT] === CHECK_ACTION_RESULT_ALLOWED)
     	if($aCheck[CHECK_ACTION_RESULT] === CHECK_ACTION_RESULT_ALLOWED)
-    		return CHECK_ACTION_RESULT_ALLOWED;
+            return CHECK_ACTION_RESULT_ALLOWED;
+
+    	return _t('_sys_txt_access_denied');
+    }
+
+    public function checkAllowedDeleteAnyEntryForProfile ($isPerformAction = false, $iProfileId = false)
+    {
+        if(!$iProfileId)
+            $iProfileId = $this->_iProfileId;
+
+    	$aCheck = checkActionModule($iProfileId, 'delete', $this->getName(), $isPerformAction);
+    	if($aCheck[CHECK_ACTION_RESULT] === CHECK_ACTION_RESULT_ALLOWED)
+            return CHECK_ACTION_RESULT_ALLOWED;
 
 
     	return _t('_sys_txt_access_denied');
     	return _t('_sys_txt_access_denied');
     }
     }

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

@@ -158,7 +158,7 @@ INSERT INTO `sys_menu_items`(`set_name`, `module`, `name`, `title_system`, `titl
 ('bx_timeline_menu_item_manage', 'bx_timeline', 'item-promote', '_bx_timeline_menu_item_title_system_item_promote', '_bx_timeline_menu_item_title_item_promote', 'javascript:void(0)', 'javascript:{js_object_view}.promotePost(this, {content_id}, 1)', '_self', 'certificate ', '', 2147483647, 1, 0, 4),
 ('bx_timeline_menu_item_manage', 'bx_timeline', 'item-promote', '_bx_timeline_menu_item_title_system_item_promote', '_bx_timeline_menu_item_title_item_promote', 'javascript:void(0)', 'javascript:{js_object_view}.promotePost(this, {content_id}, 1)', '_self', 'certificate ', '', 2147483647, 1, 0, 4),
 ('bx_timeline_menu_item_manage', 'bx_timeline', 'item-unpromote', '_bx_timeline_menu_item_title_system_item_unpromote', '_bx_timeline_menu_item_title_item_unpromote', 'javascript:void(0)', 'javascript:{js_object_view}.promotePost(this, {content_id}, 0)', '_self', 'certificate', '', 2147483647, 1, 0, 5),
 ('bx_timeline_menu_item_manage', 'bx_timeline', 'item-unpromote', '_bx_timeline_menu_item_title_system_item_unpromote', '_bx_timeline_menu_item_title_item_unpromote', 'javascript:void(0)', 'javascript:{js_object_view}.promotePost(this, {content_id}, 0)', '_self', 'certificate', '', 2147483647, 1, 0, 5),
 ('bx_timeline_menu_item_manage', 'bx_timeline', 'item-report', '_bx_timeline_menu_item_title_system_item_report', '', 'javascript:void(0)', '', '', '', '', 2147483647, 1, 0, 6),
 ('bx_timeline_menu_item_manage', 'bx_timeline', 'item-report', '_bx_timeline_menu_item_title_system_item_report', '', 'javascript:void(0)', '', '', '', '', 2147483647, 1, 0, 6),
-('bx_timeline_menu_item_manage', 'bx_timeline', 'notes', '_sys_menu_item_title_system_va_notes', '_sys_menu_item_title_va_notes', 'javascript:void(0)', 'javascript:bx_get_notes(this,  ''{module_uri}'', {content_id});', '_self', 'exclamation-triangle', '', 2147483647, 1, 0, 7),
+('bx_timeline_menu_item_manage', 'bx_timeline', 'item-notes', '_sys_menu_item_title_system_va_notes', '_sys_menu_item_title_va_notes', 'javascript:void(0)', 'javascript:bx_get_notes(this,  ''{module_uri}'', {content_id});', '_self', 'exclamation-triangle', '', 2147483647, 1, 0, 7),
 ('bx_timeline_menu_item_manage', 'bx_timeline', 'item-mute', '_bx_timeline_menu_item_title_system_item_mute', '_bx_timeline_menu_item_title_item_mute', 'javascript:void(0)', 'javascript:{js_object_view}.muteAuthor(this, {content_id})', '_self', 'user-slash', '', 2147483647, 1, 0, 8),
 ('bx_timeline_menu_item_manage', 'bx_timeline', 'item-mute', '_bx_timeline_menu_item_title_system_item_mute', '_bx_timeline_menu_item_title_item_mute', 'javascript:void(0)', 'javascript:{js_object_view}.muteAuthor(this, {content_id})', '_self', 'user-slash', '', 2147483647, 1, 0, 8),
 ('bx_timeline_menu_item_manage', 'bx_timeline', 'item-edit', '_bx_timeline_menu_item_title_system_item_edit', '_bx_timeline_menu_item_title_item_edit', 'javascript:void(0)', 'javascript:{js_object_view}.editPost(this, {content_id})', '_self', 'pencil-alt', '', 2147483647, 1, 0, 9),
 ('bx_timeline_menu_item_manage', 'bx_timeline', 'item-edit', '_bx_timeline_menu_item_title_system_item_edit', '_bx_timeline_menu_item_title_item_edit', 'javascript:void(0)', 'javascript:{js_object_view}.editPost(this, {content_id})', '_self', 'pencil-alt', '', 2147483647, 1, 0, 9),
 ('bx_timeline_menu_item_manage', 'bx_timeline', 'item-delete', '_bx_timeline_menu_item_title_system_item_delete', '_bx_timeline_menu_item_title_item_delete', 'javascript:void(0)', 'javascript:{js_object_view}.deletePost(this, {content_id})', '_self', 'remove', '', 2147483647, 1, 0, 10);
 ('bx_timeline_menu_item_manage', 'bx_timeline', 'item-delete', '_bx_timeline_menu_item_title_system_item_delete', '_bx_timeline_menu_item_title_item_delete', 'javascript:void(0)', 'javascript:{js_object_view}.deletePost(this, {content_id})', '_self', 'remove', '', 2147483647, 1, 0, 10);