BxBaseModGroupsPageEntry.php 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. $this->_sCoverClass = 'bx-base-group-cover-wrapper ' . $this->_oModule->getName() . '_cover';
  20. }
  21. protected function _processPermissionsCheck ()
  22. {
  23. $CNF = &$this->_oModule->_oConfig->CNF;
  24. $oPrivacy = BxDolPrivacy::getObjectInstance($CNF['OBJECT_PRIVACY_VIEW']);
  25. $mixedAllowView = $this->_oModule->checkAllowedView($this->_aContentInfo);
  26. if (!$oPrivacy->isPartiallyVisible($this->_aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']]) && CHECK_ACTION_RESULT_ALLOWED !== ($sMsg = $mixedAllowView)) {
  27. $this->_oTemplate->displayAccessDenied($sMsg);
  28. exit;
  29. }
  30. elseif ($oPrivacy->isPartiallyVisible($this->_aContentInfo[$CNF['FIELD_ALLOW_VIEW_TO']]) && $CNF['OBJECT_PAGE_VIEW_ENTRY'] == $this->_sObject && CHECK_ACTION_RESULT_ALLOWED !== $mixedAllowView) {
  31. // replace current page with different set of blocks
  32. $aObject = BxDolPageQuery::getPageObject($CNF['OBJECT_PAGE_VIEW_ENTRY_CLOSED']);
  33. $this->_sObject = $aObject['object'];
  34. $this->_aObject = $aObject;
  35. $this->_oQuery = new BxDolPageQuery($this->_aObject);
  36. }
  37. $this->_oModule->checkAllowedView($this->_aContentInfo, true);
  38. }
  39. public function getCode ()
  40. {
  41. $CNF = &$this->_oModule->_oConfig->CNF;
  42. $sRv = '';
  43. if (bx_get('key')){
  44. $sKey = bx_get('key');
  45. $sId = $this->_oModule->getName() . '_popup_invite';
  46. $aData = $this->_oModule->_oDb->getInviteByKey($sKey, $this->_oProfile->id());
  47. if (!isset($aData['invited_profile_id'])){
  48. $sRv = _t('_bx_groups_txt_invite_popup_error_invitation_absent');
  49. }
  50. else{
  51. if ($aData['invited_profile_id'] != bx_get_logged_profile_id()){
  52. $sRv = _t('_bx_groups_txt_invite_popup_error_invitation_wrong_user');
  53. }
  54. else{
  55. $sRv = $this->_oModule->_oTemplate->parseHtmlByName('popup_invite.html', array(
  56. 'PopupId' => $sId
  57. ));
  58. }
  59. }
  60. }
  61. $this->_oTemplate->addJs(array('invite_popup.js'));
  62. return ($sRv != '' ? $this->_oModule->_oTemplate->getJsCode('invite_popup', array(
  63. 'sPopupId' => $sId,
  64. 'sKey' => $sKey,
  65. 'sAcceptUrl' => BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $this->_aProfileInfo['content_id']),
  66. 'sDeclineUrl' => BX_DOL_URL_ROOT,
  67. 'iGroupProfileId' => $this->_oProfile->id(),
  68. )) . BxTemplFunctions::getInstance()->popupBox($sId, _t($CNF['T']['txt_invitation_popup_title']), $sRv, true) : '').parent::getCode();
  69. }
  70. }
  71. /** @} */