From 4e6fe634e102c7710fce65898f00793fba89f94c Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Sat, 22 Nov 2014 13:10:00 +0100 Subject: [PATCH] Fixed post list disregarding viewPosts privilege --- public_html/css/post-list.css | 30 +++++++++---------- .../Presenters/GlobalCommentListPresenter.js | 9 +++++- .../js/Presenters/PostListPresenter.js | 2 ++ .../templates/global-comment-list-item.tpl | 2 +- public_html/templates/post-list-item.tpl | 18 ++++++++--- 5 files changed, 40 insertions(+), 21 deletions(-) diff --git a/public_html/css/post-list.css b/public_html/css/post-list.css index 64519e7b..f21c5962 100644 --- a/public_html/css/post-list.css +++ b/public_html/css/post-list.css @@ -68,7 +68,7 @@ .post-small { position: relative; } -.post-small a { +.post-small .link { display: inline-block; margin: 0.2em; border: 1px solid #999; @@ -82,20 +82,20 @@ } -.post-small a:focus, -.post-small a:hover { +.post-small .link:focus, +.post-small .link:hover { background: #64C2ED; border-color: #64C2ED; box-shadow: 0 0 0 2px #64C2ED; outline: 0; } -.post-small a:focus img:not(.loading), -.post-small a:hover img:not(.loading) { +.post-small .link:focus img:not(.loading), +.post-small .link:hover img:not(.loading) { opacity: .8 !important; } -.post-small a .info { +.post-small .link .info { display: none; text-align: center; position: absolute; @@ -105,22 +105,22 @@ background: #64C2ED; color: black; } -.post-small a .info ul { +.post-small .link .info ul { list-style-type: none; padding: 0; margin: 0; } -.post-small a .info li { +.post-small .link .info li { display: inline-block; margin: 0.1em 0.5em; padding: 0; } -.post-small a:focus .info, -.post-small a:hover .info { +.post-small .link:focus .info, +.post-small .link:hover .info { display: block; } -.post-small:not(.post-type-image) a::before { +.post-small:not(.post-type-image) .link::before { display: block; content: ''; z-index: 2; @@ -133,7 +133,7 @@ border-left: 50px solid transparent; } -.post-small:not(.post-type-image) a::after { +.post-small:not(.post-type-image) .link::after { display: block; content: '...'; z-index: 3; @@ -148,14 +148,14 @@ color: white; font-size: 15px; } -.post-small.post-type-youtube a::after { +.post-small.post-type-youtube .link::after { font-size: 13px; content: 'youtube'; } -.post-small.post-type-video a::after { +.post-small.post-type-video .link::after { content: 'video'; } -.post-small.post-type-flash a::after { +.post-small.post-type-flash .link::after { content: 'flash'; } diff --git a/public_html/js/Presenters/GlobalCommentListPresenter.js b/public_html/js/Presenters/GlobalCommentListPresenter.js index 73d79874..2b41b2ec 100644 --- a/public_html/js/Presenters/GlobalCommentListPresenter.js +++ b/public_html/js/Presenters/GlobalCommentListPresenter.js @@ -5,17 +5,23 @@ App.Presenters.GlobalCommentListPresenter = function( _, jQuery, util, + auth, promise, pagerPresenter, topNavigationPresenter) { var $el; + var privileges; var templates = {}; function init(params, loaded) { $el = jQuery('#content'); topNavigationPresenter.select('comments'); + privileges = { + canViewPosts: auth.hasPrivilege(auth.privileges.viewPosts), + }; + promise.wait( util.promiseTemplate('global-comment-list'), util.promiseTemplate('global-comment-list-item'), @@ -69,6 +75,7 @@ App.Presenters.GlobalCommentListPresenter = function( util: util, post: post, postTemplate: templates.post, + canViewPosts: privileges.canViewPosts, }) + ''); util.loadImagesNicely($post.find('img')); @@ -95,4 +102,4 @@ App.Presenters.GlobalCommentListPresenter = function( }; -App.DI.register('globalCommentListPresenter', ['_', 'jQuery', 'util', 'promise', 'pagerPresenter', 'topNavigationPresenter'], App.Presenters.GlobalCommentListPresenter); +App.DI.register('globalCommentListPresenter', ['_', 'jQuery', 'util', 'auth', 'promise', 'pagerPresenter', 'topNavigationPresenter'], App.Presenters.GlobalCommentListPresenter); diff --git a/public_html/js/Presenters/PostListPresenter.js b/public_html/js/Presenters/PostListPresenter.js index febc7665..382a54d8 100644 --- a/public_html/js/Presenters/PostListPresenter.js +++ b/public_html/js/Presenters/PostListPresenter.js @@ -29,6 +29,7 @@ App.Presenters.PostListPresenter = function( params.query = params.query || {}; privileges.canMassTag = auth.hasPrivilege(auth.privileges.massTag); + privileges.canViewPosts = auth.hasPrivilege(auth.privileges.viewPosts); promise.wait( util.promiseTemplate('post-list'), @@ -165,6 +166,7 @@ App.Presenters.PostListPresenter = function( util: util, query: params.query, post: post, + canViewPosts: privileges.canViewPosts, }) + ''); $post.data('post', post); util.loadImagesNicely($post.find('img')); diff --git a/public_html/templates/global-comment-list-item.tpl b/public_html/templates/global-comment-list-item.tpl index 2b3f27bf..6d00cc28 100644 --- a/public_html/templates/global-comment-list-item.tpl +++ b/public_html/templates/global-comment-list-item.tpl @@ -1,6 +1,6 @@
- <%= postTemplate({post: post, util: util}) %> + <%= postTemplate({post: post, util: util, canViewPosts: canViewPosts}) %>
diff --git a/public_html/templates/post-list-item.tpl b/public_html/templates/post-list-item.tpl index 1499d090..d91401ac 100644 --- a/public_html/templates/post-list-item.tpl +++ b/public_html/templates/post-list-item.tpl @@ -1,7 +1,12 @@
- + + <% if (canViewPosts) { %> + + <% } else { %> + + <% } %> <%= post.idMarkdown %> @@ -31,7 +36,12 @@
<% } %> - + + <% if (canViewPosts) { %> + + <% } else { %> + + <% } %>