Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Who's Online
This discussion is related to the Who's Online addon.
Comments
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\"");
$q = "SELECT LUM_Role.Name FROM `LUM_User` LEFT JOIN `LUM_Role` USING (`RoleID`) WHERE UserID='".$Comment->AuthUserID."' LIMIT 1;"; $res = mysql_query($q); $row = mysql_fetch_array($res); $role = $row[0]; $role = str_replace(" ","",$role); $role = strtolower($role);
And then, on line 163 (my version anyway), this line:
$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:
$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.
$q = "SELECT LUM_Role.Name FROM `LUM_User` LEFT JOIN `LUM_Role` USING (`RoleID`) WHERE UserID='".$Comment->AuthUserID."' LIMIT 1;";
is the key. Would you give me some more clues on how to modify it?
function GetWhosOnline() { $s = $this->Context->ObjectFactory->NewContextObject($this->Context, "SqlBuilder"); $s->SetMainTable("User", "u"); $s->AddSelect(array("Name", "UserID", "DateLastActive", "Preferences","RoleID"), "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, "RoleID" => $rows['RoleID'])); } return $my_array; } }
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`;"; $res = mysql_query($q); $role = array(); while ($row = mysql_fetch_array($res)) { $tmp = $row[1]; $tmp = str_replace(" ","",$tmp); $role[$row[0]] = strtolower($tmp); }
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
I.E.
[ ] show currently online visitors
[ ] show everyone who visited in the last [15] mins
[ ] show everyone who visited today
$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
into1 DAY
to get a whole day.if ((in_array($Context->SelfUrl, array("categories.php", "index.php", "post.php", "comments.php")) && !isset($_GET['PageID']) || ($Context->SelfUrl == "index.php" && isset($_GET['PostBackAction']))) && $Context->Session->UserID > 0 && !$Context->Session->User->Preference("HideWhosOnline") ) {
To make it show count when not signed in, add this code to the end of the file (outside all other methods / ifs):
if ((in_array($Context->SelfUrl, array("categories.php", "index.php", "comments.php")) && !isset($_GET['PageID']) ) && $Context->Session->UserID == 0 ) { $ListName = $Context->GetDefinition("Who's Online"); $Panel->AddList($ListName,501); $online_list = $WhosOnline->GetWhosOnline(); $guest_count = $WhosOnline->GetGuestCount(); $phantom_count = 0; $user_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")) { $user_count++; } } if ($user_count > 0) { $user_string = "$user_count registered user"; if ($user_count > 1) $user_string .= "s"; $Panel->AddListItem($ListName,'','',$user_string); } 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,'','',$Context->Dictionary['None online']); } }