Registered users now have rank 1, guests' names are grey

Any new registrations will set global_rank=1 in the database
If you wish to upgrade, run "UPDATE `registrations` SET `global_rank`=1 WHERE `global_rank`=0" on your MySQL database
This commit is contained in:
calzoneman 2013-04-17 13:29:52 -05:00
parent e9d3fa83e4
commit 8a8838a58d
6 changed files with 49 additions and 38 deletions

View File

@ -55,7 +55,7 @@ exports.register = function(name, pw) {
return false;
}
var hash = bcrypt.hashSync(pw, 10);
var query = "INSERT INTO registrations VALUES (NULL, '{1}', '{2}', 0)"
var query = "INSERT INTO registrations VALUES (NULL, '{1}', '{2}', 1)"
.replace(/\{1\}/, name)
.replace(/\{2\}/, hash);
var results = db.querySync(query);

View File

@ -999,20 +999,22 @@ Channel.prototype.filterMessage = function(msg) {
return msg;
}
Channel.prototype.sendMessage = function(username, msg, msgclass) {
Channel.prototype.sendMessage = function(username, msg, msgclass, data) {
// I don't want HTML from strangers
msg = msg.replace(/</g, "&lt;").replace(/>/g, "&gt;");
msg = this.filterMessage(msg);
this.sendAll("chatMsg", {
var msgobj = {
username: username,
msg: msg,
msgclass: msgclass
});
this.chatbuffer.push({
username: username,
msg: msg,
msgclass: msgclass
});
};
if(data) {
for(var key in data) {
msgobj[key] = data[key];
}
}
this.sendAll("chatMsg", msgobj);
this.chatbuffer.push(msgobj);
if(this.chatbuffer.length > 15)
this.chatbuffer.shift();
this.logger.log("<" + username + "." + msgclass + "> " + msg);

View File

@ -23,6 +23,13 @@ function handle(chan, user, msg) {
chan.sendMessage(user.name, msg.substring(5), "shout");
}
}
else if(msg.indexOf("/m ") == 0) {
if(user.rank >= Rank.Moderator) {
chan.sendMessage(user.name, msg.substring(3), "modflair", {
modflair: user.rank
});
}
}
else if(msg.indexOf("/kick ") == 0) {
handleKick(chan, user, msg.substring(6).split(" "));
}

View File

@ -83,7 +83,7 @@
}
.userlist_guest {
color: #aaaaaa;
color: #888888;
}
.action {

View File

@ -178,7 +178,7 @@ function initCallbacks() {
var name = users[i].children[1].innerHTML;
// Reformat user
if(name == data.name) {
fmtUserlistItem(users[i], data.rank, data.leader);
formatUserlistItem(users[i], data.rank, data.leader);
}
}
});

View File

@ -23,7 +23,7 @@ function addUser(name, rank, leader) {
var div = $("<div/>").attr("class", "userlist_item");
var flair = $("<span/>").appendTo(div);
var nametag = $("<span/>").text(name).appendTo(div);
fmtUserlistItem(div[0], rank, leader);
formatUserlistItem(div[0], rank, leader);
addUserDropdown(div, name);
var users = $("#userlist").children();
for(var i = 0; i < users.length; i++) {
@ -37,15 +37,10 @@ function addUser(name, rank, leader) {
}
// Format a userlist entry based on a person"s rank
function fmtUserlistItem(div, rank, leader) {
function formatUserlistItem(div, rank, leader) {
var name = div.children[1];
$(name).removeClass();
if(rank >= Rank.Siteadmin)
$(name).attr("class", "userlist_siteadmin");
else if(rank >= Rank.Owner)
$(name).attr("class", "userlist_owner");
else if(rank >= Rank.Moderator)
$(name).attr("class", "userlist_op");
$(name).addClass(getNameColor(rank));
var flair = div.children[0];
// denote current leader with a star
@ -57,6 +52,19 @@ function fmtUserlistItem(div, rank, leader) {
}
}
function getNameColor(rank) {
if(rank >= Rank.Siteadmin)
return "userlist_siteadmin";
else if(rank >= Rank.Owner)
return "userlist_owner";
else if(rank >= Rank.Moderator)
return "userlist_op";
else if(rank == Rank.Guest)
return "userlist_guest";
else
return "";
}
// Adds a dropdown with user actions (promote/demote/leader)
function addUserDropdown(entry, name) {
$(entry).find(".dropdown").remove();
@ -191,30 +199,24 @@ function formatChatMessage(data) {
}
}
}
var name = $("<span/>").appendTo(div);
$("<strong/>").text("<" + data.username + "> ").appendTo(name);
var message = $("<span/>").appendTo(div);
message[0].innerHTML = data.msg;
if(data.msgclass == "action") {
var message = $("<span/>")
.addClass("action")
.appendTo(div);
name.remove();
message.addClass("action");
message[0].innerHTML = data.username + " " + data.msg;
}
else if(data.msgclass == "drink") {
if(data.msgclass == "drink") {
div.addClass("drink");
var name = $("<span/>");
$("<strong/>").text("<" + data.username + "> ").appendTo(name);
var message = $("<span/>");
message[0].innerHTML = data.msg;
name.appendTo(div);
message.appendTo(div);
}
else {
var name = $("<span/>");
$("<strong/>").text("<" + data.username + "> ").appendTo(name);
if(data.msgclass == "shout")
if(data.msgclass == "shout") {
message.addClass("shout");
name.addClass("shout");
var message = $("<span/>").addClass(data.msgclass);
message[0].innerHTML = data.msg;
name.appendTo(div);
message.appendTo(div);
}
if(data.modflair) {
name.addClass(getNameColor(data.modflair));
}
return div;
}