BxBaseModGroupsTemplate.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. * 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' => $isPublic && $this->getModule()->checkAllowedFanAdd($aData) === CHECK_ACTION_RESULT_ALLOWED,
  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. protected function _getUnitClass($aData, $sTemplateName = 'unit.html')
  42. {
  43. $sResult = '';
  44. switch($sTemplateName) {
  45. case 'unit.html':
  46. case 'unit_with_cover.html':
  47. $sResult = 'bx-base-pofile-unit-with-cover bx-base-groups-unit-with-cover';
  48. break;
  49. case 'unit_wo_info.html':
  50. $sResult = 'bx-base-pofile-unit-wo-info bx-base-groups-unit-wo-info';
  51. break;
  52. }
  53. return $sResult;
  54. }
  55. }
  56. /** @} */