aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorBjoern Schiessle <schiessle@owncloud.com>2014-06-12 19:49:52 +0200
committerBjoern Schiessle <schiessle@owncloud.com>2014-06-14 10:22:38 +0200
commit84a651e46deff5fe577ed564e5826ff24c18f9a5 (patch)
tree1b137ebc8b504180b7bfeed99590c8c751af07e9 /apps
parente7b58ed2bdfe4bb56866e76b8fdd618946fa3c51 (diff)
downloadnextcloud-server-84a651e46deff5fe577ed564e5826ff24c18f9a5.tar.gz
nextcloud-server-84a651e46deff5fe577ed564e5826ff24c18f9a5.zip
add settings to disable server to server sharing
Diffstat (limited to 'apps')
-rw-r--r--apps/files_sharing/ajax/external.php14
-rw-r--r--apps/files_sharing/appinfo/app.php2
-rw-r--r--apps/files_sharing/js/external.js6
-rw-r--r--apps/files_sharing/js/settings-admin.js11
-rw-r--r--apps/files_sharing/lib/helper.php20
-rw-r--r--apps/files_sharing/publicwebdav.php4
-rw-r--r--apps/files_sharing/settings-admin.php17
-rw-r--r--apps/files_sharing/templates/settings-admin.php13
8 files changed, 82 insertions, 5 deletions
diff --git a/apps/files_sharing/ajax/external.php b/apps/files_sharing/ajax/external.php
index 3759559764d..5b4d4656d62 100644
--- a/apps/files_sharing/ajax/external.php
+++ b/apps/files_sharing/ajax/external.php
@@ -9,6 +9,14 @@
OCP\JSON::callCheck();
OCP\JSON::checkLoggedIn();
+$l = OC_L10N::get('files_sharing');
+
+// check if server admin allows to mount public links from other servers
+if (OCA\Files_Sharing\Helper::isIncomingServer2serverShareEnabled() === false) {
+ \OCP\JSON::error(array('data' => array('message' => $l->t('Server to server sharing is not enabled on this server'))));
+ exit();
+}
+
$token = $_POST['token'];
$remote = $_POST['remote'];
$owner = $_POST['owner'];
@@ -32,6 +40,8 @@ $storage = $mount->getStorage();
$result = $storage->file_exists('');
if($result){
$storage->getScanner()->scanAll();
+ \OCP\JSON::success();
+} else {
+ $externalManager->removeShare($mount->getMountPoint());
+ \OCP\JSON::error(array('data' => array('message' => $l->t("Couldn't add remote share"))));
}
-
-echo json_encode($result);
diff --git a/apps/files_sharing/appinfo/app.php b/apps/files_sharing/appinfo/app.php
index db4e042faeb..a9f4ff5089b 100644
--- a/apps/files_sharing/appinfo/app.php
+++ b/apps/files_sharing/appinfo/app.php
@@ -12,6 +12,8 @@ OC::$CLASSPATH['OCA\Files\Share\Api'] = 'files_sharing/lib/api.php';
OC::$CLASSPATH['OCA\Files\Share\Maintainer'] = 'files_sharing/lib/maintainer.php';
OC::$CLASSPATH['OCA\Files\Share\Proxy'] = 'files_sharing/lib/proxy.php';
+\OCP\App::registerAdmin('files_sharing', 'settings-admin');
+
$externalManager = new \OCA\Files_Sharing\External\Manager(
\OC::$server->getDatabaseConnection(),
\OC\Files\Filesystem::getMountManager(),
diff --git a/apps/files_sharing/js/external.js b/apps/files_sharing/js/external.js
index 5e133db2f57..bc02ecfaf97 100644
--- a/apps/files_sharing/js/external.js
+++ b/apps/files_sharing/js/external.js
@@ -22,10 +22,10 @@ $(document).ready(function () {
password = password || '';
if (add) {
addExternalShare(remote, token, owner, name, password).then(function (result) {
- if (result && result !== 'false') {
- FileList.reload();
+ if (result.status === 'error') {
+ OC.Notification.show(result.data.message);
} else {
- OC.dialogs.alert('Error adding ' + name, 'Error adding share');
+ FileList.reload();
}
});
}
diff --git a/apps/files_sharing/js/settings-admin.js b/apps/files_sharing/js/settings-admin.js
new file mode 100644
index 00000000000..257c864b04f
--- /dev/null
+++ b/apps/files_sharing/js/settings-admin.js
@@ -0,0 +1,11 @@
+$(document).ready(function() {
+
+ $('#fileSharingSettings input').change(function() {
+ var value = 'no';
+ if (this.checked) {
+ value = 'yes';
+ }
+ OC.AppConfig.setValue('files_sharing', $(this).attr('name'), value);
+ });
+
+});
diff --git a/apps/files_sharing/lib/helper.php b/apps/files_sharing/lib/helper.php
index 49546f012a6..a86cb832f3b 100644
--- a/apps/files_sharing/lib/helper.php
+++ b/apps/files_sharing/lib/helper.php
@@ -202,4 +202,24 @@ class Helper {
return $path;
}
+
+ /**
+ * allow users from other ownCloud instances to mount public links share by this instance
+ * @return bool
+ */
+ public static function isOutgoingServer2serverShareEnabled() {
+ $appConfig = \OC::$server->getAppConfig();
+ $result = $appConfig->getValue('files_sharing', 'outgoing_server2server_share_enabled', 'yes');
+ return ($result === 'yes') ? true : false;
+ }
+
+ /**
+ * allow user to mount public links from onther ownClouds
+ * @return bool
+ */
+ public static function isIncomingServer2serverShareEnabled() {
+ $appConfig = \OC::$server->getAppConfig();
+ $result = $appConfig->getValue('files_sharing', 'incoming_server2server_share_enabled', 'yes');
+ return ($result === 'yes') ? true : false;
+ }
}
diff --git a/apps/files_sharing/publicwebdav.php b/apps/files_sharing/publicwebdav.php
index f33b920bc54..b41d3a238ac 100644
--- a/apps/files_sharing/publicwebdav.php
+++ b/apps/files_sharing/publicwebdav.php
@@ -6,6 +6,10 @@
* See the COPYING-README file.
*/
+if (OCA\Files_Sharing\Helper::isOutgoingServer2serverShareEnabled() === false) {
+ return false;
+}
+
// load needed apps
$RUNTIME_APPTYPES = array('filesystem', 'authentication', 'logging');
diff --git a/apps/files_sharing/settings-admin.php b/apps/files_sharing/settings-admin.php
new file mode 100644
index 00000000000..9c630b6a911
--- /dev/null
+++ b/apps/files_sharing/settings-admin.php
@@ -0,0 +1,17 @@
+<?php
+/**
+ * Copyright (c) 2011 Robin Appelman <icewind@owncloud.com>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+\OC_Util::checkAdminUser();
+
+\OCP\Util::addScript('files_sharing', 'settings-admin');
+
+$tmpl = new OCP\Template('files_sharing', 'settings-admin');
+$tmpl->assign('outgoingServer2serverShareEnabled', OCA\Files_Sharing\Helper::isOutgoingServer2serverShareEnabled());
+$tmpl->assign('incomingServer2serverShareEnabled', OCA\Files_Sharing\Helper::isIncomingServer2serverShareEnabled());
+
+return $tmpl->fetchPage();
diff --git a/apps/files_sharing/templates/settings-admin.php b/apps/files_sharing/templates/settings-admin.php
new file mode 100644
index 00000000000..18cf2276701
--- /dev/null
+++ b/apps/files_sharing/templates/settings-admin.php
@@ -0,0 +1,13 @@
+<div class="section" id="fileSharingSettings" >
+
+ <h2><?php p($l->t('File Sharing'));?></h2>
+
+ <input type="checkbox" name="outgoing_server2server_share_enabled" id="outgoingServer2serverShareEnabled"
+ value="1" <?php if ($_['outgoingServer2serverShareEnabled']) print_unescaped('checked="checked"'); ?> />
+ <label for="outgoingServer2serverShareEnabled"><?php p($l->t('Allow other instances to mount public links shared from this server'));?></label><br/>
+
+ <input type="checkbox" name="incoming_server2server_share_enabled" id="incomingServer2serverShareEnabled"
+ value="1" <?php if ($_['incomingServer2serverShareEnabled']) print_unescaped('checked="checked"'); ?> />
+ <label for="incomingServer2serverShareEnabled"><?php p($l->t('Allow users to mount public link shares'));?></label><br/>
+
+</div>