CronishPlugin.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. /**
  3. * GNU social cronish plugin, to imitate cron actions
  4. *
  5. * @category Cron
  6. * @package GNUsocial
  7. * @author Mikael Nordfeldth <mmn@hethane.se>
  8. * @copyright 2013 Free Software Foundation, Inc.
  9. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
  10. * @link http://gnu.io/social/
  11. */
  12. if (!defined('GNUSOCIAL')) { exit(1); }
  13. class CronishPlugin extends Plugin {
  14. const PLUGIN_VERSION = '2.0.0';
  15. public function onCronMinutely()
  16. {
  17. common_debug('CRON: Running near-minutely cron job!');
  18. }
  19. public function onCronHourly()
  20. {
  21. common_debug('CRON: Running near-hourly cron job!');
  22. }
  23. public function onCronDaily()
  24. {
  25. common_debug('CRON: Running near-daily cron job!');
  26. }
  27. public function onCronWeekly()
  28. {
  29. common_debug('CRON: Running near-weekly cron job!');
  30. }
  31. /**
  32. * When the page has finished rendering, let's do some cron jobs
  33. * if we have the time.
  34. */
  35. public function onEndActionExecute(Action $action)
  36. {
  37. $cron = new Cronish();
  38. $cron->callTimedEvents();
  39. return true;
  40. }
  41. public function onPluginVersion(array &$versions): bool
  42. {
  43. $versions[] = array('name' => 'Cronish',
  44. 'version' => self::PLUGIN_VERSION,
  45. 'author' => 'Mikael Nordfeldth',
  46. 'homepage' => 'http://www.gnu.org/software/social/',
  47. 'description' =>
  48. // TRANS: Plugin description.
  49. _m('Cronish plugin that executes events on a near-minutely/hour/day/week basis.'));
  50. return true;
  51. }
  52. }