mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-10-31 02:55:58 +01:00 
			
		
		
		
	| @@ -18,6 +18,7 @@ | |||||||
| 	"reply-to-topics": "Reply to Topics", | 	"reply-to-topics": "Reply to Topics", | ||||||
| 	"tag-topics": "Tag Topics", | 	"tag-topics": "Tag Topics", | ||||||
| 	"edit-posts": "Edit Posts", | 	"edit-posts": "Edit Posts", | ||||||
|  | 	"view-edit-history": "View Edit History", | ||||||
| 	"delete-posts": "Delete Posts", | 	"delete-posts": "Delete Posts", | ||||||
| 	"upvote-posts": "Upvote Posts", | 	"upvote-posts": "Upvote Posts", | ||||||
| 	"downvote-posts": "Downvote Posts", | 	"downvote-posts": "Downvote Posts", | ||||||
|   | |||||||
| @@ -140,7 +140,7 @@ define('forum/topic/postTools', [ | |||||||
| 			} | 			} | ||||||
| 		}); | 		}); | ||||||
|  |  | ||||||
| 		if (config.enablePostHistory) { | 		if (config.enablePostHistory && ajaxify.data.privileges['posts:history']) { | ||||||
| 			postContainer.on('click', '[component="post/view-history"], [component="post/edit-indicator"]', function () { | 			postContainer.on('click', '[component="post/view-history"], [component="post/edit-indicator"]', function () { | ||||||
| 				var btn = $(this); | 				var btn = $(this); | ||||||
| 				diffs.open(getData(btn, 'data-pid')); | 				diffs.open(getData(btn, 'data-pid')); | ||||||
|   | |||||||
| @@ -60,6 +60,7 @@ module.exports = function (Categories) { | |||||||
| 					'topics:reply', | 					'topics:reply', | ||||||
| 					'topics:tag', | 					'topics:tag', | ||||||
| 					'posts:edit', | 					'posts:edit', | ||||||
|  | 					'posts:history', | ||||||
| 					'posts:delete', | 					'posts:delete', | ||||||
| 					'posts:upvote', | 					'posts:upvote', | ||||||
| 					'posts:downvote', | 					'posts:downvote', | ||||||
|   | |||||||
| @@ -10,6 +10,7 @@ privileges.privilegeLabels = [ | |||||||
| 	{ name: '[[admin/manage/privileges:reply-to-topics]]' }, | 	{ name: '[[admin/manage/privileges:reply-to-topics]]' }, | ||||||
| 	{ name: '[[admin/manage/privileges:tag-topics]]' }, | 	{ name: '[[admin/manage/privileges:tag-topics]]' }, | ||||||
| 	{ name: '[[admin/manage/privileges:edit-posts]]' }, | 	{ name: '[[admin/manage/privileges:edit-posts]]' }, | ||||||
|  | 	{ name: '[[admin/manage/privileges:view-edit-history]]' }, | ||||||
| 	{ name: '[[admin/manage/privileges:delete-posts]]' }, | 	{ name: '[[admin/manage/privileges:delete-posts]]' }, | ||||||
| 	{ name: '[[admin/manage/privileges:upvote-posts]]' }, | 	{ name: '[[admin/manage/privileges:upvote-posts]]' }, | ||||||
| 	{ name: '[[admin/manage/privileges:downvote-posts]]' }, | 	{ name: '[[admin/manage/privileges:downvote-posts]]' }, | ||||||
| @@ -26,6 +27,7 @@ privileges.userPrivilegeList = [ | |||||||
| 	'topics:reply', | 	'topics:reply', | ||||||
| 	'topics:tag', | 	'topics:tag', | ||||||
| 	'posts:edit', | 	'posts:edit', | ||||||
|  | 	'posts:history', | ||||||
| 	'posts:delete', | 	'posts:delete', | ||||||
| 	'posts:upvote', | 	'posts:upvote', | ||||||
| 	'posts:downvote', | 	'posts:downvote', | ||||||
|   | |||||||
| @@ -16,7 +16,7 @@ module.exports = function (privileges) { | |||||||
|  |  | ||||||
| 	privileges.topics.get = function (tid, uid, callback) { | 	privileges.topics.get = function (tid, uid, callback) { | ||||||
| 		var topic; | 		var topic; | ||||||
| 		var privs = ['topics:reply', 'topics:read', 'topics:tag', 'topics:delete', 'posts:edit', 'posts:delete', 'read']; | 		var privs = ['topics:reply', 'topics:read', 'topics:tag', 'topics:delete', 'posts:edit', 'posts:history', 'posts:delete', 'read']; | ||||||
| 		async.waterfall([ | 		async.waterfall([ | ||||||
| 			async.apply(topics.getTopicFields, tid, ['cid', 'uid', 'locked', 'deleted']), | 			async.apply(topics.getTopicFields, tid, ['cid', 'uid', 'locked', 'deleted']), | ||||||
| 			function (_topic, next) { | 			function (_topic, next) { | ||||||
| @@ -44,6 +44,7 @@ module.exports = function (privileges) { | |||||||
| 					'topics:tag': privData['topics:tag'] || isAdminOrMod, | 					'topics:tag': privData['topics:tag'] || isAdminOrMod, | ||||||
| 					'topics:delete': (isOwner && privData['topics:delete']) || isAdminOrMod, | 					'topics:delete': (isOwner && privData['topics:delete']) || isAdminOrMod, | ||||||
| 					'posts:edit': (privData['posts:edit'] && !locked) || isAdminOrMod, | 					'posts:edit': (privData['posts:edit'] && !locked) || isAdminOrMod, | ||||||
|  | 					'posts:history': privData['posts:history'] || isAdminOrMod, | ||||||
| 					'posts:delete': (privData['posts:delete'] && !locked) || isAdminOrMod, | 					'posts:delete': (privData['posts:delete'] && !locked) || isAdminOrMod, | ||||||
| 					read: privData.read || isAdminOrMod, | 					read: privData.read || isAdminOrMod, | ||||||
| 					view_thread_tools: editable || deletable, | 					view_thread_tools: editable || deletable, | ||||||
|   | |||||||
| @@ -2,10 +2,16 @@ | |||||||
|  |  | ||||||
| var async = require('async'); | var async = require('async'); | ||||||
| var posts = require('../../posts'); | var posts = require('../../posts'); | ||||||
|  | var privileges = require('../../privileges'); | ||||||
|  |  | ||||||
| module.exports = function (SocketPosts) { | module.exports = function (SocketPosts) { | ||||||
| 	SocketPosts.getDiffs = function (socket, data, callback) { | 	SocketPosts.getDiffs = function (socket, data, callback) { | ||||||
| 		async.waterfall([ | 		async.waterfall([ | ||||||
|  | 			function (next) { | ||||||
|  | 				privileges.posts.can('posts:history', data.pid, socket.uid, function (err, allowed) { | ||||||
|  | 					next(err || allowed ? null : new Error('[[error:no-privileges]]')); | ||||||
|  | 				}); | ||||||
|  | 			}, | ||||||
| 			function (next) { | 			function (next) { | ||||||
| 				posts.diffs.list(data.pid, next); | 				posts.diffs.list(data.pid, next); | ||||||
| 			}, | 			}, | ||||||
| @@ -17,6 +23,12 @@ module.exports = function (SocketPosts) { | |||||||
| 	}; | 	}; | ||||||
|  |  | ||||||
| 	SocketPosts.showPostAt = function (socket, data, callback) { | 	SocketPosts.showPostAt = function (socket, data, callback) { | ||||||
|  | 		privileges.posts.can('posts:history', data.pid, socket.uid, function (err, allowed) { | ||||||
|  | 			if (err || !allowed) { | ||||||
|  | 				return callback(err || new Error('[[error:no-privileges]]')); | ||||||
|  | 			} | ||||||
|  |  | ||||||
| 			posts.diffs.load(data.pid, data.since, socket.uid, callback); | 			posts.diffs.load(data.pid, data.since, socket.uid, callback); | ||||||
|  | 		}); | ||||||
| 	}; | 	}; | ||||||
| }; | }; | ||||||
|   | |||||||
							
								
								
									
										22
									
								
								src/upgrades/1.10.0/post_history_privilege.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								src/upgrades/1.10.0/post_history_privilege.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,22 @@ | |||||||
|  | 'use strict'; | ||||||
|  |  | ||||||
|  |  | ||||||
|  | var async = require('async'); | ||||||
|  |  | ||||||
|  | var privileges = require('../../privileges'); | ||||||
|  | var db = require('../../database'); | ||||||
|  |  | ||||||
|  | module.exports = { | ||||||
|  | 	name: 'Give post history viewing privilege to registered-users on all categories', | ||||||
|  | 	timestamp: Date.UTC(2018, 5, 7), | ||||||
|  | 	method: function (callback) { | ||||||
|  | 		db.getSortedSetRange('categories:cid', 0, -1, function (err, cids) { | ||||||
|  | 			if (err) { | ||||||
|  | 				return callback(err); | ||||||
|  | 			} | ||||||
|  | 			async.eachSeries(cids, function (cid, next) { | ||||||
|  | 				privileges.categories.give(['posts:history'], cid, 'registered-users', next); | ||||||
|  | 			}, callback); | ||||||
|  | 		}); | ||||||
|  | 	}, | ||||||
|  | }; | ||||||
| @@ -5,7 +5,7 @@ | |||||||
| 								<th class="arrowed" colspan="3"> | 								<th class="arrowed" colspan="3"> | ||||||
| 									[[admin/manage/categories:privileges.section-viewing]] | 									[[admin/manage/categories:privileges.section-viewing]] | ||||||
| 								</th> | 								</th> | ||||||
| 								<th class="arrowed" colspan="8"> | 								<th class="arrowed" colspan="9"> | ||||||
| 									[[admin/manage/categories:privileges.section-posting]] | 									[[admin/manage/categories:privileges.section-posting]] | ||||||
| 								</th> | 								</th> | ||||||
| 								<th class="arrowed" colspan="2"> | 								<th class="arrowed" colspan="2"> | ||||||
| @@ -61,7 +61,7 @@ | |||||||
| 								<th class="arrowed" colspan="3"> | 								<th class="arrowed" colspan="3"> | ||||||
| 									[[admin/manage/categories:privileges.section-viewing]] | 									[[admin/manage/categories:privileges.section-viewing]] | ||||||
| 								</th> | 								</th> | ||||||
| 								<th class="arrowed" colspan="8"> | 								<th class="arrowed" colspan="9"> | ||||||
| 									[[admin/manage/categories:privileges.section-posting]] | 									[[admin/manage/categories:privileges.section-posting]] | ||||||
| 								</th> | 								</th> | ||||||
| 								<th class="arrowed" colspan="2"> | 								<th class="arrowed" colspan="2"> | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user