BxGroupsPrivacy.php 2.2 KB

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