AntonLV пре 9 година
родитељ
комит
719593709f

+ 24 - 0
modules/base/general/classes/BxBaseModGeneralSearchResult.php

@@ -48,6 +48,30 @@ class BxBaseModGeneralSearchResult extends BxTemplSearchResult
 
         return parent::rss();
     }
+
+    /**
+     * Add conditions for private content
+     */
+    protected function addConditionsForPrivateContent($CNF, $oProfile, $aCustomGroup = array()) 
+    {
+        if(empty($CNF['OBJECT_PRIVACY_VIEW']))
+            return;
+
+        $oPrivacy = BxDolPrivacy::getObjectInstance($CNF['OBJECT_PRIVACY_VIEW']);
+        if(!$oPrivacy)
+            return;
+
+        $aCondition = $oPrivacy->getContentPublicAsCondition($oProfile ? $oProfile->id() : 0, $aCustomGroup);
+        if(empty($aCondition) || !is_array($aCondition))
+            return;
+
+        if(isset($aCondition['restriction']))
+            $this->aCurrent['restriction'] = array_merge($this->aCurrent['restriction'], $aCondition['restriction']);
+        if(isset($aCondition['join']))
+            $this->aCurrent['join'] = array_merge($this->aCurrent['join'], $aCondition['join']);
+
+        $this->setProcessPrivateContent(false);
+    }
 }
 
 /** @} */

+ 12 - 0
modules/base/groups/classes/BxBaseModGroupsSearchResult.php

@@ -16,6 +16,18 @@ class BxBaseModGroupsSearchResult extends BxBaseModProfileSearchResult
         parent::__construct($sMode, $aParams);
     }
 
