1
0

BxBaseModGroupsPageEntry.php 5.0 KB

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