parent
0aa6c1b163
commit
6e5e8c6b46
|
@ -10,8 +10,9 @@ OC.Share={
|
||||||
// Load all share icons
|
// Load all share icons
|
||||||
$.get(OC.filePath('core', 'ajax', 'share.php'), { fetch: 'getItemsSharedStatuses', itemType: itemType }, function(result) {
|
$.get(OC.filePath('core', 'ajax', 'share.php'), { fetch: 'getItemsSharedStatuses', itemType: itemType }, function(result) {
|
||||||
if (result && result.status === 'success') {
|
if (result && result.status === 'success') {
|
||||||
$.each(result.data, function(item, hasLink) {
|
$.each(result.data, function(item, data) {
|
||||||
OC.Share.statuses[item] = hasLink;
|
OC.Share.statuses[item] = data;
|
||||||
|
var hasLink = data['link'];
|
||||||
// Links override shared in terms of icon display
|
// Links override shared in terms of icon display
|
||||||
if (hasLink) {
|
if (hasLink) {
|
||||||
var image = OC.imagePath('core', 'actions/public');
|
var image = OC.imagePath('core', 'actions/public');
|
||||||
|
@ -21,30 +22,33 @@ OC.Share={
|
||||||
if (itemType != 'file' && itemType != 'folder') {
|
if (itemType != 'file' && itemType != 'folder') {
|
||||||
$('a.share[data-item="'+item+'"]').css('background', 'url('+image+') no-repeat center');
|
$('a.share[data-item="'+item+'"]').css('background', 'url('+image+') no-repeat center');
|
||||||
} else {
|
} else {
|
||||||
var file = $('tr').filterAttr('data-file', OC.basename(item));
|
var file = $('tr').filterAttr('data-id', item);
|
||||||
if (file.length > 0) {
|
if (file.length > 0) {
|
||||||
var action = $(file).find('.fileactions .action').filterAttr('data-action', 'Share');
|
var action = $(file).find('.fileactions .action').filterAttr('data-action', 'Share');
|
||||||
var img = action.find('img').attr('src', image);
|
var img = action.find('img').attr('src', image);
|
||||||
action.addClass('permanent');
|
action.addClass('permanent');
|
||||||
action.html(' '+t('core', 'Shared')).prepend(img);
|
action.html(' '+t('core', 'Shared')).prepend(img);
|
||||||
}
|
} else {
|
||||||
var dir = $('#dir').val();
|
var dir = $('#dir').val();
|
||||||
if (dir.length > 1) {
|
if (dir.length > 1) {
|
||||||
var last = '';
|
var last = '';
|
||||||
var path = dir;
|
var path = dir;
|
||||||
// Search for possible parent folders that are shared
|
// Search for possible parent folders that are shared
|
||||||
while (path != last) {
|
while (path != last) {
|
||||||
if (path == item) {
|
if (path == data['path']) {
|
||||||
var action = $('.fileactions .action').filterAttr('data-action', 'Share');
|
var actions = $('.fileactions .action').filterAttr('data-action', 'Share');
|
||||||
var img = action.find('img');
|
$.each(actions, function(index, action) {
|
||||||
if (img.attr('src') != OC.imagePath('core', 'actions/public')) {
|
var img = $(action).find('img');
|
||||||
img.attr('src', image);
|
if (img.attr('src') != OC.imagePath('core', 'actions/public')) {
|
||||||
action.addClass('permanent');
|
img.attr('src', image);
|
||||||
action.html(' '+t('core', 'Shared')).prepend(img);
|
$(action).addClass('permanent');
|
||||||
|
$(action).html(' '+t('core', 'Shared')).prepend(img);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
last = path;
|
||||||
|
path = OC.Share.dirname(path);
|
||||||
}
|
}
|
||||||
last = path;
|
|
||||||
path = OC.Share.dirname(path);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,15 +57,6 @@ OC.Share={
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
updateIcon:function(itemType, itemSource) {
|
updateIcon:function(itemType, itemSource) {
|
||||||
if (itemType == 'file' || itemType == 'folder') {
|
|
||||||
var file = $('tr').filterAttr('data-id', String(itemSource));
|
|
||||||
var filename = file.data('file');
|
|
||||||
if ($('#dir').val() == '/') {
|
|
||||||
itemSource = $('#dir').val() + filename;
|
|
||||||
} else {
|
|
||||||
itemSource = $('#dir').val() + '/' + filename;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var shares = false;
|
var shares = false;
|
||||||
var link = false;
|
var link = false;
|
||||||
var image = OC.imagePath('core', 'actions/share');
|
var image = OC.imagePath('core', 'actions/share');
|
||||||
|
@ -83,18 +78,21 @@ OC.Share={
|
||||||
if (itemType != 'file' && itemType != 'folder') {
|
if (itemType != 'file' && itemType != 'folder') {
|
||||||
$('a.share[data-item="'+itemSource+'"]').css('background', 'url('+image+') no-repeat center');
|
$('a.share[data-item="'+itemSource+'"]').css('background', 'url('+image+') no-repeat center');
|
||||||
} else {
|
} else {
|
||||||
var action = $(file).find('.fileactions .action').filterAttr('data-action', 'Share');
|
var file = $('tr').filterAttr('data-id', String(itemSource));
|
||||||
var img = action.find('img').attr('src', image);
|
if (file.length > 0) {
|
||||||
if (shares) {
|
var action = $(file).find('.fileactions .action').filterAttr('data-action', 'Share');
|
||||||
action.addClass('permanent');
|
var img = action.find('img').attr('src', image);
|
||||||
action.html(' '+t('core', 'Shared')).prepend(img);
|
if (shares) {
|
||||||
} else {
|
action.addClass('permanent');
|
||||||
action.removeClass('permanent');
|
action.html(' '+t('core', 'Shared')).prepend(img);
|
||||||
action.html(' '+t('core', 'Share')).prepend(img);
|
} else {
|
||||||
|
action.removeClass('permanent');
|
||||||
|
action.html(' '+t('core', 'Share')).prepend(img);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (shares) {
|
if (shares) {
|
||||||
OC.Share.statuses[itemSource] = link;
|
OC.Share.statuses[itemSource]['link'] = link;
|
||||||
} else {
|
} else {
|
||||||
delete OC.Share.statuses[itemSource];
|
delete OC.Share.statuses[itemSource];
|
||||||
}
|
}
|
||||||
|
@ -102,21 +100,7 @@ OC.Share={
|
||||||
loadItem:function(itemType, itemSource) {
|
loadItem:function(itemType, itemSource) {
|
||||||
var data = '';
|
var data = '';
|
||||||
var checkReshare = true;
|
var checkReshare = true;
|
||||||
// Switch file sources to path to check if status is set
|
if (typeof OC.Share.statuses[itemSource] === 'undefined') {
|
||||||
if (itemType == 'file' || itemType == 'folder') {
|
|
||||||
var filename = $('tr').filterAttr('data-id', String(itemSource)).data('file');
|
|
||||||
if ($('#dir').val() == '/') {
|
|
||||||
var item = $('#dir').val() + filename;
|
|
||||||
} else {
|
|
||||||
var item = $('#dir').val() + '/' + filename;
|
|
||||||
}
|
|
||||||
if (item.substring(0, 8) != '/Shared/') {
|
|
||||||
checkReshare = false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
var item = itemSource;
|
|
||||||
}
|
|
||||||
if (typeof OC.Share.statuses[item] === 'undefined') {
|
|
||||||
// NOTE: Check does not always work and misses some shares, fix later
|
// NOTE: Check does not always work and misses some shares, fix later
|
||||||
checkShares = true;
|
checkShares = true;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -759,7 +759,7 @@ class Share {
|
||||||
if ($format == self::FORMAT_STATUSES) {
|
if ($format == self::FORMAT_STATUSES) {
|
||||||
if ($itemType == 'file' || $itemType == 'folder') {
|
if ($itemType == 'file' || $itemType == 'folder') {
|
||||||
$select = '`*PREFIX*share`.`id`, `item_type`, `*PREFIX*share`.`parent`,'
|
$select = '`*PREFIX*share`.`id`, `item_type`, `*PREFIX*share`.`parent`,'
|
||||||
.' `share_type`, `file_source`, `path`, `expiration`';
|
.' `share_type`, `file_source`, `path`, `expiration`, `storage`';
|
||||||
} else {
|
} else {
|
||||||
$select = '`id`, `item_type`, `item_source`, `parent`, `share_type`, `expiration`';
|
$select = '`id`, `item_type`, `item_source`, `parent`, `share_type`, `expiration`';
|
||||||
}
|
}
|
||||||
|
@ -768,7 +768,7 @@ class Share {
|
||||||
if ($itemType == 'file' || $itemType == 'folder') {
|
if ($itemType == 'file' || $itemType == 'folder') {
|
||||||
$select = '`*PREFIX*share`.`id`, `item_type`, `*PREFIX*share`.`parent`,'
|
$select = '`*PREFIX*share`.`id`, `item_type`, `*PREFIX*share`.`parent`,'
|
||||||
.' `share_type`, `share_with`, `file_source`, `path`, `permissions`, `stime`,'
|
.' `share_type`, `share_with`, `file_source`, `path`, `permissions`, `stime`,'
|
||||||
.' `expiration`, `token`';
|
.' `expiration`, `token`, `storage`';
|
||||||
} else {
|
} else {
|
||||||
$select = '`id`, `item_type`, `item_source`, `parent`, `share_type`, `share_with`, `permissions`,'
|
$select = '`id`, `item_type`, `item_source`, `parent`, `share_type`, `share_with`, `permissions`,'
|
||||||
.' `stime`, `file_source`, `expiration`, `token`';
|
.' `stime`, `file_source`, `expiration`, `token`';
|
||||||
|
@ -804,6 +804,7 @@ class Share {
|
||||||
$items = array();
|
$items = array();
|
||||||
$targets = array();
|
$targets = array();
|
||||||
$switchedItems = array();
|
$switchedItems = array();
|
||||||
|
$mounts = array();
|
||||||
while ($row = $result->fetchRow()) {
|
while ($row = $result->fetchRow()) {
|
||||||
// Filter out duplicate group shares for users with unique targets
|
// Filter out duplicate group shares for users with unique targets
|
||||||
if ($row['share_type'] == self::$shareTypeGroupUserUnique && isset($items[$row['parent']])) {
|
if ($row['share_type'] == self::$shareTypeGroupUserUnique && isset($items[$row['parent']])) {
|
||||||
|
@ -848,8 +849,13 @@ class Share {
|
||||||
if (isset($row['parent'])) {
|
if (isset($row['parent'])) {
|
||||||
$row['path'] = '/Shared/'.basename($row['path']);
|
$row['path'] = '/Shared/'.basename($row['path']);
|
||||||
} else {
|
} else {
|
||||||
// Strip 'files' from path
|
if (!isset($mounts[$row['storage']])) {
|
||||||
$row['path'] = substr($row['path'], 5);
|
$mounts[$row['storage']] = \OC\Files\Mount::findByNumericId($row['storage']);
|
||||||
|
}
|
||||||
|
if ($mounts[$row['storage']]) {
|
||||||
|
$path = $mounts[$row['storage']]->getMountPoint().$row['path'];
|
||||||
|
$row['path'] = substr($path, $root);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isset($row['expiration'])) {
|
if (isset($row['expiration'])) {
|
||||||
|
@ -957,15 +963,14 @@ class Share {
|
||||||
return $items;
|
return $items;
|
||||||
} else if ($format == self::FORMAT_STATUSES) {
|
} else if ($format == self::FORMAT_STATUSES) {
|
||||||
$statuses = array();
|
$statuses = array();
|
||||||
// Switch column to path for files and folders, used for determining statuses inside of folders
|
|
||||||
if ($itemType == 'file' || $itemType == 'folder') {
|
|
||||||
$column = 'path';
|
|
||||||
}
|
|
||||||
foreach ($items as $item) {
|
foreach ($items as $item) {
|
||||||
if ($item['share_type'] == self::SHARE_TYPE_LINK) {
|
if ($item['share_type'] == self::SHARE_TYPE_LINK) {
|
||||||
$statuses[$item[$column]] = true;
|
$statuses[$item[$column]]['link'] = true;
|
||||||
} else if (!isset($statuses[$item[$column]])) {
|
} else if (!isset($statuses[$item[$column]])) {
|
||||||
$statuses[$item[$column]] = false;
|
$statuses[$item[$column]]['link'] = false;
|
||||||
|
}
|
||||||
|
if ($itemType == 'file' || $itemType == 'folder') {
|
||||||
|
$statuses[$item[$column]]['path'] = $item['path'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $statuses;
|
return $statuses;
|
||||||
|
|
Loading…
Reference in New Issue