OC.Share={ icons:[], itemUsers:[], itemGroups:[], itemPrivateLink:false, usersAndGroups:[], loadIcons:function() { // Cache all icons for shared files $.getJSON(OC.filePath('files_sharing', 'ajax', 'getstatuses.php'), function(result) { if (result && result.status === 'success') { $.each(result.data, function(item, hasPrivateLink) { if (hasPrivateLink) { OC.Share.icons[item] = OC.imagePath('core', 'actions/public'); } else { OC.Share.icons[item] = OC.imagePath('core', 'actions/shared'); } }); } }); }, loadItem:function(item) { $.ajax({type: 'GET', url: OC.filePath('files_sharing', 'ajax', 'getitem.php'), data: { item: item }, async: false, success: function(result) { if (result && result.status === 'success') { var item = result.data; OC.Share.itemUsers = item.users; OC.Share.itemGroups = item.groups; OC.Share.itemPrivateLink = item.privateLink; } }}); }, share:function(source, uid_shared_with, permissions, callback) { $.post(OC.filePath('files_sharing', 'ajax', 'share.php'), { sources: source, uid_shared_with: uid_shared_with, permissions: permissions }, function(result) { if (result && result.status === 'success') { if (callback) { callback(result.data); } } else { OC.dialogs.alert('Error', 'Error while sharing'); } }); }, unshare:function(source, uid_shared_with, callback) { $.post(OC.filePath('files_sharing', 'ajax', 'unshare.php'), { source: source, uid_shared_with: uid_shared_with }, function(result) { if (result && result.status === 'success') { if (callback) { callback(); } } else { OC.dialogs.alert('Error', 'Error while unsharing'); } }); }, changePermissions:function(source, uid_shared_with, permissions) { $.post(OC.filePath('files_sharing','ajax','setpermissions.php'), { source: source, uid_shared_with: uid_shared_with, permissions: permissions }, function(result) { if (!result || result.status !== 'success') { OC.dialogs.alert('Error', 'Error while changing permissions'); } }); }, showDropDown:function(item, appendTo) { OC.Share.loadItem(item); var html = '