BxBaseServiceConnections.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
  4. * CC-BY License - http://creativecommons.org/licenses/by/3.0/
  5. *
  6. * @defgroup DolphinCore Dolphin Core
  7. * @{
  8. */
  9. /**
  10. * System services for connections.
  11. */
  12. class BxBaseServiceConnections extends BxDol {
  13. public function __construct() {
  14. parent::__construct();
  15. }
  16. /**
  17. * get grid with friends connections
  18. */
  19. public function serviceConnectionsTable ()
  20. {
  21. bx_import('BxDolGrid');
  22. $oGrid = BxDolGrid::getObjectInstance('sys_grid_connections');
  23. if (!$oGrid)
  24. return false;
  25. return $oGrid->getCode();
  26. }
  27. /**
  28. * get number of received unconfirmed connections (friend requests)
  29. * @param $sConnectionsObject connections object to get unconfirmed connections from
  30. * @param $mixedId id to get connections for, if omitted then logged-in profile id is used
  31. * @return number
  32. */
  33. public function serviceGetUnconfirmedConnectionsNum ($sConnectionsObject, $mixedId = 0)
  34. {
  35. bx_import('BxDolConnection');
  36. $oConnection = BxDolConnection::getObjectInstance($sConnectionsObject);
  37. if (!$oConnection)
  38. return 0;
  39. if (!$mixedId)
  40. $mixedId = bx_get_logged_profile_id();
  41. $i = 0;
  42. $a = $oConnection->getConnectedInitiators($mixedId, 0); // get received friend requests
  43. foreach ($a as $iId)
  44. if (BxDolProfile::getInstance($iId))
  45. ++$i;
  46. return $i;
  47. }
  48. }
  49. /** @} */