BxBaseModNotificationsConfig.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
  4. * CC-BY License - http://creativecommons.org/licenses/by/3.0/
  5. *
  6. * @defgroup BaseNotifications Base classes for Notifications like modules
  7. * @ingroup TridentModules
  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 $_iPrivacyViewDefault;
  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->_iPrivacyViewDefault = BX_DOL_PG_ALL;
  44. }
  45. public function init(&$oDb)
  46. {
  47. $this->_oDb = &$oDb;
  48. $sOptionPrefix = $this->getPrefix('option');
  49. $aHandlers = $this->_oDb->getHandlers();
  50. foreach($aHandlers as $aHandler) {
  51. if($aHandler['type'] === BX_BASE_MOD_NTFS_HANDLER_TYPE_INSERT && !empty($aHandler['content'])) {
  52. $aContent = unserialize($aHandler['content']);
  53. if(is_array($aContent) && !empty($aContent))
  54. $aHandler = array_merge($aHandler, $aContent);
  55. }
  56. $this->_aHandlers[$aHandler['alert_unit'] . (!empty($aHandler['alert_action']) ? '_' . $aHandler['alert_action'] :'')] = $aHandler;
  57. }
  58. $sHideTimeline = getParam($sOptionPrefix . 'events_hide');
  59. if(!empty($sHideTimeline))
  60. $this->_aHandlersHidden = explode(',', $sHideTimeline);
  61. }
  62. public function getHandlerDescriptor()
  63. {
  64. return $this->_aHandlerDescriptor;
  65. }
  66. public function getHandlersMethod()
  67. {
  68. return $this->_sHandlersMethod;
  69. }
  70. public function isHandler($sKey = '')
  71. {
  72. return isset($this->_aHandlers[$sKey]);
  73. }
  74. public function getHandlers($sKey = '')
  75. {
  76. if($sKey == '')
  77. return $this->_aHandlers;
  78. return isset($this->_aHandlers[$sKey]) ? $this->_aHandlers[$sKey] : '';
  79. }
  80. public function getHandlersHidden()
  81. {
  82. return $this->_aHandlersHidden;
  83. }
  84. public function getPerPage($sType = 'default')
  85. {
  86. if(empty($sType))
  87. return $this->_aPerPage;
  88. return isset($this->_aPerPage[$sType]) ? $this->_aPerPage[$sType] : '';
  89. }
  90. public function getHtmlIds($sType, $sKey = '')
  91. {
  92. if(empty($sKey))
  93. return isset($this->_aHtmlIds[$sType]) ? $this->_aHtmlIds[$sType] : array();
  94. return isset($this->_aHtmlIds[$sType][$sKey]) ? $this->_aHtmlIds[$sType][$sKey] : '';
  95. }
  96. public function getAnimationEffect()
  97. {
  98. return $this->_sAnimationEffect;
  99. }
  100. public function getAnimationSpeed()
  101. {
  102. return $this->_iAnimationSpeed;
  103. }
  104. public function getPrivacyViewDefault()
  105. {
  106. return $this->_iPrivacyViewDefault;
  107. }
  108. }
  109. /** @} */