BxGroupsPrivacy.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. class BxGroupsPrivacy extends BxBaseModProfilePrivacy
  12. {
  13. function __construct($aOptions, $oTemplate = false)
  14. {
  15. $this->MODULE = 'bx_groups';
  16. parent::__construct($aOptions, $oTemplate);
  17. }
  18. /**
  19. * Check whethere viewer is a member of dynamic group.
  20. *
  21. * @param mixed $mixedGroupId dynamic group ID.
  22. * @param integer $iObjectOwnerId object owner ID.
  23. * @param integer $iViewerId viewer ID.
  24. * @return boolean result of operation.
  25. */
  26. function isDynamicGroupMember($mixedGroupId, $iObjectOwnerId, $iViewerId, $iObjectId)
  27. {
  28. if ('c' == $mixedGroupId)
  29. return $this->isClosedGroupAccess($iObjectOwnerId, $iViewerId, $iObjectId);
  30. if ('s' == $mixedGroupId)
  31. return $this->isSecretGroupAccess($iObjectOwnerId, $iViewerId, $iObjectId);
  32. return false;
  33. }
  34. function isClosedGroupAccess ($iObjectOwnerId, $iViewerId, $iObjectId)
  35. {
  36. if (!($oConnection = BxDolConnection::getObjectInstance($this->_oModule->_oConfig->CNF['OBJECT_CONNECTIONS'])))
  37. return false;
  38. $oGroupProfile = BxDolProfile::getInstanceByContentAndType($iObjectId, $this->MODULE);
  39. return $oConnection->isConnected($iViewerId, $oGroupProfile->id(), true);
  40. }
  41. function isSecretGroupAccess ($iObjectOwnerId, $iViewerId, $iObjectId)
  42. {
  43. return $this->isClosedGroupAccess($iObjectOwnerId, $iViewerId, $iObjectId);
  44. }
  45. static function getGroupChooser ($sObject, $iOwnerId = 0, $aParams = array())
  46. {
  47. if (!$iOwnerId)
  48. $iOwnerId = bx_get_logged_profile_id();
  49. $aParams['dynamic_groups'] = array(
  50. array ('key' => '', 'value' => '----'),
  51. array ('key' => 'c', 'value' => _t('_bx_groups_privacy_group_closed')),
  52. array ('key' => 's', 'value' => _t('_bx_groups_privacy_group_secret')),
  53. );
  54. return parent::getGroupChooser($sObject, $iOwnerId, $aParams);
  55. }
  56. }
  57. /** @} */