BxBaseModGroupsTemplate.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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 BaseGroups Base classes for groups modules
  7. * @ingroup TridentModules
  8. *
  9. * @{
  10. */
  11. /*
  12. * Groups module representation.
  13. */
  14. class BxBaseModGroupsTemplate extends BxBaseModProfileTemplate
  15. {
  16. function __construct(&$oConfig, &$oDb)
  17. {
  18. parent::__construct($oConfig, $oDb);
  19. }
  20. function unitVars ($aData, $isCheckPrivateContent = true, $sTemplateName = 'unit.html')
  21. {
  22. $aVars = parent::unitVars ($aData, $isCheckPrivateContent, $sTemplateName);
  23. $CNF = &$this->_oConfig->CNF;
  24. $oPrivacy = BxDolPrivacy::getObjectInstance($CNF['OBJECT_PRIVACY_VIEW']);
  25. $isPublic = CHECK_ACTION_RESULT_ALLOWED === $this->getModule()->checkAllowedView($aData) || $oPrivacy->isPartiallyVisible($aData[$CNF['FIELD_ALLOW_VIEW_TO']]);
  26. $oConn = BxDolConnection::getObjectInstance($CNF['OBJECT_CONNECTIONS']);
  27. $oGroupProfile = BxDolProfile::getInstanceByContentAndType($aData[$CNF['FIELD_ID']], $this->MODULE);
  28. $aVars['title'] = $isPublic ? bx_process_output($aData[$CNF['FIELD_NAME']]) : _t($CNF['T']['txt_private_group']);
  29. $aVars['bx_if:info']['condition'] = true;
  30. $aVars['bx_if:info']['content']['members'] = $isPublic ? _t($CNF['T']['txt_N_fans'], $oConn ? $oConn->getConnectedInitiatorsCount($oGroupProfile->id(), true) : 0) : '&nbsp;';
  31. $aVars['bx_if:info']['content']['bx_if:btn'] = array (
  32. 'condition' => isLogged() && $isPublic && !$oConn->isConnected(bx_get_logged_profile_id(), $oGroupProfile->id(), true),
  33. 'content' => array (
  34. 'id' => $oGroupProfile->id(),
  35. 'title' => $oConn->isConnectedNotMutual(bx_get_logged_profile_id(), $oGroupProfile->id()) ? _t($CNF['T']['menu_item_title_become_fan_sent']) : _t($CNF['T']['menu_item_title_become_fan']),
  36. 'object' => $CNF['OBJECT_CONNECTIONS'],
  37. ),
  38. );
  39. return $aVars;
  40. }
  41. }
  42. /** @} */