mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-11-03 20:45:58 +01:00 
			
		
		
		
	closes #962
This commit is contained in:
		@@ -22,9 +22,11 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
<hr/>
 | 
					<hr/>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<div class="alert alert-warning hide {no_topics_message}" id="category-no-topics">
 | 
					<!-- IF !topics.length -->
 | 
				
			||||||
 | 
					<div class="alert alert-warning" id="category-no-topics">
 | 
				
			||||||
	[[category:no_topics]]
 | 
						[[category:no_topics]]
 | 
				
			||||||
</div>
 | 
					</div>
 | 
				
			||||||
 | 
					<!-- ENDIF !topics.length -->
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<div class="category row">
 | 
					<div class="category row">
 | 
				
			||||||
	<div class="{topic_row_size}">
 | 
						<div class="{topic_row_size}">
 | 
				
			||||||
@@ -94,7 +96,8 @@
 | 
				
			|||||||
		<!-- ENDIF usePagination -->
 | 
							<!-- ENDIF usePagination -->
 | 
				
			||||||
	</div>
 | 
						</div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	<div class="col-md-3 col-xs-12 {show_sidebar} category-sidebar">
 | 
						<!-- IF topics.length -->
 | 
				
			||||||
 | 
						<div class="col-md-3 col-xs-12 category-sidebar">
 | 
				
			||||||
		<div class="panel panel-default">
 | 
							<div class="panel panel-default">
 | 
				
			||||||
			<div class="panel-heading">[[category:sidebar.recent_replies]]</div>
 | 
								<div class="panel-heading">[[category:sidebar.recent_replies]]</div>
 | 
				
			||||||
			<div class="panel-body recent-replies">
 | 
								<div class="panel-body recent-replies">
 | 
				
			||||||
@@ -129,6 +132,7 @@
 | 
				
			|||||||
		</div>
 | 
							</div>
 | 
				
			||||||
		<!-- END sidebars -->
 | 
							<!-- END sidebars -->
 | 
				
			||||||
	</div>
 | 
						</div>
 | 
				
			||||||
 | 
						<!-- ENDIF topics.length -->
 | 
				
			||||||
