final pass - resolved #961

v1.18.x
Julian Lam 11 years ago
parent 8da065d8fd
commit 0670382992

@ -244,6 +244,7 @@ define(['uploader'], function(uploader) {
'<div class="btn-group">' +
'<button type="button" data-priv="+r" class="btn btn-default' + (resultObj.privileges['+r'] ? ' active' : '') + '">Read</button>' +
'<button type="button" data-priv="+w" class="btn btn-default' + (resultObj.privileges['+w'] ? ' active' : '') + '">Write</button>' +
'<button type="button" data-priv="mods" class="btn btn-default' + (resultObj.privileges['mods'] ? ' active' : '') + '">Moderator</button>' +
'</div>' +
'</div>' +
'<img src="' + resultObj.picture + '" /> ' + resultObj.username;
@ -331,12 +332,15 @@ define(['uploader'], function(uploader) {
Categories.refreshPrivilegeList = function (cid) {
var modalEl = $('#category-permissions-modal'),
readMembers = modalEl.find('#category-permissions-read'),
writeMembers = modalEl.find('#category-permissions-write');
writeMembers = modalEl.find('#category-permissions-write'),
moderatorsEl = modalEl.find('#category-permissions-mods');
socket.emit('admin.categories.getPrivilegeSettings', cid, function(err, privilegeList) {
var readLength = privilegeList['+r'].length,
writeLength = privilegeList['+w'].length,
modLength = privilegeList['mods'].length,
readFrag = document.createDocumentFragment(),
writeFrag = document.createDocumentFragment(),
modFrag = document.createDocumentFragment(),
liEl = document.createElement('li'),
x, userObj;
@ -350,7 +354,7 @@ define(['uploader'], function(uploader) {
}
} else {
liEl.className = 'empty';
liEl.innerHTML = 'No users are in this list';
liEl.innerHTML = 'All users can read and see this category';
readFrag.appendChild(liEl.cloneNode(true));
}
@ -364,12 +368,27 @@ define(['uploader'], function(uploader) {
}
} else {
liEl.className = 'empty';
liEl.innerHTML = 'No users are in this list';
liEl.innerHTML = 'All users can write to this category';
writeFrag.appendChild(liEl.cloneNode(true));
}
if (modLength > 0) {
for(x=0;x<modLength;x++) {
userObj = privilegeList['mods'][x];
liEl.setAttribute('data-uid', userObj.uid);
liEl.innerHTML = '<img src="' + userObj.picture + '" title="' + userObj.username + '" />';
modFrag.appendChild(liEl.cloneNode(true));
}
} else {
liEl.className = 'empty';
liEl.innerHTML = 'No moderators';
modFrag.appendChild(liEl.cloneNode(true));
}
readMembers.html(readFrag);
writeMembers.html(writeFrag);
moderatorsEl.html(modFrag);
});
};

@ -158,7 +158,7 @@
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<div id="category-permissions-modal" class="modal permissions-modal" tabindex="-1" role="dialog" aria-labelledby="Category Permissions" aria-hidden="true">
<div id="category-permissions-modal" class="modal permissions-modal fade" tabindex="-1" role="dialog" aria-labelledby="Category Permissions" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
@ -166,12 +166,15 @@
<h3>Category Permissions</h3>
</div>
<div class="modal-body">
<p>The following users can read Topics in this Category</p>
<p>The following users can view &amp; read Topics in this Category</p>
<ul class="members" id="category-permissions-read"></ul>
<p>The following users can post and reply to Topics in this Category</p>
<ul class="members" id="category-permissions-write"></ul>
<p>The following users are moderators of this Category</p>
<ul class="members" id="category-permissions-mods"></ul>
<hr />
<form role="form">
<div class="form-group">

@ -186,6 +186,17 @@ SocketAdmin.categories.getPrivilegeSettings = function(socket, cid, callback) {
});
}
});
},
"mods": function(next) {
groups.getByGroupName('cid:' + cid + ':privileges:mods', { expand: true }, function(err, groupObj) {
if (!err) {
next.apply(this, arguments);
} else {
next(null, {
members: []
});
}
});
}
}, function(err, data) {
if(err) {
@ -194,7 +205,8 @@ SocketAdmin.categories.getPrivilegeSettings = function(socket, cid, callback) {
callback(null, {
"+r": data['+r'].members,
"+w": data['+w'].members
"+w": data['+w'].members,
"mods": data['mods'].members
});
});
};

Loading…
Cancel
Save