OC.Share={ SHARE_TYPE_USER:0, SHARE_TYPE_GROUP:1, SHARE_TYPE_PRIVATE_LINK:3, 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) { var data = ''; $.ajax({type: 'GET', url: OC.filePath('core', 'ajax', 'share.php'), data: { fetch: 'getItem', itemType: itemType, item: item }, async: false, success: function(result) { if (result && result.status === 'success') { data = result.data; } else { data = false; } }}); return 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, item, shareType, shareWith, callback) { $.post(OC.filePath('core', 'ajax', 'share.php'), { action: 'unshare', itemType: itemType, item: item, 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) { var html = '