]> source.dussan.org Git - nextcloud-server.git/commitdiff
add settings to disable server to server sharing
authorBjoern Schiessle <schiessle@owncloud.com>
Thu, 12 Jun 2014 17:49:52 +0000 (19:49 +0200)
committerBjoern Schiessle <schiessle@owncloud.com>
Sat, 14 Jun 2014 08:22:38 +0000 (10:22 +0200)
apps/files_sharing/ajax/external.php
apps/files_sharing/appinfo/app.php
apps/files_sharing/js/external.js
apps/files_sharing/js/settings-admin.js [new file with mode: 0644]
apps/files_sharing/lib/helper.php
apps/files_sharing/publicwebdav.php
apps/files_sharing/settings-admin.php [new file with mode: 0644]
apps/files_sharing/templates/settings-admin.php [new file with mode: 0644]

index 3759559764d4cab557ce2e4cea5426e7549792b8..5b4d4656d62a631782495608dd2a0deaa3baab5f 100644 (file)
@@ -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);
index db4e042faebc7a8b4e20ad3aed1a1e21610e90f1..a9f4ff5089b5da195438a7f1ee91cabaa54caa16 100644 (file)
@@ -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(),
index 5e133db2f574b5fdec545c6d10576a3e4498c698..bc02ecfaf97e1928f7a9b530ab71e5e7681049da 100644 (file)
@@ -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 (file)
index 0000000..257c864
--- /dev/null
@@ -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);
+       });
+
+});
index 49546f012a63e87b7535ca8d4017cd6c3efd8cee..a86cb832f3b51a2f841b64598f66a575e2d7639e 100644 (file)
@@ -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;
+       }
 }
index f33b920bc54e2a5f5320cc38f724e300d769bc80..b41d3a238ac1f82de86d6cd69aee1a791739f2b5 100644 (file)
@@ -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 (file)
index 0000000..9c630b6
--- /dev/null
@@ -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 (file)
index 0000000..18cf227
--- /dev/null
@@ -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>