1
0

BxBaseModProfileInstaller.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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 BaseProfile Base classes for profile modules
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. class BxBaseModProfileInstaller extends BxBaseModGeneralInstaller
  12. {
  13. protected $_sParamDefaultProfileType;
  14. function __construct($aConfig)
  15. {
  16. parent::__construct($aConfig);
  17. $this->_sParamDefaultProfileType = 'sys_account_default_profile_type';
  18. }
  19. function enable($aParams)
  20. {
  21. $aResult = parent::enable($aParams);
  22. if(BxDolService::call($this->_aConfig['name'], 'act_as_profile') !== true)
  23. return $aResult;
  24. if($aResult['result'] && getParam($this->_sParamDefaultProfileType) == '')
  25. setParam($this->_sParamDefaultProfileType, $this->_aConfig['name']);
  26. return $aResult;
  27. }
  28. function disable($aParams)
  29. {
  30. $aResult = parent::disable($aParams);
  31. if(BxDolService::call($this->_aConfig['name'], 'act_as_profile') !== true)
  32. return $aResult;
  33. if($aResult['result'] && getParam($this->_sParamDefaultProfileType) == $this->_aConfig['name'])
  34. setParam($this->_sParamDefaultProfileType, '');
  35. if ($aResult['result']) { // disabling was successful
  36. // TODO: switch accounts context which active profiles belong to this module
  37. }
  38. return $aResult;
  39. }
  40. }
  41. /** @} */