summaryrefslogtreecommitdiffstats
path: root/settings
diff options
context:
space:
mode:
authorGeorg Ehrke <developer@georgehrke.com>2014-06-16 15:54:50 +0200
committerGeorg Ehrke <developer@georgehrke.com>2014-06-16 15:54:50 +0200
commit15c215cd031602013d982d630306314fc6c1b21c (patch)
treee7f5bea6cc6d43694cd61dfedaef4ce7723e3b52 /settings
parentb67588d35c2ebf031e4f4f46fbce73fd555d33e8 (diff)
parent86f546ff6487b9ac8b18ad14ca290b8051f0496e (diff)
downloadnextcloud-server-15c215cd031602013d982d630306314fc6c1b21c.tar.gz
nextcloud-server-15c215cd031602013d982d630306314fc6c1b21c.zip
Merge pull request #8808 from owncloud/update_shipped_apps_from_appstore
Make shipped apps updatable via appstore
Diffstat (limited to 'settings')
-rw-r--r--settings/ajax/disableapp.php11
-rw-r--r--settings/ajax/installapp.php19
-rw-r--r--settings/ajax/uninstallapp.php19
-rw-r--r--settings/ajax/updateapp.php41
-rw-r--r--settings/js/apps.js27
-rw-r--r--settings/routes.php2
-rw-r--r--settings/templates/apps.php1
7 files changed, 111 insertions, 9 deletions
diff --git a/settings/ajax/disableapp.php b/settings/ajax/disableapp.php
index 466a719157d..c1e5bc8eac7 100644
--- a/settings/ajax/disableapp.php
+++ b/settings/ajax/disableapp.php
@@ -1,7 +1,14 @@
<?php
-OC_JSON::checkAdminUser();
+OCP\JSON::checkAdminUser();
OCP\JSON::callCheck();
-OC_App::disable(OC_App::cleanAppId($_POST['appid']));
+if (!array_key_exists('appid', $_POST)) {
+ OC_JSON::error();
+ exit;
+}
+$appId = $_POST['appid'];
+$appId = OC_App::cleanAppId($appId);
+
+OC_App::disable($appId);
OC_JSON::success();
diff --git a/settings/ajax/installapp.php b/settings/ajax/installapp.php
new file mode 100644
index 00000000000..47f40f2b0cd
--- /dev/null
+++ b/settings/ajax/installapp.php
@@ -0,0 +1,19 @@
+<?php
+OCP\JSON::checkAdminUser();
+OCP\JSON::callCheck();
+
+if (!array_key_exists('appid', $_POST)) {
+ OC_JSON::error();
+ exit;
+}
+
+$appId = $_POST['appid'];
+$appId = OC_App::cleanAppId($appId);
+
+$result = OC_App::installApp($appId);
+if($result !== false) {
+ OC_JSON::success(array('data' => array('appid' => $appId)));
+} else {
+ $l = OC_L10N::get('settings');
+ OC_JSON::error(array("data" => array( "message" => $l->t("Couldn't remove app.") )));
+}
diff --git a/settings/ajax/uninstallapp.php b/settings/ajax/uninstallapp.php
new file mode 100644
index 00000000000..5c6371dc16f
--- /dev/null
+++ b/settings/ajax/uninstallapp.php
@@ -0,0 +1,19 @@
+<?php
+OCP\JSON::checkAdminUser();
+OCP\JSON::callCheck();
+
+if (!array_key_exists('appid', $_POST)) {
+ OC_JSON::error();
+ exit;
+}
+
+$appId = $_POST['appid'];
+$appId = OC_App::cleanAppId($appId);
+
+$result = OC_App::removeApp($appId);
+if($result !== false) {
+ OC_JSON::success(array('data' => array('appid' => $appId)));
+} else {
+ $l = OC_L10N::get('settings');
+ OC_JSON::error(array("data" => array( "message" => $l->t("Couldn't remove app.") )));
+}
diff --git a/settings/ajax/updateapp.php b/settings/ajax/updateapp.php
index 91c342d5d07..78f6775fe95 100644
--- a/settings/ajax/updateapp.php
+++ b/settings/ajax/updateapp.php
@@ -1,15 +1,42 @@
<?php
-
-OC_JSON::checkAdminUser();
+/**
+ * Copyright (c) 2013 Georg Ehrke georg@ownCloud.com
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+OCP\JSON::checkAdminUser();
OCP\JSON::callCheck();
-$appid = $_POST['appid'];
-$appid = OC_App::cleanAppId($appid);
+if (!array_key_exists('appid', $_POST)) {
+ OCP\JSON::error(array(
+ 'message' => 'No AppId given!'
+ ));
+ exit;
+}
+
+$appId = $_POST['appid'];
+
+if (!is_numeric($appId)) {
+ $appId = OC_Appconfig::getValue($appId, 'ocsid', null);
+ $isShipped = OC_App::isShipped($appId);
+
+ if ($appId === null) {
+ OCP\JSON::error(array(
+ 'message' => 'No OCS-ID found for app!'
+ ));
+ exit;
+ }
+} else {
+ $isShipped = false;
+}
+
+$appId = OC_App::cleanAppId($appId);
-$result = OC_Installer::updateApp($appid);
+$result = OC_Installer::updateAppByOCSId($appId, $isShipped);
if($result !== false) {
- OC_JSON::success(array('data' => array('appid' => $appid)));
+ OC_JSON::success(array('data' => array('appid' => $appId)));
} else {
- $l = OC_L10N::get('settings');
+ $l = OC_L10N::get('settings');
OC_JSON::error(array("data" => array( "message" => $l->t("Couldn't update app.") )));
}
diff --git a/settings/js/apps.js b/settings/js/apps.js
index ed75e06c066..4cd7520caa7 100644
--- a/settings/js/apps.js
+++ b/settings/js/apps.js
@@ -84,6 +84,14 @@ OC.Settings.Apps = OC.Settings.Apps || {
page.find('input.update').hide();
}
+ if (app.removable !== false) {
+ page.find('input.uninstall').show();
+ page.find('input.uninstall').data('appid', app.id);
+ page.find('input.uninstall').attr('value', t('settings', 'Uninstall App'));
+ } else {
+ page.find('input.uninstall').hide();
+ }
+
page.find('input.enable').show();
page.find('input.enable').val((app.active) ? t('settings', 'Disable') : t('settings', 'Enable'));
page.find('input.enable').data('appid', app.id);
@@ -221,6 +229,18 @@ OC.Settings.Apps = OC.Settings.Apps || {
}
},'json');
},
+ uninstallApp:function(appid, element) {
+ element.val(t('settings','Uninstalling ....'));
+ $.post(OC.filePath('settings','ajax','uninstallapp.php'),{appid:appid},function(result) {
+ if(!result || result.status !== 'success') {
+ OC.Settings.Apps.showErrorMessage(t('settings','Error while uninstalling app'),t('settings','Error'));
+ element.val(t('settings','Uninstall'));
+ } else {
+ OC.Settings.Apps.removeNavigation(appid);
+ appitem.removeClass('active');
+ }
+ },'json');
+ },
insertApp:function(appdata) {
var applist = $('#app-navigation ul li');
@@ -351,6 +371,13 @@ $(document).ready(function(){
OC.Settings.Apps.updateApp(appid, element);
}
});
+ $('#app-content input.uninstall').click(function(){
+ var element = $(this);
+ var appid=$(this).data('appid');
+ if(appid) {
+ OC.Settings.Apps.uninstallApp(appid, element);
+ }
+ });
$('#group_select').change(function() {
var element = $('#app-content input.enable');
diff --git a/settings/routes.php b/settings/routes.php
index 9acfc2852bd..1c8ad1b3fe8 100644
--- a/settings/routes.php
+++ b/settings/routes.php
@@ -71,6 +71,8 @@ $this->create('settings_ajax_disableapp', '/settings/ajax/disableapp.php')
->actionInclude('settings/ajax/disableapp.php');
$this->create('settings_ajax_updateapp', '/settings/ajax/updateapp.php')
->actionInclude('settings/ajax/updateapp.php');
+$this->create('settings_ajax_uninstallapp', '/settings/ajax/uninstallapp.php')
+ ->actionInclude('settings/ajax/uninstallapp.php');
$this->create('settings_ajax_navigationdetect', '/settings/ajax/navigationdetect.php')
->actionInclude('settings/ajax/navigationdetect.php');
$this->create('apps_custom', '/settings/js/apps-custom.js')
diff --git a/settings/templates/apps.php b/settings/templates/apps.php
index 776c3220462..b35eda4350c 100644
--- a/settings/templates/apps.php
+++ b/settings/templates/apps.php
@@ -53,6 +53,7 @@
print_unescaped($l->t('<span class="licence"></span>-licensed by <span class="author"></span>'));?></p>
<input class="enable hidden" type="submit" />
<input class="update hidden" type="submit" value="<?php p($l->t('Update')); ?>" />
+ <input class="uninstall hidden" type="submit" value="<?php p($l->t('Uninstall')); ?>"/>
<br />
<input class="hidden" type="checkbox" id="groups_enable"/>
<label class="hidden" for="groups_enable"><?php p($l->t('Enable only for specific groups')); ?></label>