2011-08-23 03:40:13 +04:00
|
|
|
/**
|
2014-03-06 11:05:44 +04:00
|
|
|
* Copyright (c) 2014, Arthur Schiwon <blizzz@owncloud.com>
|
|
|
|
* Copyright (c) 2014, Raghu Nayyar <beingminimal@gmail.com>
|
2011-08-23 03:40:13 +04:00
|
|
|
* Copyright (c) 2011, Robin Appelman <icewind1991@gmail.com>
|
|
|
|
* This file is licensed under the Affero General Public License version 3 or later.
|
|
|
|
* See the COPYING-README file.
|
|
|
|
*/
|
|
|
|
|
2016-08-19 11:46:42 +03:00
|
|
|
/* globals escapeHTML, GroupList, DeleteHandler, UserManagementFilter */
|
|
|
|
|
2014-05-06 06:41:54 +04:00
|
|
|
var $userList;
|
|
|
|
var $userListBody;
|
2017-03-03 16:44:16 +03:00
|
|
|
var $emptyContainer;
|
2014-05-06 06:41:54 +04:00
|
|
|
|
2015-10-07 17:17:38 +03:00
|
|
|
var UserDeleteHandler;
|
2012-12-20 12:59:09 +04:00
|
|
|
var UserList = {
|
2013-03-19 17:49:02 +04:00
|
|
|
availableGroups: [],
|
2014-12-11 17:37:56 +03:00
|
|
|
offset: 0,
|
2013-04-30 21:51:28 +04:00
|
|
|
usersToLoad: 10, //So many users will be loaded when user scrolls down
|
2016-06-07 12:40:04 +03:00
|
|
|
initialUsersToLoad: 50, //initial number of users to load
|
2014-02-20 21:42:03 +04:00
|
|
|
currentGid: '',
|
2015-08-05 18:29:20 +03:00
|
|
|
filter: '',
|
2012-07-04 17:28:08 +04:00
|
|
|
|
2014-08-11 18:37:48 +04:00
|
|
|
/**
|
|
|
|
* Initializes the user list
|
|
|
|
* @param $el user list table element
|
|
|
|
*/
|
|
|
|
initialize: function($el) {
|
|
|
|
this.$el = $el;
|
|
|
|
|
|
|
|
// initially the list might already contain user entries (not fully ajaxified yet)
|
|
|
|
// initialize these entries
|
|
|
|
this.$el.find('.quota-user').singleSelect().on('change', this.onQuotaSelect);
|
|
|
|
},
|
|
|
|
|
2014-12-15 14:43:42 +03:00
|
|
|
/**
|
|
|
|
* Add a user row from user object
|
|
|
|
*
|
|
|
|
* @param user object containing following keys:
|
|
|
|
* {
|
|
|
|
* 'name': 'username',
|
|
|
|
* 'displayname': 'Users display name',
|
|
|
|
* 'groups': ['group1', 'group2'],
|
|
|
|
* 'subadmin': ['group4', 'group5'],
|
|
|
|
* 'quota': '10 GB',
|
|
|
|
* 'storageLocation': '/srv/www/owncloud/data/username',
|
|
|
|
* 'lastLogin': '1418632333'
|
|
|
|
* 'backend': 'LDAP',
|
|
|
|
* 'email': 'username@example.org'
|
2015-01-23 19:45:45 +03:00
|
|
|
* 'isRestoreDisabled':false
|
2014-12-15 14:43:42 +03:00
|
|
|
* }
|
|
|
|
*/
|
2016-10-11 13:41:19 +03:00
|
|
|
add: function (user) {
|
2015-04-12 17:22:21 +03:00
|
|
|
if (this.currentGid && this.currentGid !== '_everyone' && _.indexOf(user.groups, this.currentGid) < 0) {
|
2015-03-27 02:09:35 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-05-06 06:41:54 +04:00
|
|
|
var $tr = $userListBody.find('tr:first-child').clone();
|
2014-12-11 17:37:56 +03:00
|
|
|
// this removes just the `display:none` of the template row
|
|
|
|
$tr.removeAttr('style');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Avatar or placeholder
|
|
|
|
*/
|
2015-12-04 16:35:48 +03:00
|
|
|
if ($tr.find('div.avatardiv').length) {
|
|
|
|
if (user.isAvatarAvailable === true) {
|
|
|
|
$('div.avatardiv', $tr).avatar(user.name, 32, undefined, undefined, undefined, user.displayname);
|
|
|
|
} else {
|
2015-12-17 09:56:02 +03:00
|
|
|
$('div.avatardiv', $tr).imageplaceholder(user.displayname, undefined, 32);
|
2015-12-04 16:35:48 +03:00
|
|
|
}
|
2013-10-07 19:00:15 +04:00
|
|
|
}
|
2014-12-11 17:37:56 +03:00
|
|
|
|
|
|
|
/**
|
2015-01-23 19:45:45 +03:00
|
|
|
* add username and displayname to row (in data and visible markup)
|
2014-12-11 17:37:56 +03:00
|
|
|
*/
|
2014-12-15 14:43:42 +03:00
|
|
|
$tr.data('uid', user.name);
|
|
|
|
$tr.data('displayname', user.displayname);
|
|
|
|
$tr.data('mailAddress', user.email);
|
2015-01-23 19:45:45 +03:00
|
|
|
$tr.data('restoreDisabled', user.isRestoreDisabled);
|
2015-04-13 18:12:06 +03:00
|
|
|
$tr.find('.name').text(user.name);
|
2014-12-15 14:43:42 +03:00
|
|
|
$tr.find('td.displayName > span').text(user.displayname);
|
|
|
|
$tr.find('td.mailAddress > span').text(user.email);
|
2015-08-07 15:00:44 +03:00
|
|
|
$tr.find('td.displayName > .action').tooltip({placement: 'top'});
|
|
|
|
$tr.find('td.mailAddress > .action').tooltip({placement: 'top'});
|
|
|
|
$tr.find('td.password > .action').tooltip({placement: 'top'});
|
2014-02-03 21:00:39 +04:00
|
|
|
|
2016-08-23 18:22:10 +03:00
|
|
|
|
2014-12-12 11:59:42 +03:00
|
|
|
/**
|
|
|
|
* groups and subadmins
|
|
|
|
*/
|
2016-08-23 18:22:10 +03:00
|
|
|
var $tdGroups = $tr.find('td.groups');
|
|
|
|
this._updateGroupListLabel($tdGroups, user.groups);
|
|
|
|
$tdGroups.find('.action').tooltip({placement: 'top'});
|
|
|
|
|
|
|
|
var $tdSubadmins = $tr.find('td.subadmins');
|
|
|
|
this._updateGroupListLabel($tdSubadmins, user.subadmin);
|
|
|
|
$tdSubadmins.find('.action').tooltip({placement: 'top'});
|
2014-12-12 11:59:42 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* remove action
|
|
|
|
*/
|
2014-12-15 14:43:42 +03:00
|
|
|
if ($tr.find('td.remove img').length === 0 && OC.currentUser !== user.name) {
|
2016-06-23 14:39:28 +03:00
|
|
|
var deleteImage = $('<img class="action">').attr({
|
2013-02-11 18:18:14 +04:00
|
|
|
src: OC.imagePath('core', 'actions/delete')
|
|
|
|
});
|
2014-05-07 19:37:33 +04:00
|
|
|
var deleteLink = $('<a class="action delete">')
|
2013-02-14 15:59:59 +04:00
|
|
|
.attr({ href: '#', 'original-title': t('settings', 'Delete')})
|
2014-05-07 19:37:33 +04:00
|
|
|
.append(deleteImage);
|
2014-05-06 06:41:54 +04:00
|
|
|
$tr.find('td.remove').append(deleteLink);
|
2014-12-15 14:43:42 +03:00
|
|
|
} else if (OC.currentUser === user.name) {
|
2014-05-06 06:41:54 +04:00
|
|
|
$tr.find('td.remove a').remove();
|
2013-02-11 18:18:14 +04:00
|
|
|
}
|
2014-12-12 11:59:42 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* quota
|
|
|
|
*/
|
2014-05-06 06:41:54 +04:00
|
|
|
var $quotaSelect = $tr.find('.quota-user');
|
2014-12-15 14:43:42 +03:00
|
|
|
if (user.quota === 'default') {
|
2014-05-06 06:41:54 +04:00
|
|
|
$quotaSelect
|
|
|
|
.data('previous', 'default')
|
|
|
|
.find('option').attr('selected', null)
|
|
|
|
.first().attr('selected', 'selected');
|
2013-02-11 18:18:14 +04:00
|
|
|
} else {
|
2016-06-23 19:42:11 +03:00
|
|
|
var $options = $quotaSelect.find('option');
|
|
|
|
var $foundOption = $options.filterAttr('value', user.quota);
|
|
|
|
if ($foundOption.length > 0) {
|
|
|
|
$foundOption.attr('selected', 'selected');
|
2013-02-11 18:18:14 +04:00
|
|
|
} else {
|
2016-06-23 19:42:11 +03:00
|
|
|
// append before "Other" entry
|
|
|
|
$options.last().before('<option value="' + escapeHTML(user.quota) + '" selected="selected">' + escapeHTML(user.quota) + '</option>');
|
2013-02-11 18:18:14 +04:00
|
|
|
}
|
|
|
|
}
|
2014-12-12 11:59:42 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* storage location
|
|
|
|
*/
|
2014-12-15 14:43:42 +03:00
|
|
|
$tr.find('td.storageLocation').text(user.storageLocation);
|
2014-06-19 16:30:22 +04:00
|
|
|
|
2014-12-12 12:21:50 +03:00
|
|
|
/**
|
|
|
|
* user backend
|
|
|
|
*/
|
2014-12-15 14:43:42 +03:00
|
|
|
$tr.find('td.userBackend').text(user.backend);
|
2014-12-12 12:21:50 +03:00
|
|
|
|
2014-12-12 11:59:42 +03:00
|
|
|
/**
|
|
|
|
* last login
|
|
|
|
*/
|
2014-07-09 18:36:51 +04:00
|
|
|
var lastLoginRel = t('settings', 'never');
|
|
|
|
var lastLoginAbs = lastLoginRel;
|
2014-12-15 14:43:42 +03:00
|
|
|
if(user.lastLogin !== 0) {
|
|
|
|
lastLoginRel = OC.Util.relativeModifiedDate(user.lastLogin);
|
|
|
|
lastLoginAbs = OC.Util.formatDate(user.lastLogin);
|
2014-02-18 21:37:10 +04:00
|
|
|
}
|
2014-07-09 18:36:51 +04:00
|
|
|
var $tdLastLogin = $tr.find('td.lastLogin');
|
2014-06-19 16:30:22 +04:00
|
|
|
$tdLastLogin.text(lastLoginRel);
|
2015-08-07 15:00:44 +03:00
|
|
|
$tdLastLogin.attr('title', lastLoginAbs);
|
|
|
|
// setup tooltip with #app-content as container to prevent the td to resize on hover
|
|
|
|
$tdLastLogin.tooltip({placement: 'top', container: '#app-content'});
|
2014-12-12 11:59:42 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* append generated row to user list
|
|
|
|
*/
|
2014-05-06 06:41:54 +04:00
|
|
|
$tr.appendTo($userList);
|
2014-02-19 14:40:07 +04:00
|
|
|
if(UserList.isEmpty === true) {
|
|
|
|
//when the list was emptied, one row was left, necessary to keep
|
|
|
|
//add working and the layout unbroken. We need to remove this item
|
2014-05-06 06:41:54 +04:00
|
|
|
$tr.show();
|
|
|
|
$userListBody.find('tr:first').remove();
|
2014-02-19 14:40:07 +04:00
|
|
|
UserList.isEmpty = false;
|
2014-04-02 23:55:57 +04:00
|
|
|
UserList.checkUsersToLoad();
|
2014-02-19 14:40:07 +04:00
|
|
|
}
|
2014-12-12 11:59:42 +03:00
|
|
|
|
2014-08-11 18:37:48 +04:00
|
|
|
$quotaSelect.on('change', UserList.onQuotaSelect);
|
2014-02-03 21:00:39 +04:00
|
|
|
|
|
|
|
// defer init so the user first sees the list appear more quickly
|
|
|
|
window.setTimeout(function(){
|
2014-05-06 06:41:54 +04:00
|
|
|
$quotaSelect.singleSelect();
|
2014-02-03 21:00:39 +04:00
|
|
|
}, 0);
|
2013-03-19 05:48:08 +04:00
|
|
|
},
|
|
|
|
// From http://my.opera.com/GreyWyvern/blog/show.dml/1671288
|
|
|
|
alphanum: function(a, b) {
|
|
|
|
function chunkify(t) {
|
|
|
|
var tz = [], x = 0, y = -1, n = 0, i, j;
|
|
|
|
|
|
|
|
while (i = (j = t.charAt(x++)).charCodeAt(0)) {
|
2014-05-07 19:37:33 +04:00
|
|
|
var m = (i === 46 || (i >=48 && i <= 57));
|
|
|
|
if (m !== n) {
|
|
|
|
tz[++y] = "";
|
|
|
|
n = m;
|
|
|
|
}
|
|
|
|
tz[y] += j;
|
2013-03-19 05:48:08 +04:00
|
|
|
}
|
|
|
|
return tz;
|
2013-02-11 18:18:14 +04:00
|
|
|
}
|
2013-03-19 05:48:08 +04:00
|
|
|
|
|
|
|
var aa = chunkify(a.toLowerCase());
|
|
|
|
var bb = chunkify(b.toLowerCase());
|
|
|
|
|
2014-05-07 19:37:33 +04:00
|
|
|
for (var x = 0; aa[x] && bb[x]; x++) {
|
2013-03-19 05:48:08 +04:00
|
|
|
if (aa[x] !== bb[x]) {
|
2014-05-07 19:37:33 +04:00
|
|
|
var c = Number(aa[x]), d = Number(bb[x]);
|
|
|
|
if (c === aa[x] && d === bb[x]) {
|
|
|
|
return c - d;
|
|
|
|
} else {
|
|
|
|
return (aa[x] > bb[x]) ? 1 : -1;
|
|
|
|
}
|
2013-03-19 05:48:08 +04:00
|
|
|
}
|
2013-02-11 18:18:14 +04:00
|
|
|
}
|
2013-03-19 05:48:08 +04:00
|
|
|
return aa.length - bb.length;
|
2013-02-11 18:18:14 +04:00
|
|
|
},
|
2014-04-17 22:14:51 +04:00
|
|
|
preSortSearchString: function(a, b) {
|
2015-08-05 18:29:20 +03:00
|
|
|
var pattern = this.filter;
|
2014-04-17 22:14:51 +04:00
|
|
|
if(typeof pattern === 'undefined') {
|
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
pattern = pattern.toLowerCase();
|
|
|
|
var aMatches = false;
|
|
|
|
var bMatches = false;
|
|
|
|
if(typeof a === 'string' && a.toLowerCase().indexOf(pattern) === 0) {
|
|
|
|
aMatches = true;
|
|
|
|
}
|
|
|
|
if(typeof b === 'string' && b.toLowerCase().indexOf(pattern) === 0) {
|
|
|
|
bMatches = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if((aMatches && bMatches) || (!aMatches && !bMatches)) {
|
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(aMatches) {
|
|
|
|
return -1;
|
|
|
|
} else {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
},
|
2013-03-19 05:48:08 +04:00
|
|
|
doSort: function() {
|
2016-01-07 17:48:59 +03:00
|
|
|
// some browsers like Chrome lose the scrolling information
|
|
|
|
// when messing with the list elements
|
|
|
|
var lastScrollTop = this.scrollArea.scrollTop();
|
|
|
|
var lastScrollLeft = this.scrollArea.scrollLeft();
|
2014-05-06 06:41:54 +04:00
|
|
|
var rows = $userListBody.find('tr').get();
|
2013-03-19 05:48:08 +04:00
|
|
|
|
|
|
|
rows.sort(function(a, b) {
|
2014-02-18 15:29:05 +04:00
|
|
|
// FIXME: inefficient way of getting the names,
|
|
|
|
// better use a data attribute
|
2015-04-13 18:12:06 +03:00
|
|
|
a = $(a).find('.name').text();
|
|
|
|
b = $(b).find('.name').text();
|
2014-04-17 22:14:51 +04:00
|
|
|
var firstSort = UserList.preSortSearchString(a, b);
|
|
|
|
if(typeof firstSort !== 'undefined') {
|
|
|
|
return firstSort;
|
|
|
|
}
|
2014-02-18 15:29:05 +04:00
|
|
|
return OC.Util.naturalSortCompare(a, b);
|
2013-03-19 05:48:08 +04:00
|
|
|
});
|
2012-12-20 12:59:09 +04:00
|
|
|
|
2013-03-19 05:48:08 +04:00
|
|
|
var items = [];
|
|
|
|
$.each(rows, function(index, row) {
|
|
|
|
items.push(row);
|
|
|
|
if(items.length === 100) {
|
2014-05-06 06:41:54 +04:00
|
|
|
$userListBody.append(items);
|
2013-03-19 05:48:08 +04:00
|
|
|
items = [];
|
|
|
|
}
|
|
|
|
});
|
|
|
|
if(items.length > 0) {
|
2014-05-06 06:41:54 +04:00
|
|
|
$userListBody.append(items);
|
2013-03-19 05:48:08 +04:00
|
|
|
}
|
2016-01-07 17:48:59 +03:00
|
|
|
this.scrollArea.scrollTop(lastScrollTop);
|
|
|
|
this.scrollArea.scrollLeft(lastScrollLeft);
|
2013-03-19 05:48:08 +04:00
|
|
|
},
|
2014-04-02 23:55:57 +04:00
|
|
|
checkUsersToLoad: function() {
|
|
|
|
//30 shall be loaded initially, from then on always 10 upon scrolling
|
|
|
|
if(UserList.isEmpty === false) {
|
|
|
|
UserList.usersToLoad = 10;
|
|
|
|
} else {
|
2015-10-28 13:18:10 +03:00
|
|
|
UserList.usersToLoad = UserList.initialUsersToLoad;
|
2014-04-02 23:55:57 +04:00
|
|
|
}
|
|
|
|
},
|
2014-02-19 14:40:07 +04:00
|
|
|
empty: function() {
|
|
|
|
//one row needs to be kept, because it is cloned to add new rows
|
2014-05-06 06:41:54 +04:00
|
|
|
$userListBody.find('tr:not(:first)').remove();
|
|
|
|
var $tr = $userListBody.find('tr:first');
|
|
|
|
$tr.hide();
|
2014-04-02 00:44:08 +04:00
|
|
|
//on an update a user may be missing when the username matches with that
|
|
|
|
//of the hidden row. So change this to a random string.
|
2014-05-06 06:41:54 +04:00
|
|
|
$tr.data('uid', Math.random().toString(36).substring(2));
|
2014-02-19 14:40:07 +04:00
|
|
|
UserList.isEmpty = true;
|
|
|
|
UserList.offset = 0;
|
2014-04-02 23:55:57 +04:00
|
|
|
UserList.checkUsersToLoad();
|
2014-02-19 14:40:07 +04:00
|
|
|
},
|
2014-02-26 21:04:55 +04:00
|
|
|
hide: function(uid) {
|
2014-05-06 18:52:14 +04:00
|
|
|
UserList.getRow(uid).hide();
|
2014-02-26 21:04:55 +04:00
|
|
|
},
|
|
|
|
show: function(uid) {
|
2014-05-06 18:52:14 +04:00
|
|
|
UserList.getRow(uid).show();
|
2014-02-26 21:04:55 +04:00
|
|
|
},
|
2014-07-08 22:05:51 +04:00
|
|
|
markRemove: function(uid) {
|
2014-07-09 18:36:51 +04:00
|
|
|
var $tr = UserList.getRow(uid);
|
2016-08-23 18:22:10 +03:00
|
|
|
var groups = $tr.find('.groups').data('groups');
|
2014-07-09 18:36:51 +04:00
|
|
|
for(var i in groups) {
|
2014-07-05 04:14:08 +04:00
|
|
|
var gid = groups[i];
|
2014-07-09 18:36:51 +04:00
|
|
|
var $li = GroupList.getGroupLI(gid);
|
|
|
|
var userCount = GroupList.getUserCount($li);
|
2015-11-10 12:28:23 +03:00
|
|
|
GroupList.setUserCount($li, userCount - 1);
|
2014-07-05 04:14:08 +04:00
|
|
|
}
|
2014-07-08 22:05:51 +04:00
|
|
|
GroupList.decEveryoneCount();
|
|
|
|
UserList.hide(uid);
|
|
|
|
},
|
|
|
|
remove: function(uid) {
|
2014-05-06 18:52:14 +04:00
|
|
|
UserList.getRow(uid).remove();
|
2014-05-06 06:41:54 +04:00
|
|
|
},
|
2014-07-08 22:05:51 +04:00
|
|
|
undoRemove: function(uid) {
|
2014-07-09 18:36:51 +04:00
|
|
|
var $tr = UserList.getRow(uid);
|
2016-08-23 18:22:10 +03:00
|
|
|
var groups = $tr.find('.groups').data('groups');
|
2014-07-09 18:36:51 +04:00
|
|
|
for(var i in groups) {
|
2014-07-08 22:05:51 +04:00
|
|
|
var gid = groups[i];
|
2014-07-09 18:36:51 +04:00
|
|
|
var $li = GroupList.getGroupLI(gid);
|
|
|
|
var userCount = GroupList.getUserCount($li);
|
2015-11-10 12:28:23 +03:00
|
|
|
GroupList.setUserCount($li, userCount + 1);
|
2014-07-08 22:05:51 +04:00
|
|
|
}
|
|
|
|
GroupList.incEveryoneCount();
|
|
|
|
UserList.getRow(uid).show();
|
|
|
|
},
|
2014-05-06 06:41:54 +04:00
|
|
|
has: function(uid) {
|
2014-05-06 18:52:14 +04:00
|
|
|
return UserList.getRow(uid).length > 0;
|
|
|
|
},
|
|
|
|
getRow: function(uid) {
|
|
|
|
return $userListBody.find('tr').filter(function(){
|
|
|
|
return UserList.getUID(this) === uid;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
getUID: function(element) {
|
|
|
|
return ($(element).closest('tr').data('uid') || '').toString();
|
|
|
|
},
|
|
|
|
getDisplayName: function(element) {
|
|
|
|
return ($(element).closest('tr').data('displayname') || '').toString();
|
2014-02-26 21:04:55 +04:00
|
|
|
},
|
2014-12-15 14:43:42 +03:00
|
|
|
getMailAddress: function(element) {
|
|
|
|
return ($(element).closest('tr').data('mailAddress') || '').toString();
|
|
|
|
},
|
2015-01-23 19:45:45 +03:00
|
|
|
getRestoreDisabled: function(element) {
|
|
|
|
return ($(element).closest('tr').data('restoreDisabled') || '');
|
|
|
|
},
|
2014-02-26 21:04:55 +04:00
|
|
|
initDeleteHandling: function() {
|
|
|
|
//set up handler
|
2014-12-04 16:15:55 +03:00
|
|
|
UserDeleteHandler = new DeleteHandler('/settings/users/users', 'username',
|
2014-07-08 22:05:51 +04:00
|
|
|
UserList.markRemove, UserList.remove);
|
2014-02-26 21:04:55 +04:00
|
|
|
|
|
|
|
//configure undo
|
|
|
|
OC.Notification.hide();
|
2014-06-05 22:30:20 +04:00
|
|
|
var msg = escapeHTML(t('settings', 'deleted {userName}', {userName: '%oid'})) + '<span class="undo">' +
|
|
|
|
escapeHTML(t('settings', 'undo')) + '</span>';
|
2014-02-26 21:04:55 +04:00
|
|
|
UserDeleteHandler.setNotification(OC.Notification, 'deleteuser', msg,
|
2014-07-08 22:05:51 +04:00
|
|
|
UserList.undoRemove);
|
2014-02-26 21:04:55 +04:00
|
|
|
|
|
|
|
//when to mark user for delete
|
2014-05-06 06:41:54 +04:00
|
|
|
$userListBody.on('click', '.delete', function () {
|
2014-02-26 21:04:55 +04:00
|
|
|
// Call function for handling delete/undo
|
2014-05-06 18:52:14 +04:00
|
|
|
var uid = UserList.getUID(this);
|
2016-10-25 14:05:13 +03:00
|
|
|
|
|
|
|
if (OC.PasswordConfirmation.requiresPasswordConfirmation()) {
|
|
|
|
OC.PasswordConfirmation.requirePasswordConfirmation(function() {
|
|
|
|
UserDeleteHandler.mark(uid);
|
|
|
|
});
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-02-26 21:04:55 +04:00
|
|
|
UserDeleteHandler.mark(uid);
|
|
|
|
});
|
|
|
|
|
|
|
|
//delete a marked user when leaving the page
|
|
|
|
$(window).on('beforeunload', function () {
|
2014-07-17 15:13:03 +04:00
|
|
|
UserDeleteHandler.deleteEntry();
|
2014-02-26 21:04:55 +04:00
|
|
|
});
|
|
|
|
},
|
2014-12-12 19:58:01 +03:00
|
|
|
update: function (gid, limit) {
|
2013-03-19 05:48:08 +04:00
|
|
|
if (UserList.updating) {
|
|
|
|
return;
|
2013-02-11 18:18:14 +04:00
|
|
|
}
|
2014-12-12 19:58:01 +03:00
|
|
|
if(!limit) {
|
|
|
|
limit = UserList.usersToLoad;
|
|
|
|
}
|
2014-05-06 06:41:54 +04:00
|
|
|
$userList.siblings('.loading').css('visibility', 'visible');
|
2013-03-19 05:48:08 +04:00
|
|
|
UserList.updating = true;
|
2014-02-19 14:40:07 +04:00
|
|
|
if(gid === undefined) {
|
|
|
|
gid = '';
|
|
|
|
}
|
2014-02-20 21:42:03 +04:00
|
|
|
UserList.currentGid = gid;
|
2015-08-05 18:29:20 +03:00
|
|
|
var pattern = this.filter;
|
2014-05-06 06:41:54 +04:00
|
|
|
$.get(
|
2014-12-04 16:15:55 +03:00
|
|
|
OC.generateUrl('/settings/users/users'),
|
2014-12-12 19:58:01 +03:00
|
|
|
{ offset: UserList.offset, limit: limit, gid: gid, pattern: pattern },
|
2014-05-06 06:41:54 +04:00
|
|
|
function (result) {
|
Expose backend type via REST API
This change will expose the user backend via the REST API which is a pre-requisite for https://github.com/owncloud/core/issues/12620.
For example:
````json
[{"name":"9707A09E-CA9A-4ABE-A66A-3F632F16C409","displayname":"Document Conversion User Account","groups":[],"subadmin":[],"quota":"default","storageLocation":"\/Users\/lreschke\/Programming\/core\/data\/9707A09E-CA9A-4ABE-A66A-3F632F16C409","lastLogin":0,"backend":"OCA\\user_ldap\\USER_LDAP"},{"name":"ED86733E-745C-4E4D-90CB-278A9737DB3C","displayname":"Hacker","groups":[],"subadmin":[],"quota":"default","storageLocation":"\/Users\/lreschke\/Programming\/core\/data\/ED86733E-745C-4E4D-90CB-278A9737DB3C","lastLogin":0,"backend":"OCA\\user_ldap\\USER_LDAP"},{"name":"71CDF45B-E125-450D-983C-D9192F36EC88","displayname":"admin","groups":[],"subadmin":[],"quota":"default","storageLocation":"\/Users\/lreschke\/Programming\/core\/data\/71CDF45B-E125-450D-983C-D9192F36EC88","lastLogin":0,"backend":"OCA\\user_ldap\\USER_LDAP"},{"name":"admin","displayname":"admin","groups":["admin"],"subadmin":[],"quota":"default","storageLocation":"\/Users\/lreschke\/Programming\/core\/data\/admin","lastLogin":"1418057287","backend":"OC_User_Database"},{"name":"test","displayname":"test","groups":[],"subadmin":[],"quota":"default","storageLocation":"\/Users\/lreschke\/Programming\/core\/data\/test","lastLogin":0,"backend":"OC_User_Database"}]
```
2014-12-09 00:38:54 +03:00
|
|
|
//The offset does not mirror the amount of users available,
|
|
|
|
//because it is backend-dependent. For correct retrieval,
|
|
|
|
//always the limit(requested amount of users) needs to be added.
|
|
|
|
$.each(result, function (index, user) {
|
|
|
|
if(UserList.has(user.name)) {
|
|
|
|
return true;
|
2013-03-19 05:48:08 +04:00
|
|
|
}
|
2016-10-11 13:41:19 +03:00
|
|
|
UserList.add(user);
|
Expose backend type via REST API
This change will expose the user backend via the REST API which is a pre-requisite for https://github.com/owncloud/core/issues/12620.
For example:
````json
[{"name":"9707A09E-CA9A-4ABE-A66A-3F632F16C409","displayname":"Document Conversion User Account","groups":[],"subadmin":[],"quota":"default","storageLocation":"\/Users\/lreschke\/Programming\/core\/data\/9707A09E-CA9A-4ABE-A66A-3F632F16C409","lastLogin":0,"backend":"OCA\\user_ldap\\USER_LDAP"},{"name":"ED86733E-745C-4E4D-90CB-278A9737DB3C","displayname":"Hacker","groups":[],"subadmin":[],"quota":"default","storageLocation":"\/Users\/lreschke\/Programming\/core\/data\/ED86733E-745C-4E4D-90CB-278A9737DB3C","lastLogin":0,"backend":"OCA\\user_ldap\\USER_LDAP"},{"name":"71CDF45B-E125-450D-983C-D9192F36EC88","displayname":"admin","groups":[],"subadmin":[],"quota":"default","storageLocation":"\/Users\/lreschke\/Programming\/core\/data\/71CDF45B-E125-450D-983C-D9192F36EC88","lastLogin":0,"backend":"OCA\\user_ldap\\USER_LDAP"},{"name":"admin","displayname":"admin","groups":["admin"],"subadmin":[],"quota":"default","storageLocation":"\/Users\/lreschke\/Programming\/core\/data\/admin","lastLogin":"1418057287","backend":"OC_User_Database"},{"name":"test","displayname":"test","groups":[],"subadmin":[],"quota":"default","storageLocation":"\/Users\/lreschke\/Programming\/core\/data\/test","lastLogin":0,"backend":"OC_User_Database"}]
```
2014-12-09 00:38:54 +03:00
|
|
|
});
|
2017-03-01 23:09:03 +03:00
|
|
|
|
Expose backend type via REST API
This change will expose the user backend via the REST API which is a pre-requisite for https://github.com/owncloud/core/issues/12620.
For example:
````json
[{"name":"9707A09E-CA9A-4ABE-A66A-3F632F16C409","displayname":"Document Conversion User Account","groups":[],"subadmin":[],"quota":"default","storageLocation":"\/Users\/lreschke\/Programming\/core\/data\/9707A09E-CA9A-4ABE-A66A-3F632F16C409","lastLogin":0,"backend":"OCA\\user_ldap\\USER_LDAP"},{"name":"ED86733E-745C-4E4D-90CB-278A9737DB3C","displayname":"Hacker","groups":[],"subadmin":[],"quota":"default","storageLocation":"\/Users\/lreschke\/Programming\/core\/data\/ED86733E-745C-4E4D-90CB-278A9737DB3C","lastLogin":0,"backend":"OCA\\user_ldap\\USER_LDAP"},{"name":"71CDF45B-E125-450D-983C-D9192F36EC88","displayname":"admin","groups":[],"subadmin":[],"quota":"default","storageLocation":"\/Users\/lreschke\/Programming\/core\/data\/71CDF45B-E125-450D-983C-D9192F36EC88","lastLogin":0,"backend":"OCA\\user_ldap\\USER_LDAP"},{"name":"admin","displayname":"admin","groups":["admin"],"subadmin":[],"quota":"default","storageLocation":"\/Users\/lreschke\/Programming\/core\/data\/admin","lastLogin":"1418057287","backend":"OC_User_Database"},{"name":"test","displayname":"test","groups":[],"subadmin":[],"quota":"default","storageLocation":"\/Users\/lreschke\/Programming\/core\/data\/test","lastLogin":0,"backend":"OC_User_Database"}]
```
2014-12-09 00:38:54 +03:00
|
|
|
if (result.length > 0) {
|
|
|
|
UserList.doSort();
|
|
|
|
$userList.siblings('.loading').css('visibility', 'hidden');
|
2014-12-12 19:58:01 +03:00
|
|
|
// reset state on load
|
|
|
|
UserList.noMoreEntries = false;
|
2017-03-01 23:09:03 +03:00
|
|
|
$userListHead.show();
|
2017-03-03 16:44:16 +03:00
|
|
|
$emptyContainer.hide();
|
|
|
|
$emptyContainer.find('h2').text('');
|
Expose backend type via REST API
This change will expose the user backend via the REST API which is a pre-requisite for https://github.com/owncloud/core/issues/12620.
For example:
````json
[{"name":"9707A09E-CA9A-4ABE-A66A-3F632F16C409","displayname":"Document Conversion User Account","groups":[],"subadmin":[],"quota":"default","storageLocation":"\/Users\/lreschke\/Programming\/core\/data\/9707A09E-CA9A-4ABE-A66A-3F632F16C409","lastLogin":0,"backend":"OCA\\user_ldap\\USER_LDAP"},{"name":"ED86733E-745C-4E4D-90CB-278A9737DB3C","displayname":"Hacker","groups":[],"subadmin":[],"quota":"default","storageLocation":"\/Users\/lreschke\/Programming\/core\/data\/ED86733E-745C-4E4D-90CB-278A9737DB3C","lastLogin":0,"backend":"OCA\\user_ldap\\USER_LDAP"},{"name":"71CDF45B-E125-450D-983C-D9192F36EC88","displayname":"admin","groups":[],"subadmin":[],"quota":"default","storageLocation":"\/Users\/lreschke\/Programming\/core\/data\/71CDF45B-E125-450D-983C-D9192F36EC88","lastLogin":0,"backend":"OCA\\user_ldap\\USER_LDAP"},{"name":"admin","displayname":"admin","groups":["admin"],"subadmin":[],"quota":"default","storageLocation":"\/Users\/lreschke\/Programming\/core\/data\/admin","lastLogin":"1418057287","backend":"OC_User_Database"},{"name":"test","displayname":"test","groups":[],"subadmin":[],"quota":"default","storageLocation":"\/Users\/lreschke\/Programming\/core\/data\/test","lastLogin":0,"backend":"OC_User_Database"}]
```
2014-12-09 00:38:54 +03:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
UserList.noMoreEntries = true;
|
|
|
|
$userList.siblings('.loading').remove();
|
2017-03-03 16:44:16 +03:00
|
|
|
|
|
|
|
if (pattern !== ""){
|
|
|
|
$userListHead.hide();
|
|
|
|
$emptyContainer.show();
|
|
|
|
$emptyContainer.find('h2').html(t('settings', 'No user found for <strong>{pattern}</strong>', {pattern: pattern}));
|
|
|
|
}
|
2014-05-06 06:41:54 +04:00
|
|
|
}
|
2015-02-04 19:19:11 +03:00
|
|
|
UserList.offset += limit;
|
Expose backend type via REST API
This change will expose the user backend via the REST API which is a pre-requisite for https://github.com/owncloud/core/issues/12620.
For example:
````json
[{"name":"9707A09E-CA9A-4ABE-A66A-3F632F16C409","displayname":"Document Conversion User Account","groups":[],"subadmin":[],"quota":"default","storageLocation":"\/Users\/lreschke\/Programming\/core\/data\/9707A09E-CA9A-4ABE-A66A-3F632F16C409","lastLogin":0,"backend":"OCA\\user_ldap\\USER_LDAP"},{"name":"ED86733E-745C-4E4D-90CB-278A9737DB3C","displayname":"Hacker","groups":[],"subadmin":[],"quota":"default","storageLocation":"\/Users\/lreschke\/Programming\/core\/data\/ED86733E-745C-4E4D-90CB-278A9737DB3C","lastLogin":0,"backend":"OCA\\user_ldap\\USER_LDAP"},{"name":"71CDF45B-E125-450D-983C-D9192F36EC88","displayname":"admin","groups":[],"subadmin":[],"quota":"default","storageLocation":"\/Users\/lreschke\/Programming\/core\/data\/71CDF45B-E125-450D-983C-D9192F36EC88","lastLogin":0,"backend":"OCA\\user_ldap\\USER_LDAP"},{"name":"admin","displayname":"admin","groups":["admin"],"subadmin":[],"quota":"default","storageLocation":"\/Users\/lreschke\/Programming\/core\/data\/admin","lastLogin":"1418057287","backend":"OC_User_Database"},{"name":"test","displayname":"test","groups":[],"subadmin":[],"quota":"default","storageLocation":"\/Users\/lreschke\/Programming\/core\/data\/test","lastLogin":0,"backend":"OC_User_Database"}]
```
2014-12-09 00:38:54 +03:00
|
|
|
}).always(function() {
|
2014-05-06 06:41:54 +04:00
|
|
|
UserList.updating = false;
|
2014-07-09 18:36:51 +04:00
|
|
|
});
|
2013-02-11 18:18:14 +04:00
|
|
|
},
|
2012-12-20 12:59:09 +04:00
|
|
|
|
2016-08-23 18:22:10 +03:00
|
|
|
applyGroupSelect: function (element, user, checked) {
|
2016-10-25 14:05:13 +03:00
|
|
|
if (OC.PasswordConfirmation.requiresPasswordConfirmation()) {
|
2016-10-25 17:58:39 +03:00
|
|
|
OC.PasswordConfirmation.requirePasswordConfirmation(_.bind(this.applySubadminSelect, this, element, user, checked));
|
2016-10-25 14:05:13 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-05-06 06:41:54 +04:00
|
|
|
var $element = $(element);
|
|
|
|
|
2017-01-18 16:35:30 +03:00
|
|
|
var addUserToGroup = null,
|
|
|
|
removeUserFromGroup = null;
|
2014-05-06 18:52:14 +04:00
|
|
|
if(user) { // Only if in a user row, and not the #newusergroups select
|
2017-01-18 16:35:30 +03:00
|
|
|
var handleUserGroupMembership = function (group, add) {
|
|
|
|
if (user === OC.getCurrentUser().uid && group === 'admin') {
|
2014-05-06 18:52:14 +04:00
|
|
|
return false;
|
|
|
|
}
|
2016-08-19 11:46:42 +03:00
|
|
|
if (!OC.isUserAdmin() && checked.length === 1 && checked[0] === group) {
|
2014-05-06 18:52:14 +04:00
|
|
|
return false;
|
|
|
|
}
|
2017-01-18 16:35:30 +03:00
|
|
|
|
|
|
|
if (add && OC.isUserAdmin() && UserList.availableGroups.indexOf(group) === -1) {
|
|
|
|
GroupList.createGroup(group);
|
|
|
|
if (UserList.availableGroups.indexOf(group) === -1) {
|
|
|
|
UserList.availableGroups.push(group);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
url: OC.linkToOCS('cloud/users/' + user , 2) + 'groups',
|
|
|
|
data: {
|
|
|
|
groupid: group
|
|
|
|
},
|
|
|
|
type: add ? 'POST' : 'DELETE',
|
|
|
|
beforeSend: function (request) {
|
|
|
|
request.setRequestHeader('Accept', 'application/json');
|
2014-05-06 18:52:14 +04:00
|
|
|
},
|
2017-01-18 16:35:30 +03:00
|
|
|
success: function() {
|
|
|
|
GroupList.update();
|
|
|
|
if (add && UserList.availableGroups.indexOf(group) === -1) {
|
|
|
|
UserList.availableGroups.push(group);
|
2014-05-06 18:52:14 +04:00
|
|
|
}
|
2017-01-18 16:35:30 +03:00
|
|
|
|
|
|
|
if (add) {
|
|
|
|
GroupList.incGroupCount(group);
|
|
|
|
} else {
|
|
|
|
GroupList.decGroupCount(group);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
error: function() {
|
|
|
|
if (add) {
|
|
|
|
OC.Notification.show(t('settings', 'Unable to add user to group {group}', {
|
|
|
|
group: group
|
|
|
|
}));
|
|
|
|
} else {
|
|
|
|
OC.Notification.show(t('settings', 'Unable to remove user from group {group}', {
|
|
|
|
group: group
|
|
|
|
}));
|
2014-05-06 06:41:54 +04:00
|
|
|
}
|
2013-02-11 18:18:14 +04:00
|
|
|
}
|
2017-01-18 16:35:30 +03:00
|
|
|
});
|
|
|
|
};
|
|
|
|
addUserToGroup = function (group) {
|
|
|
|
return handleUserGroupMembership(group, true);
|
|
|
|
};
|
|
|
|
removeUserFromGroup = function (group) {
|
|
|
|
return handleUserGroupMembership(group, false);
|
2014-07-09 16:30:28 +04:00
|
|
|
};
|
|
|
|
}
|
2014-05-06 06:41:54 +04:00
|
|
|
var addGroup = function (select, group) {
|
|
|
|
GroupList.addGroup(escapeHTML(group));
|
|
|
|
};
|
|
|
|
var label;
|
2016-08-19 11:46:42 +03:00
|
|
|
if (OC.isUserAdmin()) {
|
2016-07-28 12:30:36 +03:00
|
|
|
label = t('settings', 'Add group');
|
2014-05-06 06:41:54 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
label = null;
|
|
|
|
}
|
|
|
|
$element.multiSelect({
|
|
|
|
createCallback: addGroup,
|
|
|
|
createText: label,
|
|
|
|
selectedFirst: true,
|
|
|
|
checked: checked,
|
2017-01-18 16:35:30 +03:00
|
|
|
oncheck: addUserToGroup,
|
|
|
|
onuncheck: removeUserFromGroup,
|
2014-05-06 06:41:54 +04:00
|
|
|
minWidth: 100
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2016-08-23 18:22:10 +03:00
|
|
|
applySubadminSelect: function (element, user, checked) {
|
2016-10-25 14:05:13 +03:00
|
|
|
if (OC.PasswordConfirmation.requiresPasswordConfirmation()) {
|
2016-10-25 17:58:39 +03:00
|
|
|
OC.PasswordConfirmation.requirePasswordConfirmation(_.bind(this.applySubadminSelect, this, element, user, checked));
|
2016-10-25 14:05:13 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-05-06 06:41:54 +04:00
|
|
|
var $element = $(element);
|
|
|
|
var checkHandler = function (group) {
|
|
|
|
if (group === 'admin') {
|
|
|
|
return false;
|
2013-02-11 18:18:14 +04:00
|
|
|
}
|
2014-05-06 06:41:54 +04:00
|
|
|
$.post(
|
|
|
|
OC.filePath('settings', 'ajax', 'togglesubadmins.php'),
|
|
|
|
{
|
|
|
|
username: user,
|
|
|
|
group: group
|
|
|
|
},
|
2016-10-25 14:05:13 +03:00
|
|
|
function (response) {
|
2016-11-22 20:23:48 +03:00
|
|
|
if (response.data !== undefined && response.data.message) {
|
2016-10-25 14:05:13 +03:00
|
|
|
OC.Notification.show(response.data.message);
|
|
|
|
}
|
2013-02-11 18:18:14 +04:00
|
|
|
}
|
2014-05-06 06:41:54 +04:00
|
|
|
);
|
|
|
|
};
|
2012-12-20 12:59:09 +04:00
|
|
|
|
2014-05-06 06:41:54 +04:00
|
|
|
$element.multiSelect({
|
|
|
|
createText: null,
|
|
|
|
checked: checked,
|
|
|
|
oncheck: checkHandler,
|
|
|
|
onuncheck: checkHandler,
|
|
|
|
minWidth: 100
|
|
|
|
});
|
2014-02-03 21:00:39 +04:00
|
|
|
},
|
|
|
|
|
2014-05-06 18:52:14 +04:00
|
|
|
_onScroll: function() {
|
2014-02-03 21:00:39 +04:00
|
|
|
if (!!UserList.noMoreEntries) {
|
|
|
|
return;
|
|
|
|
}
|
2014-02-20 21:42:03 +04:00
|
|
|
if (UserList.scrollArea.scrollTop() + UserList.scrollArea.height() > UserList.scrollArea.get(0).scrollHeight - 500) {
|
2014-12-12 19:58:01 +03:00
|
|
|
UserList.update(UserList.currentGid);
|
2014-02-03 21:00:39 +04:00
|
|
|
}
|
2014-08-11 18:37:48 +04:00
|
|
|
},
|
2012-08-12 00:01:43 +04:00
|
|
|
|
2014-08-11 18:37:48 +04:00
|
|
|
/**
|
|
|
|
* Event handler for when a quota has been changed through a single select.
|
|
|
|
* This will save the value.
|
|
|
|
*/
|
|
|
|
onQuotaSelect: function(ev) {
|
|
|
|
var $select = $(ev.target);
|
|
|
|
var uid = UserList.getUID($select);
|
|
|
|
var quota = $select.val();
|
2016-06-23 19:42:11 +03:00
|
|
|
if (quota === 'other') {
|
|
|
|
return;
|
|
|
|
}
|
2017-02-27 09:49:15 +03:00
|
|
|
if ((quota !== 'default' && quota !=="none") && (!OC.Util.computerFileSize(quota))) {
|
2016-06-24 10:20:13 +03:00
|
|
|
// the select component has added the bogus value, delete it again
|
|
|
|
$select.find('option[selected]').remove();
|
|
|
|
OC.Notification.showTemporary(t('core', 'Invalid quota value "{val}"', {val: quota}));
|
|
|
|
return;
|
|
|
|
}
|
2016-11-10 19:18:12 +03:00
|
|
|
UserList._updateQuota(uid, quota, function(returnedQuota) {
|
2014-08-11 18:37:48 +04:00
|
|
|
if (quota !== returnedQuota) {
|
|
|
|
$select.find(':selected').text(returnedQuota);
|
2014-02-19 11:44:18 +04:00
|
|
|
}
|
2014-08-11 18:37:48 +04:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Saves the quota for the given user
|
|
|
|
* @param {String} [uid] optional user id, sets default quota if empty
|
|
|
|
* @param {String} quota quota value
|
|
|
|
* @param {Function} ready callback after save
|
|
|
|
*/
|
|
|
|
_updateQuota: function(uid, quota, ready) {
|
2016-11-10 19:18:12 +03:00
|
|
|
if (OC.PasswordConfirmation.requiresPasswordConfirmation()) {
|
|
|
|
OC.PasswordConfirmation.requirePasswordConfirmation(_.bind(this._updateQuota, this, uid, quota, ready));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-08-11 18:37:48 +04:00
|
|
|
$.post(
|
|
|
|
OC.filePath('settings', 'ajax', 'setquota.php'),
|
|
|
|
{username: uid, quota: quota},
|
|
|
|
function (result) {
|
2016-11-10 19:18:12 +03:00
|
|
|
if (result.status === 'error') {
|
|
|
|
OC.Notification.showTemporary(result.data.message);
|
|
|
|
} else {
|
|
|
|
if (ready) {
|
|
|
|
ready(result.data.quota);
|
|
|
|
}
|
2014-08-11 18:37:48 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
2016-08-23 18:22:10 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a temporary jquery.multiselect selector on the given group field
|
|
|
|
*/
|
|
|
|
_triggerGroupEdit: function($td, isSubadminSelect) {
|
|
|
|
var $groupsListContainer = $td.find('.groupsListContainer');
|
|
|
|
var placeholder = $groupsListContainer.attr('data-placeholder') || t('settings', 'no group');
|
|
|
|
var user = UserList.getUID($td);
|
|
|
|
var checked = $td.data('groups') || [];
|
2016-08-24 11:03:07 +03:00
|
|
|
var extraGroups = [].concat(checked);
|
2016-08-23 18:22:10 +03:00
|
|
|
|
|
|
|
$td.find('.multiselectoptions').remove();
|
|
|
|
|
|
|
|
// jquery.multiselect can only work with select+options in DOM ? We'll give jquery.multiselect what it wants...
|
|
|
|
var $groupsSelect;
|
|
|
|
if (isSubadminSelect) {
|
|
|
|
$groupsSelect = $('<select multiple="multiple" class="groupsselect multiselect button" title="' + placeholder + '"></select>');
|
|
|
|
} else {
|
|
|
|
$groupsSelect = $('<select multiple="multiple" class="subadminsselect multiselect button" title="' + placeholder + '"></select>')
|
|
|
|
}
|
|
|
|
|
2016-08-24 11:03:07 +03:00
|
|
|
function createItem(group) {
|
2016-08-23 18:22:10 +03:00
|
|
|
if (isSubadminSelect && group === 'admin') {
|
|
|
|
// can't become subadmin of "admin" group
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
$groupsSelect.append($('<option value="' + escapeHTML(group) + '">' + escapeHTML(group) + '</option>'));
|
2016-08-24 11:03:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
$.each(this.availableGroups, function (i, group) {
|
|
|
|
// some new groups might be selected but not in the available groups list yet
|
|
|
|
var extraIndex = extraGroups.indexOf(group);
|
|
|
|
if (extraIndex >= 0) {
|
|
|
|
// remove extra group as it was found
|
|
|
|
extraGroups.splice(extraIndex, 1);
|
|
|
|
}
|
|
|
|
createItem(group);
|
|
|
|
});
|
|
|
|
$.each(extraGroups, function (i, group) {
|
|
|
|
createItem(group);
|
2016-08-23 18:22:10 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
$td.append($groupsSelect);
|
|
|
|
|
|
|
|
if (isSubadminSelect) {
|
|
|
|
UserList.applySubadminSelect($groupsSelect, user, checked);
|
|
|
|
} else {
|
|
|
|
UserList.applyGroupSelect($groupsSelect, user, checked);
|
|
|
|
}
|
|
|
|
|
|
|
|
$groupsListContainer.addClass('hidden');
|
|
|
|
$td.find('.multiselect:not(.groupsListContainer):first').click();
|
|
|
|
$groupsSelect.on('dropdownclosed', function(e) {
|
|
|
|
$groupsSelect.remove();
|
|
|
|
$td.find('.multiselect:not(.groupsListContainer)').parent().remove();
|
|
|
|
$td.find('.multiselectoptions').remove();
|
|
|
|
$groupsListContainer.removeClass('hidden');
|
|
|
|
UserList._updateGroupListLabel($td, e.checked);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Updates the groups list td with the given groups selection
|
|
|
|
*/
|
|
|
|
_updateGroupListLabel: function($td, groups) {
|
|
|
|
var placeholder = $td.find('.groupsListContainer').attr('data-placeholder');
|
|
|
|
var $groupsEl = $td.find('.groupsList');
|
|
|
|
$groupsEl.text(groups.join(', ') || placeholder || t('settings', 'no group'));
|
|
|
|
$td.data('groups', groups);
|
2014-08-11 18:37:48 +04:00
|
|
|
}
|
|
|
|
};
|
2014-02-19 11:44:18 +04:00
|
|
|
|
2012-12-20 12:59:09 +04:00
|
|
|
$(document).ready(function () {
|
2014-05-06 06:41:54 +04:00
|
|
|
$userList = $('#userlist');
|
|
|
|
$userListBody = $userList.find('tbody');
|
2017-03-01 23:09:03 +03:00
|
|
|
$userListHead = $userList.find('thead');
|
2017-03-03 16:44:16 +03:00
|
|
|
$emptyContainer = $userList.siblings('.emptycontent');
|
2014-05-06 06:41:54 +04:00
|
|
|
|
2014-02-26 21:04:55 +04:00
|
|
|
UserList.initDeleteHandling();
|
2012-12-20 12:59:09 +04:00
|
|
|
|
2014-04-17 22:14:51 +04:00
|
|
|
// Implements User Search
|
2015-08-05 18:29:20 +03:00
|
|
|
OCA.Search.users= new UserManagementFilter(UserList, GroupList);
|
2014-04-17 22:14:51 +04:00
|
|
|
|
2016-01-07 17:48:59 +03:00
|
|
|
UserList.scrollArea = $('#app-content');
|
|
|
|
|
2013-03-19 05:48:08 +04:00
|
|
|
UserList.doSort();
|
2014-05-06 06:41:54 +04:00
|
|
|
UserList.availableGroups = $userList.data('groups');
|
2014-04-01 17:59:53 +04:00
|
|
|
|
|
|
|
UserList.scrollArea.scroll(function(e) {UserList._onScroll(e);});
|
|
|
|
|
2014-05-06 06:41:54 +04:00
|
|
|
$userList.after($('<div class="loading" style="height: 200px; visibility: hidden;"></div>'));
|
2012-12-20 12:59:09 +04:00
|
|
|
|
2014-08-11 18:37:48 +04:00
|
|
|
// TODO: move other init calls inside of initialize
|
|
|
|
UserList.initialize($('#userlist'));
|
|
|
|
|
2016-11-18 16:19:07 +03:00
|
|
|
var _submitPasswordChange = function(uid, password, recoveryPasswordVal, blurFunction) {
|
2016-10-25 14:05:13 +03:00
|
|
|
if (OC.PasswordConfirmation.requiresPasswordConfirmation()) {
|
|
|
|
OC.PasswordConfirmation.requirePasswordConfirmation(function() {
|
2016-11-18 16:19:07 +03:00
|
|
|
_submitPasswordChange(uid, password, recoveryPasswordVal, blurFunction);
|
2016-10-25 14:05:13 +03:00
|
|
|
});
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$.post(
|
|
|
|
OC.generateUrl('/settings/users/changepassword'),
|
|
|
|
{username: uid, password: password, recoveryPassword: recoveryPasswordVal},
|
|
|
|
function (result) {
|
2016-11-18 16:19:07 +03:00
|
|
|
blurFunction();
|
2016-10-25 14:05:13 +03:00
|
|
|
if (result.status === 'success') {
|
|
|
|
OC.Notification.showTemporary(t('admin', 'Password successfully changed'));
|
|
|
|
} else {
|
|
|
|
OC.Notification.showTemporary(t('admin', result.data.message));
|
|
|
|
}
|
|
|
|
}
|
2016-11-18 16:19:07 +03:00
|
|
|
).fail(blurFunction);
|
2016-10-25 14:05:13 +03:00
|
|
|
};
|
|
|
|
|
2014-05-06 06:41:54 +04:00
|
|
|
$userListBody.on('click', '.password', function (event) {
|
2013-02-11 18:18:14 +04:00
|
|
|
event.stopPropagation();
|
2014-05-06 06:41:54 +04:00
|
|
|
|
|
|
|
var $td = $(this).closest('td');
|
2015-01-23 19:45:45 +03:00
|
|
|
var $tr = $(this).closest('tr');
|
2014-05-06 18:52:14 +04:00
|
|
|
var uid = UserList.getUID($td);
|
2014-05-06 06:41:54 +04:00
|
|
|
var $input = $('<input type="password">');
|
2015-01-23 19:45:45 +03:00
|
|
|
var isRestoreDisabled = UserList.getRestoreDisabled($td) === true;
|
2016-11-18 16:19:07 +03:00
|
|
|
var blurFunction = function () {
|
|
|
|
$(this).replaceWith($('<span>●●●●●●●</span>'));
|
|
|
|
$td.find('img').show();
|
|
|
|
// remove highlight class from users without recovery ability
|
|
|
|
$tr.removeClass('row-warning');
|
|
|
|
};
|
2016-11-30 15:36:37 +03:00
|
|
|
blurFunction = _.bind(blurFunction, $input);
|
2015-01-23 19:45:45 +03:00
|
|
|
if(isRestoreDisabled) {
|
|
|
|
$tr.addClass('row-warning');
|
2017-01-13 16:01:15 +03:00
|
|
|
// add tooltip if the password change could cause data loss - no recovery enabled
|
2015-01-23 19:45:45 +03:00
|
|
|
$input.attr('title', t('settings', 'Changing the password will result in data loss, because data recovery is not available for this user'));
|
2017-01-13 16:01:15 +03:00
|
|
|
$input.tooltip({placement:'bottom'});
|
2015-01-23 19:45:45 +03:00
|
|
|
}
|
2014-05-06 06:41:54 +04:00
|
|
|
$td.find('img').hide();
|
|
|
|
$td.children('span').replaceWith($input);
|
|
|
|
$input
|
|
|
|
.focus()
|
|
|
|
.keypress(function (event) {
|
|
|
|
if (event.keyCode === 13) {
|
|
|
|
if ($(this).val().length > 0) {
|
|
|
|
var recoveryPasswordVal = $('input:password[id="recoveryPassword"]').val();
|
2016-11-18 16:19:07 +03:00
|
|
|
$input.off('blur');
|
|
|
|
_submitPasswordChange(uid, $(this).val(), recoveryPasswordVal, blurFunction);
|
2014-05-06 06:41:54 +04:00
|
|
|
} else {
|
|
|
|
$input.blur();
|
|
|
|
}
|
2013-02-11 18:18:14 +04:00
|
|
|
}
|
2014-05-06 06:41:54 +04:00
|
|
|
})
|
2016-11-18 16:19:07 +03:00
|
|
|
.blur(blurFunction);
|
2013-02-11 18:18:14 +04:00
|
|
|
});
|
2014-05-06 06:41:54 +04:00
|
|
|
$('input:password[id="recoveryPassword"]').keyup(function() {
|
2013-05-16 18:01:40 +04:00
|
|
|
OC.Notification.hide();
|
|
|
|
});
|
|
|
|
|
2016-11-18 16:19:07 +03:00
|
|
|
var _submitDisplayNameChange = function($tr, uid, displayName, blurFunction) {
|
2016-11-03 12:13:00 +03:00
|
|
|
var $div = $tr.find('div.avatardiv');
|
|
|
|
if ($div.length) {
|
|
|
|
$div.imageplaceholder(uid, displayName);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (OC.PasswordConfirmation.requiresPasswordConfirmation()) {
|
|
|
|
OC.PasswordConfirmation.requirePasswordConfirmation(function() {
|
2016-11-18 16:19:07 +03:00
|
|
|
_submitDisplayNameChange($tr, uid, displayName, blurFunction);
|
2016-11-03 12:13:00 +03:00
|
|
|
});
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
type: 'POST',
|
|
|
|
url: OC.generateUrl('/settings/users/{id}/displayName', {id: uid}),
|
|
|
|
data: {
|
|
|
|
username: uid,
|
|
|
|
displayName: displayName
|
|
|
|
}
|
2016-11-18 16:19:07 +03:00
|
|
|
}).success(function (result) {
|
2016-11-03 12:13:00 +03:00
|
|
|
if (result && result.status==='success' && $div.length){
|
|
|
|
$div.avatar(result.data.username, 32);
|
|
|
|
}
|
|
|
|
$tr.data('displayname', displayName);
|
2016-11-18 16:19:07 +03:00
|
|
|
blurFunction();
|
2016-11-03 12:13:00 +03:00
|
|
|
}).fail(function (result) {
|
|
|
|
OC.Notification.showTemporary(result.responseJSON.message);
|
2016-11-18 16:19:07 +03:00
|
|
|
$tr.find('.displayName input').blur(blurFunction);
|
2016-11-03 12:13:00 +03:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2014-05-06 06:41:54 +04:00
|
|
|
$userListBody.on('click', '.displayName', function (event) {
|
2013-02-11 18:18:14 +04:00
|
|
|
event.stopPropagation();
|
2014-05-06 06:41:54 +04:00
|
|
|
var $td = $(this).closest('td');
|
|
|
|
var $tr = $td.closest('tr');
|
2014-05-06 18:52:14 +04:00
|
|
|
var uid = UserList.getUID($td);
|
|
|
|
var displayName = escapeHTML(UserList.getDisplayName($td));
|
2014-05-06 06:41:54 +04:00
|
|
|
var $input = $('<input type="text" value="' + displayName + '">');
|
2016-11-18 16:19:07 +03:00
|
|
|
var blurFunction = function() {
|
|
|
|
var displayName = $tr.data('displayname');
|
|
|
|
$input.replaceWith('<span>' + escapeHTML(displayName) + '</span>');
|
|
|
|
$td.find('img').show();
|
|
|
|
};
|
2014-05-06 06:41:54 +04:00
|
|
|
$td.find('img').hide();
|
|
|
|
$td.children('span').replaceWith($input);
|
|
|
|
$input
|
|
|
|
.focus()
|
|
|
|
.keypress(function (event) {
|
|
|
|
if (event.keyCode === 13) {
|
|
|
|
if ($(this).val().length > 0) {
|
2016-11-18 16:19:07 +03:00
|
|
|
$input.off('blur');
|
|
|
|
_submitDisplayNameChange($tr, uid, $(this).val(), blurFunction);
|
2014-05-06 06:41:54 +04:00
|
|
|
} else {
|
|
|
|
$input.blur();
|
|
|
|
}
|
2013-02-11 18:18:14 +04:00
|
|
|
}
|
2014-05-06 06:41:54 +04:00
|
|
|
})
|
2016-11-18 16:19:07 +03:00
|
|
|
.blur(blurFunction);
|
2013-02-11 18:18:14 +04:00
|
|
|
});
|
2012-08-12 00:01:43 +04:00
|
|
|
|
2016-11-18 16:19:07 +03:00
|
|
|
var _submitEmailChange = function($tr, $td, $input, uid, mailAddress, blurFunction) {
|
2016-11-11 11:43:43 +03:00
|
|
|
if (OC.PasswordConfirmation.requiresPasswordConfirmation()) {
|
|
|
|
OC.PasswordConfirmation.requirePasswordConfirmation(function() {
|
2016-11-18 16:19:07 +03:00
|
|
|
_submitEmailChange($tr, $td, $input, uid, mailAddress, blurFunction);
|
2016-11-11 11:43:43 +03:00
|
|
|
});
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
type: 'PUT',
|
|
|
|
url: OC.generateUrl('/settings/users/{id}/mailAddress', {id: uid}),
|
|
|
|
data: {
|
|
|
|
mailAddress: mailAddress
|
|
|
|
}
|
|
|
|
}).success(function () {
|
|
|
|
// set data attribute to new value
|
|
|
|
// will in blur() be used to show the text instead of the input field
|
|
|
|
$tr.data('mailAddress', mailAddress);
|
|
|
|
$td.find('.loading-small').css('display', '');
|
|
|
|
$input.removeAttr('disabled')
|
|
|
|
.triggerHandler('blur'); // needed instead of $input.blur() for Firefox
|
2016-11-18 16:19:07 +03:00
|
|
|
blurFunction();
|
2016-11-11 11:43:43 +03:00
|
|
|
}).fail(function (result) {
|
|
|
|
if (!_.isUndefined(result.responseJSON.data)) {
|
|
|
|
OC.Notification.showTemporary(result.responseJSON.data.message);
|
|
|
|
} else if (!_.isUndefined(result.responseJSON.message)) {
|
|
|
|
OC.Notification.showTemporary(result.responseJSON.message);
|
|
|
|
} else {
|
|
|
|
OC.Notification.showTemporary(t('settings', 'Could not change the users email'));
|
|
|
|
}
|
|
|
|
$td.find('.loading-small').css('display', '');
|
|
|
|
$input.removeAttr('disabled')
|
|
|
|
.css('padding-right', '6px');
|
2016-11-18 16:19:07 +03:00
|
|
|
$input.blur(blurFunction);
|
2016-11-11 11:43:43 +03:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2014-12-15 14:43:42 +03:00
|
|
|
$userListBody.on('click', '.mailAddress', function (event) {
|
|
|
|
event.stopPropagation();
|
|
|
|
var $td = $(this).closest('td');
|
|
|
|
var $tr = $td.closest('tr');
|
|
|
|
var uid = UserList.getUID($td);
|
|
|
|
var mailAddress = escapeHTML(UserList.getMailAddress($td));
|
|
|
|
var $input = $('<input type="text">').val(mailAddress);
|
2016-11-18 16:19:07 +03:00
|
|
|
var blurFunction = function() {
|
|
|
|
if($td.find('.loading-small').css('display') === 'inline-block') {
|
|
|
|
// in Chrome the blur event is fired too early by the browser - even if the request is still running
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
var $span = $('<span>').text($tr.data('mailAddress'));
|
|
|
|
$input.replaceWith($span);
|
|
|
|
$td.find('img').show();
|
|
|
|
};
|
2014-12-15 14:43:42 +03:00
|
|
|
$td.children('span').replaceWith($input);
|
2015-04-20 15:27:58 +03:00
|
|
|
$td.find('img').hide();
|
2014-12-15 14:43:42 +03:00
|
|
|
$input
|
|
|
|
.focus()
|
|
|
|
.keypress(function (event) {
|
|
|
|
if (event.keyCode === 13) {
|
2015-04-20 15:27:58 +03:00
|
|
|
// enter key
|
|
|
|
|
|
|
|
$td.find('.loading-small').css('display', 'inline-block');
|
|
|
|
$input.css('padding-right', '26px');
|
|
|
|
$input.attr('disabled', 'disabled');
|
2016-11-18 16:19:07 +03:00
|
|
|
$input.off('blur');
|
|
|
|
_submitEmailChange($tr, $td, $input, uid, $(this).val(), blurFunction);
|
2014-12-15 14:43:42 +03:00
|
|
|
}
|
|
|
|
})
|
2016-11-18 16:19:07 +03:00
|
|
|
.blur(blurFunction);
|
2014-12-15 14:43:42 +03:00
|
|
|
});
|
|
|
|
|
2016-08-23 18:22:10 +03:00
|
|
|
$('#newuser .groupsListContainer').on('click', function (event) {
|
|
|
|
event.stopPropagation();
|
|
|
|
var $div = $(this).closest('.groups');
|
|
|
|
UserList._triggerGroupEdit($div);
|
|
|
|
});
|
|
|
|
$userListBody.on('click', '.groups .groupsListContainer, .subadmins .groupsListContainer', function (event) {
|
|
|
|
event.stopPropagation();
|
|
|
|
var $td = $(this).closest('td');
|
|
|
|
var isSubadminSelect = $td.hasClass('subadmins');
|
|
|
|
UserList._triggerGroupEdit($td, isSubadminSelect);
|
|
|
|
});
|
|
|
|
|
2014-08-11 18:37:48 +04:00
|
|
|
// init the quota field select box after it is shown the first time
|
|
|
|
$('#app-settings').one('show', function() {
|
|
|
|
$(this).find('#default_quota').singleSelect().on('change', UserList.onQuotaSelect);
|
2013-02-11 18:18:14 +04:00
|
|
|
});
|
2012-08-12 00:01:43 +04:00
|
|
|
|
2017-03-03 16:44:16 +03:00
|
|
|
$('#newuser input').click(function() {
|
|
|
|
// empty the container also here to avoid visual delay
|
|
|
|
$emptyContainer.hide();
|
|
|
|
OC.Search = new OCA.Search($('#searchbox'), $('#searchresults'));
|
|
|
|
OC.Search.clear();
|
|
|
|
});
|
|
|
|
|
2016-08-23 18:22:10 +03:00
|
|
|
UserList._updateGroupListLabel($('#newuser .groups'), []);
|
2016-10-25 14:05:13 +03:00
|
|
|
var _submitNewUserForm = function (event) {
|
2016-11-18 16:19:07 +03:00
|
|
|
event.preventDefault();
|
2016-10-25 14:05:13 +03:00
|
|
|
if (OC.PasswordConfirmation.requiresPasswordConfirmation()) {
|
|
|
|
OC.PasswordConfirmation.requirePasswordConfirmation(function() {
|
|
|
|
_submitNewUserForm(event);
|
|
|
|
});
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-02-11 18:18:14 +04:00
|
|
|
var username = $('#newusername').val();
|
|
|
|
var password = $('#newuserpassword').val();
|
2014-12-16 11:08:38 +03:00
|
|
|
var email = $('#newemail').val();
|
2013-04-17 17:32:03 +04:00
|
|
|
if ($.trim(username) === '') {
|
2016-02-22 11:17:59 +03:00
|
|
|
OC.Notification.showTemporary(t('settings', 'Error creating user: {message}', {
|
|
|
|
message: t('settings', 'A valid username must be provided')
|
|
|
|
}));
|
2013-02-11 18:18:14 +04:00
|
|
|
return false;
|
|
|
|
}
|
2017-02-15 21:17:55 +03:00
|
|
|
if ($.trim(password) === '' && !$('#CheckboxMailOnUserCreate').is(':checked')) {
|
2016-02-22 11:17:59 +03:00
|
|
|
OC.Notification.showTemporary(t('settings', 'Error creating user: {message}', {
|
|
|
|
message: t('settings', 'A valid password must be provided')
|
|
|
|
}));
|
2013-02-11 18:18:14 +04:00
|
|
|
return false;
|
|
|
|
}
|
2014-12-16 11:08:38 +03:00
|
|
|
if(!$('#CheckboxMailOnUserCreate').is(':checked')) {
|
|
|
|
email = '';
|
|
|
|
}
|
|
|
|
if ($('#CheckboxMailOnUserCreate').is(':checked') && $.trim(email) === '') {
|
2016-02-22 11:17:59 +03:00
|
|
|
OC.Notification.showTemporary( t('settings', 'Error creating user: {message}', {
|
|
|
|
message: t('settings', 'A valid email must be provided')
|
|
|
|
}));
|
2014-12-16 11:08:38 +03:00
|
|
|
return false;
|
|
|
|
}
|
2015-10-07 17:17:38 +03:00
|
|
|
|
|
|
|
var promise;
|
|
|
|
if (UserDeleteHandler) {
|
|
|
|
promise = UserDeleteHandler.deleteEntry();
|
|
|
|
} else {
|
|
|
|
promise = $.Deferred().resolve().promise();
|
|
|
|
}
|
|
|
|
|
|
|
|
promise.then(function() {
|
2016-08-23 18:22:10 +03:00
|
|
|
var groups = $('#newuser .groups').data('groups') || [];
|
2015-10-07 17:17:38 +03:00
|
|
|
$.post(
|
|
|
|
OC.generateUrl('/settings/users/users'),
|
|
|
|
{
|
|
|
|
username: username,
|
|
|
|
password: password,
|
|
|
|
groups: groups,
|
|
|
|
email: email
|
|
|
|
},
|
|
|
|
function (result) {
|
|
|
|
if (result.groups) {
|
|
|
|
for (var i in result.groups) {
|
|
|
|
var gid = result.groups[i];
|
|
|
|
if(UserList.availableGroups.indexOf(gid) === -1) {
|
|
|
|
UserList.availableGroups.push(gid);
|
|
|
|
}
|
2016-08-19 11:46:42 +03:00
|
|
|
var $li = GroupList.getGroupLI(gid);
|
|
|
|
var userCount = GroupList.getUserCount($li);
|
2015-10-07 17:17:38 +03:00
|
|
|
GroupList.setUserCount($li, userCount + 1);
|
2014-07-05 03:21:18 +04:00
|
|
|
}
|
2013-07-03 23:06:09 +04:00
|
|
|
}
|
2015-10-07 17:17:38 +03:00
|
|
|
if(!UserList.has(username)) {
|
2016-10-11 13:41:19 +03:00
|
|
|
UserList.add(result);
|
|
|
|
UserList.doSort();
|
2015-10-07 17:17:38 +03:00
|
|
|
}
|
|
|
|
$('#newusername').focus();
|
|
|
|
GroupList.incEveryoneCount();
|
2016-02-22 11:17:59 +03:00
|
|
|
}).fail(function(result) {
|
|
|
|
OC.Notification.showTemporary(t('settings', 'Error creating user: {message}', {
|
|
|
|
message: result.responseJSON.message
|
2016-05-11 20:41:13 +03:00
|
|
|
}, undefined, {escape: false}));
|
2015-10-07 17:17:38 +03:00
|
|
|
}).success(function(){
|
|
|
|
$('#newuser').get(0).reset();
|
|
|
|
});
|
|
|
|
});
|
2016-11-11 11:43:43 +03:00
|
|
|
};
|
2016-10-25 14:05:13 +03:00
|
|
|
$('#newuser').submit(_submitNewUserForm);
|
2014-04-17 22:14:51 +04:00
|
|
|
|
2015-09-25 07:24:08 +03:00
|
|
|
if ($('#CheckboxStorageLocation').is(':checked')) {
|
|
|
|
$("#userlist .storageLocation").show();
|
|
|
|
}
|
2014-07-17 00:23:15 +04:00
|
|
|
// Option to display/hide the "Storage location" column
|
|
|
|
$('#CheckboxStorageLocation').click(function() {
|
|
|
|
if ($('#CheckboxStorageLocation').is(':checked')) {
|
2016-10-25 16:46:24 +03:00
|
|
|
OCP.AppConfig.setValue('core', 'umgmt_show_storage_location', 'true', {
|
|
|
|
success: function () {
|
|
|
|
$("#userlist .storageLocation").show();
|
|
|
|
}
|
|
|
|
});
|
2014-07-17 00:23:15 +04:00
|
|
|
} else {
|
2016-10-25 16:46:24 +03:00
|
|
|
OCP.AppConfig.setValue('core', 'umgmt_show_storage_location', 'false', {
|
|
|
|
success: function () {
|
|
|
|
$("#userlist .storageLocation").hide();
|
|
|
|
}
|
|
|
|
});
|
2014-07-17 00:23:15 +04:00
|
|
|
}
|
|
|
|
});
|
2015-09-25 07:24:08 +03:00
|
|
|
|
|
|
|
if ($('#CheckboxLastLogin').is(':checked')) {
|
|
|
|
$("#userlist .lastLogin").show();
|
|
|
|
}
|
2014-07-17 00:23:15 +04:00
|
|
|
// Option to display/hide the "Last Login" column
|
|
|
|
$('#CheckboxLastLogin').click(function() {
|
|
|
|
if ($('#CheckboxLastLogin').is(':checked')) {
|
2014-12-12 12:21:50 +03:00
|
|
|
$("#userlist .lastLogin").show();
|
2016-09-20 12:17:13 +03:00
|
|
|
OCP.AppConfig.setValue('core', 'umgmt_show_last_login', 'true');
|
2014-12-12 12:21:50 +03:00
|
|
|
} else {
|
|
|
|
$("#userlist .lastLogin").hide();
|
2016-09-20 12:17:13 +03:00
|
|
|
OCP.AppConfig.setValue('core', 'umgmt_show_last_login', 'false');
|
2014-12-12 12:21:50 +03:00
|
|
|
}
|
|
|
|
});
|
2015-09-25 07:24:08 +03:00
|
|
|
|
|
|
|
if ($('#CheckboxEmailAddress').is(':checked')) {
|
|
|
|
$("#userlist .mailAddress").show();
|
|
|
|
}
|
2014-12-15 14:43:42 +03:00
|
|
|
// Option to display/hide the "Mail Address" column
|
|
|
|
$('#CheckboxEmailAddress').click(function() {
|
|
|
|
if ($('#CheckboxEmailAddress').is(':checked')) {
|
|
|
|
$("#userlist .mailAddress").show();
|
2016-09-20 12:17:13 +03:00
|
|
|
OCP.AppConfig.setValue('core', 'umgmt_show_email', 'true');
|
2014-12-15 14:43:42 +03:00
|
|
|
} else {
|
|
|
|
$("#userlist .mailAddress").hide();
|
2016-09-20 12:17:13 +03:00
|
|
|
OCP.AppConfig.setValue('core', 'umgmt_show_email', 'false');
|
2014-12-15 14:43:42 +03:00
|
|
|
}
|
|
|
|
});
|
2015-09-25 07:24:08 +03:00
|
|
|
|
|
|
|
if ($('#CheckboxUserBackend').is(':checked')) {
|
|
|
|
$("#userlist .userBackend").show();
|
|
|
|
}
|
2014-12-15 14:43:42 +03:00
|
|
|
// Option to display/hide the "User Backend" column
|
2014-12-12 12:21:50 +03:00
|
|
|
$('#CheckboxUserBackend').click(function() {
|
|
|
|
if ($('#CheckboxUserBackend').is(':checked')) {
|
|
|
|
$("#userlist .userBackend").show();
|
2016-09-20 12:17:13 +03:00
|
|
|
OCP.AppConfig.setValue('core', 'umgmt_show_backend', 'true');
|
2014-07-17 00:23:15 +04:00
|
|
|
} else {
|
2014-12-12 12:21:50 +03:00
|
|
|
$("#userlist .userBackend").hide();
|
2016-09-20 12:17:13 +03:00
|
|
|
OCP.AppConfig.setValue('core', 'umgmt_show_backend', 'false');
|
2014-07-17 00:23:15 +04:00
|
|
|
}
|
|
|
|
});
|
2015-09-25 07:24:08 +03:00
|
|
|
|
|
|
|
if ($('#CheckboxMailOnUserCreate').is(':checked')) {
|
|
|
|
$("#newemail").show();
|
|
|
|
}
|
2014-12-16 11:08:38 +03:00
|
|
|
// Option to display/hide the "E-Mail" input field
|
|
|
|
$('#CheckboxMailOnUserCreate').click(function() {
|
|
|
|
if ($('#CheckboxMailOnUserCreate').is(':checked')) {
|
|
|
|
$("#newemail").show();
|
2016-09-20 12:17:13 +03:00
|
|
|
OCP.AppConfig.setValue('core', 'umgmt_send_email', 'true');
|
2014-12-16 11:08:38 +03:00
|
|
|
} else {
|
|
|
|
$("#newemail").hide();
|
2016-09-20 12:17:13 +03:00
|
|
|
OCP.AppConfig.setValue('core', 'umgmt_send_email', 'false');
|
2014-12-16 11:08:38 +03:00
|
|
|
}
|
|
|
|
});
|
2014-07-17 00:23:15 +04:00
|
|
|
|
2014-12-12 19:58:01 +03:00
|
|
|
// calculate initial limit of users to load
|
2015-10-28 13:18:10 +03:00
|
|
|
var initialUserCountLimit = UserList.initialUsersToLoad,
|
2014-12-12 19:58:01 +03:00
|
|
|
containerHeight = $('#app-content').height();
|
|
|
|
if(containerHeight > 40) {
|
|
|
|
initialUserCountLimit = Math.floor(containerHeight/40);
|
2015-10-28 13:18:10 +03:00
|
|
|
if (initialUserCountLimit < UserList.initialUsersToLoad) {
|
|
|
|
initialUserCountLimit = UserList.initialUsersToLoad;
|
2015-02-04 19:19:11 +03:00
|
|
|
}
|
2014-12-12 19:58:01 +03:00
|
|
|
}
|
2015-10-28 13:18:10 +03:00
|
|
|
//realign initialUserCountLimit with usersToLoad as a safeguard
|
|
|
|
while((initialUserCountLimit % UserList.usersToLoad) !== 0) {
|
|
|
|
// must be a multiple of this, otherwise LDAP freaks out.
|
|
|
|
// FIXME: solve this in LDAP backend in 8.1
|
|
|
|
initialUserCountLimit = initialUserCountLimit + 1;
|
|
|
|
}
|
2014-12-12 19:58:01 +03:00
|
|
|
|
2014-12-11 17:37:56 +03:00
|
|
|
// trigger loading of users on startup
|
2014-12-12 19:58:01 +03:00
|
|
|
UserList.update(UserList.currentGid, initialUserCountLimit);
|
2014-07-17 00:23:15 +04:00
|
|
|
|
2015-07-29 12:01:51 +03:00
|
|
|
_.defer(function() {
|
|
|
|
$('#app-content').trigger($.Event('apprendered'));
|
|
|
|
});
|
|
|
|
|
2011-08-09 17:25:18 +04:00
|
|
|
});
|