BxBaseModProfileConfig.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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-friends' => 'checkAllowedFriends',
  26. 'profile-friend-add' => 'checkAllowedFriendAdd',
  27. 'profile-friend-remove' => 'checkAllowedFriendRemove',
  28. 'profile-relations' => 'checkAllowedRelations',
  29. 'profile-relation-add' => 'checkAllowedRelationAdd',
  30. 'profile-relation-remove' => 'checkAllowedRelationRemove',
  31. 'profile-subscriptions' => 'checkAllowedSubscriptions',
  32. 'profile-subscribe-add' => 'checkAllowedSubscribeAdd',
  33. 'profile-subscribe-remove' => 'checkAllowedSubscribeRemove',
  34. 'profile-actions-more' => 'checkAllowedViewMoreMenu',
  35. 'profile-set-acl-level' => 'checkAllowedSetMembership',
  36. 'convos-compose' => 'checkAllowedCompose',
  37. 'messenger' => 'checkAllowedCompose',
  38. );
  39. $this->_aConnectionToFunctionCheck = [
  40. 'sys_profiles_friends' => [
  41. 'friends' => 'checkAllowedFriends',
  42. 'add' => 'checkAllowedFriendAdd',
  43. 'remove' => 'checkAllowedFriendRemove'
  44. ],
  45. 'sys_profiles_subscriptions' => [
  46. 'subscriptions' => 'checkAllowedSubscriptions',
  47. 'add' => 'checkAllowedSubscribeAdd',
  48. 'remove' => 'checkAllowedSubscribeRemove'
  49. ]
  50. ];
  51. $this->_bRoles = false;
  52. $this->_aRoles = false;
  53. }
  54. public function isFriends()
  55. {
  56. return ($sKey = 'PARAM_FRIENDS') && (!isset($this->CNF[$sKey]) || getParam($this->CNF[$sKey]) == 'on');
  57. }
  58. public function isRoles()
  59. {
  60. if($this->_aRoles === false)
  61. $this->_initRoles();
  62. return $this->_bRoles;
  63. }
  64. public function isMultiRoles()
  65. {
  66. return !empty($this->CNF['PARAM_MMODE']) && getParam($this->CNF['PARAM_MMODE']) == BX_BASE_MOD_GROUPS_MMODE_MULTI_ROLES;
  67. }
  68. public function getRoles()
  69. {
  70. if($this->_aRoles === false)
  71. $this->_initRoles();
  72. return $this->_aRoles;
  73. }
  74. protected function _initRoles()
  75. {
  76. if(empty($this->CNF['OBJECT_PRE_LIST_ROLES']))
  77. return;
  78. $this->_aRoles = BxDolFormQuery::getDataItems($this->CNF['OBJECT_PRE_LIST_ROLES']);
  79. $this->_bRoles = !empty($this->_aRoles) && is_array($this->_aRoles);
  80. }
  81. public function getConnectionToFunctionCheck()
  82. {
  83. return $this->_aConnectionToFunctionCheck;
  84. }
  85. }
  86. /** @} */