diff --git a/apps/files_sharing/appinfo/app.php b/apps/files_sharing/appinfo/app.php index ffdcbf0510..bdaea64bb9 100644 --- a/apps/files_sharing/appinfo/app.php +++ b/apps/files_sharing/appinfo/app.php @@ -8,6 +8,7 @@ OC::$CLASSPATH['OC\Files\Cache\Shared_Permissions'] = 'files_sharing/lib/permiss OC::$CLASSPATH['OC\Files\Cache\Shared_Updater'] = 'files_sharing/lib/updater.php'; OC::$CLASSPATH['OC\Files\Cache\Shared_Watcher'] = 'files_sharing/lib/watcher.php'; OC::$CLASSPATH['OCA\Files\Share\Api'] = 'files_sharing/lib/api.php'; +OC::$CLASSPATH['OCA\Files\Share\Maintainer'] = 'files_sharing/lib/maintainer.php'; OCP\Util::connectHook('OC_Filesystem', 'setup', '\OC\Files\Storage\Shared', 'setup'); OCP\Share::registerBackend('file', 'OC_Share_Backend_File'); OCP\Share::registerBackend('folder', 'OC_Share_Backend_Folder', 'file'); @@ -17,3 +18,4 @@ OCP\Util::addScript('files_sharing', 'share'); \OC_Hook::connect('OC_Filesystem', 'post_rename', '\OC\Files\Cache\Shared_Updater', 'renameHook'); \OC_Hook::connect('OCP\Share', 'post_shared', '\OC\Files\Cache\Shared_Updater', 'shareHook'); \OC_Hook::connect('OCP\Share', 'pre_unshare', '\OC\Files\Cache\Shared_Updater', 'shareHook'); +\OC_Hook::connect('OC_Appconfig', 'post_set_value', '\OCA\Files\Share\Maintainer', 'configChangeHook'); diff --git a/apps/files_sharing/lib/maintainer.php b/apps/files_sharing/lib/maintainer.php new file mode 100644 index 0000000000..bbb3268410 --- /dev/null +++ b/apps/files_sharing/lib/maintainer.php @@ -0,0 +1,44 @@ +. + */ + +namespace OCA\Files\Share; + +/** + * Maintains stuff around the sharing functionality + * + * for example: on disable of "allow links" it removes all link shares + */ + +class Maintainer { + + /** + * Keeps track of the "allow links" config setting + * and removes all link shares if the config option is set to "no" + * + * @param array with app, key, value as named values + */ + static public function configChangeHook($params) { + if($params['app'] === 'core' && $params['key'] === 'shareapi_allow_links' && $params['value'] === 'no') { + \OCP\Share::removeAllLinkShares(); + } + } + +} diff --git a/core/js/share.js b/core/js/share.js index 270eab356e..25126d3c23 100644 --- a/core/js/share.js +++ b/core/js/share.js @@ -203,7 +203,19 @@ OC.Share={ html += ''; html += ''; - if (link) { + var linksAllowed = false; + $.ajax({ + type: 'GET', + url: OC.filePath('core', 'ajax', 'appconfig.php'), + data: { action:'getValue', app:'core', key:'shareapi_allow_links', defaultValue:'yes' }, + async: false, + success: function(result) { + if (result && result.status === 'success' && result.data === 'yes') { + linksAllowed = true; + } + } + }); + if (link && linksAllowed) { html += '