BxBaseModProfileSearchResult.php 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
  4. * CC-BY License - http://creativecommons.org/licenses/by/3.0/
  5. *
  6. * @defgroup BaseProfile Base classes for profile modules
  7. * @ingroup TridentModules
  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. }
  18. protected function _setConnectionsConditions ($aParams)
  19. {
  20. $oConnection = isset($aParams['object']) ? BxDolConnection::getObjectInstance($aParams['object']) : false;
  21. if (!$oConnection || !isset($aParams['profile']) || !(int)$aParams['profile'])
  22. return false;
  23. $sContentType = isset($aParams['type']) ? $aParams['type'] : BX_CONNECTIONS_CONTENT_TYPE_CONTENT;
  24. $isMutual = isset($aParams['mutual']) ? $aParams['mutual'] : false;
  25. $a = $oConnection->getConnectionsAsCondition ($sContentType, 'id', (int)$aParams['profile'], (int)$aParams['profile2'], $isMutual);
  26. $this->aCurrent['restriction'] = array_merge($this->aCurrent['restriction'], $a['restriction']);
  27. $this->aCurrent['join'] = array_merge($this->aCurrent['join'], $a['join']);
  28. return true;
  29. }
  30. protected function _setAclConditions ($aParams)
  31. {
  32. $oAcl = BxDolAcl::getInstance();
  33. if(!$oAcl || empty($aParams['level']))
  34. return false;
  35. if(!is_array($aParams['level']))
  36. $aParams['level'] = array($aParams['level']);
  37. $this->aCurrent['title'] = array();
  38. foreach($aParams['level'] as $iLevelId) {
  39. $aInfo = $oAcl->getMembershipInfo($iLevelId);
  40. if(empty($aInfo) || !is_array($aInfo))
  41. continue;
  42. $this->aCurrent['title'][] = _t($aInfo['name']);
  43. }
  44. $aCondition = $oAcl->getContentByLevelAsCondition('id', $aParams['level']);
  45. $this->aCurrent['restriction_sql'] = (!empty($this->aCurrent['restriction_sql']) ? $this->aCurrent['restriction_sql'] : '') . $aCondition['restriction_sql'];
  46. $this->aCurrent['restriction'] = array_merge($this->aCurrent['restriction'], $aCondition['restriction']);
  47. $this->aCurrent['join'] = array_merge($this->aCurrent['join'], $aCondition['join']);
  48. return true;
  49. }
  50. protected function _setFavoriteConditions($sMode, $aParams, &$oProfileAuthor)
  51. {
  52. $CNF = &$this->oModule->_oConfig->CNF;
  53. $oProfileAuthor = BxDolProfile::getInstance((int)$aParams['user']);
  54. if(!$oProfileAuthor)
  55. return false;
  56. $iProfileAuthor = $oProfileAuthor->id();
  57. $oFavorite = $this->oModule->getObjectFavorite();
  58. if(!$oFavorite->isPublic() && $iProfileAuthor != bx_get_logged_profile_id())
  59. return false;
  60. $aConditions = $oFavorite->getConditionsTrack($CNF['TABLE_ENTRIES'], 'id', $iProfileAuthor);
  61. if(!empty($aConditions) && is_array($aConditions)) {
  62. if(empty($this->aCurrent['restriction']) || !is_array($this->aCurrent['restriction']))
  63. $this->aCurrent['restriction'] = array();
  64. $this->aCurrent['restriction'] = array_merge($this->aCurrent['restriction'], $aConditions['restriction']);
  65. if(empty($this->aCurrent['join']) || !is_array($this->aCurrent['join']))
  66. $this->aCurrent['join'] = array();
  67. $this->aCurrent['join'] = array_merge($this->aCurrent['join'], $aConditions['join']);
  68. }
  69. $this->sBrowseUrl = 'page.php?i=' . $CNF['URI_VIEW_FAVORITES'] . '&profile_id={profile_id}';
  70. $this->aCurrent['title'] = _t($CNF['T']['txt_browse_favorites']);
  71. $this->aCurrent['rss']['link'] = 'modules/?r=' . $this->oModule->_oConfig->getUri() . '/rss/' . $sMode . '/' . $iProfileAuthor;
  72. return true;
  73. }
  74. }
  75. /** @} */