</div>
 | 
					</div>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<input type="hidden" template-variable="category_id" value="{category_id}" />
 | 
					<input type="hidden" template-variable="category_id" value="{category_id}" />
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -48,9 +48,9 @@ var db = require('./database'),
 | 
				
			|||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	Categories.getCategoryById = function(category_id, start, end, current_user, callback) {
 | 
						Categories.getCategoryById = function(category_id, start, end, current_user, callback) {
 | 
				
			||||||
		Categories.getCategoryData(category_id, function(err, categoryData) {
 | 
					
 | 
				
			||||||
			if (err) {
 | 
							function getCategoryData(next) {
 | 
				
			||||||
				return callback(err);
 | 
								Categories.getCategoryData(category_id, next);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		function getTopics(next) {
 | 
							function getTopics(next) {
 | 
				
			||||||
@@ -58,7 +58,16 @@ var db = require('./database'),
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		function getActiveUsers(next) {
 | 
							function getActiveUsers(next) {
 | 
				
			||||||
				Categories.getActiveUsers(category_id, next);
 | 
								Categories.getActiveUsers(category_id, function(err, uids) {
 | 
				
			||||||
 | 
									if(err) {
 | 
				
			||||||
 | 
										return next(err);
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
									user.getMultipleUserFields(uids, ['uid', 'username', 'userslug', 'picture'], next);
 | 
				
			||||||
 | 
								});
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							function getModerators(next) {
 | 
				
			||||||
 | 
								Categories.getModerators(category_id, next);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		function getSidebars(next) {
 | 
							function getSidebars(next) {
 | 
				
			||||||
@@ -71,59 +80,37 @@ var db = require('./database'),
 | 
				
			|||||||
			Categories.getPageCount(category_id, next);
 | 
								Categories.getPageCount(category_id, next);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			async.parallel([getTopics, getActiveUsers, getSidebars, getPageCount], function(err, results) {
 | 
							async.parallel({
 | 
				
			||||||
 | 
								'category': getCategoryData,
 | 
				
			||||||
 | 
								'topics': getTopics,
 | 
				
			||||||
 | 
								'active_users': getActiveUsers,
 | 
				
			||||||
 | 
								'moderators': getModerators,
 | 
				
			||||||
 | 
								'sidebars': getSidebars,
 | 
				
			||||||
 | 
								'pageCount': getPageCount
 | 
				
			||||||
 | 
							}, function(err, results) {
 | 
				
			||||||
			if(err) {
 | 
								if(err) {
 | 
				
			||||||
				return callback(err);
 | 
									return callback(err);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				var active_users = results[1],
 | 
					 | 
				
			||||||
					sidebars = results[2],
 | 
					 | 
				
			||||||
					pageCount = results[3];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			var category = {
 | 
								var category = {
 | 
				
			||||||
					'category_name': categoryData.name,
 | 
									'category_name': results.category.name,
 | 
				
			||||||
					'category_description': categoryData.description,
 | 
									'category_description': results.category.description,
 | 
				
			||||||
					'link': categoryData.link,
 | 
									'link': results.category.link,
 | 
				
			||||||
					'disabled': categoryData.disabled || '0',
 | 
									'disabled': results.category.disabled || '0',
 | 
				
			||||||
					'show_sidebar': 'show',
 | 
					 | 
				
			||||||
				'show_topic_button': 'inline-block',
 | 
									'show_topic_button': 'inline-block',
 | 
				
			||||||
					'no_topics_message': 'hidden',
 | 
					 | 
				
			||||||
				'topic_row_size': 'col-md-9',
 | 
									'topic_row_size': 'col-md-9',
 | 
				
			||||||
				'category_id': category_id,
 | 
									'category_id': category_id,
 | 
				
			||||||
					'active_users': [],
 | 
									'active_users': results.active_users,
 | 
				
			||||||
					'topics': results[0].topics,
 | 
									'moderators': results.moderators,
 | 
				
			||||||
					'nextStart': results[0].nextStart,
 | 
									'topics': results.topics.topics,
 | 
				
			||||||
					'pageCount': pageCount,
 | 
									'nextStart': results.topics.nextStart,
 | 
				
			||||||
 | 
									'pageCount': results.pageCount,
 | 
				
			||||||
				'disableSocialButtons': meta.config.disableSocialButtons !== undefined ? parseInt(meta.config.disableSocialButtons, 10) !== 0 : false,
 | 
									'disableSocialButtons': meta.config.disableSocialButtons !== undefined ? parseInt(meta.config.disableSocialButtons, 10) !== 0 : false,
 | 
				
			||||||
					'sidebars': sidebars
 | 
									'sidebars': results.sidebars
 | 
				
			||||||
			};
 | 
								};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				function getModerators(next) {
 | 
					 | 
				
			||||||
					Categories.getModerators(category_id, next);
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
				function getActiveUsers(next) {
 | 
					 | 
				
			||||||
					user.getMultipleUserFields(active_users, ['uid', 'username', 'userslug', 'picture'], next);
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
				if (!category.topics.length) {
 | 
					 | 
				
			||||||
					getModerators(function(err, moderators) {
 | 
					 | 
				
			||||||
						category.moderators = moderators;
 | 
					 | 
				
			||||||
						category.show_sidebar = 'hidden';
 | 
					 | 
				
			||||||
						category.no_topics_message = 'show';
 | 
					 | 
				
			||||||
			callback(null, category);
 | 
								callback(null, category);
 | 
				
			||||||
		});
 | 
							});
 | 
				
			||||||
				} else {
 | 
					 | 
				
			||||||
					async.parallel([getModerators, getActiveUsers], function(err, results) {
 | 
					 | 
				
			||||||
						category.moderators = results[0];
 | 
					 | 
				
			||||||
						category.active_users = results[1];
 | 
					 | 
				
			||||||
						category.show_sidebar = category.topics.length > 0 ? 'show' : 'hidden';
 | 
					 | 
				
			||||||
						callback(null, category);
 | 
					 | 
				
			||||||
					});
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			});
 | 
					 | 
				
			||||||
		});
 | 
					 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	Categories.getCategoryTopics = function(cid, start, stop, uid, callback) {
 | 
						Categories.getCategoryTopics = function(cid, start, stop, uid, callback) {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user