BxBaseModProfileSearchResult.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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 BaseProfile Base classes for profile modules
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. class BxBaseModProfileSearchResult extends BxBaseModGeneralSearchResult
  12. {
  13. public function __construct($sMode = '', $aParams = array())
  14. {
  15. parent::__construct($sMode, $aParams);
  16. $this->aUnitViews = array('gallery' => 'unit_with_cover.html', 'showcase' => 'unit_with_cover_showcase.html');
  17. if (!empty($aParams['unit_view']))
  18. $this->sUnitViewDefault = $aParams['unit_view'];
  19. $this->sUnitTemplate = $this->aUnitViews[$this->sUnitViewDefault];
  20. $this->sCenterContentUnitSelector = '.bx-base-pofile-unit';
  21. $this->addContainerClass (array('bx-def-margin-sec-lefttopright-neg', 'bx-base-pofile-units-wrapper', 'bx-def-margin-sec-bottom-neg'));
  22. if ('unit_with_cover_showcase.html' == $this->sUnitTemplate){
  23. $this->bShowcaseView = true;
  24. $this->removeContainerClass ('bx-def-margin-bottom-neg');
  25. }
  26. }
  27. protected function _setConnectionsConditions ($aParams)
  28. {
  29. $oConnection = isset($aParams['object']) ? BxDolConnection::getObjectInstance($aParams['object']) : false;
  30. if (!$oConnection || !isset($aParams['profile']) || !(int)$aParams['profile'])
  31. return false;
  32. $sContentType = isset($aParams['type']) ? $aParams['type'] : BX_CONNECTIONS_CONTENT_TYPE_CONTENT;
  33. $isMutual = isset($aParams['mutual']) ? $aParams['mutual'] : false;
  34. $a = $oConnection->getConnectionsAsCondition ($sContentType, 'id', (int)$aParams['profile'], (int)$aParams['profile2'], $isMutual);
  35. $this->aCurrent['restriction'] = array_merge($this->aCurrent['restriction'], $a['restriction']);
  36. $this->aCurrent['join'] = array_merge($this->aCurrent['join'], $a['join']);
  37. return true;
  38. }
  39. protected function _setAclConditions ($aParams)
  40. {
  41. $oAcl = BxDolAcl::getInstance();
  42. if(!$oAcl || empty($aParams['level']))
  43. return false;
  44. if(!is_array($aParams['level']))
  45. $aParams['level'] = array($aParams['level']);
  46. $this->aCurrent['title'] = array();
  47. foreach($aParams['level'] as $iLevelId) {
  48. $aInfo = $oAcl->getMembershipInfo($iLevelId);
  49. if(empty($aInfo) || !is_array($aInfo))
  50. continue;
  51. $this->aCurrent['title'][] = _t($aInfo['name']);
  52. }
  53. $aCondition = $oAcl->getContentByLevelAsCondition('id', $aParams['level']);
  54. $this->aCurrent['restriction_sql'] = (!empty($this->aCurrent['restriction_sql']) ? $this->aCurrent['restriction_sql'] : '') . $aCondition['restriction_sql'];
  55. $this->aCurrent['restriction'] = array_merge($this->aCurrent['restriction'], $aCondition['restriction']);
  56. $this->aCurrent['join'] = array_merge($this->aCurrent['join'], $aCondition['join']);
  57. return true;
  58. }
  59. protected function _setFavoriteConditions($sMode, $aParams, &$oProfileAuthor)
  60. {
  61. $CNF = &$this->oModule->_oConfig->CNF;
  62. $oProfileAuthor = BxDolProfile::getInstance((int)$aParams['user']);
  63. if(!$oProfileAuthor)
  64. return false;
  65. $iProfileAuthor = $oProfileAuthor->id();
  66. $oFavorite = $this->oModule->getObjectFavorite();
  67. if(!$oFavorite->isPublic() && $iProfileAuthor != bx_get_logged_profile_id())
  68. return false;
  69. $aConditions = $oFavorite->getConditionsTrack($CNF['TABLE_ENTRIES'], 'id', $iProfileAuthor);
  70. if(!empty($aConditions) && is_array($aConditions)) {
  71. if(empty($this->aCurrent['restriction']) || !is_array($this->aCurrent['restriction']))
  72. $this->aCurrent['restriction'] = array();
  73. $this->aCurrent['restriction'] = array_merge($this->aCurrent['restriction'], $aConditions['restriction']);
  74. if(empty($this->aCurrent['join']) || !is_array($this->aCurrent['join']))
  75. $this->aCurrent['join'] = array();
  76. $this->aCurrent['join'] = array_merge($this->aCurrent['join'], $aConditions['join']);
  77. }
  78. $this->sBrowseUrl = 'page.php?i=' . $CNF['URI_VIEW_FAVORITES'] . '&profile_id={profile_id}';
  79. $this->aCurrent['title'] = _t($CNF['T']['txt_browse_favorites']);
  80. $this->aCurrent['rss']['link'] = 'modules/?r=' . $this->oModule->_oConfig->getUri() . '/rss/' . $sMode . '/' . $iProfileAuthor;
  81. return true;
  82. }
  83. }
  84. /** @} */