BxAdsCronPruning.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. require_once(BX_DIRECTORY_PATH_INC . "design.inc.php");
  12. class BxAdsCronPruning extends BxDolCron
  13. {
  14. protected $_sModule;
  15. protected $_oModule;
  16. public function __construct()
  17. {
  18. $this->_sModule = 'bx_ads';
  19. $this->_oModule = BxDolModule::getInstance($this->_sModule);
  20. parent::__construct();
  21. }
  22. function processing()
  23. {
  24. $CNF = &$this->_oModule->_oConfig->CNF;
  25. $sStatus = 'hidden';
  26. $aEntries = $this->_oModule->_oDb->getEntriesBy(array('type' => 'expired', 'days' => (int)getParam($CNF['PARAM_LIFETIME'])));
  27. foreach($aEntries as $aEntry) {
  28. if(!$this->_oModule->_oDb->updateEntriesBy(array($CNF['FIELD_STATUS'] => $sStatus), array($CNF['FIELD_ID'] => $aEntry[$CNF['FIELD_ID']])))
  29. continue;
  30. $aEntry[$CNF['FIELD_STATUS']] = $sStatus;
  31. $this->_oModule->alertAfterEdit($aEntry);
  32. }
  33. }
  34. }
  35. /** @} */