BxGroupsModule.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. public function checkAllowedManageAdmins ($mixedDataEntry, $isPerformAction = false)
  71. {
  72. $aDataEntry = is_array($mixedDataEntry) ? $mixedDataEntry : $this->_oDb->getContentInfoById((int)$mixedDataEntry);
  73. return parent::checkAllowedEdit ($aDataEntry, $isPerformAction);
  74. }
  75. public function checkAllowedEdit ($aDataEntry, $isPerformAction = false)
  76. {
  77. if ($this->_oDb->isAdmin($aDataEntry[$this->_oConfig->CNF['FIELD_ID']], bx_get_logged_profile_id()))
  78. return CHECK_ACTION_RESULT_ALLOWED;
  79. return parent::checkAllowedEdit ($aDataEntry, $isPerformAction);
  80. }
  81. public function checkAllowedChangeCover ($aDataEntry, $isPerformAction = false)
  82. {
  83. if ($this->_oDb->isAdmin($aDataEntry[$this->_oConfig->CNF['FIELD_ID']], bx_get_logged_profile_id()))
  84. return CHECK_ACTION_RESULT_ALLOWED;
  85. return parent::checkAllowedChangeCover ($aDataEntry, $isPerformAction);
  86. }
  87. public function checkAllowedDelete (&$aDataEntry, $isPerformAction = false)
  88. {
  89. if ($this->_oDb->isAdmin($aDataEntry[$this->_oConfig->CNF['FIELD_ID']], bx_get_logged_profile_id()))
  90. return CHECK_ACTION_RESULT_ALLOWED;
  91. return parent::checkAllowedDelete ($aDataEntry, $isPerformAction);
  92. }
  93. }
  94. /** @} */