BxBaseModFilesPrivacy.php 2.1 KB

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