Merge pull request #3219 from owncloud/disabled-links-ui
Disabled links UI fixes
This commit is contained in:
commit
05523e7a70
|
@ -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_Updater'] = 'files_sharing/lib/updater.php';
|
||||||
OC::$CLASSPATH['OC\Files\Cache\Shared_Watcher'] = 'files_sharing/lib/watcher.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\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\Util::connectHook('OC_Filesystem', 'setup', '\OC\Files\Storage\Shared', 'setup');
|
||||||
OCP\Share::registerBackend('file', 'OC_Share_Backend_File');
|
OCP\Share::registerBackend('file', 'OC_Share_Backend_File');
|
||||||
OCP\Share::registerBackend('folder', 'OC_Share_Backend_Folder', '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('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', 'post_shared', '\OC\Files\Cache\Shared_Updater', 'shareHook');
|
||||||
\OC_Hook::connect('OCP\Share', 'pre_unshare', '\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');
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* ownCloud
|
||||||
|
*
|
||||||
|
* @author Morris Jobke
|
||||||
|
* @copyright 2013 Morris Jobke morris.jobke@gmail.com
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 3 of the License, or any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public
|
||||||
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -203,7 +203,19 @@ OC.Share={
|
||||||
html += '<input id="shareWith" type="text" placeholder="'+t('core', 'Share with')+'" />';
|
html += '<input id="shareWith" type="text" placeholder="'+t('core', 'Share with')+'" />';
|
||||||
html += '<ul id="shareWithList">';
|
html += '<ul id="shareWithList">';
|
||||||
html += '</ul>';
|
html += '</ul>';
|
||||||
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 += '<div id="link">';
|
html += '<div id="link">';
|
||||||
html += '<input type="checkbox" name="linkCheckbox" id="linkCheckbox" value="1" /><label for="linkCheckbox">'+t('core', 'Share with link')+'</label>';
|
html += '<input type="checkbox" name="linkCheckbox" id="linkCheckbox" value="1" /><label for="linkCheckbox">'+t('core', 'Share with link')+'</label>';
|
||||||
html += '<br />';
|
html += '<br />';
|
||||||
|
|
|
@ -134,6 +134,12 @@ class OC_Appconfig{
|
||||||
.' WHERE `appid` = ? AND `configkey` = ?' );
|
.' WHERE `appid` = ? AND `configkey` = ?' );
|
||||||
$query->execute( array( $value, $app, $key ));
|
$query->execute( array( $value, $app, $key ));
|
||||||
}
|
}
|
||||||
|
// TODO where should this be documented?
|
||||||
|
\OC_Hook::emit('OC_Appconfig', 'post_set_value', array(
|
||||||
|
'app' => $app,
|
||||||
|
'key' => $key,
|
||||||
|
'value' => $value
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -960,6 +960,10 @@ class Share {
|
||||||
$queryArgs = array($itemType);
|
$queryArgs = array($itemType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (\OC_Appconfig::getValue('core', 'shareapi_allow_links', 'yes') !== 'yes') {
|
||||||
|
$where .= ' AND `share_type` != ?';
|
||||||
|
$queryArgs[] = self::SHARE_TYPE_LINK;
|
||||||
|
}
|
||||||
if (isset($shareType)) {
|
if (isset($shareType)) {
|
||||||
// Include all user and group items
|
// Include all user and group items
|
||||||
if ($shareType == self::$shareTypeUserAndGroups && isset($shareWith)) {
|
if ($shareType == self::$shareTypeUserAndGroups && isset($shareWith)) {
|
||||||
|
@ -1717,6 +1721,18 @@ class Share {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete all shares with type SHARE_TYPE_LINK
|
||||||
|
*/
|
||||||
|
public static function removeAllLinkShares() {
|
||||||
|
// Delete any link shares
|
||||||
|
$query = \OC_DB::prepare('SELECT `id` FROM `*PREFIX*share` WHERE `share_type` = ?');
|
||||||
|
$result = $query->execute(array(self::SHARE_TYPE_LINK));
|
||||||
|
while ($item = $result->fetchRow()) {
|
||||||
|
self::delete($item['id']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hook Listeners
|
* Hook Listeners
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue