AntonLV 7 年 前
親
コミット
f220746566

+ 10 - 3
modules/base/general/classes/BxBaseModGeneralModule.php

@@ -1156,6 +1156,16 @@ class BxBaseModGeneralModule extends BxDolModule
         );
     }
 
+    public function serviceGetTimelinePostAllowedView($aEvent)
+    {
+        $iContentId = (int)$aEvent['object_id'];
+        $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
+        if(empty($aContentInfo) || !is_array($aContentInfo))
+            return _t('_sys_txt_access_denied');
+
+        return $this->serviceCheckAllowedViewForProfile($aContentInfo);
+    }
+
     /**
      * Check particular action permission without content
      * @param $sAction action to check, for example: Browse, Add
@@ -1225,9 +1235,6 @@ class BxBaseModGeneralModule extends BxDolModule
     // ====== PERMISSION METHODS
     public function serviceCheckAllowedViewForProfile ($aDataEntry, $isPerformAction = false, $iProfileId = false)
     {
-        if(is_numeric($aDataEntry))
-            $aDataEntry = $this->_oDb->getContentInfoById((int)$aDataEntry);
-
         if (!$iProfileId)
             $iProfileId = $this->_iProfileId;
 

+ 1 - 2
modules/base/groups/classes/BxBaseModGroupsModule.php

@@ -561,8 +561,7 @@ class BxBaseModGroupsModule extends BxBaseModProfileModule
 
     public function serviceCheckAllowedViewForProfile ($aDataEntry, $isPerformAction = false, $iProfileId = false)
     {
-        $iContentId = is_numeric($aDataEntry) ? (int)$aDataEntry : $aDataEntry[$this->_oConfig->CNF['FIELD_ID']];
-        if($this->isFan($iContentId, $iProfileId))
+        if ($this->isFan($aDataEntry[$this->_oConfig->CNF['FIELD_ID']], $iProfileId))
             return CHECK_ACTION_RESULT_ALLOWED;
 
         return parent::serviceCheckAllowedViewForProfile ($aDataEntry, $isPerformAction, $iProfileId);

+ 1 - 2
modules/base/profile/classes/BxBaseModProfileModule.php

@@ -1028,8 +1028,7 @@ class BxBaseModProfileModule extends BxBaseModGeneralModule implements iBxDolCon
         if (!$iProfileId)
             $iProfileId = $this->_iProfileId;
 
-        $iContentId = is_numeric($aDataEntry) ? (int)$aDataEntry : $aDataEntry[$this->_oConfig->CNF['FIELD_ID']];
-        $oProfile = BxDolProfile::getInstanceByContentAndType($iContentId, $this->getName());
+        $oProfile = BxDolProfile::getInstanceByContentAndType($aDataEntry[$this->_oConfig->CNF['FIELD_ID']], $this->getName());
         if ($oProfile && $oProfile->id() == $iProfileId)
             return CHECK_ACTION_RESULT_ALLOWED;
 

+ 3 - 3
modules/boonex/channels/classes/BxCnlDb.php

@@ -66,10 +66,10 @@ class BxCnlDb extends BxBaseModGroupsDb
     public function getContentById($iId)
     {
         $CNF = &$this->_oConfig->CNF;
-        $aBindings = array(
+
+        return $this->getRow("SELECT * FROM `" . $CNF['TABLE_CONTENT'] . "` WHERE `id` = :id LIMIT 1", array(
             'id' => $iId
-        );
-        return $this->getFirstRow("SELECT * FROM `" . $CNF['TABLE_CONTENT'] . "` WHERE `id` = :id", $aBindings);
+        ));
     }
     
     public function getDataByContent($iContentId, $sModuleName)

+ 18 - 1
modules/boonex/channels/classes/BxCnlModule.php

@@ -165,7 +165,24 @@ class BxCnlModule extends BxBaseModGroupsModule
             )
         );
     }
-    
+
+    public function serviceGetTimelinePostAllowedView ($aEvent)
+    {
+        $sError = _t('_sys_txt_access_denied');
+
+        if(empty($aEvent) || !is_array($aEvent))
+            return $sError;
+
+        $aEventContent = $this->_oDb->getContentById($aEvent['object_id']);
+        if(empty($aEventContent) || !is_array($aEventContent))
+            return $sError;
+
+        if(!BxDolRequest::serviceExists($aEventContent['module_name'], 'get_timeline_post_allowed_view'))
+            return $sError;
+
+        return BxDolService::call($aEventContent['module_name'], 'get_timeline_post_allowed_view', array(array('id' => $aEvent['id'], 'owner_id' => $aEventContent['author_id'], 'object_id' => $aEventContent['content_id'])));
+    }
+
     public function serviceGetTimelinePostHashtag($aEvent, $aBrowseParams = array())
     {
         if(empty($aEvent) || !is_array($aEvent))

+ 2 - 2
modules/boonex/timeline/classes/BxTimelineTemplate.php

@@ -358,8 +358,8 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
         $aEvent[$sKey] = CHECK_ACTION_RESULT_ALLOWED;
         if(isset($aResult[$sKey], $aResult[$sKey]['module'], $aResult[$sKey]['method']))
             $aEvent[$sKey] = BxDolService::call($aResult[$sKey]['module'], $aResult[$sKey]['method'], array($aEvent));
-        else if(($aHandler = $this->_oConfig->getHandler($aEvent)) !== false && BxDolRequest::serviceExists($aHandler['module_name'], 'check_allowed_view_for_profile'))
-            $aEvent[$sKey] = BxDolService::call($aHandler['module_name'], 'check_allowed_view_for_profile', array($aEvent['object_id']));
+        else if(($aHandler = $this->_oConfig->getHandler($aEvent)) !== false && BxDolRequest::serviceExists($aHandler['module_name'], 'get_timeline_post_allowed_view'))
+            $aEvent[$sKey] = BxDolService::call($aHandler['module_name'], 'get_timeline_post_allowed_view', array($aEvent));
 
         if(isset($aEvent[$sKey]) && $aEvent[$sKey] !== CHECK_ACTION_RESULT_ALLOWED) 
             return '';