BxEventsTemplate.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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 Events Events
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. /*
  12. * Groups module representation.
  13. */
  14. class BxEventsTemplate extends BxBaseModGroupsTemplate
  15. {
  16. function __construct(&$oConfig, &$oDb)
  17. {
  18. $this->MODULE = 'bx_events';
  19. parent::__construct($oConfig, $oDb);
  20. }
  21. function unitVars ($aData, $isCheckPrivateContent = true, $mixedTemplate = false, $aParams = array())
  22. {
  23. $aVars = parent::unitVars ($aData, $isCheckPrivateContent, $mixedTemplate, $aParams);
  24. $CNF = &$this->_oConfig->CNF;
  25. $oPrivacy = BxDolPrivacy::getObjectInstance($CNF['OBJECT_PRIVACY_VIEW']);
  26. $aContentInfo = $this->getModule()->_oDb->getContentInfoById($aData[$CNF['FIELD_ID']]);
  27. $oDateStart = date_create('@' . $aContentInfo['date_start']);
  28. $oDateStart->setTimezone(new DateTimeZone($aContentInfo['timezone'] ? $aContentInfo['timezone'] : 'UTC'));
  29. $oDateEnd = date_create('@' . $aContentInfo['date_end']);
  30. $oDateEnd->setTimezone(new DateTimeZone($aContentInfo['timezone'] ? $aContentInfo['timezone'] : 'UTC'));
  31. $isPublic = CHECK_ACTION_RESULT_ALLOWED === $this->getModule()->checkAllowedView($aData) || $oPrivacy->isPartiallyVisible($aData[$CNF['FIELD_ALLOW_VIEW_TO']]);
  32. if ($isPublic) {
  33. $aVars['bx_if:info']['content']['members'] = $oDateStart->format(getParam('bx_events_short_date_format'));
  34. }
  35. return array_merge($aVars, array(
  36. 'date_start' => $aData['date_start'],
  37. 'date_start_f' => strftime('%e %b', $oDateStart->getTimestamp()),
  38. 'date_end' => $aData['date_end'],
  39. 'date_end_f' => strftime('%e %b', $oDateEnd->getTimestamp()),
  40. ));
  41. }
  42. }
  43. /** @} */