+    protected function addConditionsForPrivateContent($CNF, $oProfile, $aCustomGroup = array()) 
+    {
+        if(empty($CNF['OBJECT_PRIVACY_VIEW']))
+            return;
+
+        $oPrivacy = BxDolPrivacy::getObjectInstance($CNF['OBJECT_PRIVACY_VIEW']);
+        if(!$oPrivacy)
+            return;
+
+        parent::addConditionsForPrivateContent($CNF, $oProfile, array_merge($aCustomGroup, $oPrivacy->getPartiallyVisiblePrivacyGroups()));
+    }
+
     protected function _setAuthorConditions($sMode, $aParams, &$oProfileAuthor)
     {
         $CNF = &$this->oModule->_oConfig->CNF;

+ 12 - 10
modules/base/profile/classes/BxBaseModProfileTemplate.php

@@ -43,13 +43,21 @@ class BxBaseModProfileTemplate extends BxBaseModGeneralTemplate
 
         $oModule = $this->getModule();
 
-        $bPublic = true; 
-        if(!empty($CNF['OBJECT_PRIVACY_VIEW'])) {
+        $bPublic = true;
+        if($isCheckPrivateContent && !empty($CNF['OBJECT_PRIVACY_VIEW'])) {
             $oPrivacy = BxDolPrivacy::getObjectInstance($CNF['OBJECT_PRIVACY_VIEW']);
             if ($oPrivacy && !$oPrivacy->check($aData[$CNF['FIELD_ID']]) && !$oPrivacy->isPartiallyVisible($aData[$CNF['FIELD_ALLOW_VIEW_TO']]))
                 $bPublic = false;
         }
 
+        $bPublicThumb = true;
+        if($isCheckPrivateContent && $oModule->checkAllowedViewProfileImage($aData) !== CHECK_ACTION_RESULT_ALLOWED)
+            $bPublicThumb = false;
+
+        $bPublicCover = true;
+        if($isCheckPrivateContent && $oModule->checkAllowedViewCoverImage($aData) !== CHECK_ACTION_RESULT_ALLOWED)
+            $bPublicCover = false;
+
         //$aVars = parent::unitVars ($aData, $isCheckPrivateContent, $sTemplateName);
 
         $oProfile = BxDolProfile::getInstanceByContentAndType($aData[$CNF['FIELD_ID']], $this->MODULE);
@@ -66,18 +74,12 @@ class BxBaseModProfileTemplate extends BxBaseModGeneralTemplate
         $oConn = BxDolConnection::getObjectInstance($sConnectionsObject);
         $aConnectionTitles = $oModule->serviceGetConnectionButtonsTitles($iProfile, $sConnectionsObject);
 
-        $sThumbUrl = '';
-        if($oModule->checkAllowedViewProfileImage($aData) === CHECK_ACTION_RESULT_ALLOWED)
-            $sThumbUrl = $this->thumb($aData, false);
+        $sThumbUrl = $bPublicThumb ? $this->thumb($aData, false) : '';
         $bThumbUrl = !empty($sThumbUrl);
-        
-        $sCoverUrl = '';
-        if($oModule->checkAllowedViewCoverImage($aData) === CHECK_ACTION_RESULT_ALLOWED)
-            $sCoverUrl = $this->urlCoverUnit($aData, false);
 
+        $sCoverUrl = $bPublicCover ? $this->urlCoverUnit($aData, false) : '';
         if(empty($sCoverUrl) && ($iCoverId = (int)getParam('sys_unit_cover_profile')) != 0)
             $sCoverUrl = BxDolTranscoder::getObjectInstance(BX_DOL_TRANSCODER_OBJ_COVER_UNIT_PROFILE)->getFileUrlById($iCoverId);
-
         if(empty($sCoverUrl))
             $sCoverUrl = $this->getImageUrl('cover.jpg');
 

+ 0 - 13
modules/base/text/classes/BxBaseModTextSearchResult.php

@@ -43,19 +43,6 @@ class BxBaseModTextSearchResult extends BxBaseModGeneralSearchResult
         $this->aCurrent['title'] = $this->_replaceMarkers($this->aCurrent['title']);
     }
 
-    protected function addConditionsForPrivateContent($CNF, $oProfileAuthor) 
-    {
-        // add conditions for private content
-        $oPrivacy = BxDolPrivacy::getObjectInstance($CNF['OBJECT_PRIVACY_VIEW']);
-        $a = $oPrivacy ? $oPrivacy->getContentPublicAsCondition($oProfileAuthor ? $oProfileAuthor->id() : 0) : array();
-        if (isset($a['restriction']))
-            $this->aCurrent['restriction'] = array_merge($this->aCurrent['restriction'], $a['restriction']);
-        if (isset($a['join']))
-            $this->aCurrent['join'] = array_merge($this->aCurrent['join'], $a['join']);
-
-        $this->setProcessPrivateContent(false);
-    }
-
     protected function getCurrentOnclick($aAdditionalParams = array(), $bReplacePagesParams = true) 
     {
         // always add UnitView as additional param

+ 0 - 13
modules/boonex/events/classes/BxEventsSearchResult.php

@@ -167,19 +167,6 @@ class BxEventsSearchResult extends BxBaseModGroupsSearchResult
         $this->sCenterContentUnitSelector = false;
     }
 
-    protected function addConditionsForPrivateContent($CNF, $oJoinedProfile) 
-    {
-        // add conditions for private content
-        $oPrivacy = BxDolPrivacy::getObjectInstance($CNF['OBJECT_PRIVACY_VIEW']);
-        $a = $oPrivacy ? $oPrivacy->getContentPublicAsCondition($oJoinedProfile ? $oJoinedProfile->id() : 0, $oPrivacy->getPartiallyVisiblePrivacyGroups()) : array();
-        if (isset($a['restriction']))
-            $this->aCurrent['restriction'] = array_merge($this->aCurrent['restriction'], $a['restriction']);
-        if (isset($a['join']))
-            $this->aCurrent['join'] = array_merge($this->aCurrent['join'], $a['join']);
-
-        $this->setProcessPrivateContent(false);
-    }
-
     function getAlterOrder()
     {
         switch ($this->aCurrent['sorting']) {

+ 0 - 13
modules/boonex/groups/classes/BxGroupsSearchResult.php

@@ -167,19 +167,6 @@ class BxGroupsSearchResult extends BxBaseModGroupsSearchResult
         $this->sCenterContentUnitSelector = false;
     }
 
-    protected function addConditionsForPrivateContent($CNF, $oJoinedProfile) 
-    {
-        // add conditions for private content
-        $oPrivacy = BxDolPrivacy::getObjectInstance($CNF['OBJECT_PRIVACY_VIEW']);
-        $a = $oPrivacy ? $oPrivacy->getContentPublicAsCondition($oJoinedProfile ? $oJoinedProfile->id() : 0, $oPrivacy->getPartiallyVisiblePrivacyGroups()) : array();
-        if (isset($a['restriction']))
-            $this->aCurrent['restriction'] = array_merge($this->aCurrent['restriction'], $a['restriction']);
-        if (isset($a['join']))
-            $this->aCurrent['join'] = array_merge($this->aCurrent['join'], $a['join']);
-
-        $this->setProcessPrivateContent(false);
-    }
-
     function getAlterOrder()
     {
         switch ($this->aCurrent['sorting']) {

+ 7 - 0
modules/boonex/organizations/classes/BxOrgsSearchResult.php

@@ -73,6 +73,9 @@ class BxOrgsSearchResult extends BxBaseModGroupsSearchResult
         $this->oModule = $this->getMain();
         $this->aCurrent['searchFields'] = explode(',', getParam($this->oModule->_oConfig->CNF['PARAM_SEARCHABLE_FIELDS']));
 
+        $oJoinedProfile = null;
+        $bProcessConditionsForPrivateContent = true;
+
         $CNF = &$this->oModule->_oConfig->CNF;
 
         switch ($sMode) {
@@ -103,6 +106,7 @@ class BxOrgsSearchResult extends BxBaseModGroupsSearchResult
 
             case 'connections':
                 if ($this->_setConnectionsConditions($aParams)) {
+                    $bProcessConditionsForPrivateContent = false;
                     $oProfile = BxDolProfile::getInstance($aParams['profile']);
                     $oProfile2 = isset($aParams['profile2']) ? BxDolProfile::getInstance($aParams['profile2']) : null;
 
@@ -180,6 +184,9 @@ class BxOrgsSearchResult extends BxBaseModGroupsSearchResult
                 $this->isError = true;
         }
 
+        if ($bProcessConditionsForPrivateContent)
+            $this->addConditionsForPrivateContent($CNF, $oJoinedProfile);
+
         $this->sCenterContentUnitSelector = false;
     }