BxGroupsModule.php 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
  4. * CC-BY License - http://creativecommons.org/licenses/by/3.0/
  5. *
  6. * @defgroup Groups Groups
  7. * @ingroup TridentModules
  8. *
  9. * @{
  10. */
  11. /**
  12. * Groups profiles module.
  13. */
  14. class BxGroupsModule extends BxBaseModProfileModule
  15. {
  16. function __construct(&$aModule)
  17. {
  18. parent::__construct($aModule);
  19. }
  20. public function serviceGetMenuSetNameForMenuTrigger ($sMenuTriggerName)
  21. {
  22. if ('trigger_profile_view_submenu' == $sMenuTriggerName)
  23. return '';
  24. elseif ('trigger_group_view_submenu' == $sMenuTriggerName)
  25. return $this->_oConfig->CNF['OBJECT_MENU_SUBMENU_VIEW_ENTRY'];
  26. else
  27. return parent::serviceGetMenuSetNameForMenuTrigger ($sMenuTriggerName);
  28. }
  29. public function serviceActAsProfile ()
  30. {
  31. return false;
  32. }
  33. public function servicePrepareFields ($aFieldsProfile)
  34. {
  35. $aFieldsProfile['group_name'] = $aFieldsProfile['name'];
  36. $aFieldsProfile['group_desc'] = isset($aFieldsProfile['description']) ? $aFieldsProfile['description'] : '';
  37. unset($aFieldsProfile['name']);
  38. unset($aFieldsProfile['description']);
  39. return $aFieldsProfile;
  40. }
  41. public function serviceFansTable ()
  42. {
  43. $oGrid = BxDolGrid::getObjectInstance('bx_groups_fans');
  44. if (!$oGrid)
  45. return false;
  46. return $oGrid->getCode();
  47. }
  48. public function serviceFans ($iContentId = 0)
  49. {
  50. if (!$iContentId)
  51. $iContentId = bx_process_input(bx_get('id'), BX_DATA_INT);
  52. if (!$iContentId)
  53. return false;
  54. $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
  55. if (!$aContentInfo)
  56. return false;
  57. bx_import('BxDolConnection');
  58. $s = $this->serviceBrowseConnectionsQuick ($iContentId, 'bx_groups_fans', BX_CONNECTIONS_CONTENT_TYPE_CONTENT, true);
  59. if (!$s)
  60. return MsgBox(_t('_sys_txt_empty'));
  61. return $s;
  62. }
  63. /**
  64. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden.
  65. */
  66. public function checkAllowedFanAdd (&$aDataEntry, $isPerformAction = false)
  67. {
  68. return $this->_checkAllowedConnectContent ($aDataEntry, $isPerformAction, 'bx_groups_fans', true, false);
  69. }
  70. /**
  71. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden.
  72. */
  73. public function checkAllowedFanRemove (&$aDataEntry, $isPerformAction = false)
  74. {
  75. if (CHECK_ACTION_RESULT_ALLOWED === $this->_checkAllowedConnectContent ($aDataEntry, $isPerformAction, 'sys_profiles_friends', false, true, true))
  76. return CHECK_ACTION_RESULT_ALLOWED;
  77. return $this->_checkAllowedConnectContent ($aDataEntry, $isPerformAction, 'bx_groups_fans', false, true, false);
  78. }
  79. }
  80. /** @} */