Przeglądaj źródła

Ticket #4630 - Content filter issues. Point 2.

AntonLV 2 lat temu
rodzic
commit
36cd353561

+ 3 - 1
inc/classes/BxDolContentFilter.php

@@ -167,8 +167,10 @@ class BxDolContentFilter extends BxDolFactory implements iBxDolSingleton
 
         $iCfwValue = $iCfDefault;
         $aViewerInfo = BxDolProfileQuery::getInstance()->getInfoById($iViewerId);
-        if(!empty($aViewerInfo) && is_array($aViewerInfo))
+        if(is_array($aViewerInfo) && isset($aViewerInfo['cfw_value']))
             $iCfwValue = $aViewerInfo['cfw_value'];
+        else
+            $iCfwValue = $this->getDefaultValueUnauthenticated();
 
         return (1 << ($iValue - 1)) & $iCfwValue;
     }

+ 15 - 0
inc/classes/BxDolPage.php

@@ -772,11 +772,26 @@ class BxDolPage extends BxDolFactory implements iBxDolFactoryObject, iBxDolRepla
         return true;
     }
 
+    public function isAvailablePage ()
+    {
+        return $this->_isAvailablePage($this->_aObject);
+    }
+
     public function isVisiblePage ()
     {
         return $this->_isVisiblePage($this->_aObject);
     }
 
+    /**
+     * Check if page can be seen by viewer.
+     * @param array $a - page object.
+     * @return type boolean (true or false).
+     */
+    public function isPage()
+    {
+        return $this->_isAvailablePage($this->_aObject) === true && $this->_isVisiblePage($this->_aObject) === true;
+    }
+
     public function isVisiblePageSubmenu ()
     {
         return $this->_aObject['submenu'] != 'disabled';

+ 22 - 17
modules/base/text/classes/BxBaseModTextPageEntry.php

@@ -24,23 +24,8 @@ class BxBaseModTextPageEntry extends BxBaseModGeneralPageEntry
 
         $CNF = &$this->_oModule->_oConfig->CNF;
 
-        $iContentId = bx_process_input(bx_get('id'), BX_DATA_INT);
-        if ($iContentId)
-            $this->_aContentInfo = $this->_oModule->_oDb->getContentInfoById($iContentId);
-
-        $iProfileId = bx_get_logged_profile_id();
-
-        $this->_bLoggedOwner = isset($this->_aContentInfo[$CNF['FIELD_AUTHOR']]) && $this->_aContentInfo[$CNF['FIELD_AUTHOR']] == $iProfileId;
-        $this->_bLoggedModerator = $this->_oModule->checkAllowedEditAnyEntry() === CHECK_ACTION_RESULT_ALLOWED;
-        $this->_bLoggedContextModerator = false;
-        if($this->_aContentInfo && !empty($CNF['FIELD_ALLOW_VIEW_TO']) && (int)$this->_aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']] < 0) {
-            $iContextProfileId = abs((int)$this->_aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']]);
-            if(($oContextProfile = BxDolProfile::getInstance($iContextProfileId)) !== false) {
-                $aAdmins = bx_srv($oContextProfile->getModule(), 'get_admins_to_manage_content', [$iContextProfileId]);
-                if(!empty($aAdmins) && in_array($iProfileId, $aAdmins))
-                    $this->_bLoggedContextModerator = true;
-            }
-        }
+        if(($iContentId = bx_get('id')) !== false)
+            $this->setContentId(bx_process_input($iContentId, BX_DATA_INT));
 
         $sTitle = $sUrl = $sIcon = "";
         if ($this->_aContentInfo && CHECK_ACTION_RESULT_ALLOWED === $this->_oModule->checkAllowedView($this->_aContentInfo)) {
@@ -105,6 +90,26 @@ class BxBaseModTextPageEntry extends BxBaseModGeneralPageEntry
         }
     }
 
+    public function setContentId($iId)
+    {
+        $CNF = &$this->_oModule->_oConfig->CNF;
+        $iProfileId = bx_get_logged_profile_id();
+
+        $this->_aContentInfo = $this->_oModule->_oDb->getContentInfoById($iId);
+
+        $this->_bLoggedOwner = isset($this->_aContentInfo[$CNF['FIELD_AUTHOR']]) && $this->_aContentInfo[$CNF['FIELD_AUTHOR']] == $iProfileId;
+        $this->_bLoggedModerator = $this->_oModule->checkAllowedEditAnyEntry() === CHECK_ACTION_RESULT_ALLOWED;
+        $this->_bLoggedContextModerator = false;
+        if($this->_aContentInfo && !empty($CNF['FIELD_ALLOW_VIEW_TO']) && (int)$this->_aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']] < 0) {
+            $iContextProfileId = abs((int)$this->_aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']]);
+            if(($oContextProfile = BxDolProfile::getInstance($iContextProfileId)) !== false) {
+                $aAdmins = bx_srv($oContextProfile->getModule(), 'get_admins_to_manage_content', [$iContextProfileId]);
+                if(!empty($aAdmins) && in_array($iProfileId, $aAdmins))
+                    $this->_bLoggedContextModerator = true;
+            }
+        }
+    }
+
     public function getCode ()
     {
         $mixedResult = parent::getCode();

+ 5 - 1
modules/boonex/albums/classes/BxAlbumsPageMedia.php

@@ -58,7 +58,11 @@ class BxAlbumsPageMedia extends BxTemplPage
 
     public function isAlbumActive()
     {
-        return $this->_oModule->isEntryActive($this->_aAlbumInfo);
+        $CNF = &$this->_oModule->_oConfig->CNF;
+
+        $oPageEntry = BxDolPage::getObjectInstance($this->MODULE . '_view_entry');
+        $oPageEntry->setContentId($this->_aAlbumInfo[$CNF['FIELD_ID']]);
+        return $oPageEntry->isPage();
     }
 
     public function getCode ()