Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
schedule_development [2016/12/08 21:45] textstorm |
schedule_development [2016/12/08 22:10] (current) textstorm |
||
---|---|---|---|
Line 2: | Line 2: | ||
This page will cover the requirements for developing SchedMan schedules and activating them. | This page will cover the requirements for developing SchedMan schedules and activating them. | ||
+ | ===== Important Notes ===== | ||
Please make sure you have set up your Cron Job as specified when you first installed the game engine, if you have not set up a Cron Job, SchedMan and some other features such as Auctions may not work correctly. | Please make sure you have set up your Cron Job as specified when you first installed the game engine, if you have not set up a Cron Job, SchedMan and some other features such as Auctions may not work correctly. | ||
+ | |||
+ | The //$db// database object **is** available to use in all schedules. | ||
+ | |||
+ | You **will not** be able to instantiate the //User class// or //use any functions// with schedules. | ||
===== Schedule Structure ===== | ===== Schedule Structure ===== | ||
- | Start with the below code structure: | + | Start with the below code structure and add your own code underneath the "Put your schedule code here" comment: |
<file php ScheduleStructure.php> | <file php ScheduleStructure.php> | ||
<?php | <?php | ||
Line 16: | Line 21: | ||
//set $count to the number of rows you have updated ($queryresult->rowCount();) it will store how many rows were affected the last time the schedule ran | //set $count to the number of rows you have updated ($queryresult->rowCount();) it will store how many rows were affected the last time the schedule ran | ||
$db->query("UPDATE scheduler SET rowsaff = '$count', running = '0' WHERE schedref = '$schedref'"); | $db->query("UPDATE scheduler SET rowsaff = '$count', running = '0' WHERE schedref = '$schedref'"); | ||
+ | } | ||
+ | ?> | ||
+ | </file> | ||
+ | |||
+ | The below code is an example of a simple schedule to clear down old Administration Panel logs: | ||
+ | <file php ClearAdminLogsSchedule.php> | ||
+ | <?php | ||
+ | if($caller) { | ||
+ | $schedref = "LOG1"; | ||
+ | $date = date("Y-m-d"); | ||
+ | $dategen = new DateTime($date); | ||
+ | $dategen->modify('-30 day'); | ||
+ | $deldate = $dategen->format('Y-m-d'); | ||
+ | $del = $db->query("DELETE FROM panel_logs WHERE logdate < '$deldate'"); | ||
+ | $count = $del->rowCount(); | ||
+ | $db->query("UPDATE scheduler SET rowsaff = '$count' WHERE schedref = '$schedref'"); | ||
} | } | ||
?> | ?> | ||
Line 22: | Line 43: | ||
Navigate to SchedMan and go to the "Create" page. You should see something similar to below. | Navigate to SchedMan and go to the "Create" page. You should see something similar to below. | ||
- | {{:untitled.png?200|}} | + | {{:schedman.png?200|}} |
To add the schedule fill the boxes in with the following values: | To add the schedule fill the boxes in with the following values: |