CronishPlugin.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. include("../plugins/Cronish/lib/cronish.php");
  14. class CronishPlugin extends Plugin {
  15. const PLUGIN_VERSION = '2.0.0';
  16. public function onCronMinutely()
  17. {
  18. common_debug('CRON: Running near-minutely cron job!');
  19. }
  20. public function onCronHourly()
  21. {
  22. common_debug('CRON: Running near-hourly cron job!');
  23. }
  24. public function onCronDaily()
  25. {
  26. common_debug('CRON: Running near-daily cron job!');
  27. }
  28. public function onCronWeekly()
  29. {
  30. common_debug('CRON: Running near-weekly cron job!');
  31. }
  32. /**
  33. * When the page has finished rendering, let's do some cron jobs
  34. * if we have the time.
  35. */
  36. public function onEndActionExecute(Action $action)
  37. {
  38. $cron = new Cronish();
  39. $cron->callTimedEvents();
  40. return true;
  41. }
  42. public function onPluginVersion(array &$versions): bool
  43. {
  44. $versions[] = array('name' => 'Cronish',
  45. 'version' => self::PLUGIN_VERSION,
  46. 'author' => 'Mikael Nordfeldth',
  47. 'homepage' => GNUSOCIAL_ENGINE_URL,
  48. 'description' =>
  49. // TRANS: Plugin description.
  50. _m('Cronish plugin that executes events on a near-minutely/hour/day/week basis.'));
  51. return true;
  52. }
  53. }