BxBaseModGroupsSearchResult.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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 _setAuthorConditions($sMode, $aParams, &$oProfileAuthor)
  29. {
  30. $CNF = &$this->oModule->_oConfig->CNF;
  31. $oProfileAuthor = BxDolProfile::getInstance((int)$aParams['author']);
  32. if (!$oProfileAuthor)
  33. return false;
  34. $iProfileAuthor = $oProfileAuthor->id();
  35. $this->aCurrent['restriction']['owner']['value'] = $iProfileAuthor;
  36. if(!empty($aParams['per_page']))
  37. $this->aCurrent['paginate']['perPage'] = is_numeric($aParams['per_page']) ? (int)$aParams['per_page'] : (int)getParam($aParams['per_page']);
  38. $this->sBrowseUrl = 'page.php?i=' . $CNF['URI_JOINED_ENTRIES'] . '&profile_id={profile_id}';
  39. $this->aCurrent['title'] = _t($CNF['T']['txt_all_entries_by_author']);
  40. $this->aCurrent['rss']['link'] = 'modules/?r=' . $this->oModule->_oConfig->getUri() . '/rss/' . $sMode . '/' . $iProfileAuthor;
  41. return true;
  42. }
  43. protected function _setFavoriteConditions($sMode, $aParams, &$oProfileAuthor)
  44. {
  45. $CNF = &$this->oModule->_oConfig->CNF;
  46. $oProfileAuthor = BxDolProfile::getInstance((int)$aParams['user']);
  47. if (!$oProfileAuthor)
  48. return false;
  49. $iProfileAuthor = $oProfileAuthor->id();
  50. $oFavorite = $this->oModule->getObjectFavorite();
  51. if(!$oFavorite || (!$oFavorite->isPublic() && $iProfileAuthor != bx_get_logged_profile_id()))
  52. return false;
  53. $aConditions = $oFavorite->getConditionsTrack($CNF['TABLE_ENTRIES'], 'id', $iProfileAuthor);
  54. if(!empty($aConditions) && is_array($aConditions)) {
  55. if(empty($this->aCurrent['restriction']) || !is_array($this->aCurrent['restriction']))
  56. $this->aCurrent['restriction'] = array();
  57. $this->aCurrent['restriction'] = array_merge($this->aCurrent['restriction'], $aConditions['restriction']);
  58. if(empty($this->aCurrent['join']) || !is_array($this->aCurrent['join']))
  59. $this->aCurrent['join'] = array();
  60. $this->aCurrent['join'] = array_merge($this->aCurrent['join'], $aConditions['join']);
  61. }
  62. $this->sBrowseUrl = 'page.php?i=' . $CNF['URI_JOINED_ENTRIES'] . '&profile_id={profile_id}';
  63. $this->aCurrent['title'] = _t($CNF['T']['txt_all_entries_by_author']);
  64. $this->aCurrent['rss']['link'] = 'modules/?r=' . $this->oModule->_oConfig->getUri() . '/rss/' . $sMode . '/' . $iProfileAuthor;
  65. return true;
  66. }
  67. protected function _updateCurrentForContext($sMode, $aParams, &$oProfileContext)
  68. {
  69. $CNF = &$this->oModule->_oConfig->CNF;
  70. $oProfileContext = BxDolProfile::getInstance((int)$aParams['context']);
  71. if (!$oProfileContext)
  72. return false;
  73. $iProfileIdContext = $oProfileContext->id();
  74. $this->aCurrent['restriction']['context'] = array(
  75. 'value' => -$iProfileIdContext,
  76. 'field' => $CNF['FIELD_ALLOW_VIEW_TO'],
  77. 'operator' => '=',
  78. 'table' => $CNF['TABLE_ENTRIES']
  79. );
  80. if(!empty($aParams['per_page']))
  81. $this->aCurrent['paginate']['perPage'] = is_numeric($aParams['per_page']) ? (int)$aParams['per_page'] : (int)getParam($aParams['per_page']);
  82. $this->sBrowseUrl = 'page.php?i=' . $CNF['URI_ENTRIES_BY_CONTEXT'] . '&profile_id={profile_id}';
  83. $this->aCurrent['title'] = _t($CNF['T']['txt_all_entries_by_context']);
  84. $this->aCurrent['rss']['link'] = 'modules/?r=' . $this->oModule->_oConfig->getUri() . '/rss/' . $sMode . '/' . $iProfileIdContext;
  85. return true;
  86. }
  87. }
  88. /** @} */