How to add to adopts_online?

Forum
Last Post
Threads / Messages

GeneticAlpha

Loving Mysidia!
Member
Joined
May 24, 2020
Messages
287
Points
18
Age
31
Location
Tennessee
Mysidian Dollar
13,377
How can I get adopts_online to have user's uid? I noticed now that I got rid of usernames being seen and use the uid or nicknames for members to be looked up, if you go to their profile, it shows them offline. But if I switch the links to usernames, it works right and shows online if they're online.

For example, if you look up a admin, and hover over their name, the address is: /profile/view/1
and it goes to the profile just fine using the uid, but shows them offline.

If I switch the link back to: /profile/view/Micolai
the username, it goes to profile and shows them online if they are.

I assumed the fix was to get adopts_online user's to have uids?
 
Last edited:
The reason it displays username is that, the user may be a guest so back then I felt it was better this way. Of course, you can change it to user id, and set the id to 0 or null if its a guest.
 
The reason it displays username is that, the user may be a guest so back then I felt it was better this way. Of course, you can change it to user id, and set the id to 0 or null if its a guest.
Hmm. I'm worried about breaking it if I mess with it haha. Is there an easier fix to my issue? Like I said before, if you click a link to a profile and it's profile/view/username
it works and the user shows online.
If I do
profile/view/uid
it works but shows user offline.
So I guess it's a minor issue, but would be nice for it to work with uid and not only with username.
 
Well for Mys v1.3.5, find this code in file /classes/class_member.php:

PHP:
    public function getonlineimg(){
        $mysidia = Registry::get("mysidia");
        $online = $mysidia->db->select("online", array(), "username = '{$this->username}'")->fetchObject();
        if(is_object($online)) $onlineimg = "<img src='templates/icons/user_online.gif'>";
        else $onlineimg = "<img src='templates/icons/user_offline.gif'>";
        return $onlineimg;
    }

Replace by:

PHP:
    public function getonlineimg(){
        $mysidia = Registry::get("mysidia");
        $online = $mysidia->db->select("online", array(), "uid = '{$this->uid}'")->fetchObject();
        if(is_object($online)) $onlineimg = "<img src='templates/icons/user_online.gif'>";
        else $onlineimg = "<img src='templates/icons/user_offline.gif'>";
        return $onlineimg;
    }

Lets see if it will fix your issue.
 
Well for Mys v1.3.5, find this code in file /classes/class_member.php:

PHP:
    public function getonlineimg(){
        $mysidia = Registry::get("mysidia");
        $online = $mysidia->db->select("online", array(), "username = '{$this->username}'")->fetchObject();
        if(is_object($online)) $onlineimg = "<img src='templates/icons/user_online.gif'>";
        else $onlineimg = "<img src='templates/icons/user_offline.gif'>";
        return $onlineimg;
    }

Replace by:

PHP:
    public function getonlineimg(){
        $mysidia = Registry::get("mysidia");
        $online = $mysidia->db->select("online", array(), "uid = '{$this->uid}'")->fetchObject();
        if(is_object($online)) $onlineimg = "<img src='templates/icons/user_online.gif'>";
        else $onlineimg = "<img src='templates/icons/user_offline.gif'>";
        return $onlineimg;
    }

Lets see if it will fix your issue.
Hm, seems to not of fixed it. >_< It seems to work if you look at your own public profile, just not if you look at someone elses'.
 
@Hall of Famer I think I figured something out but I had a question. I know it says $online is the call for if a user is online, but is there a call for if they're offline? I tried $offline but my thing didn't work, and I think it should. I need something to look and see if the user is offline. I can only get it to recognize if they're online. I'm trying to set up a if case that says if it recognizes them as on, display online, if it recognizes them as off, display, this, etc.
 
@Hall of Famer I think I figured something out but I had a question. I know it says $online is the call for if a user is online, but is there a call for if they're offline? I tried $offline but my thing didn't work, and I think it should. I need something to look and see if the user is offline. I can only get it to recognize if they're online. I'm trying to set up a if case that says if it recognizes them as on, display online, if it recognizes them as off, display, this, etc.

I dont think theres a direct way to check if a user is offline, but clearly a user is offline if he/she isnt online. So if you have a list of online users, just check if the user is in the online list. If not, then you know he/she must be offline.
 
I dont think theres a direct way to check if a user is offline, but clearly a user is offline if he/she isnt online. So if you have a list of online users, just check if the user is in the online list. If not, then you know he/she must be offline.
How could I go about doing that? This was the original code that was only displaying the user as always offline:

$line = $mysidia->db->select("online", array("username"), "username = '{$mysidia->input->get("user")}'")->fetchColumn();
if($line == $mysidia->input->get("user")){$online = "<font color=green>Currently working</font>";}
else{$online = '<font color=red>Off work</font>';}

and I recently tried doing this and now it always displays online:

if ($line == "$online"){
$document->add(new Comment("<p>Online Status: <font color=green>Currently working</font></p>"));
}
elseif ($line == $mysidia->input->get("user")){ $online =
$document->add(new Comment("<p>Online Status: <font color=red>Off work</font></p>"));
}

$line = $mysidia->db->select("online", array("username"), "username = '{$mysidia->input->get("user")}'")->fetchColumn();
 
What is "$online"? It seems that you are displaying a variable in a string, this doesnt look like logical PHP code at all. Do you mean "online" without the dollar sign $?
 
To be honest I'm not sure haha I had help getting this code but don't remember where. The $online actually works by displaying the online, if I change it to online it doesn't work anymore and the whole code disappears.

I think it would be less hassle if I just deleted the online status from public profiles since the online list shows if a user is on anyway, and not worry about the profile showing status.
 

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,277
Messages
33,119
Members
1,602
Latest member
BerrieMilk
BETA

Latest Threads

Latest Posts

Top