BxBaseModProfileSearchResult.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. }
  51. /** @} */