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(
|
2011-08-13 21:56:33 +00:00
|
|
|
OC.filePath('settings','ajax','togglegroups.php'),
|
2011-08-10 18:51:35 +00:00
|
|
|
{
|
|
|
|
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(
|
2011-08-13 21:56:33 +00:00
|
|
|
OC.filePath('settings','ajax','removeuser.php'),
|
2011-08-09 13:25:18 +00:00
|
|
|
{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){
|
2011-08-11 18:59:17 +00:00
|
|
|
event.stopPropagation();
|
2011-08-11 09:26:57 +00:00
|
|
|
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) {
|
2011-08-11 09:38:37 +00:00
|
|
|
if($(this).val().length>0){
|
|
|
|
$.post(
|
2011-08-13 21:56:33 +00:00
|
|
|
OC.filePath('settings','ajax','changepassword.php'),
|
2011-08-11 09:38:37 +00:00
|
|
|
{username:uid,password:$(this).val()},
|
|
|
|
function(result){}
|
|
|
|
);
|
|
|
|
input.blur();
|
|
|
|
}else{
|
|
|
|
input.blur();
|
|
|
|
}
|
2011-08-11 09:26:57 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
input.blur(function(){
|
|
|
|
$(this).replaceWith($('<span>●●●●●●●</span>'));
|
|
|
|
img.css('display','');
|
|
|
|
});
|
|
|
|
});
|
2011-08-11 18:59:17 +00:00
|
|
|
$('td.password').live('click',function(event){
|
|
|
|
$(this).children('img').click();
|
|
|
|
});
|
2011-08-11 09:26:57 +00:00
|
|
|
|
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(
|
2011-08-13 21:56:33 +00:00
|
|
|
OC.filePath('settings','ajax','createuser.php'),
|
2011-08-09 13:25:18 +00:00
|
|
|
{
|
|
|
|
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-11 18:59:17 +00:00
|
|
|
var tr=$('#content table tr').first().next().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){
|
2011-08-14 12:55:43 +00:00
|
|
|
tr.find('td.remove').append($('<img alt="Delete" title="'+t('settings','Delete')+'" class="svg action" src="'+OC.imagePath('core','actions/delete')+'"/>'));
|
2011-08-11 09:26:57 +00:00
|
|
|
}
|
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
|
|
|
});
|