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



  • Options
    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)

    $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\"");
  • Options
    I just updated the above code. Sorry to keep changing things up like this.
  • Options
    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?
  • Options
    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;"; $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.
  • Options
    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.
  • Options
    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

    $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?
  • Options
    ok here is what you do. Change GetWhosOnline function to this:
    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 :)
  • Options
    How about adding the ability to see who was online? And have a preference to specify how far in the past to display?

    [ ] show currently online visitors
    [ ] show everyone who visited in the last [15] mins
    [ ] show everyone who visited today
  • Options
    @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
  • Options
    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.
  • Options
    hi! i noticed, that users who logged out are also seen as online until the 5 minute timeout. how about adding an "is_online" column, which is also set to true in the UpdateDateLastActive() function. after logout is_online is set to false. in the GetWhosOnline() we add date_sub(...) and is_online=true how about this idea?
  • Options
    What determines the order of the Who's Online list? It's not alphabetized and I'm always on top of my list.
  • Options
    Most recent activity I think. Everyone will probably be at the top of their own list.
  • Options
    Any chance of someone packing all the enhancements/bugfixes up and making an unofficial release? Or better still, just getting it updated on the addons site :)
  • Options
    Is there a way to show the total members and guests count not just when someone is signed in?
  • Options
    Ok to make whos online appear on pages that use postbackaction (ie PageMaker addon) you need to change the big if statement to this: 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']); } }
  • Options
    Go on Mr Do - package up all the fixes/enhancements and create an unofficial update, be a saint ;)
  • Options
    With an option for the inline names display please ;)
  • Options
    hehe okey. i will look into it latertoday. but how/where do I upload such a file? Since im not the OP, I cant edit his stuff.
  • Options
    Just pop it on your own webspace and leave a link in here, then a mod can update the official one if they want. If you don't have spac eyou can pop it on, just email me and I'll host it.
Sign In or Register to comment.