updateapp.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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 <oc.list@georgehrke.com>
  8. * @author Lukas Reschke <lukas@statuscode.ch>
  9. * @author Robin Appelman <robin@icewind.nl>
  10. * @author Roeland Jago Douma <roeland@famdouma.nl>
  11. * @author Thomas Müller <thomas.mueller@tmit.eu>
  12. *
  13. * @license AGPL-3.0
  14. *
  15. * This code is free software: you can redistribute it and/or modify
  16. * it under the terms of the GNU Affero General Public License, version 3,
  17. * as published by the Free Software Foundation.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU Affero General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU Affero General Public License, version 3,
  25. * along with this program. If not, see <http://www.gnu.org/licenses/>
  26. *
  27. */
  28. \OC_JSON::checkAdminUser();
  29. \OC_JSON::callCheck();
  30. if (!array_key_exists('appid', $_POST)) {
  31. \OC_JSON::error(array(
  32. 'message' => 'No AppId given!'
  33. ));
  34. return;
  35. }
  36. $appId = (string)$_POST['appid'];
  37. $appId = OC_App::cleanAppId($appId);
  38. $config = \OC::$server->getConfig();
  39. $config->setSystemValue('maintenance', true);
  40. try {
  41. $installer = \OC::$server->query(\OC\Installer::class);
  42. $result = $installer->updateAppstoreApp($appId);
  43. $config->setSystemValue('maintenance', false);
  44. } catch(Exception $ex) {
  45. $config->setSystemValue('maintenance', false);
  46. OC_JSON::error(array('data' => array( 'message' => $ex->getMessage() )));
  47. return;
  48. }
  49. if($result !== false) {
  50. OC_JSON::success(array('data' => array('appid' => $appId)));
  51. } else {
  52. $l = \OC::$server->getL10N('settings');
  53. OC_JSON::error(array('data' => array( 'message' => $l->t("Couldn't update app.") )));
  54. }