@@ -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); |
@@ -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(), |
@@ -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(); | |||
} | |||
}); | |||
} |
@@ -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); | |||
}); | |||
}); |
@@ -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; | |||
} | |||
} |
@@ -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'); | |||
@@ -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(); |
@@ -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> |