Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

maintenanceplugin.php 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. /**
  3. * ownCloud
  4. *
  5. * @author Thomas Müller
  6. * @copyright 2013 Thomas Müller <thomas.mueller@tmit.eu>
  7. *
  8. * @license AGPL3
  9. */
  10. require 'ServiceUnavailable.php';
  11. class OC_Connector_Sabre_MaintenancePlugin extends Sabre_DAV_ServerPlugin
  12. {
  13. /**
  14. * Reference to main server object
  15. *
  16. * @var Sabre_DAV_Server
  17. */
  18. private $server;
  19. /**
  20. * This initializes the plugin.
  21. *
  22. * This function is called by Sabre_DAV_Server, after
  23. * addPlugin is called.
  24. *
  25. * This method should set up the required event subscriptions.
  26. *
  27. * @param Sabre_DAV_Server $server
  28. * @return void
  29. */
  30. public function initialize(Sabre_DAV_Server $server) {
  31. $this->server = $server;
  32. $this->server->subscribeEvent('beforeMethod', array($this, 'checkMaintenanceMode'), 10);
  33. }
  34. /**
  35. * This method is called before any HTTP method and returns http status code 503
  36. * in case the system is in maintenance mode.
  37. *
  38. * @throws Sabre_DAV_Exception_ServiceUnavailable
  39. * @internal param string $method
  40. * @return bool
  41. */
  42. public function checkMaintenanceMode() {
  43. if (OC_Config::getValue('maintenance', false)) {
  44. throw new Sabre_DAV_Exception_ServiceUnavailable();
  45. }
  46. if (OC::checkUpgrade(false)) {
  47. throw new Sabre_DAV_Exception_ServiceUnavailable('Upgrade needed');
  48. }
  49. return true;
  50. }
  51. }