BxBaseModGroupsPageEntry.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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. public function getCode ()
  61. {
  62. $CNF = &$this->_oModule->_oConfig->CNF;
  63. $sInvitation = '';
  64. if(!empty($CNF['TABLE_INVITES'])) {
  65. $sKey = '';
  66. $iGroupProfileId = $this->_oProfile->id();
  67. if(($sKey = bx_get('key')) !== false)
  68. $mixedInvited = $this->_oModule->isInvited($sKey, $iGroupProfileId);
  69. else if(($iProfileId = bx_get_logged_profile_id()) !== false)
  70. $mixedInvited = $this->_oModule->isInvitedByProfileId($iProfileId, $iGroupProfileId);
  71. if ($mixedInvited === true) {
  72. $sId = $this->_oModule->getName() . '_popup_invite';
  73. $this->_oTemplate->addJs(array('invite_popup.js'));
  74. $sInvitation .= $this->_oModule->_oTemplate->getJsCode('invite_popup', array(
  75. 'sPopupId' => $sId,
  76. 'sKey' => $sKey,
  77. 'sAcceptUrl' => BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $this->_aProfileInfo['content_id']),
  78. 'sDeclineUrl' => BX_DOL_URL_ROOT,
  79. 'iGroupProfileId' => $this->_oProfile->id(),
  80. ));
  81. $sInvitation .= BxTemplFunctions::getInstance()->popupBox($sId, _t($CNF['T']['txt_invitation_popup_title']), $this->_oModule->_oTemplate->parseHtmlByName('popup_invite.html', array(
  82. 'popup_id' => $sId,
  83. 'text' => _t($CNF['T']['txt_invitation_popup_text']),
  84. 'button_accept' => _t($CNF['T']['txt_invitation_popup_accept_button']),
  85. 'button_decline' => _t($CNF['T']['txt_invitation_popup_decline_button']),
  86. )), true);
  87. }
  88. }
  89. return $sInvitation . parent::getCode();
  90. }
  91. }
  92. /** @} */