BxReputationGridManageLeaderboard.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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 BxReputationGridManageLeaderboard extends BxTemplGrid
  12. {
  13. protected $_sModule;
  14. protected $_oModule;
  15. protected $_iContextId;
  16. public function __construct ($aOptions, $oTemplate = false)
  17. {
  18. $this->_sModule = 'bx_reputation';
  19. $this->_oModule = BxDolModule::getInstance($this->_sModule);
  20. parent::__construct ($aOptions, $oTemplate);
  21. $this->_sDefaultSortingOrder = 'DESC';
  22. $this->_iContextId = 0;
  23. if(($iContextId = bx_get('context_id')) !== false)
  24. $this->setContextId($iContextId);
  25. }
  26. public function setContextId($iContextId)
  27. {
  28. $this->_iContextId = (int)$iContextId;
  29. $this->_aQueryAppend['context_id'] = $this->_iContextId;
  30. }
  31. protected function _getCellProfileId($mixedValue, $sKey, $aField, $aRow)
  32. {
  33. if($this->_bIsApi)
  34. return ['type' => 'profile', 'data' => BxDolProfile::getData($mixedValue)];
  35. if(($oProfile = BxDolProfile::getInstanceMagic($mixedValue)));
  36. $mixedValue = $oProfile->getUnit();
  37. return parent::_getCellDefault($mixedValue, $sKey, $aField, $aRow);
  38. }
  39. protected function _getCellPoints($mixedValue, $sKey, $aField, $aRow)
  40. {
  41. return parent::_getCellDefault($mixedValue, $sKey, $aField, $aRow);
  42. }
  43. protected function _getDataSql($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage)
  44. {
  45. $this->_aOptions['source'] .= $this->_oModule->_oDb->prepareAsString(" AND `context_id`=?", $this->_iContextId);
  46. return parent::_getDataSql($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage);
  47. }
  48. }
  49. /** @} */