BxBaseModGroupsSearchResult.php 3.3 KB

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