BxBaseModGeneralSearchResult.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 BaseGeneral Base classes for modules
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. class BxBaseModGeneralSearchResult extends BxTemplSearchResult
  12. {
  13. protected $oModule;
  14. function __construct($sMode = '', $aParams = array())
  15. {
  16. parent::__construct();
  17. }
  18. function getMain()
  19. {
  20. return BxDolModule::getInstance($this->aCurrent['module_name']);
  21. }
  22. function getRssUnitLink (&$a)
  23. {
  24. $CNF = &$this->oModule->_oConfig->CNF;
  25. return BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $a[$CNF['FIELD_ID']]);
  26. }
  27. function getRssPageUrl ()
  28. {
  29. if (false === parent::getRssPageUrl())
  30. return false;
  31. $oPermalinks = BxDolPermalinks::getInstance();
  32. return BX_DOL_URL_ROOT . $oPermalinks->permalink($this->aCurrent['rss']['link']);
  33. }
  34. function rss ()
  35. {
  36. if (!isset($this->aCurrent['rss']))
  37. return '';
  38. $this->aCurrent['paginate']['perPage'] = empty($this->oModule->_oConfig->CNF['PARAM_NUM_RSS']) ? 10 : getParam($this->oModule->_oConfig->CNF['PARAM_NUM_RSS']);
  39. return parent::rss();
  40. }
  41. /**
  42. * Add conditions for private content
  43. */
  44. protected function addConditionsForPrivateContent($CNF, $oProfile, $aCustomGroup = array())
  45. {
  46. if(empty($CNF['OBJECT_PRIVACY_VIEW']))
  47. return;
  48. $oPrivacy = BxDolPrivacy::getObjectInstance($CNF['OBJECT_PRIVACY_VIEW']);
  49. if(!$oPrivacy)
  50. return;
  51. $aCondition = $oPrivacy->getContentPublicAsCondition($oProfile ? $oProfile->id() : 0, $aCustomGroup);
  52. if(empty($aCondition) || !is_array($aCondition))
  53. return;
  54. if(isset($aCondition['restriction']))
  55. $this->aCurrent['restriction'] = array_merge($this->aCurrent['restriction'], $aCondition['restriction']);
  56. if(isset($aCondition['join']))
  57. $this->aCurrent['join'] = array_merge($this->aCurrent['join'], $aCondition['join']);
  58. $this->setProcessPrivateContent(false);
  59. }
  60. }
  61. /** @} */