BxBaseModGroupsGridBans.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 BxBaseModGroupsGridBans extends BxDolGridConnections
  12. {
  13. protected $_oModule;
  14. protected $_sContentModule;
  15. protected $_iGroupProfileId;
  16. protected $_aContentInfo = [];
  17. protected $_bManageMembers;
  18. public function __construct ($aOptions, $oTemplate = false)
  19. {
  20. $this->_oModule = BxDolModule::getInstance($this->_sContentModule);
  21. $CNF = &$this->_oModule->_oConfig->CNF;
  22. $this->_sObjectConnections = 'sys_profiles_bans';
  23. parent::__construct ($aOptions, $oTemplate);
  24. if(!$this->_bInit)
  25. return;
  26. $this->_iGroupProfileId = $this->_oProfile->id();
  27. $this->_aContentInfo = $this->_oModule->_oDb->getContentInfoById($this->_oProfile->getContentId());
  28. if($this->_oModule->checkAllowedEdit($this->_aContentInfo) === CHECK_ACTION_RESULT_ALLOWED || $this->_iGroupProfileId == bx_get_logged_profile_id())
  29. $this->_bOwner = true;
  30. $this->_bManageMembers = $this->_oModule->checkAllowedManageFans($this->_iGroupProfileId) === CHECK_ACTION_RESULT_ALLOWED || $this->_oModule->checkAllowedManageAdmins($this->_iGroupProfileId) === CHECK_ACTION_RESULT_ALLOWED;
  31. $aSQLParts = $this->_oConnection->getConnectedContentAsSQLParts('p', 'id', $this->_iGroupProfileId, $this->_bOwner ? false : true);
  32. $this->addMarkers(array(
  33. 'profile_id' => $this->_iGroupProfileId,
  34. 'join_connections' => $aSQLParts['join'],
  35. 'content_module' => $this->_sContentModule,
  36. ));
  37. }
  38. protected function _getCellAdded ($mixedValue, $sKey, $aField, $aRow)
  39. {
  40. return parent::_getCellDefault(bx_time_js($mixedValue), $sKey, $aField, $aRow);
  41. }
  42. protected function _getActionDelete ($sType, $sKey, $a, $isSmall = false, $isDisabled = false, $aRow = array())
  43. {
  44. if (!$this->_bManageMembers)
  45. return $this->_bIsApi ? [] : '';
  46. if (isset($aRow[$this->_aOptions['field_id']]))
  47. $a['attr']['bx_grid_action_data'] = $aRow[$this->_aOptions['field_id']] . ':' . $this->_iGroupProfileId;
  48. return parent::_getActionDelete($sType, $sKey, $a, $isSmall, $isDisabled, $aRow);
  49. }
  50. protected function _delete ($mixedId)
  51. {
  52. list($iProfileId, $iContextId) = $this->__prepareIds($mixedId);
  53. if($this->_oConnection->isConnected($iContextId, $iProfileId))
  54. $a = $this->_oConnection->removeConnection($iContextId, $iProfileId);
  55. if(isset($a['err']) && $a['err'])
  56. return false;
  57. return true;
  58. }
  59. }
  60. /** @} */