You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

updateapp.php 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. /**
  3. * @author Christopher Schäpers <kondou@ts.unde.re>
  4. * @author Frank Karlitschek <frank@karlitschek.de>
  5. * @author Georg Ehrke <georg@owncloud.com>
  6. * @author Lukas Reschke <lukas@statuscode.ch>
  7. * @author Robin Appelman <icewind@owncloud.com>
  8. * @author Thomas Müller <thomas.mueller@tmit.eu>
  9. *
  10. * @copyright Copyright (c) 2016, 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. OCP\JSON::checkAdminUser();
  27. OCP\JSON::callCheck();
  28. if (!array_key_exists('appid', $_POST)) {
  29. OCP\JSON::error(array(
  30. 'message' => 'No AppId given!'
  31. ));
  32. return;
  33. }
  34. $appId = (string)$_POST['appid'];
  35. if (!is_numeric($appId)) {
  36. $appId = \OC::$server->getAppConfig()->getValue($appId, 'ocsid', null);
  37. if ($appId === null) {
  38. OCP\JSON::error(array(
  39. 'message' => 'No OCS-ID found for app!'
  40. ));
  41. exit;
  42. }
  43. }
  44. $appId = OC_App::cleanAppId($appId);
  45. $config = \OC::$server->getConfig();
  46. $config->setSystemValue('maintenance', true);
  47. try {
  48. $result = \OC\Installer::updateAppByOCSId($appId);
  49. $config->setSystemValue('maintenance', false);
  50. } catch(Exception $ex) {
  51. $config->setSystemValue('maintenance', false);
  52. OC_JSON::error(array("data" => array( "message" => $ex->getMessage() )));
  53. return;
  54. }
  55. if($result !== false) {
  56. OC_JSON::success(array('data' => array('appid' => $appId)));
  57. } else {
  58. $l = \OC::$server->getL10N('settings');
  59. OC_JSON::error(array("data" => array( "message" => $l->t("Couldn't update app.") )));
  60. }