rootnik
12-28-2005, 08:55 PM
I know, this is a very strange request for help.
I need some help putting this all together...
I know the time stamp for whoseonline:
$datecut = TIMENOW - $vbulletin->options['cookietimeout'];
The time stamp for last activity is in user.lastactivity
The profile field is in userfield.field10
field10 is a drop downbox. There are only 3 vaules:
1. null
2. Closed
3. Open
What I want to do is IF the user has field10 set to "Open", change it to "Closed" if they are not currently active. This will be done via a cron job every 45 minutes.
The most efficent way would be:
Check the database for user ids (userfield.userid) who has field10 set to "Open".
Then check to see if those users are online(by comparing $datecut with user.lastactivity). If they are not, set field10 to "Closed"
Anybody up to helping a mysql dummy out? :(
Edit:
I know how to query the database for a list of userids that have field10 set to closed...
SELECT `userfield`.`userid`
FROM userfield
WHERE (
`userfield`.`field10` = 'Closed'
)
And how to find a list of users who are no online
SELECT `user`.`userid`, `user`.`lastactivity`
FROM user
WHERE (`user`.`lastactivity` < $datecut)
But I am having a very hard time connecting the 2 together. I need to somehow match the userid in the userfield table with the userid in the user table and then get the lastactivity.
As you can see, I am lost (but trying)
I need some help putting this all together...
I know the time stamp for whoseonline:
$datecut = TIMENOW - $vbulletin->options['cookietimeout'];
The time stamp for last activity is in user.lastactivity
The profile field is in userfield.field10
field10 is a drop downbox. There are only 3 vaules:
1. null
2. Closed
3. Open
What I want to do is IF the user has field10 set to "Open", change it to "Closed" if they are not currently active. This will be done via a cron job every 45 minutes.
The most efficent way would be:
Check the database for user ids (userfield.userid) who has field10 set to "Open".
Then check to see if those users are online(by comparing $datecut with user.lastactivity). If they are not, set field10 to "Closed"
Anybody up to helping a mysql dummy out? :(
Edit:
I know how to query the database for a list of userids that have field10 set to closed...
SELECT `userfield`.`userid`
FROM userfield
WHERE (
`userfield`.`field10` = 'Closed'
)
And how to find a list of users who are no online
SELECT `user`.`userid`, `user`.`lastactivity`
FROM user
WHERE (`user`.`lastactivity` < $datecut)
But I am having a very hard time connecting the 2 together. I need to somehow match the userid in the userfield table with the userid in the user table and then get the lastactivity.
As you can see, I am lost (but trying)