Welcome Guest, Not a member yet? Register   Sign In
A temporized message system
#1

[eluser]Kurai[/eluser]
Hi everyone!
I'm building a message system. From now on I've created login, simple message insert and show and an administrator backend.
Now, for the difficult part.
What I need is a system that, starting on a given time (for example the admin pressing a Start now! button) gradually delivers to the users temporized message. A message could for example be delivered 10 or 20 minutes after the start, and so on.
More, the system should be able, at a given time, to change something in the database (for example a flag in one of the messages, or other)

The first part is indeed quite simple in my mind: I can, for example, change the relative time in absolute time when you press the start button, and then selecting the messages according to server time.

The second one is really puzzling for me.

Any ideas on how to improve the first one and how to do the second one?
Thank you!
#2

[eluser]Kurai[/eluser]
Sorry for the up. Noone has an idea on this topic? Even a general way of proceed would be useful Smile
Thanks!
#3

[eluser]CI Lee[/eluser]
A generalized answer would be to have a table for messages with one column being a "start_time" which on the message being entered would have the current time inserted and a "message_duration" being stored in the database as well. You should also have a column of "live_status" that is just a Y/N that defaults to "y" switch and an "updated" column that is Y/N defaulting to "N".

Then you could have your app check to see if there are any messages in the system with a live_status of "y" and "updated" = N, if there is it would check to see if the "start_time" was more than "message_duration" ago using the date helper.

If it is not more than "message_duration" it would continue to display that message, however if it is greater than "message_duration" it would update the "live_status" to "N" and the "updated" to "y" that way it would not get put back in the message que.

Does that make sense?
Was that what you were looking for?

-Lee
#4

[eluser]sikkle[/eluser]
i'll prolly look at a temp table, with cron job with field flag.

make sense ?
#5

[eluser]Kurai[/eluser]
CI lee probably yours is the right solution for me. I will think deeply about that, thank you.

Sikkle: good idea, but I am a cronjob newbie. Is there a way to set up a cronjob from inside php? Do you have some recources on that topic, by chance? Thank you.

Any other ideas are welcome Smile
#6

[eluser]Colin Williams[/eluser]
No need for a cronjob, I don't think. Cron is usually set with crontab (just search 'crontab' in Google). The short of it is, you set some runtime rules and point to a script (could be a codeigniter controller) in a text file on your server, then you point crontab at that file (you have to do this from the command line.)

CI Lee's solution sounds optimal.




Theme © iAndrew 2016 - Forum software by © MyBB