Log in

View Full Version : help in automating a task


Keyser520
04-01-2008, 05:57 AM
I want to automate a task to run once a day. This task should look at the last time a thread was posted in a section. If no thread was posted in the last 30 days, that forum needs to be turned off and closed. How can I implement this?

Thanks in advance,
Keyser520

Dismounted
04-01-2008, 08:05 AM
You can create a vBulletin Scheduled Task to do what you want.

Keyser520
04-01-2008, 11:22 AM
That's what I'm asking: how do I do that? I don't see the options in the scheduled task to do any of the things I asked in the first post. Can you give me specifics of how to do this? Or point me to a place where examples are posted?

Dismounted
04-01-2008, 01:19 PM
You will need to create your own task using PHP. I don't believe there are any examples relevant to this task.

Keyser520
04-01-2008, 01:50 PM
Could you help me at all? I know php, but I don't know the way vbulletin is programmed, so creating such a task is knowledge that I don't have.

Lynne
04-01-2008, 02:25 PM
I've written a couple of cron jobs/Scheduled Tasks for my site. Here is the basic template I use:


<?php
// ######################## SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);
if (!is_object($vbulletin->db))
{
exit;
}

// ################################################## ######################
// ######################### START MAIN SCRIPT ############################
// ################################################## ######################

Queries and Stuff Here
$vbulletin->db->query("Your Query"
);


log_cron_action('', $nextitem, 1);

?>

Keyser520
04-01-2008, 03:02 PM
To be more specific:

I have sections on my forum for instructors/djs. Each of them is the moderator of their own specific forum. I want to have the script check to see if that user has posted in their forum in the last month. If they have not, i want it to close and hide that forum.

Dismounted
04-02-2008, 05:24 AM
This requires more knowledge of MySQL than PHP. All the PHP you need has been posted by Lynne. You just need to craft an SQL query to delete the posts/threads/forums. You need to compare dateline (in the database) to the current time. dateline is UNIX time (seconds from epoch).

Keyser520
04-02-2008, 10:18 PM
That's the part I don't have knowledge of... :-(

Jase2
04-02-2008, 10:22 PM
Well, you can always request to someone make the mod (unpaid). Or, you can post in the "Request for paid services" forum and see if someone will create it you.

Keyser520
04-03-2008, 03:02 PM
Ok, consider this my request....

(or do I have to post that somewhere special?)

Jase2
04-03-2008, 03:20 PM
Paid or unpaid modification?