BxReputationConfig.php 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. // database tables
  19. 'TABLE_EVENTS' => $aModule['db_prefix'] . 'events',
  20. 'TABLE_LEVELS' => $aModule['db_prefix'] . 'levels',
  21. 'TABLE_PROFILES' => $aModule['db_prefix'] . 'profiles',
  22. 'TABLE_PROFILES_LEVELS' => $aModule['db_prefix'] . 'profiles_levels',
  23. // database fields
  24. 'FIELD_LEVEL_NAME' => 'name',
  25. 'FIELD_LEVEL_ICON' => 'icon',
  26. // page URIs
  27. 'URL_LEADERBOARD' => 'page.php?i=leaderboard',
  28. 'URL_HISTORY' => 'page.php?i=points-history',
  29. // some params
  30. 'PARAM_MULTILEVEL' => 'bx_reputation_enable_multilevel',
  31. 'PARAM_LEADERBOARD_LIMIT' => 'bx_reputation_leaderboard_limit',
  32. 'PARAM_HISTORY_LIMIT' => 'bx_reputation_history_limit',
  33. // objects
  34. 'OBJECT_FORM_HANDLER' => 'bx_reputation_handler',
  35. 'OBJECT_FORM_HANDLER_DISPLAY_EDIT' => 'bx_reputation_handler_edit',
  36. 'OBJECT_FORM_LEVEL' => 'bx_reputation_level',
  37. 'OBJECT_FORM_LEVEL_DISPLAY_ADD' => 'bx_reputation_level_add',
  38. 'OBJECT_FORM_LEVEL_DISPLAY_EDIT' => 'bx_reputation_level_edit',
  39. 'OBJECT_GRID_HANDLERS' => 'bx_reputation_handlers',
  40. 'OBJECT_GRID_LEVELS' => 'bx_reputation_levels',
  41. // some language keys
  42. 'T' => [
  43. 'grid_action_err_perform' => '_bx_reputation_grid_action_err_perform',
  44. 'popup_title_handler_edit' => '_bx_reputation_popup_title_handler_edit',
  45. 'popup_title_level_add' => '_bx_reputation_popup_title_level_add',
  46. 'popup_title_level_edit' => '_bx_reputation_popup_title_level_edit',
  47. 'filter_item_select_one_filter1' => '_bx_reputation_grid_filter_item_title_hdr_select_one_filter1',
  48. 'err_cannot_perform' => '_bx_reputation_err_cannot_perform',
  49. ]
  50. ];
  51. $this->_aJsClasses = [
  52. 'handlers' => 'BxReputationHandlers',
  53. 'levels' => 'BxReputationLevels',
  54. ];
  55. $this->_aJsObjects = [
  56. 'handlers' => 'oBxReputationHandlers',
  57. 'levels' => 'oBxReputationLevels',
  58. ];
  59. $sHtmlPrefix = str_replace('_', '-', $this->_sName);
  60. $this->_aHtmlIds = [
  61. 'handler_popup' => $sHtmlPrefix . '-handler-popup',
  62. 'level_popup' => $sHtmlPrefix . '-level-popup',
  63. ];
  64. $this->_aHandlerFields = ['group', 'type', 'alert_unit', 'alert_action', 'points_active', 'points_passive'];
  65. $this->_aHandlerDescriptor = [];
  66. $this->_sHandlersMethod = 'get_reputation_data';
  67. }
  68. public function init(&$oDb)
  69. {
  70. parent::init($oDb);
  71. }
  72. public function isMultilevel()
  73. {
  74. return getParam($this->CNF['PARAM_MULTILEVEL']) == 'on';
  75. }
  76. public function getLevelName($sName)
  77. {
  78. return uriGenerate($sName, $this->CNF['TABLE_LEVELS'], $this->CNF['FIELD_LEVEL_NAME'], ['lowercase' => false]);
  79. }
  80. }
  81. /** @} */