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

UserList={
	useUndo:true,
	
	/**
	 * @brief Initiate user deletion process in UI
	 * @param string uid the user ID to be deleted
	 *
	 * Does not actually delete the user; it sets them for
	 * deletion when the current page is unloaded, at which point 
	 * finishDelete() completes the process. This allows for 'undo'.
	 */
	do_delete:function( uid ) {
		
		UserList.deleteUid = uid;
		
		// Set undo flag
		UserList.deleteCanceled = false;
		
		// Provide user with option to undo
		$('#notification').html(t('users', 'deleted')+' '+uid+'<span class="undo">'+t('users', 'undo')+'</span>');
		$('#notification').data('deleteuser',true);
		$('#notification').fadeIn();
			
	},
	
	/**
	 * @brief Delete a user via ajax
	 * @param bool ready whether to use ready() upon completion
	 *
	 * Executes deletion via ajax of user identified by property deleteUid 
	 * if 'undo' has not been used.  Completes the user deletion procedure 
	 * and reflects success in UI.
	 */
	finishDelete:function( ready ){
		
		// Check deletion has not been undone
		if( !UserList.deleteCanceled && UserList.deleteUid ){
			
			// Delete user via ajax
			$.ajax({
				type: 'POST',
				url: OC.filePath('settings', 'ajax', 'removeuser.php'),
				async: false,
				data: { username: UserList.deleteUid },
				success: function(result) {
					if (result.status == 'success') {
						// Remove undo option, & remove user from table
						$('#notification').fadeOut();
						$('tr').filterAttr('data-uid', UserList.deleteUid).remove();
						UserList.deleteCanceled = true;
						UserList.deleteFiles = null;
						if (ready) {
							ready();
						}
					}
				}
			});
 		}
	},

	add:function(username, groups, subadmin, quota, sort) {
		var tr = $('tbody tr').first().clone();
		tr.data('uid', username);
		tr.find('td.name').text(username);
		var groupsSelect = $('<select multiple="multiple" class="groupsselect" data-placehoder="Groups" title="Groups">');
		groupsSelect.data('username', username);
		groupsSelect.data('userGroups', groups);
		tr.find('td.groups').empty();
		if (tr.find('td.subadmins').length > 0) {
			var subadminSelect = $('<select multiple="multiple" class="subadminsselect" data-placehoder="subadmins" title="' + t('files', 'Group Admin') + '">');
			subadminSelect.data('username', username);
			subadminSelect.data('userGroups', groups);
			subadminSelect.data('subadmin', subadmin);
			tr.find('td.subadmins').empty();
		}
		var allGroups = String($('#content table').data('groups')).split(', ');
		$.each(allGroups, function(i, group) {
			groupsSelect.append($('<option value="'+group+'">'+group+'</option>'));
			if (typeof subadminSelect !== 'undefined' && group != 'admin') {
				subadminSelect.append($('<option value="'+group+'">'+group+'</option>'));
			}
		});
		tr.find('td.groups').append(groupsSelect);
		UserList.applyMultiplySelect(groupsSelect);
		tr.find('td.subadmins').append(subadminSelect);
		UserList.applyMultiplySelect(subadminSelect);
		if (tr.find('td.remove img').length == 0 && OC.currentUser != username) {
			tr.find('td.remove').append($('<img alt="Delete" title="'+t('settings','Delete')+'" class="svg action" src="'+OC.imagePath('core','actions/delete')+'"/>'));
		} else if (OC.currentUser == username) {
			tr.find('td.remove a').remove();
		}
		var quotaSelect = tr.find('select.quota-user');
		if (quota == 'default') {
			quotaSelect.find('option').attr('selected', null);
			quotaSelect.find('option').first().attr('selected', 'selected');
			quotaSelect.data('previous', 'default');
		} else {
			if (quotaSelect.find('option[value="'+quota+'"]').length > 0) {
				quotaSelect.find('option[value="'+quota+'"]').attr('selected', 'selected');
			} else {
				quotaSelect.append('<option value="'+quota+'" selected="selected">'+quota+'</option>');
			}
		}
		var added = false;<commit_msg>fix UI bug with subadmins<commit_after>/**
 * Copyright (c) 2011, <NAME> <<EMAIL>>
 * This file is licensed under the Affero General Public License version 3 or later.
 * See the COPYING-README file.
 */

UserList={
	useUndo:true,
	
	/**
	 * @brief Initiate user deletion process in UI
	 * @param string uid the user ID to be deleted
	 *
	 * Does not actually delete the user; it sets them for
	 * deletion when the current page is unloaded, at which point 
	 * finishDelete() completes the process. This allows for 'undo'.
	 */
	do_delete:function( uid ) {
		
		UserList.deleteUid = uid;
		
		// Set undo flag
		UserList.deleteCanceled = false;
		
		// Provide user with option to undo
		$('#notification').html(t('users', 'deleted')+' '+uid+'<span class="undo">'+t('users', 'undo')+'</span>');
		$('#notification').data('deleteuser',true);
		$('#notification').fadeIn();
			
	},
	
	/**
	 * @brief Delete a user via ajax
	 * @param bool ready whether to use ready() upon completion
	 *
	 * Executes deletion via ajax of user identified by property deleteUid 
	 * if 'undo' has not been used.  Completes the user deletion procedure 
	 * and reflects success in UI.
	 */
	finishDelete:function( ready ){
		
		// Check deletion has not been undone
		if( !UserList.deleteCanceled && UserList.deleteUid ){
			
			// Delete user via ajax
			$.ajax({
				type: 'POST',
				url: OC.filePath('settings', 'ajax', 'removeuser.php'),
				async: false,
				data: { username: UserList.deleteUid },
				success: function(result) {
					if (result.status == 'success') {
						// Remove undo option, & remove user from table
						$('#notification').fadeOut();
						$('tr').filterAttr('data-uid', UserList.deleteUid).remove();
						UserList.deleteCanceled = true;
						UserList.deleteFiles = null;
						if (ready) {
							ready();
						}
					}
				}
			});
 		}
	},

	add:function(username, groups, subadmin, quota, sort) {
		var tr = $('tbody tr').first().clone();
		tr.data('uid', username);
		tr.find('td.name').text(username);
		var groupsSelect = $('<select multiple="multiple" class="groupsselect" data-placehoder="Groups" title="Groups">');
		groupsSelect.data('username', username);
		groupsSelect.data('userGroups', groups);
		tr.find('td.groups').empty();
		if (tr.find('td.subadmins').length > 0) {
			var subadminSelect = $('<select multiple="multiple" class="subadminsselect" data-placehoder="subadmins" title="' + t('files', 'Group Admin') + '">');
			subadminSelect.data('username', username);
			subadminSelect.data('userGroups', groups);
			subadminSelect.data('subadmin', subadmin);
			tr.find('td.subadmins').empty();
		}
		var allGroups = String($('#content table').data('groups')).split(', ');
		$.each(allGroups, function(i, group) {
			groupsSelect.append($('<option value="'+group+'">'+group+'</option>'));
			if (typeof subadminSelect !== 'undefined' && group != 'admin') {
				subadminSelect.append($('<option value="'+group+'">'+group+'</option>'));
			}
		});
		tr.find('td.groups').append(groupsSelect);
		UserList.applyMultiplySelect(groupsSelect);
		if (tr.find('td.subadmins').length > 0) {
			tr.find('td.subadmins').append(subadminSelect);
			UserList.applyMultiplySelect(subadminSelect);
		}
		if (tr.find('td.remove img').length == 0 && OC.currentUser != username) {
			tr.find('td.remove').append($('<img alt="Delete" title="'+t('settings','Delete')+'" class="svg action" src="'+OC.imagePath('core','actions/delete')+'"/>'));
		} else if (OC.currentUser == username) {
			tr.find('td.remove a').remove();
		}
		var quotaSelect = tr.find('select.quota-user');
		if (quota == 'default') {
			quotaSelect.find('option').attr('selected', null);
			quotaSelect.find('option').first().attr('selected', 'selected');
			quotaSelect.data('previous', 'default');
		} else {
			if (quotaSelect.find('option[value="'+quota+'"]').length > 0) {
				quotaSelect.find('option[value="'+quota+'"]').attr('selected', 'selected');
			} else {
				quotaSelect.append('<option value="'+quota+'" selected="selected">'+quota+'</option>');
			}
		}
		var added = false;
{'fraction_non_alphanumeric': 0.190004948045522, 'fraction_numerical': 0.002102919346857991, 'mean_word_length': 4.143129770992366, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 36, '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': '2931043', 'n_tokens_mistral': 2932, 'n_tokens_neox': 2507, 'n_words': 586}