BxBaseModNotificationsConfig.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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 DolphinModules
  8. *
  9. * @{
  10. */
  11. bx_import('BxBaseModGeneralConfig');
  12. class BxBaseModNotificationsConfig extends BxBaseModGeneralConfig
  13. {
  14. protected $_oDb;
  15. protected $_aPrefixes;
  16. protected $_aObjects;
  17. protected $_aHandlerDescriptor;
  18. protected $_sHandlersMethod;
  19. protected $_aHandlers;
  20. protected $_aHandlersHidden;
  21. protected $_aJsClass;
  22. protected $_aJsObjects;
  23. protected $_aPerPage;
  24. protected $_aHtmlIds;
  25. protected $_sAnimationEffect;
  26. protected $_iAnimationSpeed;
  27. protected $_iPrivacyViewDefault;
  28. function __construct($aModule)
  29. {
  30. parent::__construct($aModule);
  31. $this->_aPrefixes = array();
  32. $this->_aObjects = array(
  33. 'alert' => $this->_sName,
  34. 'conn_subscriptions' => 'sys_profiles_subscriptions'
  35. );
  36. $this->_aHandlerDescriptor = array();
  37. $this->_sHandlersMethod = '';
  38. $this->_aHandlersHidden = array();
  39. $this->_aHandlers = array();
  40. $this->_aJsClass = array();
  41. $this->_aJsObjects = array();
  42. $this->_aPerPage = array();
  43. $this->_aHtmlIds = array();
  44. $this->_sAnimationEffect = 'fade';
  45. $this->_iAnimationSpeed = 'slow';
  46. $this->_iPrivacyViewDefault = BX_DOL_PG_ALL;
  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 getPrefix($sType = '')
  66. {
  67. if(empty($sType))
  68. return $this->_aPrefixes;
  69. return $this->_aPrefixes[$sType];
  70. }
  71. public function getObject($sType = '')
  72. {
  73. if(empty($sType))
  74. return $this->_aObjects;
  75. return $this->_aObjects[$sType];
  76. }
  77. public function getHandlerDescriptor()
  78. {
  79. return $this->_aHandlerDescriptor;
  80. }
  81. public function getHandlersMethod()
  82. {
  83. return $this->_sHandlersMethod;
  84. }
  85. public function isHandler($sKey = '')
  86. {
  87. return isset($this->_aHandlers[$sKey]);
  88. }
  89. public function getHandlers($sKey = '')
  90. {
  91. if($sKey == '')
  92. return $this->_aHandlers;
  93. return $this->_aHandlers[$sKey];
  94. }
  95. public function getHandlersHidden()
  96. {
  97. return $this->_aHandlersHidden;
  98. }
  99. public function getJsClass($sType)
  100. {
  101. return $this->_aJsClass[$sType];
  102. }
  103. public function getJsObject($sType)
  104. {
  105. return $this->_aJsObjects[$sType];
  106. }
  107. public function getPerPage($sType = 'default')
  108. {
  109. if(empty($sType))
  110. return $this->_aPerPage;
  111. return $this->_aPerPage[$sType];
  112. }
  113. public function getHtmlIds($sType, $sKey = '')
  114. {
  115. if(empty($sKey))
  116. return $this->_aHtmlIds[$sType];
  117. return $this->_aHtmlIds[$sType][$sKey];
  118. }
  119. public function getAnimationEffect()
  120. {
  121. return $this->_sAnimationEffect;
  122. }
  123. public function getAnimationSpeed()
  124. {
  125. return $this->_iAnimationSpeed;
  126. }
  127. public function getPrivacyViewDefault()
  128. {
  129. return $this->_iPrivacyViewDefault;
  130. }
  131. }
  132. /** @} */