1
0

BxBaseModGroupsSearchResult.php 5.1 KB

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