BxBaseServiceConnections.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. {
  14. public function __construct()
  15. {
  16. parent::__construct();
  17. }
  18. /**
  19. * get grid with friends connections
  20. */
  21. public function serviceConnectionsTable ()
  22. {
  23. bx_import('BxDolGrid');
  24. $oGrid = BxDolGrid::getObjectInstance('sys_grid_connections');
  25. if (!$oGrid)
  26. return false;
  27. return $oGrid->getCode();
  28. }
  29. /**
  30. * get number of received unconfirmed connections (friend requests)
  31. * @param $sConnectionsObject connections object to get unconfirmed connections from
  32. * @param $mixedId id to get connections for, if omitted then logged-in profile id is used
  33. * @return number
  34. */
  35. public function serviceGetUnconfirmedConnectionsNum ($sConnectionsObject, $mixedId = 0)
  36. {
  37. bx_import('BxDolConnection');
  38. $oConnection = BxDolConnection::getObjectInstance($sConnectionsObject);
  39. if (!$oConnection)
  40. return 0;
  41. if (!$mixedId)
  42. $mixedId = bx_get_logged_profile_id();
  43. $i = 0;
  44. $a = $oConnection->getConnectedInitiators($mixedId, 0); // get received friend requests
  45. foreach ($a as $iId)
  46. if (BxDolProfile::getInstance($iId))
  47. ++$i;
  48. return $i;
  49. }
  50. }
  51. /** @} */