Преглед изворни кода

Ticket #5143 - Contexts: Browse joined entries posted in a context.

AntonLV пре 1 година
родитељ
комит
71554eac5e

+ 1 - 1
inc/classes/BxDolSearch.php

@@ -598,7 +598,7 @@ class BxDolSearchResult implements iBxDolReplaceable
             'type' => $this->_sMode,
         ];
 
-        foreach(['author', 'category', 'context', 'followed_contexts'] as $sParamAdd)
+        foreach(['author', 'category', 'context', 'joined_profile', 'followed_contexts'] as $sParamAdd)
             if(isset($this->_aParams[$sParamAdd]))
                 $aParams[$sParamAdd] = $this->_aParams[$sParamAdd];
 

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

@@ -1002,7 +1002,37 @@ class BxBaseModGroupsModule extends BxBaseModProfileModule
 
         return $this->_serviceBrowse ('joined_entries', array('joined_profile' => $iProfileId), BX_DB_PADDING_DEF, $bDisplayEmptyMsg);
     }
-    
+
+    /**
+     * Display entries posted into particular context and joined by profile
+     */
+    public function serviceBrowseContextJoinedEntries ($iContextPid = 0, $iProfileId = 0, $aParams = [])
+    {
+        if(!$iContextPid)
+            $iContextPid = bx_process_input(bx_get('profile_id'), BX_DATA_INT);
+        if(!$iContextPid)
+            return $this->_bIsApi ? [] : '';
+
+        if(!$iProfileId)
+            $iProfileId = bx_get_logged_profile_id();
+        if(!$iProfileId)
+            return $this->_bIsApi ? [] : '';
+
+        $bEmptyMessage = true;
+        if(isset($aParams['empty_message'])) {
+            $bEmptyMessage = (bool)$aParams['empty_message'];
+            unset($aParams['empty_message']);
+        }
+
+        $bAjaxPaginate = true;
+        if(isset($aParams['ajax_paginate'])) {
+            $bAjaxPaginate = (bool)$aParams['ajax_paginate'];
+            unset($aParams['ajax_paginate']);
+        }
+
+        return $this->_serviceBrowse ('context_joined_entries', ['context' => $iContextPid, 'joined_profile' => $iProfileId], BX_DB_PADDING_DEF, $bEmptyMessage, $bAjaxPaginate);
+    }
+
     public function serviceBrowseFollowedEntries ($iProfileId = 0, $bDisplayEmptyMsg = false)
     {
         if (!$iProfileId)

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

@@ -161,6 +161,33 @@ class BxBaseModGroupsSearchResult extends BxBaseModProfileSearchResult
         return true;
     }
 
+    protected function _updateCurrentForJoinedEntries($sMode, $aParams, &$oJoinedProfile)
+    {
+        $CNF = &$this->oModule->_oConfig->CNF;
+
+        $oJoinedProfile = BxDolProfile::getInstance((int)$aParams['joined_profile']);
+        if (!$oJoinedProfile)
+            return false;
+
+        $bProcessConditionsForPrivateContent = false;
+
+        $this->aCurrent['join']['fans'] = array(
+            'type' => 'INNER',
+            'table' => 'bx_groups_fans',
+            'mainField' => 'id',
+            'onField' => 'content',
+            'joinFields' => array('initiator'),
+        );
+
+        $this->aCurrent['restriction']['fans'] = array('value' => $oJoinedProfile->id(), 'field' => 'initiator', 'operator' => '=', 'table' => 'bx_groups_fans');
+
+        $this->sBrowseUrl = 'page.php?i=' . $CNF['URI_JOINED_ENTRIES'] . '&profile_id={profile_id}';
+        $this->aCurrent['title'] = ($sKey = 'txt_joined_entries') && !empty($CNF['T'][$sKey]) ? _t($CNF['T'][$sKey]) : '';
+        $this->aCurrent['rss']['link'] = 'modules/?r=groups/rss/' . $sMode . '/' . $oJoinedProfile->id();
+
+        return true;
+    }
+
     protected function _updateCurrentForContext($sMode, $aParams, &$oProfileContext)
     {
         $CNF = &$this->oModule->_oConfig->CNF;

+ 17 - 19
modules/boonex/groups/classes/BxGroupsSearchResult.php

@@ -91,30 +91,28 @@ class BxGroupsSearchResult extends BxBaseModGroupsSearchResult
                 break;
 
             case 'joined_entries':
-                $oJoinedProfile = BxDolProfile::getInstance((int)$aParams['joined_profile']);
-                if (!$oJoinedProfile) {
+                $oJoinedProfile = null;
+                if(!$this->_updateCurrentForJoinedEntries($sMode, $aParams, $oJoinedProfile))
                     $this->isError = true;
-                    break;
-                }
-
-                $bProcessConditionsForPrivateContent = false;
 
-                $this->aCurrent['join']['fans'] = array(
-                    'type' => 'INNER',
-                    'table' => 'bx_groups_fans',
-                    'mainField' => 'id',
-                    'onField' => 'content',
-                    'joinFields' => array('initiator'),
-                );
+                if(!$this->aCurrent['title'])
+                    $this->aCurrent['title'] = _t('_bx_groups_page_title_joined_entries');
+                break;
 
-                $this->aCurrent['restriction']['fans'] = array('value' => $oJoinedProfile->id(), 'field' => 'initiator', 'operator' => '=', 'table' => 'bx_groups_fans');
+            case 'context_joined_entries':
+                $oProfileContext = null;
+                if(!$this->_updateCurrentForContext('context', $aParams, $oProfileContext))
+                    $this->isError = true;
+                
+                $oJoinedProfile = null;
+                if(!$this->_updateCurrentForJoinedEntries('joined_entries', $aParams, $oJoinedProfile))
+                    $this->isError = true;
 
-                $this->sBrowseUrl = 'page.php?i=' . $CNF['URI_JOINED_ENTRIES'] . '&profile_id={profile_id}';
-                $this->aCurrent['title'] = _t('_bx_groups_page_title_joined_entries');
-                $this->aCurrent['rss']['link'] = 'modules/?r=groups/rss/' . $sMode . '/' . $oJoinedProfile->id();
+                $this->sBrowseUrl = '';
+                $this->aCurrent['title'] = '';
+                unset($this->aCurrent['rss']);
                 break;
-                
-                
+
             case 'followed_entries':
                 $oJoinedProfile = BxDolProfile::getInstance((int)$aParams['followed_profile']);
                 if (!$oJoinedProfile) {