1
0

BxBaseModGroupsAlertsResponse.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. class BxBaseModGroupsAlertsResponse extends BxBaseModProfileAlertsResponse
  12. {
  13. public function __construct()
  14. {
  15. parent::__construct();
  16. }
  17. public function response($oAlert)
  18. {
  19. parent::response($oAlert);
  20. $CNF = $this->_oModule->_oConfig->CNF;
  21. // connection events
  22. if (isset($CNF['OBJECT_CONNECTIONS']) && $CNF['OBJECT_CONNECTIONS'] == $oAlert->sUnit && 'connection_added' == $oAlert->sAction) {
  23. $this->_oModule->serviceAddMutualConnection($oAlert->aExtras['content'], $oAlert->aExtras['initiator']);
  24. }
  25. elseif (isset($CNF['OBJECT_CONNECTIONS']) && $CNF['OBJECT_CONNECTIONS'] == $oAlert->sUnit && 'connection_removed' == $oAlert->sAction) {
  26. $this->_oModule->serviceOnRemoveConnection($oAlert->aExtras['content'], $oAlert->aExtras['initiator']);
  27. }
  28. // profile delete event
  29. if ('profile' == $oAlert->sUnit && 'delete' == $oAlert->sAction) {
  30. $this->_oModule->serviceDeleteProfileFromFansAndAdmins($oAlert->iObject);
  31. $this->_oModule->serviceReassignEntitiesByAuthor($oAlert->iObject);
  32. }
  33. if ($this->MODULE != $oAlert->sUnit)
  34. return;
  35. // join group events
  36. switch ($oAlert->sAction) {
  37. case 'join_invitation':
  38. $this->sendMailInvitation($oAlert, $oAlert->aExtras['profile'], bx_get_logged_profile_id());
  39. break;
  40. case 'join_request':
  41. $this->sendMailJoinRequest($oAlert, $oAlert->aExtras['profile'], bx_get_logged_profile_id());
  42. break;
  43. case 'join_request_accepted':
  44. $this->sendMailJoinRequestAccepted($oAlert, $oAlert->aExtras['profile'], bx_get_logged_profile_id());
  45. break;
  46. }
  47. }
  48. protected function sendMailInvitation ($oAlert, $iProfileId, $iSender = 0)
  49. {
  50. sendMailTemplate($this->_oModule->_oConfig->CNF['EMAIL_INVITATION'], 0, $iProfileId, array(
  51. 'InviterUrl' => BxDolProfile::getInstance($iSender)->getUrl(),
  52. 'InviterDisplayName' => BxDolProfile::getInstance($iSender)->getDisplayName(),
  53. 'EntryUrl' => $oAlert->aExtras['entry_url'],
  54. 'EntryTitle' => $oAlert->aExtras['entry_title'],
  55. ), BX_EMAIL_NOTIFY);
  56. }
  57. protected function sendMailJoinRequest ($oAlert, $iProfileId, $iSender = 0)
  58. {
  59. $aAdmins = $this->_oModule->_oDb->getAdmins($oAlert->aExtras['group_profile']);
  60. foreach ($aAdmins as $iAdminProfileId) {
  61. sendMailTemplate($this->_oModule->_oConfig->CNF['EMAIL_JOIN_REQUEST'], 0, $iAdminProfileId, array(
  62. 'NewMemberUrl' => BxDolProfile::getInstance($iProfileId)->getUrl(),
  63. 'NewMemberDisplayName' => BxDolProfile::getInstance($iProfileId)->getDisplayName(),
  64. 'EntryUrl' => $oAlert->aExtras['entry_url'],
  65. 'EntryTitle' => $oAlert->aExtras['entry_title'],
  66. ), BX_EMAIL_NOTIFY);
  67. }
  68. }
  69. protected function sendMailJoinRequestAccepted ($oAlert, $iProfileId, $iSender = 0)
  70. {
  71. sendMailTemplate($this->_oModule->_oConfig->CNF['EMAIL_JOIN_CONFIRM'], 0, $iProfileId, array(
  72. 'EntryUrl' => $oAlert->aExtras['entry_url'],
  73. 'EntryTitle' => $oAlert->aExtras['entry_title'],
  74. ), BX_EMAIL_NOTIFY);
  75. }
  76. protected function processTimelineShare ($oAlert, $iGroupProfileId)
  77. {
  78. if ($oAlert->aExtras['check_result'][CHECK_ACTION_RESULT] !== CHECK_ACTION_RESULT_ALLOWED)
  79. return;
  80. $oGroupProfile = BxDolProfile::getInstance($iGroupProfileId);
  81. if (!$oGroupProfile)
  82. return;
  83. $oPrivacy = BxDolPrivacy::getObjectInstance($this->_oModule->_oConfig->CNF['OBJECT_PRIVACY_VIEW']);
  84. $aContentInfo = $this->_oModule->serviceGetContentInfoById($oGroupProfile->getContentId());
  85. if (BX_DOL_PG_ALL == $aContentInfo[$this->_oModule->_oConfig->CNF['FIELD_ALLOW_VIEW_TO']] || (BX_DOL_PG_MEMBERS == $aContentInfo[$this->_oModule->_oConfig->CNF['FIELD_ALLOW_VIEW_TO']] && isLogged()) || $oPrivacy->isPartiallyVisible($aContentInfo[$this->_oModule->_oConfig->CNF['FIELD_ALLOW_VIEW_TO']])) {
  86. $oAlert->aExtras['check_result'][CHECK_ACTION_RESULT] = CHECK_ACTION_RESULT_ALLOWED;
  87. }
  88. else {
  89. $oAlert->aExtras['check_result'][CHECK_ACTION_RESULT] = CHECK_ACTION_MESSAGE_NOT_ALLOWED;
  90. $oAlert->aExtras['check_result'][CHECK_ACTION_MESSAGE] = _t('_sys_access_denied_to_private_content');
  91. }
  92. }
  93. }
  94. /** @} */