2011-04-16 15:49:57 +00:00
|
|
|
$(document).ready(function(){
|
2011-08-10 18:51:35 +00:00
|
|
|
function applyMultiplySelect(element){
|
|
|
|
var checked=[];
|
|
|
|
var user=element.data('username')
|
|
|
|
if(element.data('userGroups')){
|
|
|
|
checked=element.data('userGroups').split(', ');
|
|
|
|
}
|
|
|
|
if(user){
|
|
|
|
var checkHandeler=function(group){
|
|
|
|
if(user==OC.currentUser && group=='admin'){
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
$.post(
|
|
|
|
OC.filePath('admin','ajax','togglegroups.php'),
|
|
|
|
{
|
|
|
|
username:user,
|
|
|
|
group:group
|
|
|
|
},
|
|
|
|
function(){}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
checkHandeler=false;
|
|
|
|
}
|
|
|
|
element.multiSelect({
|
|
|
|
createText:'add group',
|
|
|
|
checked:checked,
|
|
|
|
oncheck:checkHandeler,
|
|
|
|
onuncheck:checkHandeler
|
|
|
|
});
|
|
|
|
}
|
|
|
|
$('select[multiple]').each(function(index,element){
|
|
|
|
applyMultiplySelect($(element));
|
|
|
|
});
|
2011-08-09 13:25:18 +00:00
|
|
|
|
|
|
|
$('td.remove>img').live('click',function(event){
|
|
|
|
var uid=$(this).parent().parent().data('uid');
|
|
|
|
$.post(
|
|
|
|
OC.filePath('admin','ajax','removeuser.php'),
|
|
|
|
{username:uid},
|
|
|
|
function(result){
|
|
|
|
|
2011-04-17 16:05:49 +00:00
|
|
|
}
|
2011-08-09 13:25:18 +00:00
|
|
|
);
|
|
|
|
$(this).parent().parent().remove();
|
|
|
|
});
|
|
|
|
|
2011-08-11 09:26:57 +00:00
|
|
|
$('td.password>img').live('click',function(event){
|
|
|
|
var img=$(this);
|
|
|
|
var uid=img.parent().parent().data('uid');
|
|
|
|
var input=$('<input type="password">');
|
|
|
|
img.css('display','none');
|
|
|
|
img.parent().children('span').replaceWith(input);
|
|
|
|
input.focus();
|
|
|
|
input.keypress(function(event) {
|
|
|
|
if(event.keyCode == 13) {
|
|
|
|
$.post(
|
|
|
|
OC.filePath('admin','ajax','changepassword.php'),
|
|
|
|
{username:uid,password:$(this).val()},
|
|
|
|
function(result){}
|
|
|
|
);
|
|
|
|
input.blur();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
input.blur(function(){
|
|
|
|
$(this).replaceWith($('<span>●●●●●●●</span>'));
|
|
|
|
img.css('display','');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2011-08-09 13:25:18 +00:00
|
|
|
$('#newuser').submit(function(event){
|
|
|
|
event.preventDefault();
|
|
|
|
var username=$('#newusername').val();
|
|
|
|
var password=$('#newuserpassword').val();
|
2011-08-10 18:51:35 +00:00
|
|
|
var groups=$('#newusergroups').prev().children('div').data('settings').checked;
|
2011-08-09 13:25:18 +00:00
|
|
|
$.post(
|
|
|
|
OC.filePath('admin','ajax','createuser.php'),
|
|
|
|
{
|
|
|
|
username:username,
|
|
|
|
password:password,
|
|
|
|
groups:groups,
|
|
|
|
},
|
|
|
|
function(result){
|
|
|
|
|
2011-04-16 15:49:57 +00:00
|
|
|
}
|
2011-08-09 13:25:18 +00:00
|
|
|
);
|
2011-08-10 18:51:35 +00:00
|
|
|
var tr=$('#content table tr').first().clone();
|
2011-08-09 13:25:18 +00:00
|
|
|
tr.attr('data-uid',username);
|
|
|
|
tr.find('td.name').text(username);
|
2011-08-10 18:51:35 +00:00
|
|
|
var select=$('<select multiple="multiple" data-placehoder="Groups" title="Groups">');
|
|
|
|
select.data('username',username);
|
|
|
|
select.data('userGroups',groups.join(', '));
|
|
|
|
tr.find('td.groups').empty();
|
|
|
|
$.each($('#content table').data('groups').split(', '),function(i,group){
|
|
|
|
select.append($('<option value="'+group+'">'+group+'</option>'));
|
2011-08-09 13:25:18 +00:00
|
|
|
});
|
2011-08-10 18:51:35 +00:00
|
|
|
tr.find('td.groups').append(select);
|
2011-08-11 09:26:57 +00:00
|
|
|
if(tr.find('td.remve img').length==0){
|
|
|
|
tr.find('td.remove').append($('<img alt="Remove" title="'+t('admin','Remove')+'" class="svg" src="'+OC.imagePath('core','actions/delete')+'"/>'));
|
|
|
|
}
|
2011-08-10 18:51:35 +00:00
|
|
|
applyMultiplySelect(select);
|
|
|
|
$('#content table tr').last().after(tr);
|
2011-04-16 15:49:57 +00:00
|
|
|
});
|
2011-08-09 13:25:18 +00:00
|
|
|
});
|