BxBaseModGroupsSearchResult.php 3.4 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. protected $aUnitViews = array('gallery' => 'unit.html', 'showcase' => 'unit_with_cover_showcase.html');
  14. public function __construct($sMode = '', $aParams = array())
  15. {
  16. parent::__construct($sMode, $aParams);
  17. }
  18. protected function addConditionsForPrivateContent($CNF, $oProfile, $aCustomGroup = array())
  19. {
  20. if(empty($CNF['OBJECT_PRIVACY_VIEW']))
  21. return;
  22. $oPrivacy = BxDolPrivacy::getObjectInstance($CNF['OBJECT_PRIVACY_VIEW']);
  23. if(!$oPrivacy)
  24. return;
  25. parent::addConditionsForPrivateContent($CNF, $oProfile, array_merge($aCustomGroup, $oPrivacy->getPartiallyVisiblePrivacyGroups()));
  26. }
  27. protected function _setAuthorConditions($sMode, $aParams, &$oProfileAuthor)
  28. {
  29. $CNF = &$this->oModule->_oConfig->CNF;
  30. $oProfileAuthor = BxDolProfile::getInstance((int)$aParams['author']);
  31. if (!$oProfileAuthor)
  32. return false;
  33. $iProfileAuthor = $oProfileAuthor->id();
  34. $this->aCurrent['restriction']['owner']['value'] = $iProfileAuthor;
  35. if(!empty($aParams['per_page']))
  36. $this->aCurrent['paginate']['perPage'] = is_numeric($aParams['per_page']) ? (int)$aParams['per_page'] : (int)getParam($aParams['per_page']);
  37. $this->sBrowseUrl = 'page.php?i=' . $CNF['URI_JOINED_ENTRIES'] . '&profile_id={profile_id}';
  38. $this->aCurrent['title'] = _t($CNF['T']['txt_all_entries_by_author']);
  39. $this->aCurrent['rss']['link'] = 'modules/?r=' . $this->oModule->_oConfig->getUri() . '/rss/' . $sMode . '/' . $iProfileAuthor;
  40. return true;
  41. }
  42. protected function _setFavoriteConditions($sMode, $aParams, &$oProfileAuthor)
  43. {
  44. $CNF = &$this->oModule->_oConfig->CNF;
  45. $oProfileAuthor = BxDolProfile::getInstance((int)$aParams['user']);
  46. if (!$oProfileAuthor)
  47. return false;
  48. $iProfileAuthor = $oProfileAuthor->id();
  49. $oFavorite = $this->oModule->getObjectFavorite();
  50. if(!$oFavorite->isPublic() && $iProfileAuthor != bx_get_logged_profile_id())
  51. return false;
  52. $aConditions = $oFavorite->getConditionsTrack($CNF['TABLE_ENTRIES'], 'id', $iProfileAuthor);
  53. if(!empty($aConditions) && is_array($aConditions)) {
  54. if(empty($this->aCurrent['restriction']) || !is_array($this->aCurrent['restriction']))
  55. $this->aCurrent['restriction'] = array();
  56. $this->aCurrent['restriction'] = array_merge($this->aCurrent['restriction'], $aConditions['restriction']);
  57. if(empty($this->aCurrent['join']) || !is_array($this->aCurrent['join']))
  58. $this->aCurrent['join'] = array();
  59. $this->aCurrent['join'] = array_merge($this->aCurrent['join'], $aConditions['join']);
  60. }
  61. $this->sBrowseUrl = 'page.php?i=' . $CNF['URI_JOINED_ENTRIES'] . '&profile_id={profile_id}';
  62. $this->aCurrent['title'] = _t($CNF['T']['txt_all_entries_by_author']);
  63. $this->aCurrent['rss']['link'] = 'modules/?r=' . $this->oModule->_oConfig->getUri() . '/rss/' . $sMode . '/' . $iProfileAuthor;
  64. return true;
  65. }
  66. }
  67. /** @} */