-
Notifications
You must be signed in to change notification settings - Fork 33
Added option to have active users similar to standard forum software #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dwendt
wants to merge
6
commits into
NodeBB:master
Choose a base branch
from
dwendt:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f84ff73
Added option to have active users similar to standard forum software
93fe61d
Merged to latest upstream.
8325199
Merged with upstream.
462721b
Fixed option to display all online users in activeusers.
5128e5e
Fix relative path for recent posts.
9ee7c2f
converted spaces to tabs and got rid of some residual junk.
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,7 @@ | |
var templatesToLoad = [ | ||
"recentreplies.tpl", "activeusers.tpl", "moderators.tpl", "forumstats.tpl", "recentposts.tpl", "recenttopics.tpl", | ||
"categories.tpl", "populartags.tpl", | ||
"admin/categorywidget.tpl", "admin/forumstats.tpl", "admin/html.tpl", "admin/text.tpl", "admin/recentposts.tpl", | ||
"admin/categorywidget.tpl", "admin/activeusers.tpl", "admin/forumstats.tpl", "admin/html.tpl", "admin/text.tpl", "admin/recentposts.tpl", | ||
"admin/recenttopics.tpl", "admin/defaultwidget.tpl", "admin/categorieswidget.tpl", "admin/populartags.tpl" | ||
]; | ||
|
||
|
@@ -101,8 +101,31 @@ | |
} | ||
|
||
var html = Widget.templates['activeusers.tpl'], cidOrtid; | ||
|
||
var match; | ||
if (widget.data.cid) { | ||
if (widget.data.global) { | ||
async.parallel({ | ||
users: function(next) { | ||
user.getUsersFromSet('users:online', 0, 49, next); | ||
}, | ||
isAdministrator: function(next) { | ||
user.isAdministrator(widget.uid, next); | ||
} | ||
}, function(err, results) { | ||
if (err) { | ||
return getUserData(err); | ||
} | ||
|
||
if (!results.isAdministrator) { | ||
results.users = results.users.filter(function(user) { | ||
return user && user.status !== 'offline'; | ||
}); | ||
} | ||
|
||
results.users = results.users.map(function(a) { return a.uid; }); | ||
getUserData(err, results.users); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no need to call this again since the results.users is an array of full user objects. can remove this line and the map above it and call
|
||
}); | ||
} else if (widget.data.cid) { | ||
cidOrtid = widget.data.cid; | ||
categories.getActiveUsers(cidOrtid, getUserData); | ||
} else if (widget.area.url.indexOf('topic') === 0) { | ||
|
@@ -214,8 +237,8 @@ | |
{ | ||
widget: "activeusers", | ||
name: "Active Users", | ||
description: "List of active users in a category.", | ||
content: Widget.templates['admin/categorywidget.tpl'] | ||
description: "List of active users, optionally in a category.", | ||
content: Widget.templates['admin/activeusers.tpl'] | ||
}, | ||
{ | ||
widget: "moderators", | ||
|
@@ -264,6 +287,5 @@ | |
callback(null, widgets); | ||
}; | ||
|
||
|
||
module.exports = Widget; | ||
}(module)); | ||
}(module)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<label> | ||
Include All Users: <input name="global" type="checkbox"><br /> | ||
<small>Active users will include all online users(regardless of current category).</small> | ||
</label> | ||
<br /> | ||
<label> | ||
Custom Category:<br /> | ||
<small>Leave blank to to dynamically pull from current category</small> | ||
</label> | ||
<input type="text" class="form-control" name="cid" placeholder="0" /> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this already returns a list of user objects so no need to call getUserData again