Logged out user data

Permalink
I am working on a users online block which will count the number of users logged into the site and display them in a list. The block should delete a user from the list once he/she has logged out of the site. My problem is I do not know which session data or function to use to verify that a user has logged out.

Please help

oneil1
 
Mnkras replied on at Permalink Reply
Mnkras
the discussion package has that functionality
oneil1 replied on at Permalink Reply
oneil1
Thanks for the response Mnkras but I do not understand what you mean.
Mnkras replied on at Permalink Reply
Mnkras
The DIscussion package in the Marketplace has that in it, if you want to write it, i would fetch the data from the table Users and the column lastonline and show if they were online in like the last 15 minutes you shouldn't need to use session data
oneil1 replied on at Permalink Reply
oneil1
ok. I understand now. What I want to implement however is something like the feature on facebook which allows a user to see all his friends online so that a message can be sent in real time. A 15 minutes delay will not facilitate this. Do you have any other suggestions as to how I may accomplish this?

Can I for instance, create a field in the user table which stores an online/offline variable then create a function which updates this variable when the user logs on or off?

I would then create a block which pulls the online status for all users on the site.
ryan replied on at Permalink Reply
ryan
oneil1 replied on at Permalink Reply
oneil1
I may have to do that..although I wanted a simple way to do what I wanted. But is it at all possible with the tools available.
Mnkras replied on at Permalink Reply
Mnkras
yea, the comet package is probably the easiest, you could set the timer to like 1 second, but i would do most of it in javascript though, or ajax
wizardontherun replied on at Permalink Reply
wizardontherun
Sorry, but i think its pretty bad when a user is looking for some in site on what others have maybe tried or did to complete a task that they would like to integrate with their own block/script without starting from scratch, and just send them over to the market place to buy something that's not what they were looking for to start. Community Forums used to be Community Help, that's were must started from learning the C5 framework.
oneil1 replied on at Permalink Reply
oneil1
Thanks for the encouragement to dig deeper into my quest for a solution wizard
jgarcia replied on at Permalink Reply
jgarcia
First, wizard, I don't think Mnkras or ryan were wrong for their suggestions. If the functionality already exists, than why re-invent the wheel (even if you have to drop a few bucks)? Yes, I understand that (apparently) neither of those packages are the solution that oneil1 was looking for, they were still trying to help.

That said, I think the following will help oneil - check out the API docs (you may have already, but just in case):http://www.concrete5.org/api/

Click "Users" in the dropdown in the upper right. Then you will see a list of all of the classes and functions associated with users in c5. It seems like the better way to do this (rather than store the currently logged in users in a table) would be to just run a script in the block itself that checks for all users online using functions that are probably already built-in to c5. Checking out /concrete/controllers/dashboard/users/search.php could probably be pretty helpful. Also, there is an "isLoggedIn()" function for the user class, that I'm sure would be pretty helpful.

Anyways...just dig into that code and the API docs and I'm sure it will lead you in the right direction.
jgarcia replied on at Permalink Reply
jgarcia
I thought about that just as I posted that last one - you could potentially override the main login script and add your code to add that user to the "currently logged in" table. You would just copy /concrete/controllers/login.php to /controllers/login.php, and make your changes there. There is a do_login() function in there and a logout() function where you code add your code.

Of course, if you are modifying a table, that should probably technically be done in a model and not a controller, but I won't tell anyone if you don't ;)
oneil1 replied on at Permalink Reply
oneil1
Thanks for the tips jgarcia but I am having some trouble with the syntax. I must admit I am more of a designer than I am a programmer, but I figure that if I can use a loop to scroll through all the users and us the isLogedin() function, then I can have what I want. I am still tugging away at the syntax to accomplish this.