BxReputationConfig.php 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. 'PARAM_ACTIONS_LIMIT' => 'bx_reputation_actions_limit',
  34. // objects
  35. 'OBJECT_FORM_HANDLER' => 'bx_reputation_handler',
  36. 'OBJECT_FORM_HANDLER_DISPLAY_EDIT' => 'bx_reputation_handler_edit',
  37. 'OBJECT_FORM_LEVEL' => 'bx_reputation_level',
  38. 'OBJECT_FORM_LEVEL_DISPLAY_ADD' => 'bx_reputation_level_add',
  39. 'OBJECT_FORM_LEVEL_DISPLAY_EDIT' => 'bx_reputation_level_edit',
  40. 'OBJECT_GRID_HANDLERS' => 'bx_reputation_handlers',
  41. 'OBJECT_GRID_LEVELS' => 'bx_reputation_levels',
  42. // some language keys
  43. 'T' => [
  44. 'grid_action_err_perform' => '_bx_reputation_grid_action_err_perform',
  45. 'popup_title_handler_edit' => '_bx_reputation_popup_title_handler_edit',
  46. 'popup_title_level_add' => '_bx_reputation_popup_title_level_add',
  47. 'popup_title_level_edit' => '_bx_reputation_popup_title_level_edit',
  48. 'filter_item_select_one_filter1' => '_bx_reputation_grid_filter_item_title_hdr_select_one_filter1',
  49. 'err_cannot_perform' => '_bx_reputation_err_cannot_perform',
  50. ]
  51. ];
  52. $this->_aJsClasses = [
  53. 'handlers' => 'BxReputationHandlers',
  54. 'levels' => 'BxReputationLevels',
  55. ];
  56. $this->_aJsObjects = [
  57. 'handlers' => 'oBxReputationHandlers',
  58. 'levels' => 'oBxReputationLevels',
  59. ];
  60. $sHtmlPrefix = str_replace('_', '-', $this->_sName);
  61. $this->_aHtmlIds = [
  62. 'handler_popup' => $sHtmlPrefix . '-handler-popup',
  63. 'level_popup' => $sHtmlPrefix . '-level-popup',
  64. ];
  65. $this->_aHandlerFields = ['group', 'type', 'alert_unit', 'alert_action', 'points_active', 'points_passive'];
  66. $this->_aHandlerDescriptor = [];
  67. $this->_sHandlersMethod = 'get_reputation_data';
  68. }
  69. public function init(&$oDb)
  70. {
  71. parent::init($oDb);
  72. }
  73. public function isMultilevel()
  74. {
  75. return getParam($this->CNF['PARAM_MULTILEVEL']) == 'on';
  76. }
  77. public function getLevelName($sName)
  78. {
  79. return uriGenerate($sName, $this->CNF['TABLE_LEVELS'], $this->CNF['FIELD_LEVEL_NAME'], ['lowercase' => false]);
  80. }
  81. }
  82. /** @} */