AntonLV před 5 roky
rodič
revize
177aa9b2be

+ 15 - 3
inc/classes/BxDolConnection.php

@@ -395,13 +395,13 @@ class BxDolConnection extends BxDolFactory implements iBxDolFactoryObject
     /**
      * Get connected content IDs for specified type
      * @param $iInitiator initiator of the connection
-     * @param $sType type of content
+     * @param $mixedType type of content or an array of types
      * @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)
+    public function getConnectedContentByType ($iInitiator, $mixedType, $isMutual = false, $iStart = 0, $iLimit = BX_CONNECTIONS_LIST_LIMIT, $iOrder = BX_CONNECTIONS_ORDER_NONE)
     {
-        return $this->_oQuery->getConnectedContentByType($iInitiator, $sType, $isMutual, $iStart, $iLimit, $iOrder);
+        return $this->_oQuery->getConnectedContentByType($iInitiator, $mixedType, $isMutual, $iStart, $iLimit, $iOrder);
     }
 
     /**
@@ -415,6 +415,18 @@ class BxDolConnection extends BxDolFactory implements iBxDolFactoryObject
         return $this->_oQuery->getConnectedInitiators($iContent, $isMutual, $iStart, $iLimit, $iOrder);
     }
 
+    /**
+     * Get connected initiators IDs
+     * @param $iContent content of the connection
+     * @param $mixedType type of content or an array of types
+     * @param $isMutual get mutual connections only
+     * @return array of available connections
+     */
+    public function getConnectedInitiatorsByType ($iContent, $mixedType, $isMutual = false, $iStart = 0, $iLimit = BX_CONNECTIONS_LIST_LIMIT, $iOrder = BX_CONNECTIONS_ORDER_NONE)
+    {
+        return $this->_oQuery->getConnectedInitiatorsByType($iContent, $mixedType, $isMutual, $iStart, $iLimit, $iOrder);
+    }
+
     /**
      * Similar to getConnectionsAsArray, but for getCommonContentAsSQLParts, getConnectedContentAsSQLParts or getConnectedInitiatorsAsSQLParts methods
      * @see getConnectionsAsArray

+ 19 - 6
inc/classes/BxDolConnectionQuery.php

@@ -156,14 +156,15 @@ class BxDolConnectionQuery extends BxDolDb
         ));
     }
     
-    public function getConnectedContentByType ($iInitiator, $sType, $isMutual = false, $iStart = 0, $iLimit = BX_CONNECTIONS_LIST_LIMIT, $iOrder = BX_CONNECTIONS_ORDER_NONE)
+    public function getConnectedContentByType ($iInitiator, $mixedType, $isMutual = false, $iStart = 0, $iLimit = BX_CONNECTIONS_LIST_LIMIT, $iOrder = BX_CONNECTIONS_ORDER_NONE)
     {
+        $mixedType = is_array($mixedType) ? $mixedType : array($mixedType);
+
         $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);
-       
+        $sQuery = $this->_getConnectionsQuery($sWhere, 'INNER JOIN `sys_profiles` `p` ON `p`.`id` = `c`.`content` AND `p`.`type` IN (' . $this->implode_escape($mixedType) . ')', '`c`.`content`', $isMutual, $iStart, $iLimit, $iOrder);
+
         return $this->getColumn($sQuery, array(
-        	'initiator' => $iInitiator,
-            'type' => $sType
+            'initiator' => $iInitiator,
         ));
     }
 
@@ -173,7 +174,19 @@ class BxDolConnectionQuery extends BxDolDb
         $sQuery = $this->_getConnectionsQuery($sWhere, '', '`c`.`initiator`', $isMutual, $iStart, $iLimit, $iOrder);
 
         return $this->getColumn($sQuery, array(
-        	'content' => $iContent
+            'content' => $iContent
+        ));
+    }
+
+    public function getConnectedInitiatorsByType ($iContent, $mixedType, $isMutual = false, $iStart = 0, $iLimit = BX_CONNECTIONS_LIST_LIMIT, $iOrder = BX_CONNECTIONS_ORDER_NONE)
+    {
+        $mixedType = is_array($mixedType) ? $mixedType : array($mixedType);
+
+        $sWhere = " AND `c`.`content` = :content";
+        $sQuery = $this->_getConnectionsQuery($sWhere, 'INNER JOIN `sys_profiles` `p` ON `p`.`id` = `c`.`initiator` AND `p`.`type` IN (' . $this->implode_escape($mixedType) . ')', '`c`.`initiator`', $isMutual, $iStart, $iLimit, $iOrder);
+
+        return $this->getColumn($sQuery, array(
+            'content' => $iContent,
         ));
     }