BxAdsGridOffersAll.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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 Ads Ads
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. class BxAdsGridOffersAll extends BxTemplGrid
  12. {
  13. protected $_sModule;
  14. protected $_oModule;
  15. protected $_iProfileId;
  16. public function __construct ($aOptions, $oTemplate = false)
  17. {
  18. $this->_sModule = 'bx_ads';
  19. $this->_oModule = BxDolModule::getInstance($this->_sModule);
  20. if(!$oTemplate)
  21. $oTemplate = $this->_oModule->_oTemplate;
  22. parent::__construct ($aOptions, $oTemplate);
  23. $this->_sDefaultSortingOrder = 'DESC';
  24. $this->_iProfileId = bx_get_logged_profile_id();
  25. }
  26. protected function _getCellContentId($mixedValue, $sKey, $aField, $aRow)
  27. {
  28. $CNF = &$this->_oModule->_oConfig->CNF;
  29. $mixedValue = $this->_oModule->_oTemplate->getEntryLink(array(
  30. $CNF['FIELD_ID'] => $aRow['content_id'],
  31. $CNF['FIELD_TITLE'] => $aRow['content_title'],
  32. ));
  33. return parent::_getCellDefault($mixedValue, $sKey, $aField, $aRow);
  34. }
  35. protected function _getActionView($sType, $sKey, $a, $isSmall = false, $isDisabled = false, $aRow = array())
  36. {
  37. $CNF = &$this->_oModule->_oConfig->CNF;
  38. $sUrl = bx_absolute_url(BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY_OFFERS'], array('id' => $aRow['content_id'])));
  39. $a['attr'] = array_merge($a['attr'], array(
  40. "onclick" => "window.open('" . $sUrl . "','_self');"
  41. ));
  42. unset($a['attr']['bx_grid_action_single']);
  43. return parent::_getActionDefault($sType, $sKey, $a, false, $isDisabled, $aRow);
  44. }
  45. protected function _getDataSqlOrderClause ($sOrderByFilter, $sOrderField, $sOrderDir, $bFieldsOnly = false)
  46. {
  47. return " GROUP BY `to`.`content_id` " . parent::_getDataSqlOrderClause ($sOrderByFilter, $sOrderField, $sOrderDir, $bFieldsOnly);
  48. }
  49. protected function _getDataSql($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage)
  50. {
  51. $this->_aOptions['source'] .= $this->_oModule->_oDb->prepareAsString(" AND `te`.`author`=?", $this->_iProfileId);
  52. return parent::_getDataSql($sFilter, $sOrderField, $sOrderDir, $iStart, $iPerPage);
  53. }
  54. protected function _getId()
  55. {
  56. $aIds = bx_get('ids');
  57. if(!empty($aIds) && is_array($aIds))
  58. return array_shift($aIds);
  59. if(($iId = bx_get('id')) !== false)
  60. return (int)$iId;
  61. return false;
  62. }
  63. }
  64. /** @} */