BxBaseModProfileSearchResult.php 4.4 KB

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