| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- <?php defined('BX_DOL') or die('hack attempt');
- /**
- * Copyright (c) UNA, Inc - https://una.io
- * MIT License - https://opensource.org/licenses/MIT
- *
- * @defgroup UnaBaseView UNA Base Representation Classes
- * @{
- */
- /**
- * System services for connections.
- */
- class BxBaseServiceConnections extends BxDol
- {
- public function __construct()
- {
- parent::__construct();
- }
- /**
- * get grid with friends connections
- */
- public function serviceConnectionsTable ()
- {
- $oGrid = BxDolGrid::getObjectInstance('sys_grid_connections');
- if (!$oGrid)
- return false;
- return $oGrid->getCode();
- }
- /**
- * get number of received unconfirmed connections (friend requests)
- * @param $sConnectionsObject connections object to get unconfirmed connections from
- * @param $mixedId id to get connections for, if omitted then logged-in profile id is used
- * @return number
- */
- public function serviceGetUnconfirmedConnectionsNum ($sConnectionsObject, $mixedId = 0)
- {
- $oConnection = BxDolConnection::getObjectInstance($sConnectionsObject);
- if (!$oConnection)
- return 0;
- if (!$mixedId)
- $mixedId = bx_get_logged_profile_id();
- $i = 0;
- $a = $oConnection->getConnectedInitiators($mixedId, 0); // get received friend requests
- foreach ($a as $iId)
- if (BxDolProfile::getInstance($iId))
- ++$i;
- return $i;
- }
- /**
- * get number of initiated connections (like "my subscriptions")
- * @param $sConnectionsObject connections object to get connections from
- * @param $mixedId id to get connections for, if omitted then logged-in profile id is used
- * @return number
- */
- public function serviceGetConnectedContentNum ($sConnectionsObject, $mixedId = 0)
- {
- $oConnection = BxDolConnection::getObjectInstance($sConnectionsObject);
- if (!$oConnection)
- return 0;
- if (!$mixedId)
- $mixedId = bx_get_logged_profile_id();
- $i = 0;
- $a = $oConnection->getConnectedContent($mixedId); // get received friend requests
- foreach ($a as $iId)
- if (BxDolProfile::getInstance($iId))
- ++$i;
- return $i;
- }
- /**
- * get number of received connections (like "subscribed me")
- * @param $sConnectionsObject connections object to get connections from
- * @param $mixedId id to get connections for, if omitted then logged-in profile id is used
- * @return number
- */
- public function serviceGetConnectedInitiatorsNum ($sConnectionsObject, $mixedId = 0)
- {
- $oConnection = BxDolConnection::getObjectInstance($sConnectionsObject);
- if (!$oConnection)
- return 0;
- if (!$mixedId)
- $mixedId = bx_get_logged_profile_id();
- $i = 0;
- $a = $oConnection->getConnectedInitiators($mixedId); // get received friend requests
- foreach ($a as $iId)
- if (BxDolProfile::getInstance($iId))
- ++$i;
- return $i;
- }
- /**
- * get grid with subscriptions connections
- */
- public function serviceSubscriptionsTable ()
- {
- $aProfile = BxDolProfile::getInstance(bx_process_input(bx_get('profile_id'), BX_DATA_INT))->getInfo();
- if(empty($aProfile) || !is_array($aProfile))
- return false;
- $CNF = &BxDolModule::getInstance($aProfile['type'])->_oConfig->CNF;
- if(getParam($CNF['PARAM_PUBLIC_SBSN']) != 'on' && $aProfile['id'] != bx_get_logged_profile_id())
- return false;
- $oGrid = BxDolGrid::getObjectInstance('sys_grid_subscriptions');
- if (!$oGrid)
- return false;
- return BxDolTemplate::getInstance()->parseHtmlByName('connections_list.html', array(
- 'name' => 'subscriptions',
- 'content' => $oGrid->getCode()
- ));
- }
- /**
- * get grid with subscribed me connections
- */
- public function serviceSubscribedMeTable ()
- {
- $aProfile = BxDolProfile::getInstance(bx_process_input(bx_get('profile_id'), BX_DATA_INT))->getInfo();
- if(empty($aProfile) || !is_array($aProfile))
- return false;
- $CNF = &BxDolModule::getInstance($aProfile['type'])->_oConfig->CNF;
- if(getParam($CNF['PARAM_PUBLIC_SBSD']) != 'on' && $aProfile['id'] != bx_get_logged_profile_id())
- return false;
- $oGrid = BxDolGrid::getObjectInstance('sys_grid_subscribed_me');
- if (!$oGrid)
- return false;
- return BxDolTemplate::getInstance()->parseHtmlByName('connections_list.html', array(
- 'name' => 'subscribers',
- 'content' => $oGrid->getCode()
- ));
- }
- /*
- * Get notification data for Notifications module - action Subscribe.
- */
- public function serviceGetNotificationsPost($aEvent)
- {
- $iProfile = (int)$aEvent['object_id'];
- $oProfile = BxDolProfile::getInstance($iProfile);
- if(!$oProfile)
- return array();
- return array(
- 'entry_sample' => '_sys_profile_sample_single',
- 'entry_url' => $oProfile->getUrl(),
- 'entry_caption' => $oProfile->getDisplayName(),
- 'entry_author' => $oProfile->id(),
- 'lang_key' => '_sys_profile_subscription_added',
- );
- }
- /*
- * Get notification data for Notifications module - action Friend.
- */
- public function serviceGetNotificationsPostFriendship($aEvent)
- {
- $iProfile = (int)$aEvent['object_id'];
- $oProfile = BxDolProfile::getInstance($iProfile);
- if(!$oProfile)
- return array();
- return array(
- 'entry_sample' => '_sys_profile_sample_single',
- 'entry_url' => $oProfile->getUrl(),
- 'entry_caption' => $oProfile->getDisplayName(),
- 'entry_author' => $oProfile->id(),
- 'lang_key' => '_sys_profile_friendship_added',
- );
- }
- }
- /** @} */
|