BxEventsCronPruning.php 1.2 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 Events Events
  7. * @ingroup UnaModules
  8. *
  9. * @{
  10. */
  11. class BxEventsCronPruning extends BxBaseModGroupsCronPruning
  12. {
  13. public function __construct()
  14. {
  15. $this->_sModule = 'bx_events';
  16. parent::__construct();
  17. }
  18. function processing()
  19. {
  20. parent::processing();
  21. $CNF = &$this->_oModule->_oConfig->CNF;
  22. $sModule = 'bx_timeline';
  23. $sMethod = 'get_events_by_descriptor';
  24. if(($iInterval = (int)getParam($CNF['PARAM_DELETE_FROM_TIMELINE_AFTER'])) != 0 && bx_is_srv($sModule, $sMethod)) {
  25. $iDateTo = time() - 3600 * $iInterval;
  26. $aEntries = $this->_oModule->_oDb->getEntriesBy(['type' => 'past', 'date_from' => $iDateTo - 86400, 'date_to' => $iDateTo]);
  27. foreach($aEntries as $aEntry) {
  28. $aEvent = bx_srv($sModule, $sMethod, [$this->_sModule, 'added', $aEntry[$CNF['FIELD_ID']]]);
  29. if(empty($aEvent) || !is_array($aEvent))
  30. continue;
  31. bx_srv($sModule, 'delete_entity', [$aEvent['id']]);
  32. }
  33. }
  34. }
  35. }
  36. /** @} */