1
0

BxBaseModGroupsMenuViewMeta.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) UNA, Inc - https://una.io
  4. * MIT License - https://opensource.org/licenses/MIT
  5. *
  6. * @defgroup BaseGroups Base classes for groups modules
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. /**
  12. * View entry meta menu
  13. */
  14. class BxBaseModGroupsMenuViewMeta extends BxBaseModProfileMenuViewMeta
  15. {
  16. public function __construct($aObject, $oTemplate = false)
  17. {
  18. parent::__construct($aObject, $oTemplate);
  19. }
  20. protected function _getMenuItemMembers($aItem)
  21. {
  22. $CNF = &$this->_oModule->_oConfig->CNF;
  23. if(!$this->_bContentPublic || !$this->_oContentProfile || empty($CNF['OBJECT_CONNECTIONS']))
  24. return false;
  25. $oConnection = BxDolConnection::getObjectInstance($CNF['OBJECT_CONNECTIONS']);
  26. if(!$oConnection)
  27. return false;
  28. $iContentProfileId = $this->_oContentProfile->id();
  29. if($this->_bIsApi) {
  30. $aCounter = $oConnection->getCounterAPI($iContentProfileId, true, ['caption' => $aItem['title']], BX_CONNECTIONS_CONTENT_TYPE_INITIATORS);
  31. $sUrl = $this->_oContentProfile->getUrl();
  32. if(!empty($CNF['URI_VIEW_MEMBERS']))
  33. $sUrl = bx_absolute_url(BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_MEMBERS'] . '&profile_id=' . $iContentProfileId));
  34. return $this->_getMenuItemAPI($aItem, ['display' => 'button'], [
  35. 'title' => $aCounter['countf'],
  36. 'link' => bx_api_get_relative_url($sUrl),
  37. 'list' => $oConnection->getConnectedListAPI($iContentProfileId, true, BX_CONNECTIONS_CONTENT_TYPE_INITIATORS)
  38. ]);
  39. }
  40. $sIcon = BxTemplFunctions::getInstanceWithTemplate($this->_oTemplate)->getIconAsHtml(!empty($aItem['icon']) ? $aItem['icon'] : '');
  41. return $oConnection->getCounter($iContentProfileId, true, ['caption' => $aItem['title'], 'custom_icon' => $sIcon], BX_CONNECTIONS_CONTENT_TYPE_INITIATORS);
  42. }
  43. }
  44. /** @} */