OC.Share={ item:[], statuses:[], loadIcons:function(itemType) { // Load all share icons $.get(OC.filePath('core', 'ajax', 'share.php'), { fetch: 'getItemsSharedStatuses', itemType: itemType }, function(result) { if (result && result.status === 'success') { $.each(result.data, function(item, hasPrivateLink) { // Private links override shared in terms of icon display if (itemType == 'file') { OC.Share.statuses[item] = hasPrivateLink; } else { if (hasPrivateLink) { $('.share').find('[data-item="'+item+'"]').attr('src', OC.imagePath('core', 'actions/public')); } else { $('.share').find('[data-item="'+item+'"]').attr('src', OC.imagePath('core', 'actions/shared')); } } }); } }); }, loadItem:function(itemType, item) { $.get(OC.filePath('core', 'ajax', 'share.php'), { fetch: 'getItemShared', itemType: itemType, item: item }, function(result) { if (result && result.status === 'success') { OC.Share.item = result.data; } }); }, share:function(itemType, item, shareType, shareWith, permissions, callback) { $.post(OC.filePath('core', 'ajax', 'share.php'), { action: 'share', itemType: itemType, item: item, shareType: shareType, shareWith: shareWith, permissions: permissions }, function(result) { if (result && result.status === 'success') { if (callback) { callback(result.data); } } else { OC.dialogs.alert('Error', 'Error while sharing'); } }); }, unshare:function(itemType, shareType, shareWith, callback) { $.post(OC.filePath('core', 'ajax', 'share.php'), { action: 'unshare', itemType: itemType, shareType: shareType, shareWith: shareWith }, function(result) { if (result && result.status === 'success') { if (callback) { callback(); } } else { OC.dialogs.alert('Error', 'Error while unsharing'); } }); }, setPermissions:function(itemType, item, shareType, shareWith, permissions) { $.post(OC.filePath('core', 'ajax', 'share.php'), { action: 'setPermissions', itemType: itemType, item: item, shareType: shareType, shareWith: shareWith, permissions: permissions }, function(result) { if (!result || result.status !== 'success') { OC.dialogs.alert('Error', 'Error while changing permissions'); } }); }, showDropDown:function(itemType, item, appendTo) { OC.Share.loadItem(item); var html = '