1
0

BxBaseModGroupsPrivacy.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) UNA, Inc - https://una.io
  4. * MIT License - https://opensource.org/licenses/MIT
  5. *
  6. * @defgroup BaseGroups Base classes for groups modules
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. class BxBaseModGroupsPrivacy extends BxBaseModProfilePrivacy
  12. {
  13. public function __construct($aOptions, $oTemplate = false)
  14. {
  15. parent::__construct($aOptions, $oTemplate);
  16. $this->_aPrivacyParticallyVisible = array_merge($this->_aPrivacyParticallyVisible, array('c', BX_DOL_PG_FRIENDS));
  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. public 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. public 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. public 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('_sys_ps_group_title_closed')),
  52. array ('key' => 's', 'value' => _t('_sys_ps_group_title_secret')),
  53. );
  54. return parent::getGroupChooser($sObject, $iOwnerId, $aParams);
  55. }
  56. protected function getObjectInfo($sAction, $iObjectId)
  57. {
  58. return BxDolPrivacy::getObjectInfo($sAction, $iObjectId);
  59. }
  60. }
  61. /** @} */