BxBaseModGroupsGridAdministration.php 3.6 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 BaseGroups Base classes for groups modules
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. class BxBaseModGroupsGridAdministration extends BxBaseModProfileGridAdministration
  12. {
  13. protected $_sFilter2Name;
  14. protected $_sFilter2Value;
  15. protected $_aFilter2Values;
  16. protected $_bContentFilter;
  17. public function __construct ($aOptions, $oTemplate = false)
  18. {
  19. parent::__construct ($aOptions, $oTemplate);
  20. $CNF = &$this->_oModule->_oConfig->CNF;
  21. if(($this->_bContentFilter = !empty($CNF['FIELD_CF'])) !== false) {
  22. $this->_sFilter2Name = 'filter2';
  23. $this->_aFilter2Values = BxDolFormQuery::getDataItems('sys_content_filter');
  24. if(($sFilter2 = bx_get($this->_sFilter2Name)) !== false) {
  25. $this->_sFilter2Value = bx_process_input($sFilter2);
  26. $this->_aQueryAppend[$this->_sFilter2Name] = $this->_sFilter2Value;
  27. }
  28. }
  29. }
  30. protected function _getActionAuditContext($sType, $sKey, $a, $isSmall = false, $isDisabled = false, $aRow = array())
  31. {
  32. if (!getParam('sys_audit_enable') || getParam('sys_audit_acl_levels') == '')
  33. return;
  34. $iProfileId = bx_get_logged_profile_id();
  35. if (!BxDolAcl::getInstance()->isMemberLevelInSet(explode(',', getParam('sys_audit_acl_levels')), $iProfileId))
  36. return;
  37. $CNF = &$this->_oModule->_oConfig->CNF;
  38. $oProfile = $this->_getProfileObject($aRow[$CNF['FIELD_ID']]);
  39. $sUrl = BX_DOL_URL_ROOT . 'page/audit-administration?context_id=' . $oProfile->id();
  40. $a['attr'] = array_merge($a['attr'], array(
  41. "onclick" => "window.open('" . $sUrl . "','_audit');"
  42. ));
  43. return $this->_getActionDefault ($sType, $sKey, $a, $isSmall, $isDisabled, $aRow);
  44. }
  45. protected function _getCellName($mixedValue, $sKey, $aField, $aRow)
  46. {
  47. $oProfile = $this->_getProfileObject($aRow['id']);
  48. return parent::_getCellDefault($oProfile->getUnit(0, array('template' => 'unit_wo_cover')), $sKey, $aField, $aRow);
  49. }
  50. protected function _getFilterControls()
  51. {
  52. parent::_getFilterControls();
  53. $sContent = $this->_getFilterSelectOne($this->_sFilter1Name, $this->_sFilter1Value, $this->_aFilter1Values);
  54. if($this->_bContentFilter)
  55. $sContent .= $this->_getFilterSelectOne($this->_sFilter2Name, $this->_sFilter2Value, $this->_aFilter2Values);
  56. $sContent .= $this->_getSearchInput();
  57. return $sContent;
  58. }
  59. protected function _getDataSql($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage)
  60. {
  61. $CNF = &$this->_oModule->_oConfig->CNF;
  62. if(strpos($sFilter, $this->_sParamsDivider) !== false) {
  63. $aFilters = explode($this->_sParamsDivider, $sFilter);
  64. if($this->_bContentFilter)
  65. list($this->_sFilter1Value, $this->_sFilter2Value, $sFilter) = $aFilters;
  66. else
  67. list($this->_sFilter1Value, $sFilter) = $aFilters;
  68. }
  69. if(!empty($this->_sFilter1Value))
  70. $this->_aOptions['source'] .= $this->_oModule->_oDb->prepareAsString(" AND `tp`.`status`=?", $this->_sFilter1Value);
  71. if(!empty($this->_sFilter2Value))
  72. $this->_aOptions['source'] .= $this->_oModule->_oDb->prepareAsString(" AND `" . $CNF['FIELD_CF'] . "`=?", $this->_sFilter2Value);
  73. return parent::_getDataSqlInner($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage);
  74. }
  75. }
  76. /** @} */