Explorar o código

#2713 Privacy control improvements

RomanL %!s(int64=6) %!d(string=hai) anos
pai
achega
25c1098b34

+ 12 - 0
inc/classes/BxDolConnection.php

@@ -391,6 +391,18 @@ class BxDolConnection extends BxDolFactory implements iBxDolFactoryObject
     {
         return $this->_oQuery->getConnectedContent($iInitiator, $isMutual, $iStart, $iLimit, $iOrder);
     }
+    
+    /**
+     * Get connected content IDs for specified type
+     * @param $iInitiator initiator of the connection
+     * @param $sType type of content
+     * @param $isMutual get mutual connections only
+     * @return array of available connections
+     */
+    public function getConnectedContentByType ($iInitiator, $sType, $isMutual = false, $iStart = 0, $iLimit = BX_CONNECTIONS_LIST_LIMIT, $iOrder = BX_CONNECTIONS_ORDER_NONE)
+    {
+        return $this->_oQuery->getConnectedContentByType($iInitiator, $sType, $isMutual, $iStart, $iLimit, $iOrder);
+    }
 
     /**
      * Get connected initiators IDs

+ 11 - 0
inc/classes/BxDolConnectionQuery.php

@@ -155,6 +155,17 @@ class BxDolConnectionQuery extends BxDolDb
         	'initiator' => $iInitiator
         ));
     }
+    
+    public function getConnectedContentByType ($iInitiator, $sType, $isMutual = false, $iStart = 0, $iLimit = BX_CONNECTIONS_LIST_LIMIT, $iOrder = BX_CONNECTIONS_ORDER_NONE)
+    {
+        $sWhere = " AND `c`.`initiator` = :initiator";
+        $sQuery = $this->_getConnectionsQuery($sWhere, 'INNER JOIN `sys_profiles` `p` ON `p`.`id` = `c`.`content` AND `p`.`type` = :type', '`c`.`content`', $isMutual, $iStart, $iLimit, $iOrder);
+       
+        return $this->getColumn($sQuery, array(
+        	'initiator' => $iInitiator,
+            'type' => $sType
+        ));
+    }
 
     public function getConnectedInitiators ($iContent, $isMutual = false, $iStart = 0, $iLimit = BX_CONNECTIONS_LIST_LIMIT, $iOrder = BX_CONNECTIONS_ORDER_NONE)
     {

+ 3 - 5
modules/base/profile/classes/BxBaseModProfileModule.php

@@ -488,18 +488,16 @@ class BxBaseModProfileModule extends BxBaseModGeneralModule implements iBxDolCon
                 continue;
 
             if (BX_CONNECTIONS_TYPE_MUTUAL == $o->getType())
-                $a = array_merge($a, $o->getConnectedContent($iProfileId, true));
+                $a = array_merge($a, $o->getConnectedContentByType($iProfileId, $this->getName(), true));
             else
-                $a = array_merge($a, $o->getConnectedContent($iProfileId));
+                $a = array_merge($a, $o->getConnectedContentByType($iProfileId, $this->getName()));
         }
-
+        echo  $this->getName().'xxx';
         $a = array_unique($a);
         $aRet = array();
         foreach ($a as $iConnectedProfileId) {
             if (!($oConnectedProfile = BxDolProfile::getInstance($iConnectedProfileId)))
                 continue;
-            if ($oConnectedProfile->getModule() != $this->getName())
-                continue;
 
             if (CHECK_ACTION_RESULT_ALLOWED === bx_srv($oConnectedProfile->getModule(), 'check_allowed_post_in_profile', array($oConnectedProfile->getContentId(), $iProfileId)))
                 $aRet[] = $iConnectedProfileId;