This extension will add a “Who’s Online� Menu option to the control panel, allowing users to see when other users are signed in and active on the boards. Please note that this extension adds a few more database queries and updates, so this could potentially degrade the performance of your server. This perfomance hit should be negligible for a reasonable number of users.
Other Requirements (if any):
Wanderer The Extensions update breaks at the apostrophe with this extension...
Who's Online 1.1
CheckingForUpdates
Error: Who'sOnline|[UNKNOWN]ExtensionStatusUnknown
Posted: Monday, 5 March 2007 at 8:26PM (AEDT)
Mark This can be fixed at the addon site level for the time being, but I'm going to implement a fix for the core as well so punctuation is acceptable.
Mark I've fixed this in subversion. I'm going to wait a day or two before releasing 1.1.2 in case some other things come up.
is this also the reason why I cannot enable this plugin after upgrading to vanilla 1.1? Its listed in the extensions list and I can check it but it does not enable.
nevermind replaced the two files anyhow and it works dandy.
skube Just wondering, anyone know of an easy way to have the names listed inline, rather than each per line? Trying to save space...
Yes I have. It was kinda hard, not knowing this system, but i figured it out. Don know if u consider this method a "hack", but it works.
1. Open the "extentions/WhosOnline/default.php" file
2. On line 150 (just before the line that says$Panel->AddList($ListName);
add the following line :$Panel->AddString("<div id='onlinenow'>",500);
3. On the next line change it to:$Panel->AddList($ListName,501);
4. 30 lines down (before the last curly bracket)
add this line:$Panel->AddString("</div>",502);
5. Save and close this file.
6. Create a "style.css" file in this extion folder and open it. Put this code there:<br /> <a href="/search?Search=%23onlinenow">#onlinenow</a> ul li ul {<br /> overflow:hidden;<br /> }<br /> <a href="/search?Search=%23onlinenow">#onlinenow</a> ul li ul li {<br /> width:auto;<br /> margin-right:4px;<br /> float:left;<br /> }<br />
7. Save the file.
Thats it.
Hope this is what u wanted
Update! I found out how to add style in an extention (been reading through other ppls extentions alot to try to learn.. )
$Head->AddStyleSheet('extensions/WhosOnline/style.css');
is the way. Just add it on the start of extentions/WhosOnline/default.php and put the style on point 6 in a style.css file and put it the same folder..
To the original poster / creater of this. Maybe you could incorporate this feature in the original with a setting in a config.php file. For instance a constant that says true or false; use same line format. If the original creater is inactive, I could clean up my code and make a newer version of this, but I dont wanna replace or add to with out permission..
When I click the download link above, the file that is downloaded still says it's version 1.1 of WhosOnline in the code. When I upload it to the server, the updates page still shows it's an old version, not 1.2.
yea i get that too. my guess is he forgot to update the version number in the default.php file :)
Wanderer They are both exactly the same apart from the version number, just change the version in your default file to 1.2 if you want.
Posted: Wednesday, 14 March 2007 at 6:56PM (AEDT)
LOL OK. Why an update with no...er...update?
Anyway, I changed the version number in the default file and now my extensions all show to be the current version. Thanks. :)
Uploaded version 1.2 of Who's Online with the correct version number.
It would be nice to have the capacity to see Who's Online connected to a certain permission level - ie., I would like to allow my users to see Who's Online, but not the anonymous guests.
It might also be nice to be able to place the list of users at the middle/bottom of the sidepanel, rather than at the top!
icouto - this doesn't display if you are not logged in
@Gauzy: doh! How silly do I feel... Bad example...
It might be nice, for instance, to let 'administrators' see who's online, but not general users.
@icouto - ah, yeah, i see what you mean now. not sure how to go about doing that, i imagine it's possible, but outside my realm of expertise.
If you look in the default.php file for this:
if (in_array($Context->SelfUrl, array("account.php", "categories.php", "comments.php", "index.php", "post.php", "search.php", "settings.php"))
&& $Context->Session->UserID > 0 && !$Context->Session->User->Preference("HideWhosOnline")) {
You could change it to
if (in_array($Context->SelfUrl, array("account.php", "categories.php", "comments.php", "index.php", "post.php", "search.php", "settings.php"))
&& $Context->Session->UserID > 0 && $Context->Session->RoleID == 4 && !$Context->Session->User->Preference("HideWhosOnline")) {
and it'l only display for users whose role ID is 4 (default admin role, you might need to change it)
important update on my hack .. I edited the original text. so look there.. the point is to use positioning on both addstring and addpanel..
btw.. Is anyone using it?
Can I ask a question here related to this add-on?
I just upgraded my forum to 1.1.2
Now, for some reason, it always says I have tons of guests. It may say 54 guests one minute, then 84 guests the next minute. I know I don't have that many people there. Is there some sort of error going on? Thanks.
sjeeps Hi,
I still can't see any guest count!
Only members name when they're signed in, so who to turn it so it show's guest as well as members?
Thanks
This addon is not workin for me. Back on March 6 there was a post about modifying 2 files, but now I don't see anything about what those files are.
I have vanilla 1.1.1, and whosonline 1.2?
I appreciate the help.
OK the upgrade to 1.2 fixed it all.. I thought I had done that.. but posting here I noticed not.... Whois is very important for my application...thanks for the work.
anybody else getting the bug that everything is displayed as being active "1 hour ago" in the title?
This seems to have fixed itself, which leads me to believe it was spambots. Who knows!
sjeeps Hi, I'm still having a problem to get the user's names listed inline, rather than each per line and Mr Do hack above didn't seem to work!
Any thoughts?
Thanks.
how doesnt it work? it works for me..
I think the problem is that I forgot to give you the line to add the style file? just put that css style into a css file allready active, at the bottom of vanilla.css in the styles folder for example..
sjeeps Ok... here is the default.php:
<?php
/*
Extension Name: Who's Online
Extension Url: http://www.thirty5.net/code/vanilla/whosonline/
Description: Adds a "who's online" list to the panel.
Version: 1.2
Author: David Knowles, Julien Cassignol, Michael Schieben
Author Url: mailto:dknowles2@gmail.com
Additional Author: Michael Schieben - michael@twoantennas.com (Adaption to Vanilla 1.0)
*/
$Context->Dictionary["MenuOptions"] = "Menu Options";
$Context->Dictionary["HideWhosOnline"] = "Hide the \"Who's Online\" panel";
$Context->Dictionary["Phantom"] = "Hide my username from the \"Who's Online\" panel";
class WhosOnline {
var $Name;
var $Context;
function WhosOnline(&$Context) {
$this->Name = "WhosOnline";
$this->Context = &$Context;
}
function GetWhosOnline() {
$s = $this->Context->ObjectFactory->NewContextObject($this->Context, "SqlBuilder");
$s->SetMainTable("User", "u");
$s->AddSelect(array("Name", "UserID", "DateLastActive", "Preferences"), "u");
$s->AddWhere("u", "DateLastActive", "", "DATE_SUB(NOW(), INTERVAL 5 MINUTE)", ">=", NULL, NULL, 0);
$result = $this->Context->Database->Select($s, $this->Name, "GetRecentUsers", "An error occurred while attempting to retrieve the requested information.");
if ($this->Context->Database->RowCount($result) == 0) {
return NULL;
} else {
$my_array = array();
while ($rows = $this->Context->Database->GetRow($result)) {
if ($rows["Preferences"]) {
$settings = unserialize($rows["Preferences"]);
if (array_key_exists("Phantom", $settings))
$phantom = ForceBool($settings["Phantom"], 0);
else
$phantom = false;
} else {
$phantom = false;
}
array_push($my_array, array("Name" => $rows["Name"], "UserID" => $rows["UserID"],
"DateLastActive" => $rows["DateLastActive"], "Phantom" => $phantom));
}
return $my_array;
}
}
function GetGuestCount() {
$s = $this->Context->ObjectFactory->NewContextObject($this->Context, "SqlBuilder");
$s->SetMainTable("IpHistory", "i");
$s->AddSelect("IpHistoryID", "i", "GuestCount", "COUNT");
$s->AddWhere("i", "UserID", "", 0, "=");
$s->AddWhere("i", "DateLogged", "", "DATE_SUB(NOW(), INTERVAL 1 MINUTE)", ">=", 'and', NULL, 0);
$result = $this->Context->Database->Select($s, $this->Name, "GetGuestCount", "An error occurred while attempting to retrieve the requested information.");
$row = $this->Context->Database->GetRow($result);
return $row["GuestCount"];
}
function GetNextIpLetter($my_ip) {
$s = $this->Context->ObjectFactory->NewContextObject($this->Context, "SqlBuilder");
$s->SetMainTable("IpHistory", "i");
$s->AddSelect("RemoteIp", "i");
$s->AddWhere("i", "UserID", "", 0, "=");
$s->AddWhere("i", "RemoteIp", "", "$my_ip([a-z])*$", "regexp");
$s->AddWhere("i", "DateLogged", "", "DATE_SUB(NOW(), INTERVAL 30 MINUTE)", ">=", 'and', NULL, 0);
$s->AddOrderBy("RemoteIp", "i", "desc");
$s->AddLimit(0, 1);
$result = $this->Context->Database->Select($s, $this->Name, "UpdateGuestLastActive", "An error occurred while logging user data.");
if ($this->Context->Database->RowCount($result) > 0) {
$row = $this->Context->Database->GetRow($result);
if (preg_match("/([a-z])+$/", $row["RemoteIp"], $ip_letter))
return ++$ip_letter[0];
else
return "a";
} else {
return "";
}
}
function GetIpHistoryID($my_ip) {
$s = $this->Context->ObjectFactory->NewContextObject($this->Context, "SqlBuilder");
$s->SetMainTable("IpHistory", "i");
$s->AddSelect("IpHistoryID", "i");
$s->AddWhere("i", "UserID", "", 0, "=");
$s->AddWhere("i", "RemoteIp", "", $my_ip, "=");
$s->AddOrderBy("IpHistoryID", "i", "desc");
$s->AddLimit(0, 1);
$result = $this->Context->Database->Select($s, $this->Name, "GetIpHistoryID",
"An error occurred while attempting to retrieve the requested information.");
$row = $this->Context->Database->GetRow($result);
return $row["IpHistoryID"];
}
function UpdateDateLastActive() {
$s = $this->Context->ObjectFactory->NewContextObject($this->Context, "SqlBuilder");
if (isset($_COOKIE['IpHistoryID'])) {
$s->SetMainTable("IpHistory", "i");
$s->AddWhere("i", "IpHistoryID", "", $_COOKIE['IpHistoryID'], "=");
$this->Context->Database->Delete($s, $this->Name, "UpdateDateLastActive", "An error occurred while deleting guest profile");
setcookie('IpHistoryID', '', time() - 3600);
}
$s->Clear();
$s->SetMainTable("User", "u");
$s->AddFieldNameValue("DateLastActive", "now()", 0);
$s->AddWhere("u", "UserID", "", $this->Context->Session->UserID, "=");
$result = $this->Context->Database->Update($s, $this->Name, "UpdateDateLastActive", "An error occurred while updating your account.");
}
function UpdateGuestLastActive() {
$s = $this->Context->ObjectFactory->NewContextObject($this->Context, "SqlBuilder");
if (isset($_COOKIE['IpHistoryID'])) {
$s->Clear();
$s->SetMainTable("IpHistory", "i");
$s->AddFieldNameValue("DateLogged", "now()", 0);
$s->AddWhere("i", "IpHistoryID", "", $_COOKIE['IpHistoryID'], "=");
$result = $this->Context->Database->Update($s, $this->Name, "UpdateGuestLastActive", "An error occurred while logging user data.");
} else {
$my_ip = GetRemoteIp(1);
$ip_letter = $this->GetNextIpLetter($my_ip);
$s->Clear();
$s->SetMainTable("IpHistory", "i");
$s->AddFieldNameValue("UserID", 0);
$s->AddFieldNameValue("RemoteIp", $my_ip . $ip_letter);
$s->AddFieldNameValue("DateLogged", "Now()", 0);
$this->Context->Database->Insert($s, $this->Name, "UpdateGuestLastActive", "An error occurred while logging user data.");
setcookie('IpHistoryID', $this->GetIpHistoryID($my_ip . $ip_letter));
}
}
}
$WhosOnline = $Context->ObjectFactory->NewContextObject($Context, "WhosOnline");
if (!in_array($Context->SelfUrl, array("signin.php", "leave.php", "post.php", "passwordrequest.php", "passwordreset.php"))) {
if ($Context->Session->UserID > 0)
$WhosOnline->UpdateDateLastActive();
else
$WhosOnline->UpdateGuestLastActive();
}
if (in_array($Context->SelfUrl, array("account.php", "categories.php", "comments.php", "index.php", "post.php", "search.php", "settings.php"))
&& $Context->Session->UserID > 0 && !$Context->Session->User->Preference("HideWhosOnline")) {
$ListName = $Context->GetDefinition("Who's Online");
$Panel->AddList($ListName);
$online_list = $WhosOnline->GetWhosOnline();
$guest_count = $WhosOnline->GetGuestCount();
$phantom_count = 0;
if ($online_list) {
foreach ($online_list as $name) {
if ($name["Phantom"]) {
$phantom_count++;
}
if (!$name["Phantom"] || !isset($name["Phantom"]) || $Context->Session->User->Permission("PERMISSION_WHOS_PHANTOM")) {
$TimePast = TimeDiff($Context, unixtimestamp($name["DateLastActive"]));
$Panel->AddListItem($ListName, $Context->GetDefinition($name["Name"]), "account.php?u=" . $name["UserID"],NULL,"title=\"$TimePast\"");
}
}
if ($phantom_count > 0) {
$phantom_string = "$phantom_count phantom user";
if ($phantom_count > 1)
$phantom_string .= "s";
$Panel->AddListItem($ListName,'','',$phantom_string);
}
if ($guest_count > 0) {
$guest_string = "$guest_count guest";
if ($guest_count > 1)
$guest_string .= "s";
$Panel->AddListItem($ListName,'','',$guest_string);
}
} else {
$Panel->AddListItem($ListName,'','',"Nobody's online.");
}
}
// Add the Who's Online setting to the forum preferences form
if ($Context->SelfUrl == "account.php" && $Context->Session->UserID > 0) {
$PostBackAction = ForceIncomingString("PostBackAction", "");
if ($PostBackAction == "Functionality") {
function PreferencesForm_AddWhosOnlinePreference(&$PreferencesForm) {
$PreferencesForm->AddPreference("MenuOptions", "HideWhosOnline", "HideWhosOnline", 0);
$PreferencesForm->AddPreference("MenuOptions", "Phantom", "Phantom", 0);
}
$Context->AddToDelegate("PreferencesForm",
"Constructor",
"PreferencesForm_AddWhosOnlinePreference");
}
}
?>
Could you please point out where to hack the code? Thank.
Look for the//////////// lines, its the code between those.<?php<br />/*<br />Extension Name: Who's Online<br />Extension Url: http://www.thirty5.net/code/vanilla/whosonline/<br />Description: Adds a "who's online" list to the panel.<br />Version: 1.2<br />Author: David Knowles, Julien Cassignol, Michael Schieben<br />Author Url: mailto:dknowles2@gmail.com<br /><br />Additional Author: Michael Schieben - michael@twoantennas.com (Adaption to Vanilla 1.0)<br /><br />*/<br />class WhosOnline {<br /> var $Name;<br /> var $Context;<br /><br /> function WhosOnline(&$Context) {<br /> $this->Name = "WhosOnline";<br /> $this->Context = &$Context;<br /> }<br /><br /> function GetWhosOnline() {<br /> $s = $this->Context->ObjectFactory->NewContextObject($this->Context, "SqlBuilder");<br /> $s->SetMainTable("User", "u");<br /> $s->AddSelect(array("Name", "UserID", "DateLastActive", "Preferences"), "u");<br /> $s->AddWhere("u", "DateLastActive", "", "DATE_SUB(NOW(), INTERVAL 5 MINUTE)", ">=", NULL, NULL, 0);<br /> $result = $this->Context->Database->Select($s, $this->Name, "GetRecentUsers", "An error occurred while attempting to retrieve the requested information.");<br /> if ($this->Context->Database->RowCount($result) == 0) {<br /> return NULL;<br /> } else { <br /> $my_array = array();<br /> while ($rows = $this->Context->Database->GetRow($result)) {<br /> if ($rows["Preferences"]) { <br /> $settings = unserialize($rows["Preferences"]);<br /> if (array_key_exists("Phantom", $settings))<br /> $phantom = ForceBool($settings["Phantom"], 0);<br /> else<br /> $phantom = false;<br /> } else { <br /> $phantom = false;<br /> }<br /> array_push($my_array, array("Name" => $rows["Name"], "UserID" => $rows["UserID"], <br /> "DateLastActive" => $rows["DateLastActive"], "Phantom" => $phantom));<br /> }<br /> return $my_array;<br /> }<br /> }<br /> <br /> function GetGuestCount() {<br /> $s = $this->Context->ObjectFactory->NewContextObject($this->Context, "SqlBuilder");<br /> $s->SetMainTable("IpHistory", "i");<br /> $s->AddSelect("IpHistoryID", "i", "GuestCount", "COUNT");<br /> $s->AddWhere("i", "UserID", "", 0, "=");<br /> $s->AddWhere("i", "DateLogged", "", "DATE_SUB(NOW(), INTERVAL 1 MINUTE)", ">=", 'and', NULL, 0);<br /> $result = $this->Context->Database->Select($s, $this->Name, "GetGuestCount", "An error occurred while attempting to retrieve the requested information.");<br /> $row = $this->Context->Database->GetRow($result);<br /> return $row["GuestCount"];<br /> }<br /><br /> function GetNextIpLetter($my_ip) { <br /> $s = $this->Context->ObjectFactory->NewContextObject($this->Context, "SqlBuilder");<br /> $s->SetMainTable("IpHistory", "i");<br /> $s->AddSelect("RemoteIp", "i");<br /> $s->AddWhere("i", "UserID", "", 0, "=");<br /> $s->AddWhere("i", "RemoteIp", "", "$my_ip([a-z])*$", "regexp");<br /> $s->AddWhere("i", "DateLogged", "", "DATE_SUB(NOW(), INTERVAL 30 MINUTE)", ">=", 'and', NULL, 0);<br /> $s->AddOrderBy("RemoteIp", "i", "desc");<br /> $s->AddLimit(0, 1);<br /> $result = $this->Context->Database->Select($s, $this->Name, "UpdateGuestLastActive", "An error occurred while logging user data.");<br /><br /> if ($this->Context->Database->RowCount($result) > 0) { <br /> $row = $this->Context->Database->GetRow($result);<br /> if (preg_match("/([a-z])+$/", $row["RemoteIp"], $ip_letter))<br /> return ++$ip_letter[0];<br /> else<br /> return "a";<br /> } else { <br /> return "";<br /> }<br /> }<br /><br /> function GetIpHistoryID($my_ip) {<br /> $s = $this->Context->ObjectFactory->NewContextObject($this->Context, "SqlBuilder");<br /> $s->SetMainTable("IpHistory", "i");<br /> $s->AddSelect("IpHistoryID", "i");<br /> $s->AddWhere("i", "UserID", "", 0, "=");<br /> $s->AddWhere("i", "RemoteIp", "", $my_ip, "=");<br /> $s->AddOrderBy("IpHistoryID", "i", "desc");<br /> $s->AddLimit(0, 1);<br /> $result = $this->Context->Database->Select($s, $this->Name, "GetIpHistoryID", <br /> "An error occurred while attempting to retrieve the requested information.");<br /> $row = $this->Context->Database->GetRow($result);<br /> return $row["IpHistoryID"];<br /> }<br /><br /> function UpdateDateLastActive() {<br /> $s = $this->Context->ObjectFactory->NewContextObject($this->Context, "SqlBuilder");<br /><br /> if (isset($_COOKIE['IpHistoryID'])) { <br /> $s->SetMainTable("IpHistory", "i");<br /> $s->AddWhere("i", "IpHistoryID", "", $_COOKIE['IpHistoryID'], "=");<br /> $this->Context->Database->Delete($s, $this->Name, "UpdateDateLastActive", "An error occurred while deleting guest profile");<br /> setcookie('IpHistoryID', '', time() - 3600);<br /> }<br /> $s->Clear();<br /> $s->SetMainTable("User", "u");<br /> $s->AddFieldNameValue("DateLastActive", "now()", 0);<br /> $s->AddWhere("u", "UserID", "", $this->Context->Session->UserID, "=");<br /> $result = $this->Context->Database->Update($s, $this->Name, "UpdateDateLastActive", "An error occurred while updating your account.");<br /> }<br /><br /> function UpdateGuestLastActive() {<br /> $s = $this->Context->ObjectFactory->NewContextObject($this->Context, "SqlBuilder");<br /> if (isset($_COOKIE['IpHistoryID'])) {<br /> $s->Clear();<br /> $s->SetMainTable("IpHistory", "i");<br /> $s->AddFieldNameValue("DateLogged", "now()", 0);<br /> $s->AddWhere("i", "IpHistoryID", "", $_COOKIE['IpHistoryID'], "=");<br /> $result = $this->Context->Database->Update($s, $this->Name, "UpdateGuestLastActive", "An error occurred while logging user data.");<br /> } else { <br /> $my_ip = GetRemoteIp(1);<br /> $ip_letter = $this->GetNextIpLetter($my_ip);<br /> $s->Clear();<br /> $s->SetMainTable("IpHistory", "i");<br /> $s->AddFieldNameValue("UserID", 0);<br /> $s->AddFieldNameValue("RemoteIp", $my_ip . $ip_letter);<br /> $s->AddFieldNameValue("DateLogged", "Now()", 0);<br /> $this->Context->Database->Insert($s, $this->Name, "UpdateGuestLastActive", "An error occurred while logging user data.");<br /> setcookie('IpHistoryID', $this->GetIpHistoryID($my_ip . $ip_letter));<br /> }<br /> }<br /><br />}<br />///////////////////////////////////////////////////<br />$Head->AddStyleSheet('extensions/WhosOnline/style.css');<br />///////////////////////////////////////////////////<br />$WhosOnline = $Context->ObjectFactory->NewContextObject($Context, "WhosOnline");<br /><br />if (!in_array($Context->SelfUrl, array("signin.php", "leave.php", "post.php", "passwordrequest.php", "passwordreset.php"))) { <br /> if ($Context->Session->UserID > 0)<br /> $WhosOnline->UpdateDateLastActive();<br /> else<br /> $WhosOnline->UpdateGuestLastActive();<br /> }<br />//, "search.php", "settings.php""account.php",<br />if (in_array($Context->SelfUrl, array("categories.php", "index.php", "post.php", "comments.php")) <br /> && $Context->Session->UserID > 0 && !$Context->Session->User->Preference("HideWhosOnline")) {<br /> $ListName = $Context->GetDefinition("Who's Online");<br /> ///////////////////////////////////////<br /> $Panel->AddString("<div id='onlinenow'>",500); <br /> $Panel->AddList($ListName,501); <br />//////////////////////////////////////// <br /> $online_list = $WhosOnline->GetWhosOnline();<br /> $guest_count = $WhosOnline->GetGuestCount();<br /> $phantom_count = 0;<br /> if ($online_list) {<br /> foreach ($online_list as $name) {<br /> if ($name["Phantom"]) { <br /> $phantom_count++;<br /> } <br /> if (!$name["Phantom"] || !isset($name["Phantom"]) || $Context->Session->User->Permission("PERMISSION_WHOS_PHANTOM")) {<br /> $TimePast = TimeDiff($Context, unixtimestamp($name["DateLastActive"]));<br /> $Panel->AddListItem($ListName, $Context->GetDefinition($name["Name"]), "account.php?u=" . $name["UserID"],NULL,"title=\"$TimePast\"");<br /> }<br /> }<br /> if ($phantom_count > 0) {<br /> $phantom_string = "$phantom_count phantom user";<br /> if ($phantom_count > 1)<br /> $phantom_string .= "s";<br /> $Panel->AddListItem($ListName,'','',$phantom_string);<br /> }<br /> if ($guest_count > 0) { <br /> $guest_string = "$guest_count guest";<br /> if ($guest_count > 1)<br /> $guest_string .= "s";<br /> $Panel->AddListItem($ListName,'','',$guest_string);<br /> }<br /> } else { <br /> $Panel->AddListItem($ListName,'','',$Context->Dictionary['None online']);<br /> }<br />//////////////////////////////////<br /> $Panel->AddString("</div>",502);<br />////////////////////////////////<br />}<br /><br />// Add the Who's Online setting to the forum preferences form<br />/*<br />if ($Context->SelfUrl == "account.php" && $Context->Session->UserID > 0) {<br /> $PostBackAction = ForceIncomingString("PostBackAction", "");<br /> if ($PostBackAction == "Functionality") {<br /> function PreferencesForm_AddWhosOnlinePreference(&$PreferencesForm) {<br /> $PreferencesForm->AddPreference("MenuOptions", "HideWhosOnline", "HideWhosOnline", 0);<br /> $PreferencesForm->AddPreference("MenuOptions", "Phantom", "Phantom", 0);<br /> }<br /><br /> $Context->AddToDelegate("PreferencesForm",<br /> "Constructor",<br /> "PreferencesForm_AddWhosOnlinePreference");<br /> }<br />}<br />*/<br />?>
And dont forget to make a style.css file in the WhosOnline folder with this contet:#onlinenow ul li ul {<br /> overflow:hidden;<br />}<br /><a href="/search?Search=%23onlinenow">#onlinenow</a> ul li ul li {<br /> width:auto;<br /> margin-right:4px;<br /> float:left;<br />}
sjeeps Ok thanks..
But the "who's online" has been moved to the bottom of the panel and still each user is show on a separate line!
So right now it's like that:
User one
user two
3 guest
And all I'm looking for is:
user one, user two etc.
3guest
:)
btw, there's a style.css file in the extension folder, thanks.
***Edit***
Never mind, I've this code in my vanilla.css file:
ol,ul,li {
list-style:none;
margin:0;
padding:0;
}
#Panel ul li {
width:200px !important;
line-height:24px;
padding:0 !important;
}
And I think that's what causing the problem! :(
so now it works?
sjeeps Yes thanks, it works fine.
I want to make the same mod as sjeeps, I've put the last code from Mr Do, but it´s still showing the list like user online.
I've created the style.css but....what can I make?
Mr Do's hack works fine for me. Did you put style.css in the WhosOnline folder?
I was wondering, would there be a way to add a character in order to separated users' names? Like a comma or something. It would be useful for users with a space in ther name.
sure, many ways. 1. make a small image of a comma and put it as background image no repeat on right on the #Panel ul li OR you can go into the code and hack some more, probably by changing the line $Panel->AddListItem($ListName, $Context->GetDefinition($name["Name"]), "account.php?u=" . $name["UserID"],NULL,"title=\"$TimePast\"");to$Panel->AddListItem($ListName, $Context->GetDefinition($name["Name"]).", ", "account.php?u=" . $name["UserID"],NULL,"title=\"$TimePast\"");Notice the difference is : .", "
Yes I put the style.css and so, but.... no response from the script.
@chimera: Not sure what to say budd. You need to discribe your situation better. In the whosonline folder, are there 2 files (default.php and styles.css)? Does the style file have this code it in: <a href="/search?Search=%23onlinenow">#onlinenow</a> ul li ul {<br /> overflow:hidden;<br />}<br /><a href="/search?Search=%23onlinenow">#onlinenow</a> ul li ul li {<br /> width:auto;<br /> margin-right:4px;<br /> float:left;<br />}
did you add/change all of the following 4 lines to the default.php file:$Head->AddStyleSheet('extensions/WhosOnline/style.css');<br />$Panel->AddString("<div id='onlinenow'>",500);<br />$Panel->AddList($ListName,501);<br />$Panel->AddString("</div>",502);
If you have still problems, whisper me an url so I can see your page
Thanks, changing the line works fine. However, the character is displayed even if the user is the last of the list. Looks like it's a pain to change this, so for now I've put a period instead of the comma :)
clever boy :P
I was having some problems with this working nicely with Friendly URL extension. When already in the account section (http://www.fngeeks.net/vanilla/account/) and then clicking on someone's name under Who's Online, I'd recieve a 404 File Not Found Error Message because it couldn't find the URL http://www.fngeeks.net/vanilla/account/account.php?u=2
They way I got it to work was with the following:
Edit: Deleted code. Found out the proper way to do it.
Alright, nix that. Went and researched this a bit more and NOW I think its working... I implemented the GetUrl() function so that it would handle both systems properly... I need someone to test this on a non-Friendly URL install.
EDIT: UPDATED AGAIN (4/30/07)
Find:$Panel->AddListItem($ListName, $Context->GetDefinition($name["Name"]), "account.php?u=" . $name["UserID"],NULL,"title=\"$TimePast\"");
Replace with:$Panel->AddListItem($ListName, $Context->GetDefinition($name["Name"]), GetUrl($Context->Configuration, 'account.php', '', 'u', $name["UserID"]), NULL, "title=\"$TimePast\"");
I just updated the above code. Sorry to keep changing things up like this.
I was trying to add color depending on role to the online users' list. I tried mimicking the dojo add-on, but can't seem to do it right :( Anyone care to help?
hm.. ok let me point you in the right direction. Ultimatly you should modify the getWhosOnline function to also retrieve the users role, I dont have time just now, but you need these lines: $q = "SELECT LUM_Role.Name FROM `LUM_User` LEFT JOIN `LUM_Role` USING (`RoleID`) WHERE UserID='".$Comment->AuthUserID."' LIMIT 1;";<br /> $res = mysql_query($q);<br /> $row = mysql_fetch_array($res);<br /> $role = $row[0];<br /> $role = str_replace(" ","",$role);<br /> $role = strtolower($role);
And then, on line 163 (my version anyway), this line: <br /> $Panel->AddListItem($ListName, $Context->GetDefinition($name["Name"]), "account.php?u=" . $name["UserID"],NULL,"title=\"$TimePast\"");
Needs to be modified to add the class containing the color, like so: <br /> $Panel->AddListItem($ListName, $Context->GetDefinition($name["Name"]), "account.php?u=" . $name["UserID"],NULL,"title=\"$TimePast\" class=\"$role\"");
Note, that you will also need to add a stylesheet for each role, by following the rules given in the Dojo Role Add On.
If you can, I'd recommend taking the time to also make those links Friendly URL compliant by using the GetUrl() function as I posted above.
Thanks Mr. Do! You know, I was already doing the second part right!, which makes me kind of proud because I'm no good at this. The "retrieving" part, though, I really didn't know where to start, and now the problem is that just cutting and pasting won't do. I'm guessing this first line<br /> $q = "SELECT LUM_Role.Name FROM `LUM_User` LEFT JOIN `LUM_Role` USING (`RoleID`) WHERE UserID='".$Comment->AuthUserID."' LIMIT 1;";<br />
is the key. Would you give me some more clues on how to modify it?
ok here is what you do. Change GetWhosOnline function to this: function GetWhosOnline() {<br /> $s = $this->Context->ObjectFactory->NewContextObject($this->Context, "SqlBuilder");<br /> $s->SetMainTable("User", "u");<br /> $s->AddSelect(array("Name", "UserID", "DateLastActive", "Preferences","RoleID"), "u");<br /> $s->AddWhere("u", "DateLastActive", "", "DATE_SUB(NOW(), INTERVAL 5 MINUTE)", ">=", NULL, NULL, 0);<br /> $result = $this->Context->Database->Select($s, $this->Name, "GetRecentUsers", "An error occurred while attempting to retrieve the requested information.");<br /> if ($this->Context->Database->RowCount($result) == 0) {<br /> return NULL;<br /> } else { <br /> $my_array = array();<br /> while ($rows = $this->Context->Database->GetRow($result)) {<br /> if ($rows["Preferences"]) { <br /> $settings = unserialize($rows["Preferences"]);<br /> if (array_key_exists("Phantom", $settings))<br /> $phantom = ForceBool($settings["Phantom"], 0);<br /> else<br /> $phantom = false;<br /> } else { <br /> $phantom = false;<br /> }<br /> array_push($my_array, array("Name" => $rows["Name"], "UserID" => $rows["UserID"], <br /> "DateLastActive" => $rows["DateLastActive"], "Phantom" => $phantom, "RoleID" => $rows['RoleID']));<br /> }<br /> return $my_array;<br /> }<br /> }Notice how I now retrieve the RoleID. Next step is to retrieve the Role names. You do this with these lines, that you place around line 160. Directly after the if ($online_list) { line: $q = "SELECT RoleID, Name FROM `LUM_Role`;";<br /> $res = mysql_query($q); $role = array();<br /> while ($row = mysql_fetch_array($res)) {<br /> $tmp = $row[1];<br /> $tmp = str_replace(" ","",$tmp);<br /> $role[$row[0]] = strtolower($tmp); <br /> }
Next step is change the add list like so: $Panel->AddListItem($ListName, $Context->GetDefinition($name["Name"]), GetUrl($Context->Configuration, 'account.php', '', 'u', $name["UserID"]), NULL, "title=\"$TimePast\" class=\"".$role[$name['RoleID']]."\"");
The css bit remains the same. Hope this gets you to the finish line :)
skube How about adding the ability to see who was online? And have a preference to specify how far in the past to display?
I.E.
[ ] show currently online visitors
[ ] show everyone who visited in the last [15] mins
[ ] show everyone who visited today
@skube: it is allready doing that. I mean its checking who was online in the last X minutes. There is no way for it to know who is reading a page at that exact moment. It checks for the last time it got a request from said user. It should be possible to do what you ask without much trouble
Unless you want something like a Settings preference, or a per-user preference, you can just edit the code of the extension. On line 31 it says $s->AddWhere("u", "DateLastActive", "", "DATE_SUB(NOW(), INTERVAL 5 MINUTE)", ">=", NULL, NULL, 0);
Just change the 5 to the amount of minutes it should check for, or change 5 MINUTE into 1 DAY to get a whole day.
Addons are custom features that you can add to your Vanilla forum. Addons are created by our community of developers and people like you!
We review addons to make sure they are safe and don't cause bugs. An addon is considered to be "Vanilla Approved" once our review process is complete.