BxCnlAlertsResponse.php 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. * @defdroup Channels Channels
  7. * @indroup UnaModules
  8. *
  9. * @{
  10. */
  11. class BxCnlAlertsResponse extends BxBaseModGroupsAlertsResponse
  12. {
  13. public function __construct()
  14. {
  15. $this->MODULE = 'bx_channels';
  16. parent::__construct();
  17. }
  18. public function response($oAlert)
  19. {
  20. parent::response($oAlert);
  21. $aProfileModulesAutofollowLabels = array('bx_persons', 'bx_organizations');
  22. if (in_array($oAlert->sUnit, $aProfileModulesAutofollowLabels) && in_array($oAlert->sAction, array('added', 'edited'))) {
  23. $this->_oModule->followLabels($oAlert->sUnit, $oAlert->iObject);
  24. }
  25. if ($oAlert->sUnit == 'meta_keyword' && $oAlert->sAction == 'added'){
  26. if (isset($oAlert->aExtras['meta']) && isset($oAlert->aExtras['object']) && isset($oAlert->iObject) && isset($oAlert->iSender)){
  27. /*
  28. * TODO: $oAlert->aExtras['object'] - contains Metatags object name but further it's used as Module name.
  29. * It's working correctly while Metatags object name is equal to Module name.
  30. * This should be changed in Ticket #1596
  31. *
  32. * Also there is a problem that only Content's Author ID is saved, but further it's used to check visibility
  33. * in case of Context. So, it works correctly when Author posts something with tags in his own profile,
  34. * but will work incorrecly when Author posts something with tags in some Context (group, event, etc).
  35. * In this case system will use Author's profile as context instead of the real Context
  36. * in which the content was posted.
  37. */
  38. $this->_oModule->processHashtag($oAlert->aExtras['meta'], $oAlert->aExtras['object'], $oAlert->iObject, $oAlert->iSender);
  39. }
  40. }
  41. if ($oAlert->sUnit == 'meta_keyword' && $oAlert->sAction == 'url'){
  42. if (isset($oAlert->aExtras['keyword'])){
  43. $sName = $oAlert->aExtras['keyword'];
  44. $iCnlId = $this->_oModule->_oDb->getChannelIdByName($sName);
  45. if ($iCnlId > 0){
  46. $oAlert->aExtras['url'] = $this->_oModule->serviceProfileUrl($iCnlId);
  47. }
  48. }
  49. }
  50. if ($oAlert->sUnit == 'meta_keyword' && $oAlert->sAction == 'deleted'){
  51. if (isset($oAlert->aExtras['object']) && isset($oAlert->iObject) && isset($oAlert->iSender)){
  52. $this->_oModule->removeContentFromChannel($oAlert->iObject, $oAlert->aExtras['object']);
  53. }
  54. }
  55. }
  56. }
  57. /** @} */