1
0

BxBaseModGroupsPageEntry.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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. * Profile create/edit/delete pages.
  13. */
  14. class BxBaseModGroupsPageEntry extends BxBaseModProfilePageEntry
  15. {
  16. public function __construct($aObject, $oTemplate = false)
  17. {
  18. parent::__construct($aObject, $oTemplate);
  19. $CNF = &$this->_oModule->_oConfig->CNF;
  20. $this->_sCoverClass = 'bx-base-group-cover-wrapper ' . $this->_oModule->getName() . '_cover';
  21. $bLoggedOwner = isset($this->_aContentInfo[$CNF['FIELD_AUTHOR']]) && $this->_aContentInfo[$CNF['FIELD_AUTHOR']] == bx_get_logged_profile_id();
  22. $bLoggedModerator = $this->_oModule->checkAllowedEditAnyEntry() === CHECK_ACTION_RESULT_ALLOWED;
  23. if(!empty($CNF['FIELD_CF']) && isset($this->_aContentInfo[$CNF['FIELD_CF']])) {
  24. $oCf = BxDolContentFilter::getInstance();
  25. if($oCf->isEnabled() && !$oCf->isAllowed($this->_aContentInfo[$CNF['FIELD_CF']])) {
  26. $this->setPageCover(false);
  27. return;
  28. }
  29. }
  30. $aInformers = array ();
  31. $oInformer = BxDolInformer::getInstance($this->_oTemplate);
  32. if($oInformer && ($bLoggedOwner || $bLoggedModerator)) {
  33. $sStatus = isset($CNF['FIELD_STATUS']) && isset($this->_aContentInfo[$CNF['FIELD_STATUS']]) ? $this->_aContentInfo[$CNF['FIELD_STATUS']] : '';
  34. //--- Display 'scheduled' informer if an item wasn't published yet.
  35. if(isset($CNF['FIELD_PUBLISHED'])) {
  36. if(!empty($CNF['INFORMERS']['scheduled']) && isset($CNF['INFORMERS']['scheduled']['map'][$sStatus])) {
  37. $this->addMarkers(array(
  38. 'date_publish_uf' => bx_time_js((int)$this->_aContentInfo[$CNF['FIELD_PUBLISHED']], BX_FORMAT_DATE, true)
  39. ));
  40. $aInformer = $CNF['INFORMERS']['scheduled'];
  41. $aInformers[] = array ('name' => $aInformer['name'], 'msg' => _t($aInformer['map'][$sStatus]['msg']), 'type' => $aInformer['map'][$sStatus]['type']);
  42. }
  43. }
  44. if($aInformers)
  45. foreach($aInformers as $aInformer)
  46. $oInformer->add($aInformer['name'], $this->_replaceMarkers($aInformer['msg']), $aInformer['type']);
  47. }
  48. }
  49. protected function _processPermissionsCheck ()
  50. {
  51. $CNF = &$this->_oModule->_oConfig->CNF;
  52. $oPrivacy = BxDolPrivacy::getObjectInstance($CNF['OBJECT_PRIVACY_VIEW']);
  53. $mixedAllowView = $this->_oModule->checkAllowedView($this->_aContentInfo);
  54. if (!$oPrivacy->isPartiallyVisible($this->_aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']]) && CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = $mixedAllowView)) {
  55. $this->_oTemplate->displayAccessDenied($sMsg);
  56. exit;
  57. }
  58. elseif ($oPrivacy->isPartiallyVisible($this->_aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']]) && $CNF['OBJECT_PAGE_VIEW_ENTRY'] == $this->_sObject && CHECK_ACTION_RESULT_ALLOWED !== $mixedAllowView) {
  59. // replace current page with different set of blocks
  60. $aObject = BxDolPageQuery::getPageObject($CNF['OBJECT_PAGE_VIEW_ENTRY_CLOSED']);
  61. $this->_sObject = $aObject['object'];
  62. $this->_aObject = $aObject;
  63. $this->_oQuery = new BxDolPageQuery($this->_aObject);
  64. }
  65. $this->_oModule->checkAllowedView($this->_aContentInfo, true);
  66. }
  67. protected function _getInvitationCode($aParams = [])
  68. {
  69. $CNF = &$this->_oModule->_oConfig->CNF;
  70. if(empty($CNF['TABLE_INVITES']) || !$this->_oProfile)
  71. return '';
  72. $iProfileId = bx_get_logged_profile_id();
  73. $iGroupProfileId = $this->_oProfile->id();
  74. if(!$this->_oModule->serviceIsInvited($iGroupProfileId, $iProfileId))
  75. return '';
  76. $sId = $this->_oModule->getName() . '_popup_invite';
  77. $sKey = $this->_oModule->serviceGetInvitedKey($iGroupProfileId, $iProfileId);
  78. $sCode = $this->_oModule->_oTemplate->getJsCode('invite_popup', array(
  79. 'sPopupId' => $sId,
  80. 'sKey' => $sKey,
  81. 'sAcceptUrl' => BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $this->_aProfileInfo['content_id']),
  82. 'sDeclineUrl' => BX_DOL_URL_ROOT,
  83. 'iGroupProfileId' => $this->_oProfile->id(),
  84. ));
  85. if(!isset($aParams['use_invitation_popup']) || $aParams['use_invitation_popup'] === true)
  86. $sCode .= BxTemplFunctions::getInstance()->popupBox($sId, _t($CNF['T']['txt_invitation_popup_title']), $this->_oModule->_oTemplate->parseHtmlByName('popup_invite.html', array(
  87. 'popup_id' => $sId,
  88. 'text' => _t($CNF['T']['txt_invitation_popup_text']),
  89. 'button_accept' => _t($CNF['T']['txt_invitation_popup_accept_button']),
  90. 'button_decline' => _t($CNF['T']['txt_invitation_popup_decline_button']),
  91. )), true);
  92. $this->_oTemplate->addJs(array('invite_popup.js'));
  93. return $sCode;
  94. }
  95. public function getCode ()
  96. {
  97. return $this->_getInvitationCode() . parent::getCode();
  98. }
  99. }
  100. /** @} */