1
0

BxBaseModProfileConfig.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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 isRoles()
  50. {
  51. if($this->_aRoles === false)
  52. $this->_initRoles();
  53. return $this->_bRoles;
  54. }
  55. public function isMultiRoles()
  56. {
  57. return !empty($this->CNF['PARAM_MMODE']) && getParam($this->CNF['PARAM_MMODE']) == BX_BASE_MOD_GROUPS_MMODE_MULTI_ROLES;
  58. }
  59. public function getRoles()
  60. {
  61. if($this->_aRoles === false)
  62. $this->_initRoles();
  63. return $this->_aRoles;
  64. }
  65. protected function _initRoles()
  66. {
  67. if(empty($this->CNF['OBJECT_PRE_LIST_ROLES']))
  68. return;
  69. $this->_aRoles = BxDolFormQuery::getDataItems($this->CNF['OBJECT_PRE_LIST_ROLES']);
  70. $this->_bRoles = !empty($this->_aRoles) && is_array($this->_aRoles);
  71. }
  72. public function getConnectionToFunctionCheck()
  73. {
  74. return $this->_aConnectionToFunctionCheck;
  75. }
  76. }
  77. /** @} */