1
0
AntonLV 8 жил өмнө
parent
commit
e61448b4c0

+ 6 - 0
inc/classes/BxDolConnection.php

@@ -12,6 +12,12 @@
  */
 define('BX_CONNECTIONS_LIST_LIMIT', 1000);
 
+/**
+ * No limit for connections lists. 
+ * Is needed for Total Number calculation.
+ */
+define('BX_CONNECTIONS_LIST_NO_LIMIT', -1);
+
 /**
  * Connections order: no order
  */

+ 5 - 1
inc/classes/BxDolConnectionQuery.php

@@ -166,7 +166,11 @@ class BxDolConnectionQuery extends BxDolDb
 
         $sWhere .= (false !== $isMutual) ? $this->prepareAsString(" AND `c`.`mutual` = ?", $isMutual) : '';
 
-        return $this->prepareAsString("SELECT $sFields FROM `" . $this->_sTable . "` AS `c` $sJoin WHERE 1 $sWhere $sOrder LIMIT ?, ?", $iStart, $iLimit);
+        $sLimit = "";
+        if($iLimit != BX_CONNECTIONS_LIST_NO_LIMIT)
+            $sLimit = $this->prepareAsString("LIMIT ?, ?", $iStart, $iLimit);
+
+        return "SELECT $sFields FROM `" . $this->_sTable . "` AS `c` $sJoin WHERE 1 $sWhere $sOrder $sLimit";
     }
 
     public function getConnectedContentCount ($iInitiator, $isMutual = false)

+ 4 - 4
template/scripts/BxBaseServiceConnections.php

@@ -99,7 +99,7 @@ class BxBaseServiceConnections extends BxDol
      * @param $mixedId id to get connections for, if omitted then logged-in profile id is used
      * @return number
      */
-    public function serviceGetConnectedContentNum ($sConnectionsObject, $mixedId = 0)
+    public function serviceGetConnectedContentNum ($sConnectionsObject, $mixedId = 0, $isMutual = false)
     {
         $oConnection = BxDolConnection::getObjectInstance($sConnectionsObject);
         if (!$oConnection)
@@ -109,7 +109,7 @@ class BxBaseServiceConnections extends BxDol
             $mixedId = bx_get_logged_profile_id();
 
         $i = 0;
-        $a = $oConnection->getConnectedContent($mixedId); // get received friend requests
+        $a = $oConnection->getConnectedContent($mixedId, $isMutual, 0, BX_CONNECTIONS_LIST_NO_LIMIT); // get received friend requests
         foreach ($a as $iId)
             if (BxDolProfile::getInstance($iId))
                 ++$i;
@@ -123,7 +123,7 @@ class BxBaseServiceConnections extends BxDol
      * @param $mixedId id to get connections for, if omitted then logged-in profile id is used
      * @return number
      */
-    public function serviceGetConnectedInitiatorsNum ($sConnectionsObject, $mixedId = 0)
+    public function serviceGetConnectedInitiatorsNum ($sConnectionsObject, $mixedId = 0, $isMutual = false)
     {
         $oConnection = BxDolConnection::getObjectInstance($sConnectionsObject);
         if (!$oConnection)
@@ -133,7 +133,7 @@ class BxBaseServiceConnections extends BxDol
             $mixedId = bx_get_logged_profile_id();
 
         $i = 0;
-        $a = $oConnection->getConnectedInitiators($mixedId); // get received friend requests
+        $a = $oConnection->getConnectedInitiators($mixedId, $isMutual, 0, BX_CONNECTIONS_LIST_NO_LIMIT); // get received friend requests
         foreach ($a as $iId)
             if (BxDolProfile::getInstance($iId))
                 ++$i;