BxBaseModNotificationsConfig.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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 BaseNotifications Base classes for Notifications like modules
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. class BxBaseModNotificationsConfig extends BxBaseModGeneralConfig
  12. {
  13. protected $_oDb;
  14. protected $_aObjects;
  15. protected $_aHandlerDescriptor;
  16. protected $_sHandlersMethod;
  17. protected $_aHandlers;
  18. protected $_aHandlersHidden;
  19. protected $_aPerPage;
  20. protected $_aHtmlIds;
  21. protected $_sAnimationEffect;
  22. protected $_iAnimationSpeed;
  23. protected $_aPrivacyViewDefault;
  24. function __construct($aModule)
  25. {
  26. parent::__construct($aModule);
  27. $this->_aPrefixes = array();
  28. $this->_aObjects = array(
  29. 'alert' => $this->_sName,
  30. 'privacy_view' => $this->_sName . '_privacy_view',
  31. 'conn_subscriptions' => 'sys_profiles_subscriptions'
  32. );
  33. $this->_aHandlerDescriptor = array();
  34. $this->_sHandlersMethod = '';
  35. $this->_aHandlersHidden = array();
  36. $this->_aHandlers = array();
  37. $this->_aJsClasses = array();
  38. $this->_aJsObjects = array();
  39. $this->_aPerPage = array();
  40. $this->_aHtmlIds = array();
  41. $this->_sAnimationEffect = 'fade';
  42. $this->_iAnimationSpeed = 'slow';
  43. $this->_aPrivacyViewDefault = array(
  44. 'object' => BX_DOL_PG_ALL,
  45. 'event' => BX_DOL_PG_ALL
  46. );
  47. }
  48. public function init(&$oDb)
  49. {
  50. $this->_oDb = &$oDb;
  51. $sOptionPrefix = $this->getPrefix('option');
  52. $aHandlers = $this->_oDb->getHandlers();
  53. foreach($aHandlers as $aHandler) {
  54. if($aHandler['type'] === BX_BASE_MOD_NTFS_HANDLER_TYPE_INSERT && !empty($aHandler['content'])) {
  55. $aContent = unserialize($aHandler['content']);
  56. if(is_array($aContent) && !empty($aContent))
  57. $aHandler = array_merge($aHandler, $aContent);
  58. }
  59. $this->_aHandlers[$aHandler['alert_unit'] . (!empty($aHandler['alert_action']) ? '_' . $aHandler['alert_action'] :'')] = $aHandler;
  60. }
  61. $sHideTimeline = getParam($sOptionPrefix . 'events_hide');
  62. if(!empty($sHideTimeline))
  63. $this->_aHandlersHidden = explode(',', $sHideTimeline);
  64. }
  65. public function getHandlerDescriptor()
  66. {
  67. return $this->_aHandlerDescriptor;
  68. }
  69. public function getHandlersMethod()
  70. {
  71. return $this->_sHandlersMethod;
  72. }
  73. public function isHandler($sKey = '')
  74. {
  75. return isset($this->_aHandlers[$sKey]);
  76. }
  77. public function getHandlers($sKey = '')
  78. {
  79. if($sKey == '')
  80. return $this->_aHandlers;
  81. return isset($this->_aHandlers[$sKey]) ? $this->_aHandlers[$sKey] : '';
  82. }
  83. public function getHandlersHidden()
  84. {
  85. return $this->_aHandlersHidden;
  86. }
  87. public function getPrivacyObject($sKey = '')
  88. {
  89. if(!$this->isHandler($sKey))
  90. return false;
  91. $aHandler = $this->getHandlers($sKey);
  92. if(empty($aHandler) || !is_array($aHandler) || empty($aHandler['privacy']))
  93. return false;
  94. return BxDolPrivacy::getObjectInstance($aHandler['privacy']);
  95. }
  96. public function getPerPage($sType = 'default')
  97. {
  98. if(empty($sType))
  99. return $this->_aPerPage;
  100. return isset($this->_aPerPage[$sType]) ? $this->_aPerPage[$sType] : '';
  101. }
  102. public function getHtmlIds($sType, $sKey = '')
  103. {
  104. if(empty($sKey))
  105. return isset($this->_aHtmlIds[$sType]) ? $this->_aHtmlIds[$sType] : array();
  106. return isset($this->_aHtmlIds[$sType][$sKey]) ? $this->_aHtmlIds[$sType][$sKey] : '';
  107. }
  108. public function getAnimationEffect()
  109. {
  110. return $this->_sAnimationEffect;
  111. }
  112. public function getAnimationSpeed()
  113. {
  114. return $this->_iAnimationSpeed;
  115. }
  116. public function getPrivacyViewDefault($sType)
  117. {
  118. return isset($this->_aPrivacyViewDefault[$sType]) ? $this->_aPrivacyViewDefault[$sType] : BX_DOL_PG_ALL;
  119. }
  120. }
  121. /** @} */