backgroundjob.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. /**
  3. * @author Bart Visscher <bartv@thisnet.nl>
  4. * @author Felix Moeller <mail@felixmoeller.de>
  5. * @author Jakob Sack <mail@jakobsack.de>
  6. * @author Jörn Friedrich Dreyer <jfd@butonic.de>
  7. * @author Morris Jobke <hey@morrisjobke.de>
  8. * @author Scrutinizer Auto-Fixer <auto-fixer@scrutinizer-ci.com>
  9. *
  10. * @copyright Copyright (c) 2015, ownCloud, Inc.
  11. * @license AGPL-3.0
  12. *
  13. * This code is free software: you can redistribute it and/or modify
  14. * it under the terms of the GNU Affero General Public License, version 3,
  15. * as published by the Free Software Foundation.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU Affero General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU Affero General Public License, version 3,
  23. * along with this program. If not, see <http://www.gnu.org/licenses/>
  24. *
  25. */
  26. /**
  27. * This class does the dirty work.
  28. */
  29. class OC_BackgroundJob{
  30. /**
  31. * get the execution type of background jobs
  32. * @return string
  33. *
  34. * This method returns the type how background jobs are executed. If the user
  35. * did not select something, the type is ajax.
  36. */
  37. public static function getExecutionType() {
  38. return OC_Appconfig::getValue( 'core', 'backgroundjobs_mode', 'ajax' );
  39. }
  40. /**
  41. * sets the background jobs execution type
  42. * @param string $type execution type
  43. * @return false|null
  44. *
  45. * This method sets the execution type of the background jobs. Possible types
  46. * are "none", "ajax", "webcron", "cron"
  47. */
  48. public static function setExecutionType( $type ) {
  49. if( !in_array( $type, array('none', 'ajax', 'webcron', 'cron'))) {
  50. return false;
  51. }
  52. return OC_Appconfig::setValue( 'core', 'backgroundjobs_mode', $type );
  53. }
  54. }