OCP\JSON::callCheck(); | OCP\JSON::callCheck(); | ||||
OCP\JSON::checkLoggedIn(); | 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']; | $token = $_POST['token']; | ||||
$remote = $_POST['remote']; | $remote = $_POST['remote']; | ||||
$owner = $_POST['owner']; | $owner = $_POST['owner']; | ||||
$result = $storage->file_exists(''); | $result = $storage->file_exists(''); | ||||
if($result){ | if($result){ | ||||
$storage->getScanner()->scanAll(); | $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); |
OC::$CLASSPATH['OCA\Files\Share\Maintainer'] = 'files_sharing/lib/maintainer.php'; | OC::$CLASSPATH['OCA\Files\Share\Maintainer'] = 'files_sharing/lib/maintainer.php'; | ||||
OC::$CLASSPATH['OCA\Files\Share\Proxy'] = 'files_sharing/lib/proxy.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( | $externalManager = new \OCA\Files_Sharing\External\Manager( | ||||
\OC::$server->getDatabaseConnection(), | \OC::$server->getDatabaseConnection(), | ||||
\OC\Files\Filesystem::getMountManager(), | \OC\Files\Filesystem::getMountManager(), |
password = password || ''; | password = password || ''; | ||||
if (add) { | if (add) { | ||||
addExternalShare(remote, token, owner, name, password).then(function (result) { | 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 { | } else { | ||||
OC.dialogs.alert('Error adding ' + name, 'Error adding share'); | |||||
FileList.reload(); | |||||
} | } | ||||
}); | }); | ||||
} | } |
$(document).ready(function() { | |||||
$('#fileSharingSettings input').change(function() { | |||||
var value = 'no'; | |||||
if (this.checked) { | |||||
value = 'yes'; | |||||
} | |||||
OC.AppConfig.setValue('files_sharing', $(this).attr('name'), value); | |||||
}); | |||||
}); |
return $path; | 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; | |||||
} | |||||
} | } |
* See the COPYING-README file. | * See the COPYING-README file. | ||||
*/ | */ | ||||
if (OCA\Files_Sharing\Helper::isOutgoingServer2serverShareEnabled() === false) { | |||||
return false; | |||||
} | |||||
// load needed apps | // load needed apps | ||||
$RUNTIME_APPTYPES = array('filesystem', 'authentication', 'logging'); | $RUNTIME_APPTYPES = array('filesystem', 'authentication', 'logging'); | ||||
<?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(); |
<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> |