BxReputationConfig.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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 Reputation Reputation
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. class BxReputationConfig extends BxBaseModNotificationsConfig
  12. {
  13. protected $_oDb;
  14. public function __construct($aModule)
  15. {
  16. parent::__construct($aModule);
  17. $this->CNF = [
  18. // module icon
  19. 'ICON' => 'star',
  20. // database tables
  21. 'TABLE_EVENTS' => $aModule['db_prefix'] . 'events',
  22. 'TABLE_LEVELS' => $aModule['db_prefix'] . 'levels',
  23. 'TABLE_PROFILES' => $aModule['db_prefix'] . 'profiles',
  24. 'TABLE_PROFILES_LEVELS' => $aModule['db_prefix'] . 'profiles_levels',
  25. // database fields
  26. 'FIELD_LEVEL_NAME' => 'name',
  27. 'FIELD_LEVEL_ICON' => 'icon',
  28. // page URIs
  29. 'URL_LEADERBOARD' => 'page.php?i=leaderboard',
  30. 'URL_MANAGE' => 'page.php?i=reputation-manage',
  31. 'URL_HISTORY' => 'page.php?i=points-history',
  32. // some params
  33. 'PARAM_MULTILEVEL' => 'bx_reputation_enable_multilevel',
  34. 'PARAM_LEADERBOARD_LIMIT' => 'bx_reputation_leaderboard_limit',
  35. 'PARAM_HISTORY_LIMIT' => 'bx_reputation_history_limit',
  36. 'PARAM_ACTIONS_LIMIT' => 'bx_reputation_actions_limit',
  37. // objects
  38. 'OBJECT_FORM_HANDLER' => 'bx_reputation_handler',
  39. 'OBJECT_FORM_HANDLER_DISPLAY_EDIT' => 'bx_reputation_handler_edit',
  40. 'OBJECT_FORM_LEVEL' => 'bx_reputation_level',
  41. 'OBJECT_FORM_LEVEL_DISPLAY_ADD' => 'bx_reputation_level_add',
  42. 'OBJECT_FORM_LEVEL_DISPLAY_EDIT' => 'bx_reputation_level_edit',
  43. 'OBJECT_MENU_SUBMENU' => 'bx_reputation_submenu',
  44. 'OBJECT_GRID_HANDLERS' => 'bx_reputation_handlers',
  45. 'OBJECT_GRID_LEVELS' => 'bx_reputation_levels',
  46. 'OBJECT_GRID_MANAGE_LEADERBOARD' => 'bx_reputation_manage_leaderboard',
  47. // some language keys
  48. 'T' => [
  49. 'grid_action_err_perform' => '_bx_reputation_grid_action_err_perform',
  50. 'popup_title_handler_edit' => '_bx_reputation_popup_title_handler_edit',
  51. 'popup_title_level_add' => '_bx_reputation_popup_title_level_add',
  52. 'popup_title_level_edit' => '_bx_reputation_popup_title_level_edit',
  53. 'filter_item_select_one_filter1' => '_bx_reputation_grid_filter_item_title_hdr_select_one_filter1',
  54. 'err_cannot_perform' => '_bx_reputation_err_cannot_perform',
  55. ]
  56. ];
  57. $this->_aJsClasses = [
  58. 'leaderboard' => 'BxReputationLeaderboard',
  59. 'handlers' => 'BxReputationHandlers',
  60. 'levels' => 'BxReputationLevels',
  61. ];
  62. $this->_aJsObjects = [
  63. 'leaderboard' => 'oBxReputationLeaderboard',
  64. 'handlers' => 'oBxReputationHandlers',
  65. 'levels' => 'oBxReputationLevels',
  66. ];
  67. $sHtmlPrefix = str_replace('_', '-', $this->_sName);
  68. $this->_aHtmlIds = [
  69. 'general' => [
  70. 'leaderboard' => $sHtmlPrefix . '-leaderboard-',
  71. 'filters_popup' => $sHtmlPrefix . '-filters-popup',
  72. 'handler_popup' => $sHtmlPrefix . '-handler-popup',
  73. 'level_popup' => $sHtmlPrefix . '-level-popup',
  74. ]
  75. ];
  76. $this->_aHandlerFields = ['group', 'type', 'alert_unit', 'alert_action', 'points_active', 'points_passive'];
  77. $this->_aHandlerDescriptor = [];
  78. $this->_sHandlersMethod = 'get_reputation_data';
  79. }
  80. public function init(&$oDb)
  81. {
  82. parent::init($oDb);
  83. }
  84. public function isMultilevel()
  85. {
  86. return getParam($this->CNF['PARAM_MULTILEVEL']) == 'on';
  87. }
  88. public function getLevelName($sName)
  89. {
  90. return uriGenerate($sName, $this->CNF['TABLE_LEVELS'], $this->CNF['FIELD_LEVEL_NAME'], ['lowercase' => false]);
  91. }
  92. }
  93. /** @} */