BxWorkspacesGridAdministration.php 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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 Workspaces Workspaces
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. class BxWorkspacesGridAdministration extends BxBaseModProfileGridAdministration
  12. {
  13. protected $_sFilter2Name;
  14. protected $_sFilter2Value;
  15. protected $_aFilter2Values;
  16. protected $_sConfirmationType;
  17. public function __construct ($aOptions, $oTemplate = false)
  18. {
  19. $this->MODULE = 'bx_workspaces';
  20. parent::__construct ($aOptions, $oTemplate);
  21. $CNF = &$this->_oModule->_oConfig->CNF;
  22. $this->_sFilter2Name = 'filter2';
  23. $aTmp = array();
  24. BxDolAclQuery::getInstance()->getLevels(array('type' => 'all_active_not_automatic_pair'), $aTmp);
  25. foreach ($aTmp as $sKey => $sValue) {
  26. $this->_aFilter2Values["level" . $sKey] = $sValue;
  27. }
  28. $sFilter2 = bx_get($this->_sFilter2Name);
  29. if(!empty($sFilter2)) {
  30. $this->_sFilter2Value = bx_process_input($sFilter2);
  31. $this->_aQueryAppend[$this->_sFilter2Name] = $this->_sFilter2Value;
  32. }
  33. $this->_sConfirmationType = getParam('sys_account_confirmation_type');
  34. if ($this->_sConfirmationType != BX_ACCOUNT_CONFIRMATION_NONE)
  35. $this->_aFilter1Values['unconfirmed'] = $CNF['T']['filter_item_unconfirmed'];
  36. }
  37. protected function _getDataSql($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage)
  38. {
  39. if(strpos($sFilter, $this->_sParamsDivider) !== false)
  40. list($this->_sFilter1Value, $this->_sFilter2Value, $sFilter) = explode($this->_sParamsDivider, $sFilter);
  41. if(!empty($this->_sFilter1Value)){
  42. if ($this->_sFilter1Value == 'unconfirmed'){
  43. switch ($this->_sConfirmationType) {
  44. case BX_ACCOUNT_CONFIRMATION_EMAIL:
  45. $this->_aOptions['source'] .= $this->_oModule->_oDb->prepareAsString(" AND `ta`.`email_confirmed` = 0 ");
  46. break;
  47. case BX_ACCOUNT_CONFIRMATION_PHONE:
  48. $this->_aOptions['source'] .= $this->_oModule->_oDb->prepareAsString(" AND `ta`.`phone_confirmed` = 0 ");
  49. break;
  50. case BX_ACCOUNT_CONFIRMATION_EMAIL_PHONE:
  51. $this->_aOptions['source'] .= $this->_oModule->_oDb->prepareAsString(" AND (`ta`.`email_confirmed` = 0 AND `ta`.`phone_confirmed` = 0) ");
  52. break;
  53. }
  54. }
  55. else{
  56. $this->_aOptions['source'] .= $this->_oModule->_oDb->prepareAsString(" AND `tp`.`status`=?", $this->_sFilter1Value);
  57. }
  58. }
  59. if(!empty($this->_sFilter2Value)){
  60. $iLevel = intval(str_replace("level", "", $this->_sFilter2Value));
  61. if ($iLevel <> 3)
  62. $this->_aOptions['source'] .= $this->_oModule->_oDb->prepareAsString(" AND `tp`.`id` IN (SELECT `IDMember` FROM `sys_acl_levels_members` WHERE IDLevel = ?) ", $iLevel);
  63. else
  64. $this->_aOptions['source'] .= $this->_oModule->_oDb->prepareAsString(" AND `tp`.`id` NOT IN (SELECT `IDMember` FROM `sys_acl_levels_members`) ");
  65. }
  66. return parent::_getDataSqlInner($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage);
  67. }
  68. protected function _getFilterControls()
  69. {
  70. parent::_getFilterControls();
  71. return $this->_getFilterSelectOne($this->_sFilter1Name, $this->_sFilter1Value, $this->_aFilter1Values) . $this->_getFilterSelectOne($this->_sFilter2Name, $this->_sFilter2Value, $this->_aFilter2Values) . $this->_getSearchInput();
  72. }
  73. }
  74. /** @} */