BxBaseModGroupsSearchResult.php 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. }
  68. /** @} */