BxDolCmtsGridAdministration.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 UnaCore UNA Core
  7. * @{
  8. */
  9. define('BX_DOL_MANAGE_TOOLS_ADMINISTRATION', 'administration');
  10. class BxDolCmtsGridAdministration extends BxTemplGrid
  11. {
  12. protected $_oCmts;
  13. protected $_sManageType;
  14. protected $_sParamsDivider;
  15. protected $_sFilter1Name;
  16. protected $_sFilter1Value;
  17. protected $_aFilter1Values;
  18. public function __construct ($aOptions, $oTemplate = false)
  19. {
  20. $this->_oCmts = null;
  21. $this->_sFilter1Name = 'filter1';
  22. $this->_aFilter1Values = ['' => _t('_adm_txt_select_module')];
  23. $aModules = BxDolModuleQuery::getInstance()->getModulesBy(array('type' => 'modules', 'active' => 1));
  24. foreach($aModules as $aModule) {
  25. $oModule = BxDolModule::getInstance($aModule['name']);
  26. if(!$oModule || !isset($oModule->_oConfig->CNF['OBJECT_COMMENTS']))
  27. continue;
  28. $this->_aFilter1Values[$aModule['name']] = $aModule['title'];
  29. }
  30. $sFilter1 = bx_get($this->_sFilter1Name);
  31. if(!empty($sFilter1)) {
  32. $this->_sFilter1Value = bx_process_input($sFilter1);
  33. $this->_aQueryAppend[$this->_sFilter1Name] = $this->_sFilter1Value;
  34. }
  35. if(!$oTemplate)
  36. $oTemplate = BxDolTemplate::getInstance();
  37. parent::__construct ($aOptions, $oTemplate);
  38. $this->_sManageType = BX_DOL_MANAGE_TOOLS_ADMINISTRATION;
  39. $this->_sParamsDivider = '#-#';
  40. $this->_sDefaultSortingOrder = 'DESC';
  41. }
  42. protected function _getDataSql($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage)
  43. {
  44. if(strpos($sFilter, $this->_sParamsDivider) !== false)
  45. list($this->_sFilter1Value, $sFilter) = explode($this->_sParamsDivider, $sFilter);
  46. if(empty($this->_sFilter1Value))
  47. return '';
  48. $oModule = BxDolModule::getInstance($this->_sFilter1Value);
  49. if(!$oModule)
  50. return '';
  51. $this->_oCmts = BxDolCmts::getObjectInstance($oModule->_oConfig->CNF['OBJECT_COMMENTS'], 0, false);
  52. if(!$this->_oCmts || !$this->_oCmts->isEnabled())
  53. return '';
  54. $this->_aOptions['source'] = $oModule->_oDb->prepareAsString("SELECT `sys_cmts_ids`.`id`, `sys_cmts_ids`.`cmt_id`, `sys_cmts_ids`.`reports`, `cmts`.*, `sys_accounts`.`email` FROM `sys_cmts_ids` INNER JOIN " . $this->_oCmts->getCommentsTableName() . " AS `cmts` ON `cmts`.`cmt_id`=`sys_cmts_ids`.`cmt_id` INNER JOIN `sys_profiles` ON `cmts`.`cmt_author_id`=`sys_profiles`.`id` INNER JOIN `sys_accounts` ON `sys_profiles`.`account_id`=`sys_accounts`.`id` WHERE `sys_cmts_ids`.`system_id`=?", $this->_oCmts->getSystemId());
  55. return parent::_getDataSql($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage);
  56. }
  57. }
  58. /** @} */