BxBaseModGroupsSearchResult.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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 BxBaseModGroupsSearchResult extends BxBaseModProfileSearchResult
  12. {
  13. public function __construct($sMode = '', $aParams = array())
  14. {
  15. if (!isset($aParams['unit_views'])) {
  16. if (!is_array($aParams))
  17. $aParams = [];
  18. $aParams['unit_views'] = array('gallery' => 'unit.html', 'showcase' => 'unit_with_cover_showcase.html');
  19. }
  20. parent::__construct($sMode, $aParams);
  21. }
  22. protected function addConditionsForPrivateContent($CNF, $oProfile, $aCustomGroup = array())
  23. {
  24. if(empty($CNF['OBJECT_PRIVACY_VIEW']))
  25. return;
  26. $oPrivacy = BxDolPrivacy::getObjectInstance($CNF['OBJECT_PRIVACY_VIEW']);
  27. if(!$oPrivacy)
  28. return;
  29. parent::addConditionsForPrivateContent($CNF, $oProfile, array_merge($aCustomGroup, $oPrivacy->getPartiallyVisiblePrivacyGroups()));
  30. }
  31. protected function addConditionsForAuthorStatus($CNF)
  32. {
  33. return;
  34. }
  35. protected function addConditionsForCf($CNF)
  36. {
  37. if(empty($CNF['FIELD_CF']))
  38. return;
  39. $oCf = BxDolContentFilter::getInstance();
  40. if(!$oCf->isEnabled())
  41. return;
  42. $aConditions = $oCf->getConditions($this->aCurrent['join']['profile']['table'], $CNF['FIELD_CF']);
  43. if(!empty($aConditions) && is_array($aConditions))
  44. $this->aCurrent['restriction'] = array_merge($this->aCurrent['restriction'], $aConditions);
  45. }
  46. protected function _setAuthorConditions($sMode, $aParams, &$oProfileAuthor)
  47. {
  48. $CNF = &$this->oModule->_oConfig->CNF;
  49. $oProfileAuthor = BxDolProfile::getInstance((int)$aParams['author']);
  50. if (!$oProfileAuthor)
  51. return false;
  52. $iProfileAuthor = $oProfileAuthor->id();
  53. $this->aCurrent['restriction']['owner']['value'] = $iProfileAuthor;
  54. if(!empty($aParams['per_page']))
  55. $this->aCurrent['paginate']['perPage'] = is_numeric($aParams['per_page']) ? (int)$aParams['per_page'] : (int)getParam($aParams['per_page']);
  56. $this->sBrowseUrl = 'page.php?i=' . $CNF['URI_JOINED_ENTRIES'] . '&profile_id={profile_id}';
  57. $this->aCurrent['title'] = _t($CNF['T']['txt_all_entries_by_author']);
  58. $this->aCurrent['rss']['link'] = 'modules/?r=' . $this->oModule->_oConfig->getUri() . '/rss/' . $sMode . '/' . $iProfileAuthor;
  59. return true;
  60. }
  61. protected function _setFavoriteConditions($sMode, $aParams, &$oProfileAuthor)
  62. {
  63. $CNF = &$this->oModule->_oConfig->CNF;
  64. $oProfileAuthor = BxDolProfile::getInstance((int)$aParams['user']);
  65. $iListId = (int)$aParams['list_id'];
  66. if (!$oProfileAuthor)
  67. return false;
  68. $iProfileAuthor = $oProfileAuthor->id();
  69. $oFavorite = $this->oModule->getObjectFavorite();
  70. if(!$oFavorite || (!$oFavorite->isPublic() && $iProfileAuthor != bx_get_logged_profile_id()))
  71. return false;
  72. $aConditions = $oFavorite->getConditionsTrack($CNF['TABLE_ENTRIES'], 'id', $iProfileAuthor, $iListId);
  73. if(!empty($aConditions) && is_array($aConditions)) {
  74. if(empty($this->aCurrent['restriction']) || !is_array($this->aCurrent['restriction']))
  75. $this->aCurrent['restriction'] = array();
  76. $this->aCurrent['restriction'] = array_merge($this->aCurrent['restriction'], $aConditions['restriction']);
  77. if(empty($this->aCurrent['join']) || !is_array($this->aCurrent['join']))
  78. $this->aCurrent['join'] = array();
  79. $this->aCurrent['join'] = array_merge($this->aCurrent['join'], $aConditions['join']);
  80. }
  81. $this->sBrowseUrl = 'page.php?i=' . $CNF['URI_JOINED_ENTRIES'] . '&profile_id={profile_id}';
  82. $this->aCurrent['title'] = _t($CNF['T']['txt_all_entries_by_author']);
  83. $this->aCurrent['rss']['link'] = 'modules/?r=' . $this->oModule->_oConfig->getUri() . '/rss/' . $sMode . '/' . $iProfileAuthor;
  84. return true;
  85. }
  86. protected function _updateCurrentForContext($sMode, $aParams, &$oProfileContext)
  87. {
  88. $CNF = &$this->oModule->_oConfig->CNF;
  89. $oProfileContext = BxDolProfile::getInstance((int)$aParams['context']);
  90. if (!$oProfileContext)
  91. return false;
  92. $iProfileIdContext = $oProfileContext->id();
  93. $this->aCurrent['restriction']['context'] = array(
  94. 'value' => -$iProfileIdContext,
  95. 'field' => $CNF['FIELD_ALLOW_VIEW_TO'],
  96. 'operator' => '=',
  97. 'table' => $CNF['TABLE_ENTRIES']
  98. );
  99. if(!empty($aParams['per_page']))
  100. $this->aCurrent['paginate']['perPage'] = is_numeric($aParams['per_page']) ? (int)$aParams['per_page'] : (int)getParam($aParams['per_page']);
  101. $this->sBrowseUrl = 'page.php?i=' . $CNF['URI_ENTRIES_BY_CONTEXT'] . '&profile_id={profile_id}';
  102. $this->aCurrent['title'] = _t($CNF['T']['txt_all_entries_by_context']);
  103. $this->aCurrent['rss']['link'] = 'modules/?r=' . $this->oModule->_oConfig->getUri() . '/rss/' . $sMode . '/' . $iProfileIdContext;
  104. return true;
  105. }
  106. }
  107. /** @} */