BxGroupsModule.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 serviceActAsProfile ()
  21. {
  22. return false;
  23. }
  24. public function servicePrepareFields ($aFieldsProfile)
  25. {
  26. $aFieldsProfile['group_name'] = $aFieldsProfile['name'];
  27. $aFieldsProfile['group_desc'] = isset($aFieldsProfile['description']) ? $aFieldsProfile['description'] : '';
  28. unset($aFieldsProfile['name']);
  29. unset($aFieldsProfile['description']);
  30. return $aFieldsProfile;
  31. }
  32. public function serviceFansTable ()
  33. {
  34. $oGrid = BxDolGrid::getObjectInstance('bx_groups_fans');
  35. if (!$oGrid)
  36. return false;
  37. return $oGrid->getCode();
  38. }
  39. public function serviceFans ($iContentId = 0)
  40. {
  41. if (!$iContentId)
  42. $iContentId = bx_process_input(bx_get('id'), BX_DATA_INT);
  43. if (!$iContentId)
  44. return false;
  45. $aContentInfo = $this->_oDb->getContentInfoById($iContentId);
  46. if (!$aContentInfo)
  47. return false;
  48. bx_import('BxDolConnection');
  49. $s = $this->serviceBrowseConnectionsQuick ($iContentId, 'bx_groups_fans', BX_CONNECTIONS_CONTENT_TYPE_CONTENT, true);
  50. if (!$s)
  51. return MsgBox(_t('_sys_txt_empty'));
  52. return $s;
  53. }
  54. /**
  55. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden.
  56. */
  57. public function checkAllowedFanAdd (&$aDataEntry, $isPerformAction = false)
  58. {
  59. return $this->_checkAllowedConnectContent ($aDataEntry, $isPerformAction, 'bx_groups_fans', true, false);
  60. }
  61. /**
  62. * @return CHECK_ACTION_RESULT_ALLOWED if access is granted or error message if access is forbidden.
  63. */
  64. public function checkAllowedFanRemove (&$aDataEntry, $isPerformAction = false)
  65. {
  66. if (CHECK_ACTION_RESULT_ALLOWED === $this->_checkAllowedConnectContent ($aDataEntry, $isPerformAction, 'sys_profiles_friends', false, true, true))
  67. return CHECK_ACTION_RESULT_ALLOWED;
  68. return $this->_checkAllowedConnectContent ($aDataEntry, $isPerformAction, 'bx_groups_fans', false, true, false);
  69. }
  70. }
  71. /** @} */