BxBaseModProfileSearchResult.php 3.9 KB

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