/*
 * Global server wide users list handling
 */
Ape.addEvent('adduser', function(user) {
	var name = user.prop('name');
	
	if(typeof name == "string"){
		name = name.toLowerCase();
		userlist[name] = user;
	}
});

Ape.addEvent('deluser', function(user) {
	var name = user.prop('name');
	
	if(typeof name == "string"){
		name = name.toLowerCase();
		delete userlist[name];
	}
});

/*
 * Global server wide channel's users counter
 */
Ape.addEvent("mkchan", function(channel) {
	//Create users property	
	channel.users = {};
	
	channel.prop("userCount", 0);
});

Ape.addEvent("beforeJoin", function(user, channel) {
	channel.prop("userCount", parseInt(channel.prop("userCount")) + 1);
	
	channel.users[user.prop("pubid")] = user;
	
	user.channels[channel.prop("name")] = channel;
	//Ape.log(channel.userCount +" users In channel "+ channel.getProperty("name"));
});

Ape.addEvent("left", function(user, channel) {
	channel.prop("userCount", parseInt(channel.prop("userCount")) - 1);
	
	delete channel.users[user.prop("pubid")];
	delete user.channels[channel.prop("name")];
	//Ape.log(channel.userCount +" users In channel "+ channel.getProperty("name"));
});

Ape.addEvent("beforeJoin", function(user, channel) {
	/*
	Ape.log("========= TEST ==========");
	Ape.log("========= User ==========");
	Ape.log(user.prop("name"));
	Ape.log(user.prop());
	Ape.log("======== Channel ========");
	Ape.log(channel.prop("name"));
	Ape.log(channel.prop());
	Ape.log("=======================");
	*/
});

@@ -521,41 +521,8 @@
 %7B%7D;%0A
-%09%0A%09channel.prop(%22userCount%22, 0);%0A
 %7D);%0A
@@ -579,79 +579,8 @@
 ) %7B%0A
-%09channel.prop(%22userCount%22, parseInt(channel.prop(%22userCount%22)) + 1);%0A%09%0A
 %09cha
@@ -672,713 +672,147 @@
 el;%0A
-%09//Ape.log(channel.userCount +%22 users In channel %22+ channel.getProperty(%22name%22));%0A%7D);%0A%0AApe.addEvent(%22left%22, function(user, channel) %7B%0A%09channel.prop(%22userCount%22, parseInt(channel.prop(%22userCount%22)) - 1);%0A%09%0A%09delete channel.users%5Buser.prop(%22pubid%22)%5D;%0A%09delete user.channels%5Bchannel.prop(%22name%22)%5D;%0A%09//Ape.log(channel.userCount +%22 users In channel %22+ channel.getProperty(%22name%22));%0A%7D);%0A%0AApe.addEvent(%22beforeJoin%22, function(user, channel) %7B%0A%09/*%0A%09Ape.log(%22========= TEST ==========%22);%0A%09Ape.log(%22========= User ==========%22);%0A%09Ape.log(user.prop(%22name%22));%0A%09Ape.log(user.prop());%0A%09Ape.log(%22======== Channel ========%22);%0A%09Ape.log(channel.prop(%22name%22));%0A%09Ape.log(channel.prop());%0A%09Ape.log(%22=======================%22);%0A%09*/%0A%7D);%0A
+%7D);%0A%0AApe.addEvent(%22left%22, function(user, channel) %7B%0A%09delete channel.users%5Buser.prop(%22pubid%22)%5D;%0A%09delete user.channels%5Bchannel.prop(%22name%22)%5D;%0A%7D);

remove usercount property from channel objects