BxFilesPrivacy.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 Files Files
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. class BxFilesPrivacy extends BxTemplPrivacy
  12. {
  13. protected $_oModule;
  14. protected $_bCustomPrivacy = false;
  15. public function __construct($aOptions, $oTemplate = false)
  16. {
  17. parent::__construct($aOptions, $oTemplate);
  18. $this->_oModule = BxDolModule::getInstance('bx_files');
  19. }
  20. public function setCustomPrivacy($b)
  21. {
  22. $this->_bCustomPrivacy = $b;
  23. }
  24. public function isCustomPrivacy()
  25. {
  26. return $this->_bCustomPrivacy;
  27. }
  28. /**
  29. * Check whethere viewer is a member of dynamic group.
  30. *
  31. * @param mixed $mixedGroupId dynamic group ID.
  32. * @param integer $iObjectOwnerId object owner ID.
  33. * @param integer $iViewerId viewer ID.
  34. * @return boolean result of operation.
  35. */
  36. public function isDynamicGroupMember($mixedGroupId, $iObjectOwnerId, $iViewerId, $iObjectId)
  37. {
  38. $oGroupProfile = BxDolProfile::getInstance($iObjectOwnerId);
  39. if (!BxDolService::call($oGroupProfile->getModule(), 'is_group_profile'))
  40. return false;
  41. if ('a' == $mixedGroupId)
  42. return true;
  43. if ('m' == $mixedGroupId)
  44. return BxDolService::call($oGroupProfile->getModule(), 'is_fan', array($oGroupProfile->id(), $iViewerId));
  45. return false;
  46. }
  47. static function getGroupChooserCustom ($sObject, $bCustomPrivacy)
  48. {
  49. $iOwnerId = bx_get_logged_profile_id();
  50. $aParams = array();
  51. if ($bCustomPrivacy)
  52. $aParams['dynamic_groups'] = array(
  53. array ('key' => 'a', 'value' => _t('_bx_files_privacy_public')),
  54. array ('key' => 'm', 'value' => _t('_bx_files_privacy_participants')),
  55. );
  56. return parent::getGroupChooser($sObject, $iOwnerId, $aParams);
  57. }
  58. protected function getGroups()
  59. {
  60. return $this->_bCustomPrivacy ? array() : parent::getGroups();
  61. }
  62. }
  63. /** @} */