MDL-15995 - portfolio cron. currently just cleans up any orphaned transfer data

Later should be extended to add hooks in the plugins
This commit is contained in:
mjollnir_
2008-08-11 12:50:26 +00:00
parent a226b58d75
commit 7e51bbcee9
2 changed files with 26 additions and 0 deletions
+7
View File
@@ -252,6 +252,13 @@
events_cron();
mtrace('done.');
if ($CFG->portfolioenabled) {
// Portfolio cron
mtrace('Starting the portfolio cron...');
require_once($CFG->libdir . '/portfoliolib.php');
portfolio_cron();
mtrace('done');
}
/// Run all core cron jobs, but not every time since they aren't too important.
/// These don't have a timer to reduce load, so we'll use a random number
+19
View File
@@ -2178,4 +2178,23 @@ function portfolio_handle_event($eventdata) {
return true;
}
/**
* main portfolio cronjob
*
*/
function portfolio_cron() {
global $DB;
if ($expired = $DB->get_records_select('portfolio_tempdata', 'expirytime < ?', array(time()))) {
foreach ($expired as $d) {
$DB->delete_records('portfolio_tempdata', array('id' => $d->id));
$fs = get_file_storage();
$fs->delete_area_files(SYSCONTEXTID, 'portfolio_exporter', $d->id);
}
}
// @todo add hooks in the plugins
}
?>