BxTimelinePrivacy.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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 Timeline Timeline
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. class BxTimelinePrivacy extends BxBaseModNotificationsPrivacy
  12. {
  13. protected $_oModule;
  14. public function __construct ($aOptions, $oTemplate = false)
  15. {
  16. parent::__construct ($aOptions, $oTemplate);
  17. $this->_oModule = BxDolModule::getInstance('bx_timeline');
  18. }
  19. public function addSpaces($aValues, $iOwnerId, $aParams)
  20. {
  21. if(!$this->_aObject['spaces'])
  22. return $aValues;
  23. if(!empty($aParams['display']) && $aParams['display'] != $this->_oModule->_oConfig->getObject('form_display_post_add'))
  24. return $aValues;
  25. $sConnections = $this->_oModule->_oConfig->getObject('conn_subscriptions');
  26. $aConnections = BxDolConnection::getObjectInstance($sConnections)->getConnectedContent($iOwnerId);
  27. $aCnnGroups = array();
  28. foreach($aConnections as $iId) {
  29. $oCnnProfile = BxDolProfile::getInstance($iId);
  30. if(!$oCnnProfile)
  31. continue;
  32. $sCnnProfileModule = $oCnnProfile->getModule();
  33. $sCnnProfileMethod = 'check_allowed_post_in_profile';
  34. if(!BxDolRequest::serviceExists($sCnnProfileModule, $sCnnProfileMethod))
  35. continue;
  36. $mixedCheckResult = bx_srv($sCnnProfileModule, $sCnnProfileMethod, array($oCnnProfile->getContentId(), $iOwnerId));
  37. if($mixedCheckResult !== CHECK_ACTION_RESULT_ALLOWED)
  38. continue;
  39. $aCnnGroups[$sCnnProfileModule][] = array('key' => -$iId, 'value' => $oCnnProfile->getDisplayName());
  40. }
  41. ksort($aCnnGroups);
  42. foreach($aCnnGroups as $sCnnGroup => $aCnnGroup) {
  43. $aValues[] = array('type' => 'group_header', 'value' => mb_strtoupper(_t('_bx_timeline_form_post_input_owner_id_following_group', _t('_' . $sCnnGroup))));
  44. if(!empty($aCnnGroup) && is_array($aCnnGroup))
  45. $aValues = array_merge($aValues, $aCnnGroup);
  46. $aValues[] = array('type' => 'group_end');
  47. }
  48. return $aValues;
  49. }
  50. }
  51. /** @} */