Sort Chat Bar So Online Users Are On Top

Roger Ghostraven Posted in Technical Support 7 years ago

Is there a way to sort the right hand chat bar so online users appear at the top?

Replies
German Michael Zülsdorff Replied 7 years ago

I have transformed your idea into a pull request now. ( see https://github.com/opensource-socialnetwork/opensource-socialnetwork/pull/1154/commits/c46cba01135715893b7c0c3c50b3be1bfed3247c ) If it's getting accepted, it'll become part of the next release.

Regarding your PHP knowledge: No one of us was born with any PHP skills available. The more important it is - if you're really interested in coding - to have a working error logging environment. You can start with simple statements like error_log("hey, this is line 153"); to get an idea of the program flow for example. And you should contact your provider, if the output doesn't appear in your log file with Ossn Error Reporting turned ON.

us Roger Ghostraven Replied 7 years ago

Zet Man,

Thank you for the reply. I'll have to admit here I'm lost. I've stared at that page for hours trying to figure it out. My background is in network admin but I'm slowly picking up PHP knowledge and I like finding things out for myself or being pointed in the right direction and finding the right answer. Unfortunately this time I am way out of my depth of understanding so for now, until my skills improve, I think I'm going to table this idea. But thank you again for the help.

German Michael Zülsdorff Replied 7 years ago

No. If you'll have a look at the sort manual page ( http://php.net/manual/en/function.sort.php )

you'll notice that this function is expecting an array as the first paramater, and a sorting type like SORT_NUMERIC as the second parameter.
In other words: this function has no option at all to specify a specific element the sort should be based on. Search the web for sorting multidimensional arrays, as $all is an arry of member records each having another array of 4 elements inside. (see code above)

us Roger Ghostraven Replied 7 years ago

I have error reporting turned on but there is no error_log in my root directory. Is my code at least right and should I be looking somewhere else?

I appreciate the help.

German Michael Zülsdorff Replied 7 years ago

Did you have a look into your error_log file?

us Roger Ghostraven Replied 7 years ago

Zet Man,

I think my sort is wrong, this is what I have on line 153:

sort ( $all , "status");

But the users are still mixed up among online and offline.

German Michael Zülsdorff Replied 7 years ago

Yes, you may sort $all one line 153 of the OssnChat class by "status" before returning.