BxBaseModGroupsPrivacy.php 2.2 KB

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