<commit_before>/*
 * Copyright (c) 2014
 *
 * This file is licensed under the Affero General Public License version 3
 * or later.
 *
 * See the COPYING-README file.
 *
 */

(function() {
	if (!OCA.Sharing) {
		OCA.Sharing = {};
	}
	OCA.Sharing.Util = {
		initialize: function(fileActions) {
			if (OCA.Files.FileList) {
				var oldCreateRow = OCA.Files.FileList.prototype._createRow;
				OCA.Files.FileList.prototype._createRow = function(fileData) {
					var tr = oldCreateRow.apply(this, arguments);
					var sharePermissions = fileData.permissions;
					if (fileData.type === 'file') {
						// files can't be shared with delete permissions
						sharePermissions = sharePermissions & ~OC.PERMISSION_DELETE;
					}
					tr.attr('data-share-permissions', sharePermissions);
					if (fileData.shareOwner) {
						tr.attr('data-share-owner', fileData.shareOwner);
						// user should always be able to rename a mount point
						if (fileData.isShareMountPoint) {
							tr.attr('data-permissions', fileData.permissions | OC.PERMISSION_UPDATE);
						}
					}
					if (fileData.recipientsDisplayName) {
						tr.attr('data-share-recipients', fileData.recipientsDisplayName);
					}
					return tr;
				};

				var oldRenderRow = OCA.Files.FileList.prototype._renderRow;
				OCA.Files.FileList.prototype._renderRow = function(fileData) {
					var $tr = oldRenderRow.apply(this, arguments);
					// if the statuses are loaded already, use them for the icon
					// (needed when scrolling to the next page)
					var shareStatus = OC.Share.statuses[fileData.id];
					if (fileData.shareOwner || fileData.recipientsDisplayName || shareStatus) {
						var permissions = $tr.data('permissions');
						var hasLink = !!(shareStatus && shareStatus.link);
						if (permissions & OC.PERMISSION_SHARE) {
							OC.Share.markFileAsShared($tr, true, hasLink);
						} else {
							// if no share action exists because the admin disabled sharing for this user
							// we create a share notification action to inform the user about files
							// shared with him otherwise we just update the existing share action.
							// TODO: make this work like/with OC.Share.markFileAsShared()
							var shareNotification = '<a class="action action-share-notification permanent"' +
									' data-action="Share-Notification" href="#" original-title="">' +
									' <img class="svg" src="' + OC.imagePath('core', 'actions/share') + '"></img>';
							$tr.find('.fileactions').append(function() {
								var shareBy = t('files_sharing', 'Shared by {owner}', {owner: fileData.shareOwner});
								var $result = $(shareNotification + '<span> ' + shareBy + '</span></span>');
								$result.on('click', function() {
									return false;
								});
								return $result;
							});
						}
					}
					return $tr;<commit_msg>Sanitize name of sharee<commit_after>/*
 * Copyright (c) 2014
 *
 * This file is licensed under the Affero General Public License version 3
 * or later.
 *
 * See the COPYING-README file.
 *
 */

(function() {
	if (!OCA.Sharing) {
		OCA.Sharing = {};
	}
	OCA.Sharing.Util = {
		initialize: function(fileActions) {
			if (OCA.Files.FileList) {
				var oldCreateRow = OCA.Files.FileList.prototype._createRow;
				OCA.Files.FileList.prototype._createRow = function(fileData) {
					var tr = oldCreateRow.apply(this, arguments);
					var sharePermissions = fileData.permissions;
					if (fileData.type === 'file') {
						// files can't be shared with delete permissions
						sharePermissions = sharePermissions & ~OC.PERMISSION_DELETE;
					}
					tr.attr('data-share-permissions', sharePermissions);
					if (fileData.shareOwner) {
						tr.attr('data-share-owner', fileData.shareOwner);
						// user should always be able to rename a mount point
						if (fileData.isShareMountPoint) {
							tr.attr('data-permissions', fileData.permissions | OC.PERMISSION_UPDATE);
						}
					}
					if (fileData.recipientsDisplayName) {
						tr.attr('data-share-recipients', fileData.recipientsDisplayName);
					}
					return tr;
				};

				var oldRenderRow = OCA.Files.FileList.prototype._renderRow;
				OCA.Files.FileList.prototype._renderRow = function(fileData) {
					var $tr = oldRenderRow.apply(this, arguments);
					// if the statuses are loaded already, use them for the icon
					// (needed when scrolling to the next page)
					var shareStatus = OC.Share.statuses[fileData.id];
					if (fileData.shareOwner || fileData.recipientsDisplayName || shareStatus) {
						var permissions = $tr.data('permissions');
						var hasLink = !!(shareStatus && shareStatus.link);
						if (permissions & OC.PERMISSION_SHARE) {
							OC.Share.markFileAsShared($tr, true, hasLink);
						} else {
							// if no share action exists because the admin disabled sharing for this user
							// we create a share notification action to inform the user about files
							// shared with him otherwise we just update the existing share action.
							// TODO: make this work like/with OC.Share.markFileAsShared()
							var shareNotification = '<a class="action action-share-notification permanent"' +
									' data-action="Share-Notification" href="#" original-title="">' +
									' <img class="svg" src="' + OC.imagePath('core', 'actions/share') + '"></img>';
							$tr.find('.fileactions').append(function() {
								var shareBy = t('files_sharing', 'Shared by {owner}', {owner: escapeHTML(fileData.shareOwner)});
								var $result = $(shareNotification + '<span> ' + shareBy + '</span></span>');
								$result.on('click', function() {
									return false;
								});
								return $result;
							});
						}
					}
					return $tr;
{'fraction_non_alphanumeric': 0.1293408929836995, 'fraction_numerical': 0.001771793054571226, 'mean_word_length': 2.969760900140647, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5083786', 'n_tokens_mistral': 2200, 'n_tokens_neox': 1643, 'n_words': 424}