BxBaseModGroupsTemplate.php 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. $this->_sUnitClassWithCover .= ' bx-base-groups-unit-with-cover';
  20. $this->_sUnitClass = $this->_sUnitClassWithCover;
  21. $this->_sUnitClassWoInfo .= ' bx-base-groups-unit-wo-info';
  22. }
  23. function unitVars ($aData, $isCheckPrivateContent = true, $sTemplateName = 'unit.html')
  24. {
  25. $aVars = parent::unitVars ($aData, $isCheckPrivateContent, $sTemplateName);
  26. $CNF = &$this->_oConfig->CNF;
  27. $oProfile = BxDolProfile::getInstance($aData[$CNF['FIELD_AUTHOR']]);
  28. if (!$oProfile)
  29. $oProfile = BxDolProfileUndefined::getInstance();
  30. $bPublic = true;
  31. if(!empty($CNF['OBJECT_PRIVACY_VIEW'])) {
  32. $oPrivacy = BxDolPrivacy::getObjectInstance($CNF['OBJECT_PRIVACY_VIEW']);
  33. if ($oPrivacy && !$oPrivacy->check($aData[$CNF['FIELD_ID']]) && !$oPrivacy->isPartiallyVisible($aData[$CNF['FIELD_ALLOW_VIEW_TO']]))
  34. $bPublic = false;
  35. }
  36. $oConn = BxDolConnection::getObjectInstance($CNF['OBJECT_CONNECTIONS']);
  37. $oGroupProfile = BxDolProfile::getInstanceByContentAndType($aData[$CNF['FIELD_ID']], $this->MODULE);
  38. $aVars['title'] = $bPublic ? bx_process_output($aData[$CNF['FIELD_NAME']]) : _t($CNF['T']['txt_private_group']);
  39. $aVars['author'] = $oProfile->getDisplayName();
  40. $aVars['author_url'] = $oProfile->getUrl();
  41. $aVars['author_icon'] = $oProfile->getIcon();
  42. $aVars['author_thumb'] = $oProfile->getThumb();
  43. $aVars['author_avatar'] = $oProfile->getAvatar();
  44. $aVars['bx_if:info']['condition'] = true;
  45. $aVars['bx_if:info']['content']['members'] = $bPublic ? _t($CNF['T']['txt_N_fans'], $oConn ? $oConn->getConnectedInitiatorsCount($oGroupProfile->id(), true) : 0) : '&nbsp;';
  46. $aVars['bx_if:info']['content']['bx_if:btn'] = array (
  47. 'condition' => $bPublic && $this->getModule()->checkAllowedFanAdd($aData) === CHECK_ACTION_RESULT_ALLOWED,
  48. 'content' => array (
  49. 'id' => $oGroupProfile->id(),
  50. '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']),
  51. 'object' => $CNF['OBJECT_CONNECTIONS'],
  52. ),
  53. );
  54. return $aVars;
  55. }
  56. }
  57. /** @} */