updateapp.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Christopher Schäpers <kondou@ts.unde.re>
  6. * @author Frank Karlitschek <frank@karlitschek.de>
  7. * @author Georg Ehrke <georg@owncloud.com>
  8. * @author Lukas Reschke <lukas@statuscode.ch>
  9. * @author Robin Appelman <robin@icewind.nl>
  10. * @author Thomas Müller <thomas.mueller@tmit.eu>
  11. *
  12. * @license AGPL-3.0
  13. *
  14. * This code is free software: you can redistribute it and/or modify
  15. * it under the terms of the GNU Affero General Public License, version 3,
  16. * as published by the Free Software Foundation.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU Affero General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU Affero General Public License, version 3,
  24. * along with this program. If not, see <http://www.gnu.org/licenses/>
  25. *
  26. */
  27. OCP\JSON::checkAdminUser();
  28. OCP\JSON::callCheck();
  29. if (!array_key_exists('appid', $_POST)) {
  30. OCP\JSON::error(array(
  31. 'message' => 'No AppId given!'
  32. ));
  33. return;
  34. }
  35. $appId = (string)$_POST['appid'];
  36. $appId = OC_App::cleanAppId($appId);
  37. $config = \OC::$server->getConfig();
  38. $config->setSystemValue('maintenance', true);
  39. try {
  40. $installer = new \OC\Installer(
  41. \OC::$server->getAppFetcher(),
  42. \OC::$server->getHTTPClientService(),
  43. \OC::$server->getTempManager(),
  44. \OC::$server->getLogger()
  45. );
  46. $result = $installer->updateAppstoreApp($appId);
  47. $config->setSystemValue('maintenance', false);
  48. } catch(Exception $ex) {
  49. $config->setSystemValue('maintenance', false);
  50. OC_JSON::error(array("data" => array( "message" => $ex->getMessage() )));
  51. return;
  52. }
  53. if($result !== false) {
  54. OC_JSON::success(array('data' => array('appid' => $appId)));
  55. } else {
  56. $l = \OC::$server->getL10N('settings');
  57. OC_JSON::error(array("data" => array( "message" => $l->t("Couldn't update app.") )));
  58. }