1
0

BxWorkspacesAlertsResponse.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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 Workspaces Workspaces
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. class BxWorkspacesAlertsResponse extends BxBaseModProfileAlertsResponse
  12. {
  13. public function __construct()
  14. {
  15. $this->MODULE = 'bx_workspaces';
  16. parent::__construct();
  17. }
  18. public function response($oAlert)
  19. {
  20. $sContextModule = getParam('bx_workspaces_context_module');
  21. // logo URL is refferring to the context when in workspace
  22. if ('system' == $oAlert->sUnit && 'get_logo' == $oAlert->sAction && bx_get_context_workspace()) {
  23. $o = BxDolProfile::getInstance(bx_get_context_workspace());
  24. if ($o) {
  25. $oAlert->aExtras['tmpl_vars']['attrs'] = preg_replace('/href="([^"]+)" title="([^"]+)"/', 'href="' . $o->getUrl() . '" title="' . $o->getDisplayName() . '"', $oAlert->aExtras['tmpl_vars']['attrs']);
  26. }
  27. }
  28. // site menu is off when in workspace
  29. if ($sContextModule && 'menu' == $oAlert->sUnit && 'get_code_before' == $oAlert->sAction && isset($oAlert->aExtras['object_name']) && $oAlert->aExtras['object_name'] == 'sys_site' && bx_get_context_workspace()) {
  30. $oAlert->aExtras['override_result'] = "site menu is off when in workspace (" . bx_get_context_workspace() . ")";
  31. }
  32. // TODO: replace 'bx_groups_fans' with proper connection object from $sContextModule
  33. if ($sContextModule && 'system' == $oAlert->sUnit && 'connection_before_add' == $oAlert->sAction && isset($oAlert->aExtras['object_name']) && $oAlert->aExtras['object_name'] == 'bx_groups_fans') {
  34. $this->_oModule->addConnection($sContextModule, $oAlert);
  35. }
  36. if ($sContextModule && 'system' == $oAlert->sUnit && 'connection_removed' == $oAlert->sAction && isset($oAlert->aExtras['object_name']) && $oAlert->aExtras['object_name'] == 'bx_groups_fans') {
  37. $this->_oModule->removeConnection($sContextModule, $oAlert);
  38. }
  39. }
  40. }
  41. /** @} */