BxBaseModProfileConfig.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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 BxBaseModProfileConfig extends BxBaseModGeneralConfig
  12. {
  13. protected $_aMenuItems2MethodsActions = array();
  14. protected $_aMenuItems2MethodsSubmenu = array();
  15. protected $_aConnectionToFunctionCheck;
  16. protected $_bRoles;
  17. protected $_aRoles;
  18. function __construct($aModule)
  19. {
  20. parent::__construct($aModule);
  21. $this->CNF = array(
  22. 'PARAM_MULTICAT_ENABLED' => false,
  23. );
  24. $this->_aMenuItems2MethodsActions = array (
  25. 'profile-friend-add' => 'checkAllowedFriendAdd',
  26. 'profile-friend-remove' => 'checkAllowedFriendRemove',
  27. 'profile-relation-add' => 'checkAllowedRelationAdd',
  28. 'profile-relation-remove' => 'checkAllowedRelationRemove',
  29. 'profile-subscribe-add' => 'checkAllowedSubscribeAdd',
  30. 'profile-subscribe-remove' => 'checkAllowedSubscribeRemove',
  31. 'profile-actions-more' => 'checkAllowedViewMoreMenu',
  32. 'profile-set-acl-level' => 'checkAllowedSetMembership',
  33. 'convos-compose' => 'checkAllowedCompose',
  34. 'messenger' => 'checkAllowedCompose',
  35. );
  36. $this->_aConnectionToFunctionCheck = [
  37. 'sys_profiles_friends' => [
  38. 'add' => 'checkAllowedFriendAdd',
  39. 'remove' => 'checkAllowedFriendRemove'
  40. ],
  41. 'sys_profiles_subscriptions' => [
  42. 'add' => 'checkAllowedSubscribeAdd',
  43. 'remove' => 'checkAllowedSubscribeRemove'
  44. ]
  45. ];
  46. $this->_bRoles = false;
  47. $this->_aRoles = false;
  48. }
  49. public function isFriends()
  50. {
  51. return ($sKey = 'PARAM_FRIENDS') && (!isset($this->CNF[$sKey]) || getParam($this->CNF[$sKey]) == 'on');
  52. }
  53. public function isRoles()
  54. {
  55. if($this->_aRoles === false)
  56. $this->_initRoles();
  57. return $this->_bRoles;
  58. }
  59. public function isMultiRoles()
  60. {
  61. return !empty($this->CNF['PARAM_MMODE']) && getParam($this->CNF['PARAM_MMODE']) == BX_BASE_MOD_GROUPS_MMODE_MULTI_ROLES;
  62. }
  63. public function getRoles()
  64. {
  65. if($this->_aRoles === false)
  66. $this->_initRoles();
  67. return $this->_aRoles;
  68. }
  69. protected function _initRoles()
  70. {
  71. if(empty($this->CNF['OBJECT_PRE_LIST_ROLES']))
  72. return;
  73. $this->_aRoles = BxDolFormQuery::getDataItems($this->CNF['OBJECT_PRE_LIST_ROLES']);
  74. $this->_bRoles = !empty($this->_aRoles) && is_array($this->_aRoles);
  75. }
  76. public function getConnectionToFunctionCheck()
  77. {
  78. return $this->_aConnectionToFunctionCheck;
  79. }
  80. }
  81. /** @} */