Fixed comments disregarding viewUsers privilege
This commit is contained in:
parent
4b4ccf365a
commit
736c0a66ff
6 changed files with 22 additions and 18 deletions
|
@ -138,7 +138,7 @@
|
||||||
<script type="text/javascript" src="/js/Presenters/PostPresenter.js"></script>
|
<script type="text/javascript" src="/js/Presenters/PostPresenter.js"></script>
|
||||||
|
|
||||||
<script type="text/javascript" src="/js/Presenters/GlobalCommentListPresenter.js"></script>
|
<script type="text/javascript" src="/js/Presenters/GlobalCommentListPresenter.js"></script>
|
||||||
<script type="text/javascript" src="/js/Presenters/PostCommentListPresenter.js"></script>
|
<script type="text/javascript" src="/js/Presenters/CommentListPresenter.js"></script>
|
||||||
|
|
||||||
<script type="text/javascript" src="/js/Presenters/TagListPresenter.js"></script>
|
<script type="text/javascript" src="/js/Presenters/TagListPresenter.js"></script>
|
||||||
<script type="text/javascript" src="/js/Presenters/TagPresenter.js"></script>
|
<script type="text/javascript" src="/js/Presenters/TagPresenter.js"></script>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
var App = App || {};
|
var App = App || {};
|
||||||
App.Presenters = App.Presenters || {};
|
App.Presenters = App.Presenters || {};
|
||||||
|
|
||||||
App.Presenters.PostCommentListPresenter = function(
|
App.Presenters.CommentListPresenter = function(
|
||||||
_,
|
_,
|
||||||
jQuery,
|
jQuery,
|
||||||
util,
|
util,
|
||||||
|
@ -26,14 +26,16 @@ App.Presenters.PostCommentListPresenter = function(
|
||||||
privileges = {
|
privileges = {
|
||||||
canListComments: auth.hasPrivilege(auth.privileges.listComments),
|
canListComments: auth.hasPrivilege(auth.privileges.listComments),
|
||||||
canAddComments: auth.hasPrivilege(auth.privileges.addComments),
|
canAddComments: auth.hasPrivilege(auth.privileges.addComments),
|
||||||
editOwnComments: auth.hasPrivilege(auth.privileges.editOwnComments),
|
canEditOwnComments: auth.hasPrivilege(auth.privileges.editOwnComments),
|
||||||
editAllComments: auth.hasPrivilege(auth.privileges.editAllComments),
|
canEditAllComments: auth.hasPrivilege(auth.privileges.editAllComments),
|
||||||
deleteOwnComments: auth.hasPrivilege(auth.privileges.deleteOwnComments),
|
canDeleteOwnComments: auth.hasPrivilege(auth.privileges.deleteOwnComments),
|
||||||
deleteAllComments: auth.hasPrivilege(auth.privileges.deleteAllComments),
|
canDeleteAllComments: auth.hasPrivilege(auth.privileges.deleteAllComments),
|
||||||
|
canViewUsers: auth.hasPrivilege(auth.privileges.viewUsers),
|
||||||
|
canViewPosts: auth.hasPrivilege(auth.privileges.viewPosts),
|
||||||
};
|
};
|
||||||
|
|
||||||
promise.wait(
|
promise.wait(
|
||||||
util.promiseTemplate('post-comment-list'),
|
util.promiseTemplate('comment-list'),
|
||||||
util.promiseTemplate('comment-list-item'),
|
util.promiseTemplate('comment-list-item'),
|
||||||
util.promiseTemplate('comment-form'))
|
util.promiseTemplate('comment-form'))
|
||||||
.then(function(
|
.then(function(
|
||||||
|
@ -103,8 +105,10 @@ App.Presenters.PostCommentListPresenter = function(
|
||||||
formatRelativeTime: util.formatRelativeTime,
|
formatRelativeTime: util.formatRelativeTime,
|
||||||
formatMarkdown: util.formatMarkdown,
|
formatMarkdown: util.formatMarkdown,
|
||||||
canVote: auth.isLoggedIn(),
|
canVote: auth.isLoggedIn(),
|
||||||
canEditComment: auth.isLoggedIn(comment.user.name) ? privileges.editOwnComments : privileges.editAllComments,
|
canEditComment: auth.isLoggedIn(comment.user.name) ? privileges.canEditOwnComments : privileges.canEditAllComments,
|
||||||
canDeleteComment: auth.isLoggedIn(comment.user.name) ? privileges.deleteOwnComments : privileges.deleteAllComments,
|
canDeleteComment: auth.isLoggedIn(comment.user.name) ? privileges.canDeleteOwnComments : privileges.canDeleteAllComments,
|
||||||
|
canViewUsers: privileges.canViewUsers,
|
||||||
|
canViewPosts: privileges.canViewPosts,
|
||||||
}) + '</li>');
|
}) + '</li>');
|
||||||
util.loadImagesNicely($item.find('img'));
|
util.loadImagesNicely($item.find('img'));
|
||||||
$targetList.append($item);
|
$targetList.append($item);
|
||||||
|
@ -227,4 +231,4 @@ App.Presenters.PostCommentListPresenter = function(
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
App.DI.register('postCommentListPresenter', ['_', 'jQuery', 'util', 'promise', 'api', 'auth', 'topNavigationPresenter', 'messagePresenter'], App.Presenters.PostCommentListPresenter);
|
App.DI.register('commentListPresenter', ['_', 'jQuery', 'util', 'promise', 'api', 'auth', 'topNavigationPresenter', 'messagePresenter'], App.Presenters.CommentListPresenter);
|
|
@ -72,7 +72,7 @@ App.Presenters.GlobalCommentListPresenter = function(
|
||||||
}) + '</li>');
|
}) + '</li>');
|
||||||
|
|
||||||
util.loadImagesNicely($post.find('img'));
|
util.loadImagesNicely($post.find('img'));
|
||||||
var presenter = App.DI.get('postCommentListPresenter');
|
var presenter = App.DI.get('commentListPresenter');
|
||||||
|
|
||||||
presenter.init({
|
presenter.init({
|
||||||
post: post,
|
post: post,
|
||||||
|
|
|
@ -14,7 +14,7 @@ App.Presenters.PostPresenter = function(
|
||||||
postsAroundCalculator,
|
postsAroundCalculator,
|
||||||
postEditPresenter,
|
postEditPresenter,
|
||||||
postContentPresenter,
|
postContentPresenter,
|
||||||
postCommentListPresenter,
|
commentListPresenter,
|
||||||
topNavigationPresenter,
|
topNavigationPresenter,
|
||||||
messagePresenter) {
|
messagePresenter) {
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ App.Presenters.PostPresenter = function(
|
||||||
presenterManager.initPresenters([
|
presenterManager.initPresenters([
|
||||||
[postContentPresenter, {post: post, $target: $el.find('#post-content-target')}],
|
[postContentPresenter, {post: post, $target: $el.find('#post-content-target')}],
|
||||||
[postEditPresenter, {post: post, $target: $el.find('#post-edit-target'), updateCallback: postEdited}],
|
[postEditPresenter, {post: post, $target: $el.find('#post-edit-target'), updateCallback: postEdited}],
|
||||||
[postCommentListPresenter, {post: post, $target: $el.find('#post-comments-target')}]],
|
[commentListPresenter, {post: post, $target: $el.find('#post-comments-target')}]],
|
||||||
function() { });
|
function() { });
|
||||||
|
|
||||||
}).fail(function() {
|
}).fail(function() {
|
||||||
|
@ -333,7 +333,7 @@ App.DI.register('postPresenter', [
|
||||||
'postsAroundCalculator',
|
'postsAroundCalculator',
|
||||||
'postEditPresenter',
|
'postEditPresenter',
|
||||||
'postContentPresenter',
|
'postContentPresenter',
|
||||||
'postCommentListPresenter',
|
'commentListPresenter',
|
||||||
'topNavigationPresenter',
|
'topNavigationPresenter',
|
||||||
'messagePresenter'],
|
'messagePresenter'],
|
||||||
App.Presenters.PostPresenter);
|
App.Presenters.PostPresenter);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<div class="comment">
|
<div class="comment">
|
||||||
<div class="avatar">
|
<div class="avatar">
|
||||||
<% if (comment.user.name) { %>
|
<% if (comment.user.name && canViewUsers) { %>
|
||||||
<a href="#/user/<%= comment.user.name %>">
|
<a href="#/user/<%= comment.user.name %>">
|
||||||
<% } %>
|
<% } %>
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
||||||
src="/data/thumbnails/40x40/avatars/<%= comment.user.name || '!' %>"
|
src="/data/thumbnails/40x40/avatars/<%= comment.user.name || '!' %>"
|
||||||
alt="<%= comment.user.name || 'Anonymous user' %>"/>
|
alt="<%= comment.user.name || 'Anonymous user' %>"/>
|
||||||
|
|
||||||
<% if (comment.user.name) { %>
|
<% if (comment.user.name && canViewUsers) { %>
|
||||||
</a>
|
</a>
|
||||||
<% } %>
|
<% } %>
|
||||||
</div>
|
</div>
|
||||||
|
@ -16,13 +16,13 @@
|
||||||
<div class="body">
|
<div class="body">
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<span class="nickname">
|
<span class="nickname">
|
||||||
<% if (comment.user.name) { %>
|
<% if (comment.user.name && canViewUsers) { %>
|
||||||
<a href="#/user/<%= comment.user.name %>">
|
<a href="#/user/<%= comment.user.name %>">
|
||||||
<% } %>
|
<% } %>
|
||||||
|
|
||||||
<%= comment.user.name || 'Anonymous user' %>
|
<%= comment.user.name || 'Anonymous user' %>
|
||||||
|
|
||||||
<% if (comment.user.name) { %>
|
<% if (comment.user.name && canViewUsers) { %>
|
||||||
</a>
|
</a>
|
||||||
<% } %>
|
<% } %>
|
||||||
</span>
|
</span>
|
||||||
|
|
Loading…
Reference in a new issue