1
0

BxBaseModProfileConfig.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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. protected $_aRolesData;
  19. function __construct($aModule)
  20. {
  21. parent::__construct($aModule);
  22. $this->CNF = array(
  23. 'PARAM_MULTICAT_ENABLED' => false,
  24. );
  25. $this->_aMenuItems2MethodsActions = array (
  26. 'profile-friends' => 'checkAllowedFriends',
  27. 'profile-friend-add' => 'checkAllowedFriendAdd',
  28. 'profile-friend-remove' => 'checkAllowedFriendRemove',
  29. 'profile-relations' => 'checkAllowedRelations',
  30. 'profile-relation-add' => 'checkAllowedRelationAdd',
  31. 'profile-relation-remove' => 'checkAllowedRelationRemove',
  32. 'profile-subscriptions' => 'checkAllowedSubscriptions',
  33. 'profile-subscribe-add' => 'checkAllowedSubscribeAdd',
  34. 'profile-subscribe-remove' => 'checkAllowedSubscribeRemove',
  35. 'profile-actions-more' => 'checkAllowedViewMoreMenu',
  36. 'profile-set-acl-level' => 'checkAllowedSetMembership',
  37. 'convos-compose' => 'checkAllowedCompose',
  38. 'messenger' => 'checkAllowedCompose',
  39. );
  40. $this->_aConnectionToFunctionCheck = [
  41. 'sys_profiles_friends' => [
  42. 'friends' => 'checkAllowedFriends',
  43. 'add' => 'checkAllowedFriendAdd',
  44. 'remove' => 'checkAllowedFriendRemove'
  45. ],
  46. 'sys_profiles_subscriptions' => [
  47. 'subscriptions' => 'checkAllowedSubscriptions',
  48. 'add' => 'checkAllowedSubscribeAdd',
  49. 'remove' => 'checkAllowedSubscribeRemove'
  50. ]
  51. ];
  52. $this->_bRoles = false;
  53. $this->_aRoles = false;
  54. $this->_aRolesData = false;
  55. }
  56. public function isFriends()
  57. {
  58. return ($sKey = 'PARAM_FRIENDS') && (!isset($this->CNF[$sKey]) || getParam($this->CNF[$sKey]) == 'on');
  59. }
  60. public function isRoles()
  61. {
  62. if($this->_aRoles === false)
  63. $this->_initRoles();
  64. return $this->_bRoles;
  65. }
  66. public function isMultiRoles()
  67. {
  68. return !empty($this->CNF['PARAM_MMODE']) && getParam($this->CNF['PARAM_MMODE']) == BX_BASE_MOD_GROUPS_MMODE_MULTI_ROLES;
  69. }
  70. public function getRoles()
  71. {
  72. if($this->_aRoles === false)
  73. $this->_initRoles();
  74. return $this->_aRoles;
  75. }
  76. public function getRolesData()
  77. {
  78. if($this->_aRoles === false)
  79. $this->_initRoles();
  80. return $this->_aRolesData;
  81. }
  82. public function roleIdI2S($iValue)
  83. {
  84. return 'r' . $iValue;
  85. }
  86. public function roleIdS2I($sValue)
  87. {
  88. return (int)substr($sValue, 1);
  89. }
  90. protected function _initRoles()
  91. {
  92. $sList = '';
  93. if(!($sList = $this->CNF['OBJECT_PRE_LIST_ROLES'] ?? false))
  94. return;
  95. $this->_aRoles = BxDolFormQuery::getDataItems($sList);
  96. $this->_bRoles = !empty($this->_aRoles) && is_array($this->_aRoles);
  97. if($this->_bRoles)
  98. $this->_aRolesData = BxDolFormQuery::getDataItems($sList, false, BX_DATA_VALUES_ALL);
  99. }
  100. public function getConnectionToFunctionCheck()
  101. {
  102. return $this->_aConnectionToFunctionCheck;
  103. }
  104. }
  105. /** @} */